-
Notifications
You must be signed in to change notification settings - Fork 318
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First poc of image processing using webview on NFTs Migrate Webview image processor to its own component Improve code injection using toString() & "show source" directive Move image fetching logic to own file Fix code injection (not calling Function.toString at compile) + add debug helper Add button to navigate to ImagePicker in NftViewer Add tip for code injection issue (first call of toString()) in debug Revert changes on NftImageViewer Add button to request compact raw data from webview script Comment Add props to set brightness & contrast (filter not working yet) Working flows on iOS: (image url / pick from gallery) -> crop at given ratio -> process Cleanup a bit the comments mess Fix android build issue by upgrading kotlin Add descriptive labelling in the main screen Gallery flow working on Android Make injected code type script Add multiple constrast filters using manual JS filter Avoid recomputing result twice in computeResult lint lint Fix import from URL on Android by downloading image in cache Improve display of the preview for each step (dimensions) Image resizing to target size (after crop, before processing) Fix expo-image-manipulator version to match expo-barcode-scanner's dependency on expo-image-loader version Fix ImageResizer: use fileURI instead of base64 (the former doesn't work on iOS) Fix rerenders Store floored value in rawResult to avoid division imprecisions Fix issues post rebase Cleanup types of image tools Implement BottomModal & CroppingScreen w/ navigation (WIP) Implement PreviewScreen Move DebugScreen to CustomImageNavigator Implement Step3Transfer with for now just a preview of the raw data Proper design of bottom modal Avoid loading source image data as base64 in JS to avoid memory issues Put back expo-file-system as it's required by expo-image-manipulator Less extreme contrast values post rebase on develop with RN upgrade Add rotate button in Step1Crop Fix contrast causing out of bound values (out of [0, 255]) Fix nav to CustomImage in NftViewer Fix gray level rounding Handle errors in loading flow Add error handling & loading state in import from gallery flow Add error handling in image preview, cropper, resizer, processor Add error handling in injected code Use regular image for debug link Add data validation: rebuild image from raw data & compare base64 with preview Fix lint & ts Add extreme aspect ratio image Add some alerts to debug importImageFromPhoneGallery more debug logs Add expo-image-picker because react-native-image-picker is buggy on samsung/xiaomi Remove debugging stuff in image importing flow Remove react-native-image-picker Move CustomImage entrypoints to debug screen Adapt cropper layout for "extreme" aspect ratio (above 2:1) Remove ImagePicker debug screen Remove unused variables Add "customImage" feature flag Update injected code doc Remove unused component Document components Remove react-native-image-picker lib Changesets Improve typing of Step1Crop params & loadImageToFileWithDimensions Remove unused imports Fix cleanup of image downloading useEffect (including cancellation) Change ImageResizer component to a hook + cleanup useEffect typing & typos Fix fitImageContain & document Improve injected code: pure functions where possible & documentation Type navigation of CustomImageNavigator Fix typing of ImageCropper (ref & style) Fix post rebase fix post rebase lint Add custom image (feature flagged) entry point in nft links panel Fix rendering logic of NftLinksPanel (with sections & separator between) update doc Disable back gesture in the Error Screen nft: add image/svg and image/svg+xml to mimeTypesMap for "image" Fix custom image entry in NFT: should only be visible if there is an "image" uri Remove fake url entrypoint Fix layout of cropping UI Revert bad change to NftViewer Remove image/svg image/svg+xml from mimetypesmap lint Add wording for screen headers Fix post rebase Fix post rebase Improve usage of the available area for the cropping UI Implement native ImagePickerModule for Android (better than expo-image-picker) Remove old dimensions logic Remove unneeded loading of original image dimensions Improve (Android) initial scaling of image in cropping UI (fills more space rather than fitting) Remove customImage flag from debug screen Fix post rebase
- Loading branch information
1 parent
6edf507
commit 4de7efb
Showing
48 changed files
with
2,478 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"live-mobile": patch | ||
--- | ||
|
||
Add custom image tool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@ledgerhq/live-common": patch | ||
--- | ||
|
||
Add "customImage" feature flag. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
apps/ledger-live-mobile/android/app/src/main/java/com/ledger/live/Constants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package com.ledger.live; | ||
|
||
public class Constants { | ||
public static final int REQUEST_ENABLE_BT = 0; | ||
public static final int REQUEST_IMAGE = 1; | ||
} |
90 changes: 90 additions & 0 deletions
90
apps/ledger-live-mobile/android/app/src/main/java/com/ledger/live/ImagePickerModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package com.ledger.live; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.content.pm.PackageManager; | ||
import android.content.pm.ResolveInfo; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import com.facebook.react.bridge.ActivityEventListener; | ||
import com.facebook.react.bridge.Arguments; | ||
import com.facebook.react.bridge.Promise; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.bridge.ReactContextBaseJavaModule; | ||
import com.facebook.react.bridge.ReactMethod; | ||
import com.facebook.react.bridge.WritableMap; | ||
|
||
import java.util.List; | ||
|
||
public class ImagePickerModule extends ReactContextBaseJavaModule implements ActivityEventListener{ | ||
private static String REACT_CLASS = "ImagePickerModule"; | ||
private static String E_NULL_RESULT = "E_NULL_RESULT"; | ||
|
||
private Promise pickerPromise; | ||
|
||
public ImagePickerModule(ReactApplicationContext context) { | ||
super(context); | ||
context.addActivityEventListener(this); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public String getName() { | ||
return REACT_CLASS; | ||
} | ||
|
||
@Override | ||
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) { | ||
try { | ||
if (requestCode == Constants.REQUEST_IMAGE) { | ||
if (resultCode == Activity.RESULT_CANCELED){ | ||
WritableMap map = Arguments.createMap(); | ||
map.putBoolean("cancelled", true); | ||
pickerPromise.resolve(map); | ||
} else if (data == null) { | ||
pickerPromise.reject(E_NULL_RESULT); | ||
} else if (resultCode == Activity.RESULT_OK) { | ||
if (pickerPromise == null) throw new Error(E_NULL_RESULT); | ||
WritableMap map = Arguments.createMap(); | ||
map.putString("uri", data.getData().toString()); | ||
pickerPromise.resolve(map); | ||
} else { | ||
pickerPromise.reject(String.valueOf(resultCode)); | ||
} | ||
pickerPromise = null; | ||
} | ||
} catch (Exception e) { | ||
if (pickerPromise != null) pickerPromise.reject(e); | ||
} | ||
} | ||
|
||
@Override | ||
public void onNewIntent(Intent intent) {} | ||
|
||
private String getDefaultPictureAppPackageName() { | ||
Intent intent = new Intent(Intent.ACTION_PICK); | ||
intent.setType("image/*"); | ||
List<ResolveInfo> pkgAppsList = getReactApplicationContext().getPackageManager().queryIntentActivities(intent, PackageManager.GET_RESOLVED_FILTER); | ||
try { | ||
return pkgAppsList.get(0).activityInfo.processName; | ||
} catch (Exception e) { | ||
return null; | ||
} | ||
} | ||
|
||
@ReactMethod | ||
public void pickImage(Promise promise) { | ||
pickerPromise = promise; | ||
try { | ||
String defaultPictureApp = getDefaultPictureAppPackageName(); | ||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT); | ||
intent.setType("image/*"); | ||
intent.addCategory(Intent.CATEGORY_OPENABLE); | ||
if (defaultPictureApp != null) intent.setPackage(defaultPictureApp); | ||
getCurrentActivity().startActivityForResult(intent, Constants.REQUEST_IMAGE); | ||
} catch(Exception e) { | ||
promise.reject(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.