Skip to content

Commit

Permalink
Inter-app settings screen and Accept Treatments option
Browse files Browse the repository at this point in the history
  • Loading branch information
jamorham committed Oct 30, 2016
1 parent 9fd69b9 commit 8a0112b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 25 deletions.
30 changes: 17 additions & 13 deletions app/src/main/java/com/eveningoutpost/dexdrip/NSClientReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,26 +72,30 @@ public void onReceive(Context context, Intent intent) {
process_SGV_json(sgv_json);
}
} else {
Log.e(TAG, "Ignoring SGV data as we are not a follower");
Log.d(TAG, "Ignoring SGV data as we are not a follower");
}
break;

case Intents.ACTION_NEW_TREATMENT:
if (bundle == null) break;
final String treatment_json = bundle.getString("treatment", "");
if (treatment_json.length() > 0) {
process_TREATMENT_json(treatment_json);
}
final String treatments_json = bundle.getString("treatments", "");
if (treatments_json.length() > 0) {
try {
final JSONArray jsonArray = new JSONArray(treatments_json);
for (int i = 0; i < jsonArray.length(); i++) {
process_TREATMENT_json(jsonArray.getString(i));
if (prefs.getBoolean("accept_nsclient_treatments", true)) {
final String treatment_json = bundle.getString("treatment", "");
if (treatment_json.length() > 0) {
process_TREATMENT_json(treatment_json);
}
final String treatments_json = bundle.getString("treatments", "");
if (treatments_json.length() > 0) {
try {
final JSONArray jsonArray = new JSONArray(treatments_json);
for (int i = 0; i < jsonArray.length(); i++) {
process_TREATMENT_json(jsonArray.getString(i));
}
} catch (JSONException e) {
Log.e(TAG, "Json exception with sgvs: " + e.toString());
}
} catch (JSONException e) {
Log.e(TAG, "Json exception with sgvs: " + e.toString());
}
} else {
Log.d(TAG, "Ignoring nsclient treatment data due to preference");
}
break;

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 26 additions & 12 deletions app/src/main/res/xml/pref_advanced_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,32 @@
<PreferenceCategory
android:key="other_category"
android:title="@string/other_settings">
<SwitchPreference
android:defaultValue="false"
android:key="broadcast_data_through_intents"
android:summary="@string/pref_summary_broadcast_enabled"
android:switchTextOff="@string/short_off_text_for_switches"
android:switchTextOn="@string/short_on_text_for_switches"
android:title="@string/pref_title_broadcast_enabled" />
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:key="xdrip_intrer_app_settings"
android:summary="For interacting with other compatible apps"
android:icon="@drawable/ic_open_in_app_grey600_48dp"
android:title="Inter-app settings">
<SwitchPreference
android:defaultValue="false"
android:key="broadcast_data_through_intents"
android:summary="@string/pref_summary_broadcast_enabled"
android:switchTextOff="@string/short_off_text_for_switches"
android:switchTextOn="@string/short_on_text_for_switches"
android:title="@string/pref_title_broadcast_enabled" />
<CheckBoxPreference
android:defaultValue="true"
android:dependency="broadcast_data_through_intents"
android:key="broadcast_data_through_intents_without_permission"
android:summary="Send broadcasts without locking to the older permission model"
android:title="@string/compatible_broadcast" />
<SwitchPreference
android:defaultValue="true"
android:key="accept_nsclient_treatments"
android:summary="Process treatment data received from NSClient app"
android:switchTextOff="@string/short_off_text_for_switches"
android:switchTextOn="@string/short_on_text_for_switches"
android:title="Accept Treatments" />
</PreferenceScreen>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:key="xdrip_less_common_settings"
android:summary="@string/debug_and_other_misc_options"
Expand Down Expand Up @@ -241,11 +260,6 @@
android:key="aggressive_service_restart"
android:summary="Repeatedly restart the collection service at any hint of missing data. Enable only if you are getting data loss."
android:title="Aggressive service restarts" />
<CheckBoxPreference
android:defaultValue="true"
android:key="broadcast_data_through_intents_without_permission"
android:summary="Send broadcasts without locking to the older permission model"
android:title="@string/compatible_broadcast" />
<CheckBoxPreference
android:defaultValue="false"
android:dependency="engineering_mode"
Expand Down

0 comments on commit 8a0112b

Please sign in to comment.