public void buttonDeleteClick(View view) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder
        .setMessage(getString(R.string.delete_thing_dialog_msg))
        .setTitle(getString(R.string.delete_thing_dialog_title))
        .setPositiveButton(
            getString(R.string.yes),
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                ThingsDB db = new ThingsDB(PhotoLocationActivity.this);
                db.deleteThing(PhotoLocationActivity.this.thingId);
                db.cleanup();

                dialog.cancel();
                PhotoLocationActivity.this.finish();
              }
            })
        .setNegativeButton(
            getString(R.string.no),
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                dialog.dismiss();
              }
            });
    AlertDialog dialog = builder.create();
    dialog.show();
  }
  private void showDialog() {

    AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
    builder
        .setTitle("Выбирите действие.")
        .setMessage("Вы желаете подтвердить?")
        .setPositiveButton(
            "Да",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                String currTime = new SimpleDateFormat("HH:mm").format(new Date());
                list.add(new FragmentComponentsList(5, "Именено", "сегодня," + currTime));
                mAdapter.notifyDataSetChanged();
                initDeleteBtn();
              }
            })
        .setNegativeButton(
            "Нет",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {}
            });
    AlertDialog alertDialog = builder.create();
    alertDialog.show();
  }
  private void addNewPodcast() {
    View dialogView = context.getLayoutInflater().inflate(R.layout.create_podcast, null);
    final TextView urlBox = (TextView) dialogView.findViewById(R.id.create_podcast_url);

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder
        .setTitle(R.string.menu_add_podcast)
        .setView(dialogView)
        .setPositiveButton(
            R.string.common_ok,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int id) {
                addNewPodcast(urlBox.getText().toString());
              }
            })
        .setNegativeButton(
            R.string.common_cancel,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
              }
            })
        .setCancelable(true);

    AlertDialog dialog = builder.create();
    dialog.show();
  }
  void showLongDialog(final int pos) {
    AlertDialog dialog =
        new AlertDialog.Builder(mContext)
            .setTitle("开发者选项")
            .setItems(
                R.array.array_device_dialog,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    switch (which) {
                      case 0:
                        showTextInputDialog(pos, Constant.TYPE_MSG_FORMAT_AT);
                        break;
                      case 1:
                        showTextInputDialog(pos, Constant.TYPE_MSG_FORMAT_LUA);
                        break;
                      case 2:
                        requestRefresh(pos);

                        break;
                    }
                  }
                })
            .create();
    dialog.show();
  }
  private void showTextInputDialog(final int pos, final String type) {

    String title = "发送运程" + type + "指令";

    LayoutInflater factory = LayoutInflater.from(mContext);
    final View textEntryView = factory.inflate(R.layout.dialog_text_input, null);

    final EditText et = (EditText) textEntryView.findViewById(R.id.et_message);

    AlertDialog dialog =
        new AlertDialog.Builder(mContext)
            .setTitle(title)
            .setView(textEntryView)
            .setPositiveButton(
                "ok",
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int whichButton) {

                    String msg = et.getEditableText().toString();
                    requestPushMsg(pos, type, msg);
                  }
                })
            .setNegativeButton(
                "cancel",
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int whichButton) {

                    dialog.cancel();
                  }
                })
            .create();
    dialog.show();
  }
  private void showLogoutDialog() {
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(MainActivity.this);
    alertDialogBuilder.setTitle("Logout");
    alertDialogBuilder
        .setMessage("Are you sure want to logout?")
        .setCancelable(false)
        .setPositiveButton(
            "Yes",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {
                mUserPreference.clear();
                Intent mIntent = new Intent(MainActivity.this, LoginActivity.class);
                startActivity(mIntent);
                finish();
              }
            })
        .setNegativeButton(
            "No",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int id) {

                dialog.cancel();
              }
            });

    AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.show();
  }
 @Override
 public void onStart() {
   super.onStart();
   final AlertDialog d = (AlertDialog) getDialog();
   if (d != null) {
     Button positiveButton = d.getButton(Dialog.BUTTON_POSITIVE);
     positiveButton.setOnClickListener(
         new View.OnClickListener() {
           @Override
           public void onClick(View v) {
             name = nameEdit.getText().toString().trim();
             if (!helper.groupExists(name)) {
               helper.addEmptyCategory(name, color);
               PointEditor editor =
                   ((MapActivity) getActivity()).getContextMenu().getPointEditor(editorTag);
               if (editor != null) {
                 editor.setCategory(name);
               }
               d.dismiss();
             } else {
               AlertDialog.Builder b = new AlertDialog.Builder(getActivity());
               b.setMessage(getString(R.string.favorite_category_dublicate_message));
               b.setNegativeButton(R.string.shared_string_ok, null);
               b.show();
             }
           }
         });
   }
 }
Esempio n. 8
0
  public void showTelescopeDialog(final Activity activity) {
    LayoutInflater inflater = LayoutInflater.from(activity);
    TelescopeLayout content =
        (TelescopeLayout) inflater.inflate(R.layout.telescope_tutorial_dialog, null);
    final AlertDialog dialog =
        new AlertDialog.Builder(activity).setView(content).setCancelable(false).create();

    content.setLens(
        new Lens() {
          @Override
          public void onCapture(File file) {
            dialog.dismiss();

            Context toastContext =
                new ContextThemeWrapper(activity, android.R.style.Theme_DeviceDefault_Dialog);
            LayoutInflater toastInflater = LayoutInflater.from(toastContext);
            Toast toast = Toast.makeText(toastContext, "", Toast.LENGTH_SHORT);
            View toastView = toastInflater.inflate(R.layout.telescope_tutorial_toast, null);
            toast.setView(toastView);
            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.show();
          }
        });

    dialog.show();
  }
Esempio n. 9
0
 @Override
 public void onCityDelete(final City city) {
   final IActionUI context = this;
   // TODO: delete city on long press
   AlertDialog.Builder builder = new AlertDialog.Builder(this);
   builder.setTitle("Remove " + city.getName() + "?");
   builder.setPositiveButton(
       android.R.string.yes,
       new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int id) {
           // Start delete task!
           new DeleteCityThread(dataBase, city, context).start();
           dialog.dismiss();
         }
       });
   builder.setNegativeButton(
       android.R.string.no,
       new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int id) {
           dialog.dismiss();
         }
       });
   AlertDialog dialog = builder.create();
   dialog.show();
 }
Esempio n. 10
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    switch (id) {
      case R.id.action_logout:
        ParseUser.logOut();
        navigateToLogin();
        break;
      case R.id.action_edit_friends:
        Intent intent = new Intent(MainActivity.this, EditFriendsActivity.class);
        startActivity(intent);
        break;
      case R.id.action_camera:
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setItems(R.array.camera_choices, mDialogListener);
        AlertDialog dialog = builder.create();
        dialog.show();
    }

    return super.onOptionsItemSelected(item);
  }
  public static void show(Context context, ScheduleView.CourseList list) {
    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.dialog_schedule, null);
    RedPagerView view = (RedPagerView) layout.findViewById(R.id.course_viewpager);

    if (list.list.size() == 1 && list.list.get(0).getCourseType() == 2) {
      ViewGroup.LayoutParams params = view.getLayoutParams();
      params.height = DensityUtils.dp2px(context, 220);
      view.setLayoutParams(params);
    }

    AlertDialog dialog =
        new AlertDialog.Builder(context)
            .setTitle("详细信息")
            .setCancelable(true)
            .setView(
                layout,
                DensityUtils.dp2px(context, 12),
                DensityUtils.dp2px(context, 24),
                DensityUtils.dp2px(context, 12),
                DensityUtils.dp2px(context, 24))
            .create();

    CoursePagerAdapter adapter = new CoursePagerAdapter(context, inflater, list, dialog);
    view.setAdapter(adapter);
    dialog.show();
  }
 @Override
 public void onStart() {
   super.onStart();
   final AlertDialog dialog = (AlertDialog) getDialog();
   // Override the onClickListeners, as the default implementation would dismiss the dialog
   if (dialog != null) {
     if (showImportAccountButton) {
       Button neutralButton = dialog.getButton(DialogInterface.BUTTON_NEUTRAL);
       neutralButton.setOnClickListener(
           new View.OnClickListener() {
             @Override
             public void onClick(View v) {
               ImportAccountsDialogFragment.show(getActivity(), LoginDialogFragment.this);
             }
           });
       // Limit button width to not push positive button out of view
       neutralButton.setMaxEms(10);
     }
     Button positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
     positiveButton.setOnClickListener(
         new View.OnClickListener() {
           @Override
           public void onClick(View v) {
             attemptLogin();
           }
         });
   }
 }
Esempio n. 13
0
  @NonNull
  @Override
  @SuppressLint("InflateParams")
  public AppCompatDialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreateDialog(savedInstanceState);
    View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_sharelink, null, false);
    ButterKnife.bind(this, view);

    // build dialog
    AlertDialog dialog =
        new AlertDialog.Builder(getActivity(), R.style.Widget_Proxy_App_Dialog)
            .setTitle(getString(R.string.dialog_sharelink_title))
            .setView(view)
            .setPositiveButton(getString(R.string.share), _positiveClicked)
            .setNegativeButton(android.R.string.cancel, _negativeClicked)
            .create();

    message.setText(getString(R.string.dialog_sharelink_message));
    // Show the SW Keyboard on dialog start. Always.
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
    dialog.getWindow().getAttributes().width = WindowManager.LayoutParams.MATCH_PARENT;
    dialog.setCanceledOnTouchOutside(false);

    return dialog;
  }
Esempio n. 14
0
  @Override
  public void onStart() {
    super.onStart();

    AlertDialog dialog = (AlertDialog) getDialog();

    dialog
        .getButton(AlertDialog.BUTTON_NEGATIVE)
        .setTextColor(ColorScheme.getPrimaryText(getActivity()));

    positiveButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE);
    positiveButton.setTextColor(ColorScheme.getAccent());
    positiveButton.setEnabled(false);

    editFileName.setOnFocusChangeListener(
        new View.OnFocusChangeListener() {

          @Override
          public void onFocusChange(View v, boolean hasFocus) {
            fromUser = hasFocus;
          }
        });

    editScriptName.addTextChangedListener(scriptNameTextWatcher);
    editFileName.addTextChangedListener(fileNameTextWatcher);

    KeyboardUtils.showKeyboard(editScriptName, true);
  }
 /** Helper method for deleting the selected card. */
 private void deleteCard() {
   AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity());
   dialog.setTitle("Delete this card?");
   dialog
       .setCancelable(false)
       .setPositiveButton(
           "OK",
           new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int id) {
               new DeleteCardWebTask().execute(mUser, mUserList);
               CardInfoDB cardInfoDB = new CardInfoDB(getActivity());
               ArtCard.CardInfo cardToRemove = MainActivity.getCurrentCard();
               cardInfoDB.deleteCardByArtistTitle(
                   cardToRemove.getArtist(), cardToRemove.getTitle());
               ArtCard.ITEMS.remove(MainActivity.getCurrentCard());
               cardInfoDB.closeDB();
             }
           })
       .setNegativeButton(
           "Cancel",
           new DialogInterface.OnClickListener() {
             public void onClick(DialogInterface dialog, int id) {
               dialog.cancel();
             }
           });
   AlertDialog alert = dialog.create();
   alert.show();
 }
Esempio n. 16
0
 @Override
 public void renderDiskVideo(final List<String> entities) {
   final AlertDialog dialog =
       new AlertDialog.Builder(getActivity())
           .setTitle("提示")
           .setMessage("检测到新的文件,是否进行编辑")
           .setPositiveButton(
               "编辑",
               new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface dialog, int which) {
                   Intent intent = new Intent(getActivity(), MovieDiskActivity.class);
                   intent.putStringArrayListExtra(MOVIE_DISK_DATA, (ArrayList<String>) entities);
                   startActivityForResult(intent, MovieActivity.MOVIE_DISK_REQUEST_CODE);
                 }
               })
           .setNegativeButton(
               "取消",
               new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface dialog, int which) {
                   dialog.dismiss();
                 }
               })
           .create();
   dialog.show();
 }
Esempio n. 17
0
  @SuppressLint("SetJavaScriptEnabled")
  protected void loginWebview(final OsmOAuth.AuthType type) {
    final WebView webview = new InputWebView(mFragment.getActivity());
    webview.getSettings().setJavaScriptEnabled(true);
    final AlertDialog dialog =
        new AlertDialog.Builder(mFragment.getActivity()).setView(webview).create();

    ThreadPool.getWorker()
        .execute(
            new Runnable() {
              @Override
              public void run() {
                final String[] auth =
                    (type == OsmOAuth.AuthType.FACEBOOK)
                        ? OsmOAuth.nativeGetFacebookAuthUrl()
                        : OsmOAuth.nativeGetGoogleAuthUrl();

                UiThread.run(
                    new Runnable() {
                      @Override
                      public void run() {
                        if (mFragment.isAdded()) loadWebviewAuth(dialog, webview, auth, type);
                      }
                    });
              }
            });

    dialog.show();
  }
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View v = inflater.inflate(R.layout.sync_enter_passphrase, null);

    TextView promptText = (TextView) v.findViewById(R.id.prompt_text);
    promptText.setText(getPromptText());

    TextView resetText = (TextView) v.findViewById(R.id.reset_text);
    resetText.setText(getResetText());
    resetText.setMovementMethod(LinkMovementMethod.getInstance());
    resetText.setVisibility(View.VISIBLE);

    EditText passphrase = (EditText) v.findViewById(R.id.passphrase);
    passphrase.setHint(R.string.sync_enter_custom_passphrase_hint);
    passphrase.setOnEditorActionListener(
        new OnEditorActionListener() {
          @Override
          public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_NEXT) {
              handleOk();
            }
            return false;
          }
        });

    final AlertDialog d =
        new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
            .setView(v)
            .setPositiveButton(
                R.string.ok,
                new Dialog.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface d, int which) {
                    // We override the onclick. This is a hack to not dismiss the dialog after
                    // click of OK and instead dismiss it after confirming the passphrase
                    // is correct.
                  }
                })
            .setNegativeButton(R.string.cancel, this)
            .setTitle(R.string.sign_in_google_account)
            .create();
    d.getDelegate().setHandleNativeActionModesEnabled(false);
    d.setOnShowListener(
        new DialogInterface.OnShowListener() {
          @Override
          public void onShow(DialogInterface dialog) {
            Button b = d.getButton(AlertDialog.BUTTON_POSITIVE);
            b.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                    handleOk();
                  }
                });
          }
        });
    return d;
  }
Esempio n. 19
0
  // if user clicks and holds and item
  @Override
  public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
    held = true;
    final int currentPos = position;
    // make sure it is not empty
    if (!inventory.get(position).equals("No items in inventory")) {
      // delete the item form the database
      // dbHandler.deleteItem(inventory.get(position).split("     --     ")[0]);
      // Tell the user it was deleted
      // Toast.makeText(this, inventory.get(position).split("     --     ")[0] + " removed",
      // Toast.LENGTH_SHORT).show();
      AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
      alertDialogBuilder.setTitle("Update Item");
      final EditText input = new EditText(MainActivity.this);
      LinearLayout.LayoutParams lp =
          new LinearLayout.LayoutParams(
              LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
      input.setLayoutParams(lp);
      alertDialogBuilder.setView(input);
      alertDialogBuilder
          .setMessage("Set new amount")
          .setCancelable(true)
          .setPositiveButton(
              "Update",
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                  held = false;
                  dbHandler.updateItem(
                      inventory.get(currentPos).split("     --     ")[0],
                      Integer.valueOf(input.getText().toString()));
                  // clear the inventory list
                  inventory.clear();
                  // fill the list view
                  populateList();
                  adapter.notifyDataSetChanged();
                }
              })
          .setNegativeButton(
              "Delete",
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                  held = false;
                  dbHandler.deleteItem(inventory.get(currentPos).split("     --     ")[0]);
                  // clear the inventory list
                  inventory.clear();
                  // fill the list view
                  populateList();
                  adapter.notifyDataSetChanged();
                }
              });

      // create alert dialog
      AlertDialog alertDialog = alertDialogBuilder.create();

      // show it
      alertDialog.show();
    }
    return false;
  }
Esempio n. 20
0
 private void stopProgress() {
   if (reqProgress != null && reqProgress.isShowing()) {
     reqProgress.dismiss();
   }
   if (reDialog != null && reDialog.isShowing()) {
     reDialog.dismiss();
   }
 }
Esempio n. 21
0
 @Override
 public void onStart() {
   super.onStart();
   AlertDialog dialog = (AlertDialog) getDialog();
   setButtonTint(dialog.getButton(Dialog.BUTTON_POSITIVE), colorBlue);
   setButtonTint(dialog.getButton(Dialog.BUTTON_NEGATIVE), colorText);
   initializeRecyclerView();
 }
Esempio n. 22
0
 @Override
 protected void onDestroy() {
   // 判断对话框是否显示状态,显示中则销毁,避免 activity 的销毁导致错误
   if (createConversationDialog != null && createConversationDialog.isShowing()) {
     createConversationDialog.dismiss();
   }
   super.onDestroy();
 }
Esempio n. 23
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
       // Get new list
     case R.id.action_fetch:
       TkkListViewFragment f =
           ((TkkListViewFragment) fm.findFragmentById(R.id.fragment_container));
       AlertDialog.Builder cDialog = new AlertDialog.Builder((f.getListView().getContext()));
       cDialog
           .setMessage(
               "Do you want to download a new stations list?\n(This will add deleted stations back)")
           .setPositiveButton(
               "Yes",
               new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface dialog, int id) {
                   progBar.setVisibility(View.VISIBLE);
                   tuxData.repopulateStations();
                   ((ArrayAdapter)
                           ((TkkListViewFragment) fm.findFragmentById(R.id.fragment_container))
                               .getListView()
                               .getAdapter())
                       .notifyDataSetChanged();
                 }
               })
           .setNegativeButton(
               "No",
               new DialogInterface.OnClickListener() {
                 @Override
                 public void onClick(DialogInterface dialog, int id) {
                   // do nothing
                 }
               });
       AlertDialog a = cDialog.show();
       TextView mView = (TextView) a.findViewById(android.R.id.message);
       if (mView != null) {
         mView.setGravity(Gravity.CENTER);
       }
       return true;
       // Edit list mode
     case R.id.action_edit:
       listEditEnabled = !listEditEnabled;
       item.setChecked(listEditEnabled);
       TkkListViewFragment fragment =
           ((TkkListViewFragment) fm.findFragmentById(R.id.fragment_container));
       fragment.getListView().setRearrangeEnabled(listEditEnabled);
       setDeleteButtons(fragment);
       return true;
       // About screen
     case R.id.action_about:
       displayAbout();
       return true;
       // The f**k that happen?
     default:
       return super.onOptionsItemSelected(item);
   }
 }
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
      AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
      LayoutInflater inflater = getActivity().getLayoutInflater();
      final View v = inflater.inflate(R.layout.fragment_show_ssh_key, null);
      builder.setView(v);

      TextView textView = (TextView) v.findViewById(R.id.public_key);
      File file = new File(getActivity().getFilesDir() + "/.ssh_key.pub");
      try {
        textView.setText(FileUtils.readFileToString(file));
      } catch (Exception e) {
        System.out.println("Exception caught :(");
        e.printStackTrace();
      }

      builder.setPositiveButton(
          getResources().getString(R.string.dialog_ok),
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
              if (getActivity() instanceof SshKeyGen) getActivity().finish();
            }
          });

      builder.setNegativeButton(
          getResources().getString(R.string.dialog_cancel),
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {}
          });

      builder.setNeutralButton(getResources().getString(R.string.ssh_keygen_copy), null);

      final AlertDialog ad = builder.setTitle("Your public key").create();
      ad.setOnShowListener(
          new DialogInterface.OnShowListener() {
            @Override
            public void onShow(DialogInterface dialog) {
              Button b = ad.getButton(AlertDialog.BUTTON_NEUTRAL);
              b.setOnClickListener(
                  new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                      TextView textView = (TextView) getDialog().findViewById(R.id.public_key);
                      ClipboardManager clipboard =
                          (ClipboardManager)
                              getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
                      ClipData clip =
                          ClipData.newPlainText("public key", textView.getText().toString());
                      clipboard.setPrimaryClip(clip);
                    }
                  });
            }
          });
      return ad;
    }
Esempio n. 25
0
 private void setButtonsListeners(AlertDialog dialog) {
   Button button = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
   if (button != null) {
     button.setOnClickListener(new ClickHandler(0 | BUTTON_MASK));
   }
   button = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
   if (button != null) button.setOnClickListener(new ClickHandler(1 | BUTTON_MASK));
   button = dialog.getButton(DialogInterface.BUTTON_NEUTRAL);
   if (button != null) button.setOnClickListener(new ClickHandler(2 | BUTTON_MASK));
 }
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
    showImportAccountButton = AccountImporter.findAccounts(getActivity()).size() > 0;

    // setRetainInstance(true);

    // Build the dialog and set up the button click handlers
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View view = inflater.inflate(R.layout.dialog_signin, null);
    ButterKnife.inject(this, view);

    builder.setView(view);
    builder.setTitle(getString(R.string.action_sign_in_short));

    builder.setPositiveButton(getString(R.string.action_sign_in_short), null);

    if (showImportAccountButton) {
      builder.setNeutralButton(getString(R.string.import_account), null);
    }

    mImageViewShowPwd.setOnClickListener(ImgViewShowPasswordListener);

    SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
    mUsername = mPrefs.getString(SettingsActivity.EDT_USERNAME_STRING, null);
    mPassword = mPrefs.getString(SettingsActivity.EDT_PASSWORD_STRING, null);
    mOc_root_path = mPrefs.getString(SettingsActivity.EDT_OWNCLOUDROOTPATH_STRING, null);
    mCbDisableHostnameVerification =
        mPrefs.getBoolean(SettingsActivity.CB_DISABLE_HOSTNAME_VERIFICATION_STRING, false);

    // Set up the login form.
    mUsernameView.setText(mUsername);
    mPasswordView.setText(mPassword);
    mOc_root_path_View.setText(mOc_root_path);

    mCbDisableHostnameVerificationView.setChecked(mCbDisableHostnameVerification);
    mCbDisableHostnameVerificationView.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
            mPrefs
                .edit()
                .putBoolean(SettingsActivity.CB_DISABLE_HOSTNAME_VERIFICATION_STRING, isChecked)
                .commit();
          }
        });

    AlertDialog dialog = builder.create();
    // Set dialog to resize when soft keyboard pops up
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

    return dialog;
  }
Esempio n. 27
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {
      case R.id.action_update_repo:
        UpdateService.updateNow(this);
        return true;

      case R.id.action_manage_repos:
        startActivity(new Intent(this, ManageReposActivity.class));
        return true;

      case R.id.action_settings:
        Intent prefs = new Intent(getBaseContext(), PreferencesActivity.class);
        startActivityForResult(prefs, REQUEST_PREFS);
        return true;

      case R.id.action_swap:
        startActivity(new Intent(this, SwapWorkflowActivity.class));
        return true;

      case R.id.action_bluetooth_apk:
        /*
         * If Bluetooth has not been enabled/turned on, then enabling
         * device discoverability will automatically enable Bluetooth
         */
        Intent discoverBt = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
        discoverBt.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 121);
        startActivityForResult(discoverBt, REQUEST_ENABLE_BLUETOOTH);
        // if this is successful, the Bluetooth transfer is started
        return true;

      case R.id.action_about:
        View view = LayoutInflater.from(this).inflate(R.layout.about, null);

        String versionName = Utils.getVersionName(this);
        if (versionName != null) {
          ((TextView) view.findViewById(R.id.version)).setText(versionName);
        }

        AlertDialog alrt = new AlertDialog.Builder(this).setView(view).create();
        alrt.setTitle(R.string.about_title);
        alrt.setButton(
            AlertDialog.BUTTON_NEGATIVE,
            getString(R.string.ok),
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int whichButton) {}
            });
        alrt.show();
        return true;
    }
    return super.onOptionsItemSelected(item);
  }
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
      // Associate the "done" button on the soft keyboard with the okay button in the view
      if (EditorInfo.IME_ACTION_DONE == actionId) {
        AlertDialog dialog = ((AlertDialog) getDialog());
        Button bt = dialog.getButton(AlertDialog.BUTTON_POSITIVE);

        bt.performClick();
        return true;
      }
      return false;
    }
 private void updateTextCount(DialogInterface dialog, CharSequence s, ParcelableStatus status) {
   if (!(dialog instanceof AlertDialog)) return;
   final AlertDialog alertDialog = (AlertDialog) dialog;
   final Button positiveButton = alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
   if (positiveButton == null) return;
   positiveButton.setText(s.length() > 0 ? R.string.comment : R.string.retweet);
   final String statusLink =
       LinkCreator.getTwitterStatusLink(status.user_screen_name, status.id).toString();
   final StatusTextCountView textCountView =
       (StatusTextCountView) alertDialog.findViewById(R.id.comment_text_count);
   textCountView.setTextCount(mValidator.getTweetLength(s + " " + statusLink));
 }
  private void addFeedback(final String username) {
    Log.d("TarotFeedback", "username :: " + username);
    View dialogLayout = LayoutInflater.from(this).inflate(R.layout.feedback_alert_dialog, null);
    AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle);
    builder.setView(dialogLayout);
    EditText usernameEditText = (EditText) dialogLayout.findViewById(R.id.user_edittext);
    usernameEditText.setText(username);
    final CommentEditText commentEditText =
        (CommentEditText) dialogLayout.findViewById(R.id.feedback_edittext);
    final RatingBar feedbackRating = (RatingBar) dialogLayout.findViewById(R.id.rating);

    final AlertDialog customAlertDialog = builder.create();
    final Button saveButton = (Button) dialogLayout.findViewById(R.id.feedback_button);

    final Feedback feedbackFromPreference = readFromPreference();
    commentEditText.setText(feedbackFromPreference.getFeedback());
    feedbackRating.setRating((float) feedbackFromPreference.getRating());

    if (!TextUtils.isEmpty(feedbackFromPreference.getObjectId())) {
      saveButton.setText(R.string.update_button_label);
    }
    saveButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            String comment = commentEditText.getText().toString();
            String user = username;
            float rating = feedbackRating.getRating();
            if (TextUtils.isEmpty(comment)) {
              Toast.makeText(
                      TarotFeedbackActivity.this,
                      getString(R.string.save_error_2),
                      Toast.LENGTH_SHORT)
                  .show();
              return;
            }

            if (rating == 0.0f) {
              Toast.makeText(
                      TarotFeedbackActivity.this,
                      getString(R.string.save_error_1),
                      Toast.LENGTH_SHORT)
                  .show();
              return;
            }
            submitFeedback(
                comment, user, rating, feedbackFromPreference.getObjectId(), customAlertDialog);
          }
        });
    customAlertDialog.show();
  }