From 89ce91d07ef7a579466a930d0f4cad1fb7fbdca7 Mon Sep 17 00:00:00 2001 From: Mark Heinis Date: Wed, 31 Jul 2019 16:42:47 +0200 Subject: [PATCH 01/17] Working on adding a new temp small widget Working on adding a new temp small widget --- app/src/debug/AndroidManifest.xml | 27 ++ app/src/main/AndroidManifest.xml | 27 ++ .../Adapters/TemperatureWidgetAdapter.java | 218 ++++++++++++++ .../domoticz/Utils/SharedPrefUtil.java | 37 ++- .../SmallTempWidgetConfigurationActivity.java | 274 ++++++++++++++++++ .../Widgets/WidgetProviderSmallTemp.java | 179 ++++++++++++ app/src/main/res/drawable-hdpi/sunny.png | Bin 0 -> 795 bytes app/src/main/res/drawable-mdpi/sunny.png | Bin 0 -> 742 bytes app/src/main/res/drawable-xhdpi/sunny.png | Bin 0 -> 1507 bytes app/src/main/res/drawable-xxhdpi/sunny.png | Bin 0 -> 2302 bytes .../widget_small_layout_transparent.xml | 63 ++-- .../widget_small_layout_transparent_dark.xml | 44 +-- .../res/layout/widget_small_temp_layout.xml | 66 +++++ .../layout/widget_small_temp_layout_dark.xml | 65 +++++ .../widget_small_temp_layout_transparent.xml | 64 ++++ ...get_small_temp_layout_transparent_dark.xml | 61 ++++ .../main/res/xml/smalltempwidgetprovider.xml | 30 ++ app/version.properties | 8 +- build.gradle | 2 +- domoticzapi/version.properties | 6 +- libs/MemorizingTrustManager/build.gradle | 2 +- 21 files changed, 1095 insertions(+), 78 deletions(-) create mode 100644 app/src/main/java/nl/hnogames/domoticz/Adapters/TemperatureWidgetAdapter.java create mode 100644 app/src/main/java/nl/hnogames/domoticz/Widgets/SmallTempWidgetConfigurationActivity.java create mode 100644 app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetProviderSmallTemp.java create mode 100644 app/src/main/res/drawable-hdpi/sunny.png create mode 100644 app/src/main/res/drawable-mdpi/sunny.png create mode 100644 app/src/main/res/drawable-xhdpi/sunny.png create mode 100644 app/src/main/res/drawable-xxhdpi/sunny.png create mode 100644 app/src/main/res/layout/widget_small_temp_layout.xml create mode 100644 app/src/main/res/layout/widget_small_temp_layout_dark.xml create mode 100644 app/src/main/res/layout/widget_small_temp_layout_transparent.xml create mode 100644 app/src/main/res/layout/widget_small_temp_layout_transparent_dark.xml create mode 100644 app/src/main/res/xml/smalltempwidgetprovider.xml diff --git a/app/src/debug/AndroidManifest.xml b/app/src/debug/AndroidManifest.xml index 73443abaf..b75101d7b 100644 --- a/app/src/debug/AndroidManifest.xml +++ b/app/src/debug/AndroidManifest.xml @@ -289,6 +289,33 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c19946579..ece59acff 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -287,6 +287,33 @@ android:resource="@xml/securitywidgetprovider"/> + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/TemperatureWidgetAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/TemperatureWidgetAdapter.java new file mode 100644 index 000000000..40db07bfc --- /dev/null +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/TemperatureWidgetAdapter.java @@ -0,0 +1,218 @@ +/* + * Copyright (C) 2015 Domoticz - Mark Heinis + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package nl.hnogames.domoticz.Adapters; + +import android.app.Activity; +import android.content.Context; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.BaseAdapter; +import android.widget.Filter; +import android.widget.Filterable; +import android.widget.ImageView; +import android.widget.TextView; + +import com.squareup.picasso.Picasso; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; + +import androidx.core.content.ContextCompat; +import az.plainpie.animation.PieAngleAnimation; +import nl.hnogames.domoticz.R; +import nl.hnogames.domoticz.Utils.SharedPrefUtil; +import nl.hnogames.domoticz.Utils.UsefulBits; +import nl.hnogames.domoticzapi.Containers.ConfigInfo; +import nl.hnogames.domoticzapi.Containers.DevicesInfo; +import nl.hnogames.domoticzapi.Containers.TemperatureInfo; +import nl.hnogames.domoticzapi.Domoticz; +import nl.hnogames.domoticzapi.DomoticzIcons; +import nl.hnogames.domoticzapi.Utils.ServerUtil; + +public class TemperatureWidgetAdapter extends BaseAdapter implements Filterable { + public ArrayList filteredData = null; + private Domoticz domoticz; + private Context context; + private ArrayList data = null; + private int layoutResourceId; + private ItemFilter mFilter = new ItemFilter(); + private ConfigInfo mConfigInfo; + private SharedPrefUtil mSharedPrefs; + + public TemperatureWidgetAdapter(Context context, + Domoticz mDomoticz, + ServerUtil configInfo, + ArrayList data) { + super(); + mSharedPrefs = new SharedPrefUtil(context); + this.mConfigInfo = configInfo.getActiveServer() != null ? configInfo.getActiveServer().getConfigInfo(context) : null; + + this.context = context; + domoticz = mDomoticz; + + Collections.sort(data, new Comparator() { + @Override + public int compare(TemperatureInfo left, TemperatureInfo right) { + return left.getName().compareTo(right.getName()); + } + }); + + this.filteredData = data; + this.data = data; + } + + @Override + public int getCount() { + return filteredData.size(); + } + + @Override + public Object getItem(int i) { + return filteredData.get(i); + } + + @Override + public long getItemId(int i) { + return 0; + } + + public Filter getFilter() { + return mFilter; + } + + @Override + public View getView(int position, View convertView, ViewGroup parent) { + ViewHolder holder; + TemperatureInfo deviceInfo = filteredData.get(position); + + holder = new ViewHolder(); + convertView = setDefaultRowId(holder); + convertView.setTag(holder); + + if (mSharedPrefs.darkThemeEnabled()) { + if ((convertView.findViewById(R.id.card_global_wrapper)) != null) + convertView.findViewById(R.id.card_global_wrapper).setBackgroundColor(ContextCompat.getColor(context, R.color.card_background_dark)); + if ((convertView.findViewById(R.id.row_wrapper)) != null) + (convertView.findViewById(R.id.row_wrapper)).setBackground(ContextCompat.getDrawable(context, R.color.card_background_dark)); + if ((convertView.findViewById(R.id.row_global_wrapper)) != null) + (convertView.findViewById(R.id.row_global_wrapper)).setBackgroundColor(ContextCompat.getColor(context, R.color.card_background_dark)); + } + + setDefaultRowData(deviceInfo, holder); + return convertView; + } + + private View setDefaultRowId(ViewHolder holder) { + layoutResourceId = R.layout.widget_configuration_row; + + LayoutInflater inflater = ((Activity) context).getLayoutInflater(); + View row = inflater.inflate(layoutResourceId, null); + + holder.signal_level = row.findViewById(R.id.switch_signal_level); + holder.iconRow = row.findViewById(R.id.rowIcon); + holder.switch_name = row.findViewById(R.id.switch_name); + holder.switch_battery_level = row.findViewById(R.id.switch_battery_level); + + return row; + } + + private void setDefaultRowData(TemperatureInfo mDeviceInfo, + ViewHolder holder) { + final double temperature = mDeviceInfo.getTemperature(); + final double setPoint = mDeviceInfo.getSetPoint(); + holder.isProtected = mDeviceInfo.isProtected(); + + String sign = mConfigInfo != null ? mConfigInfo.getTempSign() : "C"; + holder.switch_name.setText(mDeviceInfo.getName()); + if (Double.isNaN(temperature) || Double.isNaN(setPoint)) { + if (holder.signal_level != null) + holder.signal_level.setVisibility(View.GONE); + + if (holder.switch_battery_level != null) { + String batteryText = context.getString(R.string.temperature) + + ": " + + mDeviceInfo.getData(); + holder.switch_battery_level.setText(batteryText); + } + } else { + if (holder.signal_level != null) + holder.signal_level.setVisibility(View.VISIBLE); + if (holder.switch_battery_level != null) { + String batteryLevelText = context.getString(R.string.temperature) + + ": " + + temperature + + " " + sign; + holder.switch_battery_level.setText(batteryLevelText); + } + + if (holder.signal_level != null) { + String signalText = context.getString(R.string.set_point) + + ": " + + mDeviceInfo.getSetPoint() + + " " + sign; + holder.signal_level.setText(signalText); + } + } + } + + static class ViewHolder { + TextView switch_name, signal_level, switch_battery_level; + Boolean isProtected; + ImageView iconRow; + } + + private class ItemFilter extends Filter { + @Override + protected FilterResults performFiltering(CharSequence constraint) { + + String filterString = constraint.toString().toLowerCase(); + + FilterResults results = new FilterResults(); + + final ArrayList list = data; + + int count = list.size(); + final ArrayList nlist = new ArrayList(count); + + TemperatureInfo filterableObject; + for (int i = 0; i < count; i++) { + filterableObject = list.get(i); + if (filterableObject.getName().toLowerCase().contains(filterString)) { + nlist.add(filterableObject); + } + } + results.values = nlist; + results.count = nlist.size(); + + return results; + } + + @SuppressWarnings("unchecked") + @Override + protected void publishResults(CharSequence constraint, FilterResults results) { + filteredData = (ArrayList) results.values; + notifyDataSetChanged(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/nl/hnogames/domoticz/Utils/SharedPrefUtil.java b/app/src/main/java/nl/hnogames/domoticz/Utils/SharedPrefUtil.java index ac1eaae6d..bf2d8f07b 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Utils/SharedPrefUtil.java +++ b/app/src/main/java/nl/hnogames/domoticz/Utils/SharedPrefUtil.java @@ -359,9 +359,44 @@ public boolean getSmallWidgetisScene(int widgetID) { return prefs.getBoolean("SMALLWIDGETSCENE" + widgetID, false); } + public void deleteSmallTempWidget(int widgetID, boolean isScene) { + editor.remove("SMALLTEMPWIDGET" + widgetID); + editor.remove("SMALLTEMPWIDGETIDX" + widgetID); + editor.remove("SMALLTEMPWIDGETPASSWORD" + widgetID); + editor.remove("SMALLTEMPWIDGETLAYOUT" + widgetID); + editor.remove("SMALLTEMPWIDGETVALUE" + widgetID); + editor.remove("SMALLTEMPWIDGETSCENE" + widgetID); + editor.commit(); + } + + public void setSmallTempWidgetIDX(int widgetID, int idx, boolean isScene, String password, String value, int layout) { + editor.putInt("SMALLTEMPWIDGET" + widgetID, idx).apply(); + editor.putBoolean("SMALLTEMPWIDGETSCENE" + widgetID, isScene).apply(); + editor.putString("SMALLTEMPWIDGETPASSWORD" + widgetID, password).apply(); + editor.putString("SMALLTEMPWIDGETVALUE" + widgetID, value).apply(); + editor.putInt("SMALLTEMPWIDGETLAYOUT" + widgetID, layout).apply(); + editor.commit(); + } + + public int getSmallTempWidgetIDX(int widgetID) { + return prefs.getInt("SMALLTEMPWIDGET" + widgetID, INVALID_IDX); + } + + public String getSmallTempWidgetPassword(int widgetID) { + return prefs.getString("SMALLTEMPWIDGETPASSWORD" + widgetID, null); + } + + public int getSmallTempWidgetLayout(int widgetID) { + return prefs.getInt("SMALLTEMPWIDGETLAYOUT" + widgetID, -1); + } + + public String getSmallTempWidgetValue(int widgetID) { + return prefs.getString("SMALLTEMPWIDGETVALUE" + widgetID, null); + } + public void deleteSecurityWidget(int widgetID) { editor.remove("WIDGETSECURITY" + widgetID); - editor.remove("SMALLWIDGETIDX" + widgetID); + editor.remove("WIDGETSECURITYIDX" + widgetID); editor.remove("WIDGETSECURITYPIN" + widgetID); editor.remove("WIDGETSECURITYPINLAYOUT" + widgetID); editor.remove("WIDGETSECURITYVALUE" + widgetID); diff --git a/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallTempWidgetConfigurationActivity.java b/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallTempWidgetConfigurationActivity.java new file mode 100644 index 000000000..242953fd3 --- /dev/null +++ b/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallTempWidgetConfigurationActivity.java @@ -0,0 +1,274 @@ +/* + * Copyright (C) 2015 Domoticz - Mark Heinis + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package nl.hnogames.domoticz.Widgets; + +import android.appwidget.AppWidgetManager; +import android.content.Intent; +import android.os.Bundle; +import android.util.Log; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ListView; +import android.widget.Toast; + +import com.afollestad.materialdialogs.MaterialDialog; + +import java.util.ArrayList; + +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.SearchView; +import androidx.core.view.MenuItemCompat; +import nl.hnogames.domoticz.Adapters.TemperatureAdapter; +import nl.hnogames.domoticz.Adapters.TemperatureWidgetAdapter; +import nl.hnogames.domoticz.Adapters.WidgetsAdapter; +import nl.hnogames.domoticz.BuildConfig; +import nl.hnogames.domoticz.R; +import nl.hnogames.domoticz.UI.PasswordDialog; +import nl.hnogames.domoticz.Utils.SharedPrefUtil; +import nl.hnogames.domoticz.Utils.UsefulBits; +import nl.hnogames.domoticz.Welcome.WelcomeViewActivity; +import nl.hnogames.domoticz.app.AppController; +import nl.hnogames.domoticzapi.Containers.DevicesInfo; +import nl.hnogames.domoticzapi.Containers.TemperatureInfo; +import nl.hnogames.domoticzapi.Domoticz; +import nl.hnogames.domoticzapi.DomoticzValues; +import nl.hnogames.domoticzapi.Interfaces.DevicesReceiver; +import nl.hnogames.domoticzapi.Interfaces.TemperatureReceiver; + +import static android.appwidget.AppWidgetManager.EXTRA_APPWIDGET_ID; +import static android.appwidget.AppWidgetManager.INVALID_APPWIDGET_ID; + +public class SmallTempWidgetConfigurationActivity extends AppCompatActivity { + + private final String TAG = this.getClass().getSimpleName(); + private final int iWelcomeResultCode = 885; + + int mAppWidgetId; + private SharedPrefUtil mSharedPrefs; + private Domoticz domoticz; + private TemperatureWidgetAdapter adapter; + private SearchView searchViewAction; + + @Override + protected void onCreate(Bundle savedInstanceState) { + mSharedPrefs = new SharedPrefUtil(this); + if (mSharedPrefs.darkThemeEnabled()) + setTheme(R.style.AppThemeDark); + else + setTheme(R.style.AppTheme); + + super.onCreate(savedInstanceState); + setContentView(R.layout.widget_configuration); + setResult(RESULT_CANCELED); + + if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { + Toast.makeText(this, getString(R.string.wizard_widgets) + " " + getString(R.string.premium_feature), Toast.LENGTH_LONG).show(); + this.finish(); + } + + if (!mSharedPrefs.IsWidgetsEnabled()) { + Toast.makeText(this, getString(R.string.wizard_widgets) + " " + getString(R.string.widget_disabled), Toast.LENGTH_LONG).show(); + this.finish(); + } + domoticz = new Domoticz(this, AppController.getInstance().getRequestQueue()); + this.setTitle(getString(R.string.pick_device_title)); + if (getSupportActionBar() != null) { + getSupportActionBar().setDisplayHomeAsUpEnabled(false); + getSupportActionBar().setHomeButtonEnabled(false); + } + + //1) Is domoticz connected? + if (mSharedPrefs.isFirstStart()) { + mSharedPrefs.setNavigationDefaults(); + Intent welcomeWizard = new Intent(this, WelcomeViewActivity.class); + startActivityForResult(welcomeWizard, iWelcomeResultCode); + mSharedPrefs.setFirstStart(false); + } else { + //2) Show list of switches to choose from + initListViews(); + } + } + + /* Called when the second activity's finished */ + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + if (data != null && resultCode == RESULT_OK) { + switch (requestCode) { + case iWelcomeResultCode: + Bundle res = data.getExtras(); + if (!res.getBoolean("RESULT", false)) + this.finish(); + else { + initListViews(); + } + break; + } + } + super.onActivityResult(requestCode, resultCode, data); + } + + public void initListViews() { + if (mSharedPrefs.isWelcomeWizardSuccess()) { + Log.i(TAG, "Showing switches for widget"); + domoticz.getTemperatures(new TemperatureReceiver() { + @Override + public void onReceiveTemperatures(ArrayList mDevicesInfo) { + ArrayList mNewDevicesInfo = new ArrayList(); + for (TemperatureInfo d : mDevicesInfo) + mNewDevicesInfo.add(d); + + ListView listView = findViewById(R.id.list); + adapter = new TemperatureWidgetAdapter(SmallTempWidgetConfigurationActivity.this, domoticz, domoticz.getServerUtil(), mNewDevicesInfo); + listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView parent, View view, int position, long id) { + final TemperatureInfo mDeviceInfo = (TemperatureInfo) adapter.getItem(position); + + if (mDeviceInfo.isProtected()) { + PasswordDialog passwordDialog = new PasswordDialog( + SmallTempWidgetConfigurationActivity.this, domoticz); + passwordDialog.show(); + passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { + @Override + public void onDismiss(String password) { + getBackground(mDeviceInfo, password, null); + } + + @Override + public void onCancel() { + } + }); + } + else{ + getBackground(mDeviceInfo, null, null); + } + } + }); + listView.setAdapter(adapter); + } + + @Override + public void onError(Exception error) { + Toast.makeText(SmallTempWidgetConfigurationActivity.this, R.string.failed_to_get_switches, Toast.LENGTH_SHORT).show(); + SmallTempWidgetConfigurationActivity.this.finish(); + } + }); + } else { + Intent welcomeWizard = new Intent(this, WelcomeViewActivity.class); + startActivityForResult(welcomeWizard, iWelcomeResultCode); + overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); + } + } + + private int getWidgetLayout(String background) { + int layout = R.layout.widget_small_layout; + String backgroundWidget = String.valueOf(background); + if (backgroundWidget.equals(getApplicationContext().getString(R.string.widget_dark))) { + layout = R.layout.widget_small_temp_layout_dark; + } else if (backgroundWidget.equals(getApplicationContext().getString(R.string.widget_light))) { + layout = R.layout.widget_small_temp_layout; + } else if (backgroundWidget.equals(getApplicationContext().getString(R.string.widget_transparent_light))) { + layout = R.layout.widget_small_temp_layout_transparent; + } else if (backgroundWidget.equals(getApplicationContext().getString(R.string.widget_transparent_dark))) { + layout = R.layout.widget_small_temp_layout_transparent_dark; + } + return layout; + } + + private void getBackground(final TemperatureInfo mSelectedTemperatureInfo, final String password, final String value) { + new MaterialDialog.Builder(this) + .title(this.getString(R.string.widget_background)) + .items(new String[]{this.getString(R.string.widget_dark), this.getString(R.string.widget_light), this.getString(R.string.widget_transparent_dark), this.getString(R.string.widget_transparent_light)}) + .itemsCallbackSingleChoice(-1, new MaterialDialog.ListCallbackSingleChoice() { + @Override + public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { + showAppWidget(mSelectedTemperatureInfo, password, value, getWidgetLayout(String.valueOf(text))); + return true; + } + }) + .positiveText(R.string.ok) + .show(); + } + + private void showAppWidget(TemperatureInfo mSelectedSwitch, String password, String value, int layoutId) { + mAppWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID; + Intent intent = getIntent(); + Bundle extras = intent.getExtras(); + int idx = mSelectedSwitch.getIdx(); + if (extras != null) { + mAppWidgetId = extras.getInt(EXTRA_APPWIDGET_ID, + INVALID_APPWIDGET_ID); + + if (UsefulBits.isEmpty(mSelectedSwitch.getType())) { + Log.i(TAG, "Widget without a type saved"); + mSharedPrefs.setSmallTempWidgetIDX(mAppWidgetId, idx, false, password, value, layoutId); + } else { + Log.i(TAG, "Widget saved " + mSelectedSwitch.getType()); + mSharedPrefs.setSmallTempWidgetIDX(mAppWidgetId, idx, false, password, value, layoutId); + } + + Intent startService = new Intent(SmallTempWidgetConfigurationActivity.this, + WidgetProviderSmallTemp.UpdateWidgetService.class); + startService.putExtra(EXTRA_APPWIDGET_ID, mAppWidgetId); + startService.setAction("FROM CONFIGURATION ACTIVITY"); + startService(startService); + setResult(RESULT_OK, startService); + finish(); + } + + if (mAppWidgetId == INVALID_APPWIDGET_ID) { + Log.i(TAG, "I am invalid"); + finish(); + } + } + + public void Filter(String text) { + try { + if (adapter != null) + adapter.getFilter().filter(text); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + getMenuInflater().inflate(R.menu.menu_search, menu); + MenuItem searchMenuItem = menu.findItem(R.id.search); + searchViewAction = (SearchView) MenuItemCompat + .getActionView(searchMenuItem); + searchViewAction.setOnQueryTextListener(new SearchView.OnQueryTextListener() { + @Override + public boolean onQueryTextSubmit(String query) { + return false; + } + + @Override + public boolean onQueryTextChange(String newText) { + Filter(newText); + return false; + } + }); + return super.onCreateOptionsMenu(menu); + } +} \ No newline at end of file diff --git a/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetProviderSmallTemp.java b/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetProviderSmallTemp.java new file mode 100644 index 000000000..6553bd0f2 --- /dev/null +++ b/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetProviderSmallTemp.java @@ -0,0 +1,179 @@ +/* + * Copyright (C) 2015 Domoticz - Mark Heinis + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package nl.hnogames.domoticz.Widgets; + +import android.app.PendingIntent; +import android.app.Service; +import android.appwidget.AppWidgetManager; +import android.appwidget.AppWidgetProvider; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.os.Build; +import android.os.IBinder; +import android.util.Log; +import android.view.View; +import android.widget.RemoteViews; + +import java.util.ArrayList; + +import androidx.annotation.Nullable; +import nl.hnogames.domoticz.R; +import nl.hnogames.domoticz.Utils.NotificationUtil; +import nl.hnogames.domoticz.Utils.SharedPrefUtil; +import nl.hnogames.domoticz.Utils.UsefulBits; +import nl.hnogames.domoticz.app.AppController; +import nl.hnogames.domoticzapi.Containers.DevicesInfo; +import nl.hnogames.domoticzapi.Containers.SceneInfo; +import nl.hnogames.domoticzapi.Domoticz; +import nl.hnogames.domoticzapi.DomoticzIcons; +import nl.hnogames.domoticzapi.DomoticzValues; +import nl.hnogames.domoticzapi.Interfaces.DevicesReceiver; +import nl.hnogames.domoticzapi.Interfaces.ScenesReceiver; + +import static android.appwidget.AppWidgetManager.EXTRA_APPWIDGET_ID; +import static android.appwidget.AppWidgetManager.INVALID_APPWIDGET_ID; + +public class WidgetProviderSmallTemp extends AppWidgetProvider { + private static String packageName; + + @Override + public void onDeleted(Context context, int[] appWidgetIds) { + super.onDeleted(context, appWidgetIds); + for (int widgetId : appWidgetIds) { + SharedPrefUtil mSharedPrefs = new SharedPrefUtil(context); + mSharedPrefs.deleteSmallWidget(widgetId, mSharedPrefs.getWidgetisScene(widgetId)); + } + } + + @Override + public void onUpdate(Context context, AppWidgetManager appWidgetManager, + int[] appWidgetIds) { + + super.onUpdate(context, appWidgetManager, appWidgetIds); + + packageName = context.getPackageName(); + // Get all ids + ComponentName thisWidget = new ComponentName(context, + WidgetProviderSmallTemp.class); + int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget); + if (allWidgetIds != null) { + for (int mAppWidgetId : allWidgetIds) { + Intent intent = new Intent(context, UpdateWidgetService.class); + intent.putExtra(EXTRA_APPWIDGET_ID, mAppWidgetId); + intent.setAction("FROM WIDGET PROVIDER"); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + context.startForegroundService(intent); + } else + context.startService(intent); + } + } + } + + public static class UpdateWidgetService extends Service { + private static final int WITHBUTTON = 1; + private RemoteViews views; + private Domoticz domoticz; + private SharedPrefUtil mSharedPrefs; + + @Nullable + @Override + public IBinder onBind(Intent intent) { + return null; + } + + @Override + public int onStartCommand(Intent intent, int flags, int startId) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + this.startForeground(1337, NotificationUtil.getForegroundServiceNotification(this, "Widget")); + } + + AppWidgetManager appWidgetManager = AppWidgetManager + .getInstance(UpdateWidgetService.this); + + try { + int incomingAppWidgetId = intent.getIntExtra(EXTRA_APPWIDGET_ID, + INVALID_APPWIDGET_ID); + if (incomingAppWidgetId != INVALID_APPWIDGET_ID) { + try { + updateAppWidget(appWidgetManager, incomingAppWidgetId); + } catch (NullPointerException e) { + if (!UsefulBits.isEmpty(e.getMessage())) + Log.e(WidgetProviderSmallTemp.class.getSimpleName() + "@onStartCommand", e.getMessage()); + } + } + + } catch (Exception ex) { + Log.e("UpdateWidget", ex.toString()); + } + + stopSelf(); + return START_NOT_STICKY; + } + + public void updateAppWidget(final AppWidgetManager appWidgetManager, + final int appWidgetId) { + if (appWidgetId == INVALID_APPWIDGET_ID) { + Log.i("WIDGET", "I am invalid"); + return; + } + + if (mSharedPrefs == null) + mSharedPrefs = new SharedPrefUtil(this.getApplicationContext()); + if (domoticz == null) + domoticz = new Domoticz(this.getApplicationContext(), AppController.getInstance().getRequestQueue()); + + final int idx = mSharedPrefs.getSmallTempWidgetIDX(appWidgetId); + views = new RemoteViews(packageName, mSharedPrefs.getSmallTempWidgetLayout(appWidgetId)); + appWidgetManager.updateAppWidget(appWidgetId, views); + domoticz.getDevice(new DevicesReceiver() { + @Override + public void onReceiveDevices(ArrayList mDevicesInfo) { + } + + @Override + public void onReceiveDevice(DevicesInfo s) { + if (s != null) { + views = new RemoteViews(packageName, mSharedPrefs.getSmallTempWidgetLayout(appWidgetId)); + final double temperature = s.getTemperature(); + String sign = domoticz.getServerUtil() != null && domoticz.getServerUtil().getActiveServer() != null + && domoticz.getServerUtil().getActiveServer().getConfigInfo(getApplicationContext()) != null ? + domoticz.getServerUtil().getActiveServer().getConfigInfo(getApplicationContext()).getTempSign() : "C"; + + String text = s.getData(); + if (!Double.isNaN(temperature)) { + text = temperature + + " " + sign; + } + views.setTextViewText(R.id.title, text); + views.setImageViewResource(R.id.rowIcon, R.drawable.sunny); + appWidgetManager.updateAppWidget(appWidgetId, views); + } + } + + @Override + public void onError(Exception error) { + } + }, idx, false); + } + } +} diff --git a/app/src/main/res/drawable-hdpi/sunny.png b/app/src/main/res/drawable-hdpi/sunny.png new file mode 100644 index 0000000000000000000000000000000000000000..27a95ac023c84d3b876f37e45efa8b550cbf2c51 GIT binary patch literal 795 zcmV+$1LXXPP)#l!6i`G*aeUyD5kV zIu1WS$KerLr;Q&ez8fae+6Li|__jgF6yFvIx#F7+p_KThLZ~FZX%I5S_rL~V!_)@p zcTIyJ#h-wXF;B!D*c(gYMUcebTMT}~|KNY|8hI^M2=Rm+iANCpl_R*w;97YPxR<-9 z*bNV=Sp3Wn#dq*gTl5x__k?>_^+yMQa)VYsOvDpQbPN9n0@}c~%KBvozy;5Lw{;t| zg>8BPK-_YB!Z&-vEq4n*OqnzB3Ih1x1b}#OFJ3`-V0HnB8}5yG1>uHU0&pIBCw^t< zn^^!6i2n?{1%SSxkH!FqDfd^r8Wg!90H>k%;?=8gY5;(EW@G@MuX+It=sbPZ3kDhi zxLob+x=Pd%%!ua!IRNPMPC*qF$r;k?{^~Ut){HEzhq1&pCkp_5uN+?6jN$pP;nB8H zDuR#|z!WpW0A{Rwpmkg5I{u^!0DUhNa?gv~$IE~&fMrmecPL6)kQKk035t?0g#en` z1IqRStHDka!PBy-w`~x_obW6#XVvnKnbY7aVF0hJdcN`BLg=3GO7Nc7OSb-ja7h;c z`d&NJtRO^$H$zdVXGbX0+SI!L8`D!`AOTzv42WEDjUllfvGoAX|2^G7Q9@y{^`xo3 zusD@ou=e!zCq@X21*>=8SZ>hgm0{M(Pk(Z>?`eJz^MZX_^#LQ#w#m5d9oeoB!MdQO zC*pJJh0N9njrneMfV&#BEek50R*9X#>+s=VV1zcYZ9mH7BD>jRnf;A?suNsIk+^j> z*&E>A;*wXYI=2cy+6jP|Xa<48Cu#9?MStuA*cc>bvGbzdk`}Km8sz*2u+}SZz`|rD z*7S)NCev2pJ+)c-9sY(1&9ku9(>4OY$!U>RoEq7m8`_^7+n*iWpB`5QcqeIGSDVIaEFLEt_+Wxka@JZICKTl=J|RXh@)K+CD*g=_P4jpk7A`AVu4m zu`#w|$O7wKBmEI_*qu+avpX|u$IY`J3=9-;)QgYED%@1nIE}31BM+C_g$o z5hRxx0qk$^a-}?Z?=>cQPT6^m=qUv8H`*R zjAOxfe1`uE-?LdMo_#oEyOXB-a+$=S@%rD;-4{cEyLOd?zojuScGcWyTisJ0zX6FN zi4!Kka2R}dA5|d}MPovoW7+(mU&^5O9>0CEgIipRK6vokns7yeIdHDE!FD#S#%&G$c>;Q65%ek# z8ixS7HG)kQAfGM9=*5zyPc{=gNH$Z?;;vuh{b}Jbg-1c+*^WKXu*1|kSc3KW%xIoZ z=X;;4^;g&}QVKn{kV4O+6sp{@Qc+^6#LJa>>z8@H;q!Dv%f4aZ+y<|HF#riR(AIXX z$eDpwwSK5>MK73&S+$ya2VZNd%wKGSJhTn{ z!?3B37_cAly+UP<^0}dXJ8bBe0Muuf__;zS&5*C(Ff?e2v1u6E(r($!{l|fp8E{nAB=yG=bYzT z0mimh?n((L1M|MaP=hh-83XAR8JS1S`r61GFguH3cn;6A&*Af^$EgpDU6YKl*6z~1 z;U0Zwylb>?I{H3WAj1KEkH3$0r0zqL{Fno%%a2m6%Io^b{DX{gXJ!oMq8(^Y zI?rPHaq*x|79jJuU@(Km+T$*0!hvf2RswcLuomqT2h@%}c8|`q(i_@|_Ldt|4EZ-= z0O|qD+8bvoC59Uf@(db@%QRw zH`WjIr&v(gJZknT0;p@OKj>Fspqj5qwE%VPH7N+xoeB+m&NP7jEgV#4Ll zLEWL12Glh_Tk{2#xg6%7L<&&RPuIoD7t}31`_uZe8tW(en>(mhSB|0Y&8=OU52y&D zxlvE^ttJ(y=&u{4%`E&4fr1y8$0`1qCY`y_0z_%A=M`)~isM&~$TswYQ-H_Vv=SqT zzJkgT^9_*_RP;Njgt_h{6vf#AhI;$_BTY_FkEYK9>?DkJ1h+hG(}q4)gUARf>$f8> z;%K+7X97& zTy;}V?x*^9R9wb(^zz9f7bw5v$%4Sp*okpYDr0bGg)mA_(gT$qN4Wxq))OWj<3A8& ztdsa4uy`3)aK>lr1!AvWVO zRuq+VrfTb~7#bQ)-IZt);5$gkH|{T!Yt_GTrE-`3IGHCh41He)Oa5A_wgjP-{+Ds7 z#i;(e6<7UrNdfxQD$lLQ+Elvb!j#n3UIje?toVDh;6#dwZC!&~(qdA6)+;2k;0*iX zlGC6G=vQF1-=ZbU_sD8y@(TTymXyu-8 zpn9y`F96)$WOZ-PdpTnnLG>?W2NQ4y`K{^>m&yPWvpUo6k|KuZ96Gr8~SBxv6y0P2t(`Y9V+n{+tO~$%Ik98oub}Ek&v+lc^Jl6 zTfOBceYxVij|y2JSL%IK*)bLjol2`wB_(6qWEGioUgB5D%l|gks0=~Px#1ZP1_K>z@;j|==^1poj532;bRa{vNPi~s^oi~*88bXWiY2$M-fK~#8N?Van6 z6h#<@yJlEWU|m5%5RHk(AKn80xCy-iy$;yx&@0fJ;2*bOB5F{?a8R-=i&>VP_I*FP zH?uq4GkvI2SA9>?*_laprtAHls;)lFbdfXr-(R`QrFxnrruv&5Qg~zT$dj_%-Tv-H zmLg;+z^UTbWGX>+0yGxCCPN9b5@2odYci7{8v!~Mza}FIvJjwG@oO@XAb9}>6~86} z36d6IRPk#PmmpaItQ5Z{VF{8Hz-sYp5|to10h|=SCP4|362NKkYZ8+n83DW$za}9G zk`Taa@oN&1VDbWVE;V(xDGGPfODS#CJoVinefMR2j-W~uM6<$IHEXCVtN-#MA_I}#AYc8Sq+bDW0 zYtL2LH${0+?(TfOHz^4wBf$Rso!iGpZPa|Ex`T{ zSAVP?y5TZ5y*H0PHM8PY^~xkD7sdVgx-h? z3A25-h1tU#;pyz%E~Wz@z^EEx&EkWTyTupBlP^AD8>B6qutrE+0~~dPm=*byEawWLw$h7zi#v zdA%&k8z}x{c1SINwzAD^duYN5z!11yyo%yy3fnI8oq+O(5uh%9q%&imFoTd1_!poq ze!`QzzA%eW5_lItwtZUs6+{Bgg*@X`fbtp|nZUsvS1=o9HYN!e&vE> z>F7+U69Hs}-OeuZ0$IB1Q1;8Tg_VuuTz5)HrpVSd)&(f9z|;UIHIfIJO174-TBJI8j$_5^qjiyrcI4>M-gmKY^~d`q{Y z{J_m_in7Xb*2^^*!e9Z;{y2kP<>QZ2S)&GHBp4*X+2R-Hu{hXARa#)y%)DlV1ib}V zDL#;2=TN+|lKDUhdI``}d?BK*I%Pvs<^v??EI@1VL8zZ-$(h#7drHtrfOW-}?NJWj z>5C0!-Zt;*A;Crg))pU>y6+#1wb^%+V66a~iZ6J&dR1v)Q}!JsXceGS@yV8s0Kw>z z{RRmd1?XISqWk~h=$ic+304H?ReVtD1TYxAvTu>#lmLB;FYw2gl`!d0BMuJ98?b!Z!~7!v-qT!0Hjd@+Ng(w{lToy zjsOFSPkIYLRwUp&fHzZCydYUGZ~q4tp9~U!tVpo00(fIN>k-8#qpNmu=TN-U;>+Xc z?u(Zkh>P1NbCs!%%0V^QyQ?HvE6q�u(U&>4~~ zGPa5JE^EeZl9V;L$kzUt{n``;i((ha)IqLJHrnQy3Sb*onK}`GN2$z9mB1E~rK9sL zZUg}48QxkC503{KN|ugr_s&OH@#pT|J{KfIhu2*?tq^Cedab~4n4RmrD(79){Ed&$ zO+kM+^fNohxc`JVXvh=yACnrAnTHE*y;O$BugweH6m*4I`8u!St!tX6Gd)1m0cOOk zeBtktc((8_4r?kwE67GNvUs*{6aEAsJeU0^K2pCzYu-Dh^@w|`Uh4=)hkRJ0JddxpqMUO|utidCn zSa)ed#3Nd?0tj+73`F=9A@XF>6hvU*v97YtypAvOQ{iz7P{U#L33?Ml<%kgBP%4`) z_IR!%PvuTz^EC|tYA6Cnga-)uF}AA_oL!W&cUTu$C-(S>&0D4=Kn;i4mk9okDtPob znO*zXMDVlmSu!H=v#}0x)$SBFPYp~{fMqx;@B#|#U(bG-%NaE}(88mOHhLr9AMeHY z9CeVs;oP0ezR_0i?%A(}WmU)jIKIg4g*z&sdYylVk_AciaEILol z@P`; - - - + android:gravity="center"> - - - - - + android:layout_marginBottom="0dp" + android:textColor="@color/secondary_dark"/> - - - \ No newline at end of file + + diff --git a/app/src/main/res/layout/widget_small_layout_transparent_dark.xml b/app/src/main/res/layout/widget_small_layout_transparent_dark.xml index 0ff54dad4..c48eccbcf 100644 --- a/app/src/main/res/layout/widget_small_layout_transparent_dark.xml +++ b/app/src/main/res/layout/widget_small_layout_transparent_dark.xml @@ -19,20 +19,12 @@ ~ specific language governing permissions and limitations ~ under the License. --> - - - - + - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/widget_small_temp_layout.xml b/app/src/main/res/layout/widget_small_temp_layout.xml new file mode 100644 index 000000000..b4d16f25a --- /dev/null +++ b/app/src/main/res/layout/widget_small_temp_layout.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/widget_small_temp_layout_dark.xml b/app/src/main/res/layout/widget_small_temp_layout_dark.xml new file mode 100644 index 000000000..475457920 --- /dev/null +++ b/app/src/main/res/layout/widget_small_temp_layout_dark.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/widget_small_temp_layout_transparent.xml b/app/src/main/res/layout/widget_small_temp_layout_transparent.xml new file mode 100644 index 000000000..5fa4e8e31 --- /dev/null +++ b/app/src/main/res/layout/widget_small_temp_layout_transparent.xml @@ -0,0 +1,64 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/widget_small_temp_layout_transparent_dark.xml b/app/src/main/res/layout/widget_small_temp_layout_transparent_dark.xml new file mode 100644 index 000000000..d3eb75caf --- /dev/null +++ b/app/src/main/res/layout/widget_small_temp_layout_transparent_dark.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/xml/smalltempwidgetprovider.xml b/app/src/main/res/xml/smalltempwidgetprovider.xml new file mode 100644 index 000000000..2efa73f96 --- /dev/null +++ b/app/src/main/res/xml/smalltempwidgetprovider.xml @@ -0,0 +1,30 @@ + + + + \ No newline at end of file diff --git a/app/version.properties b/app/version.properties index d5f81031c..6241f1591 100644 --- a/app/version.properties +++ b/app/version.properties @@ -1,4 +1,4 @@ -#Tue Jul 30 09:42:06 CEST 2019 -VERSION_BUILD=6105 -VERSION_PATCH=125 -VERSION_CODE=441 +#Wed Jul 31 16:40:44 CEST 2019 +VERSION_BUILD=6134 +VERSION_PATCH=127 +VERSION_CODE=443 diff --git a/build.gradle b/build.gradle index b1d436f60..496e20250 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ buildscript { } //noinspection GroovyAssignabilityCheck dependencies { - classpath 'com.android.tools.build:gradle:3.4.1' + classpath 'com.android.tools.build:gradle:3.4.2' classpath 'com.google.gms:google-services:4.2.0' classpath 'com.google.firebase:perf-plugin:1.2.1' classpath 'io.fabric.tools:gradle:1.29.0' diff --git a/domoticzapi/version.properties b/domoticzapi/version.properties index cc81a3aa8..6a2f7359f 100644 --- a/domoticzapi/version.properties +++ b/domoticzapi/version.properties @@ -1,4 +1,4 @@ -#Tue Jul 30 09:42:07 CEST 2019 +#Wed Jul 31 16:40:45 CEST 2019 VERSION_BUILD=3675 -VERSION_PATCH=229 -VERSION_CODE=229 +VERSION_PATCH=230 +VERSION_CODE=230 diff --git a/libs/MemorizingTrustManager/build.gradle b/libs/MemorizingTrustManager/build.gradle index afd72d48d..2ad8535a9 100644 --- a/libs/MemorizingTrustManager/build.gradle +++ b/libs/MemorizingTrustManager/build.gradle @@ -6,7 +6,7 @@ buildscript { } //noinspection GroovyAssignabilityCheck dependencies { - classpath 'com.android.tools.build:gradle:3.4.1' + classpath 'com.android.tools.build:gradle:3.4.2' } } From d8f6d85a22a5583146f7f905adc5f5a0627061ae Mon Sep 17 00:00:00 2001 From: Mark Heinis Date: Thu, 1 Aug 2019 08:50:38 +0200 Subject: [PATCH 02/17] Added a small widget for temperature sensors #464 Added a small widget for temperature sensors #464 --- .../Widgets/WidgetProviderSmallTemp.java | 24 +++++- .../main/res/layout/widget_small_layout.xml | 85 ++++++------------- .../res/layout/widget_small_layout_dark.xml | 83 +++++------------- .../widget_small_layout_transparent.xml | 56 ++++-------- .../widget_small_layout_transparent_dark.xml | 83 +++++++----------- .../res/layout/widget_small_temp_layout.xml | 83 ++++++------------ .../layout/widget_small_temp_layout_dark.xml | 80 ++++++----------- .../widget_small_temp_layout_transparent.xml | 78 ++++++----------- ...get_small_temp_layout_transparent_dark.xml | 77 ++++++----------- .../main/res/xml/smalltempwidgetprovider.xml | 2 +- app/version.properties | 4 +- domoticzapi/version.properties | 2 +- 12 files changed, 227 insertions(+), 430 deletions(-) diff --git a/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetProviderSmallTemp.java b/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetProviderSmallTemp.java index 6553bd0f2..12de4f073 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetProviderSmallTemp.java +++ b/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetProviderSmallTemp.java @@ -34,6 +34,8 @@ import android.view.View; import android.widget.RemoteViews; +import com.squareup.picasso.Picasso; + import java.util.ArrayList; import androidx.annotation.Nullable; @@ -165,7 +167,27 @@ public void onReceiveDevice(DevicesInfo s) { + " " + sign; } views.setTextViewText(R.id.title, text); - views.setImageViewResource(R.id.rowIcon, R.drawable.sunny); + views.setTextViewText(R.id.desc, s.getName()); + + int icon; + if ((!UsefulBits.isEmpty(sign) && sign.equals("C") && s.getTemperature() < 0) || + (!UsefulBits.isEmpty(sign) && sign.equals("F") && s.getTemperature() < 30)) { + icon = (DomoticzIcons.getDrawableIcon(s.getTypeImg(), + s.getType(), + null, + domoticz.getServerUtil().getActiveServer().getConfigInfo(getApplicationContext()) != null && s.getTemperature() > domoticz.getServerUtil().getActiveServer().getConfigInfo(getApplicationContext()).getDegreeDaysBaseTemperature(), + true, + "Freezing")); + } else { + icon = (DomoticzIcons.getDrawableIcon(s.getTypeImg(), + s.getType(), + null, + domoticz.getServerUtil().getActiveServer().getConfigInfo(getApplicationContext()) != null && s.getTemperature() > domoticz.getServerUtil().getActiveServer().getConfigInfo(getApplicationContext()).getDegreeDaysBaseTemperature(), + false, + null)); + } + + views.setImageViewResource(R.id.rowIcon, icon); appWidgetManager.updateAppWidget(appWidgetId, views); } } diff --git a/app/src/main/res/layout/widget_small_layout.xml b/app/src/main/res/layout/widget_small_layout.xml index 6ab4c75e2..d48383e37 100644 --- a/app/src/main/res/layout/widget_small_layout.xml +++ b/app/src/main/res/layout/widget_small_layout.xml @@ -1,76 +1,39 @@ - - - + android:orientation="horizontal" + xmlns:android="http://schemas.android.com/apk/res/android" > - + + android:layout_centerHorizontal="true" + android:src="@drawable/defaultimage" + android:layout_height="50dp" /> - - - + android:layout_below="@+id/rowIcon" + android:layout_centerHorizontal="true" + android:textColor="@color/white" + android:clickable="false"/> - + - - + \ No newline at end of file diff --git a/app/src/main/res/layout/widget_small_layout_dark.xml b/app/src/main/res/layout/widget_small_layout_dark.xml index 93ea351a3..5a9983f56 100644 --- a/app/src/main/res/layout/widget_small_layout_dark.xml +++ b/app/src/main/res/layout/widget_small_layout_dark.xml @@ -1,76 +1,39 @@ - + - + - - - - - + + android:layout_below="@+id/rowIcon" + android:layout_centerHorizontal="true" + android:textColor="@color/white" + android:clickable="false"/> + android:layout_centerHorizontal="true" + android:clickable="false"/> - - - \ No newline at end of file + + \ No newline at end of file diff --git a/app/src/main/res/layout/widget_small_layout_transparent.xml b/app/src/main/res/layout/widget_small_layout_transparent.xml index a4cfaa4bc..1fb3b0b9d 100644 --- a/app/src/main/res/layout/widget_small_layout_transparent.xml +++ b/app/src/main/res/layout/widget_small_layout_transparent.xml @@ -1,60 +1,36 @@ - + - + + android:layout_centerHorizontal="true" + android:src="@drawable/defaultimage" + android:layout_height="50dp" /> + android:layout_below="@+id/rowIcon" + android:layout_centerHorizontal="true" + android:clickable="false"/> + android:layout_centerHorizontal="true" + android:clickable="false"/> + + \ No newline at end of file diff --git a/app/src/main/res/layout/widget_small_layout_transparent_dark.xml b/app/src/main/res/layout/widget_small_layout_transparent_dark.xml index c48eccbcf..ed9928e7a 100644 --- a/app/src/main/res/layout/widget_small_layout_transparent_dark.xml +++ b/app/src/main/res/layout/widget_small_layout_transparent_dark.xml @@ -1,61 +1,38 @@ - - + + + + android:layout_centerHorizontal="true" + android:src="@drawable/defaultimage" + android:layout_height="50dp" /> - + - + - \ No newline at end of file + + \ No newline at end of file diff --git a/app/src/main/res/layout/widget_small_temp_layout.xml b/app/src/main/res/layout/widget_small_temp_layout.xml index b4d16f25a..d48383e37 100644 --- a/app/src/main/res/layout/widget_small_temp_layout.xml +++ b/app/src/main/res/layout/widget_small_temp_layout.xml @@ -1,66 +1,39 @@ - - - + android:orientation="horizontal" + xmlns:android="http://schemas.android.com/apk/res/android" > + + + android:layout_centerHorizontal="true" + android:src="@drawable/defaultimage" + android:layout_height="50dp" /> + + - + - + \ No newline at end of file diff --git a/app/src/main/res/layout/widget_small_temp_layout_dark.xml b/app/src/main/res/layout/widget_small_temp_layout_dark.xml index 475457920..1a86f7811 100644 --- a/app/src/main/res/layout/widget_small_temp_layout_dark.xml +++ b/app/src/main/res/layout/widget_small_temp_layout_dark.xml @@ -1,65 +1,39 @@ - - - + android:orientation="horizontal" + xmlns:android="http://schemas.android.com/apk/res/android" > + + + android:layout_centerHorizontal="true" + android:src="@drawable/defaultimage" + android:layout_height="50dp" /> - + - + + \ No newline at end of file diff --git a/app/src/main/res/layout/widget_small_temp_layout_transparent.xml b/app/src/main/res/layout/widget_small_temp_layout_transparent.xml index 5fa4e8e31..1fb3b0b9d 100644 --- a/app/src/main/res/layout/widget_small_temp_layout_transparent.xml +++ b/app/src/main/res/layout/widget_small_temp_layout_transparent.xml @@ -1,64 +1,36 @@ - - - + android:orientation="horizontal" + xmlns:android="http://schemas.android.com/apk/res/android" > + + + android:layout_centerHorizontal="true" + android:src="@drawable/defaultimage" + android:layout_height="50dp" /> - + - + + \ No newline at end of file diff --git a/app/src/main/res/layout/widget_small_temp_layout_transparent_dark.xml b/app/src/main/res/layout/widget_small_temp_layout_transparent_dark.xml index d3eb75caf..ed9928e7a 100644 --- a/app/src/main/res/layout/widget_small_temp_layout_transparent_dark.xml +++ b/app/src/main/res/layout/widget_small_temp_layout_transparent_dark.xml @@ -1,61 +1,38 @@ - - - + android:orientation="horizontal" + xmlns:android="http://schemas.android.com/apk/res/android" > + + + android:layout_centerHorizontal="true" + android:src="@drawable/defaultimage" + android:layout_height="50dp" /> - + - + + \ No newline at end of file diff --git a/app/src/main/res/xml/smalltempwidgetprovider.xml b/app/src/main/res/xml/smalltempwidgetprovider.xml index 2efa73f96..556860670 100644 --- a/app/src/main/res/xml/smalltempwidgetprovider.xml +++ b/app/src/main/res/xml/smalltempwidgetprovider.xml @@ -23,7 +23,7 @@ Date: Thu, 1 Aug 2019 08:55:59 +0200 Subject: [PATCH 03/17] Set allowBackup to false as its giving issues Set allowBackup to false as its giving issues --- app/src/debug/AndroidManifest.xml | 2 +- app/src/main/AndroidManifest.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/debug/AndroidManifest.xml b/app/src/debug/AndroidManifest.xml index b75101d7b..3c8241cb7 100644 --- a/app/src/debug/AndroidManifest.xml +++ b/app/src/debug/AndroidManifest.xml @@ -123,7 +123,7 @@ Date: Thu, 1 Aug 2019 09:11:31 +0200 Subject: [PATCH 04/17] Code cleanup Code cleanup --- app/src/debug/AndroidManifest.xml | 66 +- app/src/main/AndroidManifest.xml | 26 +- .../domoticz/Adapters/BluetoothAdapter.java | 2 +- .../domoticz/Adapters/CamerasAdapter.java | 20 +- .../domoticz/Adapters/DashboardAdapter.java | 274 ++--- .../domoticz/Adapters/EventsAdapter.java | 4 +- .../domoticz/Adapters/LocationAdapter.java | 2 +- .../domoticz/Adapters/LogAdapter.java | 4 +- .../domoticz/Adapters/NFCAdapter.java | 2 +- .../domoticz/Adapters/PlansAdapter.java | 2 +- .../domoticz/Adapters/QRCodeAdapter.java | 2 +- .../domoticz/Adapters/SceneAdapter.java | 40 +- .../domoticz/Adapters/SpeechAdapter.java | 4 +- .../domoticz/Adapters/SwitchesAdapter.java | 258 ++--- .../domoticz/Adapters/TemperatureAdapter.java | 30 +- .../Adapters/TemperatureWidgetAdapter.java | 6 - .../domoticz/Adapters/TimersAdapter.java | 14 +- .../Adapters/UserVariablesAdapter.java | 4 +- .../domoticz/Adapters/UtilityAdapter.java | 20 +- .../domoticz/Adapters/WeatherAdapter.java | 2 +- .../domoticz/Adapters/WidgetsAdapter.java | 16 +- .../domoticz/BluetoothSettingsActivity.java | 122 +- .../nl/hnogames/domoticz/CameraActivity.java | 2 +- .../domoticz/Containers/LocationInfo.java | 34 +- .../hnogames/domoticz/Fragments/Camera.java | 12 +- .../hnogames/domoticz/Fragments/Cameras.java | 4 +- .../domoticz/Fragments/Dashboard.java | 396 +++---- .../nl/hnogames/domoticz/Fragments/Graph.java | 152 +-- .../domoticz/Fragments/MainPager.java | 12 +- .../nl/hnogames/domoticz/Fragments/Plans.java | 2 +- .../hnogames/domoticz/Fragments/Scenes.java | 26 +- .../hnogames/domoticz/Fragments/Switches.java | 326 +++--- .../domoticz/Fragments/Temperature.java | 30 +- .../Fragments/TemperatureMainPager.java | 12 +- .../domoticz/Fragments/UserVariables.java | 24 +- .../domoticz/Fragments/Utilities.java | 136 +-- .../hnogames/domoticz/Fragments/Weather.java | 56 +- .../hnogames/domoticz/Fragments/Wizard.java | 1014 ++++++++--------- .../domoticz/GeoSettingsActivity.java | 162 +-- .../nl/hnogames/domoticz/GraphActivity.java | 2 +- .../Helpers/BasicAuthInterceptor.java | 4 +- .../Helpers/DefaultHeadersInterceptor.java | 12 +- .../nl/hnogames/domoticz/MainActivity.java | 286 ++--- .../domoticz/NFCSettingsActivity.java | 150 +-- .../nl/hnogames/domoticz/PlanActivity.java | 4 +- .../domoticz/Preference/Preference.java | 172 +-- .../domoticz/QRCodeCaptureActivity.java | 4 +- .../domoticz/QRCodeSettingsActivity.java | 126 +- .../domoticz/ServerListSettingsActivity.java | 2 +- .../domoticz/ServerSettingsActivity.java | 30 +- .../Service/BluetoothConnectionReceiver.java | 6 +- .../Service/FCMMessageInstanceService.java | 2 +- .../GeofenceTransitionsIntentService.java | 22 +- .../domoticz/Service/NFCServiceActivity.java | 4 +- .../Service/WearMessageListenerService.java | 16 +- .../hnogames/domoticz/SettingsActivity.java | 2 +- .../domoticz/SpeechSettingsActivity.java | 110 +- .../UI/Backdrop/BackdropContainer.java | 2 +- .../UI/Backdrop/ToolbarIconClick.java | 2 +- .../domoticz/UI/DeviceInfoDialog.java | 10 +- .../UI/FingerprintPasswordDialog.java | 34 +- .../UI/MjpegViewer/MjpegInputStream.java | 2 +- .../domoticz/UI/MultiSelectionSpinner.java | 12 +- .../domoticz/UI/NotificationInfoDialog.java | 4 +- .../hnogames/domoticz/UI/PasswordDialog.java | 62 +- .../domoticz/UI/RGBWWColorPickerDialog.java | 4 +- .../hnogames/domoticz/UI/SceneInfoDialog.java | 4 +- .../UI/ScheduledTemperatureDialog.java | 2 +- .../domoticz/UI/SecurityPanelDialog.java | 16 +- .../domoticz/UI/SimpleTextDialog.java | 4 +- .../nl/hnogames/domoticz/UI/SortDialog.java | 4 +- .../domoticz/UI/SunriseInfoDialog.java | 4 +- .../nl/hnogames/domoticz/UI/SwitchDialog.java | 6 +- .../domoticz/UI/SwitchInfoDialog.java | 10 +- .../domoticz/UI/SwitchLogInfoDialog.java | 6 +- .../domoticz/UI/SwitchTimerInfoDialog.java | 4 +- .../domoticz/UI/TemperatureDialog.java | 8 +- .../domoticz/UI/TemperatureInfoDialog.java | 4 +- .../nl/hnogames/domoticz/UI/TextDialog.java | 8 +- .../domoticz/UI/UtilitiesInfoDialog.java | 4 +- .../domoticz/UI/WWColorPickerDialog.java | 4 +- .../domoticz/UI/WeatherInfoDialog.java | 4 +- .../nl/hnogames/domoticz/UpdateActivity.java | 82 +- .../domoticz/Utils/BitmapLruCache.java | 4 +- .../hnogames/domoticz/Utils/DeviceUtils.java | 2 +- .../domoticz/Utils/NotificationUtil.java | 68 +- .../domoticz/Utils/PermissionsUtil.java | 38 +- .../hnogames/domoticz/Utils/PicassoUtil.java | 160 +-- .../domoticz/Utils/SerializableManager.java | 8 +- .../domoticz/Utils/SharedPrefUtil.java | 18 +- .../hnogames/domoticz/Utils/UsefulBits.java | 94 +- .../domoticz/Welcome/SetupServerSettings.java | 104 +- .../domoticz/Welcome/WelcomePage2.java | 4 +- .../domoticz/Welcome/WelcomePage3.java | 82 +- .../domoticz/Welcome/WelcomePage4.java | 4 +- .../SecurityWidgetConfigurationActivity.java | 38 +- .../Widgets/SecurityWidgetIntentService.java | 16 +- .../Widgets/SecurityWidgetProvider.java | 26 +- .../SmallTempWidgetConfigurationActivity.java | 42 +- .../SmallWidgetConfigurationActivity.java | 52 +- .../Widgets/WidgetConfigurationActivity.java | 50 +- .../domoticz/Widgets/WidgetIntentService.java | 16 +- .../domoticz/Widgets/WidgetProviderLarge.java | 108 +- .../domoticz/Widgets/WidgetProviderSmall.java | 50 +- .../Widgets/WidgetProviderSmallTemp.java | 10 +- .../domoticz/app/AppCompatAssistActivity.java | 14 +- .../app/AppCompatPermissionsActivity.java | 10 +- .../hnogames/domoticz/app/AppController.java | 6 +- .../domoticz/app/DomoticzCardFragment.java | 14 +- .../app/DomoticzDashboardFragment.java | 32 +- .../app/DomoticzRecyclerFragment.java | 34 +- .../main/res/layout/widget_small_layout.xml | 25 +- .../res/layout/widget_small_layout_dark.xml | 71 +- .../widget_small_layout_transparent.xml | 17 +- .../widget_small_layout_transparent_dark.xml | 25 +- .../res/layout/widget_small_temp_layout.xml | 25 +- .../layout/widget_small_temp_layout_dark.xml | 25 +- .../widget_small_temp_layout_transparent.xml | 17 +- ...get_small_temp_layout_transparent_dark.xml | 25 +- app/version.properties | 4 +- domoticzapi/version.properties | 2 +- 121 files changed, 2968 insertions(+), 2952 deletions(-) diff --git a/app/src/debug/AndroidManifest.xml b/app/src/debug/AndroidManifest.xml index 3c8241cb7..bdd9f4ea1 100644 --- a/app/src/debug/AndroidManifest.xml +++ b/app/src/debug/AndroidManifest.xml @@ -89,48 +89,46 @@ - + - - - - - - - - - - + + + + + + + + + + - + @@ -155,8 +153,8 @@ android:enabled="true" android:exported="true"> - - + + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index afab9b49f..3617d6e19 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -87,7 +87,7 @@ - + @@ -95,39 +95,37 @@ + tools:node="remove"/> + tools:node="remove"/> + tools:node="remove"/> + tools:node="remove"/> + tools:node="remove"/> + tools:node="remove"/> + tools:node="remove"/> + tools:node="remove"/> + tools:node="remove"/> @@ -153,8 +151,8 @@ android:enabled="true" android:exported="true"> - - + + diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/BluetoothAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/BluetoothAdapter.java index 31e194e54..f34122c0e 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Adapters/BluetoothAdapter.java +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/BluetoothAdapter.java @@ -124,7 +124,7 @@ public View getView(int position, View convertView, ViewGroup parent) { holder.switch_idx.setText(context.getString(R.string.connectedSwitch) + ": " + mBluetoothInfo.getSwitchIdx()); } else { holder.switch_idx.setText(context.getString(R.string.connectedSwitch) - + ": " + context.getString(R.string.not_available)); + + ": " + context.getString(R.string.not_available)); } if (!UsefulBits.isEmpty(mBluetoothInfo.getValue())) diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/CamerasAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/CamerasAdapter.java index 08acfc790..44638443a 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Adapters/CamerasAdapter.java +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/CamerasAdapter.java @@ -110,7 +110,7 @@ private void SaveSorting() { @Override public DataObjectHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()) - .inflate(R.layout.camera_row, parent, false); + .inflate(R.layout.camera_row, parent, false); if (mSharedPrefs.darkThemeEnabled()) { if ((view.findViewById(R.id.card_global_wrapper)) != null) @@ -138,16 +138,16 @@ public void onBindViewHolder(@NonNull DataObjectHolder holder, int position) { if (holder.camera.getDrawable() == null) { picasso.load(imageUrl) - .placeholder(R.drawable.placeholder) - //.error(mSharedPrefs.darkThemeEnabled() ? R.drawable.baseline_error_outline_white_24 : R.drawable.baseline_error_outline_black_24) - .into(holder.camera); + .placeholder(R.drawable.placeholder) + //.error(mSharedPrefs.darkThemeEnabled() ? R.drawable.baseline_error_outline_white_24 : R.drawable.baseline_error_outline_black_24) + .into(holder.camera); } else picasso.load(imageUrl) - .memoryPolicy(MemoryPolicy.NO_CACHE) - .noFade() - .noPlaceholder() - //.error(mSharedPrefs.darkThemeEnabled() ? R.drawable.baseline_error_outline_white_24 : R.drawable.baseline_error_outline_black_24) - .into(holder.camera); + .memoryPolicy(MemoryPolicy.NO_CACHE) + .noFade() + .noPlaceholder() + //.error(mSharedPrefs.darkThemeEnabled() ? R.drawable.baseline_error_outline_white_24 : R.drawable.baseline_error_outline_black_24) + .into(holder.camera); } catch (Exception ex) { Log.i("CameraAdapter", ex.getMessage()); } @@ -190,7 +190,7 @@ public interface onClickListener { } public static class DataObjectHolder extends RecyclerView.ViewHolder - implements View.OnClickListener, RVHViewHolder { + implements View.OnClickListener, RVHViewHolder { TextView name; ImageView camera; diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/DashboardAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/DashboardAdapter.java index 9266543cb..e713b2ea4 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Adapters/DashboardAdapter.java +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/DashboardAdapter.java @@ -73,12 +73,12 @@ public class DashboardAdapter extends RecyclerView.Adapter data = null; public ArrayList filteredData = null; @@ -164,10 +164,10 @@ public DataObjectHolder onCreateViewHolder(ViewGroup parent, int viewType) { View row; if (showAsList) row = LayoutInflater.from(parent.getContext()) - .inflate(R.layout.dashboard_row_list, parent, false); + .inflate(R.layout.dashboard_row_list, parent, false); else row = LayoutInflater.from(parent.getContext()) - .inflate(R.layout.dashboard_row, parent, false); + .inflate(R.layout.dashboard_row, parent, false); if (mSharedPrefs.darkThemeEnabled()) { if ((row.findViewById(R.id.card_global_wrapper)) != null) @@ -221,7 +221,7 @@ private void setSwitchRowData(DevicesInfo mDeviceInfo, DataObjectHolder holder) { holder.pieView.setVisibility(View.GONE); if (mDeviceInfo.getSwitchTypeVal() == 0 && - (mDeviceInfo.getSwitchType() == null)) { + (mDeviceInfo.getSwitchType() == null)) { if (mDeviceInfo.getType() != null && mDeviceInfo.getType().equals("sunrise")) { setButtons(holder, Buttons.CLOCK); setClockRowData(mDeviceInfo, holder); @@ -318,7 +318,7 @@ private void setSwitchRowData(DevicesInfo mDeviceInfo, case DomoticzValues.Device.Type.Value.DIMMER: if (mDeviceInfo.getSubType().startsWith(DomoticzValues.Device.SubType.Name.RGB) || - mDeviceInfo.getSubType().startsWith(DomoticzValues.Device.SubType.Name.WW)) { + mDeviceInfo.getSubType().startsWith(DomoticzValues.Device.SubType.Name.WW)) { if (mSharedPrefs.showSwitchesAsButtons()) { setButtons(holder, Buttons.DIMMER_BUTTONS); setDimmerOnOffButtonRowData(mDeviceInfo, holder, true); @@ -376,7 +376,7 @@ private void setSwitchRowData(DevicesInfo mDeviceInfo, default: throw new NullPointerException( - "No supported switch type defined in the adapter (setSwitchRowData)"); + "No supported switch type defined in the adapter (setSwitchRowData)"); } } } @@ -406,18 +406,18 @@ private void setDefaultRowData(DevicesInfo mDeviceInfo, if (holder.signal_level != null) { text = context.getString(R.string.last_update) - + ": "; + + ": "; if (mDeviceInfo.getLastUpdateDateTime() != null) { text += UsefulBits.getFormattedDate(context, - mDeviceInfo.getLastUpdateDateTime().getTime()); + mDeviceInfo.getLastUpdateDateTime().getTime()); } holder.signal_level.setText(text); } if (holder.switch_battery_level != null) { text = context.getString(R.string.status) - + ": " - + mDeviceInfo.getData(); + + ": " + + mDeviceInfo.getData(); holder.switch_battery_level.setText(text); if (mDeviceInfo.getUsage() != null && mDeviceInfo.getUsage().length() > 0) { try { @@ -439,10 +439,10 @@ private void setDefaultRowData(DevicesInfo mDeviceInfo, if (mDeviceInfo.getCounterToday() != null && mDeviceInfo.getCounterToday().length() > 0) holder.switch_battery_level.append(" " + context.getString(R.string.today) + ": " + mDeviceInfo.getCounterToday()); if (mDeviceInfo.getCounter() != null && mDeviceInfo.getCounter().length() > 0 && - !mDeviceInfo.getCounter().equals(mDeviceInfo.getData())) + !mDeviceInfo.getCounter().equals(mDeviceInfo.getData())) holder.switch_battery_level.append(" " + context.getString(R.string.total) + ": " + mDeviceInfo.getCounter()); if (mDeviceInfo.getType() != null && mDeviceInfo.getType().length() > 0 && - mDeviceInfo.getType().equals("Wind")) { + mDeviceInfo.getType().equals("Wind")) { text = context.getString(R.string.direction) + " " + mDeviceInfo.getDirection() + " " + mDeviceInfo.getDirectionStr(); holder.switch_battery_level.setText(text); } @@ -460,7 +460,7 @@ private void setDefaultRowData(DevicesInfo mDeviceInfo, holder.switch_battery_level.append(", " + context.getString(R.string.dewPoint) + ": " + mDeviceInfo.getDewPoint() + " " + tempSign); if ((mDeviceInfo.getType() != null && mDeviceInfo.getType().equals(DomoticzValues.Device.Type.Value.TEMP)) || - !Double.isNaN(mDeviceInfo.getTemperature())) { + !Double.isNaN(mDeviceInfo.getTemperature())) { holder.switch_battery_level.append(", " + context.getString(R.string.temp) + ": " + mDeviceInfo.getTemperature() + " " + tempSign); holder.pieView.setVisibility(View.VISIBLE); double temp = mDeviceInfo.getTemperature(); @@ -469,7 +469,7 @@ private void setDefaultRowData(DevicesInfo mDeviceInfo, holder.pieView.setPercentage(Float.valueOf(temp + "")); holder.pieView.setInnerText(mDeviceInfo.getTemperature() + " " + tempSign); if ((!UsefulBits.isEmpty(tempSign) && tempSign.equals("C") && mDeviceInfo.getTemperature() < 0) || - (!UsefulBits.isEmpty(tempSign) && tempSign.equals("F") && mDeviceInfo.getTemperature() < 30)) + (!UsefulBits.isEmpty(tempSign) && tempSign.equals("F") && mDeviceInfo.getTemperature() < 30)) holder.pieView.setPercentageBackgroundColor(ContextCompat.getColor(context, R.color.material_blue_600)); else holder.pieView.setPercentageBackgroundColor(ContextCompat.getColor(context, R.color.material_orange_600)); @@ -490,11 +490,11 @@ private void setDefaultRowData(DevicesInfo mDeviceInfo, } Picasso.get().load(DomoticzIcons.getDrawableIcon(mDeviceInfo.getTypeImg(), - mDeviceInfo.getType(), - mDeviceInfo.getSubType(), - mDeviceInfo.getStatusBoolean(), - mDeviceInfo.getUseCustomImage(), - mDeviceInfo.getImage())).into(holder.iconRow); + mDeviceInfo.getType(), + mDeviceInfo.getSubType(), + mDeviceInfo.getStatusBoolean(), + mDeviceInfo.getUseCustomImage(), + mDeviceInfo.getImage())).into(holder.iconRow); holder.iconRow.setAlpha(1f); if (!mDeviceInfo.getStatusBoolean()) @@ -517,13 +517,13 @@ private void setSecurityPanelSwitchRowData(DevicesInfo mDeviceInfo, DataObjectHo holder.switch_name.setText(mDeviceInfo.getName()); String text = context.getString(R.string.last_update) + ": " + - UsefulBits.getFormattedDate(context, mDeviceInfo.getLastUpdateDateTime().getTime()); + UsefulBits.getFormattedDate(context, mDeviceInfo.getLastUpdateDateTime().getTime()); if (holder.signal_level != null) holder.signal_level.setText(text); text = context.getString(R.string.status) + ": " + - mDeviceInfo.getData(); + mDeviceInfo.getData(); if (holder.switch_battery_level != null) holder.switch_battery_level.setText(text); @@ -544,11 +544,11 @@ public void onClick(View v) { } Picasso.get().load(DomoticzIcons.getDrawableIcon(mDeviceInfo.getTypeImg(), - mDeviceInfo.getType(), - mDeviceInfo.getSwitchType(), - mDeviceInfo.getStatusBoolean(), - mDeviceInfo.getUseCustomImage(), - mDeviceInfo.getImage())).into(holder.iconRow); + mDeviceInfo.getType(), + mDeviceInfo.getSwitchType(), + mDeviceInfo.getStatusBoolean(), + mDeviceInfo.getUseCustomImage(), + mDeviceInfo.getImage())).into(holder.iconRow); if (!mDeviceInfo.getStatusBoolean()) holder.iconRow.setAlpha(0.5f); @@ -573,23 +573,23 @@ private void setOnOffButtonRowData(final DevicesInfo mDeviceInfo, if (holder.signal_level != null) { text = context.getString(R.string.last_update) - + ": " - + UsefulBits.getFormattedDate(context, - mDeviceInfo.getLastUpdateDateTime().getTime()); + + ": " + + UsefulBits.getFormattedDate(context, + mDeviceInfo.getLastUpdateDateTime().getTime()); holder.signal_level.setText(text); } if (holder.switch_battery_level != null) { text = context.getString(R.string.status) + ": " + - mDeviceInfo.getData(); + mDeviceInfo.getData(); holder.switch_battery_level.setText(text); } Picasso.get().load(DomoticzIcons.getDrawableIcon(mDeviceInfo.getTypeImg(), - mDeviceInfo.getType(), - mDeviceInfo.getSubType(), - mDeviceInfo.getStatusBoolean(), - mDeviceInfo.getUseCustomImage(), - mDeviceInfo.getImage())).into(holder.iconRow); + mDeviceInfo.getType(), + mDeviceInfo.getSubType(), + mDeviceInfo.getStatusBoolean(), + mDeviceInfo.getUseCustomImage(), + mDeviceInfo.getImage())).into(holder.iconRow); if (holder.buttonOn != null) { if (mDeviceInfo.getType().equals(DomoticzValues.Scene.Type.GROUP) || mDeviceInfo.getType().equals(DomoticzValues.Scene.Type.SCENE)) @@ -653,22 +653,22 @@ private void setOnOffSwitchRowData(final DevicesInfo mDeviceInfo, if (holder.signal_level != null) { text = context.getString(R.string.last_update) - + ": " - + UsefulBits.getFormattedDate(context, mDeviceInfo.getLastUpdateDateTime().getTime()); + + ": " + + UsefulBits.getFormattedDate(context, mDeviceInfo.getLastUpdateDateTime().getTime()); holder.signal_level.setText(text); } text = context.getString(R.string.status) + ": " + - mDeviceInfo.getData(); + mDeviceInfo.getData(); if (holder.switch_battery_level != null) holder.switch_battery_level.setText(text); Picasso.get().load(DomoticzIcons.getDrawableIcon(mDeviceInfo.getTypeImg(), - mDeviceInfo.getType(), - mDeviceInfo.getSubType(), - mDeviceInfo.getStatusBoolean(), - mDeviceInfo.getUseCustomImage(), - mDeviceInfo.getImage())).into(holder.iconRow); + mDeviceInfo.getType(), + mDeviceInfo.getSubType(), + mDeviceInfo.getStatusBoolean(), + mDeviceInfo.getUseCustomImage(), + mDeviceInfo.getImage())).into(holder.iconRow); if (!mDeviceInfo.getStatusBoolean()) holder.iconRow.setAlpha(0.5f); @@ -739,24 +739,24 @@ public void onClick(View v) { String text; if (holder.signal_level != null) { text = context.getString(R.string.last_update) - + ": " - + UsefulBits.getFormattedDate(context, mDeviceInfo.getLastUpdateDateTime().getTime()); + + ": " + + UsefulBits.getFormattedDate(context, mDeviceInfo.getLastUpdateDateTime().getTime()); holder.signal_level.setText(text); } if (holder.switch_battery_level != null) { String setPointText = - context.getString(R.string.set_point) + ": " + setPoint; + context.getString(R.string.set_point) + ": " + setPoint; holder.switch_battery_level.setText(setPointText); } Picasso.get().load(DomoticzIcons.getDrawableIcon( - mDeviceInfo.getTypeImg(), - mDeviceInfo.getType(), - mDeviceInfo.getSubType(), - false, - false, - null)).into(holder.iconRow); + mDeviceInfo.getTypeImg(), + mDeviceInfo.getType(), + mDeviceInfo.getSubType(), + false, + false, + null)).into(holder.iconRow); } /** @@ -806,8 +806,8 @@ private void setTemperatureRowData(DevicesInfo mDeviceInfo, DataObjectHolder hol if (holder.switch_battery_level != null) { String batteryText = context.getString(R.string.temperature) - + ": " - + mDeviceInfo.getData(); + + ": " + + mDeviceInfo.getData(); holder.switch_battery_level.setText(batteryText); } } else { @@ -815,17 +815,17 @@ private void setTemperatureRowData(DevicesInfo mDeviceInfo, DataObjectHolder hol holder.signal_level.setVisibility(View.VISIBLE); if (holder.switch_battery_level != null) { String batteryLevelText = context.getString(R.string.temperature) - + ": " - + temperature - + " " + sign; + + ": " + + temperature + + " " + sign; holder.switch_battery_level.setText(batteryLevelText); } if (holder.signal_level != null) { String signalText = context.getString(R.string.set_point) - + ": " - + mDeviceInfo.getSetPoint() - + " " + sign; + + ": " + + mDeviceInfo.getSetPoint() + + " " + sign; holder.signal_level.setText(signalText); } } @@ -878,12 +878,12 @@ public void onClick(View v) { if ((sign.equals("C") && temperature < 0) || (sign.equals("F") && temperature < 30)) { Picasso.get().load(DomoticzIcons.getDrawableIcon(mDeviceInfo.getTypeImg(), mDeviceInfo.getType(), mDeviceInfo.getSubType(), - mConfigInfo != null && temperature > mConfigInfo.getDegreeDaysBaseTemperature(), - true, "Freezing")).into(holder.iconRow); + mConfigInfo != null && temperature > mConfigInfo.getDegreeDaysBaseTemperature(), + true, "Freezing")).into(holder.iconRow); } else { Picasso.get().load(DomoticzIcons.getDrawableIcon(mDeviceInfo.getTypeImg(), mDeviceInfo.getType(), mDeviceInfo.getSubType(), - mConfigInfo != null && temperature > mConfigInfo.getDegreeDaysBaseTemperature(), - false, null)).into(holder.iconRow); + mConfigInfo != null && temperature > mConfigInfo.getDegreeDaysBaseTemperature(), + false, null)).into(holder.iconRow); } } @@ -912,8 +912,8 @@ private void setContactSwitchRowData(DevicesInfo mDevicesInfo, } String text = context.getString(R.string.last_update) - + ": " - + UsefulBits.getFormattedDate(context, mDevicesInfo.getLastUpdateDateTime().getTime()); + + ": " + + UsefulBits.getFormattedDate(context, mDevicesInfo.getLastUpdateDateTime().getTime()); if (holder.signal_level != null) { holder.signal_level.setText(text); } @@ -950,11 +950,11 @@ public void onClick(View v) { } Picasso.get().load(DomoticzIcons.getDrawableIcon(mDevicesInfo.getTypeImg(), - mDevicesInfo.getType(), - mDevicesInfo.getSwitchType(), - mDevicesInfo.getStatusBoolean(), - mDevicesInfo.getUseCustomImage(), - mDevicesInfo.getImage())).into(holder.iconRow); + mDevicesInfo.getType(), + mDevicesInfo.getSwitchType(), + mDevicesInfo.getStatusBoolean(), + mDevicesInfo.getUseCustomImage(), + mDevicesInfo.getImage())).into(holder.iconRow); if (!mDevicesInfo.getStatusBoolean()) holder.iconRow.setAlpha(0.5f); @@ -975,22 +975,22 @@ private void setPushOnOffSwitchRowData(DevicesInfo mDeviceInfo, DataObjectHolder holder.switch_name.setText(mDeviceInfo.getName()); String text = context.getString(R.string.last_update) - + ": " - + UsefulBits.getFormattedDate(context, mDeviceInfo.getLastUpdateDateTime().getTime()); + + ": " + + UsefulBits.getFormattedDate(context, mDeviceInfo.getLastUpdateDateTime().getTime()); if (holder.signal_level != null) holder.signal_level.setText(text); text = context.getString(R.string.status) + ": " + - mDeviceInfo.getData(); + mDeviceInfo.getData(); if (holder.switch_battery_level != null) holder.switch_battery_level.setText(text); Picasso.get().load(DomoticzIcons.getDrawableIcon(mDeviceInfo.getTypeImg(), - mDeviceInfo.getType(), - mDeviceInfo.getSubType(), - mDeviceInfo.getStatusBoolean(), - mDeviceInfo.getUseCustomImage(), - mDeviceInfo.getImage())).into(holder.iconRow); + mDeviceInfo.getType(), + mDeviceInfo.getSubType(), + mDeviceInfo.getStatusBoolean(), + mDeviceInfo.getUseCustomImage(), + mDeviceInfo.getImage())).into(holder.iconRow); if (!mDeviceInfo.getStatusBoolean()) holder.iconRow.setAlpha(0.5f); @@ -1054,16 +1054,16 @@ private void setBlindsRowData(final DevicesInfo mDeviceInfo, if (holder.signal_level != null) { text = context.getString(R.string.last_update) - + ": " - + UsefulBits.getFormattedDate( - context, - mDeviceInfo.getLastUpdateDateTime().getTime()); + + ": " + + UsefulBits.getFormattedDate( + context, + mDeviceInfo.getLastUpdateDateTime().getTime()); holder.signal_level.setText(text); } if (holder.switch_battery_level != null) { text = context.getString(R.string.status) + ": " + - mDeviceInfo.getData(); + mDeviceInfo.getData(); holder.switch_battery_level.setText(text); } @@ -1117,7 +1117,7 @@ public void onClick(View view) { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { String percentage = calculateDimPercentage(seekBar.getMax(), progress); TextView switch_dimmer_level = seekBar.getRootView() - .findViewById(mDeviceInfo.getIdx() + ID_TEXTVIEW); + .findViewById(mDeviceInfo.getIdx() + ID_TEXTVIEW); if (switch_dimmer_level != null) switch_dimmer_level.setText(percentage); } @@ -1137,16 +1137,16 @@ public void onStopTrackingTouch(SeekBar seekBar) { holder.switch_dimmer_level.setId(mDeviceInfo.getIdx() + ID_TEXTVIEW); String percentage = calculateDimPercentage( - mDeviceInfo.getMaxDimLevel(), mDeviceInfo.getLevel()); + mDeviceInfo.getMaxDimLevel(), mDeviceInfo.getLevel()); holder.switch_dimmer_level.setText(percentage); } Picasso.get().load(DomoticzIcons.getDrawableIcon(mDeviceInfo.getTypeImg(), - mDeviceInfo.getType(), - mDeviceInfo.getSubType(), - mDeviceInfo.getStatusBoolean(), - mDeviceInfo.getUseCustomImage(), - mDeviceInfo.getImage())).into(holder.iconRow); + mDeviceInfo.getType(), + mDeviceInfo.getSubType(), + mDeviceInfo.getStatusBoolean(), + mDeviceInfo.getUseCustomImage(), + mDeviceInfo.getImage())).into(holder.iconRow); if (!mDeviceInfo.getStatusBoolean()) holder.iconRow.setAlpha(0.5f); @@ -1169,15 +1169,15 @@ private void setSelectorRowData(final DevicesInfo mDeviceInfo, if (holder.signal_level != null) { text = context.getString(R.string.last_update) - + ": " - + UsefulBits.getFormattedDate(context, - mDeviceInfo.getLastUpdateDateTime().getTime()); + + ": " + + UsefulBits.getFormattedDate(context, + mDeviceInfo.getLastUpdateDateTime().getTime()); holder.signal_level.setText(text); } if (holder.switch_battery_level != null) { text = context.getString(R.string.status) + ": " + - mDeviceInfo.getStatus(); + mDeviceInfo.getStatus(); holder.switch_battery_level.setText(text); } @@ -1189,7 +1189,7 @@ private void setSelectorRowData(final DevicesInfo mDeviceInfo, holder.spSelector.setTag(mDeviceInfo.getIdx()); if (levelNames != null && levelNames.size() > loadLevel) { ArrayAdapter dataAdapter = new ArrayAdapter(context, - android.R.layout.simple_spinner_item, levelNames); + android.R.layout.simple_spinner_item, levelNames); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); holder.spSelector.setAdapter(dataAdapter); holder.spSelector.setSelection(loadLevel); @@ -1214,11 +1214,11 @@ public void onNothingSelected(AdapterView arg0) { }); Picasso.get().load(DomoticzIcons.getDrawableIcon(mDeviceInfo.getTypeImg(), - mDeviceInfo.getType(), - mDeviceInfo.getSwitchType(), - mDeviceInfo.getStatusBoolean(), - mDeviceInfo.getUseCustomImage(), - mDeviceInfo.getImage())).into(holder.iconRow); + mDeviceInfo.getType(), + mDeviceInfo.getSwitchType(), + mDeviceInfo.getStatusBoolean(), + mDeviceInfo.getUseCustomImage(), + mDeviceInfo.getImage())).into(holder.iconRow); if (!mDeviceInfo.getStatusBoolean()) holder.iconRow.setAlpha(0.5f); @@ -1244,29 +1244,29 @@ private void setDimmerRowData(final DevicesInfo mDeviceInfo, if (holder.signal_level != null) { text = context.getString(R.string.last_update) - + ": " - + UsefulBits.getFormattedDate(context, - mDeviceInfo.getLastUpdateDateTime().getTime()); + + ": " + + UsefulBits.getFormattedDate(context, + mDeviceInfo.getLastUpdateDateTime().getTime()); holder.signal_level.setText(text); } if (holder.switch_battery_level != null) { text = context.getString(R.string.status) + ": " + - mDeviceInfo.getStatus(); + mDeviceInfo.getStatus(); holder.switch_battery_level.setText(text); } holder.switch_dimmer_level.setId(mDeviceInfo.getIdx() + ID_TEXTVIEW); String percentage = calculateDimPercentage( - mDeviceInfo.getMaxDimLevel(), mDeviceInfo.getLevel()); + mDeviceInfo.getMaxDimLevel(), mDeviceInfo.getLevel()); holder.switch_dimmer_level.setText(percentage); Picasso.get().load(DomoticzIcons.getDrawableIcon(mDeviceInfo.getTypeImg(), - mDeviceInfo.getType(), - mDeviceInfo.getSubType(), - mDeviceInfo.getStatusBoolean(), - mDeviceInfo.getUseCustomImage(), - mDeviceInfo.getImage())).into(holder.iconRow); + mDeviceInfo.getType(), + mDeviceInfo.getSubType(), + mDeviceInfo.getStatusBoolean(), + mDeviceInfo.getUseCustomImage(), + mDeviceInfo.getImage())).into(holder.iconRow); if (!mDeviceInfo.getStatusBoolean()) holder.iconRow.setAlpha(0.5f); @@ -1310,7 +1310,7 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { String percentage = calculateDimPercentage(seekBar.getMax(), progress); TextView switch_dimmer_level = seekBar.getRootView() - .findViewById(mDeviceInfo.getIdx() + ID_TEXTVIEW); + .findViewById(mDeviceInfo.getIdx() + ID_TEXTVIEW); if (switch_dimmer_level != null) switch_dimmer_level.setText(percentage); @@ -1327,7 +1327,7 @@ public void onStopTrackingTouch(SeekBar seekBar) { SwitchMaterial dimmerOnOffSwitch = null; try { dimmerOnOffSwitch = seekBar.getRootView() - .findViewById(mDeviceInfo.getIdx() + ID_SWITCH); + .findViewById(mDeviceInfo.getIdx() + ID_SWITCH); if (progress == 0 && dimmerOnOffSwitch.isChecked()) { dimmerOnOffSwitch.setChecked(false); seekBar.setProgress(previousDimmerValue); @@ -1391,29 +1391,29 @@ private void setDimmerOnOffButtonRowData(final DevicesInfo mDeviceInfo, if (holder.signal_level != null && mDeviceInfo.getLastUpdateDateTime() != null) { text = context.getString(R.string.last_update) - + ": " - + UsefulBits.getFormattedDate(context, - mDeviceInfo.getLastUpdateDateTime().getTime()); + + ": " + + UsefulBits.getFormattedDate(context, + mDeviceInfo.getLastUpdateDateTime().getTime()); holder.signal_level.setText(text); } if (holder.switch_battery_level != null) { text = context.getString(R.string.status) + ": " + - mDeviceInfo.getStatus(); + mDeviceInfo.getStatus(); holder.switch_battery_level.setText(text); } holder.switch_dimmer_level.setId(mDeviceInfo.getIdx() + ID_TEXTVIEW); String percentage = calculateDimPercentage( - mDeviceInfo.getMaxDimLevel(), mDeviceInfo.getLevel()); + mDeviceInfo.getMaxDimLevel(), mDeviceInfo.getLevel()); holder.switch_dimmer_level.setText(percentage); Picasso.get().load(DomoticzIcons.getDrawableIcon(mDeviceInfo.getTypeImg(), - mDeviceInfo.getType(), - mDeviceInfo.getSubType(), - mDeviceInfo.getStatusBoolean(), - mDeviceInfo.getUseCustomImage(), - mDeviceInfo.getImage())).into(holder.iconRow); + mDeviceInfo.getType(), + mDeviceInfo.getSubType(), + mDeviceInfo.getStatusBoolean(), + mDeviceInfo.getUseCustomImage(), + mDeviceInfo.getImage())).into(holder.iconRow); if (!mDeviceInfo.getStatusBoolean()) holder.iconRow.setAlpha(0.5f); @@ -1461,7 +1461,7 @@ public void onClick(View v) { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { String percentage = calculateDimPercentage(seekBar.getMax(), progress); TextView switch_dimmer_level = seekBar.getRootView() - .findViewById(mDeviceInfo.getIdx() + ID_TEXTVIEW); + .findViewById(mDeviceInfo.getIdx() + ID_TEXTVIEW); if (switch_dimmer_level != null) switch_dimmer_level.setText(percentage); } @@ -1527,12 +1527,12 @@ private void setModalSwitchRowData(DevicesInfo mDeviceInfo, holder.switch_name.setText(mDeviceInfo.getName()); String text = context.getString(R.string.last_update) + ": " + - UsefulBits.getFormattedDate(context, - mDeviceInfo.getLastUpdateDateTime().getTime()); + UsefulBits.getFormattedDate(context, + mDeviceInfo.getLastUpdateDateTime().getTime()); holder.signal_level.setText(text); text = context.getString(R.string.status) + ": " + - getStatus(stateArrayRes, stateNamesArrayRes, mDeviceInfo.getStatus()); + getStatus(stateArrayRes, stateNamesArrayRes, mDeviceInfo.getStatus()); holder.switch_battery_level.setText(text); if (holder.buttonSetStatus != null) { @@ -1547,11 +1547,11 @@ public void onClick(View v) { } Picasso.get().load(DomoticzIcons.getDrawableIcon(mDeviceInfo.getTypeImg(), - mDeviceInfo.getType(), - mDeviceInfo.getSwitchType(), - mDeviceInfo.getStatusBoolean(), - mDeviceInfo.getUseCustomImage(), - mDeviceInfo.getImage())).into(holder.iconRow); + mDeviceInfo.getType(), + mDeviceInfo.getSwitchType(), + mDeviceInfo.getStatusBoolean(), + mDeviceInfo.getUseCustomImage(), + mDeviceInfo.getImage())).into(holder.iconRow); } /** diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/EventsAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/EventsAdapter.java index 3ce7827eb..801a2fcd6 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Adapters/EventsAdapter.java +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/EventsAdapter.java @@ -81,7 +81,7 @@ public Filter getFilter() { @Override public DataObjectHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()) - .inflate(R.layout.event_row_default, parent, false); + .inflate(R.layout.event_row_default, parent, false); if (mSharedPrefs.darkThemeEnabled()) { if ((view.findViewById(R.id.card_global_wrapper)) != null) @@ -147,7 +147,7 @@ public interface onClickListener { } public static class DataObjectHolder extends RecyclerView.ViewHolder - implements View.OnClickListener { + implements View.OnClickListener { TextView name; TextView message; SwitchMaterial buttonON; diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/LocationAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/LocationAdapter.java index 8081702e5..5c24fbf1f 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Adapters/LocationAdapter.java +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/LocationAdapter.java @@ -118,7 +118,7 @@ public View getView(int position, View convertView, ViewGroup parent) { holder.connectedSwitch.setText(context.getString(R.string.connectedSwitch) + ": " + mLocationInfo.getSwitchIdx()); } else { holder.connectedSwitch.setText(context.getString(R.string.connectedSwitch) - + ": " + context.getString(R.string.not_available)); + + ": " + context.getString(R.string.not_available)); } if (!UsefulBits.isEmpty(mLocationInfo.getValue())) diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/LogAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/LogAdapter.java index 4d2646ab0..9e6b97ae8 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Adapters/LogAdapter.java +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/LogAdapter.java @@ -76,7 +76,7 @@ public Filter getFilter() { @Override public DataObjectHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()) - .inflate(R.layout.logs_row_default, parent, false); + .inflate(R.layout.logs_row_default, parent, false); if (mSharedPrefs.darkThemeEnabled()) { if ((view.findViewById(R.id.card_global_wrapper)) != null) @@ -137,7 +137,7 @@ public interface onClickListener { public static class DataObjectHolder extends RecyclerView.ViewHolder - implements View.OnClickListener { + implements View.OnClickListener { TextView name; TextView datetime; TextView message; diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/NFCAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/NFCAdapter.java index 0a742d3d6..3a6b7b74a 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Adapters/NFCAdapter.java +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/NFCAdapter.java @@ -124,7 +124,7 @@ public View getView(int position, View convertView, ViewGroup parent) { holder.nfc_switch_idx.setText(context.getString(R.string.connectedSwitch) + ": " + mNFCInfo.getSwitchIdx()); } else { holder.nfc_switch_idx.setText(context.getString(R.string.connectedSwitch) - + ": " + context.getString(R.string.not_available)); + + ": " + context.getString(R.string.not_available)); } if (!UsefulBits.isEmpty(mNFCInfo.getValue())) diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/PlansAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/PlansAdapter.java index f46021f77..d6fda7a2c 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Adapters/PlansAdapter.java +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/PlansAdapter.java @@ -96,7 +96,7 @@ private void SaveSorting() { @Override public DataObjectHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()) - .inflate(R.layout.plan_row, parent, false); + .inflate(R.layout.plan_row, parent, false); if (mSharedPrefs.darkThemeEnabled()) { if ((view.findViewById(R.id.card_global_wrapper)) != null) diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/QRCodeAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/QRCodeAdapter.java index 3fd955ce4..c4720885f 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Adapters/QRCodeAdapter.java +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/QRCodeAdapter.java @@ -125,7 +125,7 @@ public View getView(int position, View convertView, ViewGroup parent) { holder.nfc_switch_idx.setText(context.getString(R.string.connectedSwitch) + ": " + mQRCodeInfo.getSwitchIdx()); } else { holder.nfc_switch_idx.setText(context.getString(R.string.connectedSwitch) - + ": " + context.getString(R.string.not_available)); + + ": " + context.getString(R.string.not_available)); } if (!UsefulBits.isEmpty(mQRCodeInfo.getValue())) diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/SceneAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/SceneAdapter.java index 60448e951..cf85c9f13 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Adapters/SceneAdapter.java +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/SceneAdapter.java @@ -97,7 +97,7 @@ public Filter getFilter() { @Override public DataObjectHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()) - .inflate(R.layout.scene_row_default, parent, false); + .inflate(R.layout.scene_row_default, parent, false); if (mSharedPrefs.darkThemeEnabled()) { if ((view.findViewById(R.id.card_global_wrapper)) != null) @@ -166,19 +166,19 @@ public void onClick(View v) { holder.switch_name.setText(mSceneInfo.getName()); String text = context.getString(R.string.last_update) - + ": " - + UsefulBits.getFormattedDate(context, - mSceneInfo.getLastUpdateDateTime().getTime()); + + ": " + + UsefulBits.getFormattedDate(context, + mSceneInfo.getLastUpdateDateTime().getTime()); holder.signal_level.setText(text); holder.switch_battery_level.setText(DomoticzValues.Scene.Type.SCENE); Picasso.get().load(DomoticzIcons.getDrawableIcon( - DomoticzValues.Scene.Type.SCENE.toLowerCase(), - null, - null, - false, - false, - null)).into(holder.iconRow); + DomoticzValues.Scene.Type.SCENE.toLowerCase(), + null, + null, + false, + false, + null)).into(holder.iconRow); if (holder.buttonOn != null) { holder.buttonOn.setId(mSceneInfo.getIdx()); @@ -231,9 +231,9 @@ public void onClick(View v) { holder.switch_name.setText(mSceneInfo.getName()); String text = context.getString(R.string.last_update) - + ": " - + UsefulBits.getFormattedDate(context, - mSceneInfo.getLastUpdateDateTime().getTime()); + + ": " + + UsefulBits.getFormattedDate(context, + mSceneInfo.getLastUpdateDateTime().getTime()); holder.signal_level.setText(text); holder.switch_battery_level.setText(DomoticzValues.Scene.Type.GROUP); @@ -258,12 +258,12 @@ public void onClick(View v) { } Picasso.get().load(DomoticzIcons.getDrawableIcon( - DomoticzValues.Scene.Type.GROUP.toLowerCase(), - null, - null, - mSceneInfo.getStatusInBoolean(), - false, - null)).into(holder.iconRow); + DomoticzValues.Scene.Type.GROUP.toLowerCase(), + null, + null, + mSceneInfo.getStatusInBoolean(), + false, + null)).into(holder.iconRow); if (!mSceneInfo.getStatusInBoolean()) holder.iconRow.setAlpha(0.5f); @@ -295,7 +295,7 @@ public void onClick(View v) { }); } } else throw new NullPointerException("Scene type not supported in the adapter for:\n" - + mSceneInfo.toString()); + + mSceneInfo.toString()); holder.itemView.setOnClickListener(new View.OnClickListener() { @Override diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/SpeechAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/SpeechAdapter.java index 98c7c3456..5ee7ffc58 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Adapters/SpeechAdapter.java +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/SpeechAdapter.java @@ -121,14 +121,14 @@ public View getView(int position, View convertView, ViewGroup parent) { holder.Speech_tag_id.setText(context.getString(R.string.connectedSwitch) + ": " + mSpeechInfo.getSwitchIdx()); } else { holder.Speech_tag_id.setText(context.getString(R.string.connectedSwitch) - + ": " + context.getString(R.string.not_available)); + + ": " + context.getString(R.string.not_available)); } if (!UsefulBits.isEmpty(mSpeechInfo.getValue())) holder.Speech_tag_id.setText(holder.Speech_tag_id.getText() + " - " + mSpeechInfo.getValue()); holder.Speech_switch_idx.setText("Commando's: \r\n" + "'" + mSpeechInfo.getName() + "' " + "\r\n'" + mSpeechInfo.getName() + " " + context.getString(R.string.button_state_on).toLowerCase() + "'\r\n" + - "'" + mSpeechInfo.getName() + " " + context.getString(R.string.button_state_off).toLowerCase() + "'"); + "'" + mSpeechInfo.getName() + " " + context.getString(R.string.button_state_off).toLowerCase() + "'"); holder.remove.setId(position); holder.remove.setOnClickListener(new View.OnClickListener() { diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/SwitchesAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/SwitchesAdapter.java index d52d33799..52316df37 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Adapters/SwitchesAdapter.java +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/SwitchesAdapter.java @@ -71,12 +71,12 @@ public class SwitchesAdapter extends RecyclerView.Adapter data = null; public ArrayList filteredData = null; @@ -158,7 +158,7 @@ public Filter getFilter() { public DataObjectHolder onCreateViewHolder(ViewGroup parent, int viewType) { View row = null; row = LayoutInflater.from(parent.getContext()) - .inflate(R.layout.switch_row_list, parent, false); + .inflate(R.layout.switch_row_list, parent, false); if (mSharedPrefs.darkThemeEnabled()) { if ((row.findViewById(R.id.card_global_wrapper)) != null) @@ -256,7 +256,7 @@ public void onClick(View v) { private void setSwitchRowData(DevicesInfo mDeviceInfo, DataObjectHolder holder) { if (mDeviceInfo.getSwitchTypeVal() == 0 && - (mDeviceInfo.getSwitchType() == null)) { + (mDeviceInfo.getSwitchType() == null)) { switch (mDeviceInfo.getType()) { case DomoticzValues.Scene.Type.GROUP: setButtons(holder, Buttons.BUTTONS); @@ -345,7 +345,7 @@ private void setSwitchRowData(DevicesInfo mDeviceInfo, case DomoticzValues.Device.Type.Value.DIMMER: if (mDeviceInfo.getSubType().startsWith(DomoticzValues.Device.SubType.Name.RGB) || - mDeviceInfo.getSubType().startsWith(DomoticzValues.Device.SubType.Name.WW)) { + mDeviceInfo.getSubType().startsWith(DomoticzValues.Device.SubType.Name.WW)) { if (mSharedPrefs.showSwitchesAsButtons()) { setButtons(holder, Buttons.DIMMER_BUTTONS); setDimmerOnOffButtonRowData(mDeviceInfo, holder, true); @@ -403,7 +403,7 @@ private void setSwitchRowData(DevicesInfo mDeviceInfo, default: throw new NullPointerException( - "No supported switch type defined in the adapter (setSwitchRowData)"); + "No supported switch type defined in the adapter (setSwitchRowData)"); } } } @@ -434,18 +434,18 @@ private void setDefaultRowData(DevicesInfo mDeviceInfo, if (holder.signal_level != null) { text = context.getString(R.string.last_update) - + ": "; + + ": "; if (mDeviceInfo.getLastUpdateDateTime() != null) { text += UsefulBits.getFormattedDate(context, - mDeviceInfo.getLastUpdateDateTime().getTime()); + mDeviceInfo.getLastUpdateDateTime().getTime()); } holder.signal_level.setText(text); } if (holder.switch_battery_level != null) { text = context.getString(R.string.status) - + ": " - + mDeviceInfo.getData(); + + ": " + + mDeviceInfo.getData(); holder.switch_battery_level.setText(text); if (mDeviceInfo.getUsage() != null && mDeviceInfo.getUsage().length() > 0) { @@ -455,7 +455,7 @@ private void setDefaultRowData(DevicesInfo mDeviceInfo, if (mDeviceInfo.getCounterToday() != null && mDeviceInfo.getCounterToday().length() > 0) holder.switch_battery_level.append(" " + context.getString(R.string.today) + ": " + mDeviceInfo.getCounterToday()); if (mDeviceInfo.getCounter() != null && mDeviceInfo.getCounter().length() > 0 && - !mDeviceInfo.getCounter().equals(mDeviceInfo.getData())) + !mDeviceInfo.getCounter().equals(mDeviceInfo.getData())) holder.switch_battery_level.append(" " + context.getString(R.string.total) + ": " + mDeviceInfo.getCounter()); if (mDeviceInfo.getType().equals("Wind")) { text = context.getString(R.string.direction) + " " + mDeviceInfo.getDirection() + " " + mDeviceInfo.getDirectionStr(); @@ -478,11 +478,11 @@ private void setDefaultRowData(DevicesInfo mDeviceInfo, } Picasso.get().load(DomoticzIcons.getDrawableIcon(mDeviceInfo.getTypeImg(), - mDeviceInfo.getType(), - mDeviceInfo.getSubType(), - mDeviceInfo.getStatusBoolean(), - mDeviceInfo.getUseCustomImage(), - mDeviceInfo.getImage())).into(holder.iconRow); + mDeviceInfo.getType(), + mDeviceInfo.getSubType(), + mDeviceInfo.getStatusBoolean(), + mDeviceInfo.getUseCustomImage(), + mDeviceInfo.getImage())).into(holder.iconRow); holder.iconRow.setAlpha(1f); if (!mDeviceInfo.getStatusBoolean()) @@ -502,13 +502,13 @@ private void setSecurityPanelSwitchRowData(DevicesInfo mDeviceInfo, DataObjectHo holder.switch_name.setText(mDeviceInfo.getName()); String text = context.getString(R.string.last_update) + ": " + - UsefulBits.getFormattedDate(context, mDeviceInfo.getLastUpdateDateTime().getTime()); + UsefulBits.getFormattedDate(context, mDeviceInfo.getLastUpdateDateTime().getTime()); if (holder.signal_level != null) holder.signal_level.setText(text); text = context.getString(R.string.status) + ": " + - mDeviceInfo.getData(); + mDeviceInfo.getData(); if (holder.switch_battery_level != null) holder.switch_battery_level.setText(text); @@ -529,11 +529,11 @@ public void onClick(View v) { } Picasso.get().load(DomoticzIcons.getDrawableIcon(mDeviceInfo.getTypeImg(), - mDeviceInfo.getType(), - mDeviceInfo.getSwitchType(), - mDeviceInfo.getStatusBoolean(), - mDeviceInfo.getUseCustomImage(), - mDeviceInfo.getImage())).into(holder.iconRow); + mDeviceInfo.getType(), + mDeviceInfo.getSwitchType(), + mDeviceInfo.getStatusBoolean(), + mDeviceInfo.getUseCustomImage(), + mDeviceInfo.getImage())).into(holder.iconRow); if (!mDeviceInfo.getStatusBoolean()) holder.iconRow.setAlpha(0.5f); @@ -558,23 +558,23 @@ private void setOnOffButtonRowData(final DevicesInfo mDeviceInfo, if (holder.signal_level != null) { text = context.getString(R.string.last_update) - + ": " - + UsefulBits.getFormattedDate(context, - mDeviceInfo.getLastUpdateDateTime().getTime()); + + ": " + + UsefulBits.getFormattedDate(context, + mDeviceInfo.getLastUpdateDateTime().getTime()); holder.signal_level.setText(text); } if (holder.switch_battery_level != null) { text = context.getString(R.string.status) + ": " + - mDeviceInfo.getData(); + mDeviceInfo.getData(); holder.switch_battery_level.setText(text); } Picasso.get().load(DomoticzIcons.getDrawableIcon(mDeviceInfo.getTypeImg(), - mDeviceInfo.getType(), - mDeviceInfo.getSubType(), - mDeviceInfo.getStatusBoolean(), - mDeviceInfo.getUseCustomImage(), - mDeviceInfo.getImage())).into(holder.iconRow); + mDeviceInfo.getType(), + mDeviceInfo.getSubType(), + mDeviceInfo.getStatusBoolean(), + mDeviceInfo.getUseCustomImage(), + mDeviceInfo.getImage())).into(holder.iconRow); if (holder.buttonOn != null) { if (mDeviceInfo.getType().equals(DomoticzValues.Scene.Type.GROUP) || mDeviceInfo.getType().equals(DomoticzValues.Scene.Type.SCENE)) @@ -638,22 +638,22 @@ private void setOnOffSwitchRowData(final DevicesInfo mDeviceInfo, if (holder.signal_level != null) { text = context.getString(R.string.last_update) - + ": " - + UsefulBits.getFormattedDate(context, mDeviceInfo.getLastUpdateDateTime().getTime()); + + ": " + + UsefulBits.getFormattedDate(context, mDeviceInfo.getLastUpdateDateTime().getTime()); holder.signal_level.setText(text); } text = context.getString(R.string.status) + ": " + - mDeviceInfo.getData(); + mDeviceInfo.getData(); if (holder.switch_battery_level != null) holder.switch_battery_level.setText(text); Picasso.get().load(DomoticzIcons.getDrawableIcon(mDeviceInfo.getTypeImg(), - mDeviceInfo.getType(), - mDeviceInfo.getSubType(), - mDeviceInfo.getStatusBoolean(), - mDeviceInfo.getUseCustomImage(), - mDeviceInfo.getImage())).into(holder.iconRow); + mDeviceInfo.getType(), + mDeviceInfo.getSubType(), + mDeviceInfo.getStatusBoolean(), + mDeviceInfo.getUseCustomImage(), + mDeviceInfo.getImage())).into(holder.iconRow); if (!mDeviceInfo.getStatusBoolean()) holder.iconRow.setAlpha(0.5f); @@ -724,24 +724,24 @@ public void onClick(View v) { String text; if (holder.signal_level != null) { text = context.getString(R.string.last_update) - + ": " - + UsefulBits.getFormattedDate(context, mDeviceInfo.getLastUpdateDateTime().getTime()); + + ": " + + UsefulBits.getFormattedDate(context, mDeviceInfo.getLastUpdateDateTime().getTime()); holder.signal_level.setText(text); } if (holder.switch_battery_level != null) { String setPointText = - context.getString(R.string.set_point) + ": " + setPoint; + context.getString(R.string.set_point) + ": " + setPoint; holder.switch_battery_level.setText(setPointText); } Picasso.get().load(DomoticzIcons.getDrawableIcon( - mDeviceInfo.getTypeImg(), - mDeviceInfo.getType(), - mDeviceInfo.getSubType(), - false, - false, - null)).into(holder.iconRow); + mDeviceInfo.getTypeImg(), + mDeviceInfo.getType(), + mDeviceInfo.getSubType(), + false, + false, + null)).into(holder.iconRow); } /** @@ -763,8 +763,8 @@ private void setTemperatureRowData(DevicesInfo mDeviceInfo, DataObjectHolder hol if (holder.switch_battery_level != null) { String batteryText = context.getString(R.string.temperature) - + ": " - + mDeviceInfo.getData(); + + ": " + + mDeviceInfo.getData(); holder.switch_battery_level.setText(batteryText); } } else { @@ -772,17 +772,17 @@ private void setTemperatureRowData(DevicesInfo mDeviceInfo, DataObjectHolder hol holder.signal_level.setVisibility(View.VISIBLE); if (holder.switch_battery_level != null) { String batteryLevelText = context.getString(R.string.temperature) - + ": " - + temperature - + " C"; + + ": " + + temperature + + " C"; holder.switch_battery_level.setText(batteryLevelText); } if (holder.signal_level != null) { String signalText = context.getString(R.string.set_point) - + ": " - + mDeviceInfo.getSetPoint() - + " C"; + + ": " + + mDeviceInfo.getSetPoint() + + " C"; holder.signal_level.setText(signalText); } } @@ -843,8 +843,8 @@ private void setContactSwitchRowData(DevicesInfo mDevicesInfo, } String text = context.getString(R.string.last_update) - + ": " - + UsefulBits.getFormattedDate(context, mDevicesInfo.getLastUpdateDateTime().getTime()); + + ": " + + UsefulBits.getFormattedDate(context, mDevicesInfo.getLastUpdateDateTime().getTime()); if (holder.signal_level != null) { holder.signal_level.setText(text); } @@ -881,11 +881,11 @@ public void onClick(View v) { } Picasso.get().load(DomoticzIcons.getDrawableIcon(mDevicesInfo.getTypeImg(), - mDevicesInfo.getType(), - mDevicesInfo.getSwitchType(), - mDevicesInfo.getStatusBoolean(), - mDevicesInfo.getUseCustomImage(), - mDevicesInfo.getImage())).into(holder.iconRow); + mDevicesInfo.getType(), + mDevicesInfo.getSwitchType(), + mDevicesInfo.getStatusBoolean(), + mDevicesInfo.getUseCustomImage(), + mDevicesInfo.getImage())).into(holder.iconRow); if (!mDevicesInfo.getStatusBoolean()) holder.iconRow.setAlpha(0.5f); @@ -906,22 +906,22 @@ private void setPushOnOffSwitchRowData(DevicesInfo mDeviceInfo, DataObjectHolder holder.switch_name.setText(mDeviceInfo.getName()); String text = context.getString(R.string.last_update) - + ": " - + UsefulBits.getFormattedDate(context, mDeviceInfo.getLastUpdateDateTime().getTime()); + + ": " + + UsefulBits.getFormattedDate(context, mDeviceInfo.getLastUpdateDateTime().getTime()); if (holder.signal_level != null) holder.signal_level.setText(text); text = context.getString(R.string.status) + ": " + - mDeviceInfo.getData(); + mDeviceInfo.getData(); if (holder.switch_battery_level != null) holder.switch_battery_level.setText(text); Picasso.get().load(DomoticzIcons.getDrawableIcon(mDeviceInfo.getTypeImg(), - mDeviceInfo.getType(), - mDeviceInfo.getSubType(), - mDeviceInfo.getStatusBoolean(), - mDeviceInfo.getUseCustomImage(), - mDeviceInfo.getImage())).into(holder.iconRow); + mDeviceInfo.getType(), + mDeviceInfo.getSubType(), + mDeviceInfo.getStatusBoolean(), + mDeviceInfo.getUseCustomImage(), + mDeviceInfo.getImage())).into(holder.iconRow); if (!mDeviceInfo.getStatusBoolean()) holder.iconRow.setAlpha(0.5f); @@ -985,16 +985,16 @@ private void setBlindsRowData(final DevicesInfo mDeviceInfo, if (holder.signal_level != null) { text = context.getString(R.string.last_update) - + ": " - + UsefulBits.getFormattedDate( - context, - mDeviceInfo.getLastUpdateDateTime().getTime()); + + ": " + + UsefulBits.getFormattedDate( + context, + mDeviceInfo.getLastUpdateDateTime().getTime()); holder.signal_level.setText(text); } if (holder.switch_battery_level != null) { text = context.getString(R.string.status) + ": " + - mDeviceInfo.getData(); + mDeviceInfo.getData(); holder.switch_battery_level.setText(text); } @@ -1048,7 +1048,7 @@ public void onClick(View view) { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { String percentage = calculateDimPercentage(seekBar.getMax(), progress); TextView switch_dimmer_level = seekBar.getRootView() - .findViewById(mDeviceInfo.getIdx() + ID_TEXTVIEW); + .findViewById(mDeviceInfo.getIdx() + ID_TEXTVIEW); if (switch_dimmer_level != null) switch_dimmer_level.setText(percentage); } @@ -1068,16 +1068,16 @@ public void onStopTrackingTouch(SeekBar seekBar) { holder.switch_dimmer_level.setId(mDeviceInfo.getIdx() + ID_TEXTVIEW); String percentage = calculateDimPercentage( - mDeviceInfo.getMaxDimLevel(), mDeviceInfo.getLevel()); + mDeviceInfo.getMaxDimLevel(), mDeviceInfo.getLevel()); holder.switch_dimmer_level.setText(percentage); } Picasso.get().load(DomoticzIcons.getDrawableIcon(mDeviceInfo.getTypeImg(), - mDeviceInfo.getType(), - mDeviceInfo.getSubType(), - mDeviceInfo.getStatusBoolean(), - mDeviceInfo.getUseCustomImage(), - mDeviceInfo.getImage())).into(holder.iconRow); + mDeviceInfo.getType(), + mDeviceInfo.getSubType(), + mDeviceInfo.getStatusBoolean(), + mDeviceInfo.getUseCustomImage(), + mDeviceInfo.getImage())).into(holder.iconRow); if (!mDeviceInfo.getStatusBoolean()) holder.iconRow.setAlpha(0.5f); @@ -1100,15 +1100,15 @@ private void setSelectorRowData(final DevicesInfo mDeviceInfo, if (holder.signal_level != null) { text = context.getString(R.string.last_update) - + ": " - + UsefulBits.getFormattedDate(context, - mDeviceInfo.getLastUpdateDateTime().getTime()); + + ": " + + UsefulBits.getFormattedDate(context, + mDeviceInfo.getLastUpdateDateTime().getTime()); holder.signal_level.setText(text); } if (holder.switch_battery_level != null) { text = context.getString(R.string.status) + ": " + - mDeviceInfo.getStatus(); + mDeviceInfo.getStatus(); holder.switch_battery_level.setText(text); } @@ -1120,7 +1120,7 @@ private void setSelectorRowData(final DevicesInfo mDeviceInfo, holder.spSelector.setTag(mDeviceInfo.getIdx()); if (levelNames != null && levelNames.size() > loadLevel) { ArrayAdapter dataAdapter = new ArrayAdapter(context, - android.R.layout.simple_spinner_item, levelNames); + android.R.layout.simple_spinner_item, levelNames); dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); holder.spSelector.setAdapter(dataAdapter); holder.spSelector.setSelection(loadLevel); @@ -1145,11 +1145,11 @@ public void onNothingSelected(AdapterView arg0) { }); Picasso.get().load(DomoticzIcons.getDrawableIcon(mDeviceInfo.getTypeImg(), - mDeviceInfo.getType(), - mDeviceInfo.getSwitchType(), - mDeviceInfo.getStatusBoolean(), - mDeviceInfo.getUseCustomImage(), - mDeviceInfo.getImage())).into(holder.iconRow); + mDeviceInfo.getType(), + mDeviceInfo.getSwitchType(), + mDeviceInfo.getStatusBoolean(), + mDeviceInfo.getUseCustomImage(), + mDeviceInfo.getImage())).into(holder.iconRow); if (!mDeviceInfo.getStatusBoolean()) holder.iconRow.setAlpha(0.5f); @@ -1175,29 +1175,29 @@ private void setDimmerRowData(final DevicesInfo mDeviceInfo, if (holder.signal_level != null) { text = context.getString(R.string.last_update) - + ": " - + UsefulBits.getFormattedDate(context, - mDeviceInfo.getLastUpdateDateTime().getTime()); + + ": " + + UsefulBits.getFormattedDate(context, + mDeviceInfo.getLastUpdateDateTime().getTime()); holder.signal_level.setText(text); } if (holder.switch_battery_level != null) { text = context.getString(R.string.status) + ": " + - mDeviceInfo.getStatus(); + mDeviceInfo.getStatus(); holder.switch_battery_level.setText(text); } holder.switch_dimmer_level.setId(mDeviceInfo.getIdx() + ID_TEXTVIEW); String percentage = calculateDimPercentage( - mDeviceInfo.getMaxDimLevel(), mDeviceInfo.getLevel()); + mDeviceInfo.getMaxDimLevel(), mDeviceInfo.getLevel()); holder.switch_dimmer_level.setText(percentage); Picasso.get().load(DomoticzIcons.getDrawableIcon(mDeviceInfo.getTypeImg(), - mDeviceInfo.getType(), - mDeviceInfo.getSubType(), - mDeviceInfo.getStatusBoolean(), - mDeviceInfo.getUseCustomImage(), - mDeviceInfo.getImage())).into(holder.iconRow); + mDeviceInfo.getType(), + mDeviceInfo.getSubType(), + mDeviceInfo.getStatusBoolean(), + mDeviceInfo.getUseCustomImage(), + mDeviceInfo.getImage())).into(holder.iconRow); if (!mDeviceInfo.getStatusBoolean()) holder.iconRow.setAlpha(0.5f); @@ -1241,7 +1241,7 @@ public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { String percentage = calculateDimPercentage(seekBar.getMax(), progress); TextView switch_dimmer_level = seekBar.getRootView() - .findViewById(mDeviceInfo.getIdx() + ID_TEXTVIEW); + .findViewById(mDeviceInfo.getIdx() + ID_TEXTVIEW); if (switch_dimmer_level != null) switch_dimmer_level.setText(percentage); @@ -1258,7 +1258,7 @@ public void onStopTrackingTouch(SeekBar seekBar) { SwitchMaterial dimmerOnOffSwitch = null; try { dimmerOnOffSwitch = seekBar.getRootView() - .findViewById(mDeviceInfo.getIdx() + ID_SWITCH); + .findViewById(mDeviceInfo.getIdx() + ID_SWITCH); if (progress == 0 && dimmerOnOffSwitch.isChecked()) { dimmerOnOffSwitch.setChecked(false); seekBar.setProgress(previousDimmerValue); @@ -1322,29 +1322,29 @@ private void setDimmerOnOffButtonRowData(final DevicesInfo mDeviceInfo, if (holder.signal_level != null && mDeviceInfo.getLastUpdateDateTime() != null) { text = context.getString(R.string.last_update) - + ": " - + UsefulBits.getFormattedDate(context, - mDeviceInfo.getLastUpdateDateTime().getTime()); + + ": " + + UsefulBits.getFormattedDate(context, + mDeviceInfo.getLastUpdateDateTime().getTime()); holder.signal_level.setText(text); } if (holder.switch_battery_level != null) { text = context.getString(R.string.status) + ": " + - mDeviceInfo.getStatus(); + mDeviceInfo.getStatus(); holder.switch_battery_level.setText(text); } holder.switch_dimmer_level.setId(mDeviceInfo.getIdx() + ID_TEXTVIEW); String percentage = calculateDimPercentage( - mDeviceInfo.getMaxDimLevel(), mDeviceInfo.getLevel()); + mDeviceInfo.getMaxDimLevel(), mDeviceInfo.getLevel()); holder.switch_dimmer_level.setText(percentage); Picasso.get().load(DomoticzIcons.getDrawableIcon(mDeviceInfo.getTypeImg(), - mDeviceInfo.getType(), - mDeviceInfo.getSubType(), - mDeviceInfo.getStatusBoolean(), - mDeviceInfo.getUseCustomImage(), - mDeviceInfo.getImage())).into(holder.iconRow); + mDeviceInfo.getType(), + mDeviceInfo.getSubType(), + mDeviceInfo.getStatusBoolean(), + mDeviceInfo.getUseCustomImage(), + mDeviceInfo.getImage())).into(holder.iconRow); if (!mDeviceInfo.getStatusBoolean()) holder.iconRow.setAlpha(0.5f); @@ -1392,7 +1392,7 @@ public void onClick(View v) { public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { String percentage = calculateDimPercentage(seekBar.getMax(), progress); TextView switch_dimmer_level = seekBar.getRootView() - .findViewById(mDeviceInfo.getIdx() + ID_TEXTVIEW); + .findViewById(mDeviceInfo.getIdx() + ID_TEXTVIEW); if (switch_dimmer_level != null) switch_dimmer_level.setText(percentage); } @@ -1458,12 +1458,12 @@ private void setModalSwitchRowData(DevicesInfo mDeviceInfo, holder.switch_name.setText(mDeviceInfo.getName()); String text = context.getString(R.string.last_update) + ": " + - UsefulBits.getFormattedDate(context, - mDeviceInfo.getLastUpdateDateTime().getTime()); + UsefulBits.getFormattedDate(context, + mDeviceInfo.getLastUpdateDateTime().getTime()); holder.signal_level.setText(text); text = context.getString(R.string.status) + ": " + - getStatus(stateArrayRes, stateNamesArrayRes, mDeviceInfo.getStatus()); + getStatus(stateArrayRes, stateNamesArrayRes, mDeviceInfo.getStatus()); holder.switch_battery_level.setText(text); if (holder.buttonSetStatus != null) { @@ -1478,11 +1478,11 @@ public void onClick(View v) { } Picasso.get().load(DomoticzIcons.getDrawableIcon(mDeviceInfo.getTypeImg(), - mDeviceInfo.getType(), - mDeviceInfo.getSwitchType(), - mDeviceInfo.getStatusBoolean(), - mDeviceInfo.getUseCustomImage(), - mDeviceInfo.getImage())).into(holder.iconRow); + mDeviceInfo.getType(), + mDeviceInfo.getSwitchType(), + mDeviceInfo.getStatusBoolean(), + mDeviceInfo.getUseCustomImage(), + mDeviceInfo.getImage())).into(holder.iconRow); } /** diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/TemperatureAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/TemperatureAdapter.java index 813ff3974..9d8d9d9fb 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Adapters/TemperatureAdapter.java +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/TemperatureAdapter.java @@ -131,7 +131,7 @@ public Filter getFilter() { @Override public DataObjectHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()) - .inflate(R.layout.temperature_row_default, parent, false); + .inflate(R.layout.temperature_row_default, parent, false); if (mSharedPrefs.darkThemeEnabled()) { if ((view.findViewById(R.id.card_global_wrapper)) != null) @@ -171,20 +171,20 @@ public void onClick(View v) { int modeIconRes = 0; if ((!UsefulBits.isEmpty(sign) && sign.equals("C") && mTemperatureInfo.getTemperature() < 0) || - (!UsefulBits.isEmpty(sign) && sign.equals("F") && mTemperatureInfo.getTemperature() < 30)) { + (!UsefulBits.isEmpty(sign) && sign.equals("F") && mTemperatureInfo.getTemperature() < 30)) { Picasso.get().load(DomoticzIcons.getDrawableIcon(mTemperatureInfo.getTypeImg(), - mTemperatureInfo.getType(), - null, - mConfigInfo != null && mTemperatureInfo.getTemperature() > mConfigInfo.getDegreeDaysBaseTemperature(), - true, - "Freezing")).into(holder.iconRow); + mTemperatureInfo.getType(), + null, + mConfigInfo != null && mTemperatureInfo.getTemperature() > mConfigInfo.getDegreeDaysBaseTemperature(), + true, + "Freezing")).into(holder.iconRow); } else { Picasso.get().load(DomoticzIcons.getDrawableIcon(mTemperatureInfo.getTypeImg(), - mTemperatureInfo.getType(), - null, - mConfigInfo != null && mTemperatureInfo.getTemperature() > mConfigInfo.getDegreeDaysBaseTemperature(), - false, - null)).into(holder.iconRow); + mTemperatureInfo.getType(), + null, + mConfigInfo != null && mTemperatureInfo.getTemperature() > mConfigInfo.getDegreeDaysBaseTemperature(), + false, + null)).into(holder.iconRow); } if (!UsefulBits.isEmpty(mTemperatureInfo.getHardwareName()) && mTemperatureInfo.getHardwareName().equalsIgnoreCase(DomoticzValues.Device.Hardware.EVOHOME)) { @@ -204,7 +204,7 @@ public void onClick(View v) { holder.pieView.setPercentageTextSize(16); if ((!UsefulBits.isEmpty(sign) && sign.equals("C") && mTemperatureInfo.getTemperature() < 0) || - (!UsefulBits.isEmpty(sign) && sign.equals("F") && mTemperatureInfo.getTemperature() < 30)) + (!UsefulBits.isEmpty(sign) && sign.equals("F") && mTemperatureInfo.getTemperature() < 30)) holder.pieView.setPercentageBackgroundColor(ContextCompat.getColor(context, R.color.material_blue_600)); else holder.pieView.setPercentageBackgroundColor(ContextCompat.getColor(context, R.color.material_orange_600)); @@ -298,7 +298,7 @@ public void unLiked(LikeButton likeButton) { holder.data.setText(R.string.wind); holder.data.append(": " + mTemperatureInfo.getData() + " " + mTemperatureInfo.getDirection()); holder.data2.setText(String.format("%s: %s", context.getString(R.string.last_update), UsefulBits.getFormattedDate(context, - mTemperatureInfo.getLastUpdateDateTime().getTime()))); + mTemperatureInfo.getLastUpdateDateTime().getTime()))); holder.data2.setVisibility(View.VISIBLE); } else { double temperature = mTemperatureInfo.getTemperature(); @@ -306,7 +306,7 @@ public void unLiked(LikeButton likeButton) { if (temperature <= 0 || setPoint <= 0) { holder.data.setText(String.format("%s: %s", context.getString(R.string.temperature), mTemperatureInfo.getData())); holder.data2.setText(String.format("%s: %s", context.getString(R.string.last_update), UsefulBits.getFormattedDate(context, - mTemperatureInfo.getLastUpdateDateTime().getTime()))); + mTemperatureInfo.getLastUpdateDateTime().getTime()))); holder.data2.setVisibility(View.VISIBLE); } else { holder.data.setText(String.format("%s: %s %s", context.getString(R.string.temperature), mTemperatureInfo.getTemperature(), sign)); diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/TemperatureWidgetAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/TemperatureWidgetAdapter.java index 40db07bfc..8e654eba2 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Adapters/TemperatureWidgetAdapter.java +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/TemperatureWidgetAdapter.java @@ -32,22 +32,16 @@ import android.widget.ImageView; import android.widget.TextView; -import com.squareup.picasso.Picasso; - import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import androidx.core.content.ContextCompat; -import az.plainpie.animation.PieAngleAnimation; import nl.hnogames.domoticz.R; import nl.hnogames.domoticz.Utils.SharedPrefUtil; -import nl.hnogames.domoticz.Utils.UsefulBits; import nl.hnogames.domoticzapi.Containers.ConfigInfo; -import nl.hnogames.domoticzapi.Containers.DevicesInfo; import nl.hnogames.domoticzapi.Containers.TemperatureInfo; import nl.hnogames.domoticzapi.Domoticz; -import nl.hnogames.domoticzapi.DomoticzIcons; import nl.hnogames.domoticzapi.Utils.ServerUtil; public class TemperatureWidgetAdapter extends BaseAdapter implements Filterable { diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/TimersAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/TimersAdapter.java index 616fe1c3f..33a1885b8 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Adapters/TimersAdapter.java +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/TimersAdapter.java @@ -170,19 +170,19 @@ else if (mSwitchTimerInfo.getType() == 27) if (mSwitchTimerInfo.getDate() != null && mSwitchTimerInfo.getDate().length() > 0) holder.switch_name.setText(String.format("%s | %s", - holder.switch_name.getText(), mSwitchTimerInfo.getDate())); + holder.switch_name.getText(), mSwitchTimerInfo.getDate())); else if (mSwitchTimerInfo.getMonthDay() > 0) days = String.format("%s %d", context.getString(R.string.button_status_day).toLowerCase(), mSwitchTimerInfo.getMonthDay()); else { if (mSwitchTimerInfo.getDays() == 128) holder.switch_name.setText(String.format("%s | %s", - holder.switch_name.getText(), context.getString(R.string.timer_every_days))); + holder.switch_name.getText(), context.getString(R.string.timer_every_days))); else if (mSwitchTimerInfo.getDays() == 512) holder.switch_name.setText(String.format("%s | %s", - holder.switch_name.getText(), context.getString(R.string.timer_weekend))); + holder.switch_name.getText(), context.getString(R.string.timer_weekend))); else if (mSwitchTimerInfo.getDays() == 256) holder.switch_name.setText(String.format("%s | %s", - holder.switch_name.getText(), context.getString(R.string.timer_working_days))); + holder.switch_name.getText(), context.getString(R.string.timer_working_days))); if (mSwitchTimerInfo.getOccurence() > 0) { if (mSwitchTimerInfo.getOccurence() == 1) @@ -216,9 +216,9 @@ else if (mSwitchTimerInfo.getOccurence() == 5) if (!UsefulBits.isEmpty(occurence) || !UsefulBits.isEmpty(days) || !UsefulBits.isEmpty(month)) holder.switch_name.setText(String.format("%s | %s %s %s", - holder.switch_name.getText(), occurence != null ? occurence.toLowerCase() : null, - days != null ? days.toLowerCase() : null, - month != null ? month.toLowerCase() : null)); + holder.switch_name.getText(), occurence != null ? occurence.toLowerCase() : null, + days != null ? days.toLowerCase() : null, + month != null ? month.toLowerCase() : null)); else holder.switch_name.setText(String.format("%s", holder.switch_name.getText().toString().toLowerCase())); if (mSwitchTimerInfo.getRandomness()) diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/UserVariablesAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/UserVariablesAdapter.java index 28c33ed45..b843eb8d2 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Adapters/UserVariablesAdapter.java +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/UserVariablesAdapter.java @@ -83,7 +83,7 @@ public Filter getFilter() { @Override public DataObjectHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()) - .inflate(R.layout.vars_row_default, parent, false); + .inflate(R.layout.vars_row_default, parent, false); if (mSharedPrefs.darkThemeEnabled()) { if ((view.findViewById(R.id.card_global_wrapper)) != null) @@ -135,7 +135,7 @@ public interface onClickListener { public static class DataObjectHolder extends RecyclerView.ViewHolder - implements View.OnClickListener { + implements View.OnClickListener { TextView name; TextView datetime; TextView message; diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/UtilityAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/UtilityAdapter.java index fda1aef84..04238b00e 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Adapters/UtilityAdapter.java +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/UtilityAdapter.java @@ -122,7 +122,7 @@ public Filter getFilter() { @Override public DataObjectHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()) - .inflate(R.layout.utilities_row_default, parent, false); + .inflate(R.layout.utilities_row_default, parent, false); if (mSharedPrefs.darkThemeEnabled()) { if ((view.findViewById(R.id.card_global_wrapper)) != null) @@ -151,7 +151,7 @@ public void onBindViewHolder(final DataObjectHolder holder, final int position) final double setPoint = mUtilitiesInfo.getSetPoint(); if ((mUtilitiesInfo.getType() != null && DomoticzValues.Device.Utility.Type.THERMOSTAT.equalsIgnoreCase(mUtilitiesInfo.getType())) || - (mUtilitiesInfo.getSubType() != null && DomoticzValues.Device.Utility.SubType.SMARTWARES.equalsIgnoreCase(mUtilitiesInfo.getSubType()))) { + (mUtilitiesInfo.getSubType() != null && DomoticzValues.Device.Utility.SubType.SMARTWARES.equalsIgnoreCase(mUtilitiesInfo.getSubType()))) { setButtons(holder, Buttons.THERMOSTAT); CreateThermostatRow(holder, mUtilitiesInfo, setPoint); } else { @@ -271,7 +271,7 @@ private void CreateDefaultRow(DataObjectHolder holder, UtilitiesInfo mUtilitiesI if (mUtilitiesInfo.getCounterToday() != null && mUtilitiesInfo.getCounterToday().length() > 0) holder.data.append(" " + context.getString(R.string.today) + ": " + mUtilitiesInfo.getCounterToday()); if (mUtilitiesInfo.getCounter() != null && mUtilitiesInfo.getCounter().length() > 0 && - !mUtilitiesInfo.getCounter().equals(mUtilitiesInfo.getData())) + !mUtilitiesInfo.getCounter().equals(mUtilitiesInfo.getData())) holder.data.append(" " + context.getString(R.string.total) + ": " + mUtilitiesInfo.getCounter()); holder.dayButton.setId(mUtilitiesInfo.getIdx()); @@ -386,13 +386,13 @@ public void onClick(View v) { }); if (mUtilitiesInfo.getSubType() - .replace("Electric", "counter") - .replace("kWh", "counter") - .replace("Gas", "counter") - .replace("Energy", "counter") - .replace("Voltcraft", "counter") - .replace("SetPoint", "temp") - .replace("YouLess counter", "counter").contains("counter")) + .replace("Electric", "counter") + .replace("kWh", "counter") + .replace("Gas", "counter") + .replace("Energy", "counter") + .replace("Voltcraft", "counter") + .replace("SetPoint", "temp") + .replace("YouLess counter", "counter").contains("counter")) holder.weekButton.setVisibility(View.VISIBLE); holder.yearButton.setId(mUtilitiesInfo.getIdx()); diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/WeatherAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/WeatherAdapter.java index 4bbd61f35..06ba41020 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Adapters/WeatherAdapter.java +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/WeatherAdapter.java @@ -131,7 +131,7 @@ public Filter getFilter() { @Override public DataObjectHolder onCreateViewHolder(ViewGroup parent, int viewType) { View view = LayoutInflater.from(parent.getContext()) - .inflate(R.layout.weather_row_default, parent, false); + .inflate(R.layout.weather_row_default, parent, false); if (mSharedPrefs.darkThemeEnabled()) { if ((view.findViewById(R.id.card_global_wrapper)) != null) diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/WidgetsAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/WidgetsAdapter.java index 77a464e94..94030f546 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Adapters/WidgetsAdapter.java +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/WidgetsAdapter.java @@ -139,11 +139,11 @@ private void setDefaultRowData(DevicesInfo mDeviceInfo, try { String text = context.getString(R.string.last_update) + ": " + - mDeviceInfo.getLastUpdate().substring(mDeviceInfo.getLastUpdate().indexOf(" ") + 1); + mDeviceInfo.getLastUpdate().substring(mDeviceInfo.getLastUpdate().indexOf(" ") + 1); if (holder.signal_level != null) holder.signal_level.setText(text); text = context.getString(R.string.data) + ": " + - mDeviceInfo.getData(); + mDeviceInfo.getData(); if (holder.switch_battery_level != null) holder.switch_battery_level.setText(text); if (mDeviceInfo.getUsage() != null && mDeviceInfo.getUsage().length() > 0) @@ -151,7 +151,7 @@ private void setDefaultRowData(DevicesInfo mDeviceInfo, if (mDeviceInfo.getCounterToday() != null && mDeviceInfo.getCounterToday().length() > 0) holder.switch_battery_level.append(" " + context.getString(R.string.today) + ": " + mDeviceInfo.getCounterToday()); if (mDeviceInfo.getCounter() != null && mDeviceInfo.getCounter().length() > 0 && - !mDeviceInfo.getCounter().equals(mDeviceInfo.getData())) + !mDeviceInfo.getCounter().equals(mDeviceInfo.getData())) holder.switch_battery_level.append(" " + context.getString(R.string.total) + ": " + mDeviceInfo.getCounter()); } catch (Exception ex) { holder.switch_battery_level.setText(""); @@ -164,11 +164,11 @@ private void setDefaultRowData(DevicesInfo mDeviceInfo, Picasso.get().load(R.drawable.qrcode).into(holder.iconRow); } else { Picasso.get().load(DomoticzIcons.getDrawableIcon(mDeviceInfo.getTypeImg(), - mDeviceInfo.getType(), - mDeviceInfo.getSubType(), - mDeviceInfo.getStatusBoolean(), - mDeviceInfo.getUseCustomImage(), - mDeviceInfo.getImage())).into(holder.iconRow); + mDeviceInfo.getType(), + mDeviceInfo.getSubType(), + mDeviceInfo.getStatusBoolean(), + mDeviceInfo.getUseCustomImage(), + mDeviceInfo.getImage())).into(holder.iconRow); } holder.iconRow.setAlpha(1f); diff --git a/app/src/main/java/nl/hnogames/domoticz/BluetoothSettingsActivity.java b/app/src/main/java/nl/hnogames/domoticz/BluetoothSettingsActivity.java index 963f5480e..adcd472bd 100644 --- a/app/src/main/java/nl/hnogames/domoticz/BluetoothSettingsActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/BluetoothSettingsActivity.java @@ -115,33 +115,33 @@ private void showPairedDevices() { } new AlertDialog.Builder(this) - .setSingleChoiceItems(items, 0, null) - .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int whichButton) { - dialog.dismiss(); - int position = ((AlertDialog) dialog).getListView().getCheckedItemPosition(); - final String Bluetooth_ID = bluetoothDevices.get(position); - - boolean newTagFound = true; - if (BluetoothList != null && BluetoothList.size() > 0) { - for (BluetoothInfo n : BluetoothList) { - if (n.getId().equals(Bluetooth_ID)) - newTagFound = false; - } + .setSingleChoiceItems(items, 0, null) + .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int whichButton) { + dialog.dismiss(); + int position = ((AlertDialog) dialog).getListView().getCheckedItemPosition(); + final String Bluetooth_ID = bluetoothDevices.get(position); + + boolean newTagFound = true; + if (BluetoothList != null && BluetoothList.size() > 0) { + for (BluetoothInfo n : BluetoothList) { + if (n.getId().equals(Bluetooth_ID)) + newTagFound = false; } + } - if (newTagFound) { - UsefulBits.showSnackbar(BluetoothSettingsActivity.this, coordinatorLayout, getString(R.string.bluetooth_saved) + ": " + Bluetooth_ID, Snackbar.LENGTH_SHORT); - BluetoothInfo BluetoothInfo = new BluetoothInfo(); - BluetoothInfo.setId(Bluetooth_ID); - BluetoothInfo.setName(String.valueOf(Bluetooth_ID)); - updateBluetooth(BluetoothInfo); - } else { - UsefulBits.showSnackbar(BluetoothSettingsActivity.this, coordinatorLayout, R.string.bluetooth_exists, Snackbar.LENGTH_SHORT); - } + if (newTagFound) { + UsefulBits.showSnackbar(BluetoothSettingsActivity.this, coordinatorLayout, getString(R.string.bluetooth_saved) + ": " + Bluetooth_ID, Snackbar.LENGTH_SHORT); + BluetoothInfo BluetoothInfo = new BluetoothInfo(); + BluetoothInfo.setId(Bluetooth_ID); + BluetoothInfo.setName(String.valueOf(Bluetooth_ID)); + updateBluetooth(BluetoothInfo); + } else { + UsefulBits.showSnackbar(BluetoothSettingsActivity.this, coordinatorLayout, R.string.bluetooth_exists, Snackbar.LENGTH_SHORT); } - }) - .show(); + } + }) + .show(); } private void createListView() { @@ -184,19 +184,19 @@ public void onReceiveDevice(DevicesInfo mDevicesInfo) { @DebugLog public void onError(Exception error) { UsefulBits.showSnackbarWithAction(BluetoothSettingsActivity.this, coordinatorLayout, BluetoothSettingsActivity.this.getString(R.string.unable_to_get_switches), Snackbar.LENGTH_SHORT, - null, new View.OnClickListener() { - @Override - public void onClick(View v) { - getSwitchesAndShowSwitchesDialog(qrInfo); - } - }, BluetoothSettingsActivity.this.getString(R.string.retry)); + null, new View.OnClickListener() { + @Override + public void onClick(View v) { + getSwitchesAndShowSwitchesDialog(qrInfo); + } + }, BluetoothSettingsActivity.this.getString(R.string.retry)); } }, 0, "all"); } private void showSwitchesDialog( - final BluetoothInfo BluetoothInfo, - final ArrayList switches) { + final BluetoothInfo BluetoothInfo, + final ArrayList switches) { final ArrayList supportedSwitches = new ArrayList<>(); for (DevicesInfo d : switches) { @@ -205,9 +205,9 @@ private void showSwitchesDialog( } SwitchDialog infoDialog = new SwitchDialog( - BluetoothSettingsActivity.this, supportedSwitches, - R.layout.dialog_switch_logs, - domoticz); + BluetoothSettingsActivity.this, supportedSwitches, + R.layout.dialog_switch_logs, + domoticz); infoDialog.onDismissListener(new SwitchDialog.DismissListener() { @Override @@ -237,16 +237,16 @@ public void onDismiss(int selectedSwitchIDX, String selectedSwitchPassword, Stri private void showSelectorDialog(final BluetoothInfo BluetoothInfo, DevicesInfo selector) { final ArrayList levelNames = selector.getLevelNames(); new MaterialDialog.Builder(this) - .title(R.string.selector_value) - .items(levelNames) - .itemsCallback(new MaterialDialog.ListCallback() { - @Override - public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { - BluetoothInfo.setValue(String.valueOf(text)); - updateBluetooth(BluetoothInfo); - } - }) - .show(); + .title(R.string.selector_value) + .items(levelNames) + .itemsCallback(new MaterialDialog.ListCallback() { + @Override + public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { + BluetoothInfo.setValue(String.valueOf(text)); + updateBluetooth(BluetoothInfo); + } + }) + .show(); } public void updateBluetooth(BluetoothInfo BluetoothInfo) { @@ -272,21 +272,21 @@ public void updateBluetooth(BluetoothInfo BluetoothInfo) { private boolean showNoDeviceAttachedDialog(final BluetoothInfo BluetoothInfo) { new MaterialDialog.Builder(this) - .title(R.string.noSwitchSelected_title) - .content(getString(R.string.noSwitchSelected_explanation_bluetooth) - + UsefulBits.newLine() - + UsefulBits.newLine() - + getString(R.string.noSwitchSelected_connectOneNow)) - .positiveText(R.string.yes) - .negativeText(R.string.no) - .onPositive(new MaterialDialog.SingleButtonCallback() { - @Override - public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { - getSwitchesAndShowSwitchesDialog(BluetoothInfo); - result = true; - } - }) - .show(); + .title(R.string.noSwitchSelected_title) + .content(getString(R.string.noSwitchSelected_explanation_bluetooth) + + UsefulBits.newLine() + + UsefulBits.newLine() + + getString(R.string.noSwitchSelected_connectOneNow)) + .positiveText(R.string.yes) + .negativeText(R.string.no) + .onPositive(new MaterialDialog.SingleButtonCallback() { + @Override + public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { + getSwitchesAndShowSwitchesDialog(BluetoothInfo); + result = true; + } + }) + .show(); return result; } @@ -313,7 +313,7 @@ private void showRemoveUndoSnackbar(final BluetoothInfo BluetoothInfo) { // Show snackbar with undo option String text = String.format(getString(R.string.something_deleted), - getString(R.string.bluetooth)); + getString(R.string.bluetooth)); UsefulBits.showSnackbarWithAction(this, coordinatorLayout, text, Snackbar.LENGTH_SHORT, new Snackbar.Callback() { @Override diff --git a/app/src/main/java/nl/hnogames/domoticz/CameraActivity.java b/app/src/main/java/nl/hnogames/domoticz/CameraActivity.java index a71b47075..540ec3236 100644 --- a/app/src/main/java/nl/hnogames/domoticz/CameraActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/CameraActivity.java @@ -55,7 +55,7 @@ protected void onCreate(Bundle savedInstanceState) { if (getSupportActionBar() != null) getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportFragmentManager().beginTransaction().replace(android.R.id.content, - camera).commit(); + camera).commit(); camera.setImage(imageUrl); } } diff --git a/app/src/main/java/nl/hnogames/domoticz/Containers/LocationInfo.java b/app/src/main/java/nl/hnogames/domoticz/Containers/LocationInfo.java index 58573c4fe..36ad6e917 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Containers/LocationInfo.java +++ b/app/src/main/java/nl/hnogames/domoticz/Containers/LocationInfo.java @@ -131,23 +131,23 @@ public Geofence toGeofence() { try { // Build a new Geofence object. return new Geofence.Builder() - // Set the request ID of the geofence. This is a string to identify this - // geofence. - .setRequestId(String.valueOf(id)) - // Set the circular region of this geofence. - .setCircularRegion( - latLng.latitude, latLng.longitude, radius - ) - // Set the expiration duration of the geofence. This geofence gets automatically - // removed after this period of time. - .setExpirationDuration(Geofence.NEVER_EXPIRE) - // Set the transition types of interest. Alerts are only generated for these - // transition. We track entry and exit transitions in this sample. - .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_DWELL | - Geofence.GEOFENCE_TRANSITION_EXIT) - .setLoiteringDelay(3000) - // Create the geofence. - .build(); + // Set the request ID of the geofence. This is a string to identify this + // geofence. + .setRequestId(String.valueOf(id)) + // Set the circular region of this geofence. + .setCircularRegion( + latLng.latitude, latLng.longitude, radius + ) + // Set the expiration duration of the geofence. This geofence gets automatically + // removed after this period of time. + .setExpirationDuration(Geofence.NEVER_EXPIRE) + // Set the transition types of interest. Alerts are only generated for these + // transition. We track entry and exit transitions in this sample. + .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_DWELL | + Geofence.GEOFENCE_TRANSITION_EXIT) + .setLoiteringDelay(3000) + // Create the geofence. + .build(); } catch (Exception ex) { // Wrong LocationInfo data detected return null; diff --git a/app/src/main/java/nl/hnogames/domoticz/Fragments/Camera.java b/app/src/main/java/nl/hnogames/domoticz/Fragments/Camera.java index cbf2cfc32..f642da53c 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Fragments/Camera.java +++ b/app/src/main/java/nl/hnogames/domoticz/Fragments/Camera.java @@ -64,8 +64,8 @@ public View onCreateView(LayoutInflater inflater, root = group.findViewById(R.id.image); root.getController().getSettings() - .setFitMethod(Settings.Fit.VERTICAL) - .setFillViewport(false); + .setFitMethod(Settings.Fit.VERTICAL) + .setFillViewport(false); FloatingActionButton fabButton = group.findViewById(R.id.fab); fabButton.setOnClickListener(new View.OnClickListener() { @@ -112,10 +112,10 @@ public void setImage(String url) { File file = new File(url); Uri uri = Uri.fromFile(file); Picasso.get() - .load(uri) - .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE) - .networkPolicy(NetworkPolicy.NO_CACHE) - .into(root); + .load(uri) + .memoryPolicy(MemoryPolicy.NO_CACHE, MemoryPolicy.NO_STORE) + .networkPolicy(NetworkPolicy.NO_CACHE) + .into(root); } } } \ No newline at end of file diff --git a/app/src/main/java/nl/hnogames/domoticz/Fragments/Cameras.java b/app/src/main/java/nl/hnogames/domoticz/Fragments/Cameras.java index 2834fec3a..7f1d07ac8 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Fragments/Cameras.java +++ b/app/src/main/java/nl/hnogames/domoticz/Fragments/Cameras.java @@ -217,7 +217,7 @@ public void onItemClick(int position, View v) { if (mItemTouchHelper == null) { mItemTouchHelper = new ItemTouchHelper(new RVHItemTouchHelperCallback(mAdapter, true, false, - false)); + false)); } if (mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { mItemTouchHelper.attachToRecyclerView(mRecyclerView); @@ -247,7 +247,7 @@ public void onPermissionDeclined(@NonNull String[] permissionName) { } } AlertDialog alert = PermissionsUtil.getAlertDialog(getActivity(), permissionFragmentHelper, getActivity().getString(R.string.permission_title), - getActivity().getString(R.string.permission_desc_storage), neededPermission); + getActivity().getString(R.string.permission_desc_storage), neededPermission); if (!alert.isShowing()) { alert.show(); } diff --git a/app/src/main/java/nl/hnogames/domoticz/Fragments/Dashboard.java b/app/src/main/java/nl/hnogames/domoticz/Fragments/Dashboard.java index 69e455756..fc957fafd 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Fragments/Dashboard.java +++ b/app/src/main/java/nl/hnogames/domoticz/Fragments/Dashboard.java @@ -77,7 +77,7 @@ @DebugLog public class Dashboard extends DomoticzDashboardFragment implements DomoticzFragmentListener, - switchesClickListener { + switchesClickListener { public static final String PERMANENT_OVERRIDE = "PermanentOverride"; public static final String AUTO = "Auto"; @@ -141,12 +141,12 @@ public void Filter(String text) { try { if (adapter != null) { if (UsefulBits.isEmpty(text) && - (UsefulBits.isEmpty(planName) || planName.length() <= 0) && - (UsefulBits.isEmpty(super.getSort()) || super.getSort().equals(mContext.getString(R.string.filterOn_all))) && - mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { + (UsefulBits.isEmpty(planName) || planName.length() <= 0) && + (UsefulBits.isEmpty(super.getSort()) || super.getSort().equals(mContext.getString(R.string.filterOn_all))) && + mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { if (mItemTouchHelper == null) { mItemTouchHelper = new ItemTouchHelper(new RVHItemTouchHelperCallback(adapter, true, false, - false)); + false)); } mItemTouchHelper.attachToRecyclerView(gridView); } else { @@ -219,8 +219,8 @@ private void processDevices(ArrayList devicesInfos) { String switchType = mExtendedStatusInfo.getSwitchType(); if (!name.startsWith(Domoticz.HIDDEN_CHARACTER) && - (appSupportedSwitchesValues.contains(switchTypeVal) && appSupportedSwitchesNames.contains(switchType)) || - UsefulBits.isEmpty(switchType)) { + (appSupportedSwitchesValues.contains(switchTypeVal) && appSupportedSwitchesNames.contains(switchType)) || + UsefulBits.isEmpty(switchType)) { if (UsefulBits.isEmpty(super.getSort()) || super.getSort().equals(mContext.getString(R.string.filterOn_all))) { supportedSwitches.add(mExtendedStatusInfo); } else { @@ -229,15 +229,15 @@ private void processDevices(ArrayList devicesInfos) { if (getActivity() instanceof MainActivity) ((MainActivity) getActivity()).Talk(mContext.getString(R.string.filter_on) + ": " + super.getSort()); if ((super.getSort().equals(mContext.getString(R.string.filterOn_on)) && mExtendedStatusInfo.getStatusBoolean()) && - mDomoticz.isOnOffSwitch(mExtendedStatusInfo)) { + mDomoticz.isOnOffSwitch(mExtendedStatusInfo)) { supportedSwitches.add(mExtendedStatusInfo); } if ((super.getSort().equals(mContext.getString(R.string.filterOn_off)) && !mExtendedStatusInfo.getStatusBoolean()) && - mDomoticz.isOnOffSwitch(mExtendedStatusInfo)) { + mDomoticz.isOnOffSwitch(mExtendedStatusInfo)) { supportedSwitches.add(mExtendedStatusInfo); } if (super.getSort().equals(mContext.getString(R.string.filterOn_static)) && - !mDomoticz.isOnOffSwitch(mExtendedStatusInfo)) { + !mDomoticz.isOnOffSwitch(mExtendedStatusInfo)) { supportedSwitches.add(mExtendedStatusInfo); } } @@ -313,11 +313,11 @@ private void createListView(ArrayList switches, SunRiseInfo sunrise if (mItemTouchHelper == null) { mItemTouchHelper = new ItemTouchHelper(new RVHItemTouchHelperCallback(adapter, true, false, - false)); + false)); } if ((UsefulBits.isEmpty(planName) || planName.length() <= 0) && - (UsefulBits.isEmpty(super.getSort()) || super.getSort().equals(mContext.getString(R.string.filterOn_all))) && - mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { + (UsefulBits.isEmpty(super.getSort()) || super.getSort().equals(mContext.getString(R.string.filterOn_all))) && + mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { mItemTouchHelper.attachToRecyclerView(gridView); } else { if (mItemTouchHelper != null) @@ -345,10 +345,10 @@ public void onRefresh() { private void showInfoDialog(final DevicesInfo mSwitch, int idx) { if (mSwitch != null) { DeviceInfoDialog infoDialog = new DeviceInfoDialog( - mContext, - mDomoticz, - mSwitch, - R.layout.dialog_switch_info); + mContext, + mDomoticz, + mSwitch, + R.layout.dialog_switch_info); infoDialog.setIdx(String.valueOf(mSwitch.getIdx())); try { if (mSwitch != null && !UsefulBits.isEmpty(mSwitch.getSubType())) @@ -444,7 +444,7 @@ public void onSwitchClick(int idx, final boolean checked) { final DevicesInfo clickedSwitch = getDevice(idx); if (clickedSwitch.isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( - mContext, mDomoticz); + mContext, mDomoticz); passwordDialog.show(); passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { @Override @@ -492,8 +492,8 @@ private void toggleSwitch(final DevicesInfo clickedSwitch, final boolean checked if (checked) jsonAction = DomoticzValues.Scene.Action.ON; else jsonAction = DomoticzValues.Scene.Action.OFF; } else if (clickedSwitch.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDS || - clickedSwitch.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDPERCENTAGE || - clickedSwitch.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.DOORLOCKINVERTED) { + clickedSwitch.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDPERCENTAGE || + clickedSwitch.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.DOORLOCKINVERTED) { if (checked) jsonAction = DomoticzValues.Device.Switch.Action.OFF; else jsonAction = DomoticzValues.Device.Switch.Action.ON; } else { @@ -561,7 +561,7 @@ public void onButtonClick(int idx, final boolean checked) { final DevicesInfo clickedSwitch = getDevice(idx); if (clickedSwitch.isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( - mContext, mDomoticz); + mContext, mDomoticz); passwordDialog.show(); passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { @Override @@ -667,14 +667,14 @@ public void onColorButtonClick(final int idx) { if (getDevice(idx).getSubType().contains(DomoticzValues.Device.SubType.Name.WW) && getDevice(idx).getSubType().contains(DomoticzValues.Device.SubType.Name.RGB)) { RGBWWColorPickerDialog colorDialog = new RGBWWColorPickerDialog(mContext, - getDevice(idx).getIdx()); + getDevice(idx).getIdx()); colorDialog.show(); colorDialog.onDismissListener(new RGBWWColorPickerDialog.DismissListener() { @Override public void onDismiss(final int value, final boolean isRGB) { if (getDevice(idx).isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( - mContext, mDomoticz); + mContext, mDomoticz); passwordDialog.show(); passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { @Override @@ -712,14 +712,14 @@ public void onChangeKelvinColor(int kelvin) { }); } else if (getDevice(idx).getSubType().startsWith(DomoticzValues.Device.SubType.Name.WW)) { WWColorPickerDialog colorDialog = new WWColorPickerDialog(mContext, - getDevice(idx).getIdx()); + getDevice(idx).getIdx()); colorDialog.show(); colorDialog.onDismissListener(new WWColorPickerDialog.DismissListener() { @Override public void onDismiss(final int kelvin) { if (getDevice(idx).isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( - mContext, mDomoticz); + mContext, mDomoticz); passwordDialog.show(); passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { @Override @@ -750,7 +750,7 @@ public void onChangeColor(int kelvin) { public void onColorSelected(final ColorEnvelope envelope, boolean fromUser) { if (getDevice(idx).isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( - mContext, mDomoticz); + mContext, mDomoticz); passwordDialog.show(); passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { @Override @@ -789,43 +789,43 @@ private void setKelvinColor(int kelvin, final int idx, final String password, fi } mDomoticz.setAction(idx, - DomoticzValues.Json.Url.Set.KELVIN, - DomoticzValues.Device.Dimmer.Action.KELVIN, - kelvin, - password, - new setCommandReceiver() { - @Override - @DebugLog - public void onReceiveResult(String result) { - if (result.contains("WRONG CODE")) { - UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.security_wrong_code, Snackbar.LENGTH_SHORT); + DomoticzValues.Json.Url.Set.KELVIN, + DomoticzValues.Device.Dimmer.Action.KELVIN, + kelvin, + password, + new setCommandReceiver() { + @Override + @DebugLog + public void onReceiveResult(String result) { + if (result.contains("WRONG CODE")) { + UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.security_wrong_code, Snackbar.LENGTH_SHORT); + if (getActivity() instanceof MainActivity) + ((MainActivity) getActivity()).Talk(R.string.security_wrong_code); + } else { + if (selected) { + UsefulBits.showSnackbar(mContext, coordinatorLayout, mContext.getString(R.string.color_set) + ": " + getDevice(idx).getName(), Snackbar.LENGTH_SHORT); if (getActivity() instanceof MainActivity) - ((MainActivity) getActivity()).Talk(R.string.security_wrong_code); - } else { - if (selected) { - UsefulBits.showSnackbar(mContext, coordinatorLayout, mContext.getString(R.string.color_set) + ": " + getDevice(idx).getName(), Snackbar.LENGTH_SHORT); - if (getActivity() instanceof MainActivity) - ((MainActivity) getActivity()).Talk(R.string.color_set); - } + ((MainActivity) getActivity()).Talk(R.string.color_set); } } + } - @Override - @DebugLog - public void onError(Exception error) { - if (selected) { - if (!UsefulBits.isEmpty(password)) { - UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.security_wrong_code, Snackbar.LENGTH_SHORT); - if (getActivity() instanceof MainActivity) - ((MainActivity) getActivity()).Talk(R.string.security_wrong_code); - } else { - UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.error_color, Snackbar.LENGTH_SHORT); - if (getActivity() instanceof MainActivity) - ((MainActivity) getActivity()).Talk(R.string.error_color); - } + @Override + @DebugLog + public void onError(Exception error) { + if (selected) { + if (!UsefulBits.isEmpty(password)) { + UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.security_wrong_code, Snackbar.LENGTH_SHORT); + if (getActivity() instanceof MainActivity) + ((MainActivity) getActivity()).Talk(R.string.security_wrong_code); + } else { + UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.error_color, Snackbar.LENGTH_SHORT); + if (getActivity() instanceof MainActivity) + ((MainActivity) getActivity()).Talk(R.string.error_color); } } - }); + } + }); } private void setRGBColor(int selectedColor, final int idx, final String password, final boolean selected) { @@ -854,38 +854,38 @@ private void setRGBColor(int selectedColor, final int idx, final String password isWhite = true; } mDomoticz.setRGBColorAction(idx, - DomoticzValues.Json.Url.Set.RGBCOLOR, - hue, - getDevice(idx).getLevel(), - isWhite, - password, - new setCommandReceiver() { - @Override - @DebugLog - public void onReceiveResult(String result) { - if (selected) { - UsefulBits.showSnackbar(mContext, coordinatorLayout, mContext.getString(R.string.color_set) + ": " + getDevice(idx).getName(), Snackbar.LENGTH_SHORT); - if (getActivity() instanceof MainActivity) - ((MainActivity) getActivity()).Talk(R.string.color_set); - } + DomoticzValues.Json.Url.Set.RGBCOLOR, + hue, + getDevice(idx).getLevel(), + isWhite, + password, + new setCommandReceiver() { + @Override + @DebugLog + public void onReceiveResult(String result) { + if (selected) { + UsefulBits.showSnackbar(mContext, coordinatorLayout, mContext.getString(R.string.color_set) + ": " + getDevice(idx).getName(), Snackbar.LENGTH_SHORT); + if (getActivity() instanceof MainActivity) + ((MainActivity) getActivity()).Talk(R.string.color_set); } + } - @Override - @DebugLog - public void onError(Exception error) { - if (selected) { - if (!UsefulBits.isEmpty(password)) { - UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.security_wrong_code, Snackbar.LENGTH_SHORT); - if (getActivity() instanceof MainActivity) - ((MainActivity) getActivity()).Talk(R.string.security_wrong_code); - } else { - UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.error_color, Snackbar.LENGTH_SHORT); - if (getActivity() instanceof MainActivity) - ((MainActivity) getActivity()).Talk(R.string.error_color); - } + @Override + @DebugLog + public void onError(Exception error) { + if (selected) { + if (!UsefulBits.isEmpty(password)) { + UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.security_wrong_code, Snackbar.LENGTH_SHORT); + if (getActivity() instanceof MainActivity) + ((MainActivity) getActivity()).Talk(R.string.security_wrong_code); + } else { + UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.error_color, Snackbar.LENGTH_SHORT); + if (getActivity() instanceof MainActivity) + ((MainActivity) getActivity()).Talk(R.string.error_color); } } - }); + } + }); } @Override @@ -916,8 +916,8 @@ public void onThermostatClick(final int idx) { if (tempUtil != null) { TemperatureDialog tempDialog = new TemperatureDialog( - mContext, - tempUtil.getSetPoint()); + mContext, + tempUtil.getSetPoint()); tempDialog.onDismissListener(new TemperatureDialog.DialogActionListener() { @Override @@ -927,7 +927,7 @@ public void onDialogAction(final double newSetPoint, DialogAction dialogAction) if (dialogAction == DialogAction.POSITIVE) { if (tempUtil.isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( - mContext, mDomoticz); + mContext, mDomoticz); passwordDialog.show(); passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { @Override @@ -938,28 +938,28 @@ public void onDismiss(final String password) { if (newSetPoint < tempUtil.getSetPoint()) action = DomoticzValues.Device.Thermostat.Action.MIN; mDomoticz.setAction(idx, jsonUrl, action, newSetPoint, password, - new setCommandReceiver() { - @Override - @DebugLog - public void onReceiveResult(String result) { - if (result.contains("WRONG CODE")) { - UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.security_wrong_code, Snackbar.LENGTH_SHORT); - if (getActivity() instanceof MainActivity) - ((MainActivity) getActivity()).Talk(R.string.security_wrong_code); - } else { - successHandling(result, false); - processDashboard(); - } - } - - @Override - @DebugLog - public void onError(Exception error) { + new setCommandReceiver() { + @Override + @DebugLog + public void onReceiveResult(String result) { + if (result.contains("WRONG CODE")) { UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.security_wrong_code, Snackbar.LENGTH_SHORT); if (getActivity() instanceof MainActivity) ((MainActivity) getActivity()).Talk(R.string.security_wrong_code); + } else { + successHandling(result, false); + processDashboard(); } - }); + } + + @Override + @DebugLog + public void onError(Exception error) { + UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.security_wrong_code, Snackbar.LENGTH_SHORT); + if (getActivity() instanceof MainActivity) + ((MainActivity) getActivity()).Talk(R.string.security_wrong_code); + } + }); } @Override @@ -972,26 +972,26 @@ public void onCancel() { if (newSetPoint < tempUtil.getSetPoint()) action = DomoticzValues.Device.Thermostat.Action.MIN; mDomoticz.setAction(idx, jsonUrl, action, newSetPoint, null, - new setCommandReceiver() { - @Override - @DebugLog - public void onReceiveResult(String result) { - if (result.contains("WRONG CODE")) { - UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.security_wrong_code, Snackbar.LENGTH_SHORT); - if (getActivity() instanceof MainActivity) - ((MainActivity) getActivity()).Talk(R.string.security_wrong_code); - } else { - successHandling(result, false); - processDashboard(); - } + new setCommandReceiver() { + @Override + @DebugLog + public void onReceiveResult(String result) { + if (result.contains("WRONG CODE")) { + UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.security_wrong_code, Snackbar.LENGTH_SHORT); + if (getActivity() instanceof MainActivity) + ((MainActivity) getActivity()).Talk(R.string.security_wrong_code); + } else { + successHandling(result, false); + processDashboard(); } - - @Override - @DebugLog - public void onError(Exception error) { - errorHandling(error, coordinatorLayout); - } - }); + } + + @Override + @DebugLog + public void onError(Exception error) { + errorHandling(error, coordinatorLayout); + } + }); } } } @@ -1036,13 +1036,13 @@ public void onError(Exception error) { TemperatureDialog tempDialog; if (evohomeZone) { tempDialog = new ScheduledTemperatureDialog( - mContext, - tempUtil.getSetPoint(), - !AUTO.equalsIgnoreCase(tempUtil.getStatus())); + mContext, + tempUtil.getSetPoint(), + !AUTO.equalsIgnoreCase(tempUtil.getStatus())); } else { tempDialog = new TemperatureDialog( - mContext, - tempUtil.getSetPoint()); + mContext, + tempUtil.getSetPoint()); } tempDialog.onDismissListener(new TemperatureDialog.DialogActionListener() { @@ -1053,7 +1053,7 @@ public void onDialogAction(double newSetPoint, DialogAction dialogAction) { addDebugText("Set idx " + idx + " to " + newSetPoint); String params = "&setpoint=" + newSetPoint + - "&mode=" + PERMANENT_OVERRIDE; + "&mode=" + PERMANENT_OVERRIDE; // add query parameters mDomoticz.setDeviceUsed(idx, tempUtil.getName(), tempUtil.getDescription(), params, commandReceiver); @@ -1061,7 +1061,7 @@ public void onDialogAction(double newSetPoint, DialogAction dialogAction) { addDebugText("Set idx " + idx + " to Auto"); String params = "&setpoint=" + newSetPoint + - "&mode=" + AUTO; + "&mode=" + AUTO; // add query parameters mDomoticz.setDeviceUsed(idx, tempUtil.getName(), tempUtil.getDescription(), params, commandReceiver); @@ -1079,8 +1079,8 @@ public void onDialogAction(double newSetPoint, DialogAction dialogAction) { @DebugLog public void onSecurityPanelButtonClick(int idx) { SecurityPanelDialog securityDialog = new SecurityPanelDialog( - mContext, mDomoticz, - getDevice(idx)); + mContext, mDomoticz, + getDevice(idx)); securityDialog.show(); securityDialog.onDismissListener(new SecurityPanelDialog.DismissListener() { @Override @@ -1105,32 +1105,32 @@ public void onStateButtonClick(final int idx, int itemsRes, final int[] stateIds } new MaterialDialog.Builder(mContext) - .title(R.string.choose_status) - .items(itemsRes) - .itemsCallback(new MaterialDialog.ListCallback() { - @Override - @DebugLog - public void onSelection(MaterialDialog dialog, View view, final int which, CharSequence text) { - if (getDevice(idx).isProtected()) { - PasswordDialog passwordDialog = new PasswordDialog( - mContext, mDomoticz); - passwordDialog.show(); - passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { - @Override - @DebugLog - public void onDismiss(String password) { - setState(idx, stateIds[which], password); - } + .title(R.string.choose_status) + .items(itemsRes) + .itemsCallback(new MaterialDialog.ListCallback() { + @Override + @DebugLog + public void onSelection(MaterialDialog dialog, View view, final int which, CharSequence text) { + if (getDevice(idx).isProtected()) { + PasswordDialog passwordDialog = new PasswordDialog( + mContext, mDomoticz); + passwordDialog.show(); + passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { + @Override + @DebugLog + public void onDismiss(String password) { + setState(idx, stateIds[which], password); + } - @Override - public void onCancel() { - } - }); - } else - setState(idx, stateIds[which], null); - } - }) - .show(); + @Override + public void onCancel() { + } + }); + } else + setState(idx, stateIds[which], null); + } + }) + .show(); } @Override @@ -1146,20 +1146,20 @@ public void onSelectorDimmerClick(final int idx, final String[] levelNames) { return; } new MaterialDialog.Builder(mContext) - .title(R.string.choose_status) - .items(levelNames) - .itemsCallback(new MaterialDialog.ListCallback() { - @Override - @DebugLog - public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { - for (int i = 0; i < levelNames.length; i++) { - if (levelNames[i].equals(text)) { - onDimmerChange(idx, i * 10, true); - } + .title(R.string.choose_status) + .items(levelNames) + .itemsCallback(new MaterialDialog.ListCallback() { + @Override + @DebugLog + public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { + for (int i = 0; i < levelNames.length; i++) { + if (levelNames[i].equals(text)) { + onDimmerChange(idx, i * 10, true); } } - }) - .show(); + } + }) + .show(); } @Override @@ -1190,30 +1190,30 @@ private void setState(final int idx, int state, final String password) { return; } mDomoticz.setModalAction(idx, - state, - 1, - password, - new setCommandReceiver() { - @Override - @DebugLog - public void onReceiveResult(String result) { - UsefulBits.showSnackbar(mContext, coordinatorLayout, mContext.getString(R.string.state_set) + ": " + getSwitch(idx).getName(), Snackbar.LENGTH_SHORT); - if (getActivity() instanceof MainActivity) - ((MainActivity) getActivity()).Talk(R.string.state_set); - processDashboard(); - } + state, + 1, + password, + new setCommandReceiver() { + @Override + @DebugLog + public void onReceiveResult(String result) { + UsefulBits.showSnackbar(mContext, coordinatorLayout, mContext.getString(R.string.state_set) + ": " + getSwitch(idx).getName(), Snackbar.LENGTH_SHORT); + if (getActivity() instanceof MainActivity) + ((MainActivity) getActivity()).Talk(R.string.state_set); + processDashboard(); + } - @Override - @DebugLog - public void onError(Exception error) { - if (!UsefulBits.isEmpty(password)) { - UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.security_wrong_code, Snackbar.LENGTH_SHORT); - if (getActivity() instanceof MainActivity) - ((MainActivity) getActivity()).Talk(R.string.security_wrong_code); - } else - errorHandling(error, coordinatorLayout); - } - }); + @Override + @DebugLog + public void onError(Exception error) { + if (!UsefulBits.isEmpty(password)) { + UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.security_wrong_code, Snackbar.LENGTH_SHORT); + if (getActivity() instanceof MainActivity) + ((MainActivity) getActivity()).Talk(R.string.security_wrong_code); + } else + errorHandling(error, coordinatorLayout); + } + }); } private DevicesInfo getSwitch(int idx) { @@ -1237,7 +1237,7 @@ public void onBlindClick(final int idx, final int jsonAction) { final DevicesInfo clickedSwitch = getDevice(idx); if (clickedSwitch.isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( - mContext, mDomoticz); + mContext, mDomoticz); passwordDialog.show(); passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { @Override @@ -1354,7 +1354,7 @@ public void onDimmerChange(int idx, final int value, final boolean selector) { final DevicesInfo clickedSwitch = getDevice(idx); if (clickedSwitch.isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( - mContext, mDomoticz); + mContext, mDomoticz); passwordDialog.show(); passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { @Override @@ -1385,8 +1385,8 @@ private void setDimmerState(DevicesInfo clickedSwitch, int value, final boolean return; } String text = String.format(mContext.getString(R.string.set_level_switch), - clickedSwitch.getName(), - !selector ? (value - 1) : ((value) / 10) + 1); + clickedSwitch.getName(), + !selector ? (value - 1) : ((value) / 10) + 1); UsefulBits.showSnackbar(mContext, coordinatorLayout, text, Snackbar.LENGTH_SHORT); if (getActivity() instanceof MainActivity) ((MainActivity) getActivity()).Talk(text); diff --git a/app/src/main/java/nl/hnogames/domoticz/Fragments/Graph.java b/app/src/main/java/nl/hnogames/domoticz/Fragments/Graph.java index d6b5c37fc..3f396b1b0 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Fragments/Graph.java +++ b/app/src/main/java/nl/hnogames/domoticz/Fragments/Graph.java @@ -471,7 +471,7 @@ private LineData generateData(View view) { } if ((addTemperature && !enableFilters) || - (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_temperature)).getText().toString()))) { + (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_temperature)).getText().toString()))) { LineDataSet dataSet = new LineDataSet(valuest, ((TextView) view.findViewById(R.id.legend_temperature)).getText().toString()); // add entries to dataset dataSet.setColor(ContextCompat.getColor(context, R.color.material_blue_600)); dataSet.setDrawCircles(false); @@ -479,7 +479,7 @@ private LineData generateData(View view) { entries.add(dataSet); if ((addSetpoint && !enableFilters) || - (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_set_point)).getText().toString()))) { + (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_set_point)).getText().toString()))) { dataSet = new LineDataSet(valuesse, ((TextView) view.findViewById(R.id.legend_set_point)).getText().toString()); // add entries to dataset dataSet.setColor(ContextCompat.getColor(context, R.color.material_pink_600)); dataSet.setDrawCircles(false); @@ -508,7 +508,7 @@ private LineData generateData(View view) { } if ((addHumidity && !enableFilters) || - (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_humidity)).getText().toString()))) { + (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_humidity)).getText().toString()))) { LineDataSet dataSet = new LineDataSet(valueshu, ((TextView) view.findViewById(R.id.legend_humidity)).getText().toString()); // add entries to dataset dataSet.setColor(ContextCompat.getColor(context, R.color.material_orange_600)); dataSet.setDrawCircles(false); @@ -517,7 +517,7 @@ private LineData generateData(View view) { } if ((addBarometer && !enableFilters) || - (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_barometer)).getText().toString()))) { + (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_barometer)).getText().toString()))) { LineDataSet dataSet = new LineDataSet(valuesba, ((TextView) view.findViewById(R.id.legend_barometer)).getText().toString()); // add entries to dataset dataSet.setColor(ContextCompat.getColor(context, R.color.material_green_600)); dataSet.setDrawCircles(false); @@ -526,7 +526,7 @@ private LineData generateData(View view) { } if ((addCounter && !enableFilters) || - (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_counter)).getText().toString()))) { + (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_counter)).getText().toString()))) { LineDataSet dataSet = new LineDataSet(valuesc, ((TextView) view.findViewById(R.id.legend_counter)).getText().toString()); // add entries to dataset dataSet.setColor(ContextCompat.getColor(context, R.color.material_indigo_600)); dataSet.setDrawCircles(false); @@ -535,7 +535,7 @@ private LineData generateData(View view) { } if ((addPowerUsage && !enableFilters) || - (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_powerusage)).getText().toString()))) { + (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_powerusage)).getText().toString()))) { LineDataSet dataSet = new LineDataSet(valueeu, ((TextView) view.findViewById(R.id.legend_powerusage)).getText().toString()); // add entries to dataset dataSet.setColor(ContextCompat.getColor(context, R.color.material_yellow_600)); dataSet.setDrawCircles(false); @@ -543,7 +543,7 @@ private LineData generateData(View view) { entries.add(dataSet); } if ((addPowerDelivery && !enableFilters) || - (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_powerdeliv)).getText().toString()))) { + (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_powerdeliv)).getText().toString()))) { LineDataSet dataSet = new LineDataSet(valueeg, ((TextView) view.findViewById(R.id.legend_powerdeliv)).getText().toString()); // add entries to dataset dataSet.setColor(ContextCompat.getColor(context, R.color.material_deep_purple_600)); dataSet.setDrawCircles(false); @@ -552,7 +552,7 @@ private LineData generateData(View view) { } if ((addPercentage && !enableFilters) || - (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_percentage)).getText().toString()))) { + (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_percentage)).getText().toString()))) { LineDataSet dataSet = new LineDataSet(valuesv, ((TextView) view.findViewById(R.id.legend_percentage)).getText().toString()); // add entries to dataset dataSet.setColor(ContextCompat.getColor(context, R.color.material_yellow_600)); dataSet.setDrawCircles(false); @@ -580,7 +580,7 @@ private LineData generateData(View view) { } if ((addSecondPercentage && !enableFilters) || - (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_percentage2)).getText().toString()))) { + (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_percentage2)).getText().toString()))) { LineDataSet dataSet = new LineDataSet(valuesv2, ((TextView) view.findViewById(R.id.legend_percentage2)).getText().toString()); // add entries to dataset dataSet.setColor(ContextCompat.getColor(context, R.color.material_orange_600)); dataSet.setDrawCircles(false); @@ -589,7 +589,7 @@ private LineData generateData(View view) { } if ((addDirection && !enableFilters) || - (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_direction)).getText().toString()))) { + (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_direction)).getText().toString()))) { LineDataSet dataSet = new LineDataSet(valuesdi, ((TextView) view.findViewById(R.id.legend_direction)).getText().toString()); // add entries to dataset dataSet.setColor(ContextCompat.getColor(context, R.color.material_green_600)); dataSet.setDrawCircles(false); @@ -598,7 +598,7 @@ private LineData generateData(View view) { } if ((addSunPower && !enableFilters) || - (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_sunpower)).getText().toString()))) { + (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_sunpower)).getText().toString()))) { LineDataSet dataSet = new LineDataSet(valuesuv, ((TextView) view.findViewById(R.id.legend_sunpower)).getText().toString()); // add entries to dataset dataSet.setColor(ContextCompat.getColor(context, R.color.material_deep_purple_600)); dataSet.setDrawCircles(false); @@ -607,7 +607,7 @@ private LineData generateData(View view) { } if ((addSpeed && !enableFilters) || - (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_speed)).getText().toString()))) { + (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_speed)).getText().toString()))) { LineDataSet dataSet = new LineDataSet(valuessp, ((TextView) view.findViewById(R.id.legend_speed)).getText().toString()); // add entries to dataset dataSet.setColor(ContextCompat.getColor(context, R.color.material_amber_600)); dataSet.setDrawCircles(false); @@ -616,7 +616,7 @@ private LineData generateData(View view) { } if ((addUsage && !enableFilters) || - (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_usage)).getText().toString()))) { + (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_usage)).getText().toString()))) { LineDataSet dataSet = new LineDataSet(valuesu, ((TextView) view.findViewById(R.id.legend_usage)).getText().toString()); // add entries to dataset dataSet.setColor(ContextCompat.getColor(context, R.color.material_orange_600)); dataSet.setDrawCircles(false); @@ -625,7 +625,7 @@ private LineData generateData(View view) { } if ((addRain && !enableFilters) || - (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_rain)).getText().toString()))) { + (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_rain)).getText().toString()))) { LineDataSet dataSet = new LineDataSet(valuesmm, ((TextView) view.findViewById(R.id.legend_rain)).getText().toString()); // add entries to dataset dataSet.setColor(ContextCompat.getColor(context, R.color.material_light_green_600)); dataSet.setDrawCircles(false); @@ -634,7 +634,7 @@ private LineData generateData(View view) { } if ((addCO2 && !enableFilters) || - (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_co2)).getText().toString()))) { + (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_co2)).getText().toString()))) { LineDataSet dataSet = new LineDataSet(valuesco2, ((TextView) view.findViewById(R.id.legend_co2)).getText().toString()); // add entries to dataset dataSet.setColor(ContextCompat.getColor(context, R.color.material_blue_600)); dataSet.setDrawCircles(false); @@ -643,7 +643,7 @@ private LineData generateData(View view) { } if ((addCO2Min && !enableFilters) || - (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_co2min)).getText().toString()))) { + (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_co2min)).getText().toString()))) { LineDataSet dataSet = new LineDataSet(valuesco2min, ((TextView) view.findViewById(R.id.legend_co2min)).getText().toString()); // add entries to dataset dataSet.setColor(ContextCompat.getColor(context, R.color.material_light_green_600)); dataSet.setDrawCircles(false); @@ -652,7 +652,7 @@ private LineData generateData(View view) { } if ((addCO2Max && !enableFilters) || - (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_co2max)).getText().toString()))) { + (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_co2max)).getText().toString()))) { LineDataSet dataSet = new LineDataSet(valuesco2max, ((TextView) view.findViewById(R.id.legend_co2max)).getText().toString()); // add entries to dataset dataSet.setColor(ContextCompat.getColor(context, R.color.md_red_400)); dataSet.setDrawCircles(false); @@ -661,7 +661,7 @@ private LineData generateData(View view) { } if ((addLux && !enableFilters) || - (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_Lux)).getText().toString()))) { + (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_Lux)).getText().toString()))) { LineDataSet dataSet = new LineDataSet(valuesLux, ((TextView) view.findViewById(R.id.legend_Lux)).getText().toString()); // add entries to dataset dataSet.setColor(ContextCompat.getColor(context, R.color.material_blue_600)); dataSet.setDrawCircles(false); @@ -670,7 +670,7 @@ private LineData generateData(View view) { } if ((addLuxMin && !enableFilters) || - (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_Luxmin)).getText().toString()))) { + (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_Luxmin)).getText().toString()))) { LineDataSet dataSet = new LineDataSet(valuesLuxmin, ((TextView) view.findViewById(R.id.legend_Luxmin)).getText().toString()); // add entries to dataset dataSet.setColor(ContextCompat.getColor(context, R.color.material_light_green_600)); dataSet.setDrawCircles(false); @@ -679,7 +679,7 @@ private LineData generateData(View view) { } if ((addLuxMax && !enableFilters) || - (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_Luxmax)).getText().toString()))) { + (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_Luxmax)).getText().toString()))) { LineDataSet dataSet = new LineDataSet(valuesLuxmax, ((TextView) view.findViewById(R.id.legend_Luxmax)).getText().toString()); // add entries to dataset dataSet.setColor(ContextCompat.getColor(context, R.color.md_red_400)); dataSet.setDrawCircles(false); @@ -688,7 +688,7 @@ private LineData generateData(View view) { } if ((addLuxAvg && !enableFilters) || - (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_LuxAvg)).getText().toString()))) { + (filterLabels != null && filterLabels.contains(((TextView) view.findViewById(R.id.legend_LuxAvg)).getText().toString()))) { LineDataSet dataSet = new LineDataSet(valuesLuxAvg, ((TextView) view.findViewById(R.id.legend_LuxAvg)).getText().toString()); // add entries to dataset dataSet.setColor(ContextCompat.getColor(context, R.color.md_yellow_400)); dataSet.setDrawCircles(false); @@ -699,10 +699,10 @@ private LineData generateData(View view) { if (entries.size() > 1) { if (addTemperature) { (view.findViewById(R.id.legend_temperature)) - .setVisibility(View.VISIBLE); + .setVisibility(View.VISIBLE); if (addSetpoint) { (view.findViewById(R.id.legend_set_point)) - .setVisibility(View.VISIBLE); + .setVisibility(View.VISIBLE); } addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_temperature)).getText()); @@ -711,116 +711,116 @@ private LineData generateData(View view) { if (addHumidity) { addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_humidity)).getText()); (view.findViewById(R.id.legend_humidity)) - .setVisibility(View.VISIBLE); + .setVisibility(View.VISIBLE); } if (addBarometer) { (view.findViewById(R.id.legend_barometer)) - .setVisibility(View.VISIBLE); + .setVisibility(View.VISIBLE); addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_barometer)).getText()); } if (addCounter) { (view.findViewById(R.id.legend_counter)) - .setVisibility(View.VISIBLE); + .setVisibility(View.VISIBLE); ((TextView) view.findViewById(R.id.legend_counter)) - .setText(axisYLabel); + .setText(axisYLabel); addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_counter)).getText()); } if (addPercentage) { (view.findViewById(R.id.legend_percentage)) - .setVisibility(View.VISIBLE); + .setVisibility(View.VISIBLE); addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_percentage)).getText()); } if (addSecondPercentage) { (view.findViewById(R.id.legend_percentage2)) - .setVisibility(View.VISIBLE); + .setVisibility(View.VISIBLE); addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_percentage2)).getText()); } if (addDirection) { (view.findViewById(R.id.legend_direction)) - .setVisibility(View.VISIBLE); + .setVisibility(View.VISIBLE); addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_direction)).getText()); } if (addSunPower) { (view.findViewById(R.id.legend_sunpower)) - .setVisibility(View.VISIBLE); + .setVisibility(View.VISIBLE); addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_sunpower)).getText()); } if (addSpeed) { (view.findViewById(R.id.legend_speed)) - .setVisibility(View.VISIBLE); + .setVisibility(View.VISIBLE); addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_speed)).getText()); } if (addUsage) { (view.findViewById(R.id.legend_usage)) - .setVisibility(View.VISIBLE); + .setVisibility(View.VISIBLE); addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_usage)).getText()); } if (addPowerDelivery) { (view.findViewById(R.id.legend_powerdeliv)) - .setVisibility(View.VISIBLE); + .setVisibility(View.VISIBLE); addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_powerdeliv)).getText()); } if (addPowerUsage) { (view.findViewById(R.id.legend_powerusage)) - .setVisibility(View.VISIBLE); + .setVisibility(View.VISIBLE); addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_powerusage)).getText()); } if (addRain) { (view.findViewById(R.id.legend_rain)) - .setVisibility(View.VISIBLE); + .setVisibility(View.VISIBLE); addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_rain)).getText()); } if (addCO2) { (view.findViewById(R.id.legend_co2)) - .setVisibility(View.VISIBLE); + .setVisibility(View.VISIBLE); addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_co2)).getText()); } if (addCO2Min) { (view.findViewById(R.id.legend_co2min)) - .setVisibility(View.VISIBLE); + .setVisibility(View.VISIBLE); addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_co2min)).getText()); } if (addCO2Max) { (view.findViewById(R.id.legend_co2max)) - .setVisibility(View.VISIBLE); + .setVisibility(View.VISIBLE); addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_co2max)).getText()); } if (addLux) { (view.findViewById(R.id.legend_Lux)) - .setVisibility(View.VISIBLE); + .setVisibility(View.VISIBLE); addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_Lux)).getText()); } if (addLuxMin) { (view.findViewById(R.id.legend_Luxmin)) - .setVisibility(View.VISIBLE); + .setVisibility(View.VISIBLE); addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_Luxmin)).getText()); } if (addLuxMax) { (view.findViewById(R.id.legend_Luxmax)) - .setVisibility(View.VISIBLE); + .setVisibility(View.VISIBLE); addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_Luxmax)).getText()); } if (addLuxAvg) { (view.findViewById(R.id.legend_LuxAvg)) - .setVisibility(View.VISIBLE); + .setVisibility(View.VISIBLE); addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_LuxAvg)).getText()); } } @@ -867,41 +867,41 @@ public boolean onOptionsItemSelected(MenuItem item) { lineLabels.toArray(items); new MaterialDialog.Builder(context) - .title(context.getString(R.string.filter)) - .items(items) - .itemsCallbackMultiChoice(selectedFilters, new MaterialDialog.ListCallbackMultiChoice() { - @Override - @DebugLog - public boolean onSelection(MaterialDialog dialog, Integer[] which, CharSequence[] text) { - selectedFilters = which; - enableFilters = true; - - if (text != null && text.length > 0) { - filterLabels = new ArrayList<>(); - - //set filters - for (CharSequence c : text) - filterLabels.add((String) c); - - LineData columnData = generateData(root); - if (columnData != null) { - chart.setData(columnData); - chart.invalidate(); // refresh - chart.setVisibility(View.VISIBLE); - chart.animateX(1000); - if (getActivity() != null) - getActivity().invalidateOptionsMenu(); - } - } else { - enableFilters = false; - Toast.makeText(context, context.getString(R.string.filter_graph_empty), Toast.LENGTH_SHORT).show(); + .title(context.getString(R.string.filter)) + .items(items) + .itemsCallbackMultiChoice(selectedFilters, new MaterialDialog.ListCallbackMultiChoice() { + @Override + @DebugLog + public boolean onSelection(MaterialDialog dialog, Integer[] which, CharSequence[] text) { + selectedFilters = which; + enableFilters = true; + + if (text != null && text.length > 0) { + filterLabels = new ArrayList<>(); + + //set filters + for (CharSequence c : text) + filterLabels.add((String) c); + + LineData columnData = generateData(root); + if (columnData != null) { + chart.setData(columnData); + chart.invalidate(); // refresh + chart.setVisibility(View.VISIBLE); + chart.animateX(1000); + if (getActivity() != null) + getActivity().invalidateOptionsMenu(); } - return true; + } else { + enableFilters = false; + Toast.makeText(context, context.getString(R.string.filter_graph_empty), Toast.LENGTH_SHORT).show(); } - }) - .positiveText(R.string.ok) - .negativeText(R.string.cancel) - .show(); + return true; + } + }) + .positiveText(R.string.ok) + .negativeText(R.string.cancel) + .show(); return true; default: break; diff --git a/app/src/main/java/nl/hnogames/domoticz/Fragments/MainPager.java b/app/src/main/java/nl/hnogames/domoticz/Fragments/MainPager.java index a2a2a4e90..ebe59ee21 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Fragments/MainPager.java +++ b/app/src/main/java/nl/hnogames/domoticz/Fragments/MainPager.java @@ -67,8 +67,8 @@ public void onCreate(Bundle savedInstanceState) { public void RefreshFragment() { try { Fragment f = (Fragment) vpPager - .getAdapter() - .instantiateItem(vpPager, vpPager.getCurrentItem()); + .getAdapter() + .instantiateItem(vpPager, vpPager.getCurrentItem()); if (f instanceof DomoticzRecyclerFragment) { ((DomoticzRecyclerFragment) f).refreshFragment(); ((DomoticzRecyclerFragment) f).showViews(); @@ -88,8 +88,8 @@ public void RefreshFragment() { public void Filter(String newText) { try { Fragment n = (Fragment) vpPager - .getAdapter() - .instantiateItem(vpPager, vpPager.getCurrentItem()); + .getAdapter() + .instantiateItem(vpPager, vpPager.getCurrentItem()); if (n instanceof DomoticzDashboardFragment) { ((DomoticzDashboardFragment) n).Filter(newText); } else if (n instanceof DomoticzRecyclerFragment) { @@ -105,8 +105,8 @@ public void Filter(String newText) { public void sortFragment(String selectedSort) { try { Fragment f = (Fragment) vpPager - .getAdapter() - .instantiateItem(vpPager, vpPager.getCurrentItem()); + .getAdapter() + .instantiateItem(vpPager, vpPager.getCurrentItem()); if (f instanceof DomoticzRecyclerFragment) { ((DomoticzRecyclerFragment) f).sortFragment(selectedSort); } else if (f instanceof DomoticzDashboardFragment) { diff --git a/app/src/main/java/nl/hnogames/domoticz/Fragments/Plans.java b/app/src/main/java/nl/hnogames/domoticz/Fragments/Plans.java index 7f1117d10..31c8ecd6d 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Fragments/Plans.java +++ b/app/src/main/java/nl/hnogames/domoticz/Fragments/Plans.java @@ -184,7 +184,7 @@ public void onItemClick(int position, View v) { if (mItemTouchHelper == null) { mItemTouchHelper = new ItemTouchHelper(new RVHItemTouchHelperCallback(mAdapter, true, false, - false)); + false)); } if (mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { mItemTouchHelper.attachToRecyclerView(mRecyclerView); diff --git a/app/src/main/java/nl/hnogames/domoticz/Fragments/Scenes.java b/app/src/main/java/nl/hnogames/domoticz/Fragments/Scenes.java index e519dc5ab..f6e60d9ae 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Fragments/Scenes.java +++ b/app/src/main/java/nl/hnogames/domoticz/Fragments/Scenes.java @@ -64,7 +64,7 @@ import nl.hnogames.domoticzapi.Utils.PhoneConnectionUtil; public class Scenes extends DomoticzRecyclerFragment implements DomoticzFragmentListener, - ScenesClickListener { + ScenesClickListener { @SuppressWarnings("unused") private static final String TAG = Scenes.class.getSimpleName(); @@ -119,11 +119,11 @@ public void Filter(String text) { try { if (adapter != null) { if (UsefulBits.isEmpty(text) && - (UsefulBits.isEmpty(super.getSort()) || super.getSort().equals(mContext.getString(R.string.filterOn_all))) && - mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { + (UsefulBits.isEmpty(super.getSort()) || super.getSort().equals(mContext.getString(R.string.filterOn_all))) && + mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { if (mItemTouchHelper == null) { mItemTouchHelper = new ItemTouchHelper(new RVHItemTouchHelperCallback(adapter, true, false, - false)); + false)); } mItemTouchHelper.attachToRecyclerView(gridView); } else { @@ -209,10 +209,10 @@ public void createListView(final ArrayList scenes) { if (mItemTouchHelper == null) { mItemTouchHelper = new ItemTouchHelper(new RVHItemTouchHelperCallback(adapter, true, false, - false)); + false)); } if ((UsefulBits.isEmpty(super.getSort()) || super.getSort().equals(mContext.getString(R.string.filterOn_all))) && - mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { + mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { mItemTouchHelper.attachToRecyclerView(gridView); } else { if (mItemTouchHelper != null) @@ -250,9 +250,9 @@ private SceneInfo getScene(int idx) { private void showInfoDialog(final SceneInfo mSceneInfo) { SceneInfoDialog infoDialog = new SceneInfoDialog( - getActivity(), - mSceneInfo, - R.layout.dialog_scene_info); + getActivity(), + mSceneInfo, + R.layout.dialog_scene_info); infoDialog.setIdx(String.valueOf(mSceneInfo.getIdx())); infoDialog.setLastUpdate(mSceneInfo.getLastUpdate()); infoDialog.setIsFavorite(mSceneInfo.getFavoriteBoolean()); @@ -322,7 +322,7 @@ public void onSceneClick(int idx, final boolean action) { final SceneInfo clickedScene = getScene(idx); if (clickedScene.isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( - getActivity(), mDomoticz); + getActivity(), mDomoticz); passwordDialog.show(); passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { @Override @@ -404,9 +404,9 @@ private void showLogDialog(ArrayList switchLogs) { Toast.makeText(getContext(), "No logs found.", Toast.LENGTH_LONG).show(); } else { SwitchLogInfoDialog infoDialog = new SwitchLogInfoDialog( - getActivity(), - switchLogs, - R.layout.dialog_switch_logs); + getActivity(), + switchLogs, + R.layout.dialog_switch_logs); infoDialog.show(); } } diff --git a/app/src/main/java/nl/hnogames/domoticz/Fragments/Switches.java b/app/src/main/java/nl/hnogames/domoticz/Fragments/Switches.java index 9b5cd0502..4e2b31654 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Fragments/Switches.java +++ b/app/src/main/java/nl/hnogames/domoticz/Fragments/Switches.java @@ -82,7 +82,7 @@ import nl.hnogames.domoticzapi.Utils.PhoneConnectionUtil; public class Switches extends DomoticzRecyclerFragment implements DomoticzFragmentListener, - switchesClickListener { + switchesClickListener { @SuppressWarnings("unused") private static final String TAG = Switches.class.getSimpleName(); @@ -146,11 +146,11 @@ public void Filter(String text) { try { if (adapter != null) { if (UsefulBits.isEmpty(text) && - (UsefulBits.isEmpty(super.getSort()) || super.getSort().equals(mContext.getString(R.string.filterOn_all))) && - mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { + (UsefulBits.isEmpty(super.getSort()) || super.getSort().equals(mContext.getString(R.string.filterOn_all))) && + mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { if (mItemTouchHelper == null) { mItemTouchHelper = new ItemTouchHelper(new RVHItemTouchHelperCallback(adapter, true, false, - false)); + false)); } mItemTouchHelper.attachToRecyclerView(gridView); } else { @@ -207,8 +207,8 @@ private void createListView(ArrayList switches) { String switchType = mDevicesInfo.getSwitchType(); if (!name.startsWith(Domoticz.HIDDEN_CHARACTER) && - appSupportedSwitchesValues.contains(switchTypeVal) && - appSupportedSwitchesNames.contains(switchType)) { + appSupportedSwitchesValues.contains(switchTypeVal) && + appSupportedSwitchesNames.contains(switchType)) { if (UsefulBits.isEmpty(super.getSort()) || super.getSort().equals(mContext.getString(R.string.filterOn_all))) { supportedSwitches.add(mDevicesInfo); } else { @@ -217,15 +217,15 @@ private void createListView(ArrayList switches) { if (getActivity() instanceof MainActivity) ((MainActivity) getActivity()).Talk(mContext.getString(R.string.filter_on) + ": " + super.getSort()); if ((super.getSort().equals(mContext.getString(R.string.filterOn_on)) && mDevicesInfo.getStatusBoolean()) && - mDomoticz.isOnOffSwitch(mDevicesInfo)) { + mDomoticz.isOnOffSwitch(mDevicesInfo)) { supportedSwitches.add(mDevicesInfo); } if ((super.getSort().equals(mContext.getString(R.string.filterOn_off)) && !mDevicesInfo.getStatusBoolean()) && - mDomoticz.isOnOffSwitch(mDevicesInfo)) { + mDomoticz.isOnOffSwitch(mDevicesInfo)) { supportedSwitches.add(mDevicesInfo); } if (super.getSort().equals(mContext.getString(R.string.filterOn_static)) && - !mDomoticz.isOnOffSwitch(mDevicesInfo)) { + !mDomoticz.isOnOffSwitch(mDevicesInfo)) { supportedSwitches.add(mDevicesInfo); } } @@ -246,10 +246,10 @@ private void createListView(ArrayList switches) { if (mItemTouchHelper == null) { mItemTouchHelper = new ItemTouchHelper(new RVHItemTouchHelperCallback(adapter, true, false, - false)); + false)); } if ((UsefulBits.isEmpty(super.getSort()) || super.getSort().equals(mContext.getString(R.string.filterOn_all))) && - mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { + mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { mItemTouchHelper.attachToRecyclerView(gridView); } else { if (mItemTouchHelper != null) @@ -281,10 +281,10 @@ public void onRefresh() { private void showInfoDialog(final DevicesInfo mSwitch) { SwitchInfoDialog infoDialog = new SwitchInfoDialog( - mContext, - mDomoticz, - mSwitch, - R.layout.dialog_switch_info); + mContext, + mDomoticz, + mSwitch, + R.layout.dialog_switch_info); infoDialog.setIdx(String.valueOf(mSwitch.getIdx())); infoDialog.setLastUpdate(mSwitch.getLastUpdate()); try { @@ -309,9 +309,9 @@ private void showLogDialog(ArrayList switchLogs) { Toast.makeText(mContext, "No logs found.", Toast.LENGTH_LONG).show(); } else { SwitchLogInfoDialog infoDialog = new SwitchLogInfoDialog( - mContext, - switchLogs, - R.layout.dialog_switch_logs); + mContext, + switchLogs, + R.layout.dialog_switch_logs); infoDialog.show(); } } @@ -321,9 +321,9 @@ private void showTimerDialog(ArrayList switchLogs) { Toast.makeText(mContext, "No timer found.", Toast.LENGTH_LONG).show(); } else { SwitchTimerInfoDialog infoDialog = new SwitchTimerInfoDialog( - mContext, - switchLogs, - R.layout.dialog_switch_logs); + mContext, + switchLogs, + R.layout.dialog_switch_logs); infoDialog.show(); } } @@ -333,8 +333,8 @@ private void showNotificationDialog(ArrayList notificationInfo Toast.makeText(mContext, "No notifications found.", Toast.LENGTH_LONG).show(); } else { NotificationInfoDialog infoDialog = new NotificationInfoDialog( - mContext, - notificationInfo); + mContext, + notificationInfo); infoDialog.show(); } } @@ -427,14 +427,14 @@ public void onLikeButtonClick(int idx, boolean checked) { public void onColorButtonClick(final int idx) { if (getSwitch(idx).getSubType().contains(DomoticzValues.Device.SubType.Name.WW) && getSwitch(idx).getSubType().contains(DomoticzValues.Device.SubType.Name.RGB)) { RGBWWColorPickerDialog colorDialog = new RGBWWColorPickerDialog(mContext, - getSwitch(idx).getIdx()); + getSwitch(idx).getIdx()); colorDialog.show(); colorDialog.onDismissListener(new RGBWWColorPickerDialog.DismissListener() { @Override public void onDismiss(final int value, final boolean isRGB) { if (getSwitch(idx).isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( - mContext, mDomoticz); + mContext, mDomoticz); passwordDialog.show(); passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { @Override @@ -472,14 +472,14 @@ public void onChangeKelvinColor(int kelvin) { }); } else if (getSwitch(idx).getSubType().startsWith(DomoticzValues.Device.SubType.Name.WW)) { WWColorPickerDialog colorDialog = new WWColorPickerDialog(mContext, - getSwitch(idx).getIdx()); + getSwitch(idx).getIdx()); colorDialog.show(); colorDialog.onDismissListener(new WWColorPickerDialog.DismissListener() { @Override public void onDismiss(final int kelvin) { if (getSwitch(idx).isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( - mContext, mDomoticz); + mContext, mDomoticz); passwordDialog.show(); passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { @Override @@ -510,7 +510,7 @@ public void onChangeColor(int kelvin) { public void onColorSelected(final ColorEnvelope envelope, boolean fromUser) { if (getSwitch(idx).isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( - mContext, mDomoticz); + mContext, mDomoticz); passwordDialog.show(); passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { @Override @@ -549,45 +549,45 @@ private void setKelvinColor(int kelvin, final int idx, final String password, fi } mDomoticz.setAction(idx, - DomoticzValues.Json.Url.Set.KELVIN, - DomoticzValues.Device.Dimmer.Action.KELVIN, - kelvin, - password, - new setCommandReceiver() { - @Override - @DebugLog - public void onReceiveResult(String result) { - if (result.contains("WRONG CODE")) { - UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.security_wrong_code, Snackbar.LENGTH_SHORT); + DomoticzValues.Json.Url.Set.KELVIN, + DomoticzValues.Device.Dimmer.Action.KELVIN, + kelvin, + password, + new setCommandReceiver() { + @Override + @DebugLog + public void onReceiveResult(String result) { + if (result.contains("WRONG CODE")) { + UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.security_wrong_code, Snackbar.LENGTH_SHORT); + if (getActivity() instanceof MainActivity) + ((MainActivity) getActivity()).Talk(R.string.security_wrong_code); + } else { + if (getSwitch(idx) == null) + return; + if (selected) { + UsefulBits.showSnackbar(mContext, coordinatorLayout, mContext.getString(R.string.color_set) + ": " + getSwitch(idx).getName(), Snackbar.LENGTH_SHORT); if (getActivity() instanceof MainActivity) - ((MainActivity) getActivity()).Talk(R.string.security_wrong_code); - } else { - if (getSwitch(idx) == null) - return; - if (selected) { - UsefulBits.showSnackbar(mContext, coordinatorLayout, mContext.getString(R.string.color_set) + ": " + getSwitch(idx).getName(), Snackbar.LENGTH_SHORT); - if (getActivity() instanceof MainActivity) - ((MainActivity) getActivity()).Talk(R.string.color_set); - } + ((MainActivity) getActivity()).Talk(R.string.color_set); } } + } - @Override - @DebugLog - public void onError(Exception error) { - if (selected) { - if (!UsefulBits.isEmpty(password)) { - UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.security_wrong_code, Snackbar.LENGTH_SHORT); - if (getActivity() instanceof MainActivity) - ((MainActivity) getActivity()).Talk(R.string.security_wrong_code); - } else { - UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.error_color, Snackbar.LENGTH_SHORT); - if (getActivity() instanceof MainActivity) - ((MainActivity) getActivity()).Talk(R.string.error_color); - } + @Override + @DebugLog + public void onError(Exception error) { + if (selected) { + if (!UsefulBits.isEmpty(password)) { + UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.security_wrong_code, Snackbar.LENGTH_SHORT); + if (getActivity() instanceof MainActivity) + ((MainActivity) getActivity()).Talk(R.string.security_wrong_code); + } else { + UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.error_color, Snackbar.LENGTH_SHORT); + if (getActivity() instanceof MainActivity) + ((MainActivity) getActivity()).Talk(R.string.error_color); } } - }); + } + }); } private void setRGBColor(int selectedColor, final int idx, final String password, final boolean selected) { @@ -606,40 +606,40 @@ private void setRGBColor(int selectedColor, final int idx, final String password isWhite = true; } mDomoticz.setRGBColorAction(idx, - DomoticzValues.Json.Url.Set.RGBCOLOR, - hue, - getSwitch(idx).getLevel(), - isWhite, - password, - new setCommandReceiver() { - @Override - @DebugLog - public void onReceiveResult(String result) { - if (getSwitch(idx) == null) - return; - if (selected) { - UsefulBits.showSnackbar(mContext, coordinatorLayout, mContext.getString(R.string.color_set) + ": " + getSwitch(idx).getName(), Snackbar.LENGTH_SHORT); - if (getActivity() instanceof MainActivity) - ((MainActivity) getActivity()).Talk(R.string.color_set); - } + DomoticzValues.Json.Url.Set.RGBCOLOR, + hue, + getSwitch(idx).getLevel(), + isWhite, + password, + new setCommandReceiver() { + @Override + @DebugLog + public void onReceiveResult(String result) { + if (getSwitch(idx) == null) + return; + if (selected) { + UsefulBits.showSnackbar(mContext, coordinatorLayout, mContext.getString(R.string.color_set) + ": " + getSwitch(idx).getName(), Snackbar.LENGTH_SHORT); + if (getActivity() instanceof MainActivity) + ((MainActivity) getActivity()).Talk(R.string.color_set); } + } - @Override - @DebugLog - public void onError(Exception error) { - if (selected) { - if (!UsefulBits.isEmpty(password)) { - UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.security_wrong_code, Snackbar.LENGTH_SHORT); - if (getActivity() instanceof MainActivity) - ((MainActivity) getActivity()).Talk(R.string.security_wrong_code); - } else { - UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.error_color, Snackbar.LENGTH_SHORT); - if (getActivity() instanceof MainActivity) - ((MainActivity) getActivity()).Talk(R.string.error_color); - } + @Override + @DebugLog + public void onError(Exception error) { + if (selected) { + if (!UsefulBits.isEmpty(password)) { + UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.security_wrong_code, Snackbar.LENGTH_SHORT); + if (getActivity() instanceof MainActivity) + ((MainActivity) getActivity()).Talk(R.string.security_wrong_code); + } else { + UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.error_color, Snackbar.LENGTH_SHORT); + if (getActivity() instanceof MainActivity) + ((MainActivity) getActivity()).Talk(R.string.error_color); } } - }); + } + }); } @Override @@ -698,8 +698,8 @@ public void onSetTemperatureClick(int idx) { @DebugLog public void onSecurityPanelButtonClick(int idx) { SecurityPanelDialog securityDialog = new SecurityPanelDialog( - mContext, mDomoticz, - getSwitch(idx)); + mContext, mDomoticz, + getSwitch(idx)); securityDialog.show(); securityDialog.onDismissListener(new SecurityPanelDialog.DismissListener() { @@ -715,52 +715,52 @@ public void onDismiss() { @DebugLog public void onStateButtonClick(final int idx, int itemsRes, final int[] stateIds) { new MaterialDialog.Builder(mContext) - .title(R.string.choose_status) - .items(itemsRes) - .itemsCallback(new MaterialDialog.ListCallback() { - @Override - @DebugLog - public void onSelection(MaterialDialog dialog, View view, final int which, CharSequence text) { - if (getSwitch(idx).isProtected()) { - PasswordDialog passwordDialog = new PasswordDialog( - mContext, mDomoticz); - passwordDialog.show(); - passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { - @Override - @DebugLog - public void onDismiss(String password) { - setState(idx, stateIds[which], password); - } + .title(R.string.choose_status) + .items(itemsRes) + .itemsCallback(new MaterialDialog.ListCallback() { + @Override + @DebugLog + public void onSelection(MaterialDialog dialog, View view, final int which, CharSequence text) { + if (getSwitch(idx).isProtected()) { + PasswordDialog passwordDialog = new PasswordDialog( + mContext, mDomoticz); + passwordDialog.show(); + passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { + @Override + @DebugLog + public void onDismiss(String password) { + setState(idx, stateIds[which], password); + } - @Override - public void onCancel() { - } - }); - } else - setState(idx, stateIds[which], null); - } - }) - .show(); + @Override + public void onCancel() { + } + }); + } else + setState(idx, stateIds[which], null); + } + }) + .show(); } @Override @DebugLog public void onSelectorDimmerClick(final int idx, final String[] levelNames) { new MaterialDialog.Builder(mContext) - .title(R.string.choose_status) - .items(levelNames) - .itemsCallback(new MaterialDialog.ListCallback() { - @Override - @DebugLog - public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { - for (int i = 0; i < levelNames.length; i++) { - if (levelNames[i].equals(text)) { - onDimmerChange(idx, i * 10, true); - } + .title(R.string.choose_status) + .items(levelNames) + .itemsCallback(new MaterialDialog.ListCallback() { + @Override + @DebugLog + public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { + for (int i = 0; i < levelNames.length; i++) { + if (levelNames[i].equals(text)) { + onDimmerChange(idx, i * 10, true); } } - }) - .show(); + } + }) + .show(); } @Override @@ -803,32 +803,32 @@ public boolean onItemLongClicked(int idx) { private void setState(final int idx, int state, final String password) { mDomoticz.setModalAction(idx, - state, - 1, - password, - new setCommandReceiver() { - @Override - @DebugLog - public void onReceiveResult(String result) { - if (getSwitch(idx) == null) - return; - UsefulBits.showSnackbar(mContext, coordinatorLayout, mContext.getString(R.string.state_set) + ": " + getSwitch(idx).getName(), Snackbar.LENGTH_SHORT); - if (getActivity() instanceof MainActivity) - ((MainActivity) getActivity()).Talk(R.string.state_set); - getSwitchesData(); - } + state, + 1, + password, + new setCommandReceiver() { + @Override + @DebugLog + public void onReceiveResult(String result) { + if (getSwitch(idx) == null) + return; + UsefulBits.showSnackbar(mContext, coordinatorLayout, mContext.getString(R.string.state_set) + ": " + getSwitch(idx).getName(), Snackbar.LENGTH_SHORT); + if (getActivity() instanceof MainActivity) + ((MainActivity) getActivity()).Talk(R.string.state_set); + getSwitchesData(); + } - @Override - @DebugLog - public void onError(Exception error) { - if (!UsefulBits.isEmpty(password)) { - UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.security_wrong_code, Snackbar.LENGTH_SHORT); - if (getActivity() instanceof MainActivity) - ((MainActivity) getActivity()).Talk(R.string.security_wrong_code); - } else - errorHandling(error); - } - }); + @Override + @DebugLog + public void onError(Exception error) { + if (!UsefulBits.isEmpty(password)) { + UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.security_wrong_code, Snackbar.LENGTH_SHORT); + if (getActivity() instanceof MainActivity) + ((MainActivity) getActivity()).Talk(R.string.security_wrong_code); + } else + errorHandling(error); + } + }); } private DevicesInfo getSwitch(int idx) { @@ -852,7 +852,7 @@ public void onSwitchClick(int idx, final boolean checked) { final DevicesInfo clickedSwitch = getSwitch(idx); if (clickedSwitch.isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( - mContext, mDomoticz); + mContext, mDomoticz); passwordDialog.show(); passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { @Override @@ -898,8 +898,8 @@ private void toggleSwitch(DevicesInfo clickedSwitch, boolean checked, final Stri if (checked) jsonAction = DomoticzValues.Scene.Action.ON; else jsonAction = DomoticzValues.Scene.Action.OFF; } else if (clickedSwitch.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDS || - clickedSwitch.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDPERCENTAGE || - clickedSwitch.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.DOORLOCKINVERTED) { + clickedSwitch.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDPERCENTAGE || + clickedSwitch.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.DOORLOCKINVERTED) { if (checked) jsonAction = DomoticzValues.Device.Switch.Action.OFF; else jsonAction = DomoticzValues.Device.Switch.Action.ON; } else { @@ -946,7 +946,7 @@ public void onButtonClick(int idx, final boolean checked) { final DevicesInfo clickedSwitch = getSwitch(idx); if (clickedSwitch.isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( - mContext, mDomoticz); + mContext, mDomoticz); passwordDialog.show(); passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { @Override @@ -1028,7 +1028,7 @@ public void onBlindClick(final int idx, final int jsonAction) { final DevicesInfo clickedSwitch = getSwitch(idx); if (clickedSwitch.isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( - mContext, mDomoticz); + mContext, mDomoticz); passwordDialog.show(); passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { @Override @@ -1122,7 +1122,7 @@ public void onDimmerChange(int idx, final int value, final boolean selector) { final DevicesInfo clickedSwitch = getSwitch(idx); if (clickedSwitch.isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( - mContext, mDomoticz); + mContext, mDomoticz); passwordDialog.show(); passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { @Override @@ -1152,8 +1152,8 @@ private void setDimmerState(DevicesInfo clickedSwitch, int value, final boolean return; } String text = String.format(mContext.getString(R.string.set_level_switch), - clickedSwitch.getName(), - !selector ? (value - 1) : ((value) / 10) + 1); + clickedSwitch.getName(), + !selector ? (value - 1) : ((value) / 10) + 1); UsefulBits.showSnackbar(mContext, coordinatorLayout, text, Snackbar.LENGTH_SHORT); if (getActivity() instanceof MainActivity) ((MainActivity) getActivity()).Talk(text); diff --git a/app/src/main/java/nl/hnogames/domoticz/Fragments/Temperature.java b/app/src/main/java/nl/hnogames/domoticz/Fragments/Temperature.java index b75fcfac7..c34a9e8a5 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Fragments/Temperature.java +++ b/app/src/main/java/nl/hnogames/domoticz/Fragments/Temperature.java @@ -113,11 +113,11 @@ public void Filter(String text) { try { if (adapter != null) { if (UsefulBits.isEmpty(text) && - (UsefulBits.isEmpty(super.getSort()) || super.getSort().equals(mContext.getString(R.string.filterOn_all))) && - mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { + (UsefulBits.isEmpty(super.getSort()) || super.getSort().equals(mContext.getString(R.string.filterOn_all))) && + mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { if (mItemTouchHelper == null) { mItemTouchHelper = new ItemTouchHelper(new RVHItemTouchHelperCallback(adapter, true, false, - false)); + false)); } mItemTouchHelper.attachToRecyclerView(gridView); } else { @@ -168,10 +168,10 @@ private void createListView(ArrayList mTemperatureInfos) { } if (mItemTouchHelper == null) { mItemTouchHelper = new ItemTouchHelper(new RVHItemTouchHelperCallback(adapter, true, false, - false)); + false)); } if ((UsefulBits.isEmpty(super.getSort()) || super.getSort().equals(mContext.getString(R.string.filterOn_all))) && - mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { + mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { mItemTouchHelper.attachToRecyclerView(gridView); } else { if (mItemTouchHelper != null) @@ -193,9 +193,9 @@ public void onRefresh() { private void showInfoDialog(final TemperatureInfo mTemperatureInfo) { TemperatureInfoDialog infoDialog = new TemperatureInfoDialog( - mContext, - mTemperatureInfo, - R.layout.dialog_utilities_info); + mContext, + mTemperatureInfo, + R.layout.dialog_utilities_info); infoDialog.setIdx(String.valueOf(mTemperatureInfo.getIdx())); infoDialog.setLastUpdate(mTemperatureInfo.getLastUpdate()); infoDialog.setIsFavorite(mTemperatureInfo.getFavoriteBoolean()); @@ -321,13 +321,13 @@ public void onError(Exception error) { TemperatureDialog tempDialog; if (evohomeZone) { tempDialog = new ScheduledTemperatureDialog( - mContext, - t.getSetPoint(), - !"auto".equalsIgnoreCase(t.getStatus())); + mContext, + t.getSetPoint(), + !"auto".equalsIgnoreCase(t.getStatus())); } else { tempDialog = new TemperatureDialog( - mContext, - t.getSetPoint()); + mContext, + t.getSetPoint()); } tempDialog.onDismissListener(new TemperatureDialog.DialogActionListener() { @@ -338,7 +338,7 @@ public void onDialogAction(double newSetPoint, DialogAction dialogAction) { addDebugText("Set idx " + idx + " to " + newSetPoint); String params = "&setpoint=" + newSetPoint + - "&mode=" + PERMANENT_OVERRIDE; + "&mode=" + PERMANENT_OVERRIDE; // add query parameters mDomoticz.setDeviceUsed(idx, t.getName(), t.getDescription(), params, commandReceiver); @@ -346,7 +346,7 @@ public void onDialogAction(double newSetPoint, DialogAction dialogAction) { addDebugText("Set idx " + idx + " to Auto"); String params = "&setpoint=" + newSetPoint + - "&mode=" + AUTO; + "&mode=" + AUTO; // add query parameters mDomoticz.setDeviceUsed(idx, t.getName(), t.getDescription(), params, commandReceiver); diff --git a/app/src/main/java/nl/hnogames/domoticz/Fragments/TemperatureMainPager.java b/app/src/main/java/nl/hnogames/domoticz/Fragments/TemperatureMainPager.java index f3fc7bca1..e01c35ceb 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Fragments/TemperatureMainPager.java +++ b/app/src/main/java/nl/hnogames/domoticz/Fragments/TemperatureMainPager.java @@ -67,8 +67,8 @@ public void onCreate(Bundle savedInstanceState) { public void RefreshFragment() { try { Fragment f = (Fragment) vpPager - .getAdapter() - .instantiateItem(vpPager, vpPager.getCurrentItem()); + .getAdapter() + .instantiateItem(vpPager, vpPager.getCurrentItem()); if (f instanceof DomoticzRecyclerFragment) { ((DomoticzRecyclerFragment) f).refreshFragment(); ((DomoticzRecyclerFragment) f).showViews(); @@ -88,8 +88,8 @@ public void RefreshFragment() { public void Filter(String newText) { try { Fragment n = (Fragment) vpPager - .getAdapter() - .instantiateItem(vpPager, vpPager.getCurrentItem()); + .getAdapter() + .instantiateItem(vpPager, vpPager.getCurrentItem()); if (n instanceof DomoticzDashboardFragment) { ((DomoticzDashboardFragment) n).Filter(newText); } else if (n instanceof DomoticzRecyclerFragment) { @@ -105,8 +105,8 @@ public void Filter(String newText) { public void sortFragment(String selectedSort) { try { Fragment f = (Fragment) vpPager - .getAdapter() - .instantiateItem(vpPager, vpPager.getCurrentItem()); + .getAdapter() + .instantiateItem(vpPager, vpPager.getCurrentItem()); if (f instanceof DomoticzRecyclerFragment) { ((DomoticzRecyclerFragment) f).sortFragment(selectedSort); } else if (f instanceof DomoticzDashboardFragment) { diff --git a/app/src/main/java/nl/hnogames/domoticz/Fragments/UserVariables.java b/app/src/main/java/nl/hnogames/domoticz/Fragments/UserVariables.java index fe43e0974..9ef9a496b 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Fragments/UserVariables.java +++ b/app/src/main/java/nl/hnogames/domoticz/Fragments/UserVariables.java @@ -160,19 +160,19 @@ public void onUserVariableClick(final UserVariableInfo clickedVar) { return; } new MaterialDialog.Builder(mContext) - .title(R.string.title_vars) - .content(clickedVar.getName() + " -> " + clickedVar.getTypeValue()) - .inputType(InputType.TYPE_CLASS_TEXT) - .input(null, clickedVar.getValue(), new MaterialDialog.InputCallback() { - @Override - public void onInput(MaterialDialog dialog, CharSequence input) { - if (validateInput(String.valueOf(input), clickedVar.getType())) { - updateUserVariable(String.valueOf(input), clickedVar); - } else { - UsefulBits.showSnackbar(mContext, coordinatorLayout, mContext.getString(R.string.var_input), Snackbar.LENGTH_SHORT); - } + .title(R.string.title_vars) + .content(clickedVar.getName() + " -> " + clickedVar.getTypeValue()) + .inputType(InputType.TYPE_CLASS_TEXT) + .input(null, clickedVar.getValue(), new MaterialDialog.InputCallback() { + @Override + public void onInput(MaterialDialog dialog, CharSequence input) { + if (validateInput(String.valueOf(input), clickedVar.getType())) { + updateUserVariable(String.valueOf(input), clickedVar); + } else { + UsefulBits.showSnackbar(mContext, coordinatorLayout, mContext.getString(R.string.var_input), Snackbar.LENGTH_SHORT); } - }).show(); + } + }).show(); } private boolean validateInput(String input, String type) { diff --git a/app/src/main/java/nl/hnogames/domoticz/Fragments/Utilities.java b/app/src/main/java/nl/hnogames/domoticz/Fragments/Utilities.java index c4916f4ab..ac452a359 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Fragments/Utilities.java +++ b/app/src/main/java/nl/hnogames/domoticz/Fragments/Utilities.java @@ -64,7 +64,7 @@ import nl.hnogames.domoticzapi.Utils.PhoneConnectionUtil; public class Utilities extends DomoticzRecyclerFragment implements DomoticzFragmentListener, - UtilityClickListener { + UtilityClickListener { private ArrayList mUtilitiesInfos; private double thermostatSetPointValue; @@ -113,11 +113,11 @@ public void Filter(String text) { try { if (adapter != null) { if (UsefulBits.isEmpty(text) && - (UsefulBits.isEmpty(super.getSort()) || super.getSort().equals(mContext.getString(R.string.filterOn_all))) && - mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { + (UsefulBits.isEmpty(super.getSort()) || super.getSort().equals(mContext.getString(R.string.filterOn_all))) && + mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { if (mItemTouchHelper == null) { mItemTouchHelper = new ItemTouchHelper(new RVHItemTouchHelperCallback(adapter, true, false, - false)); + false)); } mItemTouchHelper.attachToRecyclerView(gridView); } else { @@ -168,10 +168,10 @@ private void createListView() { } if (mItemTouchHelper == null) { mItemTouchHelper = new ItemTouchHelper(new RVHItemTouchHelperCallback(adapter, true, false, - false)); + false)); } if ((UsefulBits.isEmpty(super.getSort()) || super.getSort().equals(mContext.getString(R.string.filterOn_all))) && - mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { + mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { mItemTouchHelper.attachToRecyclerView(gridView); } else { if (mItemTouchHelper != null) @@ -194,9 +194,9 @@ public void onRefresh() { private void showInfoDialog(final UtilitiesInfo mUtilitiesInfo) { UtilitiesInfoDialog infoDialog = new UtilitiesInfoDialog( - mContext, - mUtilitiesInfo, - R.layout.dialog_utilities_info); + mContext, + mUtilitiesInfo, + R.layout.dialog_utilities_info); infoDialog.setIdx(String.valueOf(mUtilitiesInfo.getIdx())); infoDialog.setLastUpdate(mUtilitiesInfo.getLastUpdate()); infoDialog.setIsFavorite(mUtilitiesInfo.getFavoriteBoolean()); @@ -240,24 +240,24 @@ private void changeFavorite(final UtilitiesInfo mUtilitiesInfo, final boolean is else jsonAction = DomoticzValues.Device.Favorite.OFF; mDomoticz.setAction(mUtilitiesInfo.getIdx(), - jsonUrl, - jsonAction, - 0, - null, - new setCommandReceiver() { - @Override - @DebugLog - public void onReceiveResult(String result) { - successHandling(result, false); - mUtilitiesInfo.setFavoriteBoolean(isFavorite); - } + jsonUrl, + jsonAction, + 0, + null, + new setCommandReceiver() { + @Override + @DebugLog + public void onReceiveResult(String result) { + successHandling(result, false); + mUtilitiesInfo.setFavoriteBoolean(isFavorite); + } - @Override - @DebugLog - public void onError(Exception error) { - errorHandling(error); - } - }); + @Override + @DebugLog + public void onError(Exception error) { + errorHandling(error); + } + }); } /** @@ -326,20 +326,20 @@ public void onClick(UtilitiesInfo utility) { public void onLogClick(final UtilitiesInfo utility, final String range) { int steps = 2; String graphType = utility.getSubType() - .replace("Electric", "counter") - .replace("kWh", "counter") - .replace("Gas", "counter") - .replace("Energy", "counter") - .replace("Voltcraft", "counter") - .replace("Voltage", "counter") - .replace("SetPoint", "temp") - .replace("Lux", "counter") - .replace("BWR102", "counter") - .replace("Sound Level", "counter") - .replace("Managed Counter", "counter") - .replace("Pressure", "counter") - .replace("Custom Sensor", "Percentage") - .replace("YouLess counter", "counter"); + .replace("Electric", "counter") + .replace("kWh", "counter") + .replace("Gas", "counter") + .replace("Energy", "counter") + .replace("Voltcraft", "counter") + .replace("Voltage", "counter") + .replace("SetPoint", "temp") + .replace("Lux", "counter") + .replace("BWR102", "counter") + .replace("Sound Level", "counter") + .replace("Managed Counter", "counter") + .replace("Pressure", "counter") + .replace("Custom Sensor", "Percentage") + .replace("YouLess counter", "counter"); if (graphType.toLowerCase().contains("counter")) graphType = "counter"; @@ -371,8 +371,8 @@ public void onThermostatClick(final int idx) { final UtilitiesInfo tempUtil = getUtility(idx); TemperatureDialog tempDialog = new TemperatureDialog( - mContext, - tempUtil.getSetPoint()); + mContext, + tempUtil.getSetPoint()); tempDialog.onDismissListener(new TemperatureDialog.DialogActionListener() { @Override @@ -383,7 +383,7 @@ public void onDialogAction(final double newSetPoint, DialogAction dialogAction) if (tempUtil != null) { if (tempUtil.isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( - mContext, mDomoticz); + mContext, mDomoticz); passwordDialog.show(); passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { @Override @@ -430,30 +430,30 @@ public void setThermostatAction(final UtilitiesInfo tempUtil, action = DomoticzValues.Device.Thermostat.Action.MIN; mDomoticz.setAction(tempUtil.getIdx(), - jsonUrl, - action, - newSetPoint, - password, - new setCommandReceiver() { - @Override - @DebugLog - public void onReceiveResult(String result) { - if (result.contains("WRONG CODE")) { - UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.security_wrong_code, Snackbar.LENGTH_SHORT); - if (getActivity() instanceof MainActivity) - ((MainActivity) getActivity()).Talk(R.string.security_wrong_code); - } else { - updateThermostatSetPointValue(tempUtil.getIdx(), thermostatSetPointValue); - successHandling(result, false); - } + jsonUrl, + action, + newSetPoint, + password, + new setCommandReceiver() { + @Override + @DebugLog + public void onReceiveResult(String result) { + if (result.contains("WRONG CODE")) { + UsefulBits.showSnackbar(mContext, coordinatorLayout, R.string.security_wrong_code, Snackbar.LENGTH_SHORT); + if (getActivity() instanceof MainActivity) + ((MainActivity) getActivity()).Talk(R.string.security_wrong_code); + } else { + updateThermostatSetPointValue(tempUtil.getIdx(), thermostatSetPointValue); + successHandling(result, false); } + } - @Override - @DebugLog - public void onError(Exception error) { - errorHandling(error); - } - }); + @Override + @DebugLog + public void onError(Exception error) { + errorHandling(error); + } + }); } @@ -523,9 +523,9 @@ private void showLogDialog(ArrayList switchLogs) { Toast.makeText(mContext, "No logs found.", Toast.LENGTH_LONG).show(); } else { SwitchLogInfoDialog infoDialog = new SwitchLogInfoDialog( - mContext, - switchLogs, - R.layout.dialog_switch_logs); + mContext, + switchLogs, + R.layout.dialog_switch_logs); infoDialog.show(); } } diff --git a/app/src/main/java/nl/hnogames/domoticz/Fragments/Weather.java b/app/src/main/java/nl/hnogames/domoticz/Fragments/Weather.java index 3d628130e..333e2f526 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Fragments/Weather.java +++ b/app/src/main/java/nl/hnogames/domoticz/Fragments/Weather.java @@ -112,11 +112,11 @@ public void Filter(String text) { try { if (adapter != null) { if (UsefulBits.isEmpty(text) && - (UsefulBits.isEmpty(super.getSort()) || super.getSort().equals(mContext.getString(R.string.filterOn_all))) && - mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { + (UsefulBits.isEmpty(super.getSort()) || super.getSort().equals(mContext.getString(R.string.filterOn_all))) && + mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { if (mItemTouchHelper == null) { mItemTouchHelper = new ItemTouchHelper(new RVHItemTouchHelperCallback(adapter, true, false, - false)); + false)); } mItemTouchHelper.attachToRecyclerView(gridView); } else { @@ -167,10 +167,10 @@ private void createListView(ArrayList mWeatherInfos) { if (mItemTouchHelper == null) { mItemTouchHelper = new ItemTouchHelper(new RVHItemTouchHelperCallback(adapter, true, false, - false)); + false)); } if ((UsefulBits.isEmpty(super.getSort()) || super.getSort().equals(mContext.getString(R.string.filterOn_all))) && - mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { + mSharedPrefs.enableCustomSorting() && !mSharedPrefs.isCustomSortingLocked()) { mItemTouchHelper.attachToRecyclerView(gridView); } else { if (mItemTouchHelper != null) @@ -192,9 +192,9 @@ public void onRefresh() { private void showInfoDialog(final WeatherInfo mWeatherInfo) { WeatherInfoDialog infoDialog = new WeatherInfoDialog( - mContext, - mWeatherInfo, - R.layout.dialog_weather); + mContext, + mWeatherInfo, + R.layout.dialog_weather); infoDialog.setWeatherInfo(mWeatherInfo); infoDialog.show(); infoDialog.onDismissListener(new WeatherInfoDialog.DismissListener() { @@ -236,24 +236,24 @@ private void changeFavorite(final WeatherInfo mWeatherInfo, final boolean isFavo else jsonAction = DomoticzValues.Device.Favorite.OFF; mDomoticz.setAction(mWeatherInfo.getIdx(), - jsonUrl, - jsonAction, - 0, - null, - new setCommandReceiver() { - @Override - @DebugLog - public void onReceiveResult(String result) { - successHandling(result, false); - mWeatherInfo.setFavoriteBoolean(isFavorite); - } + jsonUrl, + jsonAction, + 0, + null, + new setCommandReceiver() { + @Override + @DebugLog + public void onReceiveResult(String result) { + successHandling(result, false); + mWeatherInfo.setFavoriteBoolean(isFavorite); + } - @Override - @DebugLog - public void onError(Exception error) { - errorHandling(error); - } - }); + @Override + @DebugLog + public void onError(Exception error) { + errorHandling(error); + } + }); } @Override @@ -280,9 +280,9 @@ public void onPause() { @DebugLog public void onLogClick(final WeatherInfo weather, final String range) { final String graphType = weather.getTypeImg() - .toLowerCase() - .replace("temperature", "temp") - .replace("visibility", "counter"); + .toLowerCase() + .replace("temperature", "temp") + .replace("visibility", "counter"); JSONObject language = null; Language languageObj = new SharedPrefUtil(mContext).getSavedLanguage(); diff --git a/app/src/main/java/nl/hnogames/domoticz/Fragments/Wizard.java b/app/src/main/java/nl/hnogames/domoticz/Fragments/Wizard.java index 90e7c5a34..573004e16 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Fragments/Wizard.java +++ b/app/src/main/java/nl/hnogames/domoticz/Fragments/Wizard.java @@ -160,563 +160,563 @@ public List generateCards(List cardsToGenerate) { for (String card : cardsToGenerate) { if (card.equalsIgnoreCase(WELCOME)) { cards.add((new Card.Builder(context) - .setTag(WELCOME) - .setDismissible() - .withProvider(new CardProvider()) - .setLayout(R.layout.material_welcome_card_layout) - .setTitle(context.getString(R.string.wizard_welcome)) - .setTitleColor(titleColorLight) - .setDescription(context.getString(R.string.wizard_welcome_description)) - .setDescriptionColor(titleColorLight) - .setSubtitleColor(titleColorLight) - .setBackgroundColor(blueColor) - .addAction(R.id.ok_button, new WelcomeButtonAction(context) - .setText(context.getString(R.string.wizard_button_nice)) - .setTextColor(titleColorLight) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - card.dismiss(); - } - }))).endConfig().build()); + .setTag(WELCOME) + .setDismissible() + .withProvider(new CardProvider()) + .setLayout(R.layout.material_welcome_card_layout) + .setTitle(context.getString(R.string.wizard_welcome)) + .setTitleColor(titleColorLight) + .setDescription(context.getString(R.string.wizard_welcome_description)) + .setDescriptionColor(titleColorLight) + .setSubtitleColor(titleColorLight) + .setBackgroundColor(blueColor) + .addAction(R.id.ok_button, new WelcomeButtonAction(context) + .setText(context.getString(R.string.wizard_button_nice)) + .setTextColor(titleColorLight) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + card.dismiss(); + } + }))).endConfig().build()); } if (card.equalsIgnoreCase(FAVORITE)) { cards.add(new Card.Builder(context) - .setTag(FAVORITE) - .setDismissible() - .withProvider(new CardProvider()) - .setLayout(R.layout.material_basic_buttons_card) - .setBackgroundColor(otherColor) - .setTitle(context.getString(R.string.wizard_favorites)) - .setTitleColor(titleColorOther) - .setDescription(context.getString(R.string.wizard_favorites_description)) - .addAction(R.id.left_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_switches)) - .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - ((MainActivity) getActivity()).changeFragment("nl.hnogames.domoticz.Fragments.Switches"); - } - })) - .addAction(R.id.right_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_done)) - .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - card.dismiss(); - } - })) - .endConfig() - .build()); + .setTag(FAVORITE) + .setDismissible() + .withProvider(new CardProvider()) + .setLayout(R.layout.material_basic_buttons_card) + .setBackgroundColor(otherColor) + .setTitle(context.getString(R.string.wizard_favorites)) + .setTitleColor(titleColorOther) + .setDescription(context.getString(R.string.wizard_favorites_description)) + .addAction(R.id.left_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_switches)) + .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + ((MainActivity) getActivity()).changeFragment("nl.hnogames.domoticz.Fragments.Switches"); + } + })) + .addAction(R.id.right_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_done)) + .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + card.dismiss(); + } + })) + .endConfig() + .build()); } if (card.equalsIgnoreCase(STARTUP)) { cards.add(new Card.Builder(context) - .setTag(STARTUP) - .setDismissible() - .withProvider(new CardProvider()) - .setLayout(R.layout.material_basic_buttons_card) - .setTitle(context.getString(R.string.wizard_startup)) - .setTitleColor(titleColorOther) - .setBackgroundColor(otherColor) - .setDescription(context.getString(R.string.wizard_startup_description)) - .addAction(R.id.left_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_settings)) - .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - startActivityForResult(new Intent(context, SettingsActivity.class), iSettingsResultCode); - } - })) - .addAction(R.id.right_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_done)) - .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - card.dismiss(); - } - })) - .endConfig() - .build()); + .setTag(STARTUP) + .setDismissible() + .withProvider(new CardProvider()) + .setLayout(R.layout.material_basic_buttons_card) + .setTitle(context.getString(R.string.wizard_startup)) + .setTitleColor(titleColorOther) + .setBackgroundColor(otherColor) + .setDescription(context.getString(R.string.wizard_startup_description)) + .addAction(R.id.left_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_settings)) + .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + startActivityForResult(new Intent(context, SettingsActivity.class), iSettingsResultCode); + } + })) + .addAction(R.id.right_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_done)) + .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + card.dismiss(); + } + })) + .endConfig() + .build()); } if (card.equalsIgnoreCase(GEOFENCE)) { cards.add(new Card.Builder(context) - .setTag(GEOFENCE) - .setDismissible() - .withProvider(new CardProvider()) - .setLayout(R.layout.material_basic_buttons_card) - .setTitle(context.getString(R.string.wizard_geo)) - .setTitleColor(titleColorOther) - .setBackgroundColor(otherColor) - .setDescription(context.getString(R.string.wizard_geo_description)) - .addAction(R.id.left_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_settings)) - .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - startActivityForResult(new Intent(context, SettingsActivity.class), iSettingsResultCode); - } - })) - .addAction(R.id.right_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_done)) - .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - card.dismiss(); - } - })) - .endConfig() - .build()); + .setTag(GEOFENCE) + .setDismissible() + .withProvider(new CardProvider()) + .setLayout(R.layout.material_basic_buttons_card) + .setTitle(context.getString(R.string.wizard_geo)) + .setTitleColor(titleColorOther) + .setBackgroundColor(otherColor) + .setDescription(context.getString(R.string.wizard_geo_description)) + .addAction(R.id.left_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_settings)) + .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + startActivityForResult(new Intent(context, SettingsActivity.class), iSettingsResultCode); + } + })) + .addAction(R.id.right_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_done)) + .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + card.dismiss(); + } + })) + .endConfig() + .build()); } if (card.equalsIgnoreCase(NFC)) { cards.add(new Card.Builder(context) - .setTag(NFC) - .setDismissible() - .withProvider(new CardProvider()) - .setLayout(R.layout.material_basic_buttons_card) - .setTitle(context.getString(R.string.wizard_nfc)) - .setTitleColor(titleColorOther) - .setBackgroundColor(otherColor) - .setDescription(context.getString(R.string.wizard_nfc_description)) - .addAction(R.id.left_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_settings)) - .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - startActivityForResult(new Intent(context, SettingsActivity.class), iSettingsResultCode); - } - })) - .addAction(R.id.right_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_done)) - .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - card.dismiss(); - } - })) - .endConfig() - .build()); + .setTag(NFC) + .setDismissible() + .withProvider(new CardProvider()) + .setLayout(R.layout.material_basic_buttons_card) + .setTitle(context.getString(R.string.wizard_nfc)) + .setTitleColor(titleColorOther) + .setBackgroundColor(otherColor) + .setDescription(context.getString(R.string.wizard_nfc_description)) + .addAction(R.id.left_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_settings)) + .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + startActivityForResult(new Intent(context, SettingsActivity.class), iSettingsResultCode); + } + })) + .addAction(R.id.right_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_done)) + .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + card.dismiss(); + } + })) + .endConfig() + .build()); } if (card.equalsIgnoreCase(QRCODE)) { cards.add(new Card.Builder(context) - .setTag(QRCODE) - .setDismissible() - .withProvider(new CardProvider()) - .setLayout(R.layout.material_basic_buttons_card) - .setTitle(context.getString(R.string.wizard_qrcode)) - .setBackgroundColor(otherColor) - .setDescription(context.getString(R.string.wizard_qrcode_description)) - .addAction(R.id.left_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_settings)) - .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - startActivityForResult(new Intent(context, SettingsActivity.class), iSettingsResultCode); - } - })) - .addAction(R.id.right_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_done)) - .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - card.dismiss(); - } - })) - .endConfig() - .build()); + .setTag(QRCODE) + .setDismissible() + .withProvider(new CardProvider()) + .setLayout(R.layout.material_basic_buttons_card) + .setTitle(context.getString(R.string.wizard_qrcode)) + .setBackgroundColor(otherColor) + .setDescription(context.getString(R.string.wizard_qrcode_description)) + .addAction(R.id.left_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_settings)) + .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + startActivityForResult(new Intent(context, SettingsActivity.class), iSettingsResultCode); + } + })) + .addAction(R.id.right_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_done)) + .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + card.dismiss(); + } + })) + .endConfig() + .build()); } if (card.equalsIgnoreCase(BLUETOOTH)) { cards.add(new Card.Builder(context) - .setTag(BLUETOOTH) - .setDismissible() - .withProvider(new CardProvider()) - .setLayout(R.layout.material_basic_buttons_card) - .setTitle(context.getString(R.string.bluetooth)) - .setTitleColor(titleColorOther) - .setBackgroundColor(otherColor) - .setDescription(context.getString(R.string.wizard_bluetooth_description)) - .addAction(R.id.left_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_settings)) - .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - startActivityForResult(new Intent(context, SettingsActivity.class), iSettingsResultCode); - } - })) - .addAction(R.id.right_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_done)) - .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - card.dismiss(); - } - })) - .endConfig() - .build()); + .setTag(BLUETOOTH) + .setDismissible() + .withProvider(new CardProvider()) + .setLayout(R.layout.material_basic_buttons_card) + .setTitle(context.getString(R.string.bluetooth)) + .setTitleColor(titleColorOther) + .setBackgroundColor(otherColor) + .setDescription(context.getString(R.string.wizard_bluetooth_description)) + .addAction(R.id.left_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_settings)) + .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + startActivityForResult(new Intent(context, SettingsActivity.class), iSettingsResultCode); + } + })) + .addAction(R.id.right_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_done)) + .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + card.dismiss(); + } + })) + .endConfig() + .build()); } if (card.equalsIgnoreCase(SPEECH)) { cards.add(new Card.Builder(context) - .setTag(SPEECH) - .setDismissible() - .withProvider(new CardProvider()) - .setLayout(R.layout.material_basic_buttons_card) - .setTitle(context.getString(R.string.wizard_speech)) - .setBackgroundColor(otherColor) - .setDescription(context.getString(R.string.wizard_speech_description)) - .addAction(R.id.left_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_settings)) - .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - startActivityForResult(new Intent(context, SettingsActivity.class), iSettingsResultCode); - } - })) - .addAction(R.id.right_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_done)) - .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - card.dismiss(); - } - })) - .endConfig() - .build()); + .setTag(SPEECH) + .setDismissible() + .withProvider(new CardProvider()) + .setLayout(R.layout.material_basic_buttons_card) + .setTitle(context.getString(R.string.wizard_speech)) + .setBackgroundColor(otherColor) + .setDescription(context.getString(R.string.wizard_speech_description)) + .addAction(R.id.left_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_settings)) + .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + startActivityForResult(new Intent(context, SettingsActivity.class), iSettingsResultCode); + } + })) + .addAction(R.id.right_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_done)) + .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + card.dismiss(); + } + })) + .endConfig() + .build()); } if (card.equalsIgnoreCase(WEAR)) { cards.add(new Card.Builder(context) - .setTag(WEAR) - .setDismissible() - .withProvider(new CardProvider()) - .setTitleColor(titleColorOther) - .setLayout(R.layout.material_basic_buttons_card) - .setTitle(context.getString(R.string.wizard_wear)) - .setTitleColor(titleColorOther) - .setBackgroundColor(otherColor) - .setDescription(context.getString(R.string.wizard_wear_description)) - .addAction(R.id.left_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_settings)) - .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - startActivityForResult(new Intent(context, SettingsActivity.class), iSettingsResultCode); - } - })) - .addAction(R.id.right_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_done)) - .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - card.dismiss(); - } - })) - .endConfig() - .build()); + .setTag(WEAR) + .setDismissible() + .withProvider(new CardProvider()) + .setTitleColor(titleColorOther) + .setLayout(R.layout.material_basic_buttons_card) + .setTitle(context.getString(R.string.wizard_wear)) + .setTitleColor(titleColorOther) + .setBackgroundColor(otherColor) + .setDescription(context.getString(R.string.wizard_wear_description)) + .addAction(R.id.left_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_settings)) + .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + startActivityForResult(new Intent(context, SettingsActivity.class), iSettingsResultCode); + } + })) + .addAction(R.id.right_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_done)) + .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + card.dismiss(); + } + })) + .endConfig() + .build()); } if (card.equalsIgnoreCase(AUTO)) { cards.add(new Card.Builder(context) - .setTag(AUTO) - .setDismissible() - .withProvider(new CardProvider()) - .setLayout(R.layout.material_basic_buttons_card) - .setBackgroundColor(otherColor) - .setTitle(context.getString(R.string.wizard_auto)) - .setTitleColor(titleColorOther) - .setDescription(context.getString(R.string.wizard_auto_description)) - .addAction(R.id.left_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_settings)) - .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - startActivityForResult(new Intent(context, SettingsActivity.class), iSettingsResultCode); - } - })) - .addAction(R.id.right_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_done)) - .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - card.dismiss(); - } - })) - .endConfig() - .build()); + .setTag(AUTO) + .setDismissible() + .withProvider(new CardProvider()) + .setLayout(R.layout.material_basic_buttons_card) + .setBackgroundColor(otherColor) + .setTitle(context.getString(R.string.wizard_auto)) + .setTitleColor(titleColorOther) + .setDescription(context.getString(R.string.wizard_auto_description)) + .addAction(R.id.left_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_settings)) + .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + startActivityForResult(new Intent(context, SettingsActivity.class), iSettingsResultCode); + } + })) + .addAction(R.id.right_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_done)) + .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + card.dismiss(); + } + })) + .endConfig() + .build()); } if (card.equalsIgnoreCase(LANGUAGE)) { cards.add(new Card.Builder(context) - .setTag(LANGUAGE) - .setDismissible() - .withProvider(new CardProvider()) - .setLayout(R.layout.material_basic_buttons_card) - .setBackgroundColor(otherColor) - .setTitle(context.getString(R.string.category_help)) - .setTitleColor(titleColorOther) - .setDescription(context.getString(R.string.translate_description)) - .addAction(R.id.left_text_button, new TextViewAction(context) - .setText(context.getString(R.string.ok)) - .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - Intent i = new Intent(Intent.ACTION_VIEW); - i.setData(Uri.parse("https://crowdin.com/project/domoticz-for-android")); - startActivity(i); - } - })) - .addAction(R.id.right_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_done)) - .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - card.dismiss(); - } - })) - .endConfig() - .build()); + .setTag(LANGUAGE) + .setDismissible() + .withProvider(new CardProvider()) + .setLayout(R.layout.material_basic_buttons_card) + .setBackgroundColor(otherColor) + .setTitle(context.getString(R.string.category_help)) + .setTitleColor(titleColorOther) + .setDescription(context.getString(R.string.translate_description)) + .addAction(R.id.left_text_button, new TextViewAction(context) + .setText(context.getString(R.string.ok)) + .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + Intent i = new Intent(Intent.ACTION_VIEW); + i.setData(Uri.parse("https://crowdin.com/project/domoticz-for-android")); + startActivity(i); + } + })) + .addAction(R.id.right_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_done)) + .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + card.dismiss(); + } + })) + .endConfig() + .build()); } if (card.equalsIgnoreCase(NOTIFICATIONS)) { cards.add(new Card.Builder(context) - .setTag(NOTIFICATIONS) - .setDismissible() - .withProvider(new CardProvider()) - .setLayout(R.layout.material_basic_buttons_card) - .setTitle(context.getString(R.string.wizard_notifications)) - .setTitleColor(titleColorOther) - .setBackgroundColor(otherColor) - .setDescription(context.getString(R.string.wizard_notifications_description)) - .addAction(R.id.left_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_settings)) - .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - startActivityForResult(new Intent(context, SettingsActivity.class), iSettingsResultCode); - } - })) - .addAction(R.id.right_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_done)) - .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - card.dismiss(); - } - })) - .endConfig() - .build()); + .setTag(NOTIFICATIONS) + .setDismissible() + .withProvider(new CardProvider()) + .setLayout(R.layout.material_basic_buttons_card) + .setTitle(context.getString(R.string.wizard_notifications)) + .setTitleColor(titleColorOther) + .setBackgroundColor(otherColor) + .setDescription(context.getString(R.string.wizard_notifications_description)) + .addAction(R.id.left_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_settings)) + .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + startActivityForResult(new Intent(context, SettingsActivity.class), iSettingsResultCode); + } + })) + .addAction(R.id.right_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_done)) + .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + card.dismiss(); + } + })) + .endConfig() + .build()); } if (card.equalsIgnoreCase(MULTISERVER)) { cards.add(new Card.Builder(context) - .setTag(MULTISERVER) - .setDismissible() - .withProvider(new CardProvider()) - .setLayout(R.layout.material_basic_buttons_card) - .setTitle(context.getString(R.string.wizard_multiserver)) - .setTitleColor(titleColorOther) - .setBackgroundColor(otherColor) - .setDescription(context.getString(R.string.wizard_multiserver_description)) - .addAction(R.id.left_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_settings)) - .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - startActivityForResult(new Intent(context, SettingsActivity.class), iSettingsResultCode); - } - })) - .addAction(R.id.right_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_done)) - .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - card.dismiss(); - } - })) - .endConfig() - .build()); + .setTag(MULTISERVER) + .setDismissible() + .withProvider(new CardProvider()) + .setLayout(R.layout.material_basic_buttons_card) + .setTitle(context.getString(R.string.wizard_multiserver)) + .setTitleColor(titleColorOther) + .setBackgroundColor(otherColor) + .setDescription(context.getString(R.string.wizard_multiserver_description)) + .addAction(R.id.left_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_settings)) + .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + startActivityForResult(new Intent(context, SettingsActivity.class), iSettingsResultCode); + } + })) + .addAction(R.id.right_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_done)) + .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + card.dismiss(); + } + })) + .endConfig() + .build()); } if (card.equalsIgnoreCase(GRAPH)) { cards.add(new Card.Builder(context) - .setTag(GRAPH) - .setDismissible() - .withProvider(new CardProvider()) - .setLayout(R.layout.material_basic_buttons_card) - .setTitle(context.getString(R.string.wizard_graph)) - .setTitleColor(titleColorOther) - .setBackgroundColor(otherColor) - .setDescription(context.getString(R.string.wizard_graph_description)) - .addAction(R.id.left_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_utilities)) - .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - ((MainActivity) getActivity()).changeFragment("nl.hnogames.domoticz.Fragments.Utilities"); - } - })) - .addAction(R.id.right_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_done)) - .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - card.dismiss(); - } - })) - .endConfig() - .build()); + .setTag(GRAPH) + .setDismissible() + .withProvider(new CardProvider()) + .setLayout(R.layout.material_basic_buttons_card) + .setTitle(context.getString(R.string.wizard_graph)) + .setTitleColor(titleColorOther) + .setBackgroundColor(otherColor) + .setDescription(context.getString(R.string.wizard_graph_description)) + .addAction(R.id.left_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_utilities)) + .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + ((MainActivity) getActivity()).changeFragment("nl.hnogames.domoticz.Fragments.Utilities"); + } + })) + .addAction(R.id.right_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_done)) + .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + card.dismiss(); + } + })) + .endConfig() + .build()); } if (card.equalsIgnoreCase(FILTER)) { cards.add(new Card.Builder(context) - .setTag(FILTER) - .setDismissible() - .withProvider(new CardProvider()) - .setLayout(R.layout.material_basic_buttons_card) - .setTitle(context.getString(R.string.wizard_filter)) - .setTitleColor(titleColorOther) - .setBackgroundColor(otherColor) - .setDescription(context.getString(R.string.wizard_filter_description)) - .addAction(R.id.left_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_nice)) - .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - ((MainActivity) getActivity()).changeFragment("nl.hnogames.domoticz.Fragments.Switches"); - } - })) - .addAction(R.id.right_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_done)) - .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - card.dismiss(); - } - })) - .endConfig() - .build()); + .setTag(FILTER) + .setDismissible() + .withProvider(new CardProvider()) + .setLayout(R.layout.material_basic_buttons_card) + .setTitle(context.getString(R.string.wizard_filter)) + .setTitleColor(titleColorOther) + .setBackgroundColor(otherColor) + .setDescription(context.getString(R.string.wizard_filter_description)) + .addAction(R.id.left_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_nice)) + .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + ((MainActivity) getActivity()).changeFragment("nl.hnogames.domoticz.Fragments.Switches"); + } + })) + .addAction(R.id.right_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_done)) + .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + card.dismiss(); + } + })) + .endConfig() + .build()); } if (card.equalsIgnoreCase(WIDGETS)) { cards.add(new Card.Builder(context) - .setTag(WIDGETS) - .setDismissible() - .withProvider(new CardProvider()) - .setLayout(R.layout.material_basic_buttons_card) - .setTitle(context.getString(R.string.wizard_widgets)) - .setTitleColor(titleColorOther) - .setBackgroundColor(otherColor) - .setDescription(context.getString(R.string.wizard_widgets_description)) - .addAction(R.id.left_text_button, new TextViewAction(context) - .setText("") - .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - card.dismiss(); + .setTag(WIDGETS) + .setDismissible() + .withProvider(new CardProvider()) + .setLayout(R.layout.material_basic_buttons_card) + .setTitle(context.getString(R.string.wizard_widgets)) + .setTitleColor(titleColorOther) + .setBackgroundColor(otherColor) + .setDescription(context.getString(R.string.wizard_widgets_description)) + .addAction(R.id.left_text_button, new TextViewAction(context) + .setText("") + .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + card.dismiss(); - } - })) - .addAction(R.id.right_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_done)) - .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - card.dismiss(); - } - })) - .endConfig() - .build()); + } + })) + .addAction(R.id.right_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_done)) + .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + card.dismiss(); + } + })) + .endConfig() + .build()); } if (card.equalsIgnoreCase(FINISH)) { cards.add(new Card.Builder(context) - .setTag(FINISH) - .setDismissible() - .withProvider(new CardProvider()) - .setLayout(R.layout.material_basic_buttons_card) - .setTitle(context.getString(R.string.wizard_menuitem)) - .setTitleColor(titleColorOther) - .setBackgroundColor(otherColor) - .setDescription(context.getString(R.string.wizard_menuitem_description)) - .addAction(R.id.left_text_button, new TextViewAction(context) - .setText(context.getString(R.string.wizard_button_wizard)) - .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - mSharedPrefs.removeWizard(); - ((MainActivity) getActivity()).drawNavigationMenu(null); - ((MainActivity) getActivity()).removeFragmentStack("nl.hnogames.domoticz.Fragments.Wizard"); - ((MainActivity) getActivity()).changeFragment("nl.hnogames.domoticz.Fragments.Dashboard"); - } - })) - .addAction(R.id.right_text_button, new TextViewAction(context) - .setText("") - .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) - .setListener(new OnActionClickListener() { - @Override - @DebugLog - public void onActionClicked(View view, Card card) { - mSharedPrefs.removeWizard(); - ((MainActivity) getActivity()).drawNavigationMenu(null); - ((MainActivity) getActivity()).removeFragmentStack("nl.hnogames.domoticz.Fragments.Wizard"); - ((MainActivity) getActivity()).changeFragment("nl.hnogames.domoticz.Fragments.Dashboard"); - } - })) - .endConfig() - .build()); + .setTag(FINISH) + .setDismissible() + .withProvider(new CardProvider()) + .setLayout(R.layout.material_basic_buttons_card) + .setTitle(context.getString(R.string.wizard_menuitem)) + .setTitleColor(titleColorOther) + .setBackgroundColor(otherColor) + .setDescription(context.getString(R.string.wizard_menuitem_description)) + .addAction(R.id.left_text_button, new TextViewAction(context) + .setText(context.getString(R.string.wizard_button_wizard)) + .setTextColor(ContextCompat.getColor(context, R.color.md_material_blue_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + mSharedPrefs.removeWizard(); + ((MainActivity) getActivity()).drawNavigationMenu(null); + ((MainActivity) getActivity()).removeFragmentStack("nl.hnogames.domoticz.Fragments.Wizard"); + ((MainActivity) getActivity()).changeFragment("nl.hnogames.domoticz.Fragments.Dashboard"); + } + })) + .addAction(R.id.right_text_button, new TextViewAction(context) + .setText("") + .setTextColor(ContextCompat.getColor(context, R.color.material_orange_600)) + .setListener(new OnActionClickListener() { + @Override + @DebugLog + public void onActionClicked(View view, Card card) { + mSharedPrefs.removeWizard(); + ((MainActivity) getActivity()).drawNavigationMenu(null); + ((MainActivity) getActivity()).removeFragmentStack("nl.hnogames.domoticz.Fragments.Wizard"); + ((MainActivity) getActivity()).changeFragment("nl.hnogames.domoticz.Fragments.Dashboard"); + } + })) + .endConfig() + .build()); } } diff --git a/app/src/main/java/nl/hnogames/domoticz/GeoSettingsActivity.java b/app/src/main/java/nl/hnogames/domoticz/GeoSettingsActivity.java index 604b39d8a..de822de0b 100644 --- a/app/src/main/java/nl/hnogames/domoticz/GeoSettingsActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/GeoSettingsActivity.java @@ -128,13 +128,13 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { geoSwitch.setChecked(false); geoNotificationSwitch.setEnabled(false); permissionHelper - .request(PermissionsUtil.INITIAL_LOCATION_PERMS); + .request(PermissionsUtil.INITIAL_LOCATION_PERMS); } else { if (!PermissionsUtil.canAccessStorage(GeoSettingsActivity.this)) { geoSwitch.setChecked(false); geoNotificationSwitch.setEnabled(false); permissionHelper - .request(PermissionsUtil.INITIAL_STORAGE_PERMS); + .request(PermissionsUtil.INITIAL_STORAGE_PERMS); } else { //all settings are correct mSharedPrefs.setGeofenceEnabled(true); @@ -176,8 +176,8 @@ protected void onResume() { } private void showSwitchesDialog( - final LocationInfo selectedLocation, - final ArrayList switches) { + final LocationInfo selectedLocation, + final ArrayList switches) { final ArrayList supportedSwitches = new ArrayList<>(); for (DevicesInfo d : switches) { @@ -186,9 +186,9 @@ private void showSwitchesDialog( } SwitchDialog infoDialog = new SwitchDialog( - GeoSettingsActivity.this, supportedSwitches, - R.layout.dialog_switch_logs, - domoticz); + GeoSettingsActivity.this, supportedSwitches, + R.layout.dialog_switch_logs, + domoticz); infoDialog.onDismissListener(new SwitchDialog.DismissListener() { @Override @@ -222,18 +222,18 @@ public void onDismiss(int selectedSwitchIDX, String selectedSwitchPassword, Stri private void showSelectorDialog(final LocationInfo selectedLocation, DevicesInfo selector) { final ArrayList levelNames = selector.getLevelNames(); new MaterialDialog.Builder(this) - .title(R.string.selector_value) - .items(levelNames) - .itemsCallback(new MaterialDialog.ListCallback() { - @Override - public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { - selectedLocation.setValue(String.valueOf(text)); - mSharedPrefs.updateLocation(selectedLocation); - adapter.data = mSharedPrefs.getLocations(); - adapter.notifyDataSetChanged(); - } - }) - .show(); + .title(R.string.selector_value) + .items(levelNames) + .itemsCallback(new MaterialDialog.ListCallback() { + @Override + public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { + selectedLocation.setValue(String.valueOf(text)); + mSharedPrefs.updateLocation(selectedLocation); + adapter.data = mSharedPrefs.getLocations(); + adapter.notifyDataSetChanged(); + } + }) + .show(); } private void createListView() { @@ -289,7 +289,7 @@ private void showRemoveUndoSnackbar(final LocationInfo locationInfo) { // Show snackbar with undo option String text = String.format(getString(R.string.something_deleted), - getString(R.string.geofence)); + getString(R.string.geofence)); UsefulBits.showSnackbarWithAction(this, coordinatorLayout, text, Snackbar.LENGTH_SHORT, new Snackbar.Callback() { @Override @@ -346,33 +346,33 @@ public void onReceiveDevice(DevicesInfo mDevicesInfo) { @DebugLog public void onError(Exception error) { UsefulBits.showSnackbarWithAction(GeoSettingsActivity.this, coordinatorLayout, GeoSettingsActivity.this.getString(R.string.unable_to_get_switches), Snackbar.LENGTH_SHORT, - null, new View.OnClickListener() { - @Override - public void onClick(View v) { - getSwitchesAndShowSwitchesDialog(locationInfo); - } - }, GeoSettingsActivity.this.getString(R.string.retry)); + null, new View.OnClickListener() { + @Override + public void onClick(View v) { + getSwitchesAndShowSwitchesDialog(locationInfo); + } + }, GeoSettingsActivity.this.getString(R.string.retry)); } }, 0, "all"); } private boolean showNoDeviceAttachedDialog(final LocationInfo locationInfo) { new MaterialDialog.Builder(this) - .title(R.string.noSwitchSelected_title) - .content(getString(R.string.noSwitchSelected_explanation) - + UsefulBits.newLine() - + UsefulBits.newLine() - + getString(R.string.noSwitchSelected_connectOneNow)) - .positiveText(R.string.yes) - .negativeText(R.string.no) - .onPositive(new MaterialDialog.SingleButtonCallback() { - @Override - public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { - getSwitchesAndShowSwitchesDialog(locationInfo); - result = true; - } - }) - .show(); + .title(R.string.noSwitchSelected_title) + .content(getString(R.string.noSwitchSelected_explanation) + + UsefulBits.newLine() + + UsefulBits.newLine() + + getString(R.string.noSwitchSelected_connectOneNow)) + .positiveText(R.string.yes) + .negativeText(R.string.no) + .onPositive(new MaterialDialog.SingleButtonCallback() { + @Override + public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { + getSwitchesAndShowSwitchesDialog(locationInfo); + result = true; + } + }) + .show(); return result; } @@ -403,17 +403,17 @@ protected void onActivityResult(int requestCode, int resultCode, final Intent da String name = data.getStringExtra(LocationPickerActivity.LOCATION_ADDRESS); if (nl.hnogames.domoticzapi.Utils.UsefulBits.isEmpty(name)) { new MaterialDialog.Builder(this) - .title(R.string.title_edit_location) - .content(R.string.Location_name) - .inputType(InputType.TYPE_CLASS_TEXT) - .input(null, prefillEditedName, new MaterialDialog.InputCallback() { - @Override - public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { - String name = String.valueOf(input); - if (!nl.hnogames.domoticzapi.Utils.UsefulBits.isEmpty(name)) - showRadiusEditor(editedID, name, latLng); - } - }).show(); + .title(R.string.title_edit_location) + .content(R.string.Location_name) + .inputType(InputType.TYPE_CLASS_TEXT) + .input(null, prefillEditedName, new MaterialDialog.InputCallback() { + @Override + public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { + String name = String.valueOf(input); + if (!nl.hnogames.domoticzapi.Utils.UsefulBits.isEmpty(name)) + showRadiusEditor(editedID, name, latLng); + } + }).show(); } else showRadiusEditor(editedLocationID, name, latLng); } else if (resultCode != RESULT_CANCELED) @@ -438,35 +438,35 @@ private void showRadiusEditor(final int editedLocationID, String name, LatLng la final LocationInfo finalLocation = location; new MaterialDialog.Builder(GeoSettingsActivity.this) - .title(R.string.radius) - .content(R.string.radius) - .inputType(InputType.TYPE_CLASS_NUMBER) - .input("500", String.valueOf(location.getRadius()), new MaterialDialog.InputCallback() { - @Override - public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { - try { - finalLocation.setRadius(Integer.parseInt(String.valueOf(input))); - } catch (Exception ex) { - } + .title(R.string.radius) + .content(R.string.radius) + .inputType(InputType.TYPE_CLASS_NUMBER) + .input("500", String.valueOf(location.getRadius()), new MaterialDialog.InputCallback() { + @Override + public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { + try { + finalLocation.setRadius(Integer.parseInt(String.valueOf(input))); + } catch (Exception ex) { + } - if (editedLocationID != -1 && locations != null) { - mSharedPrefs.updateLocation(finalLocation); - for (int i = locations.size() - 1; i >= 0; i--) - if (locations.get(i).getID() == editedLocationID) { - locations.set(i, finalLocation); - GeoUtils.geofencesAlreadyRegistered = false; - oGeoUtils.AddGeofences(); - break; - } - } else { - mSharedPrefs.addLocation(finalLocation); - locations = mSharedPrefs.getLocations(); - GeoUtils.geofencesAlreadyRegistered = false; - oGeoUtils.AddGeofences(); - } - adapter.notifyDataSetChanged(); + if (editedLocationID != -1 && locations != null) { + mSharedPrefs.updateLocation(finalLocation); + for (int i = locations.size() - 1; i >= 0; i--) + if (locations.get(i).getID() == editedLocationID) { + locations.set(i, finalLocation); + GeoUtils.geofencesAlreadyRegistered = false; + oGeoUtils.AddGeofences(); + break; + } + } else { + mSharedPrefs.addLocation(finalLocation); + locations = mSharedPrefs.getLocations(); + GeoUtils.geofencesAlreadyRegistered = false; + oGeoUtils.AddGeofences(); } - }).show(); + adapter.notifyDataSetChanged(); + } + }).show(); } private void showEditLocationDialog(LocationInfo location) { @@ -507,7 +507,7 @@ public void onPermissionDeclined(@NonNull String[] permissionName) { Log.i("onPermissionDeclined", "Permission(s) " + Arrays.toString(permissionName) + " Declined"); String[] neededPermission = PermissionHelper.declinedPermissions(GeoSettingsActivity.this, PermissionsUtil.INITIAL_LOCATION_PERMS); AlertDialog alert = PermissionsUtil.getAlertDialog(GeoSettingsActivity.this, permissionHelper, GeoSettingsActivity.this.getString(R.string.permission_title), - GeoSettingsActivity.this.getString(R.string.permission_desc_location), neededPermission); + GeoSettingsActivity.this.getString(R.string.permission_desc_location), neededPermission); if (!alert.isShowing()) { alert.show(); } @@ -548,7 +548,7 @@ public void onPermissionGranted(@NonNull String[] permissionName) { invalidateOptionsMenu(); } else { permissionHelper - .request(PermissionsUtil.INITIAL_STORAGE_PERMS); + .request(PermissionsUtil.INITIAL_STORAGE_PERMS); } } } diff --git a/app/src/main/java/nl/hnogames/domoticz/GraphActivity.java b/app/src/main/java/nl/hnogames/domoticz/GraphActivity.java index da0a1c6b3..2eb26b6ad 100644 --- a/app/src/main/java/nl/hnogames/domoticz/GraphActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/GraphActivity.java @@ -60,7 +60,7 @@ protected void onCreate(Bundle savedInstanceState) { if (getSupportActionBar() != null) getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportFragmentManager().beginTransaction().replace(android.R.id.content, - graph).commit(); + graph).commit(); } catch (Exception ex) { this.finish(); } diff --git a/app/src/main/java/nl/hnogames/domoticz/Helpers/BasicAuthInterceptor.java b/app/src/main/java/nl/hnogames/domoticz/Helpers/BasicAuthInterceptor.java index 6e66a7565..8ce402c51 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Helpers/BasicAuthInterceptor.java +++ b/app/src/main/java/nl/hnogames/domoticz/Helpers/BasicAuthInterceptor.java @@ -20,8 +20,8 @@ public BasicAuthInterceptor(String username, String password) { public Response intercept(Chain chain) throws IOException { String credential = Credentials.basic(username, password); Request compressedRequest = chain.request().newBuilder() - .header("Authorization", credential) - .build(); + .header("Authorization", credential) + .build(); return chain.proceed(compressedRequest); } } \ No newline at end of file diff --git a/app/src/main/java/nl/hnogames/domoticz/Helpers/DefaultHeadersInterceptor.java b/app/src/main/java/nl/hnogames/domoticz/Helpers/DefaultHeadersInterceptor.java index 969447c1c..892f75f54 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Helpers/DefaultHeadersInterceptor.java +++ b/app/src/main/java/nl/hnogames/domoticz/Helpers/DefaultHeadersInterceptor.java @@ -44,12 +44,12 @@ public Response intercept(Chain chain) throws IOException { Request request = chain.request(); Request.Builder builder = request.newBuilder(); builder.header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8") - .header("Connection", "keep-alive") - //.header("Accept-Language", "en-GB,en;q=0.5") - //.header("Upgrade-Insecure-Requests", "1") - .header("Accept-Encoding", "gzip, deflate, br") - //.header("X-Client-Id", getPackageName() + "-" + getVersionName() + "-" + getVersionCode() + "-" + getBuildType()) - .header("User-Agent", getPackageName() + "-" + getVersionName() + "-" + getVersionCode() + "-" + getBuildType()); + .header("Connection", "keep-alive") + //.header("Accept-Language", "en-GB,en;q=0.5") + //.header("Upgrade-Insecure-Requests", "1") + .header("Accept-Encoding", "gzip, deflate, br") + //.header("X-Client-Id", getPackageName() + "-" + getVersionName() + "-" + getVersionCode() + "-" + getBuildType()) + .header("User-Agent", getPackageName() + "-" + getVersionName() + "-" + getVersionCode() + "-" + getBuildType()); if (useBasicAuth) builder.header("Authorization", Credentials.basic(sUsername, sPassword)); if (useCookie) diff --git a/app/src/main/java/nl/hnogames/domoticz/MainActivity.java b/app/src/main/java/nl/hnogames/domoticz/MainActivity.java index f980cb928..1ef09d398 100644 --- a/app/src/main/java/nl/hnogames/domoticz/MainActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/MainActivity.java @@ -246,11 +246,11 @@ public void onAuthenticationFailed() { } }); promptInfo = new BiometricPrompt.PromptInfo.Builder() - .setTitle(getString(R.string.app_name_domoticz)) - .setSubtitle(getString(R.string.fingerprint_make_sure)) - .setDescription(getString(R.string.fingerprint_dialog_description)) - .setNegativeButtonText(getString(R.string.security_password_fallback)) - .build(); + .setTitle(getString(R.string.app_name_domoticz)) + .setSubtitle(getString(R.string.fingerprint_make_sure)) + .setDescription(getString(R.string.fingerprint_dialog_description)) + .setNegativeButtonText(getString(R.string.security_password_fallback)) + .build(); } private void FallbackSecurity() { @@ -463,7 +463,7 @@ public void onReceiveDevice(DevicesInfo mDevicesInfo) { if (!isSceneOrGroup) { if (inputJSONAction < 0) { if (mDevicesInfo.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDS || - mDevicesInfo.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDPERCENTAGE) { + mDevicesInfo.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDPERCENTAGE) { if (!mDevicesInfo.getStatusBoolean()) { jsonAction = DomoticzValues.Device.Switch.Action.OFF; if (!UsefulBits.isEmpty(value)) { @@ -494,7 +494,7 @@ public void onReceiveDevice(DevicesInfo mDevicesInfo) { } } else { if (mDevicesInfo.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDS || - mDevicesInfo.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDPERCENTAGE) { + mDevicesInfo.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDPERCENTAGE) { if (inputJSONAction == 1) { jsonAction = DomoticzValues.Device.Switch.Action.OFF; if (!UsefulBits.isEmpty(value)) { @@ -781,10 +781,10 @@ private void setupMobileDevice() { private void appRate() { if (!BuildConfig.DEBUG) { AppRate.with(this) - .setInstallDays(0) // default 10, 0 means install day. - .setLaunchTimes(3) // default 10 - .setRemindInterval(2) // default 1 - .monitor(); + .setInstallDays(0) // default 10, 0 means install day. + .setLaunchTimes(3) // default 10 + .setRemindInterval(2) // default 1 + .monitor(); // Show a dialog if meets conditions AppRate.showRateDialogIfMeetsConditions(this); @@ -800,9 +800,9 @@ public void drawNavigationMenu(final ConfigInfo mConfig) { config = mServerUtil.getActiveServer().getConfigInfo(this); ProfileDrawerItem loggedinAccount = new ProfileDrawerItem() - .withName("Logged in") - .withEmail(domoticz.getUserCredentials(Domoticz.Authentication.USERNAME)) - .withIcon(R.mipmap.ic_launcher); + .withName("Logged in") + .withEmail(domoticz.getUserCredentials(Domoticz.Authentication.USERNAME)) + .withIcon(R.mipmap.ic_launcher); if (mSharedPrefs.darkThemeEnabled()) { loggedinAccount.withSelectedColorRes(R.color.primary); loggedinAccount.withSelectedTextColorRes(R.color.white); @@ -812,78 +812,78 @@ public void drawNavigationMenu(final ConfigInfo mConfig) { // Create the AccountHeader final ConfigInfo finalConfig = config; AccountHeader headerResult = new AccountHeaderBuilder() - .withActivity(this) - .withHeaderBackground(R.drawable.darkheader) - .addProfiles(loggedinAccount) - .withOnlyMainProfileImageVisible(true) - .withTextColorRes(R.color.white) - .withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() { - @Override - @DebugLog - public boolean onProfileChanged(View view, final IProfile profile, boolean current) { - if (!current) { - if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { - if (getFragmentCoordinatorLayout() != null) { - Snackbar.make(getFragmentCoordinatorLayout(), getString(R.string.category_account) + " " + getString(R.string.premium_feature), Snackbar.LENGTH_LONG) - .setAction(R.string.upgrade, new View.OnClickListener() { - @Override - public void onClick(View view) { - UsefulBits.openPremiumAppStore(MainActivity.this); - } - }) - .setActionTextColor(ContextCompat.getColor(MainActivity.this, R.color.primary)) - .show(); - } - return false; - } else { - PasswordDialog passwordDialog = new PasswordDialog(MainActivity.this, null); - passwordDialog.show(); - passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { - @Override - @DebugLog - public void onDismiss(String password) { - if (UsefulBits.isEmpty(password)) { - UsefulBits.showSnackbar(MainActivity.this, getFragmentCoordinatorLayout(), R.string.security_wrong_code, Snackbar.LENGTH_SHORT); - Talk(R.string.security_wrong_code); - drawNavigationMenu(finalConfig); - } else { - for (UserInfo user : finalConfig.getUsers()) { - if (user.getUsername().equals(profile.getEmail().getText())) { - String md5Pass = UsefulBits.getMd5String(password); - if (md5Pass.equals(user.getPassword())) { - domoticz.LogOff(); - domoticz.setUserCredentials(user.getUsername(), password); - initScreen(); - } else { - UsefulBits.showSnackbar(MainActivity.this, getFragmentCoordinatorLayout(), R.string.security_wrong_code, Snackbar.LENGTH_SHORT); - drawNavigationMenu(finalConfig); - } + .withActivity(this) + .withHeaderBackground(R.drawable.darkheader) + .addProfiles(loggedinAccount) + .withOnlyMainProfileImageVisible(true) + .withTextColorRes(R.color.white) + .withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() { + @Override + @DebugLog + public boolean onProfileChanged(View view, final IProfile profile, boolean current) { + if (!current) { + if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { + if (getFragmentCoordinatorLayout() != null) { + Snackbar.make(getFragmentCoordinatorLayout(), getString(R.string.category_account) + " " + getString(R.string.premium_feature), Snackbar.LENGTH_LONG) + .setAction(R.string.upgrade, new View.OnClickListener() { + @Override + public void onClick(View view) { + UsefulBits.openPremiumAppStore(MainActivity.this); + } + }) + .setActionTextColor(ContextCompat.getColor(MainActivity.this, R.color.primary)) + .show(); + } + return false; + } else { + PasswordDialog passwordDialog = new PasswordDialog(MainActivity.this, null); + passwordDialog.show(); + passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { + @Override + @DebugLog + public void onDismiss(String password) { + if (UsefulBits.isEmpty(password)) { + UsefulBits.showSnackbar(MainActivity.this, getFragmentCoordinatorLayout(), R.string.security_wrong_code, Snackbar.LENGTH_SHORT); + Talk(R.string.security_wrong_code); + drawNavigationMenu(finalConfig); + } else { + for (UserInfo user : finalConfig.getUsers()) { + if (user.getUsername().equals(profile.getEmail().getText())) { + String md5Pass = UsefulBits.getMd5String(password); + if (md5Pass.equals(user.getPassword())) { + domoticz.LogOff(); + domoticz.setUserCredentials(user.getUsername(), password); + initScreen(); + } else { + UsefulBits.showSnackbar(MainActivity.this, getFragmentCoordinatorLayout(), R.string.security_wrong_code, Snackbar.LENGTH_SHORT); + drawNavigationMenu(finalConfig); } } } } + } - @Override - public void onCancel() { - } - }); - } - - drawNavigationMenu(finalConfig); + @Override + public void onCancel() { + } + }); } - return false; + + drawNavigationMenu(finalConfig); } - }) - .build(); + return false; + } + }) + .build(); if (config != null && - config.getUsers() != null) { + config.getUsers() != null) { for (UserInfo user : config.getUsers()) { if (!allUsers.contains(user.getUsername())) { ProfileDrawerItem profile = new ProfileDrawerItem().withName(user.getRightsValue(this) ).withEmail(user.getUsername()) - .withIcon(R.drawable.users) - .withEnabled(user.isEnabled()); + .withIcon(R.drawable.users) + .withEnabled(user.isEnabled()); if (mSharedPrefs.darkThemeEnabled()) { profile.withSelectedColorRes(R.color.primary); @@ -895,38 +895,38 @@ public void onCancel() { } drawer = new DrawerBuilder() - .withActivity(this) - .withTranslucentStatusBar(false) - .withActionBarDrawerToggle(true) - .withAccountHeader(headerResult) - .withToolbar(toolbar) - .withSelectedItem(-1) - .withDrawerItems(getDrawerItems()) - .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { - @Override - @DebugLog - public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { - if (drawerItem != null) { - if (searchViewAction != null) { - searchViewAction.setQuery("", false); - searchViewAction.clearFocus(); - } + .withActivity(this) + .withTranslucentStatusBar(false) + .withActionBarDrawerToggle(true) + .withAccountHeader(headerResult) + .withToolbar(toolbar) + .withSelectedItem(-1) + .withDrawerItems(getDrawerItems()) + .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { + @Override + @DebugLog + public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { + if (drawerItem != null) { + if (searchViewAction != null) { + searchViewAction.setQuery("", false); + searchViewAction.clearFocus(); + } - if (drawerItem.getTag() != null && String.valueOf(drawerItem.getTag()).equals("Settings")) { - stopCameraTimer(); - startActivityForResult(new Intent(MainActivity.this, SettingsActivity.class), iSettingsResultCode); - } else if (drawerItem.getTag() != null) { - changeFragment(String.valueOf(drawerItem.getTag())); - stopCameraTimer(); - invalidateOptionsMenu(); - if (onPhone) - drawer.closeDrawer(); - } + if (drawerItem.getTag() != null && String.valueOf(drawerItem.getTag()).equals("Settings")) { + stopCameraTimer(); + startActivityForResult(new Intent(MainActivity.this, SettingsActivity.class), iSettingsResultCode); + } else if (drawerItem.getTag() != null) { + changeFragment(String.valueOf(drawerItem.getTag())); + stopCameraTimer(); + invalidateOptionsMenu(); + if (onPhone) + drawer.closeDrawer(); } - return false; } - }) - .build(); + return false; + } + }) + .build(); drawer.addStickyFooterItem(createSecondaryDrawerItem(this.getString(R.string.action_settings), "gmd_settings", "Settings")); } @@ -956,20 +956,20 @@ private List getDrawerItems() { for (int i = 0; i < drawerActions.length; i++) if (fragments[i].contains("Fragments.Dashboard") || - (fragments[i].contains("Fragments.Switch") && (mConfigInfo != null && mConfigInfo.isEnableTabLights())) || - (fragments[i].contains("Fragments.Scene") && (mConfigInfo != null && mConfigInfo.isEnableTabScenes()))) + (fragments[i].contains("Fragments.Switch") && (mConfigInfo != null && mConfigInfo.isEnableTabLights())) || + (fragments[i].contains("Fragments.Scene") && (mConfigInfo != null && mConfigInfo.isEnableTabScenes()))) drawerItems.add(createPrimaryDrawerItem(drawerActions[i], ICONS[i], fragments[i])); drawerItems.add(new DividerDrawerItem()); for (int i = 0; i < drawerActions.length; i++) if ((fragments[i].contains("Fragments.Temperature") && (mConfigInfo != null && mConfigInfo.isEnableTabTemp())) || - (fragments[i].contains("Fragments.Weather") && (mConfigInfo != null && mConfigInfo.isEnableTabWeather()))) + (fragments[i].contains("Fragments.Weather") && (mConfigInfo != null && mConfigInfo.isEnableTabWeather()))) drawerItems.add(createPrimaryDrawerItem(drawerActions[i], ICONS[i], fragments[i])); drawerItems.add(new DividerDrawerItem()); for (int i = 0; i < drawerActions.length; i++) { if ((fragments[i].contains("Fragments.Plans")) || - (fragments[i].contains("Fragments.Utilities") && (mConfigInfo != null && mConfigInfo.isEnableTabUtility()))) + (fragments[i].contains("Fragments.Utilities") && (mConfigInfo != null && mConfigInfo.isEnableTabUtility()))) drawerItems.add(createPrimaryDrawerItem(drawerActions[i], ICONS[i], fragments[i])); } @@ -993,8 +993,8 @@ private List getDrawerItems() { private SecondaryDrawerItem createSecondaryDrawerItem(String title, String icon, String fragmentID) { SecondaryDrawerItem item = new SecondaryDrawerItem(); item.withName(title) - .withIcon(GoogleMaterial.Icon.valueOf(icon)).withIconColorRes(R.color.primary) - .withTag(fragmentID); + .withIcon(GoogleMaterial.Icon.valueOf(icon)).withIconColorRes(R.color.primary) + .withTag(fragmentID); if (mSharedPrefs.darkThemeEnabled()) { item.withIconColorRes(R.color.white); item.withSelectedColorRes(R.color.primary); @@ -1007,8 +1007,8 @@ private SecondaryDrawerItem createSecondaryDrawerItem(String title, String icon, private PrimaryDrawerItem createPrimaryDrawerItem(String title, String icon, String fragmentID) { PrimaryDrawerItem item = new PrimaryDrawerItem(); item.withName(title) - .withIcon(GoogleMaterial.Icon.valueOf(icon)).withIconColorRes(R.color.primary) - .withTag(fragmentID); + .withIcon(GoogleMaterial.Icon.valueOf(icon)).withIconColorRes(R.color.primary) + .withTag(fragmentID); if (mSharedPrefs.darkThemeEnabled()) { item.withIconColorRes(R.color.white); item.withSelectedColorRes(R.color.primary); @@ -1137,11 +1137,11 @@ public void onResults(Bundle results) { recognitionProgressView.setBackgroundColor(color); } int[] colors = { - ContextCompat.getColor(this, R.color.material_amber_600), - ContextCompat.getColor(this, R.color.material_blue_600), - ContextCompat.getColor(this, R.color.material_deep_purple_600), - ContextCompat.getColor(this, R.color.material_green_600), - ContextCompat.getColor(this, R.color.material_orange_600) + ContextCompat.getColor(this, R.color.material_amber_600), + ContextCompat.getColor(this, R.color.material_blue_600), + ContextCompat.getColor(this, R.color.material_deep_purple_600), + ContextCompat.getColor(this, R.color.material_green_600), + ContextCompat.getColor(this, R.color.material_orange_600) }; recognitionProgressView.setColors(colors); recognitionProgressView.setSpeechRecognizer(speechRecognizer); @@ -1200,13 +1200,13 @@ public void run() { return true; case R.id.action_sort: SortDialog infoDialog = (latestFragment instanceof Logs) ? - new SortDialog( - this, - R.layout.dialog_switch_logs, - new String[]{getString(R.string.filter_all), getString(R.string.filter_normal), getString(R.string.filter_status), getString(R.string.filter_error)}) : - new SortDialog( - this, - R.layout.dialog_switch_logs, null); + new SortDialog( + this, + R.layout.dialog_switch_logs, + new String[]{getString(R.string.filter_all), getString(R.string.filter_normal), getString(R.string.filter_status), getString(R.string.filter_error)}) : + new SortDialog( + this, + R.layout.dialog_switch_logs, null); infoDialog.onDismissListener(new SortDialog.DismissListener() { @Override @DebugLog @@ -1249,7 +1249,7 @@ private void stopRecognitionAnimation() { @DebugLog private void showSpeechResults(Bundle results) { ArrayList matches = results - .getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); + .getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); if (matches == null) return; int jsonAction = -1; @@ -1344,35 +1344,35 @@ public void showServerDialog() { for (ServerInfo s : mServerUtil.getEnabledServerList()) { serverNames[count] = s.getServerName(); if (mServerUtil.getActiveServer() != null && - mServerUtil.getActiveServer().getServerName().equals(s.getServerName())) + mServerUtil.getActiveServer().getServerName().equals(s.getServerName())) selectionId = count; count++; } //show dialog with servers new MaterialDialog.Builder(this) - .title(R.string.choose_server) - .items(serverNames) - .itemsCallbackSingleChoice(selectionId, new MaterialDialog.ListCallbackSingleChoice() { - @Override - @DebugLog - public boolean onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) { - try { - for (ServerInfo s : mServerUtil.getEnabledServerList()) { - if (s.getServerName() != null && s.getServerName().contentEquals(text)) { - String message = String.format(getString(R.string.switch_to_server), s.getServerName()); - showSnackbar(message); - mServerUtil.setActiveServer(s); - MainActivity.this.recreate(); - } + .title(R.string.choose_server) + .items(serverNames) + .itemsCallbackSingleChoice(selectionId, new MaterialDialog.ListCallbackSingleChoice() { + @Override + @DebugLog + public boolean onSelection(MaterialDialog dialog, View itemView, int which, CharSequence text) { + try { + for (ServerInfo s : mServerUtil.getEnabledServerList()) { + if (s.getServerName() != null && s.getServerName().contentEquals(text)) { + String message = String.format(getString(R.string.switch_to_server), s.getServerName()); + showSnackbar(message); + mServerUtil.setActiveServer(s); + MainActivity.this.recreate(); } - return false; - } catch (Exception ex) { - return false; } + return false; + } catch (Exception ex) { + return false; } - }) - .show(); + } + }) + .show(); } /** diff --git a/app/src/main/java/nl/hnogames/domoticz/NFCSettingsActivity.java b/app/src/main/java/nl/hnogames/domoticz/NFCSettingsActivity.java index 962189aab..4c7d70b6b 100644 --- a/app/src/main/java/nl/hnogames/domoticz/NFCSettingsActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/NFCSettingsActivity.java @@ -69,16 +69,16 @@ public class NFCSettingsActivity extends AppCompatAssistActivity implements NFCClickListener { // list of NFC technologies detected: private final String[][] techList = new String[][]{ - new String[]{ - NfcA.class.getName(), - NfcB.class.getName(), - NfcF.class.getName(), - NfcV.class.getName(), - IsoDep.class.getName(), - MifareClassic.class.getName(), - MifareUltralight.class.getName(), - Ndef.class.getName() - } + new String[]{ + NfcA.class.getName(), + NfcB.class.getName(), + NfcF.class.getName(), + NfcV.class.getName(), + IsoDep.class.getName(), + MifareClassic.class.getName(), + MifareUltralight.class.getName(), + Ndef.class.getName() + } }; boolean result = false; @@ -178,22 +178,22 @@ protected void onNewIntent(Intent intent) { if (newTagFound) { UsefulBits.showSnackbar(this, coordinatorLayout, getString(R.string.nfc_tag_found) + ": " + tagID, Snackbar.LENGTH_SHORT); new MaterialDialog.Builder(this) - .title(R.string.nfc_tag_found) - .content(R.string.nfc_tag_name) - .inputType(InputType.TYPE_CLASS_TEXT) - .input(R.string.category_nfc, 0, new MaterialDialog.InputCallback() { - @Override - public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { - if (!UsefulBits.isEmpty(String.valueOf(input))) { - UsefulBits.showSnackbar(NFCSettingsActivity.this, coordinatorLayout, getString(R.string.nfc_saved) + ": " + input, Snackbar.LENGTH_SHORT); - NFCInfo newNFC = new NFCInfo(); - newNFC.setId(tagID); - newNFC.setName(String.valueOf(input)); - updateNFC(newNFC); - } - busyWithTag = false; + .title(R.string.nfc_tag_found) + .content(R.string.nfc_tag_name) + .inputType(InputType.TYPE_CLASS_TEXT) + .input(R.string.category_nfc, 0, new MaterialDialog.InputCallback() { + @Override + public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { + if (!UsefulBits.isEmpty(String.valueOf(input))) { + UsefulBits.showSnackbar(NFCSettingsActivity.this, coordinatorLayout, getString(R.string.nfc_saved) + ": " + input, Snackbar.LENGTH_SHORT); + NFCInfo newNFC = new NFCInfo(); + newNFC.setId(tagID); + newNFC.setName(String.valueOf(input)); + updateNFC(newNFC); } - }).show(); + busyWithTag = false; + } + }).show(); } else { UsefulBits.showSnackbar(NFCSettingsActivity.this, coordinatorLayout, R.string.nfc_exists, Snackbar.LENGTH_SHORT); busyWithTag = false; @@ -227,20 +227,20 @@ public boolean onItemLongClick(AdapterView parent, View view, final int posit private void showEditDialog(final NFCInfo mNFCInfo) { busyWithTag = true; new MaterialDialog.Builder(this) - .title(R.string.nfc_tag_edit) - .content(R.string.nfc_tag_name) - .inputType(InputType.TYPE_CLASS_TEXT) - .negativeText(R.string.cancel) - .input(this.getString(R.string.category_nfc), mNFCInfo.getName(), new MaterialDialog.InputCallback() { - @Override - public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { - if (!UsefulBits.isEmpty(String.valueOf(input))) { - mNFCInfo.setName(String.valueOf(input)); - updateNFC(mNFCInfo); - } - busyWithTag = false; + .title(R.string.nfc_tag_edit) + .content(R.string.nfc_tag_name) + .inputType(InputType.TYPE_CLASS_TEXT) + .negativeText(R.string.cancel) + .input(this.getString(R.string.category_nfc), mNFCInfo.getName(), new MaterialDialog.InputCallback() { + @Override + public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { + if (!UsefulBits.isEmpty(String.valueOf(input))) { + mNFCInfo.setName(String.valueOf(input)); + updateNFC(mNFCInfo); } - }).show(); + busyWithTag = false; + } + }).show(); } private void getSwitchesAndShowSwitchesDialog(final NFCInfo nfcInfo) { @@ -260,19 +260,19 @@ public void onReceiveDevice(DevicesInfo mDevicesInfo) { @DebugLog public void onError(Exception error) { UsefulBits.showSnackbarWithAction(NFCSettingsActivity.this, coordinatorLayout, NFCSettingsActivity.this.getString(R.string.unable_to_get_switches), Snackbar.LENGTH_SHORT, - null, new View.OnClickListener() { - @Override - public void onClick(View v) { - getSwitchesAndShowSwitchesDialog(nfcInfo); - } - }, NFCSettingsActivity.this.getString(R.string.retry)); + null, new View.OnClickListener() { + @Override + public void onClick(View v) { + getSwitchesAndShowSwitchesDialog(nfcInfo); + } + }, NFCSettingsActivity.this.getString(R.string.retry)); } }, 0, "all"); } private void showSwitchesDialog( - final NFCInfo nfcInfo, - ArrayList switches) { + final NFCInfo nfcInfo, + ArrayList switches) { final ArrayList supportedSwitches = new ArrayList<>(); for (DevicesInfo d : switches) { @@ -281,9 +281,9 @@ private void showSwitchesDialog( } SwitchDialog infoDialog = new SwitchDialog( - NFCSettingsActivity.this, supportedSwitches, - R.layout.dialog_switch_logs, - domoticz); + NFCSettingsActivity.this, supportedSwitches, + R.layout.dialog_switch_logs, + domoticz); infoDialog.onDismissListener(new SwitchDialog.DismissListener() { @Override @@ -312,16 +312,16 @@ public void onDismiss(int selectedSwitchIDX, String selectedSwitchPassword, Stri private void showSelectorDialog(final NFCInfo nfcInfo, DevicesInfo selector) { final ArrayList levelNames = selector.getLevelNames(); new MaterialDialog.Builder(this) - .title(R.string.selector_value) - .items(levelNames) - .itemsCallback(new MaterialDialog.ListCallback() { - @Override - public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { - nfcInfo.setValue(String.valueOf(text)); - updateNFC(nfcInfo); - } - }) - .show(); + .title(R.string.selector_value) + .items(levelNames) + .itemsCallback(new MaterialDialog.ListCallback() { + @Override + public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { + nfcInfo.setValue(String.valueOf(text)); + updateNFC(nfcInfo); + } + }) + .show(); } public void updateNFC(NFCInfo nfcInfo) { @@ -347,21 +347,21 @@ public void updateNFC(NFCInfo nfcInfo) { private boolean showNoDeviceAttachedDialog(final NFCInfo nfcInfo) { new MaterialDialog.Builder(this) - .title(R.string.noSwitchSelected_title) - .content(getString(R.string.noSwitchSelected_explanation_nfc) - + UsefulBits.newLine() - + UsefulBits.newLine() - + getString(R.string.noSwitchSelected_connectOneNow)) - .positiveText(R.string.yes) - .negativeText(R.string.no) - .onPositive(new MaterialDialog.SingleButtonCallback() { - @Override - public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { - getSwitchesAndShowSwitchesDialog(nfcInfo); - result = true; - } - }) - .show(); + .title(R.string.noSwitchSelected_title) + .content(getString(R.string.noSwitchSelected_explanation_nfc) + + UsefulBits.newLine() + + UsefulBits.newLine() + + getString(R.string.noSwitchSelected_connectOneNow)) + .positiveText(R.string.yes) + .negativeText(R.string.no) + .onPositive(new MaterialDialog.SingleButtonCallback() { + @Override + public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { + getSwitchesAndShowSwitchesDialog(nfcInfo); + result = true; + } + }) + .show(); return result; } @@ -400,7 +400,7 @@ private void showRemoveUndoSnackbar(final NFCInfo nfcInfo) { // Show snackbar with undo option String text = String.format(getString(R.string.something_deleted), - getString(R.string.nfc)); + getString(R.string.nfc)); UsefulBits.showSnackbarWithAction(this, coordinatorLayout, text, Snackbar.LENGTH_SHORT, new Snackbar.Callback() { @Override diff --git a/app/src/main/java/nl/hnogames/domoticz/PlanActivity.java b/app/src/main/java/nl/hnogames/domoticz/PlanActivity.java index 3805dec9e..fd7d1a24c 100644 --- a/app/src/main/java/nl/hnogames/domoticz/PlanActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/PlanActivity.java @@ -45,8 +45,8 @@ public class PlanActivity extends AppCompatAssistActivity { @DebugLog public ConfigInfo getConfig() { return mServerUtil != null && mServerUtil.getActiveServer() != null ? - mServerUtil.getActiveServer().getConfigInfo(this) : - null; + mServerUtil.getActiveServer().getConfigInfo(this) : + null; } private void setupAutoRefresh() { diff --git a/app/src/main/java/nl/hnogames/domoticz/Preference/Preference.java b/app/src/main/java/nl/hnogames/domoticz/Preference/Preference.java index 1f692bfef..6ab7331ca 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Preference/Preference.java +++ b/app/src/main/java/nl/hnogames/domoticz/Preference/Preference.java @@ -526,24 +526,24 @@ public boolean onPreferenceChange(android.preference.Preference preference, Obje } else { if ((boolean) newValue) { new MaterialDialog.Builder(mContext) - .title(R.string.wizard_widgets) - .content(R.string.widget_warning) - .positiveText(R.string.ok) - .negativeText(R.string.cancel) - .onPositive(new MaterialDialog.SingleButtonCallback() { - @Override - public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { - mSharedPrefs.SetWidgetsEnabled(true); - ((SettingsActivity) getActivity()).reloadSettings(); - } - }) - .onNegative(new MaterialDialog.SingleButtonCallback() { - @Override - public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { - mSharedPrefs.SetWidgetsEnabled(false); - } - }) - .show(); + .title(R.string.wizard_widgets) + .content(R.string.widget_warning) + .positiveText(R.string.ok) + .negativeText(R.string.cancel) + .onPositive(new MaterialDialog.SingleButtonCallback() { + @Override + public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { + mSharedPrefs.SetWidgetsEnabled(true); + ((SettingsActivity) getActivity()).reloadSettings(); + } + }) + .onNegative(new MaterialDialog.SingleButtonCallback() { + @Override + public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { + mSharedPrefs.SetWidgetsEnabled(false); + } + }) + .show(); return false; } else { return true; @@ -593,9 +593,9 @@ public boolean onPreferenceClick(android.preference.Preference preference) { if (logs != null && logs.size() > 0) { Collections.reverse(logs); new MaterialDialog.Builder(mContext) - .title(mContext.getString(R.string.notification_show_title)) - .items((CharSequence[]) logs.toArray(new String[0])) - .show(); + .title(mContext.getString(R.string.notification_show_title)) + .items((CharSequence[]) logs.toArray(new String[0])) + .show(); } else UsefulBits.showSimpleToast(mContext, getString(R.string.notification_show_nothing), Toast.LENGTH_LONG); return true; @@ -636,19 +636,19 @@ public boolean onPreferenceClick(android.preference.Preference preference) { public boolean onPreferenceClick(android.preference.Preference preference) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { new MaterialDialog.Builder(mContext) - .title(R.string.category_Reset) - .content(R.string.are_you_sure_clear_settings) - .positiveText(R.string.ok) - .negativeText(R.string.cancel) - .onPositive(new MaterialDialog.SingleButtonCallback() { - @SuppressLint("NewApi") - @Override - public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { - ((ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE)) - .clearApplicationUserData(); - } - }) - .show(); + .title(R.string.category_Reset) + .content(R.string.are_you_sure_clear_settings) + .positiveText(R.string.ok) + .negativeText(R.string.cancel) + .onPositive(new MaterialDialog.SingleButtonCallback() { + @SuppressLint("NewApi") + @Override + public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { + ((ActivityManager) mContext.getSystemService(Context.ACTIVITY_SERVICE)) + .clearApplicationUserData(); + } + }) + .show(); } else { startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0); } @@ -684,18 +684,18 @@ public boolean onPreferenceChange(android.preference.Preference preference, Obje return false; } else { new MaterialDialog.Builder(mContext) - .title(R.string.category_startup_security) - .content(R.string.fingerprint_sure) - .positiveText(R.string.ok) - .negativeText(R.string.cancel) - .onPositive(new MaterialDialog.SingleButtonCallback() { - @Override - public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { - mSharedPrefs.setStartupSecurityEnabled(true); - ((SettingsActivity) getActivity()).reloadSettings(); - } - }) - .show(); + .title(R.string.category_startup_security) + .content(R.string.fingerprint_sure) + .positiveText(R.string.ok) + .negativeText(R.string.cancel) + .onPositive(new MaterialDialog.SingleButtonCallback() { + @Override + public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { + mSharedPrefs.setStartupSecurityEnabled(true); + ((SettingsActivity) getActivity()).reloadSettings(); + } + }) + .show(); return false; } @@ -711,9 +711,9 @@ private void GetVersion() { PackageInfo pInfo = null; try { pInfo = mContext - .getPackageManager() - .getPackageInfo(mContext - .getPackageName(), 0); + .getPackageManager() + .getPackageInfo(mContext + .getPackageName(), 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } @@ -731,8 +731,8 @@ private Boolean checkBiometricSupport() { return false; } if (ActivityCompat.checkSelfPermission(mContext, - Manifest.permission.USE_BIOMETRIC) != - PackageManager.PERMISSION_GRANTED) { + Manifest.permission.USE_BIOMETRIC) != + PackageManager.PERMISSION_GRANTED) { return false; } if (packageManager.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) @@ -784,20 +784,20 @@ public void onError(Exception error) { private void showRestartMessage() { new MaterialDialog.Builder(mContext) - .title(R.string.restart_required_title) - .content(mContext.getString(R.string.restart_required_msg) - + UsefulBits.newLine() - + UsefulBits.newLine() - + mContext.getString(R.string.restart_now)) - .positiveText(R.string.yes) - .negativeText(R.string.no) - .onPositive(new MaterialDialog.SingleButtonCallback() { - @Override - public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { - UsefulBits.restartApplication(getActivity()); - } - }) - .show(); + .title(R.string.restart_required_title) + .content(mContext.getString(R.string.restart_required_msg) + + UsefulBits.newLine() + + UsefulBits.newLine() + + mContext.getString(R.string.restart_now)) + .positiveText(R.string.yes) + .negativeText(R.string.no) + .onPositive(new MaterialDialog.SingleButtonCallback() { + @Override + public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { + UsefulBits.restartApplication(getActivity()); + } + }) + .show(); } private void handleInfoAndAbout() { @@ -830,29 +830,29 @@ public boolean onPreferenceClick(android.preference.Preference preference) { private void handleImportExportButtons() { SettingsFile = new File(Environment.getExternalStorageDirectory(), - "/Domoticz/DomoticzSettings.txt"); + "/Domoticz/DomoticzSettings.txt"); final String sPath = SettingsFile.getPath(). - substring(0, SettingsFile.getPath().lastIndexOf("/")); + substring(0, SettingsFile.getPath().lastIndexOf("/")); //noinspection unused boolean mkdirsResultIsOk = new File(sPath + "/").mkdirs(); android.preference.Preference exportButton = findPreference("export_settings"); exportButton.setOnPreferenceClickListener( - new android.preference.Preference.OnPreferenceClickListener() { - @Override - public boolean onPreferenceClick(android.preference.Preference preference) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (!PermissionsUtil.canAccessStorage(mContext)) { - permissionHelper.request(PermissionsUtil.INITIAL_STORAGE_PERMS); - } else - exportSettings(); + new android.preference.Preference.OnPreferenceClickListener() { + @Override + public boolean onPreferenceClick(android.preference.Preference preference) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (!PermissionsUtil.canAccessStorage(mContext)) { + permissionHelper.request(PermissionsUtil.INITIAL_STORAGE_PERMS); } else exportSettings(); + } else + exportSettings(); - return false; - } - }); + return false; + } + }); android.preference.Preference importButton = findPreference("import_settings"); importButton.setOnPreferenceClickListener(new android.preference.Preference.OnPreferenceClickListener() { @Override @@ -900,14 +900,14 @@ private void showPremiumSnackbar(final String category) { public void run() { if (getView() != null) { Snackbar.make(getView(), category + " " + getString(R.string.premium_feature), Snackbar.LENGTH_LONG) - .setAction(R.string.upgrade, new View.OnClickListener() { - @Override - public void onClick(View view) { - UsefulBits.openPremiumAppStore(mContext); - } - }) - .setActionTextColor(ContextCompat.getColor(mContext, R.color.material_blue_600)) - .show(); + .setAction(R.string.upgrade, new View.OnClickListener() { + @Override + public void onClick(View view) { + UsefulBits.openPremiumAppStore(mContext); + } + }) + .setActionTextColor(ContextCompat.getColor(mContext, R.color.material_blue_600)) + .show(); } } }, (300)); diff --git a/app/src/main/java/nl/hnogames/domoticz/QRCodeCaptureActivity.java b/app/src/main/java/nl/hnogames/domoticz/QRCodeCaptureActivity.java index 653c9e8cc..0e8c07663 100644 --- a/app/src/main/java/nl/hnogames/domoticz/QRCodeCaptureActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/QRCodeCaptureActivity.java @@ -42,7 +42,7 @@ public class QRCodeCaptureActivity extends AppCompatAssistActivity implements ZX public void onCreate(Bundle state) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { setSystemUiFlags(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | - View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); + View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); setFullscreenFlags(); } @@ -60,7 +60,7 @@ private void setSystemUiFlags(int flags) { private void setFullscreenFlags() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { int fullscreenFlags = View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | - View.SYSTEM_UI_FLAG_FULLSCREEN; + View.SYSTEM_UI_FLAG_FULLSCREEN; setSystemUiFlags(fullscreenFlags); } diff --git a/app/src/main/java/nl/hnogames/domoticz/QRCodeSettingsActivity.java b/app/src/main/java/nl/hnogames/domoticz/QRCodeSettingsActivity.java index 638165c7a..e6e18566a 100644 --- a/app/src/main/java/nl/hnogames/domoticz/QRCodeSettingsActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/QRCodeSettingsActivity.java @@ -126,19 +126,19 @@ public boolean onItemLongClick(AdapterView parent, View view, final int posit private void showEditDialog(final QRCodeInfo mQRCodeInfo) { new MaterialDialog.Builder(this) - .title(R.string.qrcode_edit) - .content(R.string.qrcode_name) - .inputType(InputType.TYPE_CLASS_TEXT) - .negativeText(R.string.cancel) - .input(this.getString(R.string.category_QRCode), mQRCodeInfo.getName(), new MaterialDialog.InputCallback() { - @Override - public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { - if (!UsefulBits.isEmpty(String.valueOf(input))) { - mQRCodeInfo.setName(String.valueOf(input)); - updateQRCode(mQRCodeInfo); - } + .title(R.string.qrcode_edit) + .content(R.string.qrcode_name) + .inputType(InputType.TYPE_CLASS_TEXT) + .negativeText(R.string.cancel) + .input(this.getString(R.string.category_QRCode), mQRCodeInfo.getName(), new MaterialDialog.InputCallback() { + @Override + public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { + if (!UsefulBits.isEmpty(String.valueOf(input))) { + mQRCodeInfo.setName(String.valueOf(input)); + updateQRCode(mQRCodeInfo); } - }).show(); + } + }).show(); } private void getSwitchesAndShowSwitchesDialog(final QRCodeInfo qrInfo) { @@ -158,19 +158,19 @@ public void onReceiveDevice(DevicesInfo mDevicesInfo) { @DebugLog public void onError(Exception error) { UsefulBits.showSnackbarWithAction(QRCodeSettingsActivity.this, coordinatorLayout, QRCodeSettingsActivity.this.getString(R.string.unable_to_get_switches), Snackbar.LENGTH_SHORT, - null, new View.OnClickListener() { - @Override - public void onClick(View v) { - getSwitchesAndShowSwitchesDialog(qrInfo); - } - }, QRCodeSettingsActivity.this.getString(R.string.retry)); + null, new View.OnClickListener() { + @Override + public void onClick(View v) { + getSwitchesAndShowSwitchesDialog(qrInfo); + } + }, QRCodeSettingsActivity.this.getString(R.string.retry)); } }, 0, "all"); } private void showSwitchesDialog( - final QRCodeInfo qrcodeInfo, - final ArrayList switches) { + final QRCodeInfo qrcodeInfo, + final ArrayList switches) { final ArrayList supportedSwitches = new ArrayList<>(); for (DevicesInfo d : switches) { @@ -179,9 +179,9 @@ private void showSwitchesDialog( } SwitchDialog infoDialog = new SwitchDialog( - QRCodeSettingsActivity.this, supportedSwitches, - R.layout.dialog_switch_logs, - domoticz); + QRCodeSettingsActivity.this, supportedSwitches, + R.layout.dialog_switch_logs, + domoticz); infoDialog.onDismissListener(new SwitchDialog.DismissListener() { @Override @@ -211,16 +211,16 @@ public void onDismiss(int selectedSwitchIDX, String selectedSwitchPassword, Stri private void showSelectorDialog(final QRCodeInfo qrcodeInfo, DevicesInfo selector) { final ArrayList levelNames = selector.getLevelNames(); new MaterialDialog.Builder(this) - .title(R.string.selector_value) - .items(levelNames) - .itemsCallback(new MaterialDialog.ListCallback() { - @Override - public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { - qrcodeInfo.setValue(String.valueOf(text)); - updateQRCode(qrcodeInfo); - } - }) - .show(); + .title(R.string.selector_value) + .items(levelNames) + .itemsCallback(new MaterialDialog.ListCallback() { + @Override + public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { + qrcodeInfo.setValue(String.valueOf(text)); + updateQRCode(qrcodeInfo); + } + }) + .show(); } public void updateQRCode(QRCodeInfo qrcodeInfo) { @@ -246,21 +246,21 @@ public void updateQRCode(QRCodeInfo qrcodeInfo) { private boolean showNoDeviceAttachedDialog(final QRCodeInfo qrcodeInfo) { new MaterialDialog.Builder(this) - .title(R.string.noSwitchSelected_title) - .content(getString(R.string.noSwitchSelected_explanation_qrcode) - + UsefulBits.newLine() - + UsefulBits.newLine() - + getString(R.string.noSwitchSelected_connectOneNow)) - .positiveText(R.string.yes) - .negativeText(R.string.no) - .onPositive(new MaterialDialog.SingleButtonCallback() { - @Override - public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { - getSwitchesAndShowSwitchesDialog(qrcodeInfo); - result = true; - } - }) - .show(); + .title(R.string.noSwitchSelected_title) + .content(getString(R.string.noSwitchSelected_explanation_qrcode) + + UsefulBits.newLine() + + UsefulBits.newLine() + + getString(R.string.noSwitchSelected_connectOneNow)) + .positiveText(R.string.yes) + .negativeText(R.string.no) + .onPositive(new MaterialDialog.SingleButtonCallback() { + @Override + public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { + getSwitchesAndShowSwitchesDialog(qrcodeInfo); + result = true; + } + }) + .show(); return result; } @@ -287,7 +287,7 @@ private void showRemoveUndoSnackbar(final QRCodeInfo qrcodeInfo) { // Show snackbar with undo option String text = String.format(getString(R.string.something_deleted), - getString(R.string.qrcode)); + getString(R.string.qrcode)); UsefulBits.showSnackbarWithAction(this, coordinatorLayout, text, Snackbar.LENGTH_SHORT, new Snackbar.Callback() { @Override @@ -370,21 +370,21 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { if (newTagFound) { UsefulBits.showSnackbar(this, coordinatorLayout, getString(R.string.qrcode_found) + ": " + QR_Code_ID, Snackbar.LENGTH_SHORT); new MaterialDialog.Builder(this) - .title(R.string.qrcode_found) - .content(R.string.qrcode_name) - .inputType(InputType.TYPE_CLASS_TEXT) - .input(R.string.category_QRCode, 0, new MaterialDialog.InputCallback() { - @Override - public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { - if (!UsefulBits.isEmpty(String.valueOf(input))) { - UsefulBits.showSnackbar(QRCodeSettingsActivity.this, coordinatorLayout, getString(R.string.qrcode_saved) + ": " + input, Snackbar.LENGTH_SHORT); - QRCodeInfo qrCodeInfo = new QRCodeInfo(); - qrCodeInfo.setId(QR_Code_ID); - qrCodeInfo.setName(String.valueOf(input)); - updateQRCode(qrCodeInfo); - } + .title(R.string.qrcode_found) + .content(R.string.qrcode_name) + .inputType(InputType.TYPE_CLASS_TEXT) + .input(R.string.category_QRCode, 0, new MaterialDialog.InputCallback() { + @Override + public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { + if (!UsefulBits.isEmpty(String.valueOf(input))) { + UsefulBits.showSnackbar(QRCodeSettingsActivity.this, coordinatorLayout, getString(R.string.qrcode_saved) + ": " + input, Snackbar.LENGTH_SHORT); + QRCodeInfo qrCodeInfo = new QRCodeInfo(); + qrCodeInfo.setId(QR_Code_ID); + qrCodeInfo.setName(String.valueOf(input)); + updateQRCode(qrCodeInfo); } - }).show(); + } + }).show(); } else { UsefulBits.showSnackbar(this, coordinatorLayout, R.string.qrcode_exists, Snackbar.LENGTH_SHORT); } diff --git a/app/src/main/java/nl/hnogames/domoticz/ServerListSettingsActivity.java b/app/src/main/java/nl/hnogames/domoticz/ServerListSettingsActivity.java index 7f57854b7..b8af6c808 100644 --- a/app/src/main/java/nl/hnogames/domoticz/ServerListSettingsActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/ServerListSettingsActivity.java @@ -157,7 +157,7 @@ private void showRemoveUndoSnackbar(final ServerInfo serverInfo) { removeServerFromListView(serverInfo); UsefulBits.showSnackbarWithAction(this, coordinatorLayout, String.format(getString(R.string.something_deleted), - getString(R.string.server)), Snackbar.LENGTH_SHORT, new Snackbar.Callback() { + getString(R.string.server)), Snackbar.LENGTH_SHORT, new Snackbar.Callback() { @Override public void onDismissed(Snackbar snackbar, int event) { super.onDismissed(snackbar, event); diff --git a/app/src/main/java/nl/hnogames/domoticz/ServerSettingsActivity.java b/app/src/main/java/nl/hnogames/domoticz/ServerSettingsActivity.java index 5cd5ed303..115741b90 100644 --- a/app/src/main/java/nl/hnogames/domoticz/ServerSettingsActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/ServerSettingsActivity.java @@ -75,8 +75,8 @@ protected void onCreate(Bundle savedInstanceState) { if (!addNew && UsefulBits.isEmpty(updateName)) { Fragment serverSettings = WelcomePage3.newInstance(SETTINGS); getSupportFragmentManager().beginTransaction() - .replace(android.R.id.content, serverSettings) - .commit(); + .replace(android.R.id.content, serverSettings) + .commit(); } else { SetupServerSettings serverSettings = SetupServerSettings.newInstance(SETTINGS); @@ -88,8 +88,8 @@ protected void onCreate(Bundle savedInstanceState) { } getSupportFragmentManager().beginTransaction() - .replace(android.R.id.content, serverSettings) - .commit(); + .replace(android.R.id.content, serverSettings) + .commit(); } } @@ -127,17 +127,17 @@ public void ServerAdded(Boolean added) { public void onBackPressed() { if (addNew) { new AlertDialog.Builder(this) - .setIcon(android.R.drawable.ic_dialog_alert) - .setTitle(getString(R.string.dont_save_new_server)) - .setMessage(R.string.are_you_sure) - .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - ServerCancel(); - } - }) - .setNegativeButton(R.string.cancel, null) - .show(); + .setIcon(android.R.drawable.ic_dialog_alert) + .setTitle(getString(R.string.dont_save_new_server)) + .setMessage(R.string.are_you_sure) + .setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + ServerCancel(); + } + }) + .setNegativeButton(R.string.cancel, null) + .show(); } else super.onBackPressed(); } diff --git a/app/src/main/java/nl/hnogames/domoticz/Service/BluetoothConnectionReceiver.java b/app/src/main/java/nl/hnogames/domoticz/Service/BluetoothConnectionReceiver.java index 45a221dac..da2c1e97e 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Service/BluetoothConnectionReceiver.java +++ b/app/src/main/java/nl/hnogames/domoticz/Service/BluetoothConnectionReceiver.java @@ -49,7 +49,7 @@ public void onReceive(Context context, Intent intent) { if (connectedDevice != null && connectedDevice.isEnabled()) { handleSwitch(context, connectedDevice.getSwitchIdx(), connectedDevice.getSwitchPassword(), (BluetoothDevice.ACTION_ACL_CONNECTED.equals(intent.getAction())), - connectedDevice.getValue(), connectedDevice.isSceneOrGroup()); + connectedDevice.getValue(), connectedDevice.isSceneOrGroup()); Toast.makeText(context, context.getString(R.string.bluetooth) + " " + connectedDevice.getName(), Toast.LENGTH_SHORT).show(); } else { Toast.makeText(context, context.getString(R.string.bluetooth_disabled), Toast.LENGTH_SHORT).show(); @@ -92,8 +92,8 @@ public void onReceiveDevice(DevicesInfo mDevicesInfo) { } if (mDevicesInfo.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDS || - mDevicesInfo.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDPERCENTAGE || - mDevicesInfo.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.DOORLOCKINVERTED) { + mDevicesInfo.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDPERCENTAGE || + mDevicesInfo.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.DOORLOCKINVERTED) { if (checked) jsonAction = DomoticzValues.Device.Switch.Action.OFF; else diff --git a/app/src/main/java/nl/hnogames/domoticz/Service/FCMMessageInstanceService.java b/app/src/main/java/nl/hnogames/domoticz/Service/FCMMessageInstanceService.java index 8214ff5a7..91da1fffc 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Service/FCMMessageInstanceService.java +++ b/app/src/main/java/nl/hnogames/domoticz/Service/FCMMessageInstanceService.java @@ -42,7 +42,7 @@ public void onMessageReceived(RemoteMessage remoteMessage) { } if (!UsefulBits.isEmpty(subject) && !UsefulBits.isEmpty(body) && - !body.equals(subject)) { + !body.equals(subject)) { String deviceid = decode(data.containsKey("deviceid") ? data.get("deviceid").toString() : ""); if (!UsefulBits.isEmpty(deviceid) && isDigitsOnly(deviceid) && Integer.valueOf(deviceid) > 0) diff --git a/app/src/main/java/nl/hnogames/domoticz/Service/GeofenceTransitionsIntentService.java b/app/src/main/java/nl/hnogames/domoticz/Service/GeofenceTransitionsIntentService.java index 167b195e7..35421019d 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Service/GeofenceTransitionsIntentService.java +++ b/app/src/main/java/nl/hnogames/domoticz/Service/GeofenceTransitionsIntentService.java @@ -72,16 +72,16 @@ private void handleEnterExit(GeofencingEvent geoFenceEvent) { if (Geofence.GEOFENCE_TRANSITION_ENTER == transitionType || Geofence.GEOFENCE_TRANSITION_DWELL == transitionType) { for (Geofence geofence : geoFenceEvent.getTriggeringGeofences()) { LocationInfo locationFound = - mSharedPrefs.getLocation(Integer.valueOf(geofence.getRequestId())); + mSharedPrefs.getLocation(Integer.valueOf(geofence.getRequestId())); Log.d(TAG, "Triggered entering a geofence location: " - + locationFound.getName()); + + locationFound.getName()); if (mSharedPrefs.isGeofenceNotificationsEnabled()) { notificationTitle = String.format( - context.getString(R.string.geofence_location_entering), locationFound.getName()); + context.getString(R.string.geofence_location_entering), locationFound.getName()); notificationDescription = context.getString(R.string.geofence_location_entering_text); NotificationUtil.sendSimpleNotification(notificationTitle, - notificationDescription, 0, context); + notificationDescription, 0, context); } if (locationFound.getSwitchIdx() > 0) handleSwitch(context, locationFound.getSwitchIdx(), locationFound.getSwitchPassword(), true, locationFound.getValue(), locationFound.isSceneOrGroup()); @@ -89,17 +89,17 @@ private void handleEnterExit(GeofencingEvent geoFenceEvent) { } else if (Geofence.GEOFENCE_TRANSITION_EXIT == transitionType) { for (Geofence geofence : geoFenceEvent.getTriggeringGeofences()) { LocationInfo locationFound - = mSharedPrefs.getLocation(Integer.valueOf(geofence.getRequestId())); + = mSharedPrefs.getLocation(Integer.valueOf(geofence.getRequestId())); Log.d(TAG, "Triggered leaving a geofence location: " - + locationFound.getName()); + + locationFound.getName()); if (mSharedPrefs.isGeofenceNotificationsEnabled()) { notificationTitle = String.format( - context.getString(R.string.geofence_location_leaving), - locationFound.getName()); + context.getString(R.string.geofence_location_leaving), + locationFound.getName()); notificationDescription = context.getString(R.string.geofence_location_leaving_text); NotificationUtil.sendSimpleNotification(notificationTitle, - notificationDescription, 0, context); + notificationDescription, 0, context); } if (locationFound.getSwitchIdx() > 0) handleSwitch(context, locationFound.getSwitchIdx(), locationFound.getSwitchPassword(), false, locationFound.getValue(), locationFound.isSceneOrGroup()); @@ -147,8 +147,8 @@ public void onReceiveDevice(DevicesInfo mDevicesInfo) { } if (mDevicesInfo.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDS || - mDevicesInfo.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDPERCENTAGE || - mDevicesInfo.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.DOORLOCKINVERTED) { + mDevicesInfo.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDPERCENTAGE || + mDevicesInfo.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.DOORLOCKINVERTED) { if (checked) jsonAction = DomoticzValues.Device.Switch.Action.OFF; else diff --git a/app/src/main/java/nl/hnogames/domoticz/Service/NFCServiceActivity.java b/app/src/main/java/nl/hnogames/domoticz/Service/NFCServiceActivity.java index f186bc13b..5092d2a0c 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Service/NFCServiceActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/Service/NFCServiceActivity.java @@ -98,8 +98,8 @@ public void onReceiveDevice(DevicesInfo mDevicesInfo) { if (!isSceneOrGroup) { if (mDevicesInfo.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDS || - mDevicesInfo.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDPERCENTAGE || - mDevicesInfo.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.DOORLOCKINVERTED) { + mDevicesInfo.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDPERCENTAGE || + mDevicesInfo.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.DOORLOCKINVERTED) { if (!mDevicesInfo.getStatusBoolean()) { jsonAction = DomoticzValues.Device.Switch.Action.OFF; if (!UsefulBits.isEmpty(value)) { diff --git a/app/src/main/java/nl/hnogames/domoticz/Service/WearMessageListenerService.java b/app/src/main/java/nl/hnogames/domoticz/Service/WearMessageListenerService.java index dc9a55f73..eccc5e942 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Service/WearMessageListenerService.java +++ b/app/src/main/java/nl/hnogames/domoticz/Service/WearMessageListenerService.java @@ -71,7 +71,7 @@ public void run() { NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(mApiClient).await(); for (Node node : nodes.getNodes()) { MessageApi.SendMessageResult result = Wearable.MessageApi.sendMessage( - mApiClient, node.getId(), path, text.getBytes()).await(); + mApiClient, node.getId(), path, text.getBytes()).await(); if (result.getStatus().isSuccess()) { Log.v("WEAR", "Message: {" + "my object" + "} sent to: " + node.getDisplayName()); @@ -132,7 +132,7 @@ public void onMessageReceived(MessageEvent messageEvent) { default: throw new NullPointerException( - "Toggle event received from wear device for unsupported switch type: " + selectedSwitch.getSwitchTypeVal()); + "Toggle event received from wear device for unsupported switch type: " + selectedSwitch.getSwitchTypeVal()); } //now send latest status getSwitches(); @@ -182,7 +182,7 @@ private void processAllSwitches(ArrayList extendedStatusSwitches) { String name = mDevicesInfo.getName(); if (!name.startsWith(Domoticz.HIDDEN_CHARACTER) && - mDevicesInfo.getFavoriteBoolean()) {//only dashboard switches.. + mDevicesInfo.getFavoriteBoolean()) {//only dashboard switches.. supportedSwitches.add(mDevicesInfo); } } @@ -221,9 +221,9 @@ private void processAllSwitches(ArrayList extendedStatusSwitches) { private void initGoogleApiClient() { mApiClient = new GoogleApiClient.Builder(this) - .addApi(Wearable.API) - .addConnectionCallbacks(this) - .build(); + .addApi(Wearable.API) + .addConnectionCallbacks(this) + .build(); mApiClient.connect(); } @@ -244,8 +244,8 @@ public void onSwitchToggle(DevicesInfo toggledDevice) { boolean checked = !toggledDevice.getStatusBoolean(); if (toggledDevice.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDS || - toggledDevice.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDPERCENTAGE || - toggledDevice.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.DOORLOCKINVERTED) { + toggledDevice.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDPERCENTAGE || + toggledDevice.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.DOORLOCKINVERTED) { if (checked) jsonAction = DomoticzValues.Device.Switch.Action.OFF; else jsonAction = DomoticzValues.Device.Switch.Action.ON; } else { diff --git a/app/src/main/java/nl/hnogames/domoticz/SettingsActivity.java b/app/src/main/java/nl/hnogames/domoticz/SettingsActivity.java index 305642578..0c7c178e1 100644 --- a/app/src/main/java/nl/hnogames/domoticz/SettingsActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/SettingsActivity.java @@ -47,7 +47,7 @@ protected void onCreate(Bundle savedInstanceState) { if (getSupportActionBar() != null) getSupportActionBar().setDisplayHomeAsUpEnabled(true); getFragmentManager().beginTransaction().replace(android.R.id.content, - new Preference()).commit(); + new Preference()).commit(); } @Override diff --git a/app/src/main/java/nl/hnogames/domoticz/SpeechSettingsActivity.java b/app/src/main/java/nl/hnogames/domoticz/SpeechSettingsActivity.java index c54dce4f6..fc7b613e4 100644 --- a/app/src/main/java/nl/hnogames/domoticz/SpeechSettingsActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/SpeechSettingsActivity.java @@ -137,19 +137,19 @@ public boolean onItemLongClick(AdapterView parent, View view, final int posit private void showEditDialog(final SpeechInfo mSpeechInfo) { new MaterialDialog.Builder(this) - .title(R.string.Speech_edit) - .content(R.string.Speech_name) - .inputType(InputType.TYPE_CLASS_TEXT) - .negativeText(R.string.cancel) - .input(this.getString(R.string.category_Speech), mSpeechInfo.getName(), new MaterialDialog.InputCallback() { - @Override - public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { - if (!UsefulBits.isEmpty(String.valueOf(input))) { - mSpeechInfo.setName(String.valueOf(input)); - updateSpeech(mSpeechInfo); - } + .title(R.string.Speech_edit) + .content(R.string.Speech_name) + .inputType(InputType.TYPE_CLASS_TEXT) + .negativeText(R.string.cancel) + .input(this.getString(R.string.category_Speech), mSpeechInfo.getName(), new MaterialDialog.InputCallback() { + @Override + public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { + if (!UsefulBits.isEmpty(String.valueOf(input))) { + mSpeechInfo.setName(String.valueOf(input)); + updateSpeech(mSpeechInfo); } - }).show(); + } + }).show(); } private void getSwitchesAndShowSwitchesDialog(final SpeechInfo qrInfo) { @@ -169,19 +169,19 @@ public void onReceiveDevice(DevicesInfo mDevicesInfo) { @DebugLog public void onError(Exception error) { UsefulBits.showSnackbarWithAction(SpeechSettingsActivity.this, coordinatorLayout, SpeechSettingsActivity.this.getString(R.string.unable_to_get_switches), Snackbar.LENGTH_SHORT, - null, new View.OnClickListener() { - @Override - public void onClick(View v) { - getSwitchesAndShowSwitchesDialog(qrInfo); - } - }, SpeechSettingsActivity.this.getString(R.string.retry)); + null, new View.OnClickListener() { + @Override + public void onClick(View v) { + getSwitchesAndShowSwitchesDialog(qrInfo); + } + }, SpeechSettingsActivity.this.getString(R.string.retry)); } }, 0, "all"); } private void showSwitchesDialog( - final SpeechInfo SpeechInfo, - final ArrayList switches) { + final SpeechInfo SpeechInfo, + final ArrayList switches) { final ArrayList supportedSwitches = new ArrayList<>(); for (DevicesInfo d : switches) { @@ -190,9 +190,9 @@ private void showSwitchesDialog( } SwitchDialog infoDialog = new SwitchDialog( - SpeechSettingsActivity.this, supportedSwitches, - R.layout.dialog_switch_logs, - domoticz); + SpeechSettingsActivity.this, supportedSwitches, + R.layout.dialog_switch_logs, + domoticz); infoDialog.onDismissListener(new SwitchDialog.DismissListener() { @Override @@ -220,16 +220,16 @@ public void onDismiss(int selectedSwitchIDX, String selectedSwitchPassword, Stri private void showSelectorDialog(final SpeechInfo SpeechInfo, DevicesInfo selector) { final ArrayList levelNames = selector.getLevelNames(); new MaterialDialog.Builder(this) - .title(R.string.selector_value) - .items(levelNames) - .itemsCallback(new MaterialDialog.ListCallback() { - @Override - public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { - SpeechInfo.setValue(String.valueOf(text)); - updateSpeech(SpeechInfo); - } - }) - .show(); + .title(R.string.selector_value) + .items(levelNames) + .itemsCallback(new MaterialDialog.ListCallback() { + @Override + public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { + SpeechInfo.setValue(String.valueOf(text)); + updateSpeech(SpeechInfo); + } + }) + .show(); } public void updateSpeech(SpeechInfo SpeechInfo) { @@ -255,21 +255,21 @@ public void updateSpeech(SpeechInfo SpeechInfo) { private boolean showNoDeviceAttachedDialog(final SpeechInfo SpeechInfo) { new MaterialDialog.Builder(this) - .title(R.string.noSwitchSelected_title) - .content(getString(R.string.noSwitchSelected_explanation_Speech) - + UsefulBits.newLine() - + UsefulBits.newLine() - + getString(R.string.noSwitchSelected_connectOneNow)) - .positiveText(R.string.yes) - .negativeText(R.string.no) - .onPositive(new MaterialDialog.SingleButtonCallback() { - @Override - public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { - getSwitchesAndShowSwitchesDialog(SpeechInfo); - result = true; - } - }) - .show(); + .title(R.string.noSwitchSelected_title) + .content(getString(R.string.noSwitchSelected_explanation_Speech) + + UsefulBits.newLine() + + UsefulBits.newLine() + + getString(R.string.noSwitchSelected_connectOneNow)) + .positiveText(R.string.yes) + .negativeText(R.string.no) + .onPositive(new MaterialDialog.SingleButtonCallback() { + @Override + public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { + getSwitchesAndShowSwitchesDialog(SpeechInfo); + result = true; + } + }) + .show(); return result; } @@ -295,7 +295,7 @@ private void showRemoveUndoSnackbar(final SpeechInfo SpeechInfo) { // Show snackbar with undo option String text = String.format(getString(R.string.something_deleted), - getString(R.string.Speech)); + getString(R.string.Speech)); UsefulBits.showSnackbarWithAction(this, coordinatorLayout, text, Snackbar.LENGTH_SHORT, new Snackbar.Callback() { @Override @@ -353,11 +353,11 @@ public void onResults(Bundle results) { } int[] colors = { - ContextCompat.getColor(this, R.color.material_amber_600), - ContextCompat.getColor(this, R.color.material_blue_600), - ContextCompat.getColor(this, R.color.material_deep_purple_600), - ContextCompat.getColor(this, R.color.material_green_600), - ContextCompat.getColor(this, R.color.material_orange_600) + ContextCompat.getColor(this, R.color.material_amber_600), + ContextCompat.getColor(this, R.color.material_blue_600), + ContextCompat.getColor(this, R.color.material_deep_purple_600), + ContextCompat.getColor(this, R.color.material_green_600), + ContextCompat.getColor(this, R.color.material_orange_600) }; recognitionProgressView.setColors(colors); recognitionProgressView.setSpeechRecognizer(speechRecognizer); @@ -389,7 +389,7 @@ private void stopRecognitionAnimation() { private void showSpeechResults(Bundle results) { ArrayList matches = results - .getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); + .getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); if (matches != null) processResult(matches.get(0).toLowerCase()); } diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/Backdrop/BackdropContainer.java b/app/src/main/java/nl/hnogames/domoticz/UI/Backdrop/BackdropContainer.java index 64f129503..8f2e867b9 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/Backdrop/BackdropContainer.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/Backdrop/BackdropContainer.java @@ -61,7 +61,7 @@ public BackdropContainer dropInterpolator(Interpolator interpolator) { public void build() { if (checkTotalview()) { toolbarIconClick = new ToolbarIconClick(context, getChildAt(1), getBackview(), mMenuicon, - mCloseicon, height, interpolator, duration); + mCloseicon, height, interpolator, duration); if (toolbar != null) { toolbar.setNavigationOnClickListener(toolbarIconClick); } diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/Backdrop/ToolbarIconClick.java b/app/src/main/java/nl/hnogames/domoticz/UI/Backdrop/ToolbarIconClick.java index f3ee10fb2..f2d7737bb 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/Backdrop/ToolbarIconClick.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/Backdrop/ToolbarIconClick.java @@ -61,7 +61,7 @@ public void onClick(View v) { updateIcon(v); ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(frontlayer, "translationY", - dropped ? translate : 0); + dropped ? translate : 0); animatorSet.play(objectAnimator); objectAnimator.setDuration(anim_duration); objectAnimator.setInterpolator(interpolator); diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/DeviceInfoDialog.java b/app/src/main/java/nl/hnogames/domoticz/UI/DeviceInfoDialog.java index 0be5d6659..f7fda7f36 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/DeviceInfoDialog.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/DeviceInfoDialog.java @@ -74,8 +74,8 @@ public DeviceInfoDialog(Context mContext, boolean wrapInScrollView = true; //noinspection ConstantConditions mdb.customView(layout, wrapInScrollView) - .theme(mSharedPrefs.darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) - .positiveText(android.R.string.ok); + .theme(mSharedPrefs.darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) + .positiveText(android.R.string.ok); mdb.dismissListener(this); } @@ -138,7 +138,7 @@ public boolean onTouch(View v, MotionEvent event) { }); signalLevelIndicator.setMax(Domoticz.signalLevelMax * 100); ProgressBarAnimation anim = - new ProgressBarAnimation(signalLevelIndicator, 5, signalLevelVal * 100); + new ProgressBarAnimation(signalLevelIndicator, 5, signalLevelVal * 100); anim.setDuration(1000); signalLevelIndicator.startAnimation(anim); @@ -184,7 +184,7 @@ private void InitButtons(View view) { public void onClick(View v) { if (mSwitch.isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( - mContext, mDomoticz); + mContext, mDomoticz); passwordDialog.show(); passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { @Override @@ -209,7 +209,7 @@ public void onCancel() { public void onClick(View v) { if (mSwitch.isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( - mContext, mDomoticz); + mContext, mDomoticz); passwordDialog.show(); passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { @Override diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/FingerprintPasswordDialog.java b/app/src/main/java/nl/hnogames/domoticz/UI/FingerprintPasswordDialog.java index 9f4eb1dc0..9182403fc 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/FingerprintPasswordDialog.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/FingerprintPasswordDialog.java @@ -59,23 +59,23 @@ public FingerprintPasswordDialog(Context c, Domoticz mDomoticz) { mdb = new MaterialDialog.Builder(mContext); mdb.customView(R.layout.dialog_password, true) - .positiveText(android.R.string.ok) - .negativeText(android.R.string.cancel) - .theme(mSharedPrefs.darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) - .onPositive(new MaterialDialog.SingleButtonCallback() { - @Override - public void onClick(MaterialDialog dialog, DialogAction which) { - if (dismissListener != null) - dismissListener.onDismiss(editPassword.getText().toString()); - } - }) - .onNegative(new MaterialDialog.SingleButtonCallback() { - @Override - public void onClick(MaterialDialog dialog, DialogAction which) { - if (dismissListener != null) - dismissListener.onCancel(); - } - }); + .positiveText(android.R.string.ok) + .negativeText(android.R.string.cancel) + .theme(mSharedPrefs.darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) + .onPositive(new MaterialDialog.SingleButtonCallback() { + @Override + public void onClick(MaterialDialog dialog, DialogAction which) { + if (dismissListener != null) + dismissListener.onDismiss(editPassword.getText().toString()); + } + }) + .onNegative(new MaterialDialog.SingleButtonCallback() { + @Override + public void onClick(MaterialDialog dialog, DialogAction which) { + if (dismissListener != null) + dismissListener.onCancel(); + } + }); mdb.dismissListener(this); } diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/MjpegViewer/MjpegInputStream.java b/app/src/main/java/nl/hnogames/domoticz/UI/MjpegViewer/MjpegInputStream.java index 9e14a33c0..8efd24670 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/MjpegViewer/MjpegInputStream.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/MjpegViewer/MjpegInputStream.java @@ -62,7 +62,7 @@ private int getStartOfSequence(byte[] sequence) throws IOException { /*********************************************************************************************/ private int parseContentLength(byte[] headerBytes) - throws IOException, NumberFormatException { + throws IOException, NumberFormatException { ByteArrayInputStream headerIn = new ByteArrayInputStream(headerBytes); Properties props = new Properties(); props.load(headerIn); diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/MultiSelectionSpinner.java b/app/src/main/java/nl/hnogames/domoticz/UI/MultiSelectionSpinner.java index 887af9110..8db436345 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/MultiSelectionSpinner.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/MultiSelectionSpinner.java @@ -52,7 +52,7 @@ public MultiSelectionSpinner(Context context) { super(context); simple_adapter = new ArrayAdapter<>(context, - android.R.layout.simple_spinner_item); + android.R.layout.simple_spinner_item); super.setAdapter(simple_adapter); } @@ -69,7 +69,7 @@ public MultiSelectionSpinner(Context context, AttributeSet attrs) { this.mContext = context; simple_adapter = new ArrayAdapter<>(context, - android.R.layout.simple_spinner_item); + android.R.layout.simple_spinner_item); super.setAdapter(simple_adapter); } @@ -81,7 +81,7 @@ public void onClick(DialogInterface dialog, int which, boolean isChecked) { simple_adapter.add(buildSelectedItemString()); } else { throw new IllegalArgumentException( - "Argument 'which' is out of bounds."); + "Argument 'which' is out of bounds."); } } @@ -97,7 +97,7 @@ public boolean performClick() { @Override public void setAdapter(SpinnerAdapter adapter) { throw new RuntimeException( - "setAdapter is not supported by MultiSelectSpinner."); + "setAdapter is not supported by MultiSelectSpinner."); } @SuppressWarnings("unused") @@ -162,7 +162,7 @@ public void setSelection(int index) { mSelection[index] = true; } else { throw new IllegalArgumentException("Index " + index - + " is out of bounds."); + + " is out of bounds."); } simple_adapter.clear(); simple_adapter.add(buildSelectedItemString()); @@ -178,7 +178,7 @@ public void setSelection(int[] selectedIndices) { mSelection[index] = true; } else { throw new IllegalArgumentException("Index " + index - + " is out of bounds."); + + " is out of bounds."); } } simple_adapter.clear(); diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/NotificationInfoDialog.java b/app/src/main/java/nl/hnogames/domoticz/UI/NotificationInfoDialog.java index 60b7c32b0..1e8f37059 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/NotificationInfoDialog.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/NotificationInfoDialog.java @@ -48,8 +48,8 @@ public NotificationInfoDialog(Context c, mdb = new MaterialDialog.Builder(mContext); mdb.customView(R.layout.dialog_switch_timer, true) - .theme((new SharedPrefUtil(mContext)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) - .positiveText(android.R.string.ok); + .theme((new SharedPrefUtil(mContext)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) + .positiveText(android.R.string.ok); } public void show() { diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/PasswordDialog.java b/app/src/main/java/nl/hnogames/domoticz/UI/PasswordDialog.java index f4d0a81f7..b71a30891 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/PasswordDialog.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/PasswordDialog.java @@ -58,37 +58,37 @@ public PasswordDialog(Context c, Domoticz mDomoticz) { mSharedPrefs = new SharedPrefUtil(c); mdb = new MaterialDialog.Builder(mContext); mdb.customView(R.layout.dialog_password, true) - .positiveText(android.R.string.ok) - .cancelListener(new DialogInterface.OnCancelListener() { - @Override - public void onCancel(DialogInterface dialog) { - if (dismissListener != null) - dismissListener.onCancel(); - } - }) - .dismissListener(new DialogInterface.OnDismissListener() { - @Override - public void onDismiss(DialogInterface dialog) { - if (dismissListener != null) - dismissListener.onDismiss(null); - } - }) - .negativeText(android.R.string.cancel) - .theme(mSharedPrefs.darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) - .onPositive(new MaterialDialog.SingleButtonCallback() { - @Override - public void onClick(MaterialDialog dialog, DialogAction which) { - if (dismissListener != null) - dismissListener.onDismiss(editPassword.getText().toString()); - } - }) - .onNegative(new MaterialDialog.SingleButtonCallback() { - @Override - public void onClick(MaterialDialog dialog, DialogAction which) { - if (dismissListener != null) - dismissListener.onCancel(); - } - }); + .positiveText(android.R.string.ok) + .cancelListener(new DialogInterface.OnCancelListener() { + @Override + public void onCancel(DialogInterface dialog) { + if (dismissListener != null) + dismissListener.onCancel(); + } + }) + .dismissListener(new DialogInterface.OnDismissListener() { + @Override + public void onDismiss(DialogInterface dialog) { + if (dismissListener != null) + dismissListener.onDismiss(null); + } + }) + .negativeText(android.R.string.cancel) + .theme(mSharedPrefs.darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) + .onPositive(new MaterialDialog.SingleButtonCallback() { + @Override + public void onClick(MaterialDialog dialog, DialogAction which) { + if (dismissListener != null) + dismissListener.onDismiss(editPassword.getText().toString()); + } + }) + .onNegative(new MaterialDialog.SingleButtonCallback() { + @Override + public void onClick(MaterialDialog dialog, DialogAction which) { + if (dismissListener != null) + dismissListener.onCancel(); + } + }); mdb.dismissListener(this); } diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/RGBWWColorPickerDialog.java b/app/src/main/java/nl/hnogames/domoticz/UI/RGBWWColorPickerDialog.java index bceea4af4..e477e97c4 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/RGBWWColorPickerDialog.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/RGBWWColorPickerDialog.java @@ -54,8 +54,8 @@ public RGBWWColorPickerDialog(Context mContext, int idx) { this.idx = idx; mdb = new MaterialDialog.Builder(mContext); mdb.customView(R.layout.dialog_rgbwwcolor, true) - .theme(mSharedPrefs.darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) - .positiveText(android.R.string.ok); + .theme(mSharedPrefs.darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) + .positiveText(android.R.string.ok); mdb.dismissListener(this); } diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/SceneInfoDialog.java b/app/src/main/java/nl/hnogames/domoticz/UI/SceneInfoDialog.java index a2b1b89ba..77b1c1269 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/SceneInfoDialog.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/SceneInfoDialog.java @@ -53,8 +53,8 @@ public SceneInfoDialog(Context mContext, boolean wrapInScrollView = true; //noinspection ConstantConditions mdb.customView(layout, wrapInScrollView) - .theme((new SharedPrefUtil(mContext)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) - .positiveText(android.R.string.ok); + .theme((new SharedPrefUtil(mContext)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) + .positiveText(android.R.string.ok); mdb.dismissListener(this); } diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/ScheduledTemperatureDialog.java b/app/src/main/java/nl/hnogames/domoticz/UI/ScheduledTemperatureDialog.java index 848729494..5b486f4d3 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/ScheduledTemperatureDialog.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/ScheduledTemperatureDialog.java @@ -31,7 +31,7 @@ public ScheduledTemperatureDialog(Context mContext, double temp, boolean canCanc if (canCancel) { getMaterialDialogBuilder() - .neutralText(R.string.follow_schedule); + .neutralText(R.string.follow_schedule); } } } diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/SecurityPanelDialog.java b/app/src/main/java/nl/hnogames/domoticz/UI/SecurityPanelDialog.java index b2e5063a1..cd21ed776 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/SecurityPanelDialog.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/SecurityPanelDialog.java @@ -73,8 +73,8 @@ public SecurityPanelDialog(Context c, Domoticz mDomoticz, DevicesInfo panelInfo) mSharedPrefs = new SharedPrefUtil(c); mdb = new MaterialDialog.Builder(mContext); mdb.customView(R.layout.dialog_security, true) - .theme(mSharedPrefs.darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) - .negativeText(android.R.string.cancel); + .theme(mSharedPrefs.darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) + .negativeText(android.R.string.cancel); mdb.dismissListener(this); } @@ -152,11 +152,11 @@ private void setFields(boolean enabled) { private void processRequest(final int status) { setFields(false); InputMethodManager imm = - (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE); + (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editPinCode.getWindowToken(), 0); final String password = - UsefulBits.getMd5String(editPinCode.getText().toString()); + UsefulBits.getMd5String(editPinCode.getText().toString()); if (validatePassword(password)) { if (mSettings.getSecOnDelay() <= 0 || status == DomoticzValues.Security.Status.DISARM) { @@ -172,8 +172,8 @@ public void onReceiveResult(String result) { public void onError(Exception error) { Log.e(TAG, domoticz.getErrorMessage(error)); Toast.makeText(mContext, - mContext.getString(R.string.security_generic_error), - Toast.LENGTH_SHORT).show(); + mContext.getString(R.string.security_generic_error), + Toast.LENGTH_SHORT).show(); setFields(true); } }); @@ -195,8 +195,8 @@ public void onReceiveResult(String result) { @Override public void onError(Exception error) { Toast.makeText(mContext, - mContext.getString(R.string.security_generic_error), - Toast.LENGTH_SHORT).show(); + mContext.getString(R.string.security_generic_error), + Toast.LENGTH_SHORT).show(); setFields(true); } }); diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/SimpleTextDialog.java b/app/src/main/java/nl/hnogames/domoticz/UI/SimpleTextDialog.java index 43449251f..662b09283 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/SimpleTextDialog.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/SimpleTextDialog.java @@ -49,8 +49,8 @@ public SimpleTextDialog(Context mContext) { //noinspection ConstantConditions mdb.customView(R.layout.dialog_text, wrapInScrollView) - .theme((new SharedPrefUtil(mContext)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) - .positiveText(android.R.string.ok); + .theme((new SharedPrefUtil(mContext)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) + .positiveText(android.R.string.ok); } public void setTitle(String title) { diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/SortDialog.java b/app/src/main/java/nl/hnogames/domoticz/UI/SortDialog.java index fa73cc8b0..caf07f0da 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/SortDialog.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/SortDialog.java @@ -49,7 +49,7 @@ public SortDialog(Context c, names = new String[]{mContext.getString(R.string.filterOn_on), mContext.getString(R.string.filterOn_off), mContext.getString(R.string.filterOn_static), mContext.getString(R.string.filterOn_all)}; mdb = new MaterialDialog.Builder(mContext); mdb.customView(layout, true) - .negativeText(android.R.string.cancel); + .negativeText(android.R.string.cancel); mdb.dismissListener(this); } @@ -63,7 +63,7 @@ public void show() { View view = md.getCustomView(); ListView listView = view.findViewById(R.id.list); ArrayAdapter adapter = new ArrayAdapter<>(mContext, - android.R.layout.simple_list_item_1, android.R.id.text1, names); + android.R.layout.simple_list_item_1, android.R.id.text1, names); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/SunriseInfoDialog.java b/app/src/main/java/nl/hnogames/domoticz/UI/SunriseInfoDialog.java index 660ea3b07..42d889fb9 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/SunriseInfoDialog.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/SunriseInfoDialog.java @@ -57,8 +57,8 @@ public SunriseInfoDialog(Context mContext, //noinspection ConstantConditions mdb.customView(R.layout.dialog_sunrise, wrapInScrollView) - .theme((new SharedPrefUtil(mContext)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) - .positiveText(android.R.string.ok); + .theme((new SharedPrefUtil(mContext)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) + .positiveText(android.R.string.ok); } public void show() { diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/SwitchDialog.java b/app/src/main/java/nl/hnogames/domoticz/UI/SwitchDialog.java index eeb45d88f..b4a6d21ee 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/SwitchDialog.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/SwitchDialog.java @@ -56,8 +56,8 @@ public SwitchDialog(Context c, mdb = new MaterialDialog.Builder(mContext); mdb.customView(layout, true) - .theme((new SharedPrefUtil(mContext)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) - .negativeText(android.R.string.cancel); + .theme((new SharedPrefUtil(mContext)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) + .negativeText(android.R.string.cancel); mdb.dismissListener(this); } @@ -72,7 +72,7 @@ public void show() { ListView listView = view.findViewById(R.id.list); String[] listData = processSwitches(); ArrayAdapter adapter = new ArrayAdapter<>(mContext, - android.R.layout.simple_list_item_1, android.R.id.text1, listData); + android.R.layout.simple_list_item_1, android.R.id.text1, listData); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, final int position, long id) { diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/SwitchInfoDialog.java b/app/src/main/java/nl/hnogames/domoticz/UI/SwitchInfoDialog.java index 43d3c5901..020ed9e60 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/SwitchInfoDialog.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/SwitchInfoDialog.java @@ -73,8 +73,8 @@ public SwitchInfoDialog(Context mContext, mdb = new MaterialDialog.Builder(mContext); boolean wrapInScrollView = true; mdb.customView(layout, wrapInScrollView) - .theme((new SharedPrefUtil(mContext)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) - .positiveText(android.R.string.ok); + .theme((new SharedPrefUtil(mContext)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) + .positiveText(android.R.string.ok); mdb.dismissListener(this); } @@ -139,7 +139,7 @@ public boolean onTouch(View v, MotionEvent event) { }); signalLevelIndicator.setMax(Domoticz.signalLevelMax * 100); ProgressBarAnimation anim = - new ProgressBarAnimation(signalLevelIndicator, 5, signalLevelVal * 100); + new ProgressBarAnimation(signalLevelIndicator, 5, signalLevelVal * 100); anim.setDuration(1000); signalLevelIndicator.startAnimation(anim); @@ -189,7 +189,7 @@ private void InitButtons(View view) { public void onClick(View v) { if (mSwitch.isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( - mContext, mDomoticz); + mContext, mDomoticz); passwordDialog.show(); passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { @Override @@ -214,7 +214,7 @@ public void onCancel() { public void onClick(View v) { if (mSwitch.isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( - mContext, mDomoticz); + mContext, mDomoticz); passwordDialog.show(); passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { @Override diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/SwitchLogInfoDialog.java b/app/src/main/java/nl/hnogames/domoticz/UI/SwitchLogInfoDialog.java index aa91531bb..3b7b50f32 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/SwitchLogInfoDialog.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/SwitchLogInfoDialog.java @@ -49,8 +49,8 @@ public SwitchLogInfoDialog(Context c, this.mContext = c; mdb = new MaterialDialog.Builder(mContext); mdb.customView(layout, true) - .theme((new SharedPrefUtil(mContext)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) - .positiveText(android.R.string.ok); + .theme((new SharedPrefUtil(mContext)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) + .positiveText(android.R.string.ok); mdb.dismissListener(this); } @@ -66,7 +66,7 @@ public void show() { String[] listData = processLogs(); ArrayAdapter adapter = new ArrayAdapter<>(mContext, - android.R.layout.simple_list_item_1, android.R.id.text1, listData); + android.R.layout.simple_list_item_1, android.R.id.text1, listData); listView.setAdapter(adapter); md.show(); diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/SwitchTimerInfoDialog.java b/app/src/main/java/nl/hnogames/domoticz/UI/SwitchTimerInfoDialog.java index 09984da3f..122cdb35c 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/SwitchTimerInfoDialog.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/SwitchTimerInfoDialog.java @@ -49,8 +49,8 @@ public SwitchTimerInfoDialog(Context c, mdb = new MaterialDialog.Builder(mContext); mdb.customView(layout, true) - .theme((new SharedPrefUtil(mContext)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) - .positiveText(android.R.string.ok); + .theme((new SharedPrefUtil(mContext)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) + .positiveText(android.R.string.ok); } public void show() { diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/TemperatureDialog.java b/app/src/main/java/nl/hnogames/domoticz/UI/TemperatureDialog.java index 7691e7ac4..ba2192d95 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/TemperatureDialog.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/TemperatureDialog.java @@ -62,10 +62,10 @@ public TemperatureDialog(Context mContext, double temp) { mdb = new MaterialDialog.Builder(mContext); mdb.customView(R.layout.dialog_temperature, false) - .negativeText(android.R.string.cancel) - .theme(mSharedPrefUtil.darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) - .positiveText(android.R.string.ok) - .onAny(this); + .negativeText(android.R.string.cancel) + .theme(mSharedPrefUtil.darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) + .positiveText(android.R.string.ok) + .onAny(this); ConfigInfo configInfo = new ServerUtil(mContext).getActiveServer().getConfigInfo(mContext); if (configInfo != null) { diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/TemperatureInfoDialog.java b/app/src/main/java/nl/hnogames/domoticz/UI/TemperatureInfoDialog.java index 192cb32a9..94216ba98 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/TemperatureInfoDialog.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/TemperatureInfoDialog.java @@ -54,8 +54,8 @@ public TemperatureInfoDialog(Context mContext, boolean wrapInScrollView = true; //noinspection ConstantConditions mdb.customView(layout, wrapInScrollView) - .theme((new SharedPrefUtil(mContext)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) - .positiveText(android.R.string.ok); + .theme((new SharedPrefUtil(mContext)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) + .positiveText(android.R.string.ok); mdb.dismissListener(this); } diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/TextDialog.java b/app/src/main/java/nl/hnogames/domoticz/UI/TextDialog.java index 307d66f44..6c9d592cd 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/TextDialog.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/TextDialog.java @@ -34,9 +34,9 @@ import nl.hnogames.domoticz.Utils.SharedPrefUtil; public class TextDialog implements - DialogInterface.OnDismissListener, - DialogInterface.OnCancelListener, - MaterialDialog.SingleButtonCallback { + DialogInterface.OnDismissListener, + DialogInterface.OnCancelListener, + MaterialDialog.SingleButtonCallback { private final MaterialDialog.Builder mdb; private Context context; @@ -54,7 +54,7 @@ public TextDialog(Context context) { mdb = new MaterialDialog.Builder(context); mdb.customView(R.layout.dialog_text, true).negativeText(android.R.string.cancel) - .theme((new SharedPrefUtil(context)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT); + .theme((new SharedPrefUtil(context)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT); mdb.dismissListener(this); mdb.cancelListener(this); mdb.onPositive(this); diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/UtilitiesInfoDialog.java b/app/src/main/java/nl/hnogames/domoticz/UI/UtilitiesInfoDialog.java index 476c6e9f6..f5eafa9c8 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/UtilitiesInfoDialog.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/UtilitiesInfoDialog.java @@ -53,8 +53,8 @@ public UtilitiesInfoDialog(Context mContext, boolean wrapInScrollView = true; //noinspection ConstantConditions mdb.customView(layout, wrapInScrollView) - .theme((new SharedPrefUtil(mContext)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) - .positiveText(android.R.string.ok); + .theme((new SharedPrefUtil(mContext)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) + .positiveText(android.R.string.ok); mdb.dismissListener(this); } diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/WWColorPickerDialog.java b/app/src/main/java/nl/hnogames/domoticz/UI/WWColorPickerDialog.java index 09cf96596..26ce23a97 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/WWColorPickerDialog.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/WWColorPickerDialog.java @@ -46,8 +46,8 @@ public WWColorPickerDialog(Context mContext, int idx) { this.idx = idx; mdb = new MaterialDialog.Builder(mContext); mdb.customView(R.layout.dialog_wwcolor, true) - .theme(mSharedPrefs.darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) - .positiveText(android.R.string.ok); + .theme(mSharedPrefs.darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) + .positiveText(android.R.string.ok); mdb.dismissListener(this); } diff --git a/app/src/main/java/nl/hnogames/domoticz/UI/WeatherInfoDialog.java b/app/src/main/java/nl/hnogames/domoticz/UI/WeatherInfoDialog.java index 0f41576aa..6a3470bc8 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UI/WeatherInfoDialog.java +++ b/app/src/main/java/nl/hnogames/domoticz/UI/WeatherInfoDialog.java @@ -51,8 +51,8 @@ public WeatherInfoDialog(Context mContext, boolean wrapInScrollView = true; //noinspection ConstantConditions mdb.customView(layout, wrapInScrollView) - .theme((new SharedPrefUtil(mContext)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) - .positiveText(android.R.string.ok); + .theme((new SharedPrefUtil(mContext)).darkThemeEnabled() ? Theme.DARK : Theme.LIGHT) + .positiveText(android.R.string.ok); mdb.dismissListener(this); } diff --git a/app/src/main/java/nl/hnogames/domoticz/UpdateActivity.java b/app/src/main/java/nl/hnogames/domoticz/UpdateActivity.java index f46ed8245..2d0f09154 100644 --- a/app/src/main/java/nl/hnogames/domoticz/UpdateActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/UpdateActivity.java @@ -108,14 +108,14 @@ public void onReceiveVersion(VersionInfo serverVersion) { if (serverVersion == null) return; if (serverUtil.getActiveServer() != null && - serverUtil.getActiveServer().getServerUpdateInfo(UpdateActivity.this) != null) { + serverUtil.getActiveServer().getServerUpdateInfo(UpdateActivity.this) != null) { currentServerVersionValue.setText(serverVersion.getVersion()); if (serverUtil.getActiveServer().getServerUpdateInfo(UpdateActivity.this).isUpdateAvailable()) { updateSummary.setText(R.string.server_update_available); updateServerVersionValue.setText(serverUtil.getActiveServer() - .getServerUpdateInfo(UpdateActivity.this) - .getUpdateRevisionNumber()); + .getServerUpdateInfo(UpdateActivity.this) + .getUpdateRevisionNumber()); } else if (mSharedPrefs.isDebugEnabled()) { String message = "Debugging: " + getString(R.string.server_update_available); updateSummary.setText(message); @@ -130,7 +130,7 @@ public void onClick(View v) { } }); if (!serverUtil.getActiveServer().getServerUpdateInfo(UpdateActivity.this).isUpdateAvailable() - && !mSharedPrefs.isDebugEnabled()) + && !mSharedPrefs.isDebugEnabled()) buttonUpdateServer.setEnabled(false); } } @@ -139,12 +139,12 @@ public void onClick(View v) { public void onError(Exception error) { mSwipeRefreshLayout.setRefreshing(false); String message = String.format( - getString(R.string.error_couldNotCheckForUpdates), - mDomoticz.getErrorMessage(error)); + getString(R.string.error_couldNotCheckForUpdates), + mDomoticz.getErrorMessage(error)); showSnackbar(message); if (serverUtil != null && - serverUtil.getActiveServer() != null && - serverUtil.getActiveServer().getServerUpdateInfo(UpdateActivity.this) != null) + serverUtil.getActiveServer() != null && + serverUtil.getActiveServer().getServerUpdateInfo(UpdateActivity.this) != null) serverUtil.getActiveServer().getServerUpdateInfo(UpdateActivity.this).setCurrentServerVersion(""); currentServerVersionValue.setText(R.string.not_available); } @@ -158,20 +158,20 @@ private void refreshData() { private void showServerUpdateWarningDialog() { new MaterialDialog.Builder(this) - .title(R.string.server_update) - .content(getString(R.string.update_server_warning) - + UsefulBits.newLine() - + UsefulBits.newLine() - + getString(R.string.continue_question)) - .positiveText(R.string.yes) - .negativeText(R.string.no) - .onPositive(new MaterialDialog.SingleButtonCallback() { - @Override - public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { - updateServer(); - } - }) - .show(); + .title(R.string.server_update) + .content(getString(R.string.update_server_warning) + + UsefulBits.newLine() + + UsefulBits.newLine() + + getString(R.string.continue_question)) + .positiveText(R.string.yes) + .negativeText(R.string.no) + .onPositive(new MaterialDialog.SingleButtonCallback() { + @Override + public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { + updateServer(); + } + }) + .show(); } private void updateServer() { @@ -181,13 +181,13 @@ private void updateServer() { final boolean showMinMax = false; final MaterialDialog dialog = new MaterialDialog.Builder(this) - .title(R.string.msg_please_wait) - .content(getString(R.string.please_wait_while_server_updated) - + UsefulBits.newLine() - + getString(R.string.this_take_minutes)) - .cancelable(false) - .progress(false, SERVER_UPDATE_TIME * 60, showMinMax) - .show(); + .title(R.string.msg_please_wait) + .content(getString(R.string.please_wait_while_server_updated) + + UsefulBits.newLine() + + getString(R.string.this_take_minutes)) + .cancelable(false) + .progress(false, SERVER_UPDATE_TIME * 60, showMinMax) + .show(); CountDownTimer mCountDownTimer = new CountDownTimer(SERVER_UPDATE_TIME * 60 * 1000, 1000) { @@ -314,8 +314,8 @@ public void onReceiveUpdate(ServerUpdateInfo serverUpdateInfo) { @Override public void onError(Exception error) { String message = String.format( - getString(R.string.error_couldNotCheckForUpdates), - mDomoticz.getErrorMessage(error)); + getString(R.string.error_couldNotCheckForUpdates), + mDomoticz.getErrorMessage(error)); showSnackbar(message); serverUtil.getActiveServer().getServerUpdateInfo(UpdateActivity.this).setUpdateRevisionNumber(""); updateServerVersionValue.setText(R.string.not_available); @@ -335,8 +335,8 @@ public void onReceiveVersion(VersionInfo serverVersion) { mSwipeRefreshLayout.setRefreshing(false); if (serverVersion != null && !UsefulBits.isEmpty(serverVersion.getVersion())) { if (serverUtil != null && - serverUtil.getActiveServer() != null && - serverUtil.getActiveServer().getServerUpdateInfo(UpdateActivity.this) != null) + serverUtil.getActiveServer() != null && + serverUtil.getActiveServer().getServerUpdateInfo(UpdateActivity.this) != null) serverUtil.getActiveServer().getServerUpdateInfo(UpdateActivity.this).setCurrentServerVersion(serverVersion.getVersion()); currentServerVersionValue.setText(serverVersion.getVersion()); } else currentServerVersionValue.setText(R.string.not_available); @@ -346,12 +346,12 @@ public void onReceiveVersion(VersionInfo serverVersion) { public void onError(Exception error) { mSwipeRefreshLayout.setRefreshing(false); String message = String.format( - getString(R.string.error_couldNotCheckForUpdates), - mDomoticz.getErrorMessage(error)); + getString(R.string.error_couldNotCheckForUpdates), + mDomoticz.getErrorMessage(error)); showSnackbar(message); if (serverUtil != null && - serverUtil.getActiveServer() != null && - serverUtil.getActiveServer().getServerUpdateInfo(UpdateActivity.this) != null) + serverUtil.getActiveServer() != null && + serverUtil.getActiveServer().getServerUpdateInfo(UpdateActivity.this) != null) serverUtil.getActiveServer().getServerUpdateInfo(UpdateActivity.this).setCurrentServerVersion(""); currentServerVersionValue.setText(R.string.not_available); } @@ -367,9 +367,9 @@ private void showSnackbar(String message) { private void showSimpleDialog(String title, String message) { new MaterialDialog.Builder(this) - .title(title) - .content(message) - .positiveText(R.string.ok) - .show(); + .title(title) + .content(message) + .positiveText(R.string.ok) + .show(); } } \ No newline at end of file diff --git a/app/src/main/java/nl/hnogames/domoticz/Utils/BitmapLruCache.java b/app/src/main/java/nl/hnogames/domoticz/Utils/BitmapLruCache.java index af8ff4327..20185e6d6 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Utils/BitmapLruCache.java +++ b/app/src/main/java/nl/hnogames/domoticz/Utils/BitmapLruCache.java @@ -28,8 +28,8 @@ import androidx.collection.LruCache; public class BitmapLruCache - extends LruCache - implements ImageLoader.ImageCache { + extends LruCache + implements ImageLoader.ImageCache { public BitmapLruCache() { this(getDefaultLruCacheSize()); diff --git a/app/src/main/java/nl/hnogames/domoticz/Utils/DeviceUtils.java b/app/src/main/java/nl/hnogames/domoticz/Utils/DeviceUtils.java index 03a07afcc..082e5b3fd 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Utils/DeviceUtils.java +++ b/app/src/main/java/nl/hnogames/domoticz/Utils/DeviceUtils.java @@ -36,7 +36,7 @@ public static boolean isAutomatedToggableDevice(DevicesInfo mDeviceInfo) { if (mDeviceInfo.equals(null)) return false; if (mDeviceInfo.getSwitchTypeVal() == 0 && - (mDeviceInfo.getSwitchType() == null)) { + (mDeviceInfo.getSwitchType() == null)) { if (mDeviceInfo.getSubType() != null && mDeviceInfo.getSubType().equals(DomoticzValues.Device.Utility.SubType.SMARTWARES)) { return true; } else { diff --git a/app/src/main/java/nl/hnogames/domoticz/Utils/NotificationUtil.java b/app/src/main/java/nl/hnogames/domoticz/Utils/NotificationUtil.java index 7d39e154a..945a2260a 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Utils/NotificationUtil.java +++ b/app/src/main/java/nl/hnogames/domoticz/Utils/NotificationUtil.java @@ -82,16 +82,16 @@ public static void sendSimpleNotification(int idx, String title, String text, in } NotificationCompat.Builder builder = - new NotificationCompat.Builder(context) - .setSmallIcon(R.drawable.domoticz_white) - .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher)) - .setContentTitle(alarmNot != null && alarmNot.contains(loggedNotification) ? context.getString(R.string.alarm) + ": " + title : title) - .setContentText(alarmNot != null && alarmNot.contains(loggedNotification) ? context.getString(R.string.alarm) + ": " + text : text) - .setChannelId(CHANNEL_ID) - .setStyle(new NotificationCompat.BigTextStyle().setSummaryText(text)) - //.setGroupSummary(true) - //.setGroup(GROUP_KEY_NOTIFICATIONS) - .setAutoCancel(true); + new NotificationCompat.Builder(context) + .setSmallIcon(R.drawable.domoticz_white) + .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher)) + .setContentTitle(alarmNot != null && alarmNot.contains(loggedNotification) ? context.getString(R.string.alarm) + ": " + title : title) + .setContentText(alarmNot != null && alarmNot.contains(loggedNotification) ? context.getString(R.string.alarm) + ": " + text : text) + .setChannelId(CHANNEL_ID) + .setStyle(new NotificationCompat.BigTextStyle().setSummaryText(text)) + //.setGroupSummary(true) + //.setGroup(GROUP_KEY_NOTIFICATIONS) + .setAutoCancel(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { int nrOfNotifications = 1; @@ -124,7 +124,7 @@ public static void sendSimpleNotification(int idx, String title, String text, in } if (prefUtil.showAutoNotifications()) { builder.extend(new NotificationCompat.CarExtender() - .setUnreadConversation(getUnreadConversation(context, text))); + .setUnreadConversation(getUnreadConversation(context, text))); } mNotificationManager.notify(NOTIFICATION_ID, builder.build()); @@ -140,8 +140,8 @@ private static void CreateChannel(String channelid, int priority, boolean backgr SharedPrefUtil prefUtil = new SharedPrefUtil(context); NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); NotificationChannel channel = new NotificationChannel(channelid, - channelid, - GetPriority(priority)); + channelid, + GetPriority(priority)); if (!backgroundProcess) { channel.setShowBadge(true); @@ -164,12 +164,12 @@ public static Notification getForegroundServiceNotification(Context context, Str } return new NotificationCompat.Builder(context) - .setSmallIcon(R.drawable.domoticz_white) - .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher)) - .setContentTitle("Domoticz") - .setContentText("Processing widget request..") - .setChannelId(channelid) - .setContentIntent(contentIntent).build(); + .setSmallIcon(R.drawable.domoticz_white) + .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher)) + .setContentTitle("Domoticz") + .setContentText("Processing widget request..") + .setChannelId(channelid) + .setContentIntent(contentIntent).build(); } private static int GetPriority(int priority) { @@ -224,41 +224,41 @@ public static void sendSimpleNotification(String title, String text, int priorit private static Intent getMessageReadIntent() { return new Intent() - .addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES) - .setAction(MESSAGE_READ_ACTION) - .putExtra(MESSAGE_CONVERSATION_ID_KEY, NOTIFICATION_ID); + .addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES) + .setAction(MESSAGE_READ_ACTION) + .putExtra(MESSAGE_CONVERSATION_ID_KEY, NOTIFICATION_ID); } private static PendingIntent getMessageReadPendingIntent(Context context) { return PendingIntent.getBroadcast(context, - NOTIFICATION_ID, - getMessageReadIntent(), - PendingIntent.FLAG_UPDATE_CURRENT); + NOTIFICATION_ID, + getMessageReadIntent(), + PendingIntent.FLAG_UPDATE_CURRENT); } private static Intent getMessageReplyIntent() { return new Intent() - .addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES) - .setAction(MESSAGE_REPLY_ACTION) - .putExtra(MESSAGE_CONVERSATION_ID_KEY, NOTIFICATION_ID); + .addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES) + .setAction(MESSAGE_REPLY_ACTION) + .putExtra(MESSAGE_CONVERSATION_ID_KEY, NOTIFICATION_ID); } private static PendingIntent getMessageReplyPendingIntent(Context context) { return PendingIntent.getBroadcast(context, - NOTIFICATION_ID, - getMessageReplyIntent(), - PendingIntent.FLAG_UPDATE_CURRENT); + NOTIFICATION_ID, + getMessageReplyIntent(), + PendingIntent.FLAG_UPDATE_CURRENT); } private static RemoteInput getVoiceReplyRemoteInput() { return new RemoteInput.Builder(VOICE_REPLY_KEY) - .setLabel("Reply") - .build(); + .setLabel("Reply") + .build(); } private static NotificationCompat.CarExtender.UnreadConversation getUnreadConversation(Context context, String text) { NotificationCompat.CarExtender.UnreadConversation.Builder unreadConversationBuilder = - new NotificationCompat.CarExtender.UnreadConversation.Builder(UNREAD_CONVERSATION_BUILDER_NAME + text); + new NotificationCompat.CarExtender.UnreadConversation.Builder(UNREAD_CONVERSATION_BUILDER_NAME + text); unreadConversationBuilder.setReadPendingIntent(getMessageReadPendingIntent(context)); unreadConversationBuilder.setReplyAction(getMessageReplyPendingIntent(context), getVoiceReplyRemoteInput()); unreadConversationBuilder.addMessage(text); diff --git a/app/src/main/java/nl/hnogames/domoticz/Utils/PermissionsUtil.java b/app/src/main/java/nl/hnogames/domoticz/Utils/PermissionsUtil.java index c66323425..92e85d89e 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Utils/PermissionsUtil.java +++ b/app/src/main/java/nl/hnogames/domoticz/Utils/PermissionsUtil.java @@ -37,34 +37,34 @@ public class PermissionsUtil { //these permissions are needed for Wifi scanning public static final String[] INITIAL_LOCATION_PERMS = { - Manifest.permission.ACCESS_FINE_LOCATION, - Manifest.permission.ACCESS_COARSE_LOCATION, + Manifest.permission.ACCESS_FINE_LOCATION, + Manifest.permission.ACCESS_COARSE_LOCATION, }; //these permissions are needed for storing camera images public static final String[] INITIAL_STORAGE_PERMS = { - Manifest.permission.READ_EXTERNAL_STORAGE, - Manifest.permission.WRITE_EXTERNAL_STORAGE + Manifest.permission.READ_EXTERNAL_STORAGE, + Manifest.permission.WRITE_EXTERNAL_STORAGE }; //these permissions are needed for getting device id public static final String[] INITIAL_DEVICE_PERMS = { - Manifest.permission.READ_PHONE_STATE + Manifest.permission.READ_PHONE_STATE }; //these permissions are needed for scanning qrcodes public static final String[] INITIAL_CAMERA_PERMS = { - Manifest.permission.CAMERA + Manifest.permission.CAMERA }; //these permissions are needed for bluetooth public static final String[] INITIAL_BLUETOOTH_PERMS = { - Manifest.permission.BLUETOOTH, - Manifest.permission.BLUETOOTH_ADMIN + Manifest.permission.BLUETOOTH, + Manifest.permission.BLUETOOTH_ADMIN }; //these permissions are needed for recording audio public static final String[] INITIAL_AUDIO_PERMS = { - Manifest.permission.RECORD_AUDIO + Manifest.permission.RECORD_AUDIO }; //these permissions are needed for fingerprint public static final String[] INITIAL_FINGERPRINT_PERMS = { - Manifest.permission.USE_FINGERPRINT + Manifest.permission.USE_FINGERPRINT }; //This range is from 0 to 255!! @@ -110,7 +110,7 @@ public static boolean canAccessAudioState(Context context) { private static boolean hasPermission(String permission, Context context) { // Using ContextCompat.checkSelfPermission will work on all API versions return (PackageManager.PERMISSION_GRANTED - == ContextCompat.checkSelfPermission(context, permission)); + == ContextCompat.checkSelfPermission(context, permission)); } public static AlertDialog getAlertDialog(Context context, final PermissionFragmentHelper permissionFragmentHelper, String title, String description, final String[] permissions) { @@ -123,8 +123,8 @@ public void onClick(DialogInterface dialog, int which) { public static AlertDialog getAlertDialog(Context context, final PermissionFragmentHelper permissionFragmentHelper, String title, String description, final String[] permissions, DialogInterface.OnClickListener oncancel) { AlertDialog builder = new AlertDialog.Builder(context) - .setTitle(title) - .create(); + .setTitle(title) + .create(); builder.setButton(DialogInterface.BUTTON_POSITIVE, context.getString(R.string.request_again), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { @@ -142,8 +142,8 @@ public void onClick(DialogInterface dialog, int which) { public static AlertDialog getAlertDialog(Context context, final PermissionFragmentHelper permissionFragmentHelper, String title, String description, final String permission) { AlertDialog builder = new AlertDialog.Builder(context) - .setTitle(title) - .create(); + .setTitle(title) + .create(); builder.setButton(DialogInterface.BUTTON_POSITIVE, "Request", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { @@ -165,8 +165,8 @@ public void onClick(DialogInterface dialog, int which) { public static AlertDialog getAlertDialog(Context context, final PermissionHelper permissionFragmentHelper, String title, String description, final String[] permissions, DialogInterface.OnClickListener oncancel) { AlertDialog builder = new AlertDialog.Builder(context) - .setTitle(title) - .create(); + .setTitle(title) + .create(); builder.setButton(DialogInterface.BUTTON_POSITIVE, context.getString(R.string.request_again), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { @@ -184,8 +184,8 @@ public void onClick(DialogInterface dialog, int which) { public static AlertDialog getAlertDialog(Context context, final PermissionHelper permissionFragmentHelper, String title, String description, final String permission) { AlertDialog builder = new AlertDialog.Builder(context) - .setTitle(title) - .create(); + .setTitle(title) + .create(); builder.setButton(DialogInterface.BUTTON_POSITIVE, "Request", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { diff --git a/app/src/main/java/nl/hnogames/domoticz/Utils/PicassoUtil.java b/app/src/main/java/nl/hnogames/domoticz/Utils/PicassoUtil.java index d8e097d0d..1e4022f2b 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Utils/PicassoUtil.java +++ b/app/src/main/java/nl/hnogames/domoticz/Utils/PicassoUtil.java @@ -87,7 +87,7 @@ private static long calculateAvailableCacheSize(File dir) { } // Target at least 90% of available or 25% of total space size = (long) Math.min(availableBytes * MAX_AVAILABLE_SPACE_USE_FRACTION, totalBytes - * MAX_TOTAL_SPACE_USE_FRACTION); + * MAX_TOTAL_SPACE_USE_FRACTION); } catch (Exception e) { // ignored } @@ -96,12 +96,12 @@ private static long calculateAvailableCacheSize(File dir) { public Picasso getPicasso(Context context, final String username, final String password) { OkHttpClient okHttpClient = providesOkHttpClient(context, new LoggingInterceptor.Builder() - .loggable(BuildConfig.DEBUG) - .setLevel(Level.BASIC) - .log(Platform.INFO) - .request("Request") - .response("Response") - .build(), username, password); + .loggable(BuildConfig.DEBUG) + .setLevel(Level.BASIC) + .log(Platform.INFO) + .request("Request") + .response("Response") + .build(), username, password); OkHttp3Downloader okHttpDownloader = providesPicassoOkHttpClient(okHttpClient); Picasso picasso = providesCustomPicasso(context, okHttpDownloader); return picasso; @@ -109,12 +109,12 @@ public Picasso getPicasso(Context context, final String username, final String p public Picasso getPicasso(Context context, final String cookie) { OkHttpClient okHttpClient = providesOkHttpClient(context, new LoggingInterceptor.Builder() - .loggable(BuildConfig.DEBUG) - .setLevel(Level.BASIC) - .log(Platform.INFO) - .request("Request") - .response("Response") - .build(), cookie); + .loggable(BuildConfig.DEBUG) + .setLevel(Level.BASIC) + .log(Platform.INFO) + .request("Request") + .response("Response") + .build(), cookie); OkHttp3Downloader okHttpDownloader = providesPicassoOkHttpClient(okHttpClient); Picasso picasso = providesCustomPicasso(context, okHttpDownloader); return picasso; @@ -122,16 +122,16 @@ public Picasso getPicasso(Context context, final String cookie) { Picasso providesCustomPicasso(Context context, OkHttp3Downloader okHttpDownloader) { return new Picasso.Builder(context) - .listener(new Picasso.Listener() { - @Override - public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) { - Log.e(TAG, "onImageLoadFailed: uri: " + uri, exception); - } - }) - .downloader(okHttpDownloader) - //.memoryCache(new LruCache(context)) - .executor(Executors.newSingleThreadExecutor())//avoid OutOfMemoryError - .build(); + .listener(new Picasso.Listener() { + @Override + public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) { + Log.e(TAG, "onImageLoadFailed: uri: " + uri, exception); + } + }) + .downloader(okHttpDownloader) + //.memoryCache(new LruCache(context)) + .executor(Executors.newSingleThreadExecutor())//avoid OutOfMemoryError + .build(); } public OkHttp3Downloader providesPicassoOkHttpClient(OkHttpClient okHttpClient) { @@ -143,20 +143,20 @@ public OkHttpClient providesOkHttpClient(Context context, Interceptor loggingInt long cacheSize = calculateDiskCacheSize(cacheDir); // Create a trust manager that does not validate certificate chains final TrustManager[] trustAllCerts = new TrustManager[]{ - new X509TrustManager() { - @Override - public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { - } + new X509TrustManager() { + @Override + public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { + } - @Override - public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { - } + @Override + public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { + } - @Override - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return new java.security.cert.X509Certificate[]{}; - } + @Override + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return new java.security.cert.X509Certificate[]{}; } + } }; SSLSocketFactory sslSocketFactory = null; @@ -176,14 +176,14 @@ public java.security.cert.X509Certificate[] getAcceptedIssuers() { e.printStackTrace(); } return new OkHttpClient.Builder() - .protocols(Arrays.asList(Protocol.HTTP_1_1)) - .hostnameVerifier(new TrustAllHostnameVerifier()) - .sslSocketFactory(sslSocketFactory, (X509TrustManager) trustAllCerts[0]) - .addNetworkInterceptor(new DefaultHeadersInterceptor(context)) - .addInterceptor(new DefaultHeadersInterceptor(context)) - .addInterceptor(loggingInterceptor) - //.cache(new Cache(cacheDir, cacheSize)) - .build(); + .protocols(Arrays.asList(Protocol.HTTP_1_1)) + .hostnameVerifier(new TrustAllHostnameVerifier()) + .sslSocketFactory(sslSocketFactory, (X509TrustManager) trustAllCerts[0]) + .addNetworkInterceptor(new DefaultHeadersInterceptor(context)) + .addInterceptor(new DefaultHeadersInterceptor(context)) + .addInterceptor(loggingInterceptor) + //.cache(new Cache(cacheDir, cacheSize)) + .build(); } public OkHttpClient providesOkHttpClient(Context context, Interceptor loggingInterceptor, String username, String password) { @@ -191,20 +191,20 @@ public OkHttpClient providesOkHttpClient(Context context, Interceptor loggingInt long cacheSize = calculateDiskCacheSize(cacheDir); // Create a trust manager that does not validate certificate chains final TrustManager[] trustAllCerts = new TrustManager[]{ - new X509TrustManager() { - @Override - public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { - } + new X509TrustManager() { + @Override + public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { + } - @Override - public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { - } + @Override + public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { + } - @Override - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return new java.security.cert.X509Certificate[]{}; - } + @Override + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return new java.security.cert.X509Certificate[]{}; } + } }; SSLSocketFactory sslSocketFactory = null; @@ -224,14 +224,14 @@ public java.security.cert.X509Certificate[] getAcceptedIssuers() { e.printStackTrace(); } return new OkHttpClient.Builder() - .protocols(Arrays.asList(Protocol.HTTP_1_1)) - .hostnameVerifier(new TrustAllHostnameVerifier()) - .sslSocketFactory(sslSocketFactory, (X509TrustManager) trustAllCerts[0]) - .addNetworkInterceptor(new DefaultHeadersInterceptor(context, username, password)) - .addInterceptor(new DefaultHeadersInterceptor(context, username, password)) - .addInterceptor(loggingInterceptor) - //.cache(new Cache(cacheDir, cacheSize)) - .build(); + .protocols(Arrays.asList(Protocol.HTTP_1_1)) + .hostnameVerifier(new TrustAllHostnameVerifier()) + .sslSocketFactory(sslSocketFactory, (X509TrustManager) trustAllCerts[0]) + .addNetworkInterceptor(new DefaultHeadersInterceptor(context, username, password)) + .addInterceptor(new DefaultHeadersInterceptor(context, username, password)) + .addInterceptor(loggingInterceptor) + //.cache(new Cache(cacheDir, cacheSize)) + .build(); } public OkHttpClient providesOkHttpClient(Context context, Interceptor loggingInterceptor, String cookie) { @@ -239,20 +239,20 @@ public OkHttpClient providesOkHttpClient(Context context, Interceptor loggingInt long cacheSize = calculateDiskCacheSize(cacheDir); // Create a trust manager that does not validate certificate chains final TrustManager[] trustAllCerts = new TrustManager[]{ - new X509TrustManager() { - @Override - public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { - } + new X509TrustManager() { + @Override + public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { + } - @Override - public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { - } + @Override + public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { + } - @Override - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return new java.security.cert.X509Certificate[]{}; - } + @Override + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return new java.security.cert.X509Certificate[]{}; } + } }; SSLSocketFactory sslSocketFactory = null; @@ -273,14 +273,14 @@ public java.security.cert.X509Certificate[] getAcceptedIssuers() { } return new OkHttpClient.Builder() - .protocols(Arrays.asList(Protocol.HTTP_1_1)) - .hostnameVerifier(new TrustAllHostnameVerifier()) - .sslSocketFactory(sslSocketFactory, (X509TrustManager) trustAllCerts[0]) - .addNetworkInterceptor(new DefaultHeadersInterceptor(context, cookie)) - .addInterceptor(new DefaultHeadersInterceptor(context, cookie)) - .addInterceptor(loggingInterceptor) - //.cache(new Cache(cacheDir, cacheSize)) - .build(); + .protocols(Arrays.asList(Protocol.HTTP_1_1)) + .hostnameVerifier(new TrustAllHostnameVerifier()) + .sslSocketFactory(sslSocketFactory, (X509TrustManager) trustAllCerts[0]) + .addNetworkInterceptor(new DefaultHeadersInterceptor(context, cookie)) + .addInterceptor(new DefaultHeadersInterceptor(context, cookie)) + .addInterceptor(loggingInterceptor) + //.cache(new Cache(cacheDir, cacheSize)) + .build(); } @SuppressLint("BadHostnameVerifier") diff --git a/app/src/main/java/nl/hnogames/domoticz/Utils/SerializableManager.java b/app/src/main/java/nl/hnogames/domoticz/Utils/SerializableManager.java index 97f4b6ad6..10b17603c 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Utils/SerializableManager.java +++ b/app/src/main/java/nl/hnogames/domoticz/Utils/SerializableManager.java @@ -56,10 +56,10 @@ public static void cleanAllSerializableObjects(Context context) { */ public static void saveSerializable(Context context, Object objectToSave, String fileName) { File SettingsFile = new File(Environment.getExternalStorageDirectory(), - "/Domoticz/DomoticzSettings.txt"); + "/Domoticz/DomoticzSettings.txt"); final String sPath = SettingsFile.getPath(). - substring(0, SettingsFile.getPath().lastIndexOf("/")); + substring(0, SettingsFile.getPath().lastIndexOf("/")); //noinspection unused boolean mkdirsResultIsOk = new File(sPath + "/").mkdirs(); @@ -85,10 +85,10 @@ public static Object readSerializedObject(Context context, String fileName) { Object objectToReturn = null; File SettingsFile = new File(Environment.getExternalStorageDirectory(), - "/Domoticz/DomoticzSettings.txt"); + "/Domoticz/DomoticzSettings.txt"); final String sPath = SettingsFile.getPath(). - substring(0, SettingsFile.getPath().lastIndexOf("/")); + substring(0, SettingsFile.getPath().lastIndexOf("/")); //noinspection unused boolean mkdirsResultIsOk = new File(sPath + "/").mkdirs(); diff --git a/app/src/main/java/nl/hnogames/domoticz/Utils/SharedPrefUtil.java b/app/src/main/java/nl/hnogames/domoticz/Utils/SharedPrefUtil.java index bf2d8f07b..c39c2b1ba 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Utils/SharedPrefUtil.java +++ b/app/src/main/java/nl/hnogames/domoticz/Utils/SharedPrefUtil.java @@ -359,7 +359,7 @@ public boolean getSmallWidgetisScene(int widgetID) { return prefs.getBoolean("SMALLWIDGETSCENE" + widgetID, false); } - public void deleteSmallTempWidget(int widgetID, boolean isScene) { + public void deleteSmallTempWidget(int widgetID) { editor.remove("SMALLTEMPWIDGET" + widgetID); editor.remove("SMALLTEMPWIDGETIDX" + widgetID); editor.remove("SMALLTEMPWIDGETPASSWORD" + widgetID); @@ -753,7 +753,7 @@ public int getStartupScreenIndex() { public void setStartupScreenIndex(int position) { String[] startupScreenValues = - mContext.getResources().getStringArray(R.array.startup_actions); + mContext.getResources().getStringArray(R.array.startup_actions); String startupScreenValue; try { @@ -992,7 +992,7 @@ public ArrayList getNFCList() { String jsonNFCs = prefs.getString(PREF_NFC_TAGS, null); Gson gson = new Gson(); NFCInfo[] item = gson.fromJson(jsonNFCs, - NFCInfo[].class); + NFCInfo[].class); nfcs = Arrays.asList(item); for (NFCInfo n : nfcs) { oReturnValue.add(n); @@ -1016,7 +1016,7 @@ public ArrayList getBluetoothList() { String jsonBluetooths = prefs.getString(PREF_BLUETOOTH, null); Gson gson = new Gson(); BluetoothInfo[] item = gson.fromJson(jsonBluetooths, - BluetoothInfo[].class); + BluetoothInfo[].class); Bluetooths = Arrays.asList(item); for (BluetoothInfo n : Bluetooths) { oReturnValue.add(n); @@ -1039,7 +1039,7 @@ public ArrayList getQRCodeList() { String jsonNFCs = prefs.getString(PREF_QR_CODES, null); Gson gson = new Gson(); QRCodeInfo[] item = gson.fromJson(jsonNFCs, - QRCodeInfo[].class); + QRCodeInfo[].class); qrs = Arrays.asList(item); for (QRCodeInfo n : qrs) { oReturnValue.add(n); @@ -1063,7 +1063,7 @@ public ArrayList getSpeechList() { String jsonNFCs = prefs.getString(PREF_SPEECH_COMMANDS, null); Gson gson = new Gson(); SpeechInfo[] item = gson.fromJson(jsonNFCs, - SpeechInfo[].class); + SpeechInfo[].class); qrs = Arrays.asList(item); for (SpeechInfo n : qrs) { oReturnValue.add(n); @@ -1090,7 +1090,7 @@ public ArrayList getLocations() { String jsonLocations = prefs.getString(PREF_GEOFENCE_LOCATIONS, null); Gson gson = new Gson(); LocationInfo[] locationItem = gson.fromJson(jsonLocations, - LocationInfo[].class); + LocationInfo[].class); locations = Arrays.asList(locationItem); for (LocationInfo l : locations) { if (l.toGeofence() != null) { @@ -1102,8 +1102,8 @@ public ArrayList getLocations() { if (incorrectDetected) { saveLocations(returnValue); Toast.makeText(mContext, - R.string.geofence_error_recreateLocations, - Toast.LENGTH_LONG).show(); + R.string.geofence_error_recreateLocations, + Toast.LENGTH_LONG).show(); } } else return null; diff --git a/app/src/main/java/nl/hnogames/domoticz/Utils/UsefulBits.java b/app/src/main/java/nl/hnogames/domoticz/Utils/UsefulBits.java index cebb1ae12..9e83bff25 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Utils/UsefulBits.java +++ b/app/src/main/java/nl/hnogames/domoticz/Utils/UsefulBits.java @@ -139,8 +139,8 @@ public static char[] Reverse(char[] A) { public static String Join(List msgs) { return msgs == null || msgs.size() == 0 ? - "" : msgs.size() == 1 ? msgs.get(0) : - msgs.subList(0, msgs.size() - 1).toString().replaceAll("^.|.$", "") + " and " + msgs.get(msgs.size() - 1); + "" : msgs.size() == 1 ? msgs.get(0) : + msgs.subList(0, msgs.size() - 1).toString().replaceAll("^.|.$", "") + " and " + msgs.get(msgs.size() - 1); } public static String newLine() { @@ -200,7 +200,7 @@ public static String getMd5String(String password) { for (byte aHash : hash) { if ((0xff & aHash) < 0x10) { hexString.append("0" - + Integer.toHexString((0xFF & aHash))); + + Integer.toHexString((0xFF & aHash))); } else { hexString.append(Integer.toHexString(0xFF & aHash)); } @@ -338,9 +338,9 @@ public static void checkDownloadedLanguage(Context context, ServerUtil serverUti showSimpleToast(context, "Downloaded language files did not match the preferred language", Toast.LENGTH_SHORT); Log.d(TAG, "Downloaded language files did not match the preferred language:" + newLine() - + "Current downloaded language: " + downloadedLanguage + newLine() - + "Active language: " + activeLanguage + newLine() - + "Downloading the correct language"); + + "Current downloaded language: " + downloadedLanguage + newLine() + + "Active language: " + activeLanguage + newLine() + + "Downloading the correct language"); mSharedPrefs.getLanguageStringsFromServer(activeLanguage.toLowerCase(), serverUtil); } } @@ -413,14 +413,14 @@ public static void setScheduledTasks(Context context) { @SuppressWarnings("PointlessArithmeticExpression") PeriodicTask task = new PeriodicTask.Builder() - .setService(TaskService.class) // Service to start - .setPersisted(true) // Will survive reboots - .setTag(TASK_TAG_PERIODIC) // Schedule periodic - .setPeriod(60 * 60 * 24 * 1) // Every day - .setFlex(60 * 60 * 8) // Flex of 8 hours - .setRequiredNetwork(Task.NETWORK_STATE_UNMETERED) // Only un metered networks - .setRequiresCharging(true) // Only when charging - .build(); + .setService(TaskService.class) // Service to start + .setPersisted(true) // Will survive reboots + .setTag(TASK_TAG_PERIODIC) // Schedule periodic + .setPeriod(60 * 60 * 24 * 1) // Every day + .setFlex(60 * 60 * 8) // Flex of 8 hours + .setRequiredNetwork(Task.NETWORK_STATE_UNMETERED) // Only un metered networks + .setRequiresCharging(true) // Only when charging + .build(); mGcmNetworkManager.schedule(task); mSharedPrefUtil.setTaskIsScheduled(true); @@ -466,8 +466,8 @@ public void onError(Exception error) { public void onError(Exception error) { if (error != null && domoticz != null) showSimpleToast(context, String.format( - context.getString(R.string.error_couldNotCheckForConfig), - domoticz.getErrorMessage(error)), Toast.LENGTH_SHORT); + context.getString(R.string.error_couldNotCheckForConfig), + domoticz.getErrorMessage(error)), Toast.LENGTH_SHORT); if (receiver != null) receiver.onError(error); } @@ -480,8 +480,8 @@ public static void GetServerUserInfo(final Domoticz domoticz, final AuthInfo aut ArrayList mDetailUserInfo = new ArrayList<>(); UserInfo currentUser = new UserInfo(domoticz.getUserCredentials(Domoticz.Authentication.USERNAME), - UsefulBits.getMd5String(domoticz.getUserCredentials(Domoticz.Authentication.PASSWORD)), - auth != null ? auth.getRights() : 0); + UsefulBits.getMd5String(domoticz.getUserCredentials(Domoticz.Authentication.PASSWORD)), + auth != null ? auth.getRights() : 0); if (currentConfig != null && currentConfig.getUsers() != null) { for (UserInfo user : currentConfig.getUsers()) { if (!user.getUsername().equals(currentUser.getUsername())) @@ -501,8 +501,8 @@ public void onReceiveUsers(final ArrayList mUserInfo) { ArrayList mDetailUserInfo = new ArrayList<>(); //also add current user UserInfo currentUser = new UserInfo(domoticz.getUserCredentials(Domoticz.Authentication.USERNAME), - UsefulBits.getMd5String(domoticz.getUserCredentials(Domoticz.Authentication.PASSWORD)), - auth != null ? auth.getRights() : 0); + UsefulBits.getMd5String(domoticz.getUserCredentials(Domoticz.Authentication.PASSWORD)), + auth != null ? auth.getRights() : 0); for (UserInfo user : mUserInfo) { if (!user.getUsername().equals(currentUser.getUsername())) mDetailUserInfo.add(user); @@ -542,7 +542,7 @@ public static boolean checkPlayServicesAvailable(final Activity activity) { // Unresolvable error Log.e(TAG, "Google Play services is unavailable."); showSimpleToast(activity, - activity.getString(R.string.google_play_services_unavailable), Toast.LENGTH_SHORT); + activity.getString(R.string.google_play_services_unavailable), Toast.LENGTH_SHORT); return false; } } @@ -584,27 +584,27 @@ public static void showSnackbarWithAction(Context context, CoordinatorLayout coo View.OnClickListener onclickListener, String actiontext) { try { if (context != null && - coordinatorLayout != null && - !UsefulBits.isEmpty(message)) { + coordinatorLayout != null && + !UsefulBits.isEmpty(message)) { if (onclickListener == null || UsefulBits.isEmpty(actiontext)) { if (callback != null) { Snackbar.make(coordinatorLayout, message, length) - .setCallback(callback) - .show(); + .setCallback(callback) + .show(); } else { Snackbar.make(coordinatorLayout, message, length) - .show(); + .show(); } } else { if (callback != null) { Snackbar.make(coordinatorLayout, message, length) - .setAction(actiontext, onclickListener) - .setCallback(callback) - .show(); + .setAction(actiontext, onclickListener) + .setCallback(callback) + .show(); } else { Snackbar.make(coordinatorLayout, message, length) - .setAction(actiontext, onclickListener) - .show(); + .setAction(actiontext, onclickListener) + .show(); } } } @@ -623,8 +623,8 @@ public static void openPremiumAppStore(Context context) { if (otherApp.activityInfo.applicationInfo.packageName.equals("com.android.vending")) { ActivityInfo otherAppActivity = otherApp.activityInfo; ComponentName componentName = new ComponentName( - otherAppActivity.applicationInfo.packageName, - otherAppActivity.name + otherAppActivity.applicationInfo.packageName, + otherAppActivity.name ); rateIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); rateIntent.setComponent(componentName); @@ -663,21 +663,21 @@ public static void checkAPK(final Context context, final SharedPrefUtil mSharedP // release build PiracyChecker oPiracyChecker = new PiracyChecker(context); oPiracyChecker - .enableSigningCertificate(context.getString(R.string.APK_VALIDATE_PROD)) - .enableGooglePlayLicensing(context.getString(R.string.APK_LICENSE_PREMIUM)) - .enableInstallerId(InstallerID.GOOGLE_PLAY) - .callback(new PiracyCheckerCallback() { - @Override - public void allow() { - mSharedPrefs.setAPKValidated(true); - } + .enableSigningCertificate(context.getString(R.string.APK_VALIDATE_PROD)) + .enableGooglePlayLicensing(context.getString(R.string.APK_LICENSE_PREMIUM)) + .enableInstallerId(InstallerID.GOOGLE_PLAY) + .callback(new PiracyCheckerCallback() { + @Override + public void allow() { + mSharedPrefs.setAPKValidated(true); + } - @Override - public void dontAllow(@NonNull PiracyCheckerError piracyCheckerError, @Nullable PirateApp pirateApp) { - mSharedPrefs.setAPKValidated(false); - } - }) - .start(); + @Override + public void dontAllow(@NonNull PiracyCheckerError piracyCheckerError, @Nullable PirateApp pirateApp) { + mSharedPrefs.setAPKValidated(false); + } + }) + .start(); } } } \ No newline at end of file diff --git a/app/src/main/java/nl/hnogames/domoticz/Welcome/SetupServerSettings.java b/app/src/main/java/nl/hnogames/domoticz/Welcome/SetupServerSettings.java index 876cd98d6..a218d286b 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Welcome/SetupServerSettings.java +++ b/app/src/main/java/nl/hnogames/domoticz/Welcome/SetupServerSettings.java @@ -73,9 +73,9 @@ public class SetupServerSettings extends Fragment implements OnPermissionCallbac private ServerUtil mServerUtil; private AppCompatEditText remote_server_input, remote_port_input, - remote_username_input, remote_password_input, - remote_directory_input, local_server_input, local_password_input, - local_username_input, local_port_input, local_directory_input, server_name_input; + remote_username_input, remote_password_input, + remote_directory_input, local_server_input, local_password_input, + local_username_input, local_port_input, local_directory_input, server_name_input; private Spinner remote_protocol_spinner, local_protocol_spinner; private SwitchMaterial localServer_switch; @@ -164,27 +164,27 @@ private void getLayoutReferences() { @Override public void onClick(View v) { new MaterialDialog.Builder(getContext()) - .title(R.string.welcome_ssid_button_prompt) - .content(R.string.welcome_msg_no_ssid_found) - .inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD) - .input(null, null, new MaterialDialog.InputCallback() { - @Override - public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { - Set ssidFromPrefs = mServerUtil.getActiveServer().getLocalServerSsid(); - final ArrayList ssidListFromPrefs = new ArrayList<>(); - if (ssidFromPrefs != null) { - if (ssidFromPrefs.size() > 0) { - for (String wifi : ssidFromPrefs) { - ssidListFromPrefs.add(wifi); - } + .title(R.string.welcome_ssid_button_prompt) + .content(R.string.welcome_msg_no_ssid_found) + .inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD) + .input(null, null, new MaterialDialog.InputCallback() { + @Override + public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { + Set ssidFromPrefs = mServerUtil.getActiveServer().getLocalServerSsid(); + final ArrayList ssidListFromPrefs = new ArrayList<>(); + if (ssidFromPrefs != null) { + if (ssidFromPrefs.size() > 0) { + for (String wifi : ssidFromPrefs) { + ssidListFromPrefs.add(wifi); } } - - ssidListFromPrefs.add(String.valueOf(input)); - mServerUtil.getActiveServer().setLocalServerSsid(ssidListFromPrefs); - setSsid_spinner(); } - }).show(); + + ssidListFromPrefs.add(String.valueOf(input)); + mServerUtil.getActiveServer().setLocalServerSsid(ssidListFromPrefs); + setSsid_spinner(); + } + }).show(); } }); @@ -243,10 +243,10 @@ private void checkConnectionData() { if (!UsefulBits.isEmpty(status)) { showErrorPopup(getString(R.string.welcome_msg_connectionDataIncomplete) + "\n\n" + status + "\n\n" - + getString(R.string.welcome_msg_correctOnPreviousPage)); + + getString(R.string.welcome_msg_correctOnPreviousPage)); } else if (!mDomoticz.isUrlValid(newServer)) { showErrorPopup(getString(R.string.welcome_msg_connectionDataInvalid) + "\n\n" - + getString(R.string.welcome_msg_correctOnPreviousPage)); + + getString(R.string.welcome_msg_correctOnPreviousPage)); } else if (!isUpdateRequest && !mServerUtil.checkUniqueServerName(newServer)) { showErrorPopup("Server name must be unique!"); } else { @@ -256,15 +256,15 @@ private void checkConnectionData() { private void showErrorPopup(String error) { new AlertDialog.Builder(getActivity()) - .setIcon(android.R.drawable.ic_dialog_info) - .setTitle("Failed") - .setMessage(error) - .setPositiveButton(this.getString(R.string.yes), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - } - }) - .show(); + .setIcon(android.R.drawable.ic_dialog_info) + .setTitle("Failed") + .setMessage(error) + .setPositiveButton(this.getString(R.string.yes), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + } + }) + .show(); } private void setPreferenceValues() { @@ -349,7 +349,7 @@ public void ReceiveSSIDs(CharSequence[] ssidFound) { private void setProtocol_spinner() { String[] protocols = getResources().getStringArray(R.array.remote_server_protocols); ArrayAdapter protocolAdapter - = new ArrayAdapter<>(getActivity(), R.layout.spinner_list_item, protocols); + = new ArrayAdapter<>(getActivity(), R.layout.spinner_list_item, protocols); remote_protocol_spinner.setAdapter(protocolAdapter); remote_protocol_spinner.setSelection(getPrefsDomoticzRemoteSecureIndex()); remote_protocol_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @@ -382,17 +382,17 @@ public void onNothingSelected(AdapterView adapterView) { private void buildServerInfo() { newServer = new ServerInfo(); newServer.setRemoteServerUsername( - remote_username_input.getText().toString().trim()); + remote_username_input.getText().toString().trim()); newServer.setRemoteServerPassword( - remote_password_input.getText().toString().trim()); + remote_password_input.getText().toString().trim()); newServer.setRemoteServerUrl( - remote_server_input.getText().toString().trim()); + remote_server_input.getText().toString().trim()); newServer.setRemoteServerPort( - remote_port_input.getText().toString().trim()); + remote_port_input.getText().toString().trim()); newServer.setRemoteServerDirectory( - remote_directory_input.getText().toString().trim()); + remote_directory_input.getText().toString().trim()); newServer.setRemoteServerSecure( - getSpinnerDomoticzRemoteSecureBoolean()); + getSpinnerDomoticzRemoteSecureBoolean()); newServer.setEnabled(false); if (!localServer_switch.isChecked()) { @@ -400,17 +400,17 @@ private void buildServerInfo() { newServer.setIsLocalServerAddressDifferent(false); } else { newServer.setLocalServerUsername( - local_username_input.getText().toString().trim()); + local_username_input.getText().toString().trim()); newServer.setLocalServerPassword( - local_password_input.getText().toString().trim()); + local_password_input.getText().toString().trim()); newServer.setLocalServerUrl( - local_server_input.getText().toString().trim()); + local_server_input.getText().toString().trim()); newServer.setLocalServerPort( - local_port_input.getText().toString().trim()); + local_port_input.getText().toString().trim()); newServer.setLocalServerDirectory( - local_directory_input.getText().toString().trim()); + local_directory_input.getText().toString().trim()); newServer.setLocalServerSecure( - getSpinnerDomoticzLocalSecureBoolean()); + getSpinnerDomoticzLocalSecureBoolean()); newServer.setIsLocalServerAddressDifferent(true); } @@ -502,13 +502,13 @@ public void onPermissionDeclined(@NonNull String[] permissionName) { Log.i("onPermissionDeclined", "Permission(s) " + Arrays.toString(permissionName) + " Declined"); String[] neededPermission = PermissionFragmentHelper.declinedPermissions(this, PermissionsUtil.INITIAL_LOCATION_PERMS); AlertDialog alert = PermissionsUtil.getAlertDialog(getActivity(), permissionFragmentHelper, getActivity().getString(R.string.permission_title), - getActivity().getString(R.string.permission_desc_location), neededPermission, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - if (mPhoneConnectionUtil != null) - mPhoneConnectionUtil.stopReceiver(); - } - }); + getActivity().getString(R.string.permission_desc_location), neededPermission, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + if (mPhoneConnectionUtil != null) + mPhoneConnectionUtil.stopReceiver(); + } + }); if (!alert.isShowing()) { alert.show(); } diff --git a/app/src/main/java/nl/hnogames/domoticz/Welcome/WelcomePage2.java b/app/src/main/java/nl/hnogames/domoticz/Welcome/WelcomePage2.java index 83d4e1317..a3faa6beb 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Welcome/WelcomePage2.java +++ b/app/src/main/java/nl/hnogames/domoticz/Welcome/WelcomePage2.java @@ -69,7 +69,7 @@ public void onClick(View v) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (!PermissionsUtil.canAccessStorage(getActivity())) { permissionFragmentHelper - .request(PermissionsUtil.INITIAL_STORAGE_PERMS); + .request(PermissionsUtil.INITIAL_STORAGE_PERMS); } else { importSettings(); } @@ -106,7 +106,7 @@ public void onPermissionDeclined(@NonNull String[] permissionName) { Log.i("onPermissionDeclined", "Permission(s) " + Arrays.toString(permissionName) + " Declined"); String[] neededPermission = PermissionFragmentHelper.declinedPermissions(this, PermissionsUtil.INITIAL_STORAGE_PERMS); AlertDialog alert = PermissionsUtil.getAlertDialog(getActivity(), permissionFragmentHelper, getActivity().getString(R.string.permission_title), - getActivity().getString(R.string.permission_desc_storage), neededPermission); + getActivity().getString(R.string.permission_desc_storage), neededPermission); if (!alert.isShowing()) { alert.show(); } diff --git a/app/src/main/java/nl/hnogames/domoticz/Welcome/WelcomePage3.java b/app/src/main/java/nl/hnogames/domoticz/Welcome/WelcomePage3.java index 33be54a10..4e60a1024 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Welcome/WelcomePage3.java +++ b/app/src/main/java/nl/hnogames/domoticz/Welcome/WelcomePage3.java @@ -70,9 +70,9 @@ public class WelcomePage3 extends Fragment implements OnPermissionCallback { private ServerUtil mServerUtil; private AppCompatEditText remote_server_input, remote_port_input, - remote_username_input, remote_password_input, - remote_directory_input, local_server_input, local_password_input, - local_username_input, local_port_input, local_directory_input; + remote_username_input, remote_password_input, + remote_directory_input, local_server_input, local_password_input, + local_username_input, local_port_input, local_directory_input; private Spinner remote_protocol_spinner, local_protocol_spinner; private SwitchMaterial localServer_switch; @@ -148,27 +148,27 @@ private void getLayoutReferences() { @Override public void onClick(View v) { new MaterialDialog.Builder(getContext()) - .title(R.string.welcome_ssid_button_prompt) - .content(R.string.welcome_msg_no_ssid_found) - .inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD) - .input(null, null, new MaterialDialog.InputCallback() { - @Override - public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { - Set ssidFromPrefs = mServerUtil.getActiveServer().getLocalServerSsid(); - final ArrayList ssidListFromPrefs = new ArrayList<>(); - if (ssidFromPrefs != null) { - if (ssidFromPrefs.size() > 0) { - for (String wifi : ssidFromPrefs) { - ssidListFromPrefs.add(wifi); - } + .title(R.string.welcome_ssid_button_prompt) + .content(R.string.welcome_msg_no_ssid_found) + .inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD) + .input(null, null, new MaterialDialog.InputCallback() { + @Override + public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { + Set ssidFromPrefs = mServerUtil.getActiveServer().getLocalServerSsid(); + final ArrayList ssidListFromPrefs = new ArrayList<>(); + if (ssidFromPrefs != null) { + if (ssidFromPrefs.size() > 0) { + for (String wifi : ssidFromPrefs) { + ssidListFromPrefs.add(wifi); } } - ssidListFromPrefs.add(String.valueOf(input)); - mServerUtil.getActiveServer().setLocalServerSsid(ssidListFromPrefs); - - setSsid_spinner(); } - }).show(); + ssidListFromPrefs.add(String.valueOf(input)); + mServerUtil.getActiveServer().setLocalServerSsid(ssidListFromPrefs); + + setSsid_spinner(); + } + }).show(); } }); @@ -288,7 +288,7 @@ public void ReceiveSSIDs(CharSequence[] ssidFound) { private void setProtocol_spinner() { String[] protocols = getResources().getStringArray(R.array.remote_server_protocols); ArrayAdapter protocolAdapter - = new ArrayAdapter<>(getActivity(), R.layout.spinner_list_item, protocols); + = new ArrayAdapter<>(getActivity(), R.layout.spinner_list_item, protocols); remote_protocol_spinner.setAdapter(protocolAdapter); remote_protocol_spinner.setSelection(getPrefsDomoticzRemoteSecureIndex()); remote_protocol_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @@ -320,34 +320,34 @@ public void onNothingSelected(AdapterView adapterView) { private void writePreferenceValues() { mServerUtil.getActiveServer().setRemoteServerUsername( - remote_username_input.getText().toString().trim()); + remote_username_input.getText().toString().trim()); mServerUtil.getActiveServer().setRemoteServerPassword( - remote_password_input.getText().toString().trim()); + remote_password_input.getText().toString().trim()); mServerUtil.getActiveServer().setRemoteServerUrl( - remote_server_input.getText().toString().trim()); + remote_server_input.getText().toString().trim()); mServerUtil.getActiveServer().setRemoteServerPort( - remote_port_input.getText().toString().trim()); + remote_port_input.getText().toString().trim()); mServerUtil.getActiveServer().setRemoteServerDirectory( - remote_directory_input.getText().toString().trim()); + remote_directory_input.getText().toString().trim()); mServerUtil.getActiveServer().setRemoteServerSecure( - getSpinnerDomoticzRemoteSecureBoolean()); + getSpinnerDomoticzRemoteSecureBoolean()); SwitchMaterial useSameAddress = v.findViewById(R.id.localServer_switch); if (!useSameAddress.isChecked()) { mServerUtil.getActiveServer().setLocalSameAddressAsRemote(); mServerUtil.getActiveServer().setIsLocalServerAddressDifferent(false); } else { mServerUtil.getActiveServer().setLocalServerUsername( - local_username_input.getText().toString().trim()); + local_username_input.getText().toString().trim()); mServerUtil.getActiveServer().setLocalServerPassword( - local_password_input.getText().toString().trim()); + local_password_input.getText().toString().trim()); mServerUtil.getActiveServer().setLocalServerUrl( - local_server_input.getText().toString().trim()); + local_server_input.getText().toString().trim()); mServerUtil.getActiveServer().setLocalServerPort( - local_port_input.getText().toString().trim()); + local_port_input.getText().toString().trim()); mServerUtil.getActiveServer().setLocalServerDirectory( - local_directory_input.getText().toString().trim()); + local_directory_input.getText().toString().trim()); mServerUtil.getActiveServer().setLocalServerSecure( - getSpinnerDomoticzLocalSecureBoolean()); + getSpinnerDomoticzLocalSecureBoolean()); mServerUtil.getActiveServer().setIsLocalServerAddressDifferent(true); } @@ -418,13 +418,13 @@ public void onPermissionDeclined(@NonNull String[] permissionName) { Log.i("onPermissionDeclined", "Permission(s) " + Arrays.toString(permissionName) + " Declined"); String[] neededPermission = PermissionFragmentHelper.declinedPermissions(this, PermissionsUtil.INITIAL_LOCATION_PERMS); AlertDialog alert = PermissionsUtil.getAlertDialog(getActivity(), permissionFragmentHelper, getActivity().getString(R.string.permission_title), - getActivity().getString(R.string.permission_desc_location), neededPermission, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - if (mPhoneConnectionUtil != null) - mPhoneConnectionUtil.stopReceiver(); - } - }); + getActivity().getString(R.string.permission_desc_location), neededPermission, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + if (mPhoneConnectionUtil != null) + mPhoneConnectionUtil.stopReceiver(); + } + }); if (!alert.isShowing()) { alert.show(); } diff --git a/app/src/main/java/nl/hnogames/domoticz/Welcome/WelcomePage4.java b/app/src/main/java/nl/hnogames/domoticz/Welcome/WelcomePage4.java index 82158d529..f00394859 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Welcome/WelcomePage4.java +++ b/app/src/main/java/nl/hnogames/domoticz/Welcome/WelcomePage4.java @@ -81,10 +81,10 @@ private void checkConnectionData() { if (!mDomoticz.isConnectionDataComplete(mServerUtil.getActiveServer())) { setResultText(getString(R.string.welcome_msg_connectionDataIncomplete) + "\n\n" - + getString(R.string.welcome_msg_correctOnPreviousPage)); + + getString(R.string.welcome_msg_correctOnPreviousPage)); } else if (!mDomoticz.isUrlValid(mServerUtil.getActiveServer())) { setResultText(getString(R.string.welcome_msg_connectionDataInvalid) + "\n\n" - + getString(R.string.welcome_msg_correctOnPreviousPage)); + + getString(R.string.welcome_msg_correctOnPreviousPage)); } else { mDomoticz.getServerVersion(new VersionReceiver() { @Override diff --git a/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetConfigurationActivity.java b/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetConfigurationActivity.java index eeac72ecc..76a44a7b3 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetConfigurationActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetConfigurationActivity.java @@ -101,10 +101,10 @@ protected void onCreate(Bundle savedInstanceState) { @Override public void onClick(View view) { InputMethodManager imm = - (InputMethodManager) getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE); + (InputMethodManager) getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editPin.getWindowToken(), 0); final String password = - UsefulBits.getMd5String(editPin.getText().toString()); + UsefulBits.getMd5String(editPin.getText().toString()); if (UsefulBits.isEmpty(password)) { Toast.makeText(getApplicationContext(), getString(R.string.security_wrong_code), Toast.LENGTH_LONG).show(); return; @@ -118,7 +118,7 @@ public void onReceiveSettings(SettingsInfo settings) { if (validatePassword(password)) { if (sSecurityPanel != null) { getBackground(sSecurityPanel, password, getApplicationContext().getString(R.string.status) + ": " + - sSecurityPanel.getData()); + sSecurityPanel.getData()); } } else Toast.makeText(getApplicationContext(), getString(R.string.security_wrong_code), Toast.LENGTH_LONG).show(); @@ -133,7 +133,7 @@ public void onError(Exception error) { if (validatePassword(password)) { if (sSecurityPanel != null) { getBackground(sSecurityPanel, password, getApplicationContext().getString(R.string.status) + ": " + - sSecurityPanel.getData()); + sSecurityPanel.getData()); } } else Toast.makeText(getApplicationContext(), getString(R.string.security_wrong_code), Toast.LENGTH_LONG).show(); @@ -170,17 +170,17 @@ public void onError(Exception error) { private void getBackground(final DevicesInfo mSelectedSwitch, final String password, final String value) { new MaterialDialog.Builder(this) - .title(this.getString(R.string.widget_background)) - .items(new String[]{this.getString(R.string.widget_dark), this.getString(R.string.widget_light), this.getString(R.string.widget_transparent_dark), this.getString(R.string.widget_transparent_light)}) - .itemsCallbackSingleChoice(-1, new MaterialDialog.ListCallbackSingleChoice() { - @Override - public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { - showAppWidget(mSelectedSwitch, value, password, getWidgetLayout(String.valueOf(text))); - return true; - } - }) - .positiveText(R.string.ok) - .show(); + .title(this.getString(R.string.widget_background)) + .items(new String[]{this.getString(R.string.widget_dark), this.getString(R.string.widget_light), this.getString(R.string.widget_transparent_dark), this.getString(R.string.widget_transparent_light)}) + .itemsCallbackSingleChoice(-1, new MaterialDialog.ListCallbackSingleChoice() { + @Override + public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { + showAppWidget(mSelectedSwitch, value, password, getWidgetLayout(String.valueOf(text))); + return true; + } + }) + .positiveText(R.string.ok) + .show(); } private int getWidgetLayout(String background) { @@ -234,12 +234,12 @@ public void onReceiveDevices(final ArrayList mDevicesInfo) { boolean deviceFound = false; for (DevicesInfo d : mDevicesInfo) { if (!UsefulBits.isEmpty(d.getSwitchType()) && - d.getSwitchType().equals(DomoticzValues.Device.Type.Name.SECURITY)) { + d.getSwitchType().equals(DomoticzValues.Device.Type.Name.SECURITY)) { if (d.getSubType().equals(DomoticzValues.Device.SubType.Name.SECURITYPANEL)) { sSecurityPanel = d; txtTitle.setText(sSecurityPanel.getName()); txtStatus.setText(getApplicationContext().getString(R.string.status) + ": " + - sSecurityPanel.getData()); + sSecurityPanel.getData()); deviceFound = true; } } @@ -276,10 +276,10 @@ private void showAppWidget(DevicesInfo mSelectedSwitch, String value, String pin if (extras != null) { mAppWidgetId = extras.getInt(EXTRA_APPWIDGET_ID, - INVALID_APPWIDGET_ID); + INVALID_APPWIDGET_ID); mSharedPrefs.setSecurityWidgetIDX(mAppWidgetId, idx, value, pin, layout); Intent startService = new Intent(SecurityWidgetConfigurationActivity.this, - SecurityWidgetProvider.UpdateSecurityWidgetService.class); + SecurityWidgetProvider.UpdateSecurityWidgetService.class); startService.putExtra(EXTRA_APPWIDGET_ID, mAppWidgetId); startService.setAction("FROM CONFIGURATION ACTIVITY"); startService(startService); diff --git a/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetIntentService.java b/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetIntentService.java index 2980d4209..8fc17a3fd 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetIntentService.java +++ b/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetIntentService.java @@ -87,18 +87,18 @@ private void processRequest(final int idx, final int status, final String passwo public void onReceiveResult(String result) { if (action == DomoticzValues.Security.Status.ARMAWAY) { Toast.makeText(mContext, mContext.getString(R.string.status) + ": " + - mContext.getString(R.string.security_arm_away), - Toast.LENGTH_LONG).show(); + mContext.getString(R.string.security_arm_away), + Toast.LENGTH_LONG).show(); } else if (action == DomoticzValues.Security.Status.ARMHOME) { Toast.makeText(mContext, mContext.getString(R.string.status) + ": " + - mContext.getString(R.string.security_arm_home), - Toast.LENGTH_LONG).show(); + mContext.getString(R.string.security_arm_home), + Toast.LENGTH_LONG).show(); } else if (action == DomoticzValues.Security.Status.DISARM) { Toast.makeText(mContext, mContext.getString(R.string.status) + ": " + - mContext.getString(R.string.security_disarm), - Toast.LENGTH_LONG).show(); + mContext.getString(R.string.security_disarm), + Toast.LENGTH_LONG).show(); } WidgetUtils.RefreshWidgets(mContext); } @@ -107,8 +107,8 @@ public void onReceiveResult(String result) { public void onError(Exception error) { Log.e("SECURITYWIDGET", domoticz.getErrorMessage(error)); Toast.makeText(mContext, - mContext.getString(R.string.security_generic_error), - Toast.LENGTH_SHORT).show(); + mContext.getString(R.string.security_generic_error), + Toast.LENGTH_SHORT).show(); } }); } diff --git a/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetProvider.java b/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetProvider.java index 84bdbddb2..58973a3a9 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetProvider.java +++ b/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetProvider.java @@ -87,7 +87,7 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, // Get all ids ComponentName thisWidget = new ComponentName(context, - SecurityWidgetProvider.class); + SecurityWidgetProvider.class); int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget); if (allWidgetIds != null) { for (int mAppWidgetId : allWidgetIds) { @@ -114,10 +114,10 @@ public int onStartCommand(Intent intent, int flags, int startId) { this.startForeground(1337, NotificationUtil.getForegroundServiceNotification(this, "Widget")); } AppWidgetManager appWidgetManager = AppWidgetManager - .getInstance(UpdateSecurityWidgetService.this); + .getInstance(UpdateSecurityWidgetService.this); try { int incomingAppWidgetId = intent.getIntExtra(EXTRA_APPWIDGET_ID, - INVALID_APPWIDGET_ID); + INVALID_APPWIDGET_ID); if (incomingAppWidgetId != INVALID_APPWIDGET_ID) { try { updateAppWidget(appWidgetManager, incomingAppWidgetId); @@ -166,24 +166,24 @@ public void onReceiveDevice(DevicesInfo s) { views = new RemoteViews(packageName, mSharedPrefs.getSecurityWidgetLayout(appWidgetId)); views.setTextViewText(R.id.title, s.getName()); views.setTextViewText(R.id.status, getApplicationContext().getString(R.string.status) + ": " + - s.getData()); + s.getData()); views.setOnClickPendingIntent(R.id.armhome, buildButtonPendingIntent( - UpdateSecurityWidgetService.this, - appWidgetId, - s.getIdx(), ACTION_WIDGET_ARMHOME, password)); + UpdateSecurityWidgetService.this, + appWidgetId, + s.getIdx(), ACTION_WIDGET_ARMHOME, password)); views.setViewVisibility(R.id.armhome, View.VISIBLE); views.setOnClickPendingIntent(R.id.armaway, buildButtonPendingIntent( - UpdateSecurityWidgetService.this, - appWidgetId, - s.getIdx(), ACTION_WIDGET_ARMAWAY, password)); + UpdateSecurityWidgetService.this, + appWidgetId, + s.getIdx(), ACTION_WIDGET_ARMAWAY, password)); views.setViewVisibility(R.id.armaway, View.VISIBLE); views.setOnClickPendingIntent(R.id.disarm, buildButtonPendingIntent( - UpdateSecurityWidgetService.this, - appWidgetId, - s.getIdx(), ACTION_WIDGET_DISARM, password)); + UpdateSecurityWidgetService.this, + appWidgetId, + s.getIdx(), ACTION_WIDGET_DISARM, password)); views.setViewVisibility(R.id.disarm, View.VISIBLE); views.setImageViewResource(R.id.rowIcon, DomoticzIcons.getDrawableIcon(s.getTypeImg(), s.getType(), s.getSwitchType(), true, s.getUseCustomImage(), s.getImage())); diff --git a/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallTempWidgetConfigurationActivity.java b/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallTempWidgetConfigurationActivity.java index 242953fd3..e263e4b03 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallTempWidgetConfigurationActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallTempWidgetConfigurationActivity.java @@ -39,9 +39,7 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.SearchView; import androidx.core.view.MenuItemCompat; -import nl.hnogames.domoticz.Adapters.TemperatureAdapter; import nl.hnogames.domoticz.Adapters.TemperatureWidgetAdapter; -import nl.hnogames.domoticz.Adapters.WidgetsAdapter; import nl.hnogames.domoticz.BuildConfig; import nl.hnogames.domoticz.R; import nl.hnogames.domoticz.UI.PasswordDialog; @@ -49,11 +47,8 @@ import nl.hnogames.domoticz.Utils.UsefulBits; import nl.hnogames.domoticz.Welcome.WelcomeViewActivity; import nl.hnogames.domoticz.app.AppController; -import nl.hnogames.domoticzapi.Containers.DevicesInfo; import nl.hnogames.domoticzapi.Containers.TemperatureInfo; import nl.hnogames.domoticzapi.Domoticz; -import nl.hnogames.domoticzapi.DomoticzValues; -import nl.hnogames.domoticzapi.Interfaces.DevicesReceiver; import nl.hnogames.domoticzapi.Interfaces.TemperatureReceiver; import static android.appwidget.AppWidgetManager.EXTRA_APPWIDGET_ID; @@ -135,7 +130,7 @@ public void initListViews() { public void onReceiveTemperatures(ArrayList mDevicesInfo) { ArrayList mNewDevicesInfo = new ArrayList(); for (TemperatureInfo d : mDevicesInfo) - mNewDevicesInfo.add(d); + mNewDevicesInfo.add(d); ListView listView = findViewById(R.id.list); adapter = new TemperatureWidgetAdapter(SmallTempWidgetConfigurationActivity.this, domoticz, domoticz.getServerUtil(), mNewDevicesInfo); @@ -158,8 +153,7 @@ public void onDismiss(String password) { public void onCancel() { } }); - } - else{ + } else { getBackground(mDeviceInfo, null, null); } } @@ -197,17 +191,17 @@ private int getWidgetLayout(String background) { private void getBackground(final TemperatureInfo mSelectedTemperatureInfo, final String password, final String value) { new MaterialDialog.Builder(this) - .title(this.getString(R.string.widget_background)) - .items(new String[]{this.getString(R.string.widget_dark), this.getString(R.string.widget_light), this.getString(R.string.widget_transparent_dark), this.getString(R.string.widget_transparent_light)}) - .itemsCallbackSingleChoice(-1, new MaterialDialog.ListCallbackSingleChoice() { - @Override - public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { - showAppWidget(mSelectedTemperatureInfo, password, value, getWidgetLayout(String.valueOf(text))); - return true; - } - }) - .positiveText(R.string.ok) - .show(); + .title(this.getString(R.string.widget_background)) + .items(new String[]{this.getString(R.string.widget_dark), this.getString(R.string.widget_light), this.getString(R.string.widget_transparent_dark), this.getString(R.string.widget_transparent_light)}) + .itemsCallbackSingleChoice(-1, new MaterialDialog.ListCallbackSingleChoice() { + @Override + public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { + showAppWidget(mSelectedTemperatureInfo, password, value, getWidgetLayout(String.valueOf(text))); + return true; + } + }) + .positiveText(R.string.ok) + .show(); } private void showAppWidget(TemperatureInfo mSelectedSwitch, String password, String value, int layoutId) { @@ -217,18 +211,18 @@ private void showAppWidget(TemperatureInfo mSelectedSwitch, String password, Str int idx = mSelectedSwitch.getIdx(); if (extras != null) { mAppWidgetId = extras.getInt(EXTRA_APPWIDGET_ID, - INVALID_APPWIDGET_ID); + INVALID_APPWIDGET_ID); if (UsefulBits.isEmpty(mSelectedSwitch.getType())) { Log.i(TAG, "Widget without a type saved"); mSharedPrefs.setSmallTempWidgetIDX(mAppWidgetId, idx, false, password, value, layoutId); } else { - Log.i(TAG, "Widget saved " + mSelectedSwitch.getType()); - mSharedPrefs.setSmallTempWidgetIDX(mAppWidgetId, idx, false, password, value, layoutId); + Log.i(TAG, "Widget saved " + mSelectedSwitch.getType()); + mSharedPrefs.setSmallTempWidgetIDX(mAppWidgetId, idx, false, password, value, layoutId); } Intent startService = new Intent(SmallTempWidgetConfigurationActivity.this, - WidgetProviderSmallTemp.UpdateWidgetService.class); + WidgetProviderSmallTemp.UpdateWidgetService.class); startService.putExtra(EXTRA_APPWIDGET_ID, mAppWidgetId); startService.setAction("FROM CONFIGURATION ACTIVITY"); startService(startService); @@ -256,7 +250,7 @@ public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_search, menu); MenuItem searchMenuItem = menu.findItem(R.id.search); searchViewAction = (SearchView) MenuItemCompat - .getActionView(searchMenuItem); + .getActionView(searchMenuItem); searchViewAction.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { diff --git a/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallWidgetConfigurationActivity.java b/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallWidgetConfigurationActivity.java index e7c3ecaae..022f4335c 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallWidgetConfigurationActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallWidgetConfigurationActivity.java @@ -161,7 +161,7 @@ public void onItemClick(AdapterView parent, View view, int position, long id) if (mDeviceInfo.isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( - SmallWidgetConfigurationActivity.this, domoticz); + SmallWidgetConfigurationActivity.this, domoticz); passwordDialog.show(); passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { @Override @@ -208,15 +208,15 @@ public void onError(Exception error) { private void showSelectorDialog(final DevicesInfo selector, final String pass) { final ArrayList levelNames = selector.getLevelNames(); new MaterialDialog.Builder(this) - .title(R.string.selector_value) - .items(levelNames) - .itemsCallback(new MaterialDialog.ListCallback() { - @Override - public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { - getBackground(selector, pass, String.valueOf(text)); - } - }) - .show(); + .title(R.string.selector_value) + .items(levelNames) + .itemsCallback(new MaterialDialog.ListCallback() { + @Override + public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { + getBackground(selector, pass, String.valueOf(text)); + } + }) + .show(); } private int getWidgetLayout(String background, DevicesInfo mSelectedSwitch) { @@ -238,17 +238,17 @@ private int getWidgetLayout(String background, DevicesInfo mSelectedSwitch) { private void getBackground(final DevicesInfo mSelectedSwitch, final String password, final String value) { new MaterialDialog.Builder(this) - .title(this.getString(R.string.widget_background)) - .items(new String[]{this.getString(R.string.widget_dark), this.getString(R.string.widget_light), this.getString(R.string.widget_transparent_dark), this.getString(R.string.widget_transparent_light)}) - .itemsCallbackSingleChoice(-1, new MaterialDialog.ListCallbackSingleChoice() { - @Override - public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { - showAppWidget(mSelectedSwitch, password, value, getWidgetLayout(String.valueOf(text), mSelectedSwitch)); - return true; - } - }) - .positiveText(R.string.ok) - .show(); + .title(this.getString(R.string.widget_background)) + .items(new String[]{this.getString(R.string.widget_dark), this.getString(R.string.widget_light), this.getString(R.string.widget_transparent_dark), this.getString(R.string.widget_transparent_light)}) + .itemsCallbackSingleChoice(-1, new MaterialDialog.ListCallbackSingleChoice() { + @Override + public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { + showAppWidget(mSelectedSwitch, password, value, getWidgetLayout(String.valueOf(text), mSelectedSwitch)); + return true; + } + }) + .positiveText(R.string.ok) + .show(); } private void showAppWidget(DevicesInfo mSelectedSwitch, String password, String value, int layoutId) { @@ -258,7 +258,7 @@ private void showAppWidget(DevicesInfo mSelectedSwitch, String password, String int idx = mSelectedSwitch.getIdx(); if (extras != null) { mAppWidgetId = extras.getInt(EXTRA_APPWIDGET_ID, - INVALID_APPWIDGET_ID); + INVALID_APPWIDGET_ID); if (UsefulBits.isEmpty(mSelectedSwitch.getType())) { Log.i(TAG, "Widget without a type saved"); @@ -274,7 +274,7 @@ private void showAppWidget(DevicesInfo mSelectedSwitch, String password, String } Intent startService = new Intent(SmallWidgetConfigurationActivity.this, - WidgetProviderSmall.UpdateWidgetService.class); + WidgetProviderSmall.UpdateWidgetService.class); startService.putExtra(EXTRA_APPWIDGET_ID, mAppWidgetId); startService.setAction("FROM CONFIGURATION ACTIVITY"); startService(startService); @@ -302,7 +302,7 @@ public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_search, menu); MenuItem searchMenuItem = menu.findItem(R.id.search); searchViewAction = (SearchView) MenuItemCompat - .getActionView(searchMenuItem); + .getActionView(searchMenuItem); searchViewAction.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { @@ -321,14 +321,14 @@ public boolean onQueryTextChange(String newText) { private boolean SmallWidgetSupported(DevicesInfo s) { if (s != null) { if (s.getSwitchTypeVal() == 0 && - (UsefulBits.isEmpty(s.getSwitchType()))) { + (UsefulBits.isEmpty(s.getSwitchType()))) { switch (s.getType()) { case DomoticzValues.Scene.Type.SCENE: case DomoticzValues.Scene.Type.GROUP: return true; } } else if (s.getSwitchTypeVal() == 0 && - (s.getSwitchType().equals(DomoticzValues.Device.Type.Name.SECURITY))) { + (s.getSwitchType().equals(DomoticzValues.Device.Type.Name.SECURITY))) { return false; //security panel is not supported for small widgets } else { switch (s.getSwitchTypeVal()) { diff --git a/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetConfigurationActivity.java b/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetConfigurationActivity.java index 62cbde9a3..76745005c 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetConfigurationActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetConfigurationActivity.java @@ -153,7 +153,7 @@ public void onItemClick(AdapterView parent, View view, int position, long id) final DevicesInfo mDeviceInfo = (DevicesInfo) adapter.getItem(position); if (mDeviceInfo.isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( - WidgetConfigurationActivity.this, domoticz); + WidgetConfigurationActivity.this, domoticz); passwordDialog.show(); passwordDialog.onDismissListener(new PasswordDialog.DismissListener() { @Override @@ -200,15 +200,15 @@ public void onError(Exception error) { private void showSelectorDialog(final DevicesInfo selector, final String pass) { final ArrayList levelNames = selector.getLevelNames(); new MaterialDialog.Builder(this) - .title(R.string.selector_value) - .items(levelNames) - .itemsCallback(new MaterialDialog.ListCallback() { - @Override - public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { - getBackground(selector, pass, String.valueOf(text)); - } - }) - .show(); + .title(R.string.selector_value) + .items(levelNames) + .itemsCallback(new MaterialDialog.ListCallback() { + @Override + public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { + getBackground(selector, pass, String.valueOf(text)); + } + }) + .show(); } private int getWidgetLayout(String background, DevicesInfo mSelectedSwitch) { @@ -257,17 +257,17 @@ private int getWidgetLayout(String background, DevicesInfo mSelectedSwitch) { private void getBackground(final DevicesInfo mSelectedSwitch, final String password, final String value) { new MaterialDialog.Builder(this) - .title(this.getString(R.string.widget_background)) - .items(new String[]{this.getString(R.string.widget_dark), this.getString(R.string.widget_light), this.getString(R.string.widget_transparent_dark), this.getString(R.string.widget_transparent_light)}) - .itemsCallbackSingleChoice(-1, new MaterialDialog.ListCallbackSingleChoice() { - @Override - public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { - showAppWidget(mSelectedSwitch, password, value, getWidgetLayout(String.valueOf(text), mSelectedSwitch)); - return true; - } - }) - .positiveText(R.string.ok) - .show(); + .title(this.getString(R.string.widget_background)) + .items(new String[]{this.getString(R.string.widget_dark), this.getString(R.string.widget_light), this.getString(R.string.widget_transparent_dark), this.getString(R.string.widget_transparent_light)}) + .itemsCallbackSingleChoice(-1, new MaterialDialog.ListCallbackSingleChoice() { + @Override + public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { + showAppWidget(mSelectedSwitch, password, value, getWidgetLayout(String.valueOf(text), mSelectedSwitch)); + return true; + } + }) + .positiveText(R.string.ok) + .show(); } private void showAppWidget(DevicesInfo mSelectedSwitch, String password, String value, int layoutId) { @@ -277,7 +277,7 @@ private void showAppWidget(DevicesInfo mSelectedSwitch, String password, String int idx = mSelectedSwitch.getIdx(); if (extras != null) { mAppWidgetId = extras.getInt(EXTRA_APPWIDGET_ID, - INVALID_APPWIDGET_ID); + INVALID_APPWIDGET_ID); if (UsefulBits.isEmpty(mSelectedSwitch.getType())) { Log.i(TAG, "Widget without a type saved"); mSharedPrefs.setWidgetIDX(mAppWidgetId, idx, false, password, value, layoutId); @@ -291,7 +291,7 @@ private void showAppWidget(DevicesInfo mSelectedSwitch, String password, String } } Intent startService = new Intent(WidgetConfigurationActivity.this, - WidgetProviderLarge.UpdateWidgetService.class); + WidgetProviderLarge.UpdateWidgetService.class); startService.putExtra(EXTRA_APPWIDGET_ID, mAppWidgetId); startService.setAction("FROM CONFIGURATION ACTIVITY"); startService(startService); @@ -318,7 +318,7 @@ public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_search, menu); MenuItem searchMenuItem = menu.findItem(R.id.search); searchViewAction = (SearchView) MenuItemCompat - .getActionView(searchMenuItem); + .getActionView(searchMenuItem); searchViewAction.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { @@ -338,7 +338,7 @@ private int withButtons(DevicesInfo s) { int withButton = 0; if (s != null) { if (s.getSwitchTypeVal() == 0 && - (UsefulBits.isEmpty(s.getSwitchType()))) { + (UsefulBits.isEmpty(s.getSwitchType()))) { switch (s.getType()) { case DomoticzValues.Scene.Type.SCENE: withButton = BUTTON_TOGGLE; diff --git a/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetIntentService.java b/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetIntentService.java index b1ed3e0e8..aa0693455 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetIntentService.java +++ b/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetIntentService.java @@ -116,8 +116,8 @@ private boolean isOnOffSwitch(DevicesInfo mExtendedStatusInfo) { return true; if (mExtendedStatusInfo.getSwitchTypeVal() == 0 && - (mExtendedStatusInfo.getSwitchType() == null || - UsefulBits.isEmpty(mExtendedStatusInfo.getSwitchType()))) { + (mExtendedStatusInfo.getSwitchType() == null || + UsefulBits.isEmpty(mExtendedStatusInfo.getSwitchType()))) { switch (mExtendedStatusInfo.getType()) { case DomoticzValues.Scene.Type.GROUP: return true; @@ -143,8 +143,8 @@ private boolean isOnOffSwitch(DevicesInfo mExtendedStatusInfo) { private boolean isPushOnSwitch(DevicesInfo mExtendedStatusInfo) { if (mExtendedStatusInfo.getSwitchTypeVal() == 0 && - (mExtendedStatusInfo.getSwitchType() == null || - UsefulBits.isEmpty(mExtendedStatusInfo.getSwitchType()))) { + (mExtendedStatusInfo.getSwitchType() == null || + UsefulBits.isEmpty(mExtendedStatusInfo.getSwitchType()))) { switch (mExtendedStatusInfo.getType()) { case DomoticzValues.Scene.Type.SCENE: return true; @@ -163,8 +163,8 @@ private boolean isPushOnSwitch(DevicesInfo mExtendedStatusInfo) { private boolean isPushOffSwitch(DevicesInfo mExtendedStatusInfo) { if (mExtendedStatusInfo.getSwitchTypeVal() == 0 && - (mExtendedStatusInfo.getSwitchType() == null || - UsefulBits.isEmpty(mExtendedStatusInfo.getSwitchType()))) { + (mExtendedStatusInfo.getSwitchType() == null || + UsefulBits.isEmpty(mExtendedStatusInfo.getSwitchType()))) { return false; } else switch (mExtendedStatusInfo.getSwitchTypeVal()) { @@ -338,8 +338,8 @@ public void onSwitchClick(final DevicesInfo clickedSwitch, boolean checked, Domo int jsonValue = 0; if (clickedSwitch.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDS || - clickedSwitch.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDPERCENTAGE || - clickedSwitch.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.DOORLOCKINVERTED) { + clickedSwitch.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDPERCENTAGE || + clickedSwitch.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.DOORLOCKINVERTED) { if (checked) { jsonAction = DomoticzValues.Device.Switch.Action.OFF; if (!UsefulBits.isEmpty(value)) { diff --git a/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetProviderLarge.java b/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetProviderLarge.java index f1a093a80..0eb72162a 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetProviderLarge.java +++ b/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetProviderLarge.java @@ -75,7 +75,7 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, packageName = context.getPackageName(); ComponentName thisWidget = new ComponentName(context, - WidgetProviderLarge.class); + WidgetProviderLarge.class); int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget); if (allWidgetIds != null) { @@ -107,10 +107,10 @@ public int onStartCommand(Intent intent, int flags, int startId) { try { AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(this - .getApplicationContext()); + .getApplicationContext()); int incomingAppWidgetId = intent.getIntExtra(EXTRA_APPWIDGET_ID, - INVALID_APPWIDGET_ID); + INVALID_APPWIDGET_ID); if (incomingAppWidgetId != INVALID_APPWIDGET_ID) { updateAppWidget(appWidgetManager, incomingAppWidgetId); } @@ -142,11 +142,11 @@ public void updateAppWidget(final AppWidgetManager appWidgetManager, views.setImageViewResource(R.id.rowIcon, R.drawable.mic); views.setTextViewText(R.id.on_button, "GO"); views.setOnClickPendingIntent(R.id.on_button, buildButtonPendingIntent( - UpdateWidgetService.this, - appWidgetId, - idx, - false, - true)); + UpdateWidgetService.this, + appWidgetId, + idx, + false, + true)); views.setViewVisibility(R.id.on_button, View.VISIBLE); appWidgetManager.updateAppWidget(appWidgetId, views); } else if (idx == iQRCodeAction) { @@ -155,11 +155,11 @@ public void updateAppWidget(final AppWidgetManager appWidgetManager, views.setImageViewResource(R.id.rowIcon, R.drawable.qrcode); views.setTextViewText(R.id.on_button, "GO"); views.setOnClickPendingIntent(R.id.on_button, buildButtonPendingIntent( - UpdateWidgetService.this, - appWidgetId, - idx, - false, - true)); + UpdateWidgetService.this, + appWidgetId, + idx, + false, + true)); views.setViewVisibility(R.id.on_button, View.VISIBLE); appWidgetManager.updateAppWidget(appWidgetId, views); } else { @@ -184,7 +184,7 @@ public void onReceiveDevice(DevicesInfo s) { if (s.getCounterToday() != null && s.getCounterToday().length() > 0) text += " Today: " + s.getCounterToday(); if (s.getCounter() != null && s.getCounter().length() > 0 && - !s.getCounter().equals(s.getData())) + !s.getCounter().equals(s.getData())) text += " Total: " + s.getCounter(); views.setTextViewText(R.id.desc, text); @@ -201,46 +201,46 @@ else if (s.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.PUSH_OFF_BUTTO } views.setOnClickPendingIntent(R.id.on_button, buildButtonPendingIntent( - UpdateWidgetService.this, - appWidgetId, - s.getIdx(), - !s.getStatusBoolean(), - true)); + UpdateWidgetService.this, + appWidgetId, + s.getIdx(), + !s.getStatusBoolean(), + true)); views.setViewVisibility(R.id.on_button, View.VISIBLE); } else if (withButtons == BUTTON_2 && s.getStatus() != null) { views.setOnClickPendingIntent(R.id.on_button, buildButtonPendingIntent( - UpdateWidgetService.this, - appWidgetId, - s.getIdx(), true, - false)); + UpdateWidgetService.this, + appWidgetId, + s.getIdx(), true, + false)); views.setViewVisibility(R.id.on_button, View.VISIBLE); views.setOnClickPendingIntent(R.id.off_button, buildButtonPendingIntent( - UpdateWidgetService.this, - appWidgetId, - s.getIdx(), false, - false)); + UpdateWidgetService.this, + appWidgetId, + s.getIdx(), false, + false)); views.setViewVisibility(R.id.off_button, View.VISIBLE); } else if (withButtons == BUTTON_3 && s.getStatus() != null) { views.setOnClickPendingIntent(R.id.switch_button_up, buildBlindPendingIntent( - UpdateWidgetService.this, - appWidgetId, - s.getIdx(), - s.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDINVERTED ? DomoticzValues.Device.Blind.Action.ON : DomoticzValues.Device.Blind.Action.OFF)); + UpdateWidgetService.this, + appWidgetId, + s.getIdx(), + s.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDINVERTED ? DomoticzValues.Device.Blind.Action.ON : DomoticzValues.Device.Blind.Action.OFF)); views.setViewVisibility(R.id.switch_button_up, View.VISIBLE); views.setOnClickPendingIntent(R.id.switch_button_stop, buildBlindPendingIntent( - UpdateWidgetService.this, - appWidgetId, - s.getIdx(), DomoticzValues.Device.Blind.Action.STOP)); + UpdateWidgetService.this, + appWidgetId, + s.getIdx(), DomoticzValues.Device.Blind.Action.STOP)); views.setViewVisibility(R.id.switch_button_stop, View.VISIBLE); views.setOnClickPendingIntent(R.id.switch_button_down, buildBlindPendingIntent( - UpdateWidgetService.this, - appWidgetId, - s.getIdx(), - s.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDINVERTED ? DomoticzValues.Device.Blind.Action.OFF : DomoticzValues.Device.Blind.Action.ON)); + UpdateWidgetService.this, + appWidgetId, + s.getIdx(), + s.getSwitchTypeVal() == DomoticzValues.Device.Type.Value.BLINDINVERTED ? DomoticzValues.Device.Blind.Action.OFF : DomoticzValues.Device.Blind.Action.ON)); views.setViewVisibility(R.id.switch_button_down, View.VISIBLE); } else { views.setViewVisibility(R.id.on_button, View.GONE); @@ -277,11 +277,11 @@ public void onReceiveScene(SceneInfo s) { views.setTextViewText(R.id.on_button, getApplicationContext().getString(R.string.button_state_on)); views.setOnClickPendingIntent(R.id.on_button, buildButtonPendingIntent( - UpdateWidgetService.this, - appWidgetId, - idx, - !s.getStatusInBoolean(), - true)); + UpdateWidgetService.this, + appWidgetId, + idx, + !s.getStatusInBoolean(), + true)); views.setViewVisibility(R.id.on_button, View.VISIBLE); } else { @@ -290,18 +290,18 @@ public void onReceiveScene(SceneInfo s) { views.setTextViewText(R.id.off_button, getApplicationContext().getString(R.string.button_state_off)); views.setTextViewText(R.id.on_button, getApplicationContext().getString(R.string.button_state_on)); views.setOnClickPendingIntent(R.id.on_button, buildButtonPendingIntent( - UpdateWidgetService.this, - appWidgetId, - idx, - true, - false)); + UpdateWidgetService.this, + appWidgetId, + idx, + true, + false)); views.setViewVisibility(R.id.on_button, View.VISIBLE); views.setOnClickPendingIntent(R.id.off_button, buildButtonPendingIntent( - UpdateWidgetService.this, - appWidgetId, - idx, - false, - false)); + UpdateWidgetService.this, + appWidgetId, + idx, + false, + false)); views.setViewVisibility(R.id.off_button, View.VISIBLE); } @@ -381,7 +381,7 @@ private int withButtons(DevicesInfo s) { int withButton = 0; if (s != null) { if (s.getSwitchTypeVal() == 0 && - (UsefulBits.isEmpty(s.getSwitchType()))) { + (UsefulBits.isEmpty(s.getSwitchType()))) { switch (s.getType()) { case DomoticzValues.Scene.Type.SCENE: withButton = BUTTON_1; diff --git a/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetProviderSmall.java b/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetProviderSmall.java index a67b8c4b4..3a5e0c67b 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetProviderSmall.java +++ b/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetProviderSmall.java @@ -76,7 +76,7 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, packageName = context.getPackageName(); // Get all ids ComponentName thisWidget = new ComponentName(context, - WidgetProviderSmall.class); + WidgetProviderSmall.class); int[] allWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget); if (allWidgetIds != null) { for (int mAppWidgetId : allWidgetIds) { @@ -110,11 +110,11 @@ public int onStartCommand(Intent intent, int flags, int startId) { } AppWidgetManager appWidgetManager = AppWidgetManager - .getInstance(UpdateWidgetService.this); + .getInstance(UpdateWidgetService.this); try { int incomingAppWidgetId = intent.getIntExtra(EXTRA_APPWIDGET_ID, - INVALID_APPWIDGET_ID); + INVALID_APPWIDGET_ID); if (incomingAppWidgetId != INVALID_APPWIDGET_ID) { try { updateAppWidget(appWidgetManager, incomingAppWidgetId); @@ -151,22 +151,22 @@ public void updateAppWidget(final AppWidgetManager appWidgetManager, views.setTextViewText(R.id.title, getApplicationContext().getString(R.string.action_speech)); views.setImageViewResource(R.id.rowIcon, R.drawable.mic); views.setOnClickPendingIntent(R.id.rowIcon, buildButtonPendingIntent( - UpdateWidgetService.this, - appWidgetId, - idx, - false, - true)); + UpdateWidgetService.this, + appWidgetId, + idx, + false, + true)); appWidgetManager.updateAppWidget(appWidgetId, views); } else if (idx == iQRCodeAction) { views.setTextViewText(R.id.desc, getApplicationContext().getString(R.string.qrcode_desc)); views.setTextViewText(R.id.title, getApplicationContext().getString(R.string.action_qrcode_scan)); views.setImageViewResource(R.id.rowIcon, R.drawable.qrcode); views.setOnClickPendingIntent(R.id.rowIcon, buildButtonPendingIntent( - UpdateWidgetService.this, - appWidgetId, - idx, - false, - true)); + UpdateWidgetService.this, + appWidgetId, + idx, + false, + true)); appWidgetManager.updateAppWidget(appWidgetId, views); } else { appWidgetManager.updateAppWidget(appWidgetId, views); @@ -189,7 +189,7 @@ public void onReceiveDevice(DevicesInfo s) { if (s.getCounterToday() != null && s.getCounterToday().length() > 0) text += " Today: " + s.getCounterToday(); if (s.getCounter() != null && s.getCounter().length() > 0 && - !s.getCounter().equals(s.getData())) + !s.getCounter().equals(s.getData())) text += " Total: " + s.getCounter(); views.setTextViewText(R.id.desc, text); @@ -197,11 +197,11 @@ public void onReceiveDevice(DevicesInfo s) { boolean newStatus = !s.getStatusBoolean();//toggle views.setOnClickPendingIntent(R.id.rowIcon, buildButtonPendingIntent( - UpdateWidgetService.this, - appWidgetId, - s.getIdx(), - newStatus, - true)); + UpdateWidgetService.this, + appWidgetId, + s.getIdx(), + newStatus, + true)); } views.setImageViewResource(R.id.rowIcon, DomoticzIcons.getDrawableIcon(s.getTypeImg(), s.getType(), s.getSwitchType(), true, s.getUseCustomImage(), s.getImage())); @@ -236,11 +236,11 @@ public void onReceiveScene(SceneInfo s) { views.setTextViewText(R.id.title, s.getName()); views.setTextViewText(R.id.desc, s.getStatusInString()); views.setOnClickPendingIntent(R.id.rowIcon, buildButtonPendingIntent( - UpdateWidgetService.this, - appWidgetId, - idx, - !s.getStatusInBoolean(), - true)); + UpdateWidgetService.this, + appWidgetId, + idx, + !s.getStatusInBoolean(), + true)); } views.setImageViewResource(R.id.rowIcon, DomoticzIcons.getDrawableIcon(s.getType(), null, null, false, false, null)); @@ -291,7 +291,7 @@ private int withButtons(DevicesInfo s) { int withButton = 0; if (s != null) { if (s.getSwitchTypeVal() == 0 && - (UsefulBits.isEmpty(s.getSwitchType()))) { + (UsefulBits.isEmpty(s.getSwitchType()))) { switch (s.getType()) { case DomoticzValues.Scene.Type.SCENE: withButton = WITHBUTTON; diff --git a/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetProviderSmallTemp.java b/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetProviderSmallTemp.java index 12de4f073..e33b41dca 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetProviderSmallTemp.java +++ b/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetProviderSmallTemp.java @@ -21,7 +21,6 @@ package nl.hnogames.domoticz.Widgets; -import android.app.PendingIntent; import android.app.Service; import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProvider; @@ -31,11 +30,8 @@ import android.os.Build; import android.os.IBinder; import android.util.Log; -import android.view.View; import android.widget.RemoteViews; -import com.squareup.picasso.Picasso; - import java.util.ArrayList; import androidx.annotation.Nullable; @@ -45,12 +41,9 @@ import nl.hnogames.domoticz.Utils.UsefulBits; import nl.hnogames.domoticz.app.AppController; import nl.hnogames.domoticzapi.Containers.DevicesInfo; -import nl.hnogames.domoticzapi.Containers.SceneInfo; import nl.hnogames.domoticzapi.Domoticz; import nl.hnogames.domoticzapi.DomoticzIcons; -import nl.hnogames.domoticzapi.DomoticzValues; import nl.hnogames.domoticzapi.Interfaces.DevicesReceiver; -import nl.hnogames.domoticzapi.Interfaces.ScenesReceiver; import static android.appwidget.AppWidgetManager.EXTRA_APPWIDGET_ID; import static android.appwidget.AppWidgetManager.INVALID_APPWIDGET_ID; @@ -63,7 +56,7 @@ public void onDeleted(Context context, int[] appWidgetIds) { super.onDeleted(context, appWidgetIds); for (int widgetId : appWidgetIds) { SharedPrefUtil mSharedPrefs = new SharedPrefUtil(context); - mSharedPrefs.deleteSmallWidget(widgetId, mSharedPrefs.getWidgetisScene(widgetId)); + mSharedPrefs.deleteSmallTempWidget(widgetId); } } @@ -92,7 +85,6 @@ public void onUpdate(Context context, AppWidgetManager appWidgetManager, } public static class UpdateWidgetService extends Service { - private static final int WITHBUTTON = 1; private RemoteViews views; private Domoticz domoticz; private SharedPrefUtil mSharedPrefs; diff --git a/app/src/main/java/nl/hnogames/domoticz/app/AppCompatAssistActivity.java b/app/src/main/java/nl/hnogames/domoticz/app/AppCompatAssistActivity.java index cf36c5101..827552769 100644 --- a/app/src/main/java/nl/hnogames/domoticz/app/AppCompatAssistActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/app/AppCompatAssistActivity.java @@ -43,13 +43,13 @@ public void onProvideAssistContent(AssistContent outContent) { super.onProvideAssistContent(outContent); try { outContent.setStructuredData( - new JSONObject() - .put("@type", "SoftwareApplication") - .put("author", "Domoticz") - .put("name", "Domoticz") - .put("id", "http://www.domoticz.com") - .put("description", "Domoticz is a very light weight home automation system that lets you monitor and configure miscellaneous devices, including lights, switches, various sensors/meters like temperature, rainfall, wind, ultraviolet (UV) radiation, electricity usage/production, gas consumption, water consumption and many more." - ).toString() + new JSONObject() + .put("@type", "SoftwareApplication") + .put("author", "Domoticz") + .put("name", "Domoticz") + .put("id", "http://www.domoticz.com") + .put("description", "Domoticz is a very light weight home automation system that lets you monitor and configure miscellaneous devices, including lights, switches, various sensors/meters like temperature, rainfall, wind, ultraviolet (UV) radiation, electricity usage/production, gas consumption, water consumption and many more." + ).toString() ); } catch (JSONException e) { e.printStackTrace(); diff --git a/app/src/main/java/nl/hnogames/domoticz/app/AppCompatPermissionsActivity.java b/app/src/main/java/nl/hnogames/domoticz/app/AppCompatPermissionsActivity.java index b1231168e..804fdd33a 100644 --- a/app/src/main/java/nl/hnogames/domoticz/app/AppCompatPermissionsActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/app/AppCompatPermissionsActivity.java @@ -56,7 +56,7 @@ public void onPermissionDeclined(@NonNull String[] permissionName) { if (builder.toString().contains("android.permission.READ_PHONE_STATE")) { AlertDialog alert = PermissionsUtil.getAlertDialog(this, permissionHelper, this.getString(R.string.permission_title), - this.getString(R.string.permission_desc_phone), permissionName); + this.getString(R.string.permission_desc_phone), permissionName); if (!alert.isShowing()) { alert.show(); } @@ -64,7 +64,7 @@ public void onPermissionDeclined(@NonNull String[] permissionName) { if (builder.toString().contains("android.permission.READ_EXTERNAL_STORAGE") || builder.toString().contains("android.permission.WRITE_EXTERNAL_STORAGE")) { AlertDialog alert = PermissionsUtil.getAlertDialog(this, permissionHelper, this.getString(R.string.permission_title), - this.getString(R.string.permission_desc_storage), permissionName); + this.getString(R.string.permission_desc_storage), permissionName); if (!alert.isShowing()) { alert.show(); } @@ -72,7 +72,7 @@ public void onPermissionDeclined(@NonNull String[] permissionName) { if (builder.toString().contains("android.permission.CAMERA")) { AlertDialog alert = PermissionsUtil.getAlertDialog(this, permissionHelper, this.getString(R.string.permission_title), - this.getString(R.string.permission_desc_camera), permissionName); + this.getString(R.string.permission_desc_camera), permissionName); if (!alert.isShowing()) { alert.show(); } @@ -80,7 +80,7 @@ public void onPermissionDeclined(@NonNull String[] permissionName) { if (builder.toString().contains("android.permission.RECORD_AUDIO")) { AlertDialog alert = PermissionsUtil.getAlertDialog(this, permissionHelper, this.getString(R.string.permission_title), - this.getString(R.string.permission_desc_audio), permissionName); + this.getString(R.string.permission_desc_audio), permissionName); if (!alert.isShowing()) { alert.show(); } @@ -88,7 +88,7 @@ public void onPermissionDeclined(@NonNull String[] permissionName) { if (builder.toString().contains("android.permission.USE_FINGERPRINT")) { AlertDialog alert = PermissionsUtil.getAlertDialog(this, permissionHelper, this.getString(R.string.permission_title), - this.getString(R.string.permission_desc_finger), permissionName); + this.getString(R.string.permission_desc_finger), permissionName); if (!alert.isShowing()) { alert.show(); } diff --git a/app/src/main/java/nl/hnogames/domoticz/app/AppController.java b/app/src/main/java/nl/hnogames/domoticz/app/AppController.java index c737d5ab8..b02107cdf 100755 --- a/app/src/main/java/nl/hnogames/domoticz/app/AppController.java +++ b/app/src/main/java/nl/hnogames/domoticz/app/AppController.java @@ -76,7 +76,7 @@ public RequestQueue getRequestQueue() { HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); HttpsURLConnection.setDefaultHostnameVerifier( - mtm.wrapHostnameVerifier(HttpsURLConnection.getDefaultHostnameVerifier())); + mtm.wrapHostnameVerifier(HttpsURLConnection.getDefaultHostnameVerifier())); } catch (KeyManagementException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { @@ -91,8 +91,8 @@ public void addToRequestQueue(Request req) { req.setTag(TAG); RetryPolicy retryPolicy = new DefaultRetryPolicy(socketTimeout, - DefaultRetryPolicy.DEFAULT_MAX_RETRIES, - DefaultRetryPolicy.DEFAULT_BACKOFF_MULT); + DefaultRetryPolicy.DEFAULT_MAX_RETRIES, + DefaultRetryPolicy.DEFAULT_BACKOFF_MULT); req.setRetryPolicy(retryPolicy); getRequestQueue().add(req); diff --git a/app/src/main/java/nl/hnogames/domoticz/app/DomoticzCardFragment.java b/app/src/main/java/nl/hnogames/domoticz/app/DomoticzCardFragment.java index 54ba1e54b..296ceefdf 100644 --- a/app/src/main/java/nl/hnogames/domoticz/app/DomoticzCardFragment.java +++ b/app/src/main/java/nl/hnogames/domoticz/app/DomoticzCardFragment.java @@ -86,9 +86,9 @@ public void setTheme() { ((ImageView) root.findViewById(R.id.errorImage)).setImageDrawable(getResources().getDrawable(R.drawable.sad_smiley_dark)); if (mSwipeRefreshLayout != null) mSwipeRefreshLayout.setColorSchemeResources( - R.color.secondary, - R.color.secondary_dark, - R.color.background_dark); + R.color.secondary, + R.color.secondary_dark, + R.color.background_dark); } } @@ -137,7 +137,7 @@ public void onAttachFragment(Fragment fragment) { listener = (DomoticzFragmentListener) fragment; } catch (ClassCastException e) { throw new ClassCastException( - fragment.toString() + " must implement DomoticzFragmentListener"); + fragment.toString() + " must implement DomoticzFragmentListener"); } } @@ -229,7 +229,7 @@ public void addDebugText(String text) { debugText.setText(temp); } } else throw new RuntimeException( - "Layout should have a TextView defined with the ID \"debugText\""); + "Layout should have a TextView defined with the ID \"debugText\""); } } @@ -241,7 +241,7 @@ private void setErrorLayoutMessage(String message) { TextView errorTextMessage = root.findViewById(R.id.errorTextMessage); errorTextMessage.setText(message); } else throw new RuntimeException( - "Layout should have a RelativeLayout defined with the ID of errorLayout"); + "Layout should have a RelativeLayout defined with the ID of errorLayout"); } } @@ -261,7 +261,7 @@ private void setMessage(String message) { TextView errorTextMessage = root.findViewById(R.id.errorTextMessage); errorTextMessage.setText(message); } else throw new RuntimeException( - "Layout should have a RelativeLayout defined with the ID of errorLayout"); + "Layout should have a RelativeLayout defined with the ID of errorLayout"); } private void hideRecyclerView() { diff --git a/app/src/main/java/nl/hnogames/domoticz/app/DomoticzDashboardFragment.java b/app/src/main/java/nl/hnogames/domoticz/app/DomoticzDashboardFragment.java index 4634b102d..24eecd18d 100644 --- a/app/src/main/java/nl/hnogames/domoticz/app/DomoticzDashboardFragment.java +++ b/app/src/main/java/nl/hnogames/domoticz/app/DomoticzDashboardFragment.java @@ -114,14 +114,14 @@ public void setTheme() { bottomLayoutWrapper.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.background_dark)); if (collapseSortButton != null) { int[][] states = new int[][]{ - new int[]{android.R.attr.state_enabled}, // enabled - new int[]{-android.R.attr.state_enabled}, // disabled - new int[]{-android.R.attr.state_checked}, // unchecked - new int[]{android.R.attr.state_pressed} // pressed + new int[]{android.R.attr.state_enabled}, // enabled + new int[]{-android.R.attr.state_enabled}, // disabled + new int[]{-android.R.attr.state_checked}, // unchecked + new int[]{android.R.attr.state_pressed} // pressed }; int[] colors = new int[]{ - R.color.primary, R.color.primary, R.color.primary, R.color.primary + R.color.primary, R.color.primary, R.color.primary, R.color.primary }; ColorStateList newStates = new ColorStateList(states, colors); @@ -129,9 +129,9 @@ public void setTheme() { collapseSortButton.setIconTint(newStates); } mSwipeRefreshLayout.setColorSchemeResources( - R.color.secondary, - R.color.secondary_dark, - R.color.background_dark); + R.color.secondary, + R.color.secondary_dark, + R.color.background_dark); } } @@ -266,9 +266,9 @@ public void onClick(View v) { backdropContainer = root.findViewById(R.id.backdropcontainer); backdropContainer - .dropInterpolator(new LinearInterpolator()) - .dropHeight(this.getResources().getDimensionPixelSize(R.dimen.sneek_height)) - .build(); + .dropInterpolator(new LinearInterpolator()) + .dropHeight(this.getResources().getDimensionPixelSize(R.dimen.sneek_height)) + .build(); //setting up our OnScrollListener gridView.setOnScrollListener(new RecyclerView.OnScrollListener() { @@ -397,7 +397,7 @@ public void onAttachFragment(Fragment fragment) { listener = (DomoticzFragmentListener) fragment; } catch (ClassCastException e) { throw new ClassCastException( - fragment.toString() + " must implement DomoticzFragmentListener"); + fragment.toString() + " must implement DomoticzFragmentListener"); } } @@ -528,7 +528,7 @@ public void addDebugText(String text) { debugText.setText(temp); } } else throw new RuntimeException( - "Layout should have a TextView defined with the ID \"debugText\""); + "Layout should have a TextView defined with the ID \"debugText\""); } } } @@ -542,7 +542,7 @@ private void setErrorLayoutMessage(String message) { TextView errorTextMessage = root.findViewById(R.id.errorTextMessage); errorTextMessage.setText(message); } else throw new RuntimeException( - "Layout should have a RelativeLayout defined with the ID of errorLayout"); + "Layout should have a RelativeLayout defined with the ID of errorLayout"); } public void setMessage(String message) { @@ -561,14 +561,14 @@ public void setMessage(String message) { TextView errorTextMessage = root.findViewById(R.id.errorTextMessage); errorTextMessage.setText(message); } else throw new RuntimeException( - "Layout should have a RelativeLayout defined with the ID of errorLayout"); + "Layout should have a RelativeLayout defined with the ID of errorLayout"); } private void hideListView() { if (gridView != null) { gridView.setVisibility(View.GONE); } else throw new RuntimeException( - "Layout should have a ListView defined with the ID of listView"); + "Layout should have a ListView defined with the ID of listView"); } private void showDebugLayout() { diff --git a/app/src/main/java/nl/hnogames/domoticz/app/DomoticzRecyclerFragment.java b/app/src/main/java/nl/hnogames/domoticz/app/DomoticzRecyclerFragment.java index 381bcfc27..6ccc6f4b1 100644 --- a/app/src/main/java/nl/hnogames/domoticz/app/DomoticzRecyclerFragment.java +++ b/app/src/main/java/nl/hnogames/domoticz/app/DomoticzRecyclerFragment.java @@ -117,14 +117,14 @@ public void setTheme() { bottomLayoutWrapper.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.background_dark)); if (collapseSortButton != null) { int[][] states = new int[][]{ - new int[]{android.R.attr.state_enabled}, // enabled - new int[]{-android.R.attr.state_enabled}, // disabled - new int[]{-android.R.attr.state_checked}, // unchecked - new int[]{android.R.attr.state_pressed} // pressed + new int[]{android.R.attr.state_enabled}, // enabled + new int[]{-android.R.attr.state_enabled}, // disabled + new int[]{-android.R.attr.state_checked}, // unchecked + new int[]{android.R.attr.state_pressed} // pressed }; int[] colors = new int[]{ - R.color.primary, R.color.primary, R.color.primary, R.color.primary + R.color.primary, R.color.primary, R.color.primary, R.color.primary }; ColorStateList newStates = new ColorStateList(states, colors); @@ -132,9 +132,9 @@ public void setTheme() { collapseSortButton.setIconTint(newStates); } mSwipeRefreshLayout.setColorSchemeResources( - R.color.secondary, - R.color.secondary_dark, - R.color.background_dark); + R.color.secondary, + R.color.secondary_dark, + R.color.background_dark); } } @@ -256,9 +256,9 @@ public void onClick(View v) { backdropContainer = root.findViewById(R.id.backdropcontainer); backdropContainer - .dropInterpolator(new LinearInterpolator()) - .dropHeight(this.getResources().getDimensionPixelSize(R.dimen.sneek_height)) - .build(); + .dropInterpolator(new LinearInterpolator()) + .dropHeight(this.getResources().getDimensionPixelSize(R.dimen.sneek_height)) + .build(); //setting up our OnScrollListener gridView.setOnScrollListener(new RecyclerView.OnScrollListener() { @@ -307,7 +307,7 @@ public void setGridViewLayout() { isPortrait = true; if (getActivity() instanceof MainActivity) { isTablet = ! - ((MainActivity) getActivity()).onPhone; + ((MainActivity) getActivity()).onPhone; } gridView.setHasFixedSize(true); @@ -367,7 +367,7 @@ public void onAttachFragment(Fragment fragment) { listener = (DomoticzFragmentListener) fragment; } catch (ClassCastException e) { throw new ClassCastException( - fragment.toString() + " must implement DomoticzFragmentListener"); + fragment.toString() + " must implement DomoticzFragmentListener"); } } @@ -489,7 +489,7 @@ public void addDebugText(String text) { debugText.setText(temp); } } else throw new RuntimeException( - "Layout should have a TextView defined with the ID \"debugText\""); + "Layout should have a TextView defined with the ID \"debugText\""); } } } @@ -503,7 +503,7 @@ private void setErrorLayoutMessage(String message) { TextView errorTextMessage = root.findViewById(R.id.errorTextMessage); errorTextMessage.setText(message); } else throw new RuntimeException( - "Layout should have a RelativeLayout defined with the ID of errorLayout"); + "Layout should have a RelativeLayout defined with the ID of errorLayout"); } public void setMessage(String message) { @@ -522,14 +522,14 @@ public void setMessage(String message) { TextView errorTextMessage = root.findViewById(R.id.errorTextMessage); errorTextMessage.setText(message); } else throw new RuntimeException( - "Layout should have a RelativeLayout defined with the ID of errorLayout"); + "Layout should have a RelativeLayout defined with the ID of errorLayout"); } private void hideListView() { if (gridView != null) { gridView.setVisibility(View.GONE); } else throw new RuntimeException( - "Layout should have a ListView defined with the ID of listView"); + "Layout should have a ListView defined with the ID of listView"); } private void showDebugLayout() { diff --git a/app/src/main/res/layout/widget_small_layout.xml b/app/src/main/res/layout/widget_small_layout.xml index d48383e37..17e455d3c 100644 --- a/app/src/main/res/layout/widget_small_layout.xml +++ b/app/src/main/res/layout/widget_small_layout.xml @@ -1,19 +1,24 @@ - + android:orientation="horizontal"> - + + android:src="@drawable/defaultimage"/> + android:clickable="false" + android:textColor="@color/white"/> + android:clickable="false" + android:textColor="@color/white"/> \ No newline at end of file diff --git a/app/src/main/res/layout/widget_small_layout_dark.xml b/app/src/main/res/layout/widget_small_layout_dark.xml index 5a9983f56..b68c137ae 100644 --- a/app/src/main/res/layout/widget_small_layout_dark.xml +++ b/app/src/main/res/layout/widget_small_layout_dark.xml @@ -1,39 +1,44 @@ - + - + - + - + - + - - \ No newline at end of file + + \ No newline at end of file diff --git a/app/src/main/res/layout/widget_small_layout_transparent.xml b/app/src/main/res/layout/widget_small_layout_transparent.xml index 1fb3b0b9d..bc424825e 100644 --- a/app/src/main/res/layout/widget_small_layout_transparent.xml +++ b/app/src/main/res/layout/widget_small_layout_transparent.xml @@ -1,18 +1,23 @@ - + android:orientation="horizontal"> - + + android:src="@drawable/defaultimage"/> - + android:orientation="horizontal"> - + + android:src="@drawable/defaultimage"/> + android:clickable="false" + android:textColor="@color/white"/> + android:clickable="false" + android:textColor="@color/white"/> \ No newline at end of file diff --git a/app/src/main/res/layout/widget_small_temp_layout.xml b/app/src/main/res/layout/widget_small_temp_layout.xml index d48383e37..17e455d3c 100644 --- a/app/src/main/res/layout/widget_small_temp_layout.xml +++ b/app/src/main/res/layout/widget_small_temp_layout.xml @@ -1,19 +1,24 @@ - + android:orientation="horizontal"> - + + android:src="@drawable/defaultimage"/> + android:clickable="false" + android:textColor="@color/white"/> + android:clickable="false" + android:textColor="@color/white"/> \ No newline at end of file diff --git a/app/src/main/res/layout/widget_small_temp_layout_dark.xml b/app/src/main/res/layout/widget_small_temp_layout_dark.xml index 1a86f7811..b68c137ae 100644 --- a/app/src/main/res/layout/widget_small_temp_layout_dark.xml +++ b/app/src/main/res/layout/widget_small_temp_layout_dark.xml @@ -1,19 +1,24 @@ - + android:orientation="horizontal"> - + + android:src="@drawable/defaultimage"/> + android:clickable="false" + android:textColor="@color/white"/> + android:clickable="false" + android:textColor="@color/white"/> \ No newline at end of file diff --git a/app/src/main/res/layout/widget_small_temp_layout_transparent.xml b/app/src/main/res/layout/widget_small_temp_layout_transparent.xml index 1fb3b0b9d..bc424825e 100644 --- a/app/src/main/res/layout/widget_small_temp_layout_transparent.xml +++ b/app/src/main/res/layout/widget_small_temp_layout_transparent.xml @@ -1,18 +1,23 @@ - + android:orientation="horizontal"> - + + android:src="@drawable/defaultimage"/> - + android:orientation="horizontal"> - + + android:src="@drawable/defaultimage"/> + android:clickable="false" + android:textColor="@color/white"/> + android:clickable="false" + android:textColor="@color/white"/> \ No newline at end of file diff --git a/app/version.properties b/app/version.properties index 86a633d6d..204ddccf6 100644 --- a/app/version.properties +++ b/app/version.properties @@ -1,4 +1,4 @@ -#Thu Aug 01 08:48:44 CEST 2019 -VERSION_BUILD=6149 +#Thu Aug 01 09:11:14 CEST 2019 +VERSION_BUILD=6156 VERSION_PATCH=127 VERSION_CODE=443 diff --git a/domoticzapi/version.properties b/domoticzapi/version.properties index eef1d0c01..a0e915feb 100644 --- a/domoticzapi/version.properties +++ b/domoticzapi/version.properties @@ -1,4 +1,4 @@ -#Thu Aug 01 08:48:44 CEST 2019 +#Thu Aug 01 09:11:14 CEST 2019 VERSION_BUILD=3675 VERSION_PATCH=230 VERSION_CODE=230 From 01e9c025bc3a3fe336a856ae79b4f6e2f7584e13 Mon Sep 17 00:00:00 2001 From: Mark Heinis Date: Thu, 1 Aug 2019 09:56:22 +0200 Subject: [PATCH 05/17] Improve the geofence location picker dialog and settings screen Improve the geofence location picker dialog and settings screen --- app/build.gradle | 5 ++++- .../hnogames/domoticz/GeoSettingsActivity.java | 16 +++++++++++----- app/version.properties | 4 ++-- domoticzapi/version.properties | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index f7a958783..48748cbb7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -219,7 +219,10 @@ dependencies { implementation 'com.github.matthiasrobbers:shortbread:1.0.2' annotationProcessor 'com.github.matthiasrobbers:shortbread-compiler:1.0.2' - implementation 'com.schibstedspain.android:leku:3.3.0' + implementation ('com.schibstedspain.android:leku:6.3.0') { + exclude group: 'com.google.android.gms' + exclude group: 'androidx.appcompat' + } implementation 'com.github.k0shk0sh:PermissionHelper:1.1.0' implementation 'com.github.zagum:SpeechRecognitionView:1.0.2' implementation "com.github.skydoves:colorpickerview:2.0.1" diff --git a/app/src/main/java/nl/hnogames/domoticz/GeoSettingsActivity.java b/app/src/main/java/nl/hnogames/domoticz/GeoSettingsActivity.java index de822de0b..6fb6d9d2a 100644 --- a/app/src/main/java/nl/hnogames/domoticz/GeoSettingsActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/GeoSettingsActivity.java @@ -82,6 +82,10 @@ public class GeoSettingsActivity extends AppCompatAssistActivity implements OnPe private SwitchMaterial geoNotificationSwitch; private int editedLocationID = -1; + private static final String LATITUDE = "latitude"; + private static final String LONGITUDE = "longitude"; + private static final String LOCATION_ADDRESS = "location_address"; + @Override protected void onCreate(Bundle savedInstanceState) { mSharedPrefs = new SharedPrefUtil(this); @@ -386,7 +390,7 @@ protected void onActivityResult(int requestCode, int resultCode, final Intent da final int editedID = editedLocationID; //Store the edited value locally, and delete the global value editedLocationID = -1; if (resultCode == RESULT_OK) { - final LatLng latLng = new LatLng(data.getDoubleExtra(LocationPickerActivity.LATITUDE, 0), data.getDoubleExtra(LocationPickerActivity.LONGITUDE, 0)); + final LatLng latLng = new LatLng(data.getDoubleExtra(LATITUDE, 0), data.getDoubleExtra(LONGITUDE, 0)); String prefillEditedName = null; if (editedID != -1) { @@ -400,7 +404,7 @@ protected void onActivityResult(int requestCode, int resultCode, final Intent da editedLocationID = -1; } - String name = data.getStringExtra(LocationPickerActivity.LOCATION_ADDRESS); + String name = data.getStringExtra(LOCATION_ADDRESS); if (nl.hnogames.domoticzapi.Utils.UsefulBits.isEmpty(name)) { new MaterialDialog.Builder(this) .title(R.string.title_edit_location) @@ -415,9 +419,10 @@ public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { } }).show(); } else - showRadiusEditor(editedLocationID, name, latLng); + showRadiusEditor(editedID, name, latLng); } else if (resultCode != RESULT_CANCELED) permissionHelper.onActivityForResult(requestCode); + super.onActivityResult(requestCode, resultCode, data); } private void showRadiusEditor(final int editedLocationID, String name, LatLng latlng) { @@ -461,6 +466,7 @@ public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { } else { mSharedPrefs.addLocation(finalLocation); locations = mSharedPrefs.getLocations(); + adapter.data = locations; GeoUtils.geofencesAlreadyRegistered = false; oGeoUtils.AddGeofences(); } @@ -471,8 +477,8 @@ public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { private void showEditLocationDialog(LocationInfo location) { Intent intent = new Intent(getApplicationContext(), LocationPickerActivity.class); - intent.putExtra(LocationPickerActivity.LATITUDE, location.getLocation().latitude); - intent.putExtra(LocationPickerActivity.LONGITUDE, location.getLocation().longitude); + intent.putExtra(LATITUDE, location.getLocation().latitude); + intent.putExtra(LONGITUDE, location.getLocation().longitude); editedLocationID = location.getID(); startActivityForResult(intent, 2); } diff --git a/app/version.properties b/app/version.properties index 204ddccf6..025994683 100644 --- a/app/version.properties +++ b/app/version.properties @@ -1,4 +1,4 @@ -#Thu Aug 01 09:11:14 CEST 2019 -VERSION_BUILD=6156 +#Thu Aug 01 09:54:05 CEST 2019 +VERSION_BUILD=6161 VERSION_PATCH=127 VERSION_CODE=443 diff --git a/domoticzapi/version.properties b/domoticzapi/version.properties index a0e915feb..d87772025 100644 --- a/domoticzapi/version.properties +++ b/domoticzapi/version.properties @@ -1,4 +1,4 @@ -#Thu Aug 01 09:11:14 CEST 2019 +#Thu Aug 01 09:54:05 CEST 2019 VERSION_BUILD=3675 VERSION_PATCH=230 VERSION_CODE=230 From 09da7c259236818a4aac7846a00525d1830530d8 Mon Sep 17 00:00:00 2001 From: Mark Heinis Date: Thu, 1 Aug 2019 10:16:08 +0200 Subject: [PATCH 06/17] Small fix on importing/exporting settings that invalidate widgets Small fix on importing/exporting settings that invalidate widgets --- .../main/java/nl/hnogames/domoticz/Preference/Preference.java | 3 +-- .../main/java/nl/hnogames/domoticz/Utils/SharedPrefUtil.java | 4 ++-- app/version.properties | 4 ++-- domoticzapi/version.properties | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/nl/hnogames/domoticz/Preference/Preference.java b/app/src/main/java/nl/hnogames/domoticz/Preference/Preference.java index 6ab7331ca..bad71576a 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Preference/Preference.java +++ b/app/src/main/java/nl/hnogames/domoticz/Preference/Preference.java @@ -872,8 +872,7 @@ public boolean onPreferenceClick(android.preference.Preference preference) { private void importSettings() { Log.v(TAG_IMPORT, "Importing settings from: " + SettingsFile.getPath()); - mSharedPrefs.loadSharedPreferencesFromFile(SettingsFile); - if (mSharedPrefs.saveSharedPreferencesToFile(SettingsFile)) + if (mSharedPrefs.loadSharedPreferencesFromFile(SettingsFile)) showSnackbar(mContext.getString(R.string.settings_imported)); else showSnackbar(mContext.getString(R.string.settings_import_failed)); diff --git a/app/src/main/java/nl/hnogames/domoticz/Utils/SharedPrefUtil.java b/app/src/main/java/nl/hnogames/domoticz/Utils/SharedPrefUtil.java index c39c2b1ba..21c8d297c 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Utils/SharedPrefUtil.java +++ b/app/src/main/java/nl/hnogames/domoticz/Utils/SharedPrefUtil.java @@ -1166,7 +1166,7 @@ public boolean saveSharedPreferencesToFile(File dst) { HashMap oSavePrefs = new HashMap(); for (Map.Entry entry : oAllPrefs.entrySet()) { //Log.d("map values", entry.getKey() + ": " + entry.getValue().toString()); - if (entry.getKey().startsWith("WIDGET") || entry.getKey().startsWith("SMALLWIDGET")) + if (entry.getKey().startsWith("WIDGET") || entry.getKey().startsWith("SMALLWIDGET")|| entry.getKey().startsWith("SMALLTEMPWIDGET")) Log.i("PREFS", "Skipped: " + entry.getKey() + ": " + entry.getValue().toString()); else if (entry.getKey().equals("receivedNotifications") || entry.getKey().equals("receivedNotificationsLog")) Log.i("PREFS", "Skipped: " + entry.getKey() + ": " + entry.getValue().toString()); @@ -1224,7 +1224,7 @@ public boolean loadSharedPreferencesFromFile(File src) { Object v = entry.getValue(); String key = entry.getKey(); if (v != null && !UsefulBits.isEmpty(key)) { - if (entry.getKey().startsWith("WIDGET") || entry.getKey().startsWith("SMALLWIDGET")) + if (entry.getKey().startsWith("WIDGET") || entry.getKey().startsWith("SMALLWIDGET")|| entry.getKey().startsWith("SMALLTEMPWIDGET")) Log.i("PREFS", "Skipped: " + entry.getKey() + ": " + entry.getValue().toString()); else if (entry.getKey().equals("receivedNotifications") || entry.getKey().equals("receivedNotificationsLog")) Log.i("PREFS", "Skipped: " + entry.getKey() + ": " + entry.getValue().toString()); diff --git a/app/version.properties b/app/version.properties index 025994683..c65ce659c 100644 --- a/app/version.properties +++ b/app/version.properties @@ -1,4 +1,4 @@ -#Thu Aug 01 09:54:05 CEST 2019 -VERSION_BUILD=6161 +#Thu Aug 01 10:07:59 CEST 2019 +VERSION_BUILD=6163 VERSION_PATCH=127 VERSION_CODE=443 diff --git a/domoticzapi/version.properties b/domoticzapi/version.properties index d87772025..2ce25c1f4 100644 --- a/domoticzapi/version.properties +++ b/domoticzapi/version.properties @@ -1,4 +1,4 @@ -#Thu Aug 01 09:54:05 CEST 2019 +#Thu Aug 01 10:08:04 CEST 2019 VERSION_BUILD=3675 VERSION_PATCH=230 VERSION_CODE=230 From 511533e5e97b784df18ae04c1db2cd599985404a Mon Sep 17 00:00:00 2001 From: Mark Heinis Date: Thu, 1 Aug 2019 11:21:39 +0200 Subject: [PATCH 07/17] Improve the error handling of widget config screens Improve the error handling of widget config screens --- .../SecurityWidgetConfigurationActivity.java | 26 ++++++++++++++ .../SmallTempWidgetConfigurationActivity.java | 35 ++++++++++++++----- .../SmallWidgetConfigurationActivity.java | 35 +++++++++++++------ .../Widgets/WidgetConfigurationActivity.java | 35 ++++++++++++++----- .../main/res/layout/widget_configuration.xml | 6 ++-- .../layout/widget_security_configuration.xml | 4 +-- app/version.properties | 4 +-- domoticzapi/version.properties | 2 +- 8 files changed, 111 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetConfigurationActivity.java b/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetConfigurationActivity.java index 76a44a7b3..da9d139d5 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetConfigurationActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetConfigurationActivity.java @@ -33,13 +33,16 @@ import android.widget.Toast; import com.afollestad.materialdialogs.MaterialDialog; +import com.google.android.material.snackbar.Snackbar; import java.util.ArrayList; import androidx.appcompat.app.AppCompatActivity; +import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.core.content.ContextCompat; import nl.hnogames.domoticz.BuildConfig; import nl.hnogames.domoticz.R; +import nl.hnogames.domoticz.SettingsActivity; import nl.hnogames.domoticz.Utils.SharedPrefUtil; import nl.hnogames.domoticz.Utils.UsefulBits; import nl.hnogames.domoticz.Welcome.WelcomeViewActivity; @@ -69,6 +72,7 @@ public class SecurityWidgetConfigurationActivity extends AppCompatActivity { private SettingsInfo mSettings; private DevicesInfo sSecurityPanel; + public CoordinatorLayout coordinatorLayout; @Override protected void onCreate(Bundle savedInstanceState) { @@ -82,6 +86,7 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.widget_security_configuration); setResult(RESULT_CANCELED); + coordinatorLayout = findViewById(R.id.coordinatorLayout); if (domoticz == null) domoticz = new Domoticz(this, AppController.getInstance().getRequestQueue()); @@ -100,6 +105,26 @@ protected void onCreate(Bundle savedInstanceState) { btnConfig.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { + if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { + UsefulBits.showSnackbarWithAction(SecurityWidgetConfigurationActivity.this, coordinatorLayout, getString(R.string.wizard_widgets) + " " + getString(R.string.premium_feature), Snackbar.LENGTH_LONG, null, new View.OnClickListener() { + @Override + public void onClick(View v) { + UsefulBits.openPremiumAppStore(SecurityWidgetConfigurationActivity.this); + } + }, getString(R.string.premium_category)); + return; + } + + if (!mSharedPrefs.IsWidgetsEnabled()) { + UsefulBits.showSnackbarWithAction(SecurityWidgetConfigurationActivity.this, coordinatorLayout, getString(R.string.widget_disabled), Snackbar.LENGTH_LONG, null, new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivityForResult(new Intent(SecurityWidgetConfigurationActivity.this, SettingsActivity.class), 888); + } + }, getString(R.string.action_settings)); + return; + } + InputMethodManager imm = (InputMethodManager) getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editPin.getWindowToken(), 0); @@ -221,6 +246,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { break; } } + super.onActivityResult(requestCode, resultCode, data); } public void initListViews() { diff --git a/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallTempWidgetConfigurationActivity.java b/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallTempWidgetConfigurationActivity.java index e263e4b03..afed7735e 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallTempWidgetConfigurationActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallTempWidgetConfigurationActivity.java @@ -33,15 +33,18 @@ import android.widget.Toast; import com.afollestad.materialdialogs.MaterialDialog; +import com.google.android.material.snackbar.Snackbar; import java.util.ArrayList; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.SearchView; +import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.core.view.MenuItemCompat; import nl.hnogames.domoticz.Adapters.TemperatureWidgetAdapter; import nl.hnogames.domoticz.BuildConfig; import nl.hnogames.domoticz.R; +import nl.hnogames.domoticz.SettingsActivity; import nl.hnogames.domoticz.UI.PasswordDialog; import nl.hnogames.domoticz.Utils.SharedPrefUtil; import nl.hnogames.domoticz.Utils.UsefulBits; @@ -64,6 +67,7 @@ public class SmallTempWidgetConfigurationActivity extends AppCompatActivity { private Domoticz domoticz; private TemperatureWidgetAdapter adapter; private SearchView searchViewAction; + public CoordinatorLayout coordinatorLayout; @Override protected void onCreate(Bundle savedInstanceState) { @@ -77,15 +81,7 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.widget_configuration); setResult(RESULT_CANCELED); - if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { - Toast.makeText(this, getString(R.string.wizard_widgets) + " " + getString(R.string.premium_feature), Toast.LENGTH_LONG).show(); - this.finish(); - } - - if (!mSharedPrefs.IsWidgetsEnabled()) { - Toast.makeText(this, getString(R.string.wizard_widgets) + " " + getString(R.string.widget_disabled), Toast.LENGTH_LONG).show(); - this.finish(); - } + coordinatorLayout = findViewById(R.id.coordinatorLayout); domoticz = new Domoticz(this, AppController.getInstance().getRequestQueue()); this.setTitle(getString(R.string.pick_device_title)); if (getSupportActionBar() != null) { @@ -137,6 +133,27 @@ public void onReceiveTemperatures(ArrayList mDevicesInfo) { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { + + if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { + UsefulBits.showSnackbarWithAction(SmallTempWidgetConfigurationActivity.this, coordinatorLayout, getString(R.string.wizard_widgets) + " " + getString(R.string.premium_feature), Snackbar.LENGTH_LONG, null, new View.OnClickListener() { + @Override + public void onClick(View v) { + UsefulBits.openPremiumAppStore(SmallTempWidgetConfigurationActivity.this); + } + }, getString(R.string.premium_category)); + return; + } + + if (!mSharedPrefs.IsWidgetsEnabled()) { + UsefulBits.showSnackbarWithAction(SmallTempWidgetConfigurationActivity.this, coordinatorLayout, getString(R.string.widget_disabled), Snackbar.LENGTH_LONG, null, new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivityForResult(new Intent(SmallTempWidgetConfigurationActivity.this, SettingsActivity.class), 888); + } + }, getString(R.string.action_settings)); + return; + } + final TemperatureInfo mDeviceInfo = (TemperatureInfo) adapter.getItem(position); if (mDeviceInfo.isProtected()) { diff --git a/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallWidgetConfigurationActivity.java b/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallWidgetConfigurationActivity.java index 022f4335c..cc53a5269 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallWidgetConfigurationActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallWidgetConfigurationActivity.java @@ -33,15 +33,18 @@ import android.widget.Toast; import com.afollestad.materialdialogs.MaterialDialog; +import com.google.android.material.snackbar.Snackbar; import java.util.ArrayList; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.SearchView; +import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.core.view.MenuItemCompat; import nl.hnogames.domoticz.Adapters.WidgetsAdapter; import nl.hnogames.domoticz.BuildConfig; import nl.hnogames.domoticz.R; +import nl.hnogames.domoticz.SettingsActivity; import nl.hnogames.domoticz.UI.PasswordDialog; import nl.hnogames.domoticz.Utils.SharedPrefUtil; import nl.hnogames.domoticz.Utils.UsefulBits; @@ -70,6 +73,7 @@ public class SmallWidgetConfigurationActivity extends AppCompatActivity { private Domoticz domoticz; private WidgetsAdapter adapter; private SearchView searchViewAction; + public CoordinatorLayout coordinatorLayout; @Override protected void onCreate(Bundle savedInstanceState) { @@ -83,15 +87,7 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.widget_configuration); setResult(RESULT_CANCELED); - if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { - Toast.makeText(this, getString(R.string.wizard_widgets) + " " + getString(R.string.premium_feature), Toast.LENGTH_LONG).show(); - this.finish(); - } - - if (!mSharedPrefs.IsWidgetsEnabled()) { - Toast.makeText(this, getString(R.string.wizard_widgets) + " " + getString(R.string.widget_disabled), Toast.LENGTH_LONG).show(); - this.finish(); - } + coordinatorLayout = findViewById(R.id.coordinatorLayout); domoticz = new Domoticz(this, AppController.getInstance().getRequestQueue()); this.setTitle(getString(R.string.pick_device_title)); if (getSupportActionBar() != null) { @@ -157,8 +153,27 @@ public void onReceiveDevices(final ArrayList mDevicesInfo) { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { - final DevicesInfo mDeviceInfo = (DevicesInfo) adapter.getItem(position); + if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { + UsefulBits.showSnackbarWithAction(SmallWidgetConfigurationActivity.this, coordinatorLayout, getString(R.string.wizard_widgets) + " " + getString(R.string.premium_feature), Snackbar.LENGTH_LONG, null, new View.OnClickListener() { + @Override + public void onClick(View v) { + UsefulBits.openPremiumAppStore(SmallWidgetConfigurationActivity.this); + } + }, getString(R.string.premium_category)); + return; + } + + if (!mSharedPrefs.IsWidgetsEnabled()) { + UsefulBits.showSnackbarWithAction(SmallWidgetConfigurationActivity.this, coordinatorLayout, getString(R.string.widget_disabled), Snackbar.LENGTH_LONG, null, new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivityForResult(new Intent(SmallWidgetConfigurationActivity.this, SettingsActivity.class), 888); + } + }, getString(R.string.action_settings)); + return; + } + final DevicesInfo mDeviceInfo = (DevicesInfo) adapter.getItem(position); if (mDeviceInfo.isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( SmallWidgetConfigurationActivity.this, domoticz); diff --git a/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetConfigurationActivity.java b/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetConfigurationActivity.java index 76745005c..99edbea92 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetConfigurationActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetConfigurationActivity.java @@ -33,15 +33,18 @@ import android.widget.Toast; import com.afollestad.materialdialogs.MaterialDialog; +import com.google.android.material.snackbar.Snackbar; import java.util.ArrayList; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.SearchView; +import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.core.view.MenuItemCompat; import nl.hnogames.domoticz.Adapters.WidgetsAdapter; import nl.hnogames.domoticz.BuildConfig; import nl.hnogames.domoticz.R; +import nl.hnogames.domoticz.SettingsActivity; import nl.hnogames.domoticz.UI.PasswordDialog; import nl.hnogames.domoticz.Utils.SharedPrefUtil; import nl.hnogames.domoticz.Utils.UsefulBits; @@ -69,6 +72,7 @@ public class WidgetConfigurationActivity extends AppCompatActivity { private Domoticz domoticz; private WidgetsAdapter adapter; private SearchView searchViewAction; + public CoordinatorLayout coordinatorLayout; @Override protected void onCreate(Bundle savedInstanceState) { @@ -81,16 +85,8 @@ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.widget_configuration); setResult(RESULT_CANCELED); + coordinatorLayout = findViewById(R.id.coordinatorLayout); - if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { - Toast.makeText(this, getString(R.string.wizard_widgets) + " " + getString(R.string.premium_feature), Toast.LENGTH_LONG).show(); - this.finish(); - } - - if (!mSharedPrefs.IsWidgetsEnabled()) { - Toast.makeText(this, getString(R.string.wizard_widgets) + " " + getString(R.string.widget_disabled), Toast.LENGTH_LONG).show(); - this.finish(); - } domoticz = new Domoticz(this, AppController.getInstance().getRequestQueue()); this.setTitle(getString(R.string.pick_device_title)); if (getSupportActionBar() != null) { @@ -124,6 +120,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { break; } } + super.onActivityResult(requestCode, resultCode, data); } public void initListViews() { @@ -150,6 +147,26 @@ public void onReceiveDevices(final ArrayList mDevicesInfo) { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { + if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { + UsefulBits.showSnackbarWithAction(WidgetConfigurationActivity.this, coordinatorLayout, getString(R.string.wizard_widgets) + " " + getString(R.string.premium_feature), Snackbar.LENGTH_LONG, null, new View.OnClickListener() { + @Override + public void onClick(View v) { + UsefulBits.openPremiumAppStore(WidgetConfigurationActivity.this); + } + }, getString(R.string.premium_category)); + return; + } + + if (!mSharedPrefs.IsWidgetsEnabled()) { + UsefulBits.showSnackbarWithAction(WidgetConfigurationActivity.this, coordinatorLayout, getString(R.string.widget_disabled), Snackbar.LENGTH_LONG, null, new View.OnClickListener() { + @Override + public void onClick(View v) { + startActivityForResult(new Intent(WidgetConfigurationActivity.this, SettingsActivity.class), 888); + } + }, getString(R.string.action_settings)); + return; + } + final DevicesInfo mDeviceInfo = (DevicesInfo) adapter.getItem(position); if (mDeviceInfo.isProtected()) { PasswordDialog passwordDialog = new PasswordDialog( diff --git a/app/src/main/res/layout/widget_configuration.xml b/app/src/main/res/layout/widget_configuration.xml index 9c7867ee6..f4899f7b1 100644 --- a/app/src/main/res/layout/widget_configuration.xml +++ b/app/src/main/res/layout/widget_configuration.xml @@ -20,10 +20,10 @@ ~ under the License. --> - @@ -33,4 +33,4 @@ android:layout_width="match_parent" android:layout_height="match_parent"/> - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/widget_security_configuration.xml b/app/src/main/res/layout/widget_security_configuration.xml index e2ff60d9a..089665d0b 100644 --- a/app/src/main/res/layout/widget_security_configuration.xml +++ b/app/src/main/res/layout/widget_security_configuration.xml @@ -20,7 +20,7 @@ ~ under the License. --> - - \ No newline at end of file + \ No newline at end of file diff --git a/app/version.properties b/app/version.properties index c65ce659c..e15379b34 100644 --- a/app/version.properties +++ b/app/version.properties @@ -1,4 +1,4 @@ -#Thu Aug 01 10:07:59 CEST 2019 -VERSION_BUILD=6163 +#Thu Aug 01 11:14:16 CEST 2019 +VERSION_BUILD=6173 VERSION_PATCH=127 VERSION_CODE=443 diff --git a/domoticzapi/version.properties b/domoticzapi/version.properties index 2ce25c1f4..76d3cd303 100644 --- a/domoticzapi/version.properties +++ b/domoticzapi/version.properties @@ -1,4 +1,4 @@ -#Thu Aug 01 10:08:04 CEST 2019 +#Thu Aug 01 11:14:16 CEST 2019 VERSION_BUILD=3675 VERSION_PATCH=230 VERSION_CODE=230 From 399d3171ae58fddc62eec3bb8a4f81784c582dbf Mon Sep 17 00:00:00 2001 From: Mark Heinis Date: Thu, 1 Aug 2019 11:45:53 +0200 Subject: [PATCH 08/17] Fixes for the security widget Fixes for the security widget --- .../nl/hnogames/domoticz/Utils/SharedPrefUtil.java | 11 +++++------ .../SecurityWidgetConfigurationActivity.java | 13 +------------ .../domoticz/Widgets/SecurityWidgetProvider.java | 6 +++--- .../SmallTempWidgetConfigurationActivity.java | 2 +- .../Widgets/SmallWidgetConfigurationActivity.java | 2 +- .../Widgets/WidgetConfigurationActivity.java | 2 +- .../res/layout/widget_security_configuration.xml | 5 ++++- app/version.properties | 4 ++-- domoticzapi/version.properties | 2 +- 9 files changed, 19 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/nl/hnogames/domoticz/Utils/SharedPrefUtil.java b/app/src/main/java/nl/hnogames/domoticz/Utils/SharedPrefUtil.java index 21c8d297c..fa25ee3f4 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Utils/SharedPrefUtil.java +++ b/app/src/main/java/nl/hnogames/domoticz/Utils/SharedPrefUtil.java @@ -396,9 +396,8 @@ public String getSmallTempWidgetValue(int widgetID) { public void deleteSecurityWidget(int widgetID) { editor.remove("WIDGETSECURITY" + widgetID); - editor.remove("WIDGETSECURITYIDX" + widgetID); editor.remove("WIDGETSECURITYPIN" + widgetID); - editor.remove("WIDGETSECURITYPINLAYOUT" + widgetID); + editor.remove("WIDGETSECURITYLAYOUT" + widgetID); editor.remove("WIDGETSECURITYVALUE" + widgetID); editor.commit(); } @@ -407,7 +406,7 @@ public void setSecurityWidgetIDX(int widgetID, int idx, String value, String pin editor.putInt("WIDGETSECURITY" + widgetID, idx).apply(); editor.putString("WIDGETSECURITYVALUE" + widgetID, value).apply(); editor.putString("WIDGETSECURITYPIN" + widgetID, pin).apply(); - editor.putInt("WIDGETSECURITYPINLAYOUT" + widgetID, layout).apply(); + editor.putInt("WIDGETSECURITYLAYOUT" + widgetID, layout).apply(); editor.commit(); } @@ -416,7 +415,7 @@ public int getSecurityWidgetIDX(int widgetID) { } public int getSecurityWidgetLayout(int widgetID) { - return prefs.getInt("WIDGETSECURITYPINLAYOUT" + widgetID, -1); + return prefs.getInt("WIDGETSECURITYLAYOUT" + widgetID, -1); } public String getSecurityWidgetValue(int widgetID) { @@ -1166,7 +1165,7 @@ public boolean saveSharedPreferencesToFile(File dst) { HashMap oSavePrefs = new HashMap(); for (Map.Entry entry : oAllPrefs.entrySet()) { //Log.d("map values", entry.getKey() + ": " + entry.getValue().toString()); - if (entry.getKey().startsWith("WIDGET") || entry.getKey().startsWith("SMALLWIDGET")|| entry.getKey().startsWith("SMALLTEMPWIDGET")) + if (entry.getKey().startsWith("WIDGET") || entry.getKey().startsWith("SMALLWIDGET")|| entry.getKey().startsWith("SMALLTEMPWIDGET")|| entry.getKey().startsWith("WIDGETSECURITY")) Log.i("PREFS", "Skipped: " + entry.getKey() + ": " + entry.getValue().toString()); else if (entry.getKey().equals("receivedNotifications") || entry.getKey().equals("receivedNotificationsLog")) Log.i("PREFS", "Skipped: " + entry.getKey() + ": " + entry.getValue().toString()); @@ -1224,7 +1223,7 @@ public boolean loadSharedPreferencesFromFile(File src) { Object v = entry.getValue(); String key = entry.getKey(); if (v != null && !UsefulBits.isEmpty(key)) { - if (entry.getKey().startsWith("WIDGET") || entry.getKey().startsWith("SMALLWIDGET")|| entry.getKey().startsWith("SMALLTEMPWIDGET")) + if (entry.getKey().startsWith("WIDGET") || entry.getKey().startsWith("SMALLWIDGET")|| entry.getKey().startsWith("SMALLTEMPWIDGET")|| entry.getKey().startsWith("WIDGETSECURITY")) Log.i("PREFS", "Skipped: " + entry.getKey() + ": " + entry.getValue().toString()); else if (entry.getKey().equals("receivedNotifications") || entry.getKey().equals("receivedNotificationsLog")) Log.i("PREFS", "Skipped: " + entry.getKey() + ": " + entry.getValue().toString()); diff --git a/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetConfigurationActivity.java b/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetConfigurationActivity.java index da9d139d5..240b09d5a 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetConfigurationActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetConfigurationActivity.java @@ -111,7 +111,7 @@ public void onClick(View view) { public void onClick(View v) { UsefulBits.openPremiumAppStore(SecurityWidgetConfigurationActivity.this); } - }, getString(R.string.premium_category)); + }, getString(R.string.upgrade)); return; } @@ -166,16 +166,6 @@ public void onError(Exception error) { } }); - if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) { - Toast.makeText(this, getString(R.string.wizard_widgets) + " " + getString(R.string.premium_feature), Toast.LENGTH_LONG).show(); - this.finish(); - } - - if (!mSharedPrefs.IsWidgetsEnabled()) { - Toast.makeText(this, getString(R.string.wizard_widgets) + " " + getString(R.string.widget_disabled), Toast.LENGTH_LONG).show(); - this.finish(); - } - if (getSupportActionBar() != null) { getSupportActionBar().setDisplayHomeAsUpEnabled(false); getSupportActionBar().setHomeButtonEnabled(false); @@ -189,7 +179,6 @@ public void onError(Exception error) { mSharedPrefs.setFirstStart(false); } else { initListViews(); - } } diff --git a/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetProvider.java b/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetProvider.java index 58973a3a9..17882d1d8 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetProvider.java +++ b/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetProvider.java @@ -143,14 +143,14 @@ public IBinder onBind(Intent intent) { public void updateAppWidget(final AppWidgetManager appWidgetManager, final int appWidgetId) { - final int idx = mSharedPrefs.getSecurityWidgetIDX(appWidgetId); + if (mSharedPrefs == null) + mSharedPrefs = new SharedPrefUtil(this.getApplicationContext()); + final int idx = mSharedPrefs.getSecurityWidgetIDX(appWidgetId); if (appWidgetId == INVALID_APPWIDGET_ID || idx == INVALID_IDX) { Log.i("WIDGET", "I am invalid"); return; } - if (mSharedPrefs == null) - mSharedPrefs = new SharedPrefUtil(this.getApplicationContext()); if (domoticz == null) domoticz = new Domoticz(this.getApplicationContext(), AppController.getInstance().getRequestQueue()); final String password = mSharedPrefs.getSecurityWidgetPin(appWidgetId); diff --git a/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallTempWidgetConfigurationActivity.java b/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallTempWidgetConfigurationActivity.java index afed7735e..d8d47b66f 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallTempWidgetConfigurationActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallTempWidgetConfigurationActivity.java @@ -140,7 +140,7 @@ public void onItemClick(AdapterView parent, View view, int position, long id) public void onClick(View v) { UsefulBits.openPremiumAppStore(SmallTempWidgetConfigurationActivity.this); } - }, getString(R.string.premium_category)); + }, getString(R.string.upgrade)); return; } diff --git a/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallWidgetConfigurationActivity.java b/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallWidgetConfigurationActivity.java index cc53a5269..ee4aad840 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallWidgetConfigurationActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/Widgets/SmallWidgetConfigurationActivity.java @@ -169,7 +169,7 @@ public void onClick(View v) { public void onClick(View v) { startActivityForResult(new Intent(SmallWidgetConfigurationActivity.this, SettingsActivity.class), 888); } - }, getString(R.string.action_settings)); + }, getString(R.string.upgrade)); return; } diff --git a/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetConfigurationActivity.java b/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetConfigurationActivity.java index 99edbea92..e611df7ef 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetConfigurationActivity.java +++ b/app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetConfigurationActivity.java @@ -153,7 +153,7 @@ public void onItemClick(AdapterView parent, View view, int position, long id) public void onClick(View v) { UsefulBits.openPremiumAppStore(WidgetConfigurationActivity.this); } - }, getString(R.string.premium_category)); + }, getString(R.string.upgrade)); return; } diff --git a/app/src/main/res/layout/widget_security_configuration.xml b/app/src/main/res/layout/widget_security_configuration.xml index 089665d0b..f42294031 100644 --- a/app/src/main/res/layout/widget_security_configuration.xml +++ b/app/src/main/res/layout/widget_security_configuration.xml @@ -26,7 +26,9 @@ android:foreground="?android:attr/selectableItemBackground" android:minHeight="?android:attr/listPreferredItemHeight" android:orientation="vertical"> - + + \ No newline at end of file diff --git a/app/version.properties b/app/version.properties index e15379b34..433bdb777 100644 --- a/app/version.properties +++ b/app/version.properties @@ -1,4 +1,4 @@ -#Thu Aug 01 11:14:16 CEST 2019 -VERSION_BUILD=6173 +#Thu Aug 01 11:43:52 CEST 2019 +VERSION_BUILD=6179 VERSION_PATCH=127 VERSION_CODE=443 diff --git a/domoticzapi/version.properties b/domoticzapi/version.properties index 76d3cd303..9e6ea1362 100644 --- a/domoticzapi/version.properties +++ b/domoticzapi/version.properties @@ -1,4 +1,4 @@ -#Thu Aug 01 11:14:16 CEST 2019 +#Thu Aug 01 11:43:52 CEST 2019 VERSION_BUILD=3675 VERSION_PATCH=230 VERSION_CODE=230 From d78773efc00ebcde744f254b32535dfc2b25f85c Mon Sep 17 00:00:00 2001 From: HNO Mobile Date: Thu, 1 Aug 2019 19:54:42 +0200 Subject: [PATCH 09/17] Hotfix issue with http calls and cleartext #540 Hotfix issue with http calls and cleartext #540 --- app/src/debug/AndroidManifest.xml | 1 + app/src/main/AndroidManifest.xml | 1 + app/version.properties | 4 ++-- domoticzapi/version.properties | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/debug/AndroidManifest.xml b/app/src/debug/AndroidManifest.xml index bdd9f4ea1..7c2da06d5 100644 --- a/app/src/debug/AndroidManifest.xml +++ b/app/src/debug/AndroidManifest.xml @@ -125,6 +125,7 @@ android:name=".app.AppController" android:icon="@mipmap/ic_launcher" android:label="@string/app_name_domoticz" + android:usesCleartextTraffic="true" android:theme="@style/AppThemeMain" tools:replace="android:icon, android:label, android:theme, android:name"> diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 3617d6e19..b5a3ffb48 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -125,6 +125,7 @@ android:name=".app.AppController" android:icon="@mipmap/ic_launcher" android:label="@string/app_name_domoticz" + android:usesCleartextTraffic="true" android:theme="@style/AppThemeMain" tools:replace="android:icon, android:label, android:theme, android:name"> diff --git a/app/version.properties b/app/version.properties index 433bdb777..2f4a4c6b9 100644 --- a/app/version.properties +++ b/app/version.properties @@ -1,4 +1,4 @@ -#Thu Aug 01 11:43:52 CEST 2019 -VERSION_BUILD=6179 +#Thu Aug 01 19:48:10 CEST 2019 +VERSION_BUILD=6180 VERSION_PATCH=127 VERSION_CODE=443 diff --git a/domoticzapi/version.properties b/domoticzapi/version.properties index 9e6ea1362..67ca7a039 100644 --- a/domoticzapi/version.properties +++ b/domoticzapi/version.properties @@ -1,4 +1,4 @@ -#Thu Aug 01 11:43:52 CEST 2019 +#Thu Aug 01 19:48:15 CEST 2019 VERSION_BUILD=3675 VERSION_PATCH=230 VERSION_CODE=230 From 71bed842ebccdc58ae64b36a4ac06b1ae557fc3e Mon Sep 17 00:00:00 2001 From: Mark Heinis Date: Fri, 2 Aug 2019 08:09:04 +0200 Subject: [PATCH 10/17] update version update version --- app/version.properties | 8 ++++---- domoticzapi/version.properties | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/version.properties b/app/version.properties index 2f4a4c6b9..80354c26f 100644 --- a/app/version.properties +++ b/app/version.properties @@ -1,4 +1,4 @@ -#Thu Aug 01 19:48:10 CEST 2019 -VERSION_BUILD=6180 -VERSION_PATCH=127 -VERSION_CODE=443 +#Thu Aug 01 20:07:58 CEST 2019 +VERSION_BUILD=6182 +VERSION_PATCH=131 +VERSION_CODE=447 diff --git a/domoticzapi/version.properties b/domoticzapi/version.properties index 67ca7a039..b147b9ec4 100644 --- a/domoticzapi/version.properties +++ b/domoticzapi/version.properties @@ -1,4 +1,4 @@ -#Thu Aug 01 19:48:15 CEST 2019 +#Thu Aug 01 20:07:58 CEST 2019 VERSION_BUILD=3675 VERSION_PATCH=230 VERSION_CODE=230 From ac2922fe060a469b7a5994084eed69f3fc53953e Mon Sep 17 00:00:00 2001 From: Mark Heinis Date: Mon, 5 Aug 2019 08:28:14 +0200 Subject: [PATCH 11/17] Fixed some crash reports Fixed some crash reports --- .../nl/hnogames/domoticz/Fragments/Logs.java | 54 ++++++------ .../Widgets/SecurityWidgetProvider.java | 84 ++++++++++--------- 2 files changed, 71 insertions(+), 67 deletions(-) diff --git a/app/src/main/java/nl/hnogames/domoticz/Fragments/Logs.java b/app/src/main/java/nl/hnogames/domoticz/Fragments/Logs.java index 0bc9c597e..3243ac9ad 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Fragments/Logs.java +++ b/app/src/main/java/nl/hnogames/domoticz/Fragments/Logs.java @@ -180,32 +180,34 @@ protected Boolean doInBackground(Boolean... geto) { } protected void onPostExecute(Boolean result) { - if (cacheLogs != null) - createListView(cacheLogs); - - int LogLevel = DomoticzValues.Log.LOGLEVEL.ALL; //Default - if (getSort().equals(getString(R.string.filter_normal))) - LogLevel = DomoticzValues.Log.LOGLEVEL.NORMAL; - if (getSort().equals(getString(R.string.filter_status))) - LogLevel = DomoticzValues.Log.LOGLEVEL.STATUS; - if (getSort().equals(getString(R.string.filter_error))) - LogLevel = DomoticzValues.Log.LOGLEVEL.ERROR; - - mDomoticz.getLogs(new LogsReceiver() { - @Override - @DebugLog - public void onReceiveLogs(ArrayList mLogInfos) { - successHandling(mLogInfos.toString(), false); - SerializableManager.saveSerializable(mContext, mLogInfos, "Logs"); - createListView(mLogInfos); - } - - @Override - @DebugLog - public void onError(Exception error) { - errorHandling(error); - } - }, LogLevel); + if (isAdded()) { + if (cacheLogs != null) + createListView(cacheLogs); + + int LogLevel = DomoticzValues.Log.LOGLEVEL.ALL; //Default + if (getSort().equals(getString(R.string.filter_normal))) + LogLevel = DomoticzValues.Log.LOGLEVEL.NORMAL; + if (getSort().equals(getString(R.string.filter_status))) + LogLevel = DomoticzValues.Log.LOGLEVEL.STATUS; + if (getSort().equals(getString(R.string.filter_error))) + LogLevel = DomoticzValues.Log.LOGLEVEL.ERROR; + + mDomoticz.getLogs(new LogsReceiver() { + @Override + @DebugLog + public void onReceiveLogs(ArrayList mLogInfos) { + successHandling(mLogInfos.toString(), false); + SerializableManager.saveSerializable(mContext, mLogInfos, "Logs"); + createListView(mLogInfos); + } + + @Override + @DebugLog + public void onError(Exception error) { + errorHandling(error); + } + }, LogLevel); + } } } } \ No newline at end of file diff --git a/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetProvider.java b/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetProvider.java index 17882d1d8..6493070ed 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetProvider.java +++ b/app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetProvider.java @@ -151,50 +151,52 @@ public void updateAppWidget(final AppWidgetManager appWidgetManager, return; } - if (domoticz == null) - domoticz = new Domoticz(this.getApplicationContext(), AppController.getInstance().getRequestQueue()); - final String password = mSharedPrefs.getSecurityWidgetPin(appWidgetId); - views = new RemoteViews(packageName, mSharedPrefs.getSecurityWidgetLayout(appWidgetId)); - domoticz.getDevice(new DevicesReceiver() { - @Override - public void onReceiveDevices(ArrayList mDevicesInfo) { - } + try { + if (domoticz == null) + domoticz = new Domoticz(this.getApplicationContext(), AppController.getInstance().getRequestQueue()); + final String password = mSharedPrefs.getSecurityWidgetPin(appWidgetId); + views = new RemoteViews(packageName, mSharedPrefs.getSecurityWidgetLayout(appWidgetId)); + domoticz.getDevice(new DevicesReceiver() { + @Override + public void onReceiveDevices(ArrayList mDevicesInfo) { + } - @Override - public void onReceiveDevice(DevicesInfo s) { - if (s != null) { - views = new RemoteViews(packageName, mSharedPrefs.getSecurityWidgetLayout(appWidgetId)); - views.setTextViewText(R.id.title, s.getName()); - views.setTextViewText(R.id.status, getApplicationContext().getString(R.string.status) + ": " + - s.getData()); - - views.setOnClickPendingIntent(R.id.armhome, buildButtonPendingIntent( - UpdateSecurityWidgetService.this, - appWidgetId, - s.getIdx(), ACTION_WIDGET_ARMHOME, password)); - views.setViewVisibility(R.id.armhome, View.VISIBLE); - - views.setOnClickPendingIntent(R.id.armaway, buildButtonPendingIntent( - UpdateSecurityWidgetService.this, - appWidgetId, - s.getIdx(), ACTION_WIDGET_ARMAWAY, password)); - views.setViewVisibility(R.id.armaway, View.VISIBLE); - - views.setOnClickPendingIntent(R.id.disarm, buildButtonPendingIntent( - UpdateSecurityWidgetService.this, - appWidgetId, - s.getIdx(), ACTION_WIDGET_DISARM, password)); - views.setViewVisibility(R.id.disarm, View.VISIBLE); - - views.setImageViewResource(R.id.rowIcon, DomoticzIcons.getDrawableIcon(s.getTypeImg(), s.getType(), s.getSwitchType(), true, s.getUseCustomImage(), s.getImage())); - appWidgetManager.updateAppWidget(appWidgetId, views); + @Override + public void onReceiveDevice(DevicesInfo s) { + if (s != null) { + views = new RemoteViews(packageName, mSharedPrefs.getSecurityWidgetLayout(appWidgetId)); + views.setTextViewText(R.id.title, s.getName()); + views.setTextViewText(R.id.status, getApplicationContext().getString(R.string.status) + ": " + + s.getData()); + + views.setOnClickPendingIntent(R.id.armhome, buildButtonPendingIntent( + UpdateSecurityWidgetService.this, + appWidgetId, + s.getIdx(), ACTION_WIDGET_ARMHOME, password)); + views.setViewVisibility(R.id.armhome, View.VISIBLE); + + views.setOnClickPendingIntent(R.id.armaway, buildButtonPendingIntent( + UpdateSecurityWidgetService.this, + appWidgetId, + s.getIdx(), ACTION_WIDGET_ARMAWAY, password)); + views.setViewVisibility(R.id.armaway, View.VISIBLE); + + views.setOnClickPendingIntent(R.id.disarm, buildButtonPendingIntent( + UpdateSecurityWidgetService.this, + appWidgetId, + s.getIdx(), ACTION_WIDGET_DISARM, password)); + views.setViewVisibility(R.id.disarm, View.VISIBLE); + + views.setImageViewResource(R.id.rowIcon, DomoticzIcons.getDrawableIcon(s.getTypeImg(), s.getType(), s.getSwitchType(), true, s.getUseCustomImage(), s.getImage())); + appWidgetManager.updateAppWidget(appWidgetId, views); + } } - } - @Override - public void onError(Exception error) { - } - }, idx, false); + @Override + public void onError(Exception error) { + } + }, idx, false); + }catch(Exception ignored){} } } } From f1ced9470cc80a0a6e516348ce7afeb8861fd054 Mon Sep 17 00:00:00 2001 From: Mark Heinis Date: Mon, 5 Aug 2019 08:35:18 +0200 Subject: [PATCH 12/17] New version New version --- app/version.properties | 8 ++++---- domoticzapi/version.properties | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/version.properties b/app/version.properties index 80354c26f..c539c7518 100644 --- a/app/version.properties +++ b/app/version.properties @@ -1,4 +1,4 @@ -#Thu Aug 01 20:07:58 CEST 2019 -VERSION_BUILD=6182 -VERSION_PATCH=131 -VERSION_CODE=447 +#Mon Aug 05 08:29:35 CEST 2019 +VERSION_BUILD=6183 +VERSION_PATCH=132 +VERSION_CODE=448 diff --git a/domoticzapi/version.properties b/domoticzapi/version.properties index b147b9ec4..659b3e7fe 100644 --- a/domoticzapi/version.properties +++ b/domoticzapi/version.properties @@ -1,4 +1,4 @@ -#Thu Aug 01 20:07:58 CEST 2019 +#Mon Aug 05 08:29:43 CEST 2019 VERSION_BUILD=3675 VERSION_PATCH=230 VERSION_CODE=230 From 5d491248e5034a8cdabcfcff750988c0519d2b69 Mon Sep 17 00:00:00 2001 From: Mark Heinis Date: Wed, 21 Aug 2019 10:24:11 +0200 Subject: [PATCH 13/17] Dont hide the actionbar for tablets Dont hide the actionbar for tablets --- .../domoticz/app/DomoticzDashboardFragment.java | 9 ++++++--- .../domoticz/app/DomoticzRecyclerFragment.java | 12 +++++++++--- app/version.properties | 4 ++-- domoticzapi/version.properties | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/nl/hnogames/domoticz/app/DomoticzDashboardFragment.java b/app/src/main/java/nl/hnogames/domoticz/app/DomoticzDashboardFragment.java index 24eecd18d..4cb11606e 100644 --- a/app/src/main/java/nl/hnogames/domoticz/app/DomoticzDashboardFragment.java +++ b/app/src/main/java/nl/hnogames/domoticz/app/DomoticzDashboardFragment.java @@ -93,6 +93,8 @@ public class DomoticzDashboardFragment extends Fragment { private int SCROLL_THRESHOLD = 600; private boolean controlsVisible = true; private boolean backdropShown = false; + boolean isTablet = false; + boolean isPortrait = false; public DomoticzDashboardFragment() { } @@ -137,6 +139,8 @@ public void setTheme() { @DebugLog public void hideViews() { + if(isTablet) + return; if (backdropShown) return; if (getActivity() instanceof MainActivity) @@ -147,6 +151,8 @@ public void hideViews() { @DebugLog public void showViews() { + if(isTablet) + return; if (getActivity() instanceof MainActivity) ((MainActivity) getActivity()).showViews(); controlsVisible = true; @@ -309,10 +315,7 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) { } public void setGridViewLayout() { - try { - boolean isTablet = false; - boolean isPortrait = false; if (getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) isPortrait = true; diff --git a/app/src/main/java/nl/hnogames/domoticz/app/DomoticzRecyclerFragment.java b/app/src/main/java/nl/hnogames/domoticz/app/DomoticzRecyclerFragment.java index 6ccc6f4b1..879c68177 100644 --- a/app/src/main/java/nl/hnogames/domoticz/app/DomoticzRecyclerFragment.java +++ b/app/src/main/java/nl/hnogames/domoticz/app/DomoticzRecyclerFragment.java @@ -96,6 +96,8 @@ public class DomoticzRecyclerFragment extends Fragment { private int SCROLL_THRESHOLD = 600; private boolean controlsVisible = true; private boolean backdropShown = false; + boolean isTablet = false; + boolean isPortrait = false; public DomoticzRecyclerFragment() { } @@ -167,6 +169,10 @@ public UserInfo getCurrentUser(Context context, Domoticz domoticz) { @DebugLog public void hideViews() { + if(isTablet) + return; + if (backdropShown) + return; if (getActivity() instanceof MainActivity) ((MainActivity) getActivity()).hideViews(); controlsVisible = false; @@ -175,12 +181,15 @@ public void hideViews() { @DebugLog public void showViews() { + if(isTablet) + return; if (getActivity() instanceof MainActivity) ((MainActivity) getActivity()).showViews(); controlsVisible = true; scrolledDistance = 0; } + public String getSort() { return sort; } @@ -300,9 +309,6 @@ public void onScrolled(RecyclerView recyclerView, int dx, int dy) { public void setGridViewLayout() { try { - boolean isTablet = false; - boolean isPortrait = false; - if (getActivity().getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) isPortrait = true; if (getActivity() instanceof MainActivity) { diff --git a/app/version.properties b/app/version.properties index c539c7518..ea51194ec 100644 --- a/app/version.properties +++ b/app/version.properties @@ -1,4 +1,4 @@ -#Mon Aug 05 08:29:35 CEST 2019 -VERSION_BUILD=6183 +#Wed Aug 21 10:21:42 CEST 2019 +VERSION_BUILD=6187 VERSION_PATCH=132 VERSION_CODE=448 diff --git a/domoticzapi/version.properties b/domoticzapi/version.properties index 659b3e7fe..dc0ea4652 100644 --- a/domoticzapi/version.properties +++ b/domoticzapi/version.properties @@ -1,4 +1,4 @@ -#Mon Aug 05 08:29:43 CEST 2019 +#Wed Aug 21 10:21:42 CEST 2019 VERSION_BUILD=3675 VERSION_PATCH=230 VERSION_CODE=230 From ebf49eedc645c129ed72589f2591f3f5b40bdeb0 Mon Sep 17 00:00:00 2001 From: Mark Heinis Date: Wed, 21 Aug 2019 10:27:35 +0200 Subject: [PATCH 14/17] Dont show the clock when looking at a specific plan Dont show the clock when looking at a specific plan --- .../main/java/nl/hnogames/domoticz/Fragments/Dashboard.java | 2 +- app/version.properties | 4 ++-- domoticzapi/version.properties | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/nl/hnogames/domoticz/Fragments/Dashboard.java b/app/src/main/java/nl/hnogames/domoticz/Fragments/Dashboard.java index fc957fafd..b1d425bd0 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Fragments/Dashboard.java +++ b/app/src/main/java/nl/hnogames/domoticz/Fragments/Dashboard.java @@ -244,7 +244,7 @@ private void processDevices(ArrayList devicesInfos) { } } } - if (mSharedPrefs.addClockToDashboard() && (UsefulBits.isEmpty(super.getSort()) || super.getSort().equals(mContext.getString(R.string.filterOn_all)))) { + if (mSharedPrefs.addClockToDashboard() && (UsefulBits.isEmpty(super.getSort()) || super.getSort().equals(mContext.getString(R.string.filterOn_all))) && planID <= 0) { mDomoticz.getSunRise(new SunRiseReceiver() { @Override public void onReceive(SunRiseInfo mSunRiseInfo) { diff --git a/app/version.properties b/app/version.properties index ea51194ec..04fbee861 100644 --- a/app/version.properties +++ b/app/version.properties @@ -1,4 +1,4 @@ -#Wed Aug 21 10:21:42 CEST 2019 -VERSION_BUILD=6187 +#Wed Aug 21 10:26:04 CEST 2019 +VERSION_BUILD=6188 VERSION_PATCH=132 VERSION_CODE=448 diff --git a/domoticzapi/version.properties b/domoticzapi/version.properties index dc0ea4652..c37eabbbb 100644 --- a/domoticzapi/version.properties +++ b/domoticzapi/version.properties @@ -1,4 +1,4 @@ -#Wed Aug 21 10:21:42 CEST 2019 +#Wed Aug 21 10:26:04 CEST 2019 VERSION_BUILD=3675 VERSION_PATCH=230 VERSION_CODE=230 From c6ca0c55a8e42fc0c51667c604e8bb49b09f1e6d Mon Sep 17 00:00:00 2001 From: Mark Heinis Date: Wed, 21 Aug 2019 11:30:52 +0200 Subject: [PATCH 15/17] #544 Dont animate the temp-circles on auto-refresh #544 Dont animate the temp-circles on auto-refresh --- .../domoticz/Adapters/DashboardAdapter.java | 17 +++++++++++------ .../domoticz/Adapters/TemperatureAdapter.java | 8 +++++--- app/version.properties | 4 ++-- domoticzapi/version.properties | 2 +- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/DashboardAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/DashboardAdapter.java index e713b2ea4..52aa86cf1 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Adapters/DashboardAdapter.java +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/DashboardAdapter.java @@ -473,9 +473,12 @@ private void setDefaultRowData(DevicesInfo mDeviceInfo, holder.pieView.setPercentageBackgroundColor(ContextCompat.getColor(context, R.color.material_blue_600)); else holder.pieView.setPercentageBackgroundColor(ContextCompat.getColor(context, R.color.material_orange_600)); - PieAngleAnimation animation = new PieAngleAnimation(holder.pieView); - animation.setDuration(2000); - holder.pieView.startAnimation(animation); + + if(mSharedPrefs.getAutoRefresh()) { + PieAngleAnimation animation = new PieAngleAnimation(holder.pieView); + animation.setDuration(2000); + holder.pieView.startAnimation(animation); + } if (!mSharedPrefs.showExtraData()) holder.switch_battery_level.setVisibility(View.GONE); } else @@ -862,9 +865,11 @@ public void onClick(View v) { holder.pieView.setPercentageBackgroundColor(R.color.md_red_600); } - PieAngleAnimation animation = new PieAngleAnimation(holder.pieView); - animation.setDuration(2000); - holder.pieView.startAnimation(animation); + if(mSharedPrefs.getAutoRefresh()) { + PieAngleAnimation animation = new PieAngleAnimation(holder.pieView); + animation.setDuration(2000); + holder.pieView.startAnimation(animation); + } } if (holder.iconMode != null) { diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/TemperatureAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/TemperatureAdapter.java index 9d8d9d9fb..297ffe1eb 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Adapters/TemperatureAdapter.java +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/TemperatureAdapter.java @@ -215,9 +215,11 @@ public void onClick(View v) { holder.pieView.setPercentage(Float.valueOf(temp + "")); holder.pieView.setInnerText(mTemperatureInfo.getTemperature() + " " + sign); - PieAngleAnimation animation = new PieAngleAnimation(holder.pieView); - animation.setDuration(2000); - holder.pieView.startAnimation(animation); + if(mSharedPrefs.getAutoRefresh()) { + PieAngleAnimation animation = new PieAngleAnimation(holder.pieView); + animation.setDuration(2000); + holder.pieView.startAnimation(animation); + } } } diff --git a/app/version.properties b/app/version.properties index 04fbee861..4a98437ba 100644 --- a/app/version.properties +++ b/app/version.properties @@ -1,4 +1,4 @@ -#Wed Aug 21 10:26:04 CEST 2019 -VERSION_BUILD=6188 +#Wed Aug 21 11:26:44 CEST 2019 +VERSION_BUILD=6193 VERSION_PATCH=132 VERSION_CODE=448 diff --git a/domoticzapi/version.properties b/domoticzapi/version.properties index c37eabbbb..d8a91e579 100644 --- a/domoticzapi/version.properties +++ b/domoticzapi/version.properties @@ -1,4 +1,4 @@ -#Wed Aug 21 10:26:04 CEST 2019 +#Wed Aug 21 11:26:46 CEST 2019 VERSION_BUILD=3675 VERSION_PATCH=230 VERSION_CODE=230 From 6dd5909dc16e86a078c2f425ebf7d32db0d1ec89 Mon Sep 17 00:00:00 2001 From: Mark Heinis Date: Wed, 21 Aug 2019 11:50:31 +0200 Subject: [PATCH 16/17] Update the gradle files / libraries Update the gradle files / libraries --- app/build.gradle | 16 ++++++++-------- .../domoticz/Adapters/DashboardAdapter.java | 4 ++-- .../domoticz/Adapters/TemperatureAdapter.java | 2 +- app/version.properties | 4 ++-- build.gradle | 2 +- domoticzapi/build.gradle | 2 +- domoticzapi/version.properties | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 ++-- libs/MemorizingTrustManager/build.gradle | 2 +- libs/SeekArc_library/build.gradle | 2 +- materialList/build.gradle | 6 +++--- wear/build.gradle | 4 ++-- 12 files changed, 25 insertions(+), 25 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 48748cbb7..78e551839 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -161,20 +161,20 @@ dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation 'androidx.appcompat:appcompat:1.1.0-beta01' + implementation 'androidx.appcompat:appcompat:1.1.0-rc01' implementation 'androidx.legacy:legacy-support-v13:1.0.0' - implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha06' + implementation 'androidx.recyclerview:recyclerview:1.1.0-beta03' implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.biometric:biometric:1.0.0-alpha04' - implementation 'com.google.android.material:material:1.1.0-alpha07' + implementation 'com.google.android.material:material:1.1.0-alpha09' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.annotation:annotation:1.1.0' - implementation "com.google.firebase:firebase-core:17.0.0" + implementation "com.google.firebase:firebase-core:17.1.0" implementation "com.google.firebase:firebase-crash:16.2.1" - implementation "com.google.firebase:firebase-perf:18.0.1" - implementation "com.google.firebase:firebase-messaging:19.0.1" - implementation "com.google.firebase:firebase-ads:18.0.0" + implementation "com.google.firebase:firebase-perf:19.0.0" + implementation "com.google.firebase:firebase-messaging:20.0.0" + implementation "com.google.firebase:firebase-ads:18.1.1" implementation "com.crashlytics.sdk.android:crashlytics:2.10.1" implementation "com.google.android.gms:play-services-analytics:17.0.0" @@ -183,7 +183,7 @@ dependencies { implementation "com.google.android.gms:play-services-gcm:17.0.0" implementation "com.google.android.gms:play-services-location:17.0.0" implementation "com.google.android.gms:play-services-places:17.0.0" - implementation "com.google.android.gms:play-services-ads:18.0.0" + implementation "com.google.android.gms:play-services-ads:18.1.1" implementation 'com.google.android.ads.consent:consent-library:1.0.7' implementation "com.github.nisrulz:recyclerviewhelper:27.1.1" diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/DashboardAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/DashboardAdapter.java index 52aa86cf1..f06ac8125 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Adapters/DashboardAdapter.java +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/DashboardAdapter.java @@ -474,7 +474,7 @@ private void setDefaultRowData(DevicesInfo mDeviceInfo, else holder.pieView.setPercentageBackgroundColor(ContextCompat.getColor(context, R.color.material_orange_600)); - if(mSharedPrefs.getAutoRefresh()) { + if(!mSharedPrefs.getAutoRefresh()) { PieAngleAnimation animation = new PieAngleAnimation(holder.pieView); animation.setDuration(2000); holder.pieView.startAnimation(animation); @@ -865,7 +865,7 @@ public void onClick(View v) { holder.pieView.setPercentageBackgroundColor(R.color.md_red_600); } - if(mSharedPrefs.getAutoRefresh()) { + if(!mSharedPrefs.getAutoRefresh()) { PieAngleAnimation animation = new PieAngleAnimation(holder.pieView); animation.setDuration(2000); holder.pieView.startAnimation(animation); diff --git a/app/src/main/java/nl/hnogames/domoticz/Adapters/TemperatureAdapter.java b/app/src/main/java/nl/hnogames/domoticz/Adapters/TemperatureAdapter.java index 297ffe1eb..ebe1807d0 100644 --- a/app/src/main/java/nl/hnogames/domoticz/Adapters/TemperatureAdapter.java +++ b/app/src/main/java/nl/hnogames/domoticz/Adapters/TemperatureAdapter.java @@ -215,7 +215,7 @@ public void onClick(View v) { holder.pieView.setPercentage(Float.valueOf(temp + "")); holder.pieView.setInnerText(mTemperatureInfo.getTemperature() + " " + sign); - if(mSharedPrefs.getAutoRefresh()) { + if(!mSharedPrefs.getAutoRefresh()) { PieAngleAnimation animation = new PieAngleAnimation(holder.pieView); animation.setDuration(2000); holder.pieView.startAnimation(animation); diff --git a/app/version.properties b/app/version.properties index 4a98437ba..5708338d0 100644 --- a/app/version.properties +++ b/app/version.properties @@ -1,4 +1,4 @@ -#Wed Aug 21 11:26:44 CEST 2019 -VERSION_BUILD=6193 +#Wed Aug 21 11:47:29 CEST 2019 +VERSION_BUILD=6199 VERSION_PATCH=132 VERSION_CODE=448 diff --git a/build.gradle b/build.gradle index 496e20250..82bb3bb7a 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ buildscript { } //noinspection GroovyAssignabilityCheck dependencies { - classpath 'com.android.tools.build:gradle:3.4.2' + classpath 'com.android.tools.build:gradle:3.5.0' classpath 'com.google.gms:google-services:4.2.0' classpath 'com.google.firebase:perf-plugin:1.2.1' classpath 'io.fabric.tools:gradle:1.29.0' diff --git a/domoticzapi/build.gradle b/domoticzapi/build.gradle index 684d3350d..dfd9b77b2 100644 --- a/domoticzapi/build.gradle +++ b/domoticzapi/build.gradle @@ -76,7 +76,7 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) testImplementation 'junit:junit:4.12' - implementation 'androidx.appcompat:appcompat:1.1.0-beta01' + implementation 'androidx.appcompat:appcompat:1.1.0-rc01' implementation 'androidx.legacy:legacy-support-v13:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0' diff --git a/domoticzapi/version.properties b/domoticzapi/version.properties index d8a91e579..f682921da 100644 --- a/domoticzapi/version.properties +++ b/domoticzapi/version.properties @@ -1,4 +1,4 @@ -#Wed Aug 21 11:26:46 CEST 2019 +#Wed Aug 21 11:47:29 CEST 2019 VERSION_BUILD=3675 VERSION_PATCH=230 VERSION_CODE=230 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 6c8e10f0b..a39225b93 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Apr 25 09:44:01 CEST 2019 +#Wed Aug 21 11:24:09 CEST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/libs/MemorizingTrustManager/build.gradle b/libs/MemorizingTrustManager/build.gradle index 2ad8535a9..9f031034a 100644 --- a/libs/MemorizingTrustManager/build.gradle +++ b/libs/MemorizingTrustManager/build.gradle @@ -6,7 +6,7 @@ buildscript { } //noinspection GroovyAssignabilityCheck dependencies { - classpath 'com.android.tools.build:gradle:3.4.2' + classpath 'com.android.tools.build:gradle:3.5.0' } } diff --git a/libs/SeekArc_library/build.gradle b/libs/SeekArc_library/build.gradle index e24dfa7d4..ec6f08b2e 100644 --- a/libs/SeekArc_library/build.gradle +++ b/libs/SeekArc_library/build.gradle @@ -33,7 +33,7 @@ android { } dependencies { - implementation 'androidx.appcompat:appcompat:1.1.0-beta01' + implementation 'androidx.appcompat:appcompat:1.1.0-rc01' implementation 'androidx.legacy:legacy-support-v13:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0' } \ No newline at end of file diff --git a/materialList/build.gradle b/materialList/build.gradle index bd7a7c40f..f86238ec9 100644 --- a/materialList/build.gradle +++ b/materialList/build.gradle @@ -21,13 +21,13 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'androidx.appcompat:appcompat:1.1.0-beta01' + implementation 'androidx.appcompat:appcompat:1.1.0-rc01' implementation 'androidx.cardview:cardview:1.0.0' - implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha06' + implementation 'androidx.recyclerview:recyclerview:1.1.0-beta03' implementation 'androidx.legacy:legacy-support-v13:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation 'com.google.firebase:firebase-core:17.0.0' + implementation 'com.google.firebase:firebase-core:17.1.0' implementation 'com.google.firebase:firebase-crash:16.2.1' implementation 'com.nineoldandroids:library:2.4.0' diff --git a/wear/build.gradle b/wear/build.gradle index 12ce4eeb4..9fbaee9f8 100644 --- a/wear/build.gradle +++ b/wear/build.gradle @@ -71,8 +71,8 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.google.android.support:wearable:2.4.0' - implementation 'com.google.android.gms:play-services-wearable:16.0.1' - implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha06' + implementation 'com.google.android.gms:play-services-wearable:17.0.0' + implementation 'androidx.recyclerview:recyclerview:1.1.0-beta03' implementation 'com.google.code.gson:gson:2.8.5' implementation 'com.squareup.picasso:picasso:2.5.2' } From 94dc91599f8bb4c314c54bbde366f72ea5092498 Mon Sep 17 00:00:00 2001 From: Mark Heinis Date: Wed, 21 Aug 2019 13:10:57 +0200 Subject: [PATCH 17/17] New build New build --- .gitignore | 3 ++- app/version.properties | 8 ++++---- domoticzapi/version.properties | 6 +++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 122df7851..edc5fe131 100644 --- a/.gitignore +++ b/.gitignore @@ -48,4 +48,5 @@ libs/MemorizingTrustManager/build/ # Android Studio build files -ajcore.* \ No newline at end of file +ajcore.* +*.hprof diff --git a/app/version.properties b/app/version.properties index 5708338d0..45cc4372a 100644 --- a/app/version.properties +++ b/app/version.properties @@ -1,4 +1,4 @@ -#Wed Aug 21 11:47:29 CEST 2019 -VERSION_BUILD=6199 -VERSION_PATCH=132 -VERSION_CODE=448 +#Wed Aug 21 13:06:12 CEST 2019 +VERSION_BUILD=6204 +VERSION_PATCH=135 +VERSION_CODE=451 diff --git a/domoticzapi/version.properties b/domoticzapi/version.properties index f682921da..33e997ccd 100644 --- a/domoticzapi/version.properties +++ b/domoticzapi/version.properties @@ -1,4 +1,4 @@ -#Wed Aug 21 11:47:29 CEST 2019 +#Wed Aug 21 13:06:14 CEST 2019 VERSION_BUILD=3675 -VERSION_PATCH=230 -VERSION_CODE=230 +VERSION_PATCH=231 +VERSION_CODE=231