diff --git a/app/src/main/java/app/fedilab/android/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/BaseMainActivity.java
index 7dfb38fb..9b5af2da 100644
--- a/app/src/main/java/app/fedilab/android/BaseMainActivity.java
+++ b/app/src/main/java/app/fedilab/android/BaseMainActivity.java
@@ -71,6 +71,7 @@ import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.PopupMenu;
import androidx.appcompat.widget.SearchView;
+import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.core.view.GravityCompat;
@@ -97,6 +98,7 @@ import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.target.Target;
import com.bumptech.glide.request.transition.Transition;
+import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.navigation.NavigationView;
@@ -1377,6 +1379,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
if (actionBar != null) {
actionBar.setDisplayShowTitleEnabled(false);
}
+ manageTopBarScrolling(binding.toolbar);
rateThisApp();
binding.compose.setOnClickListener(v -> startActivity(new Intent(this, ComposeActivity.class)));
@@ -1600,6 +1603,23 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
fetchRecentAccounts(BaseMainActivity.this, headerMainBinding);
}
+ private void manageTopBarScrolling(Toolbar toolbar) {
+ final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this);
+ final boolean topBarScrolling = !sharedpreferences.getBoolean(getString(R.string.SET_DISABLE_TOPBAR_SCROLLING), false);
+
+ final AppBarLayout.LayoutParams toolbarLayoutParams = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
+
+ int scrollFlags = toolbarLayoutParams.getScrollFlags();
+
+ if (topBarScrolling) {
+ scrollFlags |= AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL;
+
+ } else {
+ scrollFlags &= ~AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL;
+ }
+ toolbarLayoutParams.setScrollFlags(scrollFlags);
+ }
+
private void manageFilters(int position) {
View view = binding.bottomNavView.findViewById(R.id.nav_home);
boolean showExtendedFilter = true;
diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/ContextActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/ContextActivity.java
index 61d62ddc..41e9af8f 100644
--- a/app/src/main/java/app/fedilab/android/mastodon/activities/ContextActivity.java
+++ b/app/src/main/java/app/fedilab/android/mastodon/activities/ContextActivity.java
@@ -30,10 +30,13 @@ import android.view.MenuItem;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.widget.Toolbar;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.preference.PreferenceManager;
+import com.google.android.material.appbar.AppBarLayout;
+
import java.net.MalformedURLException;
import java.net.URL;
import java.util.regex.Matcher;
@@ -87,6 +90,7 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
}
+ manageTopBarScrolling(binding.toolbar, sharedpreferences);
displayCW = sharedpreferences.getBoolean(getString(R.string.SET_EXPAND_CW), false);
focusedStatus = null; // or other values
MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account);
@@ -131,6 +135,22 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon
outState.clear();
}
+ private void manageTopBarScrolling(Toolbar toolbar, SharedPreferences sharedpreferences) {
+ final boolean topBarScrolling = !sharedpreferences.getBoolean(getString(R.string.SET_DISABLE_TOPBAR_SCROLLING), false);
+
+ final AppBarLayout.LayoutParams toolbarLayoutParams = (AppBarLayout.LayoutParams) toolbar.getLayoutParams();
+
+ int scrollFlags = toolbarLayoutParams.getScrollFlags();
+
+ if (topBarScrolling) {
+ scrollFlags |= AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL;
+
+ } else {
+ scrollFlags &= ~AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL;
+ }
+ toolbarLayoutParams.setScrollFlags(scrollFlags);
+ }
+
private void loadLocalConversation() {
Bundle args = new Bundle();
args.putSerializable(Helper.ARG_STATUS, focusedStatus);
diff --git a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentInterfaceSettings.java b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentInterfaceSettings.java
index c18a0c8f..08dcd379 100644
--- a/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentInterfaceSettings.java
+++ b/app/src/main/java/app/fedilab/android/mastodon/ui/fragment/settings/FragmentInterfaceSettings.java
@@ -120,6 +120,9 @@ public class FragmentInterfaceSettings extends PreferenceFragmentCompat implemen
editor.putString(getString(R.string.SET_LOGO_LAUNCHER), newLauncher);
}
}
+ if (key.compareToIgnoreCase(getString(R.string.SET_DISABLE_TOPBAR_SCROLLING)) == 0) {
+ recreate = true;
+ }
editor.apply();
}
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 565a3579..13f0b11f 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1065,6 +1065,7 @@
SET_LONG_PRESS_STORE_MEDIA
SET_UNFOLLOW_VALIDATION
SET_USE_SINGLE_TOPBAR
+ SET_DISABLE_TOPBAR_SCROLLING
SET_DISPLAY_COUNTERS
SET_DISPLAY_COMPACT_ACTION_BUTTON
@@ -1731,6 +1732,7 @@
Load exported settings
Push distributor
Single action bar
+ Disable top bar scrolling
When enabled, the app will only have a single bar for timelines
Timelines in a list
When enabled, all pinned timelines will be displayed in a drop-down menu
diff --git a/app/src/main/res/xml/pref_interface.xml b/app/src/main/res/xml/pref_interface.xml
index fd36d463..b60c07b6 100644
--- a/app/src/main/res/xml/pref_interface.xml
+++ b/app/src/main/res/xml/pref_interface.xml
@@ -12,6 +12,13 @@
app:summary="@string/set_single_topbar"
app:title="@string/set_single_topbar_title" />
+
+