From d9e7ece523beec7d4e5e2c7ff72e2dfc6daae04c Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Sun, 15 Feb 2026 15:29:46 +0100 Subject: [PATCH] feat: Add link helper to open App Store for Nextcloud apps Signed-off-by: Andy Scherzinger --- .../common/core/utils/ecosystem/LinkHelper.kt | 46 + gradle/verification-metadata.xml | 1065 +++++++++++++++++ 2 files changed, 1111 insertions(+) create mode 100644 core/src/main/java/com/nextcloud/android/common/core/utils/ecosystem/LinkHelper.kt diff --git a/core/src/main/java/com/nextcloud/android/common/core/utils/ecosystem/LinkHelper.kt b/core/src/main/java/com/nextcloud/android/common/core/utils/ecosystem/LinkHelper.kt new file mode 100644 index 00000000..23561573 --- /dev/null +++ b/core/src/main/java/com/nextcloud/android/common/core/utils/ecosystem/LinkHelper.kt @@ -0,0 +1,46 @@ +/* + * Nextcloud Android Common Library + * + * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: MIT + */ + +package com.nextcloud.android.common.core.utils.ecosystem + +import android.content.ActivityNotFoundException +import android.content.Context +import android.content.Intent +import androidx.core.net.toUri + +/** + * Helper class for opening Nextcloud apps if present + * or falling back to opening the app store + * in case the app is not yet installed on the device. + */ +object LinkHelper { + /** + * Open app store page of specified app or search for specified string. Will attempt to open browser when no app + * store is available. + * + * @param string packageName or url-encoded search string + * @param search false -> show app corresponding to packageName; true -> open search for string + */ + fun openAppStore( + string: String, + search: Boolean = false, + context: Context + ) { + var suffix = (if (search) "search?q=" else "details?id=") + string + val intent = Intent(Intent.ACTION_VIEW, "market://$suffix".toUri()) + try { + context.startActivity(intent) + } catch (_: ActivityNotFoundException) { + // all is lost: open Google play store web page for app + if (!search) { + suffix = "apps/$suffix" + } + intent.setData("https://play.google.com/store/$suffix".toUri()) + context.startActivity(intent) + } + } +} diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 48dd66ba..ab607d23 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -910,6 +910,11 @@ + + + + + @@ -982,6 +987,14 @@ + + + + + + + + @@ -1048,6 +1061,11 @@ + + + + + @@ -1120,6 +1138,14 @@ + + + + + + + + @@ -1186,6 +1212,11 @@ + + + + + @@ -1266,6 +1297,14 @@ + + + + + + + + @@ -1340,6 +1379,11 @@ + + + + + @@ -1420,6 +1464,14 @@ + + + + + + + + @@ -1542,6 +1594,11 @@ + + + + + @@ -1622,6 +1679,14 @@ + + + + + + + + @@ -1744,6 +1809,11 @@ + + + + + @@ -1824,6 +1894,14 @@ + + + + + + + + @@ -1898,6 +1976,11 @@ + + + + + @@ -1930,6 +2013,14 @@ + + + + + + + + @@ -1956,6 +2047,11 @@ + + + + + @@ -1972,6 +2068,14 @@ + + + + + + + + @@ -1982,6 +2086,11 @@ + + + + + @@ -2062,6 +2171,14 @@ + + + + + + + + @@ -2136,6 +2253,11 @@ + + + + + @@ -2216,6 +2338,14 @@ + + + + + + + + @@ -2290,6 +2420,11 @@ + + + + + @@ -2370,6 +2505,14 @@ + + + + + + + + @@ -2444,6 +2587,11 @@ + + + + + @@ -2524,6 +2672,14 @@ + + + + + + + + @@ -2598,6 +2754,11 @@ + + + + + @@ -2678,6 +2839,14 @@ + + + + + + + + @@ -2752,6 +2921,11 @@ + + + + + @@ -2832,6 +3006,14 @@ + + + + + + + + @@ -2906,6 +3088,11 @@ + + + + + @@ -2986,6 +3173,14 @@ + + + + + + + + @@ -3416,6 +3611,14 @@ + + + + + + + + @@ -3544,6 +3747,14 @@ + + + + + + + + @@ -3680,6 +3891,14 @@ + + + + + + + + @@ -5997,6 +6216,14 @@ + + + + + + + + @@ -6125,6 +6352,14 @@ + + + + + + + + @@ -6205,6 +6440,11 @@ + + + + + @@ -6333,11 +6573,24 @@ + + + + + + + + + + + + + @@ -6418,6 +6671,11 @@ + + + + + @@ -6554,6 +6812,14 @@ + + + + + + + + @@ -6690,6 +6956,14 @@ + + + + + + + + @@ -6826,6 +7100,14 @@ + + + + + + + + @@ -7050,6 +7332,14 @@ + + + + + + + + @@ -7170,6 +7460,14 @@ + + + + + + + + @@ -7290,6 +7588,14 @@ + + + + + + + + @@ -7410,6 +7716,14 @@ + + + + + + + + @@ -7530,6 +7844,14 @@ + + + + + + + + @@ -7650,6 +7972,14 @@ + + + + + + + + @@ -7770,6 +8100,14 @@ + + + + + + + + @@ -7978,6 +8316,14 @@ + + + + + + + + @@ -8098,6 +8444,14 @@ + + + + + + + + @@ -8218,6 +8572,14 @@ + + + + + + + + @@ -8338,6 +8700,14 @@ + + + + + + + + @@ -8458,6 +8828,14 @@ + + + + + + + + @@ -8578,6 +8956,14 @@ + + + + + + + + @@ -8698,6 +9084,14 @@ + + + + + + + + @@ -8890,6 +9284,14 @@ + + + + + + + + @@ -9018,6 +9420,14 @@ + + + + + + + + @@ -9042,6 +9452,14 @@ + + + + + + + + @@ -9050,6 +9468,14 @@ + + + + + + + + @@ -9178,6 +9604,14 @@ + + + + + + + + @@ -9314,6 +9748,14 @@ + + + + + + + + @@ -9474,6 +9916,14 @@ + + + + + + + + @@ -9578,6 +10028,14 @@ + + + + + + + + @@ -9986,6 +10444,14 @@ + + + + + + + + @@ -10490,6 +10956,14 @@ + + + + + + + + @@ -10610,6 +11084,14 @@ + + + + + + + + @@ -10714,6 +11196,14 @@ + + + + + + + + @@ -10834,6 +11324,14 @@ + + + + + + + + @@ -11274,6 +11772,14 @@ + + + + + + + + @@ -11394,6 +11900,14 @@ + + + + + + + + @@ -11498,6 +12012,14 @@ + + + + + + + + @@ -11618,6 +12140,14 @@ + + + + + + + + @@ -11722,6 +12252,14 @@ + + + + + + + + @@ -11842,6 +12380,14 @@ + + + + + + + + @@ -11946,6 +12492,14 @@ + + + + + + + + @@ -12050,6 +12604,14 @@ + + + + + + + + @@ -12154,6 +12716,14 @@ + + + + + + + + @@ -12274,6 +12844,14 @@ + + + + + + + + @@ -12378,6 +12956,14 @@ + + + + + + + + @@ -12498,6 +13084,14 @@ + + + + + + + + @@ -12730,6 +13324,14 @@ + + + + + + + + @@ -12850,6 +13452,14 @@ + + + + + + + + @@ -12858,6 +13468,14 @@ + + + + + + + + @@ -12866,6 +13484,14 @@ + + + + + + + + @@ -12970,6 +13596,14 @@ + + + + + + + + @@ -13147,6 +13781,14 @@ + + + + + + + + @@ -13227,6 +13869,14 @@ + + + + + + + + @@ -13307,6 +13957,14 @@ + + + + + + + + @@ -13689,6 +14347,14 @@ + + + + + + + + @@ -13745,6 +14411,14 @@ + + + + + + + + @@ -13801,6 +14475,14 @@ + + + + + + + + @@ -13944,6 +14626,14 @@ + + + + + + + + @@ -14019,6 +14709,11 @@ + + + + + @@ -15770,6 +16465,11 @@ + + + + + @@ -15791,6 +16491,11 @@ + + + + + @@ -15812,6 +16517,11 @@ + + + + + @@ -15836,6 +16546,14 @@ + + + + + + + + @@ -15860,6 +16578,14 @@ + + + + + + + + @@ -15881,6 +16607,11 @@ + + + + + @@ -15905,6 +16636,14 @@ + + + + + + + + @@ -15926,6 +16665,11 @@ + + + + + @@ -15950,6 +16694,14 @@ + + + + + + + + @@ -15974,6 +16726,14 @@ + + + + + + + + @@ -16290,6 +17050,14 @@ + + + + + + + + @@ -16319,6 +17087,14 @@ + + + + + + + + @@ -16339,6 +17115,11 @@ + + + + + @@ -17077,6 +17858,14 @@ + + + + + + + + @@ -17125,6 +17914,14 @@ + + + + + + + + @@ -17157,6 +17954,14 @@ + + + + + + + + @@ -17213,6 +18018,14 @@ + + + + + + + + @@ -17282,6 +18095,14 @@ + + + + + + + + @@ -17375,6 +18196,14 @@ + + + + + + + + @@ -17383,6 +18212,14 @@ + + + + + + + + @@ -17431,6 +18268,14 @@ + + + + + + + + @@ -17528,6 +18373,14 @@ + + + + + + + + @@ -17621,6 +18474,14 @@ + + + + + + + + @@ -17669,6 +18530,14 @@ + + + + + + + + @@ -17762,6 +18631,14 @@ + + + + + + + + @@ -17859,6 +18736,14 @@ + + + + + + + + @@ -17907,6 +18792,14 @@ + + + + + + + + @@ -17955,6 +18848,14 @@ + + + + + + + + @@ -18018,6 +18919,14 @@ + + + + + + + + @@ -18066,6 +18975,14 @@ + + + + + + + + @@ -18114,6 +19031,14 @@ + + + + + + + + @@ -18202,6 +19127,14 @@ + + + + + + + + @@ -18258,6 +19191,14 @@ + + + + + + + + @@ -18338,6 +19279,14 @@ + + + + + + + + @@ -18386,6 +19335,14 @@ + + + + + + + + @@ -18466,6 +19423,14 @@ + + + + + + + + @@ -18538,6 +19503,14 @@ + + + + + + + + @@ -18852,6 +19825,14 @@ + + + + + + + + @@ -18951,6 +19932,11 @@ + + + + + @@ -19174,6 +20160,14 @@ + + + + + + + + @@ -19222,6 +20216,14 @@ + + + + + + + + @@ -19270,6 +20272,14 @@ + + + + + + + + @@ -19318,6 +20328,14 @@ + + + + + + + + @@ -19628,6 +20646,14 @@ + + + + + + + + @@ -19678,6 +20704,11 @@ + + + + + @@ -19708,6 +20739,11 @@ + + + + + @@ -19759,6 +20795,14 @@ + + + + + + + + @@ -20112,6 +21156,14 @@ + + + + + + + + @@ -20125,6 +21177,14 @@ + + + + + + + + @@ -20135,6 +21195,11 @@ + + + + +