Skip to content

Commit

Permalink
Added fragment transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
WSTxda committed Mar 5, 2024
1 parent 3688d20 commit 0dfef60
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.google.android.material.color.MaterialColors;
import com.google.android.material.transition.platform.MaterialSharedAxis;

import org.microg.tools.updater.UpdateChecker;

import java.util.ArrayList;
Expand Down Expand Up @@ -81,6 +84,21 @@ public static String getLibVersion(String packageName) {
}
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setEnterTransition(new MaterialSharedAxis(MaterialSharedAxis.X, true));
setExitTransition(new MaterialSharedAxis(MaterialSharedAxis.X, true));
setReenterTransition(new MaterialSharedAxis(MaterialSharedAxis.X, false));
setReturnTransition(new MaterialSharedAxis(MaterialSharedAxis.X, false));
}

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
view.setBackgroundColor(MaterialColors.getColor(view, android.R.attr.colorBackground));
}

public static String getSelfVersion(Context context) {
return getLibVersion(BuildConfig.GMS_APPLICATION_NAMESPACE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,34 @@

package org.microg.tools.ui;

import android.os.Bundle;
import android.view.View;

import androidx.fragment.app.DialogFragment;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;

import com.google.android.material.color.MaterialColors;
import com.google.android.material.transition.platform.MaterialSharedAxis;

public abstract class AbstractSettingsFragment extends PreferenceFragmentCompat {
private static final String TAG = AbstractSettingsFragment.class.getSimpleName();

private static final String DIALOG_FRAGMENT_TAG = "androidx.preference.PreferenceFragment.DIALOG";

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setEnterTransition(new MaterialSharedAxis(MaterialSharedAxis.X, true));
setReenterTransition(new MaterialSharedAxis(MaterialSharedAxis.X, false));
}

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
view.setBackgroundColor(MaterialColors.getColor(view, android.R.attr.colorBackground));
}

@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof DialogPreference) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import androidx.preference.Preference
import androidx.preference.PreferenceCategory
import androidx.preference.PreferenceFragmentCompat
import com.google.android.gms.R
import com.google.android.material.color.MaterialColors
import com.google.android.material.transition.platform.MaterialSharedAxis
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand All @@ -34,6 +36,12 @@ class AccountsFragment : PreferenceFragmentCompat() {
updateAccountList()
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enterTransition = MaterialSharedAxis(MaterialSharedAxis.X, true)
reenterTransition = MaterialSharedAxis(MaterialSharedAxis.X, false)
}

override fun onResume() {
super.onResume()
updateAccountList()
Expand Down Expand Up @@ -120,6 +128,7 @@ class AccountsFragment : PreferenceFragmentCompat() {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
view.setBackgroundColor(MaterialColors.getColor(view, android.R.attr.colorBackground))

findPreference<Preference>("pref_manage_accounts")?.setOnPreferenceClickListener {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import android.os.Bundle
import android.os.Handler
import android.text.format.DateUtils
import android.util.Log
import android.view.View
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.lifecycle.lifecycleScope
Expand All @@ -19,6 +20,8 @@ import androidx.preference.Preference
import androidx.preference.PreferenceCategory
import androidx.preference.PreferenceFragmentCompat
import com.google.android.gms.R
import com.google.android.material.color.MaterialColors
import com.google.android.material.transition.platform.MaterialSharedAxis
import org.microg.gms.checkin.CheckinPreferences
import org.microg.gms.checkin.getCheckinServiceInfo
import org.microg.gms.profile.ProfileManager
Expand All @@ -44,6 +47,8 @@ class DeviceRegistrationFragment : PreferenceFragmentCompat() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enterTransition = MaterialSharedAxis(MaterialSharedAxis.X, true)
reenterTransition = MaterialSharedAxis(MaterialSharedAxis.X, false)
profileFileImport = registerForActivityResult(ActivityResultContracts.GetContent(), this::onFileSelected)
}

Expand All @@ -70,6 +75,11 @@ class DeviceRegistrationFragment : PreferenceFragmentCompat() {
addPreferencesFromResource(R.xml.preferences_device_registration)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
view.setBackgroundColor(MaterialColors.getColor(view, android.R.attr.colorBackground))
}

@SuppressLint("RestrictedApi")
override fun onBindPreferences() {
switchBarPreference = preferenceScreen.findPreference("pref_checkin_enabled") ?: switchBarPreference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ package org.microg.gms.ui

import android.annotation.SuppressLint
import android.os.Bundle
import android.view.View
import androidx.lifecycle.lifecycleScope
import androidx.preference.ListPreference
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.TwoStatePreference
import com.google.android.gms.R
import com.google.android.material.color.MaterialColors
import com.google.android.material.transition.platform.MaterialSharedAxis
import org.microg.gms.gcm.*

class PushNotificationAdvancedFragment : PreferenceFragmentCompat() {
Expand All @@ -25,6 +28,17 @@ class PushNotificationAdvancedFragment : PreferenceFragmentCompat() {
addPreferencesFromResource(R.xml.preferences_gcm_advanced)
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enterTransition = MaterialSharedAxis(MaterialSharedAxis.X, true)
reenterTransition = MaterialSharedAxis(MaterialSharedAxis.X, false)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
view.setBackgroundColor(MaterialColors.getColor(view, android.R.attr.colorBackground))
}

@SuppressLint("RestrictedApi")
override fun onBindPreferences() {
confirmNewApps = preferenceScreen.findPreference(GcmPrefs.PREF_CONFIRM_NEW_APPS) ?: confirmNewApps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package org.microg.gms.ui

import android.os.Bundle
import android.text.format.DateUtils
import android.view.View
import androidx.appcompat.content.res.AppCompatResources
import androidx.core.os.bundleOf
import androidx.lifecycle.lifecycleScope
Expand All @@ -15,6 +16,8 @@ import androidx.preference.Preference
import androidx.preference.PreferenceCategory
import androidx.preference.PreferenceFragmentCompat
import com.google.android.gms.R
import com.google.android.material.color.MaterialColors
import com.google.android.material.transition.platform.MaterialSharedAxis
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.microg.gms.gcm.GcmDatabase
Expand All @@ -29,9 +32,16 @@ class PushNotificationAllAppsFragment : PreferenceFragmentCompat() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enterTransition = MaterialSharedAxis(MaterialSharedAxis.X, true)
reenterTransition = MaterialSharedAxis(MaterialSharedAxis.X, false)
database = GcmDatabase(context)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
view.setBackgroundColor(MaterialColors.getColor(view, android.R.attr.colorBackground))
}

override fun onResume() {
super.onResume()
updateContent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ package org.microg.gms.ui
import android.annotation.SuppressLint
import android.os.Bundle
import android.text.format.DateUtils
import android.view.View
import androidx.appcompat.app.AlertDialog
import androidx.lifecycle.lifecycleScope
import androidx.preference.Preference
import androidx.preference.PreferenceCategory
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.TwoStatePreference
import com.google.android.gms.R
import com.google.android.material.color.MaterialColors
import com.google.android.material.transition.platform.MaterialSharedAxis
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.microg.gms.gcm.GcmDatabase
Expand All @@ -38,9 +41,16 @@ class PushNotificationAppFragment : PreferenceFragmentCompat() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enterTransition = MaterialSharedAxis(MaterialSharedAxis.X, true)
reenterTransition = MaterialSharedAxis(MaterialSharedAxis.X, false)
database = GcmDatabase(context)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
view.setBackgroundColor(MaterialColors.getColor(view, android.R.attr.colorBackground))
}

@SuppressLint("RestrictedApi")
override fun onBindPreferences() {
appHeadingPreference = preferenceScreen.findPreference("pref_push_app_heading") ?: appHeadingPreference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,21 @@ package org.microg.gms.ui
import android.annotation.SuppressLint
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.text.format.DateUtils
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import androidx.core.os.bundleOf
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import androidx.preference.Preference
import androidx.preference.PreferenceCategory
import androidx.preference.PreferenceFragmentCompat
import com.google.android.gms.R
import com.google.android.material.color.MaterialColors
import com.google.android.material.transition.platform.MaterialSharedAxis
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.microg.gms.checkin.CheckinPreferences
Expand All @@ -39,9 +43,16 @@ class PushNotificationFragment : PreferenceFragmentCompat() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enterTransition = MaterialSharedAxis(MaterialSharedAxis.X, true)
reenterTransition = MaterialSharedAxis(MaterialSharedAxis.X, false)
database = GcmDatabase(context)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
view.setBackgroundColor(MaterialColors.getColor(view, android.R.attr.colorBackground))
}

override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
addPreferencesFromResource(R.xml.preferences_push_notifications)
}
Expand All @@ -67,7 +78,6 @@ class PushNotificationFragment : PreferenceFragmentCompat() {

override fun onResume() {
super.onResume()

switchBarPreference.isEnabled = CheckinPreferences.isEnabled(requireContext())
switchBarPreference.isChecked = GcmPrefs.get(requireContext()).isEnabled

Expand Down

0 comments on commit 0dfef60

Please sign in to comment.