2 * ownCloud Android client application
4 * @author Bartek Przybylski
5 * @author David A. Velasco
6 * Copyright (C) 2011 Bartek Przybylski
7 * Copyright (C) 2015 ownCloud Inc.
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2,
11 * as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 package com
.owncloud
.android
.ui
.activity
;
24 import android
.accounts
.Account
;
25 import android
.accounts
.AccountManager
;
26 import android
.accounts
.AccountManagerCallback
;
27 import android
.accounts
.AccountManagerFuture
;
28 import android
.content
.ComponentName
;
29 import android
.content
.Context
;
30 import android
.content
.Intent
;
31 import android
.content
.ServiceConnection
;
32 import android
.content
.SharedPreferences
;
33 import android
.content
.pm
.PackageInfo
;
34 import android
.content
.pm
.PackageManager
.NameNotFoundException
;
35 import android
.net
.Uri
;
36 import android
.os
.Bundle
;
37 import android
.os
.Handler
;
38 import android
.os
.IBinder
;
39 import android
.preference
.CheckBoxPreference
;
40 import android
.preference
.Preference
;
41 import android
.preference
.Preference
.OnPreferenceChangeListener
;
42 import android
.preference
.Preference
.OnPreferenceClickListener
;
43 import android
.preference
.PreferenceCategory
;
44 import android
.preference
.PreferenceManager
;
45 import android
.view
.ContextMenu
;
46 import android
.view
.ContextMenu
.ContextMenuInfo
;
47 import android
.view
.View
;
48 import android
.widget
.AdapterView
;
49 import android
.widget
.AdapterView
.OnItemLongClickListener
;
50 import android
.widget
.ListAdapter
;
51 import android
.widget
.ListView
;
53 import com
.actionbarsherlock
.app
.ActionBar
;
54 import com
.actionbarsherlock
.app
.SherlockPreferenceActivity
;
55 import com
.actionbarsherlock
.view
.Menu
;
56 import com
.actionbarsherlock
.view
.MenuItem
;
57 import com
.owncloud
.android
.MainApp
;
58 import com
.owncloud
.android
.R
;
59 import com
.owncloud
.android
.authentication
.AccountUtils
;
60 import com
.owncloud
.android
.authentication
.AuthenticatorActivity
;
61 import com
.owncloud
.android
.datamodel
.FileDataStorageManager
;
62 import com
.owncloud
.android
.datamodel
.OCFile
;
63 import com
.owncloud
.android
.db
.DbHandler
;
64 import com
.owncloud
.android
.files
.FileOperationsHelper
;
65 import com
.owncloud
.android
.files
.services
.FileDownloader
;
66 import com
.owncloud
.android
.files
.services
.FileUploader
;
67 import com
.owncloud
.android
.lib
.common
.utils
.Log_OC
;
68 import com
.owncloud
.android
.services
.OperationsService
;
69 import com
.owncloud
.android
.ui
.RadioButtonPreference
;
70 import com
.owncloud
.android
.utils
.DisplayUtils
;
76 * An Activity that allows the user to change the application's settings.
78 public class Preferences
extends SherlockPreferenceActivity
79 implements AccountManagerCallback
<Boolean
>, ComponentsGetter
{
81 private static final String TAG
= "OwnCloudPreferences";
83 private static final int ACTION_SELECT_UPLOAD_PATH
= 1;
84 private static final int ACTION_SELECT_UPLOAD_VIDEO_PATH
= 2;
86 private DbHandler mDbHandler
;
87 private CheckBoxPreference pCode
;
88 private Preference pAboutApp
;
90 private PreferenceCategory mAccountsPrefCategory
= null
;
91 private final Handler mHandler
= new Handler();
92 private String mAccountName
;
93 private boolean mShowContextMenu
= false
;
94 private String mUploadPath
;
95 private PreferenceCategory mPrefInstantUploadCategory
;
96 private Preference mPrefInstantUpload
;
97 private Preference mPrefInstantUploadPath
;
98 private Preference mPrefInstantUploadPathWiFi
;
99 private Preference mPrefInstantVideoUpload
;
100 private Preference mPrefInstantVideoUploadPath
;
101 private Preference mPrefInstantVideoUploadPathWiFi
;
102 private String mUploadVideoPath
;
104 protected FileDownloader
.FileDownloaderBinder mDownloaderBinder
= null
;
105 protected FileUploader
.FileUploaderBinder mUploaderBinder
= null
;
106 private ServiceConnection mDownloadServiceConnection
, mUploadServiceConnection
= null
;
108 @SuppressWarnings("deprecation")
110 public void onCreate(Bundle savedInstanceState
) {
111 super.onCreate(savedInstanceState
);
112 mDbHandler
= new DbHandler(getBaseContext());
113 addPreferencesFromResource(R
.xml
.preferences
);
115 ActionBar actionBar
= getSherlock().getActionBar();
116 actionBar
.setIcon(DisplayUtils
.getSeasonalIconId());
117 actionBar
.setDisplayHomeAsUpEnabled(true
);
118 actionBar
.setTitle(R
.string
.actionbar_settings
);
120 // Load the accounts category for adding the list of accounts
121 mAccountsPrefCategory
= (PreferenceCategory
) findPreference("accounts_category");
123 ListView listView
= getListView();
124 listView
.setOnItemLongClickListener(new OnItemLongClickListener() {
126 public boolean onItemLongClick(AdapterView
<?
> parent
, View view
, int position
, long id
) {
127 ListView listView
= (ListView
) parent
;
128 ListAdapter listAdapter
= listView
.getAdapter();
129 Object obj
= listAdapter
.getItem(position
);
131 if (obj
!= null
&& obj
instanceof RadioButtonPreference
) {
132 mShowContextMenu
= true
;
133 mAccountName
= ((RadioButtonPreference
) obj
).getKey();
135 Preferences
.this.openContextMenu(listView
);
137 View
.OnLongClickListener longListener
= (View
.OnLongClickListener
) obj
;
138 return longListener
.onLongClick(view
);
147 PackageInfo pkg
= getPackageManager().getPackageInfo(getPackageName(), 0);
148 temp
= pkg
.versionName
;
149 } catch (NameNotFoundException e
) {
151 Log_OC
.e(TAG
, "Error while showing about dialog", e
);
153 final String appVersion
= temp
;
155 // Register context menu for list of preferences.
156 registerForContextMenu(getListView());
158 pCode
= (CheckBoxPreference
) findPreference("set_pincode");
160 pCode
.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
162 public boolean onPreferenceChange(Preference preference
, Object newValue
) {
163 Intent i
= new Intent(getApplicationContext(), PinCodeActivity
.class);
164 i
.putExtra(PinCodeActivity
.EXTRA_ACTIVITY
, "preferences");
165 i
.putExtra(PinCodeActivity
.EXTRA_NEW_STATE
, newValue
.toString());
174 PreferenceCategory preferenceCategory
= (PreferenceCategory
) findPreference("more");
176 boolean helpEnabled
= getResources().getBoolean(R
.bool
.help_enabled
);
177 Preference pHelp
= findPreference("help");
180 pHelp
.setOnPreferenceClickListener(new OnPreferenceClickListener() {
182 public boolean onPreferenceClick(Preference preference
) {
183 String helpWeb
=(String
) getText(R
.string
.url_help
);
184 if (helpWeb
!= null
&& helpWeb
.length() > 0) {
185 Uri uriUrl
= Uri
.parse(helpWeb
);
186 Intent intent
= new Intent(Intent
.ACTION_VIEW
, uriUrl
);
187 startActivity(intent
);
193 preferenceCategory
.removePreference(pHelp
);
199 boolean recommendEnabled
= getResources().getBoolean(R
.bool
.recommend_enabled
);
200 Preference pRecommend
= findPreference("recommend");
201 if (pRecommend
!= null
){
202 if (recommendEnabled
) {
203 pRecommend
.setOnPreferenceClickListener(new OnPreferenceClickListener() {
205 public boolean onPreferenceClick(Preference preference
) {
207 Intent intent
= new Intent(Intent
.ACTION_SENDTO
);
208 intent
.setType("text/plain");
209 intent
.setData(Uri
.parse(getString(R
.string
.mail_recommend
)));
210 intent
.addFlags(Intent
.FLAG_ACTIVITY_NEW_TASK
);
212 String appName
= getString(R
.string
.app_name
);
213 String downloadUrl
= getString(R
.string
.url_app_download
);
214 Account currentAccount
= AccountUtils
.getCurrentOwnCloudAccount(Preferences
.this);
215 String username
= currentAccount
.name
.substring(0, currentAccount
.name
.lastIndexOf('@'));
217 String recommendSubject
= String
.format(getString(R
.string
.recommend_subject
), appName
);
218 String recommendText
= String
.format(getString(R
.string
.recommend_text
),
219 appName
, downloadUrl
, username
);
221 intent
.putExtra(Intent
.EXTRA_SUBJECT
, recommendSubject
);
222 intent
.putExtra(Intent
.EXTRA_TEXT
, recommendText
);
223 startActivity(intent
);
230 preferenceCategory
.removePreference(pRecommend
);
235 boolean feedbackEnabled
= getResources().getBoolean(R
.bool
.feedback_enabled
);
236 Preference pFeedback
= findPreference("feedback");
237 if (pFeedback
!= null
){
238 if (feedbackEnabled
) {
239 pFeedback
.setOnPreferenceClickListener(new OnPreferenceClickListener() {
241 public boolean onPreferenceClick(Preference preference
) {
242 String feedbackMail
=(String
) getText(R
.string
.mail_feedback
);
243 String feedback
=(String
) getText(R
.string
.prefs_feedback
) + " - android v" + appVersion
;
244 Intent intent
= new Intent(Intent
.ACTION_SENDTO
);
245 intent
.setType("text/plain");
246 intent
.putExtra(Intent
.EXTRA_SUBJECT
, feedback
);
248 intent
.setData(Uri
.parse(feedbackMail
));
249 intent
.addFlags(Intent
.FLAG_ACTIVITY_NEW_TASK
);
250 startActivity(intent
);
256 preferenceCategory
.removePreference(pFeedback
);
261 boolean imprintEnabled
= getResources().getBoolean(R
.bool
.imprint_enabled
);
262 Preference pImprint
= findPreference("imprint");
263 if (pImprint
!= null
) {
264 if (imprintEnabled
) {
265 pImprint
.setOnPreferenceClickListener(new OnPreferenceClickListener() {
267 public boolean onPreferenceClick(Preference preference
) {
268 String imprintWeb
= (String
) getText(R
.string
.url_imprint
);
269 if (imprintWeb
!= null
&& imprintWeb
.length() > 0) {
270 Uri uriUrl
= Uri
.parse(imprintWeb
);
271 Intent intent
= new Intent(Intent
.ACTION_VIEW
, uriUrl
);
272 startActivity(intent
);
274 //ImprintDialog.newInstance(true).show(preference.get, "IMPRINT_DIALOG");
279 preferenceCategory
.removePreference(pImprint
);
283 mPrefInstantUploadPath
= findPreference("instant_upload_path");
284 if (mPrefInstantUploadPath
!= null
){
286 mPrefInstantUploadPath
.setOnPreferenceClickListener(new OnPreferenceClickListener() {
288 public boolean onPreferenceClick(Preference preference
) {
289 if (!mUploadPath
.endsWith(OCFile
.PATH_SEPARATOR
)) {
290 mUploadPath
+= OCFile
.PATH_SEPARATOR
;
292 Intent intent
= new Intent(Preferences
.this, UploadPathActivity
.class);
293 intent
.putExtra(UploadPathActivity
.KEY_INSTANT_UPLOAD_PATH
, mUploadPath
);
294 startActivityForResult(intent
, ACTION_SELECT_UPLOAD_PATH
);
300 mPrefInstantUploadCategory
= (PreferenceCategory
) findPreference("instant_uploading_category");
302 mPrefInstantUploadPathWiFi
= findPreference("instant_upload_on_wifi");
303 mPrefInstantUpload
= findPreference("instant_uploading");
305 toggleInstantPictureOptions(((CheckBoxPreference
) mPrefInstantUpload
).isChecked());
307 mPrefInstantUpload
.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
310 public boolean onPreferenceChange(Preference preference
, Object newValue
) {
311 toggleInstantPictureOptions((Boolean
) newValue
);
316 mPrefInstantVideoUploadPath
= findPreference("instant_video_upload_path");
317 if (mPrefInstantVideoUploadPath
!= null
){
319 mPrefInstantVideoUploadPath
.setOnPreferenceClickListener(new OnPreferenceClickListener() {
321 public boolean onPreferenceClick(Preference preference
) {
322 if (!mUploadVideoPath
.endsWith(OCFile
.PATH_SEPARATOR
)) {
323 mUploadVideoPath
+= OCFile
.PATH_SEPARATOR
;
325 Intent intent
= new Intent(Preferences
.this, UploadPathActivity
.class);
326 intent
.putExtra(UploadPathActivity
.KEY_INSTANT_UPLOAD_PATH
, mUploadVideoPath
);
327 startActivityForResult(intent
, ACTION_SELECT_UPLOAD_VIDEO_PATH
);
333 mPrefInstantVideoUploadPathWiFi
= findPreference("instant_video_upload_on_wifi");
334 mPrefInstantVideoUpload
= findPreference("instant_video_uploading");
335 toggleInstantVideoOptions(((CheckBoxPreference
) mPrefInstantVideoUpload
).isChecked());
337 mPrefInstantVideoUpload
.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
340 public boolean onPreferenceChange(Preference preference
, Object newValue
) {
341 toggleInstantVideoOptions((Boolean
) newValue
);
347 pAboutApp
= (Preference
) findPreference("about_app");
348 if (pAboutApp
!= null
) {
349 pAboutApp
.setTitle(String
.format(getString(R
.string
.about_android
), getString(R
.string
.app_name
)));
350 pAboutApp
.setSummary(String
.format(getString(R
.string
.about_version
), appVersion
));
353 loadInstantUploadPath();
354 loadInstantUploadVideoPath();
356 /* ComponentsGetter */
357 mDownloadServiceConnection
= newTransferenceServiceConnection();
358 if (mDownloadServiceConnection
!= null
) {
359 bindService(new Intent(this, FileDownloader
.class), mDownloadServiceConnection
,
360 Context
.BIND_AUTO_CREATE
);
362 mUploadServiceConnection
= newTransferenceServiceConnection();
363 if (mUploadServiceConnection
!= null
) {
364 bindService(new Intent(this, FileUploader
.class), mUploadServiceConnection
,
365 Context
.BIND_AUTO_CREATE
);
370 private void toggleInstantPictureOptions(Boolean value
){
372 mPrefInstantUploadCategory
.addPreference(mPrefInstantUploadPathWiFi
);
373 mPrefInstantUploadCategory
.addPreference(mPrefInstantUploadPath
);
375 mPrefInstantUploadCategory
.removePreference(mPrefInstantUploadPathWiFi
);
376 mPrefInstantUploadCategory
.removePreference(mPrefInstantUploadPath
);
380 private void toggleInstantVideoOptions(Boolean value
){
382 mPrefInstantUploadCategory
.addPreference(mPrefInstantVideoUploadPathWiFi
);
383 mPrefInstantUploadCategory
.addPreference(mPrefInstantVideoUploadPath
);
385 mPrefInstantUploadCategory
.removePreference(mPrefInstantVideoUploadPathWiFi
);
386 mPrefInstantUploadCategory
.removePreference(mPrefInstantVideoUploadPath
);
391 protected void onPause() {
396 public void onCreateContextMenu(ContextMenu menu
, View v
, ContextMenuInfo menuInfo
) {
398 // Filter for only showing contextual menu when long press on the
400 if (mShowContextMenu
) {
401 getMenuInflater().inflate(R
.menu
.account_picker_long_click
, menu
);
402 mShowContextMenu
= false
;
404 super.onCreateContextMenu(menu
, v
, menuInfo
);
408 * Called when the user clicked on an item into the context menu created at
409 * {@link #onCreateContextMenu(ContextMenu, View, ContextMenuInfo)} for
410 * every ownCloud {@link Account} , containing 'secondary actions' for them.
415 public boolean onContextItemSelected(android
.view
.MenuItem item
) {
416 AccountManager am
= (AccountManager
) getSystemService(ACCOUNT_SERVICE
);
417 Account accounts
[] = am
.getAccountsByType(MainApp
.getAccountType());
418 for (Account a
: accounts
) {
419 if (a
.name
.equals(mAccountName
)) {
420 if (item
.getItemId() == R
.id
.change_password
) {
422 // Change account password
423 Intent updateAccountCredentials
= new Intent(this, AuthenticatorActivity
.class);
424 updateAccountCredentials
.putExtra(AuthenticatorActivity
.EXTRA_ACCOUNT
, a
);
425 updateAccountCredentials
.putExtra(AuthenticatorActivity
.EXTRA_ACTION
,
426 AuthenticatorActivity
.ACTION_UPDATE_TOKEN
);
427 startActivity(updateAccountCredentials
);
429 } else if (item
.getItemId() == R
.id
.delete_account
) {
432 am
.removeAccount(a
, this, mHandler
);
433 Log_OC
.d(TAG
, "Remove an account " + a
.name
);
442 public void run(AccountManagerFuture
<Boolean
> future
) {
443 if (future
.isDone()) {
444 // after remove account
445 Account account
= new Account(mAccountName
, MainApp
.getAccountType());
446 if (!AccountUtils
.exists(account
, MainApp
.getAppContext())) {
448 if (mUploaderBinder
!= null
) {
449 mUploaderBinder
.cancel(account
);
451 if (mDownloaderBinder
!= null
) {
452 mDownloaderBinder
.cancel(account
);
456 Account a
= AccountUtils
.getCurrentOwnCloudAccount(this);
457 String accountName
= "";
459 Account
[] accounts
= AccountManager
.get(this).getAccountsByType(MainApp
.getAccountType());
460 if (accounts
.length
!= 0)
461 accountName
= accounts
[0].name
;
462 AccountUtils
.setCurrentOwnCloudAccount(this, accountName
);
464 addAccountsCheckboxPreferences();
469 protected void onResume() {
471 SharedPreferences appPrefs
= PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
472 boolean state
= appPrefs
.getBoolean("set_pincode", false
);
473 pCode
.setChecked(state
);
475 // Populate the accounts category with the list of accounts
476 addAccountsCheckboxPreferences();
480 public boolean onCreateOptionsMenu(Menu menu
) {
481 super.onCreateOptionsMenu(menu
);
486 public boolean onMenuItemSelected(int featureId
, MenuItem item
) {
487 super.onMenuItemSelected(featureId
, item
);
490 switch (item
.getItemId()) {
491 case android
.R
.id
.home
:
492 intent
= new Intent(getBaseContext(), FileDisplayActivity
.class);
493 intent
.addFlags(Intent
.FLAG_ACTIVITY_CLEAR_TOP
);
494 startActivity(intent
);
497 Log_OC
.w(TAG
, "Unknown menu item triggered");
504 protected void onActivityResult(int requestCode
, int resultCode
, Intent data
) {
505 super.onActivityResult(requestCode
, resultCode
, data
);
507 if (requestCode
== ACTION_SELECT_UPLOAD_PATH
&& resultCode
== RESULT_OK
){
509 OCFile folderToUpload
= (OCFile
) data
.getParcelableExtra(UploadPathActivity
.EXTRA_FOLDER
);
511 mUploadPath
= folderToUpload
.getRemotePath();
513 mUploadPath
= DisplayUtils
.getPathWithoutLastSlash(mUploadPath
);
515 // Show the path on summary preference
516 mPrefInstantUploadPath
.setSummary(mUploadPath
);
518 saveInstantUploadPathOnPreferences();
520 } else if (requestCode
== ACTION_SELECT_UPLOAD_VIDEO_PATH
&& resultCode
== RESULT_OK
){
522 OCFile folderToUploadVideo
= (OCFile
) data
.getParcelableExtra(UploadPathActivity
.EXTRA_FOLDER
);
524 mUploadVideoPath
= folderToUploadVideo
.getRemotePath();
526 mUploadVideoPath
= DisplayUtils
.getPathWithoutLastSlash(mUploadVideoPath
);
528 // Show the video path on summary preference
529 mPrefInstantVideoUploadPath
.setSummary(mUploadVideoPath
);
531 saveInstantUploadVideoPathOnPreferences();
536 protected void onDestroy() {
539 if (mDownloadServiceConnection
!= null
) {
540 unbindService(mDownloadServiceConnection
);
541 mDownloadServiceConnection
= null
;
543 if (mUploadServiceConnection
!= null
) {
544 unbindService(mUploadServiceConnection
);
545 mUploadServiceConnection
= null
;
552 * Create the list of accounts that has been added into the app
554 @SuppressWarnings("deprecation")
555 private void addAccountsCheckboxPreferences() {
557 // Remove accounts in case list is refreshing for avoiding to have
559 if (mAccountsPrefCategory
.getPreferenceCount() > 0) {
560 mAccountsPrefCategory
.removeAll();
563 AccountManager am
= (AccountManager
) getSystemService(ACCOUNT_SERVICE
);
564 Account accounts
[] = am
.getAccountsByType(MainApp
.getAccountType());
565 Account currentAccount
= AccountUtils
.getCurrentOwnCloudAccount(getApplicationContext());
567 if (am
.getAccountsByType(MainApp
.getAccountType()).length
== 0) {
568 // Show create account screen if there isn't any account
569 am
.addAccount(MainApp
.getAccountType(), null
, null
, null
, this,
575 for (Account a
: accounts
) {
576 RadioButtonPreference accountPreference
= new RadioButtonPreference(this);
577 accountPreference
.setKey(a
.name
);
578 // Handle internationalized domain names
579 accountPreference
.setTitle(DisplayUtils
.convertIdn(a
.name
, false
));
580 mAccountsPrefCategory
.addPreference(accountPreference
);
582 // Check the current account that is being used
583 if (a
.name
.equals(currentAccount
.name
)) {
584 accountPreference
.setChecked(true
);
586 accountPreference
.setChecked(false
);
589 accountPreference
.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
591 public boolean onPreferenceChange(Preference preference
, Object newValue
) {
592 String key
= preference
.getKey();
593 AccountManager am
= (AccountManager
) getSystemService(ACCOUNT_SERVICE
);
594 Account accounts
[] = am
.getAccountsByType(MainApp
.getAccountType());
595 for (Account a
: accounts
) {
596 RadioButtonPreference p
= (RadioButtonPreference
) findPreference(a
.name
);
597 if (key
.equals(a
.name
)) {
598 boolean accountChanged
= !p
.isChecked();
600 AccountUtils
.setCurrentOwnCloudAccount(
601 getApplicationContext(),
604 if (accountChanged
) {
605 // restart the main activity
606 Intent i
= new Intent(
608 FileDisplayActivity
.class
610 i
.addFlags(Intent
.FLAG_ACTIVITY_CLEAR_TOP
);
619 return (Boolean
) newValue
;
625 // Add Create Account preference at the end of account list if
626 // Multiaccount is enabled
627 if (getResources().getBoolean(R
.bool
.multiaccount_support
)) {
628 createAddAccountPreference();
635 * Create the preference for allow adding new accounts
637 private void createAddAccountPreference() {
638 Preference addAccountPref
= new Preference(this);
639 addAccountPref
.setKey("add_account");
640 addAccountPref
.setTitle(getString(R
.string
.prefs_add_account
));
641 mAccountsPrefCategory
.addPreference(addAccountPref
);
643 addAccountPref
.setOnPreferenceClickListener(new OnPreferenceClickListener() {
645 public boolean onPreferenceClick(Preference preference
) {
646 AccountManager am
= AccountManager
.get(getApplicationContext());
647 am
.addAccount(MainApp
.getAccountType(), null
, null
, null
, Preferences
.this, null
, null
);
655 * Load upload path set on preferences
657 private void loadInstantUploadPath() {
658 SharedPreferences appPrefs
= PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
659 mUploadPath
= appPrefs
.getString("instant_upload_path", getString(R
.string
.instant_upload_path
));
660 mPrefInstantUploadPath
.setSummary(mUploadPath
);
664 * Save the "Instant Upload Path" on preferences
666 private void saveInstantUploadPathOnPreferences() {
667 SharedPreferences appPrefs
= PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
668 SharedPreferences
.Editor editor
= appPrefs
.edit();
669 editor
.putString("instant_upload_path", mUploadPath
);
674 * Load upload video path set on preferences
676 private void loadInstantUploadVideoPath() {
677 SharedPreferences appPrefs
= PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
678 mUploadVideoPath
= appPrefs
.getString("instant_video_upload_path", getString(R
.string
.instant_upload_path
));
679 mPrefInstantVideoUploadPath
.setSummary(mUploadVideoPath
);
683 * Save the "Instant Video Upload Path" on preferences
685 private void saveInstantUploadVideoPathOnPreferences() {
686 SharedPreferences appPrefs
= PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
687 SharedPreferences
.Editor editor
= appPrefs
.edit();
688 editor
.putString("instant_video_upload_path", mUploadVideoPath
);
692 // Methods for ComponetsGetter
694 public FileDownloader
.FileDownloaderBinder
getFileDownloaderBinder() {
695 return mDownloaderBinder
;
700 public FileUploader
.FileUploaderBinder
getFileUploaderBinder() {
701 return mUploaderBinder
;
705 public OperationsService
.OperationsServiceBinder
getOperationsServiceBinder() {
710 public FileDataStorageManager
getStorageManager() {
715 public FileOperationsHelper
getFileOperationsHelper() {
719 protected ServiceConnection
newTransferenceServiceConnection() {
720 return new PreferencesServiceConnection();
723 /** Defines callbacks for service binding, passed to bindService() */
724 private class PreferencesServiceConnection
implements ServiceConnection
{
727 public void onServiceConnected(ComponentName component
, IBinder service
) {
729 if (component
.equals(new ComponentName(Preferences
.this, FileDownloader
.class))) {
730 mDownloaderBinder
= (FileDownloader
.FileDownloaderBinder
) service
;
732 } else if (component
.equals(new ComponentName(Preferences
.this, FileUploader
.class))) {
733 Log_OC
.d(TAG
, "Upload service connected");
734 mUploaderBinder
= (FileUploader
.FileUploaderBinder
) service
;
742 public void onServiceDisconnected(ComponentName component
) {
743 if (component
.equals(new ComponentName(Preferences
.this, FileDownloader
.class))) {
744 Log_OC
.d(TAG
, "Download service suddenly disconnected");
745 mDownloaderBinder
= null
;
746 } else if (component
.equals(new ComponentName(Preferences
.this, FileUploader
.class))) {
747 Log_OC
.d(TAG
, "Upload service suddenly disconnected");
748 mUploaderBinder
= null
;