Skip to content

Commit

Permalink
Merge pull request #148 from nextcloud/145_no_go_back_alternative
Browse files Browse the repository at this point in the history
#145 Alternative fix for drawer navigation fix in upload activity
  • Loading branch information
tobiasKaminsky authored Jul 24, 2016
2 parents 8876f52 + 7d0e65f commit c405859
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 22 deletions.
4 changes: 2 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.owncloud.android"
android:versionCode="10020001"
android:versionName="1.2.0 RC1">
android:versionCode="10020002"
android:versionName="1.2.0 RC2">

<uses-sdk
android:minSdkVersion="14"
Expand Down
18 changes: 9 additions & 9 deletions src/com/owncloud/android/ui/activity/DrawerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,14 +204,12 @@ public boolean onNavigationItemSelected(MenuItem menuItem) {
case R.id.nav_all_files:
menuItem.setChecked(true);
mCheckedMenuItem = menuItem.getItemId();
MainApp.showOnlyFilesOnDevice(false);
refreshDirectory();
showFiles(false);
break;
case R.id.nav_on_device:
menuItem.setChecked(true);
mCheckedMenuItem = menuItem.getItemId();
MainApp.showOnlyFilesOnDevice(true);
refreshDirectory();
showFiles(true);
break;
case R.id.nav_uploads:
Intent uploadListIntent = new Intent(getApplicationContext(),
Expand Down Expand Up @@ -251,6 +249,13 @@ public boolean onNavigationItemSelected(MenuItem menuItem) {
}
}

/**
* show the file list to the user.
*
* @param onDeviceOnly flag to decide if all files or only the ones on the device should be shown
*/
public abstract void showFiles(boolean onDeviceOnly);

/**
* sets the new/current account and restarts. In case the given account equals the actual/current account the
* call will be ignored.
Expand Down Expand Up @@ -405,11 +410,6 @@ private void repopulateAccountList(Account[] accounts) {
showMenu();
}

/**
* Method that gets called on drawer menu click for 'All Files' and 'Offline Files'.
*/
public abstract void refreshDirectory();

/**
* Updates title bar and home buttons (state and icon).
* <p/>
Expand Down
8 changes: 5 additions & 3 deletions src/com/owncloud/android/ui/activity/FileActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import android.support.v4.app.FragmentTransaction;
import android.widget.Toast;

import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountUtils;
import com.owncloud.android.authentication.AuthenticatorActivity;
Expand Down Expand Up @@ -73,7 +74,7 @@
/**
* Activity with common behaviour for activities handling {@link OCFile}s in ownCloud {@link Account}s .
*/
public class FileActivity extends DrawerActivity
public abstract class FileActivity extends DrawerActivity
implements OnRemoteOperationListener, ComponentsGetter, SslUntrustedCertDialog.OnSslUntrustedCertListener {

public static final String EXTRA_FILE = "com.owncloud.android.ui.activity.FILE";
Expand Down Expand Up @@ -119,8 +120,9 @@ public class FileActivity extends DrawerActivity
private ServiceConnection mDownloadServiceConnection, mUploadServiceConnection = null;

@Override
public void refreshDirectory() {
// implementation to be done in FileDisplayActivity
public void showFiles(boolean onDeviceOnly) {
// must be specialized in subclasses
MainApp.showOnlyFilesOnDevice(onDeviceOnly);
}

/**
Expand Down
10 changes: 8 additions & 2 deletions src/com/owncloud/android/ui/activity/FileDisplayActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,11 @@ protected void onCreate(Bundle savedInstanceState) {
setupToolbar();

// setup drawer
setupDrawer(R.id.nav_all_files);
if(MainApp.getOnlyOnDevice()) {
setupDrawer(R.id.nav_on_device);
} else {
setupDrawer(R.id.nav_all_files);
}

mDualPane = getResources().getBoolean(R.bool.large_land_layout);
mLeftFragmentContainer = findViewById(R.id.left_fragment_container);
Expand Down Expand Up @@ -1795,7 +1799,9 @@ public void allFilesOption() {
browseToRoot();
}

public void refreshDirectory() {
@Override
public void showFiles(boolean onDeviceOnly) {
super.showFiles(onDeviceOnly);
getListOfFilesFragment().refreshDirectory();
}
}
9 changes: 8 additions & 1 deletion src/com/owncloud/android/ui/activity/UploadListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import android.os.Bundle;
import android.os.IBinder;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.GravityCompat;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
Expand Down Expand Up @@ -71,6 +70,14 @@ public class UploadListActivity extends FileActivity implements UploadListFragme

private UploadMessagesReceiver mUploadMessagesReceiver;

@Override
public void showFiles(boolean onDeviceOnly) {
super.showFiles(onDeviceOnly);
Intent i = new Intent(getApplicationContext(), FileDisplayActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down
5 changes: 0 additions & 5 deletions src/com/owncloud/android/ui/preview/PreviewImageActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,4 @@ private boolean isHoneycombOrHigher() {
}
return false;
}

@Override
public void refreshDirectory() {
backToDisplayActivity();
}
}

0 comments on commit c405859

Please sign in to comment.