mirror of
https://github.com/syncthing/syncthing-android.git
synced 2024-11-29 15:51:17 +00:00
* Add drawable: ic_refresh_white_24 * Add menu: recent_changes_list * Add strings: no_recent_changes, refresh * Update layout: activity_recent_changes Add TextView if no recent changes were returned by Syncthing's REST API * Add refresh button to recent changes dialog (fixes #361) Add text notice if no recent changes were returned by Syncthing's REST API. Update built-in test data generation. * Fix lint * Fix lint: RelativeLayout => LinearLayout * Imported de translation
This commit is contained in:
parent
fa030319ff
commit
030a7c7bc3
10 changed files with 78 additions and 10 deletions
|
@ -7,6 +7,10 @@ import android.support.v7.widget.LinearLayoutManager;
|
|||
import android.support.v7.widget.RecyclerView;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
|
@ -26,6 +30,8 @@ import java.io.File;
|
|||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
import static com.nutomic.syncthingandroid.service.Constants.ENABLE_TEST_DATA;
|
||||
|
||||
|
@ -99,6 +105,24 @@ public class RecentChangesActivity extends SyncthingActivity
|
|||
mRecyclerView.setAdapter(mRecentChangeAdapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
MenuInflater inflater = getMenuInflater();
|
||||
inflater.inflate(R.menu.recent_changes_list, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.refresh:
|
||||
onTimerEvent();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
|
||||
super.onServiceConnected(componentName, iBinder);
|
||||
|
@ -157,9 +181,11 @@ public class RecentChangesActivity extends SyncthingActivity
|
|||
|
||||
if (ENABLE_TEST_DATA) {
|
||||
DiskEvent fakeDiskEvent = new DiskEvent();
|
||||
fakeDiskEvent.id = 2;
|
||||
fakeDiskEvent.id = 10;
|
||||
fakeDiskEvent.globalID = 84;
|
||||
fakeDiskEvent.time = "2018-10-28T14:08:01.6183215+01:00";
|
||||
fakeDiskEvent.time = "2018-10-28T14:08:" +
|
||||
String.format(Locale.getDefault(), "%02d", new Random().nextInt(60)) +
|
||||
".6183215+01:00";
|
||||
fakeDiskEvent.type = "RemoteChangeDetected";
|
||||
fakeDiskEvent.data.action = "added";
|
||||
fakeDiskEvent.data.folder = "abcd-efgh";
|
||||
|
@ -169,12 +195,22 @@ public class RecentChangesActivity extends SyncthingActivity
|
|||
fakeDiskEvent.data.path = "document1.txt";
|
||||
fakeDiskEvent.data.type = "file";
|
||||
diskEvents.add(fakeDiskEvent);
|
||||
fakeDiskEvent = deepCopy(fakeDiskEvent, new TypeToken<DiskEvent>(){}.getType());
|
||||
fakeDiskEvent.id = 1;
|
||||
fakeDiskEvent.data.action = "deleted";
|
||||
diskEvents.add(fakeDiskEvent);
|
||||
|
||||
for (int i = 9; i > 0; i--) {
|
||||
fakeDiskEvent = deepCopy(fakeDiskEvent, new TypeToken<DiskEvent>(){}.getType());
|
||||
fakeDiskEvent.id = i;
|
||||
fakeDiskEvent.data.action = "deleted";
|
||||
diskEvents.add(fakeDiskEvent);
|
||||
}
|
||||
|
||||
if (new Random().nextInt(2) == 0) {
|
||||
diskEvents.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// Show text if the list is empty.
|
||||
findViewById(R.id.no_recent_changes).setVisibility(diskEvents.size() > 0 ? View.GONE : View.VISIBLE);
|
||||
|
||||
mRecentChangeAdapter.clear();
|
||||
for (DiskEvent diskEvent : diskEvents) {
|
||||
if (diskEvent.data != null) {
|
||||
|
|
BIN
app/src/main/res/drawable-hdpi/ic_refresh_white_24.png
Normal file
BIN
app/src/main/res/drawable-hdpi/ic_refresh_white_24.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 349 B |
BIN
app/src/main/res/drawable-mdpi/ic_refresh_white_24.png
Normal file
BIN
app/src/main/res/drawable-mdpi/ic_refresh_white_24.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 259 B |
BIN
app/src/main/res/drawable-xhdpi/ic_refresh_white_24.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_refresh_white_24.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 470 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_refresh_white_24.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/ic_refresh_white_24.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 661 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_refresh_white_24.png
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/ic_refresh_white_24.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 876 B |
|
@ -1,15 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".activities.RecentChangesActivity">
|
||||
|
||||
<include layout="@layout/widget_toolbar" />
|
||||
|
||||
<TextView
|
||||
style="@style/Widget.Syncthing.TextView.Label.Details"
|
||||
android:id="@+id/no_recent_changes"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawableLeft="@drawable/ic_label_outline_black_24dp"
|
||||
android:drawableStart="@drawable/ic_label_outline_black_24dp"
|
||||
android:focusable="false"
|
||||
android:text="@string/no_recent_changes" />
|
||||
|
||||
<android.support.v7.widget.RecyclerView
|
||||
android:id="@+id/changes_recycler_view"
|
||||
android:paddingTop="?attr/actionBarSize"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbars="vertical" />
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
|
|
12
app/src/main/res/menu/recent_changes_list.xml
Normal file
12
app/src/main/res/menu/recent_changes_list.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<item
|
||||
android:id="@+id/refresh"
|
||||
android:icon="@drawable/ic_refresh_white_24"
|
||||
android:title="@string/refresh"
|
||||
app:showAsAction="always|withText" />
|
||||
|
||||
</menu>
|
|
@ -59,6 +59,8 @@ Bitte melden Sie auftretende Probleme via GitHub.</string>
|
|||
|
||||
<string name="main_menu">Hauptmenü</string>
|
||||
|
||||
<string name="refresh">Aktualisieren</string>
|
||||
|
||||
<!-- MainActivity -->
|
||||
|
||||
|
||||
|
@ -364,6 +366,8 @@ Bitte melden Sie auftretende Probleme via GitHub.</string>
|
|||
<string name="tip_xiaomi_autostart_text">Xiaomi MIUI verbietet standardmäßig den Apps, sich selbst zu starten. Von Deinem Startbildschirm beginnend: Wähle \"Einstellungen\" > \"Rechte\" > \"Autostart\" und aktiviere den \"Syncthing-Fork\" Schieberegler.</string>
|
||||
|
||||
<!-- RecentChangesActivity -->
|
||||
<string name="no_recent_changes">Es gibt keine kürzlichen Änderungen.</string>
|
||||
|
||||
<string name="recent_changes_title">Letzte Änderungen</string>
|
||||
<string name="modified_by_device">Gerät: %1$s</string>
|
||||
<string name="modification_time">Zeit: %1$s</string>
|
||||
|
|
|
@ -59,6 +59,8 @@ Please report any problems you encounter via Github.</string>
|
|||
|
||||
<string name="main_menu">Main Menu</string>
|
||||
|
||||
<string name="refresh">Refresh</string>
|
||||
|
||||
<!-- MainActivity -->
|
||||
|
||||
|
||||
|
@ -367,6 +369,8 @@ Please report any problems you encounter via Github.</string>
|
|||
<string name="tip_xiaomi_autostart_text">Xiaomi MIUI disallows apps to start on their own by default. From home screen, go to \'Settings\' > \'Permissions\' > \'Autostart\' and enable the \'Syncthing-Fork\' slider.</string>
|
||||
|
||||
<!-- RecentChangesActivity -->
|
||||
<string name="no_recent_changes">There are no recent changes.</string>
|
||||
|
||||
<string name="recent_changes_title">Recent changes</string>
|
||||
<string name="modified_by_device">Device: %1$s</string>
|
||||
<string name="modification_time">Time: %1$s</string>
|
||||
|
|
Loading…
Reference in a new issue