From eabf13a564616074b5a9a4ba55fa17cf165cd176 Mon Sep 17 00:00:00 2001 From: Oizaro <45825534+Oizaro@users.noreply.github.com> Date: Thu, 24 Sep 2020 21:13:01 +0200 Subject: [PATCH] Migrate spoof switch to button --- .../gms/auth/login/AssistantActivity.java | 18 ++++++++++++++++++ .../microg/gms/auth/login/LoginActivity.java | 16 +++++++++++++++- .../org/microg/gms/ui/SettingsFragment.kt | 5 ----- .../src/main/res/drawable/ic_brand_spoof.xml | 15 --------------- .../src/main/res/layout/login_assistant.xml | 16 ++++++++++++++++ .../src/main/res/values-in/strings.xml | 5 ++--- .../src/main/res/values-it/strings.xml | 5 ++--- .../src/main/res/values/strings.xml | 5 ++--- .../src/main/res/xml/preferences_start.xml | 6 ------ 9 files changed, 55 insertions(+), 36 deletions(-) delete mode 100644 play-services-core/src/main/res/drawable/ic_brand_spoof.xml diff --git a/play-services-core/src/main/java/org/microg/gms/auth/login/AssistantActivity.java b/play-services-core/src/main/java/org/microg/gms/auth/login/AssistantActivity.java index a967e501..7465d274 100644 --- a/play-services-core/src/main/java/org/microg/gms/auth/login/AssistantActivity.java +++ b/play-services-core/src/main/java/org/microg/gms/auth/login/AssistantActivity.java @@ -38,6 +38,7 @@ public abstract class AssistantActivity extends Activity { super.onCreate(savedInstanceState); setContentView(R.layout.login_assistant); formatTitle(); + findViewById(R.id.spoof_button).setOnClickListener(v -> onSpoofButtonClicked()); findViewById(R.id.next_button).setOnClickListener(v -> onNextButtonClicked()); findViewById(R.id.back_button).setOnClickListener(v -> onBackButtonClicked()); } @@ -53,6 +54,19 @@ public abstract class AssistantActivity extends Activity { } } + public void setSpoofButtonText(@StringRes int res) { + setSpoofButtonText(getText(res)); + } + + public void setSpoofButtonText(CharSequence text) { + if (text == null) { + findViewById(R.id.spoof_button).setVisibility(View.GONE); + } else { + findViewById(R.id.spoof_button).setVisibility(View.VISIBLE); + ((Button) findViewById(R.id.spoof_button)).setText(text); + } + } + public void setNextButtonText(@StringRes int res) { setNextButtonText(getText(res)); } @@ -79,6 +93,10 @@ public abstract class AssistantActivity extends Activity { } } + protected void onSpoofButtonClicked() { + + } + protected void onNextButtonClicked() { } diff --git a/play-services-core/src/main/java/org/microg/gms/auth/login/LoginActivity.java b/play-services-core/src/main/java/org/microg/gms/auth/login/LoginActivity.java index 9b9829a9..41c06620 100644 --- a/play-services-core/src/main/java/org/microg/gms/auth/login/LoginActivity.java +++ b/play-services-core/src/main/java/org/microg/gms/auth/login/LoginActivity.java @@ -50,6 +50,7 @@ import org.microg.gms.auth.AuthConstants; import org.microg.gms.auth.AuthManager; import org.microg.gms.auth.AuthRequest; import org.microg.gms.auth.AuthResponse; +import org.microg.gms.checkin.CheckinClient; import org.microg.gms.checkin.CheckinManager; import org.microg.gms.checkin.LastCheckinInfo; import org.microg.gms.common.HttpFormClient; @@ -146,10 +147,19 @@ public class LoginActivity extends AssistantActivity { } else { setMessage(R.string.auth_before_connect); setBackButtonText(android.R.string.cancel); + CheckinClient.brandSpoof = false; setNextButtonText(R.string.auth_sign_in); } } + @Override + protected void onSpoofButtonClicked() { + super.onSpoofButtonClicked(); + CheckinClient.brandSpoof = true; + state = 1; + init(); + } + @Override protected void onNextButtonClicked() { super.onNextButtonClicked(); @@ -174,6 +184,7 @@ public class LoginActivity extends AssistantActivity { private void init() { setTitle(R.string.just_a_sec); setBackButtonText(null); + setSpoofButtonText(null); setNextButtonText(null); View loading = getLayoutInflater().inflate(R.layout.login_assistant_loading, authContent, false); authContent.removeAllViews(); @@ -267,6 +278,7 @@ public class LoginActivity extends AssistantActivity { } } showError(R.string.auth_general_error_desc); + setSpoofButtonText(R.string.brand_spoof_button); } private void retrieveRtToken(String oAuthToken) { @@ -299,6 +311,7 @@ public class LoginActivity extends AssistantActivity { Log.w(TAG, "Account NOT created!"); runOnUiThread(() -> { showError(R.string.auth_general_error_desc); + setSpoofButtonText(R.string.brand_spoof_button); setNextButtonText(android.R.string.ok); }); state = -2; @@ -310,6 +323,7 @@ public class LoginActivity extends AssistantActivity { Log.w(TAG, "onException", exception); runOnUiThread(() -> { showError(R.string.auth_general_error_desc); + setSpoofButtonText(R.string.brand_spoof_button); setNextButtonText(android.R.string.ok); }); state = -2; @@ -340,12 +354,12 @@ public class LoginActivity extends AssistantActivity { checkin(true); finish(); } - @Override public void onException(Exception exception) { Log.w(TAG, "onException", exception); runOnUiThread(() -> { showError(R.string.auth_general_error_desc); + setSpoofButtonText(R.string.brand_spoof_button); setNextButtonText(android.R.string.ok); }); state = -2; diff --git a/play-services-core/src/main/kotlin/org/microg/gms/ui/SettingsFragment.kt b/play-services-core/src/main/kotlin/org/microg/gms/ui/SettingsFragment.kt index 384719cb..7800816d 100644 --- a/play-services-core/src/main/kotlin/org/microg/gms/ui/SettingsFragment.kt +++ b/play-services-core/src/main/kotlin/org/microg/gms/ui/SettingsFragment.kt @@ -49,11 +49,6 @@ class SettingsFragment : ResourceSettingsFragment() { PackageManager.DONT_KILL_APP) true } - - findPreference(BRAND_SPOOF_FIX_ENABLED)!!.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue -> - CheckinClient.brandSpoof = newValue as Boolean - true - } } override fun onResume() { diff --git a/play-services-core/src/main/res/drawable/ic_brand_spoof.xml b/play-services-core/src/main/res/drawable/ic_brand_spoof.xml deleted file mode 100644 index 909af61a..00000000 --- a/play-services-core/src/main/res/drawable/ic_brand_spoof.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/play-services-core/src/main/res/layout/login_assistant.xml b/play-services-core/src/main/res/layout/login_assistant.xml index a85dd5e3..134f0ea1 100755 --- a/play-services-core/src/main/res/layout/login_assistant.xml +++ b/play-services-core/src/main/res/layout/login_assistant.xml @@ -79,6 +79,22 @@ android:textAppearance="@style/TextAppearance.AppCompat.Body1" android:textSize="16sp"/> +