2019-11-14 14:35:08 -05:00
|
|
|
package org.thoughtcrime.securesms;
|
|
|
|
|
2020-09-26 10:35:18 -04:00
|
|
|
import android.app.Activity;
|
2020-12-19 16:54:00 -04:00
|
|
|
import android.content.Context;
|
2020-08-13 16:39:43 -03:00
|
|
|
import android.content.Intent;
|
|
|
|
import android.net.Uri;
|
2019-11-14 14:35:08 -05:00
|
|
|
import android.os.Bundle;
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
2020-09-26 10:35:18 -04:00
|
|
|
import androidx.annotation.Nullable;
|
2019-11-14 14:35:08 -05:00
|
|
|
|
2021-03-16 16:50:10 -04:00
|
|
|
import org.thoughtcrime.securesms.devicetransfer.olddevice.OldDeviceTransferLockedDialog;
|
|
|
|
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
2021-01-06 15:31:33 -05:00
|
|
|
import org.thoughtcrime.securesms.util.AppStartup;
|
2020-12-02 10:27:20 -05:00
|
|
|
import org.thoughtcrime.securesms.util.CachedInflater;
|
2020-08-13 16:39:43 -03:00
|
|
|
import org.thoughtcrime.securesms.util.CommunicationActions;
|
2019-11-14 14:35:08 -05:00
|
|
|
import org.thoughtcrime.securesms.util.DynamicNoActionBarTheme;
|
|
|
|
import org.thoughtcrime.securesms.util.DynamicTheme;
|
|
|
|
|
2020-06-22 17:01:40 -07:00
|
|
|
public class MainActivity extends PassphraseRequiredActivity {
|
2019-11-14 14:35:08 -05:00
|
|
|
|
2020-09-26 10:35:18 -04:00
|
|
|
public static final int RESULT_CONFIG_CHANGED = Activity.RESULT_FIRST_USER + 901;
|
|
|
|
|
2019-11-14 14:35:08 -05:00
|
|
|
private final DynamicTheme dynamicTheme = new DynamicNoActionBarTheme();
|
|
|
|
private final MainNavigator navigator = new MainNavigator(this);
|
|
|
|
|
2020-12-19 16:54:00 -04:00
|
|
|
public static @NonNull Intent clearTop(@NonNull Context context) {
|
|
|
|
Intent intent = new Intent(context, MainActivity.class);
|
|
|
|
|
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
|
|
|
|
Intent.FLAG_ACTIVITY_NEW_TASK |
|
|
|
|
Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
|
|
|
|
|
|
|
return intent;
|
|
|
|
}
|
|
|
|
|
2019-11-14 14:35:08 -05:00
|
|
|
@Override
|
|
|
|
protected void onCreate(Bundle savedInstanceState, boolean ready) {
|
2021-01-06 15:31:33 -05:00
|
|
|
AppStartup.getInstance().onCriticalRenderEventStart();
|
2019-11-14 14:35:08 -05:00
|
|
|
super.onCreate(savedInstanceState, ready);
|
|
|
|
setContentView(R.layout.main_activity);
|
|
|
|
|
|
|
|
navigator.onCreate(savedInstanceState);
|
2020-08-13 16:39:43 -03:00
|
|
|
|
|
|
|
handleGroupLinkInIntent(getIntent());
|
2021-02-02 16:42:47 -05:00
|
|
|
handleProxyInIntent(getIntent());
|
2020-12-02 10:27:20 -05:00
|
|
|
|
|
|
|
CachedInflater.from(this).clear();
|
2020-08-13 16:39:43 -03:00
|
|
|
}
|
|
|
|
|
2021-01-07 10:37:55 -04:00
|
|
|
@Override
|
|
|
|
public Intent getIntent() {
|
|
|
|
return super.getIntent().setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
|
|
|
|
Intent.FLAG_ACTIVITY_NEW_TASK |
|
|
|
|
Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
|
|
|
}
|
|
|
|
|
2020-08-13 16:39:43 -03:00
|
|
|
@Override
|
|
|
|
protected void onNewIntent(Intent intent) {
|
|
|
|
super.onNewIntent(intent);
|
|
|
|
handleGroupLinkInIntent(intent);
|
2021-02-02 16:42:47 -05:00
|
|
|
handleProxyInIntent(intent);
|
2019-11-14 14:35:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onPreCreate() {
|
|
|
|
super.onPreCreate();
|
|
|
|
dynamicTheme.onCreate(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onResume() {
|
|
|
|
super.onResume();
|
|
|
|
dynamicTheme.onResume(this);
|
2021-03-16 16:50:10 -04:00
|
|
|
if (SignalStore.misc().isOldDeviceTransferLocked()) {
|
|
|
|
OldDeviceTransferLockedDialog.show(getSupportFragmentManager());
|
|
|
|
}
|
2019-11-14 14:35:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onBackPressed() {
|
|
|
|
if (!navigator.onBackPressed()) {
|
|
|
|
super.onBackPressed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-26 10:35:18 -04:00
|
|
|
@Override
|
|
|
|
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
|
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
|
|
if (requestCode == MainNavigator.REQUEST_CONFIG_CHANGES && resultCode == RESULT_CONFIG_CHANGED) {
|
|
|
|
recreate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-14 14:35:08 -05:00
|
|
|
public @NonNull MainNavigator getNavigator() {
|
|
|
|
return navigator;
|
|
|
|
}
|
2020-08-13 16:39:43 -03:00
|
|
|
|
|
|
|
private void handleGroupLinkInIntent(Intent intent) {
|
|
|
|
Uri data = intent.getData();
|
|
|
|
if (data != null) {
|
|
|
|
CommunicationActions.handlePotentialGroupLinkUrl(this, data.toString());
|
|
|
|
}
|
|
|
|
}
|
2021-02-02 16:42:47 -05:00
|
|
|
|
|
|
|
private void handleProxyInIntent(Intent intent) {
|
|
|
|
Uri data = intent.getData();
|
|
|
|
if (data != null) {
|
|
|
|
CommunicationActions.handlePotentialProxyLinkUrl(this, data.toString());
|
|
|
|
}
|
|
|
|
}
|
2019-11-14 14:35:08 -05:00
|
|
|
}
|