mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-07 10:30:14 -05:00
add support for second line in log view
This commit is contained in:
parent
7fedde2638
commit
6699917279
@ -121,6 +121,7 @@ public class PgpCertifyOperation {
|
||||
log.add(LogType.MSG_CRT_SAVE, 2,
|
||||
KeyFormattingUtils.convertKeyIdToHex(certifiedKey.getMasterKeyId()));
|
||||
// store the signed key in our local cache
|
||||
mProviderHelper.clearLog();
|
||||
SaveKeyringResult result = mProviderHelper.savePublicKeyRing(certifiedKey);
|
||||
|
||||
if (result.success()) {
|
||||
@ -129,6 +130,8 @@ public class PgpCertifyOperation {
|
||||
log.add(LogType.MSG_CRT_WARN_SAVE_FAILED, 3);
|
||||
}
|
||||
|
||||
log.add(result, 2);
|
||||
|
||||
// TODO do something with import results
|
||||
|
||||
}
|
||||
|
@ -133,6 +133,12 @@ public class ProviderHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public void clearLog() {
|
||||
if (mLog != null) {
|
||||
mLog.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// If we ever switch to api level 11, we can ditch this whole mess!
|
||||
public static final int FIELD_TYPE_NULL = 1;
|
||||
// this is called integer to stay coherent with the constants in Cursor (api level 11)
|
||||
|
@ -163,12 +163,16 @@ public class LogDisplayFragment extends ListFragment implements OnTouchListener,
|
||||
}
|
||||
|
||||
private class ItemHolder {
|
||||
final TextView mText;
|
||||
final ImageView mImg, mSub;
|
||||
public ItemHolder(TextView text, ImageView image, ImageView sub) {
|
||||
final View mSecond;
|
||||
final TextView mText, mSecondText;
|
||||
final ImageView mImg, mSecondImg, mSub;
|
||||
public ItemHolder(TextView text, ImageView image, ImageView sub, View second, TextView secondText, ImageView secondImg) {
|
||||
mText = text;
|
||||
mImg = image;
|
||||
mSub = sub;
|
||||
mSecond = second;
|
||||
mSecondText = secondText;
|
||||
mSecondImg = secondImg;
|
||||
}
|
||||
}
|
||||
|
||||
@ -181,7 +185,10 @@ public class LogDisplayFragment extends ListFragment implements OnTouchListener,
|
||||
ih = new ItemHolder(
|
||||
(TextView) convertView.findViewById(R.id.log_text),
|
||||
(ImageView) convertView.findViewById(R.id.log_img),
|
||||
(ImageView) convertView.findViewById(R.id.log_sub)
|
||||
(ImageView) convertView.findViewById(R.id.log_sub),
|
||||
convertView.findViewById(R.id.log_second),
|
||||
(TextView) convertView.findViewById(R.id.log_second_text),
|
||||
(ImageView) convertView.findViewById(R.id.log_second_img)
|
||||
);
|
||||
convertView.setTag(ih);
|
||||
} else {
|
||||
@ -191,8 +198,38 @@ public class LogDisplayFragment extends ListFragment implements OnTouchListener,
|
||||
if (entry instanceof SubLogEntryParcel) {
|
||||
ih.mSub.setVisibility(View.VISIBLE);
|
||||
convertView.setClickable(false);
|
||||
|
||||
OperationResult result = ((SubLogEntryParcel) entry).getSubResult();
|
||||
LogEntryParcel subEntry = result.getLog().getLast();
|
||||
if (subEntry != null) {
|
||||
ih.mSecond.setVisibility(View.VISIBLE);
|
||||
// special case: first parameter may be a quantity
|
||||
if (subEntry.mParameters != null && subEntry.mParameters.length > 0
|
||||
&& subEntry.mParameters[0] instanceof Integer) {
|
||||
ih.mSecondText.setText(getResources().getQuantityString(subEntry.mType.getMsgId(),
|
||||
(Integer) subEntry.mParameters[0],
|
||||
subEntry.mParameters));
|
||||
} else {
|
||||
ih.mSecondText.setText(getResources().getString(subEntry.mType.getMsgId(),
|
||||
subEntry.mParameters));
|
||||
}
|
||||
ih.mSecondText.setTextColor(subEntry.mType.mLevel == LogLevel.DEBUG ? Color.GRAY : Color.BLACK);
|
||||
switch (subEntry.mType.mLevel) {
|
||||
case DEBUG: ih.mSecondImg.setBackgroundColor(Color.GRAY); break;
|
||||
case INFO: ih.mSecondImg.setBackgroundColor(Color.BLACK); break;
|
||||
case WARN: ih.mSecondImg.setBackgroundColor(Color.YELLOW); break;
|
||||
case ERROR: ih.mSecondImg.setBackgroundColor(Color.RED); break;
|
||||
case START: ih.mSecondImg.setBackgroundColor(getResources().getColor(R.color.emphasis)); break;
|
||||
case OK: ih.mSecondImg.setBackgroundColor(Color.GREEN); break;
|
||||
case CANCELLED: ih.mSecondImg.setBackgroundColor(Color.RED); break;
|
||||
}
|
||||
} else {
|
||||
ih.mSecond.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
} else {
|
||||
ih.mSub.setVisibility(View.GONE);
|
||||
ih.mSecond.setVisibility(View.GONE);
|
||||
convertView.setClickable(true);
|
||||
}
|
||||
|
||||
@ -206,14 +243,14 @@ public class LogDisplayFragment extends ListFragment implements OnTouchListener,
|
||||
ih.mText.setText(getResources().getString(entry.mType.getMsgId(),
|
||||
entry.mParameters));
|
||||
}
|
||||
ih.mText.setTextColor(entry.mType.mLevel == LogLevel.DEBUG ? Color.GRAY : Color.BLACK);
|
||||
convertView.setPadding((entry.mIndent) * dipFactor, 0, 0, 0);
|
||||
ih.mText.setTextColor(entry.mType.mLevel == LogLevel.DEBUG ? Color.GRAY : Color.BLACK);
|
||||
switch (entry.mType.mLevel) {
|
||||
case DEBUG: ih.mImg.setBackgroundColor(Color.GRAY); break;
|
||||
case INFO: ih.mImg.setBackgroundColor(Color.BLACK); break;
|
||||
case WARN: ih.mImg.setBackgroundColor(Color.YELLOW); break;
|
||||
case ERROR: ih.mImg.setBackgroundColor(Color.RED); break;
|
||||
case START: ih.mImg.setBackgroundColor(Color.GREEN); break;
|
||||
case START: ih.mImg.setBackgroundColor(getResources().getColor(R.color.emphasis)); break;
|
||||
case OK: ih.mImg.setBackgroundColor(Color.GREEN); break;
|
||||
case CANCELLED: ih.mImg.setBackgroundColor(Color.RED); break;
|
||||
}
|
||||
|
@ -1,7 +1,13 @@
|
||||
<?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:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
@ -26,12 +32,39 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/log_sub"
|
||||
android:minWidth="10dp"
|
||||
android:background="@drawable/ic_action_view_as_list"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:src="@drawable/ic_action_view_as_list"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:gravity="center_vertical" />
|
||||
android:gravity="center_vertical"
|
||||
android:layout_marginTop="4dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/log_second"
|
||||
android:layout_marginLeft="8dip">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/log_second_img"
|
||||
android:minWidth="10dp"
|
||||
android:background="@color/bg_gray" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Log Entry Text"
|
||||
android:id="@+id/log_second_text"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user