/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* Vibrator vib = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); vib.vibrate(500); */ setContentView(R.layout.main); startService(new Intent(this, SystemSens.class)); DecimalFormat df = new DecimalFormat(); df.setMaximumFractionDigits(1); mValText = (TextView) findViewById(R.id.Value); mValText.setText( "Scroll to set battery goal within next " + df.format(Status.getLevel() / 6) + " hours."); mStatusText = (TextView) findViewById(R.id.Status); // mOkButton = (Button) findViewById(R.id.Ok); // mOkButton.setOnClickListener(mOkListener); mSubmitButton = (Button) findViewById(R.id.Submit); mSubmitButton.setOnClickListener(mSubmitListener); if (!mIsBound) bindService( new Intent(IPowerMonitor.class.getName()), mSystemSensConnection, Context.BIND_AUTO_CREATE); /* mSeekBar = (SeekBar) findViewById(R.id.SeekBar); if (Status.isPlugged()) { mValText.setText("Set battery goal after charging."); mSubmitButton.setEnabled(true); mSeekBar.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } } ); } else { mSeekBar.setOnSeekBarChangeListener(mSBListener); } mSeekBar.setOnSeekBarChangeListener(mSBListener); */ }
private void readStatus() { mStatusText.setText(Status.getString()); double curDeadline = Status.getDeadline(); if (Double.isNaN(curDeadline)) { Log.i(TAG, "curDeadline is NaN"); curDeadline = 0.0D; } Log.i(TAG, "curLevel is " + Status.getLevel()); mDeadline = (int) curDeadline; Log.i(TAG, "curDeadline is " + mDeadline); // mSeekBar.setMax(1440); mSeekBar = (SeekBar) findViewById(R.id.SeekBar); int maxTime = (int) Status.getLevel(); mSeekBar.setMax(maxTime); mSeekBar.setProgress(mDeadline); if (Status.isPlugged()) { mValText.setText("Set battery goal after charging."); mSubmitButton.setEnabled(true); mSeekBar.setOnTouchListener( new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); } else { mSeekBar.setOnSeekBarChangeListener(mSBListener); } /* mSeekBar.setOnSeekBarChangeListener(mSBListener); */ mChanged = false; }