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 659e1fdd7b..4b5767ebd0 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 @@ -58,6 +58,7 @@ import org.microg.gms.common.HttpFormClient; import org.microg.gms.common.Utils; import org.microg.gms.people.PeopleManager; +import org.microg.gms.ui.UtilsKt; import java.io.IOException; import java.util.Locale; @@ -147,8 +148,6 @@ public void onPageFinished(WebView view, String url) { } else { retrieveRtToken(getIntent().getStringExtra(EXTRA_TOKEN)); } - } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - init(); } else { setMessage(R.string.auth_before_connect); setSpoofButtonText(R.string.brand_spoof_button); @@ -162,7 +161,10 @@ protected void onHuaweiButtonClicked() { super.onHuaweiButtonClicked(); state++; if (state == 1) { - PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean("pref_hide_launcher_icon", false).apply(); + if (SDK_INT >= Build.VERSION_CODES.M) { + PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean("pref_hide_launcher_icon", false).apply(); + UtilsKt.hideIcon(this, false); + } PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean(HuaweiButtonPreference, true).apply(); if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(LoginButtonPreference, true)) { LastCheckinInfo.ClearCheckinInfo(this); 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 bdc16d5985..141b33f546 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 @@ -55,14 +55,7 @@ class SettingsFragment : ResourceSettingsFragment() { findPreference(PREF_CAST_HIDE_LAUNCHER_ICON)?.apply { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { setOnPreferenceChangeListener { _, newValue -> - pm.setComponentEnabledSetting( - ComponentName.createRelative(requireActivity(), "org.microg.gms.ui.SettingsActivityLauncher"), - when (newValue) { - true -> PackageManager.COMPONENT_ENABLED_STATE_DISABLED - else -> PackageManager.COMPONENT_ENABLED_STATE_ENABLED - }, - PackageManager.DONT_KILL_APP - ) + requireActivity().hideIcon(newValue as Boolean) true } } else { diff --git a/play-services-core/src/main/kotlin/org/microg/gms/ui/Utils.kt b/play-services-core/src/main/kotlin/org/microg/gms/ui/Utils.kt index 69d526d7b2..5cfd2bfa9a 100644 --- a/play-services-core/src/main/kotlin/org/microg/gms/ui/Utils.kt +++ b/play-services-core/src/main/kotlin/org/microg/gms/ui/Utils.kt @@ -5,13 +5,16 @@ package org.microg.gms.ui +import android.content.ComponentName import android.content.Context import android.content.pm.ApplicationInfo import android.content.pm.PackageManager +import android.os.Build import android.os.Bundle import android.provider.Settings import android.util.Log import androidx.annotation.IdRes +import androidx.annotation.RequiresApi import androidx.navigation.NavController import androidx.navigation.navOptions import androidx.navigation.ui.R @@ -36,6 +39,18 @@ fun NavController.navigate(context: Context, @IdRes resId: Int, args: Bundle? = } else null) } +@RequiresApi(Build.VERSION_CODES.M) +fun Context.hideIcon(hide: Boolean) { + packageManager.setComponentEnabledSetting( + ComponentName.createRelative(this, "org.microg.gms.ui.SettingsActivityLauncher"), + when (hide) { + true -> PackageManager.COMPONENT_ENABLED_STATE_DISABLED + false -> PackageManager.COMPONENT_ENABLED_STATE_ENABLED + }, + PackageManager.DONT_KILL_APP + ) +} + val Context.systemAnimationsEnabled: Boolean get() {