Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
11 changes: 11 additions & 0 deletions res/menu/file_select_all.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/actionbar_select_all"
android:icon="@android:drawable/checkbox_off_background"
android:orderInCategory="1"
android:showAsAction="always"
android:title="actionbar_select_all"/>


</menu>
44 changes: 40 additions & 4 deletions src/com/owncloud/android/ui/activity/UploadFilesActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.ActionBar.OnNavigationListener;
import com.actionbarsherlock.internal.view.menu.ActionMenuItemView;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuInflater;
import com.actionbarsherlock.view.MenuItem;
import com.owncloud.android.R;
import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
Expand Down Expand Up @@ -73,6 +76,8 @@ public class UploadFilesActivity extends FileActivity implements
private static final String WAIT_DIALOG_TAG = "WAIT";
private static final String QUERY_TO_MOVE_DIALOG_TAG = "QUERY_TO_MOVE";

private boolean selectAllToggled = false;
private Menu menu;

@Override
public void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -119,6 +124,7 @@ public void onCreate(Bundle savedInstanceState) {
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
actionBar.setListNavigationCallbacks(mDirectories, this);


// wait dialog
if (mCurrentDialog != null) {
mCurrentDialog.dismiss();
Expand All @@ -127,8 +133,15 @@ public void onCreate(Bundle savedInstanceState) {

Log_OC.d(TAG, "onCreate() end");
}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu items for use in the action bar
MenuInflater inflater = getSherlock().getMenuInflater();
inflater.inflate(R.menu.file_select_all, menu);
this.menu = menu;
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
boolean retval = true;
Expand All @@ -139,12 +152,33 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
break;
}
case R.id.actionbar_select_all:{
if(selectAllToggled){
toggleOffSelectAll();
}else{
toggleOnSelectAll(item);
}
break;
}
default:
retval = super.onOptionsItemSelected(item);
}
return retval;
}

public void toggleOffSelectAll(MenuItem item){
selectAllToggled = false;
item.setIcon(android.R.drawable.checkbox_off_background);
mFileListFragment.deselectAll();
}
public void toggleOffSelectAll(){
MenuItem item = menu.findItem(R.id.actionbar_select_all);
toggleOffSelectAll(item);
}
public void toggleOnSelectAll(MenuItem item){
selectAllToggled = true;
item.setIcon(android.R.drawable.checkbox_on_background);
mFileListFragment.selectAll();
}

@Override
public boolean onNavigationItemSelected(int itemPosition, long itemId) {
Expand Down Expand Up @@ -175,6 +209,7 @@ public void onBackPressed() {
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(false);
}
toggleOffSelectAll();
}


Expand Down Expand Up @@ -242,10 +277,11 @@ public View getDropDownView(int position, View convertView,
* {@inheritDoc}
*/
@Override
public void onDirectoryClick(File directory) {
public void onDirectoryClick(File directory) {
pushDirname(directory);
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
toggleOffSelectAll();
}


Expand Down
22 changes: 21 additions & 1 deletion src/com/owncloud/android/ui/fragment/LocalFileListFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,33 @@ public void onActivityCreated(Bundle savedInstanceState) {
Log_OC.i(TAG, "onActivityCreated() stop");
}

public void selectAll(){
int numberOfFiles = mAdapter.getCount();
for(int i = 0; i < numberOfFiles; i++){
File file = (File) mAdapter.getItem(i);
if (file != null) {
if (!file.isDirectory()) {
/// Click on a file
getListView().setItemChecked(i, true);
// notify the change to the container Activity
mContainerActivity.onFileClick(file);
}
}
}
}

public void deselectAll(){
mAdapter = new LocalFileListAdapter(mContainerActivity.getInitialDirectory(), getActivity());
setListAdapter(mAdapter);
}

/**
* Checks the file clicked over. Browses inside if it is a directory. Notifies the container activity in any case.
*/
@Override
public void onItemClick(AdapterView<?> l, View v, int position, long id) {
File file = (File) mAdapter.getItem(position);
File file = (File) mAdapter.getItem(position);

if (file != null) {
/// Click on a directory
if (file.isDirectory()) {
Expand Down
4 changes: 2 additions & 2 deletions tests/.classpath
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry combineaccessrules="false" kind="src" path="/owncloud-android"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>