Layout tweaks: outline StrengthMeter, indent EditTexts.

This commit is contained in:
akwizgran
2014-02-11 11:40:08 +00:00
parent 44c39e6e4a
commit b10827d84b
8 changed files with 41 additions and 23 deletions

View File

@@ -62,13 +62,12 @@ public class PasswordActivity extends RoboActivity {
layout.setLayoutParams(MATCH_MATCH);
layout.setOrientation(VERTICAL);
layout.setGravity(CENTER_HORIZONTAL);
int pad = LayoutUtils.getPadding(this);
layout.setPadding(pad, pad, pad, pad);
enterPassword = new TextView(this);
enterPassword.setGravity(CENTER);
enterPassword.setTextSize(18);
enterPassword.setPadding(pad, pad, pad, 0);
enterPassword.setText(R.string.enter_password);
layout.addView(enterPassword);

View File

@@ -76,13 +76,12 @@ public class SetupActivity extends RoboActivity implements OnClickListener {
layout.setLayoutParams(MATCH_MATCH);
layout.setOrientation(VERTICAL);
layout.setGravity(CENTER_HORIZONTAL);
int pad = LayoutUtils.getPadding(this);
layout.setPadding(pad, pad, pad, pad);
TextView chooseNickname = new TextView(this);
chooseNickname.setGravity(CENTER);
chooseNickname.setTextSize(18);
chooseNickname.setPadding(pad, pad, pad, 0);
chooseNickname.setText(R.string.choose_nickname);
layout.addView(chooseNickname);
@@ -102,7 +101,7 @@ public class SetupActivity extends RoboActivity implements OnClickListener {
TextView choosePassword = new TextView(this);
choosePassword.setGravity(CENTER);
choosePassword.setTextSize(18);
choosePassword.setPadding(pad, pad, pad, 0);
choosePassword.setPadding(0, pad, 0, 0);
choosePassword.setText(R.string.choose_password);
layout.addView(choosePassword);
@@ -122,7 +121,7 @@ public class SetupActivity extends RoboActivity implements OnClickListener {
TextView confirmPassword = new TextView(this);
confirmPassword.setGravity(CENTER);
confirmPassword.setTextSize(18);
confirmPassword.setPadding(pad, pad, pad, 0);
confirmPassword.setPadding(0, pad, 0, 0);
confirmPassword.setText(R.string.confirm_password);
layout.addView(confirmPassword);
@@ -140,13 +139,13 @@ public class SetupActivity extends RoboActivity implements OnClickListener {
layout.addView(passwordConfirmation);
strengthMeter = new StrengthMeter(this);
strengthMeter.setPadding(5 * pad, pad, 5 * pad, 0);
strengthMeter.setPadding(0, 2 * pad, 0, 0);
layout.addView(strengthMeter);
feedback = new TextView(this);
feedback.setGravity(CENTER);
feedback.setTextSize(14);
feedback.setPadding(pad, pad, pad, pad);
feedback.setPadding(0, pad, 0, pad);
feedback.setText("");
layout.addView(feedback);

View File

@@ -155,6 +155,7 @@ implements EventListener, OnClickListener, OnItemClickListener {
LinearLayout footer = new LinearLayout(this);
footer.setLayoutParams(MATCH_WRAP);
footer.setOrientation(HORIZONTAL);
footer.setPadding(pad, 0, 0, 0);
content = new EditText(this);
content.setId(1);
@@ -168,6 +169,8 @@ implements EventListener, OnClickListener, OnItemClickListener {
sendButton.setId(2);
sendButton.setBackgroundResource(0);
sendButton.setImageResource(R.drawable.social_send_now);
sendButton.setScaleX(1.5f);
sendButton.setScaleY(1.5f);
sendButton.setEnabled(false); // Enabled after loading the group
sendButton.setOnClickListener(this);
footer.addView(sendButton);

View File

@@ -97,16 +97,17 @@ implements OnClickListener {
LinearLayout layout = new LinearLayout(this);
layout.setLayoutParams(MATCH_WRAP);
layout.setOrientation(VERTICAL);
int pad = LayoutUtils.getPadding(this);
layout.setPadding(pad, pad, pad, pad);
RelativeLayout header = new RelativeLayout(this);
int pad = LayoutUtils.getPadding(this);
from = new TextView(this);
from.setId(1);
from.setTextSize(18);
from.setSingleLine();
from.setEllipsize(END);
from.setPadding(pad, pad, pad, pad);
from.setPadding(0, 0, pad, pad);
from.setText(R.string.from);
RelativeLayout.LayoutParams leftOf = CommonLayoutParams.relative();
leftOf.addRule(ALIGN_PARENT_LEFT);
@@ -118,6 +119,8 @@ implements OnClickListener {
sendButton.setId(2);
sendButton.setBackgroundResource(0);
sendButton.setImageResource(R.drawable.social_send_now);
sendButton.setScaleX(1.5f);
sendButton.setScaleY(1.5f);
sendButton.setEnabled(false); // Enabled after loading the group
sendButton.setOnClickListener(this);
RelativeLayout.LayoutParams right = CommonLayoutParams.relative();
@@ -130,7 +133,7 @@ implements OnClickListener {
to.setTextSize(18);
to.setSingleLine();
to.setEllipsize(END);
to.setPadding(pad, 0, pad, pad);
to.setPadding(0, 0, pad, pad);
String format = getResources().getString(R.string.format_to);
to.setText(String.format(format, contactName));
layout.addView(to);

View File

@@ -82,13 +82,12 @@ SelectContactsDialog.Listener {
layout.setLayoutParams(MATCH_MATCH);
layout.setOrientation(VERTICAL);
layout.setGravity(CENTER_HORIZONTAL);
int pad = LayoutUtils.getPadding(this);
layout.setPadding(pad, pad, pad, pad);
TextView chooseName = new TextView(this);
chooseName.setGravity(CENTER);
chooseName.setTextSize(18);
chooseName.setPadding(pad, pad, pad, 0);
chooseName.setText(R.string.choose_forum_name);
layout.addView(chooseName);

View File

@@ -110,14 +110,15 @@ implements OnItemSelectedListener, OnClickListener {
LinearLayout layout = new LinearLayout(this);
layout.setLayoutParams(MATCH_WRAP);
layout.setOrientation(VERTICAL);
int pad = LayoutUtils.getPadding(this);
layout.setPadding(pad, pad, pad, pad);
RelativeLayout header = new RelativeLayout(this);
int pad = LayoutUtils.getPadding(this);
TextView from = new TextView(this);
from.setId(1);
from.setTextSize(18);
from.setPadding(pad, pad, 0, pad);
from.setPadding(0, 0, 0, pad);
from.setText(R.string.from);
RelativeLayout.LayoutParams left = CommonLayoutParams.relative();
left.addRule(ALIGN_PARENT_LEFT);
@@ -139,6 +140,8 @@ implements OnItemSelectedListener, OnClickListener {
sendButton.setId(3);
sendButton.setBackgroundResource(0);
sendButton.setImageResource(R.drawable.social_send_now);
sendButton.setScaleX(1.5f);
sendButton.setScaleY(1.5f);
sendButton.setEnabled(false); // Enabled after loading the group
sendButton.setOnClickListener(this);
RelativeLayout.LayoutParams right = CommonLayoutParams.relative();
@@ -151,7 +154,7 @@ implements OnItemSelectedListener, OnClickListener {
to.setTextSize(18);
to.setSingleLine();
to.setEllipsize(END);
to.setPadding(pad, 0, pad, pad);
to.setPadding(0, 0, pad, pad);
to.setText(R.string.to);
layout.addView(to);

View File

@@ -71,13 +71,12 @@ implements OnEditorActionListener, OnClickListener {
layout.setLayoutParams(MATCH_MATCH);
layout.setOrientation(VERTICAL);
layout.setGravity(CENTER_HORIZONTAL);
int pad = LayoutUtils.getPadding(this);
layout.setPadding(pad, pad, pad, pad);
TextView chooseNickname = new TextView(this);
chooseNickname.setGravity(CENTER);
chooseNickname.setTextSize(18);
chooseNickname.setPadding(pad, pad, pad, 0);
chooseNickname.setText(R.string.choose_nickname);
layout.addView(chooseNickname);

View File

@@ -1,5 +1,8 @@
package org.briarproject.android.util;
import static android.graphics.Color.BLACK;
import static android.graphics.Paint.Style.FILL;
import static android.graphics.Paint.Style.STROKE;
import static android.graphics.drawable.ClipDrawable.HORIZONTAL;
import static android.view.Gravity.LEFT;
import static org.briarproject.api.crypto.PasswordStrengthEstimator.QUITE_STRONG;
@@ -8,9 +11,11 @@ import static org.briarproject.api.crypto.PasswordStrengthEstimator.STRONG;
import static org.briarproject.api.crypto.PasswordStrengthEstimator.WEAK;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.ClipDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.RectShape;
import android.widget.ProgressBar;
public class StrengthMeter extends ProgressBar {
@@ -26,10 +31,18 @@ public class StrengthMeter extends ProgressBar {
public StrengthMeter(Context context) {
super(context, null, android.R.attr.progressBarStyleHorizontal);
bar = new ShapeDrawable(new RectShape());
bar.getPaint().setColor(Color.RED);
ClipDrawable progress = new ClipDrawable(bar, LEFT, HORIZONTAL);
setProgressDrawable(progress);
bar = new ShapeDrawable();
bar.getPaint().setColor(RED);
ClipDrawable clip = new ClipDrawable(bar, LEFT, HORIZONTAL);
ShapeDrawable background = new ShapeDrawable();
Paint p = background.getPaint();
p.setStyle(FILL);
p.setColor(getResources().getColor(android.R.color.transparent));
p.setStyle(STROKE);
p.setStrokeWidth(1);
p.setColor(BLACK);
Drawable[] layers = new Drawable[] { clip, background };
setProgressDrawable(new LayerDrawable(layers));
setIndeterminate(false);
}