Skip to content

Commit

Permalink
Fixes for the security widget
Browse files Browse the repository at this point in the history
Fixes for the security widget
  • Loading branch information
Mark Heinis committed Aug 1, 2019
1 parent 511533e commit 399d317
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 28 deletions.
11 changes: 5 additions & 6 deletions app/src/main/java/nl/hnogames/domoticz/Utils/SharedPrefUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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();
}

Expand All @@ -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) {
Expand Down Expand Up @@ -1166,7 +1165,7 @@ public boolean saveSharedPreferencesToFile(File dst) {
HashMap<String, Object> oSavePrefs = new HashMap<String, Object>();
for (Map.Entry<String, ?> 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());
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand All @@ -189,7 +179,6 @@ public void onError(Exception error) {
mSharedPrefs.setFirstStart(false);
} else {
initListViews();

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 4 additions & 1 deletion app/src/main/res/layout/widget_security_configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
android:foreground="?android:attr/selectableItemBackground"
android:minHeight="?android:attr/listPreferredItemHeight"
android:orientation="vertical">

<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/title"
style="@style/row_name_small"
Expand Down Expand Up @@ -78,5 +80,6 @@
android:background="@drawable/button_status"
android:text="@string/ok"
android:textSize="12dp"/>
</LinearLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
4 changes: 2 additions & 2 deletions app/version.properties
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion domoticzapi/version.properties
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 399d317

Please sign in to comment.