瀏覽代碼

m3 theming for backup fragnment

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 2 年之前
父節點
當前提交
1657850ccb

+ 1 - 1
app/build.gradle

@@ -355,7 +355,7 @@ dependencies {
     gplayImplementation "com.google.firebase:firebase-messaging:23.0.7"
 
     // TODO change back to tag before merging
-    implementation 'com.github.nextcloud.android-common:ui:8c24dfaa7d'
+    implementation 'com.github.nextcloud.android-common:ui:e05f5addf4'
 }
 
 configurations.all {

+ 4 - 4
app/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/BackupFragment.java

@@ -197,7 +197,7 @@ public class BackupFragment extends FileFragment implements DatePickerDialog.OnD
         }
 
         viewThemeUtils.material.colorMaterialButtonPrimaryFilled(binding.backupNow);
-        viewThemeUtils.platform.colorTextButtons(binding.contactsDatepicker);
+        viewThemeUtils.material.colorMaterialButtonPrimaryOutlined(binding.contactsDatepicker);
 
         int primaryAccentColor = themeColorUtils.primaryAccentColor(getContext());
         binding.dataToBackUpTitle.setTextColor(primaryAccentColor);
@@ -306,7 +306,7 @@ public class BackupFragment extends FileFragment implements DatePickerDialog.OnD
                     Collections.sort(backupFiles, new AlphanumComparator<>());
 
                     if (backupFiles == null || backupFiles.isEmpty()) {
-                        binding.contactsDatepicker.setVisibility(View.GONE);
+                        binding.contactsDatepicker.setVisibility(View.INVISIBLE);
                     } else {
                         binding.contactsDatepicker.setVisibility(View.VISIBLE);
                     }
@@ -556,8 +556,8 @@ public class BackupFragment extends FileFragment implements DatePickerDialog.OnD
             datePickerDialog.setTitle("");
             datePickerDialog.show();
 
-            datePickerDialog.getButton(DatePickerDialog.BUTTON_NEGATIVE).setTextColor(themeColorUtils.primaryColor(getContext(), true));
-            datePickerDialog.getButton(DatePickerDialog.BUTTON_POSITIVE).setTextColor(themeColorUtils.primaryColor(getContext(), true));
+            viewThemeUtils.platform.colorTextButtons(datePickerDialog.getButton(DatePickerDialog.BUTTON_NEGATIVE),
+                                                     datePickerDialog.getButton(DatePickerDialog.BUTTON_POSITIVE));
 
             // set background to transparent
             datePickerDialog.getButton(DatePickerDialog.BUTTON_NEGATIVE).setBackgroundColor(0x00000000);

+ 5 - 20
app/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/BackupListAdapter.kt

@@ -26,7 +26,6 @@ import android.content.Context
 import android.content.res.Resources
 import android.database.Cursor
 import android.graphics.BitmapFactory
-import android.graphics.PorterDuff
 import android.graphics.drawable.Drawable
 import android.provider.ContactsContract
 import android.view.LayoutInflater
@@ -51,7 +50,7 @@ import com.owncloud.android.ui.TextDrawable
 import com.owncloud.android.ui.fragment.contactsbackup.BackupListFragment.getDisplayName
 import com.owncloud.android.utils.BitmapUtils
 import com.owncloud.android.utils.DisplayUtils
-import com.owncloud.android.utils.theme.ThemeColorUtils
+import com.owncloud.android.utils.theme.newm3.ViewThemeUtils
 import ezvcard.VCard
 import ezvcard.property.Photo
 import third_parties.sufficientlysecure.AndroidCalendar
@@ -64,7 +63,7 @@ class BackupListAdapter(
     private val checkedCalendars: HashMap<String, Int> = HashMap(),
     val backupListFragment: BackupListFragment,
     val context: Context,
-    private val themeColorUtils: ThemeColorUtils
+    private val viewThemeUtils: ViewThemeUtils
 ) : SectionedRecyclerViewAdapter<SectionedViewHolder>() {
     private val calendarFiles = arrayListOf<OCFile>()
     private val contacts = arrayListOf<VCard>()
@@ -160,7 +159,7 @@ class BackupListAdapter(
     override fun onBindHeaderViewHolder(holder: SectionedViewHolder?, section: Int, expanded: Boolean) {
         val headerViewHolder = holder as BackupListHeaderViewHolder
 
-        headerViewHolder.binding.name.setTextColor(themeColorUtils.primaryColor(context))
+        viewThemeUtils.platform.colorPrimaryTextViewElement(headerViewHolder.binding.name)
 
         if (section == SECTION_CALENDAR) {
             headerViewHolder.binding.name.text = context.resources.getString(R.string.calendars)
@@ -207,6 +206,7 @@ class BackupListAdapter(
         setChecked(checkedVCards.contains(position), holder.binding.name)
 
         holder.binding.name.text = getDisplayName(vCard)
+        viewThemeUtils.platform.themeCheckedTextView(holder.binding.name)
 
         // photo
         if (vCard.photos.size > 0) {
@@ -229,24 +229,13 @@ class BackupListAdapter(
 
     private fun setChecked(checked: Boolean, checkedTextView: CheckedTextView) {
         checkedTextView.isChecked = checked
-        if (checked) {
-            checkedTextView.checkMarkDrawable
-                .setColorFilter(themeColorUtils.primaryColor(context), PorterDuff.Mode.SRC_ATOP)
-        } else {
-            checkedTextView.checkMarkDrawable.clearColorFilter()
-        }
     }
 
     private fun toggleVCard(holder: ContactItemViewHolder, position: Int) {
         holder.binding.name.isChecked = !holder.binding.name.isChecked
         if (holder.binding.name.isChecked) {
-            holder.binding.name.checkMarkDrawable.setColorFilter(
-                themeColorUtils.primaryColor(context),
-                PorterDuff.Mode.SRC_ATOP
-            )
             checkedVCards.add(position)
         } else {
-            holder.binding.name.checkMarkDrawable.clearColorFilter()
             checkedVCards.remove(position)
         }
 
@@ -295,6 +284,7 @@ class BackupListAdapter(
         val calendarName = name.substring(0, name.indexOf("_"))
         val date = name.substring(name.lastIndexOf("_") + 1).replace(".ics", "").replace("-", ":")
         holder.binding.name.text = context.resources.getString(R.string.calendar_name_linewrap, calendarName, date)
+        viewThemeUtils.platform.themeCheckedTextView(holder.binding.name)
         holder.setCalendars(ArrayList(AndroidCalendar.loadAll(context.contentResolver)))
         holder.binding.spinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
             override fun onItemSelected(parent: AdapterView<*>?, view: View?, calendarPosition: Int, id: Long) {
@@ -313,14 +303,9 @@ class BackupListAdapter(
         val checkedTextView = holder.binding.name
         checkedTextView.isChecked = !checkedTextView.isChecked
         if (checkedTextView.isChecked) {
-            checkedTextView.checkMarkDrawable.setColorFilter(
-                themeColorUtils.primaryColor(context),
-                PorterDuff.Mode.SRC_ATOP
-            )
             holder.showCalendars(true)
             checkedCalendars[calendarFiles[position].storagePath] = 0
         } else {
-            checkedTextView.checkMarkDrawable.clearColorFilter()
             checkedCalendars.remove(calendarFiles[position].storagePath)
             holder.showCalendars(false)
         }

+ 3 - 3
app/src/main/java/com/owncloud/android/ui/fragment/contactsbackup/BackupListFragment.java

@@ -155,7 +155,7 @@ public class BackupListFragment extends FileFragment implements Injectable {
                                                 new HashMap<>(),
                                                 this,
                                                 requireContext(),
-                                                themeColorUtils);
+                                                viewThemeUtils);
         } else {
             HashMap<String, Integer> checkedCalendarItems = new HashMap<>();
             String[] checkedCalendarItemsArray = savedInstanceState.getStringArray(CHECKED_CALENDAR_ITEMS_ARRAY_KEY);
@@ -185,7 +185,7 @@ public class BackupListFragment extends FileFragment implements Injectable {
                                                 checkedCalendarItems,
                                                 this,
                                                 requireContext(),
-                                                themeColorUtils);
+                                                viewThemeUtils);
         }
 
         binding.list.setAdapter(listAdapter);
@@ -250,7 +250,7 @@ public class BackupListFragment extends FileFragment implements Injectable {
             closeFragment();
         });
 
-        binding.restoreSelected.setTextColor(themeColorUtils.primaryAccentColor(getContext()));
+        viewThemeUtils.material.colorMaterialButtonPrimaryBorderless(binding.restoreSelected);
 
         return view;
     }

+ 22 - 19
app/src/main/res/layout/backup_fragment.xml

@@ -65,6 +65,7 @@
                 android:id="@+id/backup_settings_title"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
+                android:paddingBottom="@dimen/standard_quarter_padding"
                 android:text="@string/backup_settings"
                 android:textStyle="bold" />
 
@@ -93,7 +94,7 @@
                         android:layout_height="wrap_content"
                         android:text="@string/daily_backup"
                         android:textColor="@color/text_color"
-                        android:textSize="14sp" />
+                        android:textSize="@dimen/two_line_primary_text_size" />
 
                     <TextView
                         android:id="@+id/last_backup_with_date"
@@ -111,32 +112,34 @@
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="match_parent"
-            android:layout_margin="@dimen/standard_margin"
-            android:orientation="horizontal">
+            android:layout_marginTop="@dimen/standard_margin"
+            android:gravity="center"
+            android:orientation="horizontal"
+            android:weightSum="1.0">
+
+            <com.google.android.material.button.MaterialButton
+                android:id="@+id/contacts_datepicker"
+                style="@style/OutlinedButton"
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
+                android:layout_weight="0.5"
+                android:minHeight="@dimen/minimum_size_for_touchable_area"
+                android:text="@string/restore_backup"
+                android:visibility="invisible"
+                app:cornerRadius="@dimen/button_corner_radius"
+                tools:visibility="visible" />
 
             <com.google.android.material.button.MaterialButton
                 android:id="@+id/backup_now"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
+                android:layout_width="0dp"
+                android:layout_height="match_parent"
                 android:layout_marginStart="@dimen/standard_half_margin"
-                android:layout_marginEnd="@dimen/standard_half_margin"
-                android:layout_weight="1"
+                android:layout_weight="0.5"
+                android:minHeight="@dimen/minimum_size_for_touchable_area"
                 android:text="@string/contacts_backup_button"
                 android:theme="@style/Button.Primary"
                 app:cornerRadius="@dimen/button_corner_radius" />
 
-            <com.google.android.material.button.MaterialButton
-                android:id="@+id/contacts_datepicker"
-                style="@style/OutlinedButton"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_marginStart="@dimen/standard_half_margin"
-                android:layout_marginEnd="@dimen/standard_half_margin"
-                android:layout_weight="1"
-                android:text="@string/restore_backup"
-                android:visibility="gone"
-                app:cornerRadius="@dimen/button_corner_radius"
-                tools:visibility="visible" />
         </LinearLayout>
 
     </LinearLayout>

+ 3 - 0
app/src/main/res/layout/backuplist_fragment.xml

@@ -54,6 +54,9 @@
             style="@style/Button.Borderless"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
+            android:layout_marginStart="@dimen/standard_margin"
+            android:layout_marginEnd="@dimen/standard_margin"
+            android:minHeight="@dimen/minimum_size_for_touchable_area"
             android:text="@string/restore_selected" />
 
     </LinearLayout>