mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-17 07:30:14 -05:00
Fixed 140 - Multiline Entries in KeyServerQueryActivity
* EditText is now singleLine and has a hint * EditText has set inputType=text and imeOptions=actionSearch * Implemented listener for the actionSearch event * Reformated the source code according to the project specification. Sorry for the diff mess :-/ Signed-off-by: Bahtiar `kalkin-` Gadimov <bahtiar@gadimov.de>
This commit is contained in:
parent
224faa42ac
commit
2fda5bfc97
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Copyright (C) 2010 Thialfihar <thi@thialfihar.org>
|
||||
<!--
|
||||
Copyright (C) 2010 Thialfihar <thi@thialfihar.org>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
@ -14,8 +15,7 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" >
|
||||
@ -34,14 +34,17 @@
|
||||
android:id="@+id/query"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"/>
|
||||
android:layout_weight="1"
|
||||
android:hint="@string/hint_secretKeys"
|
||||
android:imeOptions="actionSearch"
|
||||
android:inputType="textNoSuggestions"
|
||||
android:singleLine="true" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_search"
|
||||
android:text="@string/btn_search"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/btn_search" />
|
||||
</LinearLayout>
|
||||
|
||||
<ListView
|
||||
|
@ -314,6 +314,7 @@
|
||||
<string name="action_importSecret">Import Secret Keys</string>
|
||||
<string name="hint_publicKeys">Search Public Keys</string>
|
||||
<string name="hint_secretKeys">Search Secret Keys</string>
|
||||
<string name="hint_query">Name, E-Mail or Key ID</string>
|
||||
<string name="filterInfo">Filter: \"%s\"</string>
|
||||
<string name="shareKeyringWith">Share Key with…</string>
|
||||
|
||||
|
@ -17,22 +17,6 @@
|
||||
|
||||
package org.sufficientlysecure.keychain.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.helper.Preferences;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.KeyServer.KeyInfo;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
@ -40,10 +24,12 @@ import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Message;
|
||||
import android.os.Messenger;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
@ -55,12 +41,27 @@ import android.widget.LinearLayout.LayoutParams;
|
||||
import android.widget.ListView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.TextView.OnEditorActionListener;
|
||||
import android.widget.Toast;
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.helper.Preferences;
|
||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||
import org.sufficientlysecure.keychain.util.KeyServer.KeyInfo;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
public class KeyServerQueryActivity extends SherlockFragmentActivity {
|
||||
|
||||
// possible intent actions for this activity
|
||||
public static final String ACTION_LOOK_UP_KEY_ID = Constants.INTENT_PREFIX + "LOOK_UP_KEY_ID";
|
||||
|
||||
public static final String ACTION_LOOK_UP_KEY_ID_AND_RETURN = Constants.INTENT_PREFIX
|
||||
+ "LOOK_UP_KEY_ID_AND_RETURN";
|
||||
|
||||
@ -69,15 +70,23 @@ public class KeyServerQueryActivity extends SherlockFragmentActivity {
|
||||
public static final String RESULT_EXTRA_TEXT = "text";
|
||||
|
||||
private ListView mList;
|
||||
|
||||
private EditText mQuery;
|
||||
|
||||
private Button mSearch;
|
||||
|
||||
private KeyInfoListAdapter mAdapter;
|
||||
|
||||
private Spinner mKeyServer;
|
||||
|
||||
private int mQueryType;
|
||||
|
||||
private String mQueryString;
|
||||
|
||||
private long mQueryId;
|
||||
|
||||
private volatile List<KeyInfo> mSearchResult;
|
||||
|
||||
private volatile String mKeyData;
|
||||
|
||||
@Override
|
||||
@ -123,17 +132,32 @@ public class KeyServerQueryActivity extends SherlockFragmentActivity {
|
||||
}
|
||||
|
||||
mList.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> adapter, View view, int position, long keyId) {
|
||||
get(keyId);
|
||||
}
|
||||
});
|
||||
|
||||
mSearch.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
String query = mQuery.getText().toString();
|
||||
search(query);
|
||||
}
|
||||
});
|
||||
mQuery.setOnEditorActionListener(new OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
|
||||
String query = mQuery.getText().toString();
|
||||
search(query);
|
||||
return false; // FIXME This is a hack to hide a keyboard
|
||||
// after search http://tinyurl.com/pwdc3q9
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
Intent intent = getIntent();
|
||||
String action = intent.getAction();
|
||||
@ -189,6 +213,7 @@ public class KeyServerQueryActivity extends SherlockFragmentActivity {
|
||||
// Message is received after querying is done in ApgService
|
||||
KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(this,
|
||||
R.string.progress_querying, ProgressDialog.STYLE_SPINNER) {
|
||||
@Override
|
||||
public void handleMessage(Message message) {
|
||||
// handle messages by standard ApgHandler first
|
||||
super.handleMessage(message);
|
||||
@ -201,10 +226,12 @@ public class KeyServerQueryActivity extends SherlockFragmentActivity {
|
||||
mSearchResult = returnData
|
||||
.getParcelableArrayList(KeychainIntentService.RESULT_QUERY_KEY_SEARCH_RESULT);
|
||||
} else if (mQueryType == Id.keyserver.get) {
|
||||
mKeyData = returnData.getString(KeychainIntentService.RESULT_QUERY_KEY_DATA);
|
||||
mKeyData = returnData
|
||||
.getString(KeychainIntentService.RESULT_QUERY_KEY_DATA);
|
||||
}
|
||||
|
||||
// TODO: IMPROVE CODE!!! some global variables can be avoided!!!
|
||||
// TODO: IMPROVE CODE!!! some global variables can be
|
||||
// avoided!!!
|
||||
if (mQueryType == Id.keyserver.search) {
|
||||
if (mSearchResult != null) {
|
||||
Toast.makeText(KeyServerQueryActivity.this,
|
||||
@ -228,7 +255,8 @@ public class KeyServerQueryActivity extends SherlockFragmentActivity {
|
||||
Intent intent = new Intent(KeyServerQueryActivity.this,
|
||||
ImportKeysActivity.class);
|
||||
intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY);
|
||||
intent.putExtra(ImportKeysActivity.EXTRA_KEY_BYTES, mKeyData.getBytes());
|
||||
intent.putExtra(ImportKeysActivity.EXTRA_KEY_BYTES,
|
||||
mKeyData.getBytes());
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
@ -251,7 +279,9 @@ public class KeyServerQueryActivity extends SherlockFragmentActivity {
|
||||
|
||||
public class KeyInfoListAdapter extends BaseAdapter {
|
||||
protected LayoutInflater mInflater;
|
||||
|
||||
protected Activity mActivity;
|
||||
|
||||
protected List<KeyInfo> mKeys;
|
||||
|
||||
public KeyInfoListAdapter(Activity activity) {
|
||||
@ -270,18 +300,22 @@ public class KeyServerQueryActivity extends SherlockFragmentActivity {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mKeys.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return mKeys.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return mKeys.get(position).keyId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
KeyInfo keyInfo = mKeys.get(position);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user