@Override public void onClick(View v) { switch (v.getId()) { case R.id.upload_btn: if ((null != WtloginUtil.getUin()) && (isNewProj == false)) { String sk = WtloginUtil.getSKey(WtloginUtil.getUin()); String psk = WtloginUtil.getPsKey(WtloginUtil.getUin()); String lsk = WtloginUtil.getLsKey(WtloginUtil.getUin()); dataPersisted(); showUploadDialog(sk, psk, lsk); } else if (isNewProj == true) { String sk = WtloginUtil.getSKey(WtloginUtil.getUin()); String psk = WtloginUtil.getPsKey(WtloginUtil.getUin()); String lsk = WtloginUtil.getLsKey(WtloginUtil.getUin()); File file = new File(strNewProjName); comfirmUpdateSize(file, sk, psk, lsk); } else { ToastUtil.ShowLongToast(GTApp.getContext(), R.string.qq_need_login); } break; case R.id.back_gt: finish(); break; } }
private void judgeToast() { if (upperValue <= lowerValue && !isToasted) { isToasted = true; ToastUtil.ShowLongToast(GTApp.getContext(), "lower value must less than upper value!"); return; } else if (upperValue <= lowerValue && isToasted) { return; } isToasted = false; }
@Override public void OnGetStWithPasswd( String userAccount, long dwSrcAppid, int dwMainSigMap, long dwSubDstAppid, String userPasswd, WUserSigInfo userSigInfo, int ret, ErrMsg errMsg) { switch (ret) { case util.S_GET_IMAGE: { } break; case util.S_GET_SMS: { } break; case util.S_SUCCESS: { loginSuccess(userAccount); } break; case util.S_BABYLH_EXPIRED: case util.S_LH_EXPIRED: { } break; default: WtloginUtil.setUin(null); // 取消菊花 dismissProDialog(); ToastUtil.ShowLongToast( GTOctopusActivity.this, errMsg.getTitle() + "," + errMsg.getMessage()); finish(); } }
/* 进行验证码验证,或者进行快速登录的回调,这两个是进行快速登录可能遇到的情况 */ protected void onActivityResult(int requestCode, int resultCode, Intent data) { String userAccount = ""; ErrMsg errMsg = null; WUserSigInfo userSigInfo = null; switch (requestCode) { case WtloginUtil.REQ_VCODE: { if (data == null) break; Bundle bundle = data.getExtras(); if (bundle == null) break; userAccount = bundle.getString("ACCOUNT"); errMsg = (ErrMsg) bundle.getParcelable("ERRMSG"); userSigInfo = (WUserSigInfo) bundle.getParcelable("USERSIG"); if (resultCode == util.S_SUCCESS) { // 转菊花,等待产品列表获取结果 showProDialog( getString(R.string.pi_octopus_pull_products), getString(R.string.pi_octopus_pull_products_content)); loginSuccess(userAccount); } else if (resultCode == util.S_LH_EXPIRED || resultCode == util.S_BABYLH_EXPIRED) { Ticket ticket = WtloginHelper.GetUserSigInfoTicket(userSigInfo, SigType.WLOGIN_LHSIG); finish(); ToastUtil.ShowLongToast( GTApp.getContext(), "lhsig=" + util.buf_to_string(ticket._sig) + " errMsg=" + errMsg); } else { finish(); ToastUtil.ShowLongToast(GTApp.getContext(), "errMsg=" + errMsg); } } break; case WtloginUtil.REQ_QLOGIN: // 快速登录返回 try { if (data == null) { // 这种情况下用户多半是直接按了返回按钮,没有进行快速登录;快速登录失败可提醒用户输入密码登录 break; } WUserSigInfo sigInfo = WtloginUtil.getSigInfo(data); if (sigInfo == null) { ToastUtil.ShowLongToast(GTApp.getContext(), R.string.pi_octopus_login_user_quickerror); break; } WtloginUtil.setUin(sigInfo.uin); // 转菊花,等待产品列表获取结果 showProDialog( getString(R.string.pi_octopus_pull_products), getString(R.string.pi_octopus_pull_products_content)); // 快速登录只是从手Q换取了A1票据,A1则相当于用户密码,在此仍需要再发起一次A1换票的流程,才能拿到目标票据 WtloginUtil.getStWithPasswd(sigInfo); // 换票据成功后会触发wtloginListener的监听 } catch (Exception e) { util.printException(e); } break; default: break; } }
private void comfirmUpdateSize( final File folder, final String skey, final String pskey, final String lskey) { // 从folder解析出三级目录 String[] paths = folder.getPath().split(FileUtil.separator); if (paths == null || paths.length <= 3) { // TODO 非预期目录有问题,无法处理的error return; } final String path1 = paths[paths.length - 3]; final String path2 = paths[paths.length - 2]; final String path3 = paths[paths.length - 1]; Object oProductPair = spProductName.getSelectedItem(); if (oProductPair == null) { ToastUtil.ShowLongToast(GTApp.getContext(), R.string.pi_octopus_upload_not_select); return; } if (!(oProductPair instanceof Pair)) { ToastUtil.ShowLongToast(GTApp.getContext(), R.string.pi_octopus_upload_not_select); return; } final Pair<String, String> productPair = (Pair) oProductPair; // 转菊花,等待产品列表获取结果 showProDialog( getString(R.string.pi_octopus_calc_size), getString(R.string.pi_octopus_calc_size_content)); new Thread( new Runnable() { @Override public void run() { long size = 0; File[] csvFiles = folder.listFiles(FileUtil.CSV_FILTER); // 网络操作需要在独立线程完成 PreUploadEntry preUploadEntry = HttpAssist.preUpload( csvFiles, productPair.first, path1, path2, path3, WtloginUtil.getUin(), skey, pskey, lskey); if (preUploadEntry == null) { ToastUtil.ShowLongToast(GTApp.getContext(), ErrorMsg.NET_ERROR); return; } final List<String> chosedFilePathList = new ArrayList<String>(); for (File f : preUploadEntry.choicedCsvFileList) { size += f.length(); chosedFilePathList.add(f.getPath()); } final long sizeKB = size / 1024 + 1; runOnUiThread( new Runnable() { @Override public void run() { dismissProDialog(); AlertDialog.Builder builder = new Builder(GTOctopusActivity.this); builder.setMessage( getString(R.string.pi_octopus_upload_confirm_content) + sizeKB + "KB"); builder.setTitle(getString(R.string.pi_octopus_upload_confirm_title)); builder.setPositiveButton( getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.setNegativeButton( getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Object oProductPair = spProductName.getSelectedItem(); if (oProductPair == null) { ToastUtil.ShowLongToast( GTApp.getContext(), R.string.pi_octopus_upload_not_select); return; } if (!(oProductPair instanceof Pair)) { ToastUtil.ShowLongToast( GTApp.getContext(), R.string.pi_octopus_upload_not_select); return; } Pair<String, String> productPair = (Pair) oProductPair; // 从folder解析出三级目录 String[] paths = folder.getPath().split(FileUtil.separator); if (paths == null || paths.length <= 3) { // TODO 报个error return; } // 分析文件,准备上传,用Service处理 Intent intent = new Intent(); intent.putExtra(SRC, folder.getPath()); intent.putExtra( FILE_ARRAY, chosedFilePathList.toArray(new String[] {})); intent.putExtra(PRODUCT_ID, productPair.first); intent.putExtra(PRODUCT_NAME, productPair.second); intent.putExtra(PATH1, paths[paths.length - 3]); intent.putExtra(PATH2, paths[paths.length - 2]); intent.putExtra(PATH3, paths[paths.length - 1]); intent.putExtra(UIN, WtloginUtil.getUin()); intent.putExtra(S_KEY, skey); intent.putExtra(P_S_KEY, pskey); intent.putExtra(LS_KEY, lskey); PluginManager.getInstance() .getPluginControler() .startService(GTOctopusEngine.getInstance(), intent); } }); builder.setCancelable(false); builder.show(); } }); } }, "choicedCsvFilesThread") .start(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent newProjIntent = this.getIntent(); if (newProjIntent != null && newProjIntent.getAction() == "New_Proj") { isNewProj = true; newProjBundle = newProjIntent.getExtras(); strNewProjName = newProjBundle.getString("name"); strIntent = newProjBundle.getString("intent"); } // 屏蔽进入界面默认唤出键盘在第一个EditText上 getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); setContentView(R.layout.pi_octopus); WtloginUtil.getHelper().SetListener(wtloginListener); TextView back = (TextView) findViewById(R.id.back_gt); back.setOnClickListener(this); Button uploadBtn = (Button) findViewById(R.id.upload_btn); uploadBtn.setOnClickListener(this); spProductName = (Spinner) findViewById(R.id.sp_product_name); if (productPairs != null) { productPairs.clear(); } productAdapter = new ArrayAdapter<Pair<String, String>>( this, android.R.layout.simple_spinner_item, productPairs); productAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spProductName.setAdapter(productAdapter); GTOctopusEngine.getInstance().addListener(this); /* * @important! 快速登录入口 * 完成wtlogin的接入之后,请到qqlogin.oa.com 申请快速登录权限 * TODO 判断是否登录过,如未登录过,则进入快速登录;如登录过,则进入上传页 */ String lsk = WtloginUtil.getLsKey(WtloginUtil.getUin()); if (lsk == null || lsk.isEmpty()) { Intent intent = WtloginUtil.getIntent(); boolean canQlogin = (intent != null); if (!canQlogin) { ToastUtil.ShowLongToast(this, R.string.qq_need_install); finish(); return; } try { GTOctopusActivity.this.startActivityForResult(intent, WtloginUtil.REQ_QLOGIN); } catch (Exception e) { ToastUtil.ShowLongToast(this, R.string.qq_quicklogin_error); } return; } // 转菊花,等待产品列表获取结果 showProDialog( getString(R.string.qq_quicklogin_trying), getString(R.string.qq_quicklogin_trying_content)); loginSuccess(WtloginUtil.getUin()); }