Encrypt UI (drop downs)

This commit is contained in:
mar-v-in 2014-08-01 23:30:31 +02:00
parent b206b6d351
commit 9d101b4fe5
6 changed files with 75 additions and 35 deletions

View File

@ -300,13 +300,12 @@ public class EncryptActivity extends DrawerActivity implements EncryptActivityIn
// file
if (mOutputUris.size() == 1) {
sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("*/*");
sendIntent.putExtra(Intent.EXTRA_STREAM, mOutputUris.get(0));
} else {
sendIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
sendIntent.setType("*/*");
sendIntent.putExtra(Intent.EXTRA_STREAM, mOutputUris);
}
sendIntent.setType("application/pgp-encrypted");
}
if (!isModeSymmetric() && mEncryptionUserIds != null) {
Set<String> users = new HashSet<String>();

View File

@ -40,6 +40,7 @@ import com.tokenautocomplete.TokenCompleteTextView;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.pgp.KeyRing;
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
@ -261,8 +262,9 @@ public class EncryptAsymmetricFragment extends Fragment implements EncryptActivi
@Override
public void bindView(View view, Context context, Cursor cursor) {
((TextView) view.findViewById(android.R.id.text1)).setText(cursor.getString(mIndexUserId));
view.findViewById(android.R.id.text2).setVisibility(View.VISIBLE);
String[] userId = KeyRing.splitUserId(cursor.getString(mIndexUserId));
((TextView) view.findViewById(android.R.id.title)).setText(userId[2] == null ? userId[0] : (userId[0] + " (" + userId[2] + ")"));
((TextView) view.findViewById(android.R.id.text1)).setText(userId[1]);
((TextView) view.findViewById(android.R.id.text2)).setText(PgpKeyHelper.convertKeyIdToHex(cursor.getLong(mIndexKeyId)));
}
@ -309,19 +311,29 @@ public class EncryptAsymmetricFragment extends Fragment implements EncryptActivi
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = getDropDownView(position, convertView, parent);
v.findViewById(android.R.id.text1).setVisibility(View.GONE);
return v;
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
View v;
if (position == 0) {
View v;
if (convertView == null) {
v = inner.newView(null, null, parent);
} else {
v = convertView;
}
((TextView) v.findViewById(android.R.id.text1)).setText("None");
((TextView) v.findViewById(android.R.id.title)).setText("None");
v.findViewById(android.R.id.text1).setVisibility(View.GONE);
v.findViewById(android.R.id.text2).setVisibility(View.GONE);
return v;
} else {
return inner.getView(position - 1, convertView, parent);
v = inner.getView(position - 1, convertView, parent);
v.findViewById(android.R.id.text1).setVisibility(View.VISIBLE);
v.findViewById(android.R.id.text2).setVisibility(View.VISIBLE);
}
return v;
}
}

View File

@ -245,7 +245,6 @@ public class EncryptFileFragment extends Fragment implements EncryptActivityInte
// Clear cache if needed
for (Uri uri : new HashSet<Uri>(thumbnailCache.keySet())) {
if (!mEncryptInterface.getInputUris().contains(uri)) {
Log.d(Constants.TAG, "Removed thumbnail for uri: "+uri);
thumbnailCache.remove(uri);
}
}

View File

@ -130,12 +130,14 @@ public class EncryptKeyCompletionView extends TokenCompleteTextView {
}
public class EncryptionKey {
private String mUserId;
private String mUserIdFull;
private String[] mUserId;
private long mKeyId;
private String mFingerprint;
public EncryptionKey(String userId, long keyId, String fingerprint) {
this.mUserId = userId;
this.mUserId = KeyRing.splitUserId(userId);
this.mUserIdFull = userId;
this.mKeyId = keyId;
this.mFingerprint = fingerprint;
}
@ -154,7 +156,7 @@ public class EncryptKeyCompletionView extends TokenCompleteTextView {
}
public String getUserId() {
return mUserId;
return mUserIdFull;
}
public String getFingerprint() {
@ -162,25 +164,31 @@ public class EncryptKeyCompletionView extends TokenCompleteTextView {
}
public String getPrimary() {
String[] userId = KeyRing.splitUserId(mUserId);
if (userId[0] != null && userId[2] != null) {
return userId[0] + " (" + userId[2] + ")";
} else if (userId[0] != null) {
return userId[0];
if (mUserId[0] != null && mUserId[2] != null) {
return mUserId[0] + " (" + mUserId[2] + ")";
} else if (mUserId[0] != null) {
return mUserId[0];
} else {
return userId[1];
return mUserId[1];
}
}
public String getSecondary() {
String[] userId = KeyRing.splitUserId(mUserId);
if (userId[0] != null) {
return userId[1] + " (" + getKeyIdHexShort() + ")";
if (mUserId[0] != null) {
return mUserId[1];
} else {
return getKeyIdHex();
}
}
public String getTertiary() {
if (mUserId[0] != null) {
return getKeyIdHex();
} else {
return null;
}
}
public long getKeyId() {
return mKeyId;
}
@ -216,6 +224,7 @@ public class EncryptKeyCompletionView extends TokenCompleteTextView {
}
((TextView) view.findViewById(android.R.id.title)).setText(getItem(position).getPrimary());
((TextView) view.findViewById(android.R.id.text1)).setText(getItem(position).getSecondary());
((TextView) view.findViewById(android.R.id.text2)).setText(getItem(position).getTertiary());
setImageByKey((ImageView) view.findViewById(android.R.id.icon), getItem(position));
return view;
}

View File

@ -3,17 +3,29 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:padding="8dp"
android:padding="4dp"
android:layout_height="wrap_content">
<TextView
android:id="@android:id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"/>
<TextView
android:id="@android:id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<TextView android:id="@android:id/title"
android:textColor="?android:attr/textColorSecondary"
android:textSize="18sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="end"/>
<TextView android:id="@android:id/text1"
android:textColor="?android:attr/textColorTertiary"
android:textSize="14sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="end"
android:layout_marginTop="-4dip"/>
<TextView android:id="@android:id/text2"
android:textColor="?android:attr/textColorTertiary"
android:textSize="14sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="end"
android:layout_marginTop="-4dip"/>
</LinearLayout>

View File

@ -30,11 +30,20 @@
android:singleLine="true"
android:ellipsize="end"
android:layout_marginTop="-4dip"/>
<TextView android:id="@android:id/text2"
android:textColor="?android:attr/textColorTertiary"
android:textSize="14sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="16dip"
android:singleLine="true"
android:ellipsize="end"
android:layout_marginTop="-4dip"/>
</LinearLayout>
<ImageView
android:id="@android:id/icon"
android:layout_width="48dip"
android:layout_height="48dip"
android:layout_width="56dip"
android:layout_height="56dip"
android:layout_marginLeft="12dip"
android:cropToPadding="true"
android:background="#ccc"