From 94c3dbcf25e7194624820dcdec241748c1ddb10d Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 11 Jul 2022 09:13:16 +0200 Subject: [PATCH] Add edit profile in main settings --- .../app/fedilab/android/BaseMainActivity.java | 5 - .../android/activities/SettingsActivity.java | 117 ++++++++++-------- app/src/main/res/layout/activity_settings.xml | 15 +++ 3 files changed, 78 insertions(+), 59 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/BaseMainActivity.java index 19532dd72..2c9218a02 100644 --- a/app/src/main/java/app/fedilab/android/BaseMainActivity.java +++ b/app/src/main/java/app/fedilab/android/BaseMainActivity.java @@ -1064,11 +1064,6 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt } - @Override - protected void onResume() { - super.onResume(); - } - public void redrawPinned(List mastodonLists) { int currentItem = binding.viewPager.getCurrentItem(); new ViewModelProvider(BaseMainActivity.this).get(TopBarVM.class).getDBPinned() diff --git a/app/src/main/java/app/fedilab/android/activities/SettingsActivity.java b/app/src/main/java/app/fedilab/android/activities/SettingsActivity.java index 6bd43a2b3..44f24efea 100644 --- a/app/src/main/java/app/fedilab/android/activities/SettingsActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/SettingsActivity.java @@ -16,6 +16,7 @@ package app.fedilab.android.activities; import static app.fedilab.android.BaseMainActivity.currentAccount; +import android.content.Intent; import android.graphics.drawable.ColorDrawable; import android.os.Bundle; import android.view.MenuItem; @@ -62,6 +63,7 @@ public class SettingsActivity extends BaseActivity { } canGoBack = false; + binding.setAccount.setOnClickListener(v -> displaySettings(SettingsEnum.ACCOUNT)); binding.setTimelines.setOnClickListener(v -> displaySettings(SettingsEnum.TIMELINES)); binding.setNotifications.setOnClickListener(v -> displaySettings(SettingsEnum.NOTIFICATIONS)); binding.setInterface.setOnClickListener(v -> displaySettings(SettingsEnum.INTERFACE)); @@ -79,61 +81,66 @@ public class SettingsActivity extends BaseActivity { public void displaySettings(SettingsEnum settingsEnum) { - ThemeHelper.slideViewsToLeft(binding.buttonContainer, binding.fragmentContainer, () -> { - FragmentManager fragmentManager = getSupportFragmentManager(); - FragmentTransaction fragmentTransaction = - fragmentManager.beginTransaction(); - String category = ""; - switch (settingsEnum) { - case TIMELINES: - FragmentTimelinesSettings fragmentTimelinesSettings = new FragmentTimelinesSettings(); - fragmentTransaction.replace(R.id.fragment_container, fragmentTimelinesSettings); - currentFragment = fragmentTimelinesSettings; - category = getString(R.string.settings_category_label_timelines); - break; - case NOTIFICATIONS: - FragmentNotificationsSettings fragmentNotificationsSettings = new FragmentNotificationsSettings(); - fragmentTransaction.replace(R.id.fragment_container, fragmentNotificationsSettings); - currentFragment = fragmentNotificationsSettings; - category = getString(R.string.notifications); - break; - case INTERFACE: - FragmentInterfaceSettings fragmentInterfaceSettings = new FragmentInterfaceSettings(); - fragmentTransaction.replace(R.id.fragment_container, fragmentInterfaceSettings); - currentFragment = fragmentInterfaceSettings; - category = getString(R.string.settings_category_label_interface); - break; - case COMPOSE: - FragmentComposeSettings fragmentComposeSettings = new FragmentComposeSettings(); - fragmentTransaction.replace(R.id.fragment_container, fragmentComposeSettings); - currentFragment = fragmentComposeSettings; - category = getString(R.string.compose); - break; - case PRIVACY: - FragmentPrivacySettings fragmentPrivacySettings = new FragmentPrivacySettings(); - fragmentTransaction.replace(R.id.fragment_container, fragmentPrivacySettings); - currentFragment = fragmentPrivacySettings; - category = getString(R.string.action_privacy); - break; - case THEMING: - FragmentThemingSettings fragmentThemingSettings = new FragmentThemingSettings(); - fragmentTransaction.replace(R.id.fragment_container, fragmentThemingSettings); - currentFragment = fragmentThemingSettings; - category = getString(R.string.theming); - break; - case LANGUAGE: - FragmentLanguageSettings fragmentLanguageSettings = new FragmentLanguageSettings(); - fragmentTransaction.replace(R.id.fragment_container, fragmentLanguageSettings); - currentFragment = fragmentLanguageSettings; - category = getString(R.string.languages); - break; + if (settingsEnum == SettingsEnum.ACCOUNT) { + Intent intent = new Intent(SettingsActivity.this, EditProfileActivity.class); + startActivity(intent); + } else { + ThemeHelper.slideViewsToLeft(binding.buttonContainer, binding.fragmentContainer, () -> { + FragmentManager fragmentManager = getSupportFragmentManager(); + FragmentTransaction fragmentTransaction = + fragmentManager.beginTransaction(); + String category = ""; + switch (settingsEnum) { + case TIMELINES: + FragmentTimelinesSettings fragmentTimelinesSettings = new FragmentTimelinesSettings(); + fragmentTransaction.replace(R.id.fragment_container, fragmentTimelinesSettings); + currentFragment = fragmentTimelinesSettings; + category = getString(R.string.settings_category_label_timelines); + break; + case NOTIFICATIONS: + FragmentNotificationsSettings fragmentNotificationsSettings = new FragmentNotificationsSettings(); + fragmentTransaction.replace(R.id.fragment_container, fragmentNotificationsSettings); + currentFragment = fragmentNotificationsSettings; + category = getString(R.string.notifications); + break; + case INTERFACE: + FragmentInterfaceSettings fragmentInterfaceSettings = new FragmentInterfaceSettings(); + fragmentTransaction.replace(R.id.fragment_container, fragmentInterfaceSettings); + currentFragment = fragmentInterfaceSettings; + category = getString(R.string.settings_category_label_interface); + break; + case COMPOSE: + FragmentComposeSettings fragmentComposeSettings = new FragmentComposeSettings(); + fragmentTransaction.replace(R.id.fragment_container, fragmentComposeSettings); + currentFragment = fragmentComposeSettings; + category = getString(R.string.compose); + break; + case PRIVACY: + FragmentPrivacySettings fragmentPrivacySettings = new FragmentPrivacySettings(); + fragmentTransaction.replace(R.id.fragment_container, fragmentPrivacySettings); + currentFragment = fragmentPrivacySettings; + category = getString(R.string.action_privacy); + break; + case THEMING: + FragmentThemingSettings fragmentThemingSettings = new FragmentThemingSettings(); + fragmentTransaction.replace(R.id.fragment_container, fragmentThemingSettings); + currentFragment = fragmentThemingSettings; + category = getString(R.string.theming); + break; + case LANGUAGE: + FragmentLanguageSettings fragmentLanguageSettings = new FragmentLanguageSettings(); + fragmentTransaction.replace(R.id.fragment_container, fragmentLanguageSettings); + currentFragment = fragmentLanguageSettings; + category = getString(R.string.languages); + break; - } - String title = String.format(Locale.getDefault(), "%s - %s", getString(R.string.settings), category); - setTitle(title); - canGoBack = true; - fragmentTransaction.commit(); - }); + } + String title = String.format(Locale.getDefault(), "%s - %s", getString(R.string.settings), category); + setTitle(title); + canGoBack = true; + fragmentTransaction.commit(); + }); + } } @@ -168,6 +175,8 @@ public class SettingsActivity extends BaseActivity { public enum SettingsEnum { + @SerializedName("ACCOUNT") + ACCOUNT("ACCOUNT"), @SerializedName("TIMELINES") TIMELINES("TIMELINES"), @SerializedName("NOTIFICATIONS") diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index d3169a5bf..117b1cf75 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -16,12 +16,27 @@ android:orientation="vertical" android:padding="24dp"> + +