Add back asking for gallery permission

This commit is contained in:
luvletter2333 2022-02-03 20:44:42 +08:00
parent 2a19e63c62
commit 20f3658279
4 changed files with 13 additions and 24 deletions

View File

@ -68,18 +68,19 @@ public class PhotoAttachPermissionCell extends FrameLayout {
imageView.setLayoutParams(LayoutHelper.createFrame(44, 44, Gravity.CENTER, 5, 0, 0, 27));
imageView2.setLayoutParams(LayoutHelper.createFrame(44, 44, Gravity.CENTER, 5, 0, 0, 27));
} else {
} else if (type == 1) {
imageView.setImageResource(R.drawable.permissions_gallery1);
imageView2.setImageResource(R.drawable.permissions_gallery2);
textView.setText(LocaleController.getString("GalleryPermissionText", R.string.GalleryPermissionText));
if (NekoXConfig.forceSystemPicker) {
imageView.setImageResource(R.drawable.baseline_open_in_browser_24);
imageView2.setVisibility(GONE);
textView.setText(LocaleController.getString("OpenInExternalApp", R.string.OpenInExternalApp));
}
imageView.setLayoutParams(LayoutHelper.createFrame(44, 44, Gravity.CENTER, 0, 0, 2, 27));
imageView2.setLayoutParams(LayoutHelper.createFrame(44, 44, Gravity.CENTER, 0, 0, 2, 27));
} else {
imageView.setImageResource(R.drawable.baseline_open_in_browser_24);
imageView2.setVisibility(GONE);
textView.setText(LocaleController.getString("OpenInExternalApp", R.string.OpenInExternalApp));
imageView.setLayoutParams(LayoutHelper.createFrame(44, 44, Gravity.CENTER, 0, 0, 2, 27));
}
}

View File

@ -628,8 +628,8 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
return;
} else if (noGalleryPermissions && position != 0) {
try {
if (NekoXConfig.forceSystemPicker) {
menu.onItemClick(open_in); // Use system photo picker
if (position == adapter.itemsCount - 2) {
menu.onItemClick(open_in); // NekoX: Use system photo picker
} else {
parentAlert.baseFragment.getParentActivity().requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 4);
}
@ -3250,7 +3250,9 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
case 3: {
PhotoAttachPermissionCell cell = (PhotoAttachPermissionCell) holder.itemView;
cell.setItemSize(itemSize);
cell.setType(needCamera && noCameraPermissions && position == 0 ? 0 : 1);
int type = needCamera && noCameraPermissions && position == 0 ? 0 : 1;
if (position == itemsCount - 2) type = 999;
cell.setType(type);
break;
}
}
@ -3322,6 +3324,7 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
}
if (noGalleryPermissions && this == adapter) {
count++;
count++; // NekoX: Additional Open In picker
}
count += cameraPhotos.size();
if (selectedAlbumEntry != null) {

View File

@ -4246,7 +4246,6 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
showPermissionErrorAlert(LocaleController.getString("VoipNeedCameraPermission", R.string.VoipNeedCameraPermission));
}
} else if (requestCode == 4) {
NekoXConfig.checkForceSystemPicker();
if (!granted) {
showPermissionErrorAlert(LocaleController.getString("PermissionStorage", R.string.PermissionStorage));
} else {

View File

@ -50,25 +50,11 @@ public class NekoXConfig {
public static final int TITLE_TYPE_ICON = 1;
public static final int TITLE_TYPE_MIX = 2;
public static boolean forceSystemPicker = false; // SDK23+ and no storage permission
private static final String EMOJI_FONT_AOSP = "NotoColorEmoji.ttf";
public static boolean loadSystemEmojiFailed = false;
private static Typeface systemEmojiTypeface;
static {
checkForceSystemPicker();
}
public static void checkForceSystemPicker() {
// TODO show alert?
// TODO not working: send photo (upstream bug)
if (Build.VERSION.SDK_INT >= 23 && ApplicationLoader.applicationContext.checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
forceSystemPicker = true;
BuildVars.NO_SCOPED_STORAGE = false;
}
}
public static SharedPreferences preferences = NitritesKt.openMainSharedPreference("nekox_config");