Skip to content

Commit 2bdb018

Browse files
authored
Merge pull request #202 from kaczmarkiewiczp/dev
v1.7.0
2 parents 109c3ec + 6043306 commit 2bdb018

27 files changed

+700
-143
lines changed

.idea/assetWizardSettings.xml

+2-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/caches/build_file_checksums.ser

0 Bytes
Binary file not shown.

.idea/misc.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ android {
77
applicationId "ca.pkay.rcloneexplorer"
88
minSdkVersion 21
99
targetSdkVersion 27
10-
versionCode 24
11-
versionName "1.6.0-DEV"
10+
versionCode 25
11+
versionName "1.7.0-DEV"
1212
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1313
}
1414
buildTypes {

app/src/main/AndroidManifest.xml

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="ca.pkay.rcloneexplorer">
44

5+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
56
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
67
<uses-permission android:name="android.permission.INTERNET" />
78
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

app/src/main/assets/changelog.md

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
### 1.7.0
2+
* **New:** Show progress in upload, download, and sync notifications
3+
* **New:** Pin remotes to navigation drawer
4+
* **New:** Option to limit transfers to Wi-Fi only
5+
* **New:** Sync
6+
* **New:** Add sync webdev
7+
* **New:** When downloading, uploading, syncing, transfer only one file in parallel
8+
* **New:** Make crash reports and app update notifications optional
9+
* **New:** Update some icons
10+
* **Fix:** Proper encoding of URLs for streaming
11+
* **Fix:** Crashes
12+
13+
***
14+
115
### 1.6.0
216
* **New:** Allow setting which remotes are in app shortcuts (from settings)
317
* **New:** Pin remotes on supported launchers (Android 8.0)

app/src/main/java/ca/pkay/rcloneexplorer/BreadcrumbView.java

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ private void init(Context context) {
4545
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
4646
childFrame = new LinearLayout(context);
4747
childFrame.setLayoutParams(layoutParams);
48+
childFrame.removeAllViews();
4849
this.context = context;
4950
addView(childFrame, layoutParams);
5051
pathList = new ArrayList<>();

app/src/main/java/ca/pkay/rcloneexplorer/Dialogs/LoadingDialog.java

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
6161
LayoutInflater inflater = ((FragmentActivity)context).getLayoutInflater();
6262
View view = inflater.inflate(R.layout.dialog_loading_indicator, null);
6363
builder.setCancelable(cancelable);
64+
setCancelable(cancelable);
6465
if (title != null) {
6566
builder.setTitle(title);
6667
} else if (titleId > 0) {

app/src/main/java/ca/pkay/rcloneexplorer/Fragments/FileExplorerFragment.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,7 @@ private void onClickOutsideOfView() {
10751075
public void onAttach(Context context) {
10761076
super.onAttach(context);
10771077
this.context = context;
1078+
isRunning = true;
10781079
}
10791080

10801081
@Override
@@ -1980,10 +1981,12 @@ protected Boolean doInBackground(Void... voids) {
19801981
@Override
19811982
protected void onPostExecute(Boolean result) {
19821983
super.onPostExecute(result);
1983-
if (result) {
1984-
Toasty.success(context, getString(R.string.trash_emptied), Toast.LENGTH_SHORT, true).show();
1985-
} else {
1986-
Toasty.error(context, getString(R.string.error_emptying_trash), Toast.LENGTH_SHORT, true).show();
1984+
if (isRunning) {
1985+
if (result) {
1986+
Toasty.success(context, getString(R.string.trash_emptied), Toast.LENGTH_SHORT, true).show();
1987+
} else {
1988+
Toasty.error(context, getString(R.string.error_emptying_trash), Toast.LENGTH_SHORT, true).show();
1989+
}
19871990
}
19881991
}
19891992
}

app/src/main/java/ca/pkay/rcloneexplorer/Fragments/RemotesFragment.java

+74-10
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import android.support.v7.widget.LinearLayoutManager;
1818
import android.support.v7.widget.PopupMenu;
1919
import android.support.v7.widget.RecyclerView;
20-
import android.util.Log;
2120
import android.view.LayoutInflater;
2221
import android.view.MenuItem;
2322
import android.view.View;
@@ -46,10 +45,20 @@ public class RemotesFragment extends Fragment implements RemotesRecyclerViewAdap
4645
private Rclone rclone;
4746
private RemotesRecyclerViewAdapter recyclerViewAdapter;
4847
private List<RemoteItem> remotes;
49-
private OnRemoteClickListener clickListener;
48+
private OnRemoteClickListener remoteClickListener;
49+
private AddRemoteToNavDrawer pinToDrawerListener;
5050
private Context context;
5151
private boolean isDarkTheme;
5252

53+
public interface OnRemoteClickListener {
54+
void onRemoteClick(RemoteItem remote);
55+
}
56+
57+
public interface AddRemoteToNavDrawer {
58+
void addRemoteToNavDrawer(RemoteItem remoteItem);
59+
void removeRemoteFromNavDrawer(RemoteItem remoteItem);
60+
}
61+
5362
/**
5463
* Mandatory empty constructor for the fragment manager to instantiate the
5564
* fragment (e.g. upon screen orientation changes).
@@ -109,7 +118,7 @@ public void onClick(View v) {
109118
RecyclerView recyclerView = view.findViewById(R.id.remotes_list);
110119
recyclerView.setItemAnimator(new LandingAnimator());
111120
recyclerView.setLayoutManager(new LinearLayoutManager(context));
112-
recyclerViewAdapter = new RemotesRecyclerViewAdapter(remotes, clickListener, this);
121+
recyclerViewAdapter = new RemotesRecyclerViewAdapter(remotes, remoteClickListener, this);
113122
recyclerView.setAdapter(recyclerViewAdapter);
114123

115124
SpeedDialView speedDialView = view.findViewById(R.id.fab);
@@ -139,7 +148,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
139148
case CONFIG_RECREATE_REQ_CODE:
140149
remotes = rclone.getRemotes();
141150
Collections.sort(remotes);
142-
recyclerViewAdapter = new RemotesRecyclerViewAdapter(remotes, clickListener, this);
151+
recyclerViewAdapter = new RemotesRecyclerViewAdapter(remotes, remoteClickListener, this);
143152
refreshFragment();
144153
if (remotes.size() == 1) {
145154
AppShortcutsHelper.populateAppShortcuts(context, remotes);
@@ -164,17 +173,23 @@ public void onAttach(Context context) {
164173
super.onAttach(context);
165174
this.context = context;
166175
if (context instanceof OnRemoteClickListener) {
167-
clickListener = (OnRemoteClickListener) context;
176+
remoteClickListener = (OnRemoteClickListener) context;
168177
} else {
169178
throw new RuntimeException(context.toString() + " must implement OnRemoteClickListener");
170179
}
180+
if (context instanceof AddRemoteToNavDrawer) {
181+
pinToDrawerListener = (AddRemoteToNavDrawer) context;
182+
} else {
183+
throw new RuntimeException(context.toString() + " must implement AddRemoteToNavDrawer");
184+
}
171185
}
172186

173187
@Override
174188
public void onDetach() {
175189
super.onDetach();
176190
context = null;
177-
clickListener = null;
191+
remoteClickListener = null;
192+
pinToDrawerListener = null;
178193
}
179194

180195
@Override
@@ -199,6 +214,13 @@ public boolean onMenuItemClick(MenuItem item) {
199214
pinRemote(remoteItem);
200215
}
201216
break;
217+
case R.id.action_favorite:
218+
if (remoteItem.isDrawerPinned()) {
219+
unpinFromDrawer(remoteItem);
220+
} else {
221+
pinToDrawer(remoteItem);
222+
}
223+
break;
202224
case R.id.action_add_to_home_screen:
203225
AppShortcutsHelper.addRemoteToHomeScreen(context, remoteItem);
204226
break;
@@ -220,6 +242,13 @@ public boolean onMenuItemClick(MenuItem item) {
220242
MenuItem addToHomeScreenAction = popupMenu.getMenu().findItem(R.id.action_add_to_home_screen);
221243
addToHomeScreenAction.setVisible(false);
222244
}
245+
246+
MenuItem favoriteAction = popupMenu.getMenu().findItem(R.id.action_favorite);
247+
if (remoteItem.isDrawerPinned()) {
248+
favoriteAction.setTitle(R.string.unpin_from_drawer);
249+
} else {
250+
favoriteAction.setTitle(R.string.pin_to_drawer);
251+
}
223252
}
224253

225254
private void pinRemote(RemoteItem remoteItem) {
@@ -260,6 +289,38 @@ private void unPinRemote(RemoteItem remoteItem) {
260289
recyclerViewAdapter.moveDataItem(remotes, from, to);
261290
}
262291

292+
private void pinToDrawer(RemoteItem remoteItem) {
293+
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
294+
SharedPreferences.Editor editor = sharedPreferences.edit();
295+
296+
Set<String> stringSet = sharedPreferences.getStringSet(getString(R.string.shared_preferences_drawer_pinned_remotes), new HashSet<String>());
297+
Set<String> pinnedRemotes = new HashSet<>(stringSet); // bug in android means that we have to create a copy
298+
pinnedRemotes.add(remoteItem.getName());
299+
remoteItem.setDrawerPinned(true);
300+
301+
editor.putStringSet(getString(R.string.shared_preferences_drawer_pinned_remotes), pinnedRemotes);
302+
editor.apply();
303+
304+
pinToDrawerListener.addRemoteToNavDrawer(remoteItem);
305+
}
306+
307+
private void unpinFromDrawer(RemoteItem remoteItem) {
308+
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
309+
SharedPreferences.Editor editor = sharedPreferences.edit();
310+
311+
Set<String> stringSet = sharedPreferences.getStringSet(getString(R.string.shared_preferences_drawer_pinned_remotes), new HashSet<String>());
312+
Set<String> pinnedRemotes = new HashSet<>(stringSet);
313+
if (pinnedRemotes.contains(remoteItem.getName())) {
314+
pinnedRemotes.remove(remoteItem.getName());
315+
}
316+
remoteItem.setDrawerPinned(false);
317+
318+
editor.putStringSet(getString(R.string.shared_preferences_drawer_pinned_remotes), pinnedRemotes);
319+
editor.apply();
320+
321+
pinToDrawerListener.removeRemoteFromNavDrawer(remoteItem);
322+
}
323+
263324
private void deleteRemote(final RemoteItem remoteItem) {
264325
AlertDialog.Builder builder;
265326
if (isDarkTheme) {
@@ -279,10 +340,6 @@ public void onClick(DialogInterface dialog, int which) {
279340
builder.show();
280341
}
281342

282-
public interface OnRemoteClickListener {
283-
void onRemoteClick(RemoteItem remote);
284-
}
285-
286343
@SuppressLint("StaticFieldLeak")
287344
private class DeleteRemote extends AsyncTask<Void, Void, Void> {
288345

@@ -313,6 +370,13 @@ protected void onPostExecute(Void aVoid) {
313370

314371
AppShortcutsHelper.removeAppShortcut(context, remoteItem.getName());
315372

373+
Set<String> drawerPinnedRemote = sharedPreferences.getStringSet(getString(R.string.shared_preferences_drawer_pinned_remotes), new HashSet<String>());
374+
if (drawerPinnedRemote.contains(remoteItem.getName())) {
375+
drawerPinnedRemote.remove(remoteItem.getName());
376+
editor.putStringSet(getString(R.string.shared_preferences_drawer_pinned_remotes), new HashSet<String>(pinnedRemotes));
377+
editor.apply();
378+
}
379+
316380
recyclerViewAdapter.removeItem(remoteItem);
317381

318382
if (rclone.getRemotes().isEmpty()) {

app/src/main/java/ca/pkay/rcloneexplorer/Items/RemoteItem.java

+50-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import android.os.Parcel;
44
import android.os.Parcelable;
55
import android.support.annotation.NonNull;
6-
import android.util.SizeF;
6+
7+
import ca.pkay.rcloneexplorer.R;
78

89
public class RemoteItem implements Comparable<RemoteItem>, Parcelable {
910

@@ -35,6 +36,7 @@ public class RemoteItem implements Comparable<RemoteItem>, Parcelable {
3536
private boolean isAlias;
3637
private boolean isCache;
3738
private boolean isPinned;
39+
private boolean isDrawerPinned;
3840

3941
public RemoteItem(String name, String type) {
4042
this.name = name;
@@ -49,6 +51,8 @@ private RemoteItem(Parcel in) {
4951
isCrypt = in.readByte() != 0;
5052
isAlias = in.readByte() != 0;
5153
isCache = in.readByte() != 0;
54+
isPinned = in.readByte() != 0;
55+
isDrawerPinned = in.readByte() != 0;
5256
}
5357

5458
public static final Creator<RemoteItem> CREATOR = new Creator<RemoteItem>() {
@@ -138,6 +142,15 @@ public boolean isPinned() {
138142
return this.isPinned;
139143
}
140144

145+
public RemoteItem setDrawerPinned(boolean isPinned) {
146+
this.isDrawerPinned = isPinned;
147+
return this;
148+
}
149+
150+
public boolean isDrawerPinned() {
151+
return this.isDrawerPinned;
152+
}
153+
141154
public boolean isRemoteType(int ...remotes) {
142155
boolean isSameType = false;
143156

@@ -198,6 +211,35 @@ private int getTypeFromString(String type) {
198211
}
199212
}
200213

214+
public int getRemoteIcon() {
215+
if (isCrypt()) {
216+
return R.drawable.ic_lock_black;
217+
} else {
218+
switch (type) {
219+
case RemoteItem.AMAZON_DRIVE:
220+
return R.drawable.ic_amazon;
221+
case RemoteItem.GOOGLE_DRIVE:
222+
return R.drawable.ic_google_drive;
223+
case RemoteItem.DROPBOX:
224+
return R.drawable.ic_dropbox;
225+
case RemoteItem.GOOGLE_CLOUD_STORAGE:
226+
return R.drawable.ic_google;
227+
case RemoteItem.ONEDRIVE:
228+
return R.drawable.ic_onedrive;
229+
case RemoteItem.S3:
230+
return R.drawable.ic_amazon;
231+
case RemoteItem.BOX:
232+
return R.drawable.ic_box;
233+
case RemoteItem.SFTP:
234+
return R.drawable.ic_terminal;
235+
case RemoteItem.LOCAL:
236+
return R.drawable.ic_tablet_cellphone;
237+
default:
238+
return R.drawable.ic_cloud;
239+
}
240+
}
241+
}
242+
201243
@Override
202244
public int compareTo(@NonNull RemoteItem remoteItem) {
203245
if (this.isPinned && !remoteItem.isPinned()) {
@@ -208,6 +250,11 @@ public int compareTo(@NonNull RemoteItem remoteItem) {
208250
return name.toLowerCase().compareTo(remoteItem.getName().toLowerCase());
209251
}
210252

253+
@Override
254+
public boolean equals(Object obj) {
255+
return obj instanceof RemoteItem && ((RemoteItem) obj).getName().equals(this.name) && ((RemoteItem) obj).getType() == this.type;
256+
}
257+
211258
@Override
212259
public int describeContents() {
213260
return 0;
@@ -221,5 +268,7 @@ public void writeToParcel(Parcel dest, int flags) {
221268
dest.writeByte((byte) (isCrypt ? 1 : 0));
222269
dest.writeByte((byte) (isAlias ? 1 : 0));
223270
dest.writeByte((byte) (isCache ? 1 : 0));
271+
dest.writeByte((byte) (isPinned ? 1 : 0));
272+
dest.writeByte((byte) (isDrawerPinned ? 1 : 0));
224273
}
225274
}

app/src/main/java/ca/pkay/rcloneexplorer/Log2File.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
import java.text.SimpleDateFormat;
1111
import java.util.Date;
1212

13-
class Log2File {
13+
public class Log2File {
1414

1515
private Context context;
1616

17-
Log2File(Context context) {
17+
public Log2File(Context context) {
1818
this.context = context;
1919
}
2020

0 commit comments

Comments
 (0)