Skip to content
This repository was archived by the owner on Apr 6, 2024. It is now read-only.

Commit 8ad8ea4

Browse files
authored
Merge pull request #116 from X1nto/master
Fixed microg icon unhiding on huawei
2 parents 3e98b98 + c7eee4f commit 8ad8ea4

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

play-services-core/src/main/java/org/microg/gms/auth/login/LoginActivity.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import org.microg.gms.common.HttpFormClient;
5959
import org.microg.gms.common.Utils;
6060
import org.microg.gms.people.PeopleManager;
61+
import org.microg.gms.ui.UtilsKt;
6162

6263
import java.io.IOException;
6364
import java.util.Locale;
@@ -147,8 +148,6 @@ public void onPageFinished(WebView view, String url) {
147148
} else {
148149
retrieveRtToken(getIntent().getStringExtra(EXTRA_TOKEN));
149150
}
150-
} else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
151-
init();
152151
} else {
153152
setMessage(R.string.auth_before_connect);
154153
setSpoofButtonText(R.string.brand_spoof_button);
@@ -162,7 +161,10 @@ protected void onHuaweiButtonClicked() {
162161
super.onHuaweiButtonClicked();
163162
state++;
164163
if (state == 1) {
165-
PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean("pref_hide_launcher_icon", false).apply();
164+
if (SDK_INT >= Build.VERSION_CODES.M) {
165+
PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean("pref_hide_launcher_icon", false).apply();
166+
UtilsKt.hideIcon(this, false);
167+
}
166168
PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean(HuaweiButtonPreference, true).apply();
167169
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(LoginButtonPreference, true)) {
168170
LastCheckinInfo.ClearCheckinInfo(this);

play-services-core/src/main/kotlin/org/microg/gms/ui/SettingsFragment.kt

+1-8
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,7 @@ class SettingsFragment : ResourceSettingsFragment() {
5555
findPreference<SwitchPreferenceCompat>(PREF_CAST_HIDE_LAUNCHER_ICON)?.apply {
5656
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
5757
setOnPreferenceChangeListener { _, newValue ->
58-
pm.setComponentEnabledSetting(
59-
ComponentName.createRelative(requireActivity(), "org.microg.gms.ui.SettingsActivityLauncher"),
60-
when (newValue) {
61-
true -> PackageManager.COMPONENT_ENABLED_STATE_DISABLED
62-
else -> PackageManager.COMPONENT_ENABLED_STATE_ENABLED
63-
},
64-
PackageManager.DONT_KILL_APP
65-
)
58+
requireActivity().hideIcon(newValue as Boolean)
6659
true
6760
}
6861
} else {

play-services-core/src/main/kotlin/org/microg/gms/ui/Utils.kt

+15
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@
55

66
package org.microg.gms.ui
77

8+
import android.content.ComponentName
89
import android.content.Context
910
import android.content.pm.ApplicationInfo
1011
import android.content.pm.PackageManager
12+
import android.os.Build
1113
import android.os.Bundle
1214
import android.provider.Settings
1315
import android.util.Log
1416
import androidx.annotation.IdRes
17+
import androidx.annotation.RequiresApi
1518
import androidx.navigation.NavController
1619
import androidx.navigation.navOptions
1720
import androidx.navigation.ui.R
@@ -36,6 +39,18 @@ fun NavController.navigate(context: Context, @IdRes resId: Int, args: Bundle? =
3639
} else null)
3740
}
3841

42+
@RequiresApi(Build.VERSION_CODES.M)
43+
fun Context.hideIcon(hide: Boolean) {
44+
packageManager.setComponentEnabledSetting(
45+
ComponentName.createRelative(this, "org.microg.gms.ui.SettingsActivityLauncher"),
46+
when (hide) {
47+
true -> PackageManager.COMPONENT_ENABLED_STATE_DISABLED
48+
false -> PackageManager.COMPONENT_ENABLED_STATE_ENABLED
49+
},
50+
PackageManager.DONT_KILL_APP
51+
)
52+
}
53+
3954
val Context.systemAnimationsEnabled: Boolean
4055
get() {
4156

0 commit comments

Comments
 (0)