private void stepBack(boolean cancelIfFirstStep) {
   switch (mStep) {
     case STEP_CHOOSE_ACCOUNT:
       if (cancelIfFirstStep) {
         mActivity.finish();
       }
       mUpLayout.setVisibility(View.INVISIBLE);
       break;
     case STEP_CHOOSE_REPO:
       if (canChooseAccount) {
         mCurrentDir = getString(R.string.settings_cuc_remote_lib_account);
         setCurrentDirText(mCurrentDir);
         chooseAccount(false);
       } else if (cancelIfFirstStep) {
         mActivity.finish();
       }
       break;
     case STEP_CHOOSE_DIR:
       if (getNavContext().isRepoRoot()) {
         mCurrentDir = getAccountManager().getCurrentAccount().getEmail();
         setCurrentDirText(mCurrentDir);
         chooseRepo();
       } else {
         String path = getNavContext().getDirPath();
         mCurrentDir = getNavContext().getRepoName() + Utils.getParentPath(path);
         setCurrentDirText(mCurrentDir);
         getNavContext().setDir(Utils.getParentPath(path), null);
         refreshDir();
       }
       break;
   }
 }
Example #2
0
 public boolean checkCameraUploadNetworkAvailable() {
   if (!Utils.isNetworkOn()) {
     return false;
   }
   // user does not allow mobile connections
   if (!Utils.isWiFiOn() && !isDataPlanAllowed()) {
     return false;
   }
   // Wi-Fi or 2G/3G/4G connections available
   return true;
 }
  /**
   * asynchronously load avatars
   *
   * @param avatarSize set a avatar size in one of 24*24, 32*32, 48*48, 64*64, 72*72, 96*96
   */
  public void loadAvatarUrls(int avatarSize) {
    List<Avatar> avatars;

    if (!Utils.isNetworkOn() || !avatarManager.isNeedToLoadNewAvatars()) {
      // Toast.makeText(AccountsActivity.this, getString(R.string.network_down),
      // Toast.LENGTH_SHORT).show();

      // use cached avatars
      avatars = avatarManager.getAvatarList();

      if (avatars == null) {
        return;
      }

      // set avatars url to adapter
      mAccountAdapter.setAvatars((ArrayList<Avatar>) avatars);

      // notify adapter data changed
      mAccountAdapter.notifyDataSetChanged();

      return;
    }

    LoadAvatarUrlsTask task = new LoadAvatarUrlsTask(avatarSize);

    ConcurrentAsyncTask.execute(task);
  }
  public void onListItemClick(final View v, final int position, final long id) {
    NavContext nav = getNavContext();
    SeafRepo repo = null;

    if (mStep == STEP_CHOOSE_REPO) {
      repo = getReposAdapter().getItem(position);
      // mCurrentFolderText.setText(nav.getRepoName());
    } else if (mStep == STEP_CHOOSE_DIR) {
      repo = getDataManager().getCachedRepoByID(nav.getRepoID());
    }

    if (repo != null) {
      final boolean continueProcess =
          handleEncryptedRepo(
              repo,
              new TaskDialog.TaskDialogListener() {
                @Override
                public void onTaskSuccess() {
                  onListItemClick(v, position, id);
                }
              });

      if (!continueProcess) return;
    }

    switch (mStep) {
      case STEP_CHOOSE_ACCOUNT:
        setAccount(getAccountAdapter().getItem(position));
        mCurrentDir = mAccount.getDisplayName();
        setCurrentDirText(mCurrentDir);
        chooseRepo();
        break;
      case STEP_CHOOSE_REPO:
        if (!isOnlyChooseRepo) {
          nav.setRepoName(repo.name);
          nav.setRepoID(repo.id);
          nav.setDir("/", repo.root);
          chooseDir();
        }
        mCurrentDir = getString(R.string.settings_cuc_remote_lib_repo, repo.name);
        setCurrentDirText(mCurrentDir);
        SeafRepo seafRepo = getReposAdapter().getItem(position);
        onRepoSelected(mAccount, seafRepo);
        break;
      case STEP_CHOOSE_DIR:
        SeafDirent dirent = getDirentsAdapter().getItem(position);
        mCurrentDir += "/" + dirent.name;
        setCurrentDirText(mCurrentDir);

        if (dirent.type == SeafDirent.DirentType.FILE) {
          return;
        }

        nav.setDir(Utils.pathJoin(nav.getDirPath(), dirent.name), dirent.id);
        refreshDir();
        break;
    }
  }
  private void refreshDir(boolean forceRefresh) {
    String repoID = getNavContext().getRepoID();
    String dirPath = getNavContext().getDirPath();

    if (!Utils.isNetworkOn() || !forceRefresh) {
      List<SeafDirent> dirents =
          getDataManager()
              .getCachedDirents(getNavContext().getRepoID(), getNavContext().getDirPath());
      if (dirents != null) {
        updateAdapterWithDirents(dirents);
        return;
      }
    }

    mLoadDirTask = new LoadDirTask(repoID, dirPath, getDataManager());
    ConcurrentAsyncTask.execute(mLoadDirTask);
  }
  private void chooseRepo(boolean forceRefresh) {
    mStep = STEP_CHOOSE_REPO;
    mUpLayout.setVisibility(View.VISIBLE);
    mCurrentDir = mAccount.getDisplayName();
    setCurrentDirText(mCurrentDir);

    setListAdapter(getReposAdapter());

    getNavContext().setRepoID(null);

    if (!Utils.isNetworkOn() || !forceRefresh) {
      List<SeafRepo> repos = getDataManager().getReposFromCache();
      if (repos != null) {
        updateAdapterWithRepos(repos);
        return;
      }
    }

    mLoadReposTask = new LoadReposTask(getDataManager());
    ConcurrentAsyncTask.execute(mLoadReposTask);
  }
Example #7
0
 @Override
 public String getSubtitle() {
   return Utils.translateCommitTime(mtime * 1000);
 }