@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
  @Override
  protected void onBindView(View view) {
    super.onBindView(view);

    View checkableView = view.findViewById(R.id.switchWidget);
    if (checkableView != null && checkableView instanceof Checkable) {
      ((Checkable) checkableView).setChecked(mChecked);
      if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        if (checkableView instanceof Switch) {
          final Switch switchView = (Switch) checkableView;
          switchView.setTextOn(mSwitchOn);
          switchView.setTextOff(mSwitchOff);
          switchView.setOnCheckedChangeListener(mListener);
        }
      } else {
        if (checkableView instanceof android.widget.Switch) {
          final android.widget.Switch switchView = (android.widget.Switch) checkableView;
          switchView.setTextOn(mSwitchOn);
          switchView.setTextOff(mSwitchOff);
          switchView.setOnCheckedChangeListener(mListener);
        }
      }
    }

    syncSummaryView(view);
  }
Exemplo n.º 2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // the alarm is the thing that triggers monitor execution
    createMonitorAlarm();

    // bind to monitoring service
    monitoringServiceConnector = new MonitoringServiceConnector(this);
    monitoringServiceConnector.bind(
        new MonitoringServiceConnector.RunPostBind() {
          @Override
          public void onPostBind(MonitoringService monitoringService) {
            onCreateAfterServiceBind(monitoringService);
          }
        });

    // create inflater and UI handler
    mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    uiHandler = new Handler();

    Button clearButton = (Button) findViewById(R.id.clearButton);
    clearButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            monitoringService.clearData();
          }
        });
    clearButton.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
            monitoringService.toggleTestMode();
            return true;
          }
        });

    Switch killSwitch = (Switch) findViewById(R.id.monitorsEnabled);
    killSwitch.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            monitoringService.setMonitorsEnabled(isChecked);
          }
        });
  }
Exemplo n.º 3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    // Open app in fullscreen mode
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_main);

    noteLayout = (RelativeLayout) findViewById(R.id.notePanel);

    canvasView = new CanvasView(this);
    switchy = new Switch(this);
    switchy = (Switch) findViewById(R.id.switch1);
    switchy.setOnCheckedChangeListener(this);

    inkRegion = new ArrayList<InkRegion>();
    inkRegion.add(new InkRegion(this, 0));
    inkRegion.add(new InkRegion(this, 1));
    inkRegion.get(0).setBackgroundColor(Color.YELLOW);
    inkRegion.get(1).setBackgroundColor(Color.CYAN);

    // noteLayout.addView(canvasView);
    noteLayout.addView(canvasView);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(200, 200);
    params.leftMargin = 300;
    params.topMargin = 200;
    inkRegion.get(0).setBackgroundColor(Color.GREEN);
    inkRegion.get(0).setPivotX(0);
    inkRegion.get(0).setPivotY(0);
    inkRegion.get(0).setRotation(45);
    inkRegion.get(0).setScaleX((float) 0.2);
    inkRegion.get(0).setScaleY((float) 0.3);
    noteLayout.addView(inkRegion.get(0), params);

    RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams(200, 200);
    params1.leftMargin = 300;
    params1.topMargin = 200;
    inkRegion.get(1).setBackgroundColor(Color.BLUE);
    inkRegion.get(1).setPivotX(0);
    inkRegion.get(1).setPivotY(0);
    inkRegion.get(1).setRotation(90);
    inkRegion.get(1).setScaleX((float) 0.2);
    inkRegion.get(1).setScaleY((float) 0.2);
    noteLayout.addView(inkRegion.get(1), params1);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    setContentView(R.layout.activity_upload_matrix);

    super.onCreate(savedInstanceState);

    activity = this;

    mtxDAO = new LedMatrixDAO(this);

    final Intent intent = getIntent();
    currMatrix = intent.getParcelableExtra(EXTRAS_LED_MATRIX);
    if (currMatrix == null) {
      currMatrix = mtxDAO.getDummyLedMatrix();
    }

    GridLayout grid = (GridLayout) findViewById(R.id.gridLayout);
    String ledColorsStr = currMatrix.getMatrix();
    if (ledColorsStr == null) {
      ledColorsStr = LedMatrixDAO.MTX_BLANK;
    }

    assert (ledColorsStr.length() == MATRIX_NN);

    DisplayMetrics displaymetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    int btnWidth = (displaymetrics.widthPixels - 50) / MATRIX_N - 4;
    Log.v(TAG, "btnWidth = " + btnWidth);

    char _c;
    int _ci;
    LedButton btn;
    for (int i = 0; i < MATRIX_NN; i++) {
      _c = ledColorsStr.charAt(i);
      _ci = Integer.valueOf("" + _c);

      ledColors.add(_ci);

      btn = new LedButton(this);
      btn.setColorIndex(_ci);
      ledButtons.add(btn);

      btn.setMinimumWidth(btnWidth);
      btn.setMinimumHeight(btnWidth);
      btn.setMaxWidth(btnWidth);
      btn.setMaxHeight(btnWidth);

      btn.setOnClickListener(onLedBtnClickListener);
      btn.setOnLongClickListener(onLedBtnLongClickListener);

      grid.addView(btn);
    }

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

    switchDraw = (Switch) findViewById(R.id.switchDraw);
    switchDraw.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {

          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            updateMatrixInfo(currMatrix);
            if (isChecked) {
              drawMode = true;
              sendMessage("B:" + currMatrix.getMatrix() + "\n");
            } else {
              drawMode = false;
            }
          }
        });

    returnText = (TextView) findViewById(R.id.textReturn);

    buttonSave = (Button) findViewById(R.id.saveButton);
    buttonDelete = (Button) findViewById(R.id.deleteButton);
    buttonSend = (Button) findViewById(R.id.sendButton);

    buttonSave.setOnClickListener(onClickListener);
    buttonDelete.setOnClickListener(onClickListener);
    buttonSend.setOnClickListener(onClickListener);

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

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

    getActionBar().setTitle(getString(R.string.title_image) + ":" + currMatrix.getName());
    getActionBar().setDisplayHomeAsUpEnabled(true);

    Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
    bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);

    toastMessage(getString(R.string.opt_info));
  }