mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-06-05 22:09:15 +02:00
Merge pull request #733 from fatihergin/feature/viewbinding-sdk-34-migration
Feature/viewbinding sdk 34 migration
This commit is contained in:
@ -1,6 +1,5 @@
|
|||||||
apply plugin: 'com.android.application'
|
apply plugin: 'com.android.application'
|
||||||
apply plugin: 'kotlin-android'
|
apply plugin: 'kotlin-android'
|
||||||
apply plugin: 'kotlin-android-extensions'
|
|
||||||
|
|
||||||
def keystorePropertiesFile = rootProject.file("keystore.properties")
|
def keystorePropertiesFile = rootProject.file("keystore.properties")
|
||||||
def keystoreProperties = new Properties()
|
def keystoreProperties = new Properties()
|
||||||
@ -9,12 +8,13 @@ if (keystorePropertiesFile.exists()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 33
|
namespace "com.simplemobiletools.filemanager.pro"
|
||||||
|
compileSdk 34
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.simplemobiletools.filemanager.pro"
|
applicationId "com.simplemobiletools.filemanager.pro"
|
||||||
minSdkVersion 23
|
minSdk 23
|
||||||
targetSdkVersion 33
|
targetSdk 34
|
||||||
versionCode 135
|
versionCode 135
|
||||||
versionName "6.16.0"
|
versionName "6.16.0"
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
@ -33,6 +33,11 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildFeatures {
|
||||||
|
buildConfig true
|
||||||
|
viewBinding true
|
||||||
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
debug {
|
debug {
|
||||||
applicationIdSuffix ".debug"
|
applicationIdSuffix ".debug"
|
||||||
@ -46,7 +51,16 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flavorDimensions "variants"
|
compileOptions {
|
||||||
|
sourceCompatibility JavaVersion.VERSION_17
|
||||||
|
targetCompatibility JavaVersion.VERSION_17
|
||||||
|
}
|
||||||
|
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = '17'
|
||||||
|
}
|
||||||
|
|
||||||
|
flavorDimensions = ["variants"]
|
||||||
productFlavors {
|
productFlavors {
|
||||||
core {}
|
core {}
|
||||||
fdroid {}
|
fdroid {}
|
||||||
@ -64,7 +78,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.github.SimpleMobileTools:Simple-Commons:ae8713396b'
|
implementation 'com.github.SimpleMobileTools:Simple-Commons:d1629c7f1a'
|
||||||
implementation 'com.github.tibbi:AndroidPdfViewer:e6a533125b'
|
implementation 'com.github.tibbi:AndroidPdfViewer:e6a533125b'
|
||||||
implementation 'com.github.Stericson:RootTools:df729dcb13'
|
implementation 'com.github.Stericson:RootTools:df729dcb13'
|
||||||
implementation 'com.github.Stericson:RootShell:1.6'
|
implementation 'com.github.Stericson:RootShell:1.6'
|
||||||
|
@ -11,20 +11,22 @@ import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
|||||||
import com.simplemobiletools.commons.helpers.isOreoPlus
|
import com.simplemobiletools.commons.helpers.isOreoPlus
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
import com.simplemobiletools.filemanager.pro.adapters.DecompressItemsAdapter
|
import com.simplemobiletools.filemanager.pro.adapters.DecompressItemsAdapter
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.ActivityDecompressBinding
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||||
import com.simplemobiletools.filemanager.pro.models.ListItem
|
import com.simplemobiletools.filemanager.pro.models.ListItem
|
||||||
import kotlinx.android.synthetic.main.activity_decompress.*
|
|
||||||
import net.lingala.zip4j.exception.ZipException
|
import net.lingala.zip4j.exception.ZipException
|
||||||
import net.lingala.zip4j.exception.ZipException.Type
|
import net.lingala.zip4j.exception.ZipException.Type
|
||||||
import net.lingala.zip4j.io.inputstream.ZipInputStream
|
import net.lingala.zip4j.io.inputstream.ZipInputStream
|
||||||
import net.lingala.zip4j.model.LocalFileHeader
|
import net.lingala.zip4j.model.LocalFileHeader
|
||||||
import java.io.BufferedInputStream
|
import java.io.BufferedInputStream
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
class DecompressActivity : SimpleActivity() {
|
class DecompressActivity : SimpleActivity() {
|
||||||
companion object {
|
companion object {
|
||||||
private const val PASSWORD = "password"
|
private const val PASSWORD = "password"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val binding by lazy(LazyThreadSafetyMode.NONE) { ActivityDecompressBinding.inflate(layoutInflater) }
|
||||||
private val allFiles = ArrayList<ListItem>()
|
private val allFiles = ArrayList<ListItem>()
|
||||||
private var currentPath = ""
|
private var currentPath = ""
|
||||||
private var uri: Uri? = null
|
private var uri: Uri? = null
|
||||||
@ -34,10 +36,12 @@ class DecompressActivity : SimpleActivity() {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_decompress)
|
setContentView(binding.root)
|
||||||
setupOptionsMenu()
|
setupOptionsMenu()
|
||||||
updateMaterialActivityViews(decompress_coordinator, decompress_list, useTransparentNavigation = true, useTopSearchMenu = false)
|
binding.apply {
|
||||||
setupMaterialScrollListener(decompress_list, decompress_toolbar)
|
updateMaterialActivityViews(decompressCoordinator, decompressList, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||||
|
setupMaterialScrollListener(decompressList, decompressToolbar)
|
||||||
|
}
|
||||||
|
|
||||||
uri = intent.data
|
uri = intent.data
|
||||||
if (uri == null) {
|
if (uri == null) {
|
||||||
@ -48,13 +52,13 @@ class DecompressActivity : SimpleActivity() {
|
|||||||
password = savedInstanceState?.getString(PASSWORD, null)
|
password = savedInstanceState?.getString(PASSWORD, null)
|
||||||
|
|
||||||
val realPath = getRealPathFromURI(uri!!)
|
val realPath = getRealPathFromURI(uri!!)
|
||||||
decompress_toolbar.title = realPath?.getFilenameFromPath() ?: Uri.decode(uri.toString().getFilenameFromPath())
|
binding.decompressToolbar.title = realPath?.getFilenameFromPath() ?: Uri.decode(uri.toString().getFilenameFromPath())
|
||||||
setupFilesList()
|
setupFilesList()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
setupToolbar(decompress_toolbar, NavigationIcon.Arrow)
|
setupToolbar(binding.decompressToolbar, NavigationIcon.Arrow)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSaveInstanceState(outState: Bundle) {
|
override fun onSaveInstanceState(outState: Bundle) {
|
||||||
@ -63,7 +67,7 @@ class DecompressActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOptionsMenu() {
|
private fun setupOptionsMenu() {
|
||||||
decompress_toolbar.setOnMenuItemClickListener { menuItem ->
|
binding.decompressToolbar.setOnMenuItemClickListener { menuItem ->
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.decompress -> decompressFiles()
|
R.id.decompress -> decompressFiles()
|
||||||
else -> return@setOnMenuItemClickListener false
|
else -> return@setOnMenuItemClickListener false
|
||||||
@ -90,12 +94,12 @@ class DecompressActivity : SimpleActivity() {
|
|||||||
currentPath = path
|
currentPath = path
|
||||||
try {
|
try {
|
||||||
val listItems = getFolderItems(currentPath)
|
val listItems = getFolderItems(currentPath)
|
||||||
DecompressItemsAdapter(this, listItems, decompress_list) {
|
DecompressItemsAdapter(this, listItems, binding.decompressList) {
|
||||||
if ((it as ListItem).isDirectory) {
|
if ((it as ListItem).isDirectory) {
|
||||||
updateCurrentPath(it.path)
|
updateCurrentPath(it.path)
|
||||||
}
|
}
|
||||||
}.apply {
|
}.apply {
|
||||||
decompress_list.adapter = this
|
binding.decompressList.adapter = this
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
showErrorToast(e)
|
||||||
@ -141,6 +145,11 @@ class DecompressActivity : SimpleActivity() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val isVulnerableForZipPathTraversal = !File(newPath).canonicalPath.startsWith(parent)
|
||||||
|
if (isVulnerableForZipPathTraversal) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
val fos = getFileOutputStreamSync(newPath, newPath.getMimeType())
|
val fos = getFileOutputStreamSync(newPath, newPath.getMimeType())
|
||||||
var count: Int
|
var count: Int
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -10,28 +10,31 @@ import com.simplemobiletools.commons.helpers.NavigationIcon
|
|||||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
import com.simplemobiletools.filemanager.pro.adapters.ManageFavoritesAdapter
|
import com.simplemobiletools.filemanager.pro.adapters.ManageFavoritesAdapter
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.ActivityFavoritesBinding
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||||
import kotlinx.android.synthetic.main.activity_favorites.*
|
|
||||||
|
|
||||||
class FavoritesActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
class FavoritesActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
||||||
|
private val binding by lazy(LazyThreadSafetyMode.NONE) { ActivityFavoritesBinding.inflate(layoutInflater) }
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_favorites)
|
setContentView(binding.root)
|
||||||
setupOptionsMenu()
|
setupOptionsMenu()
|
||||||
updateFavorites()
|
updateFavorites()
|
||||||
updateMaterialActivityViews(manage_favorites_coordinator, manage_favorites_list, useTransparentNavigation = true, useTopSearchMenu = false)
|
binding.apply {
|
||||||
setupMaterialScrollListener(manage_favorites_list, manage_favorites_toolbar)
|
updateMaterialActivityViews(manageFavoritesCoordinator, manageFavoritesList, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||||
|
setupMaterialScrollListener(manageFavoritesList, manageFavoritesToolbar)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
setupToolbar(manage_favorites_toolbar, NavigationIcon.Arrow)
|
setupToolbar(binding.manageFavoritesToolbar, NavigationIcon.Arrow)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOptionsMenu() {
|
private fun setupOptionsMenu() {
|
||||||
manage_favorites_toolbar.setOnMenuItemClickListener { menuItem ->
|
binding.manageFavoritesToolbar.setOnMenuItemClickListener { menuItem ->
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.add_favorite -> addFavorite()
|
R.id.add_favorite -> addFavorite()
|
||||||
else -> return@setOnMenuItemClickListener false
|
else -> return@setOnMenuItemClickListener false
|
||||||
@ -41,22 +44,24 @@ class FavoritesActivity : SimpleActivity(), RefreshRecyclerViewListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateFavorites() {
|
private fun updateFavorites() {
|
||||||
val favorites = ArrayList<String>()
|
binding.apply {
|
||||||
config.favorites.mapTo(favorites) { it }
|
val favorites = ArrayList<String>()
|
||||||
manage_favorites_placeholder.beVisibleIf(favorites.isEmpty())
|
config.favorites.mapTo(favorites) { it }
|
||||||
manage_favorites_placeholder.setTextColor(getProperTextColor())
|
manageFavoritesPlaceholder.beVisibleIf(favorites.isEmpty())
|
||||||
|
manageFavoritesPlaceholder.setTextColor(getProperTextColor())
|
||||||
|
|
||||||
manage_favorites_placeholder_2.apply {
|
manageFavoritesPlaceholder2.apply {
|
||||||
paintFlags = paintFlags or Paint.UNDERLINE_TEXT_FLAG
|
paintFlags = paintFlags or Paint.UNDERLINE_TEXT_FLAG
|
||||||
beVisibleIf(favorites.isEmpty())
|
beVisibleIf(favorites.isEmpty())
|
||||||
setTextColor(getProperPrimaryColor())
|
setTextColor(getProperPrimaryColor())
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
addFavorite()
|
addFavorite()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ManageFavoritesAdapter(this, favorites, this, manage_favorites_list) { }.apply {
|
ManageFavoritesAdapter(this@FavoritesActivity, favorites, this@FavoritesActivity, manageFavoritesList) { }.apply {
|
||||||
manage_favorites_list.adapter = this
|
manageFavoritesList.adapter = this
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ import com.simplemobiletools.commons.models.Release
|
|||||||
import com.simplemobiletools.filemanager.pro.BuildConfig
|
import com.simplemobiletools.filemanager.pro.BuildConfig
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
import com.simplemobiletools.filemanager.pro.adapters.ViewPagerAdapter
|
import com.simplemobiletools.filemanager.pro.adapters.ViewPagerAdapter
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.ActivityMainBinding
|
||||||
import com.simplemobiletools.filemanager.pro.dialogs.ChangeSortingDialog
|
import com.simplemobiletools.filemanager.pro.dialogs.ChangeSortingDialog
|
||||||
import com.simplemobiletools.filemanager.pro.dialogs.ChangeViewTypeDialog
|
import com.simplemobiletools.filemanager.pro.dialogs.ChangeViewTypeDialog
|
||||||
import com.simplemobiletools.filemanager.pro.dialogs.InsertFilenameDialog
|
import com.simplemobiletools.filemanager.pro.dialogs.InsertFilenameDialog
|
||||||
@ -38,11 +39,6 @@ import com.simplemobiletools.filemanager.pro.helpers.MAX_COLUMN_COUNT
|
|||||||
import com.simplemobiletools.filemanager.pro.helpers.RootHelpers
|
import com.simplemobiletools.filemanager.pro.helpers.RootHelpers
|
||||||
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
|
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
|
||||||
import com.stericson.RootTools.RootTools
|
import com.stericson.RootTools.RootTools
|
||||||
import kotlinx.android.synthetic.main.activity_main.*
|
|
||||||
import kotlinx.android.synthetic.main.items_fragment.*
|
|
||||||
import kotlinx.android.synthetic.main.items_fragment.view.*
|
|
||||||
import kotlinx.android.synthetic.main.recents_fragment.*
|
|
||||||
import kotlinx.android.synthetic.main.storage_fragment.*
|
|
||||||
import me.grantland.widget.AutofitHelper
|
import me.grantland.widget.AutofitHelper
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@ -50,6 +46,8 @@ class MainActivity : SimpleActivity() {
|
|||||||
private val BACK_PRESS_TIMEOUT = 5000
|
private val BACK_PRESS_TIMEOUT = 5000
|
||||||
private val MANAGE_STORAGE_RC = 201
|
private val MANAGE_STORAGE_RC = 201
|
||||||
private val PICKED_PATH = "picked_path"
|
private val PICKED_PATH = "picked_path"
|
||||||
|
private val binding by lazy(LazyThreadSafetyMode.NONE) { ActivityMainBinding.inflate(layoutInflater) }
|
||||||
|
|
||||||
private var wasBackJustPressed = false
|
private var wasBackJustPressed = false
|
||||||
private var mIsPasswordProtectionPending = false
|
private var mIsPasswordProtectionPending = false
|
||||||
private var mWasProtectionHandled = false
|
private var mWasProtectionHandled = false
|
||||||
@ -63,7 +61,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(binding.root)
|
||||||
appLaunched(BuildConfig.APPLICATION_ID)
|
appLaunched(BuildConfig.APPLICATION_ID)
|
||||||
setupOptionsMenu()
|
setupOptionsMenu()
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
@ -79,7 +77,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
setupTabs()
|
setupTabs()
|
||||||
|
|
||||||
updateMaterialActivityViews(main_coordinator, null, useTransparentNavigation = false, useTopSearchMenu = true)
|
updateMaterialActivityViews(binding.mainCoordinator, null, useTransparentNavigation = false, useTopSearchMenu = true)
|
||||||
|
|
||||||
mIsPasswordProtectionPending = config.isAppPasswordProtectionOn
|
mIsPasswordProtectionPending = config.isAppPasswordProtectionOn
|
||||||
|
|
||||||
@ -132,7 +130,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (main_view_pager.adapter == null && mWasProtectionHandled) {
|
if (binding.mainViewPager.adapter == null && mWasProtectionHandled) {
|
||||||
initFragments()
|
initFragments()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,7 +138,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
super.onPause()
|
super.onPause()
|
||||||
storeStateVariables()
|
storeStateVariables()
|
||||||
config.lastUsedViewPagerPage = main_view_pager.currentItem
|
config.lastUsedViewPagerPage = binding.mainViewPager.currentItem
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
@ -150,11 +148,11 @@ class MainActivity : SimpleActivity() {
|
|||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
val currentFragment = getCurrentFragment()
|
val currentFragment = getCurrentFragment()
|
||||||
if (main_menu.isSearchOpen) {
|
if (binding.mainMenu.isSearchOpen) {
|
||||||
main_menu.closeSearch()
|
binding.mainMenu.closeSearch()
|
||||||
} else if (currentFragment is RecentsFragment || currentFragment is StorageFragment) {
|
} else if (currentFragment is RecentsFragment || currentFragment is StorageFragment) {
|
||||||
super.onBackPressed()
|
super.onBackPressed()
|
||||||
} else if (currentFragment!!.breadcrumbs.getItemCount() <= 1) {
|
} else if ((currentFragment as ItemsFragment).getBreadcrumbs().getItemCount() <= 1) {
|
||||||
if (!wasBackJustPressed && config.pressBackTwice) {
|
if (!wasBackJustPressed && config.pressBackTwice) {
|
||||||
wasBackJustPressed = true
|
wasBackJustPressed = true
|
||||||
toast(R.string.press_back_again)
|
toast(R.string.press_back_again)
|
||||||
@ -165,8 +163,8 @@ class MainActivity : SimpleActivity() {
|
|||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
currentFragment.breadcrumbs?.removeBreadcrumb()
|
currentFragment.getBreadcrumbs().removeBreadcrumb()
|
||||||
openPath(currentFragment.breadcrumbs.getLastItem().path)
|
openPath(currentFragment.getBreadcrumbs().getLastItem().path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +174,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
val currentViewType = config.getFolderViewType(currentFragment.currentPath)
|
val currentViewType = config.getFolderViewType(currentFragment.currentPath)
|
||||||
val favorites = config.favorites
|
val favorites = config.favorites
|
||||||
|
|
||||||
main_menu.getToolbar().menu.apply {
|
binding.mainMenu.getToolbar().menu.apply {
|
||||||
findItem(R.id.sort).isVisible = currentFragment is ItemsFragment
|
findItem(R.id.sort).isVisible = currentFragment is ItemsFragment
|
||||||
findItem(R.id.change_view_type).isVisible = currentFragment !is StorageFragment
|
findItem(R.id.change_view_type).isVisible = currentFragment !is StorageFragment
|
||||||
|
|
||||||
@ -200,49 +198,51 @@ class MainActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOptionsMenu() {
|
private fun setupOptionsMenu() {
|
||||||
main_menu.getToolbar().inflateMenu(R.menu.menu)
|
binding.mainMenu.apply {
|
||||||
main_menu.toggleHideOnScroll(false)
|
getToolbar().inflateMenu(R.menu.menu)
|
||||||
main_menu.setupMenu()
|
toggleHideOnScroll(false)
|
||||||
|
setupMenu()
|
||||||
|
|
||||||
main_menu.onSearchClosedListener = {
|
onSearchClosedListener = {
|
||||||
getAllFragments().forEach {
|
getAllFragments().forEach {
|
||||||
it?.searchQueryChanged("")
|
it?.searchQueryChanged("")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
main_menu.onSearchTextChangedListener = { text ->
|
onSearchTextChangedListener = { text ->
|
||||||
getCurrentFragment()?.searchQueryChanged(text)
|
getCurrentFragment()?.searchQueryChanged(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
main_menu.getToolbar().setOnMenuItemClickListener { menuItem ->
|
getToolbar().setOnMenuItemClickListener { menuItem ->
|
||||||
if (getCurrentFragment() == null) {
|
if (getCurrentFragment() == null) {
|
||||||
|
return@setOnMenuItemClickListener true
|
||||||
|
}
|
||||||
|
|
||||||
|
when (menuItem.itemId) {
|
||||||
|
R.id.go_home -> goHome()
|
||||||
|
R.id.go_to_favorite -> goToFavorite()
|
||||||
|
R.id.sort -> showSortingDialog()
|
||||||
|
R.id.add_favorite -> addFavorite()
|
||||||
|
R.id.remove_favorite -> removeFavorite()
|
||||||
|
R.id.toggle_filename -> toggleFilenameVisibility()
|
||||||
|
R.id.set_as_home -> setAsHome()
|
||||||
|
R.id.change_view_type -> changeViewType()
|
||||||
|
R.id.temporarily_show_hidden -> tryToggleTemporarilyShowHidden()
|
||||||
|
R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden()
|
||||||
|
R.id.column_count -> changeColumnCount()
|
||||||
|
R.id.more_apps_from_us -> launchMoreAppsFromUsIntent()
|
||||||
|
R.id.settings -> launchSettings()
|
||||||
|
R.id.about -> launchAbout()
|
||||||
|
else -> return@setOnMenuItemClickListener false
|
||||||
|
}
|
||||||
return@setOnMenuItemClickListener true
|
return@setOnMenuItemClickListener true
|
||||||
}
|
}
|
||||||
|
|
||||||
when (menuItem.itemId) {
|
|
||||||
R.id.go_home -> goHome()
|
|
||||||
R.id.go_to_favorite -> goToFavorite()
|
|
||||||
R.id.sort -> showSortingDialog()
|
|
||||||
R.id.add_favorite -> addFavorite()
|
|
||||||
R.id.remove_favorite -> removeFavorite()
|
|
||||||
R.id.toggle_filename -> toggleFilenameVisibility()
|
|
||||||
R.id.set_as_home -> setAsHome()
|
|
||||||
R.id.change_view_type -> changeViewType()
|
|
||||||
R.id.temporarily_show_hidden -> tryToggleTemporarilyShowHidden()
|
|
||||||
R.id.stop_showing_hidden -> tryToggleTemporarilyShowHidden()
|
|
||||||
R.id.column_count -> changeColumnCount()
|
|
||||||
R.id.more_apps_from_us -> launchMoreAppsFromUsIntent()
|
|
||||||
R.id.settings -> launchSettings()
|
|
||||||
R.id.about -> launchAbout()
|
|
||||||
else -> return@setOnMenuItemClickListener false
|
|
||||||
}
|
|
||||||
return@setOnMenuItemClickListener true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSaveInstanceState(outState: Bundle) {
|
override fun onSaveInstanceState(outState: Bundle) {
|
||||||
super.onSaveInstanceState(outState)
|
super.onSaveInstanceState(outState)
|
||||||
outState.putString(PICKED_PATH, items_fragment?.currentPath ?: "")
|
outState.putString(PICKED_PATH, getItemsFragment()?.currentPath ?: "")
|
||||||
outState.putBoolean(WAS_PROTECTION_HANDLED, mWasProtectionHandled)
|
outState.putBoolean(WAS_PROTECTION_HANDLED, mWasProtectionHandled)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,8 +251,8 @@ class MainActivity : SimpleActivity() {
|
|||||||
mWasProtectionHandled = savedInstanceState.getBoolean(WAS_PROTECTION_HANDLED, false)
|
mWasProtectionHandled = savedInstanceState.getBoolean(WAS_PROTECTION_HANDLED, false)
|
||||||
val path = savedInstanceState.getString(PICKED_PATH) ?: internalStoragePath
|
val path = savedInstanceState.getString(PICKED_PATH) ?: internalStoragePath
|
||||||
|
|
||||||
if (main_view_pager.adapter == null) {
|
if (binding.mainViewPager.adapter == null) {
|
||||||
main_view_pager.onGlobalLayout {
|
binding.mainViewPager.onGlobalLayout {
|
||||||
restorePath(path)
|
restorePath(path)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -287,7 +287,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
|
|
||||||
private fun updateMenuColors() {
|
private fun updateMenuColors() {
|
||||||
updateStatusbarColor(getProperBackgroundColor())
|
updateStatusbarColor(getProperBackgroundColor())
|
||||||
main_menu.updateColors()
|
binding.mainMenu.updateColors()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun storeStateVariables() {
|
private fun storeStateVariables() {
|
||||||
@ -304,11 +304,11 @@ class MainActivity : SimpleActivity() {
|
|||||||
handleStoragePermission {
|
handleStoragePermission {
|
||||||
checkOTGPath()
|
checkOTGPath()
|
||||||
if (it) {
|
if (it) {
|
||||||
if (main_view_pager.adapter == null) {
|
if (binding.mainViewPager.adapter == null) {
|
||||||
initFragments()
|
initFragments()
|
||||||
}
|
}
|
||||||
|
|
||||||
main_view_pager.onGlobalLayout {
|
binding.mainViewPager.onGlobalLayout {
|
||||||
initFileManager(!hadPermission)
|
initFileManager(!hadPermission)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -368,41 +368,43 @@ class MainActivity : SimpleActivity() {
|
|||||||
tryOpenPathIntent(data.path!!, false, finishActivity = true)
|
tryOpenPathIntent(data.path!!, false, finishActivity = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
main_view_pager.currentItem = 0
|
binding.mainViewPager.currentItem = 0
|
||||||
} else {
|
} else {
|
||||||
openPath(config.homeFolder)
|
openPath(config.homeFolder)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (refreshRecents) {
|
if (refreshRecents) {
|
||||||
recents_fragment?.refreshFragment()
|
getRecentsFragment()?.refreshFragment()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initFragments() {
|
private fun initFragments() {
|
||||||
main_view_pager.adapter = ViewPagerAdapter(this, mTabsToShow)
|
binding.mainViewPager.apply {
|
||||||
main_view_pager.offscreenPageLimit = 2
|
adapter = ViewPagerAdapter(this@MainActivity, mTabsToShow)
|
||||||
main_view_pager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
|
offscreenPageLimit = 2
|
||||||
override fun onPageScrollStateChanged(state: Int) {}
|
addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
|
||||||
|
override fun onPageScrollStateChanged(state: Int) {}
|
||||||
|
|
||||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {}
|
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {}
|
||||||
|
|
||||||
override fun onPageSelected(position: Int) {
|
override fun onPageSelected(position: Int) {
|
||||||
main_tabs_holder.getTabAt(position)?.select()
|
binding.mainTabsHolder.getTabAt(position)?.select()
|
||||||
getAllFragments().forEach {
|
getAllFragments().forEach {
|
||||||
(it as? ItemOperationsListener)?.finishActMode()
|
(it as? ItemOperationsListener)?.finishActMode()
|
||||||
|
}
|
||||||
|
refreshMenuItems()
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
currentItem = config.lastUsedViewPagerPage
|
||||||
|
|
||||||
|
onGlobalLayout {
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
}
|
}
|
||||||
})
|
|
||||||
main_view_pager.currentItem = config.lastUsedViewPagerPage
|
|
||||||
|
|
||||||
main_view_pager.onGlobalLayout {
|
|
||||||
refreshMenuItems()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupTabs() {
|
private fun setupTabs() {
|
||||||
main_tabs_holder.removeAllTabs()
|
binding.mainTabsHolder.removeAllTabs()
|
||||||
val action = intent.action
|
val action = intent.action
|
||||||
val isPickFileIntent = action == RingtoneManager.ACTION_RINGTONE_PICKER || action == Intent.ACTION_GET_CONTENT || action == Intent.ACTION_PICK
|
val isPickFileIntent = action == RingtoneManager.ACTION_RINGTONE_PICKER || action == Intent.ACTION_GET_CONTENT || action == Intent.ACTION_PICK
|
||||||
val isCreateDocumentIntent = action == Intent.ACTION_CREATE_DOCUMENT
|
val isCreateDocumentIntent = action == Intent.ACTION_CREATE_DOCUMENT
|
||||||
@ -421,41 +423,45 @@ class MainActivity : SimpleActivity() {
|
|||||||
|
|
||||||
mTabsToShow.forEachIndexed { index, value ->
|
mTabsToShow.forEachIndexed { index, value ->
|
||||||
if (config.showTabs and value != 0) {
|
if (config.showTabs and value != 0) {
|
||||||
main_tabs_holder.newTab().setCustomView(R.layout.bottom_tablayout_item).apply {
|
binding.mainTabsHolder.newTab().setCustomView(R.layout.bottom_tablayout_item).apply {
|
||||||
customView?.findViewById<ImageView>(R.id.tab_item_icon)?.setImageDrawable(getTabIcon(index))
|
customView?.findViewById<ImageView>(R.id.tab_item_icon)?.setImageDrawable(getTabIcon(index))
|
||||||
customView?.findViewById<TextView>(R.id.tab_item_label)?.text = getTabLabel(index)
|
customView?.findViewById<TextView>(R.id.tab_item_label)?.text = getTabLabel(index)
|
||||||
AutofitHelper.create(customView?.findViewById(R.id.tab_item_label))
|
AutofitHelper.create(customView?.findViewById(R.id.tab_item_label))
|
||||||
main_tabs_holder.addTab(this)
|
binding.mainTabsHolder.addTab(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
main_tabs_holder.onTabSelectionChanged(
|
binding.mainTabsHolder.apply {
|
||||||
tabUnselectedAction = {
|
onTabSelectionChanged(
|
||||||
updateBottomTabItemColors(it.customView, false, getDeselectedTabDrawableIds()[it.position])
|
tabUnselectedAction = {
|
||||||
},
|
updateBottomTabItemColors(it.customView, false, getDeselectedTabDrawableIds()[it.position])
|
||||||
tabSelectedAction = {
|
},
|
||||||
main_menu.closeSearch()
|
tabSelectedAction = {
|
||||||
main_view_pager.currentItem = it.position
|
binding.mainMenu.closeSearch()
|
||||||
updateBottomTabItemColors(it.customView, true, getSelectedTabDrawableIds()[it.position])
|
binding.mainViewPager.currentItem = it.position
|
||||||
}
|
updateBottomTabItemColors(it.customView, true, getSelectedTabDrawableIds()[it.position])
|
||||||
)
|
}
|
||||||
|
)
|
||||||
|
|
||||||
main_tabs_holder.beGoneIf(main_tabs_holder.tabCount == 1)
|
beGoneIf(tabCount == 1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupTabColors() {
|
private fun setupTabColors() {
|
||||||
val activeView = main_tabs_holder.getTabAt(main_view_pager.currentItem)?.customView
|
binding.apply {
|
||||||
updateBottomTabItemColors(activeView, true, getSelectedTabDrawableIds()[main_view_pager.currentItem])
|
val activeView = mainTabsHolder.getTabAt(mainViewPager.currentItem)?.customView
|
||||||
|
updateBottomTabItemColors(activeView, true, getSelectedTabDrawableIds()[mainViewPager.currentItem])
|
||||||
|
|
||||||
getInactiveTabIndexes(main_view_pager.currentItem).forEach { index ->
|
getInactiveTabIndexes(mainViewPager.currentItem).forEach { index ->
|
||||||
val inactiveView = main_tabs_holder.getTabAt(index)?.customView
|
val inactiveView = mainTabsHolder.getTabAt(index)?.customView
|
||||||
updateBottomTabItemColors(inactiveView, false, getDeselectedTabDrawableIds()[index])
|
updateBottomTabItemColors(inactiveView, false, getDeselectedTabDrawableIds()[index])
|
||||||
|
}
|
||||||
|
|
||||||
|
val bottomBarColor = getBottomNavigationBackgroundColor()
|
||||||
|
updateNavigationBarColor(bottomBarColor)
|
||||||
|
mainTabsHolder.setBackgroundColor(bottomBarColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
val bottomBarColor = getBottomNavigationBackgroundColor()
|
|
||||||
updateNavigationBarColor(bottomBarColor)
|
|
||||||
main_tabs_holder.setBackgroundColor(bottomBarColor)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getTabIcon(position: Int): Drawable {
|
private fun getTabIcon(position: Int): Drawable {
|
||||||
@ -504,7 +510,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
newPath = internalStoragePath
|
newPath = internalStoragePath
|
||||||
}
|
}
|
||||||
|
|
||||||
items_fragment?.openPath(newPath, forceRefresh)
|
getItemsFragment()?.openPath(newPath, forceRefresh)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun goHome() {
|
private fun goHome() {
|
||||||
@ -714,12 +720,12 @@ class MainActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun openedDirectory() {
|
fun openedDirectory() {
|
||||||
if (main_menu.isSearchOpen) {
|
if (binding.mainMenu.isSearchOpen) {
|
||||||
main_menu.closeSearch()
|
binding.mainMenu.closeSearch()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getInactiveTabIndexes(activeIndex: Int) = (0 until main_tabs_holder.tabCount).filter { it != activeIndex }
|
private fun getInactiveTabIndexes(activeIndex: Int) = (0 until binding.mainTabsHolder.tabCount).filter { it != activeIndex }
|
||||||
|
|
||||||
private fun getSelectedTabDrawableIds(): ArrayList<Int> {
|
private fun getSelectedTabDrawableIds(): ArrayList<Int> {
|
||||||
val showTabs = config.showTabs
|
val showTabs = config.showTabs
|
||||||
@ -759,24 +765,28 @@ class MainActivity : SimpleActivity() {
|
|||||||
return icons
|
return icons
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getAllFragments(): ArrayList<MyViewPagerFragment?> = arrayListOf(items_fragment, recents_fragment, storage_fragment)
|
private fun getRecentsFragment() = findViewById<RecentsFragment>(R.id.recents_fragment);
|
||||||
|
private fun getItemsFragment() = findViewById<ItemsFragment>(R.id.items_fragment);
|
||||||
|
private fun getStorageFragment() = findViewById<StorageFragment>(R.id.storage_fragment);
|
||||||
|
private fun getAllFragments(): ArrayList<MyViewPagerFragment<*>?> =
|
||||||
|
arrayListOf(getItemsFragment(), getRecentsFragment(), getStorageFragment())
|
||||||
|
|
||||||
private fun getCurrentFragment(): MyViewPagerFragment? {
|
private fun getCurrentFragment(): MyViewPagerFragment<*>? {
|
||||||
val showTabs = config.showTabs
|
val showTabs = config.showTabs
|
||||||
val fragments = arrayListOf<MyViewPagerFragment>()
|
val fragments = arrayListOf<MyViewPagerFragment<*>>()
|
||||||
if (showTabs and TAB_FILES != 0) {
|
if (showTabs and TAB_FILES != 0) {
|
||||||
fragments.add(items_fragment)
|
fragments.add(getItemsFragment())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showTabs and TAB_RECENT_FILES != 0) {
|
if (showTabs and TAB_RECENT_FILES != 0) {
|
||||||
fragments.add(recents_fragment)
|
fragments.add(getRecentsFragment())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showTabs and TAB_STORAGE_ANALYSIS != 0) {
|
if (showTabs and TAB_STORAGE_ANALYSIS != 0) {
|
||||||
fragments.add(storage_fragment)
|
fragments.add(getStorageFragment())
|
||||||
}
|
}
|
||||||
|
|
||||||
return fragments.getOrNull(main_view_pager.currentItem)
|
return fragments.getOrNull(binding.mainViewPager.currentItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getTabsList() = arrayListOf(TAB_FILES, TAB_RECENT_FILES, TAB_STORAGE_ANALYSIS)
|
private fun getTabsList() = arrayListOf(TAB_FILES, TAB_RECENT_FILES, TAB_STORAGE_ANALYSIS)
|
||||||
|
@ -21,6 +21,7 @@ import com.simplemobiletools.commons.views.MyGridLayoutManager
|
|||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
import com.simplemobiletools.filemanager.pro.adapters.ItemsAdapter
|
import com.simplemobiletools.filemanager.pro.adapters.ItemsAdapter
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.ActivityMimetypesBinding
|
||||||
import com.simplemobiletools.filemanager.pro.dialogs.ChangeSortingDialog
|
import com.simplemobiletools.filemanager.pro.dialogs.ChangeSortingDialog
|
||||||
import com.simplemobiletools.filemanager.pro.dialogs.ChangeViewTypeDialog
|
import com.simplemobiletools.filemanager.pro.dialogs.ChangeViewTypeDialog
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||||
@ -28,10 +29,10 @@ import com.simplemobiletools.filemanager.pro.extensions.tryOpenPathIntent
|
|||||||
import com.simplemobiletools.filemanager.pro.helpers.*
|
import com.simplemobiletools.filemanager.pro.helpers.*
|
||||||
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
|
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
|
||||||
import com.simplemobiletools.filemanager.pro.models.ListItem
|
import com.simplemobiletools.filemanager.pro.models.ListItem
|
||||||
import kotlinx.android.synthetic.main.activity_mimetypes.*
|
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
|
class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
|
||||||
|
private val binding by lazy(LazyThreadSafetyMode.NONE) { ActivityMimetypesBinding.inflate(layoutInflater) }
|
||||||
private var isSearchOpen = false
|
private var isSearchOpen = false
|
||||||
private var currentMimeType = ""
|
private var currentMimeType = ""
|
||||||
private var lastSearchedText = ""
|
private var lastSearchedText = ""
|
||||||
@ -43,14 +44,16 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_mimetypes)
|
setContentView(binding.root)
|
||||||
setupOptionsMenu()
|
setupOptionsMenu()
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
updateMaterialActivityViews(mimetypes_coordinator, mimetypes_list, useTransparentNavigation = true, useTopSearchMenu = false)
|
binding.apply {
|
||||||
setupMaterialScrollListener(mimetypes_list, mimetypes_toolbar)
|
updateMaterialActivityViews(mimetypesCoordinator, mimetypesList, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||||
|
setupMaterialScrollListener(mimetypesList, mimetypesToolbar)
|
||||||
|
}
|
||||||
|
|
||||||
currentMimeType = intent.getStringExtra(SHOW_MIMETYPE) ?: return
|
currentMimeType = intent.getStringExtra(SHOW_MIMETYPE) ?: return
|
||||||
mimetypes_toolbar.title = getString(
|
binding.mimetypesToolbar.title = getString(
|
||||||
when (currentMimeType) {
|
when (currentMimeType) {
|
||||||
IMAGES -> R.string.images
|
IMAGES -> R.string.images
|
||||||
VIDEOS -> R.string.videos
|
VIDEOS -> R.string.videos
|
||||||
@ -70,20 +73,22 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
|
|||||||
reFetchItems()
|
reFetchItems()
|
||||||
}
|
}
|
||||||
|
|
||||||
mimetypes_fastscroller.updateColors(getProperPrimaryColor())
|
binding.apply {
|
||||||
mimetypes_placeholder.setTextColor(getProperTextColor())
|
mimetypesFastscroller.updateColors(getProperPrimaryColor())
|
||||||
mimetypes_placeholder_2.setTextColor(getProperTextColor())
|
mimetypesPlaceholder.setTextColor(getProperTextColor())
|
||||||
|
mimetypesPlaceholder2.setTextColor(getProperTextColor())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
setupToolbar(mimetypes_toolbar, NavigationIcon.Arrow, searchMenuItem = searchMenuItem)
|
setupToolbar(binding.mimetypesToolbar, NavigationIcon.Arrow, searchMenuItem = searchMenuItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun refreshMenuItems() {
|
private fun refreshMenuItems() {
|
||||||
val currentViewType = config.getFolderViewType(currentMimeType)
|
val currentViewType = config.getFolderViewType(currentMimeType)
|
||||||
|
|
||||||
mimetypes_toolbar.menu.apply {
|
binding.mimetypesToolbar.menu.apply {
|
||||||
findItem(R.id.toggle_filename).isVisible = currentViewType == VIEW_TYPE_GRID
|
findItem(R.id.toggle_filename).isVisible = currentViewType == VIEW_TYPE_GRID
|
||||||
|
|
||||||
findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden()
|
findItem(R.id.temporarily_show_hidden).isVisible = !config.shouldShowHidden()
|
||||||
@ -94,8 +99,8 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOptionsMenu() {
|
private fun setupOptionsMenu() {
|
||||||
setupSearch(mimetypes_toolbar.menu)
|
setupSearch(binding.mimetypesToolbar.menu)
|
||||||
mimetypes_toolbar.setOnMenuItemClickListener { menuItem ->
|
binding.mimetypesToolbar.setOnMenuItemClickListener { menuItem ->
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.sort -> showSortingDialog()
|
R.id.sort -> showSortingDialog()
|
||||||
R.id.toggle_filename -> toggleFilenameVisibility()
|
R.id.toggle_filename -> toggleFilenameVisibility()
|
||||||
@ -130,15 +135,19 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
|
|||||||
lastSearchedText = searchText
|
lastSearchedText = searchText
|
||||||
when {
|
when {
|
||||||
searchText.isEmpty() -> {
|
searchText.isEmpty() -> {
|
||||||
mimetypes_fastscroller.beVisible()
|
binding.apply {
|
||||||
getRecyclerAdapter()?.updateItems(storedItems)
|
mimetypesFastscroller.beVisible()
|
||||||
mimetypes_placeholder.beGoneIf(storedItems.isNotEmpty())
|
getRecyclerAdapter()?.updateItems(storedItems)
|
||||||
mimetypes_placeholder_2.beGone()
|
mimetypesPlaceholder.beGoneIf(storedItems.isNotEmpty())
|
||||||
|
mimetypesPlaceholder2.beGone()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
searchText.length == 1 -> {
|
searchText.length == 1 -> {
|
||||||
mimetypes_fastscroller.beGone()
|
binding.apply {
|
||||||
mimetypes_placeholder.beVisible()
|
mimetypesFastscroller.beGone()
|
||||||
mimetypes_placeholder_2.beVisible()
|
mimetypesPlaceholder.beVisible()
|
||||||
|
mimetypesPlaceholder2.beVisible()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
@ -150,9 +159,11 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
|
|||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
getRecyclerAdapter()?.updateItems(listItems, text)
|
getRecyclerAdapter()?.updateItems(listItems, text)
|
||||||
mimetypes_fastscroller.beVisibleIf(listItems.isNotEmpty())
|
binding.apply {
|
||||||
mimetypes_placeholder.beVisibleIf(listItems.isEmpty())
|
mimetypesFastscroller.beVisibleIf(listItems.isNotEmpty())
|
||||||
mimetypes_placeholder_2.beGone()
|
mimetypesPlaceholder.beVisibleIf(listItems.isEmpty())
|
||||||
|
mimetypesPlaceholder2.beGone()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,7 +210,7 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun columnCountChanged() {
|
override fun columnCountChanged() {
|
||||||
(mimetypes_list.layoutManager as MyGridLayoutManager).spanCount = config.fileColumnCnt
|
(binding.mimetypesList.layoutManager as MyGridLayoutManager).spanCount = config.fileColumnCnt
|
||||||
refreshMenuItems()
|
refreshMenuItems()
|
||||||
getRecyclerAdapter()?.apply {
|
getRecyclerAdapter()?.apply {
|
||||||
notifyItemRangeChanged(0, listItems.size)
|
notifyItemRangeChanged(0, listItems.size)
|
||||||
@ -337,21 +348,21 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
storedItems = items
|
storedItems = items
|
||||||
ItemsAdapter(this as SimpleActivity, storedItems, this, mimetypes_list, false, null) {
|
ItemsAdapter(this as SimpleActivity, storedItems, this, binding.mimetypesList, false, null) {
|
||||||
tryOpenPathIntent((it as ListItem).path, false)
|
tryOpenPathIntent((it as ListItem).path, false)
|
||||||
}.apply {
|
}.apply {
|
||||||
setupZoomListener(zoomListener)
|
setupZoomListener(zoomListener)
|
||||||
mimetypes_list.adapter = this
|
binding.mimetypesList.adapter = this
|
||||||
}
|
}
|
||||||
|
|
||||||
if (areSystemAnimationsEnabled) {
|
if (areSystemAnimationsEnabled) {
|
||||||
mimetypes_list.scheduleLayoutAnimation()
|
binding.mimetypesList.scheduleLayoutAnimation()
|
||||||
}
|
}
|
||||||
|
|
||||||
mimetypes_placeholder.beVisibleIf(items.isEmpty())
|
binding.mimetypesPlaceholder.beVisibleIf(items.isEmpty())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getRecyclerAdapter() = mimetypes_list.adapter as? ItemsAdapter
|
private fun getRecyclerAdapter() = binding.mimetypesList.adapter as? ItemsAdapter
|
||||||
|
|
||||||
private fun showSortingDialog() {
|
private fun showSortingDialog() {
|
||||||
ChangeSortingDialog(this, currentMimeType) {
|
ChangeSortingDialog(this, currentMimeType) {
|
||||||
@ -396,13 +407,13 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
|
|||||||
setupListLayoutManager()
|
setupListLayoutManager()
|
||||||
}
|
}
|
||||||
|
|
||||||
mimetypes_list.adapter = null
|
binding.mimetypesList.adapter = null
|
||||||
initZoomListener()
|
initZoomListener()
|
||||||
addItems(storedItems)
|
addItems(storedItems)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupGridLayoutManager() {
|
private fun setupGridLayoutManager() {
|
||||||
val layoutManager = mimetypes_list.layoutManager as MyGridLayoutManager
|
val layoutManager = binding.mimetypesList.layoutManager as MyGridLayoutManager
|
||||||
layoutManager.spanCount = config.fileColumnCnt ?: 3
|
layoutManager.spanCount = config.fileColumnCnt ?: 3
|
||||||
|
|
||||||
layoutManager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
|
layoutManager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
|
||||||
@ -417,14 +428,14 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupListLayoutManager() {
|
private fun setupListLayoutManager() {
|
||||||
val layoutManager = mimetypes_list.layoutManager as MyGridLayoutManager
|
val layoutManager = binding.mimetypesList.layoutManager as MyGridLayoutManager
|
||||||
layoutManager.spanCount = 1
|
layoutManager.spanCount = 1
|
||||||
zoomListener = null
|
zoomListener = null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initZoomListener() {
|
private fun initZoomListener() {
|
||||||
if (config.getFolderViewType(currentMimeType) == VIEW_TYPE_GRID) {
|
if (config.getFolderViewType(currentMimeType) == VIEW_TYPE_GRID) {
|
||||||
val layoutManager = mimetypes_list.layoutManager as MyGridLayoutManager
|
val layoutManager = binding.mimetypesList.layoutManager as MyGridLayoutManager
|
||||||
zoomListener = object : MyRecyclerView.MyZoomListener {
|
zoomListener = object : MyRecyclerView.MyZoomListener {
|
||||||
override fun zoomIn() {
|
override fun zoomIn() {
|
||||||
if (layoutManager.spanCount > 1) {
|
if (layoutManager.spanCount > 1) {
|
||||||
|
@ -16,15 +16,13 @@ import com.simplemobiletools.commons.extensions.*
|
|||||||
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
|
import com.simplemobiletools.commons.helpers.REAL_FILE_PATH
|
||||||
import com.simplemobiletools.commons.helpers.isPiePlus
|
import com.simplemobiletools.commons.helpers.isPiePlus
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.ActivityPdfViewerBinding
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.hideSystemUI
|
import com.simplemobiletools.filemanager.pro.extensions.hideSystemUI
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.showSystemUI
|
import com.simplemobiletools.filemanager.pro.extensions.showSystemUI
|
||||||
import com.simplemobiletools.filemanager.pro.helpers.PdfDocumentAdapter
|
import com.simplemobiletools.filemanager.pro.helpers.PdfDocumentAdapter
|
||||||
import kotlinx.android.synthetic.main.activity_pdf_viewer.pdf_viewer
|
|
||||||
import kotlinx.android.synthetic.main.activity_pdf_viewer.pdf_viewer_appbar
|
|
||||||
import kotlinx.android.synthetic.main.activity_pdf_viewer.pdf_viewer_toolbar
|
|
||||||
import kotlinx.android.synthetic.main.activity_pdf_viewer.top_shadow
|
|
||||||
|
|
||||||
class PDFViewerActivity : SimpleActivity() {
|
class PDFViewerActivity : SimpleActivity() {
|
||||||
|
private val binding by lazy(LazyThreadSafetyMode.NONE) { ActivityPdfViewerBinding.inflate(layoutInflater) }
|
||||||
private var realFilePath = ""
|
private var realFilePath = ""
|
||||||
private var isFullScreen = false
|
private var isFullScreen = false
|
||||||
private var passwordDialog: EnterPasswordDialog? = null
|
private var passwordDialog: EnterPasswordDialog? = null
|
||||||
@ -33,14 +31,14 @@ class PDFViewerActivity : SimpleActivity() {
|
|||||||
showTransparentTop = true
|
showTransparentTop = true
|
||||||
|
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_pdf_viewer)
|
setContentView(binding.root)
|
||||||
|
|
||||||
if (checkAppSideloading()) {
|
if (checkAppSideloading()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
checkNotchSupport()
|
checkNotchSupport()
|
||||||
pdf_viewer_toolbar.apply {
|
binding.pdfViewerToolbar.apply {
|
||||||
setTitleTextColor(Color.WHITE)
|
setTitleTextColor(Color.WHITE)
|
||||||
overflowIcon = resources.getColoredDrawableWithColor(R.drawable.ic_three_dots_vector, Color.WHITE)
|
overflowIcon = resources.getColoredDrawableWithColor(R.drawable.ic_three_dots_vector, Color.WHITE)
|
||||||
navigationIcon = resources.getColoredDrawableWithColor(R.drawable.ic_arrow_left_vector, Color.WHITE)
|
navigationIcon = resources.getColoredDrawableWithColor(R.drawable.ic_arrow_left_vector, Color.WHITE)
|
||||||
@ -48,7 +46,7 @@ class PDFViewerActivity : SimpleActivity() {
|
|||||||
|
|
||||||
if (intent.extras?.containsKey(REAL_FILE_PATH) == true) {
|
if (intent.extras?.containsKey(REAL_FILE_PATH) == true) {
|
||||||
realFilePath = intent.extras?.get(REAL_FILE_PATH)?.toString() ?: ""
|
realFilePath = intent.extras?.get(REAL_FILE_PATH)?.toString() ?: ""
|
||||||
pdf_viewer_toolbar.title = realFilePath.getFilenameFromPath()
|
binding.pdfViewerToolbar.title = realFilePath.getFilenameFromPath()
|
||||||
}
|
}
|
||||||
|
|
||||||
setupMenu()
|
setupMenu()
|
||||||
@ -61,8 +59,8 @@ class PDFViewerActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupMenu() {
|
private fun setupMenu() {
|
||||||
(pdf_viewer_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
|
(binding.pdfViewerAppbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
|
||||||
pdf_viewer_toolbar.menu.apply {
|
binding.pdfViewerToolbar.menu.apply {
|
||||||
findItem(R.id.menu_print).isVisible = realFilePath.isNotEmpty()
|
findItem(R.id.menu_print).isVisible = realFilePath.isNotEmpty()
|
||||||
findItem(R.id.menu_print).setOnMenuItemClickListener {
|
findItem(R.id.menu_print).setOnMenuItemClickListener {
|
||||||
printText()
|
printText()
|
||||||
@ -70,24 +68,24 @@ class PDFViewerActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pdf_viewer_toolbar.setNavigationOnClickListener {
|
binding.pdfViewerToolbar.setNavigationOnClickListener {
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!portrait && navigationBarOnSide && navigationBarWidth > 0) {
|
if (!portrait && navigationBarOnSide && navigationBarWidth > 0) {
|
||||||
pdf_viewer_appbar.setPadding(0, 0, navigationBarWidth, 0)
|
binding.pdfViewerAppbar.setPadding(0, 0, navigationBarWidth, 0)
|
||||||
} else {
|
} else {
|
||||||
pdf_viewer_appbar.setPadding(0, 0, 0, 0)
|
binding.pdfViewerAppbar.setPadding(0, 0, 0, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onConfigurationChanged(newConfig: Configuration) {
|
override fun onConfigurationChanged(newConfig: Configuration) {
|
||||||
super.onConfigurationChanged(newConfig)
|
super.onConfigurationChanged(newConfig)
|
||||||
(pdf_viewer_appbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
|
(binding.pdfViewerAppbar.layoutParams as RelativeLayout.LayoutParams).topMargin = statusBarHeight
|
||||||
if (!portrait && navigationBarOnSide && navigationBarWidth > 0) {
|
if (!portrait && navigationBarOnSide && navigationBarWidth > 0) {
|
||||||
pdf_viewer_appbar.setPadding(0, 0, navigationBarWidth, 0)
|
binding.pdfViewerAppbar.setPadding(0, 0, navigationBarWidth, 0)
|
||||||
} else {
|
} else {
|
||||||
pdf_viewer_appbar.setPadding(0, 0, 0, 0)
|
binding.pdfViewerAppbar.setPadding(0, 0, 0, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,8 +101,8 @@ class PDFViewerActivity : SimpleActivity() {
|
|||||||
|
|
||||||
private fun loadPdfViewer(uri: Uri, filePassword: String? = null) {
|
private fun loadPdfViewer(uri: Uri, filePassword: String? = null) {
|
||||||
val primaryColor = getProperPrimaryColor()
|
val primaryColor = getProperPrimaryColor()
|
||||||
pdf_viewer.setBackgroundColor(getProperBackgroundColor())
|
binding.pdfViewer.setBackgroundColor(getProperBackgroundColor())
|
||||||
pdf_viewer.fromUri(uri)
|
binding.pdfViewer.fromUri(uri)
|
||||||
.password(filePassword)
|
.password(filePassword)
|
||||||
.scrollHandle(DefaultScrollHandle(this, primaryColor.getContrastColor(), primaryColor))
|
.scrollHandle(DefaultScrollHandle(this, primaryColor.getContrastColor(), primaryColor))
|
||||||
.spacing(15)
|
.spacing(15)
|
||||||
@ -140,7 +138,7 @@ class PDFViewerActivity : SimpleActivity() {
|
|||||||
|
|
||||||
val filename = getFilenameFromUri(uri)
|
val filename = getFilenameFromUri(uri)
|
||||||
if (filename.isNotEmpty()) {
|
if (filename.isNotEmpty()) {
|
||||||
pdf_viewer_toolbar.title = filename
|
binding.pdfViewerToolbar.title = filename
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,14 +161,14 @@ class PDFViewerActivity : SimpleActivity() {
|
|||||||
showSystemUI(true)
|
showSystemUI(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
top_shadow.animate().alpha(newAlpha).start()
|
binding.topShadow.animate().alpha(newAlpha).start()
|
||||||
pdf_viewer_appbar.animate().alpha(newAlpha).withStartAction {
|
binding.pdfViewerAppbar.animate().alpha(newAlpha).withStartAction {
|
||||||
if (newAlpha == 1f) {
|
if (newAlpha == 1f) {
|
||||||
pdf_viewer_appbar.beVisible()
|
binding.pdfViewerAppbar.beVisible()
|
||||||
}
|
}
|
||||||
}.withEndAction {
|
}.withEndAction {
|
||||||
if (newAlpha == 0f) {
|
if (newAlpha == 0f) {
|
||||||
pdf_viewer_appbar.beGone()
|
binding.pdfViewerAppbar.beGone()
|
||||||
}
|
}
|
||||||
}.start()
|
}.start()
|
||||||
|
|
||||||
|
@ -21,17 +21,17 @@ import com.simplemobiletools.commons.helpers.SAVE_DISCARD_PROMPT_INTERVAL
|
|||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.commons.views.MyEditText
|
import com.simplemobiletools.commons.views.MyEditText
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.ActivityReadTextBinding
|
||||||
import com.simplemobiletools.filemanager.pro.dialogs.SaveAsDialog
|
import com.simplemobiletools.filemanager.pro.dialogs.SaveAsDialog
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.openPath
|
import com.simplemobiletools.filemanager.pro.extensions.openPath
|
||||||
import com.simplemobiletools.filemanager.pro.views.GestureEditText
|
import com.simplemobiletools.filemanager.pro.views.GestureEditText
|
||||||
import kotlinx.android.synthetic.main.activity_read_text.*
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.OutputStream
|
import java.io.OutputStream
|
||||||
|
|
||||||
class ReadTextActivity : SimpleActivity() {
|
class ReadTextActivity : SimpleActivity() {
|
||||||
private val SELECT_SAVE_FILE_INTENT = 1
|
private val SELECT_SAVE_FILE_INTENT = 1
|
||||||
private val SELECT_SAVE_FILE_AND_EXIT_INTENT = 2
|
private val SELECT_SAVE_FILE_AND_EXIT_INTENT = 2
|
||||||
|
private val binding by lazy(LazyThreadSafetyMode.NONE) { ActivityReadTextBinding.inflate(layoutInflater) }
|
||||||
|
|
||||||
private var filePath = ""
|
private var filePath = ""
|
||||||
private var originalText = ""
|
private var originalText = ""
|
||||||
@ -48,10 +48,12 @@ class ReadTextActivity : SimpleActivity() {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_read_text)
|
setContentView(binding.root)
|
||||||
setupOptionsMenu()
|
setupOptionsMenu()
|
||||||
updateMaterialActivityViews(read_text_coordinator, read_text_view, useTransparentNavigation = true, useTopSearchMenu = false)
|
binding.apply {
|
||||||
setupMaterialScrollListener(read_text_holder, read_text_toolbar)
|
updateMaterialActivityViews(readTextCoordinator, readTextView, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||||
|
setupMaterialScrollListener(readTextHolder, readTextToolbar)
|
||||||
|
}
|
||||||
|
|
||||||
searchQueryET = findViewById(R.id.search_query)
|
searchQueryET = findViewById(R.id.search_query)
|
||||||
searchPrevBtn = findViewById(R.id.search_previous)
|
searchPrevBtn = findViewById(R.id.search_previous)
|
||||||
@ -75,10 +77,10 @@ class ReadTextActivity : SimpleActivity() {
|
|||||||
|
|
||||||
val filename = getFilenameFromUri(uri)
|
val filename = getFilenameFromUri(uri)
|
||||||
if (filename.isNotEmpty()) {
|
if (filename.isNotEmpty()) {
|
||||||
read_text_toolbar.title = Uri.decode(filename)
|
binding.readTextToolbar.title = Uri.decode(filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
read_text_view.onGlobalLayout {
|
binding.readTextView.onGlobalLayout {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
checkIntent(uri)
|
checkIntent(uri)
|
||||||
}
|
}
|
||||||
@ -89,7 +91,7 @@ class ReadTextActivity : SimpleActivity() {
|
|||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
setupToolbar(read_text_toolbar, NavigationIcon.Arrow)
|
setupToolbar(binding.readTextToolbar, NavigationIcon.Arrow)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
||||||
@ -107,7 +109,7 @@ class ReadTextActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
override fun onBackPressed() {
|
||||||
val hasUnsavedChanges = originalText != read_text_view.text.toString()
|
val hasUnsavedChanges = originalText != binding.readTextView.text.toString()
|
||||||
when {
|
when {
|
||||||
isSearchActive -> closeSearch()
|
isSearchActive -> closeSearch()
|
||||||
hasUnsavedChanges && System.currentTimeMillis() - lastSavePromptTS > SAVE_DISCARD_PROMPT_INTERVAL -> {
|
hasUnsavedChanges && System.currentTimeMillis() - lastSavePromptTS > SAVE_DISCARD_PROMPT_INTERVAL -> {
|
||||||
@ -125,7 +127,7 @@ class ReadTextActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOptionsMenu() {
|
private fun setupOptionsMenu() {
|
||||||
read_text_toolbar.setOnMenuItemClickListener { menuItem ->
|
binding.readTextToolbar.setOnMenuItemClickListener { menuItem ->
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
R.id.menu_search -> openSearch()
|
R.id.menu_search -> openSearch()
|
||||||
R.id.menu_save -> saveText()
|
R.id.menu_save -> saveText()
|
||||||
@ -139,11 +141,11 @@ class ReadTextActivity : SimpleActivity() {
|
|||||||
|
|
||||||
private fun openSearch() {
|
private fun openSearch() {
|
||||||
isSearchActive = true
|
isSearchActive = true
|
||||||
search_wrapper.beVisible()
|
binding.searchWrapper.beVisible()
|
||||||
showKeyboard(searchQueryET)
|
showKeyboard(searchQueryET)
|
||||||
|
|
||||||
read_text_view.requestFocus()
|
binding.readTextView.requestFocus()
|
||||||
read_text_view.setSelection(0)
|
binding.readTextView.setSelection(0)
|
||||||
|
|
||||||
searchQueryET.postDelayed({
|
searchQueryET.postDelayed({
|
||||||
searchQueryET.requestFocus()
|
searchQueryET.requestFocus()
|
||||||
@ -187,7 +189,7 @@ class ReadTextActivity : SimpleActivity() {
|
|||||||
|
|
||||||
private fun saveTextContent(outputStream: OutputStream?, shouldExitAfterSaving: Boolean, shouldOverwriteOriginalText: Boolean) {
|
private fun saveTextContent(outputStream: OutputStream?, shouldExitAfterSaving: Boolean, shouldOverwriteOriginalText: Boolean) {
|
||||||
if (outputStream != null) {
|
if (outputStream != null) {
|
||||||
val currentText = read_text_view.text.toString()
|
val currentText = binding.readTextView.text.toString()
|
||||||
outputStream.bufferedWriter().use { it.write(currentText) }
|
outputStream.bufferedWriter().use { it.write(currentText) }
|
||||||
toast(R.string.file_saved)
|
toast(R.string.file_saved)
|
||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
@ -215,7 +217,7 @@ class ReadTextActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
webView.loadData(read_text_view.text.toString(), "text/plain", "UTF-8")
|
webView.loadData(binding.readTextView.text.toString(), "text/plain", "UTF-8")
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
showErrorToast(e)
|
showErrorToast(e)
|
||||||
}
|
}
|
||||||
@ -264,11 +266,11 @@ class ReadTextActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
read_text_view.setText(originalText)
|
binding.readTextView.setText(originalText)
|
||||||
if (originalText.isNotEmpty()) {
|
if (originalText.isNotEmpty()) {
|
||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
} else {
|
} else {
|
||||||
showKeyboard(read_text_view)
|
showKeyboard(binding.readTextView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,7 +301,7 @@ class ReadTextActivity : SimpleActivity() {
|
|||||||
false
|
false
|
||||||
})
|
})
|
||||||
|
|
||||||
search_wrapper.setBackgroundColor(getProperPrimaryColor())
|
binding.searchWrapper.setBackgroundColor(getProperPrimaryColor())
|
||||||
val contrastColor = getProperPrimaryColor().getContrastColor()
|
val contrastColor = getProperPrimaryColor().getContrastColor()
|
||||||
arrayListOf(searchPrevBtn, searchNextBtn, searchClearBtn).forEach {
|
arrayListOf(searchPrevBtn, searchNextBtn, searchClearBtn).forEach {
|
||||||
it.applyColorFilter(contrastColor)
|
it.applyColorFilter(contrastColor)
|
||||||
@ -307,16 +309,16 @@ class ReadTextActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun searchTextChanged(text: String) {
|
private fun searchTextChanged(text: String) {
|
||||||
read_text_view.text?.clearBackgroundSpans()
|
binding.readTextView.text?.clearBackgroundSpans()
|
||||||
|
|
||||||
if (text.isNotBlank() && text.length > 1) {
|
if (text.isNotBlank() && text.length > 1) {
|
||||||
searchMatches = read_text_view.value.searchMatches(text)
|
searchMatches = binding.readTextView.value.searchMatches(text)
|
||||||
read_text_view.highlightText(text, getProperPrimaryColor())
|
binding.readTextView.highlightText(text, getProperPrimaryColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchMatches.isNotEmpty()) {
|
if (searchMatches.isNotEmpty()) {
|
||||||
read_text_view.requestFocus()
|
binding.readTextView.requestFocus()
|
||||||
read_text_view.setSelection(searchMatches.getOrNull(searchIndex) ?: 0)
|
binding.readTextView.setSelection(searchMatches.getOrNull(searchIndex) ?: 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
searchQueryET.postDelayed({
|
searchQueryET.postDelayed({
|
||||||
@ -331,7 +333,7 @@ class ReadTextActivity : SimpleActivity() {
|
|||||||
searchIndex = searchMatches.lastIndex
|
searchIndex = searchMatches.lastIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
selectSearchMatch(read_text_view)
|
selectSearchMatch(binding.readTextView)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun goToNextSearchResult() {
|
private fun goToNextSearchResult() {
|
||||||
@ -341,13 +343,13 @@ class ReadTextActivity : SimpleActivity() {
|
|||||||
searchIndex = 0
|
searchIndex = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
selectSearchMatch(read_text_view)
|
selectSearchMatch(binding.readTextView)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun closeSearch() {
|
private fun closeSearch() {
|
||||||
searchQueryET.text?.clear()
|
searchQueryET.text?.clear()
|
||||||
isSearchActive = false
|
isSearchActive = false
|
||||||
search_wrapper.beGone()
|
binding.searchWrapper.beGone()
|
||||||
hideKeyboard()
|
hideKeyboard()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,14 +8,16 @@ import com.simplemobiletools.commons.extensions.*
|
|||||||
import com.simplemobiletools.commons.helpers.NavigationIcon
|
import com.simplemobiletools.commons.helpers.NavigationIcon
|
||||||
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.ActivitySaveAsBinding
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||||
import kotlinx.android.synthetic.main.activity_save_as.activity_save_as_toolbar
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class SaveAsActivity : SimpleActivity() {
|
class SaveAsActivity : SimpleActivity() {
|
||||||
|
private val binding by lazy(LazyThreadSafetyMode.NONE) { ActivitySaveAsBinding.inflate(layoutInflater) }
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_save_as)
|
setContentView(binding.root)
|
||||||
|
|
||||||
if (intent.action == Intent.ACTION_SEND && intent.extras?.containsKey(Intent.EXTRA_STREAM) == true) {
|
if (intent.action == Intent.ACTION_SEND && intent.extras?.containsKey(Intent.EXTRA_STREAM) == true) {
|
||||||
FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden(), showFAB = true, showFavoritesButton = true) {
|
FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden(), showFAB = true, showFavoritesButton = true) {
|
||||||
@ -59,6 +61,6 @@ class SaveAsActivity : SimpleActivity() {
|
|||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
setupToolbar(activity_save_as_toolbar, NavigationIcon.Arrow)
|
setupToolbar(binding.activitySaveAsToolbar, NavigationIcon.Arrow)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,26 +10,29 @@ import com.simplemobiletools.commons.extensions.*
|
|||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.commons.models.RadioItem
|
import com.simplemobiletools.commons.models.RadioItem
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.ActivitySettingsBinding
|
||||||
import com.simplemobiletools.filemanager.pro.dialogs.ManageVisibleTabsDialog
|
import com.simplemobiletools.filemanager.pro.dialogs.ManageVisibleTabsDialog
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||||
import com.simplemobiletools.filemanager.pro.helpers.RootHelpers
|
import com.simplemobiletools.filemanager.pro.helpers.RootHelpers
|
||||||
import kotlinx.android.synthetic.main.activity_settings.*
|
import java.util.Locale
|
||||||
import java.util.*
|
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
class SettingsActivity : SimpleActivity() {
|
class SettingsActivity : SimpleActivity() {
|
||||||
|
private val binding by lazy(LazyThreadSafetyMode.NONE) { ActivitySettingsBinding.inflate(layoutInflater) }
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
isMaterialActivity = true
|
isMaterialActivity = true
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_settings)
|
setContentView(binding.root)
|
||||||
updateMaterialActivityViews(settings_coordinator, settings_holder, useTransparentNavigation = true, useTopSearchMenu = false)
|
binding.apply {
|
||||||
setupMaterialScrollListener(settings_nested_scrollview, settings_toolbar)
|
updateMaterialActivityViews(settingsCoordinator, settingsHolder, useTransparentNavigation = true, useTopSearchMenu = false)
|
||||||
|
setupMaterialScrollListener(settingsNestedScrollview, settingsToolbar)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
setupToolbar(settings_toolbar, NavigationIcon.Arrow)
|
setupToolbar(binding.settingsToolbar, NavigationIcon.Arrow)
|
||||||
|
|
||||||
setupCustomizeColors()
|
setupCustomizeColors()
|
||||||
setupUseEnglish()
|
setupUseEnglish()
|
||||||
@ -47,65 +50,71 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
setupKeepLastModified()
|
setupKeepLastModified()
|
||||||
setupDeleteConfirmation()
|
setupDeleteConfirmation()
|
||||||
setupEnableRootAccess()
|
setupEnableRootAccess()
|
||||||
updateTextColors(settings_nested_scrollview)
|
updateTextColors(binding.settingsNestedScrollview)
|
||||||
|
|
||||||
arrayOf(
|
binding.apply {
|
||||||
settings_color_customization_section_label,
|
arrayOf(
|
||||||
settings_general_settings_label,
|
settingsColorCustomizationSectionLabel,
|
||||||
settings_visibility_label,
|
settingsGeneralSettingsLabel,
|
||||||
settings_scrolling_label,
|
settingsVisibilityLabel,
|
||||||
settings_file_operations_label,
|
settingsScrollingLabel,
|
||||||
settings_security_label
|
settingsFileOperationsLabel,
|
||||||
).forEach {
|
settingsSecurityLabel
|
||||||
it.setTextColor(getProperPrimaryColor())
|
).forEach {
|
||||||
|
it.setTextColor(getProperPrimaryColor())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupCustomizeColors() {
|
private fun setupCustomizeColors() {
|
||||||
settings_color_customization_holder.setOnClickListener {
|
binding.settingsColorCustomizationHolder.setOnClickListener {
|
||||||
startCustomizationActivity()
|
startCustomizationActivity()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupUseEnglish() {
|
private fun setupUseEnglish() {
|
||||||
settings_use_english_holder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
|
binding.apply {
|
||||||
settings_use_english.isChecked = config.useEnglish
|
settingsUseEnglishHolder.beVisibleIf((config.wasUseEnglishToggled || Locale.getDefault().language != "en") && !isTiramisuPlus())
|
||||||
settings_use_english_holder.setOnClickListener {
|
settingsUseEnglish.isChecked = config.useEnglish
|
||||||
settings_use_english.toggle()
|
settingsUseEnglishHolder.setOnClickListener {
|
||||||
config.useEnglish = settings_use_english.isChecked
|
settingsUseEnglish.toggle()
|
||||||
exitProcess(0)
|
config.useEnglish = settingsUseEnglish.isChecked
|
||||||
|
exitProcess(0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupLanguage() {
|
private fun setupLanguage() {
|
||||||
settings_language.text = Locale.getDefault().displayLanguage
|
binding.apply {
|
||||||
settings_language_holder.beVisibleIf(isTiramisuPlus())
|
settingsLanguage.text = Locale.getDefault().displayLanguage
|
||||||
settings_language_holder.setOnClickListener {
|
settingsLanguageHolder.beVisibleIf(isTiramisuPlus())
|
||||||
launchChangeAppLanguageIntent()
|
settingsLanguageHolder.setOnClickListener {
|
||||||
|
launchChangeAppLanguageIntent()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupManageFavorites() {
|
private fun setupManageFavorites() {
|
||||||
settings_manage_favorites_holder.setOnClickListener {
|
binding.settingsManageFavoritesHolder.setOnClickListener {
|
||||||
startActivity(Intent(this, FavoritesActivity::class.java))
|
startActivity(Intent(this, FavoritesActivity::class.java))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupManageShownTabs() {
|
private fun setupManageShownTabs() {
|
||||||
settings_manage_tabs_holder.setOnClickListener {
|
binding.settingsManageTabsHolder.setOnClickListener {
|
||||||
ManageVisibleTabsDialog(this)
|
ManageVisibleTabsDialog(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupChangeDateTimeFormat() {
|
private fun setupChangeDateTimeFormat() {
|
||||||
settings_change_date_time_format_holder.setOnClickListener {
|
binding.settingsChangeDateTimeFormatHolder.setOnClickListener {
|
||||||
ChangeDateTimeFormatDialog(this) {}
|
ChangeDateTimeFormatDialog(this) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupFontSize() {
|
private fun setupFontSize() {
|
||||||
settings_font_size.text = getFontSizeText()
|
binding.settingsFontSize.text = getFontSizeText()
|
||||||
settings_font_size_holder.setOnClickListener {
|
binding.settingsFontSizeHolder.setOnClickListener {
|
||||||
val items = arrayListOf(
|
val items = arrayListOf(
|
||||||
RadioItem(FONT_SIZE_SMALL, getString(R.string.small)),
|
RadioItem(FONT_SIZE_SMALL, getString(R.string.small)),
|
||||||
RadioItem(FONT_SIZE_MEDIUM, getString(R.string.medium)),
|
RadioItem(FONT_SIZE_MEDIUM, getString(R.string.medium)),
|
||||||
@ -115,14 +124,14 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
|
|
||||||
RadioGroupDialog(this@SettingsActivity, items, config.fontSize) {
|
RadioGroupDialog(this@SettingsActivity, items, config.fontSize) {
|
||||||
config.fontSize = it as Int
|
config.fontSize = it as Int
|
||||||
settings_font_size.text = getFontSizeText()
|
binding.settingsFontSize.text = getFontSizeText()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupShowHidden() {
|
private fun setupShowHidden() {
|
||||||
settings_show_hidden.isChecked = config.showHidden
|
binding.settingsShowHidden.isChecked = config.showHidden
|
||||||
settings_show_hidden_holder.setOnClickListener {
|
binding.settingsShowHiddenHolder.setOnClickListener {
|
||||||
if (config.showHidden) {
|
if (config.showHidden) {
|
||||||
toggleShowHidden()
|
toggleShowHidden()
|
||||||
} else {
|
} else {
|
||||||
@ -134,34 +143,38 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun toggleShowHidden() {
|
private fun toggleShowHidden() {
|
||||||
settings_show_hidden.toggle()
|
binding.settingsShowHidden.toggle()
|
||||||
config.showHidden = settings_show_hidden.isChecked
|
config.showHidden = binding.settingsShowHidden.isChecked
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupEnablePullToRefresh() {
|
private fun setupEnablePullToRefresh() {
|
||||||
settings_enable_pull_to_refresh.isChecked = config.enablePullToRefresh
|
binding.apply {
|
||||||
settings_enable_pull_to_refresh_holder.setOnClickListener {
|
settingsEnablePullToRefresh.isChecked = config.enablePullToRefresh
|
||||||
settings_enable_pull_to_refresh.toggle()
|
settingsEnablePullToRefreshHolder.setOnClickListener {
|
||||||
config.enablePullToRefresh = settings_enable_pull_to_refresh.isChecked
|
settingsEnablePullToRefresh.toggle()
|
||||||
|
config.enablePullToRefresh = settingsEnablePullToRefresh.isChecked
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupPressBackTwice() {
|
private fun setupPressBackTwice() {
|
||||||
settings_press_back_twice.isChecked = config.pressBackTwice
|
binding.apply {
|
||||||
settings_press_back_twice_holder.setOnClickListener {
|
settingsPressBackTwice.isChecked = config.pressBackTwice
|
||||||
settings_press_back_twice.toggle()
|
settingsPressBackTwiceHolder.setOnClickListener {
|
||||||
config.pressBackTwice = settings_press_back_twice.isChecked
|
settingsPressBackTwice.toggle()
|
||||||
|
config.pressBackTwice = settingsPressBackTwice.isChecked
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupHiddenItemPasswordProtection() {
|
private fun setupHiddenItemPasswordProtection() {
|
||||||
settings_password_protection.isChecked = config.isHiddenPasswordProtectionOn
|
binding.settingsPasswordProtection.isChecked = config.isHiddenPasswordProtectionOn
|
||||||
settings_password_protection_holder.setOnClickListener {
|
binding.settingsPasswordProtectionHolder.setOnClickListener {
|
||||||
val tabToShow = if (config.isHiddenPasswordProtectionOn) config.hiddenProtectionType else SHOW_ALL_TABS
|
val tabToShow = if (config.isHiddenPasswordProtectionOn) config.hiddenProtectionType else SHOW_ALL_TABS
|
||||||
SecurityDialog(this, config.hiddenPasswordHash, tabToShow) { hash, type, success ->
|
SecurityDialog(this, config.hiddenPasswordHash, tabToShow) { hash, type, success ->
|
||||||
if (success) {
|
if (success) {
|
||||||
val hasPasswordProtection = config.isHiddenPasswordProtectionOn
|
val hasPasswordProtection = config.isHiddenPasswordProtectionOn
|
||||||
settings_password_protection.isChecked = !hasPasswordProtection
|
binding.settingsPasswordProtection.isChecked = !hasPasswordProtection
|
||||||
config.isHiddenPasswordProtectionOn = !hasPasswordProtection
|
config.isHiddenPasswordProtectionOn = !hasPasswordProtection
|
||||||
config.hiddenPasswordHash = if (hasPasswordProtection) "" else hash
|
config.hiddenPasswordHash = if (hasPasswordProtection) "" else hash
|
||||||
config.hiddenProtectionType = type
|
config.hiddenProtectionType = type
|
||||||
@ -177,13 +190,13 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupAppPasswordProtection() {
|
private fun setupAppPasswordProtection() {
|
||||||
settings_app_password_protection.isChecked = config.isAppPasswordProtectionOn
|
binding.settingsAppPasswordProtection.isChecked = config.isAppPasswordProtectionOn
|
||||||
settings_app_password_protection_holder.setOnClickListener {
|
binding.settingsAppPasswordProtectionHolder.setOnClickListener {
|
||||||
val tabToShow = if (config.isAppPasswordProtectionOn) config.appProtectionType else SHOW_ALL_TABS
|
val tabToShow = if (config.isAppPasswordProtectionOn) config.appProtectionType else SHOW_ALL_TABS
|
||||||
SecurityDialog(this, config.appPasswordHash, tabToShow) { hash, type, success ->
|
SecurityDialog(this, config.appPasswordHash, tabToShow) { hash, type, success ->
|
||||||
if (success) {
|
if (success) {
|
||||||
val hasPasswordProtection = config.isAppPasswordProtectionOn
|
val hasPasswordProtection = config.isAppPasswordProtectionOn
|
||||||
settings_app_password_protection.isChecked = !hasPasswordProtection
|
binding.settingsAppPasswordProtection.isChecked = !hasPasswordProtection
|
||||||
config.isAppPasswordProtectionOn = !hasPasswordProtection
|
config.isAppPasswordProtectionOn = !hasPasswordProtection
|
||||||
config.appPasswordHash = if (hasPasswordProtection) "" else hash
|
config.appPasswordHash = if (hasPasswordProtection) "" else hash
|
||||||
config.appProtectionType = type
|
config.appProtectionType = type
|
||||||
@ -199,13 +212,13 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupFileDeletionPasswordProtection() {
|
private fun setupFileDeletionPasswordProtection() {
|
||||||
settings_file_deletion_password_protection.isChecked = config.isDeletePasswordProtectionOn
|
binding.settingsFileDeletionPasswordProtection.isChecked = config.isDeletePasswordProtectionOn
|
||||||
settings_file_deletion_password_protection_holder.setOnClickListener {
|
binding.settingsFileDeletionPasswordProtectionHolder.setOnClickListener {
|
||||||
val tabToShow = if (config.isDeletePasswordProtectionOn) config.deleteProtectionType else SHOW_ALL_TABS
|
val tabToShow = if (config.isDeletePasswordProtectionOn) config.deleteProtectionType else SHOW_ALL_TABS
|
||||||
SecurityDialog(this, config.deletePasswordHash, tabToShow) { hash, type, success ->
|
SecurityDialog(this, config.deletePasswordHash, tabToShow) { hash, type, success ->
|
||||||
if (success) {
|
if (success) {
|
||||||
val hasPasswordProtection = config.isDeletePasswordProtectionOn
|
val hasPasswordProtection = config.isDeletePasswordProtectionOn
|
||||||
settings_file_deletion_password_protection.isChecked = !hasPasswordProtection
|
binding.settingsFileDeletionPasswordProtection.isChecked = !hasPasswordProtection
|
||||||
config.isDeletePasswordProtectionOn = !hasPasswordProtection
|
config.isDeletePasswordProtectionOn = !hasPasswordProtection
|
||||||
config.deletePasswordHash = if (hasPasswordProtection) "" else hash
|
config.deletePasswordHash = if (hasPasswordProtection) "" else hash
|
||||||
config.deleteProtectionType = type
|
config.deleteProtectionType = type
|
||||||
@ -221,37 +234,43 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupKeepLastModified() {
|
private fun setupKeepLastModified() {
|
||||||
settings_keep_last_modified.isChecked = config.keepLastModified
|
binding.apply {
|
||||||
settings_keep_last_modified_holder.setOnClickListener {
|
settingsKeepLastModified.isChecked = config.keepLastModified
|
||||||
settings_keep_last_modified.toggle()
|
settingsKeepLastModifiedHolder.setOnClickListener {
|
||||||
config.keepLastModified = settings_keep_last_modified.isChecked
|
settingsKeepLastModified.toggle()
|
||||||
|
config.keepLastModified = settingsKeepLastModified.isChecked
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupDeleteConfirmation() {
|
private fun setupDeleteConfirmation() {
|
||||||
settings_skip_delete_confirmation.isChecked = config.skipDeleteConfirmation
|
binding.apply {
|
||||||
settings_skip_delete_confirmation_holder.setOnClickListener {
|
settingsSkipDeleteConfirmation.isChecked = config.skipDeleteConfirmation
|
||||||
settings_skip_delete_confirmation.toggle()
|
settingsSkipDeleteConfirmationHolder.setOnClickListener {
|
||||||
config.skipDeleteConfirmation = settings_skip_delete_confirmation.isChecked
|
settingsSkipDeleteConfirmation.toggle()
|
||||||
|
config.skipDeleteConfirmation = settingsSkipDeleteConfirmation.isChecked
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupEnableRootAccess() {
|
private fun setupEnableRootAccess() {
|
||||||
settings_enable_root_access_holder.beVisibleIf(config.isRootAvailable)
|
binding.apply {
|
||||||
settings_enable_root_access.isChecked = config.enableRootAccess
|
settingsEnableRootAccessHolder.beVisibleIf(config.isRootAvailable)
|
||||||
settings_enable_root_access_holder.setOnClickListener {
|
settingsEnableRootAccess.isChecked = config.enableRootAccess
|
||||||
if (!config.enableRootAccess) {
|
settingsEnableRootAccessHolder.setOnClickListener {
|
||||||
RootHelpers(this).askRootIfNeeded {
|
if (!config.enableRootAccess) {
|
||||||
toggleRootAccess(it)
|
RootHelpers(this@SettingsActivity).askRootIfNeeded {
|
||||||
|
toggleRootAccess(it)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
toggleRootAccess(false)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
toggleRootAccess(false)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toggleRootAccess(enable: Boolean) {
|
private fun toggleRootAccess(enable: Boolean) {
|
||||||
settings_enable_root_access.isChecked = enable
|
binding.settingsEnableRootAccess.isChecked = enable
|
||||||
config.enableRootAccess = enable
|
config.enableRootAccess = enable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,9 @@ import com.simplemobiletools.commons.helpers.getFilePlaceholderDrawables
|
|||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
|
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.ItemDecompressionListFileDirBinding
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||||
import com.simplemobiletools.filemanager.pro.models.ListItem
|
import com.simplemobiletools.filemanager.pro.models.ListItem
|
||||||
import kotlinx.android.synthetic.main.item_file_dir_list.view.*
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class DecompressItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) :
|
class DecompressItemsAdapter(activity: SimpleActivity, var listItems: MutableList<ListItem>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit) :
|
||||||
MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
|
MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
|
||||||
@ -60,7 +59,9 @@ class DecompressItemsAdapter(activity: SimpleActivity, var listItems: MutableLis
|
|||||||
|
|
||||||
override fun onActionModeDestroyed() {}
|
override fun onActionModeDestroyed() {}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_decompression_list_file_dir, parent)
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
|
return createViewHolder(ItemDecompressionListFileDirBinding.inflate(layoutInflater, parent, false).root)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
|
||||||
val fileDirItem = listItems[position]
|
val fileDirItem = listItems[position]
|
||||||
@ -75,22 +76,23 @@ class DecompressItemsAdapter(activity: SimpleActivity, var listItems: MutableLis
|
|||||||
override fun onViewRecycled(holder: ViewHolder) {
|
override fun onViewRecycled(holder: ViewHolder) {
|
||||||
super.onViewRecycled(holder)
|
super.onViewRecycled(holder)
|
||||||
if (!activity.isDestroyed && !activity.isFinishing) {
|
if (!activity.isDestroyed && !activity.isFinishing) {
|
||||||
val icon = holder.itemView.item_icon
|
ItemDecompressionListFileDirBinding.bind(holder.itemView).apply {
|
||||||
if (icon != null) {
|
if (itemIcon != null) {
|
||||||
Glide.with(activity).clear(icon)
|
Glide.with(activity).clear(itemIcon)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupView(view: View, listItem: ListItem) {
|
private fun setupView(view: View, listItem: ListItem) {
|
||||||
view.apply {
|
ItemDecompressionListFileDirBinding.bind(view).apply {
|
||||||
val fileName = listItem.name
|
val fileName = listItem.name
|
||||||
item_name.text = fileName
|
itemName.text = fileName
|
||||||
item_name.setTextColor(textColor)
|
itemName.setTextColor(textColor)
|
||||||
item_name.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
itemName.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
||||||
|
|
||||||
if (listItem.isDirectory) {
|
if (listItem.isDirectory) {
|
||||||
item_icon.setImageDrawable(folderDrawable)
|
itemIcon.setImageDrawable(folderDrawable)
|
||||||
} else {
|
} else {
|
||||||
val drawable = fileDrawables.getOrElse(fileName.substringAfterLast(".").toLowerCase(), { fileDrawable })
|
val drawable = fileDrawables.getOrElse(fileName.substringAfterLast(".").toLowerCase(), { fileDrawable })
|
||||||
val options = RequestOptions()
|
val options = RequestOptions()
|
||||||
@ -105,7 +107,7 @@ class DecompressItemsAdapter(activity: SimpleActivity, var listItems: MutableLis
|
|||||||
.load(itemToLoad)
|
.load(itemToLoad)
|
||||||
.transition(DrawableTransitionOptions.withCrossFade())
|
.transition(DrawableTransitionOptions.withCrossFade())
|
||||||
.apply(options)
|
.apply(options)
|
||||||
.into(item_icon)
|
.into(itemIcon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,15 @@ import android.graphics.drawable.Icon
|
|||||||
import android.graphics.drawable.LayerDrawable
|
import android.graphics.drawable.LayerDrawable
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
|
import android.view.LayoutInflater
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.FrameLayout
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.TextView
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
|
import androidx.viewbinding.ViewBinding
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.load.DecodeFormat
|
import com.bumptech.glide.load.DecodeFormat
|
||||||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||||
@ -32,18 +37,13 @@ import com.simplemobiletools.commons.views.MyRecyclerView
|
|||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
|
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
|
||||||
import com.simplemobiletools.filemanager.pro.activities.SplashActivity
|
import com.simplemobiletools.filemanager.pro.activities.SplashActivity
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.*
|
||||||
import com.simplemobiletools.filemanager.pro.dialogs.CompressAsDialog
|
import com.simplemobiletools.filemanager.pro.dialogs.CompressAsDialog
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.*
|
import com.simplemobiletools.filemanager.pro.extensions.*
|
||||||
import com.simplemobiletools.filemanager.pro.helpers.*
|
import com.simplemobiletools.filemanager.pro.helpers.*
|
||||||
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
|
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
|
||||||
import com.simplemobiletools.filemanager.pro.models.ListItem
|
import com.simplemobiletools.filemanager.pro.models.ListItem
|
||||||
import com.stericson.RootTools.RootTools
|
import com.stericson.RootTools.RootTools
|
||||||
import kotlinx.android.synthetic.main.item_file_dir_list.view.*
|
|
||||||
import kotlinx.android.synthetic.main.item_file_dir_list.view.item_frame
|
|
||||||
import kotlinx.android.synthetic.main.item_file_dir_list.view.item_icon
|
|
||||||
import kotlinx.android.synthetic.main.item_file_dir_list.view.item_name
|
|
||||||
import kotlinx.android.synthetic.main.item_file_grid.view.*
|
|
||||||
import kotlinx.android.synthetic.main.item_section.view.*
|
|
||||||
import net.lingala.zip4j.exception.ZipException
|
import net.lingala.zip4j.exception.ZipException
|
||||||
import net.lingala.zip4j.io.inputstream.ZipInputStream
|
import net.lingala.zip4j.io.inputstream.ZipInputStream
|
||||||
import net.lingala.zip4j.io.outputstream.ZipOutputStream
|
import net.lingala.zip4j.io.outputstream.ZipOutputStream
|
||||||
@ -60,10 +60,6 @@ class ItemsAdapter(
|
|||||||
val isPickMultipleIntent: Boolean, val swipeRefreshLayout: SwipeRefreshLayout?, canHaveIndividualViewType: Boolean = true, itemClick: (Any) -> Unit
|
val isPickMultipleIntent: Boolean, val swipeRefreshLayout: SwipeRefreshLayout?, canHaveIndividualViewType: Boolean = true, itemClick: (Any) -> Unit
|
||||||
) : MyRecyclerViewAdapter(activity, recyclerView, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate {
|
) : MyRecyclerViewAdapter(activity, recyclerView, itemClick), RecyclerViewFastScroller.OnPopupTextUpdate {
|
||||||
|
|
||||||
private val TYPE_FILE = 1
|
|
||||||
private val TYPE_DIR = 2
|
|
||||||
private val TYPE_SECTION = 3
|
|
||||||
private val TYPE_GRID_TYPE_DIVIDER = 4
|
|
||||||
private lateinit var fileDrawable: Drawable
|
private lateinit var fileDrawable: Drawable
|
||||||
private lateinit var folderDrawable: Drawable
|
private lateinit var folderDrawable: Drawable
|
||||||
private var fileDrawables = HashMap<String, Drawable>()
|
private var fileDrawables = HashMap<String, Drawable>()
|
||||||
@ -84,6 +80,13 @@ class ItemsAdapter(
|
|||||||
private val isListViewType = viewType == VIEW_TYPE_LIST
|
private val isListViewType = viewType == VIEW_TYPE_LIST
|
||||||
private var displayFilenamesInGrid = config.displayFilenames
|
private var displayFilenamesInGrid = config.displayFilenames
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val TYPE_FILE = 1
|
||||||
|
private const val TYPE_DIR = 2
|
||||||
|
private const val TYPE_SECTION = 3
|
||||||
|
private const val TYPE_GRID_TYPE_DIVIDER = 4
|
||||||
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setupDragListener(true)
|
setupDragListener(true)
|
||||||
initDrawables()
|
initDrawables()
|
||||||
@ -161,28 +164,16 @@ class ItemsAdapter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
val layout = if (viewType == TYPE_SECTION) {
|
val binding = Binding.getByItemViewType(viewType, isListViewType).inflate(layoutInflater, parent, false)
|
||||||
R.layout.item_section
|
|
||||||
} else if (viewType == TYPE_GRID_TYPE_DIVIDER) {
|
return createViewHolder(binding.root)
|
||||||
R.layout.item_empty
|
|
||||||
} else {
|
|
||||||
if (isListViewType) {
|
|
||||||
R.layout.item_file_dir_list
|
|
||||||
} else {
|
|
||||||
if (viewType == TYPE_DIR) {
|
|
||||||
R.layout.item_dir_grid
|
|
||||||
} else {
|
|
||||||
R.layout.item_file_grid
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return createViewHolder(layout, parent)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int) {
|
||||||
val fileDirItem = listItems[position]
|
val fileDirItem = listItems[position]
|
||||||
holder.bindView(fileDirItem, true, !fileDirItem.isSectionTitle) { itemView, layoutPosition ->
|
holder.bindView(fileDirItem, true, !fileDirItem.isSectionTitle) { itemView, layoutPosition ->
|
||||||
setupView(itemView, fileDirItem)
|
val viewType = getItemViewType(position)
|
||||||
|
setupView(Binding.getByItemViewType(viewType, isListViewType).bind(itemView), fileDirItem)
|
||||||
}
|
}
|
||||||
bindViewHolder(holder)
|
bindViewHolder(holder)
|
||||||
}
|
}
|
||||||
@ -831,55 +822,55 @@ class ItemsAdapter(
|
|||||||
override fun onViewRecycled(holder: ViewHolder) {
|
override fun onViewRecycled(holder: ViewHolder) {
|
||||||
super.onViewRecycled(holder)
|
super.onViewRecycled(holder)
|
||||||
if (!activity.isDestroyed && !activity.isFinishing) {
|
if (!activity.isDestroyed && !activity.isFinishing) {
|
||||||
val icon = holder.itemView.item_icon
|
val icon = Binding.getByItemViewType(holder.itemViewType, isListViewType).bind(holder.itemView).itemIcon
|
||||||
if (icon != null) {
|
if (icon != null) {
|
||||||
Glide.with(activity).clear(icon)
|
Glide.with(activity).clear(icon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupView(view: View, listItem: ListItem) {
|
private fun setupView(binding: ItemViewBinding, listItem: ListItem) {
|
||||||
val isSelected = selectedKeys.contains(listItem.path.hashCode())
|
val isSelected = selectedKeys.contains(listItem.path.hashCode())
|
||||||
view.apply {
|
binding.apply {
|
||||||
if (listItem.isSectionTitle) {
|
if (listItem.isSectionTitle) {
|
||||||
item_icon.setImageDrawable(folderDrawable)
|
itemIcon?.setImageDrawable(folderDrawable)
|
||||||
item_section.text = if (textToHighlight.isEmpty()) listItem.mName else listItem.mName.highlightTextPart(textToHighlight, properPrimaryColor)
|
itemSection?.text = if (textToHighlight.isEmpty()) listItem.mName else listItem.mName.highlightTextPart(textToHighlight, properPrimaryColor)
|
||||||
item_section.setTextColor(textColor)
|
itemSection?.setTextColor(textColor)
|
||||||
item_section.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
itemSection?.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
||||||
} else if (!listItem.isGridTypeDivider) {
|
} else if (!listItem.isGridTypeDivider) {
|
||||||
setupViewBackground(activity)
|
root.setupViewBackground(activity)
|
||||||
item_frame.isSelected = isSelected
|
itemFrame.isSelected = isSelected
|
||||||
val fileName = listItem.name
|
val fileName = listItem.name
|
||||||
item_name.text = if (textToHighlight.isEmpty()) fileName else fileName.highlightTextPart(textToHighlight, properPrimaryColor)
|
itemName?.text = if (textToHighlight.isEmpty()) fileName else fileName.highlightTextPart(textToHighlight, properPrimaryColor)
|
||||||
item_name.setTextColor(textColor)
|
itemName?.setTextColor(textColor)
|
||||||
item_name.setTextSize(TypedValue.COMPLEX_UNIT_PX, if (isListViewType) fontSize else smallerFontSize)
|
itemName?.setTextSize(TypedValue.COMPLEX_UNIT_PX, if (isListViewType) fontSize else smallerFontSize)
|
||||||
|
|
||||||
item_details?.setTextColor(textColor)
|
itemDetails?.setTextColor(textColor)
|
||||||
item_details?.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
itemDetails?.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize)
|
||||||
|
|
||||||
item_date?.setTextColor(textColor)
|
itemDate?.setTextColor(textColor)
|
||||||
item_date?.setTextSize(TypedValue.COMPLEX_UNIT_PX, smallerFontSize)
|
itemDate?.setTextSize(TypedValue.COMPLEX_UNIT_PX, smallerFontSize)
|
||||||
|
|
||||||
item_check?.beVisibleIf(isSelected)
|
itemCheck?.beVisibleIf(isSelected)
|
||||||
if (isSelected) {
|
if (isSelected) {
|
||||||
item_check?.background?.applyColorFilter(properPrimaryColor)
|
itemCheck?.background?.applyColorFilter(properPrimaryColor)
|
||||||
item_check?.applyColorFilter(contrastColor)
|
itemCheck?.applyColorFilter(contrastColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isListViewType && !listItem.isDirectory) {
|
if (!isListViewType && !listItem.isDirectory) {
|
||||||
item_name.beVisibleIf(displayFilenamesInGrid)
|
itemName?.beVisibleIf(displayFilenamesInGrid)
|
||||||
} else {
|
} else {
|
||||||
item_name.beVisible()
|
itemName?.beVisible()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listItem.isDirectory) {
|
if (listItem.isDirectory) {
|
||||||
item_icon.setImageDrawable(folderDrawable)
|
itemIcon?.setImageDrawable(folderDrawable)
|
||||||
item_details?.text = getChildrenCnt(listItem)
|
itemDetails?.text = getChildrenCnt(listItem)
|
||||||
item_date?.beGone()
|
itemDate?.beGone()
|
||||||
} else {
|
} else {
|
||||||
item_details?.text = listItem.size.formatSize()
|
itemDetails?.text = listItem.size.formatSize()
|
||||||
item_date?.beVisible()
|
itemDate?.beVisible()
|
||||||
item_date?.text = listItem.modified.formatDate(activity, dateFormat, timeFormat)
|
itemDate?.text = listItem.modified.formatDate(activity, dateFormat, timeFormat)
|
||||||
|
|
||||||
val drawable = fileDrawables.getOrElse(fileName.substringAfterLast(".").toLowerCase(), { fileDrawable })
|
val drawable = fileDrawables.getOrElse(fileName.substringAfterLast(".").toLowerCase(), { fileDrawable })
|
||||||
val options = RequestOptions()
|
val options = RequestOptions()
|
||||||
@ -889,12 +880,12 @@ class ItemsAdapter(
|
|||||||
.transform(CenterCrop(), RoundedCorners(10))
|
.transform(CenterCrop(), RoundedCorners(10))
|
||||||
|
|
||||||
val itemToLoad = getImagePathToLoad(listItem.path)
|
val itemToLoad = getImagePathToLoad(listItem.path)
|
||||||
if (!activity.isDestroyed) {
|
if (!activity.isDestroyed && itemIcon != null) {
|
||||||
Glide.with(activity)
|
Glide.with(activity)
|
||||||
.load(itemToLoad)
|
.load(itemToLoad)
|
||||||
.transition(DrawableTransitionOptions.withCrossFade())
|
.transition(DrawableTransitionOptions.withCrossFade())
|
||||||
.apply(options)
|
.apply(options)
|
||||||
.into(item_icon)
|
.into(itemIcon!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -941,4 +932,146 @@ class ItemsAdapter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onChange(position: Int) = listItems.getOrNull(position)?.getBubbleText(activity, dateFormat, timeFormat) ?: ""
|
override fun onChange(position: Int) = listItems.getOrNull(position)?.getBubbleText(activity, dateFormat, timeFormat) ?: ""
|
||||||
|
|
||||||
|
private sealed interface Binding {
|
||||||
|
companion object {
|
||||||
|
fun getByItemViewType(viewType: Int, isListViewType: Boolean): Binding {
|
||||||
|
return when (viewType) {
|
||||||
|
TYPE_SECTION -> ItemSection
|
||||||
|
TYPE_GRID_TYPE_DIVIDER -> ItemEmpty
|
||||||
|
else -> {
|
||||||
|
if (isListViewType) {
|
||||||
|
ItemFileDirList
|
||||||
|
} else if (viewType == TYPE_DIR) {
|
||||||
|
ItemDirGrid
|
||||||
|
} else {
|
||||||
|
ItemFileGrid
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun inflate(layoutInflater: LayoutInflater, viewGroup: ViewGroup, attachToRoot: Boolean): ItemViewBinding
|
||||||
|
fun bind(view: View): ItemViewBinding
|
||||||
|
|
||||||
|
data object ItemSection : Binding {
|
||||||
|
override fun inflate(layoutInflater: LayoutInflater, viewGroup: ViewGroup, attachToRoot: Boolean): ItemViewBinding {
|
||||||
|
return ItemSectionBindingAdapter(ItemSectionBinding.inflate(layoutInflater, viewGroup, attachToRoot))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun bind(view: View): ItemViewBinding {
|
||||||
|
return ItemSectionBindingAdapter(ItemSectionBinding.bind(view))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data object ItemEmpty : Binding {
|
||||||
|
override fun inflate(layoutInflater: LayoutInflater, viewGroup: ViewGroup, attachToRoot: Boolean): ItemViewBinding {
|
||||||
|
return ItemEmptyBindingAdapter(ItemEmptyBinding.inflate(layoutInflater, viewGroup, attachToRoot))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun bind(view: View): ItemViewBinding {
|
||||||
|
return ItemEmptyBindingAdapter(ItemEmptyBinding.bind(view))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data object ItemFileDirList : Binding {
|
||||||
|
override fun inflate(layoutInflater: LayoutInflater, viewGroup: ViewGroup, attachToRoot: Boolean): ItemViewBinding {
|
||||||
|
return ItemFileDirListBindingAdapter(ItemFileDirListBinding.inflate(layoutInflater, viewGroup, attachToRoot))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun bind(view: View): ItemViewBinding {
|
||||||
|
return ItemFileDirListBindingAdapter(ItemFileDirListBinding.bind(view))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data object ItemDirGrid : Binding {
|
||||||
|
override fun inflate(layoutInflater: LayoutInflater, viewGroup: ViewGroup, attachToRoot: Boolean): ItemViewBinding {
|
||||||
|
return ItemDirGridBindingAdapter(ItemDirGridBinding.inflate(layoutInflater, viewGroup, attachToRoot))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun bind(view: View): ItemViewBinding {
|
||||||
|
return ItemDirGridBindingAdapter(ItemDirGridBinding.bind(view))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data object ItemFileGrid : Binding {
|
||||||
|
override fun inflate(layoutInflater: LayoutInflater, viewGroup: ViewGroup, attachToRoot: Boolean): ItemViewBinding {
|
||||||
|
return ItemFileGridBindingAdapter(ItemFileGridBinding.inflate(layoutInflater, viewGroup, attachToRoot))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun bind(view: View): ItemViewBinding {
|
||||||
|
return ItemFileGridBindingAdapter(ItemFileGridBinding.bind(view))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private interface ItemViewBinding : ViewBinding {
|
||||||
|
val itemFrame: FrameLayout
|
||||||
|
val itemName: TextView?
|
||||||
|
val itemIcon: ImageView?
|
||||||
|
val itemCheck: ImageView?
|
||||||
|
val itemDetails: TextView?
|
||||||
|
val itemDate: TextView?
|
||||||
|
val itemSection: TextView?
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ItemSectionBindingAdapter(val binding: ItemSectionBinding) : ItemViewBinding {
|
||||||
|
override val itemFrame: FrameLayout = binding.itemFrame
|
||||||
|
override val itemName: TextView? = null
|
||||||
|
override val itemIcon: ImageView = binding.itemIcon
|
||||||
|
override val itemDetails: TextView? = null
|
||||||
|
override val itemDate: TextView? = null
|
||||||
|
override val itemCheck: ImageView? = null
|
||||||
|
override val itemSection: TextView = binding.itemSection
|
||||||
|
override fun getRoot(): View = binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ItemEmptyBindingAdapter(val binding: ItemEmptyBinding) : ItemViewBinding {
|
||||||
|
override val itemFrame: FrameLayout = binding.itemFrame
|
||||||
|
override val itemName: TextView? = null
|
||||||
|
override val itemIcon: ImageView? = null
|
||||||
|
override val itemDetails: TextView? = null
|
||||||
|
override val itemDate: TextView? = null
|
||||||
|
override val itemCheck: ImageView? = null
|
||||||
|
override val itemSection: TextView? = null
|
||||||
|
|
||||||
|
override fun getRoot(): View = binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ItemFileDirListBindingAdapter(val binding: ItemFileDirListBinding) : ItemViewBinding {
|
||||||
|
override val itemFrame: FrameLayout = binding.itemFrame
|
||||||
|
override val itemName: TextView = binding.itemName
|
||||||
|
override val itemIcon: ImageView = binding.itemIcon
|
||||||
|
override val itemDetails: TextView = binding.itemDetails
|
||||||
|
override val itemDate: TextView = binding.itemDate
|
||||||
|
override val itemCheck: ImageView? = null
|
||||||
|
override val itemSection: TextView? = null
|
||||||
|
|
||||||
|
override fun getRoot(): View = binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ItemDirGridBindingAdapter(val binding: ItemDirGridBinding) : ItemViewBinding {
|
||||||
|
override val itemFrame: FrameLayout = binding.itemFrame
|
||||||
|
override val itemName: TextView = binding.itemName
|
||||||
|
override val itemIcon: ImageView = binding.itemIcon
|
||||||
|
override val itemDetails: TextView? = null
|
||||||
|
override val itemDate: TextView? = null
|
||||||
|
override val itemCheck: ImageView = binding.itemCheck
|
||||||
|
override val itemSection: TextView? = null
|
||||||
|
|
||||||
|
override fun getRoot(): View = binding.root
|
||||||
|
}
|
||||||
|
|
||||||
|
private class ItemFileGridBindingAdapter(val binding: ItemFileGridBinding) : ItemViewBinding {
|
||||||
|
override val itemFrame: FrameLayout = binding.itemFrame
|
||||||
|
override val itemName: TextView = binding.itemName
|
||||||
|
override val itemIcon: ImageView = binding.itemIcon
|
||||||
|
override val itemDetails: TextView? = null
|
||||||
|
override val itemDate: TextView? = null
|
||||||
|
override val itemCheck: ImageView? = null
|
||||||
|
override val itemSection: TextView? = null
|
||||||
|
|
||||||
|
override fun getRoot(): View = binding.root
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ import com.simplemobiletools.commons.extensions.setupViewBackground
|
|||||||
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
import com.simplemobiletools.commons.interfaces.RefreshRecyclerViewListener
|
||||||
import com.simplemobiletools.commons.views.MyRecyclerView
|
import com.simplemobiletools.commons.views.MyRecyclerView
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.ItemManageFavoriteBinding
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||||
import kotlinx.android.synthetic.main.item_manage_favorite.view.*
|
|
||||||
|
|
||||||
class ManageFavoritesAdapter(
|
class ManageFavoritesAdapter(
|
||||||
activity: BaseSimpleActivity, var favorites: ArrayList<String>, val listener: RefreshRecyclerViewListener?,
|
activity: BaseSimpleActivity, var favorites: ArrayList<String>, val listener: RefreshRecyclerViewListener?,
|
||||||
@ -46,7 +46,9 @@ class ManageFavoritesAdapter(
|
|||||||
|
|
||||||
override fun prepareActionMode(menu: Menu) {}
|
override fun prepareActionMode(menu: Menu) {}
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.item_manage_favorite, parent)
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
|
||||||
|
return createViewHolder(ItemManageFavoriteBinding.inflate(layoutInflater, parent, false).root)
|
||||||
|
}
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
|
||||||
val favorite = favorites[position]
|
val favorite = favorites[position]
|
||||||
@ -59,22 +61,22 @@ class ManageFavoritesAdapter(
|
|||||||
override fun getItemCount() = favorites.size
|
override fun getItemCount() = favorites.size
|
||||||
|
|
||||||
private fun setupView(view: View, favorite: String, isSelected: Boolean) {
|
private fun setupView(view: View, favorite: String, isSelected: Boolean) {
|
||||||
view.apply {
|
ItemManageFavoriteBinding.bind(view).apply {
|
||||||
setupViewBackground(activity)
|
root.setupViewBackground(activity)
|
||||||
manage_favorite_title.apply {
|
manageFavoriteTitle.apply {
|
||||||
text = favorite
|
text = favorite
|
||||||
setTextColor(activity.getProperTextColor())
|
setTextColor(activity.getProperTextColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
manage_favorite_holder?.isSelected = isSelected
|
manageFavoriteHolder?.isSelected = isSelected
|
||||||
|
|
||||||
overflow_menu_icon.drawable.apply {
|
overflowMenuIcon.drawable.apply {
|
||||||
mutate()
|
mutate()
|
||||||
setTint(activity.getProperTextColor())
|
setTint(activity.getProperTextColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
overflow_menu_icon.setOnClickListener {
|
overflowMenuIcon.setOnClickListener {
|
||||||
showPopupMenu(overflow_menu_anchor, favorite)
|
showPopupMenu(overflowMenuAnchor, favorite)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ class ViewPagerAdapter(val activity: SimpleActivity, val tabsToShow: ArrayList<I
|
|||||||
val view = activity.layoutInflater.inflate(layout, container, false)
|
val view = activity.layoutInflater.inflate(layout, container, false)
|
||||||
container.addView(view)
|
container.addView(view)
|
||||||
|
|
||||||
(view as MyViewPagerFragment).apply {
|
(view as MyViewPagerFragment<*>).apply {
|
||||||
val isPickRingtoneIntent = activity.intent.action == RingtoneManager.ACTION_RINGTONE_PICKER
|
val isPickRingtoneIntent = activity.intent.action == RingtoneManager.ACTION_RINGTONE_PICKER
|
||||||
val isGetContentIntent = activity.intent.action == Intent.ACTION_GET_CONTENT || activity.intent.action == Intent.ACTION_PICK
|
val isGetContentIntent = activity.intent.action == Intent.ACTION_GET_CONTENT || activity.intent.action == Intent.ACTION_PICK
|
||||||
val isCreateDocumentIntent = activity.intent.action == Intent.ACTION_CREATE_DOCUMENT
|
val isCreateDocumentIntent = activity.intent.action == Intent.ACTION_CREATE_DOCUMENT
|
||||||
|
@ -1,34 +1,33 @@
|
|||||||
package com.simplemobiletools.filemanager.pro.dialogs
|
package com.simplemobiletools.filemanager.pro.dialogs
|
||||||
|
|
||||||
import android.view.View
|
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.beVisibleIf
|
import com.simplemobiletools.commons.extensions.beVisibleIf
|
||||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
import com.simplemobiletools.commons.extensions.setupDialogStuff
|
||||||
import com.simplemobiletools.commons.helpers.*
|
import com.simplemobiletools.commons.helpers.*
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.DialogChangeSortingBinding
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||||
import kotlinx.android.synthetic.main.dialog_change_sorting.view.*
|
|
||||||
|
|
||||||
class ChangeSortingDialog(val activity: BaseSimpleActivity, val path: String = "", val callback: () -> Unit) {
|
class ChangeSortingDialog(val activity: BaseSimpleActivity, val path: String = "", val callback: () -> Unit) {
|
||||||
private var currSorting = 0
|
private var currSorting = 0
|
||||||
private var config = activity.config
|
private var config = activity.config
|
||||||
private var view: View
|
private val binding: DialogChangeSortingBinding
|
||||||
|
|
||||||
init {
|
init {
|
||||||
currSorting = config.getFolderSorting(path)
|
currSorting = config.getFolderSorting(path)
|
||||||
view = activity.layoutInflater.inflate(R.layout.dialog_change_sorting, null).apply {
|
binding = DialogChangeSortingBinding.inflate(activity.layoutInflater).apply {
|
||||||
sorting_dialog_use_for_this_folder.isChecked = config.hasCustomSorting(path)
|
sortingDialogUseForThisFolder.isChecked = config.hasCustomSorting(path)
|
||||||
|
|
||||||
sorting_dialog_numeric_sorting.beVisibleIf(currSorting and SORT_BY_NAME != 0)
|
sortingDialogNumericSorting.beVisibleIf(currSorting and SORT_BY_NAME != 0)
|
||||||
sorting_dialog_numeric_sorting.isChecked = currSorting and SORT_USE_NUMERIC_VALUE != 0
|
sortingDialogNumericSorting.isChecked = currSorting and SORT_USE_NUMERIC_VALUE != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.sort_by)
|
activity.setupDialogStuff(binding.root, this, R.string.sort_by)
|
||||||
}
|
}
|
||||||
|
|
||||||
setupSortRadio()
|
setupSortRadio()
|
||||||
@ -36,34 +35,33 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val path: String = "
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupSortRadio() {
|
private fun setupSortRadio() {
|
||||||
val sortingRadio = view.sorting_dialog_radio_sorting
|
binding.apply {
|
||||||
|
sortingDialogRadioSorting.setOnCheckedChangeListener { group, checkedId ->
|
||||||
|
val isSortingByName = checkedId == sortingDialogRadioName.id
|
||||||
|
binding.sortingDialogNumericSorting.beVisibleIf(isSortingByName)
|
||||||
|
}
|
||||||
|
|
||||||
sortingRadio.setOnCheckedChangeListener { group, checkedId ->
|
val sortBtn = when {
|
||||||
val isSortingByName = checkedId == sortingRadio.sorting_dialog_radio_name.id
|
currSorting and SORT_BY_SIZE != 0 -> sortingDialogRadioSize
|
||||||
view.sorting_dialog_numeric_sorting.beVisibleIf(isSortingByName)
|
currSorting and SORT_BY_DATE_MODIFIED != 0 -> sortingDialogRadioLastModified
|
||||||
|
currSorting and SORT_BY_EXTENSION != 0 -> sortingDialogRadioExtension
|
||||||
|
else -> sortingDialogRadioName
|
||||||
|
}
|
||||||
|
sortBtn.isChecked = true
|
||||||
}
|
}
|
||||||
|
|
||||||
val sortBtn = when {
|
|
||||||
currSorting and SORT_BY_SIZE != 0 -> sortingRadio.sorting_dialog_radio_size
|
|
||||||
currSorting and SORT_BY_DATE_MODIFIED != 0 -> sortingRadio.sorting_dialog_radio_last_modified
|
|
||||||
currSorting and SORT_BY_EXTENSION != 0 -> sortingRadio.sorting_dialog_radio_extension
|
|
||||||
else -> sortingRadio.sorting_dialog_radio_name
|
|
||||||
}
|
|
||||||
sortBtn.isChecked = true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupOrderRadio() {
|
private fun setupOrderRadio() {
|
||||||
val orderRadio = view.sorting_dialog_radio_order
|
var orderBtn = binding.sortingDialogRadioAscending
|
||||||
var orderBtn = orderRadio.sorting_dialog_radio_ascending
|
|
||||||
|
|
||||||
if (currSorting and SORT_DESCENDING != 0) {
|
if (currSorting and SORT_DESCENDING != 0) {
|
||||||
orderBtn = orderRadio.sorting_dialog_radio_descending
|
orderBtn = binding.sortingDialogRadioDescending
|
||||||
}
|
}
|
||||||
orderBtn.isChecked = true
|
orderBtn.isChecked = true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dialogConfirmed() {
|
private fun dialogConfirmed() {
|
||||||
val sortingRadio = view.sorting_dialog_radio_sorting
|
val sortingRadio = binding.sortingDialogRadioSorting
|
||||||
var sorting = when (sortingRadio.checkedRadioButtonId) {
|
var sorting = when (sortingRadio.checkedRadioButtonId) {
|
||||||
R.id.sorting_dialog_radio_name -> SORT_BY_NAME
|
R.id.sorting_dialog_radio_name -> SORT_BY_NAME
|
||||||
R.id.sorting_dialog_radio_size -> SORT_BY_SIZE
|
R.id.sorting_dialog_radio_size -> SORT_BY_SIZE
|
||||||
@ -71,15 +69,15 @@ class ChangeSortingDialog(val activity: BaseSimpleActivity, val path: String = "
|
|||||||
else -> SORT_BY_EXTENSION
|
else -> SORT_BY_EXTENSION
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view.sorting_dialog_radio_order.checkedRadioButtonId == R.id.sorting_dialog_radio_descending) {
|
if (binding.sortingDialogRadioOrder.checkedRadioButtonId == R.id.sorting_dialog_radio_descending) {
|
||||||
sorting = sorting or SORT_DESCENDING
|
sorting = sorting or SORT_DESCENDING
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view.sorting_dialog_numeric_sorting.isChecked) {
|
if (binding.sortingDialogNumericSorting.isChecked) {
|
||||||
sorting = sorting or SORT_USE_NUMERIC_VALUE
|
sorting = sorting or SORT_USE_NUMERIC_VALUE
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view.sorting_dialog_use_for_this_folder.isChecked) {
|
if (binding.sortingDialogUseForThisFolder.isChecked) {
|
||||||
config.saveCustomSorting(path, sorting)
|
config.saveCustomSorting(path, sorting)
|
||||||
} else {
|
} else {
|
||||||
config.removeCustomSorting(path)
|
config.removeCustomSorting(path)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.simplemobiletools.filemanager.pro.dialogs
|
package com.simplemobiletools.filemanager.pro.dialogs
|
||||||
|
|
||||||
import android.view.View
|
|
||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.beGone
|
import com.simplemobiletools.commons.extensions.beGone
|
||||||
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
import com.simplemobiletools.commons.extensions.getAlertDialogBuilder
|
||||||
@ -8,29 +7,29 @@ import com.simplemobiletools.commons.extensions.setupDialogStuff
|
|||||||
import com.simplemobiletools.commons.helpers.VIEW_TYPE_GRID
|
import com.simplemobiletools.commons.helpers.VIEW_TYPE_GRID
|
||||||
import com.simplemobiletools.commons.helpers.VIEW_TYPE_LIST
|
import com.simplemobiletools.commons.helpers.VIEW_TYPE_LIST
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.DialogChangeViewTypeBinding
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||||
import kotlinx.android.synthetic.main.dialog_change_view_type.view.*
|
|
||||||
|
|
||||||
class ChangeViewTypeDialog(val activity: BaseSimpleActivity, val path: String = "", showFolderCheck: Boolean = true, val callback: () -> Unit) {
|
class ChangeViewTypeDialog(val activity: BaseSimpleActivity, val path: String = "", showFolderCheck: Boolean = true, val callback: () -> Unit) {
|
||||||
private var view: View
|
private var binding: DialogChangeViewTypeBinding
|
||||||
private var config = activity.config
|
private var config = activity.config
|
||||||
|
|
||||||
init {
|
init {
|
||||||
view = activity.layoutInflater.inflate(R.layout.dialog_change_view_type, null).apply {
|
binding = DialogChangeViewTypeBinding.inflate(activity.layoutInflater).apply {
|
||||||
val currViewType = config.getFolderViewType(this@ChangeViewTypeDialog.path)
|
val currViewType = config.getFolderViewType(this@ChangeViewTypeDialog.path)
|
||||||
val viewToCheck = if (currViewType == VIEW_TYPE_GRID) {
|
val viewToCheck = if (currViewType == VIEW_TYPE_GRID) {
|
||||||
change_view_type_dialog_radio_grid.id
|
changeViewTypeDialogRadioGrid.id
|
||||||
} else {
|
} else {
|
||||||
change_view_type_dialog_radio_list.id
|
changeViewTypeDialogRadioList.id
|
||||||
}
|
}
|
||||||
|
|
||||||
change_view_type_dialog_radio.check(viewToCheck)
|
changeViewTypeDialogRadio.check(viewToCheck)
|
||||||
if (!showFolderCheck) {
|
if (!showFolderCheck) {
|
||||||
use_for_this_folder_divider.beGone()
|
useForThisFolderDivider.beGone()
|
||||||
change_view_type_dialog_use_for_this_folder.beGone()
|
changeViewTypeDialogUseForThisFolder.beGone()
|
||||||
}
|
}
|
||||||
|
|
||||||
change_view_type_dialog_use_for_this_folder.apply {
|
changeViewTypeDialogUseForThisFolder.apply {
|
||||||
isChecked = config.hasCustomViewType(this@ChangeViewTypeDialog.path)
|
isChecked = config.hasCustomViewType(this@ChangeViewTypeDialog.path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -39,18 +38,18 @@ class ChangeViewTypeDialog(val activity: BaseSimpleActivity, val path: String =
|
|||||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this)
|
activity.setupDialogStuff(binding.root, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dialogConfirmed() {
|
private fun dialogConfirmed() {
|
||||||
val viewType = if (view.change_view_type_dialog_radio.checkedRadioButtonId == view.change_view_type_dialog_radio_grid.id) {
|
val viewType = if (binding.changeViewTypeDialogRadio.checkedRadioButtonId == binding.changeViewTypeDialogRadioGrid.id) {
|
||||||
VIEW_TYPE_GRID
|
VIEW_TYPE_GRID
|
||||||
} else {
|
} else {
|
||||||
VIEW_TYPE_LIST
|
VIEW_TYPE_LIST
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view.change_view_type_dialog_use_for_this_folder.isChecked) {
|
if (binding.changeViewTypeDialogUseForThisFolder.isChecked) {
|
||||||
config.saveFolderViewType(this.path, viewType)
|
config.saveFolderViewType(this.path, viewType)
|
||||||
} else {
|
} else {
|
||||||
config.removeFolderViewType(this.path)
|
config.removeFolderViewType(this.path)
|
||||||
|
@ -6,11 +6,11 @@ import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
|||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.DialogCompressAsBinding
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||||
import kotlinx.android.synthetic.main.dialog_compress_as.view.*
|
|
||||||
|
|
||||||
class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val callback: (destination: String, password: String?) -> Unit) {
|
class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val callback: (destination: String, password: String?) -> Unit) {
|
||||||
private val view = activity.layoutInflater.inflate(R.layout.dialog_compress_as, null)
|
private val binding = DialogCompressAsBinding.inflate(activity.layoutInflater)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val filename = path.getFilenameFromPath()
|
val filename = path.getFilenameFromPath()
|
||||||
@ -18,8 +18,8 @@ class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val c
|
|||||||
val baseFilename = filename.substring(0, indexOfDot)
|
val baseFilename = filename.substring(0, indexOfDot)
|
||||||
var realPath = path.getParentPath()
|
var realPath = path.getParentPath()
|
||||||
|
|
||||||
view.apply {
|
binding.apply {
|
||||||
filename_value.setText(baseFilename)
|
filenameValue.setText(baseFilename)
|
||||||
|
|
||||||
folder.setText(activity.humanizePath(realPath))
|
folder.setText(activity.humanizePath(realPath))
|
||||||
folder.setOnClickListener {
|
folder.setOnClickListener {
|
||||||
@ -29,8 +29,8 @@ class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val c
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
password_protect.setOnCheckedChangeListener { _, _ ->
|
passwordProtect.setOnCheckedChangeListener { _, _ ->
|
||||||
enter_password_hint.beVisibleIf(password_protect.isChecked)
|
enterPasswordHint.beVisibleIf(passwordProtect.isChecked)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,13 +38,13 @@ class CompressAsDialog(val activity: BaseSimpleActivity, val path: String, val c
|
|||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.compress_as) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this, R.string.compress_as) { alertDialog ->
|
||||||
alertDialog.showKeyboard(view.filename_value)
|
alertDialog.showKeyboard(binding.filenameValue)
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
|
||||||
val name = view.filename_value.value
|
val name = binding.filenameValue.value
|
||||||
var password: String? = null
|
var password: String? = null
|
||||||
if (view.password_protect.isChecked) {
|
if (binding.passwordProtect.isChecked) {
|
||||||
password = view.password.value
|
password = binding.password.value
|
||||||
if (password.isEmpty()) {
|
if (password.isEmpty()) {
|
||||||
activity.toast(R.string.empty_password_new)
|
activity.toast(R.string.empty_password_new)
|
||||||
return@OnClickListener
|
return@OnClickListener
|
||||||
|
@ -6,23 +6,23 @@ import com.simplemobiletools.commons.extensions.*
|
|||||||
import com.simplemobiletools.commons.helpers.isRPlus
|
import com.simplemobiletools.commons.helpers.isRPlus
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
|
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.DialogCreateNewBinding
|
||||||
import com.simplemobiletools.filemanager.pro.helpers.RootHelpers
|
import com.simplemobiletools.filemanager.pro.helpers.RootHelpers
|
||||||
import kotlinx.android.synthetic.main.dialog_create_new.view.*
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
|
||||||
class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val callback: (success: Boolean) -> Unit) {
|
class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val callback: (success: Boolean) -> Unit) {
|
||||||
private val view = activity.layoutInflater.inflate(R.layout.dialog_create_new, null)
|
private val binding = DialogCreateNewBinding.inflate(activity.layoutInflater)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.create_new) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this, R.string.create_new) { alertDialog ->
|
||||||
alertDialog.showKeyboard(view.item_title)
|
alertDialog.showKeyboard(binding.itemTitle)
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(View.OnClickListener {
|
||||||
val name = view.item_title.value
|
val name = binding.itemTitle.value
|
||||||
if (name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
activity.toast(R.string.empty_name)
|
activity.toast(R.string.empty_name)
|
||||||
} else if (name.isAValidFilename()) {
|
} else if (name.isAValidFilename()) {
|
||||||
@ -32,7 +32,7 @@ class CreateNewItemDialog(val activity: SimpleActivity, val path: String, val ca
|
|||||||
return@OnClickListener
|
return@OnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
if (view.dialog_radio_group.checkedRadioButtonId == R.id.dialog_radio_directory) {
|
if (binding.dialogRadioGroup.checkedRadioButtonId == R.id.dialog_radio_directory) {
|
||||||
createDirectory(newPath, alertDialog) {
|
createDirectory(newPath, alertDialog) {
|
||||||
callback(it)
|
callback(it)
|
||||||
}
|
}
|
||||||
|
@ -4,23 +4,23 @@ import androidx.appcompat.app.AlertDialog
|
|||||||
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
import com.simplemobiletools.commons.activities.BaseSimpleActivity
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
import kotlinx.android.synthetic.main.dialog_insert_filename.view.*
|
import com.simplemobiletools.filemanager.pro.databinding.DialogInsertFilenameBinding
|
||||||
|
|
||||||
class InsertFilenameDialog(
|
class InsertFilenameDialog(
|
||||||
val activity: BaseSimpleActivity, var path: String, val callback: (filename: String) -> Unit
|
val activity: BaseSimpleActivity, var path: String, val callback: (filename: String) -> Unit
|
||||||
) {
|
) {
|
||||||
init {
|
init {
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_insert_filename, null)
|
val binding = DialogInsertFilenameBinding.inflate(activity.layoutInflater)
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.filename) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this, R.string.filename) { alertDialog ->
|
||||||
alertDialog.showKeyboard(view.insert_filename_title)
|
alertDialog.showKeyboard(binding.insertFilenameTitle)
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
val filename = view.insert_filename_title.value
|
val filename = binding.insertFilenameTitle.value
|
||||||
val extension = view.insert_filename_extension_title.value
|
val extension = binding.insertFilenameExtensionTitle.value
|
||||||
|
|
||||||
if (filename.isEmpty()) {
|
if (filename.isEmpty()) {
|
||||||
activity.toast(R.string.filename_cannot_be_empty)
|
activity.toast(R.string.filename_cannot_be_empty)
|
||||||
|
@ -10,12 +10,12 @@ import com.simplemobiletools.commons.helpers.TAB_STORAGE_ANALYSIS
|
|||||||
import com.simplemobiletools.commons.helpers.isOreoPlus
|
import com.simplemobiletools.commons.helpers.isOreoPlus
|
||||||
import com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
import com.simplemobiletools.commons.views.MyAppCompatCheckbox
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.DialogManageVisibleTabsBinding
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||||
import com.simplemobiletools.filemanager.pro.helpers.ALL_TABS_MASK
|
import com.simplemobiletools.filemanager.pro.helpers.ALL_TABS_MASK
|
||||||
import kotlinx.android.synthetic.main.dialog_manage_visible_tabs.view.*
|
|
||||||
|
|
||||||
class ManageVisibleTabsDialog(val activity: BaseSimpleActivity) {
|
class ManageVisibleTabsDialog(val activity: BaseSimpleActivity) {
|
||||||
private var view = activity.layoutInflater.inflate(R.layout.dialog_manage_visible_tabs, null)
|
private val binding = DialogManageVisibleTabsBinding.inflate(activity.layoutInflater)
|
||||||
private val tabs = LinkedHashMap<Int, Int>()
|
private val tabs = LinkedHashMap<Int, Int>()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@ -26,26 +26,26 @@ class ManageVisibleTabsDialog(val activity: BaseSimpleActivity) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isOreoPlus()) {
|
if (!isOreoPlus()) {
|
||||||
view.manage_visible_tabs_storage_analysis.beGone()
|
binding.manageVisibleTabsStorageAnalysis.beGone()
|
||||||
}
|
}
|
||||||
|
|
||||||
val showTabs = activity.config.showTabs
|
val showTabs = activity.config.showTabs
|
||||||
for ((key, value) in tabs) {
|
for ((key, value) in tabs) {
|
||||||
view.findViewById<MyAppCompatCheckbox>(value).isChecked = showTabs and key != 0
|
binding.root.findViewById<MyAppCompatCheckbox>(value).isChecked = showTabs and key != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.getAlertDialogBuilder()
|
activity.getAlertDialogBuilder()
|
||||||
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
.setPositiveButton(R.string.ok) { dialog, which -> dialogConfirmed() }
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this)
|
activity.setupDialogStuff(binding.root, this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun dialogConfirmed() {
|
private fun dialogConfirmed() {
|
||||||
var result = 0
|
var result = 0
|
||||||
for ((key, value) in tabs) {
|
for ((key, value) in tabs) {
|
||||||
if (view.findViewById<MyAppCompatCheckbox>(value).isChecked) {
|
if (binding.root.findViewById<MyAppCompatCheckbox>(value).isChecked) {
|
||||||
result += key
|
result += key
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
|||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
import kotlinx.android.synthetic.main.dialog_save_as.view.*
|
import com.simplemobiletools.filemanager.pro.databinding.DialogSaveAsBinding
|
||||||
|
|
||||||
class SaveAsDialog(
|
class SaveAsDialog(
|
||||||
val activity: BaseSimpleActivity, var path: String, val hidePath: Boolean,
|
val activity: BaseSimpleActivity, var path: String, val hidePath: Boolean,
|
||||||
@ -19,8 +19,8 @@ class SaveAsDialog(
|
|||||||
}
|
}
|
||||||
|
|
||||||
var realPath = path.getParentPath()
|
var realPath = path.getParentPath()
|
||||||
val view = activity.layoutInflater.inflate(R.layout.dialog_save_as, null).apply {
|
val binding = DialogSaveAsBinding.inflate(activity.layoutInflater).apply {
|
||||||
folder_value.setText(activity.humanizePath(realPath))
|
folderValue.setText(activity.humanizePath(realPath))
|
||||||
|
|
||||||
val fullName = path.getFilenameFromPath()
|
val fullName = path.getFilenameFromPath()
|
||||||
val dotAt = fullName.lastIndexOf(".")
|
val dotAt = fullName.lastIndexOf(".")
|
||||||
@ -29,17 +29,17 @@ class SaveAsDialog(
|
|||||||
if (dotAt > 0) {
|
if (dotAt > 0) {
|
||||||
name = fullName.substring(0, dotAt)
|
name = fullName.substring(0, dotAt)
|
||||||
val extension = fullName.substring(dotAt + 1)
|
val extension = fullName.substring(dotAt + 1)
|
||||||
extension_value.setText(extension)
|
extensionValue.setText(extension)
|
||||||
}
|
}
|
||||||
|
|
||||||
filename_value.setText(name)
|
filenameValue.setText(name)
|
||||||
|
|
||||||
if (hidePath) {
|
if (hidePath) {
|
||||||
folder_hint.beGone()
|
folderHint.beGone()
|
||||||
} else {
|
} else {
|
||||||
folder_value.setOnClickListener {
|
folderValue.setOnClickListener {
|
||||||
FilePickerDialog(activity, realPath, false, false, true, true, showFavoritesButton = true) {
|
FilePickerDialog(activity, realPath, false, false, true, true, showFavoritesButton = true) {
|
||||||
folder_value.setText(activity.humanizePath(it))
|
folderValue.setText(activity.humanizePath(it))
|
||||||
realPath = it
|
realPath = it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,11 +50,11 @@ class SaveAsDialog(
|
|||||||
.setPositiveButton(R.string.ok, null)
|
.setPositiveButton(R.string.ok, null)
|
||||||
.setNegativeButton(R.string.cancel, null)
|
.setNegativeButton(R.string.cancel, null)
|
||||||
.apply {
|
.apply {
|
||||||
activity.setupDialogStuff(view, this, R.string.save_as) { alertDialog ->
|
activity.setupDialogStuff(binding.root, this, R.string.save_as) { alertDialog ->
|
||||||
alertDialog.showKeyboard(view.filename_value)
|
alertDialog.showKeyboard(binding.filenameValue)
|
||||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener {
|
||||||
val filename = view.filename_value.value
|
val filename = binding.filenameValue.value
|
||||||
val extension = view.extension_value.value
|
val extension = binding.extensionValue.value
|
||||||
|
|
||||||
if (filename.isEmpty()) {
|
if (filename.isEmpty()) {
|
||||||
activity.toast(R.string.filename_cannot_be_empty)
|
activity.toast(R.string.filename_cannot_be_empty)
|
||||||
|
@ -17,6 +17,7 @@ import com.simplemobiletools.filemanager.pro.R
|
|||||||
import com.simplemobiletools.filemanager.pro.activities.MainActivity
|
import com.simplemobiletools.filemanager.pro.activities.MainActivity
|
||||||
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
|
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
|
||||||
import com.simplemobiletools.filemanager.pro.adapters.ItemsAdapter
|
import com.simplemobiletools.filemanager.pro.adapters.ItemsAdapter
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.ItemsFragmentBinding
|
||||||
import com.simplemobiletools.filemanager.pro.dialogs.CreateNewItemDialog
|
import com.simplemobiletools.filemanager.pro.dialogs.CreateNewItemDialog
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.isPathOnRoot
|
import com.simplemobiletools.filemanager.pro.extensions.isPathOnRoot
|
||||||
@ -24,10 +25,10 @@ import com.simplemobiletools.filemanager.pro.helpers.MAX_COLUMN_COUNT
|
|||||||
import com.simplemobiletools.filemanager.pro.helpers.RootHelpers
|
import com.simplemobiletools.filemanager.pro.helpers.RootHelpers
|
||||||
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
|
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
|
||||||
import com.simplemobiletools.filemanager.pro.models.ListItem
|
import com.simplemobiletools.filemanager.pro.models.ListItem
|
||||||
import kotlinx.android.synthetic.main.items_fragment.view.*
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), ItemOperationsListener,
|
class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment<MyViewPagerFragment.ItemsInnerBinding>(context, attributeSet),
|
||||||
|
ItemOperationsListener,
|
||||||
Breadcrumbs.BreadcrumbsListener {
|
Breadcrumbs.BreadcrumbsListener {
|
||||||
private var showHidden = false
|
private var showHidden = false
|
||||||
private var lastSearchedText = ""
|
private var lastSearchedText = ""
|
||||||
@ -36,17 +37,26 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
|
|
||||||
private var storedItems = ArrayList<ListItem>()
|
private var storedItems = ArrayList<ListItem>()
|
||||||
private var itemsIgnoringSearch = ArrayList<ListItem>()
|
private var itemsIgnoringSearch = ArrayList<ListItem>()
|
||||||
|
private lateinit var binding: ItemsFragmentBinding
|
||||||
|
|
||||||
|
override fun onFinishInflate() {
|
||||||
|
super.onFinishInflate()
|
||||||
|
binding = ItemsFragmentBinding.bind(this)
|
||||||
|
innerBinding = ItemsInnerBinding(binding)
|
||||||
|
}
|
||||||
|
|
||||||
override fun setupFragment(activity: SimpleActivity) {
|
override fun setupFragment(activity: SimpleActivity) {
|
||||||
if (this.activity == null) {
|
if (this.activity == null) {
|
||||||
this.activity = activity
|
this.activity = activity
|
||||||
breadcrumbs.listener = this@ItemsFragment
|
binding.apply {
|
||||||
items_swipe_refresh.setOnRefreshListener { refreshFragment() }
|
breadcrumbs.listener = this@ItemsFragment
|
||||||
items_fab.setOnClickListener {
|
itemsSwipeRefresh.setOnRefreshListener { refreshFragment() }
|
||||||
if (isCreateDocumentIntent) {
|
itemsFab.setOnClickListener {
|
||||||
(activity as MainActivity).createDocumentConfirmed(currentPath)
|
if (isCreateDocumentIntent) {
|
||||||
} else {
|
(activity as MainActivity).createDocumentConfirmed(currentPath)
|
||||||
createNewItem()
|
} else {
|
||||||
|
createNewItem()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,22 +70,24 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
initDrawables()
|
initDrawables()
|
||||||
}
|
}
|
||||||
|
|
||||||
val properPrimaryColor = context!!.getProperPrimaryColor()
|
binding.apply {
|
||||||
items_fastscroller.updateColors(properPrimaryColor)
|
val properPrimaryColor = context!!.getProperPrimaryColor()
|
||||||
progress_bar.setIndicatorColor(properPrimaryColor)
|
itemsFastscroller.updateColors(properPrimaryColor)
|
||||||
progress_bar.trackColor = properPrimaryColor.adjustAlpha(LOWER_ALPHA)
|
progressBar.setIndicatorColor(properPrimaryColor)
|
||||||
|
progressBar.trackColor = properPrimaryColor.adjustAlpha(LOWER_ALPHA)
|
||||||
|
|
||||||
if (currentPath != "") {
|
if (currentPath != "") {
|
||||||
breadcrumbs.updateColor(textColor)
|
breadcrumbs.updateColor(textColor)
|
||||||
|
}
|
||||||
|
|
||||||
|
itemsSwipeRefresh.isEnabled = lastSearchedText.isEmpty() && activity?.config?.enablePullToRefresh != false
|
||||||
}
|
}
|
||||||
|
|
||||||
items_swipe_refresh.isEnabled = lastSearchedText.isEmpty() && activity?.config?.enablePullToRefresh != false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setupFontSize() {
|
override fun setupFontSize() {
|
||||||
getRecyclerAdapter()?.updateFontSizes()
|
getRecyclerAdapter()?.updateFontSizes()
|
||||||
if (currentPath != "") {
|
if (currentPath != "") {
|
||||||
breadcrumbs.updateFontSize(context!!.getTextSize(), false)
|
binding.breadcrumbs.updateFontSize(context!!.getTextSize(), false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,18 +145,18 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
|
|
||||||
private fun addItems(items: ArrayList<ListItem>, forceRefresh: Boolean = false) {
|
private fun addItems(items: ArrayList<ListItem>, forceRefresh: Boolean = false) {
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
items_swipe_refresh?.isRefreshing = false
|
binding.itemsSwipeRefresh?.isRefreshing = false
|
||||||
breadcrumbs.setBreadcrumb(currentPath)
|
binding.breadcrumbs.setBreadcrumb(currentPath)
|
||||||
if (!forceRefresh && items.hashCode() == storedItems.hashCode()) {
|
if (!forceRefresh && items.hashCode() == storedItems.hashCode()) {
|
||||||
return@runOnUiThread
|
return@runOnUiThread
|
||||||
}
|
}
|
||||||
|
|
||||||
storedItems = items
|
storedItems = items
|
||||||
if (items_list.adapter == null) {
|
if (binding.itemsList.adapter == null) {
|
||||||
breadcrumbs.updateFontSize(context!!.getTextSize(), true)
|
binding.breadcrumbs.updateFontSize(context!!.getTextSize(), true)
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemsAdapter(activity as SimpleActivity, storedItems, this, items_list, isPickMultipleIntent, items_swipe_refresh) {
|
ItemsAdapter(activity as SimpleActivity, storedItems, this, binding.itemsList, isPickMultipleIntent, binding.itemsSwipeRefresh) {
|
||||||
if ((it as? ListItem)?.isSectionTitle == true) {
|
if ((it as? ListItem)?.isSectionTitle == true) {
|
||||||
openDirectory(it.mPath)
|
openDirectory(it.mPath)
|
||||||
searchClosed()
|
searchClosed()
|
||||||
@ -153,11 +165,11 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
}
|
}
|
||||||
}.apply {
|
}.apply {
|
||||||
setupZoomListener(zoomListener)
|
setupZoomListener(zoomListener)
|
||||||
items_list.adapter = this
|
binding.itemsList.adapter = this
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.areSystemAnimationsEnabled) {
|
if (context.areSystemAnimationsEnabled) {
|
||||||
items_list.scheduleLayoutAnimation()
|
binding.itemsList.scheduleLayoutAnimation()
|
||||||
}
|
}
|
||||||
|
|
||||||
getRecyclerLayoutManager().onRestoreInstanceState(scrollStates[currentPath])
|
getRecyclerLayoutManager().onRestoreInstanceState(scrollStates[currentPath])
|
||||||
@ -166,7 +178,7 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
|
|
||||||
private fun getScrollState() = getRecyclerLayoutManager().onSaveInstanceState()
|
private fun getScrollState() = getRecyclerLayoutManager().onSaveInstanceState()
|
||||||
|
|
||||||
private fun getRecyclerLayoutManager() = (items_list.layoutManager as MyGridLayoutManager)
|
private fun getRecyclerLayoutManager() = (binding.itemsList.layoutManager as MyGridLayoutManager)
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
private fun getItems(path: String, callback: (originalPath: String, items: ArrayList<ListItem>) -> Unit) {
|
private fun getItems(path: String, callback: (originalPath: String, items: ArrayList<ListItem>) -> Unit) {
|
||||||
@ -295,60 +307,64 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
items_swipe_refresh.isEnabled = text.isEmpty() && activity?.config?.enablePullToRefresh != false
|
binding.apply {
|
||||||
when {
|
itemsSwipeRefresh.isEnabled = text.isEmpty() && activity?.config?.enablePullToRefresh != false
|
||||||
text.isEmpty() -> {
|
when {
|
||||||
items_fastscroller.beVisible()
|
text.isEmpty() -> {
|
||||||
getRecyclerAdapter()?.updateItems(itemsIgnoringSearch)
|
itemsFastscroller.beVisible()
|
||||||
items_placeholder.beGone()
|
getRecyclerAdapter()?.updateItems(itemsIgnoringSearch)
|
||||||
items_placeholder_2.beGone()
|
itemsPlaceholder.beGone()
|
||||||
hideProgressBar()
|
itemsPlaceholder2.beGone()
|
||||||
}
|
hideProgressBar()
|
||||||
text.length == 1 -> {
|
}
|
||||||
items_fastscroller.beGone()
|
|
||||||
items_placeholder.beVisible()
|
|
||||||
items_placeholder_2.beVisible()
|
|
||||||
hideProgressBar()
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
showProgressBar()
|
|
||||||
ensureBackgroundThread {
|
|
||||||
val files = searchFiles(text, currentPath)
|
|
||||||
files.sortBy { it.getParentPath() }
|
|
||||||
|
|
||||||
if (lastSearchedText != text) {
|
text.length == 1 -> {
|
||||||
return@ensureBackgroundThread
|
itemsFastscroller.beGone()
|
||||||
}
|
itemsPlaceholder.beVisible()
|
||||||
|
itemsPlaceholder2.beVisible()
|
||||||
|
hideProgressBar()
|
||||||
|
}
|
||||||
|
|
||||||
val listItems = ArrayList<ListItem>()
|
else -> {
|
||||||
|
showProgressBar()
|
||||||
|
ensureBackgroundThread {
|
||||||
|
val files = searchFiles(text, currentPath)
|
||||||
|
files.sortBy { it.getParentPath() }
|
||||||
|
|
||||||
var previousParent = ""
|
if (lastSearchedText != text) {
|
||||||
files.forEach {
|
return@ensureBackgroundThread
|
||||||
val parent = it.mPath.getParentPath()
|
|
||||||
if (!it.isDirectory && parent != previousParent && context != null) {
|
|
||||||
val sectionTitle = ListItem(parent, context!!.humanizePath(parent), false, 0, 0, 0, true, false)
|
|
||||||
listItems.add(sectionTitle)
|
|
||||||
previousParent = parent
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it.isDirectory) {
|
val listItems = ArrayList<ListItem>()
|
||||||
val sectionTitle = ListItem(it.path, context!!.humanizePath(it.path), true, 0, 0, 0, true, false)
|
|
||||||
listItems.add(sectionTitle)
|
var previousParent = ""
|
||||||
previousParent = parent
|
files.forEach {
|
||||||
|
val parent = it.mPath.getParentPath()
|
||||||
|
if (!it.isDirectory && parent != previousParent && context != null) {
|
||||||
|
val sectionTitle = ListItem(parent, context!!.humanizePath(parent), false, 0, 0, 0, true, false)
|
||||||
|
listItems.add(sectionTitle)
|
||||||
|
previousParent = parent
|
||||||
|
}
|
||||||
|
|
||||||
|
if (it.isDirectory) {
|
||||||
|
val sectionTitle = ListItem(it.path, context!!.humanizePath(it.path), true, 0, 0, 0, true, false)
|
||||||
|
listItems.add(sectionTitle)
|
||||||
|
previousParent = parent
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!it.isDirectory) {
|
||||||
|
listItems.add(it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!it.isDirectory) {
|
activity?.runOnUiThread {
|
||||||
listItems.add(it)
|
getRecyclerAdapter()?.updateItems(listItems, text)
|
||||||
|
itemsFastscroller.beVisibleIf(listItems.isNotEmpty())
|
||||||
|
itemsPlaceholder.beVisibleIf(listItems.isEmpty())
|
||||||
|
itemsPlaceholder2.beGone()
|
||||||
|
hideProgressBar()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
activity?.runOnUiThread {
|
|
||||||
getRecyclerAdapter()?.updateItems(listItems, text)
|
|
||||||
items_fastscroller.beVisibleIf(listItems.isNotEmpty())
|
|
||||||
items_placeholder.beVisibleIf(listItems.isEmpty())
|
|
||||||
items_placeholder_2.beGone()
|
|
||||||
hideProgressBar()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -390,12 +406,14 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun searchClosed() {
|
private fun searchClosed() {
|
||||||
lastSearchedText = ""
|
binding.apply {
|
||||||
items_swipe_refresh.isEnabled = activity?.config?.enablePullToRefresh != false
|
lastSearchedText = ""
|
||||||
items_fastscroller.beVisible()
|
itemsSwipeRefresh.isEnabled = activity?.config?.enablePullToRefresh != false
|
||||||
items_placeholder.beGone()
|
itemsFastscroller.beVisible()
|
||||||
items_placeholder_2.beGone()
|
itemsPlaceholder.beGone()
|
||||||
hideProgressBar()
|
itemsPlaceholder2.beGone()
|
||||||
|
hideProgressBar()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createNewItem() {
|
private fun createNewItem() {
|
||||||
@ -408,7 +426,7 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getRecyclerAdapter() = items_list.adapter as? ItemsAdapter
|
private fun getRecyclerAdapter() = binding.itemsList.adapter as? ItemsAdapter
|
||||||
|
|
||||||
private fun setupLayoutManager() {
|
private fun setupLayoutManager() {
|
||||||
if (context!!.config.getFolderViewType(currentPath) == VIEW_TYPE_GRID) {
|
if (context!!.config.getFolderViewType(currentPath) == VIEW_TYPE_GRID) {
|
||||||
@ -419,13 +437,13 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
setupListLayoutManager()
|
setupListLayoutManager()
|
||||||
}
|
}
|
||||||
|
|
||||||
items_list.adapter = null
|
binding.itemsList.adapter = null
|
||||||
initZoomListener()
|
initZoomListener()
|
||||||
addItems(storedItems, true)
|
addItems(storedItems, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupGridLayoutManager() {
|
private fun setupGridLayoutManager() {
|
||||||
val layoutManager = items_list.layoutManager as MyGridLayoutManager
|
val layoutManager = binding.itemsList.layoutManager as MyGridLayoutManager
|
||||||
layoutManager.spanCount = context?.config?.fileColumnCnt ?: 3
|
layoutManager.spanCount = context?.config?.fileColumnCnt ?: 3
|
||||||
|
|
||||||
layoutManager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
|
layoutManager.spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
|
||||||
@ -440,14 +458,14 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setupListLayoutManager() {
|
private fun setupListLayoutManager() {
|
||||||
val layoutManager = items_list.layoutManager as MyGridLayoutManager
|
val layoutManager = binding.itemsList.layoutManager as MyGridLayoutManager
|
||||||
layoutManager.spanCount = 1
|
layoutManager.spanCount = 1
|
||||||
zoomListener = null
|
zoomListener = null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initZoomListener() {
|
private fun initZoomListener() {
|
||||||
if (context?.config?.getFolderViewType(currentPath) == VIEW_TYPE_GRID) {
|
if (context?.config?.getFolderViewType(currentPath) == VIEW_TYPE_GRID) {
|
||||||
val layoutManager = items_list.layoutManager as MyGridLayoutManager
|
val layoutManager = binding.itemsList.layoutManager as MyGridLayoutManager
|
||||||
zoomListener = object : MyRecyclerView.MyZoomListener {
|
zoomListener = object : MyRecyclerView.MyZoomListener {
|
||||||
override fun zoomIn() {
|
override fun zoomIn() {
|
||||||
if (layoutManager.spanCount > 1) {
|
if (layoutManager.spanCount > 1) {
|
||||||
@ -483,21 +501,23 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun columnCountChanged() {
|
override fun columnCountChanged() {
|
||||||
(items_list.layoutManager as MyGridLayoutManager).spanCount = context!!.config.fileColumnCnt
|
(binding.itemsList.layoutManager as MyGridLayoutManager).spanCount = context!!.config.fileColumnCnt
|
||||||
(activity as? MainActivity)?.refreshMenuItems()
|
(activity as? MainActivity)?.refreshMenuItems()
|
||||||
getRecyclerAdapter()?.apply {
|
getRecyclerAdapter()?.apply {
|
||||||
notifyItemRangeChanged(0, listItems.size)
|
notifyItemRangeChanged(0, listItems.size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showProgressBar() {
|
fun showProgressBar() {
|
||||||
progress_bar.show()
|
binding.progressBar.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hideProgressBar() {
|
private fun hideProgressBar() {
|
||||||
progress_bar.hide()
|
binding.progressBar.hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getBreadcrumbs() = binding.breadcrumbs
|
||||||
|
|
||||||
override fun toggleFilenameVisibility() {
|
override fun toggleFilenameVisibility() {
|
||||||
getRecyclerAdapter()?.updateDisplayFilenamesInGrid()
|
getRecyclerAdapter()?.updateDisplayFilenamesInGrid()
|
||||||
}
|
}
|
||||||
@ -509,7 +529,7 @@ class ItemsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerF
|
|||||||
openPath(it)
|
openPath(it)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val item = breadcrumbs.getItem(id)
|
val item = binding.breadcrumbs.getItem(id)
|
||||||
openPath(item.path)
|
openPath(item.path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,15 +6,19 @@ import android.widget.RelativeLayout
|
|||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
import com.simplemobiletools.commons.helpers.VIEW_TYPE_LIST
|
import com.simplemobiletools.commons.helpers.VIEW_TYPE_LIST
|
||||||
import com.simplemobiletools.commons.models.FileDirItem
|
import com.simplemobiletools.commons.models.FileDirItem
|
||||||
|
import com.simplemobiletools.commons.views.MyFloatingActionButton
|
||||||
import com.simplemobiletools.filemanager.pro.R
|
import com.simplemobiletools.filemanager.pro.R
|
||||||
import com.simplemobiletools.filemanager.pro.activities.MainActivity
|
import com.simplemobiletools.filemanager.pro.activities.MainActivity
|
||||||
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
|
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.ItemsFragmentBinding
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.RecentsFragmentBinding
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.StorageFragmentBinding
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.isPathOnRoot
|
import com.simplemobiletools.filemanager.pro.extensions.isPathOnRoot
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.tryOpenPathIntent
|
import com.simplemobiletools.filemanager.pro.extensions.tryOpenPathIntent
|
||||||
import com.simplemobiletools.filemanager.pro.helpers.RootHelpers
|
import com.simplemobiletools.filemanager.pro.helpers.RootHelpers
|
||||||
import kotlinx.android.synthetic.main.items_fragment.view.*
|
|
||||||
|
|
||||||
abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet) : RelativeLayout(context, attributeSet) {
|
abstract class MyViewPagerFragment<BINDING : MyViewPagerFragment.InnerBinding>(context: Context, attributeSet: AttributeSet) :
|
||||||
|
RelativeLayout(context, attributeSet) {
|
||||||
protected var activity: SimpleActivity? = null
|
protected var activity: SimpleActivity? = null
|
||||||
protected var currentViewType = VIEW_TYPE_LIST
|
protected var currentViewType = VIEW_TYPE_LIST
|
||||||
|
|
||||||
@ -24,6 +28,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
|||||||
var isPickMultipleIntent = false
|
var isPickMultipleIntent = false
|
||||||
var wantedMimeType = ""
|
var wantedMimeType = ""
|
||||||
protected var isCreateDocumentIntent = false
|
protected var isCreateDocumentIntent = false
|
||||||
|
protected lateinit var innerBinding: BINDING
|
||||||
|
|
||||||
protected fun clickedPath(path: String) {
|
protected fun clickedPath(path: String) {
|
||||||
if (isGetContentIntent || isCreateDocumentIntent) {
|
if (isGetContentIntent || isCreateDocumentIntent) {
|
||||||
@ -48,7 +53,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
|||||||
|
|
||||||
this.isCreateDocumentIntent = isCreateDocumentIntent
|
this.isCreateDocumentIntent = isCreateDocumentIntent
|
||||||
val fabIcon = context.resources.getColoredDrawableWithColor(iconId, context.getProperPrimaryColor().getContrastColor())
|
val fabIcon = context.resources.getColoredDrawableWithColor(iconId, context.getProperPrimaryColor().getContrastColor())
|
||||||
items_fab?.setImageDrawable(fabIcon)
|
innerBinding.itemsFab?.setImageDrawable(fabIcon)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun handleFileDeleting(files: ArrayList<FileDirItem>, hasFolder: Boolean) {
|
fun handleFileDeleting(files: ArrayList<FileDirItem>, hasFolder: Boolean) {
|
||||||
@ -90,4 +95,20 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
|||||||
abstract fun refreshFragment()
|
abstract fun refreshFragment()
|
||||||
|
|
||||||
abstract fun searchQueryChanged(text: String)
|
abstract fun searchQueryChanged(text: String)
|
||||||
|
|
||||||
|
interface InnerBinding {
|
||||||
|
val itemsFab: MyFloatingActionButton?
|
||||||
|
}
|
||||||
|
|
||||||
|
class ItemsInnerBinding(val binding: ItemsFragmentBinding) : InnerBinding {
|
||||||
|
override val itemsFab: MyFloatingActionButton = binding.itemsFab
|
||||||
|
}
|
||||||
|
|
||||||
|
class RecentsInnerBinding(val binding: RecentsFragmentBinding) : InnerBinding {
|
||||||
|
override val itemsFab: MyFloatingActionButton? = null
|
||||||
|
}
|
||||||
|
|
||||||
|
class StorageInnerBinding(val binding: StorageFragmentBinding) : InnerBinding {
|
||||||
|
override val itemsFab: MyFloatingActionButton? = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,25 +17,31 @@ import com.simplemobiletools.commons.views.MyRecyclerView
|
|||||||
import com.simplemobiletools.filemanager.pro.activities.MainActivity
|
import com.simplemobiletools.filemanager.pro.activities.MainActivity
|
||||||
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
|
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
|
||||||
import com.simplemobiletools.filemanager.pro.adapters.ItemsAdapter
|
import com.simplemobiletools.filemanager.pro.adapters.ItemsAdapter
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.RecentsFragmentBinding
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||||
import com.simplemobiletools.filemanager.pro.helpers.MAX_COLUMN_COUNT
|
import com.simplemobiletools.filemanager.pro.helpers.MAX_COLUMN_COUNT
|
||||||
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
|
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
|
||||||
import com.simplemobiletools.filemanager.pro.models.ListItem
|
import com.simplemobiletools.filemanager.pro.models.ListItem
|
||||||
import kotlinx.android.synthetic.main.recents_fragment.view.recents_list
|
|
||||||
import kotlinx.android.synthetic.main.recents_fragment.view.recents_placeholder
|
|
||||||
import kotlinx.android.synthetic.main.recents_fragment.view.recents_swipe_refresh
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), ItemOperationsListener {
|
class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment<MyViewPagerFragment.RecentsInnerBinding>(context, attributeSet),
|
||||||
|
ItemOperationsListener {
|
||||||
private val RECENTS_LIMIT = 50
|
private val RECENTS_LIMIT = 50
|
||||||
private var filesIgnoringSearch = ArrayList<ListItem>()
|
private var filesIgnoringSearch = ArrayList<ListItem>()
|
||||||
private var lastSearchedText = ""
|
private var lastSearchedText = ""
|
||||||
private var zoomListener: MyRecyclerView.MyZoomListener? = null
|
private var zoomListener: MyRecyclerView.MyZoomListener? = null
|
||||||
|
private lateinit var binding: RecentsFragmentBinding
|
||||||
|
|
||||||
|
override fun onFinishInflate() {
|
||||||
|
super.onFinishInflate()
|
||||||
|
binding = RecentsFragmentBinding.bind(this)
|
||||||
|
innerBinding = RecentsInnerBinding(binding)
|
||||||
|
}
|
||||||
|
|
||||||
override fun setupFragment(activity: SimpleActivity) {
|
override fun setupFragment(activity: SimpleActivity) {
|
||||||
if (this.activity == null) {
|
if (this.activity == null) {
|
||||||
this.activity = activity
|
this.activity = activity
|
||||||
recents_swipe_refresh.setOnRefreshListener { refreshFragment() }
|
binding.recentsSwipeRefresh.setOnRefreshListener { refreshFragment() }
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshFragment()
|
refreshFragment()
|
||||||
@ -44,9 +50,11 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||||||
override fun refreshFragment() {
|
override fun refreshFragment() {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
getRecents { recents ->
|
getRecents { recents ->
|
||||||
recents_swipe_refresh?.isRefreshing = false
|
binding.apply {
|
||||||
recents_list.beVisibleIf(recents.isNotEmpty())
|
recentsSwipeRefresh?.isRefreshing = false
|
||||||
recents_placeholder.beVisibleIf(recents.isEmpty())
|
recentsList.beVisibleIf(recents.isNotEmpty())
|
||||||
|
recentsPlaceholder.beVisibleIf(recents.isEmpty())
|
||||||
|
}
|
||||||
filesIgnoringSearch = recents
|
filesIgnoringSearch = recents
|
||||||
addItems(recents, false)
|
addItems(recents, false)
|
||||||
|
|
||||||
@ -58,24 +66,24 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun addItems(recents: ArrayList<ListItem>, forceRefresh: Boolean) {
|
private fun addItems(recents: ArrayList<ListItem>, forceRefresh: Boolean) {
|
||||||
if (!forceRefresh && recents.hashCode() == (recents_list.adapter as? ItemsAdapter)?.listItems.hashCode()) {
|
if (!forceRefresh && recents.hashCode() == (binding.recentsList.adapter as? ItemsAdapter)?.listItems.hashCode()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemsAdapter(activity as SimpleActivity, recents, this, recents_list, isPickMultipleIntent, recents_swipe_refresh, false) {
|
ItemsAdapter(activity as SimpleActivity, recents, this, binding.recentsList, isPickMultipleIntent, binding.recentsSwipeRefresh, false) {
|
||||||
clickedPath((it as FileDirItem).path)
|
clickedPath((it as FileDirItem).path)
|
||||||
}.apply {
|
}.apply {
|
||||||
setupZoomListener(zoomListener)
|
setupZoomListener(zoomListener)
|
||||||
recents_list.adapter = this
|
binding.recentsList.adapter = this
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.areSystemAnimationsEnabled) {
|
if (context.areSystemAnimationsEnabled) {
|
||||||
recents_list.scheduleLayoutAnimation()
|
binding.recentsList.scheduleLayoutAnimation()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onResume(textColor: Int) {
|
override fun onResume(textColor: Int) {
|
||||||
recents_placeholder.setTextColor(textColor)
|
binding.recentsPlaceholder.setTextColor(textColor)
|
||||||
|
|
||||||
getRecyclerAdapter()?.apply {
|
getRecyclerAdapter()?.apply {
|
||||||
updatePrimaryColor()
|
updatePrimaryColor()
|
||||||
@ -83,7 +91,7 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||||||
initDrawables()
|
initDrawables()
|
||||||
}
|
}
|
||||||
|
|
||||||
recents_swipe_refresh.isEnabled = lastSearchedText.isEmpty() && activity?.config?.enablePullToRefresh != false
|
binding.recentsSwipeRefresh.isEnabled = lastSearchedText.isEmpty() && activity?.config?.enablePullToRefresh != false
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupLayoutManager() {
|
private fun setupLayoutManager() {
|
||||||
@ -95,26 +103,26 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||||||
setupListLayoutManager()
|
setupListLayoutManager()
|
||||||
}
|
}
|
||||||
|
|
||||||
val oldItems = (recents_list.adapter as? ItemsAdapter)?.listItems?.toMutableList() as ArrayList<ListItem>
|
val oldItems = (binding.recentsList.adapter as? ItemsAdapter)?.listItems?.toMutableList() as ArrayList<ListItem>
|
||||||
recents_list.adapter = null
|
binding.recentsList.adapter = null
|
||||||
initZoomListener()
|
initZoomListener()
|
||||||
addItems(oldItems, true)
|
addItems(oldItems, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupGridLayoutManager() {
|
private fun setupGridLayoutManager() {
|
||||||
val layoutManager = recents_list.layoutManager as MyGridLayoutManager
|
val layoutManager = binding.recentsList.layoutManager as MyGridLayoutManager
|
||||||
layoutManager.spanCount = context?.config?.fileColumnCnt ?: 3
|
layoutManager.spanCount = context?.config?.fileColumnCnt ?: 3
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupListLayoutManager() {
|
private fun setupListLayoutManager() {
|
||||||
val layoutManager = recents_list.layoutManager as MyGridLayoutManager
|
val layoutManager = binding.recentsList.layoutManager as MyGridLayoutManager
|
||||||
layoutManager.spanCount = 1
|
layoutManager.spanCount = 1
|
||||||
zoomListener = null
|
zoomListener = null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initZoomListener() {
|
private fun initZoomListener() {
|
||||||
if (context?.config?.getFolderViewType("") == VIEW_TYPE_GRID) {
|
if (context?.config?.getFolderViewType("") == VIEW_TYPE_GRID) {
|
||||||
val layoutManager = recents_list.layoutManager as MyGridLayoutManager
|
val layoutManager = binding.recentsList.layoutManager as MyGridLayoutManager
|
||||||
zoomListener = object : MyRecyclerView.MyZoomListener {
|
zoomListener = object : MyRecyclerView.MyZoomListener {
|
||||||
override fun zoomIn() {
|
override fun zoomIn() {
|
||||||
if (layoutManager.spanCount > 1) {
|
if (layoutManager.spanCount > 1) {
|
||||||
@ -187,7 +195,7 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getRecyclerAdapter() = recents_list.adapter as? ItemsAdapter
|
private fun getRecyclerAdapter() = binding.recentsList.adapter as? ItemsAdapter
|
||||||
|
|
||||||
override fun toggleFilenameVisibility() {
|
override fun toggleFilenameVisibility() {
|
||||||
getRecyclerAdapter()?.updateDisplayFilenamesInGrid()
|
getRecyclerAdapter()?.updateDisplayFilenamesInGrid()
|
||||||
@ -208,7 +216,7 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun columnCountChanged() {
|
override fun columnCountChanged() {
|
||||||
(recents_list.layoutManager as MyGridLayoutManager).spanCount = context!!.config.fileColumnCnt
|
(binding.recentsList.layoutManager as MyGridLayoutManager).spanCount = context!!.config.fileColumnCnt
|
||||||
(activity as? MainActivity)?.refreshMenuItems()
|
(activity as? MainActivity)?.refreshMenuItems()
|
||||||
getRecyclerAdapter()?.apply {
|
getRecyclerAdapter()?.apply {
|
||||||
notifyItemRangeChanged(0, listItems.size)
|
notifyItemRangeChanged(0, listItems.size)
|
||||||
@ -234,9 +242,11 @@ class RecentsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||||||
override fun searchQueryChanged(text: String) {
|
override fun searchQueryChanged(text: String) {
|
||||||
lastSearchedText = text
|
lastSearchedText = text
|
||||||
val filtered = filesIgnoringSearch.filter { it.mName.contains(text, true) }.toMutableList() as ArrayList<ListItem>
|
val filtered = filesIgnoringSearch.filter { it.mName.contains(text, true) }.toMutableList() as ArrayList<ListItem>
|
||||||
(recents_list.adapter as? ItemsAdapter)?.updateItems(filtered, text)
|
binding.apply {
|
||||||
recents_placeholder.beVisibleIf(filtered.isEmpty())
|
(recentsList.adapter as? ItemsAdapter)?.updateItems(filtered, text)
|
||||||
recents_swipe_refresh.isEnabled = lastSearchedText.isEmpty() && activity?.config?.enablePullToRefresh != false
|
recentsPlaceholder.beVisibleIf(filtered.isEmpty())
|
||||||
|
recentsSwipeRefresh.isEnabled = lastSearchedText.isEmpty() && activity?.config?.enablePullToRefresh != false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun finishActMode() {
|
override fun finishActMode() {
|
||||||
|
@ -21,28 +21,36 @@ import com.simplemobiletools.filemanager.pro.R
|
|||||||
import com.simplemobiletools.filemanager.pro.activities.MimeTypesActivity
|
import com.simplemobiletools.filemanager.pro.activities.MimeTypesActivity
|
||||||
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
|
import com.simplemobiletools.filemanager.pro.activities.SimpleActivity
|
||||||
import com.simplemobiletools.filemanager.pro.adapters.ItemsAdapter
|
import com.simplemobiletools.filemanager.pro.adapters.ItemsAdapter
|
||||||
|
import com.simplemobiletools.filemanager.pro.databinding.StorageFragmentBinding
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.config
|
import com.simplemobiletools.filemanager.pro.extensions.config
|
||||||
import com.simplemobiletools.filemanager.pro.extensions.formatSizeThousand
|
import com.simplemobiletools.filemanager.pro.extensions.formatSizeThousand
|
||||||
import com.simplemobiletools.filemanager.pro.helpers.*
|
import com.simplemobiletools.filemanager.pro.helpers.*
|
||||||
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
|
import com.simplemobiletools.filemanager.pro.interfaces.ItemOperationsListener
|
||||||
import com.simplemobiletools.filemanager.pro.models.ListItem
|
import com.simplemobiletools.filemanager.pro.models.ListItem
|
||||||
import kotlinx.android.synthetic.main.storage_fragment.view.*
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet), ItemOperationsListener {
|
class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment<MyViewPagerFragment.StorageInnerBinding>(context, attributeSet),
|
||||||
|
ItemOperationsListener {
|
||||||
private val SIZE_DIVIDER = 100000
|
private val SIZE_DIVIDER = 100000
|
||||||
private var allDeviceListItems = ArrayList<ListItem>()
|
private var allDeviceListItems = ArrayList<ListItem>()
|
||||||
private var lastSearchedText = ""
|
private var lastSearchedText = ""
|
||||||
|
private lateinit var binding: StorageFragmentBinding
|
||||||
|
|
||||||
|
override fun onFinishInflate() {
|
||||||
|
super.onFinishInflate()
|
||||||
|
binding = StorageFragmentBinding.bind(this)
|
||||||
|
innerBinding = StorageInnerBinding(binding)
|
||||||
|
}
|
||||||
|
|
||||||
override fun setupFragment(activity: SimpleActivity) {
|
override fun setupFragment(activity: SimpleActivity) {
|
||||||
if (this.activity == null) {
|
if (this.activity == null) {
|
||||||
this.activity = activity
|
this.activity = activity
|
||||||
}
|
}
|
||||||
|
|
||||||
total_space.text = String.format(context.getString(R.string.total_storage), "…")
|
binding.totalSpace.text = String.format(context.getString(R.string.total_storage), "…")
|
||||||
getSizes()
|
getSizes()
|
||||||
|
|
||||||
free_space_holder.setOnClickListener {
|
binding.freeSpaceHolder.setOnClickListener {
|
||||||
try {
|
try {
|
||||||
val storageSettingsIntent = Intent(Settings.ACTION_INTERNAL_STORAGE_SETTINGS)
|
val storageSettingsIntent = Intent(Settings.ACTION_INTERNAL_STORAGE_SETTINGS)
|
||||||
activity.startActivity(storageSettingsIntent)
|
activity.startActivity(storageSettingsIntent)
|
||||||
@ -51,12 +59,14 @@ class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
images_holder.setOnClickListener { launchMimetypeActivity(IMAGES) }
|
binding.apply {
|
||||||
videos_holder.setOnClickListener { launchMimetypeActivity(VIDEOS) }
|
imagesHolder.setOnClickListener { launchMimetypeActivity(IMAGES) }
|
||||||
audio_holder.setOnClickListener { launchMimetypeActivity(AUDIO) }
|
videosHolder.setOnClickListener { launchMimetypeActivity(VIDEOS) }
|
||||||
documents_holder.setOnClickListener { launchMimetypeActivity(DOCUMENTS) }
|
audioHolder.setOnClickListener { launchMimetypeActivity(AUDIO) }
|
||||||
archives_holder.setOnClickListener { launchMimetypeActivity(ARCHIVES) }
|
documentsHolder.setOnClickListener { launchMimetypeActivity(DOCUMENTS) }
|
||||||
others_holder.setOnClickListener { launchMimetypeActivity(OTHERS) }
|
archivesHolder.setOnClickListener { launchMimetypeActivity(ARCHIVES) }
|
||||||
|
othersHolder.setOnClickListener { launchMimetypeActivity(OTHERS) }
|
||||||
|
}
|
||||||
|
|
||||||
Handler().postDelayed({
|
Handler().postDelayed({
|
||||||
refreshFragment()
|
refreshFragment()
|
||||||
@ -65,39 +75,42 @@ class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||||||
|
|
||||||
override fun onResume(textColor: Int) {
|
override fun onResume(textColor: Int) {
|
||||||
getSizes()
|
getSizes()
|
||||||
context.updateTextColors(storage_fragment)
|
context.updateTextColors(binding.root)
|
||||||
|
|
||||||
val properPrimaryColor = context.getProperPrimaryColor()
|
binding.apply {
|
||||||
main_storage_usage_progressbar.setIndicatorColor(properPrimaryColor)
|
val properPrimaryColor = context.getProperPrimaryColor()
|
||||||
main_storage_usage_progressbar.trackColor = properPrimaryColor.adjustAlpha(LOWER_ALPHA)
|
mainStorageUsageProgressbar.setIndicatorColor(properPrimaryColor)
|
||||||
|
mainStorageUsageProgressbar.trackColor = properPrimaryColor.adjustAlpha(LOWER_ALPHA)
|
||||||
|
|
||||||
val redColor = context.resources.getColor(R.color.md_red_700)
|
val redColor = context.resources.getColor(R.color.md_red_700)
|
||||||
images_progressbar.setIndicatorColor(redColor)
|
imagesProgressbar.setIndicatorColor(redColor)
|
||||||
images_progressbar.trackColor = redColor.adjustAlpha(LOWER_ALPHA)
|
imagesProgressbar.trackColor = redColor.adjustAlpha(LOWER_ALPHA)
|
||||||
|
|
||||||
val greenColor = context.resources.getColor(R.color.md_green_700)
|
val greenColor = context.resources.getColor(R.color.md_green_700)
|
||||||
videos_progressbar.setIndicatorColor(greenColor)
|
videosProgressbar.setIndicatorColor(greenColor)
|
||||||
videos_progressbar.trackColor = greenColor.adjustAlpha(LOWER_ALPHA)
|
videosProgressbar.trackColor = greenColor.adjustAlpha(LOWER_ALPHA)
|
||||||
|
|
||||||
val lightBlueColor = context.resources.getColor(R.color.md_light_blue_700)
|
val lightBlueColor = context.resources.getColor(R.color.md_light_blue_700)
|
||||||
audio_progressbar.setIndicatorColor(lightBlueColor)
|
audioProgressbar.setIndicatorColor(lightBlueColor)
|
||||||
audio_progressbar.trackColor = lightBlueColor.adjustAlpha(LOWER_ALPHA)
|
audioProgressbar.trackColor = lightBlueColor.adjustAlpha(LOWER_ALPHA)
|
||||||
|
|
||||||
val yellowColor = context.resources.getColor(R.color.md_yellow_700)
|
val yellowColor = context.resources.getColor(R.color.md_yellow_700)
|
||||||
documents_progressbar.setIndicatorColor(yellowColor)
|
documentsProgressbar.setIndicatorColor(yellowColor)
|
||||||
documents_progressbar.trackColor = yellowColor.adjustAlpha(LOWER_ALPHA)
|
documentsProgressbar.trackColor = yellowColor.adjustAlpha(LOWER_ALPHA)
|
||||||
|
|
||||||
val tealColor = context.resources.getColor(R.color.md_teal_700)
|
val tealColor = context.resources.getColor(R.color.md_teal_700)
|
||||||
archives_progressbar.setIndicatorColor(tealColor)
|
archivesProgressbar.setIndicatorColor(tealColor)
|
||||||
archives_progressbar.trackColor = tealColor.adjustAlpha(LOWER_ALPHA)
|
archivesProgressbar.trackColor = tealColor.adjustAlpha(LOWER_ALPHA)
|
||||||
|
|
||||||
val pinkColor = context.resources.getColor(R.color.md_pink_700)
|
val pinkColor = context.resources.getColor(R.color.md_pink_700)
|
||||||
others_progressbar.setIndicatorColor(pinkColor)
|
othersProgressbar.setIndicatorColor(pinkColor)
|
||||||
others_progressbar.trackColor = pinkColor.adjustAlpha(LOWER_ALPHA)
|
othersProgressbar.trackColor = pinkColor.adjustAlpha(LOWER_ALPHA)
|
||||||
|
|
||||||
|
searchHolder.setBackgroundColor(context.getProperBackgroundColor())
|
||||||
|
progressBar.setIndicatorColor(properPrimaryColor)
|
||||||
|
progressBar.trackColor = properPrimaryColor.adjustAlpha(LOWER_ALPHA)
|
||||||
|
}
|
||||||
|
|
||||||
search_holder.setBackgroundColor(context.getProperBackgroundColor())
|
|
||||||
progress_bar.setIndicatorColor(properPrimaryColor)
|
|
||||||
progress_bar.trackColor = properPrimaryColor.adjustAlpha(LOWER_ALPHA)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun launchMimetypeActivity(mimetype: String) {
|
private fun launchMimetypeActivity(mimetype: String) {
|
||||||
@ -116,31 +129,33 @@ class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||||||
getMainStorageStats(context)
|
getMainStorageStats(context)
|
||||||
|
|
||||||
val filesSize = getSizesByMimeType()
|
val filesSize = getSizesByMimeType()
|
||||||
val imagesSize = filesSize[IMAGES]!!
|
val fileSizeImages = filesSize[IMAGES]!!
|
||||||
val videosSize = filesSize[VIDEOS]!!
|
val fileSizeVideos = filesSize[VIDEOS]!!
|
||||||
val audioSize = filesSize[AUDIO]!!
|
val fileSizeAudios = filesSize[AUDIO]!!
|
||||||
val documentsSize = filesSize[DOCUMENTS]!!
|
val fileSizeDocuments = filesSize[DOCUMENTS]!!
|
||||||
val archivesSize = filesSize[ARCHIVES]!!
|
val fileSizeArchives = filesSize[ARCHIVES]!!
|
||||||
val othersSize = filesSize[OTHERS]!!
|
val fileSizeOthers = filesSize[OTHERS]!!
|
||||||
|
|
||||||
post {
|
post {
|
||||||
images_size.text = imagesSize.formatSize()
|
binding.apply {
|
||||||
images_progressbar.progress = (imagesSize / SIZE_DIVIDER).toInt()
|
imagesSize.text = fileSizeImages.formatSize()
|
||||||
|
imagesProgressbar.progress = (fileSizeImages / SIZE_DIVIDER).toInt()
|
||||||
|
|
||||||
videos_size.text = videosSize.formatSize()
|
videosSize.text = fileSizeVideos.formatSize()
|
||||||
videos_progressbar.progress = (videosSize / SIZE_DIVIDER).toInt()
|
videosProgressbar.progress = (fileSizeVideos / SIZE_DIVIDER).toInt()
|
||||||
|
|
||||||
audio_size.text = audioSize.formatSize()
|
audioSize.text = fileSizeAudios.formatSize()
|
||||||
audio_progressbar.progress = (audioSize / SIZE_DIVIDER).toInt()
|
audioProgressbar.progress = (fileSizeAudios / SIZE_DIVIDER).toInt()
|
||||||
|
|
||||||
documents_size.text = documentsSize.formatSize()
|
documentsSize.text = fileSizeDocuments.formatSize()
|
||||||
documents_progressbar.progress = (documentsSize / SIZE_DIVIDER).toInt()
|
documentsProgressbar.progress = (fileSizeDocuments / SIZE_DIVIDER).toInt()
|
||||||
|
|
||||||
archives_size.text = archivesSize.formatSize()
|
archivesSize.text = fileSizeArchives.formatSize()
|
||||||
archives_progressbar.progress = (archivesSize / SIZE_DIVIDER).toInt()
|
archivesProgressbar.progress = (fileSizeArchives / SIZE_DIVIDER).toInt()
|
||||||
|
|
||||||
others_size.text = othersSize.formatSize()
|
othersSize.text = fileSizeOthers.formatSize()
|
||||||
others_progressbar.progress = (othersSize / SIZE_DIVIDER).toInt()
|
othersProgressbar.progress = (fileSizeOthers / SIZE_DIVIDER).toInt()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -217,23 +232,25 @@ class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||||||
// internal storage
|
// internal storage
|
||||||
val storageStatsManager = context.getSystemService(AppCompatActivity.STORAGE_STATS_SERVICE) as StorageStatsManager
|
val storageStatsManager = context.getSystemService(AppCompatActivity.STORAGE_STATS_SERVICE) as StorageStatsManager
|
||||||
val uuid = StorageManager.UUID_DEFAULT
|
val uuid = StorageManager.UUID_DEFAULT
|
||||||
val totalSpace = storageStatsManager.getTotalBytes(uuid)
|
val totalStorageSpace = storageStatsManager.getTotalBytes(uuid)
|
||||||
val freeSpace = storageStatsManager.getFreeBytes(uuid)
|
val freeStorageSpace = storageStatsManager.getFreeBytes(uuid)
|
||||||
|
|
||||||
post {
|
post {
|
||||||
arrayOf(
|
binding.apply {
|
||||||
main_storage_usage_progressbar, images_progressbar, videos_progressbar, audio_progressbar, documents_progressbar,
|
arrayOf(
|
||||||
archives_progressbar, others_progressbar
|
mainStorageUsageProgressbar, imagesProgressbar, videosProgressbar, audioProgressbar, documentsProgressbar,
|
||||||
).forEach {
|
archivesProgressbar, othersProgressbar
|
||||||
it.max = (totalSpace / SIZE_DIVIDER).toInt()
|
).forEach {
|
||||||
|
it.max = (totalStorageSpace / SIZE_DIVIDER).toInt()
|
||||||
|
}
|
||||||
|
|
||||||
|
mainStorageUsageProgressbar.progress = ((totalStorageSpace - freeStorageSpace) / SIZE_DIVIDER).toInt()
|
||||||
|
|
||||||
|
mainStorageUsageProgressbar.beVisible()
|
||||||
|
freeSpaceValue.text = freeStorageSpace.formatSizeThousand()
|
||||||
|
totalSpace.text = String.format(context.getString(R.string.total_storage), totalStorageSpace.formatSizeThousand())
|
||||||
|
freeSpaceLabel.beVisible()
|
||||||
}
|
}
|
||||||
|
|
||||||
main_storage_usage_progressbar.progress = ((totalSpace - freeSpace) / SIZE_DIVIDER).toInt()
|
|
||||||
|
|
||||||
main_storage_usage_progressbar.beVisible()
|
|
||||||
free_space_value.text = freeSpace.formatSizeThousand()
|
|
||||||
total_space.text = String.format(context.getString(R.string.total_storage), totalSpace.formatSizeThousand())
|
|
||||||
free_space_label.beVisible()
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// sd card
|
// sd card
|
||||||
@ -245,41 +262,42 @@ class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||||||
|
|
||||||
override fun searchQueryChanged(text: String) {
|
override fun searchQueryChanged(text: String) {
|
||||||
lastSearchedText = text
|
lastSearchedText = text
|
||||||
|
binding.apply {
|
||||||
if (text.isNotEmpty()) {
|
if (text.isNotEmpty()) {
|
||||||
if (search_holder.alpha < 1f) {
|
if (searchHolder.alpha < 1f) {
|
||||||
search_holder.fadeIn()
|
searchHolder.fadeIn()
|
||||||
}
|
|
||||||
} else {
|
|
||||||
search_holder.animate().alpha(0f).setDuration(SHORT_ANIMATION_DURATION).withEndAction {
|
|
||||||
search_holder.beGone()
|
|
||||||
(search_results_list.adapter as? ItemsAdapter)?.updateItems(allDeviceListItems, text)
|
|
||||||
}.start()
|
|
||||||
}
|
|
||||||
|
|
||||||
if (text.length == 1) {
|
|
||||||
search_results_list.beGone()
|
|
||||||
search_placeholder.beVisible()
|
|
||||||
search_placeholder_2.beVisible()
|
|
||||||
hideProgressBar()
|
|
||||||
} else if (text.isEmpty()) {
|
|
||||||
search_results_list.beGone()
|
|
||||||
hideProgressBar()
|
|
||||||
} else {
|
|
||||||
showProgressBar()
|
|
||||||
ensureBackgroundThread {
|
|
||||||
val start = System.currentTimeMillis()
|
|
||||||
val filtered = allDeviceListItems.filter { it.mName.contains(text, true) }.toMutableList() as ArrayList<ListItem>
|
|
||||||
if (lastSearchedText != text) {
|
|
||||||
return@ensureBackgroundThread
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
searchHolder.animate().alpha(0f).setDuration(SHORT_ANIMATION_DURATION).withEndAction {
|
||||||
|
searchHolder.beGone()
|
||||||
|
(searchResultsList.adapter as? ItemsAdapter)?.updateItems(allDeviceListItems, text)
|
||||||
|
}.start()
|
||||||
|
}
|
||||||
|
|
||||||
(context as? Activity)?.runOnUiThread {
|
if (text.length == 1) {
|
||||||
(search_results_list.adapter as? ItemsAdapter)?.updateItems(filtered, text)
|
searchResultsList.beGone()
|
||||||
search_results_list.beVisible()
|
searchPlaceholder.beVisible()
|
||||||
search_placeholder.beVisibleIf(filtered.isEmpty())
|
searchPlaceholder2.beVisible()
|
||||||
search_placeholder_2.beGone()
|
hideProgressBar()
|
||||||
hideProgressBar()
|
} else if (text.isEmpty()) {
|
||||||
|
searchResultsList.beGone()
|
||||||
|
hideProgressBar()
|
||||||
|
} else {
|
||||||
|
showProgressBar()
|
||||||
|
ensureBackgroundThread {
|
||||||
|
val start = System.currentTimeMillis()
|
||||||
|
val filtered = allDeviceListItems.filter { it.mName.contains(text, true) }.toMutableList() as ArrayList<ListItem>
|
||||||
|
if (lastSearchedText != text) {
|
||||||
|
return@ensureBackgroundThread
|
||||||
|
}
|
||||||
|
|
||||||
|
(context as? Activity)?.runOnUiThread {
|
||||||
|
(searchResultsList.adapter as? ItemsAdapter)?.updateItems(filtered, text)
|
||||||
|
searchResultsList.beVisible()
|
||||||
|
searchPlaceholder.beVisibleIf(filtered.isEmpty())
|
||||||
|
searchPlaceholder2.beGone()
|
||||||
|
hideProgressBar()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -294,25 +312,25 @@ class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||||||
setupListLayoutManager()
|
setupListLayoutManager()
|
||||||
}
|
}
|
||||||
|
|
||||||
search_results_list.adapter = null
|
binding.searchResultsList.adapter = null
|
||||||
addItems()
|
addItems()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupGridLayoutManager() {
|
private fun setupGridLayoutManager() {
|
||||||
val layoutManager = search_results_list.layoutManager as MyGridLayoutManager
|
val layoutManager = binding.searchResultsList.layoutManager as MyGridLayoutManager
|
||||||
layoutManager.spanCount = context?.config?.fileColumnCnt ?: 3
|
layoutManager.spanCount = context?.config?.fileColumnCnt ?: 3
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupListLayoutManager() {
|
private fun setupListLayoutManager() {
|
||||||
val layoutManager = search_results_list.layoutManager as MyGridLayoutManager
|
val layoutManager = binding.searchResultsList.layoutManager as MyGridLayoutManager
|
||||||
layoutManager.spanCount = 1
|
layoutManager.spanCount = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addItems() {
|
private fun addItems() {
|
||||||
ItemsAdapter(context as SimpleActivity, ArrayList(), this, search_results_list, false, null, false) {
|
ItemsAdapter(context as SimpleActivity, ArrayList(), this, binding.searchResultsList, false, null, false) {
|
||||||
clickedPath((it as FileDirItem).path)
|
clickedPath((it as FileDirItem).path)
|
||||||
}.apply {
|
}.apply {
|
||||||
search_results_list.adapter = this
|
binding.searchResultsList.adapter = this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,14 +385,14 @@ class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun showProgressBar() {
|
private fun showProgressBar() {
|
||||||
progress_bar.show()
|
binding.progressBar.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hideProgressBar() {
|
private fun hideProgressBar() {
|
||||||
progress_bar.hide()
|
binding.progressBar.hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getRecyclerAdapter() = search_results_list.adapter as? ItemsAdapter
|
private fun getRecyclerAdapter() = binding.searchResultsList.adapter as? ItemsAdapter
|
||||||
|
|
||||||
override fun refreshFragment() {
|
override fun refreshFragment() {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
@ -403,7 +421,7 @@ class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun columnCountChanged() {
|
override fun columnCountChanged() {
|
||||||
(search_results_list.layoutManager as MyGridLayoutManager).spanCount = context!!.config.fileColumnCnt
|
(binding.searchResultsList.layoutManager as MyGridLayoutManager).spanCount = context!!.config.fileColumnCnt
|
||||||
getRecyclerAdapter()?.apply {
|
getRecyclerAdapter()?.apply {
|
||||||
notifyItemRangeChanged(0, listItems.size)
|
notifyItemRangeChanged(0, listItems.size)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.7.10'
|
ext.kotlin_version = '1.9.0'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
@ -9,7 +9,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:7.3.1'
|
classpath 'com.android.tools.build:gradle:8.1.0'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
@ -10,8 +10,9 @@
|
|||||||
# Specifies the JVM arguments used for the daemon process.
|
# Specifies the JVM arguments used for the daemon process.
|
||||||
# The setting is particularly useful for tweaking memory settings.
|
# The setting is particularly useful for tweaking memory settings.
|
||||||
android.enableJetifier=true
|
android.enableJetifier=true
|
||||||
|
android.nonTransitiveRClass=false
|
||||||
android.useAndroidX=true
|
android.useAndroidX=true
|
||||||
org.gradle.jvmargs=-Xmx1536m
|
org.gradle.jvmargs=-Xmx4g
|
||||||
|
|
||||||
# When configured, Gradle will run in incubating parallel mode.
|
# When configured, Gradle will run in incubating parallel mode.
|
||||||
# This option should only be used with decoupled projects. More details, visit
|
# This option should only be used with decoupled projects. More details, visit
|
||||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
|
||||||
|
Reference in New Issue
Block a user