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.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.View;
|
||||
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) {
|
||||
String action = intent.getAction();
|
||||
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.
|
||||
* 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.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
@@ -119,15 +122,7 @@ public class ImportKeysCloudFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
View configButton = view.findViewById(R.id.cloud_import_server_config_button);
|
||||
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);
|
||||
}
|
||||
});
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
return view;
|
||||
}
|
||||
@@ -162,6 +157,25 @@ public class ImportKeysCloudFragment extends Fragment {
|
||||
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) {
|
||||
Preferences.CloudSearchPrefs cloudSearchPrefs
|
||||
= getArguments().getParcelable(ARG_CLOUD_SEARCH_PREFS);
|
||||
|
||||
@@ -25,10 +25,14 @@ import android.content.pm.PackageManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Toast;
|
||||
@@ -105,6 +109,8 @@ public class ImportKeysFileFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -115,6 +121,23 @@ public class ImportKeysFileFragment extends Fragment {
|
||||
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
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
switch (requestCode) {
|
||||
|
||||
Reference in New Issue
Block a user