Bug Fixes
This commit is contained in:
parent
bc00740f5b
commit
bfe7e88578
@ -43,4 +43,5 @@ dependencies {
|
|||||||
implementation 'androidx.preference:preference:1.1.1'
|
implementation 'androidx.preference:preference:1.1.1'
|
||||||
implementation 'com.github.clans:fab:1.6.4'
|
implementation 'com.github.clans:fab:1.6.4'
|
||||||
implementation 'com.jaredrummler:cyanea:1.0.2'
|
implementation 'com.jaredrummler:cyanea:1.0.2'
|
||||||
|
implementation 'com.github.bumptech.glide:glide:4.11.0'
|
||||||
}
|
}
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
package sushi.hardcore.droidfs
|
|
||||||
|
|
||||||
import android.widget.ImageView
|
|
||||||
|
|
||||||
class ColorEngine(val themeColor: Int) {
|
|
||||||
fun applyTo(imageView: ImageView){
|
|
||||||
imageView.setColorFilter(themeColor)
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,6 +3,7 @@ package sushi.hardcore.droidfs
|
|||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import com.jaredrummler.cyanea.app.CyaneaAppCompatActivity
|
import com.jaredrummler.cyanea.app.CyaneaAppCompatActivity
|
||||||
@ -13,12 +14,9 @@ open class ColoredActivity: CyaneaAppCompatActivity() {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this)
|
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
if (!sharedPrefs.getBoolean("usf_screenshot", false)){
|
|
||||||
window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE)
|
|
||||||
}
|
|
||||||
val themeColor = ThemeColor.getThemeColor(this)
|
val themeColor = ThemeColor.getThemeColor(this)
|
||||||
val backgroundColor = ContextCompat.getColor(this, R.color.backgroundColor)
|
|
||||||
if (cyanea.accent != themeColor){
|
if (cyanea.accent != themeColor){
|
||||||
|
val backgroundColor = ContextCompat.getColor(this, R.color.backgroundColor)
|
||||||
cyanea.edit{
|
cyanea.edit{
|
||||||
accent(themeColor)
|
accent(themeColor)
|
||||||
//accentDark(themeColor)
|
//accentDark(themeColor)
|
||||||
|
@ -5,6 +5,7 @@ import android.content.Intent
|
|||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.view.WindowManager
|
||||||
import android.widget.AdapterView.OnItemClickListener
|
import android.widget.AdapterView.OnItemClickListener
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import kotlinx.android.synthetic.main.activity_change_password.*
|
import kotlinx.android.synthetic.main.activity_change_password.*
|
||||||
@ -39,6 +40,9 @@ class OpenActivity : ColoredActivity() {
|
|||||||
private var usf_fingerprint = false
|
private var usf_fingerprint = false
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
if (!sharedPrefs.getBoolean("usf_screenshot", false)){
|
||||||
|
window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE)
|
||||||
|
}
|
||||||
setContentView(R.layout.activity_open)
|
setContentView(R.layout.activity_open)
|
||||||
setSupportActionBar(toolbar)
|
setSupportActionBar(toolbar)
|
||||||
//val sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this)
|
//val sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
|
@ -189,7 +189,7 @@ class ExplorerActivity : ExplorerActivityRO() {
|
|||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
menuInflater.inflate(R.menu.explorer, menu)
|
menuInflater.inflate(R.menu.explorer, menu)
|
||||||
handle_menu_items(menu)
|
handleMenuItems(menu)
|
||||||
if (usf_share){
|
if (usf_share){
|
||||||
menu.findItem(R.id.explorer_menu_share).isVisible = false
|
menu.findItem(R.id.explorer_menu_share).isVisible = false
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ class ExplorerActivityDrop : ExplorerActivityRO() {
|
|||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
menuInflater.inflate(R.menu.explorer_drop, menu)
|
menuInflater.inflate(R.menu.explorer_drop, menu)
|
||||||
handle_menu_items(menu)
|
handleMenuItems(menu)
|
||||||
menu.findItem(R.id.explorer_menu_validate).isVisible = explorer_adapter.selectedItems.isEmpty()
|
menu.findItem(R.id.explorer_menu_validate).isVisible = explorer_adapter.selectedItems.isEmpty()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ class ExplorerActivityPick : ExplorerActivityRO() {
|
|||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
menuInflater.inflate(R.menu.explorer_pick, menu)
|
menuInflater.inflate(R.menu.explorer_pick, menu)
|
||||||
handle_menu_items(menu)
|
handleMenuItems(menu)
|
||||||
val any_item_selected = explorer_adapter.selectedItems.isNotEmpty()
|
val any_item_selected = explorer_adapter.selectedItems.isNotEmpty()
|
||||||
menu.findItem(R.id.explorer_menu_select_all).isVisible = any_item_selected
|
menu.findItem(R.id.explorer_menu_select_all).isVisible = any_item_selected
|
||||||
menu.findItem(R.id.explorer_menu_validate).isVisible = any_item_selected
|
menu.findItem(R.id.explorer_menu_validate).isVisible = any_item_selected
|
||||||
|
@ -54,7 +54,7 @@ open class ExplorerActivityRO : ColoredActivity() {
|
|||||||
}
|
}
|
||||||
usf_open = sharedPrefs.getBoolean("usf_open", false)
|
usf_open = sharedPrefs.getBoolean("usf_open", false)
|
||||||
val intent = intent
|
val intent = intent
|
||||||
volume_name = intent.getStringExtra("volume_name")
|
volume_name = intent.getStringExtra("volume_name") ?: ""
|
||||||
val sessionID = intent.getIntExtra("sessionID", -1)
|
val sessionID = intent.getIntExtra("sessionID", -1)
|
||||||
gocryptfsVolume = GocryptfsVolume(sessionID)
|
gocryptfsVolume = GocryptfsVolume(sessionID)
|
||||||
sort_modes_entries = resources.getStringArray(R.array.sort_orders_entries)
|
sort_modes_entries = resources.getStringArray(R.array.sort_orders_entries)
|
||||||
@ -143,7 +143,7 @@ open class ExplorerActivityRO : ColoredActivity() {
|
|||||||
invalidateOptionsMenu()
|
invalidateOptionsMenu()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sort_explorer_elements() {
|
private fun sortExplorerElements() {
|
||||||
when (sort_modes_values[current_sort_mode_index]) {
|
when (sort_modes_values[current_sort_mode_index]) {
|
||||||
"name" -> {
|
"name" -> {
|
||||||
explorer_elements.sortWith(Comparator { o1, o2 -> o1.name.compareTo(o2.name) })
|
explorer_elements.sortWith(Comparator { o1, o2 -> o1.name.compareTo(o2.name) })
|
||||||
@ -171,7 +171,7 @@ open class ExplorerActivityRO : ColoredActivity() {
|
|||||||
protected fun setCurrentPath(path: String) {
|
protected fun setCurrentPath(path: String) {
|
||||||
explorer_elements = gocryptfsVolume.list_dir(path)
|
explorer_elements = gocryptfsVolume.list_dir(path)
|
||||||
text_dir_empty.visibility = if (explorer_elements.size == 0) View.VISIBLE else View.INVISIBLE
|
text_dir_empty.visibility = if (explorer_elements.size == 0) View.VISIBLE else View.INVISIBLE
|
||||||
sort_explorer_elements()
|
sortExplorerElements()
|
||||||
if (path.isNotEmpty()) { //not root
|
if (path.isNotEmpty()) { //not root
|
||||||
explorer_elements.add(0, ExplorerElement("..", (-1).toShort(), -1, -1))
|
explorer_elements.add(0, ExplorerElement("..", (-1).toShort(), -1, -1))
|
||||||
}
|
}
|
||||||
@ -213,7 +213,7 @@ open class ExplorerActivityRO : ColoredActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createFolder(folder_name: String){
|
private fun createFolder(folder_name: String){
|
||||||
if (folder_name.isEmpty()) {
|
if (folder_name.isEmpty()) {
|
||||||
Toast.makeText(this, R.string.error_filename_empty, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, R.string.error_filename_empty, Toast.LENGTH_SHORT).show()
|
||||||
} else {
|
} else {
|
||||||
@ -270,7 +270,7 @@ open class ExplorerActivityRO : ColoredActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun handle_menu_items(menu: Menu){
|
fun handleMenuItems(menu: Menu){
|
||||||
menu.findItem(R.id.explorer_menu_rename).isVisible = false
|
menu.findItem(R.id.explorer_menu_rename).isVisible = false
|
||||||
if (usf_open){
|
if (usf_open){
|
||||||
menu.findItem(R.id.explorer_menu_external_open)?.isVisible = false
|
menu.findItem(R.id.explorer_menu_external_open)?.isVisible = false
|
||||||
|
@ -15,7 +15,7 @@ import java.io.File
|
|||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
|
|
||||||
abstract class FileViewerActivity: ColoredActivity() {
|
abstract class FileViewerActivity: ColoredActivity() {
|
||||||
var cachedFiles: MutableList<Uri> = ArrayList()
|
private var cachedFiles: MutableList<Uri> = ArrayList()
|
||||||
lateinit var gocryptfsVolume: GocryptfsVolume
|
lateinit var gocryptfsVolume: GocryptfsVolume
|
||||||
lateinit var filePath: String
|
lateinit var filePath: String
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
@ -1,64 +1,59 @@
|
|||||||
package sushi.hardcore.droidfs.file_viewers
|
package sushi.hardcore.droidfs.file_viewers
|
||||||
|
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.BitmapFactory
|
|
||||||
import android.graphics.Matrix
|
import android.graphics.Matrix
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.util.DisplayMetrics
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import com.bumptech.glide.Glide
|
||||||
|
import com.bumptech.glide.RequestBuilder
|
||||||
|
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool
|
||||||
|
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation
|
||||||
import kotlinx.android.synthetic.main.activity_image_viewer.*
|
import kotlinx.android.synthetic.main.activity_image_viewer.*
|
||||||
import sushi.hardcore.droidfs.R
|
import sushi.hardcore.droidfs.R
|
||||||
|
import java.security.MessageDigest
|
||||||
|
|
||||||
class ImageViewer: FileViewerActivity() {
|
class ImageViewer: FileViewerActivity() {
|
||||||
companion object {
|
companion object {
|
||||||
private const val hideDelay: Long = 3000
|
private const val hideDelay: Long = 3000
|
||||||
}
|
}
|
||||||
private lateinit var bmpImage: Bitmap
|
private lateinit var glideImage: RequestBuilder<Drawable>
|
||||||
|
private var rotationAngle: Float = 0F
|
||||||
private val handler = Handler()
|
private val handler = Handler()
|
||||||
private val hideActionButtons = Runnable { action_buttons.visibility = View.GONE }
|
private val hideActionButtons = Runnable { action_buttons.visibility = View.GONE }
|
||||||
override fun viewFile() {
|
override fun viewFile() {
|
||||||
loadWholeFile(filePath)?.let {
|
val imageBuff = loadWholeFile(filePath)
|
||||||
val metrics = DisplayMetrics()
|
if (imageBuff != null){
|
||||||
windowManager.defaultDisplay.getRealMetrics(metrics)
|
|
||||||
bmpImage = decodeSampledBitmapFromBuffer(it, metrics.widthPixels, metrics.heightPixels)
|
|
||||||
setContentView(R.layout.activity_image_viewer)
|
setContentView(R.layout.activity_image_viewer)
|
||||||
image_viewer.setImageBitmap(bmpImage)
|
glideImage = Glide.with(this).load(imageBuff)
|
||||||
|
glideImage.into(image_viewer)
|
||||||
handler.postDelayed(hideActionButtons, hideDelay)
|
handler.postDelayed(hideActionButtons, hideDelay)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun calculateInSampleSize(options: BitmapFactory.Options, reqWidth: Int, reqHeight: Int): Int {
|
class RotateTransformation(private val rotationAngle: Float): BitmapTransformation() {
|
||||||
var inSampleSize = 1
|
|
||||||
if (options.outHeight > reqHeight || options.outWidth > reqWidth){
|
override fun transform(pool: BitmapPool, toTransform: Bitmap, outWidth: Int, outHeight: Int): Bitmap {
|
||||||
val halfHeight = options.outHeight/2
|
val matrix = Matrix()
|
||||||
val halfWidth = options.outWidth/2
|
matrix.postRotate(rotationAngle)
|
||||||
while (halfHeight/inSampleSize >= reqHeight && halfWidth/inSampleSize >= reqWidth){
|
return Bitmap.createBitmap(toTransform, 0, 0, toTransform.width, toTransform.height, matrix, true)
|
||||||
inSampleSize *= 2
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return inSampleSize
|
|
||||||
}
|
override fun updateDiskCacheKey(messageDigest: MessageDigest) {
|
||||||
private fun decodeSampledBitmapFromBuffer(buff: ByteArray, reqWidth: Int, reqHeight: Int): Bitmap {
|
messageDigest.update("rotate$rotationAngle".toByteArray())
|
||||||
return BitmapFactory.Options().run {
|
|
||||||
inJustDecodeBounds = true
|
|
||||||
BitmapFactory.decodeByteArray(buff, 0, buff.size, this)
|
|
||||||
inSampleSize = calculateInSampleSize(this, reqWidth, reqHeight)
|
|
||||||
inJustDecodeBounds = false
|
|
||||||
BitmapFactory.decodeByteArray(buff, 0, buff.size, this)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun rotateImage(degrees: Float){
|
private fun rotateImage(){
|
||||||
val matrix = Matrix()
|
glideImage.transform(RotateTransformation(rotationAngle)).into(image_viewer)
|
||||||
matrix.postRotate(degrees)
|
|
||||||
bmpImage = Bitmap.createBitmap(bmpImage, 0, 0, bmpImage.width, bmpImage.height, matrix, true)
|
|
||||||
image_viewer.setImageBitmap(bmpImage)
|
|
||||||
}
|
}
|
||||||
fun onCLickRotateRight(view: View){
|
fun onCLickRotateRight(view: View){
|
||||||
rotateImage(90F)
|
rotationAngle += 90
|
||||||
|
rotateImage()
|
||||||
}
|
}
|
||||||
fun onClickRotateLeft(view: View){
|
fun onClickRotateLeft(view: View){
|
||||||
rotateImage(-90F)
|
rotationAngle -= 90
|
||||||
|
rotateImage()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUserInteraction() {
|
override fun onUserInteraction() {
|
||||||
|
Loading…
Reference in New Issue
Block a user