fix internal image zoom#3184
Conversation
|
Any chance the new file could be in Kotlin? Java is being deprecated by Google so I'd rather not accept more new Java code where it can be easily prevented. I haven't had time to review the actual change yet, but it seems this adds even more complexity to the view activity? Given Google is reducing support for Android XML and the view activity still depends on Android XML (and still needs to be migrated, see #2483), I will need to look closely if this won't make migrating the view activity harder. I'll get back later after a basic review, this might need its own view to prevent the already overly complex view activity to become even harder to migrate. |
|
thanks for coming back so quickly yes will do, but I'll need the next weekend for it . maybe its wise for me to rework this first, before you spend time looking at it but if youhave the time now that would be great of course too I will think about the issues and implications of the view activity and the #2483 thing as well; thanks for steering me toward this one update: just changed to a draft |
|
Had some time to test it. The zooming looks good, but I do worry about the extra complexity. Maybe the zooming can have its own UI, just a very minimal Jetpack Compose UI screen (look at AboutActivity for that) and we can just launch that from the view screen? I think that may be better for maintainability. |
a6c89ce to
27bcb6c
Compare
|
Hi , thanks for your comments again @TheLastProject let me know what else you'd like to have in there, whenever you have time |
TheLastProject
left a comment
There was a problem hiding this comment.
I'll have to take a deeper look soon, but the general flow seems reasonable. Noticing one consistency-with-rest-of-codebase issue. I'll do a test and deeper review later :)
| @Composable | ||
| fun LoyaltyCardImageScreen( | ||
| bitmap: Bitmap, | ||
| contentDescription: String, | ||
| onBack: () -> Unit, | ||
| ) { |
There was a problem hiding this comment.
Please put the ui elements in the compose directory as done with other activities.
There was a problem hiding this comment.
yea true, thx, see commit below
- keep new compose ui with existing compose code
TheLastProject
left a comment
There was a problem hiding this comment.
This is great, it works really well and the code is easy to understand for me. I'm quite happy to see more functionality move out of the LoyaltyCardView.java activity, so that's great too.
I found a few small issues and I think some file renames might be good for future maintainability but otherwise this is basically ready to be merged I think :)
|
|
||
| currentWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN) |
There was a problem hiding this comment.
We're not doing any input so this is unneeded
| currentWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN) |
| switch (imageType) { | ||
| case NONE: | ||
| case BARCODE: | ||
| return; | ||
| case ICON: | ||
| file = Utils.retrieveCardImageAsFile(this, loyaltyCardId, ImageLocationType.icon); | ||
| break; | ||
| startImageActivity(ImageLocationType.icon); | ||
| return; | ||
| case IMAGE_FRONT: | ||
| file = Utils.retrieveCardImageAsFile(this, loyaltyCardId, ImageLocationType.front); | ||
| break; | ||
| startImageActivity(ImageLocationType.front); | ||
| return; | ||
| case IMAGE_BACK: | ||
| file = Utils.retrieveCardImageAsFile(this, loyaltyCardId, ImageLocationType.back); | ||
| break; | ||
| case BARCODE: | ||
| Toast.makeText(this, R.string.barcodeLongPressMessage, Toast.LENGTH_SHORT).show(); | ||
| startImageActivity(ImageLocationType.back); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Android Studio complains about the unnecessary return. How about this? Then we even have logging in case something stupid gets done in the future :)
private void openImage(LoyaltyCardImageType imageType) {
switch (imageType) {
case ICON:
startImageActivity(ImageLocationType.icon);
break;
case IMAGE_FRONT:
startImageActivity(ImageLocationType.front);
break;
case IMAGE_BACK:
startImageActivity(ImageLocationType.back);
break;
default:
Log.w(TAG, "openImage called with unsupported image type");
}
}
| @StringRes contentDescriptionRes: Int, | ||
| onBack: () -> Unit, | ||
| ) { | ||
| var scale by remember { mutableStateOf(1F) } |
There was a problem hiding this comment.
Android Studio suggestion:
Prefer mutableFloatStateOf instead of mutableStateOf
| Icon( | ||
| imageVector = Icons.AutoMirrored.Filled.ArrowBack, | ||
| contentDescription = stringResource(R.string.back) | ||
| ) |
There was a problem hiding this comment.
The back icon remains black in dark mode. Maybe using the CatimaTopAppBar like in the AboutActivity makes sense? Also standardizes the UI more, which should help future maintenance.
There was a problem hiding this comment.
Maybe move this into it's own cardimageview package and rename it to LoyaltyCardImageViewActivity.kt, given how stand-alone it is and to make clear this is specifically for viewing images, nothing else?
There was a problem hiding this comment.
Sorry, I asked you already to move this to compose, but I think it may be best for this to use the same package as the activity. So maybe move this to compose/cardimageview/LoyaltyCardImageViewActivity.kt?
| import protect.card_locker.R | ||
|
|
||
| @Composable | ||
| fun LoyaltyCardImageScreen( |
There was a problem hiding this comment.
Given with the other renames, maybe LoyaltyCardImageViewScreen?
|
thanks ! i will try to get this done by the next weekend |
fix #2156
per the discussion; happy to change the PR with changes related to other issues (though I only digged up the 2156 one)
thanks for the great app, I really like it !