Various layout fixes, moved remaining layout from XML to Java.
BIN
res/drawable-hdpi/action_settings.png
Normal file
|
After Width: | Height: | Size: 1.5 KiB |
BIN
res/drawable-hdpi/alerts_and_states_error.png
Normal file
|
After Width: | Height: | Size: 1.4 KiB |
BIN
res/drawable-hdpi/alerts_and_states_warning.png
Normal file
|
After Width: | Height: | Size: 1.6 KiB |
BIN
res/drawable-hdpi/navigation_accept.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
BIN
res/drawable-hdpi/social_add_person.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 499 B |
|
Before Width: | Height: | Size: 552 B |
@@ -1,5 +0,0 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/add_contact_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" />
|
||||
@@ -1,5 +0,0 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/codes_do_not_match_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" />
|
||||
@@ -1,5 +0,0 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/connection_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" />
|
||||
@@ -1,5 +0,0 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/connection_failed_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" />
|
||||
@@ -1,5 +0,0 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/connection_succeeded_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" />
|
||||
@@ -1,5 +0,0 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/contact_added_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" />
|
||||
@@ -1,5 +0,0 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/invitation_code_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" />
|
||||
@@ -1,5 +0,0 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/network_setup_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" />
|
||||
@@ -1,71 +0,0 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/test_bt_screen_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Testing Bluetooth actions"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Show paired devices info"
|
||||
android:onClick="showBtPairedDevicesButtonClicked" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/test_bt_conn_btn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Connect bluetooh"
|
||||
android:onClick="testBtConnButtonClicked" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/test_bt_sendData_btn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="testBtSendDataButtonClicked"
|
||||
android:text="Send data" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/test_bt_recvData_btn"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:onClick="testBtReceiveDataButtonClicked"
|
||||
android:text="Recive data" />
|
||||
</LinearLayout>
|
||||
|
||||
<ScrollView
|
||||
android:id="@+id/test_bt_log_view"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/test_bt_log_console_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Bluetooth actions log" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/test_bt_log_console_msgs"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="actions log..." />
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -1,5 +0,0 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/wait_for_contact_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" />
|
||||
@@ -1,39 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">Briar</string>
|
||||
<string name="menu_settings">Settings</string>
|
||||
<string name="title">Add a Contact</string>
|
||||
<string name="welcome">Welcome to Briar! Add a contact to get started.</string>
|
||||
<string name="add_contact_button">Add a contact</string>
|
||||
<string name="face_to_face">For security reasons you must be face to face with someone to add them as a contact.</string>
|
||||
<string name="same_network">Briar can add contacts via Wi-Fi or Bluetooth. To use Wi-Fi you must both be connected to the same network.</string>
|
||||
<string name="wifi_not_available">Wi-Fi is not available on this device.</string>
|
||||
<string name="wifi_disabled">Wi-Fi is OFF.</string>
|
||||
<string name="turn_on_wifi_button">Turn on Wi-Fi</string>
|
||||
<string name="wifi_disconnected">Wi-Fi is DISCONNECTED.</string>
|
||||
<string name="connect_to_wifi_button">Connect to Wi-Fi</string>
|
||||
<string name="wifi_connected">Wi-Fi is CONNECTED to %1$s.</string>
|
||||
<string name="bluetooth_not_available">Bluetooth is not available on this device.</string>
|
||||
<string name="bluetooth_disabled">Bluetooth is OFF.</string>
|
||||
<string name="turn_on_bluetooth_button">Turn on Bluetooth</string>
|
||||
<string name="bluetooth_not_discoverable">Bluetooth is NOT DISCOVERABLE.</string>
|
||||
<string name="make_bluetooth_discoverable_button">Make Bluetooth discoverable</string>
|
||||
<string name="bluetooth_enabled">Bluetooth is ON.</string>
|
||||
<string name="wifi_not_available">Wi-Fi is not available on this device</string>
|
||||
<string name="wifi_disabled">Wi-Fi is OFF</string>
|
||||
<string name="wifi_disconnected">Wi-Fi is DISCONNECTED</string>
|
||||
<string name="wifi_connected">Wi-Fi is CONNECTED to %1$s</string>
|
||||
<string name="bluetooth_not_available">Bluetooth is not available on this device</string>
|
||||
<string name="bluetooth_disabled">Bluetooth is OFF</string>
|
||||
<string name="bluetooth_not_discoverable">Bluetooth is NOT DISCOVERABLE</string>
|
||||
<string name="bluetooth_enabled">Bluetooth is ON</string>
|
||||
<string name="continue_button">Continue</string>
|
||||
<string name="your_invitation_code">Your invitation code is</string>
|
||||
<string name="enter_invitation_code">Please enter your contact\'s invitation code:</string>
|
||||
<string name="connecting_wifi">Connecting via %1$s\u2026</string>
|
||||
<string name="connecting_bluetooth">Connecting via Bluetooth\u2026</string>
|
||||
<string name="connection_failed">Connection failed.</string>
|
||||
<string name="connection_failed">Connection failed</string>
|
||||
<string name="check_same_network">Please check that you are both using the same network.</string>
|
||||
<string name="try_again_button">Try again</string>
|
||||
<string name="connected_to_contact">Connected to contact.</string>
|
||||
<string name="connected_to_contact">Connected to contact</string>
|
||||
<string name="your_confirmation_code">Your confirmation code is</string>
|
||||
<string name="enter_confirmation_code">Please enter your contact\'s confirmation code:</string>
|
||||
<string name="waiting_for_contact">Waiting for contact\u2026</string>
|
||||
<string name="codes_do_not_match">Codes do not match!</string>
|
||||
<string name="codes_do_not_match">Codes do not match</string>
|
||||
<string name="interfering">This could mean that someone is trying to interfere with your connection.</string>
|
||||
<string name="contact_added">Contact added.</string>
|
||||
<string name="contact_added">Contact added</string>
|
||||
<string name="enter_nickname">Please enter a nickname for this contact:</string>
|
||||
<string name="add_another_contact_button">Add another contact</string>
|
||||
<string name="done_button">Done</string>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||