0
0
Fork 0
mirror of https://github.com/YTVanced/VancedMicroG synced 2024-12-04 00:37:27 +00:00

unhide microg icon on huawei

This commit is contained in:
X1nto 2021-03-16 09:30:07 +04:00
parent f779e2593e
commit c7eee4fab1
3 changed files with 21 additions and 11 deletions

View file

@ -58,6 +58,7 @@ import org.microg.gms.checkin.LastCheckinInfo;
import org.microg.gms.common.HttpFormClient; import org.microg.gms.common.HttpFormClient;
import org.microg.gms.common.Utils; import org.microg.gms.common.Utils;
import org.microg.gms.people.PeopleManager; import org.microg.gms.people.PeopleManager;
import org.microg.gms.ui.UtilsKt;
import java.io.IOException; import java.io.IOException;
import java.util.Locale; import java.util.Locale;
@ -147,8 +148,6 @@ public class LoginActivity extends AssistantActivity {
} else { } else {
retrieveRtToken(getIntent().getStringExtra(EXTRA_TOKEN)); retrieveRtToken(getIntent().getStringExtra(EXTRA_TOKEN));
} }
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
init();
} else { } else {
setMessage(R.string.auth_before_connect); setMessage(R.string.auth_before_connect);
setSpoofButtonText(R.string.brand_spoof_button); setSpoofButtonText(R.string.brand_spoof_button);
@ -162,7 +161,10 @@ public class LoginActivity extends AssistantActivity {
super.onHuaweiButtonClicked(); super.onHuaweiButtonClicked();
state++; state++;
if (state == 1) { 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(); PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean(HuaweiButtonPreference, true).apply();
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(LoginButtonPreference, true)) { if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(LoginButtonPreference, true)) {
LastCheckinInfo.ClearCheckinInfo(this); LastCheckinInfo.ClearCheckinInfo(this);

View file

@ -55,14 +55,7 @@ class SettingsFragment : ResourceSettingsFragment() {
findPreference<SwitchPreferenceCompat>(PREF_CAST_HIDE_LAUNCHER_ICON)?.apply { findPreference<SwitchPreferenceCompat>(PREF_CAST_HIDE_LAUNCHER_ICON)?.apply {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
setOnPreferenceChangeListener { _, newValue -> setOnPreferenceChangeListener { _, newValue ->
pm.setComponentEnabledSetting( requireActivity().hideIcon(newValue as Boolean)
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
)
true true
} }
} else { } else {

View file

@ -5,13 +5,16 @@
package org.microg.gms.ui package org.microg.gms.ui
import android.content.ComponentName
import android.content.Context import android.content.Context
import android.content.pm.ApplicationInfo import android.content.pm.ApplicationInfo
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.provider.Settings import android.provider.Settings
import android.util.Log import android.util.Log
import androidx.annotation.IdRes import androidx.annotation.IdRes
import androidx.annotation.RequiresApi
import androidx.navigation.NavController import androidx.navigation.NavController
import androidx.navigation.navOptions import androidx.navigation.navOptions
import androidx.navigation.ui.R import androidx.navigation.ui.R
@ -36,6 +39,18 @@ fun NavController.navigate(context: Context, @IdRes resId: Int, args: Bundle? =
} else null) } 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 val Context.systemAnimationsEnabled: Boolean
get() { get() {