summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorOta Chasák <chasak.ota@gmail.com>2013-04-24 15:59:20 +0100
committerMichael Meeks <michael.meeks@suse.com>2013-04-24 16:44:46 +0100
commitb6ab91d55e1bfb487abba2b15589a1988178ee88 (patch)
tree6d574d388e41701f7d5e8e60fe69b755ce2c36f5 /android
parent8379fceb2e7c33e5e0555295be06fde60a6bb240 (diff)
fdo#60791 - fix android remote count-down / clock.
Diffstat (limited to 'android')
-rw-r--r--android/sdremote/Makefile2
-rw-r--r--android/sdremote/res/layout/presentation_clockbar.xml17
-rw-r--r--android/sdremote/res/values/strings.xml10
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java136
4 files changed, 97 insertions, 68 deletions
diff --git a/android/sdremote/Makefile b/android/sdremote/Makefile
index 26acfd8ae0bb..78b89eb9bc8e 100644
--- a/android/sdremote/Makefile
+++ b/android/sdremote/Makefile
@@ -13,7 +13,7 @@ endif
all: properties translations.done
mkdir -p ../abs-lib/libs
cp $(ANDROID_SDK_HOME)/extras/android/support/v4/android-support-v4.jar ../abs-lib/libs
- $(ANT) -quiet debug
+ $(ANT) debug
properties:
echo sdk.dir=$(ANDROID_SDK_HOME) >local.properties
diff --git a/android/sdremote/res/layout/presentation_clockbar.xml b/android/sdremote/res/layout/presentation_clockbar.xml
index 4d5d028f8904..98b913ccc5f6 100644
--- a/android/sdremote/res/layout/presentation_clockbar.xml
+++ b/android/sdremote/res/layout/presentation_clockbar.xml
@@ -73,15 +73,20 @@
android:background="#DD4D4D4D"
android:orientation="horizontal" >
- <EditText
- android:id="@+id/clockbar_countdown_time"
+ <AutoCompleteTextView android:id="@+id/countdown_time"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:completionThreshold="1" />
+
+ <Button
+ android:id="@+id/clockbar_countdown_reset"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight="1"
- android:ems="10"
- android:inputType="time"
- android:text="03:00" >
- </EditText>
+ android:background="#00000000"
+ android:text="@string/clock_timer_reset"
+ android:textColor="#FFFFFF" />
<Button
android:id="@+id/clockbar_countdown_button"
diff --git a/android/sdremote/res/values/strings.xml b/android/sdremote/res/values/strings.xml
index 84edffc8a3f7..3500aee5d640 100644
--- a/android/sdremote/res/values/strings.xml
+++ b/android/sdremote/res/values/strings.xml
@@ -54,5 +54,13 @@
<string name="reconnect_description1">Your connection has been dropped.</string>
<string name="reconnect_description2">Please try to reconnect</string>
<string name="wifiAlertMsg">This is still an experimental feature. You need to \"enable experimental features\" in \"Preference\"-\"LibreOffice\"-\"Advanced\" on your computer. \nThe use over Bluetooth is recommanded.</string>
-
+ <string-array name="countdown_values">
+ <item >5:00</item>
+ <item >10:00</item>
+ <item >15:00</item>
+ <item >20:00</item>
+ <item >30:00</item>
+ <item >45:00</item>
+ </string-array>
+ <string name="wrong_time_format">You have entered wrong time format</string>
</resources>
diff --git a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
index 51e590f1d3ab..ab081df7c6a1 100644
--- a/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
+++ b/android/sdremote/src/org/libreoffice/impressremote/PresentationActivity.java
@@ -23,6 +23,7 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
+import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
@@ -37,10 +38,11 @@ import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
+import android.widget.ArrayAdapter;
+import android.widget.AutoCompleteTextView;
import android.widget.Button;
-import android.widget.EditText;
import android.widget.FrameLayout;
-import android.widget.TextView;
+import android.widget.Toast;
import android.widget.ToggleButton;
import com.actionbarsherlock.app.ActionBar;
@@ -205,8 +207,7 @@ public class PresentationActivity extends SherlockFragmentActivity {
}
private class ActionBarManager implements OnClickListener,
- FragmentManager.OnBackStackChangedListener,
- TextView.OnEditorActionListener {
+ FragmentManager.OnBackStackChangedListener {
private Handler timerHandler = new Handler();
@@ -226,8 +227,12 @@ public class PresentationActivity extends SherlockFragmentActivity {
// ------- COUNTDOWN BAR
private View mCountdownBar;
- private EditText mCountdownEntry;
private Button mCountdownButton;
+ private Button mCountdownButtonReset;
+ private AutoCompleteTextView mCountDownTime;
+
+ private SharedPreferences prefs;
+ private static final String COUNTDOWN_KEY = "countdownTime";
private String aTimeFormat = getResources().getString(
R.string.actionbar_timeformat);
@@ -305,13 +310,22 @@ public class PresentationActivity extends SherlockFragmentActivity {
// Countdown bar
mCountdownBar = mOuterLayout
.findViewById(R.id.clockbar_countdownbar);
-
- mCountdownEntry = (EditText) mCountdownBar
- .findViewById(R.id.clockbar_countdown_time);
mCountdownButton = (Button) mCountdownBar
.findViewById(R.id.clockbar_countdown_button);
+ mCountdownButton.setTag(Boolean.valueOf(false));
+ mCountdownButtonReset = (Button) mCountdownBar.findViewById(R.id.clockbar_countdown_reset);
+ mCountdownButtonReset.setTag(Boolean.valueOf(false));
+
+ prefs = PreferenceManager.getDefaultSharedPreferences(mCountdownBar.getContext());
+
+ String[] entries = getResources().getStringArray(R.array.countdown_values);
+ String savedTime = prefs.getString(COUNTDOWN_KEY, entries[0]);
+ mCountDownTime = (AutoCompleteTextView) mCountdownBar.findViewById(R.id.countdown_time);
+ mCountDownTime.setAdapter(new ArrayAdapter<String>(mCountdownBar.getContext(), android.R.layout.simple_dropdown_item_1line, entries));
+ mCountDownTime.setText(savedTime);
+
mCountdownButton.setOnClickListener(this);
- mCountdownEntry.setOnEditorActionListener(this);
+ mCountdownButtonReset.setOnClickListener(this);
updateClockBar();
hidePopups();
@@ -324,23 +338,6 @@ public class PresentationActivity extends SherlockFragmentActivity {
}
mClockBar_clockButton.setChecked(!mTimerOn);
- // FrameLayout.LayoutParams aParams = (LayoutParams) mCountdownBar
- // .getLayoutParams();
- // aParams.topMargin = mClockBar.getBottom();
- // // aParams.height = mClockBar.getHeight();
- // // aParams.bottomMargin = aParams.topMargin + aParams.height;
- // // aParams.leftMargin = 100;
- // mCountdownBar.setLayoutParams(aParams);
- // mCountdownBar.setPadding(0, mClockBar.getBottom(), 0, 0);
- // mStopwatchBar.setPadding(0, mClockBar.getBottom(), 0, 0);
- // // mCountdownBar.requestLayout();
- // // mOuterLayout.requestLayout();
- // // mOuterLayout.invalidate();
- // // aParams = (LayoutParams) mStopwatchBar.getLayoutParams();
- // // aParams.topMargin = mClockBar.getHeight();
- // // mOuterLayout.invalidate();
- // // mStopwatchBar.setY(mClockBar.getHeight());
-
boolean aIsCountdown = mCommunicationService.getSlideShow()
.getTimer().isCountdown();
// Stopwatch
@@ -368,13 +365,23 @@ public class PresentationActivity extends SherlockFragmentActivity {
mCountdownBar.bringToFront();
if (aCountdownMode) {
Timer aTimer = mCommunicationService.getSlideShow().getTimer();
- if (aTimer.isRunning()) {
+ boolean resetClicked = (Boolean) mCountdownButtonReset.getTag();
+ boolean countdownButtonClicked = (Boolean) mCountdownButton.getTag();
+ if (aTimer.isRunning() && countdownButtonClicked) {//start or resume clicked
mCountdownButton.setText(R.string.clock_timer_pause);
- } else {
+ mCountdownButton.setTag(Boolean.valueOf(false));
+ }else if(resetClicked){//reset clicked
+ mCountdownButton.setText(R.string.clock_timer_start);
+ mCountdownButtonReset.setTag(Boolean.valueOf(false));
+ } else if(!aTimer.isRunning() && countdownButtonClicked){//pause clicked
mCountdownButton.setText(R.string.clock_timer_resume);
+ mCountdownButton.setTag(Boolean.valueOf(false));
+ }else if(!aTimer.isRunning()){
+ mCountdownButton.setText(R.string.clock_timer_start);
}
}
+
}
private Runnable timerUpdateRunnable = new Runnable() {
@@ -468,55 +475,64 @@ public class PresentationActivity extends SherlockFragmentActivity {
} else if (aSource == mCountdownButton) {
if (aTimer.isRunning()) {
aTimer.stopTimer();
+ mCountdownButton.setTag(Boolean.valueOf(true));
+ updateClockBar();
} else {
- aTimer.startTimer();
+ try {
+ String time = mCountDownTime.getText().toString();
+ long aTime = this.validateDate(time);
+ Editor editor = prefs.edit();
+ editor.putString(COUNTDOWN_KEY, time);
+ editor.commit();
+ aTimer.setCountdownTime(aTime);
+ aTimer.startTimer();
+ mCountdownButton.setTag(Boolean.valueOf(true));
+ updateClockBar();
+ } catch (ParseException e) {
+ Toast.makeText(mCountDownTime.getContext(), R.string.wrong_time_format, Toast.LENGTH_LONG).show();
+ }
}
+ }else if(aSource == mCountdownButtonReset){
+ aTimer.reset();
+ mCountdownButtonReset.setTag(Boolean.valueOf(true));
updateClockBar();
}
}
- @Override
- public void onBackStackChanged() {
- if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
- mThumbnailButton.setChecked(false);
+ /*
+ *
+ * @param timeText
+ * @return timeText in millis, or throws ParseException
+ * @throws ParseException - if timeText is not valid time
+ */
+ private long validateDate(String timeText) throws ParseException {
+ long aTime = 0;
+ try {
+ SimpleDateFormat aFormat = new SimpleDateFormat("HH:mm:ss");
+ aFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+ aTime = aFormat.parse(timeText).getTime();
+ } catch (ParseException e) {
+ }
+ if (aTime == 0) {
+ SimpleDateFormat aFormat = new SimpleDateFormat("mm:ss");
+ aFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+ aTime = aFormat.parse(timeText).getTime();
}
+ return aTime;
}
@Override
- public boolean onEditorAction(TextView tv, int aID, KeyEvent aEvent) {
- if (aEvent != null && aEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
-
- long aTime = 0;
- try {
- SimpleDateFormat aFormat = new SimpleDateFormat("HH:mm:ss");
- aFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
- aTime = aFormat.parse(mCountdownEntry.getText().toString())
- .getTime();
- } catch (ParseException e) {
- }
- if (aTime == 0) {
- try {
- SimpleDateFormat aFormat = new SimpleDateFormat("mm:ss");
- aFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
- aTime = aFormat.parse(
- mCountdownEntry.getText().toString())
- .getTime();
- } catch (ParseException e) {
- }
- }
- mCommunicationService.getSlideShow().getTimer()
- .setCountdownTime(aTime);
- return true;
+ public void onBackStackChanged() {
+ if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
+ mThumbnailButton.setChecked(false);
}
- return false;
}
}
- /**
+ /*
* Intermediate layout that catches all touches, used in order to hide
* the clock menu as appropriate.
- *
*/
public static class InterceptorLayout extends FrameLayout {