mirror of https://github.com/M66B/FairEmail.git
Added option to disable Android photo picker
This commit is contained in:
parent
17f7e16651
commit
455c6e3dd7
|
@ -3034,7 +3034,8 @@ public class FragmentCompose extends FragmentBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onAddImage(boolean photo) {
|
private void onAddImage(boolean photo) {
|
||||||
PackageManager pm = getContext().getPackageManager();
|
Context context = getContext();
|
||||||
|
PackageManager pm = context.getPackageManager();
|
||||||
if (photo) {
|
if (photo) {
|
||||||
// https://developer.android.com/training/camera/photobasics
|
// https://developer.android.com/training/camera/photobasics
|
||||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||||
|
@ -3049,26 +3050,28 @@ public class FragmentCompose extends FragmentBase {
|
||||||
});
|
});
|
||||||
snackbar.show();
|
snackbar.show();
|
||||||
} else {
|
} else {
|
||||||
File dir = new File(getContext().getFilesDir(), "photo");
|
File dir = new File(context.getFilesDir(), "photo");
|
||||||
if (!dir.exists())
|
if (!dir.exists())
|
||||||
dir.mkdir();
|
dir.mkdir();
|
||||||
File file = new File(dir, working + ".jpg");
|
File file = new File(dir, working + ".jpg");
|
||||||
try {
|
try {
|
||||||
photoURI = FileProvider.getUriForFile(getContext(), BuildConfig.APPLICATION_ID, file);
|
photoURI = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID, file);
|
||||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
|
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
|
||||||
startActivityForResult(intent, REQUEST_TAKE_PHOTO);
|
startActivityForResult(intent, REQUEST_TAKE_PHOTO);
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
// java.lang.IllegalArgumentException: Failed to resolve canonical path for ...
|
// java.lang.IllegalArgumentException: Failed to resolve canonical path for ...
|
||||||
Helper.reportNoViewer(getContext(), intent, ex);
|
Helper.reportNoViewer(context, intent, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// https://developer.android.com/reference/android/provider/MediaStore#ACTION_PICK_IMAGES
|
// https://developer.android.com/reference/android/provider/MediaStore#ACTION_PICK_IMAGES
|
||||||
// Android 12: cmd device_config put storage_native_boot picker_intent_enabled true
|
// Android 12: cmd device_config put storage_native_boot picker_intent_enabled true
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
boolean photo_picker = prefs.getBoolean("photo_picker", true);
|
||||||
Intent picker = new Intent(MediaStore.ACTION_PICK_IMAGES);
|
Intent picker = new Intent(MediaStore.ACTION_PICK_IMAGES);
|
||||||
picker.setType("image/*");
|
picker.setType("image/*");
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU &&
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU &&
|
||||||
picker.resolveActivity(pm) != null) {
|
photo_picker && picker.resolveActivity(pm) != null) {
|
||||||
Log.i("Using photo picker");
|
Log.i("Using photo picker");
|
||||||
picker.putExtra(MediaStore.EXTRA_PICK_IMAGES_MAX, MediaStore.getPickImagesMaxLimit());
|
picker.putExtra(MediaStore.EXTRA_PICK_IMAGES_MAX, MediaStore.getPickImagesMaxLimit());
|
||||||
startActivityForResult(picker, REQUEST_IMAGE_FILE);
|
startActivityForResult(picker, REQUEST_IMAGE_FILE);
|
||||||
|
@ -3082,7 +3085,7 @@ public class FragmentCompose extends FragmentBase {
|
||||||
if (intent.resolveActivity(pm) == null) // GET_CONTENT whitelisted
|
if (intent.resolveActivity(pm) == null) // GET_CONTENT whitelisted
|
||||||
noStorageAccessFramework();
|
noStorageAccessFramework();
|
||||||
else
|
else
|
||||||
startActivityForResult(Helper.getChooser(getContext(), intent), REQUEST_IMAGE_FILE);
|
startActivityForResult(Helper.getChooser(context, intent), REQUEST_IMAGE_FILE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
||||||
private SwitchCompat swConversationActionsReplies;
|
private SwitchCompat swConversationActionsReplies;
|
||||||
private SwitchCompat swLanguageDetection;
|
private SwitchCompat swLanguageDetection;
|
||||||
private EditText etDefaultSnooze;
|
private EditText etDefaultSnooze;
|
||||||
|
private SwitchCompat swPhotoPicker;
|
||||||
private SwitchCompat swPull;
|
private SwitchCompat swPull;
|
||||||
private SwitchCompat swAutoScroll;
|
private SwitchCompat swAutoScroll;
|
||||||
private SwitchCompat swQuickFilter;
|
private SwitchCompat swQuickFilter;
|
||||||
|
@ -104,7 +105,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
||||||
|
|
||||||
private final static String[] RESET_OPTIONS = new String[]{
|
private final static String[] RESET_OPTIONS = new String[]{
|
||||||
"restore_on_launch", "sync_on_launch", "double_back", "conversation_actions", "conversation_actions_replies", "language_detection",
|
"restore_on_launch", "sync_on_launch", "double_back", "conversation_actions", "conversation_actions_replies", "language_detection",
|
||||||
"default_snooze",
|
"photo_picker", "default_snooze",
|
||||||
"pull", "autoscroll", "quick_filter", "quick_scroll", "swipe_sensitivity", "foldernav",
|
"pull", "autoscroll", "quick_filter", "quick_scroll", "swipe_sensitivity", "foldernav",
|
||||||
"doubletap", "swipenav", "volumenav", "reversed", "swipe_close", "swipe_move",
|
"doubletap", "swipenav", "volumenav", "reversed", "swipe_close", "swipe_move",
|
||||||
"autoexpand", "expand_first", "expand_all", "expand_one", "collapse_multiple",
|
"autoexpand", "expand_first", "expand_all", "expand_one", "collapse_multiple",
|
||||||
|
@ -133,6 +134,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
||||||
swConversationActionsReplies = view.findViewById(R.id.swConversationActionsReplies);
|
swConversationActionsReplies = view.findViewById(R.id.swConversationActionsReplies);
|
||||||
swLanguageDetection = view.findViewById(R.id.swLanguageDetection);
|
swLanguageDetection = view.findViewById(R.id.swLanguageDetection);
|
||||||
etDefaultSnooze = view.findViewById(R.id.etDefaultSnooze);
|
etDefaultSnooze = view.findViewById(R.id.etDefaultSnooze);
|
||||||
|
swPhotoPicker = view.findViewById(R.id.swPhotoPicker);
|
||||||
swPull = view.findViewById(R.id.swPull);
|
swPull = view.findViewById(R.id.swPull);
|
||||||
swAutoScroll = view.findViewById(R.id.swAutoScroll);
|
swAutoScroll = view.findViewById(R.id.swAutoScroll);
|
||||||
swQuickFilter = view.findViewById(R.id.swQuickFilter);
|
swQuickFilter = view.findViewById(R.id.swQuickFilter);
|
||||||
|
@ -249,6 +251,14 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
swPhotoPicker.setVisibility(Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU ? View.GONE : View.VISIBLE);
|
||||||
|
swPhotoPicker.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||||
|
prefs.edit().putBoolean("photo_picker", checked).apply();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
swPull.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
swPull.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||||
|
@ -548,6 +558,8 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
||||||
etDefaultSnooze.setText(default_snooze == 1 ? null : Integer.toString(default_snooze));
|
etDefaultSnooze.setText(default_snooze == 1 ? null : Integer.toString(default_snooze));
|
||||||
etDefaultSnooze.setHint("1");
|
etDefaultSnooze.setHint("1");
|
||||||
|
|
||||||
|
swPhotoPicker.setChecked(prefs.getBoolean("photo_picker", true));
|
||||||
|
|
||||||
swPull.setChecked(prefs.getBoolean("pull", true));
|
swPull.setChecked(prefs.getBoolean("pull", true));
|
||||||
swAutoScroll.setChecked(prefs.getBoolean("autoscroll", false));
|
swAutoScroll.setChecked(prefs.getBoolean("autoscroll", false));
|
||||||
swQuickFilter.setChecked(prefs.getBoolean("quick_filter", false));
|
swQuickFilter.setChecked(prefs.getBoolean("quick_filter", false));
|
||||||
|
|
|
@ -215,6 +215,18 @@
|
||||||
app:layout_constraintBottom_toBottomOf="@+id/etDefaultSnooze"
|
app:layout_constraintBottom_toBottomOf="@+id/etDefaultSnooze"
|
||||||
app:layout_constraintStart_toEndOf="@+id/etDefaultSnooze"
|
app:layout_constraintStart_toEndOf="@+id/etDefaultSnooze"
|
||||||
app:layout_constraintTop_toTopOf="@+id/etDefaultSnooze" />
|
app:layout_constraintTop_toTopOf="@+id/etDefaultSnooze" />
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.SwitchCompat
|
||||||
|
android:id="@+id/swPhotoPicker"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="12dp"
|
||||||
|
android:checked="true"
|
||||||
|
android:text="@string/title_advanced_photo_picker"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/etDefaultSnooze"
|
||||||
|
app:switchPadding="12dp" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
|
|
@ -598,6 +598,7 @@
|
||||||
<string name="title_advanced_conversation_actions">Suggest actions (Android 10+)</string>
|
<string name="title_advanced_conversation_actions">Suggest actions (Android 10+)</string>
|
||||||
<string name="title_advanced_conversation_actions_replies">Suggest reply texts (Android 10+)</string>
|
<string name="title_advanced_conversation_actions_replies">Suggest reply texts (Android 10+)</string>
|
||||||
<string name="title_advanced_language_detection">Detect message text language</string>
|
<string name="title_advanced_language_detection">Detect message text language</string>
|
||||||
|
<string name="title_advanced_photo_picker">Use the Android photo picker</string>
|
||||||
<string name="title_advanced_pull_refresh">Pull down to refresh</string>
|
<string name="title_advanced_pull_refresh">Pull down to refresh</string>
|
||||||
<string name="title_advanced_autoscroll">Scroll to top on receiving new messages</string>
|
<string name="title_advanced_autoscroll">Scroll to top on receiving new messages</string>
|
||||||
<string name="title_advanced_double_tap">Double tap to mark message read/unread</string>
|
<string name="title_advanced_double_tap">Double tap to mark message read/unread</string>
|
||||||
|
|
Loading…
Reference in New Issue