UserPreference works now

This commit is contained in:
zeapo
2014-10-19 13:24:38 +02:00
parent b8b5234e5b
commit 83c3231ab0

View File

@@ -1,12 +1,15 @@
package com.zeapo.pwdstore;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
@@ -22,19 +25,29 @@ import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URI;
public class UserPreference extends PreferenceActivity implements Preference.OnPreferenceClickListener {
public class UserPreference extends ActionBarActivity implements Preference.OnPreferenceClickListener {
public static class PrefsFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preference);
findPreference("openpgp_key_id").setOnPreferenceClickListener((UserPreference) getActivity());
findPreference("ssh_key").setOnPreferenceClickListener((UserPreference) getActivity());
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preference);
findPreference("openpgp_key_id").setOnPreferenceClickListener(this);
findPreference("ssh_key").setOnPreferenceClickListener(this);
getActionBar().setDisplayHomeAsUpEnabled(true);
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new PrefsFragment()).commit();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will