diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..3e6a508 --- /dev/null +++ b/.clang-format @@ -0,0 +1,26 @@ +--- +Language: Java +AccessModifierOffset: -4 +AllowShortBlocksOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +# class, constructor, method should be next line +BreakBeforeBraces: Linux +# Keep '=' at end of line when wrapping, but move things like '&&', '||' to beginning of newline +BreakBeforeBinaryOperators: NonAssignment +# FIXME: break for brace after synchronized block, anonymous class declarations +BreakAfterJavaFieldAnnotations: true +ColumnLimit: 120 +IndentCaseLabels: true +IndentWidth: 4 +MaxEmptyLinesToKeep: 1 +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpacesInParentheses: false +TabWidth: 4 +UseTab: ForContinuationAndIndentation +SpaceAfterCStyleCast: true +# Spaces inside {} for array literals, i.e. "new Object[] { args }" +Cpp11BracedListStyle: false +ReflowComments: false diff --git a/src/yy/tidialogs/BaseDialogProxy.java b/src/yy/tidialogs/BaseDialogProxy.java new file mode 100644 index 0000000..e37a84f --- /dev/null +++ b/src/yy/tidialogs/BaseDialogProxy.java @@ -0,0 +1,36 @@ +package yy.tidialogs; + +import org.appcelerator.kroll.KrollDict; +import org.appcelerator.kroll.annotations.Kroll; +import org.appcelerator.titanium.proxy.TiViewProxy; +import org.appcelerator.titanium.util.TiUIHelper; + +@Kroll.proxy +public abstract class BaseDialogProxy extends TiViewProxy +{ + + public BaseDialogProxy() + { + super(); + } + + @Override + protected void handleShow(KrollDict options) + { + super.handleShow(options); + // If there's a lock on the UI message queue, there's a good chance + // we're in the middle of activity stack transitions. An alert + // dialog should occur above the "topmost" activity, so if activity + // stack transitions are occurring, try to give them a chance to + // "settle" + // before determining which Activity should be the context for the + // AlertDialog. + TiUIHelper.runUiDelayedIfBlock(new Runnable() { + @Override + public void run() + { + getOrCreateView().show(); + } + }); + } +} diff --git a/src/yy/tidialogs/BaseUIDialog.java b/src/yy/tidialogs/BaseUIDialog.java new file mode 100644 index 0000000..86ca0e7 --- /dev/null +++ b/src/yy/tidialogs/BaseUIDialog.java @@ -0,0 +1,63 @@ +package yy.tidialogs; + +import android.app.AlertDialog; + +import org.appcelerator.kroll.KrollDict; +import org.appcelerator.titanium.proxy.TiViewProxy; +import org.appcelerator.titanium.view.TiUIView; + +import android.content.DialogInterface; +import android.content.DialogInterface.OnDismissListener; + +import java.util.concurrent.atomic.AtomicInteger; + +public abstract class BaseUIDialog extends TiUIView +{ + protected AlertDialog dialog; + + private AtomicInteger dismissCallCount = new AtomicInteger(0); + protected OnDismissListener dismissListener; + + public BaseUIDialog(TiViewProxy proxy) + { + super(proxy); + dismissListener = new OnDismissListener() { + @Override + public void onDismiss(DialogInterface dialog) + { + if (dismissCallCount.get() == 0) { + dismissCallCount.incrementAndGet(); + KrollDict data = new KrollDict(); + data.put("cancel", true); + data.put("value", null); + fireEvent("cancel", data); + } + } + }; + } + + abstract protected AlertDialog getDialog(); + + @Override + public void show() + { + getDialog().show(); + } + + @Override + public void hide() + { + if (dialog != null) { + dialog.hide(); + } + } + + @Override + public void release() + { + if (dialog != null) { + dialog.dismiss(); + dialog = null; + } + } +} diff --git a/src/yy/tidialogs/DatePickerProxy.java b/src/yy/tidialogs/DatePickerProxy.java index 41d6521..be9e5f0 100644 --- a/src/yy/tidialogs/DatePickerProxy.java +++ b/src/yy/tidialogs/DatePickerProxy.java @@ -5,78 +5,102 @@ import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.annotations.Kroll; +import org.appcelerator.titanium.TiApplication; +import org.appcelerator.titanium.TiC; import org.appcelerator.titanium.proxy.TiViewProxy; -import org.appcelerator.titanium.util.TiUIHelper; import org.appcelerator.titanium.view.TiUIView; import android.R; import android.app.Activity; import android.app.DatePickerDialog; +import android.app.DatePickerDialog.OnDateSetListener; import android.content.DialogInterface; +import android.os.Build; import android.widget.DatePicker; +import ti.modules.titanium.ui.widget.picker.TiDatePickerDialog; + @Kroll.proxy(creatableInModule = TidialogsModule.class) -public class DatePickerProxy extends TiViewProxy { - private class BasicDatePicker extends TiUIView { +public class DatePickerProxy extends BaseDialogProxy +{ + private class BasicDatePicker extends BaseUIDialog + { private int year; private int month; private int day; + private Date maxDate; + private Date minDate; + private String okButtonTitle; private String cancelButtonTitle; - public BasicDatePicker(TiViewProxy proxy) { + public BasicDatePicker(TiViewProxy proxy) + { super(proxy); - } - private DatePickerDialog getDialog() { - DatePickerDialog picker = new DatePickerDialog(this.proxy.getActivity(), - new DatePickerDialog.OnDateSetListener() { - // when dialog box is closed, below method will be - // called. - public void onDateSet(DatePicker view, - int selectedYear, int selectedMonth, - int selectedDay) { - year = selectedYear; - month = selectedMonth; - day = selectedDay; - - KrollDict data = new KrollDict(); - - Calendar calendar = Calendar.getInstance(); - calendar.set(Calendar.YEAR, year); - calendar.set(Calendar.MONTH, month); - calendar.set(Calendar.DAY_OF_MONTH, day); - Date value = calendar.getTime(); - - data.put("value", value); - data.put("year", year); - data.put("month", month); - data.put("day", day); - fireEvent("click", data); - - } - }, year, month, day); - picker.setCanceledOnTouchOutside(false); + protected DatePickerDialog getDialog() + { + if (dialog != null) { + return (DatePickerDialog) dialog; + } + OnDateSetListener dateSetListener = new OnDateSetListener() { + // when dialog box is closed, below method will be + // called. + public void onDateSet(DatePicker view, int selectedYear, int selectedMonth, int selectedDay) + { + year = selectedYear; + month = selectedMonth; + day = selectedDay; + + KrollDict data = new KrollDict(); + + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.YEAR, year); + calendar.set(Calendar.MONTH, month); + calendar.set(Calendar.DAY_OF_MONTH, day); + Date value = calendar.getTime(); + + data.put("value", value); + data.put("year", year); + data.put("month", month); + data.put("day", day); + fireEvent("click", data); + } + }; + DatePickerDialog picker; - picker.setButton(DialogInterface.BUTTON_POSITIVE, okButtonTitle, picker); + if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) + && (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)) { + picker = + new TiDatePickerDialog(TiApplication.getAppCurrentActivity(), dateSetListener, year, month, day); + } else { + picker = new DatePickerDialog(TiApplication.getAppCurrentActivity(), dateSetListener, year, month, day); + } + + if (minDate != null) { + picker.getDatePicker().setMinDate(trimDate(minDate).getTime()); + } + + if (maxDate != null) { + picker.getDatePicker().setMaxDate(trimDate(maxDate).getTime()); + } + + picker.setOnDismissListener(dismissListener); - picker.setButton(DialogInterface.BUTTON_NEGATIVE, cancelButtonTitle, - new DialogInterface.OnClickListener() { + picker.setCanceledOnTouchOutside(false); - @Override - public void onClick(DialogInterface dialog, int which) { - fireEvent("cancel", new KrollDict()); - } - }); + picker.setButton(DialogInterface.BUTTON_POSITIVE, okButtonTitle, picker); + dialog = picker; return picker; } @Override - public void processProperties(KrollDict d) { + public void processProperties(KrollDict d) + { super.processProperties(d); Calendar c = Calendar.getInstance(); if (d.containsKey("value")) { @@ -102,47 +126,58 @@ public void processProperties(KrollDict d) { } } + if (d.containsKey(TiC.PROPERTY_MIN_DATE)) { + minDate = (Date) d.get(TiC.PROPERTY_MIN_DATE); + } + if (d.containsKey(TiC.PROPERTY_MAX_DATE)) { + maxDate = (Date) d.get(TiC.PROPERTY_MAX_DATE); + } + if (d.containsKey("okButtonTitle")) { okButtonTitle = d.getString("okButtonTitle"); } else { - okButtonTitle = this.proxy.getActivity().getApplication().getResources().getString(R.string.ok); + okButtonTitle = + TiApplication.getAppCurrentActivity().getApplication().getResources().getString(R.string.ok); } if (d.containsKey("cancelButtonTitle")) { cancelButtonTitle = d.getString("cancelButtonTitle"); } else { - cancelButtonTitle = this.proxy.getActivity().getApplication().getResources().getString(R.string.cancel); + cancelButtonTitle = + TiApplication.getAppCurrentActivity().getApplication().getResources().getString(R.string.cancel); } } - - public void show() { - getDialog().show(); - } - } - public DatePickerProxy() { + public DatePickerProxy() + { super(); } @Override - public TiUIView createView(Activity activity) { + public TiUIView createView(Activity activity) + { return new BasicDatePicker(this); } @Override - public void handleCreationDict(KrollDict options) { + public void handleCreationDict(KrollDict options) + { super.handleCreationDict(options); } - @Override - protected void handleShow(KrollDict options) { - super.handleShow(options); - TiUIHelper.runUiDelayedIfBlock(new Runnable() { - @Override - public void run() { - BasicDatePicker d = (BasicDatePicker) getOrCreateView(); - d.show(); - } - }); + /** + * Trim hour, minute, second and millisecond from the date + * @param inDate input date + * @return return the trimmed date + */ + public static Date trimDate(Date inDate) + { + Calendar cal = Calendar.getInstance(); + cal.setTime(inDate); + cal.set(Calendar.HOUR_OF_DAY, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + return cal.getTime(); } } \ No newline at end of file diff --git a/src/yy/tidialogs/MultiPickerProxy.java b/src/yy/tidialogs/MultiPickerProxy.java index 996804c..eabc2f7 100644 --- a/src/yy/tidialogs/MultiPickerProxy.java +++ b/src/yy/tidialogs/MultiPickerProxy.java @@ -8,49 +8,59 @@ import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.KrollFunction; import org.appcelerator.kroll.annotations.Kroll; -import org.appcelerator.titanium.TiBlob; +import org.appcelerator.titanium.TiApplication; import org.appcelerator.titanium.TiC; -import org.appcelerator.titanium.io.TiBaseFile; -import org.appcelerator.titanium.io.TiFileFactory; import org.appcelerator.titanium.proxy.TiViewProxy; import org.appcelerator.titanium.util.TiUIHelper; -import org.appcelerator.titanium.view.TiDrawableReference; import org.appcelerator.titanium.view.TiUIView; import org.appcelerator.kroll.common.Log; - import android.R; import android.app.Activity; import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.content.DialogInterface; -import android.graphics.Bitmap; import android.graphics.drawable.Drawable; - - @Kroll.proxy(creatableInModule = TidialogsModule.class) -public class MultiPickerProxy extends TiViewProxy { +public class MultiPickerProxy extends BaseDialogProxy +{ private static final String LCAT = "TiDialogs"; private KrollFunction onChange; - private class MultiPicker extends TiUIView { + private class MultiPicker extends BaseUIDialog + { Builder builder; - public MultiPicker(TiViewProxy proxy) { + public MultiPicker(TiViewProxy proxy) + { super(proxy); } - private Builder getBuilder() { + @Override + protected AlertDialog getDialog() + { + if (dialog != null) { + return dialog; + } + dialog = getBuilder().create(); + dialog.setOnDismissListener(dismissListener); + builder = null; + return dialog; + } + + private Builder getBuilder() + { if (builder == null) { - builder = new AlertDialog.Builder(this.proxy.getActivity()); + builder = new AlertDialog.Builder(TiApplication.getAppCurrentActivity()); builder.setCancelable(true); } return builder; } @Override - public void processProperties(KrollDict properties) { + public void processProperties(KrollDict properties) + { super.processProperties(properties); String okButtonTitle; String cancelButtonTitle; @@ -69,29 +79,28 @@ public void processProperties(KrollDict properties) { getBuilder().setMessage(properties.getString("message")); } if (properties.containsKeyAndNotNull("icon")) { - Drawable icon = TiUIHelper.getResourceDrawable(resolveUrl(null, - properties.getString("icon"))); + Drawable icon = TiUIHelper.getResourceDrawable(resolveUrl(null, properties.getString("icon"))); getBuilder().setIcon(icon); } if (properties.containsKeyAndNotNull(TiC.PROPERTY_ANDROID_VIEW)) { Object o = properties.get(TiC.PROPERTY_ANDROID_VIEW); if (o instanceof TiUIView) { - TiUIView view = (TiUIView)o; + TiUIView view = (TiUIView) o; getBuilder().setCustomTitle(view.getNativeView()); } } if (properties.containsKey("okButtonTitle")) { okButtonTitle = properties.getString("okButtonTitle"); } else { - okButtonTitle = this.proxy.getActivity().getApplication() - .getResources().getString(R.string.ok); + okButtonTitle = + TiApplication.getAppCurrentActivity().getApplication().getResources().getString(R.string.ok); } if (properties.containsKeyAndNotNull("cancelButtonTitle")) { cancelButtonTitle = properties.getString("cancelButtonTitle"); } else { - cancelButtonTitle = this.proxy.getActivity().getApplication() - .getResources().getString(R.string.cancel); + cancelButtonTitle = + TiApplication.getAppCurrentActivity().getApplication().getResources().getString(R.string.cancel); } if (properties.containsKeyAndNotNull("canCancel")) { @@ -113,132 +122,87 @@ public void processProperties(KrollDict properties) { // are there any preselections? if (properties.containsKeyAndNotNull("selected")) { - List s = Arrays.asList(properties - .getStringArray("selected")); + List s = Arrays.asList(properties.getStringArray("selected")); for (int i = 0; i < options.length; i++) { checked[i] = s.contains(options[i]); if (checked[i] == true) { resultList[i] = Boolean.TRUE; selectedItems.add(i); // keep info about - // preselected items! + // preselected items! } } } - getBuilder().setMultiChoiceItems(options, checked, - new DialogInterface.OnMultiChoiceClickListener() { - // called whenever an item is clicked, toggles - // selection info - @Override - public void onClick(DialogInterface dialog, - int which, boolean isChecked) { - resultList[which] = isChecked; - Log.d(LCAT, resultList.toString()); - KrollDict kd = new KrollDict(); - kd.put("index", which); - kd.put("checked", isChecked); - kd.put("value", isChecked); - if (hasListeners("change")) { - fireEvent("change", kd); - } - if (onChange != null) - onChange.call(getKrollObject(), kd); - if (isChecked) { - // we can be sure, item is not already in - // selection list - selectedItems.add(which); - - } else if (selectedItems.contains(which)) { - selectedItems.remove(Integer.valueOf(which)); - } + getBuilder() + .setMultiChoiceItems(options, checked, + new DialogInterface.OnMultiChoiceClickListener() { + // called whenever an item is clicked, toggles + // selection info + @Override + public void onClick(DialogInterface dialog, int which, boolean isChecked) + { + resultList[which] = isChecked; + Log.d(LCAT, resultList.toString()); + KrollDict kd = new KrollDict(); + kd.put("index", which); + kd.put("checked", isChecked); + kd.put("value", isChecked); + if (hasListeners("change")) { + fireEvent("change", kd); + } + if (onChange != null) + onChange.call(getKrollObject(), kd); + if (isChecked) { + // we can be sure, item is not already in + // selection list + selectedItems.add(which); + + } else if (selectedItems.contains(which)) { + selectedItems.remove(Integer.valueOf(which)); + } + } + }) + + // ok returns indexes of selected items and the corresponding + // selected items -> wording is not the best + .setPositiveButton(okButtonTitle, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int id) + { + // convert to int array + + ArrayList selections = new ArrayList(); + for (Integer s : selectedItems) { + selections.add(options[s]); } - }) - - // ok returns indexes of selected items and the corresponding - // selected items -> wording is not the best - .setPositiveButton(okButtonTitle, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, - int id) { - // convert to int array - - ArrayList selections = new ArrayList(); - for (Integer s : selectedItems) { - selections.add(options[s]); - } - - KrollDict data = new KrollDict(); - data.put( - "indexes", - selectedItems - .toArray(new Integer[selectedItems - .size()])); - data.put("selections", selections - .toArray(new String[selections - .size()])); - data.put("result", resultList); - if (hasListeners("click")) - fireEvent("click", data); - } - }); - - if (cancellable == true) { - - // cancel returns nothing - getBuilder().setNegativeButton(cancelButtonTitle, - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, - int id) { - fireEvent("cancel", new KrollDict()); - } - }); - } else { - getBuilder().setCancelable(false); - } - } - } + KrollDict data = new KrollDict(); + data.put("indexes", selectedItems.toArray(new Integer[selectedItems.size()])); + data.put("selections", selections.toArray(new String[selections.size()])); + data.put("result", resultList); + if (hasListeners("click")) + fireEvent("click", data); + } + }); - public void show() { - getBuilder().create().show(); - builder = null; - Log.d(LCAT, "show Dialog"); + getBuilder().setCancelable(cancellable); + } } - } - public MultiPickerProxy() { + public MultiPickerProxy() + { super(); } @Override - public TiUIView createView(Activity activity) { + public TiUIView createView(Activity activity) + { return new MultiPicker(this); } @Override - public void handleCreationDict(KrollDict options) { + public void handleCreationDict(KrollDict options) + { super.handleCreationDict(options); } - - @Override - protected void handleShow(KrollDict options) { - super.handleShow(options); - // If there's a lock on the UI message queue, there's a good chance - // we're in the middle of activity stack transitions. An alert - // dialog should occur above the "topmost" activity, so if activity - // stack transitions are occurring, try to give them a chance to - // "settle" - // before determining which Activity should be the context for the - // AlertDialog. - TiUIHelper.runUiDelayedIfBlock(new Runnable() { - @Override - public void run() { - MultiPicker d = (MultiPicker) getOrCreateView(); - d.show(); - } - }); - } - } diff --git a/src/yy/tidialogs/TidialogsModule.java b/src/yy/tidialogs/TidialogsModule.java index 0d19134..ed34f81 100644 --- a/src/yy/tidialogs/TidialogsModule.java +++ b/src/yy/tidialogs/TidialogsModule.java @@ -5,10 +5,10 @@ import org.appcelerator.titanium.TiApplication; -@Kroll.module(name="Tidialogs", id="yy.tidialogs") +@Kroll.module(name = "Tidialogs", id = "yy.tidialogs") public class TidialogsModule extends KrollModule { - + public TidialogsModule() { super(); @@ -17,7 +17,5 @@ public TidialogsModule() @Kroll.onAppCreate public static void onAppCreate(TiApplication app) { - } } - diff --git a/src/yy/tidialogs/TimePickerProxy.java b/src/yy/tidialogs/TimePickerProxy.java index 2085db6..8bdd2e4 100644 --- a/src/yy/tidialogs/TimePickerProxy.java +++ b/src/yy/tidialogs/TimePickerProxy.java @@ -5,8 +5,9 @@ import org.appcelerator.kroll.KrollDict; import org.appcelerator.kroll.annotations.Kroll; +import org.appcelerator.titanium.TiApplication; import org.appcelerator.titanium.proxy.TiViewProxy; -import org.appcelerator.titanium.util.TiUIHelper; +import org.appcelerator.titanium.util.TiConvert; import org.appcelerator.titanium.view.TiUIView; import android.R; @@ -14,69 +15,84 @@ import android.app.TimePickerDialog; import android.content.DialogInterface; import android.text.format.DateFormat; +import android.os.Build; import android.widget.TimePicker; +import ti.modules.titanium.ui.widget.picker.TiTimePickerDialog; + @Kroll.proxy(creatableInModule = TidialogsModule.class) -public class TimePickerProxy extends TiViewProxy { - private class BasicDatePicker extends TiUIView { +public class TimePickerProxy extends BaseDialogProxy +{ + private class BasicTimePicker extends BaseUIDialog + { private int hour; private int minute; + private boolean is24HourView; private String okButtonTitle; private String cancelButtonTitle; - public BasicDatePicker(TiViewProxy proxy) { + public BasicTimePicker(TiViewProxy proxy) + { super(proxy); - } - private TimePickerDialog getDialog() { - TimePickerDialog picker = new TimePickerDialog(this.proxy.getActivity(), - new TimePickerDialog.OnTimeSetListener() { + protected TimePickerDialog getDialog() + { + if (dialog != null) { + return (TimePickerDialog) dialog; + } + TimePickerDialog.OnTimeSetListener timeSetListener = new TimePickerDialog.OnTimeSetListener() { - @Override - public void onTimeSet(TimePicker selectedTime, - int selectedHour, int selectedMinute) { - // TODO Auto-generated method stub + @Override + public void onTimeSet(TimePicker selectedTime, int selectedHour, int selectedMinute) + { + // TODO Auto-generated method stub - hour = selectedHour; - minute = selectedMinute; + hour = selectedHour; + minute = selectedMinute; - KrollDict data = new KrollDict(); + KrollDict data = new KrollDict(); - Calendar calendar = Calendar.getInstance(); - calendar.set(Calendar.HOUR_OF_DAY, hour); - calendar.set(Calendar.MINUTE, minute); - Date value = calendar.getTime(); + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.HOUR_OF_DAY, hour); + calendar.set(Calendar.MINUTE, minute); + Date value = calendar.getTime(); - data.put("value", value); - data.put("hour", hour); - data.put("minute", minute); - fireEvent("click", data); + data.put("value", value); + data.put("hour", hour); + data.put("minute", minute); + fireEvent("click", data); + } + }; - } - }, hour, minute, DateFormat.is24HourFormat(this.proxy - .getActivity())); + // TimePickerDialog has a bug in Android 4.x + // If build version is using Android 4.x, use + // our TiTimePickerDialog. It was fixed from Android 5.0. + TimePickerDialog picker; + + Activity activity = TiApplication.getAppCurrentActivity(); + if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) + && (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)) { + picker = new TiTimePickerDialog(activity, timeSetListener, hour, minute, is24HourView); + } else { + picker = new TimePickerDialog(activity, timeSetListener, hour, minute, is24HourView); + } picker.setCanceledOnTouchOutside(false); picker.setButton(DialogInterface.BUTTON_POSITIVE, okButtonTitle, picker); - picker.setButton(DialogInterface.BUTTON_NEGATIVE, cancelButtonTitle, - new DialogInterface.OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int which) { - fireEvent("cancel", new KrollDict()); - } - }); + picker.setOnDismissListener(dismissListener); + dialog = picker; return picker; } @Override - public void processProperties(KrollDict d) { + public void processProperties(KrollDict d) + { super.processProperties(d); Calendar c = Calendar.getInstance(); @@ -97,47 +113,41 @@ public void processProperties(KrollDict d) { } } + if (d.containsKey("format24")) { + is24HourView = TiConvert.toBoolean(d, "format24"); + } else { + is24HourView = DateFormat.is24HourFormat(TiApplication.getAppCurrentActivity()); + } + if (d.containsKey("okButtonTitle")) { okButtonTitle = d.getString("okButtonTitle"); } else { - okButtonTitle = this.proxy.getActivity().getApplication().getResources().getString(R.string.ok); + okButtonTitle = + TiApplication.getAppCurrentActivity().getApplication().getResources().getString(R.string.ok); } if (d.containsKey("cancelButtonTitle")) { cancelButtonTitle = d.getString("cancelButtonTitle"); } else { - cancelButtonTitle = this.proxy.getActivity().getApplication().getResources().getString(R.string.cancel); + cancelButtonTitle = + TiApplication.getAppCurrentActivity().getApplication().getResources().getString(R.string.cancel); } } - - public void show() { - getDialog().show(); - } - } - public TimePickerProxy() { + public TimePickerProxy() + { super(); } @Override - public TiUIView createView(Activity activity) { - return new BasicDatePicker(this); + public TiUIView createView(Activity activity) + { + return new BasicTimePicker(this); } @Override - public void handleCreationDict(KrollDict options) { + public void handleCreationDict(KrollDict options) + { super.handleCreationDict(options); } - - @Override - protected void handleShow(KrollDict options) { - super.handleShow(options); - TiUIHelper.runUiDelayedIfBlock(new Runnable() { - @Override - public void run() { - BasicDatePicker d = (BasicDatePicker) getOrCreateView(); - d.show(); - } - }); - } } \ No newline at end of file