Skip to content

Commit 279aad0

Browse files
committed
[AppInfo] Open "Open by default" settings in the "Open links" dialog
If App Manager does not have enough permission to manage domains or links, the "Open links" dialog has a button that directs the user to Android Settings. If the app has the "Open by default" page, clicking on the button will open that page instead of the "App info" page (which is still used as a fallback method). Signed-off-by: Muntashir Al-Islam <muntashirakon@riseup.net>
1 parent c061078 commit 279aad0

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

app/src/main/java/io/github/muntashirakon/AppManager/details/info/AppInfoFragment.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
import io.github.muntashirakon.AppManager.utils.ContextUtils;
157157
import io.github.muntashirakon.AppManager.utils.DateUtils;
158158
import io.github.muntashirakon.AppManager.utils.DigestUtils;
159+
import io.github.muntashirakon.AppManager.utils.ExUtils;
159160
import io.github.muntashirakon.AppManager.utils.FreezeUtils;
160161
import io.github.muntashirakon.AppManager.utils.IntentUtils;
161162
import io.github.muntashirakon.AppManager.utils.KeyStoreUtils;
@@ -898,11 +899,12 @@ private List<TagItem> getTagCloudItems(@NonNull AppInfoViewModel.TagCloud tagClo
898899
ThreadUtils.postOnMainThread(() -> UIUtils.displayShortToast(R.string.failed));
899900
}
900901
}));
901-
} else {
902+
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
902903
builder.setPositiveButton(R.string.app_settings, (dialog, which) -> {
903904
try {
904-
startActivity(IntentUtils.getAppDetailsSettings(mPackageName));
905-
} catch (Throwable ignore) {
905+
startActivity(IntentUtils.getSettings(Settings.ACTION_APP_OPEN_BY_DEFAULT_SETTINGS, mPackageName));
906+
} catch (Throwable th) {
907+
ExUtils.exceptionAsIgnored(() -> startActivity(IntentUtils.getAppDetailsSettings(mPackageName)));
906908
}
907909
});
908910
}

app/src/main/java/io/github/muntashirakon/AppManager/utils/IntentUtils.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@
66
import android.net.Uri;
77
import android.provider.Settings;
88

9+
import androidx.annotation.NonNull;
10+
911
public final class IntentUtils {
10-
public static Intent getAppDetailsSettings(String packageName) {
11-
return new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
12+
@NonNull
13+
public static Intent getAppDetailsSettings(@NonNull String packageName) {
14+
return getSettings(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, packageName);
15+
}
16+
17+
@NonNull
18+
public static Intent getSettings(@NonNull String action, String packageName) {
19+
return new Intent(action)
1220
.addCategory(Intent.CATEGORY_DEFAULT)
1321
.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
1422
.setData(Uri.parse("package:" + packageName));

0 commit comments

Comments
 (0)