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 00000000..1d613e51 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_refresh_black_24.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_refresh_black_24.png b/app/src/main/res/drawable-mdpi/ic_refresh_black_24.png new file mode 100644 index 00000000..9c1bd788 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_refresh_black_24.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_refresh_black_24.png b/app/src/main/res/drawable-xhdpi/ic_refresh_black_24.png new file mode 100644 index 00000000..bc32ad05 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_refresh_black_24.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_refresh_black_24.png b/app/src/main/res/drawable-xxhdpi/ic_refresh_black_24.png new file mode 100644 index 00000000..8d2a0480 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_refresh_black_24.png differ 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 00000000..dcaeff78 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_refresh_black_24.png differ diff --git a/app/src/main/res/layout/activity_device.xml b/app/src/main/res/layout/activity_device.xml index 20dc5c00..76d17ca7 100644 --- a/app/src/main/res/layout/activity_device.xml +++ b/app/src/main/res/layout/activity_device.xml @@ -61,9 +61,14 @@ android:id="@+id/discoveredDevicesTitle" android:layout_width="match_parent" android:layout_height="wrap_content" + android:layout_marginEnd="@dimen/abc_action_bar_content_inset_material" + android:layout_marginRight="@dimen/abc_action_bar_content_inset_material" + android:clickable="true" android:drawableLeft="@drawable/ic_device_hub_black_24dp_active" android:drawableStart="@drawable/ic_device_hub_black_24dp_active" - android:focusable="false" + android:drawableEnd="@drawable/ic_refresh_black_24" + android:drawableRight="@drawable/ic_refresh_black_24" + android:focusable="true" android:text="@string/discovered_devices_title" android:visibility="gone" /> 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 +