From 64d1aec910f607663b87943229a7096c65fb4b1c Mon Sep 17 00:00:00 2001 From: jens Date: Thu, 18 Mar 2021 20:00:19 +0100 Subject: [PATCH] Google shit again. --- .../jens/automation2/ActivityMainScreen.java | 68 +++++++++++++------ .../jens/automation2/AutomationService.java | 16 ++--- .../com/jens/automation2/Miscellaneous.java | 16 +++++ .../main/res/layout/main_overview_layout.xml | 19 +++++- app/src/main/res/values-de/strings.xml | 2 +- app/src/main/res/values-es/strings.xml | 2 +- app/src/main/res/values-it/strings.xml | 2 +- app/src/main/res/values/strings.xml | 4 +- 8 files changed, 94 insertions(+), 35 deletions(-) diff --git a/app/src/main/java/com/jens/automation2/ActivityMainScreen.java b/app/src/main/java/com/jens/automation2/ActivityMainScreen.java index aaba214a..37d3d972 100644 --- a/app/src/main/java/com/jens/automation2/ActivityMainScreen.java +++ b/app/src/main/java/com/jens/automation2/ActivityMainScreen.java @@ -2,13 +2,13 @@ package com.jens.automation2; import android.annotation.SuppressLint; import android.app.AlertDialog; +import android.app.PendingIntent; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; import android.os.Build; import android.os.Bundle; -import android.os.StrictMode; import android.util.Log; import android.view.MotionEvent; import android.view.View; @@ -29,7 +29,6 @@ import com.jens.automation2.AutomationService.serviceCommands; import com.jens.automation2.Trigger.Trigger_Enum; import com.jens.automation2.location.LocationProvider; -import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Calendar; @@ -41,7 +40,7 @@ public class ActivityMainScreen extends ActivityGeneric private static ActivityMainScreen activityMainScreenInstance = null; private ToggleButton toggleService, tbLockSound; private Button bShowHelp, bPrivacy, bSettingsErase, bSettingsSetToDefault, bVolumeTest, bAddSoundLockTIme; - private TextView tvActivePoi, tvClosestPoi, tvLastRule, tvMainScreenNote1, tvMainScreenNote2, tvMainScreenNote3, tvlockSoundDuration; + private TextView tvActivePoi, tvClosestPoi, tvLastRule, tvMainScreenNotePermissions, tvMainScreenNoteFeaturesFromOtherFlavor, tvMainScreenNoteLocationImpossibleBlameGoogle, tvMainScreenNoteNews, tvlockSoundDuration; private ListView lvRuleHistory; private ArrayAdapter ruleHistoryListViewAdapter; @@ -70,9 +69,10 @@ public class ActivityMainScreen extends ActivityGeneric tvClosestPoi = (TextView) findViewById(R.id.tvClosestPoi); lvRuleHistory = (ListView) findViewById(R.id.lvRuleHistory); tvLastRule = (TextView) findViewById(R.id.tvTimeFrameHelpText); - tvMainScreenNote1 = (TextView) findViewById(R.id.tvMainScreenNote1); - tvMainScreenNote2 = (TextView) findViewById(R.id.tvMainScreenNote2); - tvMainScreenNote3 = (TextView) findViewById(R.id.tvMainScreenNote3); + tvMainScreenNotePermissions = (TextView) findViewById(R.id.tvMainScreenNotePermissions); + tvMainScreenNoteFeaturesFromOtherFlavor = (TextView) findViewById(R.id.tvMainScreenNoteFeaturesFromOtherFlavor); + tvMainScreenNoteLocationImpossibleBlameGoogle = (TextView) findViewById(R.id.tvMainScreenNoteLocationImpossibleBlameGoogle); + tvMainScreenNoteNews = (TextView) findViewById(R.id.tvMainScreenNoteNews); tvlockSoundDuration = (TextView)findViewById(R.id.tvlockSoundDuration); tbLockSound = (ToggleButton) findViewById(R.id.tbLockSound); toggleService = (ToggleButton) findViewById(R.id.tbArmMastListener); @@ -95,7 +95,7 @@ public class ActivityMainScreen extends ActivityGeneric } }); - tvMainScreenNote1.setOnClickListener(new OnClickListener() + tvMainScreenNotePermissions.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) @@ -291,24 +291,54 @@ public class ActivityMainScreen extends ActivityGeneric { if(ActivityPermissions.needMorePermissions(activityMainScreenInstance)) { - activityMainScreenInstance.tvMainScreenNote1.setText(R.string.mainScreenPermissionNote); - activityMainScreenInstance.tvMainScreenNote1.setVisibility(View.VISIBLE); + activityMainScreenInstance.tvMainScreenNotePermissions.setText(R.string.mainScreenPermissionNote); + activityMainScreenInstance.tvMainScreenNotePermissions.setVisibility(View.VISIBLE); } else { - activityMainScreenInstance.tvMainScreenNote1.setText(""); - activityMainScreenInstance.tvMainScreenNote1.setVisibility(View.GONE); + activityMainScreenInstance.tvMainScreenNotePermissions.setText(""); + activityMainScreenInstance.tvMainScreenNotePermissions.setVisibility(View.GONE); } if(Miscellaneous.restrictedFeaturesConfigured()) { - activityMainScreenInstance.tvMainScreenNote2.setText(R.string.settingsReferringToRestrictedFeatures); - activityMainScreenInstance.tvMainScreenNote2.setVisibility(View.VISIBLE); + activityMainScreenInstance.tvMainScreenNoteFeaturesFromOtherFlavor.setText(R.string.settingsReferringToRestrictedFeatures); + activityMainScreenInstance.tvMainScreenNoteFeaturesFromOtherFlavor.setVisibility(View.VISIBLE); } else { - activityMainScreenInstance.tvMainScreenNote2.setText(""); - activityMainScreenInstance.tvMainScreenNote2.setVisibility(View.GONE); + activityMainScreenInstance.tvMainScreenNoteFeaturesFromOtherFlavor.setText(""); + activityMainScreenInstance.tvMainScreenNoteFeaturesFromOtherFlavor.setVisibility(View.GONE); + } + + if(Miscellaneous.googleToBlameForLocation()) + { +// Intent intent = new Intent(AutomationService.this, ActivityDisplayLongMessage.class); +// intent.putExtra("longMessage", getResources().getString(R.string.locationEngineDisabledLong)); +// PendingIntent pi = PendingIntent.getActivity(AutomationService.this, 0, intent, 0); +// if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) +// Miscellaneous.createDismissableNotificationWithDelay(2200, getResources().getString(R.string.featuresDisabled), notificationIdLocationRestriction, pi); +// else +// Miscellaneous.createDismissableNotification(getResources().getString(R.string.featuresDisabled), notificationIdLocationRestriction, pi); + + activityMainScreenInstance.tvMainScreenNoteLocationImpossibleBlameGoogle.setText(R.string.locationEngineDisabledShort); + activityMainScreenInstance.tvMainScreenNoteLocationImpossibleBlameGoogle.setVisibility(View.VISIBLE); + activityMainScreenInstance.tvMainScreenNoteLocationImpossibleBlameGoogle.setOnClickListener(new OnClickListener() + { + @Override + public void onClick(View v) + { + Intent intent = new Intent(Miscellaneous.getAnyContext(), ActivityDisplayLongMessage.class); + intent.putExtra("longMessage", Miscellaneous.getAnyContext().getResources().getString(R.string.locationEngineDisabledLong)); + Miscellaneous.getAnyContext().startActivity(intent); + } + }); + } + else + { + activityMainScreenInstance.tvMainScreenNoteLocationImpossibleBlameGoogle.setText(""); + activityMainScreenInstance.tvMainScreenNoteLocationImpossibleBlameGoogle.setVisibility(View.GONE); + activityMainScreenInstance.tvMainScreenNoteLocationImpossibleBlameGoogle.setOnClickListener(null); } if (AutomationService.isMyServiceRunning(activityMainScreenInstance)) @@ -612,13 +642,13 @@ public class ActivityMainScreen extends ActivityGeneric { if (newsToDisplay.size() > 0) { - activityMainScreenInstance.tvMainScreenNote3.setText(HtmlCompat.fromHtml(newsToDisplay.get(0).toStringHtml(), 0)); - activityMainScreenInstance.tvMainScreenNote3.setVisibility(View.VISIBLE); + activityMainScreenInstance.tvMainScreenNoteNews.setText(HtmlCompat.fromHtml(newsToDisplay.get(0).toStringHtml(), 0)); + activityMainScreenInstance.tvMainScreenNoteNews.setVisibility(View.VISIBLE); } else { - activityMainScreenInstance.tvMainScreenNote3.setText(""); - activityMainScreenInstance.tvMainScreenNote3.setVisibility(View.GONE); + activityMainScreenInstance.tvMainScreenNoteNews.setText(""); + activityMainScreenInstance.tvMainScreenNoteNews.setVisibility(View.GONE); } } catch(Exception e) diff --git a/app/src/main/java/com/jens/automation2/AutomationService.java b/app/src/main/java/com/jens/automation2/AutomationService.java index c40bae19..c21e3845 100644 --- a/app/src/main/java/com/jens/automation2/AutomationService.java +++ b/app/src/main/java/com/jens/automation2/AutomationService.java @@ -367,9 +367,9 @@ public class AutomationService extends Service implements OnInitListener Intent intent = new Intent(AutomationService.this, ActivityPermissions.class); PendingIntent pi = PendingIntent.getActivity(AutomationService.this, 0, intent, 0); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) - Miscellaneous.createDismissableNotificationWithDelay(1010, getResources().getString(R.string.appRunningInLimitedMode), ActivityPermissions.notificationIdPermissions, pi); + Miscellaneous.createDismissableNotificationWithDelay(1010, getResources().getString(R.string.featuresDisabled), ActivityPermissions.notificationIdPermissions, pi); else - Miscellaneous.createDismissableNotification(getResources().getString(R.string.appRunningInLimitedMode), ActivityPermissions.notificationIdPermissions, pi); + Miscellaneous.createDismissableNotification(getResources().getString(R.string.featuresDisabled), ActivityPermissions.notificationIdPermissions, pi); } // else // Toast.makeText(Miscellaneous.getAnyContext(), "Have all required permissions.", Toast.LENGTH_LONG).show(); @@ -390,28 +390,28 @@ public class AutomationService extends Service implements OnInitListener PendingIntent pi = PendingIntent.getActivity(AutomationService.this, 0, intent, 0); // Miscellaneous.createDismissableNotification(getResources().getString(R.string.settingsReferringToRestrictedFeatures), ActivityPermissions.notificationIdPermissions, pi); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) - Miscellaneous.createDismissableNotificationWithDelay(3300, getResources().getString(R.string.settingsReferringToRestrictedFeatures), notificationIdRestrictions, pi); + Miscellaneous.createDismissableNotificationWithDelay(3300, getResources().getString(R.string.featuresDisabled), notificationIdRestrictions, pi); else - Miscellaneous.createDismissableNotification(getResources().getString(R.string.settingsReferringToRestrictedFeatures), notificationIdRestrictions, pi); + Miscellaneous.createDismissableNotification(getResources().getString(R.string.featuresDisabled), notificationIdRestrictions, pi); } } } protected void checkForMissingBackgroundLocationPermission() { + if(Miscellaneous.googleToBlameForLocation()) if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { if (BuildConfig.FLAVOR.equalsIgnoreCase("googlePlayFlavor")) { if (Rule.isAnyRuleUsing(Trigger_Enum.pointOfInterest)) { - Intent intent = new Intent(AutomationService.this, ActivityDisplayLongMessage.class); - intent.putExtra("longMessage", getResources().getString(R.string.locationEngineDisabledLong)); + Intent intent = new Intent(AutomationService.this, ActivityMainTabLayout.class); PendingIntent pi = PendingIntent.getActivity(AutomationService.this, 0, intent, 0); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) - Miscellaneous.createDismissableNotificationWithDelay(2200, getResources().getString(R.string.locationEngineDisabledShort), notificationIdLocationRestriction, pi); + Miscellaneous.createDismissableNotificationWithDelay(2200, getResources().getString(R.string.featuresDisabled), notificationIdLocationRestriction, pi); else - Miscellaneous.createDismissableNotification(getResources().getString(R.string.locationEngineDisabledShort), notificationIdLocationRestriction, pi); + Miscellaneous.createDismissableNotification(getResources().getString(R.string.featuresDisabled), notificationIdLocationRestriction, pi); } } } diff --git a/app/src/main/java/com/jens/automation2/Miscellaneous.java b/app/src/main/java/com/jens/automation2/Miscellaneous.java index ac6fe832..d55576cf 100644 --- a/app/src/main/java/com/jens/automation2/Miscellaneous.java +++ b/app/src/main/java/com/jens/automation2/Miscellaneous.java @@ -1186,4 +1186,20 @@ public class Miscellaneous extends Service return returnValue; } + + public static boolean googleToBlameForLocation() + { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) + { + if (BuildConfig.FLAVOR.equalsIgnoreCase("googlePlayFlavor")) + { + if (Rule.isAnyRuleUsing(Trigger.Trigger_Enum.pointOfInterest)) + { + return true; + } + } + } + + return false; + } } \ No newline at end of file diff --git a/app/src/main/res/layout/main_overview_layout.xml b/app/src/main/res/layout/main_overview_layout.xml index ebfaf3c1..fe44ecb1 100644 --- a/app/src/main/res/layout/main_overview_layout.xml +++ b/app/src/main/res/layout/main_overview_layout.xml @@ -27,7 +27,7 @@ + + Fortfahren Regel Einstellungen lesen und speichern - Die Anwendung läuft in einem eingeschränkten Modus, weil nicht alle benötigen Rechte genehmigt wurden. + WARNING: Funktionen wurden deaktiviert, Automation läuft in einem eingeschränkten Modus. Klicken Sie hier für mehr Informationen. Grün = aktiviert, rot = deaktiviert, gelb = nicht genügend Rechte Die Berechtigung Betriebssystemeinstellungen ändern zu können, wird benötigt (auch für einfache Dinge wie Bluetooth oder WLAN einschalten). Nach dem Klick auf "Fortfahren" öffnet sich ein Fenster, in dem Sie das für Automation aktivieren müssen. Drücken Sie dann auf Ihren "Zurück" Knopf. Anschließend werden in einem zweiten Dialog weitere Berechtigungen angefragt. diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 8ef9e62b..84724113 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -523,7 +523,7 @@ continue Rule Read and store settings - The app is running in limited mode because of lacking permissions. + : Features are disabled, Automation is running in limited mode. Click here for more information. Green = enabled, red = disabled, yellow = not enough permissions The permission to change some OS settings is required (even simple stuff like turn on bluetooth or wifi). After clicking "continue" a window will popup where you need to enable this for Automation. Then hit your "back" key. Further permissions will be requested in a second dialog afterwards. diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index e8cb49c1..2ace7671 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -82,7 +82,7 @@ qualsiasi numero qualsiasi wifi Automation richiede l’autorizzazione per archiviare e leggere le impostazioni e le regole. - L\'applicazione è in esecuzione in modalità limitata a causa di autorizzazioni mancanti. + L\'applicazione è in esecuzione in modalità limitata a causa di autorizzazioni mancanti. App avviata. App terminata. Automation diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 01ba3d29..1fa21f02 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -527,7 +527,7 @@ continue Rule Read and store settings - The app is running in limited mode because of lacking permissions. + WARNING: Features are disabled, Automation is running in limited mode. Click here for more information. Green = enabled, red = disabled, yellow = not enough permissions The permission to change some OS settings is required (even simple stuff like turn on bluetooth or wifi). After clicking "continue" a window will popup where you need to enable this for Automation. Then hit your "back" key. Further permissions will be requested in a second dialog afterwards. @@ -607,6 +607,6 @@ Announcements about this app only, we\'re probably talking about 1-2 per year, not more. Automation now uses another path to store your files. All your Automation-files have been moved here: \"%s\". The external storage permission is not required anymore; you can revoke it. It will be removed in a future version. Would you like to receive (only important) news about this app on the main screen? Those are downloaded from the developer\'s website. There will be no intrusive notification, just a text on the main screen when you open the app. - Location cannot be determined anymore. + Location cannot be determined anymore. Click here to find out why. Unfortunately your location cannot be determined anymore. A debt of gratitude is owed to Google for its infinite wisdom and amiableness.
Let me explain this further. Starting with Android 10 a new permission was introduced that is needed to determine your location in the background (which of course is required for an app like this). Whilst I consider that a good idea the chicanery it involves are not.
When developing an app you can try to qualify for this permission by abiding to a catalog of requirements. Unfortunately new versions of my app have been rejected over a period three months. I fulfilled all these requirements, Google\'s shitty development support claimed I would not. After giving them proof that I did after all - I got a response like \"I cannot help you anymore\". Eventually I gave up.
As a consequence the Google Play version can NOT use your location as a trigger anymore. The alternative would have been to have this application removed from the store entirely.
I\'m very sorry about that, but I\'ve tried my best arguing with a \"support\" that repeatedly failed to pass the Turing test.
The good news - You can still have it all:
Automation is now open source and can be found in F-Droid. That is an app store that really cares about your privacy - rather than just acting like that. Simply uninstall this app and install it again from F-Droid. Click here to find out more: https://f-droid.org/en/packages/com.jens.automation2/
\ No newline at end of file