mirror of
http://galexander.org/git/simplesshd.git
synced 2025-01-03 19:50:55 +00:00
Add new "Enable /sdcard" menu option that requests the
WRITE_EXTERNAL_STORAGE permission even if it's already been requested once before on startup, because changing from SDK 30 to SDK 29 appears to clear it.
This commit is contained in:
parent
e37a4bed87
commit
c9d81b5f33
@ -53,7 +53,7 @@ public class SimpleSSHD extends Activity
|
||||
synchronized (lock) {
|
||||
curr = this;
|
||||
}
|
||||
permission();
|
||||
permission_startup();
|
||||
update_startstop_prime();
|
||||
updater = new UpdaterThread();
|
||||
updater.start();
|
||||
@ -88,6 +88,9 @@ public class SimpleSSHD extends Activity
|
||||
case R.id.resetkeys:
|
||||
resetkeys_clicked(null);
|
||||
return true;
|
||||
case R.id.trypermission:
|
||||
permission_clicked(null);
|
||||
return true;
|
||||
case R.id.doc:
|
||||
doc_clicked(null);
|
||||
return true;
|
||||
@ -111,6 +114,9 @@ public class SimpleSSHD extends Activity
|
||||
public void resetkeys_clicked(View v) {
|
||||
reset_keys();
|
||||
}
|
||||
public void permission_clicked(View v) {
|
||||
permission_menu();
|
||||
}
|
||||
public void doc_clicked(View v) {
|
||||
try {
|
||||
Intent i = new Intent(Intent.ACTION_VIEW);
|
||||
@ -312,7 +318,7 @@ public class SimpleSSHD extends Activity
|
||||
}
|
||||
}
|
||||
|
||||
public void permission() {
|
||||
private void permission_startup() {
|
||||
if (android.os.Build.VERSION.SDK_INT < 23) {
|
||||
return;
|
||||
}
|
||||
@ -325,6 +331,22 @@ public class SimpleSSHD extends Activity
|
||||
requestPermissions(new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, 0);
|
||||
}
|
||||
|
||||
private void toast(String s) {
|
||||
Toast.makeText(this, s, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
private void permission_menu() {
|
||||
if (android.os.Build.VERSION.SDK_INT < 23) {
|
||||
toast("Your phone uses an Android version that grants external storage access by default.");
|
||||
return;
|
||||
}
|
||||
if (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
||||
toast("External storage permission already granted.");
|
||||
return;
|
||||
}
|
||||
requestPermissions(new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, 0);
|
||||
}
|
||||
|
||||
public void onRequestPermissionsResult(int code, String[] perms, int[] results) {
|
||||
Prefs.set_requested(); /* whatever result, don't ask again */
|
||||
}
|
||||
|
@ -61,9 +61,12 @@
|
||||
android:text="Reset Keys"
|
||||
android:onClick="resetkeys_clicked" />
|
||||
<Button style="@style/tv_button" android:id="@+id/option4"
|
||||
android:text="Enable /sdcard"
|
||||
android:onClick="permission_clicked" />
|
||||
<Button style="@style/tv_button" android:id="@+id/option5"
|
||||
android:text="Documentation"
|
||||
android:onClick="doc_clicked" />
|
||||
<Button style="@style/tv_button" android:id="@+id/option5"
|
||||
<Button style="@style/tv_button" android:id="@+id/option6"
|
||||
android:nextFocusDown="@+id/startstop"
|
||||
android:text="About"
|
||||
android:onClick="about_clicked" />
|
||||
|
@ -10,6 +10,8 @@ button list in res/layout/main_tv.xml -->
|
||||
<item android:id="@+id/resetkeys"
|
||||
android:icon="@android:drawable/ic_secure"
|
||||
android:title="Reset Keys" />
|
||||
<item android:id="@+id/trypermission"
|
||||
android:title="Enable /sdcard" />
|
||||
<item android:id="@+id/doc"
|
||||
android:icon="@android:drawable/ic_menu_help"
|
||||
android:title="Documentation" />
|
||||
|
Loading…
Reference in New Issue
Block a user