Kaydet (Commit) d07bb04d authored tarafından Artur Dryomov's avatar Artur Dryomov

Remove cancel buttons from timer dialogs.

The cancel button just duplicates back button on Android devices.

Change-Id: Ic0647e4e74d2009b21807467acb63184847a1e25
üst 20eb1462
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<string name="button_cancel">Cancel</string> <string name="button_cancel">Cancel</string>
<string name="button_save">Save</string> <string name="button_save">Save</string>
<string name="button_start">Start</string> <string name="button_start">Start</string>
<string name="button_reset">Reset</string> <string name="button_remove">Remove</string>
<string name="message_impress_pin_validation">Go to “Slide Show → Impress Remote” in LibreOffice Impress and enter the code.</string> <string name="message_impress_pin_validation">Go to “Slide Show → Impress Remote” in LibreOffice Impress and enter the code.</string>
<string name="message_connection_failed_title">Connection failed</string> <string name="message_connection_failed_title">Connection failed</string>
......
...@@ -16,14 +16,13 @@ import android.content.DialogInterface; ...@@ -16,14 +16,13 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager; import android.support.v4.content.LocalBroadcastManager;
import android.view.View;
import android.widget.TimePicker; import android.widget.TimePicker;
import com.actionbarsherlock.app.SherlockDialogFragment; import com.actionbarsherlock.app.SherlockDialogFragment;
import org.libreoffice.impressremote.R; import org.libreoffice.impressremote.R;
import org.libreoffice.impressremote.util.Intents; import org.libreoffice.impressremote.util.Intents;
public class TimerEditingDialog extends SherlockDialogFragment implements TimePickerDialog.OnTimeSetListener, DialogInterface.OnClickListener, DialogInterface.OnShowListener, View.OnClickListener { public class TimerEditingDialog extends SherlockDialogFragment implements TimePickerDialog.OnTimeSetListener, DialogInterface.OnClickListener {
public static final String TAG = "TIMER_EDITING"; public static final String TAG = "TIMER_EDITING";
private static final boolean IS_24_HOUR_VIEW = true; private static final boolean IS_24_HOUR_VIEW = true;
...@@ -61,10 +60,7 @@ public class TimerEditingDialog extends SherlockDialogFragment implements TimePi ...@@ -61,10 +60,7 @@ public class TimerEditingDialog extends SherlockDialogFragment implements TimePi
aDialog.setTitle(R.string.title_timer); aDialog.setTitle(R.string.title_timer);
aDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.button_save), this); aDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.button_save), this);
aDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.button_cancel), this); aDialog.setButton(DialogInterface.BUTTON_NEUTRAL, getString(R.string.button_remove), this);
aDialog.setButton(DialogInterface.BUTTON_NEUTRAL, getString(R.string.button_reset), this);
aDialog.setOnShowListener(this);
return aDialog; return aDialog;
} }
...@@ -90,27 +86,19 @@ public class TimerEditingDialog extends SherlockDialogFragment implements TimePi ...@@ -90,27 +86,19 @@ public class TimerEditingDialog extends SherlockDialogFragment implements TimePi
public void onClick(DialogInterface aDialogInterface, int aButtonId) { public void onClick(DialogInterface aDialogInterface, int aButtonId) {
getTimePickerDialog().onClick(aDialogInterface, aButtonId); getTimePickerDialog().onClick(aDialogInterface, aButtonId);
switch (aButtonId) { if (aButtonId == DialogInterface.BUTTON_NEUTRAL) {
case DialogInterface.BUTTON_NEGATIVE: resetTime();
resumeTimer();
break;
case DialogInterface.BUTTON_POSITIVE:
changeTimer();
break;
default:
break;
} }
changeTimer();
} }
private TimePickerDialog getTimePickerDialog() { private TimePickerDialog getTimePickerDialog() {
return (TimePickerDialog) getDialog(); return (TimePickerDialog) getDialog();
} }
private void resumeTimer() { private void resetTime() {
Intent aIntent = Intents.buildTimerResumedIntent(); mMinutes = 0;
LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(aIntent);
} }
private void changeTimer() { private void changeTimer() {
...@@ -119,27 +107,15 @@ public class TimerEditingDialog extends SherlockDialogFragment implements TimePi ...@@ -119,27 +107,15 @@ public class TimerEditingDialog extends SherlockDialogFragment implements TimePi
} }
@Override @Override
public void onShow(DialogInterface dialogInterface) { public void onCancel(DialogInterface dialog) {
setUpNeutralButton(); super.onCancel(dialog);
}
private void setUpNeutralButton() {
TimePickerDialog aDialog = (TimePickerDialog) getDialog();
aDialog.getButton(DialogInterface.BUTTON_NEUTRAL).setOnClickListener(this); resumeTimer();
} }
@Override private void resumeTimer() {
public void onClick(View aView) { Intent aIntent = Intents.buildTimerResumedIntent();
// Requires the additional listener to not close the dialog. LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(aIntent);
resetTime();
}
private void resetTime() {
TimePickerDialog aDialog = (TimePickerDialog) getDialog();
aDialog.updateTime(0, 0);
} }
} }
......
...@@ -44,7 +44,6 @@ public class TimerSettingDialog extends SherlockDialogFragment implements TimePi ...@@ -44,7 +44,6 @@ public class TimerSettingDialog extends SherlockDialogFragment implements TimePi
aDialog.setTitle(R.string.title_timer); aDialog.setTitle(R.string.title_timer);
aDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.button_start), this); aDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.button_start), this);
aDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.button_cancel), this);
return aDialog; return aDialog;
} }
...@@ -62,10 +61,6 @@ public class TimerSettingDialog extends SherlockDialogFragment implements TimePi ...@@ -62,10 +61,6 @@ public class TimerSettingDialog extends SherlockDialogFragment implements TimePi
public void onClick(DialogInterface aDialogInterface, int aButtonId) { public void onClick(DialogInterface aDialogInterface, int aButtonId) {
getTimePickerDialog().onClick(aDialogInterface, aButtonId); getTimePickerDialog().onClick(aDialogInterface, aButtonId);
if (aButtonId != DialogInterface.BUTTON_POSITIVE) {
return;
}
startTimer(); startTimer();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment