mirror of https://github.com/M66B/FairEmail.git
Card layout
This commit is contained in:
parent
78b2b58716
commit
d32137a689
|
@ -79,6 +79,7 @@ import android.widget.Button;
|
|||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
@ -179,6 +180,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
private boolean contacts;
|
||||
private float textSize;
|
||||
|
||||
private boolean cards;
|
||||
private boolean date;
|
||||
private boolean threading;
|
||||
private boolean circular;
|
||||
|
@ -230,6 +232,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
public class ViewHolder extends RecyclerView.ViewHolder implements
|
||||
View.OnClickListener, View.OnLongClickListener, View.OnKeyListener,
|
||||
BottomNavigationView.OnNavigationItemSelectedListener {
|
||||
private CardView card;
|
||||
private View view;
|
||||
private CardView vwColor;
|
||||
private ImageView ivExpander;
|
||||
|
@ -331,10 +334,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
ViewHolder(final View itemView) {
|
||||
super(itemView);
|
||||
|
||||
card = itemView.findViewById(R.id.card);
|
||||
view = itemView.findViewById(R.id.clItem);
|
||||
|
||||
vwColor = itemView.findViewById(R.id.vwColor);
|
||||
vwColor.setRadius(circular ? dp3 / 2f : 0f);
|
||||
ivExpander = itemView.findViewById(R.id.ivExpander);
|
||||
ivFlagged = itemView.findViewById(R.id.ivFlagged);
|
||||
ivAvatar = itemView.findViewById(R.id.ivAvatar);
|
||||
|
@ -357,6 +360,20 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
tvError = itemView.findViewById(R.id.tvError);
|
||||
pbLoading = itemView.findViewById(R.id.pbLoading);
|
||||
vwRipple = itemView.findViewById(R.id.vwRipple);
|
||||
|
||||
if (!cards) {
|
||||
FrameLayout.LayoutParams lparam = (FrameLayout.LayoutParams) card.getLayoutParams();
|
||||
lparam.setMargins(0, 0, 0, 0);
|
||||
card.setLayoutParams(lparam);
|
||||
|
||||
card.setRadius(0);
|
||||
card.setElevation(0);
|
||||
card.setCardBackgroundColor(Color.TRANSPARENT);
|
||||
|
||||
view.setPadding(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
vwColor.setRadius(circular ? dp3 / 2f : 0f);
|
||||
}
|
||||
|
||||
private void ensureExpanded() {
|
||||
|
@ -2989,6 +3006,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
|||
this.textSize = Helper.getTextSize(context, zoom);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
this.cards = prefs.getBoolean("cards", true);
|
||||
this.date = prefs.getBoolean("date", true);
|
||||
this.threading = prefs.getBoolean("threading", true);
|
||||
this.circular = prefs.getBoolean("circular", true);
|
||||
|
|
|
@ -191,6 +191,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
private long attachment = -1;
|
||||
private OpenPgpServiceConnection pgpService;
|
||||
|
||||
private boolean cards;
|
||||
private boolean date;
|
||||
private boolean threading;
|
||||
private boolean swipenav;
|
||||
|
@ -311,6 +312,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
|
||||
swipenav = prefs.getBoolean("swipenav", true);
|
||||
autoscroll = (prefs.getBoolean("autoscroll", false) || viewType == AdapterMessage.ViewType.THREAD);
|
||||
cards = prefs.getBoolean("cards", true);
|
||||
date = prefs.getBoolean("date", true);
|
||||
threading = prefs.getBoolean("threading", true);
|
||||
actionbar = prefs.getBoolean("actionbar", true);
|
||||
|
@ -455,17 +457,19 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
};
|
||||
rvMessage.setLayoutManager(llm);
|
||||
|
||||
DividerItemDecoration itemDecorator = new DividerItemDecoration(getContext(), llm.getOrientation()) {
|
||||
@Override
|
||||
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
|
||||
if (view.findViewById(R.id.clItem).getVisibility() == View.GONE)
|
||||
outRect.setEmpty();
|
||||
else
|
||||
super.getItemOffsets(outRect, view, parent, state);
|
||||
}
|
||||
};
|
||||
itemDecorator.setDrawable(getContext().getDrawable(R.drawable.divider));
|
||||
rvMessage.addItemDecoration(itemDecorator);
|
||||
if (!cards) {
|
||||
DividerItemDecoration itemDecorator = new DividerItemDecoration(getContext(), llm.getOrientation()) {
|
||||
@Override
|
||||
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
|
||||
if (view.findViewById(R.id.clItem).getVisibility() == View.GONE)
|
||||
outRect.setEmpty();
|
||||
else
|
||||
super.getItemOffsets(outRect, view, parent, state);
|
||||
}
|
||||
};
|
||||
itemDecorator.setDrawable(getContext().getDrawable(R.drawable.divider));
|
||||
rvMessage.addItemDecoration(itemDecorator);
|
||||
}
|
||||
|
||||
DividerItemDecoration dateDecorator = new DividerItemDecoration(getContext(), llm.getOrientation()) {
|
||||
@Override
|
||||
|
@ -524,6 +528,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
|||
TextView tvDate = header.findViewById(R.id.tvDate);
|
||||
tvDate.setTextSize(TypedValue.COMPLEX_UNIT_PX, Helper.getTextSize(parent.getContext(), adapter.getZoom()));
|
||||
|
||||
if (cards) {
|
||||
View vSeparatorDate = header.findViewById(R.id.vSeparatorDate);
|
||||
vSeparatorDate.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(new Date());
|
||||
cal.set(Calendar.HOUR_OF_DAY, 0);
|
||||
|
|
|
@ -38,7 +38,7 @@ public class FragmentOptions extends FragmentBase {
|
|||
private PagerAdapter adapter;
|
||||
|
||||
static String[] OPTIONS_RESTART = new String[]{
|
||||
"startup", "date", "threading", "avatars", "generated_icons", "identicons", "circular", "name_email", "subject_italic", "flags", "preview", "preview_italic",
|
||||
"startup", "cards", "date", "threading", "avatars", "generated_icons", "identicons", "circular", "name_email", "subject_italic", "flags", "preview", "preview_italic",
|
||||
"addresses", "attachments_alt", "contrast", "monospaced", "inline_images", "contact_images", "all_images", "collapse_quotes", "autocontent", "actionbar",
|
||||
"autoscroll", "swipenav", "autoexpand", "autoclose", "onclose",
|
||||
"subscriptions", "debug",
|
||||
|
|
|
@ -44,6 +44,7 @@ import androidx.preference.PreferenceManager;
|
|||
public class FragmentOptionsDisplay extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private Button btnTheme;
|
||||
private Spinner spStartup;
|
||||
private SwitchCompat swCards;
|
||||
private SwitchCompat swDate;
|
||||
private SwitchCompat swThreading;
|
||||
private SwitchCompat swAvatars;
|
||||
|
@ -68,7 +69,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
private SwitchCompat swActionbar;
|
||||
|
||||
private final static String[] RESET_OPTIONS = new String[]{
|
||||
"theme", "startup", "date", "threading", "avatars", "generated_icons", "identicons", "circular", "name_email", "subject_italic",
|
||||
"theme", "startup", "cards", "date", "threading", "avatars", "generated_icons", "identicons", "circular", "name_email", "subject_italic",
|
||||
"flags", "preview", "preview_italic", "addresses", "attachments_alt",
|
||||
"contrast", "monospaced", "inline_images", "contact_images", "all_images", "collapse_quotes", "autocontent", "actionbar",
|
||||
};
|
||||
|
@ -85,6 +86,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
|
||||
btnTheme = view.findViewById(R.id.btnTheme);
|
||||
spStartup = view.findViewById(R.id.spStartup);
|
||||
swCards = view.findViewById(R.id.swCards);
|
||||
swDate = view.findViewById(R.id.swDate);
|
||||
swThreading = view.findViewById(R.id.swThreading);
|
||||
swAvatars = view.findViewById(R.id.swAvatars);
|
||||
|
@ -133,6 +135,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
}
|
||||
});
|
||||
|
||||
swCards.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("cards", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
swDate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
|
@ -341,6 +350,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
|
|||
break;
|
||||
}
|
||||
|
||||
swCards.setChecked(prefs.getBoolean("cards", true));
|
||||
swDate.setChecked(prefs.getBoolean("date", true));
|
||||
swThreading.setChecked(prefs.getBoolean("threading", true));
|
||||
swAvatars.setChecked(prefs.getBoolean("avatars", true));
|
||||
|
|
|
@ -51,6 +51,18 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvStartup" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swCards"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:checked="true"
|
||||
android:text="@string/title_advanced_cards"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/spStartup"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swDate"
|
||||
android:layout_width="0dp"
|
||||
|
@ -60,7 +72,7 @@
|
|||
android:text="@string/title_advanced_date_header"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/spStartup"
|
||||
app:layout_constraintTop_toBottomOf="@id/swCards"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
|
|
|
@ -4,29 +4,40 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/clItem"
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/activatableItemBackground"
|
||||
android:descendantFocusability="beforeDescendants"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true">
|
||||
android:layout_margin="6dp"
|
||||
app:cardBackgroundColor="?attr/colorCardBackground"
|
||||
app:cardCornerRadius="6dp"
|
||||
app:cardElevation="6dp">
|
||||
|
||||
<include
|
||||
android:id="@+id/inHeader"
|
||||
layout="@layout/include_message_compact"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/clItem"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
android:background="?attr/activatableItemBackground"
|
||||
android:descendantFocusability="beforeDescendants"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:padding="6dp">
|
||||
|
||||
<ViewStub
|
||||
android:id="@+id/vsBody"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout="@layout/include_message_body"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/inHeader" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<include
|
||||
android:id="@+id/inHeader"
|
||||
layout="@layout/include_message_compact"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ViewStub
|
||||
android:id="@+id/vsBody"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout="@layout/include_message_body"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/inHeader" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</FrameLayout>
|
||||
|
|
|
@ -4,29 +4,40 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/clItem"
|
||||
<androidx.cardview.widget.CardView
|
||||
android:id="@+id/card"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/activatableItemBackground"
|
||||
android:descendantFocusability="beforeDescendants"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true">
|
||||
android:layout_margin="6dp"
|
||||
app:cardBackgroundColor="?attr/colorCardBackground"
|
||||
app:cardCornerRadius="6dp"
|
||||
app:cardElevation="6dp">
|
||||
|
||||
<include
|
||||
android:id="@+id/inHeader"
|
||||
layout="@layout/include_message_normal"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/clItem"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
android:background="?attr/activatableItemBackground"
|
||||
android:descendantFocusability="beforeDescendants"
|
||||
android:focusable="true"
|
||||
android:focusableInTouchMode="true"
|
||||
android:padding="6dp">
|
||||
|
||||
<ViewStub
|
||||
android:id="@+id/vsBody"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout="@layout/include_message_body"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/inHeader" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<include
|
||||
android:id="@+id/inHeader"
|
||||
layout="@layout/include_message_normal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<ViewStub
|
||||
android:id="@+id/vsBody"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout="@layout/include_message_body"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/inHeader" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
</FrameLayout>
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
<color name="lightColorDrawerScrim">#99000000</color>
|
||||
<color name="lightColorDrawerText">#111</color>
|
||||
<color name="lightColorDrawerBackground">#eee</color>
|
||||
<color name="lightColorCardBackground">#eee</color>
|
||||
|
||||
<color name="darkColorUnread">#fff</color>
|
||||
<color name="darkColorItemSelected">#444</color>
|
||||
|
@ -34,6 +35,7 @@
|
|||
<color name="darkColorDrawerScrim">#997f7f7f</color>
|
||||
<color name="darkColorDrawerText">#fff</color>
|
||||
<color name="darkColorDrawerBackground">#222</color>
|
||||
<color name="darkColorCardBackground">#222</color>
|
||||
|
||||
<!-- default: #323232 -->
|
||||
<color name="design_snackbar_background_color" tools:override="true">#222</color>
|
||||
|
|
|
@ -213,6 +213,7 @@
|
|||
<string name="title_advanced_browse">Browse messages on the server</string>
|
||||
|
||||
<string name="title_advanced_startup">Show on start screen</string>
|
||||
<string name="title_advanced_cards">Show cards</string>
|
||||
<string name="title_advanced_date_header">Group by date</string>
|
||||
<string name="title_advanced_threading">Conversation threading</string>
|
||||
<string name="title_advanced_avatars">Show contact photos</string>
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<attr name="colorDrawerScrim" format="reference" />
|
||||
<attr name="colorDrawerText" format="reference" />
|
||||
<attr name="colorDrawerBackground" format="reference" />
|
||||
<attr name="colorCardBackground" format="reference" />
|
||||
<attr name="activatableItemBackground" format="reference" />
|
||||
|
||||
<style name="AppThemeLight" parent="Base.Theme.AppCompat.Light.DarkActionBar">
|
||||
|
@ -24,6 +25,8 @@
|
|||
<item name="colorDrawerText">@color/lightColorDrawerText</item>
|
||||
<item name="colorDrawerBackground">@color/lightColorDrawerBackground</item>
|
||||
|
||||
<item name="colorCardBackground">@color/lightColorCardBackground</item>
|
||||
|
||||
<item name="activatableItemBackground">@drawable/activatable_item_background_light</item>
|
||||
|
||||
<item name="android:textColorLink">@color/colorAccentDark</item>
|
||||
|
@ -50,6 +53,8 @@
|
|||
<item name="colorDrawerText">@color/darkColorDrawerText</item>
|
||||
<item name="colorDrawerBackground">@color/darkColorDrawerBackground</item>
|
||||
|
||||
<item name="colorCardBackground">@color/darkColorCardBackground</item>
|
||||
|
||||
<item name="activatableItemBackground">@drawable/activatable_item_background_dark</item>
|
||||
|
||||
<item name="android:checkboxStyle">@style/checkboxStyle</item>
|
||||
|
|
Loading…
Reference in New Issue