aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2014-06-10 01:53:25 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2014-06-10 01:53:25 +0200
commit7324bfcb536b4975365ab9affa0a71ef29e29b93 (patch)
treeb80808b00912f1c514386a5741153c441dcacda1 /OpenKeychain/src/main/java/org/sufficientlysecure
parentd73a3e2fa89663e133ce4750e4aba86354c8b252 (diff)
downloadopen-keychain-7324bfcb536b4975365ab9affa0a71ef29e29b93.tar.gz
open-keychain-7324bfcb536b4975365ab9affa0a71ef29e29b93.tar.bz2
open-keychain-7324bfcb536b4975365ab9affa0a71ef29e29b93.zip
import-log: add LogDisplay activity
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java8
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/LogDisplayActivity.java17
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/LogDisplayFragment.java86
3 files changed, 107 insertions, 4 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java
index d1869454d..90d772bd1 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java
@@ -438,10 +438,10 @@ public class ImportKeysActivity extends ActionBarActivity implements ActionBar.O
new SuperToast.OnClickListener() {
@Override
public void onClick(View view, Parcelable token) {
- // Intent intent = new Intent(
- // ImportKeysActivity.this, LogDisplayActivity.class);
- // intent.putExtra(LogDisplayFragment.EXTRA_RESULT, result);
- // startActivity(intent);
+ Intent intent = new Intent(
+ ImportKeysActivity.this, LogDisplayActivity.class);
+ intent.putExtra(LogDisplayFragment.EXTRA_RESULT, result);
+ startActivity(intent);
}
}));
toast.show();
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/LogDisplayActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/LogDisplayActivity.java
new file mode 100644
index 000000000..28c120d01
--- /dev/null
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/LogDisplayActivity.java
@@ -0,0 +1,17 @@
+package org.sufficientlysecure.keychain.ui;
+
+import android.os.Bundle;
+import android.support.v7.app.ActionBarActivity;
+
+import org.sufficientlysecure.keychain.R;
+
+public class LogDisplayActivity extends ActionBarActivity {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.log_display_activity);
+ }
+
+} \ No newline at end of file
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/LogDisplayFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/LogDisplayFragment.java
new file mode 100644
index 000000000..36d3e932e
--- /dev/null
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/LogDisplayFragment.java
@@ -0,0 +1,86 @@
+package org.sufficientlysecure.keychain.ui;
+
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.support.v4.app.ListFragment;
+import android.util.TypedValue;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.TextView;
+
+import org.sufficientlysecure.keychain.R;
+import org.sufficientlysecure.keychain.service.OperationResultParcel;
+import org.sufficientlysecure.keychain.service.OperationResultParcel.LogEntryParcel;
+
+import java.util.ArrayList;
+
+public class LogDisplayFragment extends ListFragment {
+
+ LogAdapter mAdapter;
+
+ public static final String EXTRA_RESULT = "log";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ Intent intent = getActivity().getIntent();
+ if (intent.getExtras() == null || !intent.getExtras().containsKey(EXTRA_RESULT)) {
+ getActivity().finish();
+ return;
+ }
+
+ OperationResultParcel result = intent.<OperationResultParcel>getParcelableExtra(EXTRA_RESULT);
+ if (result == null) {
+ getActivity().finish();
+ return;
+ }
+
+ mAdapter = new LogAdapter(getActivity(), result.getLog());
+ setListAdapter(mAdapter);
+
+ }
+
+ private class LogAdapter extends ArrayAdapter<LogEntryParcel> {
+
+ private LayoutInflater mInflater;
+ private int dipFactor;
+
+ public LogAdapter(Context context, ArrayList<LogEntryParcel> log) {
+ super(context, R.layout.log_display_item, log);
+ mInflater = LayoutInflater.from(getContext());
+ dipFactor = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
+ (float) 6, getResources().getDisplayMetrics());
+
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ LogEntryParcel entry = getItem(position);
+ TextView text;
+ if (convertView == null) {
+ convertView = mInflater.inflate(R.layout.log_display_item, parent, false);
+ text = (TextView) convertView.findViewById(R.id.log_text);
+ convertView.setTag(text);
+ } else {
+ text = (TextView) convertView.getTag();
+ }
+
+ text.setPadding(entry.mIndent*dipFactor, 0, 0, 0);
+ text.setText(getResources().getString(entry.mType.getMsgId(), (Object[]) entry.mParameters));
+ switch (entry.mLevel) {
+ case DEBUG: text.setTextColor(Color.GRAY); break;
+ case INFO: text.setTextColor(Color.BLACK); break;
+ case WARN: text.setTextColor(Color.YELLOW); break;
+ case ERROR: text.setTextColor(Color.RED); break;
+ }
+
+ return convertView;
+ }
+
+ }
+}