From 06d63826e6a7be67f6eff15aea3fac2dd7715932 Mon Sep 17 00:00:00 2001 From: jens Date: Sat, 20 Nov 2021 16:14:21 +0100 Subject: [PATCH] Donate button --- .../jens/automation2/ActivityMainScreen.java | 20 +++++++++++++++++- .../jens/automation2/XmlFileInterface.java | 21 ++++++++++++++++--- .../main/res/layout/main_overview_layout.xml | 8 +++++++ app/src/main/res/values/strings.xml | 2 ++ 4 files changed, 47 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/jens/automation2/ActivityMainScreen.java b/app/src/main/java/com/jens/automation2/ActivityMainScreen.java index ca9ecaf6..722ac783 100644 --- a/app/src/main/java/com/jens/automation2/ActivityMainScreen.java +++ b/app/src/main/java/com/jens/automation2/ActivityMainScreen.java @@ -44,7 +44,7 @@ public class ActivityMainScreen extends ActivityGeneric private static ActivityMainScreen activityMainScreenInstance = null; private ToggleButton toggleService, tbLockSound; - private Button bShowHelp, bPrivacy, bSettingsErase, bAddSoundLockTIme; + private Button bShowHelp, bPrivacy, bSettingsErase, bAddSoundLockTIme, bDonate; private TextView tvActivePoi, tvClosestPoi, tvLastRule, tvMainScreenNotePermissions, tvMainScreenNoteFeaturesFromOtherFlavor, tvMainScreenNoteLocationImpossibleBlameGoogle, tvMainScreenNoteNews, tvlockSoundDuration; private static boolean updateNoteDisplayed = false; @@ -82,6 +82,12 @@ public class ActivityMainScreen extends ActivityGeneric tvlockSoundDuration = (TextView)findViewById(R.id.tvlockSoundDuration); tbLockSound = (ToggleButton) findViewById(R.id.tbLockSound); toggleService = (ToggleButton) findViewById(R.id.tbArmMastListener); + + bDonate = (Button)findViewById(R.id.bDonate); + + if(!BuildConfig.FLAVOR.equalsIgnoreCase("googlePlayFlavor")) + bDonate.setVisibility(View.VISIBLE); + toggleService.setChecked(AutomationService.isMyServiceRunning(this)); toggleService.setOnCheckedChangeListener(new OnCheckedChangeListener() { @@ -111,6 +117,18 @@ public class ActivityMainScreen extends ActivityGeneric } }); + bDonate.setOnClickListener(new OnClickListener() + { + @Override + public void onClick(View v) + { + String privacyPolicyUrl = "https://server47.de/donate"; + + Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(privacyPolicyUrl)); + startActivity(browserIntent); + } + }); + tbLockSound.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override diff --git a/app/src/main/java/com/jens/automation2/XmlFileInterface.java b/app/src/main/java/com/jens/automation2/XmlFileInterface.java index 5c469307..303633f3 100644 --- a/app/src/main/java/com/jens/automation2/XmlFileInterface.java +++ b/app/src/main/java/com/jens/automation2/XmlFileInterface.java @@ -819,7 +819,15 @@ public class XmlFileInterface // Starts by looking for the entry tag if (name.equals("Trigger")) { - triggerCollection.add(readTrigger(parser)); + try + { + triggerCollection.add(readTrigger(parser)); + } + catch (IllegalArgumentException | NullPointerException e) + { + Miscellaneous.logEvent("e", "XMLFileInterface", "Unknown trigger found in config file. File was probably created by a newer program version. Details: " + Log.getStackTraceString(e), 1); + Miscellaneous.messageBox(context.getString(R.string.error), context.getString(R.string.elementSkipped), context).show(); + } } else { @@ -1055,7 +1063,15 @@ public class XmlFileInterface // Starts by looking for the entry tag if (name.equals("Action")) { - actionCollection.add(readAction(parser)); + try + { + actionCollection.add(readAction(parser)); + } + catch (IllegalArgumentException | NullPointerException e) + { + Miscellaneous.logEvent("e", "XMLFileInterface", "Unknown action found in config file. File was probably created by a newer program version. Details: " + Log.getStackTraceString(e), 1); + Miscellaneous.messageBox(context.getString(R.string.error), context.getString(R.string.elementSkipped), context).show(); + } } else { @@ -1064,7 +1080,6 @@ public class XmlFileInterface } return (actionCollection); } - private static Action readAction(XmlPullParser parser) throws IOException, XmlPullParserException { diff --git a/app/src/main/res/layout/main_overview_layout.xml b/app/src/main/res/layout/main_overview_layout.xml index c300af40..a62946d4 100644 --- a/app/src/main/res/layout/main_overview_layout.xml +++ b/app/src/main/res/layout/main_overview_layout.xml @@ -332,6 +332,14 @@ android:layout_height="wrap_content" android:layout_gravity="top" android:text="@string/settings" /> + +