mirror of https://github.com/M66B/FairEmail.git
Added auto hide toolbar
This commit is contained in:
parent
0d395e54dc
commit
de672d0c05
|
@ -6,6 +6,12 @@
|
|||
|
||||
For support you can use [the contact form](https://contact.faircode.eu/?product=fairemailsupport).
|
||||
|
||||
### Next version
|
||||
|
||||
* Auto hide top toolbar when scrolling messages
|
||||
* Small improvements and minor bug fixes
|
||||
* Updated translations
|
||||
|
||||
### 1.2028 - 2023-01-06
|
||||
|
||||
* Small improvements and minor bug fixes
|
||||
|
|
|
@ -6,6 +6,12 @@
|
|||
|
||||
For support you can use [the contact form](https://contact.faircode.eu/?product=fairemailsupport).
|
||||
|
||||
### Next version
|
||||
|
||||
* Auto hide top toolbar when scrolling messages
|
||||
* Small improvements and minor bug fixes
|
||||
* Updated translations
|
||||
|
||||
### 1.2028 - 2023-01-06
|
||||
|
||||
* Small improvements and minor bug fixes
|
||||
|
|
|
@ -20,6 +20,7 @@ package eu.faircode.email;
|
|||
*/
|
||||
|
||||
import android.Manifest;
|
||||
import android.animation.ValueAnimator;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
|
@ -42,6 +43,7 @@ import android.view.Menu;
|
|||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
@ -832,6 +834,43 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
|||
return super.shouldUpRecreateTask(targetIntent);
|
||||
}
|
||||
|
||||
public ValueAnimator abAnimator = null;
|
||||
|
||||
public void showActionBar(boolean show) {
|
||||
ViewGroup abv = findViewById(R.id.action_bar);
|
||||
if (abv == null) {
|
||||
ActionBar ab = getSupportActionBar();
|
||||
if (ab == null)
|
||||
return;
|
||||
if (show)
|
||||
ab.show();
|
||||
else
|
||||
ab.hide();
|
||||
} else {
|
||||
if (abAnimator == null) {
|
||||
abAnimator = ValueAnimator.ofInt(0, Helper.getActionBarHeight(this));
|
||||
abAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
|
||||
@Override
|
||||
public void onAnimationUpdate(ValueAnimator anim) {
|
||||
abv.getLayoutParams().height = (Integer) anim.getAnimatedValue();
|
||||
abv.requestLayout();
|
||||
}
|
||||
});
|
||||
abAnimator.setDuration(250L);
|
||||
} else
|
||||
abAnimator.cancel();
|
||||
|
||||
int target = (show ? Helper.getActionBarHeight(this) : 0);
|
||||
if (abv.getLayoutParams().height == target)
|
||||
return;
|
||||
|
||||
if (show)
|
||||
abAnimator.start();
|
||||
else
|
||||
abAnimator.reverse();
|
||||
}
|
||||
}
|
||||
|
||||
Handler getMainHandler() {
|
||||
return ApplicationEx.getMainHandler();
|
||||
}
|
||||
|
|
|
@ -1301,6 +1301,8 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
|
|||
if (count == 0)
|
||||
finish();
|
||||
else {
|
||||
showActionBar(true);
|
||||
|
||||
if (count < lastBackStackCount) {
|
||||
Intent intent = getIntent();
|
||||
intent.setAction(null);
|
||||
|
|
|
@ -106,6 +106,12 @@ public class FragmentBase extends Fragment {
|
|||
return null;
|
||||
}
|
||||
|
||||
protected void showActionBar(boolean show) {
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity instanceof ActivityBase)
|
||||
((ActivityBase) activity).showActionBar(show);
|
||||
}
|
||||
|
||||
protected void setCount(String count) {
|
||||
this.count = count;
|
||||
updateSubtitle();
|
||||
|
|
|
@ -27,6 +27,7 @@ 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;
|
||||
|
@ -338,6 +339,7 @@ public class FragmentMessages extends FragmentBase
|
|||
|
||||
private WebView printWebView = null;
|
||||
|
||||
private boolean hide_toolbar;
|
||||
private boolean cards;
|
||||
private boolean dividers;
|
||||
private boolean category;
|
||||
|
@ -478,7 +480,7 @@ public class FragmentMessages extends FragmentBase
|
|||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
|
||||
swipenav = prefs.getBoolean("swipenav", true);
|
||||
hide_toolbar = prefs.getBoolean("hide_toolbar", true);
|
||||
cards = prefs.getBoolean("cards", true);
|
||||
dividers = prefs.getBoolean("dividers", true);
|
||||
category = prefs.getBoolean("group_category", false);
|
||||
|
@ -488,6 +490,7 @@ public class FragmentMessages extends FragmentBase
|
|||
date_bold = prefs.getBoolean("date_bold", false);
|
||||
threading = (prefs.getBoolean("threading", true) ||
|
||||
args.getBoolean("force_threading"));
|
||||
swipenav = prefs.getBoolean("swipenav", true);
|
||||
seekbar = prefs.getBoolean("seekbar", false);
|
||||
actionbar = prefs.getBoolean("actionbar", true);
|
||||
boolean actionbar_swap = prefs.getBoolean("actionbar_swap", false);
|
||||
|
@ -1105,6 +1108,8 @@ public class FragmentMessages extends FragmentBase
|
|||
});
|
||||
|
||||
rvMessage.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
private boolean show = true;
|
||||
|
||||
@Override
|
||||
public void onScrolled(@NonNull RecyclerView rv, int dx, int dy) {
|
||||
if (dy != 0) {
|
||||
|
@ -1115,6 +1120,19 @@ public class FragmentMessages extends FragmentBase
|
|||
updateExpanded();
|
||||
}
|
||||
}
|
||||
|
||||
if (hide_toolbar) {
|
||||
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 == SCROLL_STATE_IDLE)
|
||||
showActionBar(show);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ public class FragmentOptions extends FragmentBase {
|
|||
"cards", "beige", "tabular_card_bg", "shadow_unread", "shadow_border", "shadow_highlight", "dividers",
|
||||
"portrait2", "portrait2c", "portrait_min_size", "landscape", "landscape_min_size",
|
||||
"column_width",
|
||||
"nav_categories", "nav_count", "nav_unseen_drafts", "nav_count_pinned", "navbar_colorize",
|
||||
"hide_toolbar", "nav_categories", "nav_count", "nav_unseen_drafts", "nav_count_pinned", "navbar_colorize",
|
||||
"indentation", "date", "date_week", "date_fixed", "date_bold", "threading", "threading_unread",
|
||||
"highlight_unread", "highlight_color", "color_stripe", "color_stripe_wide",
|
||||
"avatars", "bimi", "favicons", "generated_icons", "identicons", "circular", "saturation", "brightness", "threshold",
|
||||
|
|
|
@ -87,6 +87,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
private SwitchCompat swClosePane;
|
||||
private TextView tvColumnWidth;
|
||||
private SeekBar sbColumnWidth;
|
||||
private SwitchCompat swHideToolbar;
|
||||
private SwitchCompat swNavOptions;
|
||||
private SwitchCompat swNavCategories;
|
||||
private SwitchCompat swNavMessageCount;
|
||||
|
@ -196,7 +197,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
"date", "date_week", "date_fixed", "date_bold", "group_category",
|
||||
"cards", "beige", "tabular_card_bg", "shadow_unread", "shadow_border", "shadow_highlight", "dividers",
|
||||
"portrait2", "portrait2c", "landscape", "close_pane", "column_width",
|
||||
"nav_options", "nav_categories", "nav_count", "nav_unseen_drafts", "nav_count_pinned", "navbar_colorize",
|
||||
"hide_toolbar", "nav_options", "nav_categories", "nav_count", "nav_unseen_drafts", "nav_count_pinned", "navbar_colorize",
|
||||
"threading", "threading_unread", "indentation", "seekbar", "actionbar", "actionbar_swap", "actionbar_color",
|
||||
"highlight_unread", "highlight_color", "color_stripe", "color_stripe_wide",
|
||||
"avatars", "bimi", "gravatars", "libravatars", "favicons", "favicons_partial", "generated_icons", "identicons",
|
||||
|
@ -250,6 +251,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
swClosePane = view.findViewById(R.id.swClosePane);
|
||||
tvColumnWidth = view.findViewById(R.id.tvColumnWidth);
|
||||
sbColumnWidth = view.findViewById(R.id.sbColumnWidth);
|
||||
swHideToolbar = view.findViewById(R.id.swHideToolbar);
|
||||
swNavOptions = view.findViewById(R.id.swNavOptions);
|
||||
swNavCategories = view.findViewById(R.id.swNavCategories);
|
||||
swNavMessageCount = view.findViewById(R.id.swNavMessageCount);
|
||||
|
@ -582,6 +584,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
}
|
||||
});
|
||||
|
||||
swHideToolbar.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("hide_toolbar", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
swNavOptions.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
|
@ -1409,6 +1418,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
tvColumnWidth.setText(getString(R.string.title_advanced_column_width, NF.format(column_width)));
|
||||
sbColumnWidth.setProgress(column_width);
|
||||
|
||||
swHideToolbar.setChecked(prefs.getBoolean("hide_toolbar", true));
|
||||
swNavOptions.setChecked(prefs.getBoolean("nav_options", true));
|
||||
swNavCategories.setChecked(prefs.getBoolean("nav_categories", false));
|
||||
swNavMessageCount.setChecked(prefs.getBoolean("nav_count", false));
|
||||
|
|
|
@ -883,14 +883,19 @@ public class Helper {
|
|||
|
||||
// View
|
||||
|
||||
static Integer actionBarHeight = null;
|
||||
|
||||
static int getActionBarHeight(Context context) {
|
||||
int actionBarHeight;
|
||||
TypedValue tv = new TypedValue();
|
||||
if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
|
||||
DisplayMetrics dm = context.getResources().getDisplayMetrics();
|
||||
return TypedValue.complexToDimensionPixelSize(tv.data, dm);
|
||||
} else
|
||||
return Helper.dp2pixels(context, 56);
|
||||
if (actionBarHeight == null) {
|
||||
TypedValue tv = new TypedValue();
|
||||
if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
|
||||
DisplayMetrics dm = context.getResources().getDisplayMetrics();
|
||||
actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, dm);
|
||||
} else
|
||||
actionBarHeight = Helper.dp2pixels(context, 56);
|
||||
}
|
||||
|
||||
return actionBarHeight;
|
||||
}
|
||||
|
||||
static int getBottomNavigationHeight(Context context) {
|
||||
|
|
|
@ -537,6 +537,17 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swHideToolbar"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_hide_toolbar"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvCaptionNavigation"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swNavOptions"
|
||||
android:layout_width="0dp"
|
||||
|
@ -545,7 +556,7 @@
|
|||
android:text="@string/title_advanced_nav_options"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvCaptionNavigation"
|
||||
app:layout_constraintTop_toBottomOf="@id/swHideToolbar"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
|
|
|
@ -506,6 +506,7 @@
|
|||
<string name="title_advanced_min_screen_size">Minimum screen size for splitting the screen</string>
|
||||
<string name="title_advanced_close_pane">Collapse row or column when closing a conversation</string>
|
||||
<string name="title_advanced_column_width">Message column width / row height: %1$s %%</string>
|
||||
<string name="title_advanced_hide_toolbar">Hide top toolbar when scrolling messages</string>
|
||||
<string name="title_advanced_nav_options">Show navigation menu options</string>
|
||||
<string name="title_advanced_nav_categories">Show account categories in the navigation menu</string>
|
||||
<string name="title_advanced_nav_pin">Pin navigation menu</string>
|
||||
|
|
|
@ -6,6 +6,12 @@ Pelecanimimus
|
|||
|
||||
For support you can use the contact form.
|
||||
|
||||
Next version
|
||||
|
||||
* Auto hide top toolbar when scrolling messages
|
||||
* Small improvements and minor bug fixes
|
||||
* Updated translations
|
||||
|
||||
1.2028 - 2023-01-06
|
||||
|
||||
* Small improvements and minor bug fixes
|
||||
|
|
Loading…
Reference in New Issue