Skip to content

Commit 399d317

Browse files
author
Mark Heinis
committed
Fixes for the security widget
Fixes for the security widget
1 parent 511533e commit 399d317

9 files changed

+19
-28
lines changed

app/src/main/java/nl/hnogames/domoticz/Utils/SharedPrefUtil.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,8 @@ public String getSmallTempWidgetValue(int widgetID) {
396396

397397
public void deleteSecurityWidget(int widgetID) {
398398
editor.remove("WIDGETSECURITY" + widgetID);
399-
editor.remove("WIDGETSECURITYIDX" + widgetID);
400399
editor.remove("WIDGETSECURITYPIN" + widgetID);
401-
editor.remove("WIDGETSECURITYPINLAYOUT" + widgetID);
400+
editor.remove("WIDGETSECURITYLAYOUT" + widgetID);
402401
editor.remove("WIDGETSECURITYVALUE" + widgetID);
403402
editor.commit();
404403
}
@@ -407,7 +406,7 @@ public void setSecurityWidgetIDX(int widgetID, int idx, String value, String pin
407406
editor.putInt("WIDGETSECURITY" + widgetID, idx).apply();
408407
editor.putString("WIDGETSECURITYVALUE" + widgetID, value).apply();
409408
editor.putString("WIDGETSECURITYPIN" + widgetID, pin).apply();
410-
editor.putInt("WIDGETSECURITYPINLAYOUT" + widgetID, layout).apply();
409+
editor.putInt("WIDGETSECURITYLAYOUT" + widgetID, layout).apply();
411410
editor.commit();
412411
}
413412

@@ -416,7 +415,7 @@ public int getSecurityWidgetIDX(int widgetID) {
416415
}
417416

418417
public int getSecurityWidgetLayout(int widgetID) {
419-
return prefs.getInt("WIDGETSECURITYPINLAYOUT" + widgetID, -1);
418+
return prefs.getInt("WIDGETSECURITYLAYOUT" + widgetID, -1);
420419
}
421420

422421
public String getSecurityWidgetValue(int widgetID) {
@@ -1166,7 +1165,7 @@ public boolean saveSharedPreferencesToFile(File dst) {
11661165
HashMap<String, Object> oSavePrefs = new HashMap<String, Object>();
11671166
for (Map.Entry<String, ?> entry : oAllPrefs.entrySet()) {
11681167
//Log.d("map values", entry.getKey() + ": " + entry.getValue().toString());
1169-
if (entry.getKey().startsWith("WIDGET") || entry.getKey().startsWith("SMALLWIDGET")|| entry.getKey().startsWith("SMALLTEMPWIDGET"))
1168+
if (entry.getKey().startsWith("WIDGET") || entry.getKey().startsWith("SMALLWIDGET")|| entry.getKey().startsWith("SMALLTEMPWIDGET")|| entry.getKey().startsWith("WIDGETSECURITY"))
11701169
Log.i("PREFS", "Skipped: " + entry.getKey() + ": " + entry.getValue().toString());
11711170
else if (entry.getKey().equals("receivedNotifications") || entry.getKey().equals("receivedNotificationsLog"))
11721171
Log.i("PREFS", "Skipped: " + entry.getKey() + ": " + entry.getValue().toString());
@@ -1224,7 +1223,7 @@ public boolean loadSharedPreferencesFromFile(File src) {
12241223
Object v = entry.getValue();
12251224
String key = entry.getKey();
12261225
if (v != null && !UsefulBits.isEmpty(key)) {
1227-
if (entry.getKey().startsWith("WIDGET") || entry.getKey().startsWith("SMALLWIDGET")|| entry.getKey().startsWith("SMALLTEMPWIDGET"))
1226+
if (entry.getKey().startsWith("WIDGET") || entry.getKey().startsWith("SMALLWIDGET")|| entry.getKey().startsWith("SMALLTEMPWIDGET")|| entry.getKey().startsWith("WIDGETSECURITY"))
12281227
Log.i("PREFS", "Skipped: " + entry.getKey() + ": " + entry.getValue().toString());
12291228
else if (entry.getKey().equals("receivedNotifications") || entry.getKey().equals("receivedNotificationsLog"))
12301229
Log.i("PREFS", "Skipped: " + entry.getKey() + ": " + entry.getValue().toString());

app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetConfigurationActivity.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public void onClick(View view) {
111111
public void onClick(View v) {
112112
UsefulBits.openPremiumAppStore(SecurityWidgetConfigurationActivity.this);
113113
}
114-
}, getString(R.string.premium_category));
114+
}, getString(R.string.upgrade));
115115
return;
116116
}
117117

@@ -166,16 +166,6 @@ public void onError(Exception error) {
166166
}
167167
});
168168

169-
if (BuildConfig.LITE_VERSION || !mSharedPrefs.isAPKValidated()) {
170-
Toast.makeText(this, getString(R.string.wizard_widgets) + " " + getString(R.string.premium_feature), Toast.LENGTH_LONG).show();
171-
this.finish();
172-
}
173-
174-
if (!mSharedPrefs.IsWidgetsEnabled()) {
175-
Toast.makeText(this, getString(R.string.wizard_widgets) + " " + getString(R.string.widget_disabled), Toast.LENGTH_LONG).show();
176-
this.finish();
177-
}
178-
179169
if (getSupportActionBar() != null) {
180170
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
181171
getSupportActionBar().setHomeButtonEnabled(false);
@@ -189,7 +179,6 @@ public void onError(Exception error) {
189179
mSharedPrefs.setFirstStart(false);
190180
} else {
191181
initListViews();
192-
193182
}
194183
}
195184

app/src/main/java/nl/hnogames/domoticz/Widgets/SecurityWidgetProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,14 @@ public IBinder onBind(Intent intent) {
143143

144144
public void updateAppWidget(final AppWidgetManager appWidgetManager,
145145
final int appWidgetId) {
146-
final int idx = mSharedPrefs.getSecurityWidgetIDX(appWidgetId);
146+
if (mSharedPrefs == null)
147+
mSharedPrefs = new SharedPrefUtil(this.getApplicationContext());
148+
final int idx = mSharedPrefs.getSecurityWidgetIDX(appWidgetId);
147149
if (appWidgetId == INVALID_APPWIDGET_ID || idx == INVALID_IDX) {
148150
Log.i("WIDGET", "I am invalid");
149151
return;
150152
}
151153

152-
if (mSharedPrefs == null)
153-
mSharedPrefs = new SharedPrefUtil(this.getApplicationContext());
154154
if (domoticz == null)
155155
domoticz = new Domoticz(this.getApplicationContext(), AppController.getInstance().getRequestQueue());
156156
final String password = mSharedPrefs.getSecurityWidgetPin(appWidgetId);

app/src/main/java/nl/hnogames/domoticz/Widgets/SmallTempWidgetConfigurationActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
140140
public void onClick(View v) {
141141
UsefulBits.openPremiumAppStore(SmallTempWidgetConfigurationActivity.this);
142142
}
143-
}, getString(R.string.premium_category));
143+
}, getString(R.string.upgrade));
144144
return;
145145
}
146146

app/src/main/java/nl/hnogames/domoticz/Widgets/SmallWidgetConfigurationActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public void onClick(View v) {
169169
public void onClick(View v) {
170170
startActivityForResult(new Intent(SmallWidgetConfigurationActivity.this, SettingsActivity.class), 888);
171171
}
172-
}, getString(R.string.action_settings));
172+
}, getString(R.string.upgrade));
173173
return;
174174
}
175175

app/src/main/java/nl/hnogames/domoticz/Widgets/WidgetConfigurationActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
153153
public void onClick(View v) {
154154
UsefulBits.openPremiumAppStore(WidgetConfigurationActivity.this);
155155
}
156-
}, getString(R.string.premium_category));
156+
}, getString(R.string.upgrade));
157157
return;
158158
}
159159

app/src/main/res/layout/widget_security_configuration.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
android:foreground="?android:attr/selectableItemBackground"
2727
android:minHeight="?android:attr/listPreferredItemHeight"
2828
android:orientation="vertical">
29-
29+
<LinearLayout android:layout_width="match_parent"
30+
android:layout_height="match_parent"
31+
android:orientation="vertical">
3032
<TextView
3133
android:id="@+id/title"
3234
style="@style/row_name_small"
@@ -78,5 +80,6 @@
7880
android:background="@drawable/button_status"
7981
android:text="@string/ok"
8082
android:textSize="12dp"/>
83+
</LinearLayout>
8184

8285
</androidx.coordinatorlayout.widget.CoordinatorLayout>

app/version.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Thu Aug 01 11:14:16 CEST 2019
2-
VERSION_BUILD=6173
1+
#Thu Aug 01 11:43:52 CEST 2019
2+
VERSION_BUILD=6179
33
VERSION_PATCH=127
44
VERSION_CODE=443

domoticzapi/version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Thu Aug 01 11:14:16 CEST 2019
1+
#Thu Aug 01 11:43:52 CEST 2019
22
VERSION_BUILD=3675
33
VERSION_PATCH=230
44
VERSION_CODE=230

0 commit comments

Comments
 (0)