mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-23 16:19:54 +01:00
Improve activate remote wipe explainer
This commit is contained in:
@@ -5,6 +5,7 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
import org.briarproject.briar.android.activity.ActivityComponent;
|
import org.briarproject.briar.android.activity.ActivityComponent;
|
||||||
@@ -41,6 +42,13 @@ public class ActivateRemoteWipeExplainerFragment extends
|
|||||||
@Nullable Bundle savedInstanceState) {
|
@Nullable Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.fragment_activate_remote_wipe_explainer,
|
View view = inflater.inflate(R.layout.fragment_activate_remote_wipe_explainer,
|
||||||
container, false);
|
container, false);
|
||||||
|
|
||||||
|
TextView titleText = view.findViewById(R.id.textView);
|
||||||
|
titleText.setText(String.format(getString(R.string.remote_wipe_activate_explain_short), viewModel.getContactName()));
|
||||||
|
|
||||||
|
TextView explainText = view.findViewById(R.id.textViewExplain);
|
||||||
|
explainText.setText(String.format(getString(R.string.remote_wipe_activate_explain_long), viewModel.getContactName()));
|
||||||
|
|
||||||
Button cancelButton = view.findViewById(R.id.button_cancel);
|
Button cancelButton = view.findViewById(R.id.button_cancel);
|
||||||
cancelButton.setOnClickListener(e -> viewModel.onCancelClicked());
|
cancelButton.setOnClickListener(e -> viewModel.onCancelClicked());
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ import android.app.Application;
|
|||||||
|
|
||||||
import org.briarproject.bramble.api.FormatException;
|
import org.briarproject.bramble.api.FormatException;
|
||||||
import org.briarproject.bramble.api.contact.ContactId;
|
import org.briarproject.bramble.api.contact.ContactId;
|
||||||
|
import org.briarproject.bramble.api.contact.ContactManager;
|
||||||
import org.briarproject.bramble.api.db.DatabaseComponent;
|
import org.briarproject.bramble.api.db.DatabaseComponent;
|
||||||
import org.briarproject.bramble.api.db.DbException;
|
import org.briarproject.bramble.api.db.DbException;
|
||||||
import org.briarproject.briar.android.remotewipe.RemoteWipeSetupState;
|
import org.briarproject.briar.android.remotewipe.RemoteWipeSetupState;
|
||||||
|
import org.briarproject.briar.android.util.UiUtils;
|
||||||
import org.briarproject.briar.api.remotewipe.RemoteWipeManager;
|
import org.briarproject.briar.api.remotewipe.RemoteWipeManager;
|
||||||
|
|
||||||
import java.text.Normalizer;
|
import java.text.Normalizer;
|
||||||
@@ -20,17 +22,21 @@ import androidx.lifecycle.MutableLiveData;
|
|||||||
public class ActivateRemoteWipeViewModel extends AndroidViewModel {
|
public class ActivateRemoteWipeViewModel extends AndroidViewModel {
|
||||||
|
|
||||||
private final RemoteWipeManager remoteWipeManager;
|
private final RemoteWipeManager remoteWipeManager;
|
||||||
|
private final ContactManager contactManager;
|
||||||
private final DatabaseComponent db;
|
private final DatabaseComponent db;
|
||||||
private final MutableLiveData<ActivateRemoteWipeState> state = new MutableLiveData<>();
|
private final MutableLiveData<ActivateRemoteWipeState> state = new MutableLiveData<>();
|
||||||
private ContactId contactId;
|
private ContactId contactId;
|
||||||
|
private String contactName;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ActivateRemoteWipeViewModel(
|
public ActivateRemoteWipeViewModel(
|
||||||
@NonNull Application application,
|
@NonNull Application application,
|
||||||
RemoteWipeManager remoteWipeManager,
|
RemoteWipeManager remoteWipeManager,
|
||||||
|
ContactManager contactManager,
|
||||||
DatabaseComponent db) {
|
DatabaseComponent db) {
|
||||||
super(application);
|
super(application);
|
||||||
this.remoteWipeManager = remoteWipeManager;
|
this.remoteWipeManager = remoteWipeManager;
|
||||||
|
this.contactManager = contactManager;
|
||||||
this.db = db;
|
this.db = db;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,6 +63,16 @@ public class ActivateRemoteWipeViewModel extends AndroidViewModel {
|
|||||||
|
|
||||||
public void setContactId(ContactId c) {
|
public void setContactId(ContactId c) {
|
||||||
contactId = c;
|
contactId = c;
|
||||||
|
|
||||||
|
try {
|
||||||
|
contactName = UiUtils.getContactDisplayName(contactManager.getContact(c));
|
||||||
|
} catch (DbException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContactName() {
|
||||||
|
return contactName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onCancelClicked() {
|
public void onCancelClicked() {
|
||||||
|
|||||||
@@ -750,8 +750,8 @@
|
|||||||
<string name="remote_wipe_activate_failure">Failed to send remote wipe signal</string>
|
<string name="remote_wipe_activate_failure">Failed to send remote wipe signal</string>
|
||||||
<string name="remote_wipe_activate_button_confirm">Activate remote wipe</string>
|
<string name="remote_wipe_activate_button_confirm">Activate remote wipe</string>
|
||||||
<string name="remote_wipe_activate_button_cancel">Cancel</string>
|
<string name="remote_wipe_activate_button_cancel">Cancel</string>
|
||||||
<string name="remote_wipe_activate_explain_short">Activate a remote wipe of this contact\'s device</string>
|
<string name="remote_wipe_activate_explain_short">Activate a remote wipe for %1$s</string>
|
||||||
<string name="remote_wipe_activate_explain_long">If confirmed by a second contact, sending this signal will remove all briar contacts and messages from this contact\s device.</string>
|
<string name="remote_wipe_activate_explain_long">If confirmed by a second contact, sending this signal will remove all Briar data from %1$s\'s device.</string>
|
||||||
|
|
||||||
<!-- Revoke -->
|
<!-- Revoke -->
|
||||||
<string name="activity_name_revoke_remote_wipe">Revoke Remote Wipe</string>
|
<string name="activity_name_revoke_remote_wipe">Revoke Remote Wipe</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user