Add initial support for external storage
This commit is contained in:
@@ -21,7 +21,10 @@ package com.aurora.store
|
|||||||
|
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.Environment
|
||||||
|
import android.provider.Settings
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@@ -42,7 +45,7 @@ import com.aurora.store.databinding.ActivityMainBinding
|
|||||||
import com.aurora.store.util.Log
|
import com.aurora.store.util.Log
|
||||||
import com.aurora.store.util.ViewUtil
|
import com.aurora.store.util.ViewUtil
|
||||||
import com.aurora.store.util.ViewUtil.getStyledAttribute
|
import com.aurora.store.util.ViewUtil.getStyledAttribute
|
||||||
import com.aurora.store.util.extensions.isQAndAbove
|
import com.aurora.store.util.extensions.isRAndAbove
|
||||||
import com.aurora.store.util.extensions.load
|
import com.aurora.store.util.extensions.load
|
||||||
import com.aurora.store.util.extensions.open
|
import com.aurora.store.util.extensions.open
|
||||||
import com.aurora.store.view.ui.about.AboutActivity
|
import com.aurora.store.view.ui.about.AboutActivity
|
||||||
@@ -97,16 +100,20 @@ class MainActivity : BaseActivity() {
|
|||||||
attachSearch()
|
attachSearch()
|
||||||
|
|
||||||
checkPermission()
|
checkPermission()
|
||||||
|
checkStoragePermission()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkPermission() = runWithPermissions(
|
private fun checkPermission() = runWithPermissions(
|
||||||
Manifest.permission.READ_EXTERNAL_STORAGE,
|
Manifest.permission.READ_EXTERNAL_STORAGE,
|
||||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||||
) {
|
) {
|
||||||
Log.i("External Storage Access Available")
|
Log.i("Required permissions available")
|
||||||
|
}
|
||||||
|
|
||||||
if (isQAndAbove()) {
|
private fun checkStoragePermission() {
|
||||||
//pickExternalFileDir()
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||||
|
if (!Environment.isExternalStorageManager())
|
||||||
|
startActivity(Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,14 +32,18 @@ fun Context.getInternalBaseDirectory(): String {
|
|||||||
object PathUtil {
|
object PathUtil {
|
||||||
|
|
||||||
private fun getDownloadDirectory(context: Context): String {
|
private fun getDownloadDirectory(context: Context): String {
|
||||||
return if (isLAndAbove())
|
return if (isLAndAbove()) {
|
||||||
context.getInternalBaseDirectory() + "/Downloads"
|
if (Preferences.getBoolean(context, Preferences.PREFERENCE_DOWNLOAD_EXTERNAL))
|
||||||
else
|
|
||||||
getExternalPath()
|
getExternalPath()
|
||||||
|
else
|
||||||
|
context.getInternalBaseDirectory() + "/Downloads"
|
||||||
|
} else {
|
||||||
|
getExternalPath()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getPackageDirectory(context: Context, packageName: String): String {
|
fun getPackageDirectory(context: Context, packageName: String): String {
|
||||||
return getDownloadDirectory(context) + "/$packageName"
|
return getDownloadDirectory(context) + "/Downloads/$packageName"
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getVersionDirectory(
|
private fun getVersionDirectory(
|
||||||
@@ -59,11 +63,11 @@ object PathUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getExternalPath(): String {
|
fun getExternalPath(): String {
|
||||||
return Environment.getExternalStorageDirectory().toString() + "/Aurora/"
|
return Environment.getExternalStorageDirectory().toString() + "/Aurora/Store"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getBaseCopyDirectory(): String {
|
fun getBaseCopyDirectory(): String {
|
||||||
return "${getExternalPath()}/files/export/"
|
return "${getExternalPath()}/Exports/"
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getObbDownloadPath(context: Context, app: App): String {
|
private fun getObbDownloadPath(context: Context, app: App): String {
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ object Preferences {
|
|||||||
const val INSTALLATION_ABANDON_SESSION = "INSTALLATION_ABANDON_SESSION"
|
const val INSTALLATION_ABANDON_SESSION = "INSTALLATION_ABANDON_SESSION"
|
||||||
|
|
||||||
const val PREFERENCE_DOWNLOAD_ACTIVE = "PREFERENCE_DOWNLOAD_ACTIVE"
|
const val PREFERENCE_DOWNLOAD_ACTIVE = "PREFERENCE_DOWNLOAD_ACTIVE"
|
||||||
|
const val PREFERENCE_DOWNLOAD_EXTERNAL = "PREFERENCE_DOWNLOAD_EXTERNAL"
|
||||||
const val PREFERENCE_DOWNLOAD_WIFI = "PREFERENCE_DOWNLOAD_WIFI"
|
const val PREFERENCE_DOWNLOAD_WIFI = "PREFERENCE_DOWNLOAD_WIFI"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ package com.aurora.store.util.extensions
|
|||||||
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.text.format.DateFormat
|
import android.text.format.DateFormat
|
||||||
|
import androidx.annotation.RequiresApi
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
fun Long.toDate(): String {
|
fun Long.toDate(): String {
|
||||||
@@ -44,3 +45,7 @@ fun isPAndAbove(): Boolean {
|
|||||||
fun isQAndAbove(): Boolean {
|
fun isQAndAbove(): Boolean {
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
|
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isRAndAbove(): Boolean {
|
||||||
|
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.R
|
||||||
|
}
|
||||||
@@ -32,6 +32,7 @@ import com.aurora.store.util.Preferences
|
|||||||
import com.aurora.store.util.Preferences.PREFERENCE_AUTO_DELETE
|
import com.aurora.store.util.Preferences.PREFERENCE_AUTO_DELETE
|
||||||
import com.aurora.store.util.Preferences.PREFERENCE_DEFAULT
|
import com.aurora.store.util.Preferences.PREFERENCE_DEFAULT
|
||||||
import com.aurora.store.util.Preferences.PREFERENCE_DOWNLOAD_ACTIVE
|
import com.aurora.store.util.Preferences.PREFERENCE_DOWNLOAD_ACTIVE
|
||||||
|
import com.aurora.store.util.Preferences.PREFERENCE_DOWNLOAD_EXTERNAL
|
||||||
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_FDROID
|
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_FDROID
|
||||||
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_GOOGLE
|
import com.aurora.store.util.Preferences.PREFERENCE_FILTER_GOOGLE
|
||||||
import com.aurora.store.util.Preferences.PREFERENCE_INSTALLER_ID
|
import com.aurora.store.util.Preferences.PREFERENCE_INSTALLER_ID
|
||||||
@@ -149,13 +150,14 @@ class OnboardingActivity : BaseActivity() {
|
|||||||
|
|
||||||
/*Downloader*/
|
/*Downloader*/
|
||||||
save(PREFERENCE_DOWNLOAD_ACTIVE, 3)
|
save(PREFERENCE_DOWNLOAD_ACTIVE, 3)
|
||||||
|
save(PREFERENCE_DOWNLOAD_EXTERNAL, false)
|
||||||
|
|
||||||
/*Theme*/
|
/*Theme*/
|
||||||
save(PREFERENCE_THEME_TYPE, 0)
|
save(PREFERENCE_THEME_TYPE, 0)
|
||||||
save(PREFERENCE_THEME_ACCENT, 0)
|
save(PREFERENCE_THEME_ACCENT, 0)
|
||||||
|
|
||||||
/*Installer*/
|
/*Installer*/
|
||||||
save(PREFERENCE_AUTO_DELETE, false)
|
save(PREFERENCE_AUTO_DELETE, true)
|
||||||
save(PREFERENCE_INSTALLER_ID, 0)
|
save(PREFERENCE_INSTALLER_ID, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import com.aurora.store.data.providers.BlacklistProvider
|
|||||||
import com.aurora.store.databinding.SheetAppMenuBinding
|
import com.aurora.store.databinding.SheetAppMenuBinding
|
||||||
import com.aurora.store.util.ApkCopier
|
import com.aurora.store.util.ApkCopier
|
||||||
import com.aurora.store.util.PackageUtil
|
import com.aurora.store.util.PackageUtil
|
||||||
import com.aurora.store.util.extensions.isQAndAbove
|
|
||||||
import com.aurora.store.util.extensions.openInfo
|
import com.aurora.store.util.extensions.openInfo
|
||||||
import com.aurora.store.util.extensions.toast
|
import com.aurora.store.util.extensions.toast
|
||||||
import com.livinglifetechway.quickpermissions_kotlin.runWithPermissions
|
import com.livinglifetechway.quickpermissions_kotlin.runWithPermissions
|
||||||
@@ -87,11 +86,6 @@ class AppMenuSheet : BaseBottomSheet() {
|
|||||||
menu.findItem(R.id.action_uninstall).isVisible = installed
|
menu.findItem(R.id.action_uninstall).isVisible = installed
|
||||||
menu.findItem(R.id.action_local).isVisible = installed
|
menu.findItem(R.id.action_local).isVisible = installed
|
||||||
|
|
||||||
if (isQAndAbove()) {
|
|
||||||
//TODO: Add Scoped Storage Access
|
|
||||||
menu.findItem(R.id.action_local).isVisible = false
|
|
||||||
}
|
|
||||||
|
|
||||||
setNavigationItemSelectedListener { item ->
|
setNavigationItemSelectedListener { item ->
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.action_blacklist -> {
|
R.id.action_blacklist -> {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<ViewStub
|
<ViewStub
|
||||||
|
android:id="@+id/header_view"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
|
|||||||
@@ -234,6 +234,8 @@
|
|||||||
<string name="pref_dialog_to_apply_restart">"This setting will be applied after you restart the app"</string>
|
<string name="pref_dialog_to_apply_restart">"This setting will be applied after you restart the app"</string>
|
||||||
<string name="pref_downloader_active_summary">"Maximum number of active downloads"</string>
|
<string name="pref_downloader_active_summary">"Maximum number of active downloads"</string>
|
||||||
<string name="pref_downloader_active_title">"Active download"</string>
|
<string name="pref_downloader_active_title">"Active download"</string>
|
||||||
|
<string name="pref_downloader_external">"User external storage"</string>
|
||||||
|
<string name="pref_downloader_external_desc">"External storage will be used for downloads, exports etc."</string>
|
||||||
<string name="pref_filter_fdroid_summary">"Removes F-Droid apps from app lists"</string>
|
<string name="pref_filter_fdroid_summary">"Removes F-Droid apps from app lists"</string>
|
||||||
<string name="pref_filter_fdroid_title">"Filter F-Droid apps"</string>
|
<string name="pref_filter_fdroid_title">"Filter F-Droid apps"</string>
|
||||||
<string name="pref_filter_google_summary">"Removes all Google Apps from search results and category apps"</string>
|
<string name="pref_filter_google_summary">"Removes all Google Apps from search results and category apps"</string>
|
||||||
|
|||||||
@@ -20,6 +20,13 @@
|
|||||||
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
app:defaultValue="false"
|
||||||
|
app:iconSpaceReserved="false"
|
||||||
|
app:key="PREFERENCE_DOWNLOAD_EXTERNAL"
|
||||||
|
app:summary="@string/pref_downloader_external_desc"
|
||||||
|
app:title="@string/pref_downloader_external" />
|
||||||
|
|
||||||
<SeekBarPreference
|
<SeekBarPreference
|
||||||
android:defaultValue="3"
|
android:defaultValue="3"
|
||||||
android:key="PREFERENCE_DOWNLOAD_ACTIVE"
|
android:key="PREFERENCE_DOWNLOAD_ACTIVE"
|
||||||
|
|||||||
Reference in New Issue
Block a user