Card layout

pull/161/head
M66B 6 years ago
parent 78b2b58716
commit d32137a689

@ -79,6 +79,7 @@ import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.EditText; import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@ -179,6 +180,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private boolean contacts; private boolean contacts;
private float textSize; private float textSize;
private boolean cards;
private boolean date; private boolean date;
private boolean threading; private boolean threading;
private boolean circular; private boolean circular;
@ -230,6 +232,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
public class ViewHolder extends RecyclerView.ViewHolder implements public class ViewHolder extends RecyclerView.ViewHolder implements
View.OnClickListener, View.OnLongClickListener, View.OnKeyListener, View.OnClickListener, View.OnLongClickListener, View.OnKeyListener,
BottomNavigationView.OnNavigationItemSelectedListener { BottomNavigationView.OnNavigationItemSelectedListener {
private CardView card;
private View view; private View view;
private CardView vwColor; private CardView vwColor;
private ImageView ivExpander; private ImageView ivExpander;
@ -331,10 +334,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ViewHolder(final View itemView) { ViewHolder(final View itemView) {
super(itemView); super(itemView);
card = itemView.findViewById(R.id.card);
view = itemView.findViewById(R.id.clItem); view = itemView.findViewById(R.id.clItem);
vwColor = itemView.findViewById(R.id.vwColor); vwColor = itemView.findViewById(R.id.vwColor);
vwColor.setRadius(circular ? dp3 / 2f : 0f);
ivExpander = itemView.findViewById(R.id.ivExpander); ivExpander = itemView.findViewById(R.id.ivExpander);
ivFlagged = itemView.findViewById(R.id.ivFlagged); ivFlagged = itemView.findViewById(R.id.ivFlagged);
ivAvatar = itemView.findViewById(R.id.ivAvatar); ivAvatar = itemView.findViewById(R.id.ivAvatar);
@ -357,6 +360,20 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
tvError = itemView.findViewById(R.id.tvError); tvError = itemView.findViewById(R.id.tvError);
pbLoading = itemView.findViewById(R.id.pbLoading); pbLoading = itemView.findViewById(R.id.pbLoading);
vwRipple = itemView.findViewById(R.id.vwRipple); 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() { private void ensureExpanded() {
@ -2989,6 +3006,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.textSize = Helper.getTextSize(context, zoom); this.textSize = Helper.getTextSize(context, zoom);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
this.cards = prefs.getBoolean("cards", true);
this.date = prefs.getBoolean("date", true); this.date = prefs.getBoolean("date", true);
this.threading = prefs.getBoolean("threading", true); this.threading = prefs.getBoolean("threading", true);
this.circular = prefs.getBoolean("circular", true); this.circular = prefs.getBoolean("circular", true);

@ -191,6 +191,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private long attachment = -1; private long attachment = -1;
private OpenPgpServiceConnection pgpService; private OpenPgpServiceConnection pgpService;
private boolean cards;
private boolean date; private boolean date;
private boolean threading; private boolean threading;
private boolean swipenav; private boolean swipenav;
@ -311,6 +312,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
swipenav = prefs.getBoolean("swipenav", true); swipenav = prefs.getBoolean("swipenav", true);
autoscroll = (prefs.getBoolean("autoscroll", false) || viewType == AdapterMessage.ViewType.THREAD); autoscroll = (prefs.getBoolean("autoscroll", false) || viewType == AdapterMessage.ViewType.THREAD);
cards = prefs.getBoolean("cards", true);
date = prefs.getBoolean("date", true); date = prefs.getBoolean("date", true);
threading = prefs.getBoolean("threading", true); threading = prefs.getBoolean("threading", true);
actionbar = prefs.getBoolean("actionbar", true); actionbar = prefs.getBoolean("actionbar", true);
@ -455,17 +457,19 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}; };
rvMessage.setLayoutManager(llm); rvMessage.setLayoutManager(llm);
DividerItemDecoration itemDecorator = new DividerItemDecoration(getContext(), llm.getOrientation()) { if (!cards) {
@Override DividerItemDecoration itemDecorator = new DividerItemDecoration(getContext(), llm.getOrientation()) {
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { @Override
if (view.findViewById(R.id.clItem).getVisibility() == View.GONE) public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
outRect.setEmpty(); if (view.findViewById(R.id.clItem).getVisibility() == View.GONE)
else outRect.setEmpty();
super.getItemOffsets(outRect, view, parent, state); else
} super.getItemOffsets(outRect, view, parent, state);
}; }
itemDecorator.setDrawable(getContext().getDrawable(R.drawable.divider)); };
rvMessage.addItemDecoration(itemDecorator); itemDecorator.setDrawable(getContext().getDrawable(R.drawable.divider));
rvMessage.addItemDecoration(itemDecorator);
}
DividerItemDecoration dateDecorator = new DividerItemDecoration(getContext(), llm.getOrientation()) { DividerItemDecoration dateDecorator = new DividerItemDecoration(getContext(), llm.getOrientation()) {
@Override @Override
@ -524,6 +528,11 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
TextView tvDate = header.findViewById(R.id.tvDate); TextView tvDate = header.findViewById(R.id.tvDate);
tvDate.setTextSize(TypedValue.COMPLEX_UNIT_PX, Helper.getTextSize(parent.getContext(), adapter.getZoom())); 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(); Calendar cal = Calendar.getInstance();
cal.setTime(new Date()); cal.setTime(new Date());
cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.HOUR_OF_DAY, 0);

@ -38,7 +38,7 @@ public class FragmentOptions extends FragmentBase {
private PagerAdapter adapter; private PagerAdapter adapter;
static String[] OPTIONS_RESTART = new String[]{ 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", "addresses", "attachments_alt", "contrast", "monospaced", "inline_images", "contact_images", "all_images", "collapse_quotes", "autocontent", "actionbar",
"autoscroll", "swipenav", "autoexpand", "autoclose", "onclose", "autoscroll", "swipenav", "autoexpand", "autoclose", "onclose",
"subscriptions", "debug", "subscriptions", "debug",

@ -44,6 +44,7 @@ import androidx.preference.PreferenceManager;
public class FragmentOptionsDisplay extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener { public class FragmentOptionsDisplay extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private Button btnTheme; private Button btnTheme;
private Spinner spStartup; private Spinner spStartup;
private SwitchCompat swCards;
private SwitchCompat swDate; private SwitchCompat swDate;
private SwitchCompat swThreading; private SwitchCompat swThreading;
private SwitchCompat swAvatars; private SwitchCompat swAvatars;
@ -68,7 +69,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swActionbar; private SwitchCompat swActionbar;
private final static String[] RESET_OPTIONS = new String[]{ 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", "flags", "preview", "preview_italic", "addresses", "attachments_alt",
"contrast", "monospaced", "inline_images", "contact_images", "all_images", "collapse_quotes", "autocontent", "actionbar", "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); btnTheme = view.findViewById(R.id.btnTheme);
spStartup = view.findViewById(R.id.spStartup); spStartup = view.findViewById(R.id.spStartup);
swCards = view.findViewById(R.id.swCards);
swDate = view.findViewById(R.id.swDate); swDate = view.findViewById(R.id.swDate);
swThreading = view.findViewById(R.id.swThreading); swThreading = view.findViewById(R.id.swThreading);
swAvatars = view.findViewById(R.id.swAvatars); 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() { swDate.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -341,6 +350,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
break; break;
} }
swCards.setChecked(prefs.getBoolean("cards", true));
swDate.setChecked(prefs.getBoolean("date", true)); swDate.setChecked(prefs.getBoolean("date", true));
swThreading.setChecked(prefs.getBoolean("threading", true)); swThreading.setChecked(prefs.getBoolean("threading", true));
swAvatars.setChecked(prefs.getBoolean("avatars", true)); swAvatars.setChecked(prefs.getBoolean("avatars", true));

@ -51,6 +51,18 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvStartup" /> 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 <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swDate" android:id="@+id/swDate"
android:layout_width="0dp" android:layout_width="0dp"
@ -60,7 +72,7 @@
android:text="@string/title_advanced_date_header" android:text="@string/title_advanced_date_header"
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/spStartup" app:layout_constraintTop_toBottomOf="@id/swCards"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat

@ -4,29 +4,40 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.cardview.widget.CardView
android:id="@+id/clItem" android:id="@+id/card"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/activatableItemBackground" android:layout_margin="6dp"
android:descendantFocusability="beforeDescendants" app:cardBackgroundColor="?attr/colorCardBackground"
android:focusable="true" app:cardCornerRadius="6dp"
android:focusableInTouchMode="true"> app:cardElevation="6dp">
<include <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/inHeader" android:id="@+id/clItem"
layout="@layout/include_message_compact"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent" android:background="?attr/activatableItemBackground"
app:layout_constraintTop_toTopOf="parent" /> android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:focusableInTouchMode="true"
android:padding="6dp">
<ViewStub <include
android:id="@+id/vsBody" android:id="@+id/inHeader"
android:layout_width="match_parent" layout="@layout/include_message_compact"
android:layout_height="wrap_content" android:layout_width="match_parent"
android:layout="@layout/include_message_body" android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/inHeader" /> app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<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> </FrameLayout>

@ -4,29 +4,40 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout <androidx.cardview.widget.CardView
android:id="@+id/clItem" android:id="@+id/card"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/activatableItemBackground" android:layout_margin="6dp"
android:descendantFocusability="beforeDescendants" app:cardBackgroundColor="?attr/colorCardBackground"
android:focusable="true" app:cardCornerRadius="6dp"
android:focusableInTouchMode="true"> app:cardElevation="6dp">
<include <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/inHeader" android:id="@+id/clItem"
layout="@layout/include_message_normal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent" android:background="?attr/activatableItemBackground"
app:layout_constraintTop_toTopOf="parent" /> android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:focusableInTouchMode="true"
android:padding="6dp">
<ViewStub <include
android:id="@+id/vsBody" android:id="@+id/inHeader"
android:layout_width="match_parent" layout="@layout/include_message_normal"
android:layout_height="wrap_content" android:layout_width="match_parent"
android:layout="@layout/include_message_body" android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/inHeader" /> app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<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> </FrameLayout>

@ -26,6 +26,7 @@
<color name="lightColorDrawerScrim">#99000000</color> <color name="lightColorDrawerScrim">#99000000</color>
<color name="lightColorDrawerText">#111</color> <color name="lightColorDrawerText">#111</color>
<color name="lightColorDrawerBackground">#eee</color> <color name="lightColorDrawerBackground">#eee</color>
<color name="lightColorCardBackground">#eee</color>
<color name="darkColorUnread">#fff</color> <color name="darkColorUnread">#fff</color>
<color name="darkColorItemSelected">#444</color> <color name="darkColorItemSelected">#444</color>
@ -34,6 +35,7 @@
<color name="darkColorDrawerScrim">#997f7f7f</color> <color name="darkColorDrawerScrim">#997f7f7f</color>
<color name="darkColorDrawerText">#fff</color> <color name="darkColorDrawerText">#fff</color>
<color name="darkColorDrawerBackground">#222</color> <color name="darkColorDrawerBackground">#222</color>
<color name="darkColorCardBackground">#222</color>
<!-- default: #323232 --> <!-- default: #323232 -->
<color name="design_snackbar_background_color" tools:override="true">#222</color> <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_browse">Browse messages on the server</string>
<string name="title_advanced_startup">Show on start screen</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_date_header">Group by date</string>
<string name="title_advanced_threading">Conversation threading</string> <string name="title_advanced_threading">Conversation threading</string>
<string name="title_advanced_avatars">Show contact photos</string> <string name="title_advanced_avatars">Show contact photos</string>

@ -6,6 +6,7 @@
<attr name="colorDrawerScrim" format="reference" /> <attr name="colorDrawerScrim" format="reference" />
<attr name="colorDrawerText" format="reference" /> <attr name="colorDrawerText" format="reference" />
<attr name="colorDrawerBackground" format="reference" /> <attr name="colorDrawerBackground" format="reference" />
<attr name="colorCardBackground" format="reference" />
<attr name="activatableItemBackground" format="reference" /> <attr name="activatableItemBackground" format="reference" />
<style name="AppThemeLight" parent="Base.Theme.AppCompat.Light.DarkActionBar"> <style name="AppThemeLight" parent="Base.Theme.AppCompat.Light.DarkActionBar">
@ -24,6 +25,8 @@
<item name="colorDrawerText">@color/lightColorDrawerText</item> <item name="colorDrawerText">@color/lightColorDrawerText</item>
<item name="colorDrawerBackground">@color/lightColorDrawerBackground</item> <item name="colorDrawerBackground">@color/lightColorDrawerBackground</item>
<item name="colorCardBackground">@color/lightColorCardBackground</item>
<item name="activatableItemBackground">@drawable/activatable_item_background_light</item> <item name="activatableItemBackground">@drawable/activatable_item_background_light</item>
<item name="android:textColorLink">@color/colorAccentDark</item> <item name="android:textColorLink">@color/colorAccentDark</item>
@ -50,6 +53,8 @@
<item name="colorDrawerText">@color/darkColorDrawerText</item> <item name="colorDrawerText">@color/darkColorDrawerText</item>
<item name="colorDrawerBackground">@color/darkColorDrawerBackground</item> <item name="colorDrawerBackground">@color/darkColorDrawerBackground</item>
<item name="colorCardBackground">@color/darkColorCardBackground</item>
<item name="activatableItemBackground">@drawable/activatable_item_background_dark</item> <item name="activatableItemBackground">@drawable/activatable_item_background_dark</item>
<item name="android:checkboxStyle">@style/checkboxStyle</item> <item name="android:checkboxStyle">@style/checkboxStyle</item>

Loading…
Cancel
Save