Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Fixed folders showing up incorrectly as files in copy/move dialog ([#267])
- Fixed error when saving files with unsupported characters ([#250])
- Fixed File manager does not ask for file access permission if opened for the first time via "share" dialog ([#85])
Comment thread
jguegel marked this conversation as resolved.
Outdated

## [1.2.3] - 2025-09-15
### Fixed
Expand Down Expand Up @@ -76,6 +77,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[#251]: https://github.com/FossifyOrg/File-Manager/issues/251
[#267]: https://github.com/FossifyOrg/File-Manager/issues/267
[#250]: https://github.com/FossifyOrg/File-Manager/issues/250
[#85]: https://github.com/FossifyOrg/File-Manager/issues/85

[Unreleased]: https://github.com/FossifyOrg/File-Manager/compare/1.2.3...HEAD
[1.2.3]: https://github.com/FossifyOrg/File-Manager/compare/1.2.2...1.2.3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
package org.fossify.filemanager.activities

import android.annotation.SuppressLint
import android.app.Activity
import android.content.ClipData
import android.content.Intent
import android.graphics.drawable.Drawable
import android.media.RingtoneManager
import android.net.Uri
import android.os.Bundle
import android.os.Environment
import android.os.Handler
import android.provider.Settings
import android.widget.ImageView
import android.widget.TextView
import androidx.viewpager.widget.ViewPager
import com.stericson.RootTools.RootTools
import me.grantland.widget.AutofitHelper
import org.fossify.commons.dialogs.ConfirmationAdvancedDialog
import org.fossify.commons.dialogs.RadioGroupDialog
import org.fossify.commons.extensions.appLaunched
import org.fossify.commons.extensions.appLockManager
Expand All @@ -43,7 +38,6 @@ import org.fossify.commons.extensions.launchMoreAppsFromUsIntent
import org.fossify.commons.extensions.onGlobalLayout
import org.fossify.commons.extensions.onTabSelectionChanged
import org.fossify.commons.extensions.sdCardPath
import org.fossify.commons.extensions.showErrorToast
import org.fossify.commons.extensions.toast
import org.fossify.commons.extensions.updateBottomTabItemColors
import org.fossify.commons.extensions.viewBinding
Expand All @@ -59,7 +53,6 @@ import org.fossify.commons.helpers.TAB_RECENT_FILES
import org.fossify.commons.helpers.TAB_STORAGE_ANALYSIS
import org.fossify.commons.helpers.VIEW_TYPE_GRID
import org.fossify.commons.helpers.ensureBackgroundThread
import org.fossify.commons.helpers.isRPlus
import org.fossify.commons.models.FAQItem
import org.fossify.commons.models.RadioItem
import org.fossify.commons.models.Release
Expand All @@ -84,7 +77,6 @@ import java.io.File
class MainActivity : SimpleActivity() {
companion object {
private const val BACK_PRESS_TIMEOUT = 5000
private const val MANAGE_STORAGE_RC = 201
private const val PICKED_PATH = "picked_path"
}

Expand Down Expand Up @@ -281,15 +273,6 @@ class MainActivity : SimpleActivity() {
}
}

@SuppressLint("NewApi")
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
super.onActivityResult(requestCode, resultCode, resultData)
isAskingPermissions = false
if (requestCode == MANAGE_STORAGE_RC && isRPlus()) {
actionOnPermission?.invoke(Environment.isExternalStorageManager())
}
}

private fun updateMenuColors() {
updateStatusbarColor(getProperBackgroundColor())
binding.mainMenu.updateColors()
Expand Down Expand Up @@ -323,39 +306,7 @@ class MainActivity : SimpleActivity() {
}
}

@SuppressLint("InlinedApi")
private fun handleStoragePermission(callback: (granted: Boolean) -> Unit) {
actionOnPermission = null
if (hasStoragePermission()) {
callback(true)
} else {
if (isRPlus()) {
ConfirmationAdvancedDialog(this, "", R.string.access_storage_prompt, R.string.ok, 0, false) { success ->
if (success) {
isAskingPermissions = true
actionOnPermission = callback
try {
val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION)
intent.addCategory("android.intent.category.DEFAULT")
intent.data = Uri.parse("package:$packageName")
startActivityForResult(intent, MANAGE_STORAGE_RC)
} catch (e: Exception) {
showErrorToast(e)
val intent = Intent()
intent.action = Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION
startActivityForResult(intent, MANAGE_STORAGE_RC)
}
} else {
finish()
}
}
} else {
handlePermission(PERMISSION_WRITE_STORAGE, callback)
}
}
}

private fun initFileManager(refreshRecents: Boolean) {
private fun initFileManager(refreshRecents: Boolean) {
if (intent.action == Intent.ACTION_VIEW && intent.data != null) {
val data = intent.data
if (data?.scheme == "file") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,24 @@ import java.io.File
class SaveAsActivity : SimpleActivity() {
private val binding by viewBinding(ActivitySaveAsBinding::inflate)

override fun onCreate(savedInstanceState: Bundle?) {

Comment thread
jguegel marked this conversation as resolved.
Outdated
override fun onCreate(savedInstanceState: Bundle?) {
Comment thread
jguegel marked this conversation as resolved.
Outdated
super.onCreate(savedInstanceState)
setContentView(binding.root)
tryInitFileManager()
}

Comment thread
jguegel marked this conversation as resolved.
private fun tryInitFileManager() {
handleStoragePermission { granted ->
if (granted) {
saveAsDialog()
} else {
toast(R.string.no_storage_permissions)
finish()
}
}
}
private fun saveAsDialog() {
Comment thread
jguegel marked this conversation as resolved.
if (intent.action == Intent.ACTION_SEND && intent.extras?.containsKey(Intent.EXTRA_STREAM) == true) {
FilePickerDialog(this, pickFile = false, showHidden = config.shouldShowHidden(), showFAB = true, showFavoritesButton = true) {
val destination = it
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
package org.fossify.filemanager.activities

import android.annotation.SuppressLint
import android.content.Intent
import android.os.Environment
import android.provider.Settings
import org.fossify.commons.activities.BaseSimpleActivity
import org.fossify.commons.dialogs.ConfirmationAdvancedDialog
import org.fossify.commons.extensions.hasPermission
import android.net.Uri
import org.fossify.commons.extensions.showErrorToast
import org.fossify.commons.extensions.toast
import org.fossify.commons.helpers.PERMISSION_WRITE_STORAGE
import org.fossify.commons.helpers.isRPlus
import org.fossify.filemanager.R
Expand Down Expand Up @@ -31,10 +37,28 @@ open class SimpleActivity : BaseSimpleActivity() {
R.mipmap.ic_launcher_grey_black
)

companion object {
private const val MANAGE_STORAGE_RC = 201
}

override fun getAppLauncherName() = getString(R.string.app_launcher_name)

override fun getRepositoryName() = "File-Manager"

@SuppressLint("NewApi")
override fun onActivityResult(requestCode: Int, resultCode: Int, dataIntent: Intent?) {
super.onActivityResult(requestCode, resultCode, dataIntent)

if (requestCode == MANAGE_STORAGE_RC && isRPlus()) {
if (Environment.isExternalStorageManager()) {
recreate()
} else {
toast(R.string.no_storage_permissions)
finish()
}
}
}

Comment thread
jguegel marked this conversation as resolved.
Outdated
@SuppressLint("NewApi")
fun hasStoragePermission(): Boolean {
return if (isRPlus()) {
Expand All @@ -43,4 +67,39 @@ open class SimpleActivity : BaseSimpleActivity() {
hasPermission(PERMISSION_WRITE_STORAGE)
}
}

@SuppressLint("InlinedApi")
fun handleStoragePermission(callback: (granted: Boolean) -> Unit) {
actionOnPermission = null
if (hasStoragePermission()) {
callback(true)
} else {
if (isRPlus()) {
ConfirmationAdvancedDialog(this, "", R.string.access_storage_prompt, R.string.ok, 0, false) { success ->
if (success) {
isAskingPermissions = true
actionOnPermission = callback
try {
val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION)
intent.addCategory("android.intent.category.DEFAULT")
intent.data = Uri.parse("package:$packageName")
startActivityForResult(intent, MANAGE_STORAGE_RC)
} catch (e: android.content.ActivityNotFoundException) {
showErrorToast(e)
val intent = Intent()
intent.action = Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION
startActivityForResult(intent, MANAGE_STORAGE_RC)
} catch (e: SecurityException) {
showErrorToast(e)
finish()
}
} else {
finish()
}
}
} else {
handlePermission(PERMISSION_WRITE_STORAGE, callback)
}
}
}
}
Loading