From 076d2b3d7eec1be1a0fe4eef50a6e302b6103056 Mon Sep 17 00:00:00 2001 From: OxygenCobalt Date: Fri, 26 Mar 2021 10:53:11 -0600 Subject: [PATCH] Update build configuration Update the build config to further optimize the app - Removed the browser dependency [-10k] - Enabled resource minification [-100k] --- app/build.gradle | 8 ++-- .../org/oxycblt/auxio/settings/AboutDialog.kt | 39 +++++++------------ 2 files changed, 16 insertions(+), 31 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 1e8b004f6..72c87b59a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -29,6 +29,7 @@ android { release { minifyEnabled true + shrinkResources true proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" } } @@ -62,8 +63,8 @@ dependencies { // General implementation "androidx.core:core-ktx:1.3.2" - implementation "androidx.activity:activity-ktx:1.2.1" - implementation "androidx.fragment:fragment-ktx:1.3.0" + implementation "androidx.activity:activity-ktx:1.2.2" + implementation "androidx.fragment:fragment-ktx:1.3.1" // UI implementation "androidx.recyclerview:recyclerview:1.1.0" @@ -88,9 +89,6 @@ dependencies { // Preferences implementation "androidx.preference:preference-ktx:1.1.1" - // Opening links - implementation "androidx.browser:browser:1.3.0" - // --- THIRD PARTY --- // ExoPlayer diff --git a/app/src/main/java/org/oxycblt/auxio/settings/AboutDialog.kt b/app/src/main/java/org/oxycblt/auxio/settings/AboutDialog.kt index 2978a0c1a..dff10eebc 100644 --- a/app/src/main/java/org/oxycblt/auxio/settings/AboutDialog.kt +++ b/app/src/main/java/org/oxycblt/auxio/settings/AboutDialog.kt @@ -5,7 +5,6 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.browser.customtabs.CustomTabsIntent import androidx.core.net.toUri import com.google.android.material.bottomsheet.BottomSheetDialogFragment import org.oxycblt.auxio.BuildConfig @@ -53,34 +52,22 @@ class AboutDialog : BottomSheetDialogFragment() { check(link in LINKS) { "Invalid link." } try { - val tabsIntent = CustomTabsIntent.Builder() - .setShareState(CustomTabsIntent.SHARE_STATE_ON) - .setShowTitle(true) - .build() - val uri = link.toUri() - val manager = requireActivity().packageManager - val browserCandidates = manager.queryIntentActivities(tabsIntent.intent, 0) - // If there are candidates for this link, then launch it through that. - if (browserCandidates.size > 0) { - tabsIntent.launchUrl(requireActivity(), uri) + val browserIntent = Intent(Intent.ACTION_VIEW, uri) + browserIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK + + val fallbackCandidates = requireContext().packageManager.queryIntentActivities( + browserIntent, 0 + ) + + // If there are candidates here, then launch those. + if (fallbackCandidates.size > 0) { + requireActivity().startActivity(browserIntent) } else { - // If there are no candidates, then fallback to another list of browsers - - val browserIntent = Intent(Intent.ACTION_VIEW, uri) - browserIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK - - val fallbackCandidates = manager.queryIntentActivities(browserIntent, 0) - - // If there are candidates here, then launch those. - if (fallbackCandidates.size > 0) { - requireActivity().startActivity(browserIntent) - } else { - // Otherwise they don't have a browser on their phone, meaning they should - // just see an error. - getString(R.string.error_no_browser).createToast(requireContext()) - } + // Otherwise they don't have a browser on their phone, meaning they should + // just see an error. + getString(R.string.error_no_browser).createToast(requireContext()) } } catch (e: Exception) { logE("Browser intent launching failed [Probably android's fault]")