simplify primary borderless button theming

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2021-02-24 13:15:43 +01:00
parent 7ab77f7194
commit 2e7c16d736
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
17 changed files with 39 additions and 44 deletions

View file

@ -118,7 +118,6 @@ import com.owncloud.android.utils.MimeTypeUtil;
import com.owncloud.android.utils.PermissionUtil;
import com.owncloud.android.utils.PushUtils;
import com.owncloud.android.utils.theme.ThemeButtonUtils;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeSnackbarUtils;
import com.owncloud.android.utils.theme.ThemeToolbarUtils;
@ -307,8 +306,7 @@ public class FileDisplayActivity extends FileActivity
.create();
alertDialog.show();
ThemeButtonUtils.themeBorderlessButton(ThemeColorUtils.primaryAccentColor(this),
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE));
ThemeButtonUtils.themeBorderlessButton(alertDialog.getButton(AlertDialog.BUTTON_POSITIVE));
} catch (WindowManager.BadTokenException e) {
Log_OC.e(TAG, "Error showing wrong storage info, so skipping it: " + e.getMessage());
}

View file

@ -95,7 +95,7 @@ public class PassCodeActivity extends AppCompatActivity implements Injectable {
int elementColor = ThemeColorUtils.primaryColor(this, true);
ThemeButtonUtils.themeBorderlessButton(binding.cancel, ThemeColorUtils.primaryColor(this, true));
ThemeButtonUtils.themeBorderlessButton(ThemeColorUtils.primaryColor(this, true), binding.cancel);
passCodeEditTexts[0] = binding.txt0;
ThemeTextInputUtils.colorEditText(passCodeEditTexts[0], elementColor);

View file

@ -894,7 +894,7 @@ public class SettingsActivity extends ThemedPreferenceActivity
.create();
alertDialog.show();
ThemeButtonUtils.themeBorderlessButton(accentColor, alertDialog.getButton(AlertDialog.BUTTON_POSITIVE));
ThemeButtonUtils.themeBorderlessButton(alertDialog.getButton(AlertDialog.BUTTON_POSITIVE));
}
}
}

View file

@ -69,7 +69,6 @@ import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.PermissionUtil;
import com.owncloud.android.utils.SyncedFolderUtils;
import com.owncloud.android.utils.theme.ThemeButtonUtils;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeUtils;
import java.io.File;
@ -204,8 +203,7 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
.setMessage(getString(R.string.power_save_check_dialog_message))
.show();
ThemeButtonUtils.themeBorderlessButton(ThemeColorUtils.primaryAccentColor(this),
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE));
ThemeButtonUtils.themeBorderlessButton(alertDialog.getButton(AlertDialog.BUTTON_POSITIVE));
}
/**
@ -819,8 +817,7 @@ public class SyncedFoldersActivity extends FileActivity implements SyncedFolderA
if (getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.RESUMED)) {
AlertDialog alertDialog = alertDialogBuilder.show();
ThemeButtonUtils.themeBorderlessButton(ThemeColorUtils.primaryAccentColor(this),
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE),
ThemeButtonUtils.themeBorderlessButton(alertDialog.getButton(AlertDialog.BUTTON_POSITIVE),
alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL));
}
}

View file

@ -30,7 +30,6 @@ import com.nextcloud.client.di.Injectable;
import com.nextcloud.client.jobs.BackgroundJobManager;
import com.owncloud.android.R;
import com.owncloud.android.utils.theme.ThemeButtonUtils;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import javax.inject.Inject;
@ -67,8 +66,7 @@ public class AccountRemovalConfirmationDialog extends DialogFragment implements
AlertDialog alertDialog = (AlertDialog) getDialog();
ThemeButtonUtils.themeBorderlessButton(ThemeColorUtils.primaryAccentColor(getActivity()),
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE),
ThemeButtonUtils.themeBorderlessButton(alertDialog.getButton(AlertDialog.BUTTON_POSITIVE),
alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL));
}

View file

@ -117,8 +117,7 @@ public class ChooseRichDocumentsTemplateDialogFragment extends DialogFragment im
AlertDialog alertDialog = (AlertDialog) getDialog();
positiveButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
ThemeButtonUtils.themeBorderlessButton(ThemeColorUtils.primaryAccentColor(getContext()),
positiveButton,
ThemeButtonUtils.themeBorderlessButton(positiveButton,
alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL));
positiveButton.setOnClickListener(this);
positiveButton.setEnabled(false);

View file

@ -121,9 +121,7 @@ public class ChooseTemplateDialogFragment extends DialogFragment implements View
AlertDialog alertDialog = (AlertDialog) getDialog();
positiveButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
ThemeButtonUtils.themeBorderlessButton(ThemeColorUtils.primaryAccentColor(getContext()),
positiveButton,
alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL));
ThemeButtonUtils.themeBorderlessButton(positiveButton, alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL));
positiveButton.setOnClickListener(this);
positiveButton.setEnabled(false);

View file

@ -22,7 +22,6 @@ import android.os.Bundle;
import com.owncloud.android.R;
import com.owncloud.android.utils.theme.ThemeButtonUtils;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
@ -78,8 +77,7 @@ public class ConfirmationDialogFragment extends DialogFragment {
AlertDialog alertDialog = (AlertDialog) getDialog();
ThemeButtonUtils.themeBorderlessButton(ThemeColorUtils.primaryAccentColor(getContext()),
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE),
ThemeButtonUtils.themeBorderlessButton(alertDialog.getButton(AlertDialog.BUTTON_POSITIVE),
alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE),
alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL));
}

View file

@ -116,9 +116,7 @@ public class ConflictsResolveDialog extends DialogFragment {
}
positiveButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
ThemeButtonUtils.themeBorderlessButton(ThemeColorUtils.primaryAccentColor(getContext()),
positiveButton,
alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL));
ThemeButtonUtils.themeBorderlessButton(positiveButton, alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL));
positiveButton.setEnabled(false);
}

View file

@ -79,8 +79,7 @@ public class CreateFolderDialogFragment
AlertDialog alertDialog = (AlertDialog) getDialog();
ThemeButtonUtils.themeBorderlessButton(ThemeColorUtils.primaryAccentColor(getContext()),
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE),
ThemeButtonUtils.themeBorderlessButton(alertDialog.getButton(AlertDialog.BUTTON_POSITIVE),
alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL));
}

View file

@ -33,7 +33,6 @@ import com.owncloud.android.ui.adapter.StoragePathAdapter;
import com.owncloud.android.ui.adapter.StoragePathItem;
import com.owncloud.android.utils.FileStorageUtils;
import com.owncloud.android.utils.theme.ThemeButtonUtils;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import java.io.File;
import java.util.ArrayList;
@ -82,8 +81,7 @@ public class LocalStoragePathPickerDialogFragment extends DialogFragment
AlertDialog alertDialog = (AlertDialog) getDialog();
ThemeButtonUtils.themeBorderlessButton(ThemeColorUtils.primaryAccentColor(getContext()),
alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE));
ThemeButtonUtils.themeBorderlessButton(alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE));
}
@Override

View file

@ -81,8 +81,7 @@ public class NoteDialogFragment extends DialogFragment implements DialogInterfac
AlertDialog alertDialog = (AlertDialog) getDialog();
ThemeButtonUtils.themeBorderlessButton(ThemeColorUtils.primaryAccentColor(getContext()),
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE),
ThemeButtonUtils.themeBorderlessButton(alertDialog.getButton(AlertDialog.BUTTON_POSITIVE),
alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL));
}

View file

@ -113,8 +113,7 @@ public class SetupEncryptionDialogFragment extends DialogFragment {
positiveButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
neutralButton = alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL);
ThemeButtonUtils.themeBorderlessButton(ThemeColorUtils.primaryAccentColor(getContext()),
positiveButton,
ThemeButtonUtils.themeBorderlessButton(positiveButton,
neutralButton);
task = new DownloadKeysAsyncTask();
@ -412,9 +411,7 @@ public class SetupEncryptionDialogFragment extends DialogFragment {
positiveButton.setVisibility(View.VISIBLE);
neutralButton.setVisibility(View.VISIBLE);
ThemeButtonUtils.themeBorderlessButton(ThemeColorUtils.primaryAccentColor(getContext()),
positiveButton,
neutralButton);
ThemeButtonUtils.themeBorderlessButton(positiveButton, neutralButton);
keyResult = KEY_GENERATE;
}

View file

@ -68,8 +68,7 @@ public class SharePasswordDialogFragment extends DialogFragment implements Dialo
AlertDialog alertDialog = (AlertDialog) getDialog();
if (alertDialog != null) {
ThemeButtonUtils.themeBorderlessButton(ThemeColorUtils.primaryAccentColor(getContext()),
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE),
ThemeButtonUtils.themeBorderlessButton(alertDialog.getButton(AlertDialog.BUTTON_POSITIVE),
alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE));
ThemeButtonUtils.themeBorderlessButton(getResources().getColor(R.color.highlight_textColor_Warning),
alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL));

View file

@ -31,7 +31,6 @@ import com.owncloud.android.ui.dialog.ConfirmationDialogFragment.ConfirmationDia
import com.owncloud.android.ui.fragment.OCFileListFragment;
import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.theme.ThemeButtonUtils;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
@ -84,8 +83,7 @@ public class SyncFileNotEnoughSpaceDialogFragment extends ConfirmationDialogFrag
AlertDialog alertDialog = (AlertDialog) getDialog();
if (alertDialog != null) {
ThemeButtonUtils.themeBorderlessButton(ThemeColorUtils.primaryAccentColor(getActivity()),
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE),
ThemeButtonUtils.themeBorderlessButton(alertDialog.getButton(AlertDialog.BUTTON_POSITIVE),
alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL),
alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE));
}

View file

@ -208,7 +208,7 @@ public class SyncedFolderPreferencesDialogFragment extends DialogFragment {
mCancel = view.findViewById(R.id.cancel);
mSave = view.findViewById(R.id.save);
ThemeButtonUtils.themeBorderlessButton(accentColor, mCancel, mSave);
ThemeButtonUtils.themeBorderlessButton(mCancel, mSave);
// Set values
setEnabled(mSyncedFolder.isEnabled());

View file

@ -32,6 +32,7 @@ import android.widget.ImageButton;
import com.owncloud.android.R;
import androidx.annotation.ColorInt;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
/**
@ -64,7 +65,25 @@ public final class ThemeButtonUtils {
}
}
public static void themeBorderlessButton(int primaryColor, Button... buttons) {
/**
* theme buttons based on accent color.
*
* @param buttons borderless buttons to be themed
*/
public static void themeBorderlessButton(@Nullable Button... buttons) {
if (buttons == null || buttons.length < 1) {
return;
}
themeBorderlessButton(ThemeColorUtils.primaryAccentColor(buttons[0].getContext()), buttons);
}
/**
* theme buttons based on given color.
*
* @param color theme color
* @param buttons borderless buttons to be themed
*/
public static void themeBorderlessButton(int color, @Nullable Button... buttons) {
if (buttons == null || buttons.length < 1) {
return;
}
@ -76,7 +95,7 @@ public final class ThemeButtonUtils {
new int[]{-android.R.attr.state_enabled}, // disabled
},
new int[]{
primaryColor,
color,
disabledColor
}
);