Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Hide app icon option #2462

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

ILoveOpenSourceApplications
Copy link

@ILoveOpenSourceApplications ILoveOpenSourceApplications commented Jul 30, 2024

Adds an option to hide icon from launcher.

Resolves #2263, resolves #2266 as well as resolves #2361.

Credits: @rufusin

@ILoveOpenSourceApplications ILoveOpenSourceApplications changed the title Add Hide icon from launcher option Add Hide app icon option Jul 30, 2024
@ale5000-git
Copy link
Member

The icon should be enabled by default.

These two should seems to do the opposite:
CheckIn.HIDE_APP_ICON -> getSettingsBoolean(key, true)
android:enabled="false"

@ale5000-git
Copy link
Member

ale5000-git commented Jul 30, 2024

Also in my opinion the variable name seems a bit strange:
private fun updateHideAppIcon(enabled: Boolean)

Personally I would choose
private fun updateHideAppIcon(hide: Boolean)
or
private fun updateShowAppIcon(enabled: Boolean)

@ale5000-git
Copy link
Member

ale5000-git commented Jul 31, 2024

The icon should be enabled by default.

android:defaultValue="false"/>

The option in microG settings is disabled so the icon should be enabled by default, but you disable the icon in reality here:
https://github.com/microg/GmsCore/pull/2462/files#diff-d629a5125b2f479f4916b4b963c3ed5bc5b8c8e79951dfb805bc1fa4a7384624R597-R605

        <activity
            android:name="org.microg.gms.ui.MainSettingsActivity"
            android:enabled="false"

Edit: Now that I read better, here you don't disable the icon but the MainSettingsActivity so you actually break the microG settings.
This one mustn't be disabled in any case.

This shouldn't be touched => org.microg.gms.ui.MainSettingsActivity
This can be disabled (but not by default) => org.microg.gms.ui.SettingsActivity

@ale5000-git
Copy link
Member

ale5000-git commented Jul 31, 2024

Also in my opinion the variable name seems a bit strange: private fun updateHideAppIcon(enabled: Boolean)

May I ask what the variable does here so that I could understand which one from the below two would make sense?

This is just personal opinion but in this case:
updateHideAppIcon(enabled=true)
when enabled = true, the icon is hidden so not enabled.

instead with this:
updateHideAppIcon(hide=true)
when hide = true, the icon is hidden so not enabled.

So actually it is the same in practice but I think the first is just more confusing but it is still personal preference.

@mar-v-in What do you think?

@ILoveOpenSourceApplications
Copy link
Author

@ale5000-git, I believe I have addressed all the requested changes in this pull request. Please let me know if there are any additional modifications or suggestions.
@mar-v-in, your input would also be greatly appreciated.
Thank you for your time and consideration.

Copy link
Member

@mar-v-in mar-v-in left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comments on the code. Also, please add a way to hide this setting on the Huawei build flavor, as devices with Huawei OS that support microG, the microG settings is automatically hidden from launcher.

@@ -75,6 +76,7 @@
import static android.view.View.VISIBLE;
import static android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT;
import static org.microg.gms.auth.AuthPrefs.isAuthVisible;
import static org.microg.gms.checkin.CheckinPreferences.hideAppIcon;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You add new imports without any need. Please remove them again

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

android:icon="@drawable/ic_hide_app_icon"
android:key="hideAppIcon"
android:summary="@string/pref_hide_app_icon_summary"
android:title="@string/pref_hide_app_icon_title" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preferences should not be directly modified from the :ui process as shared preferences are not safe for multi-process use. That's why we generally use the SettingsProvider to store settings.

However, in this case, the settings provider is not needed, as the ground truth of the component enabled state is in the PackageManager. With your code, if someone enables or disables the component without using this setting (e.g. by directly invoking pm disable via adb), the setting would no longer match the actual live state.

I suggest you make the setting non-persistent (by settings android:persistent="false") and configure it from code by taking the value from getComponentEnabledSetting when realizing the setting.

@@ -65,9 +65,15 @@
android:title="@string/service_name_location"/>
</PreferenceCategory>
<PreferenceCategory android:layout="@layout/preference_category_no_label" android:key="prefcat_footer">
<SwitchPreferenceCompat
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this setting is so important that it deserves a prime location at the top level settings dialog. I suggest to create a new section for these kind of things, although I don't know how to name it or what else would belong there.

Copy link
Member

@ale5000-git ale5000-git Oct 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mar-v-in
Some ideas:

  1. Other settings
  2. Minor settings
  3. Trivial settings
  4. UI settings

play-services-core/src/main/res/xml/preferences_start.xml Outdated Show resolved Hide resolved
@@ -34,6 +34,7 @@ object SettingsContract {
const val SECURITY_TOKEN = "securityToken"
const val VERSION_INFO = "versionInfo"
const val DEVICE_DATA_VERSION_INFO = "deviceDataVersionInfo"
const val HIDE_APP_ICON = "hideAppIcon"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not belong into the Checkin settings contract. In fact it's not needed at all in SettingsContract or SettingsProvider, see my other comment

@ale5000-git
Copy link
Member

@mar-v-in
I think it would also be nice to be able to optionally set the default status in /system/etc/microg.xml, so ROM authors and flashable ZIPs can set it without the need to mess with it in other ways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants