/** {@inheritDoc}. */
  @Override
  protected Dialog onCreateDialog(int id) {
    Dialog dialog;
    switch (id) {
      case DIALOG_CREATE:
        dialog = new CreatePrivacyList(PrivacyList.this, mPrivacyListManager).create();
        dialog.setOnDismissListener(
            new OnDismissListener() {

              @Override
              public void onDismiss(DialogInterface dialog) {
                PrivacyList.this.removeDialog(DIALOG_CREATE);
              }
            });
        break;
      case DIALOG_DELETE:
        dialog =
            new DeletePrivacyList(PrivacyList.this, mPrivacyListManager, mCurrPrivacyListName)
                .create();
        dialog.setOnDismissListener(
            new OnDismissListener() {

              @Override
              public void onDismiss(DialogInterface dialog) {
                PrivacyList.this.removeDialog(DIALOG_DELETE);
              }
            });
        break;
      default:
        dialog = null;
    }
    return dialog;
  }
Example #2
0
        public void handleMessage(android.os.Message msg) {
          dismissLoadingDialog();
          switch (msg.what) {
            case MSG_DEAUTHORIZE_SUCCESS:
              Dialog dialog =
                  DialogUtil.createMsgDialog(
                      FacebookActivity.this,
                      getString(R.string.deauthorize_complete),
                      getString(R.string.confirm));
              dialog.setOnDismissListener(
                  new OnDismissListener() {

                    @Override
                    public void onDismiss(DialogInterface dialog) {
                      // TODO Auto-generated method stub
                      finish();
                    }
                  });
              dialog.show();
              break;
            case MSG_DEAUTHORIZE_ERROR:
              String message = (String) msg.obj;
              DialogUtil.createMsgDialog(
                      FacebookActivity.this, message, getString(R.string.confirm))
                  .show();
              break;
            case MSG_NET_ERROR:
              DialogUtil.createMsgDialog(
                      FacebookActivity.this,
                      getString(R.string.net_error),
                      getString(R.string.confirm))
                  .show();
              break;
          }
        };
  /** 자동가입앱인 경우는 가입안된 유저가 나오는 것은 에러 상황. */
  protected void showSignup() {
    Logger.d("not registered user");
    //        redirectLoginActivity();
    String message = "not registered user.\nYou should signup at UserManagememt menu.";
    Dialog dialog =
        new DialogBuilder(this)
            .setMessage(message)
            .setPositiveButton(
                android.R.string.ok,
                new OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                  }
                })
            .create();

    dialog.setOnDismissListener(
        new OnDismissListener() {
          @Override
          public void onDismiss(DialogInterface dialog) {
            finish();
          }
        });
    dialog.show();
  }
 @Override
 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
   if (buttonView == mEnabledSwitch) {
     if (isChecked != mLastEnabledState) {
       if (isChecked) {
         mDialogClicked = false;
         if (mEnableDialog != null) dismissDialogs();
         mEnableDialog =
             new AlertDialog.Builder(getActivity())
                 .setMessage(
                     getActivity().getResources().getString(R.string.dev_settings_warning_message))
                 .setTitle(R.string.dev_settings_warning_title)
                 .setIconAttribute(android.R.attr.alertDialogIcon)
                 .setPositiveButton(android.R.string.yes, this)
                 .setNegativeButton(android.R.string.no, this)
                 .show();
         mEnableDialog.setOnDismissListener(this);
       } else {
         resetDangerousOptions();
         Settings.Global.putInt(
             getActivity().getContentResolver(), Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0);
         mLastEnabledState = isChecked;
         setPrefsEnabledState(mLastEnabledState);
       }
     }
   }
 }
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    if (item.getItemId() == R.id.mnuDelete) {
      // they have requested that we delete the selected race
      AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
      ListView list = (ListView) info.targetView.getParent();
      DBPathEntry db = (DBPathEntry) list.getItemAtPosition(info.position);

      try {
        if (db.GetFile().delete()) {
          Toast.makeText(this, "Database deleted", Toast.LENGTH_LONG).show();
        } else {
          Toast.makeText(this, "Failed to delete DB", Toast.LENGTH_LONG).show();
        }
      } catch (Exception e) {
        Toast.makeText(this, "Failed to delete file " + e.toString(), Toast.LENGTH_LONG).show();
      }
      FirstTimeSetup(); // refresh the list
      return true;
    } else if (item.getItemId() == R.id.mnuRename) {
      AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
      ListView list = (ListView) info.targetView.getParent();
      DBPathEntry db = (DBPathEntry) list.getItemAtPosition(info.position);

      // they have requested that we rename the selected race
      Dialog d = new RenameDialog<DBPathEntry>(this, "Set the new DB name", db, R.id.edtRename);
      d.setOnDismissListener(this);
      d.show();

      return true;
    }
    return false;
  }
Example #6
0
  // 第三方应用发送到微信的请求处理后的响应结果,会回调到该方法
  @Override
  public void onResp(BaseResp resp) {
    Log.d(TAG, ">>>#WXResponse---errorCode" + resp.errCode + "--errorMsg:" + resp.errStr);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
      finish();
    } else {
      switch (resp.errCode) {
        case BaseResp.ErrCode.ERR_OK:
          UploadAttachmentClient.getInstance().startUpload();
          dialog =
              ShareDialogUtil.displayDialog(
                  WXEntryActivity.this, ShareDialogUtil.TYPE_SHARE_COMFIRM, true);
          break;
        case BaseResp.ErrCode.ERR_AUTH_DENIED:
          dialog =
              ShareDialogUtil.displayDialog(
                  WXEntryActivity.this, ShareDialogUtil.TYPE_SHARE_COMFIRM, true);
          break;
        case BaseResp.ErrCode.ERR_USER_CANCEL:
          finish();
        default:
          finish();
          break;
      }
      if (dialog != null)
        dialog.setOnDismissListener(
            new OnDismissListener() {

              @Override
              public void onDismiss(DialogInterface dialog) {
                finish();
              }
            });
    }
  }
Example #7
0
  private void showDialog(Bundle state) {
    final Context context = getContext();

    Dialog dialog = mDialog = new ThemePreferencePreview(context);
    dialog.setOnDismissListener(this);
    if (state != null) {
      dialog.onRestoreInstanceState(state);
    }
    dialog.show();
  }
  @Override
  public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {

    if (Utils.isMonkeyRunning()) {
      return false;
    }

    if (preference == mEnableAdb) {
      if (mEnableAdb.isChecked()) {
        mOkClicked = false;
        if (mOkDialog != null) dismissDialog();
        mOkDialog =
            new AlertDialog.Builder(getActivity())
                .setMessage(getActivity().getResources().getString(R.string.adb_warning_message))
                .setTitle(R.string.adb_warning_title)
                .setIcon(android.R.drawable.ic_dialog_alert)
                .setPositiveButton(android.R.string.yes, this)
                .setNegativeButton(android.R.string.no, this)
                .show();
        mOkDialog.setOnDismissListener(this);
      } else {
        Settings.Secure.putInt(getActivity().getContentResolver(), Settings.Secure.ADB_ENABLED, 0);
      }
    } else if (preference == mKeepScreenOn) {
      Settings.System.putInt(
          getActivity().getContentResolver(),
          Settings.System.STAY_ON_WHILE_PLUGGED_IN,
          mKeepScreenOn.isChecked()
              ? (BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB)
              : 0);
    } else if (preference == mAllowMockLocation) {
      Settings.Secure.putInt(
          getActivity().getContentResolver(),
          Settings.Secure.ALLOW_MOCK_LOCATION,
          mAllowMockLocation.isChecked() ? 1 : 0);
    } else if (preference == mStrictMode) {
      writeStrictModeVisualOptions();
    } else if (preference == mPointerLocation) {
      writePointerLocationOptions();
    } else if (preference == mShowTouches) {
      writeShowTouchesOptions();
    } else if (preference == mShowScreenUpdates) {
      writeFlingerOptions();
    } else if (preference == mShowCpuUsage) {
      writeCpuUsageOptions();
    } else if (preference == mImmediatelyDestroyActivities) {
      writeImmediatelyDestroyActivitiesOptions();
    } else if (preference == mShowAllANRs) {
      writeShowAllANRsOptions();
    } else if (preference == mForceHardwareUi) {
      writeHardwareUiOptions();
    }

    return false;
  }
Example #9
0
 public static c a(
     Dialog dialog, android.content.DialogInterface.OnCancelListener oncancellistener) {
   c c1 = new c();
   dialog = (Dialog) am.a(dialog, "Cannot display null dialog");
   dialog.setOnCancelListener(null);
   dialog.setOnDismissListener(null);
   c1.a = dialog;
   if (oncancellistener != null) {
     c1.b = oncancellistener;
   }
   return c1;
 }
Example #10
0
  private Dialog getDialogPressedBack() {
    PressedBackBuilder pressedBackBuilder = new PressedBackBuilder(this);
    Dialog dialog = pressedBackBuilder.create();
    dialog.setOnDismissListener(
        new OnDismissListener() {

          public void onDismiss(DialogInterface dialog) {
            dialog.dismiss();
          }
        });
    return dialog;
  }
Example #11
0
  public void setOnDismissListener(DialogInterface.OnDismissListener listener) {
    mOnDismissListener = listener;
    mDialog.setOnDismissListener(
        new android.content.DialogInterface.OnDismissListener() {

          @Override
          public void onDismiss(android.content.DialogInterface dialog) {
            if (mOnDismissListener != null) {
              mOnDismissListener.onDismiss(DropDownDialog.this);
            }
          }
        });
  }
Example #12
0
  private Dialog getDialogErrorGenerateCSV() {
    SummaryErrorGenereateCSVBuilder summaryErrorGenereateCSVBuilder =
        new SummaryErrorGenereateCSVBuilder(this);
    Dialog dialog = summaryErrorGenereateCSVBuilder.create();
    dialog.setOnDismissListener(
        new OnDismissListener() {

          public void onDismiss(DialogInterface dialog) {
            dialog.dismiss();
          }
        });
    return dialog;
  }
Example #13
0
  /** @hide */
  public boolean takeCancelAndDismissListeners(
      String msg, final OnCancelListener cancel, final OnDismissListener dismiss) {
    if (mCancelAndDismissTaken != null) {
      mCancelAndDismissTaken = null;
    } else if (mCancelMessage != null || mDismissMessage != null) {
      return false;
    }

    setOnCancelListener(cancel);
    setOnDismissListener(dismiss);
    mCancelAndDismissTaken = msg;

    return true;
  }
Example #14
0
  private Dialog getDialogGenerateCSV() {
    final SummaryConfirmRequisition summaryConfirmRequisition = new SummaryConfirmRequisition(this);
    Dialog dialog = summaryConfirmRequisition.create();
    dialog.setOnDismissListener(
        new OnDismissListener() {

          public void onDismiss(DialogInterface dialog) {
            if (summaryConfirmRequisition.getPressedButtonOPk()) {
              generateCSV();
              dialog.dismiss();
            }
          }
        });
    return dialog;
  }
Example #15
0
  @Override
  public void onDestroyView() {
    Log_OC.d(TAG, "onDestroyView");

    mSsoWebView.setWebViewClient(null);

    // Work around bug: http://code.google.com/p/android/issues/detail?id=17423
    Dialog dialog = getDialog();
    if ((dialog != null)) {
      dialog.setOnDismissListener(null);
      // dialog.dismiss();
      // dialog.setDismissMessage(null);
    }

    super.onDestroyView();
  }
  public static Dialog createPermissionSettingDialog(
      final Activity activity, String forbiddenPermissions) {
    if (forbiddenPermissions.length() > 1) {
      forbiddenPermissions = forbiddenPermissions.substring(0, forbiddenPermissions.length() - 1);
    }
    Dialog dialog =
        new AlertDialog.Builder(activity)
            .setTitle(R.string.permission_title)
            .setMessage(
                activity.getString(R.string.permission_setting_guidedialog, forbiddenPermissions))
            .setPositiveButton(
                R.string.permission_gosetting,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    final Intent intentnew =
                        new Intent(
                            Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
                            Uri.parse(
                                PermissionsUtil.PACKAGE_URI_PREFIX + activity.getPackageName()));
                    activity.startActivity(intentnew);
                  }
                })
            .setNegativeButton(
                R.string.permission_know,
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                  }
                })
            .create();
    dialog.setOnDismissListener(
        new OnDismissListener() {

          @Override
          public void onDismiss(DialogInterface dialog) {
            // TODO Auto-generated method stub
            activity.finish();
          }
        });
    dialog.setCanceledOnTouchOutside(false);
    return dialog;
  }
  @Override
  public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {

    if (Utils.isMonkeyRunning()) {
      return false;
    }

    if (preference == mEnableAdb) {
      if (mEnableAdb.isChecked()) {
        mOkClicked = false;
        if (mOkDialog != null) dismissDialog();
        mOkDialog =
            new AlertDialog.Builder(this)
                .setMessage(getResources().getString(R.string.adb_warning_message))
                .setTitle(R.string.adb_warning_title)
                .setIcon(android.R.drawable.ic_dialog_alert)
                .setPositiveButton(android.R.string.yes, this)
                .setNegativeButton(android.R.string.no, this)
                .show();
        mOkDialog.setOnDismissListener(this);
      } else {
        Settings.Secure.putInt(getContentResolver(), Settings.Secure.ADB_ENABLED, 0);
        SystemProperties.set("persist.service.adb.enable", "0");
      }
    } else if (preference == mAdbNotify) {
      Settings.Secure.putInt(
          getContentResolver(), Settings.Secure.ADB_NOTIFY, mAdbNotify.isChecked() ? 1 : 0);
    } else if (preference == mKeepScreenOn) {
      Settings.System.putInt(
          getContentResolver(),
          Settings.System.STAY_ON_WHILE_PLUGGED_IN,
          mKeepScreenOn.isChecked()
              ? (BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB)
              : 0);
    } else if (preference == mAllowMockLocation) {
      Settings.Secure.putInt(
          getContentResolver(),
          Settings.Secure.ALLOW_MOCK_LOCATION,
          mAllowMockLocation.isChecked() ? 1 : 0);
    }

    return false;
  }
  private void buildDialog() {

    AlertDialog.Builder builder =
        new AlertDialog.Builder(context)
            .setTitle(context.getString(R.string.passcode_dialog_title))
            .setIcon(R.drawable.ten20_logo_transparent)
            .setPositiveButton(context.getString(R.string.passcode_dialog_ok), mOkClickListener)
            .setNegativeButton(
                context.getString(R.string.passcode_dialog_cancel), mCancelClickListener);

    passcodeEditText = new EditText(context);
    passcodeEditText.setTransformationMethod(new PasswordTransformationMethod());
    passcodeEditText.setKeyListener(new DigitsKeyListener());

    builder.setView(passcodeEditText);

    dialog = builder.create();
    dialog.setOnDismissListener(this);
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
  }
Example #19
0
  private Dialog getDialogCancel() {
    final SummaryDialogCancel summaryDialogCancel = new SummaryDialogCancel(this);
    Dialog dialog = summaryDialogCancel.create();
    dialog.setOnDismissListener(
        new OnDismissListener() {

          public void onDismiss(DialogInterface dialog) {
            if (summaryDialogCancel.isPressedButtonOPk()) {
              Toast toast =
                  Toast.makeText(
                      FrmSummary.this,
                      R.string.lblSummaryMessageCancelLisRequisition,
                      Toast.LENGTH_SHORT);
              toast.setGravity(Gravity.CENTER, 0, 0);
              toast.show();
              finish();
            }
            dialog.dismiss();
          }
        });
    return dialog;
  }
Example #20
0
 @Override
 protected Dialog onCreateDialog(int id, Bundle args) {
   // TODO Auto-generated method stub
   Dialog dialog = null;
   switch (id) {
     case DIALOG_CAPTURE:
       dialog = new Dialog(this);
       dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
       dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
       dialog.setContentView(R.layout.image_popup);
       return dialog;
     case DIALOG_PASSWORD:
       dialog = new Dialog(this);
       dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
       dialog.setContentView(R.layout.dialog_password);
       mPassword = new MyPassword(mContext, dialog);
       return dialog;
     case DIALOG_SELECTICON:
       dialog = new Dialog(this);
       dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
       dialog.setContentView(R.layout.dialog_userimage);
       mListener = new RadioGroupListener(dialog, mHandler);
       dialog.setOnDismissListener(mListener.getDismissListener());
       return dialog;
     case DIALOG_NFC:
       dialog = new Dialog(this);
       dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
       dialog.setContentView(R.layout.dialog_nfc);
       NFCDialog = dialog;
       return dialog;
     case DIALOG_SENSOR:
       dialog = new Dialog(this);
       dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
       dialog.setContentView(R.layout.dialog_sensor);
       return dialog;
   }
   return null;
 }
 @Override
 protected Dialog onCreateDialog(int id) {
   Dialog dialog = null;
   LayoutInflater factory = null;
   View view = null;
   Builder builder = null;
   switch (id) {
     case DIALOG_LOGCONTROL:
       builder = new AlertDialog.Builder(this);
       factory = LayoutInflater.from(this);
       view = factory.inflate(R.layout.logcontrol, null);
       builder
           .setTitle(R.string.dialog_tracking_title)
           .setIcon(android.R.drawable.ic_dialog_alert)
           .setNegativeButton(R.string.btn_cancel, mDialogClickListener)
           .setView(view);
       dialog = builder.create();
       start = (Button) view.findViewById(R.id.logcontrol_start);
       pause = (Button) view.findViewById(R.id.logcontrol_pause);
       resume = (Button) view.findViewById(R.id.logcontrol_resume);
       stop = (Button) view.findViewById(R.id.logcontrol_stop);
       start.setOnClickListener(mLoggingControlListener);
       pause.setOnClickListener(mLoggingControlListener);
       resume.setOnClickListener(mLoggingControlListener);
       stop.setOnClickListener(mLoggingControlListener);
       dialog.setOnDismissListener(
           new OnDismissListener() {
             public void onDismiss(DialogInterface dialog) {
               if (!paused) {
                 finish();
               }
             }
           });
       return dialog;
     default:
       return super.onCreateDialog(id);
   }
 }
Example #22
0
  protected Dialog onCreateDialog(final int id) {
    Dialog dialog;
    switch (id) {
      case Isense.DIALOG_LOGIN_ID:
        LoginActivity la = new LoginActivity(mContext);
        dialog =
            la.getDialog(
                new Handler() {
                  public void handleMessage(Message msg) {
                    switch (msg.what) {
                      case LoginActivity.LOGIN_SUCCESSFULL:
                        break;
                      case LoginActivity.LOGIN_CANCELED:
                        break;
                      case LoginActivity.LOGIN_FAILED:
                        break;
                    }
                  }
                });
        break;
      default:
        dialog = null;
    }

    if (dialog != null) {
      dialog.setOnDismissListener(
          new OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
              removeDialog(id);
            }
          });
    }

    return dialog;
  }
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    // url=getIntent().getStringExtra("img");
    // new ServerRead().execute("");
    dialog = new Dialog(this);
    dialog.getWindow();
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.push_image);

    // set the custom dialog components - text, image and button

    dialog.setOnCancelListener(
        new DialogInterface.OnCancelListener() {

          @Override
          public void onCancel(DialogInterface dialog) {
            finish();
          }
        });

    dialog.setOnDismissListener(
        new DialogInterface.OnDismissListener() {

          @Override
          public void onDismiss(DialogInterface dialog) {
            // TODO Auto-generated method stub
            finish();
          }
        });

    // set the custom dialog components - text, image and button
    // splash.setImageBitmap(splashbitmap);

    setView();
  }
Example #24
0
  @Override
  protected Dialog onCreateDialog(int ignore, Bundle args) {

    // TODO set values from "flags" to messagebox dialog

    // get colors

    int[] colors = args.getIntArray("colors");
    int backgroundColor;
    int textColor;
    int buttonBorderColor;
    int buttonBackgroundColor;
    int buttonSelectedColor;
    if (colors != null) {
      int i = -1;
      backgroundColor = colors[++i];
      textColor = colors[++i];
      buttonBorderColor = colors[++i];
      buttonBackgroundColor = colors[++i];
      buttonSelectedColor = colors[++i];
    } else {
      backgroundColor = Color.TRANSPARENT;
      textColor = Color.TRANSPARENT;
      buttonBorderColor = Color.TRANSPARENT;
      buttonBackgroundColor = Color.TRANSPARENT;
      buttonSelectedColor = Color.TRANSPARENT;
    }

    // create dialog with title and a listener to wake up calling thread

    final Dialog dialog = new Dialog(this);
    dialog.setTitle(args.getString("title"));
    dialog.setCancelable(false);
    dialog.setOnDismissListener(
        new DialogInterface.OnDismissListener() {
          @Override
          public void onDismiss(DialogInterface unused) {
            synchronized (messageboxSelection) {
              messageboxSelection.notify();
            }
          }
        });

    // create text

    TextView message = new TextView(this);
    message.setGravity(Gravity.CENTER);
    message.setText(args.getString("message"));
    if (textColor != Color.TRANSPARENT) {
      message.setTextColor(textColor);
    }

    // create buttons

    int[] buttonFlags = args.getIntArray("buttonFlags");
    int[] buttonIds = args.getIntArray("buttonIds");
    String[] buttonTexts = args.getStringArray("buttonTexts");

    final SparseArray<Button> mapping = new SparseArray<Button>();

    LinearLayout buttons = new LinearLayout(this);
    buttons.setOrientation(LinearLayout.HORIZONTAL);
    buttons.setGravity(Gravity.CENTER);
    for (int i = 0; i < buttonTexts.length; ++i) {
      Button button = new Button(this);
      final int id = buttonIds[i];
      button.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              messageboxSelection[0] = id;
              dialog.dismiss();
            }
          });
      if (buttonFlags[i] != 0) {
        // see SDL_messagebox.h
        if ((buttonFlags[i] & 0x00000001) != 0) {
          mapping.put(KeyEvent.KEYCODE_ENTER, button);
        }
        if ((buttonFlags[i] & 0x00000002) != 0) {
          mapping.put(111, button); /* API 11: KeyEvent.KEYCODE_ESCAPE */
        }
      }
      button.setText(buttonTexts[i]);
      if (textColor != Color.TRANSPARENT) {
        button.setTextColor(textColor);
      }
      if (buttonBorderColor != Color.TRANSPARENT) {
        // TODO set color for border of messagebox button
      }
      if (buttonBackgroundColor != Color.TRANSPARENT) {
        Drawable drawable = button.getBackground();
        if (drawable == null) {
          // setting the color this way removes the style
          button.setBackgroundColor(buttonBackgroundColor);
        } else {
          // setting the color this way keeps the style (gradient, padding, etc.)
          drawable.setColorFilter(buttonBackgroundColor, PorterDuff.Mode.MULTIPLY);
        }
      }
      if (buttonSelectedColor != Color.TRANSPARENT) {
        // TODO set color for selected messagebox button
      }
      buttons.addView(button);
    }

    // create content

    LinearLayout content = new LinearLayout(this);
    content.setOrientation(LinearLayout.VERTICAL);
    content.addView(message);
    content.addView(buttons);
    if (backgroundColor != Color.TRANSPARENT) {
      content.setBackgroundColor(backgroundColor);
    }

    // add content to dialog and return

    dialog.setContentView(content);
    dialog.setOnKeyListener(
        new Dialog.OnKeyListener() {
          @Override
          public boolean onKey(DialogInterface d, int keyCode, KeyEvent event) {
            Button button = mapping.get(keyCode);
            if (button != null) {
              if (event.getAction() == KeyEvent.ACTION_UP) {
                button.performClick();
              }
              return true; // also for ignored actions
            }
            return false;
          }
        });

    return dialog;
  }
Example #25
0
 /**
  * Sets on dismiss listener.
  *
  * @param onDismissListener the on dismiss listener
  */
 public void setOnDismissListener(DialogInterface.OnDismissListener onDismissListener) {
   dialog.setOnDismissListener(onDismissListener);
 }
Example #26
0
  @Override
  protected void onPrepareDialog(int id, Dialog dialog, Bundle args) {
    // TODO Auto-generated method stub

    final Dialog pDialog = dialog;
    switch (id) {
      case DIALOG_CAPTURE:
        int position = args.getInt("selected");
        BitmapFactory.Options bfo = new BitmapFactory.Options();
        bfo.inSampleSize = 1;

        String arrImage[] = mImageAdapter.getImagePath(position).split("/");
        String imageName = "";
        if (arrImage.length == 6) {
          imageName = arrImage[5];
        }
        TextView textView = (TextView) dialog.findViewById(R.id.textView1);
        textView.setText(imageName);

        Bitmap bm = BitmapFactory.decodeFile(mImageAdapter.getImagePath(position), bfo);
        Bitmap resized = Bitmap.createScaledBitmap(bm, imgWidth, imgHeight, true);
        ImageView imageView = (ImageView) dialog.findViewById(R.id.imageView2);
        imageView.setImageBitmap(resized);
        imageView.setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View v) {
                // TODO Auto-generated method stub
                pDialog.dismiss();
              }
            });
        break;
      case DIALOG_PASSWORD:
        dialog.setOnDismissListener(
            new OnDismissListener() {

              @Override
              public void onDismiss(DialogInterface dialog) {
                // TODO Auto-generated method stub
                // Send Unlock Message
                if (mPassword.getTmpPassword().equals("")) {
                  String PASSWORD = mPassword.getPassword();
                  if (tButton3.isChecked()) {
                    dataID = String.valueOf(Constants.MSG_NFC);
                    data = PASSWORD;
                    dataLen = mSocket.makeDataLenToByte(data.length());
                    mSocket.sendMessage(dataID.getBytes(), dataLen, data.getBytes());
                  } else {
                    dataID = String.valueOf(Constants.MSG_UNLOCK);
                    data = PASSWORD + "," + mUser.getName() + "," + String.valueOf(mUser.getIcon());
                    dataLen = mSocket.makeDataLenToByte(data.length());
                    mSocket.sendMessage(dataID.getBytes(), dataLen, data.getBytes());
                  }
                } else {
                  mPassword.setTmpPassword();
                }
              }
            });
        break;
      case DIALOG_SELECTICON:
        // mListener.setDialog(dialog);
        // mListener.setView();
        break;

      case DIALOG_NFC:
        mNfcAdapter.setNdefPushMessageCallback(this, this);
        mNfcAdapter.setOnNdefPushCompleteCallback(this, this);

      case DIALOG_SENSOR:
        dialog.setCanceledOnTouchOutside(true);
    }
  }
  @Override
  public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {

    if (Utils.isMonkeyRunning()) {
      return false;
    }

    if (preference == mEnableAdb) {
      if (mEnableAdb.isChecked()) {
        mDialogClicked = false;
        if (mAdbDialog != null) dismissDialogs();
        mAdbDialog =
            new AlertDialog.Builder(getActivity())
                .setMessage(getActivity().getResources().getString(R.string.adb_warning_message))
                .setTitle(R.string.adb_warning_title)
                .setIconAttribute(android.R.attr.alertDialogIcon)
                .setPositiveButton(android.R.string.yes, this)
                .setNegativeButton(android.R.string.no, this)
                .show();
        mAdbDialog.setOnDismissListener(this);
      } else {
        Settings.Global.putInt(getActivity().getContentResolver(), Settings.Global.ADB_ENABLED, 0);
        mVerifyAppsOverUsb.setEnabled(false);
        mVerifyAppsOverUsb.setChecked(false);
        updateBugreportOptions();
      }
    } else if (preference == mBugreportInPower) {
      Settings.Secure.putInt(
          getActivity().getContentResolver(),
          Settings.Secure.BUGREPORT_IN_POWER_MENU,
          mBugreportInPower.isChecked() ? 1 : 0);
    } else if (preference == mKeepScreenOn) {
      Settings.Global.putInt(
          getActivity().getContentResolver(),
          Settings.Global.STAY_ON_WHILE_PLUGGED_IN,
          mKeepScreenOn.isChecked()
              ? (BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB)
              : 0);
    } else if (preference == mEnforceReadExternal) {
      if (mEnforceReadExternal.isChecked()) {
        ConfirmEnforceFragment.show(this);
      } else {
        setPermissionEnforced(getActivity(), READ_EXTERNAL_STORAGE, false);
      }
    } else if (preference == mAllowMockLocation) {
      Settings.Secure.putInt(
          getActivity().getContentResolver(),
          Settings.Secure.ALLOW_MOCK_LOCATION,
          mAllowMockLocation.isChecked() ? 1 : 0);
    } else if (preference == mDebugAppPref) {
      startActivityForResult(new Intent(getActivity(), AppPicker.class), RESULT_DEBUG_APP);
    } else if (preference == mWaitForDebugger) {
      writeDebuggerOptions();
    } else if (preference == mVerifyAppsOverUsb) {
      writeVerifyAppsOverUsbOptions();
    } else if (preference == mStrictMode) {
      writeStrictModeVisualOptions();
    } else if (preference == mPointerLocation) {
      writePointerLocationOptions();
    } else if (preference == mShowTouches) {
      writeShowTouchesOptions();
    } else if (preference == mShowScreenUpdates) {
      writeShowUpdatesOption();
    } else if (preference == mDisableOverlays) {
      writeDisableOverlaysOption();
    } else if (preference == mShowCpuUsage) {
      writeCpuUsageOptions();
    } else if (preference == mImmediatelyDestroyActivities) {
      writeImmediatelyDestroyActivitiesOptions();
    } else if (preference == mShowAllANRs) {
      writeShowAllANRsOptions();
    } else if (preference == mForceHardwareUi) {
      writeHardwareUiOptions();
    } else if (preference == mForceMsaa) {
      writeMsaaOptions();
    } else if (preference == mTrackFrameTime) {
      writeTrackFrameTimeOptions();
    } else if (preference == mShowHwScreenUpdates) {
      writeShowHwScreenUpdatesOptions();
    } else if (preference == mShowHwLayersUpdates) {
      writeShowHwLayersUpdatesOptions();
    } else if (preference == mShowHwOverdraw) {
      writeShowHwOverdrawOptions();
    } else if (preference == mDebugLayout) {
      writeDebugLayoutOptions();
    } else if (preference == mKillAppLongpressBack) {
      writeKillAppLongpressBackOptions();
    }

    return false;
  }
Example #28
0
  protected Dialog onCreateDialog(int id) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    switch (id) {
      case PROMPT_OAUTH:
        builder
            .setMessage(R.string.commentneedsinaoauth)
            .setCancelable(false)
            .setPositiveButton(
                R.string.ok,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int id) {
                    FlipdroidApplications application = (FlipdroidApplications) getApplication();
                    OAuth oauth = new OAuth();
                    application.setOauth(oauth);
                    //// System.out.println("OAuthHolder.oauth" + application + oauth);
                    oauth.RequestAccessToken(PageActivity.this, "flipdroid://SinaAccountSaver");
                  }
                })
            .setNegativeButton(
                R.string.cancel,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int id) {}
                });
        this.dialog = builder.create();
        break;
      case NAVIGATION:
        LayoutInflater li = LayoutInflater.from(this);
        View v = li.inflate(R.layout.dialog_nav_title_view, null);

        // builder.setView(v);
        builder.setCustomTitle(v);

        builder.setAdapter(
            sourceAdapter,
            new DialogInterface.OnClickListener() {

              public void onClick(DialogInterface dialogInterface, int i) {
                Intent intent = new Intent(PageActivity.this, PageActivity.class);
                SourceItem cursor = sourceAdapter.getItem(i);
                intent.putExtra("type", cursor.getSourceType());
                intent.putExtra("sourceId", cursor.getSourceId());
                intent.putExtra("sourceImage", cursor.getSourceImage());
                intent.putExtra("sourceName", cursor.getSourceName());
                intent.putExtra("contentUrl", cursor.getSourceURL());
                if (dialog != null) dialog.dismiss();
                startActivity(intent);
                finishActivity();
              }
            });

        this.dialog = builder.create();
        Button btn_addshortcut = (Button) v.findViewById(R.id.btnaddshortcut);
        btn_addshortcut.setText("add shortcut");

        btn_addshortcut.setOnClickListener(
            new Button.OnClickListener() {
              public void onClick(View v) {
                addShortcut();
                dialog.cancel();
              }
            });

        dialog.setOnKeyListener(
            new DialogInterface.OnKeyListener() {
              public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
                if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_MENU) {
                  if (dialog != null) {
                    dialog.dismiss();
                    return true;
                  }
                }

                return false;
              }
            });
        break;
      default:
        this.dialog = null;
    }
    if (dialog != null) {
      dialog.setOnDismissListener(
          new DialogInterface.OnDismissListener() {
            public void onDismiss(DialogInterface dialogInterface) {
              dialog = null;
            }
          });
    }
    return this.dialog;
  }
  @Override
  protected Dialog onCreateDialog(int id, Bundle bundle) {
    Xlog.i(TAG, "onCreateDialog id, dialog id = " + id);
    Dialog dialog = null;
    switch (id) {
      case DIALOG_INSTALLWARNING: // warning user before install
        dialog =
            new AlertDialog.Builder(this)
                .setTitle(R.string.install_sd_title)
                .setMessage(getString(R.string.install_sd_message))
                .setPositiveButton(
                    R.string.btn_install,
                    new DialogInterface.OnClickListener() {

                      public void onClick(DialogInterface dialog, int whichButton) {
                        invalidateOptionsMenu();
                        mDownloadInfo.setActivityID(mActivityOrder);
                        mDownloadInfo.setTargetVer(mVersion);
                        mDownloadInfo.setUpgradeStartedState(true);
                        installPackage(DES_PACKAGE, mVersion);
                      }
                    })
                .setNegativeButton(
                    android.R.string.no,
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int whichButton) {
                        Xlog.v(TAG, "Dialog_Install_warning, cancel,finish activity");
                        if (!mDownloadInfo.getIfNeedRefreshMenu()) {

                          if (mDownloadInfo.getActivityID() < 0) {
                            mGoToMainEntry = true;
                            SdPkgInstallActivity.this.startActivity(
                                new Intent(SdPkgInstallActivity.this, MainEntry.class));
                          }
                        }
                        SdPkgInstallActivity.this.finish();
                      }
                    })
                .create();
        mCurrentDialog = id;
        dialog.setOnDismissListener(this);
        break;
      case DIALOG_NOSDCARD: // error occur before unzip update.zip to correct SD card
        dialog =
            new AlertDialog.Builder(this)
                .setTitle(R.string.error_sdcard)
                .setMessage(getString(R.string.sdcard_crash_or_unmount))
                .setOnCancelListener(this)
                .setPositiveButton(android.R.string.ok, this)
                .create();
        mCurrentDialog = id;
        dialog.setOnDismissListener(this);
        break;
      case DIALOG_NOENOUGHSPACE: // error occur before unzip update.zip to correct SD card
        dialog =
            new AlertDialog.Builder(this)
                .setTitle(R.string.insufficient_space_title)
                .setMessage(getString(R.string.install_sd_info))
                .setOnCancelListener(
                    new DialogInterface.OnCancelListener() {
                      @Override
                      public void onCancel(DialogInterface dialog) {
                        mDownloadInfo.setUpgradeStartedState(false);
                      }
                    })
                .setPositiveButton(
                    android.R.string.ok,
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int whichButton) {

                        SdPkgInstallActivity.this.finish();
                        Xlog.v(TAG, "Dialog_No_enough_space, OK,finish activity");
                      }
                    })
                .create();
        mCurrentDialog = id;
        dialog.setOnDismissListener(this);
        break;
      case DIALOG_INVALIDATEPACKAGE:
        dialog =
            new AlertDialog.Builder(this)
                .setTitle(getString(R.string.package_error_title))
                .setMessage(getString(R.string.package_error_message_invalid))
                .setOnCancelListener(this)
                .setPositiveButton(android.R.string.yes, this)
                .create();
        mCurrentDialog = id;
        dialog.setOnDismissListener(this);
        break;
      case DIALOG_UNZIPPING:
        mUnzipProgressDialog = new ProgressDialog(this);
        mUnzipProgressDialog.setIndeterminate(true);
        mUnzipProgressDialog.setCancelable(false);
        mUnzipProgressDialog.setProgressStyle(android.R.attr.progressBarStyleSmall);
        mUnzipProgressDialog.setMessage(getString(R.string.installing_message));
        mUnzipProgressDialog.show();
        sIsUnzip = true;
        mUnzipProgressDialog.setOnKeyListener(
            new DialogInterface.OnKeyListener() {
              public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                if (keyCode == KeyEvent.KEYCODE_BACK) {
                  SdPkgInstallActivity.this.finish();
                  Xlog.v(TAG, "DIALOG_UNZIPPING,Keycode_back,finish activity");
                  return true;
                }
                return false;
              }
            });
        mUnzipProgressDialog.setOnDismissListener(
            new DialogInterface.OnDismissListener() {
              public void onDismiss(DialogInterface dialog) {
                mUnzipProgressDialog = null;
              }
            });
        return mUnzipProgressDialog;
      case DIALOG_UNKNOWN_ERROR:
        dialog =
            new AlertDialog.Builder(this)
                .setTitle(R.string.unknown_error)
                .setMessage(getString(R.string.unknown_error_content))
                .setOnCancelListener(
                    new DialogInterface.OnCancelListener() {
                      @Override
                      public void onCancel(DialogInterface dialog) {
                        mDownloadInfo.setUpgradeStartedState(false);
                      }
                    })
                .setPositiveButton(
                    android.R.string.ok,
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int whichButton) {
                        Xlog.v(TAG, "Dialog_Unknown_error, ok,finish activity");
                        Util.deleteFile(mUpdatePath);
                        SdPkgInstallActivity.this.finish();
                      }
                    })
                .create();
        mCurrentDialog = id;
        dialog.setOnDismissListener(this);
        break;
      case DIALOG_OTARESULT:
        dialog =
            new AlertDialog.Builder(this)
                .setTitle(mOTADialogTitleResId)
                .setMessage(getString(mOTADialogMessageResId))
                .setOnCancelListener(this)
                .setPositiveButton(android.R.string.ok, this)
                .create();
        mCurrentDialog = id;
        dialog.setOnDismissListener(this);
        break;
      case DIALOG_SDCARDMOUNTED:
        dialog =
            new AlertDialog.Builder(this)
                .setTitle(getString(R.string.error_sdcard))
                .setMessage(getString(R.string.sdcard_inserted))
                .setPositiveButton(
                    android.R.string.yes,
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int whichButton) {

                        mGoToMainEntry = true;
                        requeryPackages();
                      }
                    })
                .setNegativeButton(android.R.string.no, null)
                .create();
        mCurrentDialog = id;
        dialog.setOnDismissListener(this);
        break;
      case DIALOG_LOW_BATTERY:
        dialog =
            new AlertDialog.Builder(this)
                .setTitle(getString(R.string.low_battery))
                .setMessage(getString(R.string.low_battery_warning))
                .setIcon(android.R.drawable.ic_dialog_alert)
                .setPositiveButton(
                    android.R.string.ok,
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int whichButton) {
                        SdPkgInstallActivity.this.finish();
                      }
                    })
                .create();
        break;
      default:
        break;
    }
    return dialog;
  }