From 07c98298e00273611c7fa6a82e1de4b6320eac76 Mon Sep 17 00:00:00 2001 From: S1m Date: Sun, 25 Feb 2024 11:58:11 +0100 Subject: [PATCH] Add dialog to inform user about minus services --- .../microg/gms/ui/MainSettingsActivity.java | 25 +++++++++++++++++++ .../src/main/res/values/strings.xml | 3 +++ 2 files changed, 28 insertions(+) diff --git a/play-services-core/src/main/java/org/microg/gms/ui/MainSettingsActivity.java b/play-services-core/src/main/java/org/microg/gms/ui/MainSettingsActivity.java index f65717f38d..6389fe4499 100644 --- a/play-services-core/src/main/java/org/microg/gms/ui/MainSettingsActivity.java +++ b/play-services-core/src/main/java/org/microg/gms/ui/MainSettingsActivity.java @@ -1,9 +1,11 @@ package org.microg.gms.ui; import android.content.Intent; +import android.content.SharedPreferences; import android.os.Bundle; import androidx.annotation.Nullable; +import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.navigation.NavController; @@ -11,8 +13,11 @@ import androidx.navigation.ui.AppBarConfiguration; import androidx.navigation.ui.NavigationUI; +import com.google.android.gms.BuildConfig; import com.google.android.gms.R; import com.google.android.material.appbar.CollapsingToolbarLayout; + +import org.microg.gms.common.Constants; import org.microg.gms.ui.settings.SettingsProvider; import static org.microg.gms.ui.settings.SettingsProviderKt.getAllSettingsProviders; @@ -20,10 +25,29 @@ public class MainSettingsActivity extends AppCompatActivity { private AppBarConfiguration appBarConfiguration; + private static final String FirstRunMaster = "FirstRun"; + private static final String FirstRunPref = "FirstRun_pref"; + private NavController getNavController() { return ((NavHostFragment)getSupportFragmentManager().findFragmentById(R.id.navhost)).getNavController(); } + private void showDialogIfNeeded() { + SharedPreferences prefs = getSharedPreferences(FirstRunMaster, MODE_PRIVATE); + if (BuildConfig.APPLICATION_ID == Constants.GMS_MINUS_PACKAGE_NAME && + prefs.getBoolean(FirstRunPref, true)) { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + + builder.setMessage(R.string.minus_dialog_information) + .setTitle(R.string.gms_minus_app_name) + .setPositiveButton(R.string.minus_dialog_information_ack, (dialog, id) -> { + prefs.edit().putBoolean(FirstRunPref, false).apply(); + }); + + builder.create().show(); + } + } + @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -45,6 +69,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { appBarConfiguration = new AppBarConfiguration.Builder(getNavController().getGraph()).build(); NavigationUI.setupWithNavController(toolbarLayout, toolbar, getNavController(), appBarConfiguration); + showDialogIfNeeded(); } @Override diff --git a/play-services-core/src/main/res/values/strings.xml b/play-services-core/src/main/res/values/strings.xml index bab22f7b6b..c83ef40a00 100644 --- a/play-services-core/src/main/res/values/strings.xml +++ b/play-services-core/src/main/res/values/strings.xml @@ -241,4 +241,7 @@ This can take a couple of minutes." Feedback currently not possible + You are using the microG Minus services. Unlike the usual microG services, this flavor only works with apps using microG libraries, not those on Google Play. This means that most applications will ignore these services. + I understand +