mirror of
https://github.com/NekoX-Dev/NekoX.git
synced 2024-12-12 11:19:29 +01:00
Workaround without storage permissions
This commit is contained in:
parent
f4c5e5d919
commit
1014cfd48d
@ -23,6 +23,8 @@ import org.telegram.messenger.R;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
|
||||
import tw.nekomimi.nekogram.NekoConfig;
|
||||
|
||||
public class PhotoAttachPermissionCell extends FrameLayout {
|
||||
|
||||
private final Theme.ResourcesProvider resourcesProvider;
|
||||
@ -70,6 +72,11 @@ public class PhotoAttachPermissionCell extends FrameLayout {
|
||||
imageView.setImageResource(R.drawable.permissions_gallery1);
|
||||
imageView2.setImageResource(R.drawable.permissions_gallery2);
|
||||
textView.setText(LocaleController.getString("GalleryPermissionText", R.string.GalleryPermissionText));
|
||||
if (NekoConfig.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));
|
||||
|
@ -1243,16 +1243,8 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
|
||||
if (num == 1) {
|
||||
showLayout(photoLayout);
|
||||
} else if (num == 3) {
|
||||
if (Build.VERSION.SDK_INT >= 23 && baseFragment.getParentActivity().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
baseFragment.getParentActivity().requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 4);
|
||||
return;
|
||||
}
|
||||
openAudioLayout(true);
|
||||
} else if (num == 4) {
|
||||
if (Build.VERSION.SDK_INT >= 23 && baseFragment.getParentActivity().checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
baseFragment.getParentActivity().requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 4);
|
||||
return;
|
||||
}
|
||||
openDocumentsLayout(true);
|
||||
} else if (num == 5) {
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
|
@ -100,6 +100,9 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearSmoothScroller;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import tw.nekomimi.nekogram.NekoConfig;
|
||||
import tw.nekomimi.nkmr.NekomuraConfig;
|
||||
|
||||
public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayout implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
private RecyclerListView cameraPhotoRecyclerView;
|
||||
@ -616,7 +619,11 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
|
||||
return;
|
||||
} else if (noGalleryPermissions) {
|
||||
try {
|
||||
parentAlert.baseFragment.getParentActivity().requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 4);
|
||||
if (NekoConfig.forceSystemPicker) {
|
||||
menu.onItemClick(open_in); // Use system photo picker
|
||||
} else {
|
||||
parentAlert.baseFragment.getParentActivity().requestPermissions(new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 4);
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
|
||||
}
|
||||
|
@ -160,6 +160,7 @@ import kotlin.Unit;
|
||||
import kotlin.text.StringsKt;
|
||||
import tw.nekomimi.nekogram.BottomBuilder;
|
||||
import tw.nekomimi.nekogram.ExternalGcm;
|
||||
import tw.nekomimi.nekogram.NekoConfig;
|
||||
import tw.nekomimi.nekogram.utils.EnvUtil;
|
||||
import tw.nekomimi.nkmr.NekomuraConfig;
|
||||
import tw.nekomimi.nekogram.NekoXConfig;
|
||||
@ -4044,6 +4045,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
|
||||
showPermissionErrorAlert(LocaleController.getString("VoipNeedCameraPermission", R.string.VoipNeedCameraPermission));
|
||||
}
|
||||
} else if (requestCode == 4) {
|
||||
NekoConfig.checkForceSystemPicker();
|
||||
if (!granted) {
|
||||
showPermissionErrorAlert(LocaleController.getString("PermissionStorage", R.string.PermissionStorage));
|
||||
} else {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package tw.nekomimi.nekogram;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
@ -7,6 +8,7 @@ import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Build;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
@ -33,6 +35,8 @@ public class NekoConfig {
|
||||
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
|
||||
|
||||
public static String getOpenPGPAppName() {
|
||||
|
||||
if (StrUtil.isNotBlank(NekomuraConfig.openPGPApp.String())) {
|
||||
@ -74,6 +78,16 @@ public class NekoConfig {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user