ImportKeys: Add menu in import fragments
- Move cloud settings to menu - TODO: Import all keys
This commit is contained in:
@@ -24,6 +24,8 @@ import android.os.Bundle;
|
|||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
@@ -114,6 +116,17 @@ public class ImportKeysActivity extends BaseActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||||
|
super.onRestoreInstanceState(savedInstanceState);
|
||||||
|
|
||||||
|
// the only thing we need to take care of for restoring state is
|
||||||
|
// that the top layout is shown iff it contains a fragment
|
||||||
|
Fragment topFragment = getSupportFragmentManager().findFragmentByTag(TAG_FRAG_TOP);
|
||||||
|
boolean hasTopFragment = topFragment != null;
|
||||||
|
findViewById(R.id.import_keys_top_layout).setVisibility(hasTopFragment ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
protected void handleActions(@NonNull Intent intent) {
|
protected void handleActions(@NonNull Intent intent) {
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
Bundle extras = intent.getExtras();
|
Bundle extras = intent.getExtras();
|
||||||
@@ -252,17 +265,6 @@ public class ImportKeysActivity extends BaseActivity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onRestoreInstanceState(Bundle savedInstanceState) {
|
|
||||||
super.onRestoreInstanceState(savedInstanceState);
|
|
||||||
|
|
||||||
// the only thing we need to take care of for restoring state is
|
|
||||||
// that the top layout is shown iff it contains a fragment
|
|
||||||
Fragment topFragment = getSupportFragmentManager().findFragmentByTag(TAG_FRAG_TOP);
|
|
||||||
boolean hasTopFragment = topFragment != null;
|
|
||||||
findViewById(R.id.import_keys_top_layout).setVisibility(hasTopFragment ? View.VISIBLE : View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows the list of keys to be imported.
|
* Shows the list of keys to be imported.
|
||||||
* If the fragment is started with non-null bytes/dataUri/serverQuery, it will immediately
|
* If the fragment is started with non-null bytes/dataUri/serverQuery, it will immediately
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ import android.preference.PreferenceActivity;
|
|||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -119,15 +122,7 @@ public class ImportKeysCloudFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
View configButton = view.findViewById(R.id.cloud_import_server_config_button);
|
setHasOptionsMenu(true);
|
||||||
configButton.setOnClickListener(new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
Intent intent = new Intent(mImportActivity, SettingsActivity.class);
|
|
||||||
intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsActivity.CloudSearchPrefsFragment.class.getName());
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
@@ -162,6 +157,25 @@ public class ImportKeysCloudFragment extends Fragment {
|
|||||||
mImportActivity = (ImportKeysActivity) activity;
|
mImportActivity = (ImportKeysActivity) activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
|
inflater.inflate(R.menu.import_keys_cloud_fragment, menu);
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.import_cloud_settings:
|
||||||
|
Intent intent = new Intent(mImportActivity, SettingsActivity.class);
|
||||||
|
intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, SettingsActivity.CloudSearchPrefsFragment.class.getName());
|
||||||
|
startActivity(intent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private void search(String query) {
|
private void search(String query) {
|
||||||
Preferences.CloudSearchPrefs cloudSearchPrefs
|
Preferences.CloudSearchPrefs cloudSearchPrefs
|
||||||
= getArguments().getParcelable(ARG_CLOUD_SEARCH_PREFS);
|
= getArguments().getParcelable(ARG_CLOUD_SEARCH_PREFS);
|
||||||
|
|||||||
@@ -25,10 +25,14 @@ import android.content.pm.PackageManager;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceActivity;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
@@ -105,6 +109,8 @@ public class ImportKeysFileFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,6 +121,23 @@ public class ImportKeysFileFragment extends Fragment {
|
|||||||
mImportActivity = (ImportKeysActivity) activity;
|
mImportActivity = (ImportKeysActivity) activity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||||
|
inflater.inflate(R.menu.import_keys_file_fragment, menu);
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
switch (item.getItemId()) {
|
||||||
|
case R.id.import_all_keys:
|
||||||
|
//TODO
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
|
|||||||
@@ -5,50 +5,33 @@
|
|||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:paddingLeft="8dp"
|
|
||||||
android:layout_height="?android:attr/listPreferredItemHeight"
|
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal"
|
||||||
|
android:paddingLeft="8dp">
|
||||||
|
|
||||||
<AutoCompleteTextView
|
<AutoCompleteTextView
|
||||||
android:id="@+id/cloud_import_server_query"
|
android:id="@+id/cloud_import_server_query"
|
||||||
android:layout_width="0dip"
|
android:layout_width="0dip"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:gravity="top|left"
|
android:gravity="top|left"
|
||||||
android:hint="@string/hint_cloud_search_hint"
|
android:hint="@string/hint_cloud_search_hint"
|
||||||
android:imeOptions="actionSearch"
|
android:imeOptions="actionSearch"
|
||||||
android:inputType="textNoSuggestions"
|
android:inputType="textNoSuggestions"
|
||||||
android:singleLine="true"
|
|
||||||
android:lines="1"
|
android:lines="1"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:minLines="1"
|
android:minLines="1"
|
||||||
android:layout_gravity="center_vertical" />
|
android:singleLine="true" />
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/cloud_import_server_search"
|
android:id="@+id/cloud_import_server_search"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:padding="8dp"
|
|
||||||
android:src="@drawable/ic_search_grey_24dp"
|
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:background="?android:selectableItemBackground" />
|
android:background="?android:selectableItemBackground"
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="1dip"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:gravity="right"
|
|
||||||
android:layout_marginBottom="8dp"
|
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:background="?android:attr/listDivider" />
|
|
||||||
|
|
||||||
<ImageButton
|
|
||||||
android:id="@+id/cloud_import_server_config_button"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
android:src="@drawable/ic_settings_grey_24dp"
|
android:src="@drawable/ic_search_grey_24dp" />
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:background="?android:selectableItemBackground" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/import_cloud_settings"
|
||||||
|
android:title="@string/menu_preferences" />
|
||||||
|
|
||||||
|
</menu>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/import_all_keys"
|
||||||
|
android:title="@string/menu_import_all_keys" />
|
||||||
|
|
||||||
|
</menu>
|
||||||
@@ -133,6 +133,7 @@
|
|||||||
<string name="menu_certify_fingerprint_phrases">"Confirm with phrases"</string>
|
<string name="menu_certify_fingerprint_phrases">"Confirm with phrases"</string>
|
||||||
<string name="menu_share_log">"Share log"</string>
|
<string name="menu_share_log">"Share log"</string>
|
||||||
<string name="menu_change_password">"Change password"</string>
|
<string name="menu_change_password">"Change password"</string>
|
||||||
|
<string name="menu_import_all_keys">"Import all keys"</string>
|
||||||
|
|
||||||
<string name="menu_keyserver_add">"Add"</string>
|
<string name="menu_keyserver_add">"Add"</string>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user