2018-08-06 14:42:22 -04:00
|
|
|
package org.thoughtcrime.securesms;
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.support.annotation.NonNull;
|
|
|
|
import android.support.annotation.Nullable;
|
|
|
|
import android.support.v4.app.TaskStackBuilder;
|
|
|
|
import android.support.v7.app.AppCompatActivity;
|
2018-08-15 12:48:04 -07:00
|
|
|
import android.widget.Toast;
|
2018-08-06 14:42:22 -04:00
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.database.Address;
|
2020-05-11 16:19:26 +10:00
|
|
|
import org.thoughtcrime.securesms.loki.activities.HomeActivity;
|
2018-08-06 14:42:22 -04:00
|
|
|
import org.thoughtcrime.securesms.recipients.Recipient;
|
|
|
|
import org.thoughtcrime.securesms.util.CommunicationActions;
|
|
|
|
|
2019-07-24 12:30:23 +10:00
|
|
|
import network.loki.messenger.R;
|
|
|
|
|
2018-08-06 14:42:22 -04:00
|
|
|
public class ShortcutLauncherActivity extends AppCompatActivity {
|
|
|
|
|
|
|
|
private static final String KEY_SERIALIZED_ADDRESS = "serialized_address";
|
|
|
|
|
|
|
|
public static Intent createIntent(@NonNull Context context, @NonNull Address address) {
|
|
|
|
Intent intent = new Intent(context, ShortcutLauncherActivity.class);
|
|
|
|
intent.setAction(Intent.ACTION_MAIN);
|
|
|
|
intent.putExtra(KEY_SERIALIZED_ADDRESS, address.serialize());
|
|
|
|
|
|
|
|
return intent;
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressLint("StaticFieldLeak")
|
|
|
|
@Override
|
|
|
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
2018-08-15 12:48:04 -07:00
|
|
|
String serializedAddress = getIntent().getStringExtra(KEY_SERIALIZED_ADDRESS);
|
|
|
|
|
|
|
|
if (serializedAddress == null) {
|
|
|
|
Toast.makeText(this, R.string.ShortcutLauncherActivity_invalid_shortcut, Toast.LENGTH_SHORT).show();
|
2020-01-21 09:38:11 +11:00
|
|
|
startActivity(new Intent(this, HomeActivity.class));
|
2018-08-15 12:48:04 -07:00
|
|
|
finish();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Address address = Address.fromSerialized(serializedAddress);
|
|
|
|
Recipient recipient = Recipient.from(this, address, true);
|
|
|
|
TaskStackBuilder backStack = TaskStackBuilder.create(this)
|
2020-01-21 09:38:11 +11:00
|
|
|
.addNextIntent(new Intent(this, HomeActivity.class));
|
2018-08-06 14:42:22 -04:00
|
|
|
|
|
|
|
CommunicationActions.startConversation(this, recipient, null, backStack);
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
}
|