Skip to content

Commit

Permalink
refactor: remove duplicated icons
Browse files Browse the repository at this point in the history
if only the color needs to be changed, there is no need for having both a light and a dark file

ic_send was actually unused
  • Loading branch information
BrayanDSO authored and david-allison committed Oct 27, 2023
1 parent 19ad510 commit 2e3daab
Show file tree
Hide file tree
Showing 24 changed files with 36 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ abstract class AbstractFlashcardViewer :
protected fun showDeleteNoteDialog() {
AlertDialog.Builder(this).show {
title(R.string.delete_card_title)
iconAttr(R.attr.dialogErrorIcon)
setIcon(R.drawable.ic_warning)
message(
text = resources.getString(
R.string.delete_note_message,
Expand Down
2 changes: 1 addition & 1 deletion AnkiDroid/src/main/java/com/ichi2/anki/DeckPicker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2382,7 +2382,7 @@ open class DeckPicker :
Timber.i("media sync disabled: displaying dialog")
AlertDialog.Builder(this).show {
setTitle(R.string.media_sync_required_title)
iconAttr(R.attr.dialogErrorIcon)
setIcon(R.drawable.ic_warning)
setMessage(R.string.media_sync_unavailable_message)
setPositiveButton(getString(R.string.scoped_storage_migrate)) { _, _ ->
Timber.i("Performing unsafe storage migration")
Expand Down
11 changes: 3 additions & 8 deletions AnkiDroid/src/main/java/com/ichi2/anki/NoteEditor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1286,27 +1286,22 @@ class NoteEditor : AnkiActivity(), DeckSelectionListener, SubtitleListener, Tags
newEditText.setCapitalize(prefs.getBoolean(PREF_NOTE_EDITOR_CAPITALIZE, true))
val mediaButton = editLineView.mediaButton
val toggleStickyButton = editLineView.toggleSticky
// Load icons from attributes
val icons = Themes.getResFromAttr(
this,
intArrayOf(R.attr.attachFileImage, R.attr.upDownImage, R.attr.toggleStickyImage)
)
// Make the icon change between media icon and switch field icon depending on whether editing note type
if (editModelMode && allowFieldRemapping()) {
// Allow remapping if originally more than two fields
mediaButton.setBackgroundResource(icons[1])
mediaButton.setBackgroundResource(R.drawable.ic_import_export)
setRemapButtonListener(mediaButton, i)
toggleStickyButton.setBackgroundResource(0)
} else if (editModelMode && !allowFieldRemapping()) {
mediaButton.setBackgroundResource(0)
toggleStickyButton.setBackgroundResource(0)
} else {
// Use media editor button if not changing note type
mediaButton.setBackgroundResource(icons[0])
mediaButton.setBackgroundResource(R.drawable.ic_attachment)
setMMButtonListener(mediaButton, i)
if (addNote) {
// toggle sticky button
toggleStickyButton.setBackgroundResource(icons[2])
toggleStickyButton.setBackgroundResource(R.drawable.ic_baseline_push_pin_24)
setToggleStickyButtonListener(toggleStickyButton, i)
} else {
toggleStickyButton.setBackgroundResource(0)
Expand Down
3 changes: 1 addition & 2 deletions AnkiDroid/src/main/java/com/ichi2/anki/ReadText.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import com.ichi2.libanki.DeckId
import com.ichi2.libanki.Sound.SoundSide
import com.ichi2.libanki.TTSTag
import com.ichi2.utils.HandlerUtils.postDelayedOnNewHandler
import com.ichi2.utils.iconAttr
import com.ichi2.utils.message
import com.ichi2.utils.positiveButton
import com.ichi2.utils.title
Expand Down Expand Up @@ -107,7 +106,7 @@ object ReadText {
if (availableTtsLocales.isEmpty()) {
Timber.w("ReadText.textToSpeech() no TTS languages available")
dialog.message(R.string.no_tts_available_message)
.iconAttr(R.attr.dialogErrorIcon)
.setIcon(R.drawable.ic_warning)
.positiveButton(R.string.dialog_ok)
} else {
val localeMappings: List<Pair<String, CharSequence>> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class BackupPromptDialog private constructor(private val windowContext: Context)
AlertDialog.Builder(context).show {
title(R.string.dismiss_backup_warning_title)
message(message)
iconAttr(R.attr.dialogErrorIcon)
setIcon(R.drawable.ic_warning)
positiveButton(R.string.dialog_cancel) { onCancel() }
negativeButton(R.string.button_disable_reminder) { onDisableReminder() }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class DatabaseErrorDialog : AsyncDialogFragment() {
dialog.show {
cancelable(false)
contentNullable(message)
iconAttr(R.attr.dialogErrorIcon)
icon(R.drawable.ic_warning)
positiveButton(R.string.error_handling_options) {
(activity as DeckPicker?)
?.showDatabaseErrorDialog(DIALOG_ERROR_HANDLING)
Expand All @@ -92,7 +92,7 @@ class DatabaseErrorDialog : AsyncDialogFragment() {
dialog.show {
cancelable(false)
contentNullable(message)
iconAttr(R.attr.dialogErrorIcon)
icon(R.drawable.ic_warning)
positiveButton(R.string.error_handling_options) {
(activity as DeckPicker?)
?.showDatabaseErrorDialog(DIALOG_ERROR_HANDLING)
Expand Down Expand Up @@ -146,7 +146,7 @@ class DatabaseErrorDialog : AsyncDialogFragment() {
i++
}
dialog.show {
iconAttr(R.attr.dialogErrorIcon)
icon(R.drawable.ic_warning)
negativeButton(R.string.dialog_cancel)
listItems(items = titles.toList().map { it as CharSequence }) { _: MaterialDialog, index: Int, _: CharSequence ->
when (mRepairValues[index]) {
Expand Down Expand Up @@ -183,7 +183,7 @@ class DatabaseErrorDialog : AsyncDialogFragment() {
// Allow user to run BackupManager.repairCollection()
dialog.show {
contentNullable(message)
iconAttr(R.attr.dialogErrorIcon)
icon(R.drawable.ic_warning)
positiveButton(R.string.dialog_positive_repair) {
(activity as DeckPicker).repairCollection()
dismissAllDialogFragments()
Expand Down Expand Up @@ -318,7 +318,7 @@ class DatabaseErrorDialog : AsyncDialogFragment() {
dialog.show {
cancelable(false)
contentNullable(message)
iconAttr(R.attr.dialogErrorIcon)
icon(R.drawable.ic_warning)
positiveButton(R.string.close) {
exit()
}
Expand Down Expand Up @@ -429,7 +429,7 @@ class DatabaseErrorDialog : AsyncDialogFragment() {
fun displayResetToNewDirectoryDialog(context: DeckPicker) {
AlertDialog.Builder(context).show {
title(R.string.backup_new_collection)
iconAttr(R.attr.dialogErrorIcon)
setIcon(R.drawable.ic_warning)
message(R.string.new_unsafe_collection)
positiveButton(R.string.dialog_positive_create) {
Timber.w("Creating new collection")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class DeckPickerConfirmDeleteDeckDialog : AnalyticsDialogFragment() {
return AlertDialog.Builder(requireActivity())
.setTitle(R.string.delete_deck_title)
.setMessage(requireArguments().getString("dialogMessage"))
.setIconAttribute(R.attr.dialogErrorIcon)
.setIcon(R.drawable.ic_warning)
.setPositiveButton(R.string.dialog_positive_delete) { _, _ ->
(activity as DeckPicker).deleteDeck(deckId)
(activity as DeckPicker).dismissAllDialogFragments()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SyncErrorDialog : AsyncDialogFragment() {
return when (requireArguments().getInt("dialogType")) {
DIALOG_USER_NOT_LOGGED_IN_SYNC -> {
// User not logged in; take them to login screen
dialog.setIconAttribute(R.attr.dialogSyncErrorIcon)
dialog.setIcon(R.drawable.ic_sync_problem)
.setPositiveButton(R.string.log_in) { _, _ ->
(activity as SyncErrorDialogListener).loginToSyncServer()
}
Expand All @@ -56,7 +56,7 @@ class SyncErrorDialog : AsyncDialogFragment() {
}
DIALOG_CONNECTION_ERROR -> {
// Connection error; allow user to retry or cancel
dialog.setIconAttribute(R.attr.dialogSyncErrorIcon)
dialog.setIcon(R.drawable.ic_sync_problem)
.setPositiveButton(R.string.retry) { _, _ ->
(activity as SyncErrorDialogListener).sync()
dismissAllDialogFragments()
Expand All @@ -68,7 +68,7 @@ class SyncErrorDialog : AsyncDialogFragment() {
}
DIALOG_SYNC_CONFLICT_RESOLUTION -> {
// Sync conflict; allow user to cancel, or choose between local and remote versions
dialog.setIconAttribute(R.attr.dialogSyncErrorIcon)
dialog.setIcon(R.drawable.ic_sync_problem)
.setPositiveButton(R.string.sync_conflict_keep_local_new) { _, _ ->
(activity as SyncErrorDialogListener?)
?.showSyncErrorDialog(DIALOG_SYNC_CONFLICT_CONFIRM_KEEP_LOCAL)
Expand All @@ -84,7 +84,7 @@ class SyncErrorDialog : AsyncDialogFragment() {
}
DIALOG_SYNC_CONFLICT_CONFIRM_KEEP_LOCAL -> {
// Confirmation before pushing local collection to server after sync conflict
dialog.setIconAttribute(R.attr.dialogSyncErrorIcon)
dialog.setIcon(R.drawable.ic_sync_problem)
.setPositiveButton(R.string.dialog_positive_replace) { _, _ ->
val activity = activity as SyncErrorDialogListener?
activity!!.sync(ConflictResolution.FULL_UPLOAD)
Expand All @@ -95,7 +95,7 @@ class SyncErrorDialog : AsyncDialogFragment() {
}
DIALOG_SYNC_CONFLICT_CONFIRM_KEEP_REMOTE -> {
// Confirmation before overwriting local collection with server collection after sync conflict
dialog.setIconAttribute(R.attr.dialogSyncErrorIcon)
dialog.setIcon(R.drawable.ic_sync_problem)
.setPositiveButton(R.string.dialog_positive_replace) { _, _ ->
val activity = activity as SyncErrorDialogListener?
activity!!.sync(ConflictResolution.FULL_DOWNLOAD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class AboutFragment : Fragment() {
fun showEnableDevOptionsDialog(context: Context) {
AlertDialog.Builder(context).show {
setTitle(R.string.dev_options_enabled_pref)
setIcon(R.drawable.ic_warning_black)
setIcon(R.drawable.ic_warning)
setMessage(R.string.dev_options_warning)
setPositiveButton(R.string.dialog_ok) { _, _ -> enableDevOptions() }
setNegativeButton(R.string.dialog_cancel) { _, _ -> clickCount = 0 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class AdvancedSettingsFragment : SettingsFragment() {
requirePreference<Preference>(R.string.pref_reset_languages_key).setOnPreferenceClickListener {
AlertDialog.Builder(requireContext()).show {
setTitle(R.string.reset_languages)
setIcon(R.drawable.ic_warning_black)
setIcon(R.drawable.ic_warning)
setMessage(R.string.reset_languages_question)
setPositiveButton(R.string.dialog_ok) { _, _ ->
if (MetaDB.resetLanguages(requireContext())) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<vector android:height="24dp"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"
android:tint="?attr/colorControlNormal">
<path android:fillColor="#FFFFFFFF"
android:strokeColor="#FF000000"
android:strokeWidth="0.3" android:pathData="M2,12.5C2,9.46 4.46,7 7.5,7H18c2.21,0 4,1.79 4,4s-1.79,4 -4,4H9.5C8.12,15 7,13.88 7,12.5S8.12,10 9.5,10H17v2H9.41c-0.55,0 -0.55,1 0,1H18c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2H7.5C5.57,9 4,10.57 4,12.5S5.57,16 7.5,16H17v2H7.5C4.46,18 2,15.54 2,12.5z"/>
</vector>
11 changes: 0 additions & 11 deletions AnkiDroid/src/main/res/drawable/ic_attachment_black.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="#FF000000"
android:fillColor="@color/white"
android:pathData="M9,3L5,6.99h3L8,14h2L10,6.99h3L9,3zM16,17.01L16,10h-2v7.01h-3L15,21l4,-3.99h-3z"/>
</vector>
5 changes: 0 additions & 5 deletions AnkiDroid/src/main/res/drawable/ic_import_export_white.xml

This file was deleted.

9 changes: 0 additions & 9 deletions AnkiDroid/src/main/res/drawable/ic_send_black.xml

This file was deleted.

5 changes: 0 additions & 5 deletions AnkiDroid/src/main/res/drawable/ic_send_white.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="#FF000000"
android:fillColor="@color/white"
android:pathData="M3,12c0,2.21 0.91,4.2 2.36,5.64L3,20h6v-6l-2.24,2.24C5.68,15.15 5,13.66 5,12c0,-2.61 1.67,-4.83 4,-5.65L9,4.26C5.55,5.15 3,8.27 3,12zM11,17h2v-2h-2v2zM21,4h-6v6l2.24,-2.24C18.32,8.85 19,10.34 19,12c0,2.61 -1.67,4.83 -4,5.65v2.09c3.45,-0.89 6,-4.01 6,-7.74 0,-2.21 -0.91,-4.2 -2.36,-5.64L21,4zM11,13h2L13,7h-2v6z"/>
</vector>
5 changes: 0 additions & 5 deletions AnkiDroid/src/main/res/drawable/ic_sync_problem_white.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="#FF000000"
android:fillColor="@color/white"
android:pathData="M1,21h22L12,2 1,21zM13,18h-2v-2h2v2zM13,14h-2v-4h2v4z"/>
</vector>
5 changes: 0 additions & 5 deletions AnkiDroid/src/main/res/drawable/ic_warning_white.xml

This file was deleted.

10 changes: 4 additions & 6 deletions AnkiDroid/src/main/res/layout/card_multimedia_editline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end|center_vertical"
android:background="?attr/toggleStickyImage"
android:background="@drawable/ic_baseline_push_pin_24"
android:layout_marginEnd="16dp"
app:layout_constraintEnd_toStartOf="@id/id_media_button"
app:layout_constraintTop_toTopOf="parent"
tools:background="@drawable/ic_baseline_push_pin_24"/>
app:layout_constraintTop_toTopOf="parent"/>


<ImageButton
Expand All @@ -37,11 +36,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="end|center_vertical"
android:background="?attr/attachFileImage"
android:background="@drawable/ic_attachment"
android:layout_marginEnd="16dp"
app:layout_constraintEnd_toStartOf="@id/id_expand_button"
app:layout_constraintTop_toTopOf="parent"
tools:background="@drawable/ic_attachment_black"/>
app:layout_constraintTop_toTopOf="parent"/>

<ImageButton
android:id="@+id/id_expand_button"
Expand Down
6 changes: 0 additions & 6 deletions AnkiDroid/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,6 @@
<attr name="buttonForegroundColor" format="color"/>
<!-- Images -->
<attr name="navDrawerImage" format="integer"/>
<attr name="attachFileImage" format="integer"/>
<attr name="toggleStickyImage" format="integer"/>
<attr name="upDownImage" format="integer"/>
<attr name="dialogErrorIcon" format="integer"/>
<attr name="dialogSyncErrorIcon" format="integer"/>
<attr name="dialogSendIcon" format="integer"/>

<!-- Filter Bottom Sheet -->
<attr name="filterSheetBackground" format="color"/>
Expand Down
6 changes: 0 additions & 6 deletions AnkiDroid/src/main/res/values/theme_dark.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,6 @@
<item name="fab_item_background">@drawable/fab_label_background</item>
<!-- Images -->
<item name="navDrawerImage">@drawable/nav_drawer_logo_dark_theme</item>
<item name="attachFileImage">@drawable/ic_attachment_white</item>
<item name="toggleStickyImage">@drawable/ic_baseline_push_pin_24</item>
<item name="upDownImage">@drawable/ic_import_export_white</item>
<item name="dialogErrorIcon">@drawable/ic_warning_white</item>
<item name="dialogSyncErrorIcon">@drawable/ic_sync_problem_white</item>
<item name="dialogSendIcon">@drawable/ic_send_white</item>
<!-- Dialog styles -->
<item name="android:listPreferredItemHeight">56dip</item>
<item name="md_color_button_text">@color/white</item>
Expand Down
6 changes: 0 additions & 6 deletions AnkiDroid/src/main/res/values/theme_light.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,6 @@ APIs. It's visible when there aren't enough decks to fill the screen.
<item name="fab_item_background">@drawable/fab_label_background</item>
<!-- Images -->
<item name="navDrawerImage">@drawable/nav_drawer_logo</item>
<item name="attachFileImage">@drawable/ic_attachment_black</item>
<item name="toggleStickyImage">@drawable/ic_baseline_push_pin_24</item>
<item name="upDownImage">@drawable/ic_import_export_black</item>
<item name="dialogErrorIcon">@drawable/ic_warning_black</item>
<item name="dialogSyncErrorIcon">@drawable/ic_sync_problem_black</item>
<item name="dialogSendIcon">@drawable/ic_send_black</item>
<!-- Dialog styles -->
<item name="android:listPreferredItemHeight">56dip</item>
<item name="md_color_button_text">@color/black</item>
Expand Down

0 comments on commit 2e3daab

Please sign in to comment.