@Override
  protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    //
    //	this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.main_login);

    mEtAccount = (EditText) findViewById(R.id.mainLoginEditAccount);
    mEtPassword = (EditText) findViewById(R.id.mainLoginEditPassword);
    mBtnLogin = (Button) findViewById(R.id.mainLoginBtn);
    mBtnRegister = (Button) findViewById(R.id.main_btn_register);

    /* this is to render the password edittext font to be default */
    mEtPassword.setTypeface(Typeface.DEFAULT);
    mEtPassword.setTransformationMethod(new PasswordTransformationMethod());

    mBtnLogin.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            MainActivity.this.tryLogin();
          }
        });

    mBtnRegister.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            Intent intent0 = new Intent(MainActivity.this, RegisterActivity.class);
            startActivity(intent0);
          }
        });
  }
  public MapView(Context ctx, boolean allowNetAccess, int mode) {
    super(ctx);

    Display display;

    this.allowNetAccess = allowNetAccess;

    geoUtils = new GeoUtils(mode);

    setBackgroundColor(0xFF555570);
    display = ((WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    scrWidth = display.getWidth();
    scrHeight = display.getHeight();
    setMinimumHeight(scrWidth);
    setMinimumWidth(scrHeight);
    tileWidth = (int) Math.ceil(scrWidth / 256.0) + 1;
    tileHeight = (int) Math.ceil(scrHeight / 256.0) + 1;
    gestureDetector = new GestureDetector(ctx, new GestureListener());

    zoomOutButton = new Button(ctx);
    zoomOutButton.setText("  -  ");
    zoomOutButton.setOnClickListener(this);

    zoomInButton = new Button(ctx);
    zoomInButton.setText("  +  ");
    zoomInButton.setOnClickListener(this);

    updateUI(true);
    addView(zoomOutButton);
    addView(zoomInButton);
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.rss_reader);
    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    btnManage = (Button) findViewById(R.id.btn_manage);
    btnBrowse = (Button) findViewById(R.id.btn_browse);
    btnRefresh = (Button) findViewById(R.id.btn_refresh);
    btnSearch = (Button) findViewById(R.id.btn_search);

    btnManage.setOnClickListener(this);
    btnBrowse.setOnClickListener(this);
    btnRefresh.setOnClickListener(this);
    btnSearch.setOnClickListener(this);

    txtSearch = (EditText) findViewById(R.id.txt_search);

    init();

    boolean hasUpdate = false;
    try {
      hasUpdate = getIntent().getExtras().getBoolean("rss_update");
    } catch (NullPointerException e) {
      e.printStackTrace();
    }

    if (hasUpdate) {
      rssFeed = dbQuery.getUpdatedRssFeed();
      updateListView();
    } else loadData(null, true, false, true);
  }
Example #4
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.settings);
   this.setTitle(R.string.setting);
   sp = PreferenceManager.getDefaultSharedPreferences(this);
   edit = sp.edit();
   Button widgettheme = (Button) findViewById(R.id.widgettheme);
   Button settime = (Button) findViewById(R.id.settime);
   Button save = (Button) findViewById(R.id.set_save);
   nc = (CheckBox) findViewById(R.id.nightcheck);
   rs = (CheckBox) findViewById(R.id.ringswitch);
   widgettheme.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View Button) {
           AlertDialog.Builder ad =
               new AlertDialog.Builder(Settings.this)
                   .setTitle("选择颜色?")
                   .setItems(
                       color,
                       new DialogInterface.OnClickListener() {
                         @Override
                         public void onClick(DialogInterface p1, int p2) {
                           edit.putInt("widgetTextColor", colori[p2]);
                           edit.commit();
                         }
                       });
           ad.show();
         }
       });
   settime.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View Button) {
           Intent set = new Intent(Settings.this, Settime.class);
           startActivity(set);
           return;
         }
       });
   save.setOnClickListener(
       new View.OnClickListener() {
         public void onClick(View Button) {
           save();
           return;
         }
       });
   nc.setChecked(sp.getBoolean("nightmode", false));
   if (sp.getBoolean("timewrong", false) == true) {
     rs.setChecked(false);
     rs.setClickable(false);
   }
 }
  protected void setupUI() {
    buttonStart.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            startTranscode();
          }
        });

    buttonStop.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            stopTranscode();
          }
        });
  }
Example #6
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.dialog_showdialog);

    Button btn = (Button) findViewById(R.id.call);
    btn.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View v) {
            showDialog(SampleDialog);
          }
        });
    Button btn2 = (Button) findViewById(R.id.call2);
    btn2.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View v) {
            showDialog(QuestionDialog);
          }
        });
  }
  private void showDeleteDialog() {
    Log.d(TAG, "showDeleteDialog() called");

    final Dialog deleteDialog = new Dialog(NoteActivity.this);
    LinearLayout dialogLayout =
        (LinearLayout) View.inflate(NoteActivity.this, R.layout.delete_note_dialog, null);
    deleteDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    deleteDialog.setContentView(dialogLayout);

    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(deleteDialog.getWindow().getAttributes());
    lp.width = WindowManager.LayoutParams.MATCH_PARENT;

    deleteDialog.show();
    deleteDialog.getWindow().setAttributes(lp);

    TextView noteTitleTextView =
        (TextView) dialogLayout.findViewById(R.id.delete_note_dialog_delete_note_title_textview);
    noteTitleTextView.setText(note.getTitle());

    Button confirmDeleteButton =
        (Button) dialogLayout.findViewById(R.id.delete_note_dialog_confirm_button);
    confirmDeleteButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Log.d(TAG, "Delete dialog confirm button clicked");
            noteProvider.deleteNote(note);
            finish();
          }
        });

    Button cancelDeleteButton =
        (Button) dialogLayout.findViewById(R.id.delete_note_dialog_cancel_button);
    cancelDeleteButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Log.d(TAG, "Delete dialog cancel button clicked");
            deleteDialog.dismiss();
          }
        });
  }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   // TODO Auto-generated method stub
   super.onCreate(savedInstanceState);
   setContentView(R.layout.snap);
   initialcam();
   // fixing for initialising an initial value for bmp via inputstream
   InputStream i = getResources().openRawResource(R.drawable.ic_launcher);
   bmp = BitmapFactory.decodeStream(i);
   ib.setOnClickListener(this);
   bton.setOnClickListener(this);
 }
Example #9
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ejemplo);

    textView = (TextView) findViewById(R.id.textView1);
    Button button = (Button) findViewById(R.id.button1);
    button.setOnClickListener(this);
    Locale locale = Locale.getDefault();
    Locale locale1 = getResources().getConfiguration().locale;
    Log.d("EjemploActivity", "El locale es: ".concat(locale.toString()));
    Log.d("EjemploActivity", "El locale1 es: ".concat(locale1.toString()));
  }
 public void setNextButton() {
   Button meatButton = (Button) findViewById(R.id.meatToppingsButton);
   meatButton.setOnClickListener(
       new View.OnClickListener() {
         @Override
         public void onClick(View v) {
           Intent intent = new Intent(MeatToppingsActivity.this, NameActivity.class);
           intent.putExtra("size", size);
           intent.putExtra("numVeggieToppings", numVeggieToppings);
           intent.putExtra("numMeatToppings", numMeatToppings);
           startActivity(intent);
         }
       });
 }
  /**
   * Configure common nav parameters by specifiying resources and activity classes. Not called
   * automatically.
   */
  protected void setupNavActions(
      int buttIdLeft,
      final Class<? extends ActivityGameBase> typeLeft,
      int buttIdRight,
      final Class<? extends ActivityGameBase> typeRight) {
    Button buttLeft = (Button) findViewById(buttIdLeft);
    Button buttRight = (Button) findViewById(buttIdRight);

    buttLeft.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            Intent intent = new Intent(ActivityGameBase.this, typeLeft);
            startActivity(intent);
          }
        });

    buttRight.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            Intent intent = new Intent(ActivityGameBase.this, typeRight);
            startActivity(intent);
          }
        });
  }
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.terciaria);

    Intent i = getIntent();
    double raizPotencia = i.getDoubleExtra("raizPotencia", 0.00);
    btnVoltar = (Button) findViewById(R.id.btnVoltar);
    btnVoltar.setOnClickListener(this);

    double raiz = Math.sqrt(raizPotencia);
    double potencia = Math.pow(raizPotencia, 2);
    TextView txtRaiz = (TextView) findViewById(R.id.resRaiz);
    txtRaiz.setText(String.valueOf(raiz));
    //
    TextView txtPotencia = (TextView) findViewById(R.id.resPotencia);
    txtPotencia.setText(String.valueOf(potencia));
  }
Example #13
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_add);
    // almacenando valores ingresados por el usuario
    nombre = (EditText) findViewById(R.id.edit_name);
    ciudad = (EditText) findViewById(R.id.edit_city);
    // declarando a los botones
    final Button agregar = (Button) findViewById(R.id.yes_b);
    // final Button cancelar = (Button)findViewById(R.id.btnCancelar);
    // acción cuando le dan click al boton agregar
    agregar.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            // se realiza el intento de enviar los datos de un activity a otro, de Registro a
            // Salida.
            // Intent intent = new Intent(RegistroLibroActivity.this, SalidaResultado.class);
            // Bundle b = new Bundle();
            // almacenamiento temporal para poder usarlo en otro activity
            String bnombre = String.valueOf(nombre.getText());
            String bciudad = String.valueOf(ciudad.getText());

            nombre.setText("");
            ciudad.setText("");

            // llamada al metodo para insertar los datos.
            insertPrso(bnombre, bciudad);
            // datos que seran vistos en el otro main
            // b.putString("T", btitulo);
            // b.putString("A", bautor);
            // b.putString("I", bidioma);
            // b.putString("B", baño);
            // intent.putExtras(b);
            // startActivity(intent);
          }
        });
    // acción cuando le dan click al boton agregar
    // cancelar.setOnClickListener(new View.OnClickListener() {
    //   public void onClick(View v) {
    //     titulo.setText(" ");
    //   autor.setText(" ");
    // idioma.setText(" ");
    // año.setText(" ");
    // }
    // });
  }
Example #14
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    c = this;
    preferences = PreferenceManager.getDefaultSharedPreferences(c);

    super.onCreate(savedInstanceState);

    setContentView(R.layout.gpu_sgx540);

    gpuCurrent = readFile(Constants.GPU_SGX540);
    seekGpu = (SeekBar) findViewById(R.id.seek_gpu);

    gpu = Arrays.asList(153, 307, 384);
    seekBar(gpu.size() - 1, gpu.indexOf(gpuCurrent));

    /*else{
    seekGpu.setEnabled(false);
    seekIva.setEnabled(false);
    TextView ns = (TextView)findViewById(R.id.not_supported);
    ns.setVisibility(View.VISIBLE);
    }*/
    preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext());

    curGpuTxt = (TextView) findViewById(R.id.current_gpu);
    maxGpuTxt = (TextView) findViewById(R.id.max_gpu);
    minGpuTxt = (TextView) findViewById(R.id.min_gpu);

    mhz = getResources().getString(R.string.mhz);
    current = getResources().getString(R.string.current);
    max = getResources().getString(R.string._max);
    min = getResources().getString(R.string._min);
    curGpuTxt.setText(current + ": " + (gpuCurrent) + mhz);
    maxGpuTxt.setText(max + ": " + gpu.get(2) + mhz);
    minGpuTxt.setText(min + ": " + gpu.get(0) + mhz);

    Button cancel = (Button) findViewById(R.id.cancel);
    cancel.setOnClickListener(
        new OnClickListener() {

          @Override
          public void onClick(View arg0) {
            finish();
          }
        });
  }
  /** Configure the common answer field. Not called automatically. Do it in setupGameActions(). */
  protected void setupAnswerActions(int fieldID, int buttID) {
    final EditText fieldAnswer = (EditText) findViewById(fieldID);
    final Button buttAnswer = (Button) findViewById(buttID);

    fieldAnswer.addTextChangedListener(
        new TextWatcherAdapter() {
          public void afterTextChanged(Editable ed) {
            buttAnswer.setClickable((ed.length() > 0));
          };
        });

    buttAnswer.setClickable(false);
    buttAnswer.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            onAnswer();
          }
        });
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.receiver);

    final Button cancelbtn = (Button) findViewById(R.id.ButtonCancel);
    // cancelbtn.setEnabled(false);
    cancelbtn.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            // streamtask.cancel(true);
            finish();
          }
        });

    try {
      Intent intent = getIntent();
      String action = intent.getAction();
      String type = intent.getType();

      if ((!(Intent.ACTION_SEND.equals(action))) || (type == null)) {
        throw new RuntimeException("Unknown intent action or type");
      }

      if (!("text/plain".equals(type))) {
        throw new RuntimeException("Type is not text/plain");
      }

      String extra = intent.getStringExtra(Intent.EXTRA_TEXT);
      if (extra == null) {
        throw new RuntimeException("Cannot get shared text");
      }

      final DownloadStreamTask streamtask = new DownloadStreamTask(this);

      //	Once created, a task is executed very simply:
      streamtask.execute(extra);

    } catch (Exception e) {
      Toast.makeText(this, e.toString(), Toast.LENGTH_LONG).show();
    }
  }
    @Override
    public DownloadStreamTask(Context _c) {
      mContext = new WeakReference<Context>(_c);
      // dialog = new ProgressDialog(myact.this);

      text1 = (TextView) findViewById(R.id.textView1);

      Button cancelbtn = (Button) findViewById(R.id.ButtonCancel);
      cancelbtn.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              // Do something in response to button click
              cancel(true);
            }
          });

      cancelbtn.setEnabled(true);
    }
Example #18
0
File: Main.java Project: hsbp/urc
  private void attachEventHandlers() {
    for (final Action a : Action.values()) {
      final Button b = (Button) findViewById(a.res);
      if (a.repeat) {
        b.setOnTouchListener(
            new View.OnTouchListener() {
              public boolean onTouch(View v, MotionEvent event) {
                switch (event.getAction()) {
                  case MotionEvent.ACTION_DOWN:
                    sender.send(a);
                    break;
                  case MotionEvent.ACTION_UP:
                    sender.stop(a);
                    break;
                }
                return false;
              }
            });
      } else {
        b.setOnClickListener(
            new View.OnClickListener() {
              public void onClick(View v) {
                sender.send(a);
              }
            });
      }
    }
    SeekBar sb = (SeekBar) findViewById(R.id.pause);
    sb.setProgress(Sender.DEFAULT_PAUSE);
    sb.setOnSeekBarChangeListener(
        new SeekBar.OnSeekBarChangeListener() {
          public void onStopTrackingTouch(SeekBar seekBar) {}

          public void onStartTrackingTouch(SeekBar seekBar) {}

          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            sender.setPause(progress);
          }
        });
  }
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.masstab);

    spinnerFrom = (Spinner) findViewById(R.id.SpinnerFrom);
    ArrayAdapter<CharSequence> adapter =
        ArrayAdapter.createFromResource(
            this, R.array.weights, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinnerFrom.setAdapter(adapter);

    spinnerTo = (Spinner) findViewById(R.id.SpinnerTo);
    spinnerTo.setAdapter(adapter);

    final Button button = (Button) findViewById(R.id.Go_Button);
    button.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            calculate();
          }
        });
  }
Example #20
0
        public void onServiceConnected(ComponentName name, IBinder service) {
          loggingService = ((GpsLoggingService.GpsLoggingBinder) service).getService();
          GpsLoggingService.SetServiceClient(GpsMainActivity.this);

          Button buttonSinglePoint = (Button) findViewById(R.id.buttonSinglePoint);

          buttonSinglePoint.setOnClickListener(GpsMainActivity.this);

          if (Session.isStarted()) {
            if (Session.isSinglePointMode()) {
              SetMainButtonEnabled(false);
            } else {
              SetMainButtonChecked(true);
              SetSinglePointButtonEnabled(false);
            }

            DisplayLocationInfo(Session.getCurrentLocationInfo());
          }

          // Form setup - toggle button, display existing location info
          ToggleButton buttonOnOff = (ToggleButton) findViewById(R.id.buttonOnOff);
          buttonOnOff.setOnCheckedChangeListener(GpsMainActivity.this);
        }
Example #21
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;
  }
Example #22
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    /*
     * TODO clean-up this upload thing
     *
     * ExceptionHandler.register(this,
     * "http://www.whidbeycleaning.com/droid/server.php");
     */
    setContentView(R.layout.main);

    commandText = (EditText) this.findViewById(R.id.commandText);
    resultText = (TextView) this.findViewById(R.id.resultText);
    sendButton = (Button) this.findViewById(R.id.sendButton);

    sendButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            final MyCommand command = new MyCommand(commandText.getText().toString());
            mServiceConnection.addJobToQueue(new ObdCommandJob(command));

            mHandler.postDelayed(
                new Runnable() {
                  @Override
                  public void run() {
                    resultText.setText(command.getName() + ">>" + command.getResult());
                  }
                },
                2000);
          }
        });

    mListener =
        new IPostListener() {
          public void stateUpdate(ObdCommandJob job) {
            String cmdName = job.getCommand().getName();
            String cmdResult = job.getCommand().getFormattedResult();

            Log.d(TAG, FuelTrim.LONG_TERM_BANK_1.getBank() + " equals " + cmdName + "?");

            if (AvailableCommandNames.ENGINE_RPM.getValue().equals(cmdName)) {
              TextView tvRpm = (TextView) findViewById(R.id.rpm_text);
              tvRpm.setText(cmdResult);
            } else if (AvailableCommandNames.SPEED.getValue().equals(cmdName)) {
              TextView tvSpeed = (TextView) findViewById(R.id.spd_text);
              tvSpeed.setText(cmdResult);
              speed = ((SpeedObdCommand) job.getCommand()).getMetricSpeed();
            } else if (AvailableCommandNames.MAF.getValue().equals(cmdName)) {
              maf = ((MassAirFlowObdCommand) job.getCommand()).getMAF();
              addTableRow(cmdName, cmdResult);
            } else if (FuelTrim.LONG_TERM_BANK_1.getBank().equals(cmdName)) {
              ltft = ((FuelTrimObdCommand) job.getCommand()).getValue();
            } else if (AvailableCommandNames.EQUIV_RATIO.getValue().equals(cmdName)) {
              equivRatio = ((CommandEquivRatioObdCommand) job.getCommand()).getRatio();
              addTableRow(cmdName, cmdResult);
            } else {
              addTableRow(cmdName, cmdResult);
            }
          }
        };

    /*
     * Validate GPS service.
     */
    LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    if (locationManager.getProvider(LocationManager.GPS_PROVIDER) == null) {
      /*
       * TODO for testing purposes we'll not make GPS a pre-requisite.
       */
      // preRequisites = false;
      showDialog(NO_GPS_ID);
    }

    /*
     * Validate Bluetooth service.
     */
    // Bluetooth device exists?
    final BluetoothAdapter mBtAdapter = BluetoothAdapter.getDefaultAdapter();
    if (mBtAdapter == null) {
      preRequisites = false;
      showDialog(NO_BLUETOOTH_ID);
    } else {
      // Bluetooth device is enabled?
      if (!mBtAdapter.isEnabled()) {
        preRequisites = false;
        showDialog(BLUETOOTH_DISABLED);
      }
    }

    /*
     * Get Orientation sensor.
     */
    sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
    List<Sensor> sens = sensorManager.getSensorList(Sensor.TYPE_ORIENTATION);
    if (sens.size() <= 0) {
      showDialog(NO_ORIENTATION_SENSOR);
    } else {
      orientSensor = sens.get(0);
    }

    // validate app pre-requisites
    if (preRequisites) {
      /*
       * Prepare service and its connection
       */
      mServiceIntent = new Intent(this, ObdGatewayService.class);
      mServiceConnection = new ObdGatewayServiceConnection();
      mServiceConnection.setServiceListener(mListener);

      // bind service
      Log.d(TAG, "Binding service..");
      bindService(mServiceIntent, mServiceConnection, Context.BIND_AUTO_CREATE);
    }
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gatt_services_characteristics);

    final Intent intent = getIntent();
    mDeviceName = intent.getStringExtra(EXTRAS_DEVICE_NAME);
    mDeviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS);

    // Sets up UI references.
    mConnectionState = (TextView) findViewById(R.id.connection_state);
    // is serial present?
    isSerial = (TextView) findViewById(R.id.isSerial);

    msgEdit = (EditText) findViewById(R.id.editText);
    returnText = (TextView) findViewById(R.id.returnText);

    sendButton = (Button) findViewById(R.id.sendButton);
    //        timeButton = (Button) findViewById(R.id.timeButton);

    sendButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            if (characteristicReady) {
              StringBuffer sb = new StringBuffer("m");
              sb.append(msgEdit.getText()).append("\n");

              sendMessage(sb.toString());
            }
          }
        });

    //        timeButton.setOnClickListener(new View.OnClickListener() {
    //
    //            @Override
    //            public void onClick(View v) {
    //                if (characteristicReady) {
    //                    StringBuffer sb = new StringBuffer("t");
    //                    Date now = new Date();
    //                    sb.append(DATE_FORMAT.format(now)).append("\n");
    //
    //                    sendMessage(sb.toString());
    //                }
    //            }
    //        });

    infoButton = (ImageView) findViewById(R.id.infoImage);
    infoButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            iascDialog();
          }
        });

    mSurfaceView = (SurfaceView) findViewById(R.id.surfaceView);
    mSurfaceHolder = mSurfaceView.getHolder();
    mSurfaceHolder.addCallback(new MyHolder());

    mPaint = new Paint();
    // 画笔的粗细
    mPaint.setStrokeWidth(5.0f);

    getActionBar().setTitle(mDeviceName);
    getActionBar().setDisplayHomeAsUpEnabled(true);

    Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
    bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
  }
  private void InitViews() {
    edSubject = (TouchEdit) findViewById(R.id.edAppointmentSubject);
    edSubject.setOnOpenKeyboard(
        new TouchEdit.OnOpenKeyboard() {
          public void OnOpenKeyboardEvent() {
            KeyboardWidget.Open(ActivityAppointment.this, edSubject.getText().toString());
          }
        });

    btnStartDate = (Button) findViewById(R.id.btnAppointmentStartDate);
    btnStartTime = (Button) findViewById(R.id.btnAppointmentStartTime);
    chkAllDay = (CheckBox) findViewById(R.id.chkAppointmentAllDay);
    chkAlarm = (CheckBox) findViewById(R.id.chkAppointmentAlarm);

    btnRepeatSelect = (Button) findViewById(R.id.btnRepeatSelect);
    btnRepeatSelect.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            OpenRepeatDialog();
          }
        });

    btnSave = (ImageButton) findViewById(R.id.btnAppointmentSave);
    btnSave.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            SaveData();
          }
        });

    btnDelete = (ImageButton) findViewById(R.id.btnAppointmentDelete);
    btnDelete.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            DeleteData();
          }
        });

    btnStartDate.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {

            DateWidget.Open(ActivityAppointment.this, false, dateStart, prefs.iFirstDayOfWeek);
          }
        });

    btnStartTime.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {

            TimeWidget.Open(
                ActivityAppointment.this,
                false,
                prefs.b24HourMode,
                dateStart.get(Calendar.HOUR_OF_DAY),
                dateStart.get(Calendar.MINUTE));
          }
        });

    chkAllDay.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            UpdateStartDateTimeView();
          }
        });
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.profile);
    findViews();
    /*Select Category work */
    final String[] categories = getIntent().getStringArrayExtra("Options");
    ArrayAdapter<String> catadapt;
    catadapt = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, categories);
    mCatSpin.setAdapter(catadapt);
    mCatSpin.setOnItemSelectedListener(
        new OnItemSelectedListener() {
          public void onItemSelected(AdapterView<?> parent, View v, int pos, long id) {
            mChosenCategory = categories[pos];
          }

          public void onNothingSelected(AdapterView<?> parent) {}
        });
    /*Availability selection work*/
    mAvail = (Button) findViewById(R.id.editavail);
    mAvail.setOnClickListener(this);
    /*Submit/Back button work*/
    mSub = (Button) findViewById(R.id.submitbutton);
    mSub.setOnClickListener(this);
    mBack.setOnClickListener(this);
    /*Web View & Camera uploader work*/
    openCam.setOnClickListener(this);
    openWeb.setOnClickListener(this);
    web.getSettings().setJavaScriptEnabled(true);
    web.loadUrl("http://www.monkbananas.com/uploader/index.php");
    // ------Everything below this line was found on StackOverflow--------------------
    web.setWebChromeClient(
        new WebChromeClient() {
          @Override
          public boolean shouldOverrideUrlLoading(WebView v, String url) {
            web.loadUrl(url);
            return true;
          }
          // The undocumented magic method override
          // Eclipse will swear at you if you try to put @Override here
          // For Android 3.0+
          public void openFileChooser(ValueCallback<Uri> uploadMsg) {

            mUploadMessage = uploadMsg;
            Intent i = new Intent(Intent.ACTION_GET_CONTENT);
            i.addCategory(Intent.CATEGORY_OPENABLE);
            i.setType("image/*");
            startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE);
          }

          // For Android 3.0+
          public void openFileChooser(ValueCallback uploadMsg, String acceptType) {
            mUploadMessage = uploadMsg;
            Intent i = new Intent(Intent.ACTION_GET_CONTENT);
            i.addCategory(Intent.CATEGORY_OPENABLE);
            i.setType("*/*");
            startActivityForResult(Intent.createChooser(i, "File Browser"), FILECHOOSER_RESULTCODE);
          }

          // For Android 4.1
          public void openFileChooser(
              ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
            mUploadMessage = uploadMsg;
            Intent i = new Intent(Intent.ACTION_GET_CONTENT);
            i.addCategory(Intent.CATEGORY_OPENABLE);
            i.setType("image/*");
            startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE);
          }
        });
  }
Example #26
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tweenlistener);

    mLinear = (LinearLayout) findViewById(R.id.linear);

    mBtn = (Button) findViewById(R.id.start);
    mBtn.setOnClickListener(
        new Button.OnClickListener() {
          public void onClick(View v) {
            // * 리스너로 연결하기
            mBtn.startAnimation(mAni1);
            // */
            /* 오프셋으로 연결하기
            mBtn.startAnimation(AnimationUtils.loadAnimation(
            		TweenListener.this, R.anim.offset));
            //*/
          }
        });

    mAni1 = AnimationUtils.loadAnimation(this, R.anim.rotate2);
    mAni2 = AnimationUtils.loadAnimation(this, R.anim.alpha2);
    mAni3 = AnimationUtils.loadAnimation(this, R.anim.scale2);

    mAni1.setAnimationListener(
        new AnimationListener() {
          public void onAnimationEnd(Animation animation) {
            mBtn.startAnimation(mAni2);
          }

          public void onAnimationRepeat(Animation animation) {
            ;
          }

          public void onAnimationStart(Animation animation) {
            ;
          }
        });

    mAni2.setAnimationListener(
        new AnimationListener() {
          public void onAnimationEnd(Animation animation) {
            mBtn.startAnimation(mAni3);
          }

          public void onAnimationRepeat(Animation animation) {
            ;
          }

          public void onAnimationStart(Animation animation) {
            ;
          }
        });

    mAni3.setAnimationListener(
        new AnimationListener() {
          public void onAnimationEnd(Animation animation) {
            Toast.makeText(TweenListener.this, "Animation End", 0).show();
          }

          public void onAnimationRepeat(Animation animation) {
            ;
          }

          public void onAnimationStart(Animation animation) {
            ;
          }
        });
  }
    @Override
    public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
      View rootView = inflater.inflate(R.layout.fragment_user_crud, container, false);

      editTextUserName = (EditText) rootView.findViewById(R.id.editTextUserName);
      editTextEmail = (EditText) rootView.findViewById(R.id.editTextEmail);
      editTextLogin = (EditText) rootView.findViewById(R.id.editTextLogin);
      editTextPassword = (EditText) rootView.findViewById(R.id.editTextPassword);
      editTextConfirmPassword = (EditText) rootView.findViewById(R.id.editTextConfirmPassword);
      editTextZipCode = (EditText) rootView.findViewById(R.id.editTextZipCode);
      editTextAddress = (EditText) rootView.findViewById(R.id.editTextAddress);
      editTextNumberAddress = (EditText) rootView.findViewById(R.id.editTextNumberAddress);
      editTextComplement = (EditText) rootView.findViewById(R.id.editTextComplement);
      editTextNeighborhood = (EditText) rootView.findViewById(R.id.editTextNeighborhood);
      editTextCity = (EditText) rootView.findViewById(R.id.editTextCity);
      txtLatitude = (TextView) rootView.findViewById(R.id.txtLatitude);
      txtLongitude = (TextView) rootView.findViewById(R.id.txtLongitude);
      radioGroupGender = (RadioGroup) rootView.findViewById(R.id.radioGender);
      spinnerStates = (Spinner) rootView.findViewById(R.id.spinnerStates);
      btnSearchZipCode = (Button) rootView.findViewById(R.id.btnSearchZipCode);
      btnSaveUser = (Button) rootView.findViewById(R.id.btnSaveUser);

      ArrayAdapter arrayAdapterStates =
          new ArrayAdapter(getActivity(), R.layout.support_simple_spinner_dropdown_item, states);
      spinnerStates.setPrompt("Estados");
      spinnerStates.setAdapter(arrayAdapterStates);
      spinnerStates.setOnItemSelectedListener(
          new AdapterView.OnItemSelectedListener() {

            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
              if (position > 0) {
                String state = (String) spinnerStates.getItemAtPosition(position);
                spinnerStates.setSelection(states.indexOf(state));
              }
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {
              Toast.makeText(
                      getActivity(), "É necessário selecionar uma Categoria", Toast.LENGTH_SHORT)
                  .show();
            }
          });

      if (getActivity().getIntent().getSerializableExtra("user") != null) {
        UserBean userBeanLoad = (UserBean) getActivity().getIntent().getSerializableExtra("user");
        editTextUserName.setText(userBeanLoad.getUserName());
        editTextEmail.setText(userBeanLoad.getEmail());
        editTextLogin.setText(userBeanLoad.getLogin());
        editTextPassword.setVisibility(View.INVISIBLE);
        editTextConfirmPassword.setVisibility(View.INVISIBLE);
        editTextZipCode.setText(userBeanLoad.getZipCode());
        editTextAddress.setText(userBeanLoad.getAddress());
        editTextNumberAddress.setText(userBeanLoad.getNumberAddress());
        editTextComplement.setText(userBeanLoad.getComplement());
        editTextNeighborhood.setText(userBeanLoad.getNeighborhood());
        editTextCity.setText(userBeanLoad.getCity());
        if (userBeanLoad.getGender().equals(UserBean.Gender.MALE.getSex())) {
          radioButtonGender = (RadioButton) rootView.findViewById(R.id.radioMale);
          radioButtonGender.setChecked(true);
        } else {
          radioButtonGender = (RadioButton) rootView.findViewById(R.id.radioFemale);
          radioButtonGender.setChecked(true);
        }

        spinnerStates.setSelection(states.indexOf(userBeanLoad.getState()));
        getActivity()
            .getWindow()
            .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
        btnSaveUser.setTag(userBeanLoad);
      }

      btnSaveUser.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              progressDialog =
                  ProgressDialog.show(getActivity(), "Processando", "Salvando usuário...");

              if (view.getTag() != null) {
                userBean = (UserBean) view.getTag();
              } else {
                userBean = new UserBean();
              }

              int selectedId = radioGroupGender.getCheckedRadioButtonId();
              switch (selectedId) {
                case R.id.radioFemale:
                  userBean.setGender(UserBean.Gender.FEMALE.getSex());
                  break;
                case R.id.radioMale:
                  userBean.setGender(UserBean.Gender.MALE.getSex());
                  break;
              }

              userBean.setUserName(editTextUserName.getText().toString());
              userBean.setEmail(editTextEmail.getText().toString());
              userBean.setLogin(editTextLogin.getText().toString());
              userBean.setPassword(editTextPassword.getText().toString());
              userBean.setZipCode(editTextZipCode.getText().toString());
              userBean.setAddress(editTextAddress.getText().toString());
              userBean.setNumberAddress(editTextNumberAddress.getText().toString());
              userBean.setComplement(editTextComplement.getText().toString());
              userBean.setNeighborhood(editTextNeighborhood.getText().toString());
              userBean.setCity(editTextCity.getText().toString());

              userBean.setState(spinnerStates.getSelectedItem().toString());

              AsyncTask<Void, Void, JSONObject> task =
                  new AsyncTask<Void, Void, JSONObject>() {

                    @Override
                    protected JSONObject doInBackground(Void... voids) {
                      Http http = new Http();
                      try {
                        StringBuilder strAddress = new StringBuilder();
                        strAddress.append(editTextAddress.getText().toString()).append(" ");
                        strAddress.append(editTextNumberAddress.getText().toString()).append(" ");
                        strAddress.append(editTextCity.getText().toString()).append(" ");
                        strAddress.append(spinnerStates.getSelectedItem().toString());

                        String result =
                            http.doGet(
                                PAGE_MAPS
                                    + URLEncoder.encode(strAddress.toString(), "UTF-8")
                                    + "&sensor=true");

                        JSONObject jsonObject = new JSONObject(result);

                        if (jsonObject.getString("status").equals("OK")) {
                          JSONArray jsonArrayResults = jsonObject.getJSONArray("results");
                          for (int i = 0; i < jsonArrayResults.length(); i++) {
                            JSONObject jsonObjectResults = jsonArrayResults.getJSONObject(i);
                            if (jsonObjectResults.get("geometry") != null) {
                              JSONObject jsonObjectGeometry =
                                  jsonObjectResults.getJSONObject("geometry");
                              return (JSONObject) jsonObjectGeometry.get("location");
                            }
                          }
                        }

                      } catch (IOException e1) {
                        Log.e(AppHelper.getClassError(UserCrudActivity.class), e1.getMessage());
                      } catch (JSONException e2) {
                        Log.e(AppHelper.getClassError(UserCrudActivity.class), e2.getMessage());
                      }

                      return null;
                    }

                    @Override
                    protected void onPostExecute(JSONObject jsonObject) {
                      super.onPostExecute(jsonObject);

                      boolean cepOK = true;
                      if (jsonObject == null || jsonObject.isNull("lng")) {
                        cepOK = false;
                        Toast.makeText(getActivity(), "CEP inexistente.", Toast.LENGTH_SHORT)
                            .show();
                      } else {
                        try {
                          userBean.setLatitude(jsonObject.get("lat").toString());
                          userBean.setLongitude(jsonObject.get("lng").toString());

                          boolean create = userBean.getId() == null ? true : false;

                          UserDB userDB = new UserDB(getActivity());
                          userBean = userDB.salvar(userBean);

                          if (userBean != null) {
                            Intent it = new Intent();
                            it.putExtra(
                                "msg",
                                create
                                    ? "Usuário salvo com sucesso!"
                                    : "Usuário atualizado com sucesso!");
                            it.putExtra("user", userBean);
                            getActivity().setResult(RESULT_OK, it);
                            getActivity().finish();
                          } else {
                            Intent it = new Intent();
                            it.putExtra(
                                "msg",
                                create
                                    ? "Falha ao cadastrar o Usuário!"
                                    : "Falha ao atualizar Usuário!");
                            getActivity().setResult(RESULT_CANCELED, it);
                            getActivity().finish();
                          }

                        } catch (JSONException e3) {
                          Log.e(AppHelper.getClassError(UserCrudActivity.class), e3.getMessage());
                        }
                      }

                      if (cepOK) {
                        UserDB userDB = new UserDB(getActivity());
                        userBean = userDB.salvar(userBean);
                        if (userBean != null) {
                          Intent it = new Intent();
                          it.putExtra(
                              "msg",
                              userBean.getId() == null
                                  ? "Usuário salvo com sucesso!"
                                  : "Usuário atualizado com sucesso!");
                          it.putExtra("user", userBean);
                          getActivity().setResult(RESULT_OK, it);
                          getActivity().finish();
                        } else {
                          Intent it = new Intent();
                          it.putExtra(
                              "msg",
                              userBean.getId() == null
                                  ? "Falha ao cadastrar o Usuário!"
                                  : "Falha ao atualizar Usuário!");
                          getActivity().setResult(RESULT_CANCELED, it);
                          getActivity().finish();
                        }
                      }
                    }
                  };

              if (validateFields(userBean)) {
                task.execute();
              }

              progressDialog.dismiss();
            }
          });

      btnSearchZipCode.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              progressDialog = ProgressDialog.show(getActivity(), "Pesquisando", "Carregando...");
              AsyncTask<Void, Void, JSONObject> task =
                  new AsyncTask<Void, Void, JSONObject>() {
                    @Override
                    protected JSONObject doInBackground(Void... params) {

                      Http http = new Http();
                      try {
                        String result =
                            http.doGet(PAGE_CORREIOS + editTextZipCode.getText().toString());
                        JSONObject jsonObject = new JSONObject(result);
                        if (!jsonObject.has("message")) {
                          return jsonObject;
                        }

                      } catch (IOException e1) {
                        Log.e(AppHelper.getClassError(UserCrudActivity.class), e1.getMessage());
                      } catch (JSONException e2) {
                        Log.e(AppHelper.getClassError(UserCrudActivity.class), e2.getMessage());
                      }

                      return null;
                    }

                    @Override
                    protected void onPostExecute(JSONObject jsonObject) {
                      if (jsonObject == null) {
                        Toast.makeText(getActivity(), "CEP inexistente.", Toast.LENGTH_SHORT)
                            .show();
                      } else {
                        try {
                          editTextAddress.setText(
                              jsonObject.get("tipoDeLogradouro")
                                  + " "
                                  + jsonObject.get("logradouro"));
                          editTextNeighborhood.setText(jsonObject.get("bairro").toString());
                          editTextCity.setText(jsonObject.get("cidade").toString());
                          spinnerStates.setSelection(
                              states.indexOf(jsonObject.get("estado").toString()));
                        } catch (JSONException e3) {
                          Log.e(AppHelper.getClassError(UserCrudActivity.class), e3.getMessage());
                        }
                      }
                      progressDialog.dismiss();
                    }
                  };
              task.execute();
            }
          });

      return rootView;
    }
Example #28
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    calculator = new Calc();

    // main layout
    LinearLayout layout = new LinearLayout(this);

    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    layout.setBackgroundColor(Color.BLACK);

    // upper result box and current opr box container
    LinearLayout upper = new LinearLayout(this);

    upper.setOrientation(LinearLayout.HORIZONTAL);
    upper.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    upper.setGravity(Gravity.TOP);
    // add the upper layout to the main layout
    layout.addView(upper);

    // result box
    resultbox = new EditText(this);
    resultbox.setEnabled(false);
    resultbox.setText(resultStr);
    upper.addView(resultbox);

    // middle tier layout
    LinearLayout middle = new LinearLayout(this);

    middle.setOrientation(LinearLayout.HORIZONTAL);
    middle.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    // bottom button grid (numbers 0-9)
    TableLayout grid = new TableLayout(this);
    TableRow[] rows = new TableRow[5];

    int rownum = 0;
    for (int i = 0; i <= 12; i++) {
      // add a new row to the grid
      if ((i) % 3 == 0 || i == 0) {
        if (i != 0) rownum = (i) / 3;
        else rownum = 0;

        rows[rownum] = new TableRow(this);
        // TODO: setup row params here
        grid.addView(rows[rownum]);
      }

      Button bttn = new Button(this);
      if (i < 10) {
        // integers
        bttn.setText(Integer.toString(i));
        final int _i = i;
        bttn.setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                // set it so the click changes the string that
                // you send in the parser and changes the upper textbox
                if (resultStr != null && resultStr != "")
                  resultStr = resultStr + Integer.toString(_i);
                else resultStr = Integer.toString(_i);
                resultbox.setText(resultStr);
              }
            });
      } else if (i == 10) {
        // prev answer bttn
        bttn.setText(".");
        bttn.setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                // set it so the click changes the string that
                // you send in the parser and changes the upper textbox
                if (resultStr != null && resultStr != "") resultStr = resultStr + ".";
                else resultStr = ".";

                resultbox.setText(resultStr);
              }
            });
      } else if (i == 11) {

        bttn.setText("Clear");
        bttn.setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                // Clear the result string
                resultStr = "";
                resultbox.setText("");
              }
            });
      } else {
        // prev answer bttn
        bttn.setText("Ansr");
        bttn.setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                // set it so the click changes the string that
                // you send in the parser and changes the upper textbox
                resultStr = prevAnswr;
                resultbox.setText(resultStr);
              }
            });
      }
      rows[rownum].addView(bttn);
    }
    middle.addView(grid);

    /*side button grid (+, -, =, parenthesis, * and %)*/
    LinearLayout rightside = new LinearLayout(this);

    rightside.setHorizontalGravity(RelativeLayout.ALIGN_PARENT_RIGHT);
    rightside.setVerticalGravity(RelativeLayout.CENTER_IN_PARENT);
    rightside.setLayoutParams(
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    rightside.setOrientation(LinearLayout.VERTICAL);

    Queue<String> rightSymbols = new LinkedList<String>();
    String[] symbols = {"+", "-", "*", "/", "(", ")"};
    List<String> l_symbols = Arrays.asList(symbols);
    rightSymbols.addAll(l_symbols);

    while (!rightSymbols.isEmpty()) {
      final String symbol = rightSymbols.poll();
      Button bttn = new Button(this);
      bttn.setText(symbol);
      bttn.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              // TODO add the symbol to the string for submission into the parser
              if (resultStr != null && resultStr != "") resultStr = resultStr + symbol;
              else resultStr = symbol;
              resultbox.setText(resultStr);
            }
          });
      rightside.addView(bttn);
    }
    middle.addView(rightside);

    // = button, on a bottom bar
    LinearLayout bottom = new LinearLayout(this);
    bottom.setOrientation(LinearLayout.HORIZONTAL);
    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    bottom.setLayoutParams(params);

    bottom.setBackgroundColor(Color.BLUE);

    Button eqbttn = new Button(this);
    LinearLayout.LayoutParams eqparams =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    eqbttn.setLayoutParams(eqparams);
    eqbttn.setText("=");
    eqbttn.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            // send information to parser and return result as textbox string
            try {
              String result = calculator.createResult(resultStr);
              resultbox.setText(result);
              resultStr = result;
              prevAnswr = result;
            } catch (Exception e) {
              // TODO Auto-generated catch block
              resultbox.setText(e.getMessage());
            }
          }
        });
    bottom.addView(eqbttn);

    layout.addView(middle);
    layout.addView(bottom);

    setContentView(layout);
  }
Example #29
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    try {
      mSharedPreferences = Prefs.getSharedPreferences(this);
    } catch (NullPointerException e) {
      if (BuildConfig.DEBUG) {
        Log.w("[" + TAG + "]", "mSharedPreferences == NullPointerException :" + e.getMessage());
      }
    }

    mSharedPreferences.registerOnSharedPreferenceChangeListener(this);

    if (Prefs.getThemeType(this) == false) {
      mThemeId = R.style.AppTheme_Light;
      setTheme(mThemeId);
    } else {
      mThemeId = R.style.AppTheme_Dark;
      setTheme(mThemeId);
    }

    // Eula.showDisclaimer( this );
    Eula.showEula(this, getApplicationContext());

    mActionBar = getActionBar();
    if (mActionBar != null) {
      mActionBar.setDisplayHomeAsUpEnabled(false);
      mActionBar.setDisplayShowHomeEnabled(true);
      mActionBar.setDisplayShowTitleEnabled(true);
    } else {
      if (BuildConfig.DEBUG) {
        Log.w("[" + TAG + "]", "mActionBar == null");
      }
    }

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
      this.setTitle(extras.getString("dir") + " :: " + getString(R.string.app_name));
    } else {
      this.setTitle(" :: " + getString(R.string.app_name));
    }

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    tvDisplay = (TextView) findViewById(R.id.tvDisplay);

    bRename = (Button) findViewById(R.id.bRename);
    bSettings = (Button) findViewById(R.id.bSettings);
    bHelp = (Button) findViewById(R.id.bHelp);
    bExit = (Button) findViewById(R.id.bExit);

    bRename.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Intent openAndroidFileBrowser = new Intent("com.scto.filerenamer.ANDROIDFILEBROWSER");
            openAndroidFileBrowser.putExtra("what", "renamer");
            openAndroidFileBrowser.putExtra("theme", mThemeId);
            startActivity(openAndroidFileBrowser);
          }
        });

    bSettings.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            Intent openPreferencesActivity = new Intent("com.scto.filerenamer.PREFERENCESACTIVITY");
            startActivity(openPreferencesActivity);
          }
        });

    bHelp.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            FragmentManager fm = getSupportFragmentManager();
            HelpDialog helpDialog = new HelpDialog();
            helpDialog.show(fm, "dlg_help");
          }
        });

    bExit.setOnClickListener(
        new View.OnClickListener() {
          public void onClick(View v) {
            FragmentManager fm = getSupportFragmentManager();
            ExitDialog exitDialog = new ExitDialog();
            exitDialog.show(fm, "dlg_exit");
          }
        });

    /*
    ChangeLog cl = new ChangeLog( this );
    if( cl.firstRun() )
    {
    	cl.getLogDialog().show();
    }
    */
    init();
  }
Example #30
0
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
      View view = convertView;
      if (view == null) {
        LayoutInflater inflater =
            (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflater.inflate(R.layout.content_list_item, null);
      }
      TextView titleTextView = (TextView) view.findViewById(R.id.list_item_title);
      TextView stateTextView = (TextView) view.findViewById(R.id.list_item_state);
      TextView downTextView = (TextView) view.findViewById(R.id.list_item_downbar);
      Button downloadButton = (Button) view.findViewById(R.id.list_item_download_button);
      Button uploadButton = (Button) view.findViewById(R.id.list_item_upload_button);

      LocationInfo info = mInfoList.get(position);
      String titleText = info.title;
      String stateText = "";

      if (titleText.length() > 30) titleText = titleText.substring(0, 28) + "...";

      synchronized (mLoaderMap) {
        if (mLoaderMap.containsKey(info.title)) {
          LoaderState loader = mLoaderMap.get(info.title);
          if (loader.state < 100) stateText = String.format(Locale.ENGLISH, "%d%%", loader.state);
          else if (loader.state == 100) stateText = String.format(Locale.ENGLISH, "Done!");
          else stateText = String.format(Locale.ENGLISH, "Failed!");
        }
      }

      if (info.localVersion < 0) titleText += " (?)";
      else {
        if (info.localModified)
          titleText += String.format(Locale.ENGLISH, " (v. %d+)", info.localVersion);
        else titleText += String.format(Locale.ENGLISH, " (v. %d)", info.localVersion);
      }

      String mapFile = NavigineApp.Settings.getString("map_file", "");
      if (mapFile.equals(info.archiveFile)) {
        titleTextView.setTypeface(null, Typeface.BOLD);
        view.setBackgroundColor(Color.parseColor("#590E0E"));
      } else {
        titleTextView.setTypeface(null, Typeface.NORMAL);
        view.setBackgroundColor(Color.BLACK);
      }

      titleTextView.setText(titleText);
      stateTextView.setText(stateText);

      if (info.localModified) {
        downloadButton.setVisibility(View.GONE);
        uploadButton.setVisibility(View.VISIBLE);
        downTextView.setText("Version is modified. Upload?");
      } else if (info.serverVersion > info.localVersion) {
        downloadButton.setVisibility(View.VISIBLE);
        uploadButton.setVisibility(View.GONE);
        String downText =
            String.format(Locale.ENGLISH, "Version available: %d", info.serverVersion);
        downTextView.setText(downText);
      } else {
        downloadButton.setVisibility(View.INVISIBLE);
        uploadButton.setVisibility(View.GONE);
        downTextView.setText("Version is up to date");
      }

      downloadButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              startDownload(position);
            }
          });

      uploadButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              startUpload(position);
            }
          });

      return view;
    }