Merge branch 'develop' into SettingsGreyedOut
[pub/Android/ownCloud.git] / src / com / owncloud / android / ui / activity / Preferences.java
1 /* ownCloud Android client application
2 * Copyright (C) 2011 Bartek Przybylski
3 * Copyright (C) 2012-2013 ownCloud Inc.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2,
7 * as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 */
18 package com.owncloud.android.ui.activity;
19
20 import android.accounts.Account;
21 import android.accounts.AccountManager;
22 import android.accounts.AccountManagerCallback;
23 import android.accounts.AccountManagerFuture;
24 import android.content.Intent;
25 import android.content.SharedPreferences;
26 import android.content.pm.PackageInfo;
27 import android.content.pm.PackageManager.NameNotFoundException;
28 import android.net.Uri;
29 import android.os.Bundle;
30 import android.os.Handler;
31 import android.preference.CheckBoxPreference;
32 import android.preference.Preference;
33 import android.preference.Preference.OnPreferenceChangeListener;
34 import android.preference.Preference.OnPreferenceClickListener;
35 import android.preference.PreferenceCategory;
36 import android.preference.PreferenceManager;
37 import android.view.ContextMenu;
38 import android.view.ContextMenu.ContextMenuInfo;
39 import android.view.View;
40 import android.widget.AdapterView;
41 import android.widget.AdapterView.OnItemLongClickListener;
42 import android.widget.ListAdapter;
43 import android.widget.ListView;
44
45 import com.actionbarsherlock.app.ActionBar;
46 import com.actionbarsherlock.app.SherlockPreferenceActivity;
47 import com.actionbarsherlock.view.Menu;
48 import com.actionbarsherlock.view.MenuItem;
49 import com.owncloud.android.MainApp;
50 import com.owncloud.android.R;
51 import com.owncloud.android.authentication.AccountUtils;
52 import com.owncloud.android.authentication.AuthenticatorActivity;
53 import com.owncloud.android.datamodel.OCFile;
54 import com.owncloud.android.db.DbHandler;
55 import com.owncloud.android.lib.common.utils.Log_OC;
56 import com.owncloud.android.ui.RadioButtonPreference;
57 import com.owncloud.android.utils.DisplayUtils;
58
59
60 /**
61 * An Activity that allows the user to change the application's settings.
62 *
63 * @author Bartek Przybylski
64 * @author David A. Velasco
65 */
66 public class Preferences extends SherlockPreferenceActivity implements AccountManagerCallback<Boolean> {
67
68 private static final String TAG = "OwnCloudPreferences";
69
70 private static final int ACTION_SELECT_UPLOAD_PATH = 1;
71 private static final int ACTION_SELECT_UPLOAD_VIDEO_PATH = 2;
72
73 private DbHandler mDbHandler;
74 private CheckBoxPreference pCode;
75 private Preference pAboutApp;
76
77 private PreferenceCategory mAccountsPrefCategory = null;
78 private final Handler mHandler = new Handler();
79 private String mAccountName;
80 private boolean mShowContextMenu = false;
81 private String mUploadPath;
82 private PreferenceCategory mPrefInstantUploadCategory;
83 private Preference mPrefInstantUpload;
84 private Preference mPrefInstantUploadPath;
85 private Preference mPrefInstantUploadPathWiFi;
86 private Preference mPrefInstantVideoUpload;
87 private Preference mPrefInstantVideoUploadPath;
88 private Preference mPrefInstantVideoUploadPathWiFi;
89 private String mUploadVideoPath;
90
91
92 @SuppressWarnings("deprecation")
93 @Override
94 public void onCreate(Bundle savedInstanceState) {
95 super.onCreate(savedInstanceState);
96 mDbHandler = new DbHandler(getBaseContext());
97 addPreferencesFromResource(R.xml.preferences);
98
99 ActionBar actionBar = getSherlock().getActionBar();
100 actionBar.setIcon(DisplayUtils.getSeasonalIconId());
101 actionBar.setDisplayHomeAsUpEnabled(true);
102 actionBar.setTitle(R.string.actionbar_settings);
103
104 // Load the accounts category for adding the list of accounts
105 mAccountsPrefCategory = (PreferenceCategory) findPreference("accounts_category");
106
107 ListView listView = getListView();
108 listView.setOnItemLongClickListener(new OnItemLongClickListener() {
109 @Override
110 public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
111 ListView listView = (ListView) parent;
112 ListAdapter listAdapter = listView.getAdapter();
113 Object obj = listAdapter.getItem(position);
114
115 if (obj != null && obj instanceof RadioButtonPreference) {
116 mShowContextMenu = true;
117 mAccountName = ((RadioButtonPreference) obj).getKey();
118
119 Preferences.this.openContextMenu(listView);
120
121 View.OnLongClickListener longListener = (View.OnLongClickListener) obj;
122 return longListener.onLongClick(view);
123 }
124 return false;
125 }
126 });
127
128 // Load package info
129 String temp;
130 try {
131 PackageInfo pkg = getPackageManager().getPackageInfo(getPackageName(), 0);
132 temp = pkg.versionName;
133 } catch (NameNotFoundException e) {
134 temp = "";
135 Log_OC.e(TAG, "Error while showing about dialog", e);
136 }
137 final String appVersion = temp;
138
139 // Register context menu for list of preferences.
140 registerForContextMenu(getListView());
141
142 pCode = (CheckBoxPreference) findPreference("set_pincode");
143 if (pCode != null){
144 pCode.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
145 @Override
146 public boolean onPreferenceChange(Preference preference, Object newValue) {
147 Intent i = new Intent(getApplicationContext(), PinCodeActivity.class);
148 i.putExtra(PinCodeActivity.EXTRA_ACTIVITY, "preferences");
149 i.putExtra(PinCodeActivity.EXTRA_NEW_STATE, newValue.toString());
150 startActivity(i);
151
152 return true;
153 }
154 });
155
156 }
157
158 PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference("more");
159
160 boolean helpEnabled = getResources().getBoolean(R.bool.help_enabled);
161 Preference pHelp = findPreference("help");
162 if (pHelp != null ){
163 if (helpEnabled) {
164 pHelp.setOnPreferenceClickListener(new OnPreferenceClickListener() {
165 @Override
166 public boolean onPreferenceClick(Preference preference) {
167 String helpWeb =(String) getText(R.string.url_help);
168 if (helpWeb != null && helpWeb.length() > 0) {
169 Uri uriUrl = Uri.parse(helpWeb);
170 Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
171 startActivity(intent);
172 }
173 return true;
174 }
175 });
176 } else {
177 preferenceCategory.removePreference(pHelp);
178 }
179
180 }
181
182
183 boolean recommendEnabled = getResources().getBoolean(R.bool.recommend_enabled);
184 Preference pRecommend = findPreference("recommend");
185 if (pRecommend != null){
186 if (recommendEnabled) {
187 pRecommend.setOnPreferenceClickListener(new OnPreferenceClickListener() {
188 @Override
189 public boolean onPreferenceClick(Preference preference) {
190
191 Intent intent = new Intent(Intent.ACTION_SENDTO);
192 intent.setType("text/plain");
193 intent.setData(Uri.parse(getString(R.string.mail_recommend)));
194 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
195
196 String appName = getString(R.string.app_name);
197 String downloadUrl = getString(R.string.url_app_download);
198 Account currentAccount = AccountUtils.getCurrentOwnCloudAccount(Preferences.this);
199 String username = currentAccount.name.substring(0, currentAccount.name.lastIndexOf('@'));
200
201 String recommendSubject = String.format(getString(R.string.recommend_subject), appName);
202 String recommendText = String.format(getString(R.string.recommend_text), appName, downloadUrl, username);
203
204 intent.putExtra(Intent.EXTRA_SUBJECT, recommendSubject);
205 intent.putExtra(Intent.EXTRA_TEXT, recommendText);
206 startActivity(intent);
207
208
209 return(true);
210
211 }
212 });
213 } else {
214 preferenceCategory.removePreference(pRecommend);
215 }
216
217 }
218
219 boolean feedbackEnabled = getResources().getBoolean(R.bool.feedback_enabled);
220 Preference pFeedback = findPreference("feedback");
221 if (pFeedback != null){
222 if (feedbackEnabled) {
223 pFeedback.setOnPreferenceClickListener(new OnPreferenceClickListener() {
224 @Override
225 public boolean onPreferenceClick(Preference preference) {
226 String feedbackMail =(String) getText(R.string.mail_feedback);
227 String feedback =(String) getText(R.string.prefs_feedback) + " - android v" + appVersion;
228 Intent intent = new Intent(Intent.ACTION_SENDTO);
229 intent.setType("text/plain");
230 intent.putExtra(Intent.EXTRA_SUBJECT, feedback);
231
232 intent.setData(Uri.parse(feedbackMail));
233 intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
234 startActivity(intent);
235
236 return true;
237 }
238 });
239 } else {
240 preferenceCategory.removePreference(pFeedback);
241 }
242
243 }
244
245 boolean imprintEnabled = getResources().getBoolean(R.bool.imprint_enabled);
246 Preference pImprint = findPreference("imprint");
247 if (pImprint != null) {
248 if (imprintEnabled) {
249 pImprint.setOnPreferenceClickListener(new OnPreferenceClickListener() {
250 @Override
251 public boolean onPreferenceClick(Preference preference) {
252 String imprintWeb = (String) getText(R.string.url_imprint);
253 if (imprintWeb != null && imprintWeb.length() > 0) {
254 Uri uriUrl = Uri.parse(imprintWeb);
255 Intent intent = new Intent(Intent.ACTION_VIEW, uriUrl);
256 startActivity(intent);
257 }
258 //ImprintDialog.newInstance(true).show(preference.get, "IMPRINT_DIALOG");
259 return true;
260 }
261 });
262 } else {
263 preferenceCategory.removePreference(pImprint);
264 }
265 }
266
267 mPrefInstantUploadPath = findPreference("instant_upload_path");
268 if (mPrefInstantUploadPath != null){
269
270 mPrefInstantUploadPath.setOnPreferenceClickListener(new OnPreferenceClickListener() {
271 @Override
272 public boolean onPreferenceClick(Preference preference) {
273 if (!mUploadPath.endsWith(OCFile.PATH_SEPARATOR)) {
274 mUploadPath += OCFile.PATH_SEPARATOR;
275 }
276 Intent intent = new Intent(Preferences.this, UploadPathActivity.class);
277 intent.putExtra(UploadPathActivity.KEY_INSTANT_UPLOAD_PATH, mUploadPath);
278 startActivityForResult(intent, ACTION_SELECT_UPLOAD_PATH);
279 return true;
280 }
281 });
282 }
283
284 mPrefInstantUploadCategory = (PreferenceCategory) findPreference("instant_uploading_category");
285
286 mPrefInstantUploadPathWiFi = findPreference("instant_upload_on_wifi");
287 mPrefInstantUpload = findPreference("instant_uploading");
288
289 toggleInstantPictureOptions(((CheckBoxPreference) mPrefInstantUpload).isChecked());
290
291 mPrefInstantUpload.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
292
293 @Override
294 public boolean onPreferenceChange(Preference preference, Object newValue) {
295 toggleInstantPictureOptions((Boolean) newValue);
296 return true;
297 }
298 });
299
300 mPrefInstantVideoUploadPath = findPreference("instant_video_upload_path");
301 if (mPrefInstantVideoUploadPath != null){
302
303 mPrefInstantVideoUploadPath.setOnPreferenceClickListener(new OnPreferenceClickListener() {
304 @Override
305 public boolean onPreferenceClick(Preference preference) {
306 if (!mUploadVideoPath.endsWith(OCFile.PATH_SEPARATOR)) {
307 mUploadVideoPath += OCFile.PATH_SEPARATOR;
308 }
309 Intent intent = new Intent(Preferences.this, UploadPathActivity.class);
310 intent.putExtra(UploadPathActivity.KEY_INSTANT_UPLOAD_PATH, mUploadVideoPath);
311 startActivityForResult(intent, ACTION_SELECT_UPLOAD_VIDEO_PATH);
312 return true;
313 }
314 });
315 }
316
317 mPrefInstantVideoUploadPathWiFi = findPreference("instant_video_upload_on_wifi");
318 mPrefInstantVideoUpload = findPreference("instant_video_uploading");
319 toggleInstantVideoOptions(((CheckBoxPreference) mPrefInstantUpload).isChecked());
320
321 mPrefInstantVideoUpload.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
322
323 @Override
324 public boolean onPreferenceChange(Preference preference, Object newValue) {
325 toggleInstantVideoOptions((Boolean) newValue);
326 return true;
327 }
328 });
329
330 /* About App */
331 pAboutApp = (Preference) findPreference("about_app");
332 if (pAboutApp != null) {
333 pAboutApp.setTitle(String.format(getString(R.string.about_android), getString(R.string.app_name)));
334 pAboutApp.setSummary(String.format(getString(R.string.about_version), appVersion));
335 }
336
337 loadInstantUploadPath();
338 loadInstantUploadVideoPath();
339
340 }
341
342 private void toggleInstantPictureOptions(Boolean value){
343 if (value){
344 mPrefInstantUploadCategory.addPreference(mPrefInstantUploadPathWiFi);
345 mPrefInstantUploadCategory.addPreference(mPrefInstantUploadPath);
346 } else {
347 mPrefInstantUploadCategory.removePreference(mPrefInstantUploadPathWiFi);
348 mPrefInstantUploadCategory.removePreference(mPrefInstantUploadPath);
349 }
350 }
351
352 private void toggleInstantVideoOptions(Boolean value){
353 if (value){
354 mPrefInstantUploadCategory.addPreference(mPrefInstantVideoUploadPathWiFi);
355 mPrefInstantUploadCategory.addPreference(mPrefInstantVideoUploadPath);
356 } else {
357 mPrefInstantUploadCategory.removePreference(mPrefInstantVideoUploadPathWiFi);
358 mPrefInstantUploadCategory.removePreference(mPrefInstantVideoUploadPath);
359 }
360 }
361
362 @Override
363 protected void onPause() {
364 super.onPause();
365 }
366
367 @Override
368 public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
369
370 // Filter for only showing contextual menu when long press on the
371 // accounts
372 if (mShowContextMenu) {
373 getMenuInflater().inflate(R.menu.account_picker_long_click, menu);
374 mShowContextMenu = false;
375 }
376 super.onCreateContextMenu(menu, v, menuInfo);
377 }
378
379 /**
380 * Called when the user clicked on an item into the context menu created at
381 * {@link #onCreateContextMenu(ContextMenu, View, ContextMenuInfo)} for
382 * every ownCloud {@link Account} , containing 'secondary actions' for them.
383 *
384 * {@inheritDoc}
385 */
386 @Override
387 public boolean onContextItemSelected(android.view.MenuItem item) {
388 AccountManager am = (AccountManager) getSystemService(ACCOUNT_SERVICE);
389 Account accounts[] = am.getAccountsByType(MainApp.getAccountType());
390 for (Account a : accounts) {
391 if (a.name.equals(mAccountName)) {
392 if (item.getItemId() == R.id.change_password) {
393
394 // Change account password
395 Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
396 updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, a);
397 updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACTION,
398 AuthenticatorActivity.ACTION_UPDATE_TOKEN);
399 startActivity(updateAccountCredentials);
400
401 } else if (item.getItemId() == R.id.delete_account) {
402
403 // Remove account
404 am.removeAccount(a, this, mHandler);
405 }
406 }
407 }
408
409 return true;
410 }
411
412 @Override
413 public void run(AccountManagerFuture<Boolean> future) {
414 if (future.isDone()) {
415 Account a = AccountUtils.getCurrentOwnCloudAccount(this);
416 String accountName = "";
417 if (a == null) {
418 Account[] accounts = AccountManager.get(this).getAccountsByType(MainApp.getAccountType());
419 if (accounts.length != 0)
420 accountName = accounts[0].name;
421 AccountUtils.setCurrentOwnCloudAccount(this, accountName);
422 }
423 addAccountsCheckboxPreferences();
424 }
425 }
426
427 @Override
428 protected void onResume() {
429 super.onResume();
430 SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
431 boolean state = appPrefs.getBoolean("set_pincode", false);
432 pCode.setChecked(state);
433
434 // Populate the accounts category with the list of accounts
435 addAccountsCheckboxPreferences();
436 }
437
438 @Override
439 public boolean onCreateOptionsMenu(Menu menu) {
440 super.onCreateOptionsMenu(menu);
441 return true;
442 }
443
444 @Override
445 public boolean onMenuItemSelected(int featureId, MenuItem item) {
446 super.onMenuItemSelected(featureId, item);
447 Intent intent;
448
449 switch (item.getItemId()) {
450 case android.R.id.home:
451 intent = new Intent(getBaseContext(), FileDisplayActivity.class);
452 intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
453 startActivity(intent);
454 break;
455 default:
456 Log_OC.w(TAG, "Unknown menu item triggered");
457 return false;
458 }
459 return true;
460 }
461
462 @Override
463 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
464 super.onActivityResult(requestCode, resultCode, data);
465
466 if (requestCode == ACTION_SELECT_UPLOAD_PATH && resultCode == RESULT_OK){
467
468 OCFile folderToUpload = (OCFile) data.getParcelableExtra(UploadPathActivity.EXTRA_FOLDER);
469
470 mUploadPath = folderToUpload.getRemotePath();
471
472 mUploadPath = DisplayUtils.getPathWithoutLastSlash(mUploadPath);
473
474 // Show the path on summary preference
475 mPrefInstantUploadPath.setSummary(mUploadPath);
476
477 saveInstantUploadPathOnPreferences();
478
479 } else if (requestCode == ACTION_SELECT_UPLOAD_VIDEO_PATH && resultCode == RESULT_OK){
480
481 OCFile folderToUploadVideo = (OCFile) data.getParcelableExtra(UploadPathActivity.EXTRA_FOLDER);
482
483 mUploadVideoPath = folderToUploadVideo.getRemotePath();
484
485 mUploadVideoPath = DisplayUtils.getPathWithoutLastSlash(mUploadVideoPath);
486
487 // Show the video path on summary preference
488 mPrefInstantVideoUploadPath.setSummary(mUploadVideoPath);
489
490 saveInstantUploadVideoPathOnPreferences();
491 }
492 }
493
494 @Override
495 protected void onDestroy() {
496 mDbHandler.close();
497 super.onDestroy();
498 }
499
500 /**
501 * Create the list of accounts that has been added into the app
502 */
503 @SuppressWarnings("deprecation")
504 private void addAccountsCheckboxPreferences() {
505
506 // Remove accounts in case list is refreshing for avoiding to have
507 // duplicate items
508 if (mAccountsPrefCategory.getPreferenceCount() > 0) {
509 mAccountsPrefCategory.removeAll();
510 }
511
512 AccountManager am = (AccountManager) getSystemService(ACCOUNT_SERVICE);
513 Account accounts[] = am.getAccountsByType(MainApp.getAccountType());
514 Account currentAccount = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext());
515
516 if (am.getAccountsByType(MainApp.getAccountType()).length == 0) {
517 // Show create account screen if there isn't any account
518 am.addAccount(MainApp.getAccountType(), null, null, null, this,
519 null,
520 null);
521 }
522 else {
523
524 for (Account a : accounts) {
525 RadioButtonPreference accountPreference = new RadioButtonPreference(this);
526 accountPreference.setKey(a.name);
527 // Handle internationalized domain names
528 accountPreference.setTitle(DisplayUtils.convertIdn(a.name, false));
529 mAccountsPrefCategory.addPreference(accountPreference);
530
531 // Check the current account that is being used
532 if (a.name.equals(currentAccount.name)) {
533 accountPreference.setChecked(true);
534 } else {
535 accountPreference.setChecked(false);
536 }
537
538 accountPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
539 @Override
540 public boolean onPreferenceChange(Preference preference, Object newValue) {
541 String key = preference.getKey();
542 AccountManager am = (AccountManager) getSystemService(ACCOUNT_SERVICE);
543 Account accounts[] = am.getAccountsByType(MainApp.getAccountType());
544 for (Account a : accounts) {
545 RadioButtonPreference p = (RadioButtonPreference) findPreference(a.name);
546 if (key.equals(a.name)) {
547 boolean accountChanged = !p.isChecked();
548 p.setChecked(true);
549 AccountUtils.setCurrentOwnCloudAccount(
550 getApplicationContext(),
551 a.name
552 );
553 if (accountChanged) {
554 // restart the main activity
555 Intent i = new Intent(
556 Preferences.this,
557 FileDisplayActivity.class
558 );
559 i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
560 startActivity(i);
561 } else {
562 finish();
563 }
564 } else {
565 p.setChecked(false);
566 }
567 }
568 return (Boolean) newValue;
569 }
570 });
571
572 }
573
574 // Add Create Account preference at the end of account list if
575 // Multiaccount is enabled
576 if (getResources().getBoolean(R.bool.multiaccount_support)) {
577 createAddAccountPreference();
578 }
579
580 }
581 }
582
583 /**
584 * Create the preference for allow adding new accounts
585 */
586 private void createAddAccountPreference() {
587 Preference addAccountPref = new Preference(this);
588 addAccountPref.setKey("add_account");
589 addAccountPref.setTitle(getString(R.string.prefs_add_account));
590 mAccountsPrefCategory.addPreference(addAccountPref);
591
592 addAccountPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
593 @Override
594 public boolean onPreferenceClick(Preference preference) {
595 AccountManager am = AccountManager.get(getApplicationContext());
596 am.addAccount(MainApp.getAccountType(), null, null, null, Preferences.this, null, null);
597 return true;
598 }
599 });
600
601 }
602
603 /**
604 * Load upload path set on preferences
605 */
606 private void loadInstantUploadPath() {
607 SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
608 mUploadPath = appPrefs.getString("instant_upload_path", getString(R.string.instant_upload_path));
609 mPrefInstantUploadPath.setSummary(mUploadPath);
610 }
611
612 /**
613 * Save the "Instant Upload Path" on preferences
614 */
615 private void saveInstantUploadPathOnPreferences() {
616 SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
617 SharedPreferences.Editor editor = appPrefs.edit();
618 editor.putString("instant_upload_path", mUploadPath);
619 editor.commit();
620 }
621
622 /**
623 * Load upload video path set on preferences
624 */
625 private void loadInstantUploadVideoPath() {
626 SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
627 mUploadVideoPath = appPrefs.getString("instant_video_upload_path", getString(R.string.instant_upload_path));
628 mPrefInstantVideoUploadPath.setSummary(mUploadVideoPath);
629 }
630
631 /**
632 * Save the "Instant Video Upload Path" on preferences
633 */
634 private void saveInstantUploadVideoPathOnPreferences() {
635 SharedPreferences appPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
636 SharedPreferences.Editor editor = appPrefs.edit();
637 editor.putString("instant_video_upload_path", mUploadVideoPath);
638 editor.commit();
639 }
640 }