mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 12:19:54 +01:00
Merge branch '533-explain-why-forum-can-t-be-shared-with-contact' into 'master'
Explain why forum can't be shared with contact Closes #533 See merge request !252
This commit is contained in:
@@ -6,10 +6,12 @@ import android.graphics.ColorFilter;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.os.Build;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.contact.BaseContactListAdapter;
|
||||
@@ -19,13 +21,31 @@ import org.briarproject.api.contact.ContactId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
public class ContactSelectorAdapter
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
|
||||
class ContactSelectorAdapter
|
||||
extends BaseContactListAdapter<ContactSelectorAdapter.SelectableContactHolder> {
|
||||
|
||||
public ContactSelectorAdapter(Context context,
|
||||
private final ColorFilter grayColorFilter;
|
||||
|
||||
ContactSelectorAdapter(Context context,
|
||||
OnItemClickListener listener) {
|
||||
|
||||
super(context, listener);
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
grayColorFilter = null;
|
||||
} else {
|
||||
// Overlay the background colour at 75% opacity
|
||||
int bg = ContextCompat.getColor(context, R.color.window_background);
|
||||
int alpha = (int) (255 * 0.75f);
|
||||
int red = Color.red(bg);
|
||||
int green = Color.green(bg);
|
||||
int blue = Color.blue(bg);
|
||||
bg = Color.argb(alpha, red, green, blue);
|
||||
grayColorFilter = new PorterDuffColorFilter(bg,
|
||||
PorterDuff.Mode.SRC_OVER);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,11 +73,16 @@ public class ContactSelectorAdapter
|
||||
if (item.isDisabled()) {
|
||||
// we share this forum already with that contact
|
||||
ui.layout.setEnabled(false);
|
||||
grayOutItem(ui);
|
||||
ui.shared.setVisibility(VISIBLE);
|
||||
grayOutItem(ui, true);
|
||||
} else {
|
||||
ui.layout.setEnabled(true);
|
||||
ui.shared.setVisibility(GONE);
|
||||
grayOutItem(ui, false);
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<ContactId> getSelectedContactIds() {
|
||||
Collection<ContactId> getSelectedContactIds() {
|
||||
Collection<ContactId> selected = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < contacts.size(); i++) {
|
||||
@@ -69,15 +94,17 @@ public class ContactSelectorAdapter
|
||||
return selected;
|
||||
}
|
||||
|
||||
protected static class SelectableContactHolder
|
||||
static class SelectableContactHolder
|
||||
extends BaseContactListAdapter.BaseContactHolder {
|
||||
|
||||
private final CheckBox checkBox;
|
||||
private final TextView shared;
|
||||
|
||||
public SelectableContactHolder(View v) {
|
||||
SelectableContactHolder(View v) {
|
||||
super(v);
|
||||
|
||||
checkBox = (CheckBox) v.findViewById(R.id.checkBox);
|
||||
shared = (TextView) v.findViewById(R.id.infoView);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,18 +113,15 @@ public class ContactSelectorAdapter
|
||||
return compareByName(c1, c2);
|
||||
}
|
||||
|
||||
private void grayOutItem(final SelectableContactHolder ui) {
|
||||
private void grayOutItem(SelectableContactHolder ui, boolean gray) {
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
float alpha = 0.25f;
|
||||
float alpha = gray ? 0.25f : 1f;
|
||||
ui.avatar.setAlpha(alpha);
|
||||
ui.name.setAlpha(alpha);
|
||||
ui.checkBox.setAlpha(alpha);
|
||||
} else {
|
||||
ColorFilter colorFilter = new PorterDuffColorFilter(Color.GRAY,
|
||||
PorterDuff.Mode.MULTIPLY);
|
||||
ui.avatar.setColorFilter(colorFilter);
|
||||
ui.name.setEnabled(false);
|
||||
ui.checkBox.setEnabled(false);
|
||||
if (gray) ui.avatar.setColorFilter(grayColorFilter);
|
||||
else ui.avatar.clearColorFilter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user