Feature/calls kee updates (#1007)
* SES-3469 Fixing shortcut activity * Reduce the time shown from 00:00:00 to 00:00 expand as needed when call exceeds the time which can be shown in 00:00 * Moved the voice setting to the top of the privacy page, and allowed for auto toggle of settings * Disabling the switch camera butotn when not in video * Moving logic into VM and adding step counter * comments * PR feedback - not exposing a mutable setpull/1710/head
parent
0445ebeb57
commit
01c3003b36
@ -1,54 +0,0 @@
|
|||||||
package org.thoughtcrime.securesms;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.core.app.TaskStackBuilder;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import org.session.libsession.utilities.Address;
|
|
||||||
import org.thoughtcrime.securesms.home.HomeActivity;
|
|
||||||
import org.session.libsession.utilities.recipients.Recipient;
|
|
||||||
import org.thoughtcrime.securesms.util.CommunicationActions;
|
|
||||||
|
|
||||||
import network.loki.messenger.R;
|
|
||||||
|
|
||||||
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.toString());
|
|
||||||
|
|
||||||
return intent;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("StaticFieldLeak")
|
|
||||||
@Override
|
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
String serializedAddress = getIntent().getStringExtra(KEY_SERIALIZED_ADDRESS);
|
|
||||||
|
|
||||||
if (serializedAddress == null) {
|
|
||||||
Toast.makeText(this, R.string.invalidShortcut, Toast.LENGTH_SHORT).show();
|
|
||||||
startActivity(new Intent(this, HomeActivity.class));
|
|
||||||
finish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Address address = Address.fromSerialized(serializedAddress);
|
|
||||||
Recipient recipient = Recipient.from(this, address, true);
|
|
||||||
TaskStackBuilder backStack = TaskStackBuilder.create(this)
|
|
||||||
.addNextIntent(new Intent(this, HomeActivity.class));
|
|
||||||
|
|
||||||
CommunicationActions.startConversation(this, recipient, null, backStack);
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,68 @@
|
|||||||
|
package org.thoughtcrime.securesms
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.app.TaskStackBuilder
|
||||||
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
import network.loki.messenger.R
|
||||||
|
import org.session.libsession.utilities.Address
|
||||||
|
import org.session.libsession.utilities.Address.Companion.fromSerialized
|
||||||
|
import org.session.libsession.utilities.recipients.Recipient
|
||||||
|
import org.thoughtcrime.securesms.conversation.v2.ConversationActivityV2
|
||||||
|
import org.thoughtcrime.securesms.dependencies.DatabaseComponent
|
||||||
|
import org.thoughtcrime.securesms.home.HomeActivity
|
||||||
|
import org.thoughtcrime.securesms.util.CommunicationActions
|
||||||
|
|
||||||
|
class ShortcutLauncherActivity : AppCompatActivity() {
|
||||||
|
@SuppressLint("StaticFieldLeak")
|
||||||
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
val serializedAddress = intent.getStringExtra(KEY_SERIALIZED_ADDRESS)
|
||||||
|
|
||||||
|
if (serializedAddress == null) {
|
||||||
|
Toast.makeText(this, R.string.invalidShortcut, Toast.LENGTH_SHORT).show()
|
||||||
|
startActivity(Intent(this, HomeActivity::class.java))
|
||||||
|
finish()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val backStack = TaskStackBuilder.create(this)
|
||||||
|
.addNextIntent(Intent(this, HomeActivity::class.java))
|
||||||
|
|
||||||
|
// start the appropriate conversation activity and finish this one
|
||||||
|
lifecycleScope.launch(Dispatchers.Default) {
|
||||||
|
val context = this@ShortcutLauncherActivity
|
||||||
|
|
||||||
|
val address = fromSerialized(serializedAddress)
|
||||||
|
val recipient = Recipient.from(context, address, true)
|
||||||
|
val threadId = DatabaseComponent.get(context).threadDatabase().getOrCreateThreadIdFor(recipient)
|
||||||
|
|
||||||
|
val intent = Intent(context, ConversationActivityV2::class.java)
|
||||||
|
intent.putExtra(ConversationActivityV2.ADDRESS, recipient.address)
|
||||||
|
intent.putExtra(ConversationActivityV2.THREAD_ID, threadId)
|
||||||
|
|
||||||
|
backStack.addNextIntent(intent)
|
||||||
|
backStack.startActivities()
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val KEY_SERIALIZED_ADDRESS = "serialized_address"
|
||||||
|
|
||||||
|
fun createIntent(context: Context, address: Address): Intent {
|
||||||
|
val intent = Intent(context, ShortcutLauncherActivity::class.java)
|
||||||
|
intent.setAction(Intent.ACTION_MAIN)
|
||||||
|
intent.putExtra(KEY_SERIALIZED_ADDRESS, address.toString())
|
||||||
|
|
||||||
|
return intent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue