mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-23 17:22:16 -05:00
Toolbar for settings
This commit is contained in:
parent
85b6669625
commit
1516ebf26a
@ -1,2 +1,3 @@
|
||||
cd ./android-icon-copier/
|
||||
python copy OpenKeychain action white search 24
|
||||
python copy OpenKeychain action white search 24
|
||||
python copy OpenKeychain navigation white arrow_back 24
|
@ -418,7 +418,7 @@
|
||||
android:label="@string/title_advanced_key_info">
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.PreferencesActivity"
|
||||
android:name=".ui.SettingsActivity"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||
android:label="@string/title_preferences">
|
||||
<intent-filter>
|
||||
@ -431,7 +431,7 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".ui.PreferencesKeyServerActivity"
|
||||
android:name=".ui.SettingsKeyServerActivity"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||
android:label="@string/title_key_server_preference"
|
||||
android:windowSoftInputMode="stateHidden" />
|
||||
|
@ -27,7 +27,6 @@ import android.support.v4.app.ActionBarDrawerToggle;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v4.widget.FixedDrawerLayout;
|
||||
import android.support.v7.app.ActionBarActivity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
@ -179,7 +178,7 @@ public abstract class DrawerActivity extends BaseActivity {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case MENU_ID_PREFERENCE: {
|
||||
Intent intent = new Intent(this, PreferencesActivity.class);
|
||||
Intent intent = new Intent(this, SettingsActivity.class);
|
||||
startActivity(intent);
|
||||
return true;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ public class ImportKeysCloudFragment extends Fragment {
|
||||
mConfigButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent i = new Intent(mImportActivity, PreferencesActivity.class);
|
||||
Intent i = new Intent(mImportActivity, SettingsActivity.class);
|
||||
// GRR, for some reason I can’t set the Action or I get an incomprehensible
|
||||
// exception about “modern two-pane layouts”
|
||||
// i.setAction(PreferencesActivity.ACTION_PREFS_CLOUD);
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
@ -26,6 +25,10 @@ import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceFragment;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import org.spongycastle.bcpg.CompressionAlgorithmTags;
|
||||
import org.spongycastle.bcpg.HashAlgorithmTags;
|
||||
@ -37,8 +40,7 @@ import org.sufficientlysecure.keychain.util.Preferences;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
public class PreferencesActivity extends PreferenceActivity {
|
||||
public class SettingsActivity extends PreferenceActivity {
|
||||
|
||||
public static final String ACTION_PREFS_CLOUD = "org.sufficientlysecure.keychain.ui.PREFS_CLOUD";
|
||||
public static final String ACTION_PREFS_ADV = "org.sufficientlysecure.keychain.ui.PREFS_ADV";
|
||||
@ -53,6 +55,8 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
sPreferences = Preferences.getPreferences(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
setupToolbar();
|
||||
|
||||
String action = getIntent().getAction();
|
||||
|
||||
if (action != null && action.equals(ACTION_PREFS_CLOUD)) {
|
||||
@ -63,9 +67,9 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
mKeyServerPreference
|
||||
.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Intent intent = new Intent(PreferencesActivity.this,
|
||||
PreferencesKeyServerActivity.class);
|
||||
intent.putExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS,
|
||||
Intent intent = new Intent(SettingsActivity.this,
|
||||
SettingsKeyServerActivity.class);
|
||||
intent.putExtra(SettingsKeyServerActivity.EXTRA_KEY_SERVERS,
|
||||
sPreferences.getKeyServers());
|
||||
startActivityForResult(intent, REQUEST_CODE_KEYSERVER_PREF);
|
||||
return false;
|
||||
@ -132,6 +136,30 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hack to get Toolbar in PreferenceActivity. See http://stackoverflow.com/a/26614696
|
||||
*/
|
||||
private void setupToolbar() {
|
||||
ViewGroup root = (ViewGroup) findViewById(android.R.id.content);
|
||||
LinearLayout content = (LinearLayout) root.getChildAt(0);
|
||||
LinearLayout toolbarContainer = (LinearLayout) View.inflate(this, R.layout.preference_toolbar_activity, null);
|
||||
|
||||
root.removeAllViews();
|
||||
toolbarContainer.addView(content);
|
||||
root.addView(toolbarContainer);
|
||||
|
||||
Toolbar toolbar = (Toolbar) toolbarContainer.findViewById(R.id.toolbar);
|
||||
toolbar.setTitle(R.string.title_preferences);
|
||||
toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.ic_arrow_back_white_24dp));
|
||||
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//What to do on back clicked
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
switch (requestCode) {
|
||||
@ -140,7 +168,7 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
return;
|
||||
}
|
||||
String servers[] = data
|
||||
.getStringArrayExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS);
|
||||
.getStringArrayExtra(SettingsKeyServerActivity.EXTRA_KEY_SERVERS);
|
||||
sPreferences.setKeyServers(servers);
|
||||
mKeyServerPreference.setSummary(keyserverSummary(this));
|
||||
break;
|
||||
@ -181,8 +209,8 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Intent intent = new Intent(getActivity(),
|
||||
PreferencesKeyServerActivity.class);
|
||||
intent.putExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS,
|
||||
SettingsKeyServerActivity.class);
|
||||
intent.putExtra(SettingsKeyServerActivity.EXTRA_KEY_SERVERS,
|
||||
sPreferences.getKeyServers());
|
||||
startActivityForResult(intent, REQUEST_CODE_KEYSERVER_PREF);
|
||||
return false;
|
||||
@ -204,7 +232,7 @@ public class PreferencesActivity extends PreferenceActivity {
|
||||
return;
|
||||
}
|
||||
String servers[] = data
|
||||
.getStringArrayExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS);
|
||||
.getStringArrayExtra(SettingsKeyServerActivity.EXTRA_KEY_SERVERS);
|
||||
sPreferences.setKeyServers(servers);
|
||||
mKeyServerPreference.setSummary(keyserverSummary(getActivity()));
|
||||
break;
|
@ -35,7 +35,7 @@ import org.sufficientlysecure.keychain.ui.widget.KeyServerEditor;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
public class PreferencesKeyServerActivity extends BaseActivity implements OnClickListener,
|
||||
public class SettingsKeyServerActivity extends BaseActivity implements OnClickListener,
|
||||
EditorListener {
|
||||
|
||||
public static final String EXTRA_KEY_SERVERS = "key_servers";
|
Binary file not shown.
After Width: | Height: | Size: 287 B |
Binary file not shown.
After Width: | Height: | Size: 240 B |
Binary file not shown.
After Width: | Height: | Size: 336 B |
Binary file not shown.
After Width: | Height: | Size: 410 B |
Binary file not shown.
After Width: | Height: | Size: 530 B |
@ -0,0 +1,10 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<include
|
||||
android:id="@+id/toolbar"
|
||||
layout="@layout/toolbar" />
|
||||
|
||||
</LinearLayout>
|
@ -17,7 +17,7 @@
|
||||
<string name="title_unlock">"Unlock Key"</string>
|
||||
<string name="title_add_subkey">"Add subkey"</string>
|
||||
<string name="title_edit_key">"Edit Key"</string>
|
||||
<string name="title_preferences">"Preferences"</string>
|
||||
<string name="title_preferences">"Settings"</string>
|
||||
<string name="title_cloud_search_preferences">"Cloud Search Preferences"</string>
|
||||
<string name="title_api_registered_apps">"Apps"</string>
|
||||
<string name="title_key_server_preference">"Keyserver Preference"</string>
|
||||
|
@ -1,8 +1,8 @@
|
||||
<preference-headers xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<header
|
||||
android:fragment="org.sufficientlysecure.keychain.ui.PreferencesActivity$CloudSearchPrefsFragment"
|
||||
android:fragment="org.sufficientlysecure.keychain.ui.SettingsActivity$CloudSearchPrefsFragment"
|
||||
android:title="@string/section_cloud_search" />
|
||||
<header
|
||||
android:fragment="org.sufficientlysecure.keychain.ui.PreferencesActivity$AdvancedPrefsFragment"
|
||||
android:fragment="org.sufficientlysecure.keychain.ui.SettingsActivity$AdvancedPrefsFragment"
|
||||
android:title="@string/section_advanced" />
|
||||
</preference-headers>
|
||||
|
Loading…
Reference in New Issue
Block a user