Sfoglia il codice sorgente

Merge pull request #9292 from nextcloud/bugfix/9291/brandedThemedPermissionDialog

Make permission dialog brandable and themed
Andy Scherzinger 3 anni fa
parent
commit
72d81ad06a

+ 10 - 3
src/main/java/com/owncloud/android/utils/PermissionUtil.kt

@@ -35,6 +35,7 @@ import androidx.appcompat.app.AlertDialog
 import androidx.core.app.ActivityCompat
 import androidx.core.content.ContextCompat
 import com.owncloud.android.R
+import com.owncloud.android.utils.theme.ThemeButtonUtils
 
 /**
  * Created by scherzia on 29.12.2015.
@@ -117,9 +118,12 @@ object PermissionUtil {
 
     @RequiresApi(Build.VERSION_CODES.R)
     private fun requestManageFilesPermission(activity: Activity) {
-        AlertDialog.Builder(activity, R.style.Theme_ownCloud_Dialog)
+        val alertDialog = AlertDialog.Builder(activity, R.style.Theme_ownCloud_Dialog)
             .setTitle(R.string.file_management_permission)
-            .setMessage(R.string.file_management_permission_text)
+            .setMessage(
+                String.format(activity.getString(
+                    R.string.file_management_permission_text),
+                    activity.getString(R.string.app_name)))
             .setCancelable(false)
             .setPositiveButton(R.string.common_ok) { dialog, _ ->
                 val intent = Intent().apply {
@@ -129,7 +133,10 @@ object PermissionUtil {
                 activity.startActivityForResult(intent, REQUEST_CODE_MANAGE_ALL_FILES)
                 dialog.dismiss()
             }
-            .show()
+            .create()
+
+        alertDialog.show()
+        ThemeButtonUtils.themeBorderlessButton(alertDialog.getButton(AlertDialog.BUTTON_POSITIVE))
     }
 
     /**

+ 1 - 1
src/main/res/values/strings.xml

@@ -1003,5 +1003,5 @@
     <string name="search_error">Error getting search results</string>
     <string name="load_more_results">Load more results</string>
     <string name="file_management_permission">Permissions needed</string>
-    <string name="file_management_permission_text">Nextcloud needs file management permissions to work properly. Please enable it in the following screen to continue.</string>
+    <string name="file_management_permission_text">%1$s needs file management permissions to work properly. Please enable it in the following screen to continue.</string>
 </resources>