diff options
author | Stefan Niedermann <info@niedermann.it> | 2020-04-12 21:18:55 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2020-04-12 21:18:55 +0300 |
commit | 6848325f2615030512cc218edc69882ae29d2be6 (patch) | |
tree | f8037f80d9c60277fba65f9779093c4f89dd5347 /app/src | |
parent | bed0467f47617ab83968b5174029d81c7d5322b6 (diff) |
#317 Adjust theme for each account
Dialogs & DeleteDialogs
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app/src')
16 files changed, 109 insertions, 89 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java index afa0e6dcb..2daef95fa 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java @@ -25,7 +25,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.annotation.RequiresApi; import androidx.appcompat.app.ActionBarDrawerToggle; -import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AppCompatDelegate; import androidx.core.view.GravityCompat; import androidx.lifecycle.LiveData; @@ -73,6 +72,7 @@ import it.niedermann.nextcloud.deck.ui.board.DeleteBoardListener; import it.niedermann.nextcloud.deck.ui.board.EditBoardDialogFragment; import it.niedermann.nextcloud.deck.ui.board.EditBoardListener; import it.niedermann.nextcloud.deck.ui.branding.BrandedActivity; +import it.niedermann.nextcloud.deck.ui.branding.BrandedAlertDialogBuilder; import it.niedermann.nextcloud.deck.ui.card.CardAdapter; import it.niedermann.nextcloud.deck.ui.card.EditActivity; import it.niedermann.nextcloud.deck.ui.exception.ExceptionHandler; @@ -696,7 +696,7 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener public void onResponse(Capabilities response) { if (response.getDeckVersion().compareTo(new Version(minimumServerAppMajor, minimumServerAppMinor, minimumServerAppPatch)) < 0) { deckVersionTooLowSnackbar = Snackbar.make(binding.coordinatorLayout, R.string.your_deck_version_is_too_old, Snackbar.LENGTH_INDEFINITE).setAction(R.string.simple_more, v -> { - new AlertDialog.Builder(MainActivity.this) + new BrandedAlertDialogBuilder(MainActivity.this) .setTitle(R.string.update_deck) .setMessage(R.string.deck_outdated_please_update) .setPositiveButton(R.string.simple_update, (dialog, whichButton) -> { @@ -717,7 +717,7 @@ public class MainActivity extends BrandedActivity implements DeleteStackListener } }); } catch (OfflineException e) { - new AlertDialog.Builder(MainActivity.this) + new BrandedAlertDialogBuilder(MainActivity.this) .setMessage(R.string.you_have_to_be_connected_to_the_internet_in_order_to_add_an_account) .setPositiveButton(R.string.simple_close, null) .show(); diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/SelectCardActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/SelectCardActivity.java index 682a1b136..83bf799eb 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/SelectCardActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/SelectCardActivity.java @@ -20,7 +20,7 @@ import it.niedermann.nextcloud.deck.R; import it.niedermann.nextcloud.deck.model.Attachment; import it.niedermann.nextcloud.deck.model.Board; import it.niedermann.nextcloud.deck.model.full.FullCard; -import it.niedermann.nextcloud.deck.ui.card.CardAdapter; +import it.niedermann.nextcloud.deck.ui.branding.BrandedAlertDialogBuilder; import it.niedermann.nextcloud.deck.ui.card.SelectCardListener; import it.niedermann.nextcloud.deck.util.ExceptionUtil; import it.niedermann.nextcloud.deck.util.FileUtils; @@ -62,7 +62,7 @@ public class SelectCardActivity extends MainActivity implements SelectCardListen } } catch (IllegalArgumentException e) { DeckLog.logError(e); - new AlertDialog.Builder(this) + new BrandedAlertDialogBuilder(this) .setTitle(R.string.error) .setMessage(R.string.operation_not_yet_supported) .setPositiveButton(R.string.simple_close, (a, b) -> finish()) @@ -98,7 +98,7 @@ public class SelectCardActivity extends MainActivity implements SelectCardListen private void handleException(Throwable throwable) { DeckLog.logError(throwable); String debugInfos = ExceptionUtil.getDebugInfos(this, throwable); - AlertDialog dialog = new AlertDialog.Builder(this) + AlertDialog dialog = new BrandedAlertDialogBuilder(this) .setTitle(R.string.error) .setMessage(debugInfos) .setPositiveButton(android.R.string.copy, (a, b) -> { diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/DeleteBoardDialogFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/DeleteBoardDialogFragment.java index 9574d96e1..a22c05c2f 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/DeleteBoardDialogFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/DeleteBoardDialogFragment.java @@ -10,9 +10,9 @@ import androidx.fragment.app.DialogFragment; import it.niedermann.nextcloud.deck.R; import it.niedermann.nextcloud.deck.model.Board; -import it.niedermann.nextcloud.deck.ui.view.DeleteDialogFragment; +import it.niedermann.nextcloud.deck.ui.branding.BrandedDeleteAlertDialogBuilder; -public class DeleteBoardDialogFragment extends DeleteDialogFragment { +public class DeleteBoardDialogFragment extends DialogFragment { private static final String KEY_BOARD = "board"; @@ -44,7 +44,7 @@ public class DeleteBoardDialogFragment extends DeleteDialogFragment { @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { - AlertDialog.Builder builder = new AlertDialog.Builder(requireContext()) + AlertDialog.Builder builder = new BrandedDeleteAlertDialogBuilder(requireContext()) .setTitle(getString(R.string.delete_something, board.getTitle())) .setMessage(R.string.delete_board_message) .setPositiveButton(R.string.simple_delete, (dialog, which) -> deleteBoardListener.onBoardDeleted(board)) diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/EditBoardDialogFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/EditBoardDialogFragment.java index 2bb9e8b26..900c473ca 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/EditBoardDialogFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/EditBoardDialogFragment.java @@ -12,6 +12,7 @@ import it.niedermann.nextcloud.deck.databinding.DialogBoardCreateBinding; import it.niedermann.nextcloud.deck.model.full.FullBoard; import it.niedermann.nextcloud.deck.persistence.sync.SyncManager; import it.niedermann.nextcloud.deck.ui.branding.BrandedActivity; +import it.niedermann.nextcloud.deck.ui.branding.BrandedAlertDialogBuilder; import it.niedermann.nextcloud.deck.ui.branding.BrandedDialogFragment; import static it.niedermann.nextcloud.deck.Application.NO_BOARD_ID; @@ -28,7 +29,9 @@ public class EditBoardDialogFragment extends BrandedDialogFragment { private FullBoard fullBoard = null; /** - * Use newInstance()-Method + * Use newInstance()-Method(dialog, which) -> { + * // Do something else + * } */ public EditBoardDialogFragment() { } @@ -51,7 +54,7 @@ public class EditBoardDialogFragment extends BrandedDialogFragment { long boardId = requireArguments().getLong(KEY_BOARD_ID); - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(requireContext()); + AlertDialog.Builder dialogBuilder = new BrandedAlertDialogBuilder(requireContext()); if (boardId == NO_BOARD_ID) { dialogBuilder.setTitle(R.string.add_board); @@ -104,7 +107,6 @@ public class EditBoardDialogFragment extends BrandedDialogFragment { @Override public void applyBrand(int mainColor, int textColor) { - super.applyBrand(mainColor, textColor); BrandedActivity.applyBrandToEditText(mainColor, textColor, binding.input); } }
\ No newline at end of file diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/accesscontrol/AccessControlDialogFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/accesscontrol/AccessControlDialogFragment.java index 0d0bd4a79..c7dbfd7d6 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/accesscontrol/AccessControlDialogFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/board/accesscontrol/AccessControlDialogFragment.java @@ -4,6 +4,7 @@ import android.app.Dialog; import android.os.Bundle; import android.view.View; import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; import android.widget.Toast; import androidx.annotation.NonNull; @@ -19,10 +20,11 @@ import it.niedermann.nextcloud.deck.model.User; import it.niedermann.nextcloud.deck.model.full.FullBoard; import it.niedermann.nextcloud.deck.persistence.sync.SyncManager; import it.niedermann.nextcloud.deck.ui.branding.BrandedActivity; +import it.niedermann.nextcloud.deck.ui.branding.BrandedAlertDialogBuilder; import it.niedermann.nextcloud.deck.ui.branding.BrandedDialogFragment; import it.niedermann.nextcloud.deck.ui.card.UserAutoCompleteAdapter; -public class AccessControlDialogFragment extends BrandedDialogFragment implements AccessControlChangedListener, AdapterView.OnItemClickListener { +public class AccessControlDialogFragment extends BrandedDialogFragment implements AccessControlChangedListener, OnItemClickListener { private DialogBoardShareBinding binding; @@ -48,7 +50,7 @@ public class AccessControlDialogFragment extends BrandedDialogFragment implement boardId = requireArguments().getLong(KEY_BOARD_ID); accountId = requireArguments().getLong(KEY_ACCOUNT_ID); - AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(requireContext()); + AlertDialog.Builder dialogBuilder = new BrandedAlertDialogBuilder(requireContext()); if (boardId == 0L || accountId == 0L) { throw new IllegalArgumentException("accountId and boardId must be provided"); @@ -112,7 +114,6 @@ public class AccessControlDialogFragment extends BrandedDialogFragment implement @Override public void applyBrand(int mainColor, int textColor) { - super.applyBrand(mainColor, textColor); BrandedActivity.applyBrandToEditText(mainColor, textColor, binding.people); } }
\ No newline at end of file diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedAlertDialogBuilder.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedAlertDialogBuilder.java new file mode 100644 index 000000000..e77050486 --- /dev/null +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedAlertDialogBuilder.java @@ -0,0 +1,44 @@ +package it.niedermann.nextcloud.deck.ui.branding; + +import android.content.Context; +import android.content.DialogInterface; +import android.widget.Button; + +import androidx.annotation.CallSuper; +import androidx.appcompat.app.AlertDialog; + +import org.jetbrains.annotations.NotNull; + +import it.niedermann.nextcloud.deck.Application; + +public class BrandedAlertDialogBuilder extends AlertDialog.Builder implements Branded { + + protected AlertDialog dialog; + + public BrandedAlertDialogBuilder(Context context) { + super(context); + } + + @NotNull + @Override + public AlertDialog create() { + this.dialog = super.create(); + dialog.setOnShowListener(dialog -> Application.registerBrandedComponent(getContext(), this)); + return dialog; + } + + @CallSuper + @Override + public void applyBrand(int mainColor, int textColor) { + final Button[] buttons = new Button[3]; + buttons[0] = dialog.getButton(DialogInterface.BUTTON_POSITIVE); + buttons[1] = dialog.getButton(DialogInterface.BUTTON_NEGATIVE); + buttons[2] = dialog.getButton(DialogInterface.BUTTON_NEUTRAL); + for (Button button : buttons) { + if (button != null) { + button.setTextColor(BrandedActivity.getColorDependingOnTheme(button.getContext(), mainColor)); + } + } + Application.deregisterBrandedComponent(this); + } +} diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedDeleteAlertDialogBuilder.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedDeleteAlertDialogBuilder.java new file mode 100644 index 000000000..29cac691f --- /dev/null +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedDeleteAlertDialogBuilder.java @@ -0,0 +1,26 @@ +package it.niedermann.nextcloud.deck.ui.branding; + +import android.content.Context; +import android.content.DialogInterface; +import android.widget.Button; + +import androidx.annotation.CallSuper; + +import it.niedermann.nextcloud.deck.R; + +public class BrandedDeleteAlertDialogBuilder extends BrandedAlertDialogBuilder { + + public BrandedDeleteAlertDialogBuilder(Context context) { + super(context); + } + + @CallSuper + @Override + public void applyBrand(int mainColor, int textColor) { + super.applyBrand(mainColor, textColor); + final Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE); + if (positiveButton != null) { + positiveButton.setTextColor(getContext().getResources().getColor(R.color.danger)); + } + } +} diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedDialogFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedDialogFragment.java index 27263ab43..8c7804def 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedDialogFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedDialogFragment.java @@ -1,16 +1,10 @@ package it.niedermann.nextcloud.deck.ui.branding; -import android.app.Dialog; -import android.content.DialogInterface; -import android.widget.Button; - -import androidx.annotation.CallSuper; -import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.DialogFragment; import it.niedermann.nextcloud.deck.Application; -public class BrandedDialogFragment extends DialogFragment implements Branded { +public abstract class BrandedDialogFragment extends DialogFragment implements Branded { @Override public void onResume() { @@ -23,22 +17,4 @@ public class BrandedDialogFragment extends DialogFragment implements Branded { Application.deregisterBrandedComponent(this); super.onPause(); } - - @CallSuper - @Override - public void applyBrand(int mainColor, int textColor) { - Dialog dialog = requireDialog(); - if (dialog instanceof AlertDialog) { - AlertDialog alertDialog = (AlertDialog) dialog; - Button[] buttons = new Button[3]; - buttons[0] = alertDialog.getButton(DialogInterface.BUTTON_POSITIVE); - buttons[1] = alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE); - buttons[2] = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL); - for (Button button : buttons) { - if (button != null) { - button.setTextColor(BrandedActivity.getColorDependingOnTheme(button.getContext(), mainColor)); - } - } - } - } } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardAdapter.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardAdapter.java index 9b09a1420..a417ea3c1 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardAdapter.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/CardAdapter.java @@ -16,7 +16,6 @@ import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.Fragment; import androidx.lifecycle.LifecycleOwner; import androidx.recyclerview.widget.RecyclerView; @@ -43,6 +42,7 @@ import it.niedermann.nextcloud.deck.model.full.FullCard; import it.niedermann.nextcloud.deck.model.full.FullStack; import it.niedermann.nextcloud.deck.persistence.sync.SyncManager; import it.niedermann.nextcloud.deck.persistence.sync.adapters.db.util.LiveDataHelper; +import it.niedermann.nextcloud.deck.ui.branding.BrandedAlertDialogBuilder; import it.niedermann.nextcloud.deck.util.DateUtil; import it.niedermann.nextcloud.deck.util.DimensionUtil; import it.niedermann.nextcloud.deck.util.ViewUtil; @@ -317,7 +317,7 @@ public class CardAdapter extends RecyclerView.Adapter<ItemCardViewHolder> implem } } final FullCard newCard = card; - new AlertDialog.Builder(context) + new BrandedAlertDialogBuilder(context) .setSingleChoiceItems(items, currentStackItem, (dialog, which) -> { dialog.cancel(); newCard.getCard().setStackId(availableStacks.get(which).getStack().getLocalId()); diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/EditActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/EditActivity.java index 34d6493b3..b4e8dbc1f 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/EditActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/EditActivity.java @@ -17,7 +17,6 @@ import android.widget.EditText; import androidx.annotation.ColorInt; import androidx.annotation.NonNull; -import androidx.appcompat.app.AlertDialog; import androidx.core.graphics.drawable.DrawableCompat; import com.google.android.material.tabs.TabLayout; @@ -38,6 +37,7 @@ import it.niedermann.nextcloud.deck.model.ocs.Version; import it.niedermann.nextcloud.deck.model.ocs.comment.DeckComment; import it.niedermann.nextcloud.deck.persistence.sync.SyncManager; import it.niedermann.nextcloud.deck.ui.branding.BrandedActivity; +import it.niedermann.nextcloud.deck.ui.branding.BrandedAlertDialogBuilder; import it.niedermann.nextcloud.deck.ui.card.attachments.NewCardAttachmentHandler; import it.niedermann.nextcloud.deck.ui.card.comments.CommentAddedListener; import it.niedermann.nextcloud.deck.ui.card.comments.CommentDeletedListener; @@ -180,7 +180,7 @@ public class EditActivity extends BrandedActivity implements CardDetailsListener fullCard.getCard().setTitle(CardUtil.generateTitleFromDescription(fullCard.getCard().getDescription())); } if (fullCard.getCard().getTitle().isEmpty()) { - new AlertDialog.Builder(this) + new BrandedAlertDialogBuilder(this) .setTitle(R.string.title_is_mandatory) .setMessage(R.string.provide_at_least_a_title_or_description) .setPositiveButton(android.R.string.ok, null) @@ -316,7 +316,7 @@ public class EditActivity extends BrandedActivity implements CardDetailsListener @Override public void finish() { if (!fullCard.equals(originalCard) && canEdit) { - new AlertDialog.Builder(this) + new BrandedAlertDialogBuilder(this) .setTitle(R.string.simple_save) .setMessage(R.string.do_you_want_to_save_your_changes) .setPositiveButton(R.string.simple_save, (dialog, whichButton) -> saveAndFinish()) diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/attachments/DeleteAttachmentDialogFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/attachments/DeleteAttachmentDialogFragment.java index 45c56595b..4e5676f05 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/attachments/DeleteAttachmentDialogFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/attachments/DeleteAttachmentDialogFragment.java @@ -10,9 +10,9 @@ import androidx.fragment.app.DialogFragment; import it.niedermann.nextcloud.deck.R; import it.niedermann.nextcloud.deck.model.Attachment; -import it.niedermann.nextcloud.deck.ui.view.DeleteDialogFragment; +import it.niedermann.nextcloud.deck.ui.branding.BrandedDeleteAlertDialogBuilder; -public class DeleteAttachmentDialogFragment extends DeleteDialogFragment { +public class DeleteAttachmentDialogFragment extends DialogFragment { private static final String KEY_ATTACHMENT = "attachment"; @@ -47,7 +47,7 @@ public class DeleteAttachmentDialogFragment extends DeleteDialogFragment { @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { - AlertDialog.Builder builder = new AlertDialog.Builder(requireContext()) + AlertDialog.Builder builder = new BrandedDeleteAlertDialogBuilder(requireContext()) .setTitle(getString(R.string.delete_something, attachment.getFilename())) .setMessage(R.string.attachment_delete_message) .setPositiveButton(R.string.simple_delete, (dialog, whichButton) -> deleteAttachmentListener.onAttachmentDeleted(attachment)) diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsEditDialogFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsEditDialogFragment.java index 4dbc22603..2502cc705 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsEditDialogFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/comments/CardCommentsEditDialogFragment.java @@ -10,7 +10,6 @@ import android.view.WindowManager; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.DialogFragment; import java.util.Objects; @@ -18,6 +17,7 @@ import java.util.Objects; import it.niedermann.nextcloud.deck.R; import it.niedermann.nextcloud.deck.databinding.DialogAddCommentBinding; import it.niedermann.nextcloud.deck.ui.branding.BrandedActivity; +import it.niedermann.nextcloud.deck.ui.branding.BrandedAlertDialogBuilder; import it.niedermann.nextcloud.deck.ui.branding.BrandedDialogFragment; public class CardCommentsEditDialogFragment extends BrandedDialogFragment { @@ -55,7 +55,7 @@ public class CardCommentsEditDialogFragment extends BrandedDialogFragment { public Dialog onCreateDialog(Bundle savedInstanceState) { binding = DialogAddCommentBinding.inflate(requireActivity().getLayoutInflater()); - return new AlertDialog.Builder(requireActivity()) + return new BrandedAlertDialogBuilder(requireActivity()) .setView(binding.getRoot()) .setTitle(R.string.simple_comment) .setNegativeButton(android.R.string.cancel, null) @@ -85,7 +85,6 @@ public class CardCommentsEditDialogFragment extends BrandedDialogFragment { @Override public void applyBrand(int mainColor, int textColor) { - super.applyBrand(mainColor, textColor); BrandedActivity.applyBrandToEditText(mainColor, textColor, binding.input); } } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/DeleteStackDialogFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/DeleteStackDialogFragment.java index da1070b4a..e0a741b00 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/DeleteStackDialogFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/DeleteStackDialogFragment.java @@ -9,9 +9,9 @@ import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.DialogFragment; import it.niedermann.nextcloud.deck.R; -import it.niedermann.nextcloud.deck.ui.view.DeleteDialogFragment; +import it.niedermann.nextcloud.deck.ui.branding.BrandedDeleteAlertDialogBuilder; -public class DeleteStackDialogFragment extends DeleteDialogFragment { +public class DeleteStackDialogFragment extends DialogFragment { private static final String KEY_STACK_ID = "stack_id"; @@ -44,7 +44,7 @@ public class DeleteStackDialogFragment extends DeleteDialogFragment { @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { - AlertDialog.Builder builder = new AlertDialog.Builder(requireContext()) + AlertDialog.Builder builder = new BrandedDeleteAlertDialogBuilder(requireContext()) .setTitle(R.string.delete_list) .setMessage(R.string.do_you_want_to_delete_the_current_list) .setPositiveButton(R.string.simple_delete, (dialog, whichButton) -> deleteStackListener.onStackDeleted(stackId)) diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/EditStackDialogFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/EditStackDialogFragment.java index 6e7cc817e..f71d66c92 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/EditStackDialogFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/stack/EditStackDialogFragment.java @@ -17,6 +17,7 @@ import java.util.Objects; import it.niedermann.nextcloud.deck.R; import it.niedermann.nextcloud.deck.databinding.DialogStackCreateBinding; import it.niedermann.nextcloud.deck.ui.branding.BrandedActivity; +import it.niedermann.nextcloud.deck.ui.branding.BrandedAlertDialogBuilder; import it.niedermann.nextcloud.deck.ui.branding.BrandedDialogFragment; import static it.niedermann.nextcloud.deck.Application.NO_STACK_ID; @@ -50,11 +51,9 @@ public class EditStackDialogFragment extends BrandedDialogFragment { public Dialog onCreateDialog(Bundle savedInstanceState) { binding = DialogStackCreateBinding.inflate(requireActivity().getLayoutInflater()); - AlertDialog.Builder builder = new AlertDialog.Builder(requireActivity()) + AlertDialog.Builder builder = new BrandedAlertDialogBuilder(requireActivity()) .setView(binding.getRoot()) - .setNegativeButton(android.R.string.cancel, (dialog, which) -> { - // Do something else - }); + .setNegativeButton(android.R.string.cancel, null); if (getArguments() == null) { throw new IllegalArgumentException("Please add at least stack id to the arguments"); } @@ -95,7 +94,6 @@ public class EditStackDialogFragment extends BrandedDialogFragment { @Override public void applyBrand(int mainColor, int textColor) { - super.applyBrand(mainColor, textColor); BrandedActivity.applyBrandToEditText(mainColor, textColor, binding.input); } } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/DeleteDialogFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/DeleteDialogFragment.java deleted file mode 100644 index 4ae92e43c..000000000 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/view/DeleteDialogFragment.java +++ /dev/null @@ -1,27 +0,0 @@ -package it.niedermann.nextcloud.deck.ui.view; - -import android.app.Dialog; -import android.content.DialogInterface; -import android.widget.Button; - -import androidx.annotation.ColorInt; -import androidx.appcompat.app.AlertDialog; - -import it.niedermann.nextcloud.deck.R; -import it.niedermann.nextcloud.deck.ui.branding.BrandedDialogFragment; - -public class DeleteDialogFragment extends BrandedDialogFragment { - - @Override - public void applyBrand(@ColorInt int mainColor, @ColorInt int textColor) { - super.applyBrand(mainColor, textColor); - final Dialog dialog = requireDialog(); - if (dialog instanceof AlertDialog) { - final Button positiveButton = ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_POSITIVE); - if (positiveButton != null) { - positiveButton.setTextColor(getResources().getColor(R.color.danger)); - } - } - } - -} diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/util/ExceptionUtil.java b/app/src/main/java/it/niedermann/nextcloud/deck/util/ExceptionUtil.java index c84cf1221..189233fbe 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/util/ExceptionUtil.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/util/ExceptionUtil.java @@ -22,6 +22,7 @@ import java.util.Objects; import it.niedermann.nextcloud.deck.BuildConfig; import it.niedermann.nextcloud.deck.R; +import it.niedermann.nextcloud.deck.ui.branding.BrandedAlertDialogBuilder; import static it.niedermann.nextcloud.deck.util.ClipboardUtil.copyToClipboard; @@ -86,7 +87,7 @@ public class ExceptionUtil { case 302: { Snackbar.make(targetView, R.string.server_misconfigured, Snackbar.LENGTH_LONG) .setAction(R.string.simple_more, v -> { - AlertDialog dialog = new AlertDialog.Builder(activity) + AlertDialog dialog = new BrandedAlertDialogBuilder(activity) .setTitle(R.string.server_misconfigured) .setMessage(activity.getString(R.string.server_misconfigured_explanation) + "\n\n\n" + debugInfos) .setPositiveButton(android.R.string.copy, (a, b) -> { @@ -104,7 +105,7 @@ public class ExceptionUtil { case 503: { Snackbar.make(targetView, R.string.server_error, Snackbar.LENGTH_LONG) .setAction(R.string.simple_more, v -> { - AlertDialog dialog = new AlertDialog.Builder(activity) + AlertDialog dialog = new BrandedAlertDialogBuilder(activity) .setTitle(R.string.server_error) .setMessage(activity.getString(R.string.server_error_explanation) + "\n\n\n" + debugInfos) .setPositiveButton(android.R.string.copy, (a, b) -> { @@ -122,7 +123,7 @@ public class ExceptionUtil { default: { Snackbar.make(targetView, R.string.error, Snackbar.LENGTH_LONG) .setAction(R.string.simple_more, v -> { - AlertDialog dialog = new AlertDialog.Builder(activity) + AlertDialog dialog = new BrandedAlertDialogBuilder(activity) .setTitle(R.string.server_error) .setMessage(debugInfos) .setPositiveButton(android.R.string.copy, (a, b) -> { |