1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-26 06:11:19 +00:00

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
This commit is contained in:
Catfriend1 2019-02-09 18:26:54 +01:00 committed by GitHub
parent e5a033a64d
commit 7bd253ab0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 42 additions and 18 deletions

View file

@ -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);
}
/**

Binary file not shown.

After

Width:  |  Height:  |  Size: 362 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 676 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 890 B

View file

@ -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" />

View file

@ -261,7 +261,10 @@ Bitte melden Sie auftretende Probleme via GitHub.</string>
<string name="discovered_devices_title">Gefundene Geräte - Tippe zur Auswahl</string>
<!-- Status text -->
<string name="discovered_device_list_empty">Die lokale Geräteerkennung hat im lokalen Netzwerk keine Geräte gefunden.</string>
<string name="discovered_device_list_empty">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.</string>
<!-- Status text -->
<string name="local_discovery_disabled">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.</string>
<!-- Setting title -->
<string name="name">Name</string>

View file

@ -264,7 +264,10 @@ Please report any problems you encounter via Github.</string>
<string name="discovered_devices_title">Discovered devices - Tap to select</string>
<!-- Status text -->
<string name="discovered_device_list_empty">Local discovery didn\'t find any devices on the local network.</string>
<string name="discovered_device_list_empty">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</string>
<!-- Status text -->
<string name="local_discovery_disabled">You have disabled local discovery in \'Settings\' > \'Syncthing Options\' > \'Local Discovery\'. Enable it to search for devices on the local network.</string>
<!-- Setting title -->
<string name="name">Name</string>
@ -604,8 +607,13 @@ Please report any problems you encounter via Github.</string>
<!-- URL of the issue tracker -->
<string name="issue_tracker_url" translatable="false">https://github.com/Catfriend1/syncthing-android/issues</string>
<!-- URL of the GitHub wiki -->
<string name="wiki_url" translatable="false">https://github.com/Catfriend1/syncthing-android/wiki</string>
<!-- URL of the Syncthing project homepage -->
<string name="url_syncthing_homepage" translatable="false">https://syncthing.net</string>
<!-- Menu item to donate -->
<!-- Title of the preference showing upstream version name -->