Skip to content

Commit

Permalink
Add dialog to inform user about minus services
Browse files Browse the repository at this point in the history
  • Loading branch information
p1gp1g committed Feb 25, 2024
1 parent dbdeccb commit 07c9829
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,29 +1,53 @@
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;
import androidx.navigation.fragment.NavHostFragment;
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;

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);
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions play-services-core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -241,4 +241,7 @@ This can take a couple of minutes."</string>

<string name="feedback_disabled">Feedback currently not possible</string>

<string name="minus_dialog_information">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.</string>
<string name="minus_dialog_information_ack">I understand</string>

</resources>

0 comments on commit 07c9829

Please sign in to comment.