Style seek bar

This commit is contained in:
M66B 2019-05-07 22:18:30 +02:00
parent cc268a655a
commit 683c8d250e
2 changed files with 22 additions and 5 deletions

View File

@ -26,6 +26,7 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
@ -138,6 +139,7 @@ public class FragmentMessages extends FragmentBase {
private boolean date; private boolean date;
private boolean threading; private boolean threading;
private boolean pull; private boolean pull;
private boolean swipenav;
private boolean autoscroll; private boolean autoscroll;
private boolean actionbar; private boolean actionbar;
private boolean autoexpand; private boolean autoexpand;
@ -145,6 +147,9 @@ public class FragmentMessages extends FragmentBase {
private boolean autonext; private boolean autonext;
private boolean addresses; private boolean addresses;
private int colorPrimary;
private int colorAccent;
private long primary; private long primary;
private boolean outbox = false; private boolean outbox = false;
private boolean connected; private boolean connected;
@ -237,6 +242,7 @@ public class FragmentMessages extends FragmentBase {
else else
pull = false; pull = false;
swipenav = prefs.getBoolean("swipenav", true);
autoscroll = prefs.getBoolean("autoscroll", false); autoscroll = prefs.getBoolean("autoscroll", false);
date = prefs.getBoolean("date", true); date = prefs.getBoolean("date", true);
threading = prefs.getBoolean("threading", true); threading = prefs.getBoolean("threading", true);
@ -245,6 +251,9 @@ public class FragmentMessages extends FragmentBase {
autoclose = prefs.getBoolean("autoclose", true); autoclose = prefs.getBoolean("autoclose", true);
autonext = (!autoclose && prefs.getBoolean("autonext", false)); autonext = (!autoclose && prefs.getBoolean("autonext", false));
addresses = prefs.getBoolean("addresses", false); addresses = prefs.getBoolean("addresses", false);
colorPrimary = Helper.resolveColor(getContext(), R.attr.colorPrimary);
colorAccent = Helper.resolveColor(getContext(), R.attr.colorAccent);
} }
@Override @Override
@ -278,7 +287,6 @@ public class FragmentMessages extends FragmentBase {
// Wire controls // Wire controls
int colorPrimary = Helper.resolveColor(getContext(), R.attr.colorPrimary);
swipeRefresh.setColorSchemeColors(Color.WHITE, Color.WHITE, Color.WHITE); swipeRefresh.setColorSchemeColors(Color.WHITE, Color.WHITE, Color.WHITE);
swipeRefresh.setProgressBackgroundColorSchemeColor(colorPrimary); swipeRefresh.setProgressBackgroundColorSchemeColor(colorPrimary);
@ -438,6 +446,13 @@ public class FragmentMessages extends FragmentBase {
rvMessage.setAdapter(adapter); rvMessage.setAdapter(adapter);
seekBar.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return false;
}
});
bottom_navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() { bottom_navigation.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override @Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) { public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
@ -534,7 +549,6 @@ public class FragmentMessages extends FragmentBase {
// Initialize // Initialize
swipeRefresh.setEnabled(pull); swipeRefresh.setEnabled(pull);
tvNoEmail.setVisibility(View.GONE); tvNoEmail.setVisibility(View.GONE);
seekBar.setEnabled(false);
seekBar.setVisibility(View.GONE); seekBar.setVisibility(View.GONE);
bottom_navigation.getMenu().findItem(R.id.action_prev).setEnabled(false); bottom_navigation.getMenu().findItem(R.id.action_prev).setEnabled(false);
bottom_navigation.getMenu().findItem(R.id.action_next).setEnabled(false); bottom_navigation.getMenu().findItem(R.id.action_next).setEnabled(false);
@ -566,12 +580,15 @@ public class FragmentMessages extends FragmentBase {
if (actionbar) { if (actionbar) {
seekBar.setMax(size - 1); seekBar.setMax(size - 1);
seekBar.setProgress(size - 1 - position); seekBar.setProgress(size - 1 - position);
seekBar.getProgressDrawable().setAlpha(0);
seekBar.getThumb().setColorFilter(
position == 0 || position == size - 1 ? colorAccent : colorPrimary,
PorterDuff.Mode.SRC_IN);
seekBar.setVisibility(size > 1 ? View.VISIBLE : View.GONE); seekBar.setVisibility(size > 1 ? View.VISIBLE : View.GONE);
} }
} }
}); });
boolean swipenav = prefs.getBoolean("swipenav", true);
if (swipenav) { if (swipenav) {
Log.i("Swipe navigation"); Log.i("Swipe navigation");

View File

@ -149,7 +149,7 @@
android:layout_height="0dp" android:layout_height="0dp"
android:scrollbarStyle="outsideOverlay" android:scrollbarStyle="outsideOverlay"
android:scrollbars="vertical" android:scrollbars="vertical"
app:layout_constraintBottom_toTopOf="@+id/seekBar" app:layout_constraintBottom_toTopOf="@+id/bottom_navigation"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparatorHintSelect" /> app:layout_constraintTop_toBottomOf="@id/vSeparatorHintSelect" />
@ -160,7 +160,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:indeterminate="true" android:indeterminate="true"
app:layout_constraintBottom_toTopOf="@+id/seekBar" app:layout_constraintBottom_toTopOf="@+id/bottom_navigation"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/vSeparatorHintSelect" /> app:layout_constraintTop_toBottomOf="@id/vSeparatorHintSelect" />