mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 02:39:05 +01:00
RemoteWipeSetupSuccess fragment
This commit is contained in:
@@ -67,6 +67,7 @@ import org.briarproject.briar.android.privategroup.reveal.RevealContactsActivity
|
||||
import org.briarproject.briar.android.privategroup.reveal.RevealContactsFragment;
|
||||
import org.briarproject.briar.android.remotewipe.RemoteWipeDisplayFragment;
|
||||
import org.briarproject.briar.android.remotewipe.RemoteWipeSetupActivity;
|
||||
import org.briarproject.briar.android.remotewipe.RemoteWipeSuccessFragment;
|
||||
import org.briarproject.briar.android.remotewipe.WiperSelectorFragment;
|
||||
import org.briarproject.briar.android.reporting.CrashFragment;
|
||||
import org.briarproject.briar.android.reporting.CrashReportActivity;
|
||||
@@ -315,4 +316,6 @@ public interface ActivityComponent {
|
||||
void inject(WiperSelectorFragment wiperSelectorFragment);
|
||||
|
||||
void inject(RemoteWipeDisplayFragment remoteWipeDisplayFragment);
|
||||
|
||||
void inject(RemoteWipeSuccessFragment remoteWipeSuccessFragment);
|
||||
}
|
||||
|
||||
@@ -60,13 +60,13 @@ public class RemoteWipeSetupActivity extends BriarActivity implements
|
||||
|
||||
private void onStateChanged(RemoteWipeSetupState state) {
|
||||
if (state.equals(RemoteWipeSetupState.SUCCESS)) {
|
||||
Toast.makeText(this,
|
||||
"Success",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
showNextFragment(new RemoteWipeSuccessFragment());
|
||||
} else if (state.equals(RemoteWipeSetupState.FAILED)) {
|
||||
Toast.makeText(this,
|
||||
"Failed",
|
||||
Toast.LENGTH_SHORT).show();
|
||||
} else if (state.equals(RemoteWipeSetupState.FINISHED)) {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,5 +2,6 @@ package org.briarproject.briar.android.remotewipe;
|
||||
|
||||
public enum RemoteWipeSetupState {
|
||||
FAILED,
|
||||
SUCCESS
|
||||
SUCCESS,
|
||||
FINISHED
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.UiThread;
|
||||
import androidx.lifecycle.AndroidViewModel;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
@@ -59,7 +60,10 @@ public class RemoteWipeSetupViewModel extends AndroidViewModel {
|
||||
return wiperNames;
|
||||
}
|
||||
|
||||
|
||||
@UiThread
|
||||
public void onSuccessDismissed() {
|
||||
state.postValue(RemoteWipeSetupState.FINISHED);
|
||||
}
|
||||
|
||||
public void setupRemoteWipe(Collection<ContactId> wipers)
|
||||
throws DbException, FormatException {
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.briarproject.briar.android.remotewipe;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
|
||||
import org.briarproject.briar.R;
|
||||
import org.briarproject.briar.android.activity.ActivityComponent;
|
||||
import org.briarproject.briar.android.fragment.BaseFragment;
|
||||
import org.briarproject.briar.android.socialbackup.recover.CustodianReturnShardViewModel;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
public class RemoteWipeSuccessFragment extends BaseFragment {
|
||||
|
||||
public static final String TAG = RemoteWipeSuccessFragment.class.getName();
|
||||
|
||||
@Inject
|
||||
ViewModelProvider.Factory viewModelFactory;
|
||||
|
||||
private RemoteWipeSetupViewModel viewModel;
|
||||
|
||||
@Override
|
||||
public void injectFragment(ActivityComponent component) {
|
||||
component.inject(this);
|
||||
viewModel = new ViewModelProvider(requireActivity(), viewModelFactory)
|
||||
.get(RemoteWipeSetupViewModel.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||
@Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_remote_wipe_setup_success,
|
||||
container, false);
|
||||
|
||||
Button button = view.findViewById(R.id.button);
|
||||
button.setOnClickListener(e -> viewModel.onSuccessDismissed());
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueTag() {
|
||||
return TAG;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/linearLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingLeft="@dimen/margin_large"
|
||||
android:paddingTop="@dimen/margin_medium"
|
||||
android:paddingRight="@dimen/margin_large"
|
||||
android:paddingBottom="@dimen/margin_medium">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="32dp"
|
||||
android:text="@string/backup_done_dismiss"
|
||||
android:textSize="24sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/textView2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:gravity="center"
|
||||
android:text="@string/remote_wipe_setup_success"
|
||||
android:textSize="30sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/imageView2" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/imageView2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="32dp"
|
||||
android:layout_marginLeft="32dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="32dp"
|
||||
android:layout_marginRight="32dp"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_baseline_done_outline_24" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -732,6 +732,9 @@
|
||||
|
||||
<!-- Remote Wipe -->
|
||||
|
||||
<!-- setup -->
|
||||
<string name="remote_wipe_setup_success">Remote wipe is set up</string>
|
||||
|
||||
<!-- settings menu -->
|
||||
<string name="pref_remote_wipe_summary">Allow trusted contacts to activate an account wipe remotely</string>
|
||||
<string name="pref_remote_wipe_title">Remote Wipe</string>
|
||||
|
||||
Reference in New Issue
Block a user