Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,15 @@ private void requestPermission(
*/
public void requestAllFilesAccess(@NonNull final OnPermissionGranted onPermissionGranted) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager()) {
final boolean hasHtml = true;
final MaterialDialog materialDialog =
GeneralDialogCreation.showBasicDialog(
this,
R.string.grant_all_files_permission,
R.string.grantper,
R.string.grant,
R.string.cancel);
R.string.cancel,
hasHtml);
materialDialog.getActionButton(DialogAction.NEGATIVE).setOnClickListener(v -> finish());
materialDialog
.getActionButton(DialogAction.POSITIVE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@
import android.text.Spanned;
import android.text.TextUtils;
import android.text.format.Formatter;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
Expand Down Expand Up @@ -124,23 +126,43 @@ public class GeneralDialogCreation {
private static final Logger LOG = LoggerFactory.getLogger(GeneralDialogCreation.class);

public static MaterialDialog showBasicDialog(
ThemedActivity themedActivity,
@NonNull ThemedActivity themedActivity,
@StringRes int content,
@StringRes int title,
@StringRes int postiveText,
@StringRes int negativeText) {
return showBasicDialog(themedActivity, content, title, postiveText, negativeText, false);
}

public static MaterialDialog showBasicDialog(
@NonNull ThemedActivity themedActivity,
@StringRes int content,
@StringRes int title,
@StringRes int postiveText,
@StringRes int negativeText,
boolean hasHtml) {
int accentColor = themedActivity.getAccent();
MaterialDialog.Builder a =
MaterialDialog.Builder dialogBuilder =
new MaterialDialog.Builder(themedActivity)
.content(content)
.content("") // HACK make it empty and then fill it manually for links to work
.widgetColor(accentColor)
.theme(themedActivity.getAppTheme().getMaterialDialogTheme())
.title(title)
.positiveText(postiveText)
.positiveColor(accentColor)
.negativeText(negativeText)
.negativeColor(accentColor);
return a.build();
MaterialDialog dialog = dialogBuilder.build();

if (hasHtml) {
dialog.getContentView().setMovementMethod(LinkMovementMethod.getInstance());
dialog.getContentView().setAutoLinkMask(Linkify.WEB_URLS);
dialog.getContentView().setLinksClickable(true);
dialog
.getContentView()
.setText(HtmlCompat.fromHtml(themedActivity.getString(content), FROM_HTML_MODE_COMPACT));
}
return dialog;
}

public static MaterialDialog showNameDialog(
Expand Down
12 changes: 9 additions & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -776,9 +776,15 @@ You only need to do this once, until the next time you select a new location for
<string name="select_similar">Select similar</string>
<string name="select_fill">Select fill</string>
<string name="error_fetching_google_play_product_list">Error fetching product list from Google Play.</string>
<string name="grant_all_files_permission"><html><body>Since Android 11, Google requests File Managers to request user permission for managing all files on the device. Details <a href="https://developer.android.com/training/data-storage/manage-all-files" target="_blank">here</a>.
\n\nAmaze File Manager needs this permission too. After pressing \'Grant\', please select <b>Allow access to manage all files</b> option on the next screen.
\n\n<font color='#ff6347'><i>Canceling this dialog will exit the app.</i></font></body></html></string>
<string name="grant_all_files_permission"><![CDATA[
<html>
<body>
Since Android 11, Google requests File Managers to request user permission for managing all files on the device. Details available at https://developer.android.com/training/data-storage/manage-all-files.<br/><br/>
Amaze File Manager needs this permission too. After pressing &apos;Grant&apos;, please select <b>Allow access to manage all files</b> option on the next screen.<br/><br/>
<font color=&apos;#ff6347&apos;><i>Canceling this dialog will exit the app.</i></font>
</body>
</html>
]]></string>
<string name="user_apps">User apps</string>
<string name="appearance">Appearance</string>
<string name="behavior">Behavior</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import android.os.Build.VERSION_CODES.P
import android.os.Build.VERSION_CODES.R
import android.os.storage.StorageManager
import android.provider.Settings
import androidx.core.text.HtmlCompat
import androidx.core.text.HtmlCompat.FROM_HTML_MODE_COMPACT
import androidx.lifecycle.Lifecycle
import androidx.test.core.app.ActivityScenario
import androidx.test.core.app.ApplicationProvider
Expand Down Expand Up @@ -128,9 +130,10 @@ class PermissionsActivityTest {
this.titleView.text,
)
assertEquals(
activity.getString(
com.amaze.filemanager.R.string.grant_all_files_permission,
),
HtmlCompat.fromHtml(
activity.getString(com.amaze.filemanager.R.string.grant_all_files_permission),
FROM_HTML_MODE_COMPACT,
).toString(),
this.contentView?.text.toString(),
)
this.getActionButton(DialogAction.POSITIVE).run {
Expand Down
Loading