mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 20:29:52 +01:00
Padding now depends on screen size. Closes dev task #57.
This commit is contained in:
@@ -2,15 +2,21 @@ package org.briarproject.android.invitation;
|
||||
|
||||
import static android.view.Gravity.CENTER_HORIZONTAL;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
||||
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
abstract class AddContactView extends LinearLayout {
|
||||
|
||||
protected final int pad;
|
||||
|
||||
protected AddContactActivity container = null;
|
||||
|
||||
AddContactView(Context ctx) {
|
||||
super(ctx);
|
||||
pad = LayoutUtils.getPadding(ctx);
|
||||
}
|
||||
|
||||
void init(AddContactActivity container) {
|
||||
|
||||
@@ -4,7 +4,10 @@ import static android.bluetooth.BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERA
|
||||
import static android.provider.Settings.ACTION_BLUETOOTH_SETTINGS;
|
||||
import static android.view.Gravity.CENTER;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP_1;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
|
||||
import android.bluetooth.BluetoothAdapter;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -17,8 +20,11 @@ import android.widget.TextView;
|
||||
|
||||
class BluetoothStatusView extends LinearLayout implements OnClickListener {
|
||||
|
||||
private final int pad;
|
||||
|
||||
public BluetoothStatusView(Context ctx) {
|
||||
super(ctx);
|
||||
pad = LayoutUtils.getPadding(ctx);
|
||||
}
|
||||
|
||||
void init() {
|
||||
@@ -33,18 +39,18 @@ class BluetoothStatusView extends LinearLayout implements OnClickListener {
|
||||
TextView status = new TextView(ctx);
|
||||
status.setLayoutParams(WRAP_WRAP_1);
|
||||
status.setTextSize(14);
|
||||
status.setPadding(10, 10, 10, 10);
|
||||
status.setPadding(pad, pad, pad, pad);
|
||||
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
|
||||
if(adapter == null) {
|
||||
ImageView warning = new ImageView(ctx);
|
||||
warning.setPadding(5, 5, 5, 5);
|
||||
warning.setPadding(pad, pad, pad, pad);
|
||||
warning.setImageResource(R.drawable.alerts_and_states_warning);
|
||||
addView(warning);
|
||||
status.setText(R.string.bluetooth_not_available);
|
||||
addView(status);
|
||||
} else if(adapter.getScanMode() == SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
|
||||
ImageView ok = new ImageView(ctx);
|
||||
ok.setPadding(5, 5, 5, 5);
|
||||
ok.setPadding(pad, pad, pad, pad);
|
||||
ok.setImageResource(R.drawable.navigation_accept);
|
||||
addView(ok);
|
||||
status.setText(R.string.bluetooth_discoverable);
|
||||
@@ -55,7 +61,7 @@ class BluetoothStatusView extends LinearLayout implements OnClickListener {
|
||||
addView(settings);
|
||||
} else if(adapter.isEnabled()) {
|
||||
ImageView warning = new ImageView(ctx);
|
||||
warning.setPadding(5, 5, 5, 5);
|
||||
warning.setPadding(pad, pad, pad, pad);
|
||||
warning.setImageResource(R.drawable.alerts_and_states_warning);
|
||||
addView(warning);
|
||||
status.setText(R.string.bluetooth_not_discoverable);
|
||||
@@ -66,7 +72,7 @@ class BluetoothStatusView extends LinearLayout implements OnClickListener {
|
||||
addView(settings);
|
||||
} else {
|
||||
ImageView warning = new ImageView(ctx);
|
||||
warning.setPadding(5, 5, 5, 5);
|
||||
warning.setPadding(pad, pad, pad, pad);
|
||||
warning.setImageResource(R.drawable.alerts_and_states_warning);
|
||||
addView(warning);
|
||||
status.setText(R.string.bluetooth_disabled);
|
||||
|
||||
@@ -6,7 +6,10 @@ import static android.view.Gravity.CENTER;
|
||||
import static android.view.Gravity.CENTER_HORIZONTAL;
|
||||
import static android.view.inputmethod.InputMethodManager.HIDE_IMPLICIT_ONLY;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
@@ -21,12 +24,15 @@ import android.widget.TextView.OnEditorActionListener;
|
||||
class CodeEntryView extends LinearLayout
|
||||
implements OnEditorActionListener, OnClickListener {
|
||||
|
||||
private final int pad;
|
||||
|
||||
private CodeEntryListener listener = null;
|
||||
private EditText codeEntry = null;
|
||||
private Button continueButton = null;
|
||||
|
||||
public CodeEntryView(Context ctx) {
|
||||
super(ctx);
|
||||
pad = LayoutUtils.getPadding(ctx);
|
||||
}
|
||||
|
||||
void init(CodeEntryListener listener, String prompt) {
|
||||
@@ -38,7 +44,7 @@ implements OnEditorActionListener, OnClickListener {
|
||||
TextView enterCode = new TextView(ctx);
|
||||
enterCode.setGravity(CENTER_HORIZONTAL);
|
||||
enterCode.setTextSize(14);
|
||||
enterCode.setPadding(10, 10, 10, 0);
|
||||
enterCode.setPadding(pad, pad, pad, 0);
|
||||
enterCode.setText(prompt);
|
||||
addView(enterCode);
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@ package org.briarproject.android.invitation;
|
||||
|
||||
import static android.view.Gravity.CENTER;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP;
|
||||
|
||||
import org.briarproject.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
@@ -30,14 +32,14 @@ class CodesDoNotMatchView extends AddContactView implements OnClickListener {
|
||||
|
||||
TextView failed = new TextView(ctx);
|
||||
failed.setTextSize(22);
|
||||
failed.setPadding(10, 10, 10, 10);
|
||||
failed.setPadding(pad, pad, pad, pad);
|
||||
failed.setText(R.string.codes_do_not_match);
|
||||
innerLayout.addView(failed);
|
||||
addView(innerLayout);
|
||||
|
||||
TextView interfering = new TextView(ctx);
|
||||
interfering.setTextSize(14);
|
||||
interfering.setPadding(10, 0, 10, 10);
|
||||
interfering.setPadding(pad, 0, pad, pad);
|
||||
interfering.setText(R.string.interfering);
|
||||
addView(interfering);
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@ package org.briarproject.android.invitation;
|
||||
|
||||
import static android.view.Gravity.CENTER;
|
||||
import static android.view.Gravity.CENTER_HORIZONTAL;
|
||||
|
||||
import org.briarproject.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.widget.ImageView;
|
||||
@@ -28,7 +30,7 @@ class ConfirmationCodeView extends AddContactView implements CodeEntryListener {
|
||||
|
||||
TextView connected = new TextView(ctx);
|
||||
connected.setTextSize(22);
|
||||
connected.setPadding(10, 10, 10, 10);
|
||||
connected.setPadding(pad, pad, pad, pad);
|
||||
connected.setText(R.string.connected_to_contact);
|
||||
innerLayout.addView(connected);
|
||||
addView(innerLayout);
|
||||
@@ -36,14 +38,14 @@ class ConfirmationCodeView extends AddContactView implements CodeEntryListener {
|
||||
TextView yourCode = new TextView(ctx);
|
||||
yourCode.setGravity(CENTER_HORIZONTAL);
|
||||
yourCode.setTextSize(14);
|
||||
yourCode.setPadding(10, 10, 10, 10);
|
||||
yourCode.setPadding(pad, pad, pad, pad);
|
||||
yourCode.setText(R.string.your_confirmation_code);
|
||||
addView(yourCode);
|
||||
|
||||
TextView code = new TextView(ctx);
|
||||
code.setGravity(CENTER_HORIZONTAL);
|
||||
code.setTextSize(50);
|
||||
code.setPadding(10, 0, 10, 10);
|
||||
code.setPadding(pad, 0, pad, pad);
|
||||
int localCode = container.getLocalConfirmationCode();
|
||||
code.setText(String.format("%06d", localCode));
|
||||
addView(code);
|
||||
|
||||
@@ -27,7 +27,7 @@ class ConnectedView extends AddContactView {
|
||||
|
||||
TextView connected = new TextView(ctx);
|
||||
connected.setTextSize(22);
|
||||
connected.setPadding(10, 10, 10, 10);
|
||||
connected.setPadding(pad, pad, pad, pad);
|
||||
connected.setText(R.string.connected_to_contact);
|
||||
innerLayout.addView(connected);
|
||||
addView(innerLayout);
|
||||
@@ -38,7 +38,7 @@ class ConnectedView extends AddContactView {
|
||||
|
||||
ProgressBar progress = new ProgressBar(ctx);
|
||||
progress.setIndeterminate(true);
|
||||
progress.setPadding(10, 10, 10, 10);
|
||||
progress.setPadding(pad, pad, pad, pad);
|
||||
innerLayout.addView(progress);
|
||||
|
||||
TextView connecting = new TextView(ctx);
|
||||
|
||||
@@ -2,7 +2,9 @@ package org.briarproject.android.invitation;
|
||||
|
||||
import static android.view.Gravity.CENTER;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP;
|
||||
|
||||
import org.briarproject.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
@@ -34,14 +36,14 @@ class ConnectionFailedView extends AddContactView implements OnClickListener {
|
||||
|
||||
TextView failed = new TextView(ctx);
|
||||
failed.setTextSize(22);
|
||||
failed.setPadding(10, 10, 10, 10);
|
||||
failed.setPadding(pad, pad, pad, pad);
|
||||
failed.setText(R.string.connection_failed);
|
||||
innerLayout.addView(failed);
|
||||
addView(innerLayout);
|
||||
|
||||
TextView checkNetwork = new TextView(ctx);
|
||||
checkNetwork.setTextSize(14);
|
||||
checkNetwork.setPadding(10, 0, 10, 10);
|
||||
checkNetwork.setPadding(pad, 0, pad, pad);
|
||||
checkNetwork.setText(R.string.check_same_network);
|
||||
addView(checkNetwork);
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@ package org.briarproject.android.invitation;
|
||||
|
||||
import static android.view.Gravity.CENTER;
|
||||
import static android.view.Gravity.CENTER_HORIZONTAL;
|
||||
|
||||
import org.briarproject.R;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
@@ -20,14 +22,14 @@ class ConnectionView extends AddContactView {
|
||||
TextView yourCode = new TextView(ctx);
|
||||
yourCode.setGravity(CENTER_HORIZONTAL);
|
||||
yourCode.setTextSize(14);
|
||||
yourCode.setPadding(10, 10, 10, 10);
|
||||
yourCode.setPadding(pad, pad, pad, pad);
|
||||
yourCode.setText(R.string.your_invitation_code);
|
||||
addView(yourCode);
|
||||
|
||||
TextView code = new TextView(ctx);
|
||||
code.setGravity(CENTER_HORIZONTAL);
|
||||
code.setTextSize(50);
|
||||
code.setPadding(10, 0, 10, 10);
|
||||
code.setPadding(pad, 0, pad, pad);
|
||||
int localCode = container.getLocalInvitationCode();
|
||||
code.setText(String.format("%06d", localCode));
|
||||
addView(code);
|
||||
@@ -40,7 +42,7 @@ class ConnectionView extends AddContactView {
|
||||
|
||||
ProgressBar progress = new ProgressBar(ctx);
|
||||
progress.setIndeterminate(true);
|
||||
progress.setPadding(10, 10, 10, 10);
|
||||
progress.setPadding(pad, pad, pad, pad);
|
||||
innerLayout.addView(progress);
|
||||
|
||||
TextView connecting = new TextView(ctx);
|
||||
@@ -58,7 +60,7 @@ class ConnectionView extends AddContactView {
|
||||
innerLayout.setGravity(CENTER);
|
||||
|
||||
ProgressBar progress = new ProgressBar(ctx);
|
||||
progress.setPadding(10, 10, 10, 10);
|
||||
progress.setPadding(pad, pad, pad, pad);
|
||||
progress.setIndeterminate(true);
|
||||
innerLayout.addView(progress);
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class ContactDetailsView extends AddContactView {
|
||||
|
||||
TextView connected = new TextView(ctx);
|
||||
connected.setTextSize(22);
|
||||
connected.setPadding(10, 10, 10, 10);
|
||||
connected.setPadding(pad, pad, pad, pad);
|
||||
connected.setText(R.string.connected_to_contact);
|
||||
innerLayout.addView(connected);
|
||||
addView(innerLayout);
|
||||
@@ -36,14 +36,14 @@ class ContactDetailsView extends AddContactView {
|
||||
TextView yourCode = new TextView(ctx);
|
||||
yourCode.setGravity(CENTER_HORIZONTAL);
|
||||
yourCode.setTextSize(14);
|
||||
yourCode.setPadding(10, 0, 10, 10);
|
||||
yourCode.setPadding(pad, 0, pad, pad);
|
||||
yourCode.setText(R.string.your_confirmation_code);
|
||||
addView(yourCode);
|
||||
|
||||
TextView code = new TextView(ctx);
|
||||
code.setGravity(CENTER_HORIZONTAL);
|
||||
code.setTextSize(50);
|
||||
code.setPadding(10, 0, 10, 10);
|
||||
code.setPadding(pad, 0, pad, pad);
|
||||
int localCode = container.getLocalConfirmationCode();
|
||||
code.setText(String.format("%06d", localCode));
|
||||
addView(code);
|
||||
@@ -54,7 +54,7 @@ class ContactDetailsView extends AddContactView {
|
||||
|
||||
ProgressBar progress = new ProgressBar(ctx);
|
||||
progress.setIndeterminate(true);
|
||||
progress.setPadding(10, 10, 10, 10);
|
||||
progress.setPadding(pad, pad, pad, pad);
|
||||
innerLayout.addView(progress);
|
||||
|
||||
TextView connecting = new TextView(ctx);
|
||||
|
||||
@@ -18,14 +18,14 @@ class InvitationCodeView extends AddContactView implements CodeEntryListener {
|
||||
TextView yourCode = new TextView(ctx);
|
||||
yourCode.setGravity(CENTER_HORIZONTAL);
|
||||
yourCode.setTextSize(14);
|
||||
yourCode.setPadding(10, 10, 10, 10);
|
||||
yourCode.setPadding(pad, pad, pad, pad);
|
||||
yourCode.setText(R.string.your_invitation_code);
|
||||
addView(yourCode);
|
||||
|
||||
TextView code = new TextView(ctx);
|
||||
code.setGravity(CENTER_HORIZONTAL);
|
||||
code.setTextSize(50);
|
||||
code.setPadding(10, 0, 10, 10);
|
||||
code.setPadding(pad, 0, pad, pad);
|
||||
int localCode = container.getLocalInvitationCode();
|
||||
code.setText(String.format("%06d", localCode));
|
||||
addView(code);
|
||||
|
||||
@@ -44,7 +44,7 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
|
||||
TextView yourNickname = new TextView(ctx);
|
||||
yourNickname.setTextSize(18);
|
||||
yourNickname.setPadding(10, 10, 10, 10);
|
||||
yourNickname.setPadding(pad, pad, pad, pad);
|
||||
yourNickname.setText(R.string.your_nickname);
|
||||
innerLayout.addView(yourNickname);
|
||||
|
||||
@@ -67,7 +67,7 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
TextView faceToFace = new TextView(ctx);
|
||||
faceToFace.setGravity(CENTER);
|
||||
faceToFace.setTextSize(14);
|
||||
faceToFace.setPadding(10, 10, 10, 10);
|
||||
faceToFace.setPadding(pad, pad, pad, pad);
|
||||
faceToFace.setText(R.string.fact_to_face);
|
||||
addView(faceToFace);
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ class WaitForContactView extends AddContactView {
|
||||
|
||||
TextView connected = new TextView(ctx);
|
||||
connected.setTextSize(22);
|
||||
connected.setPadding(10, 10, 10, 10);
|
||||
connected.setPadding(pad, pad, pad, pad);
|
||||
connected.setText(R.string.connected_to_contact);
|
||||
innerLayout.addView(connected);
|
||||
addView(innerLayout);
|
||||
@@ -36,14 +36,14 @@ class WaitForContactView extends AddContactView {
|
||||
TextView yourCode = new TextView(ctx);
|
||||
yourCode.setGravity(CENTER_HORIZONTAL);
|
||||
yourCode.setTextSize(14);
|
||||
yourCode.setPadding(10, 0, 10, 10);
|
||||
yourCode.setPadding(pad, 0, pad, pad);
|
||||
yourCode.setText(R.string.your_confirmation_code);
|
||||
addView(yourCode);
|
||||
|
||||
TextView code = new TextView(ctx);
|
||||
code.setGravity(CENTER_HORIZONTAL);
|
||||
code.setTextSize(50);
|
||||
code.setPadding(10, 0, 10, 10);
|
||||
code.setPadding(pad, 0, pad, pad);
|
||||
int localCode = container.getLocalConfirmationCode();
|
||||
code.setText(String.format("%06d", localCode));
|
||||
addView(code);
|
||||
@@ -54,7 +54,7 @@ class WaitForContactView extends AddContactView {
|
||||
|
||||
ProgressBar progress = new ProgressBar(ctx);
|
||||
progress.setIndeterminate(true);
|
||||
progress.setPadding(10, 10, 10, 10);
|
||||
progress.setPadding(pad, pad, pad, pad);
|
||||
innerLayout.addView(progress);
|
||||
|
||||
TextView connecting = new TextView(ctx);
|
||||
|
||||
@@ -4,7 +4,10 @@ import static android.content.Context.WIFI_SERVICE;
|
||||
import static android.provider.Settings.ACTION_WIFI_SETTINGS;
|
||||
import static android.view.Gravity.CENTER;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.WRAP_WRAP_1;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.wifi.WifiInfo;
|
||||
@@ -18,8 +21,11 @@ import android.widget.TextView;
|
||||
|
||||
class WifiStatusView extends LinearLayout implements OnClickListener {
|
||||
|
||||
private final int pad;
|
||||
|
||||
public WifiStatusView(Context ctx) {
|
||||
super(ctx);
|
||||
pad = LayoutUtils.getPadding(ctx);
|
||||
}
|
||||
|
||||
void init() {
|
||||
@@ -33,12 +39,12 @@ class WifiStatusView extends LinearLayout implements OnClickListener {
|
||||
Context ctx = getContext();
|
||||
TextView status = new TextView(ctx);
|
||||
status.setTextSize(14);
|
||||
status.setPadding(10, 10, 10, 10);
|
||||
status.setPadding(pad, pad, pad, pad);
|
||||
status.setLayoutParams(WRAP_WRAP_1);
|
||||
WifiManager wifi = (WifiManager) ctx.getSystemService(WIFI_SERVICE);
|
||||
if(wifi == null) {
|
||||
ImageView warning = new ImageView(ctx);
|
||||
warning.setPadding(5, 5, 5, 5);
|
||||
warning.setPadding(pad, pad, pad, pad);
|
||||
warning.setImageResource(R.drawable.alerts_and_states_warning);
|
||||
addView(warning);
|
||||
status.setText(R.string.wifi_not_available);
|
||||
@@ -49,7 +55,7 @@ class WifiStatusView extends LinearLayout implements OnClickListener {
|
||||
int networkId = info.getNetworkId();
|
||||
if(networkName == null || networkId == -1) {
|
||||
ImageView warning = new ImageView(ctx);
|
||||
warning.setPadding(5, 5, 5, 5);
|
||||
warning.setPadding(pad, pad, pad, pad);
|
||||
warning.setImageResource(R.drawable.alerts_and_states_warning);
|
||||
addView(warning);
|
||||
status.setText(R.string.wifi_disconnected);
|
||||
@@ -60,7 +66,7 @@ class WifiStatusView extends LinearLayout implements OnClickListener {
|
||||
addView(settings);
|
||||
} else {
|
||||
ImageView ok = new ImageView(ctx);
|
||||
ok.setPadding(5, 5, 5, 5);
|
||||
ok.setPadding(pad, pad, pad, pad);
|
||||
ok.setImageResource(R.drawable.navigation_accept);
|
||||
addView(ok);
|
||||
String format = getResources().getString(
|
||||
@@ -74,7 +80,7 @@ class WifiStatusView extends LinearLayout implements OnClickListener {
|
||||
}
|
||||
} else {
|
||||
ImageView warning = new ImageView(ctx);
|
||||
warning.setPadding(5, 5, 5, 5);
|
||||
warning.setPadding(pad, pad, pad, pad);
|
||||
warning.setImageResource(R.drawable.alerts_and_states_warning);
|
||||
addView(warning);
|
||||
status.setText(R.string.wifi_disabled);
|
||||
|
||||
Reference in New Issue
Block a user