2 * ownCloud Android client application
4 * @author Bartek Przybylski
5 * Copyright (C) 2012 Bartek Przybylski
6 * Copyright (C) 2015 ownCloud Inc.
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 package com
.owncloud
.android
.ui
.activity
;
25 import java
.util
.ArrayList
;
26 import java
.util
.HashMap
;
27 import java
.util
.LinkedList
;
28 import java
.util
.List
;
29 import java
.util
.Stack
;
30 import java
.util
.Vector
;
33 import android
.accounts
.Account
;
34 import android
.accounts
.AccountManager
;
35 import android
.app
.AlertDialog
;
36 import android
.app
.AlertDialog
.Builder
;
37 import android
.app
.Dialog
;
38 import android
.app
.ProgressDialog
;
39 import android
.content
.Context
;
40 import android
.content
.DialogInterface
;
41 import android
.content
.DialogInterface
.OnCancelListener
;
42 import android
.content
.DialogInterface
.OnClickListener
;
43 import android
.content
.Intent
;
44 import android
.content
.SharedPreferences
;
45 import android
.content
.res
.Resources
.NotFoundException
;
46 import android
.database
.Cursor
;
47 import android
.net
.Uri
;
48 import android
.os
.Bundle
;
49 import android
.os
.Parcelable
;
50 import android
.preference
.PreferenceManager
;
51 import android
.provider
.MediaStore
;
52 import android
.provider
.MediaStore
.Audio
;
53 import android
.provider
.MediaStore
.Images
;
54 import android
.provider
.MediaStore
.Video
;
55 import android
.support
.v4
.app
.Fragment
;
56 import android
.support
.v4
.app
.FragmentManager
;
57 import android
.support
.v4
.app
.FragmentTransaction
;
58 import android
.view
.View
;
59 import android
.widget
.AdapterView
;
60 import android
.widget
.AdapterView
.OnItemClickListener
;
61 import android
.widget
.Button
;
62 import android
.widget
.EditText
;
63 import android
.widget
.ListView
;
64 import android
.widget
.SimpleAdapter
;
65 import android
.widget
.Toast
;
67 import com
.actionbarsherlock
.app
.ActionBar
;
68 import com
.actionbarsherlock
.view
.MenuItem
;
69 import com
.owncloud
.android
.MainApp
;
70 import com
.owncloud
.android
.R
;
71 import com
.owncloud
.android
.authentication
.AccountAuthenticator
;
72 import com
.owncloud
.android
.datamodel
.OCFile
;
73 import com
.owncloud
.android
.files
.services
.FileUploader
;
74 import com
.owncloud
.android
.lib
.common
.operations
.RemoteOperation
;
75 import com
.owncloud
.android
.lib
.common
.operations
.RemoteOperationResult
;
76 import com
.owncloud
.android
.lib
.common
.utils
.Log_OC
;
77 import com
.owncloud
.android
.operations
.CreateFolderOperation
;
78 import com
.owncloud
.android
.ui
.dialog
.CreateFolderDialogFragment
;
79 import com
.owncloud
.android
.ui
.dialog
.LoadingDialog
;
80 import com
.owncloud
.android
.utils
.CopyTmpFileAsyncTask
;
81 import com
.owncloud
.android
.utils
.DisplayUtils
;
82 import com
.owncloud
.android
.utils
.ErrorMessageAdapter
;
86 * This can be used to upload things to an ownCloud instance.
88 public class Uploader
extends FileActivity
89 implements OnItemClickListener
, android
.view
.View
.OnClickListener
,
90 CopyTmpFileAsyncTask
.OnCopyTmpFileTaskListener
{
92 private static final String TAG
= Uploader
.class.getSimpleName();
94 private AccountManager mAccountManager
;
95 private Stack
<String
> mParents
;
96 private ArrayList
<Parcelable
> mStreamsToUpload
;
97 private boolean mCreateDir
;
98 private String mUploadPath
;
100 private boolean mAccountSelected
;
102 private ArrayList
<String
> mRemoteCacheData
;
103 private int mNumCacheFile
;
105 private final static int DIALOG_NO_ACCOUNT
= 0;
106 private final static int DIALOG_WAITING
= 1;
107 private final static int DIALOG_NO_STREAM
= 2;
108 private final static int DIALOG_MULTIPLE_ACCOUNT
= 3;
110 private final static int REQUEST_CODE_SETUP_ACCOUNT
= 0;
112 private final static String KEY_PARENTS
= "PARENTS";
113 private final static String KEY_FILE
= "FILE";
114 private final static String KEY_ACCOUNT_SELECTED
= "ACCOUNT_SELECTED";
115 private final static String KEY_NUM_CACHE_FILE
= "NUM_CACHE_FILE";
116 private final static String KEY_REMOTE_CACHE_DATA
= "REMOTE_CACHE_DATA";
118 private static final String DIALOG_WAIT_COPY_FILE
= "DIALOG_WAIT_COPY_FILE";
121 protected void onCreate(Bundle savedInstanceState
) {
122 prepareStreamsToUpload();
124 if (savedInstanceState
== null
) {
125 mParents
= new Stack
<String
>();
126 mAccountSelected
= false
;
129 // ArrayList for files with path in private storage
130 mRemoteCacheData
= new ArrayList
<String
>();
132 mParents
= (Stack
<String
>) savedInstanceState
.getSerializable(KEY_PARENTS
);
133 mFile
= savedInstanceState
.getParcelable(KEY_FILE
);
134 mAccountSelected
= savedInstanceState
.getBoolean(KEY_ACCOUNT_SELECTED
);
135 mNumCacheFile
= savedInstanceState
.getInt(KEY_NUM_CACHE_FILE
);
136 mRemoteCacheData
= savedInstanceState
.getStringArrayList(KEY_REMOTE_CACHE_DATA
);
139 super.onCreate(savedInstanceState
);
141 if (mAccountSelected
) {
142 setAccount((Account
) savedInstanceState
.getParcelable(FileActivity
.EXTRA_ACCOUNT
));
146 ActionBar actionBar
= getSupportActionBar();
147 actionBar
.setIcon(DisplayUtils
.getSeasonalIconId());
152 protected void setAccount(Account account
, boolean savedAccount
) {
153 if (somethingToUpload()) {
154 mAccountManager
= (AccountManager
) getSystemService(Context
.ACCOUNT_SERVICE
);
155 Account
[] accounts
= mAccountManager
.getAccountsByType(MainApp
.getAccountType());
156 if (accounts
.length
== 0) {
157 Log_OC
.i(TAG
, "No ownCloud account is available");
158 showDialog(DIALOG_NO_ACCOUNT
);
159 } else if (accounts
.length
> 1 && !mAccountSelected
) {
160 Log_OC
.i(TAG
, "More than one ownCloud is available");
161 showDialog(DIALOG_MULTIPLE_ACCOUNT
);
164 setAccount(accounts
[0]);
169 showDialog(DIALOG_NO_STREAM
);
172 super.setAccount(account
, savedAccount
);
176 protected void onAccountSet(boolean stateWasRecovered
) {
177 super.onAccountSet(mAccountWasRestored
);
179 populateDirectoryList();
183 protected void onSaveInstanceState(Bundle outState
) {
184 Log_OC
.d(TAG
, "onSaveInstanceState() start");
185 super.onSaveInstanceState(outState
);
186 outState
.putSerializable(KEY_PARENTS
, mParents
);
187 //outState.putParcelable(KEY_ACCOUNT, mAccount);
188 outState
.putParcelable(KEY_FILE
, mFile
);
189 outState
.putBoolean(KEY_ACCOUNT_SELECTED
, mAccountSelected
);
190 outState
.putInt(KEY_NUM_CACHE_FILE
, mNumCacheFile
);
191 outState
.putStringArrayList(KEY_REMOTE_CACHE_DATA
, mRemoteCacheData
);
192 outState
.putParcelable(FileActivity
.EXTRA_ACCOUNT
, getAccount());
194 Log_OC
.d(TAG
, "onSaveInstanceState() end");
198 protected Dialog
onCreateDialog(final int id
) {
199 final AlertDialog
.Builder builder
= new Builder(this);
202 ProgressDialog pDialog
= new ProgressDialog(this);
203 pDialog
.setIndeterminate(false
);
204 pDialog
.setCancelable(false
);
205 pDialog
.setMessage(getResources().getString(R
.string
.uploader_info_uploading
));
207 case DIALOG_NO_ACCOUNT
:
208 builder
.setIcon(android
.R
.drawable
.ic_dialog_alert
);
209 builder
.setTitle(R
.string
.uploader_wrn_no_account_title
);
210 builder
.setMessage(String
.format(
211 getString(R
.string
.uploader_wrn_no_account_text
), getString(R
.string
.app_name
)));
212 builder
.setCancelable(false
);
213 builder
.setPositiveButton(R
.string
.uploader_wrn_no_account_setup_btn_text
, new OnClickListener() {
215 public void onClick(DialogInterface dialog
, int which
) {
216 if (android
.os
.Build
.VERSION
.SDK_INT
> android
.os
.Build
.VERSION_CODES
.ECLAIR_MR1
) {
217 // using string value since in API7 this
218 // constatn is not defined
219 // in API7 < this constatant is defined in
220 // Settings.ADD_ACCOUNT_SETTINGS
221 // and Settings.EXTRA_AUTHORITIES
222 Intent intent
= new Intent(android
.provider
.Settings
.ACTION_ADD_ACCOUNT
);
223 intent
.putExtra("authorities", new String
[] { MainApp
.getAuthTokenType() });
224 startActivityForResult(intent
, REQUEST_CODE_SETUP_ACCOUNT
);
226 // since in API7 there is no direct call for
227 // account setup, so we need to
228 // show our own AccountSetupAcricity, get
229 // desired results and setup
230 // everything for ourself
231 Intent intent
= new Intent(getBaseContext(), AccountAuthenticator
.class);
232 startActivityForResult(intent
, REQUEST_CODE_SETUP_ACCOUNT
);
236 builder
.setNegativeButton(R
.string
.uploader_wrn_no_account_quit_btn_text
, new OnClickListener() {
238 public void onClick(DialogInterface dialog
, int which
) {
242 return builder
.create();
243 case DIALOG_MULTIPLE_ACCOUNT
:
244 CharSequence ac
[] = new CharSequence
[
245 mAccountManager
.getAccountsByType(MainApp
.getAccountType()).length
];
246 for (int i
= 0; i
< ac
.length
; ++i
) {
247 ac
[i
] = DisplayUtils
.convertIdn(
248 mAccountManager
.getAccountsByType(MainApp
.getAccountType())[i
].name
, false
);
250 builder
.setTitle(R
.string
.common_choose_account
);
251 builder
.setItems(ac
, new OnClickListener() {
253 public void onClick(DialogInterface dialog
, int which
) {
254 setAccount(mAccountManager
.getAccountsByType(MainApp
.getAccountType())[which
]);
255 onAccountSet(mAccountWasRestored
);
257 mAccountSelected
= true
;
260 builder
.setCancelable(true
);
261 builder
.setOnCancelListener(new OnCancelListener() {
263 public void onCancel(DialogInterface dialog
) {
268 return builder
.create();
269 case DIALOG_NO_STREAM
:
270 builder
.setIcon(android
.R
.drawable
.ic_dialog_alert
);
271 builder
.setTitle(R
.string
.uploader_wrn_no_content_title
);
272 builder
.setMessage(R
.string
.uploader_wrn_no_content_text
);
273 builder
.setCancelable(false
);
274 builder
.setNegativeButton(R
.string
.common_cancel
, new OnClickListener() {
276 public void onClick(DialogInterface dialog
, int which
) {
280 return builder
.create();
282 throw new IllegalArgumentException("Unknown dialog id: " + id
);
286 class a
implements OnClickListener
{
290 public a(String path
, EditText dirname
) {
296 public void onClick(DialogInterface dialog
, int which
) {
297 Uploader
.this.mUploadPath
= mPath
+ mDirname
.getText().toString();
298 Uploader
.this.mCreateDir
= true
;
304 public void onBackPressed() {
306 if (mParents
.size() <= 1) {
307 super.onBackPressed();
311 populateDirectoryList();
316 public void onItemClick(AdapterView
<?
> parent
, View view
, int position
, long id
) {
317 // click on folder in the list
318 Log_OC
.d(TAG
, "on item click");
319 Vector
<OCFile
> tmpfiles
= getStorageManager().getFolderContent(mFile
);
320 if (tmpfiles
.size() <= 0) return;
322 Vector
<OCFile
> files
= new Vector
<OCFile
>();
323 for (OCFile f
: tmpfiles
)
326 if (files
.size() < position
) {
327 throw new IndexOutOfBoundsException("Incorrect item selected");
329 mParents
.push(files
.get(position
).getFileName());
330 populateDirectoryList();
334 public void onClick(View v
) {
337 case R
.id
.uploader_choose_folder
:
338 mUploadPath
= ""; // first element in mParents is root dir, represented by "";
339 // init mUploadPath with "/" results in a "//" prefix
340 for (String p
: mParents
)
341 mUploadPath
+= p
+ OCFile
.PATH_SEPARATOR
;
342 Log_OC
.d(TAG
, "Uploading file to dir " + mUploadPath
);
348 case R
.id
.uploader_new_folder
:
349 CreateFolderDialogFragment dialog
= CreateFolderDialogFragment
.newInstance(mFile
);
350 dialog
.show(getSupportFragmentManager(), "createdirdialog");
355 throw new IllegalArgumentException("Wrong element clicked");
360 protected void onActivityResult(int requestCode
, int resultCode
, Intent data
) {
361 super.onActivityResult(requestCode
, resultCode
, data
);
362 Log_OC
.i(TAG
, "result received. req: " + requestCode
+ " res: " + resultCode
);
363 if (requestCode
== REQUEST_CODE_SETUP_ACCOUNT
) {
364 dismissDialog(DIALOG_NO_ACCOUNT
);
365 if (resultCode
== RESULT_CANCELED
) {
368 Account
[] accounts
= mAccountManager
.getAccountsByType(MainApp
.getAuthTokenType());
369 if (accounts
.length
== 0) {
370 showDialog(DIALOG_NO_ACCOUNT
);
372 // there is no need for checking for is there more then one
373 // account at this point
374 // since account setup can set only one account at time
375 setAccount(accounts
[0]);
376 populateDirectoryList();
381 private void populateDirectoryList() {
382 setContentView(R
.layout
.uploader_layout
);
384 ListView mListView
= (ListView
) findViewById(android
.R
.id
.list
);
386 String current_dir
= mParents
.peek();
387 if(current_dir
.equals("")){
388 getSupportActionBar().setTitle(getString(R
.string
.default_display_name_for_root_folder
));
391 getSupportActionBar().setTitle(current_dir
);
393 boolean notRoot
= (mParents
.size() > 1);
394 ActionBar actionBar
= getSupportActionBar();
395 actionBar
.setDisplayHomeAsUpEnabled(notRoot
);
396 actionBar
.setHomeButtonEnabled(notRoot
);
398 String full_path
= generatePath(mParents
);
400 Log_OC
.d(TAG
, "Populating view with content of : " + full_path
);
402 mFile
= getStorageManager().getFileByPath(full_path
);
404 Vector
<OCFile
> files
= getStorageManager().getFolderContent(mFile
);
405 List
<HashMap
<String
, Object
>> data
= new LinkedList
<HashMap
<String
,Object
>>();
406 for (OCFile f
: files
) {
407 HashMap
<String
, Object
> h
= new HashMap
<String
, Object
>();
409 h
.put("dirname", f
.getFileName());
413 SimpleAdapter sa
= new SimpleAdapter(this,
415 R
.layout
.uploader_list_item_layout
,
416 new String
[] {"dirname"},
417 new int[] {R
.id
.textView1
});
419 mListView
.setAdapter(sa
);
420 Button btnChooseFolder
= (Button
) findViewById(R
.id
.uploader_choose_folder
);
421 btnChooseFolder
.setOnClickListener(this);
423 Button btnNewFolder
= (Button
) findViewById(R
.id
.uploader_new_folder
);
424 btnNewFolder
.setOnClickListener(this);
426 mListView
.setOnItemClickListener(this);
430 private String
generatePath(Stack
<String
> dirs
) {
431 String full_path
= "";
433 for (String a
: dirs
)
434 full_path
+= a
+ "/";
438 private void prepareStreamsToUpload() {
439 if (getIntent().getAction().equals(Intent
.ACTION_SEND
)) {
440 mStreamsToUpload
= new ArrayList
<Parcelable
>();
441 mStreamsToUpload
.add(getIntent().getParcelableExtra(Intent
.EXTRA_STREAM
));
442 } else if (getIntent().getAction().equals(Intent
.ACTION_SEND_MULTIPLE
)) {
443 mStreamsToUpload
= getIntent().getParcelableArrayListExtra(Intent
.EXTRA_STREAM
);
447 private boolean somethingToUpload() {
448 return (mStreamsToUpload
!= null
&& mStreamsToUpload
.get(0) != null
);
451 public void uploadFiles() {
454 // ArrayList for files with path in external storage
455 ArrayList
<String
> local
= new ArrayList
<String
>();
456 ArrayList
<String
> remote
= new ArrayList
<String
>();
458 // this checks the mimeType
459 for (Parcelable mStream
: mStreamsToUpload
) {
461 Uri uri
= (Uri
) mStream
;
463 String filePath
= "";
466 if (uri
.getScheme().equals("content")) {
467 String mimeType
= getContentResolver().getType(uri
);
469 if (mimeType
.contains("image")) {
470 String
[] CONTENT_PROJECTION
= { Images
.Media
.DATA
,
471 Images
.Media
.DISPLAY_NAME
, Images
.Media
.MIME_TYPE
,
473 Cursor c
= getContentResolver().query(uri
, CONTENT_PROJECTION
, null
,
476 int index
= c
.getColumnIndex(Images
.Media
.DATA
);
477 data
= c
.getString(index
);
478 filePath
= mUploadPath
+
479 c
.getString(c
.getColumnIndex(Images
.Media
.DISPLAY_NAME
));
481 } else if (mimeType
.contains("video")) {
482 String
[] CONTENT_PROJECTION
= { Video
.Media
.DATA
,
483 Video
.Media
.DISPLAY_NAME
, Video
.Media
.MIME_TYPE
,
484 Video
.Media
.SIZE
, Video
.Media
.DATE_MODIFIED
};
485 Cursor c
= getContentResolver().query(uri
, CONTENT_PROJECTION
, null
,
488 int index
= c
.getColumnIndex(Video
.Media
.DATA
);
489 data
= c
.getString(index
);
490 filePath
= mUploadPath
+
491 c
.getString(c
.getColumnIndex(Video
.Media
.DISPLAY_NAME
));
493 } else if (mimeType
.contains("audio")) {
494 String
[] CONTENT_PROJECTION
= { Audio
.Media
.DATA
,
495 Audio
.Media
.DISPLAY_NAME
, Audio
.Media
.MIME_TYPE
,
497 Cursor c
= getContentResolver().query(uri
, CONTENT_PROJECTION
, null
,
500 int index
= c
.getColumnIndex(Audio
.Media
.DATA
);
501 data
= c
.getString(index
);
502 filePath
= mUploadPath
+
503 c
.getString(c
.getColumnIndex(Audio
.Media
.DISPLAY_NAME
));
506 Cursor cursor
= getContentResolver().query(uri
,
507 new String
[]{MediaStore
.MediaColumns
.DISPLAY_NAME
},
509 cursor
.moveToFirst();
510 int nameIndex
= cursor
.getColumnIndex(cursor
.getColumnNames()[0]);
511 if (nameIndex
>= 0) {
512 filePath
= mUploadPath
+ cursor
.getString(nameIndex
);
516 } else if (uri
.getScheme().equals("file")) {
517 filePath
= Uri
.decode(uri
.toString()).replace(uri
.getScheme() +
519 if (filePath
.contains("mnt")) {
520 String splitedFilePath
[] = filePath
.split("/mnt");
521 filePath
= splitedFilePath
[1];
523 final File file
= new File(filePath
);
524 data
= file
.getAbsolutePath();
525 filePath
= mUploadPath
+ file
.getName();
528 throw new SecurityException();
531 mRemoteCacheData
.add(filePath
);
532 CopyTmpFileAsyncTask copyTask
= new CopyTmpFileAsyncTask(this);
533 Object
[] params
= { uri
, filePath
, mRemoteCacheData
.size()-1 };
535 showWaitingCopyDialog();
536 copyTask
.execute(params
);
538 remote
.add(filePath
);
543 throw new SecurityException();
546 Intent intent
= new Intent(getApplicationContext(), FileUploader
.class);
547 intent
.putExtra(FileUploader
.KEY_UPLOAD_TYPE
, FileUploader
.UPLOAD_MULTIPLE_FILES
);
548 intent
.putExtra(FileUploader
.KEY_LOCAL_FILE
, local
.toArray(new String
[local
.size()]));
549 intent
.putExtra(FileUploader
.KEY_REMOTE_FILE
,
550 remote
.toArray(new String
[remote
.size()]));
551 intent
.putExtra(FileUploader
.KEY_ACCOUNT
, getAccount());
552 startService(intent
);
554 //Save the path to shared preferences
555 SharedPreferences
.Editor appPrefs
= PreferenceManager
556 .getDefaultSharedPreferences(getApplicationContext()).edit();
557 appPrefs
.putString("last_upload_path", mUploadPath
);
563 } catch (SecurityException e
) {
564 String message
= String
.format(getString(R
.string
.uploader_error_forbidden_content
),
565 getString(R
.string
.app_name
));
566 Toast
.makeText(this, message
, Toast
.LENGTH_LONG
).show();
571 public void onRemoteOperationFinish(RemoteOperation operation
, RemoteOperationResult result
) {
572 super.onRemoteOperationFinish(operation
, result
);
575 if (operation
instanceof CreateFolderOperation
) {
576 onCreateFolderOperationFinish((CreateFolderOperation
)operation
, result
);
582 * Updates the view associated to the activity after the finish of an operation
583 * trying create a new folder
585 * @param operation Creation operation performed.
586 * @param result Result of the creation.
588 private void onCreateFolderOperationFinish(CreateFolderOperation operation
,
589 RemoteOperationResult result
) {
590 if (result
.isSuccess()) {
591 dismissLoadingDialog();
592 populateDirectoryList();
594 dismissLoadingDialog();
596 Toast msg
= Toast
.makeText(this,
597 ErrorMessageAdapter
.getErrorCauseMessage(result
, operation
, getResources()),
601 } catch (NotFoundException e
) {
602 Log_OC
.e(TAG
, "Error while trying to show fail message " , e
);
609 * Loads the target folder initialize shown to the user.
611 * The target account has to be chosen before this method is called.
613 private void initTargetFolder() {
614 if (getStorageManager() == null
) {
615 throw new IllegalStateException("Do not call this method before " +
616 "initializing mStorageManager");
619 SharedPreferences appPreferences
= PreferenceManager
620 .getDefaultSharedPreferences(getApplicationContext());
622 String last_path
= appPreferences
.getString("last_upload_path", "");
623 // "/" equals root-directory
624 if(last_path
.equals("/")) {
627 String
[] dir_names
= last_path
.split("/");
628 for (String dir
: dir_names
)
631 //Make sure that path still exists, if it doesn't pop the stack and try the previous path
632 while(!getStorageManager().fileExists(generatePath(mParents
)) && mParents
.size() > 1){
639 public boolean onOptionsItemSelected(MenuItem item
) {
640 boolean retval
= true
;
641 switch (item
.getItemId()) {
642 case android
.R
.id
.home
:
643 if((mParents
.size() > 1)) {
649 retval
= super.onOptionsItemSelected(item
);
656 * Process the result of CopyTmpFileAsyncTask
661 public void OnCopyTmpFileTaskListener(String result
, int index
) {
662 if (mNumCacheFile
-- == 0) {
663 dismissWaitingCopyDialog();
665 if (result
!= null
) {
666 Intent intent
= new Intent(getApplicationContext(), FileUploader
.class);
667 intent
.putExtra(FileUploader
.KEY_UPLOAD_TYPE
, FileUploader
.UPLOAD_SINGLE_FILE
);
668 intent
.putExtra(FileUploader
.KEY_LOCAL_FILE
, result
);
669 intent
.putExtra(FileUploader
.KEY_REMOTE_FILE
, mRemoteCacheData
.get(index
));
670 intent
.putExtra(FileUploader
.KEY_ACCOUNT
, getAccount());
671 startService(intent
);
674 String message
= String
.format(getString(R
.string
.uploader_error_forbidden_content
),
675 getString(R
.string
.app_name
));
676 Toast
.makeText(this, message
, Toast
.LENGTH_LONG
).show();
677 Log_OC
.d(TAG
, message
);
682 * Show waiting for copy dialog
684 public void showWaitingCopyDialog() {
686 LoadingDialog loading
= new LoadingDialog(
687 getResources().getString(R
.string
.wait_for_tmp_copy_from_private_storage
));
688 FragmentManager fm
= getSupportFragmentManager();
689 FragmentTransaction ft
= fm
.beginTransaction();
690 loading
.show(ft
, DIALOG_WAIT_COPY_FILE
);
696 * Dismiss waiting for copy dialog
698 public void dismissWaitingCopyDialog(){
699 Fragment frag
= getSupportFragmentManager().findFragmentByTag(DIALOG_WAIT_COPY_FILE
);
701 LoadingDialog loading
= (LoadingDialog
) frag
;