mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 05:39:53 +01:00
Merge branch 'identicon-contrast' into 'master'
Increase contrast between identicons and background Identicons currently have a dark or light background depending on the V component of the foreground colour. But V isn't a great measure of brightness - cyan looks much brighter than blue with the same V, for example. This leads to some identicons having low contrast between the foreground and background. This patch scales the R, G and B components of the foreground colour to 3/4 of the full range and sets the background to white, so there's always good contrast between the foreground and background. The patch also adds a 1dp outline around identicons and adds some padding to the identity selection dropdown. Before:  After:  See merge request !100
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
@@ -10,7 +11,9 @@
|
|||||||
android:layout_height="@dimen/listitem_picture_size"
|
android:layout_height="@dimen/listitem_picture_size"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginLeft="@dimen/listitem_horizontal_margin"
|
android:layout_marginLeft="@dimen/listitem_horizontal_margin"
|
||||||
android:layout_marginStart="@dimen/listitem_horizontal_margin"/>
|
android:layout_marginStart="@dimen/listitem_horizontal_margin"
|
||||||
|
app:civ_border_width="@dimen/avatar_border_width"
|
||||||
|
app:civ_border_color="@color/briar_text_primary"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/statusView"
|
android:id="@+id/statusView"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:gravity="center_vertical">
|
android:gravity="center_vertical">
|
||||||
@@ -9,14 +10,16 @@
|
|||||||
<de.hdodenhof.circleimageview.CircleImageView
|
<de.hdodenhof.circleimageview.CircleImageView
|
||||||
android:id="@+id/avatarView"
|
android:id="@+id/avatarView"
|
||||||
android:layout_width="@dimen/dropdown_picture_size"
|
android:layout_width="@dimen/dropdown_picture_size"
|
||||||
android:layout_height="@dimen/dropdown_picture_size"/>
|
android:layout_height="@dimen/dropdown_picture_size"
|
||||||
|
android:layout_margin="@dimen/margin_small"
|
||||||
|
app:civ_border_width="@dimen/avatar_border_width"
|
||||||
|
app:civ_border_color="@color/briar_text_primary"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/nameView"
|
android:id="@+id/nameView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="@dimen/margin_medium"
|
android:layout_margin="@dimen/margin_small"
|
||||||
android:layout_marginStart="@dimen/margin_medium"
|
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textSize="@dimen/text_size_medium"
|
android:textSize="@dimen/text_size_medium"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
@@ -19,7 +20,9 @@
|
|||||||
android:layout_alignParentStart="true"
|
android:layout_alignParentStart="true"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginLeft="@dimen/listitem_horizontal_margin"
|
android:layout_marginLeft="@dimen/listitem_horizontal_margin"
|
||||||
android:layout_marginStart="@dimen/listitem_horizontal_margin"/>
|
android:layout_marginStart="@dimen/listitem_horizontal_margin"
|
||||||
|
app:civ_border_width="@dimen/avatar_border_width"
|
||||||
|
app:civ_border_color="@color/briar_text_primary"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/bulbHolder"
|
android:id="@+id/bulbHolder"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
@@ -16,7 +17,8 @@
|
|||||||
android:layout_height="@dimen/listitem_picture_size"
|
android:layout_height="@dimen/listitem_picture_size"
|
||||||
android:layout_marginLeft="@dimen/listitem_horizontal_margin"
|
android:layout_marginLeft="@dimen/listitem_horizontal_margin"
|
||||||
android:layout_marginStart="@dimen/listitem_horizontal_margin"
|
android:layout_marginStart="@dimen/listitem_horizontal_margin"
|
||||||
/>
|
app:civ_border_width="@dimen/avatar_border_width"
|
||||||
|
app:civ_border_color="@color/briar_text_primary"/>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/msgLayout"
|
android:id="@+id/msgLayout"
|
||||||
|
|||||||
@@ -21,11 +21,10 @@
|
|||||||
<dimen name="nav_seperator_height">1dp</dimen>
|
<dimen name="nav_seperator_height">1dp</dimen>
|
||||||
|
|
||||||
<dimen name="listitem_horizontal_margin">16dp</dimen>
|
<dimen name="listitem_horizontal_margin">16dp</dimen>
|
||||||
<dimen name="listitem_picture_size">40dp</dimen>
|
|
||||||
<dimen name="listitem_text_left_margin">72dp</dimen>
|
<dimen name="listitem_text_left_margin">72dp</dimen>
|
||||||
|
|
||||||
<dimen name="listitem_height_one_line_avatar">56dp</dimen>
|
<dimen name="listitem_height_one_line_avatar">56dp</dimen>
|
||||||
|
<dimen name="listitem_picture_size">40dp</dimen>
|
||||||
<dimen name="dropdown_picture_size">32dp</dimen>
|
<dimen name="dropdown_picture_size">32dp</dimen>
|
||||||
|
<dimen name="avatar_border_width">1dp</dimen>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ package im.delight.android.identicons;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
import org.briarproject.api.crypto.CryptoComponent;
|
import org.briarproject.api.crypto.CryptoComponent;
|
||||||
@@ -73,11 +72,6 @@ public class AsymmetricIdenticon extends IdenticonView {
|
|||||||
protected boolean isCellVisible(int row, int column) {
|
protected boolean isCellVisible(int row, int column) {
|
||||||
return getByte(3 + row * getColumnCount() + column) >= 0;
|
return getByte(3 + row * getColumnCount() + column) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getIconColor() {
|
|
||||||
return Color.rgb(getByte(0) + 128, getByte(1) + 128, getByte(2) + 128);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -93,15 +93,16 @@ public abstract class IdenticonBase {
|
|||||||
|
|
||||||
abstract protected boolean isCellVisible(int row, int column);
|
abstract protected boolean isCellVisible(int row, int column);
|
||||||
|
|
||||||
abstract protected int getIconColor();
|
protected int getIconColor() {
|
||||||
|
int r = getByte(0) * 3 / 4 + 96;
|
||||||
|
int g = getByte(1) * 3 / 4 + 96;
|
||||||
|
int b = getByte(2) * 3 / 4 + 96;
|
||||||
|
return Color.rgb(r, g, b);
|
||||||
|
}
|
||||||
|
|
||||||
protected int getBackgroundColor() {
|
protected int getBackgroundColor() {
|
||||||
float[] hsv = new float[3];
|
// http://www.google.com/design/spec/style/color.html#color-themes
|
||||||
Color.colorToHSV(getIconColor(), hsv);
|
return Color.rgb(0xFA, 0xFA, 0xFA);
|
||||||
if (hsv[2] < 0.5)
|
|
||||||
return Color.parseColor("#ffeeeeee"); // @color/background_material_light
|
|
||||||
else
|
|
||||||
return Color.parseColor("#ff303030"); // @color/background_material_dark
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateSize(int w, int h) {
|
public void updateSize(int w, int h) {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package im.delight.android.identicons;
|
package im.delight.android.identicons;
|
||||||
|
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.graphics.ColorFilter;
|
import android.graphics.ColorFilter;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
@@ -39,11 +38,6 @@ public class IdenticonDrawable extends Drawable {
|
|||||||
protected boolean isCellVisible(int row, int column) {
|
protected boolean isCellVisible(int row, int column) {
|
||||||
return getByte(3 + row * CENTER_COLUMN_INDEX + getSymmetricColumnIndex(column)) >= 0;
|
return getByte(3 + row * CENTER_COLUMN_INDEX + getSymmetricColumnIndex(column)) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getIconColor() {
|
|
||||||
return Color.rgb(getByte(0) + 128, getByte(1) + 128, getByte(2) + 128);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
mDelegate.show(toShow);
|
mDelegate.show(toShow);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,10 +94,6 @@ abstract public class IdenticonView extends View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected byte getByte(int index) {
|
|
||||||
return getDelegate().getByte(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract protected IdenticonBase getDelegate();
|
abstract protected IdenticonBase getDelegate();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ package im.delight.android.identicons;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
|
||||||
import org.briarproject.api.crypto.CryptoComponent;
|
import org.briarproject.api.crypto.CryptoComponent;
|
||||||
@@ -70,11 +69,6 @@ public class SymmetricIdenticon extends IdenticonView {
|
|||||||
protected boolean isCellVisible(int row, int column) {
|
protected boolean isCellVisible(int row, int column) {
|
||||||
return getByte(3 + row * CENTER_COLUMN_INDEX + getSymmetricColumnIndex(column)) >= 0;
|
return getByte(3 + row * CENTER_COLUMN_INDEX + getSymmetricColumnIndex(column)) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getIconColor() {
|
|
||||||
return Color.rgb(getByte(0) + 128, getByte(1) + 128, getByte(2) + 128);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user