mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 08:40:03 +02:00
Merge pull request 'Allow to disable scrolling of the top bar in settings' (#1021) from aur/Fedilab:disable_topbar_scrolling into develop
Reviewed-on: https://codeberg.org/tom79/Fedilab/pulls/1021
This commit is contained in:
commit
4d66a3f9a8
5 changed files with 52 additions and 0 deletions
|
@ -71,6 +71,7 @@ import androidx.appcompat.app.ActionBar;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.widget.PopupMenu;
|
import androidx.appcompat.widget.PopupMenu;
|
||||||
import androidx.appcompat.widget.SearchView;
|
import androidx.appcompat.widget.SearchView;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.core.view.GravityCompat;
|
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.CustomTarget;
|
||||||
import com.bumptech.glide.request.target.Target;
|
import com.bumptech.glide.request.target.Target;
|
||||||
import com.bumptech.glide.request.transition.Transition;
|
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.bottomnavigation.BottomNavigationView;
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||||
import com.google.android.material.navigation.NavigationView;
|
import com.google.android.material.navigation.NavigationView;
|
||||||
|
@ -1377,6 +1379,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
||||||
if (actionBar != null) {
|
if (actionBar != null) {
|
||||||
actionBar.setDisplayShowTitleEnabled(false);
|
actionBar.setDisplayShowTitleEnabled(false);
|
||||||
}
|
}
|
||||||
|
manageTopBarScrolling(binding.toolbar);
|
||||||
rateThisApp();
|
rateThisApp();
|
||||||
|
|
||||||
binding.compose.setOnClickListener(v -> startActivity(new Intent(this, ComposeActivity.class)));
|
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);
|
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) {
|
private void manageFilters(int position) {
|
||||||
View view = binding.bottomNavView.findViewById(R.id.nav_home);
|
View view = binding.bottomNavView.findViewById(R.id.nav_home);
|
||||||
boolean showExtendedFilter = true;
|
boolean showExtendedFilter = true;
|
||||||
|
|
|
@ -30,10 +30,13 @@ import android.view.MenuItem;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.preference.PreferenceManager;
|
import androidx.preference.PreferenceManager;
|
||||||
|
|
||||||
|
import com.google.android.material.appbar.AppBarLayout;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
@ -87,6 +90,7 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon
|
||||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||||
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
getSupportActionBar().setDisplayShowHomeEnabled(true);
|
||||||
}
|
}
|
||||||
|
manageTopBarScrolling(binding.toolbar, sharedpreferences);
|
||||||
displayCW = sharedpreferences.getBoolean(getString(R.string.SET_EXPAND_CW), false);
|
displayCW = sharedpreferences.getBoolean(getString(R.string.SET_EXPAND_CW), false);
|
||||||
focusedStatus = null; // or other values
|
focusedStatus = null; // or other values
|
||||||
MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account);
|
MastodonHelper.loadPPMastodon(binding.profilePicture, currentAccount.mastodon_account);
|
||||||
|
@ -131,6 +135,22 @@ public class ContextActivity extends BaseActivity implements FragmentMastodonCon
|
||||||
outState.clear();
|
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() {
|
private void loadLocalConversation() {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putSerializable(Helper.ARG_STATUS, focusedStatus);
|
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);
|
editor.putString(getString(R.string.SET_LOGO_LAUNCHER), newLauncher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (key.compareToIgnoreCase(getString(R.string.SET_DISABLE_TOPBAR_SCROLLING)) == 0) {
|
||||||
|
recreate = true;
|
||||||
|
}
|
||||||
editor.apply();
|
editor.apply();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1065,6 +1065,7 @@
|
||||||
<string name="SET_LONG_PRESS_STORE_MEDIA" translatable="false">SET_LONG_PRESS_STORE_MEDIA</string>
|
<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_UNFOLLOW_VALIDATION" translatable="false">SET_UNFOLLOW_VALIDATION</string>
|
||||||
<string name="SET_USE_SINGLE_TOPBAR" translatable="false">SET_USE_SINGLE_TOPBAR</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_COUNTERS" translatable="false">SET_DISPLAY_COUNTERS</string>
|
||||||
<string name="SET_DISPLAY_COMPACT_ACTION_BUTTON" translatable="false">SET_DISPLAY_COMPACT_ACTION_BUTTON</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="load_settings">Load exported settings</string>
|
||||||
<string name="push_distributors">Push distributor</string>
|
<string name="push_distributors">Push distributor</string>
|
||||||
<string name="set_single_topbar_title">Single action bar</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_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_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>
|
<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:summary="@string/set_single_topbar"
|
||||||
app:title="@string/set_single_topbar_title" />
|
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
|
<SwitchPreferenceCompat
|
||||||
app:defaultValue="false"
|
app:defaultValue="false"
|
||||||
app:iconSpaceReserved="false"
|
app:iconSpaceReserved="false"
|
||||||
|
|
Loading…
Reference in a new issue