Mercurial > 510Connectbot
changeset 500:11d714165a2d
updates for android10+
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Tue, 07 Jun 2022 16:10:58 -0700 |
parents | 267e72057707 |
children | aee5f34cc2db |
files | app/src/main/java/com/five_ten_sg/connectbot/HostListActivity.java |
diffstat | 1 files changed, 11 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/app/src/main/java/com/five_ten_sg/connectbot/HostListActivity.java Tue Jun 07 16:04:52 2022 -0700 +++ b/app/src/main/java/com/five_ten_sg/connectbot/HostListActivity.java Tue Jun 07 16:10:58 2022 -0700 @@ -71,6 +71,7 @@ import android.widget.ListView; import android.widget.Spinner; import android.widget.TextView; +import android.widget.Toast; import android.content.pm.PackageManager; import android.os.Build; import android.Manifest; @@ -81,6 +82,7 @@ protected static final String TAG = "ConnectBot.HostListActivity"; public final static int REQUEST_EDIT = 1; public final static int REQUEST_EULA = 2; + public final static int REQUEST_STORAGEMANAGER = 3; protected TerminalManager bound = null; @@ -163,6 +165,13 @@ else if (requestCode == REQUEST_EDIT) { updateList(); } + else if (requestCode == REQUEST_STORAGE_MANAGER) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { + if (!Environment.isExternalStorageManager()) { + Toast.makeText(this, "Allow permission for storage access!", Toast.LENGTH_SHORT).show(); + } + } + } } @Override @@ -284,23 +293,11 @@ Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION); intent.addCategory("android.intent.category.DEFAULT"); intent.setData(Uri.parse(String.format("package:%s",getApplicationContext().getPackageName()))); - startActivityForResult(intent, 31415); + startActivityForResult(intent, REQUEST_STORAGE_MANAGER); } catch (Exception e) { Intent intent = new Intent(); intent.setAction(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION); - startActivityForResult(intent, 31415); - } - } - } - - @Override - protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { - super.onActivityResult(requestCode, resultCode, data); - if (requestCode == 31415) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - if (!Environment.isExternalStorageManager()) { - Toast.makeText(this, "Allow permission for storage access!", Toast.LENGTH_SHORT).show(); - } + startActivityForResult(intent, REQUEST_STORAGE_MANAGER); } } }