@OptionsItem(R.id.pickFile) void pickFile() { int permissionCheck = ContextCompat.checkSelfPermission(this, READ_EXTERNAL_STORAGE); if (permissionCheck != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions( this, new String[]{READ_EXTERNAL_STORAGE}, PERMISSION_CODE ); return; } launchPicker(); }
@OptionsItem void action_save() { String url = Global.HOST_API + mProjectPath + "/git/edit/" + mVersion + UrlCreate.pathEncode2(file.path); RequestParams params = new RequestParams(); params.put("content", editFragment.getInput()); mGitAll.getGitFileObject().data = editFragment.getInput(); params.put("message", "update " + mGitFileInfoObject.name); params.put("lastCommitSha", mGitAll.getCommitId()); MyAsyncHttpClient.post(this, url, params, new MyJsonResponse(EditCodeActivity.this) { @Override public void onMySuccess(JSONObject response) { super.onMySuccess(response); closeAndSave(); } @Override public void onFinish() { super.onFinish(); showProgressBar(false); } }); showProgressBar(true); }
@OptionsItem protected final void action_download() { //showButtomToast("savePic"); if (mFile != null && mFile.exists() && mFile.isFile()) { showButtomToast("文件已经下载"); return; } else if (isDownloading) { showButtomToast("文件正在下载"); return; } urlDownload = String.format(urlDownloadBase, mProjectObjectId, mAttachmentFileObject.file_id); if (mFileSaveHelp.needShowHint()) { String msgFormat = "您的文件将下载到以下路径:\n%s\n您也可以去设置界面设置您的下载路径"; new AlertDialog.Builder(this) .setTitle("提示") .setMessage(String.format(msgFormat, mFileSaveHelp.getDefaultPath())) .setPositiveButton("确定", (dialog, which) -> download(urlDownload)) .show(); mFileSaveHelp.alwaysHideHint(); } else { download(urlDownload); } }
@OptionsItem protected final void action_open_by_other() { if (mFile != null && mFile.exists()) { // try { // Intent mResultIntent = new Intent(Intent.ACTION_VIEW); // Uri fileUri = Uri.fromFile(mFile); // type = getContentResolver().getType(fileUri); // mResultIntent.setDataAndType(fileUri, // type); // startActivity(mResultIntent); // } catch (Exception e) { // Global.errorLog(e); // showMiddleToast("没有能打开此文件的程序"); // } AttachmentsDownloadDetailActivity.openFile(this, mFile); } else { showMiddleToast("文件未下载"); } }
@OptionsItem(android.R.id.home) void close() { if (mAttachmentFolderObject != null) { if (mAttachmentFolderObject.parent != null) { mAttachmentFolderObject = mAttachmentFolderObject.parent; mData.clear(); mData.addAll(mAttachmentFolderObject.sub_folders); adapter.notifyDataSetChanged(); //isTopFolder = false; getSupportActionBar().setTitle(mAttachmentFolderObject.name); } else { mAttachmentFolderObject = null; mData.clear(); mData.addAll(mDefaultData); adapter.notifyDataSetChanged(); getSupportActionBar().setTitle(R.string.title_activity_attachment_folder_selector); ///isTopFolder = true; } setBottomBtn(); } else { onBackPressed(); } }
@OptionsItem protected final void action_share() { String urlString = webView.getUrl(); if (urlString == null) { Toast.makeText(WebActivity.this, "获取链接失败", Toast.LENGTH_SHORT).show(); return; } String title = actionbarTitle.getText().toString(); if (title.isEmpty()) { Toast.makeText(WebActivity.this, "获取标题失败", Toast.LENGTH_SHORT).show(); return; } action_share_third(); }
@OptionsItem void action_ok() { final String customName = nameText.getText().toString().trim(); if (TextUtils.isEmpty(customName)) { Toast.makeText(this, "请输入位置名称", Toast.LENGTH_SHORT).show(); nameText.requestFocus(); return; } final String areaAddress = addressText.getText().toString().trim(); final String customAddress = TextUtils.isEmpty(areaAddress) ? areaText.getText().toString().trim() : areaAddress; BaiduLbsLoader.store(getApplicationContext(), customName, customAddress, latitude, longitude, new BaiduLbsLoader.StorePoiListener() { @Override public void onStoreResult(boolean success, String id) { if (!success) { Toast.makeText(LocationEditActivity.this, "保存失败,请重试", Toast.LENGTH_SHORT).show(); } else { final LocationObject data = LocationObject.newCustom(id, customName, customAddress, latitude, longitude); data.city = city; Intent intent = new Intent(); intent.putExtra("location", data); setResult(RESULT_OK, intent); finish(); } } }); }
@OptionsItem(android.R.id.home) final protected void clickBack() { if (mCurrentFragment instanceof BaseProjectHomeFragment) { if (((BaseProjectHomeFragment) mCurrentFragment).isBackToRefresh()) { InitProUtils.backIntentToMain(this); return; } } finish(); }
@OptionsItem void action_preview() { file.data = editFragment.getInput(); previewFragment.loadData(); switchFragment(previewFragment, editFragment); previewMenu.setVisible(false); editMenu.setVisible(true); }
@OptionsItem void action_edit() { switchFragment(editFragment, previewFragment); previewMenu.setVisible(true); editMenu.setVisible(false); }
@OptionsItem(R.id.action_info) protected final void tips() { if (maskInfo.getVisibility() == View.GONE) { maskInfo.getBackground().setAlpha(200); maskInfo.setVisibility(View.VISIBLE); } else { maskInfo.setVisibility(View.GONE); } }
@OptionsItem void action_filter() { if (pageIndex != program_title.length) { pager.setCurrentItem(program_title.length, false); } else { pager.setCurrentItem(program_title.length - pageIndex, false); } }
@OptionsItem protected final void action_history() { String peek = pathStack.peek(); if (peek.isEmpty() && mVersion.isEmpty()) { showButtomToast("没有Commit记录"); return; } String commitUrl = UrlCreate.gitTreeCommit(mProjectPath, mVersion, peek); BranchCommitListActivity_.intent(this).mCommitsUrl(commitUrl).start(); // RedPointTip.markUsed(getActivity(), RedPointTip.Type.CodeHistory); }
@OptionsItem void action_save() { if (id != 0) { beginSaveTopicLabels(); } else { saveTopicLabels = true; finish(); } }
@OptionsItem void action_save() { String newName = editText.getText().toString(); if (TextUtils.isEmpty(newName)) { showButtomToast("名字不能为空"); return; } labelObject.name = newName; String url = Global.HOST_API + projectPath + "/topics/label/" + labelObject.id; RequestParams params = new RequestParams(); params.put("name", labelObject.name); String colorStringr = String.format("#%06X", labelObject.getColor() & 0x00FFFFFF); params.put("color", colorStringr); MyAsyncHttpClient.put(this, url, params, new MyJsonResponse(this) { @Override public void onMySuccess(JSONObject response) { super.onMySuccess(response); Intent intent = new Intent(); intent.putExtra("resultData", labelObject); setResult(RESULT_OK, intent); finish(); } @Override public void onFinish() { super.onFinish(); showProgressBar(false); } }); showProgressBar(true); }
@OptionsItem protected void action_preview() { SaveData saveData = (SaveData) getActivity(); saveData.saveData(new TopicAddActivity.TopicData(title.getText().toString(), edit.getText().toString(), mOldData.labels)); saveData.switchPreview(); Global.popSoftkeyboard(getActivity(), edit, false); }
@OptionsItem void action_modify() { ReadmeEditActivity_.intent(this) .mProjectObject(mProjectObject) .mPostParam(mPostParam) .startForResult(RESULT_EDIT); }
@OptionsItem protected void action_delete() { String messageFormat = "确定要删除文件 \"%s\" 么?"; AlertDialog.Builder builder = new AlertDialog.Builder(AttachmentsDetailBaseActivity.this); builder.setTitle("删除文件").setMessage(String.format(messageFormat, mAttachmentFileObject.getName())) .setPositiveButton("确定", (dialog, which) -> { showDialogLoading("正在删除"); deleteNetwork(String.format(HOST_FILE_DELETE, mProjectObjectId, mAttachmentFileObject.file_id), HOST_FILE_DELETE); }).setNegativeButton("取消", null) .show(); }
@OptionsItem protected final void action_copy() { String preViewUrl = mAttachmentFileObject.owner_preview; int pos = preViewUrl.lastIndexOf("imagePreview"); if (pos != -1) { preViewUrl = preViewUrl.substring(0, pos) + "download"; } Global.copy(this, preViewUrl); showButtomToast("已复制 " + preViewUrl); }
@OptionsItem protected final void action_link_public() { ShareFileLinkActivity_.intent(this) .mAttachmentFileObject(mAttachmentFileObject) .mProject(mProject) .startForResult(RESULT_SHARE_LINK); }
@OptionsItem void action_info() { new AlertDialog.Builder(this) .setTitle("文件信息") .setMessage(String.format(fileInfoFormat, mAttachmentFileObject.fileType, Global.HumanReadableFilesize(mAttachmentFileObject.getSize()), Global.dayToNow(mAttachmentFileObject.created_at), Global.dayToNow(mAttachmentFileObject.updated_at), mAttachmentFileObject.owner.name)) .setPositiveButton("确定", null) .show(); }
@OptionsItem protected final void action_copy() { String link = getLink(); if (link.isEmpty()) { showButtomToast("复制链接失败"); } else { Global.copy(this, link); showButtomToast("已复制链接 " + link); } }
@OptionsItem protected final void action_delete() { String messageFormat = "确定要删除文件 \"%s\" 么?"; new AlertDialog.Builder(this) .setTitle("删除文件") .setMessage(String.format(messageFormat, mAttachmentFileObject.getName())) .setPositiveButton("确定", (dialog, which) -> { showDialogLoading("正在删除"); deleteNetwork(String.format(HOST_FILE_DELETE, mProjectObjectId, mAttachmentFileObject.file_id), HOST_FILE_DELETE); }) .setNegativeButton("取消", null) .show(); }
@OptionsItem protected final void action_edit() { FileDynamicActivity.ProjectFileParam param = new FileDynamicActivity.ProjectFileParam(mAttachmentFileObject, mProject); TxtEditActivity_.intent(this) .mParam(param) .startForResult(RESULT_MODIFY_TXT); }
@OptionsItem void action_about() { showPop("项目所有者:拥有对项目的所有权限。\n" + "项目管理员:拥有对项目的部分权限。不能删除,转让项目,不能对其他管理员进行操作。\n" + "普通成员:可以阅读和推送代码。\n" + "受限成员:不能进入与代码相关的页面。"); }
@OptionsItem protected final void action_source() { if (mRef.isEmpty()) { showButtomToast("稍等,正在载入数据"); } else { String url = mSingleFile.getHttpSourceFile(mProjectPath, mRef); Log.d("", url); SourceActivity_.intent(this).url(url).start(); } }
@OptionsItem void action_add() { Intent intent = new Intent(getActivity(), MembersSelectActivity_.class); intent.putExtra("mMerge", mMerge); intent.putExtra("mSelect", true); startActivityForResult(intent, RESULT_ADD_USER); }
@OptionsItem protected final void action_edit() { FileDynamicActivity.ProjectFileParam param = new FileDynamicActivity.ProjectFileParam(mAttachmentFileObject, mProject); MarkdownEditActivity_.intent(this) .mParam(param) .startForResult(RESULT_MODIFY_TXT); }
@OptionsItem protected void action_delete() { String messageFormat = "确定要删除图片 \"%s\" 么?"; new AlertDialog.Builder(this) .setTitle("删除图片") .setMessage(String.format(messageFormat, mAttachmentFileObject.getName())) .setPositiveButton("确定", (dialog, which) -> { showDialogLoading("正在删除"); deleteNetwork(String.format(HOST_FILE_DELETE, mProjectObjectId, mAttachmentFileObject.file_id), HOST_FILE_DELETE); }) .setNegativeButton("取消", null) .show(); }
@OptionsItem protected void action_download() { //showButtomToast("savePic"); if (mFile != null && mFile.exists() && mFile.isFile()) { showButtomToast("图片已经下载"); return; } else if (isDownloading) { showButtomToast("图片正在下载"); return; } urlDownload = String.format(urlDownloadBase, mProjectObjectId, mAttachmentFileObject.file_id); if (!share.contains(FileUtil.DOWNLOAD_SETTING_HINT)) { String msgFormat = "您的文件将下载到以下路径:\n%s\n您也可以去设置界面设置您的下载路径"; new AlertDialog.Builder(this) .setTitle("提示") .setMessage(String.format(msgFormat, defaultPath)) .setPositiveButton("确定", (dialog, which) -> download(urlDownload)) .show(); SharedPreferences.Editor editor = share.edit(); editor.putBoolean(FileUtil.DOWNLOAD_SETTING_HINT, true); editor.commit(); } else { download(urlDownload); } }
@OptionsItem public void action_add() { mNeedUpdate = true; Intent intent = new Intent(getActivity(), TaskAddActivity_.class); TaskObject.SingleTask task = new TaskObject.SingleTask(); task.project = mProjectObject; task.project_id = mProjectObject.getId(); task.owner = AccountInfo.loadAccount(getActivity()); task.owner_id = task.owner.id; intent.putExtra("mSingleTask", task); intent.putExtra("mUserOwner", mMembers.user); getParentFragment().startActivityForResult(intent, ListModify.RESULT_EDIT_LIST); }
@OptionsItem void action_edit() { EditCodeActivity_.intent(this) .mProjectPath(mProjectPath) .mGitFileInfoObject(mGitFileInfoObject) .mVersion(mVersion) .mGitAll(mFile) .startForResult(RESULT_EDIT); }
@OptionsItem void action_history() { String peek = mGitFileInfoObject.path; if (peek.isEmpty() && mVersion.isEmpty()) { showButtomToast("没有Commit记录"); return; } String commitUrl = UrlCreate.gitTreeCommit(mProjectPath, mVersion, peek); BranchCommitListActivity_.intent(this).mCommitsUrl(commitUrl).start(); // RedPointTip.markUsed(getActivity(), RedPointTip.Type.CodeHistory); }