From 0a4121e6cf62a03aa1282101cadfd219e453888b Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Mon, 30 Jun 2014 01:15:56 +0200 Subject: [PATCH] Add ActionBar back button to repo/node settings Activities. --- .../nutomic/syncthingandroid/gui/NodeSettingsActivity.java | 5 +++++ .../nutomic/syncthingandroid/gui/RepoSettingsActivity.java | 5 +++++ .../com/nutomic/syncthingandroid/gui/SettingsActivity.java | 2 -- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/nutomic/syncthingandroid/gui/NodeSettingsActivity.java b/src/main/java/com/nutomic/syncthingandroid/gui/NodeSettingsActivity.java index 006e41e3..56f222ca 100644 --- a/src/main/java/com/nutomic/syncthingandroid/gui/NodeSettingsActivity.java +++ b/src/main/java/com/nutomic/syncthingandroid/gui/NodeSettingsActivity.java @@ -6,6 +6,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.ServiceConnection; +import android.os.Build; import android.os.Bundle; import android.os.IBinder; import android.preference.EditTextPreference; @@ -69,6 +70,10 @@ public class NodeSettingsActivity extends PreferenceActivity implements protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + getActionBar().setDisplayHomeAsUpEnabled(true); + } + if (getIntent().getAction().equals(ACTION_CREATE)) { addPreferencesFromResource(R.xml.node_settings_create); } diff --git a/src/main/java/com/nutomic/syncthingandroid/gui/RepoSettingsActivity.java b/src/main/java/com/nutomic/syncthingandroid/gui/RepoSettingsActivity.java index cbb688ab..252343e5 100644 --- a/src/main/java/com/nutomic/syncthingandroid/gui/RepoSettingsActivity.java +++ b/src/main/java/com/nutomic/syncthingandroid/gui/RepoSettingsActivity.java @@ -7,6 +7,7 @@ import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.content.ServiceConnection; +import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.IBinder; @@ -80,6 +81,10 @@ public class RepoSettingsActivity extends PreferenceActivity protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { + getActionBar().setDisplayHomeAsUpEnabled(true); + } + if (getIntent().getAction().equals(ACTION_CREATE)) { addPreferencesFromResource(R.xml.repo_settings_create); } diff --git a/src/main/java/com/nutomic/syncthingandroid/gui/SettingsActivity.java b/src/main/java/com/nutomic/syncthingandroid/gui/SettingsActivity.java index 3d33fb02..ce6a5b45 100644 --- a/src/main/java/com/nutomic/syncthingandroid/gui/SettingsActivity.java +++ b/src/main/java/com/nutomic/syncthingandroid/gui/SettingsActivity.java @@ -110,8 +110,6 @@ public class SettingsActivity extends PreferenceActivity public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // There is currently no way to get ActionBar in PreferenceActivity on pre-honeycomb with - // compatibility library, so we'll have to do a version check. if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { getActionBar().setDisplayHomeAsUpEnabled(true); }