mirror of
https://github.com/YTVanced/VancedMicroG
synced 2024-12-03 08:17:26 +00:00
Merge pull request #116 from X1nto/master
Fixed microg icon unhiding on huawei
This commit is contained in:
commit
8ad8ea42e6
3 changed files with 21 additions and 11 deletions
|
@ -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);
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
|
@ -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() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue