Skip to content

Commit 5a1686c

Browse files
committed
android app: add image example when asking for permission
cool thing that it displays different images based on the theme
1 parent 772f6f3 commit 5a1686c

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

android/app/src/main/java/org/toni/customfetch_android/SettingsActivity.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import android.os.Bundle
88
import android.os.Environment
99
import android.provider.Settings
1010
import android.util.Log
11+
import android.view.View
1112
import androidx.appcompat.app.AppCompatActivity
1213
import androidx.preference.PreferenceFragmentCompat
1314
import java.io.File
@@ -29,9 +30,9 @@ class SettingsActivity : AppCompatActivity() {
2930
supportActionBar?.setDisplayHomeAsUpEnabled(true)
3031
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
3132
if (!Environment.isExternalStorageManager()) {
32-
AlertDialog.Builder(this)
33+
val alert = AlertDialog.Builder(this)
3334
.setTitle("Grant external storage management permission")
34-
.setMessage("Customfetch needs permissions to manage external storage for writing config files.\n"+
35+
.setMessage("Customfetch needs permissions to manage external storage to able to access config files.\n"+
3536
"By default we going to read/write the following directories:\n"+
3637
"/storage/emulated/0/.config/\n"+
3738
"/storage/emulated/0/.config/customfetch/")
@@ -41,7 +42,10 @@ class SettingsActivity : AppCompatActivity() {
4142
startActivity(intent)
4243
}
4344
.setIcon(android.R.drawable.ic_dialog_alert)
44-
.show()
45+
46+
val view: View = layoutInflater.inflate(R.layout.grant_perm, null, false);
47+
alert.setView(view)
48+
alert.show()
4549
}
4650
}
4751
}
14.7 KB
Loading
14.4 KB
Loading
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
android:gravity="center">
6+
7+
<ImageView
8+
android:id="@+id/dialog_imageview"
9+
android:layout_width="254dp"
10+
android:layout_height="185dp"
11+
android:layout_gravity="center"
12+
android:adjustViewBounds="true"
13+
android:scaleType="fitCenter"
14+
android:src="@drawable/grant_perm" />
15+
16+
</LinearLayout>

0 commit comments

Comments
 (0)