Răsfoiți Sursa

move primary action button theming to new theming method

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 4 ani în urmă
părinte
comite
5b76892ab1

+ 6 - 5
src/main/java/com/owncloud/android/ui/activity/FolderPickerActivity.java

@@ -25,9 +25,7 @@ import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
-import android.content.res.ColorStateList;
 import android.content.res.Resources.NotFoundException;
-import android.graphics.PorterDuff;
 import android.os.Bundle;
 import android.os.Parcelable;
 import android.util.Log;
@@ -401,13 +399,16 @@ public class FolderPickerActivity extends FileActivity implements FileFragment.C
         mChooseBtn = findViewById(R.id.folder_picker_btn_choose);
 
         if (mChooseBtn != null) {
-            mChooseBtn.setBackgroundTintMode(PorterDuff.Mode.SRC_ATOP);
-            mChooseBtn.setBackgroundTintList(ColorStateList.valueOf(ThemeUtils.primaryColor(this, true)));
+            ThemeUtils.colorPrimaryButton(mChooseBtn, this);
             mChooseBtn.setOnClickListener(this);
         }
 
         if (mCancelBtn != null) {
-            mCancelBtn.setTextColor(ThemeUtils.primaryColor(this, true));
+            if (this instanceof FilePickerActivity) {
+                ThemeUtils.colorPrimaryButton(mCancelBtn, this);
+            } else {
+                mCancelBtn.setTextColor(ThemeUtils.primaryColor(this, true));
+            }
             mCancelBtn.setOnClickListener(this);
         }
     }

+ 1 - 1
src/main/java/com/owncloud/android/ui/activity/PassCodeActivity.java

@@ -98,7 +98,7 @@ public class PassCodeActivity extends AppCompatActivity implements Injectable {
         int elementColor = ThemeUtils.elementColor(this);
 
         mBCancel = findViewById(R.id.cancel);
-        mBCancel.setBackgroundColor(ThemeUtils.primaryColor(this));
+        ThemeUtils.colorPrimaryButton(mBCancel, this);
 
         mPassCodeHdr = findViewById(R.id.header);
         mPassCodeHdrExplanation = findViewById(R.id.explanation);

+ 3 - 7
src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java

@@ -765,19 +765,15 @@ public class ReceiveExternalFilesActivity extends FileActivity
                 mListView.setAdapter(sa);
             }
             MaterialButton btnChooseFolder = findViewById(R.id.uploader_choose_folder);
-            btnChooseFolder.setBackgroundTintMode(PorterDuff.Mode.SRC_ATOP);
-            btnChooseFolder.setBackgroundTintList(ColorStateList.valueOf(ThemeUtils.primaryColor(this, true)));
+            ThemeUtils.colorPrimaryButton(btnChooseFolder, this);
             btnChooseFolder.setOnClickListener(this);
-            btnChooseFolder.setTextColor(ThemeUtils.fontColor(this));
 
             if (mFile.canWrite()) {
                 btnChooseFolder.setEnabled(true);
-                btnChooseFolder.setBackgroundTintList(ColorStateList.valueOf(ThemeUtils.primaryColor(getAccount(),
-                                                                                                     true,
-                                                                                                     this)));
+                ThemeUtils.colorPrimaryButton(btnChooseFolder, this);
             } else {
                 btnChooseFolder.setEnabled(false);
-                btnChooseFolder.setBackgroundTintList(ColorStateList.valueOf(Color.GRAY));
+                btnChooseFolder.setBackgroundColor(Color.GRAY);
             }
 
             ThemeUtils.colorStatusBar(this);

+ 1 - 2
src/main/java/com/owncloud/android/ui/activity/SyncedFoldersActivity.java

@@ -243,8 +243,7 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
         adapter = new SyncedFolderAdapter(this, clock, gridWidth, this, lightVersion);
         syncedFolderProvider = new SyncedFolderProvider(getContentResolver(), preferences, clock);
         emptyContentIcon.setImageResource(R.drawable.nav_synced_folders);
-        emptyContentActionButton.setBackgroundColor(ThemeUtils.primaryColor(this));
-        emptyContentActionButton.setTextColor(ThemeUtils.fontColor(this));
+        ThemeUtils.colorPrimaryButton(emptyContentActionButton, this);
 
         final GridLayoutManager lm = new GridLayoutManager(this, gridWidth);
         adapter.setLayoutManager(lm);

+ 1 - 3
src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java

@@ -178,9 +178,7 @@ public class UploadFilesActivity extends FileActivity implements LocalFileListFr
         cancelButton.setOnClickListener(this);
 
         MaterialButton uploadButton = findViewById(R.id.upload_files_btn_upload);
-        uploadButton.setBackgroundTintMode(PorterDuff.Mode.SRC_ATOP);
-        uploadButton.setBackgroundTintList(ColorStateList.valueOf(ThemeUtils.primaryColor(this, true)));
-        uploadButton.setTextColor(ThemeUtils.fontColor(this, false));
+        ThemeUtils.colorPrimaryButton(uploadButton, this);
         uploadButton.setOnClickListener(this);
 
         sortButton = findViewById(R.id.sort_button);

+ 1 - 2
src/main/java/com/owncloud/android/ui/adapter/NotificationListAdapter.java

@@ -163,8 +163,7 @@ public class NotificationListAdapter extends RecyclerView.Adapter<NotificationLi
             int primaryColor = ThemeUtils.primaryColor(notificationsActivity);
 
             if (action.primary) {
-                button.setBackgroundColor(primaryColor);
-                button.setTextColor(ThemeUtils.fontColor(notificationsActivity));
+                ThemeUtils.colorPrimaryButton(button, notificationsActivity);
                 button.setTypeface(button.getTypeface(), Typeface.BOLD);
             } else {
                 button.setBackgroundColor(resources.getColor(R.color.grey_200));

+ 2 - 8
src/main/java/com/owncloud/android/ui/fragment/contactsbackup/ContactsBackupFragment.java

@@ -184,14 +184,8 @@ public class ContactsBackupFragment extends FileFragment implements DatePickerDi
             calendarPickerOpen = true;
         }
 
-        int primaryColor = ThemeUtils.primaryColor(getContext(), true);
-        int fontColor = ThemeUtils.fontColor(getContext(), false);
-
-        backupNow.setBackgroundColor(primaryColor);
-        backupNow.setTextColor(fontColor);
-
-        contactsDatePickerBtn.setBackgroundColor(primaryColor);
-        contactsDatePickerBtn.setTextColor(fontColor);
+        ThemeUtils.colorPrimaryButton(backupNow, getContext());
+        ThemeUtils.colorPrimaryButton(contactsDatePickerBtn, getContext());
 
         return view;
     }