From d81b6fe8accd9973dd278783d93e085494e346b4 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 14 Aug 2019 17:21:37 +0200 Subject: [PATCH] Cards everywhere --- .../java/eu/faircode/email/AdapterFolder.java | 30 +- .../eu/faircode/email/AdapterMessage.java | 28 +- .../eu/faircode/email/FragmentAccounts.java | 17 +- .../eu/faircode/email/FragmentAnswers.java | 20 +- .../eu/faircode/email/FragmentIdentities.java | 20 +- .../java/eu/faircode/email/FragmentRules.java | 21 +- .../eu/faircode/email/ViewCardOptional.java | 71 ++++ .../java/eu/faircode/email/ViewStripe.java | 39 ++ .../res/layout/include_message_compact.xml | 6 +- .../res/layout/include_message_normal.xml | 6 +- app/src/main/res/layout/item_account.xml | 393 +++++++++--------- app/src/main/res/layout/item_answer.xml | 39 +- app/src/main/res/layout/item_folder.xml | 19 +- .../res/layout/item_folder_unselectable.xml | 20 +- app/src/main/res/layout/item_identity.xml | 307 +++++++------- .../main/res/layout/item_message_compact.xml | 14 +- .../main/res/layout/item_message_normal.xml | 14 +- app/src/main/res/layout/item_rule.xml | 112 ++--- 18 files changed, 636 insertions(+), 540 deletions(-) create mode 100644 app/src/main/java/eu/faircode/email/ViewCardOptional.java create mode 100644 app/src/main/java/eu/faircode/email/ViewStripe.java diff --git a/app/src/main/java/eu/faircode/email/AdapterFolder.java b/app/src/main/java/eu/faircode/email/AdapterFolder.java index 06450f7e78..a1affad81e 100644 --- a/app/src/main/java/eu/faircode/email/AdapterFolder.java +++ b/app/src/main/java/eu/faircode/email/AdapterFolder.java @@ -37,14 +37,12 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; -import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; import androidx.appcompat.widget.PopupMenu; -import androidx.cardview.widget.CardView; import androidx.fragment.app.Fragment; import androidx.lifecycle.Lifecycle; import androidx.lifecycle.LifecycleObserver; @@ -75,12 +73,9 @@ public class AdapterFolder extends RecyclerView.Adapter. + + Copyright 2018-2019 by Marcel Bokhorst (M66B) +*/ + +import android.content.Context; +import android.content.SharedPreferences; +import android.graphics.Color; +import android.util.AttributeSet; +import android.widget.FrameLayout; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.cardview.widget.CardView; +import androidx.preference.PreferenceManager; + +public class ViewCardOptional extends CardView { + public ViewCardOptional(@NonNull Context context) { + super(context); + } + + public ViewCardOptional(@NonNull Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + } + + public ViewCardOptional(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + boolean cards = prefs.getBoolean("cards", true); + if (cards) { + int dp6 = Helper.dp2pixels(getContext(), 6); + int color = Helper.resolveColor(getContext(), R.attr.colorCardBackground); + + FrameLayout.LayoutParams lparam = (FrameLayout.LayoutParams) getLayoutParams(); + lparam.setMargins(dp6, dp6, dp6, dp6); + setLayoutParams(lparam); + + setRadius(dp6); + setElevation(dp6); + setCardBackgroundColor(color); + + getChildAt(0).setPadding(dp6, dp6, dp6, dp6); + } else { + setRadius(0); + setElevation(0); + setCardBackgroundColor(Color.TRANSPARENT); + } + } +} diff --git a/app/src/main/java/eu/faircode/email/ViewStripe.java b/app/src/main/java/eu/faircode/email/ViewStripe.java new file mode 100644 index 0000000000..302bb8cfef --- /dev/null +++ b/app/src/main/java/eu/faircode/email/ViewStripe.java @@ -0,0 +1,39 @@ +package eu.faircode.email; + +import android.content.Context; +import android.content.SharedPreferences; +import android.util.AttributeSet; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.cardview.widget.CardView; +import androidx.preference.PreferenceManager; + +public class ViewStripe extends CardView { + public ViewStripe(@NonNull Context context) { + super(context); + } + + public ViewStripe(@NonNull Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + } + + public ViewStripe(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + boolean circular = prefs.getBoolean("circular", true); + setRadius(circular ? Helper.dp2pixels(getContext(), 3) / 2f : 0f); + setElevation(0); + } + + @Override + public void setBackgroundColor(int color) { + setCardBackgroundColor(color); + } +} diff --git a/app/src/main/res/layout/include_message_compact.xml b/app/src/main/res/layout/include_message_compact.xml index 4d484c856f..b0c26962db 100644 --- a/app/src/main/res/layout/include_message_compact.xml +++ b/app/src/main/res/layout/include_message_compact.xml @@ -4,13 +4,11 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - diff --git a/app/src/main/res/layout/include_message_normal.xml b/app/src/main/res/layout/include_message_normal.xml index c21cd6f771..5be55a465e 100644 --- a/app/src/main/res/layout/include_message_normal.xml +++ b/app/src/main/res/layout/include_message_normal.xml @@ -3,13 +3,11 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - diff --git a/app/src/main/res/layout/item_account.xml b/app/src/main/res/layout/item_account.xml index d4598bc3a1..3f367580ac 100644 --- a/app/src/main/res/layout/item_account.xml +++ b/app/src/main/res/layout/item_account.xml @@ -4,213 +4,218 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - + android:layout_height="wrap_content"> - - - - - - - - - - - + android:background="?attr/activatableItemBackground" + android:foreground="?attr/selectableItemBackground"> - + - + - + - + - + - + - + - + - + - + - - + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_answer.xml b/app/src/main/res/layout/item_answer.xml index cdc4a9a5ed..bf88ececfe 100644 --- a/app/src/main/res/layout/item_answer.xml +++ b/app/src/main/res/layout/item_answer.xml @@ -4,24 +4,29 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - + android:layout_height="wrap_content"> - - + android:background="?attr/activatableItemBackground" + android:foreground="?attr/selectableItemBackground" + android:padding="6dp"> + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_folder.xml b/app/src/main/res/layout/item_folder.xml index ac9903bfa7..78d0a58830 100644 --- a/app/src/main/res/layout/item_folder.xml +++ b/app/src/main/res/layout/item_folder.xml @@ -4,30 +4,23 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - + android:layout_height="wrap_content"> + android:foreground="?attr/selectableItemBackground"> - @@ -257,5 +250,5 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvError" /> - + \ No newline at end of file diff --git a/app/src/main/res/layout/item_folder_unselectable.xml b/app/src/main/res/layout/item_folder_unselectable.xml index 99cf4878ed..7d1a3fd3c7 100644 --- a/app/src/main/res/layout/item_folder_unselectable.xml +++ b/app/src/main/res/layout/item_folder_unselectable.xml @@ -4,28 +4,20 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - + android:layout_height="wrap_content"> + android:layout_height="wrap_content"> - @@ -89,5 +81,5 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvName" /> - + \ No newline at end of file diff --git a/app/src/main/res/layout/item_identity.xml b/app/src/main/res/layout/item_identity.xml index bc11299990..fcdf9ea2ea 100644 --- a/app/src/main/res/layout/item_identity.xml +++ b/app/src/main/res/layout/item_identity.xml @@ -4,167 +4,172 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - + android:layout_height="wrap_content"> - - - - - - - - - + android:background="?attr/activatableItemBackground" + android:foreground="?attr/selectableItemBackground"> - + - + - + - + - + - + - + - - + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/item_message_compact.xml b/app/src/main/res/layout/item_message_compact.xml index da68312f2d..4690e8e33b 100644 --- a/app/src/main/res/layout/item_message_compact.xml +++ b/app/src/main/res/layout/item_message_compact.xml @@ -4,14 +4,9 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - + android:layout_height="wrap_content"> + android:focusableInTouchMode="true"> - + diff --git a/app/src/main/res/layout/item_message_normal.xml b/app/src/main/res/layout/item_message_normal.xml index 3e884a8622..896927540e 100644 --- a/app/src/main/res/layout/item_message_normal.xml +++ b/app/src/main/res/layout/item_message_normal.xml @@ -4,14 +4,9 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - + android:layout_height="wrap_content"> + android:focusableInTouchMode="true"> - + diff --git a/app/src/main/res/layout/item_rule.xml b/app/src/main/res/layout/item_rule.xml index 92f3c73d4d..a762789564 100644 --- a/app/src/main/res/layout/item_rule.xml +++ b/app/src/main/res/layout/item_rule.xml @@ -4,66 +4,70 @@ android:layout_width="match_parent" android:layout_height="wrap_content"> - + android:layout_height="wrap_content"> - + android:background="?attr/activatableItemBackground" + android:foreground="?attr/selectableItemBackground" + android:padding="6dp"> - + - + - + - + - + + + \ No newline at end of file