示例#1
0
  private void showUserHashDialog() {
    String userHash = NavigineApp.Settings.getString("user_hash", "");

    LayoutInflater inflater = getLayoutInflater();
    View view = inflater.inflate(R.layout.user_hash_dialog, null);
    _userEdit = (EditText) view.findViewById(R.id.user_hash_edit);
    _userEdit.setText(userHash);
    _userEdit.setTypeface(Typeface.MONOSPACE);
    // _userEdit.addTextChangedListener(new TextWatcher()
    //  {
    //    public void afterTextChanged(Editable s) { }
    //    public void beforeTextChanged(CharSequence s, int start, int count, int after) { }
    //    public void onTextChanged(CharSequence s, int start, int before, int count)
    //    {
    //      String text = _userEdit.getText().toString();
    //      int length  = _userEdit.getText().length();
    //
    //      if (text.endsWith("-"))
    //        return;
    //
    //      if (count <= before)
    //        return;
    //
    //      if (length == 4 || length == 9 || length == 14)
    //      {
    //        _userEdit.setText((text + "-"));
    //        _userEdit.setSelection(length + 1);
    //      }
    //    }
    //  });

    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(mContext);
    alertBuilder.setView(view);
    alertBuilder.setTitle("Enter user ID");
    alertBuilder.setNegativeButton(
        getString(R.string.cancel_button),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dlg, int id) {}
        });

    alertBuilder.setPositiveButton(
        getString(R.string.ok_button),
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dlg, int id) {
            String userHash = _userEdit.getText().toString();
            SharedPreferences.Editor editor = NavigineApp.Settings.edit();
            editor.putString("user_hash", userHash);
            editor.commit();
            NavigineApp.applySettings();
            refreshMapList();
          }
        });

    AlertDialog dialog = alertBuilder.create();
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
  }
        private void doRetryableAlert(Exception e, String msg) {
          AlertDialog.Builder dialog = new AlertDialog.Builder(SelectAccount.this);
          dialog.setTitle(msg);
          String dispMsg = msg + "\n\n" + e.getMessage();
          dialog.setMessage(dispMsg);
          dialog.setPositiveButton(
              "Retry",
              new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                  requestAccountList();
                }
              });
          dialog.setNegativeButton("Cancel", emptyClickListener);

          AlertDialog dlg = dialog.create();
          dlg.show();
        }
示例#3
0
  private void selectItem(int index) {
    _info = mInfoList.get(index);
    if (!(new File(_info.archiveFile)).exists()) {
      String text =
          String.format(
              Locale.ENGLISH,
              "Location '%s' cannot be selected!\n" + "Please, download location first!",
              _info.title);
      Toast.makeText(mContext, text, Toast.LENGTH_LONG).show();
      return;
    }

    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(mContext);
    alertBuilder.setTitle(String.format(Locale.ENGLISH, "Location '%s'", _info.title));

    alertBuilder.setNegativeButton(
        "Delete location",
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dlg, int id) {
            deleteLocation(_info);
          }
        });
    alertBuilder.setPositiveButton(
        "Select location",
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dlg, int id) {
            selectLocation(_info);
          }
        });

    AlertDialog dialog = alertBuilder.create();
    dialog.setCanceledOnTouchOutside(false);
    dialog.show();
  }
示例#4
0
  // Setup
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    Log.v("SDL", "Device: " + android.os.Build.DEVICE);
    Log.v("SDL", "Model: " + android.os.Build.MODEL);
    Log.v("SDL", "onCreate():" + mSingleton);
    super.onCreate(savedInstanceState);

    SDLActivity.initialize();
    // So we can call stuff from static callbacks
    mSingleton = this;

    // Load shared libraries
    String errorMsgBrokenLib = "";
    try {
      loadLibraries();
    } catch (UnsatisfiedLinkError e) {
      System.err.println(e.getMessage());
      mBrokenLibraries = true;
      errorMsgBrokenLib = e.getMessage();
    } catch (Exception e) {
      System.err.println(e.getMessage());
      mBrokenLibraries = true;
      errorMsgBrokenLib = e.getMessage();
    }

    if (mBrokenLibraries) {
      AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this);
      dlgAlert.setMessage(
          "An error occurred while trying to start the application. Please try again and/or reinstall."
              + System.getProperty("line.separator")
              + System.getProperty("line.separator")
              + "Error: "
              + errorMsgBrokenLib);
      dlgAlert.setTitle("SDL Error");
      dlgAlert.setPositiveButton(
          "Exit",
          new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int id) {
              // if this button is clicked, close current activity
              SDLActivity.mSingleton.finish();
            }
          });
      dlgAlert.setCancelable(false);
      dlgAlert.create().show();

      return;
    }

    // Set up the surface
    mSurface = new SDLSurface(getApplication());

    if (Build.VERSION.SDK_INT >= 12) {
      mJoystickHandler = new SDLJoystickHandler_API12();
    } else {
      mJoystickHandler = new SDLJoystickHandler();
    }

    mLayout = new AbsoluteLayout(this);
    mLayout.addView(mSurface);

    setContentView(mLayout);
  }
示例#5
0
 @Override
 public void onClick(View view) {
   if (view.getId() == R.id.draw_btn) {
     if (!drawView.getErase()) {
       final Dialog brushDialog = new Dialog(this);
       brushDialog.setTitle("Brush size:");
       brushDialog.setContentView(R.layout.brush_chooser);
       ImageButton smallBtn = (ImageButton) brushDialog.findViewById(R.id.small_brush);
       smallBtn.setOnClickListener(
           new OnClickListener() {
             @Override
             public void onClick(View v) {
               drawView.setBrushSize(smallBrush);
               drawView.setLastBrushSize(smallBrush);
               brushDialog.dismiss();
             }
           });
       ImageButton mediumBtn = (ImageButton) brushDialog.findViewById(R.id.medium_brush);
       mediumBtn.setOnClickListener(
           new OnClickListener() {
             @Override
             public void onClick(View v) {
               drawView.setBrushSize(mediumBrush);
               drawView.setLastBrushSize(mediumBrush);
               brushDialog.dismiss();
             }
           });
       ImageButton largeBtn = (ImageButton) brushDialog.findViewById(R.id.large_brush);
       largeBtn.setOnClickListener(
           new OnClickListener() {
             @Override
             public void onClick(View v) {
               drawView.setBrushSize(largeBrush);
               drawView.setLastBrushSize(largeBrush);
               brushDialog.dismiss();
             }
           });
       brushDialog.show();
     }
     drawView.setErase(false);
   } else if (view.getId() == R.id.erase_btn) {
     if (drawView.getErase()) {
       final Dialog brushDialog = new Dialog(this);
       brushDialog.setTitle("Eraser size:");
       brushDialog.setContentView(R.layout.brush_chooser);
       ImageButton smallBtn = (ImageButton) brushDialog.findViewById(R.id.small_brush);
       smallBtn.setOnClickListener(
           new OnClickListener() {
             @Override
             public void onClick(View v) {
               drawView.setBrushSize(smallBrush);
               brushDialog.dismiss();
             }
           });
       ImageButton mediumBtn = (ImageButton) brushDialog.findViewById(R.id.medium_brush);
       mediumBtn.setOnClickListener(
           new OnClickListener() {
             @Override
             public void onClick(View v) {
               drawView.setBrushSize(mediumBrush);
               brushDialog.dismiss();
             }
           });
       ImageButton largeBtn = (ImageButton) brushDialog.findViewById(R.id.large_brush);
       largeBtn.setOnClickListener(
           new OnClickListener() {
             @Override
             public void onClick(View v) {
               drawView.setBrushSize(largeBrush);
               brushDialog.dismiss();
             }
           });
       brushDialog.show();
     }
     drawView.setErase(true);
   } else if (view.getId() == R.id.new_btn) {
     AlertDialog.Builder newDialog = new AlertDialog.Builder(this);
     newDialog.setTitle("New equation");
     newDialog.setMessage("Start new equation?");
     newDialog.setPositiveButton(
         "Yes",
         new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int which) {
             drawView.startNew();
             dialog.dismiss();
           }
         });
     newDialog.setNegativeButton(
         "Cancel",
         new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int which) {
             dialog.cancel();
           }
         });
     newDialog.show();
   } else if (view.getId() == R.id.equals_btn) {
     // save drawing
   }
 }