mirror of https://github.com/M66B/FairEmail.git
Hide toolbar improvements
This commit is contained in:
parent
24cb83c93f
commit
b2fa1c596a
|
@ -847,8 +847,11 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
|||
else
|
||||
ab.hide();
|
||||
} else {
|
||||
int height = Helper.getActionBarHeight(this);
|
||||
int current = abv.getLayoutParams().height;
|
||||
int target = (show ? height : 0);
|
||||
if (abAnimator == null) {
|
||||
abAnimator = ValueAnimator.ofInt(0, Helper.getActionBarHeight(this));
|
||||
abAnimator = ValueAnimator.ofInt(current, target);
|
||||
abAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator anim) {
|
||||
|
@ -860,18 +863,13 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
|||
}
|
||||
}
|
||||
});
|
||||
abAnimator.setDuration(250L);
|
||||
} else
|
||||
} else {
|
||||
abAnimator.cancel();
|
||||
abAnimator.setIntValues(current, target);
|
||||
}
|
||||
|
||||
int target = (show ? Helper.getActionBarHeight(this) : 0);
|
||||
if (abv.getLayoutParams().height == target)
|
||||
return;
|
||||
|
||||
if (show)
|
||||
abAnimator.start();
|
||||
else
|
||||
abAnimator.reverse();
|
||||
abAnimator.setDuration(250L * Math.abs(current - target) / height);
|
||||
abAnimator.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -124,6 +124,7 @@ public class FragmentFolders extends FragmentBase {
|
|||
private boolean primary;
|
||||
private boolean show_hidden = false;
|
||||
private boolean show_flagged = false;
|
||||
private boolean hide_toolbar = false;
|
||||
private String searching = null;
|
||||
private AdapterFolder adapter;
|
||||
|
||||
|
@ -155,6 +156,7 @@ public class FragmentFolders extends FragmentBase {
|
|||
compact = prefs.getBoolean("compact_folders", true);
|
||||
show_hidden = false; // prefs.getBoolean("hidden_folders", false);
|
||||
show_flagged = prefs.getBoolean("flagged_folders", false);
|
||||
hide_toolbar = prefs.getBoolean("hide_toolbar", true);
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
ViewModelSelected selectedModel =
|
||||
|
@ -308,6 +310,26 @@ public class FragmentFolders extends FragmentBase {
|
|||
rvFolder.addItemDecoration(categoryDecorator);
|
||||
}
|
||||
|
||||
rvFolder.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
private boolean show = true;
|
||||
|
||||
@Override
|
||||
public void onScrolled(@NonNull RecyclerView rv, int dx, int dy) {
|
||||
if (hide_toolbar && dy != 0) {
|
||||
int range = rv.computeVerticalScrollRange();
|
||||
int extend = rv.computeVerticalScrollExtent();
|
||||
boolean canScrollVertical = (range > extend);
|
||||
show = (!canScrollVertical || (rv.computeVerticalScrollOffset() == 0 || dy < 0));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
||||
if (hide_toolbar && newState != RecyclerView.SCROLL_STATE_DRAGGING)
|
||||
showActionBar(show);
|
||||
}
|
||||
});
|
||||
|
||||
adapter = new AdapterFolder(this, account, unified, primary, compact, show_hidden, show_flagged, null);
|
||||
rvFolder.setAdapter(adapter);
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ import static android.text.format.DateUtils.FORMAT_SHOW_WEEKDAY;
|
|||
import static android.view.KeyEvent.ACTION_DOWN;
|
||||
import static android.view.KeyEvent.ACTION_UP;
|
||||
import static androidx.recyclerview.widget.RecyclerView.NO_POSITION;
|
||||
import static androidx.recyclerview.widget.RecyclerView.SCROLL_STATE_IDLE;
|
||||
import static org.openintents.openpgp.OpenPgpSignatureResult.RESULT_KEY_MISSING;
|
||||
import static org.openintents.openpgp.OpenPgpSignatureResult.RESULT_NO_SIGNATURE;
|
||||
import static org.openintents.openpgp.OpenPgpSignatureResult.RESULT_VALID_KEY_CONFIRMED;
|
||||
|
@ -1123,17 +1122,18 @@ public class FragmentMessages extends FragmentBase
|
|||
}
|
||||
}
|
||||
|
||||
if (hide_toolbar) {
|
||||
if (hide_toolbar && dy != 0) {
|
||||
int range = rv.computeVerticalScrollRange();
|
||||
int extend = rv.computeVerticalScrollExtent();
|
||||
int offset = rv.computeVerticalScrollOffset();
|
||||
boolean canScrollVertical = (range > extend);
|
||||
show = (!canScrollVertical || (rv.computeVerticalScrollOffset() == 0 || dy < 0));
|
||||
show = (!canScrollVertical || (offset == 0 || dy < 0));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
||||
if (hide_toolbar && newState == SCROLL_STATE_IDLE)
|
||||
if (hide_toolbar && newState != RecyclerView.SCROLL_STATE_DRAGGING)
|
||||
showActionBar(show);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue