Remove android:onClick properties

This commit is contained in:
Matéo Duparc 2021-06-07 16:34:50 +02:00
parent 9cf3e71fd2
commit b0145e0192
Signed by: hardcoresushi
GPG Key ID: 007F84120107191E
22 changed files with 317 additions and 366 deletions

View File

@ -9,7 +9,6 @@ import android.os.Build
import android.os.Bundle
import android.text.InputType
import android.util.DisplayMetrics
import android.util.Log
import android.util.Size
import android.view.MotionEvent
import android.view.ScaleGestureDetector
@ -44,7 +43,7 @@ class CameraActivity : BaseActivity(), SensorOrientationListener.Listener {
private const val CAMERA_PERMISSION_REQUEST_CODE = 1
private const val fileNameRandomMin = 100000
private const val fileNameRandomMax = 999999
private val dateFormat = SimpleDateFormat("yyyyMMdd_HHmmss")
private val dateFormat = SimpleDateFormat("yyyyMMdd_HHmmss", Locale.US)
private val random = Random()
}
private var timerDuration = 0
@ -88,6 +87,74 @@ class CameraActivity : BaseActivity(), SensorOrientationListener.Listener {
cameraExecutor = Executors.newSingleThreadExecutor()
image_ratio.setOnClickListener {
resolutions?.let {
ColoredAlertDialogBuilder(this)
.setTitle(R.string.choose_resolution)
.setSingleChoiceItems(DialogSingleChoiceAdapter(this, it.map { size -> size.toString() }.toTypedArray()), currentResolutionIndex) { dialog, which ->
setupCamera(resolutions!![which])
dialog.dismiss()
currentResolutionIndex = which
}
.setNegativeButton(R.string.cancel, null)
.show()
}
}
image_timer.setOnClickListener {
val dialogEditTextView = layoutInflater.inflate(R.layout.dialog_edit_text, null)
val dialogEditText = dialogEditTextView.findViewById<EditText>(R.id.dialog_edit_text)
dialogEditText.inputType = InputType.TYPE_CLASS_NUMBER
val dialog = ColoredAlertDialogBuilder(this)
.setView(dialogEditTextView)
.setTitle(getString(R.string.enter_timer_duration))
.setPositiveButton(R.string.ok) { _, _ ->
val enteredValue = dialogEditText.text.toString()
if (enteredValue.isEmpty()){
Toast.makeText(this, getString(R.string.timer_empty_error_msg), Toast.LENGTH_SHORT).show()
} else {
timerDuration = enteredValue.toInt()
}
}
.setNegativeButton(R.string.cancel, null)
.create()
dialogEditText.setOnEditorActionListener { _, _, _ ->
timerDuration = dialogEditText.text.toString().toInt()
dialog.dismiss()
true
}
dialog.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
dialog.show()
}
image_close.setOnClickListener {
isFinishingIntentionally = true
finish()
}
image_flash.setOnClickListener {
image_flash.setImageResource(when (imageCapture?.flashMode) {
ImageCapture.FLASH_MODE_AUTO -> {
imageCapture?.flashMode = ImageCapture.FLASH_MODE_ON
R.drawable.icon_flash_on
}
ImageCapture.FLASH_MODE_ON -> {
imageCapture?.flashMode = ImageCapture.FLASH_MODE_OFF
R.drawable.icon_flash_off
}
else -> {
imageCapture?.flashMode = ImageCapture.FLASH_MODE_AUTO
R.drawable.icon_flash_auto
}
})
}
image_camera_switch.setOnClickListener {
isBackCamera = if (isBackCamera) {
image_camera_switch.setImageResource(R.drawable.icon_camera_front)
false
} else {
image_camera_switch.setImageResource(R.drawable.icon_camera_back)
true
}
setupCamera()
}
take_photo_button.onClick = ::onClickTakePhoto
orientedIcons = listOf(image_ratio, image_timer, image_close, image_flash, image_camera_switch)
sensorOrientationListener = SensorOrientationListener(this)
@ -99,23 +166,25 @@ class CameraActivity : BaseActivity(), SensorOrientationListener.Listener {
return true
}
})
camera_preview.setOnTouchListener { _, motionEvent: MotionEvent ->
when (motionEvent.action) {
camera_preview.setOnTouchListener { view, event ->
view.performClick()
when (event.action) {
MotionEvent.ACTION_DOWN -> true
MotionEvent.ACTION_UP -> {
val factory = camera_preview.meteringPointFactory
val point = factory.createPoint(motionEvent.x, motionEvent.y)
val point = factory.createPoint(event.x, event.y)
val action = FocusMeteringAction.Builder(point).build()
imageCapture?.camera?.cameraControl?.startFocusAndMetering(action)
true
}
MotionEvent.ACTION_MOVE -> scaleGestureDetector.onTouchEvent(motionEvent)
MotionEvent.ACTION_MOVE -> scaleGestureDetector.onTouchEvent(event)
else -> false
}
}
}
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
when (requestCode) {
CAMERA_PERMISSION_REQUEST_CODE -> if (grantResults.size == 1) {
if (grantResults[0] != PackageManager.PERMISSION_GRANTED) {
@ -134,7 +203,7 @@ class CameraActivity : BaseActivity(), SensorOrientationListener.Listener {
}
}
private fun adaptPreviewSize(resolution: Size){
private fun adaptPreviewSize(resolution: Size) {
val metrics = DisplayMetrics()
windowManager.defaultDisplay.getMetrics(metrics)
//resolution.width and resolution.height seem to be inverted
@ -238,79 +307,6 @@ class CameraActivity : BaseActivity(), SensorOrientationListener.Listener {
}
}
fun onClickFlash(view: View) {
image_flash.setImageResource(when (imageCapture?.flashMode) {
ImageCapture.FLASH_MODE_AUTO -> {
imageCapture?.flashMode = ImageCapture.FLASH_MODE_ON
R.drawable.icon_flash_on
}
ImageCapture.FLASH_MODE_ON -> {
imageCapture?.flashMode = ImageCapture.FLASH_MODE_OFF
R.drawable.icon_flash_off
}
else -> {
imageCapture?.flashMode = ImageCapture.FLASH_MODE_AUTO
R.drawable.icon_flash_auto
}
})
}
fun onClickCameraSwitch(view: View) {
isBackCamera = if (isBackCamera) {
image_camera_switch.setImageResource(R.drawable.icon_camera_front)
false
} else {
image_camera_switch.setImageResource(R.drawable.icon_camera_back)
true
}
setupCamera()
}
fun onClickTimer(view: View) {
val dialogEditTextView = layoutInflater.inflate(R.layout.dialog_edit_text, null)
val dialogEditText = dialogEditTextView.findViewById<EditText>(R.id.dialog_edit_text)
dialogEditText.inputType = InputType.TYPE_CLASS_NUMBER
val dialog = ColoredAlertDialogBuilder(this)
.setView(dialogEditTextView)
.setTitle(getString(R.string.enter_timer_duration))
.setPositiveButton(R.string.ok) { _, _ ->
val enteredValue = dialogEditText.text.toString()
if (enteredValue.isEmpty()){
Toast.makeText(this, getString(R.string.timer_empty_error_msg), Toast.LENGTH_SHORT).show()
} else {
timerDuration = enteredValue.toInt()
}
}
.setNegativeButton(R.string.cancel, null)
.create()
dialogEditText.setOnEditorActionListener { _, _, _ ->
timerDuration = dialogEditText.text.toString().toInt()
dialog.dismiss()
true
}
dialog.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
dialog.show()
}
fun onClickRatio(view: View) {
resolutions?.let {
ColoredAlertDialogBuilder(this)
.setTitle(R.string.choose_resolution)
.setSingleChoiceItems(DialogSingleChoiceAdapter(this, it.map { size -> size.toString() }.toTypedArray()), currentResolutionIndex) { dialog, which ->
setupCamera(resolutions!![which])
dialog.dismiss()
currentResolutionIndex = which
}
.setNegativeButton(R.string.cancel, null)
.show()
}
}
fun onClickClose(view: View) {
isFinishingIntentionally = true
finish()
}
override fun onDestroy() {
super.onDestroy()
cameraExecutor.shutdown()

View File

@ -5,7 +5,6 @@ import android.os.Build
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.view.View
import android.widget.AdapterView.OnItemClickListener
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
@ -25,7 +24,7 @@ class ChangePasswordActivity : VolumeActionActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_change_password)
setupActionBar()
setupLayout()
setupFingerprintStuff()
savedVolumesAdapter = SavedVolumesAdapter(this, volumeDatabase)
if (savedVolumesAdapter.count > 0){
@ -40,7 +39,7 @@ class ChangePasswordActivity : VolumeActionActivity() {
switch_hidden_volume.isChecked = false
edit_volume_path.setText(currentVolumeName)
}
onClickSwitchHiddenVolume(switch_hidden_volume)
onClickSwitchHiddenVolume()
}
} else {
WidgetUtil.hideWithPadding(saved_path_listview)
@ -71,14 +70,13 @@ class ChangePasswordActivity : VolumeActionActivity() {
}
edit_volume_path.addTextChangedListener(textWatcher)
edit_volume_name.addTextChangedListener(textWatcher)
edit_new_password_confirm.setOnEditorActionListener { v, _, _ ->
onClickChangePassword(v)
edit_new_password_confirm.setOnEditorActionListener { _, _, _ ->
checkVolumePathThenChangePassword()
true
}
button_change_password.setOnClickListener {
checkVolumePathThenChangePassword()
}
fun pickDirectory(view: View?) {
askPermissionThenPickDirectory()
}
override fun onDirectoryPicked(uri: Uri) {
@ -102,7 +100,7 @@ class ChangePasswordActivity : VolumeActionActivity() {
}
}
fun onClickChangePassword(view: View?) {
fun checkVolumePathThenChangePassword() {
loadVolumePath {
val volumeFile = File(currentVolumePath)
if (!GocryptfsVolume.isGocryptfsVolume(volumeFile)){
@ -209,12 +207,6 @@ class ChangePasswordActivity : VolumeActionActivity() {
.show()
}
fun onClickRememberPath(view: View) {
if (!checkbox_remember_path.isChecked){
checkbox_save_password.isChecked = false
}
}
override fun onDestroy() {
super.onDestroy()
Wiper.wipeEditText(edit_old_password)

View File

@ -18,11 +18,11 @@ class ConstValues {
Pair("image", listOf("png", "jpg", "jpeg", "gif", "bmp")),
Pair("video", listOf("mp4", "webm", "mkv", "mov")),
Pair("audio", listOf("mp3", "ogg", "m4a", "wav", "flac")),
Pair("text", listOf("txt", "json", "conf", "log", "xml", "java", "kt", "py", "pl", "rb", "go", "c", "h", "cpp", "hpp", "sh", "bat", "js", "html", "css", "php", "yml", "yaml", "ini", "md"))
Pair("text", listOf("txt", "json", "conf", "log", "xml", "java", "kt", "py", "pl", "rb", "go", "c", "h", "cpp", "hpp", "rs", "sh", "bat", "js", "html", "css", "php", "yml", "yaml", "toml", "ini", "md"))
)
fun isExtensionType(extensionType: String, path: String): Boolean {
return fileExtensions[extensionType]?.contains(File(path).extension.toLowerCase(Locale.ROOT)) ?: false
return fileExtensions[extensionType]?.contains(File(path).extension.lowercase()) ?: false
}
fun isImage(path: String): Boolean {

View File

@ -4,7 +4,6 @@ import android.content.Intent
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_create.*
@ -23,14 +22,19 @@ class CreateActivity : VolumeActionActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_create)
setupActionBar()
setupLayout()
setupFingerprintStuff()
edit_password_confirm.setOnEditorActionListener { v, _, _ ->
onClickCreate(v)
edit_password_confirm.setOnEditorActionListener { _, _, _ ->
createVolume()
true
}
switch_hidden_volume.setOnClickListener {
onClickSwitchHiddenVolume(it)
button_create.setOnClickListener {
createVolume()
}
}
override fun onClickSwitchHiddenVolume() {
super.onClickSwitchHiddenVolume()
if (switch_hidden_volume.isChecked){
ColoredAlertDialogBuilder(this)
.setTitle(R.string.warning)
@ -39,11 +43,6 @@ class CreateActivity : VolumeActionActivity() {
.show()
}
}
}
fun pickDirectory(view: View?) {
askPermissionThenPickDirectory()
}
override fun onDirectoryPicked(uri: Uri) {
if (PathUtils.isTreeUriOnPrimaryStorage(uri)){
@ -66,7 +65,7 @@ class CreateActivity : VolumeActionActivity() {
}
}
fun onClickCreate(view: View?) {
fun createVolume() {
loadVolumePath {
val password = edit_password.text.toString().toCharArray()
val passwordConfirm = edit_password_confirm.text.toString().toCharArray()
@ -173,12 +172,6 @@ class CreateActivity : VolumeActionActivity() {
.show()
}
fun onClickRememberPath(view: View) {
if (!checkbox_remember_path.isChecked) {
checkbox_save_password.isChecked = false
}
}
override fun onPause() {
super.onPause()
//Closing volume if leaving activity while showing dialog

View File

@ -4,7 +4,7 @@ import android.content.Intent
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.view.View
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.toolbar.*
import sushi.hardcore.droidfs.widgets.ColoredAlertDialogBuilder
@ -29,6 +29,15 @@ class MainActivity : BaseActivity() {
.show()
}
}
button_open.setOnClickListener {
startActivity(OpenActivity::class.java)
}
button_create.setOnClickListener {
startActivity(CreateActivity::class.java)
}
button_change_password.setOnClickListener {
startActivity(ChangePasswordActivity::class.java)
}
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
@ -47,18 +56,8 @@ class MainActivity : BaseActivity() {
return true
}
fun onClickCreate(v: View?) {
val intent = Intent(this, CreateActivity::class.java)
startActivity(intent)
}
fun onClickOpen(v: View?) {
val intent = Intent(this, OpenActivity::class.java)
startActivity(intent)
}
fun onClickChangePassword(v: View?) {
val intent = Intent(this, ChangePasswordActivity::class.java)
fun <T> startActivity(clazz: Class<T>) {
val intent = Intent(this, clazz)
startActivity(intent)
}
}

View File

@ -7,7 +7,6 @@ import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.view.MenuItem
import android.view.View
import android.widget.AdapterView.OnItemClickListener
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_open.*
@ -34,7 +33,7 @@ class OpenActivity : VolumeActionActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_open)
setupActionBar()
setupLayout()
setupFingerprintStuff()
savedVolumesAdapter = SavedVolumesAdapter(this, volumeDatabase)
if (savedVolumesAdapter.count > 0){
@ -49,7 +48,7 @@ class OpenActivity : VolumeActionActivity() {
switch_hidden_volume.isChecked = false
edit_volume_path.setText(currentVolumeName)
}
onClickSwitchHiddenVolume(switch_hidden_volume)
onClickSwitchHiddenVolume()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M){
volume.hash?.let { hash ->
volume.iv?.let { iv ->
@ -89,10 +88,13 @@ class OpenActivity : VolumeActionActivity() {
}
edit_volume_path.addTextChangedListener(textWatcher)
edit_volume_name.addTextChangedListener(textWatcher)
edit_password.setOnEditorActionListener { v, _, _ ->
onClickOpen(v)
edit_password.setOnEditorActionListener { _, _, _ ->
checkVolumePathThenOpen()
true
}
button_open.setOnClickListener {
checkVolumePathThenOpen()
}
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
@ -106,10 +108,6 @@ class OpenActivity : VolumeActionActivity() {
}
}
fun pickDirectory(view: View?) {
askPermissionThenPickDirectory()
}
override fun onPickingDirectory() {
isStartingActivity = true
}
@ -127,7 +125,7 @@ class OpenActivity : VolumeActionActivity() {
}
}
fun onClickOpen(view: View?) {
fun checkVolumePathThenOpen() {
loadVolumePath {
val volumeFile = File(currentVolumePath)
if (!GocryptfsVolume.isGocryptfsVolume(volumeFile)){
@ -245,12 +243,6 @@ class OpenActivity : VolumeActionActivity() {
finish()
}
fun onClickRememberPath(view: View) {
if (!checkbox_remember_path.isChecked){
checkbox_save_password.isChecked = false
}
}
override fun onBackPressed() {
super.onBackPressed()
isFinishingIntentionally = true

View File

@ -10,7 +10,7 @@ import kotlinx.android.synthetic.main.toolbar.*
import sushi.hardcore.droidfs.widgets.SimpleActionPreference
import sushi.hardcore.droidfs.widgets.ThemeColor
class SettingsActivity : BaseActivity(), PreferenceFragmentCompat.OnPreferenceStartFragmentCallback {
class SettingsActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -72,12 +72,4 @@ class SettingsActivity : BaseActivity(), PreferenceFragmentCompat.OnPreferenceSt
ThemeColor.tintPreferenceIcons(preferenceScreen, ThemeColor.getThemeColor(requireContext()))
}
}
override fun onPreferenceStartFragment(caller: PreferenceFragmentCompat, pref: Preference): Boolean {
val fragment = supportFragmentManager.fragmentFactory.instantiate(classLoader, pref.fragment)
fragment.arguments = pref.extras
fragment.setTargetFragment(caller, 0)
supportFragmentManager.beginTransaction().replace(R.id.settings, fragment).addToBackStack(null).commit()
return true
}
}

View File

@ -10,7 +10,6 @@ import android.os.Build
import android.security.keystore.KeyGenParameterSpec
import android.security.keystore.KeyPermanentlyInvalidatedException
import android.security.keystore.KeyProperties
import android.view.View
import android.widget.LinearLayout
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
@ -59,10 +58,10 @@ abstract class VolumeActionActivity : BaseActivity() {
private const val GCM_TAG_LEN = 128
}
protected open fun onPickingDirectory() {}
protected abstract fun onDirectoryPicked(uri: Uri)
protected fun askPermissionThenPickDirectory() {
protected fun setupLayout() {
setSupportActionBar(toolbar)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
button_pick_directory.setOnClickListener {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) +
ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
@ -74,6 +73,38 @@ abstract class VolumeActionActivity : BaseActivity() {
safePickDirectory()
}
}
switch_hidden_volume.setOnClickListener {
onClickSwitchHiddenVolume()
}
checkbox_remember_path.setOnClickListener {
if (!checkbox_remember_path.isChecked) {
checkbox_save_password.isChecked = false
}
}
checkbox_save_password.setOnClickListener {
if (checkbox_save_password.isChecked) {
if (biometricCanAuthenticateCode == 0) {
checkbox_remember_path.isChecked = checkbox_remember_path.isEnabled
} else {
checkbox_save_password.isChecked = false
printAuthenticateImpossibleError()
}
}
}
}
protected open fun onClickSwitchHiddenVolume() {
if (switch_hidden_volume.isChecked){
WidgetUtil.show(hidden_volume_section, originalHiddenVolumeSectionLayoutParams)
WidgetUtil.hide(normal_volume_section)
} else {
WidgetUtil.show(normal_volume_section, originalNormalVolumeSectionLayoutParams)
WidgetUtil.hide(hidden_volume_section)
}
}
protected open fun onPickingDirectory() {}
protected abstract fun onDirectoryPicked(uri: Uri)
private fun safePickDirectory() {
try {
@ -185,11 +216,6 @@ abstract class VolumeActionActivity : BaseActivity() {
}
}
protected fun setupActionBar(){
setSupportActionBar(toolbar)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
}
private fun canAuthenticate(): Int {
val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as KeyguardManager
return if (!keyguardManager.isKeyguardSecure) {
@ -215,17 +241,6 @@ abstract class VolumeActionActivity : BaseActivity() {
}, Toast.LENGTH_SHORT).show()
}
fun onClickSavePasswordHash(view: View) {
if (checkbox_save_password.isChecked){
if (biometricCanAuthenticateCode == 0){
checkbox_remember_path.isChecked = checkbox_remember_path.isEnabled
} else {
checkbox_save_password.isChecked = false
printAuthenticateImpossibleError()
}
}
}
@RequiresApi(Build.VERSION_CODES.M)
private fun prepareCipher() {
keyStore = KeyStore.getInstance(ANDROID_KEY_STORE)
@ -337,14 +352,4 @@ abstract class VolumeActionActivity : BaseActivity() {
callback()
}
}
fun onClickSwitchHiddenVolume(view: View){
if (switch_hidden_volume.isChecked){
WidgetUtil.show(hidden_volume_section, originalHiddenVolumeSectionLayoutParams)
WidgetUtil.hide(normal_volume_section)
} else {
WidgetUtil.show(normal_volume_section, originalNormalVolumeSectionLayoutParams)
WidgetUtil.hide(hidden_volume_section)
}
}
}

View File

@ -4,11 +4,11 @@ import android.app.Activity
import android.content.Intent
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.WindowManager
import android.widget.EditText
import android.widget.Toast
import androidx.activity.result.contract.ActivityResultContracts
import kotlinx.android.synthetic.main.activity_explorer.*
import sushi.hardcore.droidfs.CameraActivity
import sushi.hardcore.droidfs.GocryptfsVolume
import sushi.hardcore.droidfs.OpenActivity
@ -146,36 +146,7 @@ class ExplorerActivity : BaseExplorerActivity() {
override fun init() {
setContentView(R.layout.activity_explorer)
usf_decrypt = sharedPrefs.getBoolean("usf_decrypt", false)
usf_share = sharedPrefs.getBoolean("usf_share", false)
}
override fun onExplorerItemLongClick(position: Int) {
cancelItemAction()
explorerAdapter.onItemLongClick(position)
invalidateOptionsMenu()
}
private fun createNewFile(fileName: String){
if (fileName.isEmpty()) {
Toast.makeText(this, R.string.error_filename_empty, Toast.LENGTH_SHORT).show()
} else {
val handleID = gocryptfsVolume.openWriteMode(fileName) //don't check overwrite because openWriteMode open in read-write (doesn't erase content)
if (handleID == -1) {
ColoredAlertDialogBuilder(this)
.setTitle(R.string.error)
.setMessage(R.string.file_creation_failed)
.setPositiveButton(R.string.ok, null)
.show()
} else {
gocryptfsVolume.closeFile(handleID)
setCurrentPath(currentDirectoryPath)
invalidateOptionsMenu()
}
}
}
fun onClickFAB(view: View) {
fab.setOnClickListener {
if (currentItemAction != ItemsActions.NONE){
openDialogCreateFolder()
} else {
@ -240,6 +211,34 @@ class ExplorerActivity : BaseExplorerActivity() {
.show()
}
}
usf_decrypt = sharedPrefs.getBoolean("usf_decrypt", false)
usf_share = sharedPrefs.getBoolean("usf_share", false)
}
override fun onExplorerItemLongClick(position: Int) {
cancelItemAction()
explorerAdapter.onItemLongClick(position)
invalidateOptionsMenu()
}
private fun createNewFile(fileName: String){
if (fileName.isEmpty()) {
Toast.makeText(this, R.string.error_filename_empty, Toast.LENGTH_SHORT).show()
} else {
val handleID = gocryptfsVolume.openWriteMode(fileName) //don't check overwrite because openWriteMode open in read-write (doesn't erase content)
if (handleID == -1) {
ColoredAlertDialogBuilder(this)
.setTitle(R.string.error)
.setMessage(R.string.file_creation_failed)
.setPositiveButton(R.string.ok, null)
.show()
} else {
gocryptfsVolume.closeFile(handleID)
setCurrentPath(currentDirectoryPath)
invalidateOptionsMenu()
}
}
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.explorer, menu)

View File

@ -4,18 +4,17 @@ import android.content.Intent
import android.net.Uri
import android.view.Menu
import android.view.MenuItem
import android.view.View
import kotlinx.android.synthetic.main.activity_explorer_drop.*
import sushi.hardcore.droidfs.R
import sushi.hardcore.droidfs.widgets.ColoredAlertDialogBuilder
class ExplorerActivityDrop : BaseExplorerActivity() {
override fun init() {
setContentView(R.layout.activity_explorer_drop)
}
fun onClickFAB(view: View) {
fab.setOnClickListener {
openDialogCreateFolder()
}
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.explorer_drop, menu)

View File

@ -83,6 +83,64 @@ class ImageViewer: FileViewerActivity() {
}
}
})
image_delete.setOnClickListener {
ColoredAlertDialogBuilder(this)
.keepFullScreen()
.setTitle(R.string.warning)
.setPositiveButton(R.string.ok) { _, _ ->
createPlaylist() //be sure the playlist is created before deleting if there is only one image
if (gocryptfsVolume.removeFile(filePath)) {
playlistNext(true)
refreshPlaylist()
if (mappedPlaylist.size == 0) { //deleted all images of the playlist
goBackToExplorer()
} else {
loadImage()
}
} else {
ColoredAlertDialogBuilder(this)
.keepFullScreen()
.setTitle(R.string.error)
.setMessage(getString(R.string.remove_failed, fileName))
.setPositiveButton(R.string.ok, null)
.show()
}
}
.setNegativeButton(R.string.cancel, null)
.setMessage(getString(R.string.single_delete_confirm, fileName))
.show()
}
image_button_slideshow.setOnClickListener {
if (!slideshowActive){
slideshowActive = true
handler.postDelayed(slideshowNext, ConstValues.slideshow_delay)
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
hideUI.run()
Toast.makeText(this, R.string.slideshow_started, Toast.LENGTH_SHORT).show()
} else {
stopSlideshow()
}
}
image_previous.setOnClickListener {
askSaveRotation {
image_viewer.resetZoomFactor()
swipeImage(1F)
}
}
image_next.setOnClickListener {
askSaveRotation {
image_viewer.resetZoomFactor()
swipeImage(-1F)
}
}
image_rotate_right.setOnClickListener {
rotationAngle += 90
rotateImage()
}
image_rotate_left.setOnClickListener {
rotationAngle -= 90
rotateImage()
}
loadImage()
handler.postDelayed(hideUI, hideDelay)
}
@ -114,46 +172,6 @@ class ImageViewer: FileViewerActivity() {
}
}
fun onClickDelete(view: View) {
ColoredAlertDialogBuilder(this)
.keepFullScreen()
.setTitle(R.string.warning)
.setPositiveButton(R.string.ok) { _, _ ->
createPlaylist() //be sure the playlist is created before deleting if there is only one image
if (gocryptfsVolume.removeFile(filePath)) {
playlistNext(true)
refreshPlaylist()
if (mappedPlaylist.size == 0) { //deleted all images of the playlist
goBackToExplorer()
} else {
loadImage()
}
} else {
ColoredAlertDialogBuilder(this)
.keepFullScreen()
.setTitle(R.string.error)
.setMessage(getString(R.string.remove_failed, fileName))
.setPositiveButton(R.string.ok, null)
.show()
}
}
.setNegativeButton(R.string.cancel, null)
.setMessage(getString(R.string.single_delete_confirm, fileName))
.show()
}
fun onClickSlideshow(view: View) {
if (!slideshowActive){
slideshowActive = true
handler.postDelayed(slideshowNext, ConstValues.slideshow_delay)
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
hideUI.run()
Toast.makeText(this, R.string.slideshow_started, Toast.LENGTH_SHORT).show()
} else {
stopSlideshow()
}
}
private fun stopSlideshow(){
slideshowActive = false
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
@ -186,27 +204,6 @@ class ImageViewer: FileViewerActivity() {
image_viewer.restoreZoomNormal()
glideImage.transform(RotateTransformation(this)).into(image_viewer)
}
fun onCLickRotateRight(view: View){
rotationAngle += 90
rotateImage()
}
fun onClickRotateLeft(view: View){
rotationAngle -= 90
rotateImage()
}
fun onClickPrevious(view: View){
askSaveRotation {
image_viewer.resetZoomFactor()
swipeImage(1F)
}
}
fun onClickNext(view: View){
askSaveRotation {
image_viewer.resetZoomFactor()
swipeImage(-1F)
}
}
private fun askSaveRotation(callback: () -> Unit){
if (rotationAngle%360 != 0f && !slideshowActive){

View File

@ -9,10 +9,11 @@ class TakePhotoButton: AppCompatImageView {
constructor(context: Context) : super(context) { init() }
constructor(context: Context, attrs: AttributeSet): super(context, attrs) { init() }
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int): super(context, attrs, defStyleAttr) { init() }
lateinit var onClick: ()->Unit
lateinit var onClick: () -> Unit
private fun init(){
setOnTouchListener{ _, event ->
private fun init() {
setOnTouchListener{ view, event ->
view.performClick()
when (event.action) {
MotionEvent.ACTION_DOWN -> onClick()
MotionEvent.ACTION_UP -> isPressed = true

View File

@ -21,7 +21,6 @@
android:id="@+id/image_ratio"
android:layout_width="30dp"
android:layout_height="30dp"
android:onClick="onClickRatio"
android:src="@drawable/icon_aspect_ratio"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/image_timer"
@ -32,7 +31,6 @@
android:id="@+id/image_timer"
android:layout_width="30dp"
android:layout_height="30dp"
android:onClick="onClickTimer"
android:src="@drawable/icon_timer_off"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/image_close"
@ -43,7 +41,6 @@
android:id="@+id/image_close"
android:layout_width="30dp"
android:layout_height="30dp"
android:onClick="onClickClose"
android:src="@drawable/icon_close"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
@ -73,8 +70,7 @@
android:src="@drawable/icon_flash_auto"
android:layout_alignEnd="@id/take_photo_button"
android:layout_marginEnd="120dp"
android:layout_centerVertical="true"
android:onClick="onClickFlash"/>
android:layout_centerVertical="true"/>
<sushi.hardcore.droidfs.widgets.TakePhotoButton
android:id="@+id/take_photo_button"
@ -90,8 +86,7 @@
android:src="@drawable/icon_camera_front"
android:layout_alignStart="@id/take_photo_button"
android:layout_marginStart="120dp"
android:layout_centerVertical="true"
android:onClick="onClickCameraSwitch"/>
android:layout_centerVertical="true"/>
</RelativeLayout>

View File

@ -97,11 +97,11 @@
android:text="@string/create_password_warning"/>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/button_change_password"
android:layout_width="match_parent"
android:layout_height="@dimen/action_activity_button_height"
android:layout_marginHorizontal="@dimen/action_activity_button_horizontal_margin"
android:layout_marginBottom="@dimen/action_activity_button_margin_bottom"
android:onClick="onClickChangePassword"
android:text="@string/change_password"
style="@style/button"/>

View File

@ -69,10 +69,10 @@
android:text="@string/create_password_warning"/>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/button_create"
android:layout_width="match_parent"
android:layout_height="@dimen/action_activity_button_height"
android:layout_marginHorizontal="@dimen/action_activity_button_horizontal_margin"
android:onClick="onClickCreate"
android:text="@string/create"
style="@style/button"/>

View File

@ -37,13 +37,13 @@
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<sushi.hardcore.droidfs.widgets.ColoredFAB
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_margin="15dp"
android:src="@drawable/icon_add"
android:onClick="onClickFAB"/>
android:src="@drawable/icon_add"/>
</RelativeLayout>

View File

@ -35,13 +35,13 @@
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<sushi.hardcore.droidfs.widgets.ColoredFAB
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_margin="15dp"
android:src="@drawable/icon_add"
android:onClick="onClickFAB"/>
android:src="@drawable/icon_add"/>
</RelativeLayout>

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -38,7 +37,6 @@
android:background="#00000000"
android:scaleType="fitCenter"
android:src="@drawable/icon_delete"
android:onClick="onClickDelete"
android:layout_marginStart="10dp"
android:layout_marginEnd="20dp"
android:layout_toStartOf="@id/image_button_slideshow"
@ -51,7 +49,6 @@
android:background="#00000000"
android:scaleType="fitCenter"
android:src="@drawable/icon_slideshow"
android:onClick="onClickSlideshow"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"/>
@ -65,40 +62,40 @@
android:gravity="center">
<ImageButton
android:id="@+id/image_previous"
android:layout_width="@dimen/image_button_size"
android:layout_height="@dimen/image_button_size"
android:layout_margin="10dp"
android:scaleType="fitCenter"
android:background="#00000000"
android:src="@drawable/exo_icon_previous"
android:onClick="onClickPrevious"/>
android:src="@drawable/exo_icon_previous"/>
<ImageButton
android:id="@+id/image_next"
android:layout_width="@dimen/image_button_size"
android:layout_height="@dimen/image_button_size"
android:layout_margin="10dp"
android:scaleType="fitCenter"
android:background="#00000000"
android:src="@drawable/icon_rotate_left"
android:onClick="onClickRotateLeft"/>
android:src="@drawable/icon_rotate_left"/>
<ImageButton
android:id="@+id/image_rotate_right"
android:layout_width="@dimen/image_button_size"
android:layout_height="@dimen/image_button_size"
android:layout_margin="10dp"
android:scaleType="fitCenter"
android:background="#00000000"
android:src="@drawable/icon_rotate_right"
android:onClick="onCLickRotateRight"/>
android:src="@drawable/icon_rotate_right"/>
<ImageButton
android:id="@+id/image_rotate_left"
android:layout_width="@dimen/image_button_size"
android:layout_height="@dimen/image_button_size"
android:layout_margin="10dp"
android:scaleType="fitCenter"
android:background="#00000000"
android:src="@drawable/exo_icon_next"
android:onClick="onClickNext"/>
android:src="@drawable/exo_icon_next"/>
</LinearLayout>

View File

@ -29,7 +29,6 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/button_create"
android:layout_marginHorizontal="@dimen/main_activity_button_hor_margin"
android:onClick="onClickOpen"
android:text="@string/open_volume"
style="@style/button"/>
@ -40,7 +39,6 @@
app:layout_constraintTop_toBottomOf="@id/button_open"
app:layout_constraintBottom_toTopOf="@id/button_change_password"
android:layout_marginHorizontal="@dimen/main_activity_button_hor_margin"
android:onClick="onClickCreate"
android:text="@string/create_volume"
style="@style/button"/>
@ -51,7 +49,6 @@
app:layout_constraintTop_toBottomOf="@id/button_create"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginHorizontal="@dimen/main_activity_button_hor_margin"
android:onClick="onClickChangePassword"
android:text="@string/change_volume_password"
style="@style/button"/>

View File

@ -56,11 +56,11 @@
android:text="@string/open_activity_warning"/>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/button_open"
android:layout_width="match_parent"
android:layout_height="@dimen/action_activity_button_height"
android:layout_marginHorizontal="@dimen/action_activity_button_horizontal_margin"
android:layout_marginBottom="@dimen/action_activity_button_margin_bottom"
android:onClick="onClickOpen"
android:text="@string/open"
style="@style/button"/>

View File

@ -8,15 +8,13 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/remember_volume_path"
android:onClick="onClickRememberPath"/>
android:text="@string/remember_volume_path"/>
<sushi.hardcore.droidfs.widgets.ColoredCheckBox
android:id="@+id/checkbox_save_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/fingerprint_save_checkbox_text"
android:onClick="onClickSavePasswordHash"/>
android:text="@string/fingerprint_save_checkbox_text"/>
</LinearLayout>

View File

@ -11,8 +11,7 @@
android:layout_height="wrap_content"
android:text="@string/hidden_volume"
app:switchPadding="10dp"
android:layout_gravity="center_horizontal"
android:onClick="onClickSwitchHiddenVolume"/>
android:layout_gravity="center_horizontal"/>
<LinearLayout
android:id="@+id/normal_volume_section"
@ -35,9 +34,9 @@
android:maxLines="1"/>
<sushi.hardcore.droidfs.widgets.ColoredImageButton
android:id="@+id/button_pick_directory"
android:layout_width="@dimen/image_button_size"
android:layout_height="@dimen/image_button_size"
android:onClick="pickDirectory"
android:scaleType="fitCenter"
android:background="#00000000"
android:src="@drawable/icon_folder" />