Skip to content

Commit

Permalink
improve naming
Browse files Browse the repository at this point in the history
  • Loading branch information
ILoveOpenSourceApplications committed Jul 30, 2024
1 parent 81ead92 commit 39c349b
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object SettingsContract {
const val SECURITY_TOKEN = "securityToken"
const val VERSION_INFO = "versionInfo"
const val DEVICE_DATA_VERSION_INFO = "deviceDataVersionInfo"
const val HIDE_LAUNCHER_ICON = "hideLauncherIcon"
const val HIDE_APP_ICON = "hideAppIcon"

val PROJECTION = arrayOf(
ENABLED,
Expand All @@ -44,7 +44,7 @@ object SettingsContract {
SECURITY_TOKEN,
VERSION_INFO,
DEVICE_DATA_VERSION_INFO,
HIDE_LAUNCHER_ICON,
HIDE_APP_ICON,
)
const val PREFERENCES_NAME = "checkin"
const val INITIAL_DIGEST = "1-929a0dca0eee55513280171a8585da7dcd3700f8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class SettingsProvider : ContentProvider() {
CheckIn.SECURITY_TOKEN -> checkInPrefs.getLong(key, 0)
CheckIn.VERSION_INFO -> checkInPrefs.getString(key, "") ?: ""
CheckIn.DEVICE_DATA_VERSION_INFO -> checkInPrefs.getString(key, "") ?: ""
CheckIn.HIDE_LAUNCHER_ICON -> getSettingsBoolean(key, true)
CheckIn.HIDE_APP_ICON -> getSettingsBoolean(key, true)
else -> throw IllegalArgumentException()
}
}
Expand All @@ -135,9 +135,9 @@ class SettingsProvider : ContentProvider() {
// special case: not saved in checkInPrefs
updateCheckInEnabled(value as Boolean)
}
if (key == CheckIn.HIDE_LAUNCHER_ICON) {
if (key == CheckIn.HIDE_APP_ICON) {
// special case: not saved in checkInPrefs
updateHideLauncherIcon(value as Boolean)
updateHideAppIcon(value as Boolean)
}
when (key) {
CheckIn.ANDROID_ID -> editor.putLong(key, value as Long)
Expand All @@ -157,9 +157,9 @@ class SettingsProvider : ContentProvider() {
.apply()
}

private fun updateHideLauncherIcon(enabled: Boolean) {
private fun updateHideAppIcon(enabled: Boolean) {
preferences.edit()
.putBoolean(CheckIn.HIDE_LAUNCHER_ICON, enabled)
.putBoolean(CheckIn.HIDE_APP_ICON, enabled)
.apply()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fun NavController.navigate(context: Context, @IdRes resId: Int, args: Bundle? =
} else null)
}

fun Context.hideIcon(hide: Boolean) {
fun Context.hideAppIcon(hide: Boolean) {
packageManager.setComponentEnabledSetting(
ComponentName.createRelative(this, "org.microg.gms.ui.SettingsActivity"),
when (hide) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +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.hideLauncherIcon;
import static org.microg.gms.checkin.CheckinPreferences.hideAppIcon;
import static org.microg.gms.common.Constants.GMS_PACKAGE_NAME;
import static org.microg.gms.common.Constants.GMS_VERSION_CODE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ object CheckinPreferences {
}
}
@JvmStatic
fun hideLauncherIcon(context: Context, enabled: Boolean) {
fun hideAppIcon(context: Context, enabled: Boolean) {
SettingsContract.setSettings(context, CheckIn.getContentUri(context)) {
put(CheckIn.HIDE_LAUNCHER_ICON, enabled)
put(CheckIn.HIDE_APP_ICON, enabled)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ class SettingsFragment : ResourceSettingsFragment() {
}
summary = getString(org.microg.tools.ui.R.string.about_version_str, AboutFragment.getSelfVersion(context))
}
findPreference<SwitchPreferenceCompat>(SettingsContract.CheckIn.HIDE_LAUNCHER_ICON)!!.apply {

findPreference<SwitchPreferenceCompat>(SettingsContract.CheckIn.HIDE_APP_ICON)!!.apply {
setOnPreferenceChangeListener { _, newValue ->
requireActivity().hideIcon(newValue as Boolean)
requireActivity().hideAppIcon(newValue as Boolean)
true
}

Expand Down
3 changes: 2 additions & 1 deletion play-services-core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ This can take a couple of minutes."</string>

<string name="pref_about_title">About microG Services</string>
<string name="pref_about_summary">Version information and used libraries</string>
<string name="pref_hide_launcher_icon">Hide icon from launcher</string>
<string name="pref_hide_app_icon_title">Hide app icon</string>
<string name="pref_hide_app_icon_summary">Hides app icon from the launcher</string>

<string name="gcm_app_error_unregistering">Error unregistering</string>
<string name="gcm_app_not_installed_anymore">No longer installed</string>
Expand Down
6 changes: 3 additions & 3 deletions play-services-core/src/main/res/xml/preferences_start.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@
</PreferenceCategory>
<PreferenceCategory android:layout="@layout/preference_category_no_label" android:key="prefcat_footer">
<SwitchPreferenceCompat
android:key="hideLauncherIcon"
android:title="@string/pref_hide_launcher_icon"
android:icon="@drawable/ic_hide_launcher_icon"
android:key="hideAppIcon"
android:title="@string/pref_hide_app_icon"
android:icon="@drawable/ic_hide_app_icon"
android:defaultValue="false"/>
<Preference
android:icon="@drawable/ic_info_outline"
Expand Down

0 comments on commit 39c349b

Please sign in to comment.