Add edit profile in main settings

This commit is contained in:
Thomas 2022-07-11 09:13:16 +02:00
parent 13d8876626
commit 94c3dbcf25
3 changed files with 78 additions and 59 deletions

View File

@ -1064,11 +1064,6 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
} }
@Override
protected void onResume() {
super.onResume();
}
public void redrawPinned(List<MastodonList> mastodonLists) { public void redrawPinned(List<MastodonList> mastodonLists) {
int currentItem = binding.viewPager.getCurrentItem(); int currentItem = binding.viewPager.getCurrentItem();
new ViewModelProvider(BaseMainActivity.this).get(TopBarVM.class).getDBPinned() new ViewModelProvider(BaseMainActivity.this).get(TopBarVM.class).getDBPinned()

View File

@ -16,6 +16,7 @@ package app.fedilab.android.activities;
import static app.fedilab.android.BaseMainActivity.currentAccount; import static app.fedilab.android.BaseMainActivity.currentAccount;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.os.Bundle; import android.os.Bundle;
import android.view.MenuItem; import android.view.MenuItem;
@ -62,6 +63,7 @@ public class SettingsActivity extends BaseActivity {
} }
canGoBack = false; canGoBack = false;
binding.setAccount.setOnClickListener(v -> displaySettings(SettingsEnum.ACCOUNT));
binding.setTimelines.setOnClickListener(v -> displaySettings(SettingsEnum.TIMELINES)); binding.setTimelines.setOnClickListener(v -> displaySettings(SettingsEnum.TIMELINES));
binding.setNotifications.setOnClickListener(v -> displaySettings(SettingsEnum.NOTIFICATIONS)); binding.setNotifications.setOnClickListener(v -> displaySettings(SettingsEnum.NOTIFICATIONS));
binding.setInterface.setOnClickListener(v -> displaySettings(SettingsEnum.INTERFACE)); binding.setInterface.setOnClickListener(v -> displaySettings(SettingsEnum.INTERFACE));
@ -79,61 +81,66 @@ public class SettingsActivity extends BaseActivity {
public void displaySettings(SettingsEnum settingsEnum) { public void displaySettings(SettingsEnum settingsEnum) {
ThemeHelper.slideViewsToLeft(binding.buttonContainer, binding.fragmentContainer, () -> { if (settingsEnum == SettingsEnum.ACCOUNT) {
FragmentManager fragmentManager = getSupportFragmentManager(); Intent intent = new Intent(SettingsActivity.this, EditProfileActivity.class);
FragmentTransaction fragmentTransaction = startActivity(intent);
fragmentManager.beginTransaction(); } else {
String category = ""; ThemeHelper.slideViewsToLeft(binding.buttonContainer, binding.fragmentContainer, () -> {
switch (settingsEnum) { FragmentManager fragmentManager = getSupportFragmentManager();
case TIMELINES: FragmentTransaction fragmentTransaction =
FragmentTimelinesSettings fragmentTimelinesSettings = new FragmentTimelinesSettings(); fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragmentTimelinesSettings); String category = "";
currentFragment = fragmentTimelinesSettings; switch (settingsEnum) {
category = getString(R.string.settings_category_label_timelines); case TIMELINES:
break; FragmentTimelinesSettings fragmentTimelinesSettings = new FragmentTimelinesSettings();
case NOTIFICATIONS: fragmentTransaction.replace(R.id.fragment_container, fragmentTimelinesSettings);
FragmentNotificationsSettings fragmentNotificationsSettings = new FragmentNotificationsSettings(); currentFragment = fragmentTimelinesSettings;
fragmentTransaction.replace(R.id.fragment_container, fragmentNotificationsSettings); category = getString(R.string.settings_category_label_timelines);
currentFragment = fragmentNotificationsSettings; break;
category = getString(R.string.notifications); case NOTIFICATIONS:
break; FragmentNotificationsSettings fragmentNotificationsSettings = new FragmentNotificationsSettings();
case INTERFACE: fragmentTransaction.replace(R.id.fragment_container, fragmentNotificationsSettings);
FragmentInterfaceSettings fragmentInterfaceSettings = new FragmentInterfaceSettings(); currentFragment = fragmentNotificationsSettings;
fragmentTransaction.replace(R.id.fragment_container, fragmentInterfaceSettings); category = getString(R.string.notifications);
currentFragment = fragmentInterfaceSettings; break;
category = getString(R.string.settings_category_label_interface); case INTERFACE:
break; FragmentInterfaceSettings fragmentInterfaceSettings = new FragmentInterfaceSettings();
case COMPOSE: fragmentTransaction.replace(R.id.fragment_container, fragmentInterfaceSettings);
FragmentComposeSettings fragmentComposeSettings = new FragmentComposeSettings(); currentFragment = fragmentInterfaceSettings;
fragmentTransaction.replace(R.id.fragment_container, fragmentComposeSettings); category = getString(R.string.settings_category_label_interface);
currentFragment = fragmentComposeSettings; break;
category = getString(R.string.compose); case COMPOSE:
break; FragmentComposeSettings fragmentComposeSettings = new FragmentComposeSettings();
case PRIVACY: fragmentTransaction.replace(R.id.fragment_container, fragmentComposeSettings);
FragmentPrivacySettings fragmentPrivacySettings = new FragmentPrivacySettings(); currentFragment = fragmentComposeSettings;
fragmentTransaction.replace(R.id.fragment_container, fragmentPrivacySettings); category = getString(R.string.compose);
currentFragment = fragmentPrivacySettings; break;
category = getString(R.string.action_privacy); case PRIVACY:
break; FragmentPrivacySettings fragmentPrivacySettings = new FragmentPrivacySettings();
case THEMING: fragmentTransaction.replace(R.id.fragment_container, fragmentPrivacySettings);
FragmentThemingSettings fragmentThemingSettings = new FragmentThemingSettings(); currentFragment = fragmentPrivacySettings;
fragmentTransaction.replace(R.id.fragment_container, fragmentThemingSettings); category = getString(R.string.action_privacy);
currentFragment = fragmentThemingSettings; break;
category = getString(R.string.theming); case THEMING:
break; FragmentThemingSettings fragmentThemingSettings = new FragmentThemingSettings();
case LANGUAGE: fragmentTransaction.replace(R.id.fragment_container, fragmentThemingSettings);
FragmentLanguageSettings fragmentLanguageSettings = new FragmentLanguageSettings(); currentFragment = fragmentThemingSettings;
fragmentTransaction.replace(R.id.fragment_container, fragmentLanguageSettings); category = getString(R.string.theming);
currentFragment = fragmentLanguageSettings; break;
category = getString(R.string.languages); case LANGUAGE:
break; 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); String title = String.format(Locale.getDefault(), "%s - %s", getString(R.string.settings), category);
setTitle(title); setTitle(title);
canGoBack = true; canGoBack = true;
fragmentTransaction.commit(); fragmentTransaction.commit();
}); });
}
} }
@ -168,6 +175,8 @@ public class SettingsActivity extends BaseActivity {
public enum SettingsEnum { public enum SettingsEnum {
@SerializedName("ACCOUNT")
ACCOUNT("ACCOUNT"),
@SerializedName("TIMELINES") @SerializedName("TIMELINES")
TIMELINES("TIMELINES"), TIMELINES("TIMELINES"),
@SerializedName("NOTIFICATIONS") @SerializedName("NOTIFICATIONS")

View File

@ -16,12 +16,27 @@
android:orientation="vertical" android:orientation="vertical"
android:padding="24dp"> android:padding="24dp">
<com.google.android.material.button.MaterialButton
android:id="@+id/set_account"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingVertical="12dp"
android:text="@string/account"
android:textAlignment="textStart"
android:textColor="@color/cyanea_accent_dark_reference"
app:icon="@drawable/ic_baseline_navigate_next_24"
app:iconGravity="end"
app:iconTint="@color/cyanea_accent_dark_reference"
app:strokeColor="@color/cyanea_accent_dark_reference" />
<com.google.android.material.button.MaterialButton <com.google.android.material.button.MaterialButton
android:id="@+id/set_timelines" android:id="@+id/set_timelines"
style="@style/Widget.MaterialComponents.Button.OutlinedButton" style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingVertical="12dp" android:paddingVertical="12dp"
android:layout_marginTop="24dp"
android:text="@string/settings_category_label_timelines" android:text="@string/settings_category_label_timelines"
android:textAlignment="textStart" android:textAlignment="textStart"
android:textColor="@color/cyanea_accent_dark_reference" android:textColor="@color/cyanea_accent_dark_reference"