Skip to content
Permalink
Browse files

Fix and prettify reconnect button

Reconnect button is now an ImageButton, and displays a toast if not connected to any machine. (Previous button raised a runtime exception). Drawables downloaded from https://material.io/resources/icons/ licensed by Google under the Apache Licence.
  • Loading branch information
medape committed Aug 30, 2019
1 parent 2949433 commit 56f2222142dbd607408f94cb72bf34ae1d78a52b
Showing with 29 additions and 12 deletions.
  1. +9 −5 app/src/main/java/com/simonramstedt/yoke/YokeActivity.java
  2. BIN app/src/main/res/drawable-hdpi/baseline_refresh_white_18.png
  3. BIN app/src/main/res/drawable-hdpi/baseline_refresh_white_24.png
  4. BIN app/src/main/res/drawable-hdpi/baseline_refresh_white_36.png
  5. BIN app/src/main/res/drawable-hdpi/baseline_refresh_white_48.png
  6. BIN app/src/main/res/drawable-mdpi/baseline_refresh_white_18.png
  7. BIN app/src/main/res/drawable-mdpi/baseline_refresh_white_24.png
  8. BIN app/src/main/res/drawable-mdpi/baseline_refresh_white_36.png
  9. BIN app/src/main/res/drawable-mdpi/baseline_refresh_white_48.png
  10. BIN app/src/main/res/drawable-xhdpi/baseline_refresh_white_18.png
  11. BIN app/src/main/res/drawable-xhdpi/baseline_refresh_white_24.png
  12. BIN app/src/main/res/drawable-xhdpi/baseline_refresh_white_36.png
  13. BIN app/src/main/res/drawable-xhdpi/baseline_refresh_white_48.png
  14. BIN app/src/main/res/drawable-xxhdpi/baseline_refresh_white_18.png
  15. BIN app/src/main/res/drawable-xxhdpi/baseline_refresh_white_24.png
  16. BIN app/src/main/res/drawable-xxhdpi/baseline_refresh_white_36.png
  17. BIN app/src/main/res/drawable-xxhdpi/baseline_refresh_white_48.png
  18. BIN app/src/main/res/drawable-xxxhdpi/baseline_refresh_white_18.png
  19. BIN app/src/main/res/drawable-xxxhdpi/baseline_refresh_white_24.png
  20. BIN app/src/main/res/drawable-xxxhdpi/baseline_refresh_white_36.png
  21. BIN app/src/main/res/drawable-xxxhdpi/baseline_refresh_white_48.png
  22. +10 −0 app/src/main/res/drawable/baseline_refresh_24.xml
  23. +4 −2 app/src/main/res/layout/main_wv.xml
  24. +6 −5 app/src/main/res/values/strings.xml
@@ -6,6 +6,7 @@
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.net.nsd.NsdManager;
import android.net.nsd.NsdServiceInfo;
import android.os.Bundle;
import android.os.Handler;
import android.text.InputType;
@@ -17,7 +18,6 @@
import android.webkit.WebView;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.net.nsd.NsdServiceInfo;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
@@ -299,11 +299,15 @@ public void connectToAddress(String tgt) {

public void reconnect(View view) {
String tgt = mSpinner.getSelectedItem().toString();
closeConnection();
if (mServiceMap.containsKey(tgt)) {
connectToService(tgt);
if (tgt.equals(NOTHING)) {
Toast.makeText(YokeActivity.this, res.getString(R.string.toast_cant_reconnect_if_not_connected), Toast.LENGTH_SHORT).show();
} else {
connectToAddress(tgt);
closeConnection();
if (mServiceMap.containsKey(tgt)) {
connectToService(tgt);
} else {
connectToAddress(tgt);
}
}
}

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="@android:color/white">
<path
android:fillColor="@android:color/white"
android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4l-2.35,2.35z"/>
</vector>
@@ -20,11 +20,13 @@
android:layout_height="match_parent"
android:src="@mipmap/yoke" />

<Button xmlns:android="http://schemas.android.com/apk/res/android"
<ImageButton
android:id="@+id/reconnectButton"
android:src="@drawable/baseline_refresh_24"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/toolbar_reconnect"
android:contentDescription="@string/toolbar_reconnect"
android:tooltipText="@string/toolbar_reconnect"
android:onClick="reconnect" />

<TextView
@@ -1,5 +1,5 @@
<resources>
<!-- Name for the app (maybe we'll want to translate it to other languages, or transcript the pronunciation. -->
<!-- Name for the app (even if it's never translated or clarified, non-latin-alphaber languages might use a phonetic transcription). -->
<string name="app_name">Yoke</string>

<!-- Strings for the toolbar, displayed as soon as the app is opened -->
@@ -9,8 +9,9 @@
<string name="toolbar_reconnect">Reconnect</string>

<!-- Toasts shown on error -->
<string name="toast_could_not_connect">Failed to connect to %1$s:%2$d</string>
<string name="toast_could_not_connect">Failed to connect to %1$s:%2$d.</string>
<string name="toast_invalid_address">Invalid address</string>
<string name="toast_cant_reconnect_if_not_connected">Please use the dropdown menu to connect to a machine.</string>

<!-- These strings are displayed when the user opens the spinner to select a machine to connect to -->
<string name="dropdown_connect_to">Connect to…</string>
@@ -28,7 +29,7 @@
<string name="log_directly_connecting">Connecting directly to IP address %1$s…</string>
<string name="log_discovery_error">Service discovery failed with error code %1$d.</string>
<string name="log_discovery_started">Service discovery started.</string>
<string name="log_discovery_stopped">Service discovery stopped: %1$s.</string>
<string name="log_discovery_stopped">Service discovery stopped: "%1$s".</string>
<string name="log_loading_url">Loading from %1$s</string>
<string name="log_nothing_selected">Nothing selected.</string>
<string name="log_open_udp_error">Failed to open UDP socket. Error message following:</string>
@@ -40,8 +41,8 @@
<string name="log_service_not_null">SERVICE NOT NULL!!!</string>
<string name="log_service_resolve_error">Resolve failed with error code %1$d.</string>
<string name="log_service_resolve_success">Resolve succeeded. </string>
<string name="log_service_resolving">Resolving service: %1$s…</string>
<string name="log_service_targeting">New service target: %1$s</string>
<string name="log_service_resolving">Resolving service "%1$s"…</string>
<string name="log_service_targeting">New service target: "%1$s".</string>
<string name="log_udp_closed">Connection closed.</string>
</resources>

0 comments on commit 56f2222

Please sign in to comment.
You can’t perform that action at this time.