Made suggested changes in FullScreenImageActivity.kt, ConversationsListActivity.kt and in some files Signed-off-by: Ezhil Shanmugham ezhil56x.contact@gmail.com

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Ezhil Shanmugham 2023-05-22 18:47:47 +05:30 committed by Andy Scherzinger
parent d4a4472968
commit 64fa8e830b
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
10 changed files with 75 additions and 73 deletions

View File

@ -4,6 +4,8 @@
* @author Marcel Hibbe
* @author Dariusz Olszewski
* @author Andy Scherzinger
* @author Ezhil Shanmugham
* Copyright (C) 2023 Ezhil Shanmugham <ezhil56x.contact@gmail.com>
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
* Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de>
* Copyright (C) 2021 Dariusz Olszewski
@ -45,12 +47,6 @@ import java.io.File
class FullScreenImageActivity : AppCompatActivity() {
lateinit var binding: ActivityFullScreenImageBinding
private val callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
finish()
}
}
private lateinit var path: String
private var showFullscreen = false
@ -61,8 +57,7 @@ class FullScreenImageActivity : AppCompatActivity() {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return if (item.itemId == android.R.id.home) {
// onBackPressed()
onBackPressedDispatcher.addCallback(this, callback)
onBackPressedDispatcher.onBackPressed()
true
} else if (item.itemId == R.id.share) {
val shareUri = FileProvider.getUriForFile(
@ -125,6 +120,13 @@ class FullScreenImageActivity : AppCompatActivity() {
binding.photoView.visibility = View.VISIBLE
displayImage(path)
}
val callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
finish()
}
}
onBackPressedDispatcher.addCallback(this, callback)
}
private fun displayImage(path: String) {

View File

@ -3,8 +3,10 @@
*
* @author Marcel Hibbe
* @author Andy Scherzinger
* @author Ezhil Shanmugham
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
* Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de>
* Copyright (C) 2023 Ezhil Shanmugham <ezhil56x.contact@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -47,12 +49,6 @@ import java.io.File
class FullScreenMediaActivity : AppCompatActivity(), Player.Listener {
lateinit var binding: ActivityFullScreenMediaBinding
private val callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
finish()
}
}
private lateinit var path: String
private lateinit var player: SimpleExoPlayer
@ -63,8 +59,7 @@ class FullScreenMediaActivity : AppCompatActivity(), Player.Listener {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return if (item.itemId == android.R.id.home) {
// onBackPressed()
onBackPressedDispatcher.addCallback(this, callback)
onBackPressedDispatcher.onBackPressed()
true
} else if (item.itemId == R.id.share) {
val shareUri = FileProvider.getUriForFile(
@ -120,6 +115,13 @@ class FullScreenMediaActivity : AppCompatActivity(), Player.Listener {
}
}
)
val callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
finish()
}
}
onBackPressedDispatcher.addCallback(this, callback)
}
override fun onStart() {

View File

@ -3,8 +3,10 @@
*
* @author Marcel Hibbe
* @author Andy Scherzinger
* @author Ezhil Shanmugham
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
* Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de>
* Copyright (C) 2023 Ezhil Shanmugham <ezhil56x.contact@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -46,12 +48,6 @@ import javax.inject.Inject
class FullScreenTextViewerActivity : AppCompatActivity() {
lateinit var binding: ActivityFullScreenTextBinding
private val callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
finish()
}
}
@Inject
lateinit var viewThemeUtils: ViewThemeUtils
@ -64,8 +60,7 @@ class FullScreenTextViewerActivity : AppCompatActivity() {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return if (item.itemId == android.R.id.home) {
// onBackPressed()
onBackPressedDispatcher.addCallback(this, callback)
onBackPressedDispatcher.onBackPressed()
true
} else if (item.itemId == R.id.share) {
val shareUri = FileProvider.getUriForFile(
@ -122,6 +117,13 @@ class FullScreenTextViewerActivity : AppCompatActivity() {
ResourcesCompat.getColor(resources, R.color.bg_default, null)
)
}
val callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
finish()
}
}
onBackPressedDispatcher.addCallback(this, callback)
}
private fun readFile(fileName: String) = File(fileName).inputStream().readBytes().toString(Charsets.UTF_8)

View File

@ -4,9 +4,11 @@
* @author Mario Danic
* @author Andy Scherzinger
* @author Marcel Hibbe
* @author Ezhil Shanmugham
* Copyright (C) 2023 Marcel Hibbe <dev@mhibbe.de>
* Copyright (C) 2021 Andy Scherzinger (infoi@andy-scherzinger.de)
* Copyright (C) 2017 Mario Danic (mario@lovelyhq.com)
* Copyright (C) 2023 Ezhil Shanmugham <ezhil56x.contact@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -75,12 +77,6 @@ import javax.inject.Inject
class MainActivity : BaseActivity(), ActionBarProvider {
lateinit var binding: ActivityMainBinding
private val callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
finish()
}
}
@Inject
lateinit var ncApi: NcApi
@ -143,6 +139,13 @@ class MainActivity : BaseActivity(), ActionBarProvider {
}
})
}
val callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
finish()
}
}
onBackPressedDispatcher.addCallback(this, callback)
}
fun lockScreenIfConditionsApply() {
@ -360,10 +363,9 @@ class MainActivity : BaseActivity(), ActionBarProvider {
}
}
override fun onBackPressed() {
fun handleOnBackPressed() {
if (!router!!.handleBack()) {
// super.onBackPressed()
onBackPressedDispatcher.addCallback(this, callback)
onBackPressedDispatcher.onBackPressed()
}
}

View File

@ -5,10 +5,12 @@
* @author Marcel Hibbe
* @author Andy Scherzinger
* @author Tim Krüger
* @author Ezhil Shanmugham
* Copyright (C) 2021-2022 Tim Krüger <t@timkrueger.me>
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
* Copyright (C) 2021-2022 Marcel Hibbe <dev@mhibbe.de>
* Copyright (C) 2017-2019 Mario Danic <mario@lovelyhq.com>
* Copyright (C) 2023 Ezhil Shanmugham <ezhil56x.contact@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -612,7 +614,7 @@ class ChatActivity :
private fun setupActionBar() {
setSupportActionBar(binding.chatToolbar)
binding.chatToolbar.setNavigationOnClickListener {
onBackPressed()
handleOnBackPressed()
}
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowHomeEnabled(true)
@ -621,7 +623,7 @@ class ChatActivity :
viewThemeUtils.material.themeToolbar(binding.chatToolbar)
}
override fun onBackPressed() {
fun handleOnBackPressed() {
val intent = Intent(this, ConversationsListActivity::class.java)
intent.putExtras(Bundle())
startActivity(intent)

View File

@ -146,12 +146,6 @@ class ConversationsListActivity :
private lateinit var binding: ControllerConversationsRvBinding
private val callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
finish()
}
}
@Inject
lateinit var userManager: UserManager
@ -195,6 +189,8 @@ class ConversationsListActivity :
private var searchHelper: MessageSearchHelper? = null
private var searchViewDisposable: Disposable? = null
private lateinit var callback: OnBackPressedCallback
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
@ -207,6 +203,13 @@ class ConversationsListActivity :
viewThemeUtils.material.themeSearchBarText(binding.searchText)
forwardMessage = intent.getBooleanExtra(KEY_FORWARD_MSG_FLAG, false)
callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
finish()
}
}
onBackPressedDispatcher.addCallback(this, callback)
}
override fun onResume() {
@ -1367,22 +1370,6 @@ class ConversationsListActivity :
showErrorDialog()
}
override fun onBackPressed() {
val callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
finish()
}
}
onBackPressedDispatcher.addCallback(this, callback)
// TODO: replace this when conductor is removed. For now it avoids loading the MainActivity which has no UI.
callback.isEnabled = true
callback.handleOnBackPressed()
finishAffinity()
}
companion object {
const val TAG = "ConvListController"
const val UNREAD_BUBBLE_DELAY = 2500

View File

@ -2,7 +2,9 @@
* Nextcloud Talk application
*
* @author Marcel Hibbe
* @author Ezhil Shanmugham
* Copyright (C) 2021 Marcel Hibbe <dev@mhibbe.de>
* Copyright (C) 2023 Ezhil Shanmugham <ezhil56x.contact@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -175,7 +177,7 @@ class LocationPickerActivity :
private fun setupActionBar() {
setSupportActionBar(binding.locationPickerToolbar)
binding.locationPickerToolbar.setNavigationOnClickListener {
onBackPressed()
handleOnBackPressed()
}
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowHomeEnabled(true)
@ -572,9 +574,9 @@ class LocationPickerActivity :
// empty
}
override fun onBackPressed() {
fun handleOnBackPressed() {
setResult(Activity.RESULT_CANCELED)
finish()
finishAffinity()
}
companion object {

View File

@ -2,8 +2,10 @@
* Nextcloud Talk application
*
* @author Álvaro Brey
* @author Ezhil Shanmugham
* Copyright (C) 2022 Álvaro Brey
* Copyright (C) 2022 Nextcloud GmbH
* Copyright (C) 2023 Ezhil Shanmugham <ezhil56x.contact@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -210,7 +212,7 @@ class MessageSearchActivity : BaseActivity() {
}
override fun onMenuItemActionCollapse(item: MenuItem): Boolean {
onBackPressed()
handleOnBackPressed()
return false
}
})
@ -236,15 +238,15 @@ class MessageSearchActivity : BaseActivity() {
.subscribe { newText -> viewModel.onQueryTextChange(newText) }
}
override fun onBackPressed() {
fun handleOnBackPressed() {
setResult(Activity.RESULT_CANCELED)
finish()
finishAffinity()
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
android.R.id.home -> {
onBackPressed()
handleOnBackPressed()
true
}
else -> super.onOptionsItemSelected(item)

View File

@ -194,7 +194,7 @@ class RemoteFileBrowserActivity : AppCompatActivity(), SelectionInterface, Swipe
return true
}
override fun onBackPressed() {
fun handleOnBackPressed() {
val callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
setResult(Activity.RESULT_CANCELED)
@ -223,7 +223,7 @@ class RemoteFileBrowserActivity : AppCompatActivity(), SelectionInterface, Swipe
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
android.R.id.home -> {
onBackPressed()
handleOnBackPressed()
true
}
R.id.files_selection_done -> {

View File

@ -56,12 +56,6 @@ import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
class SharedItemsActivity : AppCompatActivity() {
private val callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
finish()
}
}
@Inject
lateinit var viewModelFactory: ViewModelProvider.Factory
@ -112,6 +106,13 @@ class SharedItemsActivity : AppCompatActivity() {
})
viewModel.initialize(user, roomToken)
val callback = object : OnBackPressedCallback(true) {
override fun handleOnBackPressed() {
finish()
}
}
onBackPressedDispatcher.addCallback(this, callback)
}
private fun handleModelChange(
@ -255,7 +256,7 @@ class SharedItemsActivity : AppCompatActivity() {
override fun onOptionsItemSelected(item: MenuItem): Boolean {
return if (item.itemId == android.R.id.home) {
onBackPressedDispatcher.addCallback(this, callback)
onBackPressedDispatcher.onBackPressed()
true
} else {
super.onOptionsItemSelected(item)