Skip to content

Commit 45286d6

Browse files
committed
fix: Cropper screen action bar color inconsistency
The image clopper screen's action bar color is inconsistent with the color of the status bar and the preceding screen ("Add image"). This PR aims to fix the inconsistency. Accompanying it, this PR changes the icon references from the current icons (hard-coded in white color) managed in CanHub repository to the new icons managed in AnkiDroid repository.
1 parent 43cfaa6 commit 45286d6

File tree

7 files changed

+82
-25
lines changed

7 files changed

+82
-25
lines changed

AnkiDroid/src/main/java/com/ichi2/imagecropper/ImageCropper.kt

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import com.canhub.cropper.CropImageView
4040
import com.ichi2.anki.R
4141
import com.ichi2.anki.snackbar.showSnackbar
4242
import com.ichi2.anki.withProgress
43+
import com.ichi2.themes.setTransparentStatusBar
4344
import com.ichi2.utils.ContentResolverUtil
4445
import kotlinx.coroutines.launch
4546
import kotlinx.parcelize.Parcelize
@@ -71,6 +72,9 @@ class ImageCropper :
7172
supportActionBar?.title = ""
7273
supportActionBar?.setDisplayHomeAsUpEnabled(true)
7374
}
75+
76+
requireActivity().setTransparentStatusBar()
77+
7478
cropImageView =
7579
view.findViewById<CropImageView>(R.id.cropImageView).apply {
7680
setOnSetImageUriCompleteListener(::onSetImageUriComplete)
@@ -119,44 +123,41 @@ class ImageCropper :
119123
menu: Menu,
120124
menuInflater: MenuInflater,
121125
) {
122-
menu.clear()
123-
// TODO make our own menu, we shouldn't rely on third party menu files
124-
menuInflater.inflate(com.canhub.cropper.R.menu.crop_image_menu, menu)
126+
menuInflater.inflate(R.menu.image_cropper_menu, menu)
125127
}
126128

127129
override fun onMenuItemSelected(menuItem: MenuItem): Boolean =
128130
when (menuItem.itemId) {
129-
com.canhub.cropper.R.id.crop_image_menu_crop -> {
130-
Timber.d("Crop image clicked")
131-
val imageFormat = cropImageView.imageUri?.let { getImageCompressFormat(it) }
132-
Timber.d("Compress format: $imageFormat")
133-
if (imageFormat != null) {
134-
cropImageView.croppedImageAsync(
135-
saveCompressFormat = imageFormat,
136-
)
137-
}
138-
true
139-
}
140-
141-
com.canhub.cropper.R.id.ic_rotate_right_24 -> {
142-
Timber.d("Rotate right clicked")
131+
R.id.action_rotate -> {
132+
Timber.d("Rotate clicked")
143133
cropImageView.rotateImage(90)
144134
true
145135
}
146136

147-
com.canhub.cropper.R.id.ic_flip_24_horizontally -> {
148-
Timber.d("Flip horizontally clicked")
149-
137+
R.id.action_flip_horizontally -> {
138+
Timber.d("Flip_horizontally clicked")
150139
cropImageView.flipImageHorizontally()
151140
true
152141
}
153142

154-
com.canhub.cropper.R.id.ic_flip_24_vertically -> {
155-
Timber.d("Flip vertically clicked")
143+
R.id.action_flip_vertically -> {
144+
Timber.d("Flip_vertically clicked")
156145
cropImageView.flipImageVertically()
157146
true
158147
}
159148

149+
R.id.action_done -> {
150+
Timber.d("Done clicked")
151+
val imageFormat = cropImageView.imageUri?.let { getImageCompressFormat(it) }
152+
Timber.d("Compress format: $imageFormat")
153+
if (imageFormat != null) {
154+
cropImageView.croppedImageAsync(
155+
saveCompressFormat = imageFormat,
156+
)
157+
}
158+
true
159+
}
160+
160161
else -> false
161162
}
162163

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24"
6+
android:tint="?attr/colorControlNormal">
7+
<path
8+
android:fillColor="@android:color/white"
9+
android:pathData="M15,21h2v-2h-2v2zM19,9h2L21,7h-2v2zM3,5v14c0,1.1 0.9,2 2,2h4v-2L5,19L5,5h4L9,3L5,3c-1.1,0 -2,0.9 -2,2zM19,3v2h2c0,-1.1 -0.9,-2 -2,-2zM11,23h2L13,1h-2v22zM19,17h2v-2h-2v2zM15,5h2L17,3h-2v2zM19,13h2v-2h-2v2zM19,21c1.1,0 2,-0.9 2,-2h-2v2z" />
10+
</vector>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24"
6+
android:tint="?attr/colorControlNormal">
7+
<path
8+
android:fillColor="@android:color/white"
9+
android:pathData="M15.55,5.55L11,1v3.07C7.06,4.56 4,7.92 4,12s3.05,7.44 7,7.93v-2.02c-2.84,-0.48 -5,-2.94 -5,-5.91s2.16,-5.43 5,-5.91L11,10l4.55,-4.45zM19.93,11c-0.17,-1.39 -0.72,-2.73 -1.62,-3.89l-1.42,1.42c0.54,0.75 0.88,1.6 1.02,2.47h2.02zM13,17.9v2.02c1.39,-0.17 2.74,-0.71 3.9,-1.61l-1.44,-1.44c-0.75,0.54 -1.59,0.89 -2.46,1.03zM16.89,15.48l1.42,1.41c0.9,-1.16 1.45,-2.5 1.62,-3.89h-2.02c-0.14,0.87 -0.48,1.72 -1.02,2.48z" />
10+
</vector>

AnkiDroid/src/main/res/layout/fragment_image_cropper.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
android:layout_width="match_parent"
3232
android:layout_height="wrap_content"
3333
android:minHeight="?attr/actionBarSize"
34-
android:background="?attr/appBarColor"
35-
android:theme="@style/ActionBarStyle"
3634
app:layout_constraintTop_toTopOf="parent"/>
3735

3836
<com.canhub.cropper.CropImageView
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!-- res/menu/image_cropper_menu.xml -->
2+
<menu xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto">
4+
<item
5+
android:id="@+id/action_rotate"
6+
android:title="@string/image_cropper_action_rotate"
7+
android:icon="@drawable/ic_rotate_right"
8+
app:showAsAction="always" />
9+
10+
<!-- Flip parent with submenu -->
11+
<item
12+
android:id="@+id/action_flip"
13+
android:title="@string/image_cropper_action_flip"
14+
android:icon="@drawable/ic_flip_horizontal"
15+
app:showAsAction="always">
16+
17+
<menu>
18+
<item
19+
android:id="@+id/action_flip_horizontally"
20+
android:title="@string/image_cropper_action_flip_horizontally" />
21+
<item
22+
android:id="@+id/action_flip_vertically"
23+
android:title="@string/image_cropper_action_flip_vertically" />
24+
</menu>
25+
</item>
26+
27+
<item
28+
android:id="@+id/action_done"
29+
android:title="@string/multimedia_editor_field_editing_done"
30+
android:icon="@drawable/ic_done"
31+
app:showAsAction="always" />
32+
</menu>

AnkiDroid/src/main/res/values/02-strings.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@
8888
<string name="missing_note_type">No note type found</string>
8989
<string name="card_previewer_empty_front_indicator" comment="Extra text appended onto a tab title in the card previewer so that the user can see at a glance whether a card has no front.">%1$s (empty)</string>
9090

91+
<!-- Image cropper -->
92+
<string name="image_cropper_action_rotate" maxLength="28" comment="Action in image cropper screen">Rotate</string>
93+
<string name="image_cropper_action_flip" maxLength="28" comment="Action in image cropper screen">Flip</string>
94+
<string name="image_cropper_action_flip_horizontally" maxLength="28" comment="Submenu action in image cropper screen">Flip horizontally</string>
95+
<string name="image_cropper_action_flip_vertically" maxLength="28" comment="Submenu action in image cropper screen">Flip vertically</string>
96+
9197
<!-- Timebox -->
9298
<string name="timebox_reached_title">Timebox reached</string>
9399
<plurals name="timebox_reached">

AnkiDroid/src/main/res/values/16-multimedia-editor.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<!-- Field editing general -->
2424
<!-- these are button names to convert field type -->
2525
<string name="multimedia_editor_field_editing_audio">Audio recording</string>
26-
<string name="multimedia_editor_field_editing_done" comment="Label of a button to tell the app that the current action is 'Done'.">Done</string>
26+
<string name="multimedia_editor_field_editing_done" maxLength="28" comment="Label of a button to tell the app that the current action is 'Done'.">Done</string>
2727

2828
<!-- Multimedia card editor activity -->
2929
<!-- for buttons -->

0 commit comments

Comments
 (0)