Browse Source

Merge branch 'master' into develop

David A. Velasco 10 years ago
parent
commit
9953a942ea

+ 2 - 5
AndroidManifest.xml

@@ -18,8 +18,8 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
  -->
 <manifest package="com.owncloud.android"
-    android:versionCode="105007"
-    android:versionName="1.5.7" xmlns:android="http://schemas.android.com/apk/res/android">
+    android:versionCode="10500800"
+    android:versionName="1.5.8" xmlns:android="http://schemas.android.com/apk/res/android">
 
     <uses-permission android:name="android.permission.GET_ACCOUNTS" />
     <uses-permission android:name="android.permission.USE_CREDENTIALS" />
@@ -59,9 +59,6 @@
         </activity>
         <activity android:name=".ui.activity.UploadFilesActivity">
         </activity>
- 		<activity android:name=".ui.activity.InstantUploadActivity">
-        </activity>
-        <activity android:name=".ui.activity.FailedUploadActivity" android:theme="@android:style/Theme.Dialog" android:excludeFromRecents="true"/>
         <activity android:name=".ui.activity.Uploader" >
             <intent-filter>
                 <action android:name="android.intent.action.SEND" >

+ 2 - 2
oc_jb_workaround/AndroidManifest.xml

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.owncloud.android.workaround.accounts"
-    android:versionCode="0100016"
-    android:versionName="1.0.16" >
+    android:versionCode="0100017"
+    android:versionName="1.0.17" >
 
     <uses-sdk
         android:minSdkVersion="16"

+ 1 - 1
owncloud-android-library

@@ -1 +1 @@
-Subproject commit e72fec72a3138d4e714a9db37eb87cb76a958bdf
+Subproject commit 5ebf81e26ed0827359aa468fb813353656b7cf27

BIN
res/drawable-hdpi/ic_favorite.png


BIN
res/drawable-mdpi/ic_favorite.png


BIN
res/drawable-xhdpi/ic_favorite.png


BIN
res/drawable/downloading_file_indicator.png


BIN
res/drawable/ic_favorite.png


BIN
res/drawable/local_file_indicator.png


BIN
res/drawable/uploading_file_indicator.png


+ 0 - 104
res/layout/failed_upload_files.xml

@@ -1,104 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- 
-  ownCloud Android client application
-
-  Copyright (C) 2012  Bartek Przybylski
-  Copyright (C) 2012-2013 ownCloud Inc.
-  
-  This program is free software: you can redistribute it and/or modify
-  it under the terms of the GNU General Public License version 2,
-  as published by the Free Software Foundation.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent"
-    android:background="@color/background_color"
-    android:orientation="vertical"
-    android:id="@+id/failed_files_list_view">
-
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_gravity="right"
-        android:orientation="horizontal" >
-
-    </LinearLayout>
-
-    <LinearLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:orientation="vertical" >
-
-        <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content" >
-
-            <TextView
-                android:id="@+id/failed_upload_headline_textview"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_weight="0.93"
-                android:hint="@string/failed_upload_headline_hint"
-                android:text="@string/failed_upload_headline_text" />
-
-        </LinearLayout>
-
-        <LinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_gravity="bottom|right" >
-
-            <CheckBox
-                android:id="@+id/failed_upload_headline_cb"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="@string/failed_upload_all_cb"
-                android:textSize="8sp" />
-
-            <Button
-                android:id="@+id/failed_upload_retry_all_btn"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:minHeight="30dp"
-                android:minWidth="90dp"
-                android:text="@string/failed_upload_headline_retryall_btn"
-                android:textSize="8sp" />
-
-            <Button
-                android:id="@+id/failed_upload_delete_all_btn"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:minHeight="30dp"
-                android:minWidth="90dp"
-                android:text="@string/failed_upload_headline_delete_all_btn"
-                android:textSize="8sp" />
-
-        </LinearLayout>
-
-    </LinearLayout>
- 
-      <ScrollView
-          android:id="@+id/failedUploadScrollView"
-          android:layout_width="match_parent"
-          android:layout_height="match_parent"
-          android:overScrollMode="ifContentScrolls" >
-
-         <LinearLayout
-             android:id="@+id/failed_upload_scrollviewlayout"
-             android:layout_width="match_parent"
-             android:layout_height="wrap_content"
-             android:orientation="vertical">
-
-           
-         </LinearLayout>
-     </ScrollView>
-
-</LinearLayout>

+ 0 - 19
res/layout/failed_upload_message_view.xml

@@ -1,19 +0,0 @@
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:id="@+id/failed_upload_message_view"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent"
-    android:background="@color/background_color"
-    android:orientation="vertical" >
-
-   <TextView android:id="@+id/faild_upload_message" 
-       android:layout_width="match_parent"
-       android:layout_height="wrap_content"
-       android:minWidth="100dp"/>
-   
-   <Button
-    android:id="@+id/failed_uploadactivity_close_button"
-    android:layout_width="fill_parent"
-    android:layout_height="wrap_content"
-    android:text="Dismiss" />
-
-</LinearLayout>

+ 17 - 14
res/layout/list_item.xml

@@ -25,34 +25,35 @@
     android:layout_height="56dp">
 
     <FrameLayout
-        android:layout_width="wrap_content"
+        android:layout_width="56dp"
         android:layout_height="56dp"
         android:focusable="false"
         android:focusableInTouchMode="false">
-        
+
         <ImageView
             android:id="@+id/imageView2"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:src="@drawable/local_file_indicator"/>
+            android:layout_width="32dp"
+            android:layout_height="32dp"
+            android:layout_gravity="center_vertical"
+            android:layout_marginLeft="22dp"
+            android:src="@drawable/local_file_indicator" />
 
         <ImageView
             android:id="@+id/imageView1"
             android:layout_width="32dp"
             android:layout_height="32dp"
-            android:layout_gravity="center_vertical|center"
-            android:layout_margin="4dp"
+            android:layout_gravity="center_vertical"
+            android:layout_marginLeft="9dp"
             android:src="@drawable/ic_menu_archive" />
 
         <ImageView
             android:id="@+id/imageView3"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_gravity="bottom"
-            android:layout_weight=".1"
-            android:maxHeight="15dip"
+            android:layout_gravity="bottom|right"
+            android:layout_marginBottom="10dp"
+            android:layout_marginRight="2dp"
             android:src="@drawable/ic_favorite" />
-        
     </FrameLayout>
 
     <LinearLayout
@@ -88,6 +89,7 @@
                 android:layout_height="wrap_content"
                 android:text="TextView"
                 android:layout_weight=".5"
+                android:textColor="@color/list_item_lastmod_and_filesize_text"
                 android:textSize="12dip"/>
 
             <TextView
@@ -96,6 +98,7 @@
                 android:layout_height="wrap_content"
                 android:gravity="right"
                 android:text="TextView"
+                android:textColor="@color/list_item_lastmod_and_filesize_text"
                 android:layout_weight=".5"
                 android:textSize="12dip"/>
 
@@ -104,7 +107,7 @@
     </LinearLayout>
 
     <LinearLayout
-        android:layout_width="wrap_content"
+        android:layout_width="25dp"
         android:layout_height="match_parent"
         android:gravity="center_vertical"
         android:orientation="vertical">
@@ -113,7 +116,7 @@
         android:id="@+id/sharedIcon"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_gravity="center_vertical"
+        android:layout_gravity="center"
         android:layout_marginLeft="4dp"
         android:layout_marginBottom="4dp"
         android:layout_marginRight="4dp"
@@ -123,7 +126,7 @@
         android:id="@+id/sharedWithMeIcon"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
-        android:layout_gravity="center_vertical"
+        android:layout_gravity="center"
         android:layout_marginLeft="4dp"
         android:layout_marginRight="4dp"
         android:layout_marginTop="4dp"

+ 3 - 3
res/menu/file_actions_menu.xml

@@ -21,14 +21,14 @@
     
 	<item 	android:id="@+id/action_share_file"				android:title="@string/action_share_file"			android:icon="@android:drawable/ic_menu_share"					android:orderInCategory="1" />
    	<item 	android:id="@+id/action_unshare_file"		    android:title="@string/action_unshare_file"			android:icon="@android:drawable/ic_menu_share"					android:orderInCategory="1" />
-    <item 	android:id="@+id/action_open_file_with"			android:title="@string/actionbar_open_with"			android:icon="@android:drawable/ic_menu_edit"					android:orderInCategory="1" /> 
+    <item 	android:id="@+id/action_open_file_with"			android:title="@string/actionbar_open_with"			android:icon="@android:drawable/ic_menu_set_as"					android:orderInCategory="1" /> 
 	<item 	android:id="@+id/action_download_file" 			android:title="@string/filedetails_download"		android:icon="@drawable/ic_action_download"						android:orderInCategory="1" />
     <item 	android:id="@+id/action_sync_file"				android:title="@string/filedetails_sync_file"		android:icon="@drawable/ic_action_refresh"						android:orderInCategory="1" />
 	<item 	android:id="@+id/action_cancel_download"		android:title="@string/common_cancel_download"	 	android:icon="@android:drawable/ic_menu_close_clear_cancel"		android:orderInCategory="1" />
 	<item 	android:id="@+id/action_cancel_upload" 			android:title="@string/common_cancel_upload"		android:icon="@android:drawable/ic_menu_close_clear_cancel"		android:orderInCategory="1" />
-	<item 	android:id="@+id/action_rename_file"			android:title="@string/common_rename"				android:icon="@android:drawable/ic_menu_set_as"					android:orderInCategory="1" />
+	<item 	android:id="@+id/action_rename_file"			android:title="@string/common_rename"				android:icon="@android:drawable/ic_menu_edit"					android:orderInCategory="1" />
     <item 	android:id="@+id/action_remove_file"			android:title="@string/common_remove"				android:icon="@android:drawable/ic_menu_delete"					android:orderInCategory="1" />
-    <item 	android:id="@+id/action_send_file"				android:title="@string/actionbar_send_file"			android:icon="@android:drawable/ic_menu_info_details"			android:orderInCategory="1" />
+    <item 	android:id="@+id/action_send_file"				android:title="@string/actionbar_send_file"			android:icon="@android:drawable/ic_menu_set_as"					android:orderInCategory="1" />
     <item 	android:id="@+id/action_see_details"			android:title="@string/actionbar_see_details"		android:icon="@android:drawable/ic_menu_info_details"			android:orderInCategory="1" />
     
 </menu>

+ 1 - 0
res/values/colors.xml

@@ -21,5 +21,6 @@
     
     <color name="filelist_icon_backgorund">#DDDDDD</color>
     <color name="owncloud_blue_bright">#00ddff</color>
+    <color name="list_item_lastmod_and_filesize_text">#989898</color>
     
 </resources>

+ 0 - 11
res/values/strings.xml

@@ -250,17 +250,6 @@
     <string name="preview_image_error_unknown_format">This image cannot be shown</string>
     
     <string name="error__upload__local_file_not_copied">%1$s could not be copied to %2$s local folder</string>
-    <string name="actionbar_failed_instant_upload">Failed InstantUpload</string>
-    <string name="failed_upload_headline_text">Failed instant uploads</string>
-    <string name="failed_upload_headline_hint">Summary of all failed instant uploads</string>
-    <string name="failed_upload_all_cb">select all</string>
-    <string name="failed_upload_headline_retryall_btn">retry all selected</string>
-    <string name="failed_upload_headline_delete_all_btn">delete all  selected from uploadqueue</string>
-    <string name="failed_upload_retry_text">retry to upload the image: </string>
-    <string name="failed_upload_load_more_images">Load more Pictures</string>
-    <string name="failed_upload_retry_do_nothing_text">do nothing you are not online for instant upload</string>
-	<string name="failed_upload_failure_text">Failure Message: </string>
-	<string name="failed_upload_quota_exceeded_text">Please check your server configuration,maybe your quota is exceeded.</string>
 
 	<string name="share_link_no_support_share_api">Sorry, sharing is not enabled on your server. Please contact your
 		administrator.</string>

+ 64 - 64
src/com/owncloud/android/files/services/FileUploader.java

@@ -28,36 +28,6 @@ import java.util.Vector;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
-import com.owncloud.android.R;
-import com.owncloud.android.authentication.AuthenticatorActivity;
-import com.owncloud.android.datamodel.FileDataStorageManager;
-import com.owncloud.android.datamodel.OCFile;
-import com.owncloud.android.db.DbHandler;
-import com.owncloud.android.notifications.NotificationBuilderWithProgressBar;
-import com.owncloud.android.notifications.NotificationDelayer;
-import com.owncloud.android.operations.CreateFolderOperation;
-import com.owncloud.android.lib.resources.files.RemoteFile;
-import com.owncloud.android.lib.common.operations.RemoteOperation;
-import com.owncloud.android.lib.common.operations.RemoteOperationResult;
-import com.owncloud.android.operations.UploadFileOperation;
-import com.owncloud.android.operations.common.SyncOperation;
-import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
-import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;
-import com.owncloud.android.lib.resources.files.ReadRemoteFileOperation;
-import com.owncloud.android.lib.resources.files.FileUtils;
-import com.owncloud.android.lib.resources.status.OwnCloudVersion;
-import com.owncloud.android.lib.common.accounts.AccountUtils.Constants;
-import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
-import com.owncloud.android.lib.common.OwnCloudAccount;
-import com.owncloud.android.lib.common.OwnCloudClient;
-import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
-import com.owncloud.android.ui.activity.FailedUploadActivity;
-import com.owncloud.android.ui.activity.FileActivity;
-import com.owncloud.android.ui.activity.FileDisplayActivity;
-import com.owncloud.android.ui.activity.InstantUploadActivity;
-import com.owncloud.android.utils.ErrorMessageAdapter;
-import com.owncloud.android.utils.Log_OC;
-
 import android.accounts.Account;
 import android.accounts.AccountManager;
 import android.accounts.AccountsException;
@@ -75,6 +45,34 @@ import android.os.Process;
 import android.support.v4.app.NotificationCompat;
 import android.webkit.MimeTypeMap;
 
+import com.owncloud.android.R;
+import com.owncloud.android.authentication.AuthenticatorActivity;
+import com.owncloud.android.datamodel.FileDataStorageManager;
+import com.owncloud.android.datamodel.OCFile;
+import com.owncloud.android.db.DbHandler;
+import com.owncloud.android.lib.common.OwnCloudAccount;
+import com.owncloud.android.lib.common.OwnCloudClient;
+import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
+import com.owncloud.android.lib.common.accounts.AccountUtils.Constants;
+import com.owncloud.android.lib.common.network.OnDatatransferProgressListener;
+import com.owncloud.android.lib.common.operations.RemoteOperation;
+import com.owncloud.android.lib.common.operations.RemoteOperationResult;
+import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
+import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;
+import com.owncloud.android.lib.resources.files.FileUtils;
+import com.owncloud.android.lib.resources.files.ReadRemoteFileOperation;
+import com.owncloud.android.lib.resources.files.RemoteFile;
+import com.owncloud.android.lib.resources.status.OwnCloudVersion;
+import com.owncloud.android.notifications.NotificationBuilderWithProgressBar;
+import com.owncloud.android.notifications.NotificationDelayer;
+import com.owncloud.android.operations.CreateFolderOperation;
+import com.owncloud.android.operations.UploadFileOperation;
+import com.owncloud.android.operations.common.SyncOperation;
+import com.owncloud.android.ui.activity.FileActivity;
+import com.owncloud.android.ui.activity.FileDisplayActivity;
+import com.owncloud.android.utils.ErrorMessageAdapter;
+import com.owncloud.android.utils.Log_OC;
+
 
 
 public class FileUploader extends Service implements OnDatatransferProgressListener {
@@ -726,7 +724,8 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
      * @param uploadResult Result of the upload operation.
      * @param upload Finished upload operation
      */
-    private void notifyUploadResult(RemoteOperationResult uploadResult, UploadFileOperation upload) {
+    private void notifyUploadResult(
+            RemoteOperationResult uploadResult, UploadFileOperation upload) {
         Log_OC.d(TAG, "NotifyUploadResult with resultCode: " + uploadResult.getCode());
         // / cancelled operation or success -> silent removal of progress notification
         mNotificationManager.cancel(R.string.uploader_upload_in_progress_ticker);
@@ -736,8 +735,6 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
             int tickerId = (uploadResult.isSuccess()) ? R.string.uploader_upload_succeeded_ticker : 
                 R.string.uploader_upload_failed_ticker;
             
-            NotificationCompat.Builder resultBuilder = new NotificationCompat.Builder(this);
-            
             String content = null;
 
             // check credentials error
@@ -748,57 +745,60 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
             tickerId = (needsToUpdateCredentials) ? 
                     R.string.uploader_upload_failed_credentials_error : tickerId;
 
-            resultBuilder
-            .setSmallIcon(R.drawable.notification_icon)
+            mNotificationBuilder
             .setTicker(getString(tickerId))
             .setContentTitle(getString(tickerId))
-            .setAutoCancel(true);
+            .setAutoCancel(true)
+            .setOngoing(false)
+            .setProgress(0, 0, false);
             
-            content =  ErrorMessageAdapter.getErrorCauseMessage(uploadResult, upload, getResources());
+            content =  ErrorMessageAdapter.getErrorCauseMessage(
+                    uploadResult, upload, getResources()
+            );
             
             if (needsToUpdateCredentials) {
                 // let the user update credentials with one click
                 Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
-                updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, upload.getAccount());
-                updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACTION, AuthenticatorActivity.ACTION_UPDATE_EXPIRED_TOKEN);
+                updateAccountCredentials.putExtra(
+                        AuthenticatorActivity.EXTRA_ACCOUNT, upload.getAccount()
+                );
+                updateAccountCredentials.putExtra(
+                        AuthenticatorActivity.EXTRA_ACTION, 
+                        AuthenticatorActivity.ACTION_UPDATE_EXPIRED_TOKEN
+                );
                 updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                 updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
                 updateAccountCredentials.addFlags(Intent.FLAG_FROM_BACKGROUND);
-                resultBuilder.setContentIntent(PendingIntent.getActivity(
-                    this, (int) System.currentTimeMillis(), updateAccountCredentials, PendingIntent.FLAG_ONE_SHOT
+                mNotificationBuilder.setContentIntent(PendingIntent.getActivity(
+                    this, 
+                    (int) System.currentTimeMillis(), 
+                    updateAccountCredentials, 
+                    PendingIntent.FLAG_ONE_SHOT
                 ));
                 
-                mUploadClient = null;   // grant that future retries on the same account will get the fresh credentials
+                mUploadClient = null;   
+                    // grant that future retries on the same account will get the fresh credentials
             } else {
-                // TODO put something smart in the contentIntent below
-
-                // we add only for instant-uploads the InstantUploadActivity and the
-                // db entry
-                Intent detailUploadIntent = null;
-                if (upload.isInstant() && InstantUploadActivity.IS_ENABLED) {
-                    detailUploadIntent = new Intent(this, InstantUploadActivity.class);
-                    detailUploadIntent.putExtra(FileUploader.KEY_ACCOUNT, upload.getAccount());
-                } else {
-                    detailUploadIntent = new Intent(this, FailedUploadActivity.class);
-                    detailUploadIntent.putExtra(FailedUploadActivity.MESSAGE, content);
-                }
-                resultBuilder
-                    .setContentIntent(PendingIntent.getActivity(
-                        this, (int) System.currentTimeMillis(), detailUploadIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT
-                    ))
-                    .setContentText(content);
+                mNotificationBuilder.setContentText(content);
     
                 if (upload.isInstant()) {
                     DbHandler db = null;
                     try {
                         db = new DbHandler(this.getBaseContext());
-                        String message = uploadResult.getLogMessage() + " errorCode: " + uploadResult.getCode();
+                        String message = uploadResult.getLogMessage() + " errorCode: " +
+                                uploadResult.getCode();
                         Log_OC.e(TAG, message + " Http-Code: " + uploadResult.getHttpCode());
                         if (uploadResult.getCode() == ResultCode.QUOTA_EXCEEDED) {
                             message = getString(R.string.failed_upload_quota_exceeded_text);
-                            if (db.updateFileState(upload.getOriginalStoragePath(), DbHandler.UPLOAD_STATUS_UPLOAD_FAILED,
+                            if (db.updateFileState(
+                                    upload.getOriginalStoragePath(), 
+                                    DbHandler.UPLOAD_STATUS_UPLOAD_FAILED,
                                     message) == 0) {
-                                db.putFileForLater(upload.getOriginalStoragePath(), upload.getAccount().name, message);
+                                db.putFileForLater(
+                                        upload.getOriginalStoragePath(), 
+                                        upload.getAccount().name, 
+                                        message
+                                );
                             }
                         }
                     } finally {
@@ -809,8 +809,8 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
                 }
             }
             
-            resultBuilder.setContentText(content);
-            mNotificationManager.notify(tickerId, resultBuilder.build());
+            mNotificationBuilder.setContentText(content);
+            mNotificationManager.notify(tickerId, mNotificationBuilder.build());
             
             if (uploadResult.isSuccess()) {
                 

+ 0 - 1
src/com/owncloud/android/providers/FileContentProvider.java

@@ -420,7 +420,6 @@ public class FileContentProvider extends ContentProvider {
         // DB case_sensitive
         db.execSQL("PRAGMA case_sensitive_like = true");
         Cursor c = sqlQuery.query(db, projection, selection, selectionArgs, null, null, order);
-        Log_OC.d(TAG, "setting notification URI: " + uri);
         c.setNotificationUri(getContext().getContentResolver(), uri);
         return c;
     }

+ 0 - 57
src/com/owncloud/android/ui/activity/FailedUploadActivity.java

@@ -1,57 +0,0 @@
-/* ownCloud Android client application
- *   Copyright (C) 2012-2013 ownCloud Inc.
- *
- *   This program is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2,
- *   as published by the Free Software Foundation.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-package com.owncloud.android.ui.activity;
-
-import com.owncloud.android.R;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.Button;
-import android.widget.TextView;
-
-
-/**
- * This Activity is used to display a detail message for failed uploads
- * 
- * The entry-point for this activity is the 'Failed upload Notification"
- * 
- * @author andomaex / Matthias Baumann
- */
-public class FailedUploadActivity extends Activity {
-
-    public static final String MESSAGE = "message";
-
-    @Override
-    public void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.failed_upload_message_view);
-        String message = getIntent().getStringExtra(MESSAGE);
-        TextView textView = (TextView) findViewById(R.id.faild_upload_message);
-        textView.setText(message);
-        Button closeBtn = (Button) findViewById(R.id.failed_uploadactivity_close_button);
-        
-        closeBtn.setOnClickListener(new OnClickListener() {
-            @Override
-            public void onClick(View v) {
-                finish();
-            }
-        });
-    }
-}

+ 3 - 19
src/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -48,7 +48,6 @@ import android.provider.MediaStore;
 import android.support.v4.app.Fragment;
 import android.support.v4.app.FragmentManager;
 import android.support.v4.app.FragmentTransaction;
-//import android.support.v4.content.LocalBroadcastManager;
 import android.util.Log;
 import android.view.View;
 import android.view.ViewGroup;
@@ -66,11 +65,9 @@ import com.owncloud.android.MainApp;
 import com.owncloud.android.R;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.files.services.FileDownloader;
-import com.owncloud.android.files.services.FileUploader;
 import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
+import com.owncloud.android.files.services.FileUploader;
 import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
-import com.owncloud.android.operations.CreateFolderOperation;
-
 import com.owncloud.android.lib.common.OwnCloudAccount;
 import com.owncloud.android.lib.common.OwnCloudClient;
 import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
@@ -80,6 +77,7 @@ import com.owncloud.android.lib.common.network.CertificateCombinedException;
 import com.owncloud.android.lib.common.operations.RemoteOperation;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult;
 import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
+import com.owncloud.android.operations.CreateFolderOperation;
 import com.owncloud.android.operations.CreateShareOperation;
 import com.owncloud.android.operations.RemoveFileOperation;
 import com.owncloud.android.operations.RenameFileOperation;
@@ -739,23 +737,13 @@ FileFragment.ContainerActivity, OnNavigationListener, OnSslUntrustedCertListener
         }
         case DIALOG_CHOOSE_UPLOAD_SOURCE: {
 
-            String[] items = null;
 
             String[] allTheItems = { getString(R.string.actionbar_upload_files),
-                    getString(R.string.actionbar_upload_from_apps),
-                    getString(R.string.actionbar_failed_instant_upload) };
-
-            String[] commonItems = { getString(R.string.actionbar_upload_files),
                     getString(R.string.actionbar_upload_from_apps) };
 
-            if (InstantUploadActivity.IS_ENABLED)
-                items = allTheItems;
-            else 
-                items = commonItems;
-
             builder = new AlertDialog.Builder(this);
             builder.setTitle(R.string.actionbar_upload);
-            builder.setItems(items, new DialogInterface.OnClickListener() {
+            builder.setItems(allTheItems, new DialogInterface.OnClickListener() {
                 public void onClick(DialogInterface dialog, int item) {
                     if (item == 0) {
                         // if (!mDualPane) {
@@ -771,10 +759,6 @@ FileFragment.ContainerActivity, OnNavigationListener, OnSslUntrustedCertListener
                         action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE);
                         startActivityForResult(Intent.createChooser(action, getString(R.string.upload_chooser_title)),
                                 ACTION_SELECT_CONTENT_FROM_APPS);
-                    } else if (item == 2 && InstantUploadActivity.IS_ENABLED) {
-                        Intent action = new Intent(FileDisplayActivity.this, InstantUploadActivity.class);
-                        action.putExtra(FileUploader.KEY_ACCOUNT, FileDisplayActivity.this.getAccount());
-                        startActivity(action);
                     }
                 }
             });

+ 0 - 476
src/com/owncloud/android/ui/activity/InstantUploadActivity.java

@@ -1,476 +0,0 @@
-/* ownCloud Android client application
- *   Copyright (C) 2012-2013 ownCloud Inc.
- *
- *   This program is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2,
- *   as published by the Free Software Foundation.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package com.owncloud.android.ui.activity;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.owncloud.android.R;
-import com.owncloud.android.authentication.AccountUtils;
-import com.owncloud.android.db.DbHandler;
-import com.owncloud.android.files.InstantUploadBroadcastReceiver;
-import com.owncloud.android.files.services.FileUploader;
-import com.owncloud.android.utils.FileStorageUtils;
-import com.owncloud.android.utils.Log_OC;
-
-import android.accounts.Account;
-import android.app.Activity;
-import android.content.Intent;
-import android.database.Cursor;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.os.Bundle;
-import android.util.SparseArray;
-import android.view.Gravity;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.View.OnLongClickListener;
-import android.view.ViewGroup;
-import android.widget.Button;
-import android.widget.CheckBox;
-import android.widget.CompoundButton;
-import android.widget.CompoundButton.OnCheckedChangeListener;
-import android.widget.ImageButton;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import android.widget.Toast;
-
-
-/**
- * This Activity is used to display a list with images they could not be
- * uploaded instantly. The images can be selected for delete or for a try again
- * upload
- * 
- * The entry-point for this activity is the 'Failed upload Notification" and a
- * sub-menu underneath the 'Upload' menu-item
- * 
- * @author andomaex / Matthias Baumann
- */
-public class InstantUploadActivity extends Activity {
-
-    private static final String LOG_TAG = InstantUploadActivity.class.getSimpleName();
-    private LinearLayout listView;
-    private static final String retry_chexbox_tag = "retry_chexbox_tag";
-    public static final boolean IS_ENABLED = false;
-    private static int MAX_LOAD_IMAGES = 5;
-    private int lastLoadImageIdx = 0;
-
-    private SparseArray<String> fileList = null;
-    CheckBox failed_upload_all_cb;
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.failed_upload_files);
-
-        Button deleteAllBtn = (Button) findViewById(R.id.failed_upload_delete_all_btn);
-        deleteAllBtn.setOnClickListener(getDeleteListner());
-        Button retryAllBtn = (Button) findViewById(R.id.failed_upload_retry_all_btn);
-        retryAllBtn.setOnClickListener(getRetryListner());
-        this.failed_upload_all_cb = (CheckBox) findViewById(R.id.failed_upload_headline_cb);
-        failed_upload_all_cb.setOnCheckedChangeListener(getCheckAllListener());
-        listView = (LinearLayout) findViewById(R.id.failed_upload_scrollviewlayout);
-        
-        loadListView(true);
-
-    }
-
-    /**
-     * init the listview with ImageButtons, checkboxes and filename for every
-     * Image that was not successfully uploaded
-     * 
-     * this method is call at Activity creation and on delete one ore more
-     * list-entry an on retry the upload by clicking the ImageButton or by click
-     * to the 'retry all' button
-     * 
-     */
-    private void loadListView(boolean reset) {
-        DbHandler db = new DbHandler(getApplicationContext());
-        Cursor c = db.getFailedFiles();
-
-        if (reset) {
-            fileList = new SparseArray<String>();
-            listView.removeAllViews();
-            lastLoadImageIdx = 0;
-        }
-        if (c != null) {
-            try {
-                c.moveToPosition(lastLoadImageIdx);
-
-                while (c.moveToNext()) {
-
-                    lastLoadImageIdx++;
-                    String imp_path = c.getString(1);
-                    String message = c.getString(4);
-                    fileList.put(lastLoadImageIdx, imp_path);
-                    LinearLayout rowLayout = getHorizontalLinearLayout(lastLoadImageIdx);
-                    rowLayout.addView(getFileCheckbox(lastLoadImageIdx));
-                    rowLayout.addView(getImageButton(imp_path, lastLoadImageIdx));
-                    rowLayout.addView(getFileButton(imp_path, message, lastLoadImageIdx));
-                    listView.addView(rowLayout);
-                    Log_OC.d(LOG_TAG, imp_path + " on idx: " + lastLoadImageIdx);
-                    if (lastLoadImageIdx % MAX_LOAD_IMAGES == 0) {
-                        break;
-                    }
-                }
-                if (lastLoadImageIdx > 0) {
-                    addLoadMoreButton(listView);
-                }
-            } finally {
-                db.close();
-            }
-        }
-    }
-
-    private void addLoadMoreButton(LinearLayout listView) {
-        if (listView != null) {
-            Button loadmoreBtn = null;
-            View oldButton = listView.findViewById(42);
-            if (oldButton != null) {
-                // remove existing button
-                listView.removeView(oldButton);
-                // to add the button at the end
-                loadmoreBtn = (Button) oldButton;
-            } else {
-                // create a new button to add to the scoll view
-                loadmoreBtn = new Button(this);
-                loadmoreBtn.setId(42);
-                loadmoreBtn.setText(getString(R.string.failed_upload_load_more_images));
-                loadmoreBtn.setBackgroundResource(R.color.background_color);
-                loadmoreBtn.setTextSize(12);
-                loadmoreBtn.setOnClickListener(new OnClickListener() {
-                    @Override
-                    public void onClick(View v) {
-                        loadListView(false);
-                    }
-
-                });
-            }
-            listView.addView(loadmoreBtn);
-        }
-    }
-
-    /**
-     * provide a list of CheckBox instances, looked up from parent listview this
-     * list ist used to select/deselect all checkboxes at the list
-     * 
-     * @return List<CheckBox>
-     */
-    private List<CheckBox> getCheckboxList() {
-        List<CheckBox> list = new ArrayList<CheckBox>();
-        for (int i = 0; i < listView.getChildCount(); i++) {
-            Log_OC.d(LOG_TAG, "ListView has Childs: " + listView.getChildCount());
-            View childView = listView.getChildAt(i);
-            if (childView != null && childView instanceof ViewGroup) {
-                View checkboxView = getChildViews((ViewGroup) childView);
-                if (checkboxView != null && checkboxView instanceof CheckBox) {
-                    Log_OC.d(LOG_TAG, "found Child: " + checkboxView.getId() + " " + checkboxView.getClass());
-                    list.add((CheckBox) checkboxView);
-                }
-            }
-        }
-        return list;
-    }
-
-    /**
-     * recursive called method, used from getCheckboxList method
-     * 
-     * @param View
-     * @return View
-     */
-    private View getChildViews(ViewGroup view) {
-        if (view != null) {
-            for (int i = 0; i < view.getChildCount(); i++) {
-                View cb = view.getChildAt(i);
-                if (cb != null && cb instanceof ViewGroup) {
-                    return getChildViews((ViewGroup) cb);
-                } else if (cb instanceof CheckBox) {
-                    return cb;
-                }
-            }
-        }
-        return null;
-    }
-
-    /**
-     * create a new OnCheckedChangeListener for the 'check all' checkbox *
-     * 
-     * @return OnCheckedChangeListener to select all checkboxes at the list
-     */
-    private OnCheckedChangeListener getCheckAllListener() {
-        return new OnCheckedChangeListener() {
-            @Override
-            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
-                List<CheckBox> list = getCheckboxList();
-                for (CheckBox checkbox : list) {
-                    ((CheckBox) checkbox).setChecked(isChecked);
-                }
-            }
-
-        };
-    }
-
-    /**
-     * Button click Listener for the retry button at the headline
-     * 
-     * @return a Listener to perform a retry for all selected images
-     */
-    private OnClickListener getRetryListner() {
-        return new OnClickListener() {
-
-            @Override
-            public void onClick(View v) {
-
-                try {
-
-                    List<CheckBox> list = getCheckboxList();
-                    for (CheckBox checkbox : list) {
-                        boolean to_retry = checkbox.isChecked();
-
-                        Log_OC.d(LOG_TAG, "Checkbox for " + checkbox.getId() + " was checked: " + to_retry);
-                        String img_path = fileList.get(checkbox.getId());
-                        if (to_retry) {
-
-                            final String msg = "Image-Path " + checkbox.getId() + " was checked: " + img_path;
-                            Log_OC.d(LOG_TAG, msg);
-                            startUpload(img_path);
-                        }
-
-                    }
-                } finally {
-                    // refresh the List
-                    listView.removeAllViews();
-                    loadListView(true);
-                    if (failed_upload_all_cb != null) {
-                        failed_upload_all_cb.setChecked(false);
-                    }
-                }
-
-            }
-        };
-    }
-
-    /**
-     * Button click Listener for the delete button at the headline
-     * 
-     * @return a Listener to perform a delete for all selected images
-     */
-    private OnClickListener getDeleteListner() {
-
-        return new OnClickListener() {
-
-            @Override
-            public void onClick(View v) {
-
-                final DbHandler dbh = new DbHandler(getApplicationContext());
-                try {
-                    List<CheckBox> list = getCheckboxList();
-                    for (CheckBox checkbox : list) {
-                        boolean to_be_delete = checkbox.isChecked();
-
-                        Log_OC.d(LOG_TAG, "Checkbox for " + checkbox.getId() + " was checked: " + to_be_delete);
-                        String img_path = fileList.get(checkbox.getId());
-                        Log_OC.d(LOG_TAG, "Image-Path " + checkbox.getId() + " was checked: " + img_path);
-                        if (to_be_delete) {
-                            boolean deleted = dbh.removeIUPendingFile(img_path);
-                            Log_OC.d(LOG_TAG, "removing " + checkbox.getId() + " was : " + deleted);
-
-                        }
-
-                    }
-                } finally {
-                    dbh.close();
-                    // refresh the List
-                    listView.removeAllViews();
-                    loadListView(true);
-                    if (failed_upload_all_cb != null) {
-                        failed_upload_all_cb.setChecked(false);
-                    }
-                }
-
-            }
-        };
-    }
-
-    private LinearLayout getHorizontalLinearLayout(int id) {
-        LinearLayout linearLayout = new LinearLayout(getApplicationContext());
-        linearLayout.setId(id);
-        linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
-                LinearLayout.LayoutParams.MATCH_PARENT));
-        linearLayout.setGravity(Gravity.RIGHT);
-        linearLayout.setOrientation(LinearLayout.HORIZONTAL);
-        return linearLayout;
-    }
-
-    private LinearLayout getVerticalLinearLayout() {
-        LinearLayout linearLayout = new LinearLayout(getApplicationContext());
-        linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
-                LinearLayout.LayoutParams.MATCH_PARENT));
-        linearLayout.setGravity(Gravity.TOP);
-        linearLayout.setOrientation(LinearLayout.VERTICAL);
-        return linearLayout;
-    }
-
-    private View getFileButton(final String img_path, String message, int id) {
-
-        TextView failureTextView = new TextView(this);
-        failureTextView.setText(getString(R.string.failed_upload_failure_text) + message);
-        failureTextView.setBackgroundResource(R.color.background_color);
-        failureTextView.setTextSize(8);
-        failureTextView.setOnLongClickListener(getOnLongClickListener(message));
-        failureTextView.setPadding(5, 5, 5, 10);
-        TextView retryButton = new TextView(this);
-        retryButton.setId(id);
-        retryButton.setText(img_path);
-        retryButton.setBackgroundResource(R.color.background_color);
-        retryButton.setTextSize(8);
-        retryButton.setOnClickListener(getImageButtonOnClickListener(img_path));
-        retryButton.setOnLongClickListener(getOnLongClickListener(message));
-        retryButton.setPadding(5, 5, 5, 10);
-        LinearLayout verticalLayout = getVerticalLinearLayout();
-        verticalLayout.addView(retryButton);
-        verticalLayout.addView(failureTextView);
-
-        return verticalLayout;
-    }
-
-    private OnLongClickListener getOnLongClickListener(final String message) {
-        return new OnLongClickListener() {
-
-            @Override
-            public boolean onLongClick(View v) {
-                Log_OC.d(LOG_TAG, message);
-                Toast toast = Toast.makeText(InstantUploadActivity.this, getString(R.string.failed_upload_retry_text)
-                        + message, Toast.LENGTH_LONG);
-                toast.show();
-                return true;
-            }
-
-        };
-    }
-
-    private CheckBox getFileCheckbox(int id) {
-        CheckBox retryCB = new CheckBox(this);
-        retryCB.setId(id);
-        retryCB.setBackgroundResource(R.color.background_color);
-        retryCB.setTextSize(8);
-        retryCB.setTag(retry_chexbox_tag);
-        return retryCB;
-    }
-
-    private ImageButton getImageButton(String img_path, int id) {
-        ImageButton imageButton = new ImageButton(this);
-        imageButton.setId(id);
-        imageButton.setClickable(true);
-        imageButton.setOnClickListener(getImageButtonOnClickListener(img_path));
-
-        // scale and add a thumbnail to the imagebutton
-        int base_scale_size = 32;
-        if (img_path != null) {
-            Log_OC.d(LOG_TAG, "add " + img_path + " to Image Button");
-            BitmapFactory.Options options = new BitmapFactory.Options();
-            options.inJustDecodeBounds = true;
-            Bitmap bitmap = BitmapFactory.decodeFile(img_path, options);
-            int width_tpm = options.outWidth, height_tmp = options.outHeight;
-            int scale = 3;
-            while (true) {
-                if (width_tpm / 2 < base_scale_size || height_tmp / 2 < base_scale_size) {
-                    break;
-                }
-                width_tpm /= 2;
-                height_tmp /= 2;
-                scale++;
-            }
-
-            Log_OC.d(LOG_TAG, "scale Imgae with: " + scale);
-            BitmapFactory.Options options2 = new BitmapFactory.Options();
-            options2.inSampleSize = scale;
-            bitmap = BitmapFactory.decodeFile(img_path, options2);
-
-            if (bitmap != null) {
-                Log_OC.d(LOG_TAG, "loaded Bitmap Bytes: " + bitmap.getRowBytes());
-                imageButton.setImageBitmap(bitmap);
-            } else {
-                Log_OC.d(LOG_TAG, "could not load imgage: " + img_path);
-            }
-        }
-        return imageButton;
-    }
-
-    private OnClickListener getImageButtonOnClickListener(final String img_path) {
-        return new OnClickListener() {
-
-            @Override
-            public void onClick(View v) {
-                startUpload(img_path);
-                loadListView(true);
-            }
-
-        };
-    }
-
-    /**
-     * start uploading a file to the INSTANT_UPLOD_DIR
-     * 
-     * @param img_path
-     */
-    private void startUpload(String img_path) {
-        // extract filename
-        String filename = FileStorageUtils.getInstantUploadFilePath(this, img_path);
-        if (canInstantUpload()) {
-            Account account = AccountUtils.getCurrentOwnCloudAccount(InstantUploadActivity.this);
-            // add file again to upload queue
-            DbHandler db = new DbHandler(InstantUploadActivity.this);
-            try {
-                db.updateFileState(img_path, DbHandler.UPLOAD_STATUS_UPLOAD_LATER, null);
-            } finally {
-                db.close();
-            }
-
-            Intent i = new Intent(InstantUploadActivity.this, FileUploader.class);
-            i.putExtra(FileUploader.KEY_ACCOUNT, account);
-            i.putExtra(FileUploader.KEY_LOCAL_FILE, img_path);
-            i.putExtra(FileUploader.KEY_REMOTE_FILE, filename);
-            i.putExtra(FileUploader.KEY_UPLOAD_TYPE, FileUploader.UPLOAD_SINGLE_FILE);
-            i.putExtra(com.owncloud.android.files.services.FileUploader.KEY_INSTANT_UPLOAD, true);
-
-            final String msg = "try to upload file with name :" + filename;
-            Log_OC.d(LOG_TAG, msg);
-            Toast toast = Toast.makeText(InstantUploadActivity.this, getString(R.string.failed_upload_retry_text)
-                    + filename, Toast.LENGTH_LONG);
-            toast.show();
-
-            startService(i);
-        } else {
-            Toast toast = Toast.makeText(InstantUploadActivity.this,
-                    getString(R.string.failed_upload_retry_do_nothing_text) + filename, Toast.LENGTH_LONG);
-            toast.show();
-        }
-    }
-
-    private boolean canInstantUpload() {
-
-        if (!InstantUploadBroadcastReceiver.isOnline(this)
-                || (InstantUploadBroadcastReceiver.instantPictureUploadViaWiFiOnly(this) && !InstantUploadBroadcastReceiver
-                        .isConnectedViaWiFi(this))) {
-            return false;
-        } else {
-            return true;
-        }
-    }
-
-}