Commit fb595b8b authored by Aayush Gupta's avatar Aayush Gupta
Browse files

Apps: Remove obsolete android version checks



minSdkVersion is high enough for us to drop these checks
Signed-off-by: Aayush Gupta's avatarAayush Gupta <theimpulson@e.email>
parent f8d29aa4
......@@ -28,9 +28,7 @@ object IntentUtils {
Intent().apply {
this.action = Intent.ACTION_VIEW
this.flags = Intent.FLAG_ACTIVITY_NEW_TASK
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
this.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
}
this.flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
this.setDataAndType(UriUtils.fromFileProvider(mContext, File(filePath)), "application/vnd.android.package-archive")
mContext.startActivity(this)
}
......
......@@ -36,11 +36,7 @@ class LocaleUtils {
val systemLocal: Locale
get() {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
LocaleList.getDefault().get(0)
} else {
Locale.getDefault()
}
return LocaleList.getDefault().get(0)
}
......@@ -51,17 +47,7 @@ class LocaleUtils {
// }
private fun forLanguageTag(languageTag: String): Locale {
return if (Build.VERSION.SDK_INT >= 21) {
Locale.forLanguageTag(languageTag)
} else {
val parts = languageTag.split("-".toRegex()).toTypedArray()
if (parts.size == 1)
Locale(parts[0])
else if (parts.size == 2 || parts.size == 3 && parts[2].startsWith("#"))
Locale(parts[0], parts[1])
else
Locale(parts[0], parts[1], parts[2])
}
return Locale.forLanguageTag(languageTag)
}
private fun toLanguageTag(locale: Locale): String {
......
......@@ -28,10 +28,6 @@ object UriUtils {
private val fileProviderPath by lazy { "${BuildConfig.APPLICATION_ID}.fileprovider" }
fun fromFileProvider(mContext: Context, file: File): Uri {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
FileProvider.getUriForFile(mContext, fileProviderPath, file)
} else {
Uri.fromFile(file)
}
return FileProvider.getUriForFile(mContext, fileProviderPath, file)
}
}
......@@ -56,12 +56,6 @@ object XApkInstallUtils {
}
return@Runnable
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && this.XSplitApks?.size ?: 0 > 1) {
handler.post {
xApkInstallProgressCallback?.onError(InstallError.LowerSdkError)
}
return@Runnable
}
if (this.useObbs()) {
installXApkObb(zipFile!!, this, xApkInstallProgressCallback)
}
......
......@@ -128,13 +128,11 @@ class ApplicationActivity :
} else {
toolbar.elevation = defaultElevation
}
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
scroll_view.setOnScrollChangeListener { view, ia, ib, ic, id ->
if (view.scrollY == 0) {
toolbar.elevation = 0f
} else {
toolbar.elevation = defaultElevation
}
scroll_view.setOnScrollChangeListener { view, ia, ib, ic, id ->
if (view.scrollY == 0) {
toolbar.elevation = 0f
} else {
toolbar.elevation = defaultElevation
}
}
}
......@@ -721,9 +719,7 @@ class ApplicationActivity :
imageView.setImageBitmap(it)
val outValue = TypedValue()
theme.resolveAttribute(android.R.attr.selectableItemBackground, outValue, true)
if (android.os.Build.VERSION.SDK_INT >= 23) {
imageView.foreground = getDrawable(outValue.resourceId)
}
imageView.foreground = getDrawable(outValue.resourceId)
app_images_container.addView(imageView)
imageView.setOnClickListener { _ ->
val intent = Intent(this, ScreenshotsActivity::class.java)
......
......@@ -149,15 +149,11 @@ class Application(val packageName: String, private val applicationManager: Appli
}
private fun canWriteStorage(activity: Activity): Boolean {
return if (android.os.Build.VERSION.SDK_INT >= 23) {
if (activity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
activity.requestPermissions(arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),
Constants.STORAGE_PERMISSION_REQUEST_CODE)
false
} else {
true
}
return if (activity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
activity.requestPermissions(arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE),
Constants.STORAGE_PERMISSION_REQUEST_CODE)
false
} else {
true
}
......
......@@ -61,11 +61,7 @@ class Installer(private val packageName: String,
}
private fun requestApplicationInstall(context: Context) {
val uri = if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
FileProvider.getUriForFile(context, context.packageName + ".provider", apk)
} else {
Uri.fromFile(apk)
}
val uri = FileProvider.getUriForFile(context, context.packageName + ".provider", apk)
val intent = Intent(Intent.ACTION_INSTALL_PACKAGE)
intent.action = Intent.ACTION_VIEW
intent.setDataAndType(uri, "application/vnd.android.package-archive")
......
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2019-2021 E FOUNDATION
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingStart="?android:dialogPreferredPadding"
android:paddingTop="@dimen/layout_padding_medium"
android:paddingEnd="?android:dialogPreferredPadding"
android:text="@string/app_privacy_description"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/text_size_large" />
\ No newline at end of file
......@@ -20,9 +20,9 @@
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingStart="@dimen/layout_padding_large"
android:paddingStart="?android:dialogPreferredPadding"
android:paddingTop="@dimen/layout_padding_medium"
android:paddingEnd="@dimen/layout_padding_large"
android:paddingEnd="?android:dialogPreferredPadding"
android:text="@string/app_privacy_description"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/text_size_large" />
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2019 e Foundation
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="@style/BaseTheme">
<item name="android:statusBarColor">@color/colorPrimaryDark</item>
<item name="android:windowLightStatusBar">true</item>
</style>
</resources>
\ No newline at end of file
......@@ -36,7 +36,7 @@
<style name="AppTheme1" parent="android:Theme">
<item name="android:windowDisablePreview">true</item>
</style>
<style name="AppTheme" parent="BaseTheme"/>
<style name="AppTheme" parent="BaseTheme"></style>
<style name="SearchSuggestionTheme" parent="Widget.AppCompat.Light.AutoCompleteTextView">
<item name="android:popupBackground">#FAFAFA</item>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment