Skip to content

Commit

Permalink
Merge pull request #203 from kaczmarkiewiczp/dev
Browse files Browse the repository at this point in the history
Improve settings layout and fix crash when sharing files
  • Loading branch information
patrykcoding authored Aug 19, 2018
2 parents 2bdb018 + 99d8610 commit cbeb04b
Show file tree
Hide file tree
Showing 41 changed files with 1,973 additions and 1,222 deletions.
5 changes: 3 additions & 2 deletions .idea/assetWizardSettings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "ca.pkay.rcloneexplorer"
minSdkVersion 21
targetSdkVersion 27
versionCode 25
versionName "1.7.0-DEV"
versionCode 26
versionName "1.7.1-DEV"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand All @@ -34,15 +34,15 @@ dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:customtabs:27.1.1'
implementation "com.leinardi.android:speed-dial:1.0-alpha03"
implementation "com.leinardi.android:speed-dial:1.0.2"
implementation 'us.feras.mdv:markdownview:1.1.0'
implementation 'jp.wasabeef:recyclerview-animators:2.3.0'
implementation 'com.github.GrenderG:Toasty:1.3.0'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.github.bumptech.glide:glide:4.7.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.4'
implementation 'com.google.firebase:firebase-messaging:17.1.0'
implementation 'com.google.firebase:firebase-messaging:17.3.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
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 @@ -82,7 +82,7 @@
android:parentActivityName=".AboutActivity"
android:theme="@style/AppTheme.NoActionBar" />
<activity
android:name=".SettingsActivity"
android:name=".Settings.SettingsActivity"
android:label="@string/title_activity_settings"
android:theme="@style/AppTheme.NoActionBar" />
<activity
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/assets/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
### 1.7.1
* **New:** Redesign settings layout
* **Update:** Libraries
* **Fix:** Some bugs with pinned navigation drawer remotes
* **Fix:** Crash when sharing files with the app
* **Fix:** Some other crashes

***

### 1.7.0
* **New:** Show progress in upload, download, and sync notifications
* **New:** Pin remotes to navigation drawer
Expand Down
10 changes: 8 additions & 2 deletions app/src/main/java/ca/pkay/rcloneexplorer/FilePicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,16 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
if (!destinationPickerType) {
speedDialView.setVisibility(View.INVISIBLE);
}
speedDialView.setMainFabOnClickListener(new View.OnClickListener() {
speedDialView.setOnChangeListener(new SpeedDialView.OnChangeListener() {
@Override
public void onClick(View v) {
public boolean onMainActionSelected() {
fabClicked();
return false;
}

@Override
public void onToggleChanged(boolean isOpen) {

}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,22 +256,27 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c
}

fab = view.findViewById(R.id.fab);
fab.setSpeedDialOverlayLayout((SpeedDialOverlayLayout)view.findViewById(R.id.fab_overlay));
fab.setMainFabOnClickListener(new View.OnClickListener() {
fab.setOverlayLayout((SpeedDialOverlayLayout)view.findViewById(R.id.fab_overlay));
fab.setOnActionSelectedListener(new SpeedDialView.OnActionSelectedListener() {
@Override
public void onClick(View v) {
if (fab.isFabMenuOpen()) {
fab.closeOptionsMenu();
public boolean onActionSelected(SpeedDialActionItem actionItem) {
switch (actionItem.getId()) {
case R.id.fab_add_folder:
onCreateNewDirectory();
break;
case R.id.fab_upload:
onUploadFiles();
break;
}
return false;
}
});
fab.addFabOptionItem(new SpeedDialActionItem.Builder(R.id.fab_upload, R.drawable.ic_file_upload)
fab.addActionItem(new SpeedDialActionItem.Builder(R.id.fab_upload, R.drawable.ic_file_upload)
.setLabel(getString(R.string.fab_upload_files))
.create());
fab.addFabOptionItem(new SpeedDialActionItem.Builder(R.id.fab_add_folder, R.drawable.ic_create_new_folder)
fab.addActionItem(new SpeedDialActionItem.Builder(R.id.fab_add_folder, R.drawable.ic_create_new_folder)
.setLabel(getString(R.string.fab_new_folder))
.create());
setFabClickListeners();

breadcrumbView = ((FragmentActivity) context).findViewById(R.id.breadcrumb_view);
breadcrumbView.setOnClickListener(this);
Expand Down Expand Up @@ -751,23 +756,6 @@ private void showFileProperties(FileItem fileItem) {
}
}

private void setFabClickListeners() {
fab.setOptionFabSelectedListener(new SpeedDialView.OnOptionFabSelectedListener() {
@Override
public void onOptionFabSelected(SpeedDialActionItem speedDialActionItem) {
fab.closeOptionsMenu();
switch (speedDialActionItem.getId()) {
case R.id.fab_add_folder:
onCreateNewDirectory();
break;
case R.id.fab_upload:
onUploadFiles();
break;
}
}
});
}

private void setBottomBarClickListeners(final View view) {
view.findViewById(R.id.file_download).setOnClickListener(new View.OnClickListener() {
@Override
Expand Down Expand Up @@ -1113,8 +1101,8 @@ public boolean onBackButtonPressed() {
} else if (isSearchMode) {
searchClicked();
return true;
} else if (fab.isFabMenuOpen()) {
fab.closeOptionsMenu();
} else if (fab.isOpen()) {
fab.close(true);
return true;
} else if (pathStack.isEmpty()) {
return false;
Expand Down Expand Up @@ -1334,8 +1322,8 @@ public void onClick(DialogInterface dialog, int which) {

@Override
public void onBreadCrumbClicked(String path) {
if (fab.isFabMenuOpen()) {
fab.closeOptionsMenu();
if (fab.isOpen()) {
fab.close(true);
}
if (isSearchMode) {
searchClicked();
Expand Down Expand Up @@ -1834,17 +1822,19 @@ protected Boolean doInBackground(FileItem... fileItems) {
rclone.logErrorOutput(process);
}

return process.exitValue() == 0;
return process != null && process.exitValue() == 0;
}

@Override
protected void onPostExecute(Boolean status) {
super.onPostExecute(status);
if (loadingDialog != null) {
if (loadingDialog.isStateSaved()) {
loadingDialog.dismissAllowingStateLoss();
} else {
if (loadingDialog.isStateSaved()) {
loadingDialog.dismissAllowingStateLoss();
} else {
try {
loadingDialog.dismiss();
} catch (NullPointerException e) {
return;
}
}
if (!status) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public interface OnRemoteClickListener {
}

public interface AddRemoteToNavDrawer {
void addRemoteToNavDrawer(RemoteItem remoteItem);
void removeRemoteFromNavDrawer(RemoteItem remoteItem);
void addRemoteToNavDrawer();
void removeRemoteFromNavDrawer();
}

/**
Expand Down Expand Up @@ -100,11 +100,17 @@ public void onClick(View view) {
});

SpeedDialView speedDialView = view.findViewById(R.id.fab);
speedDialView.setMainFabOnClickListener(new View.OnClickListener() {
speedDialView.setOnChangeListener(new SpeedDialView.OnChangeListener() {
@Override
public void onClick(View v) {
public boolean onMainActionSelected() {
Intent intent = new Intent(context, RemoteConfig.class);
startActivityForResult(intent, CONFIG_RECREATE_REQ_CODE);
return false;
}

@Override
public void onToggleChanged(boolean isOpen) {

}
});
return view;
Expand All @@ -122,11 +128,17 @@ public void onClick(View v) {
recyclerView.setAdapter(recyclerViewAdapter);

SpeedDialView speedDialView = view.findViewById(R.id.fab);
speedDialView.setMainFabOnClickListener(new View.OnClickListener() {
speedDialView.setOnChangeListener(new SpeedDialView.OnChangeListener() {
@Override
public void onClick(View v) {
public boolean onMainActionSelected() {
Intent intent = new Intent(context, RemoteConfig.class);
startActivityForResult(intent, CONFIG_REQ_CODE);
return false;
}

@Override
public void onToggleChanged(boolean isOpen) {

}
});

Expand Down Expand Up @@ -301,7 +313,7 @@ private void pinToDrawer(RemoteItem remoteItem) {
editor.putStringSet(getString(R.string.shared_preferences_drawer_pinned_remotes), pinnedRemotes);
editor.apply();

pinToDrawerListener.addRemoteToNavDrawer(remoteItem);
pinToDrawerListener.addRemoteToNavDrawer();
}

private void unpinFromDrawer(RemoteItem remoteItem) {
Expand All @@ -318,7 +330,7 @@ private void unpinFromDrawer(RemoteItem remoteItem) {
editor.putStringSet(getString(R.string.shared_preferences_drawer_pinned_remotes), pinnedRemotes);
editor.apply();

pinToDrawerListener.removeRemoteFromNavDrawer(remoteItem);
pinToDrawerListener.removeRemoteFromNavDrawer();
}

private void deleteRemote(final RemoteItem remoteItem) {
Expand Down Expand Up @@ -373,8 +385,9 @@ protected void onPostExecute(Void aVoid) {
Set<String> drawerPinnedRemote = sharedPreferences.getStringSet(getString(R.string.shared_preferences_drawer_pinned_remotes), new HashSet<String>());
if (drawerPinnedRemote.contains(remoteItem.getName())) {
drawerPinnedRemote.remove(remoteItem.getName());
editor.putStringSet(getString(R.string.shared_preferences_drawer_pinned_remotes), new HashSet<String>(pinnedRemotes));
editor.putStringSet(getString(R.string.shared_preferences_drawer_pinned_remotes), new HashSet<>(pinnedRemotes));
editor.apply();
pinToDrawerListener.removeRemoteFromNavDrawer();
}

recyclerViewAdapter.removeItem(remoteItem);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package ca.pkay.rcloneexplorer.Fragments;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.Collections;
import java.util.List;

import ca.pkay.rcloneexplorer.Items.RemoteItem;
import ca.pkay.rcloneexplorer.R;
import ca.pkay.rcloneexplorer.Rclone;
import ca.pkay.rcloneexplorer.RecyclerViewAdapters.ShareRemotesRecyclerViewAdapter;
import jp.wasabeef.recyclerview.animators.LandingAnimator;

public class ShareRemotesFragment extends Fragment {

private List<RemoteItem> remotes;
private OnRemoteClickListener remoteClickListener;
private Context context;

public interface OnRemoteClickListener {
void onRemoteClick(RemoteItem remote);
}

/**
* Mandatory empty constructor for the fragment manager to instantiate the
* fragment (e.g. upon screen orientation changes).
*/
public ShareRemotesFragment() {
}

@SuppressWarnings("unused")
public static ShareRemotesFragment newInstance() {
return new ShareRemotesFragment();
}

@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getContext() == null) {
return;
}

((FragmentActivity) context).setTitle(getString(R.string.remotes_toolbar_title));
Rclone rclone = new Rclone(getContext());
remotes = rclone.getRemotes();
Collections.sort(remotes);
}

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_share_remotes_list, container, false);

final Context context = view.getContext();
RecyclerView recyclerView = view.findViewById(R.id.share_remotes_list);
recyclerView.setItemAnimator(new LandingAnimator());
recyclerView.setLayoutManager(new LinearLayoutManager(context));
ShareRemotesRecyclerViewAdapter recyclerViewAdapter = new ShareRemotesRecyclerViewAdapter(remotes, remoteClickListener);
recyclerView.setAdapter(recyclerViewAdapter);

return view;
}

@Override
public void onAttach(Context context) {
super.onAttach(context);
this.context = context;
if (context instanceof OnRemoteClickListener) {
remoteClickListener = (OnRemoteClickListener) context;
} else {
throw new RuntimeException(context.toString() + " must implement OnRemoteClickListener");
}
}

@Override
public void onDetach() {
super.onDetach();
context = null;
remoteClickListener = null;
}
}
7 changes: 5 additions & 2 deletions app/src/main/java/ca/pkay/rcloneexplorer/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import ca.pkay.rcloneexplorer.Fragments.FileExplorerFragment;
import ca.pkay.rcloneexplorer.Fragments.RemotesFragment;
import ca.pkay.rcloneexplorer.Items.RemoteItem;
import ca.pkay.rcloneexplorer.Settings.SettingsActivity;
import es.dmoral.toasty.Toasty;
import io.fabric.sdk.android.Fabric;

Expand Down Expand Up @@ -476,7 +477,7 @@ private void startPinnedRemote(RemoteItem remoteItem) {
}

@Override
public void addRemoteToNavDrawer(RemoteItem remoteItem) {
public void addRemoteToNavDrawer() {
Menu menu = navigationView.getMenu();

// remove all items and add them again so that it's in alpha order
Expand All @@ -488,7 +489,7 @@ public void addRemoteToNavDrawer(RemoteItem remoteItem) {
}

@Override
public void removeRemoteFromNavDrawer(RemoteItem remoteItem) {
public void removeRemoteFromNavDrawer() {
Menu menu = navigationView.getMenu();

// remove all items and add them again so that it's in alpha order
Expand Down Expand Up @@ -586,10 +587,12 @@ protected void onPostExecute(Boolean success) {
editor.apply();

if (rclone.isConfigEncrypted()) {
pinRemotesToDrawer(); // this will clear any previous pinned remotes
askForConfigPassword();
} else {
AppShortcutsHelper.removeAllAppShortcuts(context);
AppShortcutsHelper.populateAppShortcuts(context, rclone.getRemotes());
pinRemotesToDrawer();
startRemotesFragment();
}
}
Expand Down
Loading

0 comments on commit cbeb04b

Please sign in to comment.