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

Commit

Permalink
Merge pull request #116 from X1nto/master
Browse files Browse the repository at this point in the history
Fixed microg icon unhiding on huawei
  • Loading branch information
KevinX8 authored Mar 16, 2021
2 parents 3e98b98 + c7eee4f commit 8ad8ea4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,7 @@ class SettingsFragment : ResourceSettingsFragment() {
findPreference<SwitchPreferenceCompat>(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 {
Expand Down
15 changes: 15 additions & 0 deletions play-services-core/src/main/kotlin/org/microg/gms/ui/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() {

Expand Down

0 comments on commit 8ad8ea4

Please sign in to comment.