diff options
author | Samuel Holland <samuel@sholland.org> | 2017-08-09 07:28:04 -0500 |
---|---|---|
committer | Samuel Holland <samuel@sholland.org> | 2017-08-09 07:28:04 -0500 |
commit | 671aae74892cea56b110719dceefeecb6fd0124e (patch) | |
tree | d75fc00ca6885adeeb6a3499d1c022af4312f385 /app/src/main | |
parent | 7d2d9f0cb3531acb9d0433a8e19ed64db329d64e (diff) |
ProfileActivity: Do not use onClick for menus
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/src/main')
3 files changed, 27 insertions, 6 deletions
diff --git a/app/src/main/java/com/wireguard/android/ProfileActivity.java b/app/src/main/java/com/wireguard/android/ProfileActivity.java index 40b81d2b..ea1836c1 100644 --- a/app/src/main/java/com/wireguard/android/ProfileActivity.java +++ b/app/src/main/java/com/wireguard/android/ProfileActivity.java @@ -51,13 +51,9 @@ abstract class ProfileActivity extends ServiceClientActivity<ProfileServiceInter return true; } - public void onMenuEdit(MenuItem item) { + public abstract void onMenuEdit(MenuItem item); - } - - public void onMenuSave(MenuItem item) { - - } + public abstract void onMenuSave(MenuItem item); public void onMenuSettings(MenuItem item) { diff --git a/app/src/main/java/com/wireguard/android/ProfileDetailActivity.java b/app/src/main/java/com/wireguard/android/ProfileDetailActivity.java index 1e178c71..446b4413 100644 --- a/app/src/main/java/com/wireguard/android/ProfileDetailActivity.java +++ b/app/src/main/java/com/wireguard/android/ProfileDetailActivity.java @@ -2,6 +2,7 @@ package com.wireguard.android; import android.app.Fragment; import android.os.Bundle; +import android.view.MenuItem; /** * Activity that allows viewing information about a single WireGuard profile. @@ -16,4 +17,14 @@ public class ProfileDetailActivity extends ProfileActivity { Fragment detailFragment = getFragmentManager().findFragmentByTag(TAG_DETAIL); ((ProfileDetailFragment) detailFragment).setProfile(getCurrentProfile()); } + + @Override + public void onMenuEdit(MenuItem item) { + + } + + @Override + public void onMenuSave(MenuItem item) { + throw new IllegalStateException(); + } } diff --git a/app/src/main/java/com/wireguard/android/ProfileListActivity.java b/app/src/main/java/com/wireguard/android/ProfileListActivity.java index feb25511..9e6965c4 100644 --- a/app/src/main/java/com/wireguard/android/ProfileListActivity.java +++ b/app/src/main/java/com/wireguard/android/ProfileListActivity.java @@ -4,6 +4,7 @@ import android.app.Fragment; import android.app.FragmentTransaction; import android.content.Intent; import android.os.Bundle; +import android.view.MenuItem; /** * Activity that allows creating/viewing/editing/deleting WireGuard profiles. @@ -36,7 +37,20 @@ public class ProfileListActivity extends ProfileActivity { onProfileSelected(getCurrentProfile()); } + @Override + public void onMenuEdit(MenuItem item) { + setIsEditing(true); + + } + + @Override + public void onMenuSave(MenuItem item) { + setIsEditing(false); + + } + public void onProfileSelected(String profile) { + setIsEditing(false); if (isSplitLayout) { updateLayout(profile); setCurrentProfile(profile); |