mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Merge branch 'main' into adb/issue-4055
This commit is contained in:
@@ -81,8 +81,9 @@ public abstract class ContactSelectionActivity extends PassphraseRequiredActionB
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
super.onOptionsItemSelected(item);
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home: super.onBackPressed(); return true;
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
getOnBackPressedDispatcher().onBackPressed();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -57,6 +57,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
@@ -233,6 +234,17 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
}
|
||||
});
|
||||
|
||||
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
if (container.isInputOpen()) {
|
||||
container.hideCurrentInput(composeText);
|
||||
} else {
|
||||
handleReturnToConversationList();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
DcEventCenter eventCenter = DcHelper.getEventCenter(this);
|
||||
eventCenter.addObserver(DcContext.DC_EVENT_CHAT_MODIFIED, this);
|
||||
eventCenter.addObserver(DcContext.DC_EVENT_CHAT_EPHEMERAL_TIMER_MODIFIED, this);
|
||||
@@ -570,15 +582,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (container.isInputOpen()){
|
||||
container.hideCurrentInput(composeText);
|
||||
} else {
|
||||
handleReturnToConversationList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onKeyboardShown() {
|
||||
inputPanel.onKeyboardShown();
|
||||
|
||||
@@ -43,6 +43,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
@@ -173,6 +174,28 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||
|
||||
initializeSearchListener();
|
||||
|
||||
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
if (searchToolbar.isVisible()) {
|
||||
searchToolbar.collapse();
|
||||
} else {
|
||||
if (isRelayingMessageContent(ConversationListActivity.this)) {
|
||||
if (switchedProfile) {
|
||||
finishAffinity();
|
||||
startActivity(new Intent(ConversationListActivity.this, ConversationListActivity.class));
|
||||
return;
|
||||
} else {
|
||||
handleResetRelaying();
|
||||
}
|
||||
}
|
||||
|
||||
setEnabled(false);
|
||||
getOnBackPressedDispatcher().onBackPressed();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
TooltipCompat.setTooltipText(searchAction, getText(R.string.search_explain));
|
||||
|
||||
TooltipCompat.setTooltipText(selfAvatar, getText(R.string.switch_account));
|
||||
@@ -445,7 +468,7 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||
startActivity(new Intent(this, ProxySettingsActivity.class));
|
||||
return true;
|
||||
} else if (itemId == android.R.id.home) {
|
||||
onBackPressed();
|
||||
getOnBackPressedDispatcher().onBackPressed();
|
||||
return true;
|
||||
} else if (itemId == R.id.menu_all_media) {
|
||||
startActivity(new Intent(this, AllMediaActivity.class));
|
||||
@@ -488,7 +511,7 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||
};
|
||||
SaveAttachmentTask saveTask = new SaveAttachmentTask(this);
|
||||
saveTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, attachments);
|
||||
onBackPressed();
|
||||
getOnBackPressedDispatcher().onBackPressed();
|
||||
}
|
||||
|
||||
private void handleOpenpgp4fpr() {
|
||||
@@ -552,20 +575,6 @@ public class ConversationListActivity extends PassphraseRequiredActionBarActivit
|
||||
overridePendingTransition(R.anim.slide_from_right, R.anim.fade_scale_out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (searchToolbar.isVisible()) searchToolbar.collapse();
|
||||
else if (isRelayingMessageContent(this)) {
|
||||
if (switchedProfile) {
|
||||
finishAffinity();
|
||||
startActivity(new Intent(this, ConversationListActivity.class));
|
||||
} else {
|
||||
handleResetRelaying();
|
||||
finish();
|
||||
}
|
||||
} else super.onBackPressed();
|
||||
}
|
||||
|
||||
private void createChat() {
|
||||
Intent intent = new Intent(this, NewConversationActivity.class);
|
||||
if (isRelayingMessageContent(this)) {
|
||||
|
||||
@@ -12,6 +12,8 @@ import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
|
||||
import com.b44t.messenger.DcChat;
|
||||
|
||||
import org.thoughtcrime.securesms.connect.DcHelper;
|
||||
@@ -33,6 +35,21 @@ public class ConversationListArchiveActivity extends PassphraseRequiredActionBar
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean(ConversationListFragment.ARCHIVE, true);
|
||||
initFragment(R.id.fragment, new ConversationListFragment(), bundle);
|
||||
|
||||
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
if (!isRelayingMessageContent(ConversationListArchiveActivity.this)) {
|
||||
// Load the ConversationListActivity in case it's not existent for some reason
|
||||
Intent intent = new Intent(ConversationListArchiveActivity.this, ConversationListActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
setEnabled(false);
|
||||
getOnBackPressedDispatcher().onBackPressed();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,7 +80,7 @@ public class ConversationListArchiveActivity extends PassphraseRequiredActionBar
|
||||
|
||||
int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
onBackPressed();
|
||||
getOnBackPressedDispatcher().onBackPressed();
|
||||
return true;
|
||||
} else if (itemId == R.id.mark_as_read) {
|
||||
DcHelper.getContext(this).marknoticedChat(DcChat.DC_CHAT_ID_ARCHIVED_LINK);
|
||||
@@ -73,20 +90,6 @@ public class ConversationListArchiveActivity extends PassphraseRequiredActionBar
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (isRelayingMessageContent(this)) {
|
||||
// Go back to the ConversationListRelayingActivity
|
||||
super.onBackPressed();
|
||||
} else {
|
||||
// Load the ConversationListActivity in case it's not existent for some reason
|
||||
Intent intent = new Intent(this, ConversationListActivity.class);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateConversation(int chatId) {
|
||||
Intent intent = new Intent(this, ConversationActivity.class);
|
||||
|
||||
@@ -20,6 +20,7 @@ import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.loader.app.LoaderManager;
|
||||
|
||||
@@ -79,6 +80,18 @@ public class CreateProfileActivity extends BaseActionBarActivity {
|
||||
initializeProfileName();
|
||||
initializeProfileAvatar();
|
||||
initializeStatusText();
|
||||
|
||||
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
if (container.isInputOpen()) {
|
||||
container.hideCurrentInput(name);
|
||||
} else {
|
||||
setEnabled(false);
|
||||
getOnBackPressedDispatcher().onBackPressed();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -93,7 +106,7 @@ public class CreateProfileActivity extends BaseActionBarActivity {
|
||||
super.onOptionsItemSelected(item);
|
||||
int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
onBackPressed();
|
||||
getOnBackPressedDispatcher().onBackPressed();
|
||||
return true;
|
||||
} else if (itemId == R.id.menu_create_profile) {
|
||||
updateProfile();
|
||||
@@ -102,15 +115,6 @@ public class CreateProfileActivity extends BaseActionBarActivity {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (container.isInputOpen()) {
|
||||
container.hideCurrentInput(name);
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
|
||||
Permissions.onRequestPermissionsResult(this, requestCode, permissions, grantResults);
|
||||
|
||||
@@ -5,6 +5,8 @@ import android.os.Bundle;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
|
||||
import org.thoughtcrime.securesms.util.TextUtil;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
@@ -45,6 +47,18 @@ public class LocalHelpActivity extends WebViewActivity
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
if (webView.canGoBack()) {
|
||||
webView.goBack();
|
||||
} else {
|
||||
setEnabled(false);
|
||||
getOnBackPressedDispatcher().onBackPressed();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
webView.loadUrl("file:///android_asset/" + helpPath.replace("LANG", helpLang) + (section!=null? section : ""));
|
||||
}
|
||||
|
||||
@@ -100,15 +114,6 @@ public class LocalHelpActivity extends WebViewActivity
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (webView.canGoBack()) {
|
||||
webView.goBack();
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean assetExists(String fileName) {
|
||||
// test using AssetManager.open();
|
||||
// AssetManager.list() is unreliable eg. on my Android 7 Moto G
|
||||
|
||||
@@ -15,6 +15,7 @@ import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
@@ -90,6 +91,19 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
|
||||
registerForEvents();
|
||||
initializeActionBar();
|
||||
|
||||
getOnBackPressedDispatcher().addCallback(this, new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
AccountManager accountManager = AccountManager.getInstance();
|
||||
if (accountManager.canRollbackAccountCreation(WelcomeActivity.this)) {
|
||||
accountManager.rollbackAccountCreation(WelcomeActivity.this);
|
||||
} else {
|
||||
setEnabled(false);
|
||||
getOnBackPressedDispatcher().onBackPressed();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
DcHelper.maybeShowMigrationError(this);
|
||||
}
|
||||
|
||||
@@ -135,7 +149,7 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
onBackPressed();
|
||||
getOnBackPressedDispatcher().onBackPressed();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -384,14 +398,4 @@ public class WelcomeActivity extends BaseActionBarActivity implements DcEventCen
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
AccountManager accountManager = AccountManager.getInstance();
|
||||
if (accountManager.canRollbackAccountCreation(this)) {
|
||||
accountManager.rollbackAccountCreation(this);
|
||||
} else {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.activity.OnBackPressedCallback;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
@@ -56,6 +57,8 @@ public class BackupTransferActivity extends BaseActionBarActivity {
|
||||
private boolean notificationControllerClosed = false;
|
||||
public boolean warnAboutCopiedQrCodeOnAbort = false;
|
||||
|
||||
private OnBackPressedCallback backPressedCallback;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
@@ -89,6 +92,15 @@ public class BackupTransferActivity extends BaseActionBarActivity {
|
||||
|
||||
// add padding to avoid content hidden behind system bars
|
||||
ViewUtil.applyWindowInsets(findViewById(R.id.backup_provider_fragment));
|
||||
|
||||
backPressedCallback = new OnBackPressedCallback(true) {
|
||||
@Override
|
||||
public void handleOnBackPressed() {
|
||||
finishOrAskToFinish();
|
||||
}
|
||||
};
|
||||
|
||||
getOnBackPressedDispatcher().addCallback(this, backPressedCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,18 +119,13 @@ public class BackupTransferActivity extends BaseActionBarActivity {
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
finishOrAskToFinish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
super.onOptionsItemSelected(item);
|
||||
|
||||
int itemId = item.getItemId();
|
||||
if (itemId == android.R.id.home) {
|
||||
finishOrAskToFinish();
|
||||
getOnBackPressedDispatcher().onBackPressed();
|
||||
return true;
|
||||
} else if (itemId == R.id.troubleshooting) {
|
||||
DcHelper.openHelp(this, "#multiclient");
|
||||
|
||||
@@ -27,11 +27,4 @@ public class ScribbleActivity extends PassphraseRequiredActionBarActivity {
|
||||
boolean cropAvatar = getIntent().getBooleanExtra(CROP_AVATAR, false);
|
||||
imageEditorFragment = initFragment(R.id.scribble_container, ImageEditorFragment.newInstance(getIntent().getData(), cropAvatar));
|
||||
}
|
||||
|
||||
/* @Override
|
||||
public void onBackPressed() {
|
||||
if (!imageEditorFragment.onBackPressed()) {
|
||||
super.onBackPressed();
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class StickerSelectActivity extends FragmentActivity implements StickerSe
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
onBackPressed();
|
||||
getOnBackPressedDispatcher().onBackPressed();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
|
||||
Reference in New Issue
Block a user