0
0
Fork 0
mirror of https://github.com/YTVanced/VancedMicroG synced 2024-11-24 20:25:14 +00:00

Disable fragment transitions when system transitions/animations are disabled

Fixes #1119
This commit is contained in:
Marvin W 2020-08-05 15:48:51 +02:00
parent 0e7ae1d767
commit 2076970d40
No known key found for this signature in database
GPG key ID: 072E9235DB996F2A
11 changed files with 66 additions and 92 deletions

View file

@ -9,7 +9,7 @@ microG GmsCore is a FLOSS (Free/Libre Open Source Software) framework to allow a
License License
------- -------
Copyright 2013-2019 microG Project Team Copyright 2013-2020 microG Project Team
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

View file

@ -360,7 +360,7 @@
android:name="org.microg.gms.auth.login.LoginActivity" android:name="org.microg.gms.auth.login.LoginActivity"
android:configChanges="keyboardHidden|orientation|screenSize" android:configChanges="keyboardHidden|orientation|screenSize"
android:exported="true" android:exported="true"
android:theme="@style/LoginBlueTheme"> android:theme="@style/Theme.LoginBlue">
<intent-filter> <intent-filter>
<action android:name="com.google.android.gms.auth.login.LOGIN" /> <action android:name="com.google.android.gms.auth.login.LOGIN" />

View file

@ -4,6 +4,7 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.navigation.NavOptions;
import androidx.navigation.fragment.NavHostFragment; import androidx.navigation.fragment.NavHostFragment;
import com.google.android.gms.R; import com.google.android.gms.R;
@ -43,7 +44,7 @@ public class SettingsFragment extends ResourceSettingsFragment {
private void updateDetails() { private void updateDetails() {
findPreference(PREF_ABOUT).setSummary(getString(R.string.about_version_str, AboutFragment.getSelfVersion(getContext()))); findPreference(PREF_ABOUT).setSummary(getString(R.string.about_version_str, AboutFragment.getSelfVersion(getContext())));
findPreference(PREF_ABOUT).setOnPreferenceClickListener(preference -> { findPreference(PREF_ABOUT).setOnPreferenceClickListener(preference -> {
NavHostFragment.findNavController(SettingsFragment.this).navigate(R.id.openAbout); UtilsKt.navigate(NavHostFragment.findNavController(SettingsFragment.this), getContext(), R.id.openAbout, null);
return true; return true;
}); });
if (GcmPrefs.get(getContext()).isEnabled()) { if (GcmPrefs.get(getContext()).isEnabled()) {
@ -55,7 +56,7 @@ public class SettingsFragment extends ResourceSettingsFragment {
findPreference(PREF_GCM).setSummary(R.string.service_status_disabled_short); findPreference(PREF_GCM).setSummary(R.string.service_status_disabled_short);
} }
findPreference(PREF_GCM).setOnPreferenceClickListener(preference -> { findPreference(PREF_GCM).setOnPreferenceClickListener(preference -> {
NavHostFragment.findNavController(SettingsFragment.this).navigate(R.id.openGcmSettings); UtilsKt.navigate(NavHostFragment.findNavController(SettingsFragment.this), getContext(), R.id.openGcmSettings, null);
return true; return true;
}); });
@ -75,7 +76,7 @@ public class SettingsFragment extends ResourceSettingsFragment {
findPreference(PREF_SNET).setSummary(R.string.service_status_disabled_short); findPreference(PREF_SNET).setSummary(R.string.service_status_disabled_short);
} }
findPreference(PREF_SNET).setOnPreferenceClickListener(preference -> { findPreference(PREF_SNET).setOnPreferenceClickListener(preference -> {
NavHostFragment.findNavController(SettingsFragment.this).navigate(R.id.openSafetyNetSettings); UtilsKt.navigate(NavHostFragment.findNavController(SettingsFragment.this), getContext(), R.id.openSafetyNetSettings, null);
return true; return true;
}); });
@ -86,7 +87,7 @@ public class SettingsFragment extends ResourceSettingsFragment {
// Preferences.splitBackendString(unifiedNlPrefs.getGeocoderBackends()).length; // Preferences.splitBackendString(unifiedNlPrefs.getGeocoderBackends()).length;
// findPreference(PREF_UNIFIEDNLP).setSummary(getResources().getQuantityString(R.plurals.pref_unifiednlp_summary, backendCount, backendCount)); // findPreference(PREF_UNIFIEDNLP).setSummary(getResources().getQuantityString(R.plurals.pref_unifiednlp_summary, backendCount, backendCount));
findPreference(PREF_UNIFIEDNLP).setOnPreferenceClickListener(preference -> { findPreference(PREF_UNIFIEDNLP).setOnPreferenceClickListener(preference -> {
NavHostFragment.findNavController(SettingsFragment.this).navigate(R.id.openUnifiedNlpSettings); UtilsKt.navigate(NavHostFragment.findNavController(SettingsFragment.this), getContext(), R.id.openUnifiedNlpSettings, null);
return true; return true;
}); });
if (Build.VERSION.SDK_INT >= 21) { if (Build.VERSION.SDK_INT >= 21) {
@ -97,7 +98,7 @@ public class SettingsFragment extends ResourceSettingsFragment {
findPreference(PREF_EXPOSURE).setSummary(R.string.service_status_disabled_short); findPreference(PREF_EXPOSURE).setSummary(R.string.service_status_disabled_short);
} }
findPreference(PREF_EXPOSURE).setOnPreferenceClickListener(preference -> { findPreference(PREF_EXPOSURE).setOnPreferenceClickListener(preference -> {
NavHostFragment.findNavController(SettingsFragment.this).navigate(R.id.openExposureNotificationSettings); UtilsKt.navigate(NavHostFragment.findNavController(SettingsFragment.this), getContext(), R.id.openExposureNotificationSettings, null);
return true; return true;
}); });
} else { } else {
@ -107,7 +108,7 @@ public class SettingsFragment extends ResourceSettingsFragment {
boolean checkinEnabled = CheckinPrefs.get(getContext()).isEnabled(); boolean checkinEnabled = CheckinPrefs.get(getContext()).isEnabled();
findPreference(PREF_CHECKIN).setSummary(checkinEnabled ? R.string.service_status_enabled_short : R.string.service_status_disabled_short); findPreference(PREF_CHECKIN).setSummary(checkinEnabled ? R.string.service_status_enabled_short : R.string.service_status_disabled_short);
findPreference(PREF_CHECKIN).setOnPreferenceClickListener(preference -> { findPreference(PREF_CHECKIN).setOnPreferenceClickListener(preference -> {
NavHostFragment.findNavController(SettingsFragment.this).navigate(R.id.openCheckinSettings); UtilsKt.navigate(NavHostFragment.findNavController(SettingsFragment.this), getContext(), R.id.openCheckinSettings, null);
return true; return true;
}); });
} }

View file

@ -40,7 +40,7 @@ class ExposureNotificationsPreferencesFragment : PreferenceFragmentCompat() {
collectedRpis = preferenceScreen.findPreference("pref_exposure_collected_rpis") ?: collectedRpis collectedRpis = preferenceScreen.findPreference("pref_exposure_collected_rpis") ?: collectedRpis
advertisingId = preferenceScreen.findPreference("pref_exposure_advertising_id") ?: advertisingId advertisingId = preferenceScreen.findPreference("pref_exposure_advertising_id") ?: advertisingId
collectedRpis.onPreferenceClickListener = Preference.OnPreferenceClickListener { collectedRpis.onPreferenceClickListener = Preference.OnPreferenceClickListener {
findNavController().navigate(R.id.openExposureRpis) findNavController().navigate(requireContext(), R.id.openExposureRpis)
true true
} }
} }
@ -82,7 +82,7 @@ class ExposureNotificationsPreferencesFragment : PreferenceFragmentCompat() {
pref.title = applicationInfo.loadLabel(context.packageManager) pref.title = applicationInfo.loadLabel(context.packageManager)
pref.icon = applicationInfo.loadIcon(context.packageManager) pref.icon = applicationInfo.loadIcon(context.packageManager)
pref.onPreferenceClickListener = Preference.OnPreferenceClickListener { pref.onPreferenceClickListener = Preference.OnPreferenceClickListener {
findNavController().navigate(R.id.openExposureAppDetails, bundleOf( findNavController().navigate(requireContext(), R.id.openExposureAppDetails, bundleOf(
"package" to applicationInfo.packageName "package" to applicationInfo.packageName
)) ))
true true

View file

@ -67,7 +67,7 @@ class PushNotificationAllAppsFragment : PreferenceFragmentCompat() {
pref.icon = applicationInfo?.loadIcon(context.packageManager) pref.icon = applicationInfo?.loadIcon(context.packageManager)
?: AppCompatResources.getDrawable(context, android.R.mipmap.sym_def_app_icon) ?: AppCompatResources.getDrawable(context, android.R.mipmap.sym_def_app_icon)
pref.onPreferenceClickListener = Preference.OnPreferenceClickListener { pref.onPreferenceClickListener = Preference.OnPreferenceClickListener {
findNavController().navigate(R.id.openGcmAppDetailsFromAll, bundleOf( findNavController().navigate(requireContext(), R.id.openGcmAppDetailsFromAll, bundleOf(
"package" to app.packageName "package" to app.packageName
)) ))
true true

View file

@ -49,7 +49,7 @@ class PushNotificationFragment : Fragment(R.layout.push_notification_fragment) {
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) { return when (item.itemId) {
MENU_ADVANCED -> { MENU_ADVANCED -> {
findNavController().navigate(R.id.openGcmAdvancedSettings) findNavController().navigate(requireContext(), R.id.openGcmAdvancedSettings)
true true
} }
else -> super.onOptionsItemSelected(item) else -> super.onOptionsItemSelected(item)

View file

@ -47,7 +47,7 @@ class PushNotificationPreferencesFragment : PreferenceFragmentCompat() {
pushAppsAll = preferenceScreen.findPreference("pref_push_apps_all") ?: pushAppsAll pushAppsAll = preferenceScreen.findPreference("pref_push_apps_all") ?: pushAppsAll
pushAppsNone = preferenceScreen.findPreference("pref_push_apps_none") ?: pushAppsNone pushAppsNone = preferenceScreen.findPreference("pref_push_apps_none") ?: pushAppsNone
pushAppsAll.onPreferenceClickListener = Preference.OnPreferenceClickListener { pushAppsAll.onPreferenceClickListener = Preference.OnPreferenceClickListener {
findNavController().navigate(R.id.openAllGcmApps) findNavController().navigate(requireContext(), R.id.openAllGcmApps)
true true
} }
} }
@ -89,7 +89,7 @@ class PushNotificationPreferencesFragment : PreferenceFragmentCompat() {
pref.title = applicationInfo.loadLabel(context.packageManager) pref.title = applicationInfo.loadLabel(context.packageManager)
pref.icon = applicationInfo.loadIcon(context.packageManager) pref.icon = applicationInfo.loadIcon(context.packageManager)
pref.onPreferenceClickListener = Preference.OnPreferenceClickListener { pref.onPreferenceClickListener = Preference.OnPreferenceClickListener {
findNavController().navigate(R.id.openGcmAppDetails, bundleOf( findNavController().navigate(requireContext(), R.id.openGcmAppDetails, bundleOf(
"package" to app.packageName "package" to app.packageName
)) ))
true true

View file

@ -48,7 +48,7 @@ class SafetyNetFragment : Fragment(R.layout.safety_net_fragment) {
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) { return when (item.itemId) {
MENU_ADVANCED -> { MENU_ADVANCED -> {
findNavController().navigate(R.id.openSafetyNetAdvancedSettings) findNavController().navigate(requireContext(), R.id.openSafetyNetAdvancedSettings)
true true
} }
else -> super.onOptionsItemSelected(item) else -> super.onOptionsItemSelected(item)

View file

@ -5,9 +5,17 @@
package org.microg.gms.ui package org.microg.gms.ui
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.provider.Settings
import android.util.Log import android.util.Log
import androidx.annotation.IdRes
import androidx.navigation.NavController
import androidx.navigation.navOptions
import androidx.navigation.ui.R
fun PackageManager.getApplicationInfoIfExists(packageName: String?, flags: Int = 0): ApplicationInfo? = packageName?.let { fun PackageManager.getApplicationInfoIfExists(packageName: String?, flags: Int = 0): ApplicationInfo? = packageName?.let {
try { try {
@ -17,3 +25,28 @@ fun PackageManager.getApplicationInfoIfExists(packageName: String?, flags: Int =
null null
} }
} }
fun NavController.navigate(context: Context, @IdRes resId: Int, args: Bundle? = null) {
navigate(resId, args, if (context.systemAnimationsEnabled) navOptions {
anim {
enter = R.anim.nav_default_enter_anim
exit = R.anim.nav_default_exit_anim
popEnter = R.anim.nav_default_pop_enter_anim
popExit = R.anim.nav_default_pop_exit_anim
}
} else null)
}
val Context.systemAnimationsEnabled: Boolean
get() {
val duration: Float
val transition: Float
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
duration = Settings.Global.getFloat(contentResolver, Settings.Global.ANIMATOR_DURATION_SCALE, 1f)
transition = Settings.Global.getFloat(contentResolver, Settings.Global.TRANSITION_ANIMATION_SCALE, 1f)
} else {
duration = Settings.System.getFloat(contentResolver, Settings.System.ANIMATOR_DURATION_SCALE, 1f)
transition = Settings.System.getFloat(contentResolver, Settings.System.TRANSITION_ANIMATION_SCALE, 1f)
}
return duration != 0f && transition != 0f
}

View file

@ -11,60 +11,28 @@
android:label="@string/gms_settings_name"> android:label="@string/gms_settings_name">
<action <action
android:id="@+id/openUnifiedNlpSettings" android:id="@+id/openUnifiedNlpSettings"
app:destination="@id/nav_unlp" app:destination="@id/nav_unlp" />
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
app:popExitAnim="@anim/fragment_close_exit" />
<action <action
android:id="@+id/openSelfcheck" android:id="@+id/openSelfcheck"
app:destination="@id/selfcheckFragment" app:destination="@id/selfcheckFragment" />
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
app:popExitAnim="@anim/fragment_close_exit" />
<action <action
android:id="@+id/openCheckinSettings" android:id="@+id/openCheckinSettings"
app:destination="@id/checkinFragment" app:destination="@id/checkinFragment" />
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
app:popExitAnim="@anim/fragment_close_exit" />
<action <action
android:id="@+id/openGcmSettings" android:id="@+id/openGcmSettings"
app:destination="@id/gcmFragment" app:destination="@id/gcmFragment" />
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
app:popExitAnim="@anim/fragment_close_exit" />
<action <action
android:id="@+id/openSafetyNetSettings" android:id="@+id/openSafetyNetSettings"
app:destination="@id/safetyNetFragment" app:destination="@id/safetyNetFragment" />
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
app:popExitAnim="@anim/fragment_close_exit" />
<action <action
android:id="@+id/openMoreGoogleSettings" android:id="@+id/openMoreGoogleSettings"
app:destination="@id/googleMoreFragment" app:destination="@id/googleMoreFragment" />
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
app:popExitAnim="@anim/fragment_close_exit" />
<action <action
android:id="@+id/openExposureNotificationSettings" android:id="@+id/openExposureNotificationSettings"
app:destination="@id/exposureNotificationsFragment" app:destination="@id/exposureNotificationsFragment" />
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
app:popExitAnim="@anim/fragment_close_exit" />
<action <action
android:id="@+id/openAbout" android:id="@+id/openAbout"
app:destination="@id/aboutFragment" app:destination="@id/aboutFragment" />
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
app:popExitAnim="@anim/fragment_close_exit" />
</fragment> </fragment>
<fragment <fragment
@ -83,25 +51,13 @@
tools:layout="@layout/push_notification_fragment"> tools:layout="@layout/push_notification_fragment">
<action <action
android:id="@+id/openGcmAppDetails" android:id="@+id/openGcmAppDetails"
app:destination="@id/gcmAppFragment" app:destination="@id/gcmAppFragment" />
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
app:popExitAnim="@anim/fragment_close_exit" />
<action <action
android:id="@+id/openAllGcmApps" android:id="@+id/openAllGcmApps"
app:destination="@id/gcmAllAppsFragment" app:destination="@id/gcmAllAppsFragment" />
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
app:popExitAnim="@anim/fragment_close_exit" />
<action <action
android:id="@+id/openGcmAdvancedSettings" android:id="@+id/openGcmAdvancedSettings"
app:destination="@id/gcmAdvancedFragment" app:destination="@id/gcmAdvancedFragment" />
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
app:popExitAnim="@anim/fragment_close_exit" />
</fragment> </fragment>
<fragment <fragment
android:id="@+id/gcmAllAppsFragment" android:id="@+id/gcmAllAppsFragment"
@ -109,11 +65,7 @@
android:label="Apps using push notifications"> android:label="Apps using push notifications">
<action <action
android:id="@+id/openGcmAppDetailsFromAll" android:id="@+id/openGcmAppDetailsFromAll"
app:destination="@id/gcmAppFragment" app:destination="@id/gcmAppFragment" />
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
app:popExitAnim="@anim/fragment_close_exit" />
</fragment> </fragment>
<fragment <fragment
android:id="@+id/gcmAppFragment" android:id="@+id/gcmAppFragment"
@ -135,11 +87,7 @@
tools:layout="@layout/safety_net_fragment"> tools:layout="@layout/safety_net_fragment">
<action <action
android:id="@+id/openSafetyNetAdvancedSettings" android:id="@+id/openSafetyNetAdvancedSettings"
app:destination="@id/safetyNetAdvancedFragment" app:destination="@id/safetyNetAdvancedFragment" />
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
app:popExitAnim="@anim/fragment_close_exit" />
</fragment> </fragment>
<fragment <fragment
android:id="@+id/safetyNetAdvancedFragment" android:id="@+id/safetyNetAdvancedFragment"
@ -164,18 +112,10 @@
<action <action
android:id="@+id/openExposureRpis" android:id="@+id/openExposureRpis"
app:destination="@id/exposureNotificationsRpisFragment" app:destination="@id/exposureNotificationsRpisFragment" />
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
app:popExitAnim="@anim/fragment_close_exit" />
<action <action
android:id="@+id/openExposureAppDetails" android:id="@+id/openExposureAppDetails"
app:destination="@id/exposureNotificationsAppFragment" app:destination="@id/exposureNotificationsAppFragment" />
app:enterAnim="@anim/fragment_open_enter"
app:exitAnim="@anim/fragment_open_exit"
app:popEnterAnim="@anim/fragment_close_enter"
app:popExitAnim="@anim/fragment_close_exit" />
</fragment> </fragment>
<fragment <fragment

View file

@ -21,9 +21,9 @@
<item name="windowNoTitle">true</item> <item name="windowNoTitle">true</item>
</style> </style>
<style name="LoginBlueTheme" parent="LoginBlueTheme.Base" /> <style name="Theme.LoginBlue" parent="Theme.LoginBlue.Base" />
<style name="LoginBlueTheme.Base" parent="Theme.AppCompat.Light"> <style name="Theme.LoginBlue.Base" parent="Theme.AppCompat.Light">
<item name="colorPrimary">@color/login_blue_theme_primary</item> <item name="colorPrimary">@color/login_blue_theme_primary</item>
<item name="colorPrimaryDark">@color/login_blue_theme_primary_dark</item> <item name="colorPrimaryDark">@color/login_blue_theme_primary_dark</item>
<item name="colorAccent">@color/login_blue_theme_accent</item> <item name="colorAccent">@color/login_blue_theme_accent</item>