Skip to content

Commit

Permalink
android app: add image example when asking for permission
Browse files Browse the repository at this point in the history
cool thing that it displays different images based on the theme
  • Loading branch information
Toni500github committed Dec 15, 2024
1 parent 772f6f3 commit 5a1686c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.os.Bundle
import android.os.Environment
import android.provider.Settings
import android.util.Log
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.preference.PreferenceFragmentCompat
import java.io.File
Expand All @@ -29,9 +30,9 @@ class SettingsActivity : AppCompatActivity() {
supportActionBar?.setDisplayHomeAsUpEnabled(true)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
if (!Environment.isExternalStorageManager()) {
AlertDialog.Builder(this)
val alert = AlertDialog.Builder(this)
.setTitle("Grant external storage management permission")
.setMessage("Customfetch needs permissions to manage external storage for writing config files.\n"+
.setMessage("Customfetch needs permissions to manage external storage to able to access config files.\n"+
"By default we going to read/write the following directories:\n"+
"/storage/emulated/0/.config/\n"+
"/storage/emulated/0/.config/customfetch/")
Expand All @@ -41,7 +42,10 @@ class SettingsActivity : AppCompatActivity() {
startActivity(intent)
}
.setIcon(android.R.drawable.ic_dialog_alert)
.show()

val view: View = layoutInflater.inflate(R.layout.grant_perm, null, false);
alert.setView(view)
alert.show()
}
}
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions android/app/src/main/res/layout/grant_perm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">

<ImageView
android:id="@+id/dialog_imageview"
android:layout_width="254dp"
android:layout_height="185dp"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:scaleType="fitCenter"
android:src="@drawable/grant_perm" />

</LinearLayout>

0 comments on commit 5a1686c

Please sign in to comment.