mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 19:49:33 +01:00
Merge pull request #3036 from nextcloud/issue-2961
Replace deprecated onBackPressed
This commit is contained in:
commit
ac5ebb3e12
@ -301,7 +301,7 @@ dependencies {
|
||||
gplayImplementation 'com.google.android.gms:play-services-base:18.2.0'
|
||||
gplayImplementation "com.google.firebase:firebase-messaging:23.1.2"
|
||||
|
||||
// implementation 'androidx.activity:activity-ktx:1.4.0'
|
||||
implementation 'androidx.activity:activity-ktx:1.7.1'
|
||||
|
||||
implementation 'com.github.nextcloud.android-common:ui:0.10.0'
|
||||
|
||||
|
@ -35,6 +35,8 @@ import android.view.WindowManager;
|
||||
|
||||
import com.nextcloud.talk.BuildConfig;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
|
||||
public abstract class CallBaseActivity extends BaseActivity {
|
||||
|
||||
public static final String TAG = "CallBaseActivity";
|
||||
@ -43,6 +45,16 @@ public abstract class CallBaseActivity extends BaseActivity {
|
||||
public Boolean isInPipMode = Boolean.FALSE;
|
||||
long onCreateTime;
|
||||
|
||||
|
||||
private OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
if (isPipModePossible()) {
|
||||
enterPipMode();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@ -58,6 +70,8 @@ public abstract class CallBaseActivity extends BaseActivity {
|
||||
if (isGreaterEqualOreo() && isPipModePossible()) {
|
||||
mPictureInPictureParamsBuilder = new PictureInPictureParams.Builder();
|
||||
}
|
||||
|
||||
getOnBackPressedDispatcher().addCallback(this, onBackPressedCallback);
|
||||
}
|
||||
|
||||
void hideNavigationIfNoPipAvailable(){
|
||||
@ -101,13 +115,6 @@ public abstract class CallBaseActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (isPipModePossible()) {
|
||||
enterPipMode();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onUserLeaveHint() {
|
||||
long onUserLeaveHintTime = System.currentTimeMillis();
|
||||
|
@ -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
|
||||
@ -43,6 +45,7 @@ import java.io.File
|
||||
|
||||
class FullScreenImageActivity : AppCompatActivity() {
|
||||
lateinit var binding: ActivityFullScreenImageBinding
|
||||
|
||||
private lateinit var path: String
|
||||
private var showFullscreen = false
|
||||
|
||||
@ -53,7 +56,7 @@ class FullScreenImageActivity : AppCompatActivity() {
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return if (item.itemId == android.R.id.home) {
|
||||
onBackPressed()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
true
|
||||
} else if (item.itemId == R.id.share) {
|
||||
val shareUri = FileProvider.getUriForFile(
|
||||
|
@ -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
|
||||
@ -56,7 +58,7 @@ class FullScreenMediaActivity : AppCompatActivity(), Player.Listener {
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return if (item.itemId == android.R.id.home) {
|
||||
onBackPressed()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
true
|
||||
} else if (item.itemId == R.id.share) {
|
||||
val shareUri = FileProvider.getUriForFile(
|
||||
|
@ -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
|
||||
@ -57,7 +59,7 @@ class FullScreenTextViewerActivity : AppCompatActivity() {
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return if (item.itemId == android.R.id.home) {
|
||||
onBackPressed()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
true
|
||||
} else if (item.itemId == R.id.share) {
|
||||
val shareUri = FileProvider.getUriForFile(
|
||||
|
@ -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
|
||||
@ -30,6 +32,7 @@ import android.os.Bundle
|
||||
import android.provider.ContactsContract
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.lifecycle.DefaultLifecycleObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.ProcessLifecycleOwner
|
||||
@ -82,6 +85,14 @@ class MainActivity : BaseActivity(), ActionBarProvider {
|
||||
|
||||
private var router: Router? = null
|
||||
|
||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
if (!router!!.handleBack()) {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
Log.d(TAG, "onCreate: Activity: " + System.identityHashCode(this).toString())
|
||||
@ -136,6 +147,8 @@ class MainActivity : BaseActivity(), ActionBarProvider {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||
}
|
||||
|
||||
fun lockScreenIfConditionsApply() {
|
||||
@ -353,12 +366,6 @@ class MainActivity : BaseActivity(), ActionBarProvider {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
if (!router!!.handleBack()) {
|
||||
super.onBackPressed()
|
||||
}
|
||||
}
|
||||
|
||||
private fun logRouterBackStack(router: Router) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
val backstack = router.backstack
|
||||
|
@ -56,6 +56,7 @@ import java.util.concurrent.ExecutionException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.OptIn;
|
||||
@ -76,7 +77,6 @@ import static com.nextcloud.talk.utils.Mimetype.IMAGE_JPEG;
|
||||
|
||||
@AutoInjector(NextcloudTalkApplication.class)
|
||||
public class TakePhotoActivity extends AppCompatActivity {
|
||||
|
||||
private static final String TAG = TakePhotoActivity.class.getSimpleName();
|
||||
|
||||
private static final float MAX_SCALE = 6.0f;
|
||||
@ -95,6 +95,23 @@ public class TakePhotoActivity extends AppCompatActivity {
|
||||
@Inject
|
||||
ViewThemeUtils viewThemeUtils;
|
||||
|
||||
private OnBackPressedCallback onBackPressedCallback = new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
Uri uri = (Uri) binding.photoPreview.getTag();
|
||||
|
||||
if (uri != null) {
|
||||
File photoFile = new File(uri.getPath());
|
||||
if (!photoFile.delete()) {
|
||||
Log.w(TAG, "Error deleting temp camera image");
|
||||
}
|
||||
binding.photoPreview.setTag(null);
|
||||
}
|
||||
|
||||
finish();
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -221,21 +238,8 @@ public class TakePhotoActivity extends AppCompatActivity {
|
||||
finish();
|
||||
}
|
||||
}, ContextCompat.getMainExecutor(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
Uri uri = (Uri) binding.photoPreview.getTag();
|
||||
|
||||
if (uri != null) {
|
||||
File photoFile = new File(uri.getPath());
|
||||
if (!photoFile.delete()) {
|
||||
Log.w(TAG, "Error deleting temp camera image");
|
||||
}
|
||||
binding.photoPreview.setTag(null);
|
||||
}
|
||||
|
||||
super.onBackPressed();
|
||||
getOnBackPressedDispatcher().addCallback(this, onBackPressedCallback);
|
||||
}
|
||||
|
||||
private void showCameraElements() {
|
||||
|
@ -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
|
||||
@ -72,6 +74,7 @@ import android.widget.ImageView
|
||||
import android.widget.PopupMenu
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.view.ContextThemeWrapper
|
||||
import androidx.core.content.ContextCompat
|
||||
@ -307,6 +310,14 @@ class ChatActivity :
|
||||
|
||||
private var videoURI: Uri? = null
|
||||
|
||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
val intent = Intent(this@ChatActivity, ConversationsListActivity::class.java)
|
||||
intent.putExtras(Bundle())
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
var typingTimer: CountDownTimer? = null
|
||||
val typingParticipants = HashMap<String, String>()
|
||||
|
||||
@ -360,6 +371,8 @@ class ChatActivity :
|
||||
|
||||
initAdapter()
|
||||
binding.messagesListView.setAdapter(adapter)
|
||||
|
||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent) {
|
||||
@ -612,7 +625,7 @@ class ChatActivity :
|
||||
private fun setupActionBar() {
|
||||
setSupportActionBar(binding.chatToolbar)
|
||||
binding.chatToolbar.setNavigationOnClickListener {
|
||||
onBackPressed()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
supportActionBar?.setDisplayShowHomeEnabled(true)
|
||||
@ -621,12 +634,6 @@ class ChatActivity :
|
||||
viewThemeUtils.material.themeToolbar(binding.chatToolbar)
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
val intent = Intent(this, ConversationsListActivity::class.java)
|
||||
intent.putExtras(Bundle())
|
||||
startActivity(intent)
|
||||
}
|
||||
|
||||
private fun initAdapter() {
|
||||
val senderId = if (!conversationUser!!.userId.equals("?")) {
|
||||
"users/" + conversationUser!!.userId
|
||||
|
@ -188,7 +188,7 @@ class ContactsActivity :
|
||||
private fun setupActionBar() {
|
||||
setSupportActionBar(binding.contactsToolbar)
|
||||
binding.contactsToolbar.setNavigationOnClickListener {
|
||||
onBackPressed()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
supportActionBar?.setDisplayShowHomeEnabled(true)
|
||||
|
@ -5,10 +5,12 @@
|
||||
* @author Andy Scherzinger
|
||||
* @author Tim Krüger
|
||||
* @author Marcel Hibbe
|
||||
* @author Ezhil Shanmugham
|
||||
* Copyright (C) 2022-2023 Marcel Hibbe (dev@mhibbe.de)
|
||||
* Copyright (C) 2021-2022 Tim Krüger <t@timkrueger.me>
|
||||
* Copyright (C) 2021 Andy Scherzinger (info@andy-scherzinger.de)
|
||||
* Copyright (C) 2017-2018 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
|
||||
@ -193,7 +195,7 @@ class ConversationInfoActivity :
|
||||
private fun setupActionBar() {
|
||||
setSupportActionBar(binding.conversationInfoToolbar)
|
||||
binding.conversationInfoToolbar.setNavigationOnClickListener {
|
||||
onBackPressed()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
supportActionBar?.setDisplayShowHomeEnabled(true)
|
||||
|
@ -2,7 +2,9 @@
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Marcel Hibbe
|
||||
* @author Ezhil Shanmugham
|
||||
* Copyright (C) 2023 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
|
||||
@ -149,7 +151,7 @@ class ConversationInfoEditActivity :
|
||||
private fun setupActionBar() {
|
||||
setSupportActionBar(binding.conversationInfoEditToolbar)
|
||||
binding.conversationInfoEditToolbar.setNavigationOnClickListener {
|
||||
onBackPressed()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
supportActionBar?.setDisplayShowHomeEnabled(true)
|
||||
|
@ -5,10 +5,12 @@
|
||||
* @author Andy Scherzinger
|
||||
* @author Marcel Hibbe
|
||||
* @author Mario Danic
|
||||
* @author Ezhil Shanmugham
|
||||
* Copyright (C) 2022 Álvaro Brey <alvaro.brey@nextcloud.com>
|
||||
* Copyright (C) 2022 Andy Scherzinger (info@andy-scherzinger.de)
|
||||
* Copyright (C) 2022 Marcel Hibbe (dev@mhibbe.de)
|
||||
* Copyright (C) 2017-2020 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
|
||||
@ -47,6 +49,7 @@ import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.core.view.MenuItemCompat
|
||||
@ -186,6 +189,13 @@ class ConversationsListActivity :
|
||||
private var searchHelper: MessageSearchHelper? = null
|
||||
private var searchViewDisposable: Disposable? = null
|
||||
|
||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
// TODO: replace this when conductor is removed. For now it avoids to load the MainActiviy which has no UI.
|
||||
finishAffinity()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
|
||||
@ -198,6 +208,8 @@ class ConversationsListActivity :
|
||||
viewThemeUtils.material.themeSearchBarText(binding.searchText)
|
||||
|
||||
forwardMessage = intent.getBooleanExtra(KEY_FORWARD_MSG_FLAG, false)
|
||||
|
||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
@ -244,7 +256,7 @@ class ConversationsListActivity :
|
||||
private fun setupActionBar() {
|
||||
setSupportActionBar(binding.conversationListToolbar)
|
||||
binding.conversationListToolbar.setNavigationOnClickListener {
|
||||
onBackPressed()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
supportActionBar?.setDisplayShowHomeEnabled(true)
|
||||
@ -1358,13 +1370,6 @@ class ConversationsListActivity :
|
||||
showErrorDialog()
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
super.onBackPressed()
|
||||
|
||||
// TODO: replace this when conductor is removed. For now it avoids to load the MainActiviy which has no UI.
|
||||
finishAffinity()
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAG = "ConvListController"
|
||||
const val UNREAD_BUBBLE_DELAY = 2500
|
||||
|
@ -123,7 +123,7 @@ class GeocodingActivity :
|
||||
private fun setupActionBar() {
|
||||
setSupportActionBar(binding.geocodingToolbar)
|
||||
binding.geocodingToolbar.setNavigationOnClickListener {
|
||||
onBackPressed()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
supportActionBar?.setDisplayShowHomeEnabled(true)
|
||||
|
@ -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
|
||||
@ -39,6 +41,7 @@ import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.core.content.PermissionChecker
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
@ -115,6 +118,13 @@ class LocationPickerActivity :
|
||||
var searchItem: MenuItem? = null
|
||||
var searchView: SearchView? = null
|
||||
|
||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
setResult(Activity.RESULT_CANCELED)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
|
||||
@ -135,6 +145,8 @@ class LocationPickerActivity :
|
||||
setupSystemColors()
|
||||
|
||||
getInstance().load(context, PreferenceManager.getDefaultSharedPreferences(context))
|
||||
|
||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
@ -175,7 +187,7 @@ class LocationPickerActivity :
|
||||
private fun setupActionBar() {
|
||||
setSupportActionBar(binding.locationPickerToolbar)
|
||||
binding.locationPickerToolbar.setNavigationOnClickListener {
|
||||
onBackPressed()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
supportActionBar?.setDisplayShowHomeEnabled(true)
|
||||
@ -572,11 +584,6 @@ class LocationPickerActivity :
|
||||
// empty
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
setResult(Activity.RESULT_CANCELED)
|
||||
finish()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val TAG = LocationPickerActivity::class.java.simpleName
|
||||
private const val REQUEST_PERMISSIONS_REQUEST_CODE = 1
|
||||
|
@ -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
|
||||
@ -29,6 +31,7 @@ import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import autodagger.AutoInjector
|
||||
@ -72,6 +75,13 @@ class MessageSearchActivity : BaseActivity() {
|
||||
private var searchViewDisposable: Disposable? = null
|
||||
private var adapter: FlexibleAdapter<AbstractFlexibleItem<*>>? = null
|
||||
|
||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
setResult(Activity.RESULT_CANCELED)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
|
||||
@ -90,6 +100,8 @@ class MessageSearchActivity : BaseActivity() {
|
||||
binding.swipeRefreshLayout.setOnRefreshListener {
|
||||
viewModel.refresh(searchView.query?.toString())
|
||||
}
|
||||
|
||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||
}
|
||||
|
||||
private fun setupActionBar() {
|
||||
@ -210,7 +222,7 @@ class MessageSearchActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
override fun onMenuItemActionCollapse(item: MenuItem): Boolean {
|
||||
onBackPressed()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
return false
|
||||
}
|
||||
})
|
||||
@ -236,15 +248,10 @@ class MessageSearchActivity : BaseActivity() {
|
||||
.subscribe { newText -> viewModel.onQueryTextChange(newText) }
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
setResult(Activity.RESULT_CANCELED)
|
||||
finish()
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
|
@ -4,9 +4,11 @@
|
||||
* @author Tobias Kaminsky
|
||||
* @author Andy Scherzinger
|
||||
* @author Tim Krüger
|
||||
* @author Ezhil Shanmugham
|
||||
* Copyright (C) 2022 Tim Krüger <t@timkrueger.me>
|
||||
* Copyright (C) 2022 Andy Scherzinger <info@andy-scherzinger.de>
|
||||
* Copyright (C) 2021 Tobias Kaminsky <tobias.kaminsky@nextcloud.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
|
||||
@ -185,7 +187,7 @@ class ProfileActivity : BaseActivity() {
|
||||
private fun setupActionBar() {
|
||||
setSupportActionBar(binding.profileToolbar)
|
||||
binding.profileToolbar.setNavigationOnClickListener {
|
||||
onBackPressed()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
supportActionBar?.setDisplayShowHomeEnabled(true)
|
||||
|
@ -3,8 +3,10 @@
|
||||
*
|
||||
* @author Andy Scherzinger
|
||||
* @author Álvaro Brey
|
||||
* @author Ezhil Shanmugham
|
||||
* Copyright (C) 2022 Andy Scherzinger <info@andy-scherzinger.de>
|
||||
* Copyright (C) 2022 Álvaro Brey <alvaro.brey@nextcloud.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
|
||||
@ -30,6 +32,7 @@ import android.util.Log
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.fragment.app.DialogFragment
|
||||
@ -73,6 +76,13 @@ class RemoteFileBrowserActivity : AppCompatActivity(), SelectionInterface, Swipe
|
||||
|
||||
private var filesSelectionDoneMenuItem: MenuItem? = null
|
||||
|
||||
private val onBackPressedCallback = object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
setResult(Activity.RESULT_CANCELED)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
|
||||
@ -110,6 +120,8 @@ class RemoteFileBrowserActivity : AppCompatActivity(), SelectionInterface, Swipe
|
||||
binding.sortButton.setOnClickListener { changeSorting() }
|
||||
|
||||
viewModel.loadItems()
|
||||
|
||||
onBackPressedDispatcher.addCallback(this, onBackPressedCallback)
|
||||
}
|
||||
|
||||
private fun initViewModel(mimeTypeSelectionFilter: String?) {
|
||||
@ -191,11 +203,6 @@ class RemoteFileBrowserActivity : AppCompatActivity(), SelectionInterface, Swipe
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
setResult(Activity.RESULT_CANCELED)
|
||||
super.onBackPressed()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
refreshCurrentPath()
|
||||
@ -213,7 +220,7 @@ class RemoteFileBrowserActivity : AppCompatActivity(), SelectionInterface, Swipe
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
android.R.id.home -> {
|
||||
onBackPressed()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
true
|
||||
}
|
||||
R.id.files_selection_done -> {
|
||||
|
@ -4,9 +4,11 @@
|
||||
* @author Andy Scherzinger
|
||||
* @author Mario Danic
|
||||
* @author Tim Krüger
|
||||
* @author Ezhil Shanmugham
|
||||
* Copyright (C) 2021 Tim Krüger <t@timkrueger.me>
|
||||
* Copyright (C) 2021-2022 Andy Scherzinger <info@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
|
||||
@ -246,7 +248,7 @@ class SettingsActivity : BaseActivity() {
|
||||
private fun setupActionBar() {
|
||||
setSupportActionBar(binding.settingsToolbar)
|
||||
binding.settingsToolbar.setNavigationOnClickListener {
|
||||
onBackPressed()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
supportActionBar?.setDisplayShowHomeEnabled(true)
|
||||
|
@ -4,9 +4,11 @@
|
||||
* @author Tim Krüger
|
||||
* @author Álvaro Brey
|
||||
* @author Marcel Hibbe
|
||||
* @author Ezhil Shanmugham
|
||||
* Copyright (C) 2023 Marcel Hibbe <dev@mhibbe.de>
|
||||
* Copyright (C) 2022 Álvaro Brey
|
||||
* Copyright (C) 2022 Tim Krüger <t@timkrueger.me>
|
||||
* 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
|
||||
@ -246,7 +248,7 @@ class SharedItemsActivity : AppCompatActivity() {
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return if (item.itemId == android.R.id.home) {
|
||||
onBackPressed()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
true
|
||||
} else {
|
||||
super.onOptionsItemSelected(item)
|
||||
|
@ -127,7 +127,7 @@ class TranslateActivity : BaseActivity() {
|
||||
private fun setupActionBar() {
|
||||
setSupportActionBar(binding.translationToolbar)
|
||||
binding.translationToolbar.setNavigationOnClickListener {
|
||||
onBackPressed()
|
||||
onBackPressedDispatcher.onBackPressed()
|
||||
}
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
supportActionBar?.setDisplayShowHomeEnabled(true)
|
||||
|
Loading…
Reference in New Issue
Block a user