Ejemplo n.º 1
0
  @Override
  protected Dialog onCreateDialog(int id) {
    switch (id) {
      case DIALOG_PROMPT:
        {
          AlertDialog dialog = (new AlertDialog.Builder(this)).create();
          dialog.setTitle("Ushahidi Setup");
          dialog.setMessage("Setup an ushahidi instance.");
          dialog.setButton2(
              "Ok",
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  Intent launchPreferencesIntent =
                      new Intent().setClass(Ushahidi.this, Settings.class);

                  // Make it a subactivity so we know when it returns
                  startActivityForResult(launchPreferencesIntent, REQUEST_CODE_SETTINGS);
                  dialog.dismiss();
                }
              });
          dialog.setCancelable(false);
          return dialog;
        }

      case DIALOG_ERROR:
        {
          AlertDialog dialog = (new AlertDialog.Builder(this)).create();
          dialog.setTitle(R.string.alert_dialog_error_title);
          dialog.setMessage(dialogErrorMsg);
          dialog.setButton2(
              "Ok",
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {

                  Intent launchPreferencesIntent = new Intent(Ushahidi.this, Settings.class);

                  // Make it a subactivity so we know when it returns
                  startActivityForResult(launchPreferencesIntent, REQUEST_CODE_SETTINGS);

                  dialog.dismiss();
                }
              });
          dialog.setCancelable(false);
          return dialog;
        }
    }
    return null;
  }
 public void askToDownloadFileManager() {
   AlertDialog alertDialog =
       new AlertDialog.Builder(this).setMessage(R.string.install_file_chooser_message).create();
   alertDialog.setTitle(R.string.install_file_chooser_title);
   alertDialog.setIcon(android.R.drawable.ic_menu_info_details);
   alertDialog.setButton(
       getResources().getText(R.string.ok),
       new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int which) {
           Intent marketIntent =
               new Intent(
                   Intent.ACTION_VIEW, Uri.parse("market://details?id=lysesoft.andexplorer"));
           startActivity(marketIntent);
           return;
         }
       });
   alertDialog.setButton2(
       getResources().getText(R.string.cancel),
       new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int which) {
           // do nothing
         }
       });
   alertDialog.show();
   return;
 }
  /**
   * The Wall Of Shame
   *
   * <p>Organizations and persons listed below have violated the copyright and/or licensing of
   * BurritoRoot and have had their rights to use any part or derivative of BurritoRoot revoked.
   *
   * <p>You are scum, you steal the hard work of our developers. You even stole my non working
   * unroot code you f*cking bum.
   *
   * <p>Author of unlockroot http://www(dot)unlockroot(dot)com Liang Bing [email protected]
   * [email protected] HongKong
   */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    AlertDialog alertDialog1 = new AlertDialog.Builder(this).create();
    alertDialog1.setTitle("Disclaimer");
    alertDialog1.setCancelable(false);
    alertDialog1.setMessage(
        "Copyright 2011 TeamAndIRC. Using this application may void your warranty. General advice is not to root you device, however if you want to, if you understand"
            + " what you are doing, and acknowledge you will hold no one responsible for any loss or damages caused by this app, or the rooting of your device click Agree. This application is"
            + "opensource, and licensed under the GPLv3. Source is available at https://github.com/CunningLogic/BurritoRoot");
    alertDialog1.setButton(
        "Agree",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            credit();
          }
        });

    alertDialog1.setButton2(
        "Disagree!",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            System.exit(0);
          }
        });

    alertDialog1.show();
  }
  /** This function is called when result returned is null. Some connection problem. */
  public void resultIsNull() {
    // Dialog for no internet connection :
    final AlertDialog alertDialog = new AlertDialog.Builder(context).create();
    alertDialog.setTitle(context.getString(R.string.unable_to_reach_hollywood));
    alertDialog.setMessage(context.getString(R.string.check_internet_connection));
    alertDialog.setCancelable(false);
    alertDialog.setButton2(
        "Settings",
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS);
            context.startActivity(intent);
            HighestRatedMoviesGridActivity.loadedOnce = true;
            alertDialog.hide();
          }
        });
    alertDialog.setButton(
        "Retry",
        new DialogInterface.OnClickListener() {

          @Override
          public void onClick(DialogInterface dialog, int which) {
            retryRequired();
            alertDialog.hide();
          }
        });

    // TODO : SET ICON FOR DIALOG :

    // alertDialog.setIcon(R.drawable.ic_radio_white_36dp);

    alertDialog.show();
  }
  public void credit() {
    AlertDialog alertDialog2 = new AlertDialog.Builder(this).create();
    alertDialog2.setTitle("Credit");
    alertDialog2.setCancelable(false);
    alertDialog2.setMessage(
        "Justin Case (jcase) :Theory, Exploit and Code.\n\n"
            + "Vashypooh :Bugging the shit out of jcase and testing\n\n"
            + "Trevor Eckhart :Testing\n\n"
            + "IOMoster :Pointing out my stupid mistake that kept this from working.\n\n"
            + "AndroidPolice.com for support all my efforts, no matter how drunk I am.\n\n"
            + "RootzWiki.com for giving me support and a home on the net.");
    alertDialog2.setButton(
        "You Rock",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            root();
          }
        });

    alertDialog2.setButton2(
        "You Suck!",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            System.exit(0);
          }
        });

    alertDialog2.show();
  }
Ejemplo n.º 6
0
  @SuppressWarnings("deprecation")
  @Override
  public void onBackPressed() {

    if (Flag_BackPress.equalsIgnoreCase("Timefeed")) {
      AlertDialog alert_back = new AlertDialog.Builder(this).create();
      alert_back.setTitle("Exit?");
      alert_back.setMessage("Are you sure want to exit?");

      alert_back.setButton(
          "No",
          new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
              dialog.dismiss();
            }
          });

      alert_back.setButton2(
          "Yes",
          new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
              MainActivity.this.finish();
            }
          });
      alert_back.show();

    } else {
      displayView(2);
    }
  }
Ejemplo n.º 7
0
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {

    if (keyCode == KeyEvent.KEYCODE_BACK) {
      {
        if (State == 1) {
          // 创建退出对话框
          AlertDialog isExit = new AlertDialog.Builder(this).create();
          // 设置对话框标题
          isExit.setTitle("系统提示");
          // 设置对话框消息
          isExit.setMessage("确定要退出吗");
          // 添加选择按钮并注册监听
          isExit.setButton("确定", listener);
          isExit.setButton2("取消", listener);
          // 显示对话框
          isExit.show();
        } else if (State == 0) {
          State = 1;
          deleteAlarm.setVisibility(View.GONE);
          adapter.TYPE = 1;
          adapter.notifyDataSetChanged();
        }
      }

      return false;
    }

    return super.onKeyDown(keyCode, event);
  }
Ejemplo n.º 8
0
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_BACK)) {
      AlertDialog ExitAlert = new AlertDialog.Builder(this).create();
      ExitAlert.setTitle("Exit Jazeit");
      ExitAlert.setIcon(R.drawable.logo);
      ExitAlert.setMessage("Are you sure you want to exit the APP?");

      ExitAlert.setButton2(
          "Continue",
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
              return;
            }
          });
      ExitAlert.setButton(
          "Exit App",
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
              // finish();
              finish();
              return;
            }
          });
      ExitAlert.show();
    }

    return false;
  }
Ejemplo n.º 9
0
 /**
  * 显示�?���?��的对话框;只能在UI线程中调用�?
  *
  * @param context
  * @param title
  * @param text
  */
 public static void showAlert(Context context, String title, String text, boolean showOk) {
   AlertDialog alertDialog = new Builder(context).create();
   alertDialog.setTitle(title);
   alertDialog.setMessage(text);
   if (showOk) {
     OnClickListener listener = null;
     alertDialog.setButton2("确定", listener);
   }
   alertDialog.show();
 }
Ejemplo n.º 10
0
    @Override
    protected boolean onTap(int i) {
      AlertDialog dialog = (new AlertDialog.Builder(IncidentMap.this)).create();
      dialog.setTitle(items.get(i).getTitle());
      dialog.setMessage(items.get(i).getSnippet());
      dialog.setButton2(
          "Ok",
          new Dialog.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
              dialog.dismiss();
            }
          });

      dialog.show();
      dialog.setCancelable(false);

      return (true);
    }
Ejemplo n.º 11
0
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {
   // TODO Auto-generated method stub
   switch (keyCode) {
     case KeyEvent.KEYCODE_BACK:
       // 创建退出对话框
       AlertDialog isExit = new AlertDialog.Builder(this).create();
       // 设置对话框标题
       isExit.setTitle("系统提示");
       // 设置对话框消息
       isExit.setMessage("真的准备离开了吗?");
       // 添加选择按钮并注册监听
       isExit.setButton("确定", listener);
       isExit.setButton2("取消", listener);
       // 显示对话框
       isExit.show();
       break;
   }
   return super.onKeyDown(keyCode, event);
 }
Ejemplo n.º 12
0
 protected Dialog onCreateDialog(int id, String message, String title) {
   switch (id) {
     case DIALOG_MESSAGE:
       {
         AlertDialog dialog = (new AlertDialog.Builder(this)).create();
         dialog.setTitle(title);
         dialog.setMessage(message);
         dialog.setButton2(
             "Ok",
             new Dialog.OnClickListener() {
               public void onClick(DialogInterface dialog, int which) {
                 dialog.dismiss();
               }
             });
         dialog.setCancelable(false);
         return dialog;
       }
   }
   return null;
 }
    // metodo para cuando se toca el area del mapa
    public boolean onTouchEvent(MotionEvent e, MapView m) {

      // si es accion de bajada
      if (e.getAction() == MotionEvent.ACTION_DOWN) {
        start = e.getEventTime();
        x = (int) e.getX();
        y = (int) e.getY();
        touchedPoint =
            map.getProjection()
                .fromPixels(x, y); // se obtine las coordenadas del punto de toque en el mapa
      }
      // si es accion de subida
      if (e.getAction() == MotionEvent.ACTION_UP) {
        stop = e.getEventTime();
      }
      // se calcula la duaracion del click
      if ((stop - start) > 1500) {
        AlertDialog alert =
            new AlertDialog.Builder(MainActivity.this).create(); // se crea un nuevo AlertDialog
        alert.setTitle("Pick an Option");
        alert.setMessage("I told to pick an option");
        // se agregan 3 botones
        alert.setButton(
            "place a pinpoint",
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                // se crea un nuevo Overlay para colocar el punto en el mapa
                OverlayItem overlayItem = new OverlayItem(touchedPoint, "what's up", "2nd string");
                // se crea un punto
                CustonPinpoint custom = new CustonPinpoint(d, MainActivity.this);
                // agrega coordenadas
                custom.insertPinpoint(overlayItem);
                // se agrega en las lista de Overlays
                oveList.add(custom);
              }
            });
        alert.setButton2(
            "get addres",
            // debe probarse en el celular
            new DialogInterface.OnClickListener() {
              public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                String display = "";
                Geocoder geocoder =
                    new Geocoder(
                        getBaseContext(),
                        Locale
                            .getDefault()); // Objeto para transformar una direccion a coordenadas y
                // viseversa
                try {
                  // se obtinen todas las direcciones que se describen en las coordenadas dadas
                  List<Address> addresses =
                      geocoder.getFromLocation(
                          touchedPoint.getLatitudeE6() / 1E6,
                          touchedPoint.getLongitudeE6() / 1E6,
                          1);
                  if (addresses.size() > 0) {
                    for (int i = 0; i < addresses.get(0).getMaxAddressLineIndex(); i++) {
                      display += addresses.get(0).getAddressLine(i) + "\n";
                    }
                    Toast toast = Toast.makeText(getBaseContext(), display, Toast.LENGTH_LONG);
                    toast.show();
                  }
                } catch (Exception e2) {
                  // TODO: handle exception
                  e2.printStackTrace();
                }
              }
            });
        alert.setButton3(
            "Toggle View",
            new DialogInterface.OnClickListener() {
              // cambia entre el mapa satelital y el de calles
              public void onClick(DialogInterface dialog, int which) {
                // TODO Auto-generated method stub
                if (map.isSatellite()) {
                  map.setSatellite(false);
                  map.setStreetView(true);
                } else {
                  map.setSatellite(true);
                  map.setStreetView(false);
                }
              }
            });
        alert.show();
        return true;
      }
      return false;
    }
  /** Create various dialog */
  @Override
  protected Dialog onCreateDialog(int id) {
    switch (id) {
      case DIALOG_ERROR_NETWORK:
        {
          AlertDialog dialog = (new AlertDialog.Builder(this)).create();
          dialog.setTitle(getString(R.string.network_error));
          dialog.setMessage(getString(R.string.network_error_msg));
          dialog.setButton2(
              getString(R.string.ok),
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  dialog.dismiss();
                }
              });
          dialog.setCancelable(false);
          return dialog;
        }
      case DIALOG_ERROR_SAVING:
        {
          AlertDialog dialog = (new AlertDialog.Builder(this)).create();
          dialog.setTitle(getString(R.string.network_error));
          dialog.setMessage(getString(R.string.file_system_error_msg));
          dialog.setButton2(
              getString(R.string.ok),
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  dialog.dismiss();
                }
              });
          dialog.setCancelable(false);
          return dialog;
        }

      case DIALOG_CHOOSE_IMAGE_METHOD:
        {
          AlertDialog dialog = (new AlertDialog.Builder(this)).create();
          dialog.setTitle(getString(R.string.choose_method));
          dialog.setMessage(getString(R.string.how_to_select_pic));
          dialog.setButton(
              getString(R.string.gallery_option),
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  deleteExistingPhoto();
                  Intent intent = new Intent();
                  intent.setAction(Intent.ACTION_PICK);
                  intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                  startActivityForResult(intent, REQUEST_CODE_IMAGE);
                  dialog.dismiss();
                }
              });
          dialog.setButton2(
              getString(R.string.cancel),
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  dialog.dismiss();
                }
              });
          dialog.setButton3(
              getString(R.string.camera_option),
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  deleteExistingPhoto();
                  Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                  intent.putExtra(
                      MediaStore.EXTRA_OUTPUT,
                      PhotoUtils.getPhotoUri(photoName, AddCheckinActivity.this));
                  startActivityForResult(intent, REQUEST_CODE_CAMERA);
                  dialog.dismiss();
                }
              });

          dialog.setCancelable(false);
          return dialog;
        }

      case DIALOG_SHOW_MESSAGE:
        AlertDialog.Builder messageBuilder = new AlertDialog.Builder(this);
        messageBuilder
            .setMessage(mErrorMessage)
            .setPositiveButton(
                getString(R.string.ok),
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                  }
                });

        AlertDialog showDialog = messageBuilder.create();
        showDialog.show();
        break;

      case DIALOG_SHOW_REQUIRED:
        AlertDialog.Builder requiredBuilder = new AlertDialog.Builder(this);
        requiredBuilder.setTitle(R.string.required_fields);
        requiredBuilder
            .setMessage(mErrorMessage)
            .setPositiveButton(
                getString(R.string.ok),
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                  }
                });

        AlertDialog showRequiredDialog = requiredBuilder.create();
        showRequiredDialog.show();
        break;

        // prompt for unsaved changes
      case DIALOG_SHOW_PROMPT:
        {
          AlertDialog dialog = (new AlertDialog.Builder(this)).create();
          dialog.setTitle(getString(R.string.unsaved_changes));
          dialog.setMessage(getString(R.string.want_to_cancel));
          dialog.setButton(
              getString(R.string.no),
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {

                  dialog.dismiss();
                }
              });
          dialog.setButton2(
              getString(R.string.yes),
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  // delete any existing photo in the pending folder
                  new DiscardTask(AddCheckinActivity.this).execute((String) null);
                  finish();
                  dialog.dismiss();
                }
              });

          dialog.setCancelable(false);
          return dialog;
        }

        // prompt for report deletion
      case DIALOG_SHOW_DELETE_PROMPT:
        {
          AlertDialog dialog = (new AlertDialog.Builder(this)).create();
          dialog.setTitle(getString(R.string.delete_report));
          dialog.setMessage(getString(R.string.want_to_delete));
          dialog.setButton(
              getString(R.string.no),
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  dialog.dismiss();
                }
              });
          dialog.setButton2(
              getString(R.string.yes),
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  // delete checkin
                  deleteCheckins();
                  dialog.dismiss();
                }
              });

          dialog.setCancelable(false);
          return dialog;
        }
    }
    return null;
  }
  /** Create various dialog */
  @Override
  protected Dialog onCreateDialog(int id) {
    switch (id) {
      case DIALOG_ERROR_NETWORK:
        {
          AlertDialog dialog = (new AlertDialog.Builder(this)).create();
          dialog.setTitle(getString(R.string.network_error));
          dialog.setMessage(getString(R.string.network_error_msg));
          dialog.setButton2(
              getString(R.string.ok),
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  dialog.dismiss();
                }
              });
          dialog.setCancelable(false);
          return dialog;
        }
      case DIALOG_ERROR_SAVING:
        {
          AlertDialog dialog = (new AlertDialog.Builder(this)).create();
          dialog.setTitle(getString(R.string.network_error));
          dialog.setMessage(getString(R.string.file_system_error_msg));
          dialog.setButton2(
              getString(R.string.ok),
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  dialog.dismiss();
                }
              });
          dialog.setCancelable(false);
          return dialog;
        }

      case DIALOG_CHOOSE_IMAGE_METHOD:
        {
          AlertDialog dialog = (new AlertDialog.Builder(this)).create();
          dialog.setTitle(getString(R.string.choose_method));
          dialog.setMessage(getString(R.string.how_to_select_pic));
          dialog.setButton(
              getString(R.string.gallery_option),
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  Intent intent = new Intent();
                  intent.setAction(Intent.ACTION_PICK);
                  intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                  startActivityForResult(intent, REQUEST_CODE_IMAGE);
                  dialog.dismiss();
                }
              });
          dialog.setButton2(
              getString(R.string.cancel),
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  dialog.dismiss();
                }
              });
          dialog.setButton3(
              getString(R.string.camera_option),
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                  intent.putExtra(
                      MediaStore.EXTRA_OUTPUT,
                      PhotoUtils.getPhotoUri(photoName, AddReportActivity.this));
                  startActivityForResult(intent, REQUEST_CODE_CAMERA);
                  dialog.dismiss();
                }
              });

          dialog.setCancelable(false);
          return dialog;
        }

      case DIALOG_MULTIPLE_CATEGORY:
        {
          if (showCategories() != null) {
            return new AlertDialog.Builder(this)
                .setTitle(R.string.choose_categories)
                .setMultiChoiceItems(
                    showCategories(),
                    setCheckedCategories(),
                    new DialogInterface.OnMultiChoiceClickListener() {
                      public void onClick(
                          DialogInterface dialog, int whichButton, boolean isChecked) {
                        // see if categories have previously

                        if (isChecked) {
                          mVectorCategories.add(mCategoriesId.get(whichButton));

                          mError = false;
                        } else {
                          mVectorCategories.remove(mCategoriesId.get(whichButton));
                        }

                        setSelectedCategories(mVectorCategories);
                      }
                    })
                .setPositiveButton(
                    R.string.ok,
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int whichButton) {

                        /* User clicked Yes so do some stuff */
                      }
                    })
                .create();
          }
        }

      case TIME_DIALOG_ID:
        return new TimePickerDialog(
            this,
            mTimeSetListener,
            mCalendar.get(Calendar.HOUR),
            mCalendar.get(Calendar.MINUTE),
            false);

      case DATE_DIALOG_ID:
        return new DatePickerDialog(
            this,
            mDateSetListener,
            mCalendar.get(Calendar.YEAR),
            mCalendar.get(Calendar.MONTH),
            mCalendar.get(Calendar.DAY_OF_MONTH));

      case DIALOG_SHOW_MESSAGE:
        AlertDialog.Builder messageBuilder = new AlertDialog.Builder(this);
        messageBuilder
            .setMessage(mErrorMessage)
            .setPositiveButton(
                getString(R.string.ok),
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                  }
                });

        AlertDialog showDialog = messageBuilder.create();
        showDialog.show();
        break;

      case DIALOG_SHOW_REQUIRED:
        AlertDialog.Builder requiredBuilder = new AlertDialog.Builder(this);
        requiredBuilder.setTitle(R.string.required_fields);
        requiredBuilder
            .setMessage(mErrorMessage)
            .setPositiveButton(
                getString(R.string.ok),
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                  }
                });

        AlertDialog showRequiredDialog = requiredBuilder.create();
        showRequiredDialog.show();
        break;

        // prompt for unsaved changes
      case DIALOG_SHOW_PROMPT:
        {
          AlertDialog dialog = (new AlertDialog.Builder(this)).create();
          dialog.setTitle(getString(R.string.unsaved_changes));
          dialog.setMessage(getString(R.string.want_to_cancel));
          dialog.setButton(
              getString(R.string.no),
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {

                  dialog.dismiss();
                }
              });
          dialog.setButton2(
              getString(R.string.yes),
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  new DiscardTask(AddReportActivity.this).execute((String) null);
                  finish();
                  dialog.dismiss();
                }
              });

          dialog.setCancelable(false);
          return dialog;
        }

        // prompt for report deletion
      case DIALOG_SHOW_DELETE_PROMPT:
        {
          AlertDialog dialog = (new AlertDialog.Builder(this)).create();
          dialog.setTitle(getString(R.string.delete_report));
          dialog.setMessage(getString(R.string.want_to_delete));
          dialog.setButton(
              getString(R.string.no),
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {

                  dialog.dismiss();
                }
              });
          dialog.setButton2(
              getString(R.string.yes),
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  // delete report
                  deleteReport();
                  dialog.dismiss();
                }
              });

          dialog.setCancelable(false);
          return dialog;
        }
    }
    return null;
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    state = savedInstanceState;
    data = getIntent().getExtras();

    // Mark as read
    SMILMessageProxy sm = SMILActivity.inbox.get(data.getInt("index"));
    AsyncFetchSMILMessage async = new AsyncFetchSMILMessage(this);
    sm = async.editMessage(sm);
    sm.setRead(true);
    async.updateMessage(sm);

    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.message_view);

    SharedPreferences myPrefs = this.getSharedPreferences("username", MODE_WORLD_READABLE);
    autoPlay = myPrefs.getBoolean("autoPlay", true);

    alertAutoPlay = new AlertDialog.Builder(this).create();
    alertAutoPlay.setTitle("Did you know?");
    alertAutoPlay.setMessage(
        "If you turn your phone into landscape mode the message will automatically play. Turn your phone back up to return to the message screen.");
    alertAutoPlay.setButton(
        "Let me try!",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            return;
          }
        });
    alertAutoPlay.setButton2(
        "Not for me! (disable feature)",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            SharedPreferences.Editor myPrefEdit =
                ViewMessageActivity.this
                    .getSharedPreferences("username", MODE_WORLD_READABLE)
                    .edit();
            myPrefEdit.putBoolean("autoPlay", false);
            myPrefEdit.commit();
            ViewMessageActivity.autoPlay = false;
            playMessage(true);
            return;
          }
        });

    _actionBar = (ActionBar) findViewById(R.id.actionBar);
    _actionBar.setTitle("Message Details");
    _actionBar.setHomeListener(
        new OnClickListener() {
          public void onClick(View v) {
            ViewMessageActivity.this.finish();
          }
        });

    workingDir += "/" + data.getString("title");

    items = new ScrollItemManager(findViewById(R.id.scrollHolder));
    items.addItem(getApplicationContext(), true);
    items.setTitle(data.getString("title"));
    items.setIcon(R.drawable.ic_home);
    items.setListener(this, 1);
    TextView item1Text1 = new TextView(this);
    item1Text1.setText(
        "From: " + data.getString("Sender") + "                   on " + data.getString("date"));
    item1Text1.setTextColor(Color.BLACK);
    items.addToLinear(item1Text1);

    items.addItem(getApplicationContext(), true);
    TextView item2Text1 = new TextView(this);
    item2Text1.setText("Subject:");
    item2Text1.setTextColor(Color.BLACK);
    TextView item2Text2 = new TextView(this);
    item2Text2.setText(data.getString("message"));
    item2Text2.setTextColor(Color.BLACK);
    items.addToLinear(item2Text1);
    items.addLine(getApplicationContext());
    items.addToLinear(item2Text2);

    items.addItem(getApplicationContext());
    items.setTitle("Play Message");
    items.setListener(this, 1);

    items.addItem(getApplicationContext());
    items.setTitle("Reply");
    // items.setListener(this, 1);

    items.addItem(getApplicationContext());
    items.setTitle("Forward");
    items.setListener(this, 2);

    items.addItem(getApplicationContext());
    items.setTitle("Reset Preference");
    items.setListener(this, 3);
  }
Ejemplo n.º 17
0
  /** Create various dialog */
  @Override
  protected Dialog onCreateDialog(int id) {
    switch (id) {
      case DIALOG_ERROR_NETWORK:
        {
          AlertDialog dialog = (new AlertDialog.Builder(this)).create();
          dialog.setTitle("Network error!");
          dialog.setMessage("Network error, please ensure you are connected to the internet");
          dialog.setButton2(
              "Ok",
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  dialog.dismiss();
                }
              });
          dialog.setCancelable(false);
          return dialog;
        }
      case DIALOG_ERROR_SAVING:
        {
          AlertDialog dialog = (new AlertDialog.Builder(this)).create();
          dialog.setTitle("File System error!");
          dialog.setMessage("File System error, please ensure your save path is correct!");
          dialog.setButton2(
              "Ok",
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  dialog.dismiss();
                }
              });
          dialog.setCancelable(false);
          return dialog;
        }
      case DIALOG_LOADING_CATEGORIES:
        {
          ProgressDialog dialog = new ProgressDialog(this);
          dialog.setTitle("Loading Categories");
          dialog.setMessage("Please wait while categories are loaded...");
          dialog.setIndeterminate(true);
          dialog.setCancelable(false);
          return dialog;
        }

      case DIALOG_LOADING_LOCATIONS:
        {
          ProgressDialog dialog = new ProgressDialog(this);
          dialog.setTitle("Loading Categories");
          dialog.setMessage("Please wait while categories are loaded...");
          dialog.setIndeterminate(true);
          dialog.setCancelable(false);
          return dialog;
        }
      case DIALOG_CHOOSE_IMAGE_METHOD:
        {
          AlertDialog dialog = (new AlertDialog.Builder(this)).create();
          dialog.setTitle("Choose Method");
          dialog.setMessage("Please choose how you would like to get the picture.");
          dialog.setButton(
              "Gallery",
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  Intent intent = new Intent();
                  intent.setAction(Intent.ACTION_PICK);
                  intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                  startActivityForResult(intent, REQUEST_CODE_IMAGE);
                  dialog.dismiss();
                }
              });
          dialog.setButton2(
              "Cancel",
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  dialog.dismiss();
                }
              });

          /**
           * Disabling camera functionality for now. will be re implemented in the next release.
           * dialog.setButton3("Camera", new Dialog.OnClickListener() { public void
           * onClick(DialogInterface dialog, int which) {
           *
           * <p>Intent launchPreferencesIntent = new Intent().setClass(AddIncident.this,
           * ImageCapture.class); // Make it a subactivity so we know when it returns
           * startActivityForResult(launchPreferencesIntent, REQUEST_CODE_CAMERA); dialog.dismiss();
           * } });
           */
          dialog.setCancelable(false);
          return dialog;
        }

      case DIALOG_MULTIPLE_CATEGORY:
        {
          return new AlertDialog.Builder(this)
              .setTitle(R.string.add_categories)
              .setMultiChoiceItems(
                  showCategories(),
                  null,
                  new DialogInterface.OnMultiChoiceClickListener() {
                    public void onClick(
                        DialogInterface dialog, int whichButton, boolean isChecked) {

                      if (isChecked) {

                        vectorCategories.add(categoriesId.get(whichButton));
                        if (!vectorCategories.isEmpty()) {
                          selectedCategories.setText(
                              Util.limitString(categoriesTitle.get(vectorCategories.get(0)), 15));
                        }
                        error = false;
                      } else {
                        // fixed a crash here.
                        vectorCategories.remove(categoriesId.get(whichButton));

                        if (vectorCategories.isEmpty()) {
                          selectedCategories.setText("");
                        } else {
                          selectedCategories.setText(
                              Util.limitString(categoriesTitle.get(vectorCategories.get(0)), 15));
                        }
                      }

                      /* User clicked on a check box do some stuff */
                    }
                  })
              .setPositiveButton(
                  R.string.btn_ok,
                  new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {

                      /* User clicked Yes so do some stuff */
                    }
                  })
              .create();
        }

      case TIME_DIALOG_ID:
        return new TimePickerDialog(this, mTimeSetListener, mHour, mMinute, false);

      case DATE_DIALOG_ID:
        return new DatePickerDialog(this, mDateSetListener, mYear, mMonth, mDay);
    }
    return null;
  }
  /*
   * (non-Javadoc)
   *
   * @see android.view.View.OnClickListener#onClick(android.view.View)
   */
  public void onClick(final View v) {

    if (v.getId() == R.id.btnJobStartDate) {
      showDialog(ID_START_DATEPICKER);

    } else if (v.getId() == R.id.btnJobStartTime) {
      showDialog(ID_START_TIMEPICKER);

    } else if (v.getId() == R.id.btnJobEndDate) {
      showDialog(ID_END_DATEPICKER);

    } else if (v.getId() == R.id.btnJobEndTime) {
      showDialog(ID_END_TIMEPICKER);

    } else if (v.getId() == R.id.btnJobDiscard) {

      AlertDialog alertDialog = new AlertDialog.Builder(this).create();
      alertDialog.setTitle("Discard, Are you sure?");
      alertDialog.setButton(
          "Yes",
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
              Intent home = new Intent(v.getContext(), HomeActivity.class);
              startActivityForResult(home, CommonConstants.HOME_REQ_ID);
              return;
            }
          });
      alertDialog.setButton2(
          "Cancel",
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
              return;
            }
          });
      alertDialog.show();

    } else if (v.getId() == R.id.btnJobReset) {
      AlertDialog alertDialog = new AlertDialog.Builder(this).create();
      alertDialog.setTitle("Reset fields, Are you sure?");
      alertDialog.setButton(
          "Yes",
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
              editTxtLatitude.setText("");
              editTxtLongitude.setText("");
              editTxtLocRange.setText("");
              editTxtNodes.setText("");
              editTxtFreq.setText("");
              editTxtTimePeriod.setText("");
              editTxtDesc.setText("");
              return;
            }
          });
      alertDialog.setButton2(
          "Cancel",
          new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
              return;
            }
          });
      alertDialog.show();

    } else if (v.getId() == R.id.btnJobSave) {
      Calendar startDatetime = null;
      Calendar endDatetime = null;
      boolean validStartEndTime = true;

      if (chkBxStarttime.isChecked()) {
        startDatetime = Calendar.getInstance();
        startDatetime.set(startYear, startMonth, startDay, startHour, startMinute);
      }
      if (chkBxEndtime.isChecked()) {
        endDatetime = Calendar.getInstance();
        endDatetime.set(endYear, endMonth, endDay, endHour, endMinute);
        validStartEndTime = Calendar.getInstance().before(endDatetime);
      }
      if (validStartEndTime && startDatetime != null && endDatetime != null) {
        validStartEndTime = startDatetime.before(endDatetime);
      }
      if (validStartEndTime) {
        if (spinSensorType.getSelectedItem().toString().length() == 0
            || editTxtLatitude.getText().length() == 0
            || editTxtLongitude.getText().length() == 0
            || editTxtLocRange.getText().length() == 0
            || editTxtNodes.getText().length() == 0
            || editTxtFreq.getText().length() == 0
            || editTxtTimePeriod.getText().length() == 0) {
          Toast.makeText(
                  AddJobActivity.this,
                  "Input Validation failed! All fields should be not null and the end date should be after the start date.",
                  Toast.LENGTH_LONG)
              .show();
        } else {
          boolean issuccess =
              serviceInvoker.addJob(
                  1,
                  Float.parseFloat(editTxtLatitude.getText().toString()),
                  Float.parseFloat(editTxtLongitude.getText().toString()),
                  Float.parseFloat(editTxtLocRange.getText().toString()),
                  (startDatetime != null) ? startDatetime.getTimeInMillis() : 0,
                  (endDatetime != null) ? endDatetime.getTimeInMillis() : 0,
                  Integer.parseInt(editTxtFreq.getText().toString()),
                  Integer.parseInt(editTxtTimePeriod.getText().toString()),
                  Integer.parseInt(editTxtNodes.getText().toString()),
                  imei,
                  editTxtDesc.getText().toString(),
                  username);
          if (issuccess) {
            // when add job completes go back to the previous step or viewjob.
            Toast.makeText(AddJobActivity.this, "Job Added Successfully.", Toast.LENGTH_LONG)
                .show();
            Intent home = new Intent(v.getContext(), HomeActivity.class);
            startActivityForResult(home, CommonConstants.HOME_REQ_ID);

          } else {
            Toast.makeText(AddJobActivity.this, "Could not add job! Try again.", Toast.LENGTH_LONG)
                .show();
          }
        }
      } else {
        Toast.makeText(AddJobActivity.this, "Invalid StartTime or ExpireTime!", Toast.LENGTH_LONG)
            .show();
      }
    }
  }
Ejemplo n.º 19
0
  /** Create various dialog */
  @Override
  protected Dialog onCreateDialog(int id) {
    switch (id) {
      case DIALOG_ERROR_NETWORK:
        {
          AlertDialog dialog = (new AlertDialog.Builder(this)).create();
          dialog.setTitle(getString(R.string.network_error));
          dialog.setMessage(getString(R.string.network_error_msg));
          dialog.setButton2(
              getString(R.string.btn_ok),
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  dialog.dismiss();
                }
              });
          dialog.setCancelable(false);
          return dialog;
        }
      case DIALOG_ERROR_SAVING:
        {
          AlertDialog dialog = (new AlertDialog.Builder(this)).create();
          dialog.setTitle(getString(R.string.network_error));
          dialog.setMessage(getString(R.string.file_system_error_msg));
          dialog.setButton2(
              getString(R.string.btn_ok),
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  dialog.dismiss();
                }
              });
          dialog.setCancelable(false);
          return dialog;
        }

      case DIALOG_CHOOSE_IMAGE_METHOD:
        {
          AlertDialog dialog = (new AlertDialog.Builder(this)).create();
          dialog.setTitle(getString(R.string.choose_method));
          dialog.setMessage(getString(R.string.how_to_select_pic));
          dialog.setButton(
              getString(R.string.gallery_option),
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  Intent intent = new Intent();
                  intent.setAction(Intent.ACTION_PICK);
                  intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                  startActivityForResult(intent, REQUEST_CODE_IMAGE);
                  dialog.dismiss();
                }
              });
          dialog.setButton2(
              getString(R.string.btn_cancel),
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  dialog.dismiss();
                }
              });
          dialog.setButton3(
              getString(R.string.camera_option),
              new Dialog.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                  intent.putExtra(
                      MediaStore.EXTRA_OUTPUT,
                      PhotoUtils.getPhotoUri("photo.jpg", IncidentAdd.this));
                  startActivityForResult(intent, REQUEST_CODE_CAMERA);
                  dialog.dismiss();
                }
              });

          dialog.setCancelable(false);
          return dialog;
        }

      case DIALOG_MULTIPLE_CATEGORY:
        {
          return new AlertDialog.Builder(this)
              .setTitle(R.string.add_categories)
              .setMultiChoiceItems(
                  showCategories(),
                  null,
                  new DialogInterface.OnMultiChoiceClickListener() {
                    public void onClick(
                        DialogInterface dialog, int whichButton, boolean isChecked) {
                      // see if categories have previously

                      if (isChecked) {
                        mVectorCategories.add(mCategoriesId.get(whichButton));
                        mError = false;
                      } else {
                        mVectorCategories.remove(mCategoriesId.get(whichButton));
                      }

                      setSelectedCategories(mVectorCategories);
                    }
                  })
              .setPositiveButton(
                  R.string.btn_ok,
                  new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {

                      /* User clicked Yes so do some stuff */
                    }
                  })
              .create();
        }

      case TIME_DIALOG_ID:
        return new TimePickerDialog(
            this,
            mTimeSetListener,
            mCalendar.get(Calendar.HOUR),
            mCalendar.get(Calendar.MINUTE),
            false);

      case DATE_DIALOG_ID:
        return new DatePickerDialog(
            this,
            mDateSetListener,
            mCalendar.get(Calendar.YEAR),
            mCalendar.get(Calendar.MONTH),
            mCalendar.get(Calendar.DAY_OF_MONTH));
    }
    return null;
  }
Ejemplo n.º 20
0
  private void startDeviceActivation() {
    final AlertDialog activationDialog = new AlertDialog.Builder(HomeScreen.this).create();
    activationDialog.setTitle("App Activation");

    View view = LayoutInflater.from(this).inflate(R.layout.appactivation, null);
    activationDialog.setView(view);
    final EditText serverip_t = (EditText) view.findViewById(R.id.serverip);
    final EditText portno_t = (EditText) view.findViewById(R.id.portno);
    final EditText emailid_t = (EditText) view.findViewById(R.id.emailid);
    final EditText password_t = (EditText) view.findViewById(R.id.password);
    activationDialog.setCancelable(false);

    activationDialog.setButton(
        AlertDialog.BUTTON_POSITIVE, "Submit", (DialogInterface.OnClickListener) null);

    activationDialog.setButton2(
        "Cancel",
        new OnClickListener() {
          @Override
          public void onClick(DialogInterface arg0, int arg1) {
            finish();
          }
        });

    activationDialog.setOnShowListener(
        new DialogInterface.OnShowListener() {

          @Override
          public void onShow(DialogInterface d) {
            Button submit = activationDialog.getButton(AlertDialog.BUTTON_POSITIVE);
            submit.setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                    String serverip = serverip_t.getText().toString();
                    String portnoStr = portno_t.getText().toString();
                    String emailid = emailid_t.getText().toString();
                    String password = password_t.getText().toString();
                    if (serverip == null
                        || serverip.trim().length() == 0
                        || portnoStr == null
                        || portnoStr.trim().length() == 0
                        || emailid == null
                        || emailid.trim().length() == 0
                        || password == null
                        || password.trim().length() == 0) {
                      ViewHelper.getOkModal(
                              HomeScreen.this,
                              "App Activation Failure",
                              "All the fields are required for a successful activation")
                          .show();
                      return;
                    }

                    Handler handler =
                        new Handler() {
                          @Override
                          public void handleMessage(Message msg) {
                            int what = msg.what;
                            if (what == 1) {
                              activationDialog.dismiss();
                              showBeans();
                            }
                          }
                        };

                    int portno = Integer.parseInt(portnoStr);
                    ActivationRequest activationRequest =
                        new ActivationRequest(serverip, portno, emailid, password);
                    new ToActivateDevice(HomeScreen.this, handler, activationRequest).execute();
                  }
                });
          }
        });

    activationDialog.show();
  }
  public void onExportFinished(ExportThread task) {
    if (task.isCancelled()) {
      if (finish_after) finish();
      return;
    }

    AlertDialog alertDialog = new AlertDialog.Builder(AdministrationFunctions.this).create();
    alertDialog.setTitle(R.string.email_export);
    alertDialog.setIcon(android.R.drawable.ic_menu_send);
    alertDialog.setButton2(
        getResources().getString(R.string.ok),
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            // setup the mail message
            final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
            emailIntent.setType("plain/text");
            // emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
            // context.getString(R.string.debug_email).split(";"));
            String subject =
                "[" + getString(R.string.app_name) + "] " + getString(R.string.export_data);
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
            // emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
            // context.getString(R.string.debug_body));
            // has to be an ArrayList
            ArrayList<Uri> uris = new ArrayList<Uri>();
            // Find all files of interest to send
            try {
              File fileIn = new File(StorageUtils.getSharedStoragePath() + "/" + "export.csv");
              Uri u = Uri.fromFile(fileIn);
              uris.add(u);
              // Send it, if there are any files to send.
              emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
              startActivity(Intent.createChooser(emailIntent, "Send mail..."));
            } catch (NullPointerException e) {
              Logger.logError(e);
              Toast.makeText(
                      AdministrationFunctions.this,
                      R.string.export_failed_sdcard,
                      Toast.LENGTH_LONG)
                  .show();
            }

            dialog.dismiss();
          }
        });
    alertDialog.setButton(
        getResources().getString(R.string.cancel),
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int which) {
            // do nothing
            dialog.dismiss();
          }
        });

    alertDialog.setOnDismissListener(
        new OnDismissListener() {
          @Override
          public void onDismiss(DialogInterface dialog) {
            if (finish_after) finish();
          }
        });

    if (!isFinishing()) {
      try {
        //
        // Catch errors resulting from 'back' being pressed multiple times so that the activity is
        // destroyed
        // before the dialog can be shown.
        // See http://code.google.com/p/android/issues/detail?id=3953
        //
        alertDialog.show();
      } catch (Exception e) {
        Logger.logError(e);
      }
    }
  }