Added stopwatch and countdown bars.

Change-Id: I Id0bd62aa9e2f6e19a3723e70a9cc8d153457c859
This commit is contained in:
Andrzej J.R. Hunt 2012-07-26 11:26:32 +02:00 committed by Michael Meeks
parent 847f98033c
commit 0eb5d4014a
3 changed files with 85 additions and 1 deletions

View file

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/clockbar_countdownbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#DD4D4D4D"
android:gravity="left|top"
android:orientation="horizontal" >
<EditText
android:id="@+id/clockbar_countdown_time"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="time" >
</EditText>
<Button
android:id="@+id/clockbar_countdown_button"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Test" />
</LinearLayout>

View file

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/clockbar_stopwatchbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#DD4D4D4D"
android:gravity="left|top"
android:orientation="horizontal" >
<Button
android:id="@+id/clockbar_stopwatch_run"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Test" />
<Button
android:id="@+id/clockbar_stopwatch_reset"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Test" />
</LinearLayout>

View file

@ -20,6 +20,8 @@ import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ToggleButton;
@ -116,6 +118,16 @@ public class PresentationActivity extends Activity {
private ToggleButton mClockBar_stopwatchButton;
private ToggleButton mClockBar_countdownButton;
// ------- STOPWATCH BAR
private View mStopwatchBar;
private Button mStopwatchButtonRun;
private Button mStopwatchButtonReset;
// ------- COUNTDOWN BAR
private View mCountdownBar;
private EditText mCountdownEntry;
private Button mCountdownButton;
private String aTimeFormat = getResources().getString(
R.string.actionbar_timeformat);
private String aTimerFormat = getResources().getString(
@ -156,6 +168,7 @@ public class PresentationActivity extends Activity {
}
private void setupClockBar() {
// ClockBar
LayoutInflater aInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
aInflater.inflate(R.layout.presentation_clockbar, mLayout);
mClockBar = mLayout.findViewById(R.id.clockbar);
@ -171,18 +184,39 @@ public class PresentationActivity extends Activity {
mClockBar_stopwatchButton.setOnClickListener(this);
mClockBar_countdownButton.setOnClickListener(this);
// Stopwatch bar
aInflater.inflate(R.layout.presentation_clockbar_stopwatchbar,
mLayout);
mStopwatchBar = mLayout.findViewById(R.id.clockbar_stopwatchbar);
mStopwatchBar.setVisibility(View.INVISIBLE);
// Countdown bar
aInflater.inflate(R.layout.presentation_clockbar_countdownbar,
mLayout);
mCountdownBar = mLayout.findViewById(R.id.clockbar_countdownbar);
mCountdownBar.setVisibility(View.INVISIBLE);
updateClockBar();
}
private void updateClockBar() {
// TODO: show/hide the sub bar
mClockBar_clockButton.setChecked(!mTimerOn);
mCountdownBar.setY(mClockBar.getHeight());
mStopwatchBar.setY(mClockBar.getHeight());
boolean aIsCountdown = mCommunicationService.getSlideShow()
.getTimer().isCountdown();
// Stopwatch
mClockBar_stopwatchButton.setChecked(mTimerOn && !aIsCountdown);
mStopwatchBar.setVisibility(mTimerOn && !aIsCountdown ? View.VISIBLE
: View.INVISIBLE);
// Countdown
mClockBar_countdownButton.setChecked(mTimerOn && aIsCountdown);
mCountdownBar.setVisibility(mTimerOn && aIsCountdown ? View.VISIBLE
: View.INVISIBLE);
}
private Handler timerHandler = new Handler();