From 5ce553f8cffa33d037dec07bafe0227070cfbff6 Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 25 Jan 2023 12:18:02 +0100 Subject: [PATCH] Some fixes --- .../app/fedilab/android/BaseMainActivity.java | 2 +- .../peertube/activities/AccountActivity.java | 19 ++----------------- .../activities/PeertubeMainActivity.java | 13 +++++++------ .../fragment/DisplayChannelsFragment.java | 2 +- .../layout/activity_account_peertube.xml | 16 ++-------------- 5 files changed, 13 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/BaseMainActivity.java index f622faf6..b2f68571 100644 --- a/app/src/main/java/app/fedilab/android/BaseMainActivity.java +++ b/app/src/main/java/app/fedilab/android/BaseMainActivity.java @@ -316,7 +316,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt } }; private NetworkStateReceiver networkStateReceiver; - private static boolean headerMenuOpen; + public static boolean headerMenuOpen; public static void fetchRecentAccounts(Activity activity, NavHeaderMainBinding headerMainBinding) { SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(activity); diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/AccountActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/AccountActivity.java index 72c7d727..653374d6 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/AccountActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/AccountActivity.java @@ -32,7 +32,6 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; -import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentStatePagerAdapter; @@ -104,22 +103,8 @@ public class AccountActivity extends BaseBarActivity { binding.instance.setText(account.getHost()); - BaseAccount finalBaseAccount = baseAccount; - binding.logoutButton.setOnClickListener(v -> { - AlertDialog.Builder dialogBuilderLogoutAccount = new AlertDialog.Builder(AccountActivity.this); - dialogBuilderLogoutAccount.setMessage(getString(R.string.logout_account_confirmation, account.getUsername(), account.getHost())); - dialogBuilderLogoutAccount.setPositiveButton(R.string.action_logout, (dialog, id) -> { - Helper.logoutCurrentUser(AccountActivity.this, finalBaseAccount); - dialog.dismiss(); - }); - dialogBuilderLogoutAccount.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss()); - AlertDialog alertDialogLogoutAccount = dialogBuilderLogoutAccount.create(); - alertDialogLogoutAccount.show(); - }); - - binding.settings.setOnClickListener(v -> { - Intent intent = new Intent(AccountActivity.this, SettingsActivity.class); - startActivity(intent); + binding.editButton.setOnClickListener(v -> { + startActivity(new Intent(AccountActivity.this, MyAccountActivity.class)); }); diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java index f0ad7c08..1b8ca1b6 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java @@ -18,6 +18,7 @@ import static app.fedilab.android.BaseMainActivity.currentAccount; import static app.fedilab.android.BaseMainActivity.currentInstance; import static app.fedilab.android.BaseMainActivity.currentToken; import static app.fedilab.android.BaseMainActivity.fetchRecentAccounts; +import static app.fedilab.android.BaseMainActivity.headerMenuOpen; import static app.fedilab.android.BaseMainActivity.manageDrawerMenu; import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_ID; import static app.fedilab.android.mastodon.helper.Helper.PREF_USER_INSTANCE; @@ -114,7 +115,6 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity { private DisplayVideosFragment recentFragment, locaFragment, trendingFragment, subscriptionFragment, mostLikedFragment; private DisplayOverviewFragment overviewFragment; private ActivityMainPeertubeBinding binding; - private static boolean headerMenuOpen; private final BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener = item -> { @@ -295,18 +295,19 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity { headerMainBinding.accountAcc.setTextSize(TypedValue.COMPLEX_UNIT_SP, 18 * 1.1f / scale); app.fedilab.android.mastodon.helper.Helper.loadPP(PeertubeMainActivity.this, headerMainBinding.accountProfilePicture, currentAccount, false); headerMainBinding.backgroundImage.setAlpha(0.5f); + headerMainBinding.accountAcc.setOnClickListener(v -> headerMainBinding.changeAccount.callOnClick()); + headerMainBinding.changeAccount.setOnClickListener(v -> { + headerMenuOpen = !headerMenuOpen; + manageDrawerMenu(PeertubeMainActivity.this, binding.drawerNavView, headerMainBinding); + }); }; mainHandler.post(myRunnable); }).start(); headerMainBinding.instanceInfo.setVisibility(View.GONE); headerMainBinding.headerOptionInfo.setVisibility(View.GONE); binding.drawerNavView.addHeaderView(headerMainBinding.getRoot()); - headerMainBinding.accountAcc.setOnClickListener(v -> headerMainBinding.changeAccount.callOnClick()); - headerMainBinding.changeAccount.setOnClickListener(v -> { - headerMenuOpen = !headerMenuOpen; - manageDrawerMenu(PeertubeMainActivity.this, binding.drawerNavView, headerMainBinding); - }); + binding.drawerNavView.setNavigationItemSelectedListener(item -> { if (item.getItemId() == R.id.action_settings) { Intent intent = new Intent(PeertubeMainActivity.this, SettingsActivity.class); diff --git a/app/src/main/java/app/fedilab/android/peertube/fragment/DisplayChannelsFragment.java b/app/src/main/java/app/fedilab/android/peertube/fragment/DisplayChannelsFragment.java index 3ec9d9b4..e1eafd7b 100644 --- a/app/src/main/java/app/fedilab/android/peertube/fragment/DisplayChannelsFragment.java +++ b/app/src/main/java/app/fedilab/android/peertube/fragment/DisplayChannelsFragment.java @@ -250,7 +250,7 @@ public class DisplayChannelsFragment extends Fragment implements ChannelListAdap AlertDialog alertDialog = dialogBuilder.create(); int position; if (oldChannelValues == null) { - position = -1; + position = 0; } else { position = 0; for (ChannelData.Channel channel : channels) { diff --git a/app/src/main/res/layouts/peertube/layout/activity_account_peertube.xml b/app/src/main/res/layouts/peertube/layout/activity_account_peertube.xml index c5aa81c6..84366305 100644 --- a/app/src/main/res/layouts/peertube/layout/activity_account_peertube.xml +++ b/app/src/main/res/layouts/peertube/layout/activity_account_peertube.xml @@ -106,28 +106,16 @@ app:layout_constraintTop_toTopOf="parent">