Allow to disable scrolling of the top bar in settings
This commit is contained in:
parent
aeb45f0bcf
commit
1c01c018a0
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1065,6 +1065,7 @@
|
|||
<string name="SET_LONG_PRESS_STORE_MEDIA" translatable="false">SET_LONG_PRESS_STORE_MEDIA</string>
|
||||
<string name="SET_UNFOLLOW_VALIDATION" translatable="false">SET_UNFOLLOW_VALIDATION</string>
|
||||
<string name="SET_USE_SINGLE_TOPBAR" translatable="false">SET_USE_SINGLE_TOPBAR</string>
|
||||
<string name="SET_DISABLE_TOPBAR_SCROLLING" translatable="false">SET_DISABLE_TOPBAR_SCROLLING</string>
|
||||
<string name="SET_DISPLAY_COUNTERS" translatable="false">SET_DISPLAY_COUNTERS</string>
|
||||
<string name="SET_DISPLAY_COMPACT_ACTION_BUTTON" translatable="false">SET_DISPLAY_COMPACT_ACTION_BUTTON</string>
|
||||
|
||||
|
@ -1731,6 +1732,7 @@
|
|||
<string name="load_settings">Load exported settings</string>
|
||||
<string name="push_distributors">Push distributor</string>
|
||||
<string name="set_single_topbar_title">Single action bar</string>
|
||||
<string name="set_disable_topbar_scrolling_title">Disable top bar scrolling</string>
|
||||
<string name="set_single_topbar">When enabled, the app will only have a single bar for timelines</string>
|
||||
<string name="set_timelines_in_a_list_title">Timelines in a list</string>
|
||||
<string name="set_timelines_in_a_list">When enabled, all pinned timelines will be displayed in a drop-down menu</string>
|
||||
|
|
|
@ -12,6 +12,13 @@
|
|||
app:summary="@string/set_single_topbar"
|
||||
app:title="@string/set_single_topbar_title" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:defaultValue="false"
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="@string/SET_DISABLE_TOPBAR_SCROLLING"
|
||||
app:singleLineTitle="false"
|
||||
app:title="@string/set_disable_topbar_scrolling_title" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
app:defaultValue="false"
|
||||
app:iconSpaceReserved="false"
|
||||
|
|
Loading…
Reference in New Issue