Update build configuration

Update the build config to further optimize the app
- Removed the browser dependency [-10k]
- Enabled resource minification [-100k]
This commit is contained in:
OxygenCobalt 2021-03-26 10:53:11 -06:00
parent b65814fdbd
commit 076d2b3d7e
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
2 changed files with 16 additions and 31 deletions

View file

@ -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

View file

@ -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]")