mirror of https://github.com/tasks/tasks
More progress on calendar picker
New and awesome date and time picker for deadlines, alarms, etc.pull/14/head
parent
1741dd34ee
commit
4cd6321fa3
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item android:state_checked="true"
|
||||
android:color="@android:color/white"/>
|
||||
<item android:state_checked="false"
|
||||
android:color="@android:color/darker_gray"/>
|
||||
</selector>
|
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2008 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_checked="false"
|
||||
android:state_enabled="true"
|
||||
android:drawable="@drawable/date_shortcut_bottom_off" />
|
||||
<item android:state_checked="true"
|
||||
android:state_enabled="true"
|
||||
android:drawable="@drawable/date_shortcut_bottom_on" />
|
||||
|
||||
</selector>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="2dip"
|
||||
android:color="@android:color/darker_gray"/>
|
||||
<corners
|
||||
android:bottomRightRadius="5dip"
|
||||
android:bottomLeftRadius="5dip"/>
|
||||
</shape>
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="2dip"
|
||||
android:color="@android:color/darker_gray"/>
|
||||
<solid
|
||||
android:color="@color/task_edit_date_shortcuts_bg"/>
|
||||
<corners
|
||||
android:bottomRightRadius="5dip"
|
||||
android:bottomLeftRadius="5dip"/>
|
||||
</shape>
|
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2008 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_checked="false"
|
||||
android:state_enabled="true"
|
||||
android:drawable="@drawable/date_shortcut_middle_off" />
|
||||
<item android:state_checked="true"
|
||||
android:state_enabled="true"
|
||||
android:drawable="@drawable/date_shortcut_middle_on" />
|
||||
|
||||
</selector>
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="2dip"
|
||||
android:color="@android:color/darker_gray"/>
|
||||
</shape>
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<solid
|
||||
android:color="@color/task_edit_date_shortcuts_bg"/>
|
||||
<stroke
|
||||
android:width="2dip"
|
||||
android:color="@android:color/darker_gray"/>
|
||||
</shape>
|
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2008 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_checked="false"
|
||||
android:state_enabled="true"
|
||||
android:drawable="@drawable/date_shortcut_standalone_off" />
|
||||
<item android:state_checked="true"
|
||||
android:state_enabled="true"
|
||||
android:drawable="@drawable/date_shortcut_standalone_on" />
|
||||
|
||||
</selector>
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="2dip"
|
||||
android:color="@android:color/darker_gray"/>
|
||||
<corners
|
||||
android:topLeftRadius="5dip"
|
||||
android:topRightRadius="5dip"
|
||||
android:bottomLeftRadius="5dip"
|
||||
android:bottomRightRadius="5dip"/>
|
||||
</shape>
|
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="2dip"
|
||||
android:color="@android:color/darker_gray"/>
|
||||
<solid
|
||||
android:color="@color/task_edit_date_shortcuts_bg"/>
|
||||
<corners
|
||||
android:topLeftRadius="5dip"
|
||||
android:topRightRadius="5dip"
|
||||
android:bottomLeftRadius="5dip"
|
||||
android:bottomRightRadius="5dip"/>
|
||||
</shape>
|
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2008 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_checked="false"
|
||||
android:state_enabled="true"
|
||||
android:drawable="@drawable/date_shortcut_top_off" />
|
||||
<item android:state_checked="true"
|
||||
android:state_enabled="true"
|
||||
android:drawable="@drawable/date_shortcut_top_on" />
|
||||
|
||||
</selector>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="2dip"
|
||||
android:color="@android:color/darker_gray"/>
|
||||
<corners
|
||||
android:topLeftRadius="5dip"
|
||||
android:topRightRadius="5dip"/>
|
||||
</shape>
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="2dip"
|
||||
android:color="@android:color/darker_gray"/>
|
||||
<solid
|
||||
android:color="@color/task_edit_date_shortcuts_bg"/>
|
||||
<corners
|
||||
android:topLeftRadius="5dip"
|
||||
android:topRightRadius="5dip"/>
|
||||
</shape>
|
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2008 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="false"
|
||||
android:drawable="@drawable/deadline_timepicker_button_bl_off" />
|
||||
<item android:state_pressed="true"
|
||||
android:drawable="@drawable/deadline_timepicker_button_bl_on" />
|
||||
|
||||
</selector>
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="2dip"
|
||||
android:color="@android:color/darker_gray"/>
|
||||
<corners
|
||||
android:bottomRightRadius="5dip"/>
|
||||
</shape>
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="2dip"
|
||||
android:color="@android:color/darker_gray"/>
|
||||
<solid
|
||||
android:color="@color/task_edit_date_shortcuts_bg"/>
|
||||
<corners
|
||||
android:bottomRightRadius="5dip"/>
|
||||
</shape>
|
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2008 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="false"
|
||||
android:drawable="@drawable/deadline_timepicker_button_br_off" />
|
||||
<item android:state_pressed="true"
|
||||
android:drawable="@drawable/deadline_timepicker_button_br_on" />
|
||||
|
||||
</selector>
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="2dip"
|
||||
android:color="@android:color/darker_gray"/>
|
||||
<corners
|
||||
android:bottomLeftRadius="5dip"/>
|
||||
</shape>
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="2dip"
|
||||
android:color="@android:color/darker_gray"/>
|
||||
<solid
|
||||
android:color="@color/task_edit_date_shortcuts_bg"/>
|
||||
<corners
|
||||
android:bottomLeftRadius="5dip"/>
|
||||
</shape>
|
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2008 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="false"
|
||||
android:drawable="@drawable/deadline_timepicker_button_tl_off" />
|
||||
<item android:state_pressed="true"
|
||||
android:drawable="@drawable/deadline_timepicker_button_tl_on" />
|
||||
|
||||
</selector>
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="2dip"
|
||||
android:color="@android:color/darker_gray"/>
|
||||
<corners
|
||||
android:topLeftRadius="5dip"/>
|
||||
</shape>
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="2dip"
|
||||
android:color="@android:color/darker_gray"/>
|
||||
<solid
|
||||
android:color="@color/task_edit_date_shortcuts_bg"/>
|
||||
<corners
|
||||
android:topLeftRadius="5dip"/>
|
||||
</shape>
|
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2008 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="false"
|
||||
android:drawable="@drawable/deadline_timepicker_button_tr_off" />
|
||||
<item android:state_pressed="true"
|
||||
android:drawable="@drawable/deadline_timepicker_button_tr_on" />
|
||||
|
||||
</selector>
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="2dip"
|
||||
android:color="@android:color/darker_gray"/>
|
||||
<corners
|
||||
android:topRightRadius="5dip"/>
|
||||
</shape>
|
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="2dip"
|
||||
android:color="@android:color/darker_gray"/>
|
||||
<solid
|
||||
android:color="@color/task_edit_date_shortcuts_bg"/>
|
||||
<corners
|
||||
android:topRightRadius="5dip"/>
|
||||
</shape>
|
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
After Width: | Height: | Size: 930 B |
Before Width: | Height: | Size: 308 B After Width: | Height: | Size: 308 B |
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="2dip"
|
||||
android:color="@android:color/white"/>
|
||||
<solid
|
||||
android:color="@android:color/black"/>
|
||||
<corners
|
||||
android:topLeftRadius="5dip"
|
||||
android:topRightRadius="5dip"
|
||||
android:bottomLeftRadius="5dip"
|
||||
android:bottomRightRadius="5dip"/>
|
||||
</shape>
|
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2008 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_checked="false"
|
||||
android:drawable="@drawable/timepicker_am_btn_off" />
|
||||
<item android:state_checked="true"
|
||||
android:drawable="@drawable/timepicker_am_btn_on" />
|
||||
|
||||
</selector>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="2dip"
|
||||
android:color="@android:color/darker_gray"/>
|
||||
<corners
|
||||
android:topLeftRadius="5dip"
|
||||
android:bottomRightRadius="5dip"/>
|
||||
</shape>
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="2dip"
|
||||
android:color="@android:color/darker_gray"/>
|
||||
<solid
|
||||
android:color="@color/task_edit_date_shortcuts_bg"/>
|
||||
<corners
|
||||
android:topLeftRadius="5dip"
|
||||
android:bottomRightRadius="5dip"/>
|
||||
</shape>
|
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2008 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_checked="false"
|
||||
android:drawable="@drawable/timepicker_pm_btn_off" />
|
||||
<item android:state_checked="true"
|
||||
android:drawable="@drawable/timepicker_pm_btn_on" />
|
||||
|
||||
</selector>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="2dip"
|
||||
android:color="@android:color/darker_gray"/>
|
||||
<corners
|
||||
android:topRightRadius="5dip"
|
||||
android:bottomLeftRadius="5dip"/>
|
||||
</shape>
|
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke
|
||||
android:width="2dip"
|
||||
android:color="@android:color/darker_gray"/>
|
||||
<solid
|
||||
android:color="@color/task_edit_date_shortcuts_bg"/>
|
||||
<corners
|
||||
android:topRightRadius="5dip"
|
||||
android:bottomLeftRadius="5dip"/>
|
||||
</shape>
|
@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<ScrollView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:minWidth="320dip"
|
||||
android:paddingLeft="10dip"
|
||||
android:paddingRight="10dip"
|
||||
android:paddingTop="5dip"
|
||||
android:paddingBottom="5dip">
|
||||
<LinearLayout
|
||||
android:id="@+id/reminders_body"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<com.todoroo.astrid.ui.CalendarView
|
||||
android:id="@+id/calendar"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="280dip"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginRight="5dip"/>
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginLeft="5dip"
|
||||
android:layout_gravity="center_vertical">
|
||||
<LinearLayout
|
||||
android:id="@+id/date_shortcuts"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginTop="5dip"
|
||||
android:layout_marginRight="5dip"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"/>
|
||||
<com.todoroo.astrid.ui.AstridTimePicker
|
||||
android:id="@+id/time_picker"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginTop="5dip"
|
||||
android:layout_marginLeft="5dip"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</merge>
|
@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/timeComponents"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="4dip"
|
||||
android:orientation="horizontal">
|
||||
<com.todoroo.astrid.ui.DeadlineNumberPicker
|
||||
android:id="@+id/hours"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@android:color/black"
|
||||
android:text=":"
|
||||
android:textColor="@android:color/white"
|
||||
android:gravity="center"
|
||||
/>
|
||||
<com.todoroo.astrid.ui.DeadlineNumberPicker
|
||||
android:id="@+id/minutes"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/am_pm_container"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="4dip">
|
||||
<ToggleButton
|
||||
android:id="@+id/am_button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dip"
|
||||
android:paddingBottom="8dip"
|
||||
android:textSize="18sp"
|
||||
android:background="@drawable/timepicker_am_btn"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/task_edit_toggle_button_text"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginRight="-1dip"/>
|
||||
<ToggleButton
|
||||
android:id="@+id/pm_button"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dip"
|
||||
android:paddingBottom="8dip"
|
||||
android:textSize="18sp"
|
||||
android:background="@drawable/timepicker_pm_btn"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/task_edit_toggle_button_text"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginLeft="-1dip"/>
|
||||
</LinearLayout>
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/hasTime"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dip"
|
||||
android:paddingBottom="8dip"
|
||||
android:textSize="18sp"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/task_edit_toggle_button_text"/>
|
||||
|
||||
</merge>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.todoroo.astrid.ui.DateAndTimePicker
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:astrid="http://schemas.android.com/apk/res/com.timsu.astrid"
|
||||
android:id="@+id/date_and_time"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical"/>
|
@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
|
||||
<!-- tags -->
|
||||
<LinearLayout
|
||||
android:id="@+id/repeat_body"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="50dip"
|
||||
android:gravity="center_vertical">
|
||||
<ImageView
|
||||
style="@style/EditRowImage"
|
||||
android:src="@drawable/icn_edit_reminders"/>
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="15dip"
|
||||
android:text="@string/TEA_date_and_time"
|
||||
style="@style/TextAppearance.GEN_EditLabel.DLG_EditLabel" />
|
||||
<TextView
|
||||
android:id="@+id/deadline_display"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="right"
|
||||
android:paddingLeft="10dip"
|
||||
style="@style/TextAppearance.EditRowDisplay" />
|
||||
<include layout="@layout/task_edit_arrow"/>
|
||||
</LinearLayout>
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1px"
|
||||
android:padding="5dip"
|
||||
style="@style/TEA_Separator" />
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:astrid="http://schemas.android.com/apk/res/com.timsu.astrid"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
<com.todoroo.astrid.ui.DateAndTimePicker
|
||||
android:id="@+id/date_and_time"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical"/>
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="7dip"
|
||||
android:paddingRight="7dip"
|
||||
android:orientation="horizontal">
|
||||
<Button
|
||||
android:id="@+id/ok"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="50dip"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/DLG_ok"/>
|
||||
<Button
|
||||
android:id="@+id/cancel"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="50dip"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/DLG_cancel"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<ScrollView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:minWidth="320dip"
|
||||
android:paddingLeft="10dip"
|
||||
android:paddingRight="10dip"
|
||||
android:paddingTop="5dip"
|
||||
android:paddingBottom="5dip">
|
||||
<LinearLayout
|
||||
android:id="@+id/reminders_body"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<com.todoroo.astrid.ui.CalendarView
|
||||
android:id="@+id/calendar"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="300dip"
|
||||
android:layout_weight="1" />
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_weight="1">
|
||||
<LinearLayout
|
||||
android:id="@+id/date_shortcuts"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginTop="5dip"
|
||||
android:layout_marginRight="5dip"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"/>
|
||||
<com.todoroo.astrid.ui.AstridTimePicker
|
||||
android:id="@+id/time_picker"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_marginTop="5dip"
|
||||
android:layout_marginLeft="5dip"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
</merge>
|
@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
**
|
||||
** Copyright 2008, The Android Open Source Project
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
-->
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<com.todoroo.astrid.ui.NumberPickerButton android:id="@+id/increment"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="36dip"
|
||||
android:src="@drawable/icn_arrow_up"
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
<View
|
||||
android:id="@+id/timepicker_left_border"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_width="2dip"
|
||||
android:background="@android:color/darker_gray"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
|
||||
<EditText android:id="@+id/timepicker_input"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
style="?android:attr/textAppearanceLarge"
|
||||
android:gravity="center"
|
||||
android:inputType="phone"
|
||||
android:textSize="30sp"
|
||||
android:textColor="@android:color/white"
|
||||
android:background="@android:color/transparent"
|
||||
/>
|
||||
<View
|
||||
android:id="@+id/timepicker_right_border"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_width="2dip"
|
||||
android:background="@android:color/darker_gray"
|
||||
android:visibility="gone"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<com.todoroo.astrid.ui.NumberPickerButton android:id="@+id/decrement"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="36dip"
|
||||
android:src="@drawable/icn_arrow_down"
|
||||
android:paddingTop="15dip"
|
||||
/>
|
||||
|
||||
</merge>
|
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
**
|
||||
** Copyright 2007, The Android Open Source Project
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
-->
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dip"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TimePicker android:id="@+id/timePicker"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<CheckBox android:id="@+id/hasTime"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/TEA_urgency_specific_time"/>
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,199 @@
|
||||
package com.todoroo.astrid.ui;
|
||||
|
||||
import java.util.Calendar;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.format.DateUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import com.timsu.astrid.R;
|
||||
import com.todoroo.andlib.utility.DateUtilities;
|
||||
|
||||
public class AstridTimePicker extends LinearLayout {
|
||||
|
||||
private final ToggleButton noTimeCheck;
|
||||
private final ToggleButton amButton;
|
||||
private final ToggleButton pmButton;
|
||||
private final NumberPicker hours;
|
||||
private final NumberPicker minutes;
|
||||
private TimePickerEnabledChangedListener listener;
|
||||
private boolean is24Hour;
|
||||
|
||||
private boolean lastSelectionWasPm; // false for AM, true for PM
|
||||
|
||||
public interface TimePickerEnabledChangedListener {
|
||||
public void timePickerEnabledChanged(boolean hasTime);
|
||||
}
|
||||
|
||||
public AstridTimePicker(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
inflater.inflate(R.layout.astrid_time_picker, this, true);
|
||||
|
||||
noTimeCheck = (ToggleButton) findViewById(R.id.hasTime);
|
||||
amButton= (ToggleButton) findViewById(R.id.am_button);
|
||||
pmButton= (ToggleButton) findViewById(R.id.pm_button);
|
||||
hours = (NumberPicker) findViewById(R.id.hours);
|
||||
minutes = (NumberPicker) findViewById(R.id.minutes);
|
||||
|
||||
initialize(context);
|
||||
}
|
||||
|
||||
private void initialize(Context context) {
|
||||
if (DateUtilities.is24HourFormat(context)) {
|
||||
hours.setRange(0, 23);
|
||||
is24Hour = true;
|
||||
findViewById(R.id.am_pm_container).setVisibility(View.GONE);
|
||||
} else {
|
||||
hours.setRange(1, 12);
|
||||
is24Hour = false;
|
||||
}
|
||||
minutes.setRange(0, 59);
|
||||
|
||||
NumberPicker.OnChangedListener autoEnableTimeCheck = new NumberPicker.OnChangedListener() {
|
||||
|
||||
@Override
|
||||
public int onChanged(NumberPicker picker, int oldVal, int newVal) {
|
||||
setHasTime(true);
|
||||
return newVal;
|
||||
}
|
||||
};
|
||||
|
||||
hours.findViewById(R.id.increment).setBackgroundResource(R.drawable.deadline_timepicker_button_tl);
|
||||
hours.findViewById(R.id.decrement).setBackgroundResource(R.drawable.deadline_timepicker_button_bl);
|
||||
hours.findViewById(R.id.timepicker_left_border).setVisibility(View.VISIBLE);
|
||||
minutes.findViewById(R.id.increment).setBackgroundResource(R.drawable.deadline_timepicker_button_tr);
|
||||
minutes.findViewById(R.id.decrement).setBackgroundResource(R.drawable.deadline_timepicker_button_br);
|
||||
minutes.findViewById(R.id.timepicker_right_border).setVisibility(View.VISIBLE);
|
||||
|
||||
String amString = DateUtils.getAMPMString(Calendar.AM).toLowerCase();
|
||||
amButton.setTextOff(amString);
|
||||
amButton.setTextOn(amString);
|
||||
amButton.setChecked(false);
|
||||
|
||||
String pmString = DateUtils.getAMPMString(Calendar.PM).toLowerCase();
|
||||
pmButton.setTextOff(pmString);
|
||||
pmButton.setTextOn(pmString);
|
||||
pmButton.setChecked(false);
|
||||
|
||||
amButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
noTimeCheck.setChecked(false);
|
||||
amButton.setChecked(true);
|
||||
pmButton.setChecked(false);
|
||||
}
|
||||
});
|
||||
|
||||
pmButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
noTimeCheck.setChecked(false);
|
||||
amButton.setChecked(false);
|
||||
pmButton.setChecked(true);
|
||||
}
|
||||
});
|
||||
|
||||
noTimeCheck.setBackgroundResource(R.drawable.date_shortcut_standalone);
|
||||
String noTime = context.getString(R.string.TEA_no_time).toLowerCase();
|
||||
noTimeCheck.setTextOff(noTime);
|
||||
noTimeCheck.setTextOn(noTime);
|
||||
|
||||
hours.setOnChangeListener(autoEnableTimeCheck);
|
||||
minutes.setOnChangeListener(autoEnableTimeCheck);
|
||||
|
||||
noTimeCheck.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
setHasTime(!isChecked, false);
|
||||
}
|
||||
});
|
||||
|
||||
minutes.setFormatter(NumberPicker.TWO_DIGIT_FORMATTER);
|
||||
}
|
||||
|
||||
public void setHasTime(boolean hasTime) {
|
||||
setHasTime(hasTime, true);
|
||||
}
|
||||
|
||||
public void setHasTime(boolean hasTime, boolean setChecked) {
|
||||
if (setChecked)
|
||||
noTimeCheck.setChecked(!hasTime);
|
||||
|
||||
|
||||
if (noTimeCheck.isChecked()) {
|
||||
hours.setText(""); //$NON-NLS-1$
|
||||
minutes.setText(""); //$NON-NLS-1$
|
||||
|
||||
lastSelectionWasPm = pmButton.isChecked();
|
||||
amButton.setChecked(false);
|
||||
pmButton.setChecked(false);
|
||||
} else {
|
||||
hours.updateView();
|
||||
minutes.updateView();
|
||||
|
||||
amButton.setChecked(!lastSelectionWasPm);
|
||||
pmButton.setChecked(lastSelectionWasPm);
|
||||
}
|
||||
|
||||
if (listener != null)
|
||||
listener.timePickerEnabledChanged(hasTime);
|
||||
}
|
||||
|
||||
public boolean hasTime() {
|
||||
return !noTimeCheck.isChecked();
|
||||
}
|
||||
|
||||
public void forceNoTime() {
|
||||
if (!noTimeCheck.isChecked())
|
||||
noTimeCheck.performClick();
|
||||
}
|
||||
|
||||
public void setHours(int hour) {
|
||||
boolean pm = false;
|
||||
if (!is24Hour) {
|
||||
if (hour == 0) {
|
||||
hour = 12;
|
||||
pm = true;
|
||||
} else if (hour > 12) {
|
||||
hour -= 12;
|
||||
pm = true;
|
||||
}
|
||||
}
|
||||
amButton.setChecked(!pm);
|
||||
pmButton.setChecked(pm);
|
||||
lastSelectionWasPm = pm;
|
||||
hours.setCurrent(hour);
|
||||
}
|
||||
|
||||
public int getHours() {
|
||||
int toReturn = hours.getCurrent();
|
||||
if (!is24Hour) {
|
||||
if (toReturn == 12) {
|
||||
if (amButton.isChecked())
|
||||
toReturn = 0;
|
||||
} else if (pmButton.isChecked())
|
||||
toReturn += 12;
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
public void setMinutes(int minute) {
|
||||
minutes.setCurrent(minute);
|
||||
}
|
||||
|
||||
public int getMinutes() {
|
||||
return minutes.getCurrent();
|
||||
}
|
||||
|
||||
public void setTimePickerEnabledChangedListener(TimePickerEnabledChangedListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
package com.todoroo.astrid.ui;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager.LayoutParams;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.timsu.astrid.R;
|
||||
|
||||
public class DateAndTimeDialog extends Dialog {
|
||||
|
||||
public interface DateAndTimeDialogListener {
|
||||
public void onDateAndTimeSelected(long date);
|
||||
public void onDateAndTimeCancelled();
|
||||
}
|
||||
|
||||
private final DateAndTimePicker dateAndTimePicker;
|
||||
private final Button okButton;
|
||||
private final Button cancelButton;
|
||||
private boolean cancelled = false;
|
||||
|
||||
private DateAndTimeDialogListener listener;
|
||||
|
||||
public DateAndTimeDialog(Context context, long startDate) {
|
||||
super(context);
|
||||
|
||||
/** 'Window.FEATURE_NO_TITLE' - Used to hide the title */
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
/** Design the dialog in main.xml file */
|
||||
setContentView(R.layout.date_time_dialog);
|
||||
|
||||
LayoutParams params = getWindow().getAttributes();
|
||||
params.height = LayoutParams.FILL_PARENT;
|
||||
params.width = LayoutParams.FILL_PARENT;
|
||||
getWindow().setAttributes((android.view.WindowManager.LayoutParams) params);
|
||||
|
||||
dateAndTimePicker = (DateAndTimePicker) findViewById(R.id.date_and_time);
|
||||
dateAndTimePicker.initializeWithDate(startDate);
|
||||
|
||||
okButton = (Button) findViewById(R.id.ok);
|
||||
cancelButton = (Button) findViewById(R.id.cancel);
|
||||
|
||||
okButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dismiss();
|
||||
if (listener != null)
|
||||
listener.onDateAndTimeSelected(dateAndTimePicker.constructDueDate());
|
||||
}
|
||||
});
|
||||
|
||||
cancelButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
cancelled = true;
|
||||
cancel();
|
||||
if (listener != null)
|
||||
listener.onDateAndTimeCancelled();
|
||||
}
|
||||
});
|
||||
|
||||
setOnCancelListener(new OnCancelListener() {
|
||||
@Override
|
||||
public void onCancel(DialogInterface dialog) {
|
||||
if (!cancelled) { // i.e. if back button pressed, which we treat as an "OK"
|
||||
if (listener != null)
|
||||
listener.onDateAndTimeSelected(dateAndTimePicker.constructDueDate());
|
||||
} else {
|
||||
cancelled = false; // reset
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public long getSelectedDate() {
|
||||
return dateAndTimePicker.constructDueDate();
|
||||
}
|
||||
|
||||
public void setSelectedDateAndTime(long date) {
|
||||
dateAndTimePicker.initializeWithDate(date);
|
||||
}
|
||||
|
||||
public boolean hasTime() {
|
||||
return dateAndTimePicker.hasTime();
|
||||
}
|
||||
|
||||
public void setDateAndTimeDialogListener(DateAndTimeDialogListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public String getDisplayString(Context context) {
|
||||
return dateAndTimePicker.getDisplayString(context);
|
||||
}
|
||||
|
||||
public String getDisplayString(Context context, long forDate) {
|
||||
return dateAndTimePicker.getDisplayString(context, forDate);
|
||||
}
|
||||
}
|
@ -0,0 +1,233 @@
|
||||
package com.todoroo.astrid.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
import com.timsu.astrid.R;
|
||||
import com.todoroo.andlib.utility.DateUtilities;
|
||||
import com.todoroo.astrid.data.Task;
|
||||
import com.todoroo.astrid.ui.AstridTimePicker.TimePickerEnabledChangedListener;
|
||||
import com.todoroo.astrid.ui.CalendarView.OnSelectedDateListener;
|
||||
|
||||
public class DateAndTimePicker extends LinearLayout {
|
||||
|
||||
public interface OnDateChangedListener {
|
||||
public void onDateChanged();
|
||||
}
|
||||
|
||||
private static final int SHORTCUT_PADDING = 8;
|
||||
|
||||
ArrayList<UrgencyValue> urgencyValues;
|
||||
|
||||
private class UrgencyValue {
|
||||
public String label;
|
||||
public int setting;
|
||||
public long dueDate;
|
||||
|
||||
public UrgencyValue(String label, int setting) {
|
||||
this.label = label;
|
||||
this.setting = setting;
|
||||
dueDate = Task.createDueDate(setting, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
private final CalendarView calendarView;
|
||||
private final AstridTimePicker timePicker;
|
||||
private final LinearLayout dateShortcuts;
|
||||
private OnDateChangedListener listener;
|
||||
|
||||
public DateAndTimePicker(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
inflater.inflate(R.layout.date_time_picker, this, true);
|
||||
|
||||
calendarView = (CalendarView) findViewById(R.id.calendar);
|
||||
timePicker = (AstridTimePicker) findViewById(R.id.time_picker);
|
||||
dateShortcuts = (LinearLayout) findViewById(R.id.date_shortcuts);
|
||||
|
||||
setUpListeners();
|
||||
constructShortcutList(context);
|
||||
}
|
||||
|
||||
public void initializeWithDate(long dateValue) {
|
||||
Date date = new Date(dateValue);
|
||||
Date forCalendar;
|
||||
if (dateValue> 0)
|
||||
forCalendar = getDateForCalendar(date);
|
||||
else
|
||||
forCalendar = date;
|
||||
calendarView.setCalendarDate(forCalendar);
|
||||
if (Task.hasDueTime(dateValue)) {
|
||||
timePicker.setHours(date.getHours());
|
||||
timePicker.setMinutes(date.getMinutes());
|
||||
timePicker.setHasTime(true);
|
||||
} else {
|
||||
timePicker.setHours(18);
|
||||
timePicker.setMinutes(0);
|
||||
timePicker.setHasTime(false);
|
||||
}
|
||||
updateShortcutView(forCalendar);
|
||||
}
|
||||
|
||||
private Date getDateForCalendar(Date date) {
|
||||
Date forCalendar = new Date(date.getTime() / 1000L * 1000L);
|
||||
forCalendar.setHours(23);
|
||||
forCalendar.setMinutes(59);
|
||||
forCalendar.setSeconds(59);
|
||||
return forCalendar;
|
||||
}
|
||||
|
||||
private void setUpListeners() {
|
||||
calendarView.setOnSelectedDateListener(new OnSelectedDateListener() {
|
||||
@Override
|
||||
public void onSelectedDate(Date date) {
|
||||
updateShortcutView(date);
|
||||
otherCallbacks();
|
||||
}
|
||||
});
|
||||
|
||||
timePicker.setTimePickerEnabledChangedListener(new TimePickerEnabledChangedListener() {
|
||||
@Override
|
||||
public void timePickerEnabledChanged(boolean hasTime) {
|
||||
if (hasTime) {
|
||||
forceDateSelected();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void forceDateSelected() {
|
||||
ToggleButton none = (ToggleButton) dateShortcuts.getChildAt(dateShortcuts.getChildCount() - 1);
|
||||
if (none.isChecked()) {
|
||||
dateShortcuts.getChildAt(0).performClick();
|
||||
}
|
||||
}
|
||||
|
||||
private void constructShortcutList(Context context) {
|
||||
String[] labels = context.getResources().getStringArray(R.array.TEA_urgency);
|
||||
urgencyValues = new ArrayList<UrgencyValue>();
|
||||
urgencyValues.add(new UrgencyValue(labels[2],
|
||||
Task.URGENCY_TODAY));
|
||||
urgencyValues.add(new UrgencyValue(labels[3],
|
||||
Task.URGENCY_TOMORROW));
|
||||
urgencyValues.add(new UrgencyValue(labels[5],
|
||||
Task.URGENCY_NEXT_WEEK));
|
||||
urgencyValues.add(new UrgencyValue(labels[7],
|
||||
Task.URGENCY_NEXT_MONTH));
|
||||
urgencyValues.add(new UrgencyValue(labels[0],
|
||||
Task.URGENCY_NONE));
|
||||
|
||||
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
|
||||
for (int i = 0; i < urgencyValues.size(); i++) {
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 0);
|
||||
UrgencyValue uv = urgencyValues.get(i);
|
||||
|
||||
ToggleButton tb = new ToggleButton(context);
|
||||
String label = uv.label.toLowerCase();
|
||||
tb.setTextOff(label);
|
||||
tb.setTextOn(label);
|
||||
tb.setTag(uv);
|
||||
if (i == 0) {
|
||||
tb.setBackgroundResource(R.drawable.date_shortcut_top);
|
||||
} else if (i == urgencyValues.size() - 2) {
|
||||
lp.topMargin = (int) (-2 * metrics.density);
|
||||
tb.setBackgroundResource(R.drawable.date_shortcut_bottom);
|
||||
} else if (i == urgencyValues.size() - 1) {
|
||||
lp.topMargin = (int) (5 * metrics.density);
|
||||
tb.setBackgroundResource(R.drawable.date_shortcut_standalone);
|
||||
} else {
|
||||
lp.topMargin = (int) (-2 * metrics.density);
|
||||
tb.setBackgroundResource(R.drawable.date_shortcut_middle);
|
||||
}
|
||||
int verticalPadding = (int) (SHORTCUT_PADDING * metrics.density);
|
||||
tb.setPadding(0, verticalPadding, 0, verticalPadding);
|
||||
tb.setLayoutParams(lp);
|
||||
tb.setGravity(Gravity.CENTER);
|
||||
tb.setTextSize(18);
|
||||
tb.setTextColor(context.getResources().getColorStateList(R.color.task_edit_toggle_button_text));
|
||||
|
||||
tb.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
UrgencyValue value = (UrgencyValue) v.getTag();
|
||||
Date date = new Date(value.dueDate);
|
||||
calendarView.setCalendarDate(date);
|
||||
calendarView.invalidate();
|
||||
if (value.setting == Task.URGENCY_NONE)
|
||||
timePicker.forceNoTime();
|
||||
updateShortcutView(date);
|
||||
otherCallbacks();
|
||||
}
|
||||
});
|
||||
dateShortcuts.addView(tb);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateShortcutView(Date date) {
|
||||
for (int i = 0; i < dateShortcuts.getChildCount(); i++) {
|
||||
ToggleButton tb = (ToggleButton) dateShortcuts.getChildAt(i);
|
||||
UrgencyValue uv = (UrgencyValue) tb.getTag();
|
||||
if (uv.dueDate == date.getTime()) {
|
||||
tb.setChecked(true);
|
||||
} else {
|
||||
tb.setChecked(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void otherCallbacks() {
|
||||
if (listener != null)
|
||||
listener.onDateChanged();
|
||||
}
|
||||
|
||||
public long constructDueDate() {
|
||||
Date calendarDate = new Date(calendarView.getCalendarDate().getTime());
|
||||
if (timePicker.hasTime() && calendarDate.getTime() > 0) {
|
||||
calendarDate.setHours(timePicker.getHours());
|
||||
calendarDate.setMinutes(timePicker.getMinutes());
|
||||
}
|
||||
return calendarDate.getTime();
|
||||
}
|
||||
|
||||
public boolean hasTime() {
|
||||
return timePicker.hasTime();
|
||||
}
|
||||
|
||||
public void setOnDateChangedListener(OnDateChangedListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
public String getDisplayString(Context context) {
|
||||
long dueDate = constructDueDate();
|
||||
return getDisplayString(context, dueDate);
|
||||
}
|
||||
|
||||
public static String getDisplayString(Context context, long forDate) {
|
||||
StringBuilder displayString = new StringBuilder();
|
||||
Date d = new Date(forDate);
|
||||
if (d.getTime() > 0) {
|
||||
displayString.append(DateUtilities.getDateString(context, d));
|
||||
if (Task.hasDueTime(forDate)) {
|
||||
displayString.append(", ");
|
||||
displayString.append(DateUtilities.getTimeString(context, d));
|
||||
}
|
||||
}
|
||||
return displayString.toString();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package com.todoroo.astrid.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.timsu.astrid.R;
|
||||
import com.todoroo.astrid.data.Task;
|
||||
import com.todoroo.astrid.ui.DateAndTimePicker.OnDateChangedListener;
|
||||
|
||||
public class DeadlineControlSet extends PopupControlSet {
|
||||
|
||||
private final DateAndTimePicker dateAndTimePicker;
|
||||
private final TextView auxDisplay;
|
||||
|
||||
public DeadlineControlSet(Activity activity, int viewLayout, int displayViewLayout, View extensionView, int auxDisplayId, int...dateShortcutViews) {
|
||||
super(activity, viewLayout, displayViewLayout, 0);
|
||||
|
||||
dateAndTimePicker = (DateAndTimePicker) getView().findViewById(R.id.date_and_time);
|
||||
auxDisplay = (TextView) extensionView.findViewById(auxDisplayId);
|
||||
setUpListeners(dateShortcutViews);
|
||||
}
|
||||
|
||||
private void setUpListeners(int[] dateShortcutViews) {
|
||||
|
||||
dateAndTimePicker.setOnDateChangedListener(new OnDateChangedListener() {
|
||||
@Override
|
||||
public void onDateChanged() {
|
||||
refreshDisplayView();
|
||||
}
|
||||
});
|
||||
|
||||
View.OnClickListener dateShortcutListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dialog.show();
|
||||
}
|
||||
};
|
||||
|
||||
for (int i : dateShortcutViews) {
|
||||
View v = activity.findViewById(i);
|
||||
if (v != null)
|
||||
v.setOnClickListener(dateShortcutListener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void refreshDisplayView() {
|
||||
TextView dateDisplay = (TextView) getDisplayView().findViewById(R.id.deadline_display);
|
||||
String toDisplay = dateAndTimePicker.getDisplayString(activity);
|
||||
dateDisplay.setText(toDisplay);
|
||||
auxDisplay.setText(toDisplay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromTask(Task task) {
|
||||
long dueDate = task.getValue(Task.DUE_DATE);
|
||||
dateAndTimePicker.initializeWithDate(dueDate);
|
||||
refreshDisplayView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String writeToModel(Task task) {
|
||||
long dueDate = dateAndTimePicker.constructDueDate();
|
||||
task.setValue(Task.DUE_DATE, dueDate);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.todoroo.astrid.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import com.timsu.astrid.R;
|
||||
|
||||
public class DeadlineNumberPicker extends NumberPicker {
|
||||
|
||||
public DeadlineNumberPicker(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public DeadlineNumberPicker(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public DeadlineNumberPicker(Context context, AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayout() {
|
||||
return R.layout.deadline_number_picker;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue