Browse Source

Add drawe access from uploads view

masensio 9 years ago
parent
commit
990f16ca47

+ 13 - 4
res/layout/upload_list_layout.xml

@@ -1,6 +1,9 @@
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent" >
+<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
+        android:id="@+id/drawer_layout"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:clickable="true" >
+
 
     <fragment
         android:id="@+id/UploadListFragment"
@@ -12,4 +15,10 @@
         android:layout_marginRight="10dp"
         class="com.owncloud.android.ui.fragment.UploadListFragment" />
 
-</FrameLayout>
+    <include
+        layout="@layout/drawer"
+        android:layout_width="240dp"
+        android:layout_height="match_parent"
+        android:layout_gravity="start"/>
+
+</android.support.v4.widget.DrawerLayout>

+ 28 - 9
src/com/owncloud/android/ui/activity/UploadListActivity.java

@@ -29,6 +29,7 @@ import android.net.Uri;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.os.Parcelable;
+import android.support.v4.view.GravityCompat;
 import android.view.Menu;
 import android.view.MenuInflater;
 import android.view.MenuItem;
@@ -58,8 +59,18 @@ public class UploadListActivity extends FileActivity implements UploadListFragme
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
+
         //Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
         setContentView(R.layout.upload_list_layout);
+
+        // Navigation Drawer
+        initDrawer();
+
+        // enable ActionBar app icon to behave as action to toggle nav drawer
+        getSupportActionBar().setHomeButtonEnabled(true);
+        mDrawerToggle.setDrawerIndicatorEnabled(true);
+        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+
     }
 
     // ////////////////////////////////////////
@@ -127,29 +138,37 @@ public class UploadListActivity extends FileActivity implements UploadListFragme
         showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, file.getAccount(this));
         startActivity(showDetailsIntent);
     }
-    
+
     @Override
     public boolean onOptionsItemSelected(MenuItem item) {
         boolean retval = true;
         switch (item.getItemId()) {
-            case R.id.action_retry_uploads: {
+            case android.R.id.home:
+                if (mDrawerLayout.isDrawerOpen(GravityCompat.START)) {
+                    mDrawerLayout.closeDrawer(GravityCompat.START);
+                } else {
+                    mDrawerLayout.openDrawer(GravityCompat.START);
+                }
+                break;
+            case R.id.action_retry_uploads:
                 Log_OC.d(TAG, "FileUploadService.retry() called by onMenuItemSelected()");
                 FileUploadService.retry(this);
                 break;
-            }
-            case R.id.action_clear_failed_uploads: {
+
+            case R.id.action_clear_failed_uploads:
                 UploadsStorageManager usm = new UploadsStorageManager(getContentResolver());
                 usm.clearFailedUploads();
                 break;
-            }
-            case R.id.action_clear_finished_uploads: {
-                UploadsStorageManager usm = new UploadsStorageManager(getContentResolver());
-                usm.clearFinishedUploads();
+
+            case R.id.action_clear_finished_uploads:
+                UploadsStorageManager storageManager = new UploadsStorageManager(getContentResolver());
+                storageManager.clearFinishedUploads();
                 break;
-            }
+
             default:
                 retval = super.onOptionsItemSelected(item);
         }
+
         return retval;
     }