diff --git a/res/drawable-hdpi/action_settings.png b/res/drawable-hdpi/action_settings.png
new file mode 100644
index 000000000..3e4580e05
Binary files /dev/null and b/res/drawable-hdpi/action_settings.png differ
diff --git a/res/drawable-hdpi/alerts_and_states_error.png b/res/drawable-hdpi/alerts_and_states_error.png
new file mode 100644
index 000000000..8ed186b47
Binary files /dev/null and b/res/drawable-hdpi/alerts_and_states_error.png differ
diff --git a/res/drawable-hdpi/alerts_and_states_warning.png b/res/drawable-hdpi/alerts_and_states_warning.png
new file mode 100644
index 000000000..1fefdd8bd
Binary files /dev/null and b/res/drawable-hdpi/alerts_and_states_warning.png differ
diff --git a/res/drawable-hdpi/navigation_accept.png b/res/drawable-hdpi/navigation_accept.png
new file mode 100644
index 000000000..53cf6877e
Binary files /dev/null and b/res/drawable-hdpi/navigation_accept.png differ
diff --git a/res/drawable-hdpi/social_add_person.png b/res/drawable-hdpi/social_add_person.png
new file mode 100644
index 000000000..d22a3ea94
Binary files /dev/null and b/res/drawable-hdpi/social_add_person.png differ
diff --git a/res/drawable-ldpi/iconic_check_alt_green.png b/res/drawable-ldpi/iconic_check_alt_green.png
deleted file mode 100644
index 0751e8d49..000000000
Binary files a/res/drawable-ldpi/iconic_check_alt_green.png and /dev/null differ
diff --git a/res/drawable-ldpi/iconic_x_alt_red.png b/res/drawable-ldpi/iconic_x_alt_red.png
deleted file mode 100644
index d560b2646..000000000
Binary files a/res/drawable-ldpi/iconic_x_alt_red.png and /dev/null differ
diff --git a/res/layout/activity_add_contact.xml b/res/layout/activity_add_contact.xml
deleted file mode 100644
index c37b80fec..000000000
--- a/res/layout/activity_add_contact.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
diff --git a/res/layout/activity_codes_do_not_match.xml b/res/layout/activity_codes_do_not_match.xml
deleted file mode 100644
index 4bd1965bc..000000000
--- a/res/layout/activity_codes_do_not_match.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
diff --git a/res/layout/activity_connection.xml b/res/layout/activity_connection.xml
deleted file mode 100644
index 367b75fc5..000000000
--- a/res/layout/activity_connection.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
\ No newline at end of file
diff --git a/res/layout/activity_connection_failed.xml b/res/layout/activity_connection_failed.xml
deleted file mode 100644
index 9672914f4..000000000
--- a/res/layout/activity_connection_failed.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
diff --git a/res/layout/activity_connection_succeeded.xml b/res/layout/activity_connection_succeeded.xml
deleted file mode 100644
index 0b6962125..000000000
--- a/res/layout/activity_connection_succeeded.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
\ No newline at end of file
diff --git a/res/layout/activity_contact_added.xml b/res/layout/activity_contact_added.xml
deleted file mode 100644
index 05a3c684f..000000000
--- a/res/layout/activity_contact_added.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
diff --git a/res/layout/activity_invitation_code.xml b/res/layout/activity_invitation_code.xml
deleted file mode 100644
index 193e86aaf..000000000
--- a/res/layout/activity_invitation_code.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
diff --git a/res/layout/activity_network_setup.xml b/res/layout/activity_network_setup.xml
deleted file mode 100644
index 48d2de513..000000000
--- a/res/layout/activity_network_setup.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
\ No newline at end of file
diff --git a/res/layout/activity_test_bluetooth.xml b/res/layout/activity_test_bluetooth.xml
deleted file mode 100644
index eaf4032a4..000000000
--- a/res/layout/activity_test_bluetooth.xml
+++ /dev/null
@@ -1,71 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/res/layout/activity_wait_for_contact.xml b/res/layout/activity_wait_for_contact.xml
deleted file mode 100644
index cd96d411b..000000000
--- a/res/layout/activity_wait_for_contact.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 0a2f6313d..58c646fb8 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1,39 +1,34 @@
Briar
- Settings
Add a Contact
Welcome to Briar! Add a contact to get started.
Add a contact
For security reasons you must be face to face with someone to add them as a contact.
Briar can add contacts via Wi-Fi or Bluetooth. To use Wi-Fi you must both be connected to the same network.
- Wi-Fi is not available on this device.
- Wi-Fi is OFF.
- Turn on Wi-Fi
- Wi-Fi is DISCONNECTED.
- Connect to Wi-Fi
- Wi-Fi is CONNECTED to %1$s.
- Bluetooth is not available on this device.
- Bluetooth is OFF.
- Turn on Bluetooth
- Bluetooth is NOT DISCOVERABLE.
- Make Bluetooth discoverable
- Bluetooth is ON.
+ Wi-Fi is not available on this device
+ Wi-Fi is OFF
+ Wi-Fi is DISCONNECTED
+ Wi-Fi is CONNECTED to %1$s
+ Bluetooth is not available on this device
+ Bluetooth is OFF
+ Bluetooth is NOT DISCOVERABLE
+ Bluetooth is ON
Continue
Your invitation code is
Please enter your contact\'s invitation code:
Connecting via %1$s\u2026
Connecting via Bluetooth\u2026
- Connection failed.
+ Connection failed
Please check that you are both using the same network.
Try again
- Connected to contact.
+ Connected to contact
Your confirmation code is
Please enter your contact\'s confirmation code:
Waiting for contact\u2026
- Codes do not match!
+ Codes do not match
This could mean that someone is trying to interfere with your connection.
- Contact added.
+ Contact added
Please enter a nickname for this contact:
Add another contact
Done
diff --git a/src/net/sf/briar/HelloWorldActivity.java b/src/net/sf/briar/HelloWorldActivity.java
index 76868cb80..3b0355a31 100644
--- a/src/net/sf/briar/HelloWorldActivity.java
+++ b/src/net/sf/briar/HelloWorldActivity.java
@@ -1,5 +1,9 @@
package net.sf.briar;
+import static android.view.Gravity.CENTER_HORIZONTAL;
+import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
+import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
+import static android.widget.LinearLayout.VERTICAL;
import net.sf.briar.android.invitation.NetworkSetupActivity;
import android.app.Activity;
import android.content.Intent;
@@ -8,6 +12,7 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
+import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;
public class HelloWorldActivity extends Activity implements OnClickListener {
@@ -15,27 +20,36 @@ public class HelloWorldActivity extends Activity implements OnClickListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_add_contact);
- LinearLayout layout = (LinearLayout) findViewById(
- R.id.add_contact_container);
+ LinearLayout layout = new LinearLayout(this);
+ layout.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));
+ layout.setOrientation(VERTICAL);
+ layout.setGravity(CENTER_HORIZONTAL);
TextView welcome = new TextView(this);
+ welcome.setPadding(0, 0, 0, 10);
welcome.setText(R.string.welcome);
layout.addView(welcome);
- Button addContact = new Button(this);
- addContact.setText(R.string.add_contact_button);
- addContact.setOnClickListener(this);
- layout.addView(addContact);
+
TextView faceToFace = new TextView(this);
+ faceToFace.setPadding(0, 0, 0, 10);
faceToFace.setText(R.string.face_to_face);
layout.addView(faceToFace);
- Intent intent = new Intent("net.sf.briar.HelloWorldService");
- startService(intent);
+ Button addContact = new Button(this);
+ LayoutParams lp = new LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
+ addContact.setLayoutParams(lp);
+ addContact.setText(R.string.add_contact_button);
+ addContact.setCompoundDrawablesWithIntrinsicBounds(
+ R.drawable.social_add_person, 0, 0, 0);
+ addContact.setOnClickListener(this);
+ layout.addView(addContact);
+
+ setContentView(layout);
+
+ startService(new Intent("net.sf.briar.HelloWorldService"));
}
public void onClick(View view) {
startActivity(new Intent(this, NetworkSetupActivity.class));
- finish();
}
}
diff --git a/src/net/sf/briar/android/invitation/BluetoothWidget.java b/src/net/sf/briar/android/invitation/BluetoothWidget.java
index e97d7d86e..03b9e76f1 100644
--- a/src/net/sf/briar/android/invitation/BluetoothWidget.java
+++ b/src/net/sf/briar/android/invitation/BluetoothWidget.java
@@ -2,14 +2,16 @@ package net.sf.briar.android.invitation;
import static android.bluetooth.BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE;
import static android.provider.Settings.ACTION_BLUETOOTH_SETTINGS;
-import static android.view.Gravity.CENTER_HORIZONTAL;
+import static android.view.Gravity.CENTER;
+import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import net.sf.briar.R;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
-import android.widget.Button;
+import android.widget.ImageButton;
+import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -23,8 +25,8 @@ public class BluetoothWidget extends LinearLayout implements OnClickListener {
void init(BluetoothStateListener listener) {
this.listener = listener;
- setOrientation(VERTICAL);
- setPadding(0, 10, 0, 10);
+ setOrientation(HORIZONTAL);
+ setGravity(CENTER);
populate();
}
@@ -32,32 +34,52 @@ public class BluetoothWidget extends LinearLayout implements OnClickListener {
removeAllViews();
Context ctx = getContext();
TextView status = new TextView(ctx);
- status.setGravity(CENTER_HORIZONTAL);
+ status.setLayoutParams(new LayoutParams(WRAP_CONTENT, WRAP_CONTENT, 1));
BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
if(adapter == null) {
bluetoothStateChanged(false);
+ ImageView warning = new ImageView(ctx);
+ warning.setImageResource(R.drawable.alerts_and_states_warning);
+ warning.setPadding(10, 10, 10, 10);
+ addView(warning);
status.setText(R.string.bluetooth_not_available);
addView(status);
} else if(adapter.getScanMode() == SCAN_MODE_CONNECTABLE_DISCOVERABLE) {
bluetoothStateChanged(true);
+ ImageView ok = new ImageView(ctx);
+ ok.setImageResource(R.drawable.navigation_accept);
+ ok.setPadding(10, 10, 10, 10);
+ addView(ok);
status.setText(R.string.bluetooth_enabled);
addView(status);
+ ImageButton settings = new ImageButton(ctx);
+ settings.setImageResource(R.drawable.action_settings);
+ settings.setOnClickListener(this);
+ addView(settings);
} else if(adapter.isEnabled()) {
bluetoothStateChanged(false);
+ ImageView warning = new ImageView(ctx);
+ warning.setImageResource(R.drawable.alerts_and_states_warning);
+ warning.setPadding(10, 10, 10, 10);
+ addView(warning);
status.setText(R.string.bluetooth_not_discoverable);
addView(status);
- Button turnOn = new Button(ctx);
- turnOn.setText(R.string.make_bluetooth_discoverable_button);
- turnOn.setOnClickListener(this);
- addView(turnOn);
+ ImageButton settings = new ImageButton(ctx);
+ settings.setImageResource(R.drawable.action_settings);
+ settings.setOnClickListener(this);
+ addView(settings);
} else {
bluetoothStateChanged(false);
+ ImageView warning = new ImageView(ctx);
+ warning.setImageResource(R.drawable.alerts_and_states_warning);
+ warning.setPadding(10, 10, 10, 10);
+ addView(warning);
status.setText(R.string.bluetooth_disabled);
addView(status);
- Button turnOn = new Button(ctx);
- turnOn.setText(R.string.turn_on_bluetooth_button);
- turnOn.setOnClickListener(this);
- addView(turnOn);
+ ImageButton settings = new ImageButton(ctx);
+ settings.setImageResource(R.drawable.action_settings);
+ settings.setOnClickListener(this);
+ addView(settings);
}
}
diff --git a/src/net/sf/briar/android/invitation/CodeEntryWidget.java b/src/net/sf/briar/android/invitation/CodeEntryWidget.java
index 556578275..788e23b85 100644
--- a/src/net/sf/briar/android/invitation/CodeEntryWidget.java
+++ b/src/net/sf/briar/android/invitation/CodeEntryWidget.java
@@ -27,10 +27,12 @@ OnEditorActionListener, OnClickListener {
void init(CodeEntryListener listener, String prompt) {
this.listener = listener;
setOrientation(VERTICAL);
+ setGravity(CENTER_HORIZONTAL);
Context ctx = getContext();
TextView enterCode = new TextView(ctx);
enterCode.setGravity(CENTER_HORIZONTAL);
+ enterCode.setPadding(0, 0, 0, 10);
enterCode.setText(prompt);
addView(enterCode);
diff --git a/src/net/sf/briar/android/invitation/CodesDoNotMatchActivity.java b/src/net/sf/briar/android/invitation/CodesDoNotMatchActivity.java
index c981bc067..6af1ad41a 100644
--- a/src/net/sf/briar/android/invitation/CodesDoNotMatchActivity.java
+++ b/src/net/sf/briar/android/invitation/CodesDoNotMatchActivity.java
@@ -1,13 +1,18 @@
package net.sf.briar.android.invitation;
import static android.view.Gravity.CENTER;
+import static android.view.Gravity.CENTER_HORIZONTAL;
+import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
+import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static android.widget.LinearLayout.HORIZONTAL;
+import static android.widget.LinearLayout.VERTICAL;
import net.sf.briar.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
+import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -19,30 +24,38 @@ implements OnClickListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_codes_do_not_match);
- LinearLayout outerLayout = (LinearLayout) findViewById(
- R.id.codes_do_not_match_container);
+ LinearLayout layout = new LinearLayout(this);
+ layout.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));
+ layout.setOrientation(VERTICAL);
+ layout.setGravity(CENTER_HORIZONTAL);
LinearLayout innerLayout = new LinearLayout(this);
innerLayout.setOrientation(HORIZONTAL);
innerLayout.setGravity(CENTER);
+
ImageView icon = new ImageView(this);
- icon.setImageResource(R.drawable.iconic_x_alt_red);
icon.setPadding(10, 10, 10, 10);
+ icon.setImageResource(R.drawable.alerts_and_states_error);
innerLayout.addView(icon);
+
TextView failed = new TextView(this);
failed.setTextSize(20);
failed.setText(R.string.codes_do_not_match);
innerLayout.addView(failed);
- outerLayout.addView(innerLayout);
+ layout.addView(innerLayout);
TextView interfering = new TextView(this);
interfering.setText(R.string.interfering);
- outerLayout.addView(interfering);
+ layout.addView(interfering);
+
Button tryAgain = new Button(this);
+ LayoutParams lp = new LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
+ tryAgain.setLayoutParams(lp);
tryAgain.setText(R.string.try_again_button);
tryAgain.setOnClickListener(this);
- outerLayout.addView(tryAgain);
+ layout.addView(tryAgain);
+
+ setContentView(layout);
}
public void onClick(View view) {
diff --git a/src/net/sf/briar/android/invitation/ConfirmationCodeActivity.java b/src/net/sf/briar/android/invitation/ConfirmationCodeActivity.java
index e4bb901df..9b696762a 100644
--- a/src/net/sf/briar/android/invitation/ConfirmationCodeActivity.java
+++ b/src/net/sf/briar/android/invitation/ConfirmationCodeActivity.java
@@ -2,12 +2,15 @@ package net.sf.briar.android.invitation;
import static android.view.Gravity.CENTER;
import static android.view.Gravity.CENTER_HORIZONTAL;
+import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.widget.LinearLayout.HORIZONTAL;
+import static android.widget.LinearLayout.VERTICAL;
import net.sf.briar.R;
import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
+import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -18,38 +21,44 @@ implements CodeEntryListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_connection_succeeded);
- LinearLayout outerLayout = (LinearLayout) findViewById(
- R.id.connection_succeeded_container);
+ LinearLayout layout = new LinearLayout(this);
+ layout.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));
+ layout.setOrientation(VERTICAL);
+ layout.setGravity(CENTER_HORIZONTAL);
LinearLayout innerLayout = new LinearLayout(this);
innerLayout.setOrientation(HORIZONTAL);
innerLayout.setGravity(CENTER);
- ImageView icon = new ImageView(this);
- icon.setImageResource(R.drawable.iconic_check_alt_green);
- icon.setPadding(10, 10, 10, 10);
- innerLayout.addView(icon);
- TextView failed = new TextView(this);
- failed.setTextSize(20);
- failed.setText(R.string.connected_to_contact);
- innerLayout.addView(failed);
- outerLayout.addView(innerLayout);
- TextView checkNetwork = new TextView(this);
- checkNetwork.setGravity(CENTER_HORIZONTAL);
- checkNetwork.setText(R.string.your_confirmation_code);
- outerLayout.addView(checkNetwork);
+ ImageView icon = new ImageView(this);
+ icon.setPadding(10, 10, 10, 10);
+ icon.setImageResource(R.drawable.navigation_accept);
+ innerLayout.addView(icon);
+
+ TextView connected = new TextView(this);
+ connected.setTextSize(20);
+ connected.setText(R.string.connected_to_contact);
+ innerLayout.addView(connected);
+ layout.addView(innerLayout);
+
+ TextView yourCode = new TextView(this);
+ yourCode.setGravity(CENTER_HORIZONTAL);
+ yourCode.setText(R.string.your_confirmation_code);
+ layout.addView(yourCode);
+
TextView code = new TextView(this);
code.setGravity(CENTER_HORIZONTAL);
- InvitationManager im = InvitationManagerFactory.getInvitationManager();
- String localConfirmationCode = im.getLocalConfirmationCode();
- code.setText(localConfirmationCode);
code.setTextSize(50);
- outerLayout.addView(code);
+ InvitationManager im = InvitationManagerFactory.getInvitationManager();
+ code.setText(im.getLocalConfirmationCode());
+ layout.addView(code);
+
CodeEntryWidget codeEntry = new CodeEntryWidget(this);
Resources res = getResources();
codeEntry.init(this, res.getString(R.string.enter_confirmation_code));
- outerLayout.addView(codeEntry);
+ layout.addView(codeEntry);
+
+ setContentView(layout);
}
public void codeEntered(String code) {
diff --git a/src/net/sf/briar/android/invitation/ConnectionActivity.java b/src/net/sf/briar/android/invitation/ConnectionActivity.java
index 2564adf00..7049f856c 100644
--- a/src/net/sf/briar/android/invitation/ConnectionActivity.java
+++ b/src/net/sf/briar/android/invitation/ConnectionActivity.java
@@ -2,12 +2,15 @@ package net.sf.briar.android.invitation;
import static android.view.Gravity.CENTER;
import static android.view.Gravity.CENTER_HORIZONTAL;
+import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.widget.LinearLayout.HORIZONTAL;
+import static android.widget.LinearLayout.VERTICAL;
import net.sf.briar.R;
import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
+import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
@@ -20,9 +23,10 @@ public class ConnectionActivity extends Activity implements ConnectionListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_connection);
- LinearLayout outerLayout = (LinearLayout) findViewById(
- R.id.connection_container);
+ LinearLayout layout = new LinearLayout(this);
+ layout.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));
+ layout.setOrientation(VERTICAL);
+ layout.setGravity(CENTER_HORIZONTAL);
Bundle b = getIntent().getExtras();
String networkName = b.getString(
@@ -33,28 +37,31 @@ public class ConnectionActivity extends Activity implements ConnectionListener {
TextView yourCode = new TextView(this);
yourCode.setGravity(CENTER_HORIZONTAL);
yourCode.setText(R.string.your_invitation_code);
- outerLayout.addView(yourCode);
+ layout.addView(yourCode);
+
TextView code = new TextView(this);
code.setGravity(CENTER_HORIZONTAL);
- code.setText(manager.getLocalInvitationCode());
code.setTextSize(50);
- outerLayout.addView(code);
+ code.setText(manager.getLocalInvitationCode());
+ layout.addView(code);
if(networkName != null) {
LinearLayout innerLayout = new LinearLayout(this);
innerLayout.setOrientation(HORIZONTAL);
innerLayout.setGravity(CENTER);
+
ProgressBar progress = new ProgressBar(this);
progress.setIndeterminate(true);
progress.setPadding(0, 10, 10, 0);
innerLayout.addView(progress);
+
TextView connecting = new TextView(this);
Resources res = getResources();
- String text = res.getString(R.string.connecting_wifi);
- text = String.format(text, networkName);
- connecting.setText(text);
+ String connectingVia = res.getString(R.string.connecting_wifi);
+ connecting.setText(String.format(connectingVia, networkName));
innerLayout.addView(connecting);
- outerLayout.addView(innerLayout);
+
+ layout.addView(innerLayout);
manager.startWifiConnectionWorker(this);
}
@@ -62,17 +69,22 @@ public class ConnectionActivity extends Activity implements ConnectionListener {
LinearLayout innerLayout = new LinearLayout(this);
innerLayout.setOrientation(HORIZONTAL);
innerLayout.setGravity(CENTER);
+
ProgressBar progress = new ProgressBar(this);
progress.setPadding(0, 10, 10, 0);
progress.setIndeterminate(true);
innerLayout.addView(progress);
+
TextView connecting = new TextView(this);
connecting.setText(R.string.connecting_bluetooth);
innerLayout.addView(connecting);
- outerLayout.addView(innerLayout);
+
+ layout.addView(innerLayout);
manager.startBluetoothConnectionWorker(this);
}
+ setContentView(layout);
+
manager.tryToConnect(this);
}
diff --git a/src/net/sf/briar/android/invitation/ConnectionFailedActivity.java b/src/net/sf/briar/android/invitation/ConnectionFailedActivity.java
index 0b868a174..433d75d40 100644
--- a/src/net/sf/briar/android/invitation/ConnectionFailedActivity.java
+++ b/src/net/sf/briar/android/invitation/ConnectionFailedActivity.java
@@ -1,15 +1,18 @@
package net.sf.briar.android.invitation;
import static android.view.Gravity.CENTER;
-import static android.view.View.INVISIBLE;
-import static android.view.View.VISIBLE;
+import static android.view.Gravity.CENTER_HORIZONTAL;
+import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
+import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import static android.widget.LinearLayout.HORIZONTAL;
+import static android.widget.LinearLayout.VERTICAL;
import net.sf.briar.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
+import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
@@ -27,37 +30,47 @@ implements WifiStateListener, BluetoothStateListener, OnClickListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_connection_failed);
- LinearLayout outerLayout = (LinearLayout) findViewById(
- R.id.connection_failed_container);
+ LinearLayout layout = new LinearLayout(this);
+ layout.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));
+ layout.setOrientation(VERTICAL);
+ layout.setGravity(CENTER_HORIZONTAL);
LinearLayout innerLayout = new LinearLayout(this);
innerLayout.setOrientation(HORIZONTAL);
innerLayout.setGravity(CENTER);
+
ImageView icon = new ImageView(this);
- icon.setImageResource(R.drawable.iconic_x_alt_red);
icon.setPadding(10, 10, 10, 10);
+ icon.setImageResource(R.drawable.alerts_and_states_error);
innerLayout.addView(icon);
+
TextView failed = new TextView(this);
failed.setTextSize(20);
failed.setText(R.string.connection_failed);
innerLayout.addView(failed);
- outerLayout.addView(innerLayout);
+ layout.addView(innerLayout);
TextView checkNetwork = new TextView(this);
checkNetwork.setText(R.string.check_same_network);
- outerLayout.addView(checkNetwork);
+ layout.addView(checkNetwork);
+
wifi = new WifiWidget(this);
wifi.init(this);
- outerLayout.addView(wifi);
+ layout.addView(wifi);
+
bluetooth = new BluetoothWidget(this);
bluetooth.init(this);
- outerLayout.addView(bluetooth);
+ layout.addView(bluetooth);
+
tryAgainButton = new Button(this);
+ LayoutParams lp = new LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
+ tryAgainButton.setLayoutParams(lp);
tryAgainButton.setText(R.string.try_again_button);
tryAgainButton.setOnClickListener(this);
- setTryAgainButtonVisibility();
- outerLayout.addView(tryAgainButton);
+ enabledOrDisableTryAgainButton();
+ layout.addView(tryAgainButton);
+
+ setContentView(layout);
}
@Override
@@ -69,19 +82,18 @@ implements WifiStateListener, BluetoothStateListener, OnClickListener {
public void wifiStateChanged(String networkName) {
this.networkName = networkName;
- setTryAgainButtonVisibility();
+ enabledOrDisableTryAgainButton();
}
public void bluetoothStateChanged(boolean enabled) {
useBluetooth = enabled;
- setTryAgainButtonVisibility();
+ enabledOrDisableTryAgainButton();
}
- private void setTryAgainButtonVisibility() {
- if(tryAgainButton == null) return;
- if(useBluetooth || networkName != null)
- tryAgainButton.setVisibility(VISIBLE);
- else tryAgainButton.setVisibility(INVISIBLE);
+ private void enabledOrDisableTryAgainButton() {
+ if(tryAgainButton == null) return; // Activity not created yet
+ if(useBluetooth || networkName != null) tryAgainButton.setEnabled(true);
+ else tryAgainButton.setEnabled(false);
}
public void onClick(View view) {
diff --git a/src/net/sf/briar/android/invitation/ContactAddedActivity.java b/src/net/sf/briar/android/invitation/ContactAddedActivity.java
index 846c25bf1..fb22cec8c 100644
--- a/src/net/sf/briar/android/invitation/ContactAddedActivity.java
+++ b/src/net/sf/briar/android/invitation/ContactAddedActivity.java
@@ -2,7 +2,9 @@ package net.sf.briar.android.invitation;
import static android.view.Gravity.CENTER;
import static android.view.Gravity.CENTER_HORIZONTAL;
+import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.widget.LinearLayout.HORIZONTAL;
+import static android.widget.LinearLayout.VERTICAL;
import net.sf.briar.R;
import android.app.Activity;
import android.content.Intent;
@@ -10,6 +12,7 @@ import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
+import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
@@ -25,27 +28,30 @@ OnEditorActionListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_contact_added);
- LinearLayout outerLayout = (LinearLayout) findViewById(
- R.id.contact_added_container);
+ LinearLayout layout = new LinearLayout(this);
+ layout.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));
+ layout.setOrientation(VERTICAL);
+ layout.setGravity(CENTER_HORIZONTAL);
LinearLayout innerLayout = new LinearLayout(this);
innerLayout.setOrientation(HORIZONTAL);
innerLayout.setGravity(CENTER);
+
ImageView icon = new ImageView(this);
- icon.setImageResource(R.drawable.iconic_check_alt_green);
+ icon.setImageResource(R.drawable.navigation_accept);
icon.setPadding(10, 10, 10, 10);
innerLayout.addView(icon);
+
TextView failed = new TextView(this);
- failed.setTextSize(20);
failed.setText(R.string.contact_added);
+ failed.setTextSize(20);
innerLayout.addView(failed);
- outerLayout.addView(innerLayout);
+ layout.addView(innerLayout);
TextView enterNickname = new TextView(this);
- enterNickname.setGravity(CENTER_HORIZONTAL);
enterNickname.setText(R.string.enter_nickname);
- outerLayout.addView(enterNickname);
+ layout.addView(enterNickname);
+
final Button addAnother = new Button(this);
final Button done = new Button(this);
this.done = done;
@@ -61,20 +67,24 @@ OnEditorActionListener {
nicknameEntry.setMaxEms(20);
nicknameEntry.setMaxLines(1);
nicknameEntry.setOnEditorActionListener(this);
- outerLayout.addView(nicknameEntry);
+ layout.addView(nicknameEntry);
innerLayout = new LinearLayout(this);
innerLayout.setOrientation(HORIZONTAL);
innerLayout.setGravity(CENTER);
+
addAnother.setText(R.string.add_another_contact_button);
addAnother.setEnabled(false);
addAnother.setOnClickListener(this);
innerLayout.addView(addAnother);
+
done.setText(R.string.done_button);
done.setEnabled(false);
done.setOnClickListener(this);
innerLayout.addView(done);
- outerLayout.addView(innerLayout);
+ layout.addView(innerLayout);
+
+ setContentView(layout);
}
public boolean onEditorAction(TextView textView, int actionId, KeyEvent e) {
diff --git a/src/net/sf/briar/android/invitation/InvitationCodeActivity.java b/src/net/sf/briar/android/invitation/InvitationCodeActivity.java
index 79e7a22cd..230771a16 100644
--- a/src/net/sf/briar/android/invitation/InvitationCodeActivity.java
+++ b/src/net/sf/briar/android/invitation/InvitationCodeActivity.java
@@ -1,11 +1,14 @@
package net.sf.briar.android.invitation;
import static android.view.Gravity.CENTER_HORIZONTAL;
+import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
+import static android.widget.LinearLayout.VERTICAL;
import net.sf.briar.R;
import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
+import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -18,24 +21,28 @@ implements CodeEntryListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_invitation_code);
- LinearLayout layout = (LinearLayout) findViewById(
- R.id.invitation_code_container);
+ LinearLayout layout = new LinearLayout(this);
+ layout.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));
+ layout.setOrientation(VERTICAL);
+ layout.setGravity(CENTER_HORIZONTAL);
TextView yourCode = new TextView(this);
yourCode.setGravity(CENTER_HORIZONTAL);
yourCode.setText(R.string.your_invitation_code);
layout.addView(yourCode);
+
TextView code = new TextView(this);
code.setGravity(CENTER_HORIZONTAL);
- String localInvitationCode = manager.getLocalInvitationCode();
- code.setText(localInvitationCode);
code.setTextSize(50);
+ code.setText(manager.getLocalInvitationCode());
layout.addView(code);
+
CodeEntryWidget codeEntry = new CodeEntryWidget(this);
Resources res = getResources();
codeEntry.init(this, res.getString(R.string.enter_invitation_code));
layout.addView(codeEntry);
+
+ setContentView(layout);
}
public void codeEntered(String code) {
diff --git a/src/net/sf/briar/android/invitation/NetworkSetupActivity.java b/src/net/sf/briar/android/invitation/NetworkSetupActivity.java
index 2488e4d12..935145ea9 100644
--- a/src/net/sf/briar/android/invitation/NetworkSetupActivity.java
+++ b/src/net/sf/briar/android/invitation/NetworkSetupActivity.java
@@ -1,13 +1,16 @@
package net.sf.briar.android.invitation;
-import static android.view.View.INVISIBLE;
-import static android.view.View.VISIBLE;
+import static android.view.Gravity.CENTER_HORIZONTAL;
+import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
+import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
+import static android.widget.LinearLayout.VERTICAL;
import net.sf.briar.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
+import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -24,24 +27,32 @@ implements WifiStateListener, BluetoothStateListener, OnClickListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_network_setup);
- LinearLayout layout = (LinearLayout) findViewById(
- R.id.network_setup_container);
+ LinearLayout layout = new LinearLayout(this);
+ layout.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));
+ layout.setOrientation(VERTICAL);
+ layout.setGravity(CENTER_HORIZONTAL);
TextView sameNetwork = new TextView(this);
sameNetwork.setText(R.string.same_network);
layout.addView(sameNetwork);
+
wifi = new WifiWidget(this);
wifi.init(this);
layout.addView(wifi);
+
bluetooth = new BluetoothWidget(this);
bluetooth.init(this);
layout.addView(bluetooth);
+
continueButton = new Button(this);
+ LayoutParams lp = new LayoutParams(WRAP_CONTENT, WRAP_CONTENT);
+ continueButton.setLayoutParams(lp);
continueButton.setText(R.string.continue_button);
continueButton.setOnClickListener(this);
- setContinueButtonVisibility();
+ enableOrDisableContinueButton();
layout.addView(continueButton);
+
+ setContentView(layout);
}
@Override
@@ -55,7 +66,7 @@ implements WifiStateListener, BluetoothStateListener, OnClickListener {
runOnUiThread(new Runnable() {
public void run() {
networkName = name;
- setContinueButtonVisibility();
+ enableOrDisableContinueButton();
}
});
}
@@ -64,16 +75,15 @@ implements WifiStateListener, BluetoothStateListener, OnClickListener {
runOnUiThread(new Runnable() {
public void run() {
useBluetooth = enabled;
- setContinueButtonVisibility();
+ enableOrDisableContinueButton();
}
});
}
- private void setContinueButtonVisibility() {
- if(continueButton == null) return;
- if(useBluetooth || networkName != null)
- continueButton.setVisibility(VISIBLE);
- else continueButton.setVisibility(INVISIBLE);
+ private void enableOrDisableContinueButton() {
+ if(continueButton == null) return; // Activity not created yet
+ if(useBluetooth || networkName != null) continueButton.setEnabled(true);
+ else continueButton.setEnabled(false);
}
public void onClick(View view) {
diff --git a/src/net/sf/briar/android/invitation/WaitForContactActivity.java b/src/net/sf/briar/android/invitation/WaitForContactActivity.java
index ed778ff23..d5f57ab2b 100644
--- a/src/net/sf/briar/android/invitation/WaitForContactActivity.java
+++ b/src/net/sf/briar/android/invitation/WaitForContactActivity.java
@@ -2,11 +2,14 @@ package net.sf.briar.android.invitation;
import static android.view.Gravity.CENTER;
import static android.view.Gravity.CENTER_HORIZONTAL;
+import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.widget.LinearLayout.HORIZONTAL;
+import static android.widget.LinearLayout.VERTICAL;
import net.sf.briar.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
+import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
@@ -18,46 +21,51 @@ implements ConfirmationListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_wait_for_contact);
- LinearLayout outerLayout = (LinearLayout) findViewById(
- R.id.wait_for_contact_container);
+ LinearLayout layout = new LinearLayout(this);
+ layout.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));
+ layout.setOrientation(VERTICAL);
+ layout.setGravity(CENTER_HORIZONTAL);
LinearLayout innerLayout = new LinearLayout(this);
innerLayout.setOrientation(HORIZONTAL);
innerLayout.setGravity(CENTER);
+
ImageView icon = new ImageView(this);
- icon.setImageResource(R.drawable.iconic_check_alt_green);
icon.setPadding(10, 10, 10, 10);
+ icon.setImageResource(R.drawable.navigation_accept);
innerLayout.addView(icon);
+
TextView failed = new TextView(this);
failed.setTextSize(20);
failed.setText(R.string.connected_to_contact);
innerLayout.addView(failed);
- outerLayout.addView(innerLayout);
+ layout.addView(innerLayout);
TextView yourCode = new TextView(this);
- yourCode.setGravity(CENTER_HORIZONTAL);
yourCode.setText(R.string.your_confirmation_code);
- outerLayout.addView(yourCode);
+ layout.addView(yourCode);
+
TextView code = new TextView(this);
- code.setGravity(CENTER_HORIZONTAL);
- InvitationManager im = InvitationManagerFactory.getInvitationManager();
- String localConfirmationCode = im.getLocalConfirmationCode();
- code.setText(localConfirmationCode);
code.setTextSize(50);
- outerLayout.addView(code);
+ InvitationManager im = InvitationManagerFactory.getInvitationManager();
+ code.setText(im.getLocalConfirmationCode());
+ layout.addView(code);
innerLayout = new LinearLayout(this);
innerLayout.setOrientation(HORIZONTAL);
innerLayout.setGravity(CENTER);
+
ProgressBar progress = new ProgressBar(this);
progress.setIndeterminate(true);
progress.setPadding(0, 10, 10, 0);
innerLayout.addView(progress);
+
TextView connecting = new TextView(this);
connecting.setText(R.string.waiting_for_contact);
innerLayout.addView(connecting);
- outerLayout.addView(innerLayout);
+ layout.addView(innerLayout);
+
+ setContentView(layout);
im.startConfirmationWorker(this);
}
diff --git a/src/net/sf/briar/android/invitation/WifiWidget.java b/src/net/sf/briar/android/invitation/WifiWidget.java
index d27d6e8b3..e3c5c2ac0 100644
--- a/src/net/sf/briar/android/invitation/WifiWidget.java
+++ b/src/net/sf/briar/android/invitation/WifiWidget.java
@@ -2,15 +2,18 @@ package net.sf.briar.android.invitation;
import static android.content.Context.WIFI_SERVICE;
import static android.provider.Settings.ACTION_WIFI_SETTINGS;
-import static android.view.Gravity.CENTER_HORIZONTAL;
+import static android.view.Gravity.CENTER;
+import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
import net.sf.briar.R;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
+import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.view.View;
import android.view.View.OnClickListener;
-import android.widget.Button;
+import android.widget.ImageButton;
+import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -24,8 +27,8 @@ public class WifiWidget extends LinearLayout implements OnClickListener {
void init(WifiStateListener listener) {
this.listener = listener;
- setOrientation(VERTICAL);
- setPadding(0, 10, 0, 0);
+ setOrientation(HORIZONTAL);
+ setGravity(CENTER);
populate();
}
@@ -33,37 +36,59 @@ public class WifiWidget extends LinearLayout implements OnClickListener {
removeAllViews();
Context ctx = getContext();
TextView status = new TextView(ctx);
- status.setGravity(CENTER_HORIZONTAL);
+ status.setLayoutParams(new LayoutParams(WRAP_CONTENT, WRAP_CONTENT, 1));
WifiManager wifi = (WifiManager) ctx.getSystemService(WIFI_SERVICE);
if(wifi == null) {
wifiStateChanged(null);
+ ImageView warning = new ImageView(ctx);
+ warning.setImageResource(R.drawable.alerts_and_states_warning);
+ warning.setPadding(10, 10, 10, 10);
+ addView(warning);
status.setText(R.string.wifi_not_available);
addView(status);
} else if(wifi.isWifiEnabled()) {
- String networkName = wifi.getConnectionInfo().getSSID();
- if(networkName == null) {
+ WifiInfo info = wifi.getConnectionInfo();
+ String networkName = info.getSSID();
+ int networkId = info.getNetworkId();
+ if(networkName == null || networkId == -1) {
wifiStateChanged(null);
+ ImageView warning = new ImageView(ctx);
+ warning.setImageResource(R.drawable.alerts_and_states_warning);
+ warning.setPadding(10, 10, 10, 10);
+ addView(warning);
status.setText(R.string.wifi_disconnected);
addView(status);
- Button connect = new Button(ctx);
- connect.setText(R.string.connect_to_wifi_button);
- connect.setOnClickListener(this);
- addView(connect);
+ ImageButton settings = new ImageButton(ctx);
+ settings.setImageResource(R.drawable.action_settings);
+ settings.setOnClickListener(this);
+ addView(settings);
} else {
wifiStateChanged(networkName);
+ ImageView ok = new ImageView(ctx);
+ ok.setImageResource(R.drawable.navigation_accept);
+ ok.setPadding(10, 10, 10, 10);
+ addView(ok);
Resources res = getResources();
String connected = res.getString(R.string.wifi_connected);
status.setText(String.format(connected, networkName));
addView(status);
+ ImageButton settings = new ImageButton(ctx);
+ settings.setImageResource(R.drawable.action_settings);
+ settings.setOnClickListener(this);
+ addView(settings);
}
} else {
wifiStateChanged(null);
+ ImageView warning = new ImageView(ctx);
+ warning.setImageResource(R.drawable.alerts_and_states_warning);
+ warning.setPadding(10, 10, 10, 10);
+ addView(warning);
status.setText(R.string.wifi_disabled);
addView(status);
- Button connect = new Button(ctx);
- connect.setText(R.string.connect_to_wifi_button);
- connect.setOnClickListener(this);
- addView(connect);
+ ImageButton settings = new ImageButton(ctx);
+ settings.setImageResource(R.drawable.action_settings);
+ settings.setOnClickListener(this);
+ addView(settings);
}
}