summaryrefslogtreecommitdiffhomepage
path: root/app/src
diff options
context:
space:
mode:
authorSamuel Holland <samuel@sholland.org>2017-08-09 07:31:12 -0500
committerSamuel Holland <samuel@sholland.org>2017-08-09 07:31:12 -0500
commitaf8e013e3307b7146308ac8afd9a1cc9b3ceba63 (patch)
tree2fedac4f6ca6c3b971d88e295a4fe28828a17cba /app/src
parentc199827b585c6deea69e8f286f5c4a6024ac479f (diff)
Hook up editing to the layout and menus
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/com/wireguard/android/ProfileDetailActivity.java5
-rw-r--r--app/src/main/java/com/wireguard/android/ProfileListActivity.java33
2 files changed, 33 insertions, 5 deletions
diff --git a/app/src/main/java/com/wireguard/android/ProfileDetailActivity.java b/app/src/main/java/com/wireguard/android/ProfileDetailActivity.java
index 446b4413..5f537935 100644
--- a/app/src/main/java/com/wireguard/android/ProfileDetailActivity.java
+++ b/app/src/main/java/com/wireguard/android/ProfileDetailActivity.java
@@ -1,6 +1,7 @@
package com.wireguard.android;
import android.app.Fragment;
+import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;
@@ -20,7 +21,9 @@ public class ProfileDetailActivity extends ProfileActivity {
@Override
public void onMenuEdit(MenuItem item) {
-
+ final Intent intent = new Intent(this, ProfileEditActivity.class);
+ intent.putExtra(KEY_PROFILE_NAME, getCurrentProfile());
+ startActivity(intent);
}
@Override
diff --git a/app/src/main/java/com/wireguard/android/ProfileListActivity.java b/app/src/main/java/com/wireguard/android/ProfileListActivity.java
index 9e6965c4..565533ae 100644
--- a/app/src/main/java/com/wireguard/android/ProfileListActivity.java
+++ b/app/src/main/java/com/wireguard/android/ProfileListActivity.java
@@ -34,13 +34,22 @@ public class ProfileListActivity extends ProfileActivity {
transaction.remove(detailFragment);
}
transaction.commit();
- onProfileSelected(getCurrentProfile());
+ if (isEditing())
+ onMenuEdit(null);
+ else
+ onProfileSelected(getCurrentProfile());
}
@Override
public void onMenuEdit(MenuItem item) {
setIsEditing(true);
-
+ if (isSplitLayout) {
+ updateLayout(getCurrentProfile());
+ } else {
+ final Intent intent = new Intent(this, ProfileEditActivity.class);
+ intent.putExtra(KEY_PROFILE_NAME, getCurrentProfile());
+ startActivity(intent);
+ }
}
@Override
@@ -64,10 +73,26 @@ public class ProfileListActivity extends ProfileActivity {
public void updateLayout(String profile) {
final Fragment fragment = getFragmentManager().findFragmentById(R.id.fragment_container);
- if (profile != null) {
+ if (isEditing() && profile == null)
+ throw new IllegalStateException();
+ if (isEditing()) {
+ if (fragment instanceof ProfileEditFragment) {
+ final ProfileEditFragment editFragment = (ProfileEditFragment) fragment;
+ if (!profile.equals(editFragment.getProfile()))
+ editFragment.setProfile(profile);
+ } else {
+ final ProfileEditFragment editFragment = new ProfileEditFragment();
+ editFragment.setProfile(profile);
+ final FragmentTransaction transaction = getFragmentManager().beginTransaction();
+ transaction.addToBackStack(null);
+ transaction.replace(R.id.fragment_container, editFragment, TAG_EDIT);
+ transaction.commit();
+ }
+ } else if (profile != null) {
if (fragment instanceof ProfileDetailFragment) {
final ProfileDetailFragment detailFragment = (ProfileDetailFragment) fragment;
- detailFragment.setProfile(profile);
+ if (!profile.equals(detailFragment.getProfile()))
+ detailFragment.setProfile(profile);
} else {
final ProfileDetailFragment detailFragment = new ProfileDetailFragment();
detailFragment.setProfile(profile);