207 lines
8.8 KiB
Java
207 lines
8.8 KiB
Java
|
package io.flutter.plugins.imagepicker;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.content.SharedPreferences;
|
||
|
import android.net.Uri;
|
||
|
import io.flutter.plugin.common.MethodCall;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.HashSet;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
class ImagePickerCache {
|
||
|
private static final String FLUTTER_IMAGE_PICKER_IMAGE_PATH_KEY = "flutter_image_picker_image_path";
|
||
|
private static final String MAP_KEY_ERROR_CODE = "errorCode";
|
||
|
private static final String MAP_KEY_ERROR_MESSAGE = "errorMessage";
|
||
|
static final String MAP_KEY_IMAGE_QUALITY = "imageQuality";
|
||
|
static final String MAP_KEY_MAX_HEIGHT = "maxHeight";
|
||
|
static final String MAP_KEY_MAX_WIDTH = "maxWidth";
|
||
|
static final String MAP_KEY_PATH = "path";
|
||
|
static final String MAP_KEY_PATH_LIST = "pathList";
|
||
|
private static final String MAP_KEY_TYPE = "type";
|
||
|
static final String SHARED_PREFERENCES_NAME = "flutter_image_picker_shared_preference";
|
||
|
private static final String SHARED_PREFERENCE_ERROR_CODE_KEY = "flutter_image_picker_error_code";
|
||
|
private static final String SHARED_PREFERENCE_ERROR_MESSAGE_KEY = "flutter_image_picker_error_message";
|
||
|
private static final String SHARED_PREFERENCE_IMAGE_QUALITY_KEY = "flutter_image_picker_image_quality";
|
||
|
private static final String SHARED_PREFERENCE_MAX_HEIGHT_KEY = "flutter_image_picker_max_height";
|
||
|
private static final String SHARED_PREFERENCE_MAX_WIDTH_KEY = "flutter_image_picker_max_width";
|
||
|
private static final String SHARED_PREFERENCE_PENDING_IMAGE_URI_PATH_KEY = "flutter_image_picker_pending_image_uri";
|
||
|
private static final String SHARED_PREFERENCE_TYPE_KEY = "flutter_image_picker_type";
|
||
|
private SharedPreferences prefs;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public ImagePickerCache(Context context) {
|
||
|
this.prefs = context.getSharedPreferences(SHARED_PREFERENCES_NAME, 0);
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public void saveTypeWithMethodCallName(String str) {
|
||
|
if (str.equals("pickImage") | str.equals("pickMultiImage")) {
|
||
|
setType("image");
|
||
|
} else if (str.equals("pickVideo")) {
|
||
|
setType("video");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void setType(String str) {
|
||
|
this.prefs.edit().putString(SHARED_PREFERENCE_TYPE_KEY, str).apply();
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public void saveDimensionWithMethodCall(MethodCall methodCall) {
|
||
|
setMaxDimension((Double) methodCall.argument(MAP_KEY_MAX_WIDTH), (Double) methodCall.argument(MAP_KEY_MAX_HEIGHT), methodCall.argument(MAP_KEY_IMAGE_QUALITY) == null ? 100 : ((Integer) methodCall.argument(MAP_KEY_IMAGE_QUALITY)).intValue());
|
||
|
}
|
||
|
|
||
|
private void setMaxDimension(Double d, Double d2, int i) {
|
||
|
SharedPreferences.Editor edit = this.prefs.edit();
|
||
|
if (d != null) {
|
||
|
edit.putLong(SHARED_PREFERENCE_MAX_WIDTH_KEY, Double.doubleToRawLongBits(d.doubleValue()));
|
||
|
}
|
||
|
if (d2 != null) {
|
||
|
edit.putLong(SHARED_PREFERENCE_MAX_HEIGHT_KEY, Double.doubleToRawLongBits(d2.doubleValue()));
|
||
|
}
|
||
|
if (i >= 0 && i < 101) {
|
||
|
edit.putInt(SHARED_PREFERENCE_IMAGE_QUALITY_KEY, i);
|
||
|
} else {
|
||
|
edit.putInt(SHARED_PREFERENCE_IMAGE_QUALITY_KEY, 100);
|
||
|
}
|
||
|
edit.apply();
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public void savePendingCameraMediaUriPath(Uri uri) {
|
||
|
this.prefs.edit().putString(SHARED_PREFERENCE_PENDING_IMAGE_URI_PATH_KEY, uri.getPath()).apply();
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public String retrievePendingCameraMediaUriPath() {
|
||
|
return this.prefs.getString(SHARED_PREFERENCE_PENDING_IMAGE_URI_PATH_KEY, "");
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public void saveResult(ArrayList<String> arrayList, String str, String str2) {
|
||
|
HashSet hashSet = new HashSet();
|
||
|
hashSet.addAll(arrayList);
|
||
|
SharedPreferences.Editor edit = this.prefs.edit();
|
||
|
if (arrayList != null) {
|
||
|
edit.putStringSet(FLUTTER_IMAGE_PICKER_IMAGE_PATH_KEY, hashSet);
|
||
|
}
|
||
|
if (str != null) {
|
||
|
edit.putString(SHARED_PREFERENCE_ERROR_CODE_KEY, str);
|
||
|
}
|
||
|
if (str2 != null) {
|
||
|
edit.putString(SHARED_PREFERENCE_ERROR_MESSAGE_KEY, str2);
|
||
|
}
|
||
|
edit.apply();
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public void clear() {
|
||
|
this.prefs.edit().clear().apply();
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* JADX WARN: Code restructure failed: missing block: B:26:0x0055, code lost:
|
||
|
|
||
|
if (r1 != false) goto L14;
|
||
|
*/
|
||
|
/*
|
||
|
Code decompiled incorrectly, please refer to instructions dump.
|
||
|
To view partially-correct add '--show-bad-code' argument
|
||
|
*/
|
||
|
public java.util.Map<java.lang.String, java.lang.Object> getCacheMap() {
|
||
|
/*
|
||
|
r5 = this;
|
||
|
java.util.HashMap r0 = new java.util.HashMap
|
||
|
r0.<init>()
|
||
|
java.util.ArrayList r1 = new java.util.ArrayList
|
||
|
r1.<init>()
|
||
|
android.content.SharedPreferences r2 = r5.prefs
|
||
|
java.lang.String r3 = "flutter_image_picker_image_path"
|
||
|
boolean r2 = r2.contains(r3)
|
||
|
if (r2 == 0) goto L27
|
||
|
android.content.SharedPreferences r2 = r5.prefs
|
||
|
r4 = 0
|
||
|
java.util.Set r2 = r2.getStringSet(r3, r4)
|
||
|
if (r2 == 0) goto L27
|
||
|
r1.addAll(r2)
|
||
|
java.lang.String r2 = "pathList"
|
||
|
r0.put(r2, r1)
|
||
|
r1 = 1
|
||
|
goto L28
|
||
|
L27:
|
||
|
r1 = 0
|
||
|
L28:
|
||
|
android.content.SharedPreferences r2 = r5.prefs
|
||
|
java.lang.String r3 = "flutter_image_picker_error_code"
|
||
|
boolean r2 = r2.contains(r3)
|
||
|
java.lang.String r4 = ""
|
||
|
if (r2 == 0) goto L55
|
||
|
android.content.SharedPreferences r1 = r5.prefs
|
||
|
java.lang.String r1 = r1.getString(r3, r4)
|
||
|
java.lang.String r2 = "errorCode"
|
||
|
r0.put(r2, r1)
|
||
|
android.content.SharedPreferences r1 = r5.prefs
|
||
|
java.lang.String r2 = "flutter_image_picker_error_message"
|
||
|
boolean r1 = r1.contains(r2)
|
||
|
if (r1 == 0) goto L57
|
||
|
android.content.SharedPreferences r1 = r5.prefs
|
||
|
java.lang.String r1 = r1.getString(r2, r4)
|
||
|
java.lang.String r2 = "errorMessage"
|
||
|
r0.put(r2, r1)
|
||
|
goto L57
|
||
|
L55:
|
||
|
if (r1 == 0) goto Lcb
|
||
|
L57:
|
||
|
android.content.SharedPreferences r1 = r5.prefs
|
||
|
java.lang.String r2 = "flutter_image_picker_type"
|
||
|
boolean r1 = r1.contains(r2)
|
||
|
if (r1 == 0) goto L6c
|
||
|
android.content.SharedPreferences r1 = r5.prefs
|
||
|
java.lang.String r1 = r1.getString(r2, r4)
|
||
|
java.lang.String r2 = "type"
|
||
|
r0.put(r2, r1)
|
||
|
L6c:
|
||
|
android.content.SharedPreferences r1 = r5.prefs
|
||
|
java.lang.String r2 = "flutter_image_picker_max_width"
|
||
|
boolean r1 = r1.contains(r2)
|
||
|
r3 = 0
|
||
|
if (r1 == 0) goto L8b
|
||
|
android.content.SharedPreferences r1 = r5.prefs
|
||
|
long r1 = r1.getLong(r2, r3)
|
||
|
double r1 = java.lang.Double.longBitsToDouble(r1)
|
||
|
java.lang.Double r1 = java.lang.Double.valueOf(r1)
|
||
|
java.lang.String r2 = "maxWidth"
|
||
|
r0.put(r2, r1)
|
||
|
L8b:
|
||
|
android.content.SharedPreferences r1 = r5.prefs
|
||
|
java.lang.String r2 = "flutter_image_picker_max_height"
|
||
|
boolean r1 = r1.contains(r2)
|
||
|
if (r1 == 0) goto La8
|
||
|
android.content.SharedPreferences r1 = r5.prefs
|
||
|
long r1 = r1.getLong(r2, r3)
|
||
|
double r1 = java.lang.Double.longBitsToDouble(r1)
|
||
|
java.lang.Double r1 = java.lang.Double.valueOf(r1)
|
||
|
java.lang.String r2 = "maxHeight"
|
||
|
r0.put(r2, r1)
|
||
|
La8:
|
||
|
android.content.SharedPreferences r1 = r5.prefs
|
||
|
java.lang.String r2 = "flutter_image_picker_image_quality"
|
||
|
boolean r1 = r1.contains(r2)
|
||
|
r3 = 100
|
||
|
java.lang.String r4 = "imageQuality"
|
||
|
if (r1 == 0) goto Lc4
|
||
|
android.content.SharedPreferences r1 = r5.prefs
|
||
|
int r1 = r1.getInt(r2, r3)
|
||
|
java.lang.Integer r1 = java.lang.Integer.valueOf(r1)
|
||
|
r0.put(r4, r1)
|
||
|
goto Lcb
|
||
|
Lc4:
|
||
|
java.lang.Integer r1 = java.lang.Integer.valueOf(r3)
|
||
|
r0.put(r4, r1)
|
||
|
Lcb:
|
||
|
return r0
|
||
|
*/
|
||
|
throw new UnsupportedOperationException("Method not decompiled: io.flutter.plugins.imagepicker.ImagePickerCache.getCacheMap():java.util.Map");
|
||
|
}
|
||
|
}
|