ProfileActivity: Also remember editing state
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
2c4f605b66
commit
7d2d9f0cb3
@ -1,5 +1,6 @@
|
|||||||
package com.wireguard.android;
|
package com.wireguard.android;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
@ -9,12 +10,14 @@ import android.view.MenuItem;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
abstract class ProfileActivity extends ServiceClientActivity<ProfileServiceInterface> {
|
abstract class ProfileActivity extends ServiceClientActivity<ProfileServiceInterface> {
|
||||||
|
public static final String KEY_IS_EDITING = "is_editing";
|
||||||
public static final String KEY_PROFILE_NAME = "profile_name";
|
public static final String KEY_PROFILE_NAME = "profile_name";
|
||||||
protected static final String TAG_DETAIL = "detail";
|
protected static final String TAG_DETAIL = "detail";
|
||||||
protected static final String TAG_LIST = "list";
|
protected static final String TAG_LIST = "list";
|
||||||
protected static final String TAG_PLACEHOLDER = "placeholder";
|
protected static final String TAG_PLACEHOLDER = "placeholder";
|
||||||
|
|
||||||
private String currentProfile;
|
private String currentProfile;
|
||||||
|
private boolean isEditing;
|
||||||
|
|
||||||
public ProfileActivity() {
|
public ProfileActivity() {
|
||||||
super(ProfileService.class);
|
super(ProfileService.class);
|
||||||
@ -24,14 +27,22 @@ abstract class ProfileActivity extends ServiceClientActivity<ProfileServiceInter
|
|||||||
return currentProfile;
|
return currentProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean isEditing() {
|
||||||
|
return isEditing;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
// Restore the saved profile if there is one; otherwise grab it from the intent.
|
// Restore the saved profile if there is one; otherwise grab it from the intent.
|
||||||
if (savedInstanceState != null)
|
if (savedInstanceState != null) {
|
||||||
currentProfile = savedInstanceState.getString(KEY_PROFILE_NAME);
|
currentProfile = savedInstanceState.getString(KEY_PROFILE_NAME);
|
||||||
else
|
isEditing = savedInstanceState.getBoolean(KEY_IS_EDITING, false);
|
||||||
currentProfile = getIntent().getStringExtra(KEY_PROFILE_NAME);
|
} else {
|
||||||
|
final Intent intent = getIntent();
|
||||||
|
currentProfile = intent.getStringExtra(KEY_PROFILE_NAME);
|
||||||
|
isEditing = intent.getBooleanExtra(KEY_IS_EDITING, false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -55,10 +66,15 @@ abstract class ProfileActivity extends ServiceClientActivity<ProfileServiceInter
|
|||||||
@Override
|
@Override
|
||||||
public void onSaveInstanceState(Bundle outState) {
|
public void onSaveInstanceState(Bundle outState) {
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
|
outState.putBoolean(KEY_IS_EDITING, isEditing);
|
||||||
outState.putString(KEY_PROFILE_NAME, currentProfile);
|
outState.putString(KEY_PROFILE_NAME, currentProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setCurrentProfile(String profile) {
|
protected void setCurrentProfile(String profile) {
|
||||||
currentProfile = profile;
|
currentProfile = profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void setIsEditing(boolean isEditing) {
|
||||||
|
this.isEditing = isEditing;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user