Improve activate remote wipe explainer

This commit is contained in:
ameba23
2021-10-12 11:06:54 +02:00
parent b9363b16b7
commit fa639ec45d
3 changed files with 26 additions and 2 deletions

View File

@@ -5,6 +5,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import org.briarproject.briar.R;
import org.briarproject.briar.android.activity.ActivityComponent;
@@ -41,6 +42,13 @@ public class ActivateRemoteWipeExplainerFragment extends
@Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_activate_remote_wipe_explainer,
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);
cancelButton.setOnClickListener(e -> viewModel.onCancelClicked());

View File

@@ -4,9 +4,11 @@ import android.app.Application;
import org.briarproject.bramble.api.FormatException;
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.DbException;
import org.briarproject.briar.android.remotewipe.RemoteWipeSetupState;
import org.briarproject.briar.android.util.UiUtils;
import org.briarproject.briar.api.remotewipe.RemoteWipeManager;
import java.text.Normalizer;
@@ -20,17 +22,21 @@ import androidx.lifecycle.MutableLiveData;
public class ActivateRemoteWipeViewModel extends AndroidViewModel {
private final RemoteWipeManager remoteWipeManager;
private final ContactManager contactManager;
private final DatabaseComponent db;
private final MutableLiveData<ActivateRemoteWipeState> state = new MutableLiveData<>();
private ContactId contactId;
private String contactName;
@Inject
public ActivateRemoteWipeViewModel(
@NonNull Application application,
RemoteWipeManager remoteWipeManager,
ContactManager contactManager,
DatabaseComponent db) {
super(application);
this.remoteWipeManager = remoteWipeManager;
this.contactManager = contactManager;
this.db = db;
}
@@ -57,6 +63,16 @@ public class ActivateRemoteWipeViewModel extends AndroidViewModel {
public void setContactId(ContactId c) {
contactId = c;
try {
contactName = UiUtils.getContactDisplayName(contactManager.getContact(c));
} catch (DbException e) {
e.printStackTrace();
}
}
public String getContactName() {
return contactName;
}
public void onCancelClicked() {

View File

@@ -750,8 +750,8 @@
<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_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_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_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 data from %1$s\'s device.</string>
<!-- Revoke -->
<string name="activity_name_revoke_remote_wipe">Revoke Remote Wipe</string>