mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 11:12:15 -05:00
import-log: add LogDisplay activity
This commit is contained in:
parent
d73a3e2fa8
commit
7324bfcb53
@ -434,6 +434,12 @@
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<activity
|
||||
android:name=".ui.LogDisplayActivity"
|
||||
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
|
||||
android:label="@string/title_log_display"
|
||||
android:exported="false" />
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,22 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/content_frame"
|
||||
android:layout_marginLeft="@dimen/drawer_content_padding"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/card_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/import_navigation_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:orientation="vertical" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/import_keys_list_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:layout_weight="0.9" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/import_footer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp">
|
||||
@ -43,16 +58,4 @@
|
||||
style="@style/SelectableItem" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/import_keys_list_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_above="@+id/import_footer"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_below="@+id/import_navigation_fragment"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp" />
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
46
OpenKeychain/src/main/res/layout/log_display_activity.xml
Normal file
46
OpenKeychain/src/main/res/layout/log_display_activity.xml
Normal file
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<fragment
|
||||
android:id="@+id/list"
|
||||
android:name="org.sufficientlysecure.keychain.ui.LogDisplayFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="0.9"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_marginLeft="8dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/import_footer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dip"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/import_import"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="Close"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:gravity="center_vertical"
|
||||
android:clickable="true"
|
||||
style="@style/SelectableItem" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
11
OpenKeychain/src/main/res/layout/log_display_fragment.xml
Normal file
11
OpenKeychain/src/main/res/layout/log_display_fragment.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ListView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/log_text" />
|
||||
</LinearLayout>
|
14
OpenKeychain/src/main/res/layout/log_display_item.xml
Normal file
14
OpenKeychain/src/main/res/layout/log_display_item.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Log Entry Text"
|
||||
android:id="@+id/log_text"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginBottom="4dp" />
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user