summaryrefslogtreecommitdiffhomepage
path: root/app/src/main/java/com/wireguard/android/fragment
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/com/wireguard/android/fragment')
-rw-r--r--app/src/main/java/com/wireguard/android/fragment/BaseFragment.java14
-rw-r--r--app/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.java8
-rw-r--r--app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java18
-rw-r--r--app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java24
4 files changed, 32 insertions, 32 deletions
diff --git a/app/src/main/java/com/wireguard/android/fragment/BaseFragment.java b/app/src/main/java/com/wireguard/android/fragment/BaseFragment.java
index 00e26348..11af26e4 100644
--- a/app/src/main/java/com/wireguard/android/fragment/BaseFragment.java
+++ b/app/src/main/java/com/wireguard/android/fragment/BaseFragment.java
@@ -23,8 +23,8 @@ import com.wireguard.android.activity.BaseActivity.OnSelectedTunnelChangedListen
import com.wireguard.android.backend.GoBackend;
import com.wireguard.android.databinding.TunnelDetailFragmentBinding;
import com.wireguard.android.databinding.TunnelListItemBinding;
-import com.wireguard.android.model.Tunnel;
-import com.wireguard.android.model.Tunnel.State;
+import com.wireguard.android.model.ObservableTunnel;
+import com.wireguard.android.backend.Tunnel.State;
import com.wireguard.android.util.ErrorMessages;
/**
@@ -36,11 +36,11 @@ public abstract class BaseFragment extends Fragment implements OnSelectedTunnelC
private static final int REQUEST_CODE_VPN_PERMISSION = 23491;
private static final String TAG = "WireGuard/" + BaseFragment.class.getSimpleName();
@Nullable private BaseActivity activity;
- @Nullable private Tunnel pendingTunnel;
+ @Nullable private ObservableTunnel pendingTunnel;
@Nullable private Boolean pendingTunnelUp;
@Nullable
- protected Tunnel getSelectedTunnel() {
+ protected ObservableTunnel getSelectedTunnel() {
return activity != null ? activity.getSelectedTunnel() : null;
}
@@ -75,14 +75,14 @@ public abstract class BaseFragment extends Fragment implements OnSelectedTunnelC
super.onDetach();
}
- protected void setSelectedTunnel(@Nullable final Tunnel tunnel) {
+ protected void setSelectedTunnel(@Nullable final ObservableTunnel tunnel) {
if (activity != null)
activity.setSelectedTunnel(tunnel);
}
public void setTunnelState(final View view, final boolean checked) {
final ViewDataBinding binding = DataBindingUtil.findBinding(view);
- final Tunnel tunnel;
+ final ObservableTunnel tunnel;
if (binding instanceof TunnelDetailFragmentBinding)
tunnel = ((TunnelDetailFragmentBinding) binding).getTunnel();
else if (binding instanceof TunnelListItemBinding)
@@ -107,7 +107,7 @@ public abstract class BaseFragment extends Fragment implements OnSelectedTunnelC
});
}
- private void setTunnelStateWithPermissionsResult(final Tunnel tunnel, final boolean checked) {
+ private void setTunnelStateWithPermissionsResult(final ObservableTunnel tunnel, final boolean checked) {
tunnel.setState(State.of(checked)).whenComplete((state, throwable) -> {
if (throwable == null)
return;
diff --git a/app/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.java b/app/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.java
index 57e0d8ea..89fe6c77 100644
--- a/app/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.java
+++ b/app/src/main/java/com/wireguard/android/fragment/TunnelDetailFragment.java
@@ -18,8 +18,8 @@ import android.view.ViewGroup;
import com.wireguard.android.R;
import com.wireguard.android.databinding.TunnelDetailFragmentBinding;
import com.wireguard.android.databinding.TunnelDetailPeerBinding;
-import com.wireguard.android.model.Tunnel;
-import com.wireguard.android.model.Tunnel.State;
+import com.wireguard.android.model.ObservableTunnel;
+import com.wireguard.android.backend.Tunnel.State;
import com.wireguard.android.ui.EdgeToEdge;
import com.wireguard.crypto.Key;
@@ -85,7 +85,7 @@ public class TunnelDetailFragment extends BaseFragment {
}
@Override
- public void onSelectedTunnelChanged(@Nullable final Tunnel oldTunnel, @Nullable final Tunnel newTunnel) {
+ public void onSelectedTunnelChanged(@Nullable final ObservableTunnel oldTunnel, @Nullable final ObservableTunnel newTunnel) {
if (binding == null)
return;
binding.setTunnel(newTunnel);
@@ -123,7 +123,7 @@ public class TunnelDetailFragment extends BaseFragment {
private void updateStats() {
if (binding == null || !isResumed())
return;
- final Tunnel tunnel = binding.getTunnel();
+ final ObservableTunnel tunnel = binding.getTunnel();
if (tunnel == null)
return;
final State state = tunnel.getState();
diff --git a/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java b/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java
index a93fabf6..b342d5a8 100644
--- a/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java
+++ b/app/src/main/java/com/wireguard/android/fragment/TunnelEditorFragment.java
@@ -11,7 +11,7 @@ import androidx.databinding.ObservableList;
import android.os.Bundle;
import androidx.annotation.Nullable;
import com.google.android.material.snackbar.Snackbar;
-import androidx.fragment.app.FragmentManager;
+
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -26,7 +26,7 @@ import com.wireguard.android.Application;
import com.wireguard.android.R;
import com.wireguard.android.databinding.TunnelEditorFragmentBinding;
import com.wireguard.android.fragment.AppListDialogFragment.AppExclusionListener;
-import com.wireguard.android.model.Tunnel;
+import com.wireguard.android.model.ObservableTunnel;
import com.wireguard.android.model.TunnelManager;
import com.wireguard.android.ui.EdgeToEdge;
import com.wireguard.android.util.ErrorMessages;
@@ -47,7 +47,7 @@ public class TunnelEditorFragment extends BaseFragment implements AppExclusionLi
private static final String TAG = "WireGuard/" + TunnelEditorFragment.class.getSimpleName();
@Nullable private TunnelEditorFragmentBinding binding;
- @Nullable private Tunnel tunnel;
+ @Nullable private ObservableTunnel tunnel;
private void onConfigLoaded(final Config config) {
if (binding != null) {
@@ -55,7 +55,7 @@ public class TunnelEditorFragment extends BaseFragment implements AppExclusionLi
}
}
- private void onConfigSaved(final Tunnel savedTunnel,
+ private void onConfigSaved(final ObservableTunnel savedTunnel,
@Nullable final Throwable throwable) {
final String message;
if (throwable == null) {
@@ -126,7 +126,7 @@ public class TunnelEditorFragment extends BaseFragment implements AppExclusionLi
getActivity().runOnUiThread(() -> {
// TODO(smaeul): Remove this hack when fixing the Config ViewModel
// The selected tunnel has to actually change, but we have to remember this one.
- final Tunnel savedTunnel = tunnel;
+ final ObservableTunnel savedTunnel = tunnel;
if (savedTunnel == getSelectedTunnel())
setSelectedTunnel(null);
setSelectedTunnel(savedTunnel);
@@ -187,8 +187,8 @@ public class TunnelEditorFragment extends BaseFragment implements AppExclusionLi
}
@Override
- public void onSelectedTunnelChanged(@Nullable final Tunnel oldTunnel,
- @Nullable final Tunnel newTunnel) {
+ public void onSelectedTunnelChanged(@Nullable final ObservableTunnel oldTunnel,
+ @Nullable final ObservableTunnel newTunnel) {
tunnel = newTunnel;
if (binding == null)
return;
@@ -201,7 +201,7 @@ public class TunnelEditorFragment extends BaseFragment implements AppExclusionLi
}
}
- private void onTunnelCreated(final Tunnel newTunnel, @Nullable final Throwable throwable) {
+ private void onTunnelCreated(final ObservableTunnel newTunnel, @Nullable final Throwable throwable) {
final String message;
if (throwable == null) {
tunnel = newTunnel;
@@ -219,7 +219,7 @@ public class TunnelEditorFragment extends BaseFragment implements AppExclusionLi
}
}
- private void onTunnelRenamed(final Tunnel renamedTunnel, final Config newConfig,
+ private void onTunnelRenamed(final ObservableTunnel renamedTunnel, final Config newConfig,
@Nullable final Throwable throwable) {
final String message;
if (throwable == null) {
diff --git a/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java b/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
index fe8a3da1..21618e60 100644
--- a/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
+++ b/app/src/main/java/com/wireguard/android/fragment/TunnelListFragment.java
@@ -17,7 +17,7 @@ import android.provider.OpenableColumns;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.material.snackbar.Snackbar;
-import androidx.fragment.app.FragmentManager;
+
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.view.ActionMode;
import androidx.recyclerview.widget.RecyclerView;
@@ -36,7 +36,7 @@ import com.wireguard.android.activity.TunnelCreatorActivity;
import com.wireguard.android.databinding.ObservableKeyedRecyclerViewAdapter;
import com.wireguard.android.databinding.TunnelListFragmentBinding;
import com.wireguard.android.databinding.TunnelListItemBinding;
-import com.wireguard.android.model.Tunnel;
+import com.wireguard.android.model.ObservableTunnel;
import com.wireguard.android.ui.EdgeToEdge;
import com.wireguard.android.util.ErrorMessages;
import com.wireguard.android.widget.MultiselectableRelativeLayout;
@@ -91,7 +91,7 @@ public class TunnelListFragment extends BaseFragment {
return;
final ContentResolver contentResolver = activity.getContentResolver();
- final Collection<CompletableFuture<Tunnel>> futureTunnels = new ArrayList<>();
+ final Collection<CompletableFuture<ObservableTunnel>> futureTunnels = new ArrayList<>();
final List<Throwable> throwables = new ArrayList<>();
Application.getAsyncWorker().supplyAsync(() -> {
final String[] columns = {OpenableColumns.DISPLAY_NAME};
@@ -161,9 +161,9 @@ public class TunnelListFragment extends BaseFragment {
onTunnelImportFinished(Collections.emptyList(), Collections.singletonList(exception));
} else {
future.whenComplete((ignored1, ignored2) -> {
- final List<Tunnel> tunnels = new ArrayList<>(futureTunnels.size());
- for (final CompletableFuture<Tunnel> futureTunnel : futureTunnels) {
- Tunnel tunnel = null;
+ final List<ObservableTunnel> tunnels = new ArrayList<>(futureTunnels.size());
+ for (final CompletableFuture<ObservableTunnel> futureTunnel : futureTunnels) {
+ ObservableTunnel tunnel = null;
try {
tunnel = futureTunnel.getNow(null);
} catch (final Exception e) {
@@ -250,7 +250,7 @@ public class TunnelListFragment extends BaseFragment {
}
@Override
- public void onSelectedTunnelChanged(@Nullable final Tunnel oldTunnel, @Nullable final Tunnel newTunnel) {
+ public void onSelectedTunnelChanged(@Nullable final ObservableTunnel oldTunnel, @Nullable final ObservableTunnel newTunnel) {
if (binding == null)
return;
Application.getTunnelManager().getTunnels().thenAccept(tunnels -> {
@@ -281,7 +281,7 @@ public class TunnelListFragment extends BaseFragment {
showSnackbar(message);
}
- private void onTunnelImportFinished(final List<Tunnel> tunnels, final Collection<Throwable> throwables) {
+ private void onTunnelImportFinished(final List<ObservableTunnel> tunnels, final Collection<Throwable> throwables) {
String message = null;
for (final Throwable throwable : throwables) {
@@ -315,7 +315,7 @@ public class TunnelListFragment extends BaseFragment {
binding.setFragment(this);
Application.getTunnelManager().getTunnels().thenAccept(binding::setTunnels);
- binding.setRowConfigurationHandler((ObservableKeyedRecyclerViewAdapter.RowConfigurationHandler<TunnelListItemBinding, Tunnel>) (binding, tunnel, position) -> {
+ binding.setRowConfigurationHandler((ObservableKeyedRecyclerViewAdapter.RowConfigurationHandler<TunnelListItemBinding, ObservableTunnel>) (binding, tunnel, position) -> {
binding.setFragment(this);
binding.getRoot().setOnClickListener(clicked -> {
if (actionMode == null) {
@@ -336,7 +336,7 @@ public class TunnelListFragment extends BaseFragment {
});
}
- private MultiselectableRelativeLayout viewForTunnel(final Tunnel tunnel, final List tunnels) {
+ private MultiselectableRelativeLayout viewForTunnel(final ObservableTunnel tunnel, final List tunnels) {
return (MultiselectableRelativeLayout) binding.tunnelList.findViewHolderForAdapterPosition(tunnels.indexOf(tunnel)).itemView;
}
@@ -355,12 +355,12 @@ public class TunnelListFragment extends BaseFragment {
case R.id.menu_action_delete:
final Iterable<Integer> copyCheckedItems = new HashSet<>(checkedItems);
Application.getTunnelManager().getTunnels().thenAccept(tunnels -> {
- final Collection<Tunnel> tunnelsToDelete = new ArrayList<>();
+ final Collection<ObservableTunnel> tunnelsToDelete = new ArrayList<>();
for (final Integer position : copyCheckedItems)
tunnelsToDelete.add(tunnels.get(position));
final CompletableFuture[] futures = StreamSupport.stream(tunnelsToDelete)
- .map(Tunnel::delete)
+ .map(ObservableTunnel::delete)
.toArray(CompletableFuture[]::new);
CompletableFuture.allOf(futures)
.thenApply(x -> futures.length)