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 @@
<string name="button_cancel">Cancel</string>
<string name="button_save">Save</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_connection_failed_title">Connection failed</string>
......
......@@ -16,14 +16,13 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import android.view.View;
import android.widget.TimePicker;
import com.actionbarsherlock.app.SherlockDialogFragment;
import org.libreoffice.impressremote.R;
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";
private static final boolean IS_24_HOUR_VIEW = true;
......@@ -61,10 +60,7 @@ public class TimerEditingDialog extends SherlockDialogFragment implements TimePi
aDialog.setTitle(R.string.title_timer);
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_reset), this);
aDialog.setOnShowListener(this);
aDialog.setButton(DialogInterface.BUTTON_NEUTRAL, getString(R.string.button_remove), this);
return aDialog;
}
......@@ -90,27 +86,19 @@ public class TimerEditingDialog extends SherlockDialogFragment implements TimePi
public void onClick(DialogInterface aDialogInterface, int aButtonId) {
getTimePickerDialog().onClick(aDialogInterface, aButtonId);
switch (aButtonId) {
case DialogInterface.BUTTON_NEGATIVE:
resumeTimer();
break;
case DialogInterface.BUTTON_POSITIVE:
changeTimer();
break;
default:
break;
if (aButtonId == DialogInterface.BUTTON_NEUTRAL) {
resetTime();
}
changeTimer();
}
private TimePickerDialog getTimePickerDialog() {
return (TimePickerDialog) getDialog();
}
private void resumeTimer() {
Intent aIntent = Intents.buildTimerResumedIntent();
LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(aIntent);
private void resetTime() {
mMinutes = 0;
}
private void changeTimer() {
......@@ -119,27 +107,15 @@ public class TimerEditingDialog extends SherlockDialogFragment implements TimePi
}
@Override
public void onShow(DialogInterface dialogInterface) {
setUpNeutralButton();
}
private void setUpNeutralButton() {
TimePickerDialog aDialog = (TimePickerDialog) getDialog();
public void onCancel(DialogInterface dialog) {
super.onCancel(dialog);
aDialog.getButton(DialogInterface.BUTTON_NEUTRAL).setOnClickListener(this);
resumeTimer();
}
@Override
public void onClick(View aView) {
// Requires the additional listener to not close the dialog.
resetTime();
}
private void resetTime() {
TimePickerDialog aDialog = (TimePickerDialog) getDialog();
aDialog.updateTime(0, 0);
private void resumeTimer() {
Intent aIntent = Intents.buildTimerResumedIntent();
LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(aIntent);
}
}
......
......@@ -44,7 +44,6 @@ public class TimerSettingDialog extends SherlockDialogFragment implements TimePi
aDialog.setTitle(R.string.title_timer);
aDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.button_start), this);
aDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.button_cancel), this);
return aDialog;
}
......@@ -62,10 +61,6 @@ public class TimerSettingDialog extends SherlockDialogFragment implements TimePi
public void onClick(DialogInterface aDialogInterface, int aButtonId) {
getTimePickerDialog().onClick(aDialogInterface, aButtonId);
if (aButtonId != DialogInterface.BUTTON_POSITIVE) {
return;
}
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