/**
   * Show related dialog base on settings
   *
   * <p>100% the same with {@link SeafilePathChooserActivity#handleEncryptedRepo}
   */
  private void handleEncryptedRepo(String repoId) {
    SeafRepo repo = mDataManager.getCachedRepoByID(repoId);
    if (repo == null || !repo.encrypted) return;

    if (!repo.canLocalDecrypt()) {
      if (!DataManager.getRepoPasswordSet(repoId)) {
        showPasswordDialog();
      }
    } else {
      if (!getDataManager().getRepoEnckeySet(repoId)) {
        showEncDialog(repo.magic, repo.encKey, repo.encVersion);
      }
    }
  }
  private boolean handleEncryptedRepo(
      SeafRepo repo, TaskDialog.TaskDialogListener taskDialogListener) {
    if (!repo.encrypted) return true;

    if (!repo.canLocalDecrypt()) {
      if (!DataManager.getRepoPasswordSet(repo.id)) {
        String password = DataManager.getRepoPassword(repo.id);
        showPasswordDialog(repo.name, repo.id, taskDialogListener, password);
        return false;
      } else {
        taskDialogListener.onTaskSuccess();
        return true;
      }

    } else {
      if (!getDataManager().getRepoEnckeySet(repo.id)) {
        Pair<String, String> pair = getDataManager().getRepoEncKey(repo.id);
        showEncDialog(
            repo.name,
            repo.id,
            repo.magic,
            repo.encKey,
            repo.encVersion,
            taskDialogListener,
            pair == null ? null : pair.first);
        return false;
      } else {
        taskDialogListener.onTaskSuccess();
        return true;
      }
    }
  }
  private View getRepoView(SeafRepo repo, View convertView, ViewGroup parent) {
    View view = convertView;
    Viewholder viewHolder;

    if (convertView == null) {
      view = LayoutInflater.from(mActivity).inflate(R.layout.list_item_entry, null);
      TextView title = (TextView) view.findViewById(R.id.list_item_title);
      TextView subtitle = (TextView) view.findViewById(R.id.list_item_subtitle);
      ImageView icon = (ImageView) view.findViewById(R.id.list_item_icon);
      ImageView action = (ImageView) view.findViewById(R.id.list_item_action);
      viewHolder = new Viewholder(title, subtitle, icon, action);
      view.setTag(viewHolder);
    } else {
      viewHolder = (Viewholder) convertView.getTag();
    }

    viewHolder.title.setText(repo.getTitle());
    viewHolder.subtitle.setText(repo.getSubtitle());
    viewHolder.icon.setImageResource(repo.getIcon());
    viewHolder.action.setVisibility(View.INVISIBLE);
    return view;
  }
Exemple #4
0
 static SeafRepo fromJson(JSONObject obj) throws JSONException {
   SeafRepo repo = new SeafRepo();
   repo.id = obj.getString("id");
   repo.name = obj.getString("name");
   repo.description = obj.getString("desc");
   repo.owner = obj.getString("owner");
   repo.permission = obj.getString("permission");
   repo.mtime = obj.getLong("mtime");
   repo.encrypted = obj.getBoolean("encrypted");
   repo.root = obj.getString("root");
   repo.size = obj.getLong("size");
   if (obj.getString("type").equals("grepo")) {
     repo.isGroupRepo = true;
   } else repo.isGroupRepo = false;
   return repo;
 }