From 7bd253ab0e37ca05af6ee70a8352cc7c5e69b25a Mon Sep 17 00:00:00 2001 From: Catfriend1 Date: Sat, 9 Feb 2019 18:26:54 +0100 Subject: [PATCH] Add device dialog: Implement refresh button and help (fixes #310) (#311) * Add drawable ic_refresh_black_24 * Add device: Add refresh button to dialog * Add device dialog: Implement refresh button (fixes #310) Always show "No devices discovered label" and refresh button if no device ID had been entered yet. * Update model/Options for SyncthingNative 1.0.1 * Add ConfigRouter#getOptions * Add ConfigXml#getOptions * Update README.md * Add string: local_discovery_disabled * Add device dialog: Show notice if local discovery is disabled and explain how to enable it. * Add device dialog: Show helpful text if no devices were discovered locally * Updated de translation --- .../activities/DeviceActivity.java | 38 +++++++++++------- .../res/drawable-hdpi/ic_refresh_black_24.png | Bin 0 -> 362 bytes .../res/drawable-mdpi/ic_refresh_black_24.png | Bin 0 -> 256 bytes .../drawable-xhdpi/ic_refresh_black_24.png | Bin 0 -> 481 bytes .../drawable-xxhdpi/ic_refresh_black_24.png | Bin 0 -> 676 bytes .../drawable-xxxhdpi/ic_refresh_black_24.png | Bin 0 -> 890 bytes app/src/main/res/layout/activity_device.xml | 7 +++- app/src/main/res/values-de/strings.xml | 5 ++- app/src/main/res/values/strings.xml | 10 ++++- 9 files changed, 42 insertions(+), 18 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/ic_refresh_black_24.png create mode 100644 app/src/main/res/drawable-mdpi/ic_refresh_black_24.png create mode 100644 app/src/main/res/drawable-xhdpi/ic_refresh_black_24.png create mode 100644 app/src/main/res/drawable-xxhdpi/ic_refresh_black_24.png create mode 100644 app/src/main/res/drawable-xxxhdpi/ic_refresh_black_24.png diff --git a/app/src/main/java/com/nutomic/syncthingandroid/activities/DeviceActivity.java b/app/src/main/java/com/nutomic/syncthingandroid/activities/DeviceActivity.java index c8542c74..fd1d65db 100644 --- a/app/src/main/java/com/nutomic/syncthingandroid/activities/DeviceActivity.java +++ b/app/src/main/java/com/nutomic/syncthingandroid/activities/DeviceActivity.java @@ -14,7 +14,6 @@ import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; import android.util.Log; -import android.util.TypedValue; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -34,6 +33,7 @@ import com.nutomic.syncthingandroid.R; import com.nutomic.syncthingandroid.model.Connections; import com.nutomic.syncthingandroid.model.Device; import com.nutomic.syncthingandroid.model.DiscoveredDevice; +import com.nutomic.syncthingandroid.model.Options; import com.nutomic.syncthingandroid.service.Constants; import com.nutomic.syncthingandroid.service.RestApi; import com.nutomic.syncthingandroid.service.SyncthingService; @@ -54,7 +54,6 @@ import javax.inject.Inject; import static android.support.v4.view.MarginLayoutParamsCompat.setMarginEnd; import static android.support.v4.view.MarginLayoutParamsCompat.setMarginStart; import static android.text.TextUtils.isEmpty; -import static android.util.TypedValue.COMPLEX_UNIT_DIP; import static android.view.View.VISIBLE; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN; import static android.view.Gravity.CENTER_VERTICAL; @@ -293,6 +292,11 @@ public class DeviceActivity extends SyncthingActivity { if (restApi != null) { restApi.getConnections(this::onReceiveConnections); if (mIsCreateMode) { + mDiscoveredDevicesTitle.setOnClickListener(view -> { + if (restApi != null) { + asyncQueryDiscoveredDevices(restApi); + } + }); asyncQueryDiscoveredDevices(restApi); } } @@ -659,18 +663,30 @@ public class DeviceActivity extends SyncthingActivity { return; } + /** + * If "mEditDeviceId" already contains content, don't show local discovery results. + * This also suppresses the results being shown a second time after the user chose a + * deviceId from the list and rotated the screen. + */ + mDiscoveredDevicesTitle.setVisibility(TextUtils.isEmpty(mEditDeviceId.getText()) ? View.VISIBLE : View.GONE); + mDiscoveredDevicesContainer.setVisibility(TextUtils.isEmpty(mEditDeviceId.getText()) ? View.VISIBLE : View.GONE); + mDiscoveredDevicesContainer.removeAllViews(); if (discoveredDevices.size() == 0) { - // No discovered devices. - int height = (int) TypedValue.applyDimension(COMPLEX_UNIT_DIP, 48, getResources().getDisplayMetrics()); - LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(WRAP_CONTENT, height); + // No discovered devices. Determine if local discovery is enabled. + Options options = mConfig.getOptions(null); + LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT); int dividerInset = getResources().getDimensionPixelOffset(R.dimen.material_divider_inset); int contentInset = getResources().getDimensionPixelOffset(R.dimen.abc_action_bar_content_inset_material); setMarginStart(params, dividerInset); setMarginEnd(params, contentInset); TextView emptyView = new TextView(mDiscoveredDevicesContainer.getContext()); emptyView.setGravity(CENTER_VERTICAL); - emptyView.setText(R.string.discovered_device_list_empty); + if (options.localAnnounceEnabled) { + emptyView.setText(getString(R.string.discovered_device_list_empty, getString(R.string.url_syncthing_homepage))); + } else { + emptyView.setText(R.string.local_discovery_disabled); + } mDiscoveredDevicesContainer.addView(emptyView, params); return; } @@ -682,8 +698,8 @@ public class DeviceActivity extends SyncthingActivity { DiscoveredDevice discoveredDevice = discoveredDevices.get(deviceId); if (discoveredDevice != null && discoveredDevice.addresses != null) { readableAddresses = TextUtils.join(", ", discoveredDevice.addresses); - // Log.v(TAG, "onReceiveDiscoveredDevices: deviceID = '" + deviceId + "' has addresses '" + readableAddresses + "'"); } + // Log.v(TAG, "onReceiveDiscoveredDevices: deviceID = '" + deviceId + "' has addresses '" + readableAddresses + "'"); String caption = deviceId + (TextUtils.isEmpty(readableAddresses) ? "" : " (" + readableAddresses + ")"); LayoutInflater inflater = getLayoutInflater(); inflater.inflate(R.layout.item_discovered_device_form, mDiscoveredDevicesContainer); @@ -694,14 +710,6 @@ public class DeviceActivity extends SyncthingActivity { deviceIdView.setOnClickListener(v -> onDeviceIdViewClick(v)); } } - - /** - * If "mEditDeviceId" already contains content, don't show local discovery results. - * This also suppresses the results being shown a second time after the user chose a - * deviceId from the list and rotated the screen. - */ - mDiscoveredDevicesTitle.setVisibility(TextUtils.isEmpty(mEditDeviceId.getText()) ? View.VISIBLE : View.GONE); - mDiscoveredDevicesContainer.setVisibility(TextUtils.isEmpty(mEditDeviceId.getText()) ? View.VISIBLE : View.GONE); } /** diff --git a/app/src/main/res/drawable-hdpi/ic_refresh_black_24.png b/app/src/main/res/drawable-hdpi/ic_refresh_black_24.png new file mode 100644 index 0000000000000000000000000000000000000000..1d613e5199e556ca17f9a1288490b209355c3fee GIT binary patch literal 362 zcmV-w0hRuVP)*FN3<)JYf58xMX%t7fLN zc}{uat1q57VV;g^+d*1?d;J#m^2;8506T@GseXv;_+e^gF(F}jBdm8< zROY-$7c{Bzqi05{Z-N(Q|1Zbm~2>AIsGZ; zQxy(MEJ$FS5Ps@ZWQ)+&YatxesNR*E_JMBM#keViuX;(C(#SC~$*an@v!q#5=U^MA zlP<1-U{~ z`gr=nsPNfNnc}bu3&Kq&Fe_Ylh;&FNkS{b#=@827^T3*QU+ncm2(Kkn3lm=2>90kh zL((PVJ4WM`b=f_9>++p^!!|JmE!cglNa&h;5=Y-|ki zVkS5ENd|Qk@r8@5VhB!jWIJlYI8P1rom2_u38OU|sYit?Td1PGo2p_9uC2za41)MV zy+M5;2v|$K&Y&Nut%ekHfe8%47e59viHnrAI-1H}>U9R8q#-S&vlKVlG1; zDTlC#(PEIQO1?bl8gKHekSJjxrp!lD8W#*WY5KDhe94xMV;B*E{H}R`6FuR~ZBbVf z2E83P&Rj#ZY|$)Q-;5&DkEe)^4>+SBluV?Rv`#}GrnS)oqogm%ZPu2HOkf~>1TunI zY$2}I(O9C;LlB>+H>kG+;vjB4u8wuA#|Z_R41uT<@T^ZQHgzsBPP}-41Ho8rHUL+wEVU$$FEV?JCbZ=68K_g2Ul(I2@5! zDjG3`1AIdM_K|~3rV*(K%5b!Dp(z)UK)S(bG7yk)2-Es zLrnCIDR}rZN6;V>HxUb6AvOO@Lv#(Q!h6JGuPCSHXd2XlZ-}3sGL4dCCLyjrOF$+{ zF^%VlpT5#m&CxKZ8RDnyR3`@hi9uZsAVFk9H9ybJPVy6!V(bf9vYmuw_NqZ9AfB zNEmPpQ57W&c!sFb5(a!nR9=JupAnTOVZe*9_L5ykRK*AbwjruUgaH!})qHeVXzQ;G zbrIE5qG4AQo+7Hen3f1JR0_L_BC3}}(fs$rf|ZDBHI}qT3>CzV9EhPBSmMPyM0E`7 zqH+jP-61N9o&SA(u&O^|s0)@QwR0JyNRKC${f0rpJ+H74u``LY5f4lkz;J3Y&5a}0000< KMNUMnLSTZ6lPZk> literal 0 HcmV?d00001 diff --git a/app/src/main/res/drawable-xxxhdpi/ic_refresh_black_24.png b/app/src/main/res/drawable-xxxhdpi/ic_refresh_black_24.png new file mode 100644 index 0000000000000000000000000000000000000000..dcaeff78931752ba498e4f80f03cec233bc7ec3c GIT binary patch literal 890 zcmV-=1BLvFP)}T7yZ7cL_+qP}3ZQHhO+qRKwW%S%ZXV-2=)OW(Dd$O;)3eWRA&+|Ob z^E@-@T*Hg}NlOMXmDQ|d8iQ!bpS;M`q*F9s;?SvlMJLuE39^dLe8yoE&c_H&9LOgO zLkgX>)Z(f_)fXanJSA9(6eGQOfMoLXHWK{+NxWLr@+zaaIbnSvLPygXF-Qvz4Xz*U z0FSZ+G0H41W|voxs0T=)9AcU^JgnJ*1V|>VimqNlp9Q>ia|x@Yt2c2ji`BBLIm1bP!Nfa=%GZwS3nm7uMW>PB zsJ>v}EJWo!!ubnvIl%X7$z|j@t1lSnr@y=$))zuM0R8*tLWlK*(C$?W&Zqc(LfjAV zp<1xM)A~Ya<<)}kJFPE-)XEvEv%i!Ej$&Oj z9~fsND(@17KM|FaFfzpYwn~5_SgszWJ7(TSRKCJmO+@86%w(Z|(yiunEL|0_^_q^M zPfc&`YB`KXR9?YUE^`r;mLy{#g?5O_1ky3~tl0*KRvAI(X3Qlq2>UIjWd26bX+$JW z58UKyP7cL&038r?mT(vmxzlu;^%5o{0eKiL@{R80{K6p=MHauZ0SU;TM67m#qXtJ7 zviwu}+UrlYC}q&E*oQsRxRpw*K=Q4hh5?)7Hdl}iKqg0WCRg(&%~f@sx}@Sr3KbCJ zlq3nK9%M0MlvO+n?j37%=x+e0vX> diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index e98f8239..838dcf48 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -261,7 +261,10 @@ Bitte melden Sie auftretende Probleme via GitHub. Gefundene Geräte - Tippe zur Auswahl - Die lokale Geräteerkennung hat im lokalen Netzwerk keine Geräte gefunden. + Die lokale Geräteerkennung hat im lokalen Netzwerk keine Geräte gefunden. Starte dieses App auf einem zweiten Telefon. Installationsdateien für Computer stehen unter %1$s zur Verfügung. + + + Du hast die lokale Geräteerkennung unter \'Einstellungen\' > \'Syncthing-Optionen\' > \'Lokale Gerätesuche\' deaktiviert. Aktiviere sie, um im lokalen Netzwerk nach Geräten zu suchen. Name diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 5e5779fc..42b6dc39 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -264,7 +264,10 @@ Please report any problems you encounter via Github. Discovered devices - Tap to select - Local discovery didn\'t find any devices on the local network. + Local discovery didn\'t find any devices on the local network. Run this app on a second phone. Installation files for computers are available at: %1$s + + + You have disabled local discovery in \'Settings\' > \'Syncthing Options\' > \'Local Discovery\'. Enable it to search for devices on the local network. Name @@ -604,8 +607,13 @@ Please report any problems you encounter via Github. https://github.com/Catfriend1/syncthing-android/issues + + https://github.com/Catfriend1/syncthing-android/wiki + + https://syncthing.net +