mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-12-23 03:11:30 +00:00
Add ActionBar back button to settings.
This commit is contained in:
parent
33840d22ea
commit
aa82330c94
2 changed files with 31 additions and 2 deletions
|
@ -26,7 +26,13 @@
|
|||
|
||||
<activity
|
||||
android:name=".SettingsActivity"
|
||||
android:label="@string/settings_title" />
|
||||
android:label="@string/settings_title" >
|
||||
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
android:value=".WebGuiActivity" />
|
||||
|
||||
</activity>
|
||||
|
||||
<service android:name=".service.SyncthingService" />
|
||||
|
||||
|
|
|
@ -2,13 +2,15 @@ package com.nutomic.syncthingandroid;
|
|||
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.support.v4.app.NavUtils;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import com.nutomic.syncthingandroid.service.GetTask;
|
||||
import com.nutomic.syncthingandroid.service.SyncthingService;
|
||||
|
||||
public class SettingsActivity extends PreferenceActivity {
|
||||
|
||||
|
@ -20,6 +22,12 @@ 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);
|
||||
}
|
||||
|
||||
addPreferencesFromResource(R.xml.settings);
|
||||
final PreferenceScreen screen = getPreferenceScreen();
|
||||
final Preference version = screen.findPreference(SYNCTHING_VERSION_KEY);
|
||||
|
@ -46,4 +54,19 @@ public class SettingsActivity extends PreferenceActivity {
|
|||
}
|
||||
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles ActionBar back selected.
|
||||
*/
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
NavUtils.navigateUpFromSameTask(this);
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue