コード例 #1
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.menu_share:
        try {
          if (passwordList == null) return true;
          Intent i = new Intent(Intent.ACTION_SEND);
          i.setType("text/plain");
          i.putExtra(
              Intent.EXTRA_SUBJECT, keygen.getSsidName() + getString(R.string.share_msg_begin));
          final StringBuilder message = new StringBuilder(keygen.getSsidName());
          message.append(getString(R.string.share_msg_begin));
          message.append(":\n");
          for (String password : passwordList) {
            message.append(password);
            message.append('\n');
          }
          i.putExtra(Intent.EXTRA_TEXT, message.toString());
          startActivity(Intent.createChooser(i, getString(R.string.share_title)));
        } catch (Exception e) {
          Toast.makeText(getActivity(), R.string.msg_err_sendto, Toast.LENGTH_SHORT).show();
        }
        return true;
      case R.id.menu_save_sd:
        if (!Environment.getExternalStorageState().equals("mounted")
            && !Environment.getExternalStorageState().equals("mounted_ro")) {
          Toast.makeText(getActivity(), R.string.msg_nosdcard, Toast.LENGTH_SHORT).show();
          return true;
        }
        final StringBuilder message = new StringBuilder(keygen.getSsidName());
        message.append(" KEYS\n");
        for (String password : passwordList) {
          message.append(password);
          message.append('\n');
        }
        try {

          final BufferedWriter out =
              new BufferedWriter(
                  new FileWriter(folderSelect + File.separator + keygen.getSsidName() + ".txt"));
          out.write(message.toString());
          out.close();
        } catch (IOException e) {
          Toast.makeText(
                  getActivity(), getString(R.string.msg_err_saving_key_file), Toast.LENGTH_SHORT)
              .show();
          return true;
        }
        Toast.makeText(
                getActivity(),
                keygen.getSsidName() + ".txt " + getString(R.string.msg_saved_key_file),
                Toast.LENGTH_SHORT)
            .show();
        return true;
    }
    return super.onOptionsItemSelected(item);
  }
コード例 #2
0
    private List<String> calcKeys(Keygen keygen) {
      long begin = System.currentTimeMillis();
      final List<String> result = keygen.getKeys();
      long end = System.currentTimeMillis() - begin;
      if (BuildConfig.DEBUG) Log.d(TAG, "Time to solve:" + end);

      final int errorCode = keygen.getErrorCode();
      if (errorCode != 0) {
        if (result == null) publishProgress(SHOW_MESSAGE_NO_SPINNER, errorCode);
        else publishProgress(SHOW_TOAST, errorCode);
      }
      return result;
    }
コード例 #3
0
 @Override
 public View onCreateView(
     LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
   root = (ViewSwitcher) inflater.inflate(R.layout.fragment_network, container, false);
   messages = (TextView) root.findViewById(R.id.loading_text);
   final View autoConnect = root.findViewById(R.id.auto_connect);
   if (keygen.getScanResult() == null) autoConnect.setVisibility(View.GONE);
   else
     autoConnect.setOnClickListener(
         new OnClickListener() {
           public void onClick(View v) {
             if (passwordList == null) return;
             if (isAutoConnectServiceRunning()) {
               Toast.makeText(getActivity(), R.string.msg_auto_connect_running, Toast.LENGTH_SHORT)
                   .show();
               return;
             }
             Intent i = new Intent(getActivity(), AutoConnectService.class);
             i.putStringArrayListExtra(
                 AutoConnectService.KEY_LIST, (ArrayList<String>) passwordList);
             i.putExtra(AutoConnectService.SCAN_RESULT, keygen.getScanResult());
             getActivity().startService(i);
           }
         });
   return root;
 }
コード例 #4
0
 @Override
 protected void onPreExecute() {
   if (!keygen.isSupported()) {
     root.findViewById(R.id.loading_spinner).setVisibility(View.GONE);
     messages.setText(R.string.msg_unspported);
     cancel(true);
   }
   if (keygen instanceof ThomsonKeygen) {
     ((ThomsonKeygen) keygen).setFolder(folderSelect);
     ((ThomsonKeygen) keygen).setInternetAlgorithm(thomson3g);
     ((ThomsonKeygen) keygen)
         .setWebdic(getActivity().getResources().openRawResource(R.raw.webdic));
   }
 }
コード例 #5
0
 public void cancel() {
   for (Keygen keygen : wifiNetwork.getKeygens()) keygen.setStopRequested(true);
   cancel(true);
 }
コード例 #6
0
 public void cancel() {
   keygen.setStopRequested(true);
   cancel(true);
 }