Skip to content

Commit

Permalink
Merge pull request #48 from kaczmarkiewiczp/dev
Browse files Browse the repository at this point in the history
Features and Fixes
  • Loading branch information
patrykcoding authored Apr 22, 2018
2 parents 41ca5aa + cd30f2b commit af2d5d7
Show file tree
Hide file tree
Showing 16 changed files with 346 additions and 286 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@ Credits/Libraries
- [Material Dialogs](https://github.com/afollestad/material-dialogs) - A beautiful, fluid, and customizable dialogs API
- [rclone](https://github.com/ncw/rclone) - "rsync for cloud storage"
- Icon made by [Smashicons](https://www.flaticon.com/authors/smashicons) from [Flaticon](https://www.flaticon.com)
- Graphics from [Game Building Tools](http://www.gamebuildingtools.com)
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
applicationId "ca.pkay.rcloneexplorer"
minSdkVersion 21
targetSdkVersion 27
versionCode 4
versionName "1.0.0-beta"
versionCode 5
versionName "1.0.1-beta"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down Expand Up @@ -39,6 +39,7 @@ dependencies {
implementation 'com.mikepenz:octicons-typeface:3.2.0.4@aar'
implementation "com.mikepenz:aboutlibraries:6.0.8"
implementation 'us.feras.mdv:markdownview:1.1.0'
implementation 'jp.wasabeef:recyclerview-animators:2.3.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:label="@string/app_short_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Expand Down
20 changes: 10 additions & 10 deletions app/src/main/assets/changelog.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
### 1.0.1-beta
* **New:** Short app name in the launcher
* **New:** Animations
* **Fix:** Scrolling in About page
* **Fix:** File Explorer not getting cleared when loading
* **Fix:** Sorting
* **Fix:** Canceled notification posted on download/upload cancel
* **Fix:** Make temporary files read-only
----
### 1.0.0-beta
***
First beta release!

* Code refactoring

***


-----
### 0.3.0-alpha
***

* **New:** Changelog added under About screen
* **New:** Clicking on File/Folder icon will select it
* **New:** App icon
* **Fix:** Status bar color

***

4 changes: 2 additions & 2 deletions app/src/main/java/ca/pkay/rcloneexplorer/FileComparators.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public int compare(FileItem fileItem, FileItem t1) {
return 1;
}

return fileItem.getName().compareTo(t1.getName());
return fileItem.getName().toLowerCase().compareTo(t1.getName().toLowerCase());
}
}

Expand All @@ -30,7 +30,7 @@ public int compare(FileItem fileItem, FileItem t1) {
return 1;
}

return t1.getName().compareTo(fileItem.getName());
return t1.getName().toLowerCase().compareTo(fileItem.getName().toLowerCase());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
import ca.pkay.rcloneexplorer.Services.DownloadService;
import ca.pkay.rcloneexplorer.Services.StreamingService;
import ca.pkay.rcloneexplorer.Services.UploadService;
import jp.wasabeef.recyclerview.animators.LandingAnimator;
import jp.wasabeef.recyclerview.animators.SlideInLeftAnimator;
import ru.bartwell.exfilepicker.ExFilePicker;
import ru.bartwell.exfilepicker.data.ExFilePickerResult;

Expand Down Expand Up @@ -165,6 +167,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c

Context context = view.getContext();
RecyclerView recyclerView = view.findViewById(R.id.file_explorer_list);
recyclerView.setItemAnimator(new LandingAnimator());
recyclerView.setLayoutManager(new LinearLayoutManager(context));
recyclerViewAdapter = new FileExplorerRecyclerViewAdapter(directoryContent, view.findViewById(R.id.empty_folder_view), this);
recyclerView.setAdapter(recyclerViewAdapter);
Expand Down Expand Up @@ -482,6 +485,7 @@ public boolean onBackButtonPressed() {
fetchDirectoryTask.cancel(true);
breadcrumbView.removeLastCrumb();
path = pathStack.pop();
recyclerViewAdapter.clear();
if (directoryCache.containsKey(path)) {
directoryContent = directoryCache.get(path);
recyclerViewAdapter.newData(directoryContent);
Expand Down Expand Up @@ -574,6 +578,7 @@ public void onBreadCrumbClicked(String path) {
// pop stack until we find path
}
breadcrumbView.removeCrumbsUpTo(path);
recyclerViewAdapter.clear();
if (directoryCache.containsKey(path)) {
directoryContent = directoryCache.get(path);
recyclerViewAdapter.newData(directoryContent);
Expand Down Expand Up @@ -943,6 +948,12 @@ protected Boolean doInBackground(FileItem... fileItems) {
e.printStackTrace();
return false;
}

if (process.exitValue() == 0) {
File savedFile = new File(fileLocation);
savedFile.setReadOnly();
}

return process.exitValue() == 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ public void onBindViewHolder(@NonNull final ViewHolder holder, int position) {
if (selectedItems.contains(item)) {
holder.view.setBackgroundColor(holder.view.getResources().getColor(R.color.colorPrimaryLight));
} else {
holder.view.setBackgroundColor(0x00000000);
holder.view.setBackgroundColor(holder.view.getResources().getColor(R.color.white));
}
} else {
holder.view.setBackgroundColor(0x00000000);
holder.view.setBackgroundColor(holder.view.getResources().getColor(R.color.white));
}
if (isInMoveMode) {
if (item.isDir()) {
Expand Down Expand Up @@ -121,15 +121,20 @@ public int getItemCount() {
}

public void clear() {
if (files == null) {
return;
}
int count = files.size();
files.clear();
isInSelectMode = false;
selectedItems.clear();
listener.onFilesSelected(false);
notifyDataSetChanged();
notifyItemRangeRemoved(0, count);
}

public void newData(List<FileItem> data) {
files = data;
this.clear();
files = new ArrayList<>(data);
isInSelectMode = false;
selectedItems.clear();
listener.onFilesSelected(false);
Expand All @@ -138,18 +143,26 @@ public void newData(List<FileItem> data) {
} else {
emptyView.setVisibility(View.INVISIBLE);
}
notifyDataSetChanged();
if (isInMoveMode) {
notifyDataSetChanged();
} else {
notifyItemRangeInserted(0, files.size());
}
}

public void updateData(List<FileItem> data) {
files = data;
this.clear();
files = new ArrayList<>(data);
if (files.isEmpty()) {
emptyView.setVisibility(View.VISIBLE);
} else {
emptyView.setVisibility(View.INVISIBLE);
}
notifyDataSetChanged();
}
if (isInMoveMode) {
notifyDataSetChanged();
} else {
notifyItemRangeInserted(0, files.size());
} }

public void refreshData() {
notifyDataSetChanged();
Expand Down Expand Up @@ -206,7 +219,7 @@ public void cancelSelection() {
private void onLongClickAction(FileItem item, ViewHolder holder) {
if (selectedItems.contains(item)) {
selectedItems.remove(item);
holder.view.setBackgroundColor(0x00000000);
holder.view.setBackgroundColor(holder.view.getResources().getColor(R.color.white));
if (selectedItems.size() == 0) {
isInSelectMode = false;
listener.onFilesSelected(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class DownloadService extends IntentService {
public static final String REMOTE_ARG = "ca.pkay.rcexplorer.download_service.arg3";
private Rclone rclone;
private List<Process> runningProcesses;
private Boolean aProcessFailed;

/**
* Creates an IntentService. Invoked by your subclass's constructor.*
Expand Down Expand Up @@ -72,21 +73,38 @@ protected void onHandleIntent(@Nullable Intent intent) {
for (Process process : runningProcesses) {
try {
process.waitFor();
if (process.exitValue() != 0) {
aProcessFailed = true;
}

} catch (InterruptedException e) {
e.printStackTrace();
}
}

stopForeground(true);

NotificationCompat.Builder builder1 = new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(android.R.drawable.stat_sys_download_done)
.setContentTitle(getString(R.string.download_complete))
.setPriority(NotificationCompat.PRIORITY_DEFAULT);
NotificationCompat.Builder builder1;
if (aProcessFailed) {
builder1 = new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(android.R.drawable.stat_sys_warning)
.setContentTitle(getString(R.string.download_cancelled))
.setPriority(NotificationCompat.PRIORITY_DEFAULT);

NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager != null) {
notificationManager.notify(2, builder1.build());
}
} else {
builder1 = new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(android.R.drawable.stat_sys_download_done)
.setContentTitle(getString(R.string.download_complete))
.setPriority(NotificationCompat.PRIORITY_DEFAULT);

NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager != null) {
notificationManager.notify(2, builder1.build());
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager != null) {
notificationManager.notify(3, builder1.build());
}
}
}

Expand All @@ -106,7 +124,9 @@ private void setNotificationChannel() {
channel.setDescription(getString(R.string.download_service_notification_description));
// Register the channel with the system
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.createNotificationChannel(channel);
if (notificationManager != null) {
notificationManager.createNotificationChannel(channel);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class UploadService extends IntentService {
public static final String REMOTE_ARG = "ca.pkay.rcexplorer.upload_service.arg3";
private Rclone rclone;
private List<Process> runningProcesses;
private Boolean aProcessFailed;

/**
* Creates an IntentService. Invoked by your subclass's constructor.*
Expand Down Expand Up @@ -72,6 +73,9 @@ protected void onHandleIntent(@Nullable Intent intent) {
for (Process process : runningProcesses) {
try {
process.waitFor();
if (process.exitValue() != 0) {
aProcessFailed = true;
}
} catch (InterruptedException e) {
e.printStackTrace();
}
Expand All @@ -80,14 +84,27 @@ protected void onHandleIntent(@Nullable Intent intent) {

stopForeground(true);

NotificationCompat.Builder builder1 = new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(android.R.drawable.stat_sys_upload_done)
.setContentTitle(getString(R.string.upload_complete))
.setPriority(NotificationCompat.PRIORITY_DEFAULT);
NotificationCompat.Builder builder1;
if (aProcessFailed) {
builder1 = new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(android.R.drawable.stat_sys_warning)
.setContentTitle(getString(R.string.upload_cancelled))
.setPriority(NotificationCompat.PRIORITY_DEFAULT);

NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager != null) {
notificationManager.notify(20, builder1.build());
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager != null) {
notificationManager.notify(21, builder1.build());
}
} else {
builder1 = new NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(android.R.drawable.stat_sys_upload_done)
.setContentTitle(getString(R.string.upload_complete))
.setPriority(NotificationCompat.PRIORITY_DEFAULT);

NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
if (notificationManager != null) {
notificationManager.notify(20, builder1.build());
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_file_download_notification.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M19,9h-4V3H9v6H5l7,7 7,-7zM5,18v2h14v-2H5z"/>
</vector>
Loading

0 comments on commit af2d5d7

Please sign in to comment.