diff --git a/res/drawable-hdpi/action_settings.png b/res/drawable-hdpi/action_settings.png new file mode 100644 index 0000000000000000000000000000000000000000..3e4580e0534c913abc5560067866b162e2972945 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 0000000000000000000000000000000000000000..8ed186b47d63710898f2149cc6dca17d515d357e 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 0000000000000000000000000000000000000000..1fefdd8bd8a8c674bd81ffb2bca82ae9acb6673b 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 0000000000000000000000000000000000000000..53cf6877eb72ad70368fd9e61fb780d42633a407 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 0000000000000000000000000000000000000000..d22a3ea949a96325a65857c4fa7eddb626a7494f 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 0751e8d49172a3b2746ac1d442383d838586075f..0000000000000000000000000000000000000000 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 d560b26460ba89d7cb1cb8465841b7f8d7dd639c..0000000000000000000000000000000000000000 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 c37b80fec002560fe9afdadabb4851b2f32d89d1..0000000000000000000000000000000000000000 --- a/res/layout/activity_add_contact.xml +++ /dev/null @@ -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" /> 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 4bd1965bc9ce73dd643c1c0d4a27ca789b591530..0000000000000000000000000000000000000000 --- a/res/layout/activity_codes_do_not_match.xml +++ /dev/null @@ -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" /> diff --git a/res/layout/activity_connection.xml b/res/layout/activity_connection.xml deleted file mode 100644 index 367b75fc552e993b3e7876fadbef2b845b0fd74f..0000000000000000000000000000000000000000 --- a/res/layout/activity_connection.xml +++ /dev/null @@ -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" /> \ 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 9672914f4ca5721234515e26b994ed1455d249a3..0000000000000000000000000000000000000000 --- a/res/layout/activity_connection_failed.xml +++ /dev/null @@ -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" /> diff --git a/res/layout/activity_connection_succeeded.xml b/res/layout/activity_connection_succeeded.xml deleted file mode 100644 index 0b6962125d6d24eed4d9440a18c9fa0374106649..0000000000000000000000000000000000000000 --- a/res/layout/activity_connection_succeeded.xml +++ /dev/null @@ -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" /> \ 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 05a3c684f1d1adfc729a5013e6dfe58195586838..0000000000000000000000000000000000000000 --- a/res/layout/activity_contact_added.xml +++ /dev/null @@ -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" /> diff --git a/res/layout/activity_invitation_code.xml b/res/layout/activity_invitation_code.xml deleted file mode 100644 index 193e86aaf5497c14f487d6b76b601d502a40f3a5..0000000000000000000000000000000000000000 --- a/res/layout/activity_invitation_code.xml +++ /dev/null @@ -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" /> diff --git a/res/layout/activity_network_setup.xml b/res/layout/activity_network_setup.xml deleted file mode 100644 index 48d2de513f0178f509f0b2a2f47bf63675cd55fa..0000000000000000000000000000000000000000 --- a/res/layout/activity_network_setup.xml +++ /dev/null @@ -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" /> \ 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 eaf4032a4c172d97ced3df021eaed863ae993ee2..0000000000000000000000000000000000000000 --- a/res/layout/activity_test_bluetooth.xml +++ /dev/null @@ -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> diff --git a/res/layout/activity_wait_for_contact.xml b/res/layout/activity_wait_for_contact.xml deleted file mode 100644 index cd96d411b253935b9d8819f08a72ea6ff0e39401..0000000000000000000000000000000000000000 --- a/res/layout/activity_wait_for_contact.xml +++ /dev/null @@ -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" /> \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 0a2f6313dfc5356be2094f881d70130fd15abed8..58c646fb87d2fa15e44df5b3b917bf0924005fa2 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -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> diff --git a/src/net/sf/briar/HelloWorldActivity.java b/src/net/sf/briar/HelloWorldActivity.java index 76868cb80646b61a2855cb60ceb95dd25834b655..3b0355a311830d90b9e3bc7df7f226abe2901cdb 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); + + TextView faceToFace = new TextView(this); + faceToFace.setPadding(0, 0, 0, 10); + faceToFace.setText(R.string.face_to_face); + layout.addView(faceToFace); + 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); - TextView faceToFace = new TextView(this); - faceToFace.setText(R.string.face_to_face); - layout.addView(faceToFace); - Intent intent = new Intent("net.sf.briar.HelloWorldService"); - startService(intent); + 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 e97d7d86e91f6a8f4b6cd2bb4beaf5775865096a..03b9e76f118c4aa8a72f200392187807149eb80b 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 5565782753448cb19fad83b62ec4872d9f9344a3..788e23b85a16b0ca594ff969217347d2fb504acc 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 c981bc067092c6acbae39b7063e8fabad76352b3..6af1ad41a2c47cf4d0aa4f1699463e1fcdfa4cdf 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 e4bb901df00ad5b414edca1fba0510365a485ed5..9b696762ab07089abb01f28594dc6a0881e385d8 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); + 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); - TextView checkNetwork = new TextView(this); - checkNetwork.setGravity(CENTER_HORIZONTAL); - checkNetwork.setText(R.string.your_confirmation_code); - outerLayout.addView(checkNetwork); + 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 2564adf002c7077c750bc77013fa1cda8cff634b..7049f856cbd6453976893ab454d9749e478a9802 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 0b868a1740276af0387873cac79e8e02bd7e1ffe..433d75d40223d046ed415e5ab87aea5bd9b3d867 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 846c25bf1ae9932d1a1dd83322b5b305eb77bb46..fb22cec8c03aa3b2ac057f5d6289a55c934a914d 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 79e7a22cd97bd0351696b74406b9d88b45def5ea..230771a163f55f60fa5c5d847b933b87c4c1a3fe 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 2488e4d12525968f971b73d8aed3a0ad92c1999b..935145ea90d15a4217e768338b9bdb5d8aac9fdb 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 ed778ff23ffc1db084b4625db0139f42ef8ab88f..d5f57ab2b909f8879dd3094ff8e208be3b7a291d 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 d27d6e8b3a871c98479e456aacb883e5429f3f0f..e3c5c2ac0d7d861466cfcb412306c240fa38b303 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); } }