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
-------
Copyright 2013-2019 microG Project Team
Copyright 2013-2020 microG Project Team
Licensed under the Apache License, Version 2.0 (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:configChanges="keyboardHidden|orientation|screenSize"
android:exported="true"
android:theme="@style/LoginBlueTheme">
android:theme="@style/Theme.LoginBlue">
<intent-filter>
<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 androidx.annotation.Nullable;
import androidx.navigation.NavOptions;
import androidx.navigation.fragment.NavHostFragment;
import com.google.android.gms.R;
@ -43,7 +44,7 @@ public class SettingsFragment extends ResourceSettingsFragment {
private void updateDetails() {
findPreference(PREF_ABOUT).setSummary(getString(R.string.about_version_str, AboutFragment.getSelfVersion(getContext())));
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;
});
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).setOnPreferenceClickListener(preference -> {
NavHostFragment.findNavController(SettingsFragment.this).navigate(R.id.openGcmSettings);
UtilsKt.navigate(NavHostFragment.findNavController(SettingsFragment.this), getContext(), R.id.openGcmSettings, null);
return true;
});
@ -75,7 +76,7 @@ public class SettingsFragment extends ResourceSettingsFragment {
findPreference(PREF_SNET).setSummary(R.string.service_status_disabled_short);
}
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;
});
@ -86,7 +87,7 @@ public class SettingsFragment extends ResourceSettingsFragment {
// Preferences.splitBackendString(unifiedNlPrefs.getGeocoderBackends()).length;
// findPreference(PREF_UNIFIEDNLP).setSummary(getResources().getQuantityString(R.plurals.pref_unifiednlp_summary, backendCount, backendCount));
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;
});
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).setOnPreferenceClickListener(preference -> {
NavHostFragment.findNavController(SettingsFragment.this).navigate(R.id.openExposureNotificationSettings);
UtilsKt.navigate(NavHostFragment.findNavController(SettingsFragment.this), getContext(), R.id.openExposureNotificationSettings, null);
return true;
});
} else {
@ -107,7 +108,7 @@ public class SettingsFragment extends ResourceSettingsFragment {
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).setOnPreferenceClickListener(preference -> {
NavHostFragment.findNavController(SettingsFragment.this).navigate(R.id.openCheckinSettings);
UtilsKt.navigate(NavHostFragment.findNavController(SettingsFragment.this), getContext(), R.id.openCheckinSettings, null);
return true;
});
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -5,9 +5,17 @@
package org.microg.gms.ui
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.navigation.NavController
import androidx.navigation.navOptions
import androidx.navigation.ui.R
fun PackageManager.getApplicationInfoIfExists(packageName: String?, flags: Int = 0): ApplicationInfo? = packageName?.let {
try {
@ -17,3 +25,28 @@ fun PackageManager.getApplicationInfoIfExists(packageName: String?, flags: Int =
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">
<action
android:id="@+id/openUnifiedNlpSettings"
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" />
app:destination="@id/nav_unlp" />
<action
android:id="@+id/openSelfcheck"
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" />
app:destination="@id/selfcheckFragment" />
<action
android:id="@+id/openCheckinSettings"
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" />
app:destination="@id/checkinFragment" />
<action
android:id="@+id/openGcmSettings"
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" />
app:destination="@id/gcmFragment" />
<action
android:id="@+id/openSafetyNetSettings"
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" />
app:destination="@id/safetyNetFragment" />
<action
android:id="@+id/openMoreGoogleSettings"
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" />
app:destination="@id/googleMoreFragment" />
<action
android:id="@+id/openExposureNotificationSettings"
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" />
app:destination="@id/exposureNotificationsFragment" />
<action
android:id="@+id/openAbout"
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" />
app:destination="@id/aboutFragment" />
</fragment>
<fragment
@ -83,25 +51,13 @@
tools:layout="@layout/push_notification_fragment">
<action
android:id="@+id/openGcmAppDetails"
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" />
app:destination="@id/gcmAppFragment" />
<action
android:id="@+id/openAllGcmApps"
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" />
app:destination="@id/gcmAllAppsFragment" />
<action
android:id="@+id/openGcmAdvancedSettings"
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" />
app:destination="@id/gcmAdvancedFragment" />
</fragment>
<fragment
android:id="@+id/gcmAllAppsFragment"
@ -109,11 +65,7 @@
android:label="Apps using push notifications">
<action
android:id="@+id/openGcmAppDetailsFromAll"
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" />
app:destination="@id/gcmAppFragment" />
</fragment>
<fragment
android:id="@+id/gcmAppFragment"
@ -135,11 +87,7 @@
tools:layout="@layout/safety_net_fragment">
<action
android:id="@+id/openSafetyNetAdvancedSettings"
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" />
app:destination="@id/safetyNetAdvancedFragment" />
</fragment>
<fragment
android:id="@+id/safetyNetAdvancedFragment"
@ -164,18 +112,10 @@
<action
android:id="@+id/openExposureRpis"
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" />
app:destination="@id/exposureNotificationsRpisFragment" />
<action
android:id="@+id/openExposureAppDetails"
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" />
app:destination="@id/exposureNotificationsAppFragment" />
</fragment>
<fragment

View file

@ -21,9 +21,9 @@
<item name="windowNoTitle">true</item>
</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="colorPrimaryDark">@color/login_blue_theme_primary_dark</item>
<item name="colorAccent">@color/login_blue_theme_accent</item>