From 399d3171ae58fddc62eec3bb8a4f81784c582dbf Mon Sep 17 00:00:00 2001 From: Mark Heinis Date: Thu, 1 Aug 2019 11:45:53 +0200 Subject: [PATCH] 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