DrawerActivity.java 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. /**
  2. * ownCloud Android client application
  3. *
  4. * @author Andy Scherzinger
  5. * Copyright (C) 2016 ownCloud Inc.
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2,
  9. * as published by the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.owncloud.android.ui.activity;
  20. import android.accounts.Account;
  21. import android.accounts.AccountManager;
  22. import android.accounts.AccountManagerCallback;
  23. import android.accounts.AccountManagerFuture;
  24. import android.accounts.OperationCanceledException;
  25. import android.content.Intent;
  26. import android.content.res.Configuration;
  27. import android.os.Bundle;
  28. import android.os.Handler;
  29. import android.support.design.widget.NavigationView;
  30. import android.support.v4.view.GravityCompat;
  31. import android.support.v4.widget.DrawerLayout;
  32. import android.support.v7.app.ActionBarDrawerToggle;
  33. import android.view.Menu;
  34. import android.view.MenuItem;
  35. import android.view.View;
  36. import android.widget.ImageView;
  37. import android.widget.TextView;
  38. import android.widget.Toast;
  39. import com.owncloud.android.MainApp;
  40. import com.owncloud.android.R;
  41. import com.owncloud.android.authentication.AccountUtils;
  42. import com.owncloud.android.datamodel.FileDataStorageManager;
  43. import com.owncloud.android.datamodel.OCFile;
  44. import com.owncloud.android.lib.common.utils.Log_OC;
  45. import com.owncloud.android.lib.resources.status.OCCapability;
  46. import com.owncloud.android.ui.TextDrawable;
  47. import com.owncloud.android.utils.BitmapUtils;
  48. /**
  49. * Base class to handle setup of the drawer implementation.
  50. */
  51. public abstract class DrawerActivity extends ToolbarActivity {
  52. private static final String TAG = DrawerActivity.class.getSimpleName();
  53. private static final String KEY_IS_ACCOUNT_CHOOSER_ACTIVE = "IS_ACCOUNT_CHOOSER_ACTIVE";
  54. private static final int ACTION_MANAGE_ACCOUNTS = 101;
  55. /**
  56. * Reference to the drawer layout.
  57. */
  58. private DrawerLayout mDrawerLayout;
  59. /**
  60. * Reference to the drawer toggle.
  61. */
  62. private ActionBarDrawerToggle mDrawerToggle;
  63. /**
  64. * Reference to the navigation view.
  65. */
  66. private NavigationView mNavigationView;
  67. /**
  68. * Reference to the account chooser toogle.
  69. */
  70. private ImageView mAccountChooserToggle;
  71. /**
  72. * ownCloud {@link Account} where the main {@link OCFile} handled by the activity is located.
  73. */
  74. private Account mCurrentAccount;
  75. /**
  76. * Flag to signal if the account chooser is active.
  77. */
  78. private boolean mIsAccountChooserActive;
  79. /**
  80. * Flag to signal that the activity will is finishing to enforce the creation of an ownCloud {@link Account}.
  81. */
  82. private boolean mRedirectingToSetupAccount = false;
  83. /**
  84. * Flag to signal when the value of mAccount was set.
  85. */
  86. protected boolean mAccountWasSet;
  87. /**
  88. * Flag to signal when the value of mAccount was restored from a saved state.
  89. */
  90. protected boolean mAccountWasRestored;
  91. /**
  92. * Capabilites of the server where {@link #mCurrentAccount} lives.
  93. */
  94. private OCCapability mCapabilities;
  95. /**
  96. * Access point to the cached database for the current ownCloud {@link Account}.
  97. */
  98. private FileDataStorageManager mStorageManager = null;
  99. /**
  100. * Initializes the drawer and its content.
  101. * This method needs to be called after the content view has been set.
  102. */
  103. protected void setupDrawer() {
  104. mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
  105. mNavigationView = (NavigationView) findViewById(R.id.nav_view);
  106. if (mNavigationView != null) {
  107. setupDrawerContent(mNavigationView);
  108. mAccountChooserToggle = (ImageView) findNavigationViewChildById(R.id.drawer_account_chooser_toogle);
  109. mAccountChooserToggle.setImageResource(R.drawable.ic_down);
  110. mIsAccountChooserActive = false;
  111. findNavigationViewChildById(R.id.drawer_active_user)
  112. .setOnClickListener(new View.OnClickListener() {
  113. @Override
  114. public void onClick(View v) {
  115. toggleAccountList();
  116. }
  117. });
  118. }
  119. mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.string.drawer_open, R.string.drawer_close) {
  120. /** Called when a drawer has settled in a completely closed state. */
  121. public void onDrawerClosed(View view) {
  122. super.onDrawerClosed(view);
  123. // standard behavior of drawer is to switch to the standard menu on closing
  124. if (mIsAccountChooserActive) {
  125. toggleAccountList();
  126. }
  127. updateActionBarTitleAndHomeButton(null);
  128. invalidateOptionsMenu();
  129. }
  130. /** Called when a drawer has settled in a completely open state. */
  131. public void onDrawerOpened(View drawerView) {
  132. super.onDrawerOpened(drawerView);
  133. getSupportActionBar().setTitle(R.string.app_name);
  134. mDrawerToggle.setDrawerIndicatorEnabled(true);
  135. invalidateOptionsMenu();
  136. }
  137. };
  138. // Set the drawer toggle as the DrawerListener
  139. mDrawerLayout.setDrawerListener(mDrawerToggle);
  140. mDrawerToggle.setDrawerIndicatorEnabled(false);
  141. }
  142. /**
  143. * setup drawer content, basically setting the item selected listener.
  144. *
  145. * @param navigationView the drawers navigation view
  146. */
  147. protected void setupDrawerContent(NavigationView navigationView) {
  148. navigationView.setNavigationItemSelectedListener(
  149. new NavigationView.OnNavigationItemSelectedListener() {
  150. @Override
  151. public boolean onNavigationItemSelected(MenuItem menuItem) {
  152. mDrawerLayout.closeDrawers();
  153. switch (menuItem.getItemId()) {
  154. case R.id.nav_all_files:
  155. menuItem.setChecked(true);
  156. allFilesOption();
  157. break;
  158. case R.id.nav_settings:
  159. Intent settingsIntent = new Intent(getApplicationContext(),
  160. Preferences.class);
  161. startActivity(settingsIntent);
  162. break;
  163. case R.id.drawer_menu_account_add:
  164. createAccount();
  165. break;
  166. case R.id.drawer_menu_account_manage:
  167. Intent manageAccountsIntent = new Intent(getApplicationContext(),
  168. ManageAccountsActivity.class);
  169. startActivityForResult(manageAccountsIntent, ACTION_MANAGE_ACCOUNTS);
  170. break;
  171. case Menu.NONE:
  172. // account clicked
  173. AccountUtils.setCurrentOwnCloudAccount(
  174. getApplicationContext(), menuItem.getTitle().toString());
  175. restart();
  176. default:
  177. Log_OC.i(TAG, "Unknown drawer menu item clicked: " + menuItem.getTitle());
  178. }
  179. return true;
  180. }
  181. });
  182. // handle correct state
  183. if (mIsAccountChooserActive) {
  184. mNavigationView.getMenu().setGroupVisible(R.id.drawer_menu_accounts, true);
  185. } else {
  186. mNavigationView.getMenu().setGroupVisible(R.id.drawer_menu_accounts, false);
  187. }
  188. }
  189. /**
  190. * checks if the drawer exists and is opened.
  191. *
  192. * @return <code>true</code> if the drawer is open, else <code>false</code>
  193. */
  194. public boolean isDrawerOpen() {
  195. return mDrawerLayout != null && mDrawerLayout.isDrawerOpen(GravityCompat.START);
  196. }
  197. /**
  198. * closes the drawer.
  199. */
  200. public void closeDrawer() {
  201. if (mDrawerLayout != null) {
  202. mDrawerLayout.closeDrawer(GravityCompat.START);
  203. }
  204. }
  205. /**
  206. * opens the drawer.
  207. */
  208. public void openDrawer() {
  209. if (mDrawerLayout != null) {
  210. mDrawerLayout.openDrawer(GravityCompat.START);
  211. }
  212. }
  213. /**
  214. * Enable or disable interaction with all drawers.
  215. *
  216. * @param lockMode The new lock mode for the given drawer. One of {@link DrawerLayout#LOCK_MODE_UNLOCKED},
  217. * {@link DrawerLayout#LOCK_MODE_LOCKED_CLOSED} or {@link DrawerLayout#LOCK_MODE_LOCKED_OPEN}.
  218. */
  219. public void setDrawerLockMode(int lockMode) {
  220. if (mDrawerLayout != null) {
  221. mDrawerLayout.setDrawerLockMode(lockMode);
  222. }
  223. }
  224. /**
  225. * Enable or disable the drawer indicator.
  226. *
  227. * @param enable <code>true</code> to enable, <code>false</code> to disable
  228. */
  229. public void setDrawerIndicatorEnabled(boolean enable) {
  230. if (mDrawerToggle != null) {
  231. mDrawerToggle.setDrawerIndicatorEnabled(enable);
  232. }
  233. }
  234. /**
  235. * updates the account list in the drawer.
  236. */
  237. public void updateAccountList() {
  238. Account[] accounts = AccountManager.get(this).getAccountsByType(MainApp.getAccountType());
  239. if(accounts.length > 0) {
  240. repopulateAccountList(accounts);
  241. setUsernameInDrawer(AccountUtils.getCurrentOwnCloudAccount(this).name);
  242. }
  243. }
  244. /**
  245. * re-populates the account list.
  246. *
  247. * @param accounts list of accounts
  248. */
  249. private void repopulateAccountList(Account[] accounts) {
  250. // remove all accounts from list
  251. mNavigationView.getMenu().removeGroup(R.id.drawer_menu_accounts);
  252. // add all accounts to list
  253. for (int i = 0; i < accounts.length; i++) {
  254. try {
  255. int[] rgb = BitmapUtils.calculateRGB(accounts[i].name);
  256. TextDrawable icon = new TextDrawable(accounts[i].name.substring(0, 1).toUpperCase()
  257. , rgb[0], rgb[1], rgb[2]);
  258. mNavigationView.getMenu().add(R.id.drawer_menu_accounts, Menu.NONE, 1, accounts[i].name).setIcon(icon);
  259. } catch (Exception e) {
  260. Log_OC.e(TAG, "Error calculating RGB value for account menu item.", e);
  261. mNavigationView.getMenu().add(R.id.drawer_menu_accounts, Menu.NONE, 1, accounts[i].name).setIcon(R
  262. .drawable.ic_account_circle);
  263. }
  264. }
  265. // re-add add-account and manage-accounts
  266. mNavigationView.getMenu().add(R.id.drawer_menu_accounts, R.id.drawer_menu_account_add, 2,
  267. getResources().getString(R.string.prefs_add_account)).setIcon(R.drawable.ic_account_plus);
  268. mNavigationView.getMenu().add(R.id.drawer_menu_accounts, R.id.drawer_menu_account_manage, 2,
  269. getResources().getString(R.string.drawer_manage_accounts)).setIcon(R.drawable.ic_settings);
  270. // adding sets menu group back to visible, so safety check and setting invisible
  271. showMenu();
  272. }
  273. /**
  274. * Method that gets called on drawer menu click for 'All Files'.
  275. */
  276. public abstract void allFilesOption();
  277. /**
  278. * Updates title bar and home buttons (state and icon).
  279. * <p/>
  280. * Assumes that navigation drawer is NOT visible.
  281. */
  282. protected void updateActionBarTitleAndHomeButton(OCFile chosenFile) {
  283. super.updateActionBarTitleAndHomeButton(chosenFile);
  284. /// set home button properties
  285. mDrawerToggle.setDrawerIndicatorEnabled(isRoot(chosenFile));
  286. }
  287. /**
  288. * sets the given account name in the drawer in case the drawer is available. The account name is shortened
  289. * beginning from the @-sign in the username.
  290. *
  291. * @param accountName the account to be set in the drawer
  292. */
  293. protected void setUsernameInDrawer(String accountName) {
  294. if (mDrawerLayout != null && accountName != null) {
  295. TextView username = (TextView) ((NavigationView) findViewById(R.id.nav_view))
  296. .getHeaderView(0).findViewById(R.id.drawer_username);
  297. TextView usernameFull = (TextView) ((NavigationView) findViewById(R.id.nav_view))
  298. .getHeaderView(0).findViewById(R.id.drawer_username_full);
  299. usernameFull.setText(accountName);
  300. int lastAtPos = accountName.lastIndexOf("@");
  301. username.setText(accountName.substring(0, lastAtPos));
  302. ImageView userIcon = (ImageView) ((NavigationView) findViewById(R.id.nav_view))
  303. .getHeaderView(0).findViewById(R.id.drawer_usericon);
  304. try {
  305. int[] rgb = BitmapUtils.calculateRGB(accountName);
  306. TextDrawable icon = new TextDrawable(
  307. accountName.substring(0, 1).toUpperCase(), rgb[0], rgb[1], rgb[2]);
  308. userIcon.setImageDrawable(icon);
  309. } catch (Exception e) {
  310. Log_OC.e(TAG, "Error calculating RGB value for active account icon.", e);
  311. userIcon.setImageResource(R.drawable.ic_account_circle);
  312. }
  313. }
  314. }
  315. /**
  316. * Toggle between standard menu and account list including saving the state.
  317. */
  318. private void toggleAccountList() {
  319. mIsAccountChooserActive = !mIsAccountChooserActive;
  320. showMenu();
  321. }
  322. /**
  323. * depending on the #mIsAccountChooserActive flag shows the account chooser or the standard menu.
  324. */
  325. private void showMenu() {
  326. if (mIsAccountChooserActive) {
  327. mAccountChooserToggle.setImageResource(R.drawable.ic_up);
  328. mNavigationView.getMenu().setGroupVisible(R.id.drawer_menu_accounts, true);
  329. mNavigationView.getMenu().setGroupVisible(R.id.drawer_menu_standard, false);
  330. } else {
  331. mAccountChooserToggle.setImageResource(R.drawable.ic_down);
  332. mNavigationView.getMenu().setGroupVisible(R.id.drawer_menu_accounts, false);
  333. mNavigationView.getMenu().setGroupVisible(R.id.drawer_menu_standard, true);
  334. }
  335. }
  336. @Override
  337. protected void onCreate(Bundle savedInstanceState) {
  338. super.onCreate(savedInstanceState);
  339. if (savedInstanceState != null) {
  340. mIsAccountChooserActive = savedInstanceState.getBoolean(KEY_IS_ACCOUNT_CHOOSER_ACTIVE, false);
  341. }
  342. }
  343. @Override
  344. protected void onSaveInstanceState(Bundle outState) {
  345. super.onSaveInstanceState(outState);
  346. outState.putBoolean(KEY_IS_ACCOUNT_CHOOSER_ACTIVE, mIsAccountChooserActive);
  347. }
  348. @Override
  349. public void onRestoreInstanceState(Bundle savedInstanceState) {
  350. super.onRestoreInstanceState(savedInstanceState);
  351. mIsAccountChooserActive = savedInstanceState.getBoolean(KEY_IS_ACCOUNT_CHOOSER_ACTIVE, false);
  352. // (re-)setup drawer state
  353. showMenu();
  354. }
  355. @Override
  356. protected void onPostCreate(Bundle savedInstanceState) {
  357. super.onPostCreate(savedInstanceState);
  358. // Sync the toggle state after onRestoreInstanceState has occurred.
  359. if (mDrawerToggle != null) {
  360. mDrawerToggle.syncState();
  361. if (isDrawerOpen()) {
  362. getSupportActionBar().setTitle(R.string.app_name);
  363. mDrawerToggle.setDrawerIndicatorEnabled(true);
  364. }
  365. }
  366. updateAccountList();
  367. }
  368. @Override
  369. public void onConfigurationChanged(Configuration newConfig) {
  370. super.onConfigurationChanged(newConfig);
  371. if (mDrawerToggle != null) {
  372. mDrawerToggle.onConfigurationChanged(newConfig);
  373. }
  374. }
  375. @Override
  376. public void onBackPressed() {
  377. if (isDrawerOpen()) {
  378. closeDrawer();
  379. return;
  380. }
  381. super.onBackPressed();
  382. }
  383. @Override
  384. protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  385. super.onActivityResult(requestCode, resultCode, data);
  386. // update Account list and active account if Manage Account activity replies with
  387. // - ACCOUNT_LIST_CHANGED = true
  388. // - RESULT_OK
  389. if (requestCode == ACTION_MANAGE_ACCOUNTS
  390. && resultCode == RESULT_OK
  391. && data.getBooleanExtra(ManageAccountsActivity.KEY_ACCOUNT_LIST_CHANGED, false)) {
  392. // current account has changed
  393. if(data.getBooleanExtra(ManageAccountsActivity.KEY_CURRENT_ACCOUNT_CHANGED, false)) {
  394. mCurrentAccount = AccountUtils.getCurrentOwnCloudAccount(this);
  395. restart();
  396. } else {
  397. updateAccountList();
  398. }
  399. }
  400. }
  401. /**
  402. * Finds a view that was identified by the id attribute from the drawer header.
  403. *
  404. * @param id the view's id
  405. * @return The view if found or <code>null</code> otherwise.
  406. */
  407. private View findNavigationViewChildById(int id) {
  408. return ((NavigationView) findViewById(R.id.nav_view)).getHeaderView(0).findViewById(id);
  409. }
  410. // TODO call on current account changed
  411. public void restart() {
  412. Intent i = new Intent(this, FileDisplayActivity.class);
  413. i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
  414. startActivity(i);
  415. }
  416. /**
  417. * Sets and validates the ownCloud {@link Account} associated to the Activity.
  418. * <p/>
  419. * If not valid, tries to swap it for other valid and existing ownCloud {@link Account}.
  420. * <p/>
  421. * POSTCONDITION: updates {@link #mAccountWasSet} and {@link #mAccountWasRestored}.
  422. *
  423. * @param account New {@link Account} to set.
  424. * @param savedAccount When 'true', account was retrieved from a saved instance state.
  425. */
  426. protected void setAccount(Account account, boolean savedAccount) {
  427. Account oldAccount = mCurrentAccount;
  428. boolean validAccount =
  429. (account != null && AccountUtils.setCurrentOwnCloudAccount(getApplicationContext(),
  430. account.name));
  431. if (validAccount) {
  432. mCurrentAccount = account;
  433. mAccountWasSet = true;
  434. mAccountWasRestored = (savedAccount || mCurrentAccount.equals(oldAccount));
  435. } else {
  436. swapToDefaultAccount();
  437. }
  438. }
  439. /**
  440. * Tries to swap the current ownCloud {@link Account} for other valid and existing.
  441. * <p/>
  442. * If no valid ownCloud {@link Account} exists, the the user is requested
  443. * to create a new ownCloud {@link Account}.
  444. * <p/>
  445. * POSTCONDITION: updates {@link #mAccountWasSet} and {@link #mAccountWasRestored}.
  446. */
  447. protected void swapToDefaultAccount() {
  448. // default to the most recently used account
  449. Account newAccount = AccountUtils.getCurrentOwnCloudAccount(getApplicationContext());
  450. if (newAccount == null) {
  451. /// no account available: force account creation
  452. createAccount();
  453. mRedirectingToSetupAccount = true;
  454. mAccountWasSet = false;
  455. mAccountWasRestored = false;
  456. } else {
  457. mAccountWasSet = true;
  458. mAccountWasRestored = (newAccount.equals(mCurrentAccount));
  459. mCurrentAccount = newAccount;
  460. }
  461. }
  462. /**
  463. * Launches the account creation activity. To use when no ownCloud account is available.
  464. */
  465. private void createAccount() {
  466. AccountManager am = AccountManager.get(getApplicationContext());
  467. am.addAccount(MainApp.getAccountType(),
  468. null,
  469. null,
  470. null,
  471. this,
  472. new AccountCreationCallback(),
  473. new Handler());
  474. }
  475. /**
  476. * Helper class handling a callback from the {@link AccountManager} after the creation of
  477. * a new ownCloud {@link Account} finished, successfully or not.
  478. * <p/>
  479. * At this moment, only called after the creation of the first account.
  480. */
  481. public class AccountCreationCallback implements AccountManagerCallback<Bundle> {
  482. @Override
  483. public void run(AccountManagerFuture<Bundle> future) {
  484. DrawerActivity.this.mRedirectingToSetupAccount = false;
  485. boolean accountWasSet = false;
  486. if (future != null) {
  487. try {
  488. Bundle result;
  489. result = future.getResult();
  490. String name = result.getString(AccountManager.KEY_ACCOUNT_NAME);
  491. String type = result.getString(AccountManager.KEY_ACCOUNT_TYPE);
  492. if (AccountUtils.setCurrentOwnCloudAccount(getApplicationContext(), name)) {
  493. setAccount(new Account(name, type), false);
  494. accountWasSet = true;
  495. }
  496. DrawerActivity.this.updateAccountList();
  497. DrawerActivity.this.restart();
  498. } catch (OperationCanceledException e) {
  499. Log_OC.d(TAG, "Account creation canceled");
  500. } catch (Exception e) {
  501. Log_OC.e(TAG, "Account creation finished in exception: ", e);
  502. }
  503. } else {
  504. Log_OC.e(TAG, "Account creation callback with null bundle");
  505. }
  506. if (!accountWasSet) {
  507. moveTaskToBack(true);
  508. }
  509. }
  510. }
  511. /**
  512. * Called when the ownCloud {@link Account} associated to the Activity was just updated.
  513. * <p/>
  514. * Child classes must grant that state depending on the {@link Account} is updated.
  515. */
  516. protected void onAccountSet(boolean stateWasRecovered) {
  517. if (getAccount() != null) {
  518. mStorageManager = new FileDataStorageManager(getAccount(), getContentResolver());
  519. mCapabilities = mStorageManager.getCapability(mCurrentAccount.name);
  520. } else {
  521. Log_OC.wtf(TAG, "onAccountChanged was called with NULL account associated!");
  522. }
  523. }
  524. protected void setAccount(Account account) {
  525. mCurrentAccount = account;
  526. }
  527. /**
  528. * Getter for the capabilities of the server where the current OC account lives.
  529. *
  530. * @return Capabilities of the server where the current OC account lives. Null if the account is not
  531. * set yet.
  532. */
  533. public OCCapability getCapabilities() {
  534. return mCapabilities;
  535. }
  536. /**
  537. * Getter for the ownCloud {@link Account} where the main {@link OCFile} handled by the activity
  538. * is located.
  539. *
  540. * @return OwnCloud {@link Account} where the main {@link OCFile} handled by the activity
  541. * is located.
  542. */
  543. public Account getAccount() {
  544. return mCurrentAccount;
  545. }
  546. @Override
  547. protected void onStart() {
  548. super.onStart();
  549. if (mAccountWasSet) {
  550. onAccountSet(mAccountWasRestored);
  551. }
  552. }
  553. /**
  554. * @return 'True' when the Activity is finishing to enforce the setup of a new account.
  555. */
  556. protected boolean isRedirectingToSetupAccount() {
  557. return mRedirectingToSetupAccount;
  558. }
  559. public FileDataStorageManager getStorageManager() {
  560. return mStorageManager;
  561. }
  562. }