├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values-land-v21 │ │ │ │ └── dimens.xml │ │ │ ├── color │ │ │ │ ├── toggle_alarm_days.xml │ │ │ │ ├── numeric_keypad_fab_color.xml │ │ │ │ ├── numeric_keypad_fab_color_dark.xml │ │ │ │ ├── icon_color.xml │ │ │ │ ├── icon_color_dark.xml │ │ │ │ ├── numeric_keypad_button_text.xml │ │ │ │ ├── numeric_keypad_button_text_dark.xml │ │ │ │ ├── fab_icon_color.xml │ │ │ │ ├── on_enabled_change_fab.xml │ │ │ │ └── tab_icon_color.xml │ │ │ ├── values-v21 │ │ │ │ ├── styles_timer.xml │ │ │ │ └── dimens.xml │ │ │ ├── values │ │ │ │ ├── ids.xml │ │ │ │ ├── prefs_timers.xml │ │ │ │ ├── prefs_world_clock.xml │ │ │ │ ├── aosp_datetimepicker_styles.xml │ │ │ │ ├── styles_alarm.xml │ │ │ │ ├── prefs_general.xml │ │ │ │ ├── attrs.xml │ │ │ │ ├── styles_stopwatch.xml │ │ │ │ └── colors.xml │ │ │ ├── values-land │ │ │ │ ├── aosp_datetimepicker_dimens.xml │ │ │ │ └── dimens.xml │ │ │ ├── menu │ │ │ │ ├── menu_timer_viewholder.xml │ │ │ │ └── menu_main.xml │ │ │ ├── drawable │ │ │ │ ├── ic_start_24dp.xml │ │ │ │ ├── ic_stop_24dp.xml │ │ │ │ ├── ic_stop_40dp.xml │ │ │ │ ├── ic_stop_48dp.xml │ │ │ │ ├── ic_add_24dp.xml │ │ │ │ ├── ic_add_48dp.xml │ │ │ │ ├── ic_pause_24dp.xml │ │ │ │ ├── ic_collapse_24dp.xml │ │ │ │ ├── ic_done_24dp.xml │ │ │ │ ├── ic_minus_circle_24dp.xml │ │ │ │ ├── ic_ringtone_24dp.xml │ │ │ │ ├── ic_add_circle_24dp.xml │ │ │ │ ├── ic_snooze_24dp.xml │ │ │ │ ├── ic_snooze_48dp.xml │ │ │ │ ├── ic_error_outline_96dp.xml │ │ │ │ ├── ic_cancel_snooze.xml │ │ │ │ ├── ic_add_lap_40dp.xml │ │ │ │ ├── ic_overflow_24dp.xml │ │ │ │ ├── ic_clock_24dp.xml │ │ │ │ ├── ic_add_lap_24dp.xml │ │ │ │ ├── ic_vibrate_24dp.xml │ │ │ │ ├── ic_backspace_24dp.xml │ │ │ │ ├── ic_stopwatch_24dp.xml │ │ │ │ ├── ic_alarm_24dp.xml │ │ │ │ ├── ic_alarm_96dp.xml │ │ │ │ ├── ic_timer_24dp.xml │ │ │ │ ├── ic_timer_96dp.xml │ │ │ │ ├── ic_dismiss_alarm_24dp.xml │ │ │ │ ├── ic_dismiss_alarm_48dp.xml │ │ │ │ └── ic_settings_24dp.xml │ │ │ ├── layout │ │ │ │ ├── content_settings.xml │ │ │ │ ├── content_header_timesup_activity.xml │ │ │ │ ├── content_header_alarm_activity.xml │ │ │ │ ├── activity_settings.xml │ │ │ │ ├── item_lap.xml │ │ │ │ ├── alarm_time_layout.xml │ │ │ │ ├── content_grid_layout_numpad.xml │ │ │ │ ├── content_grid_layout_numpad_dark.xml │ │ │ │ ├── fragment_recycler_view.xml │ │ │ │ ├── fragment_stopwatch.xml │ │ │ │ ├── activity_main.xml │ │ │ │ └── item_timer.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout-land │ │ │ │ ├── item_timer.xml │ │ │ │ └── fragment_stopwatch.xml │ │ └── java │ │ │ └── com │ │ │ └── philliphsu │ │ │ └── clock2 │ │ │ ├── list │ │ │ ├── OnListItemInteractionListener.java │ │ │ ├── ScrollHandler.java │ │ │ └── BaseViewHolder.java │ │ │ ├── util │ │ │ ├── Preconditions.java │ │ │ ├── ConfigurationUtils.java │ │ │ ├── FragmentTagUtils.java │ │ │ ├── TimeFormatUtils.java │ │ │ ├── ParcelableUtil.java │ │ │ ├── KeyboardUtils.java │ │ │ ├── ContentIntentUtils.java │ │ │ ├── TimeTextUtils.java │ │ │ ├── LocalBroadcastHelper.java │ │ │ └── DelayedSnackbarHandler.java │ │ │ ├── data │ │ │ ├── ObjectWithId.java │ │ │ ├── BaseItemCursor.java │ │ │ └── ClockAppDatabaseHelper.java │ │ │ ├── alarms │ │ │ ├── background │ │ │ │ └── OnBootUpReceiver.java │ │ │ ├── data │ │ │ │ └── AlarmsListCursorLoader.java │ │ │ └── misc │ │ │ │ └── AlarmPreferences.java │ │ │ ├── UntouchableSeekBar.java │ │ │ ├── stopwatch │ │ │ ├── data │ │ │ │ ├── LapsCursorLoader.java │ │ │ │ ├── LapCursor.java │ │ │ │ ├── AsyncLapsTableUpdateHandler.java │ │ │ │ └── LapsTable.java │ │ │ └── ui │ │ │ │ ├── ChronometerWithMillis.java │ │ │ │ ├── LapsAdapter.java │ │ │ │ └── LapViewHolder.java │ │ │ ├── timers │ │ │ ├── data │ │ │ │ ├── TimersListCursorLoader.java │ │ │ │ ├── TimerCursor.java │ │ │ │ └── TimersTableManager.java │ │ │ ├── ui │ │ │ │ ├── TimersCursorAdapter.java │ │ │ │ └── CountdownChronometer.java │ │ │ └── TimerController.java │ │ │ ├── dialogs │ │ │ ├── AddLabelDialogController.java │ │ │ ├── RingtonePickerDialogController.java │ │ │ ├── DialogFragmentController.java │ │ │ ├── BaseAlertDialogFragment.java │ │ │ └── SystemTimePickerDialog.java │ │ │ ├── BaseFragment.java │ │ │ ├── ringtone │ │ │ └── playback │ │ │ │ └── RingtoneLoop.java │ │ │ └── settings │ │ │ └── SettingsActivity.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── philliphsu │ │ │ └── clock2 │ │ │ ├── ExampleUnitTest.java │ │ │ ├── RingtoneServiceTest.java │ │ │ └── DurationUtilsTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── philliphsu │ │ └── clock2 │ │ └── ApplicationTest.java └── proguard-rules.pro ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── settings.gradle ├── gradle.properties ├── README.md ├── .gitignore └── gradlew.bat /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/philliphsu/ClockPlus/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/philliphsu/ClockPlus/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/philliphsu/ClockPlus/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/philliphsu/ClockPlus/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/philliphsu/ClockPlus/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/philliphsu/ClockPlus/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | include ':app' 21 | -------------------------------------------------------------------------------- /app/src/main/res/values-land-v21/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 50dp 23 | -------------------------------------------------------------------------------- /app/src/main/res/color/toggle_alarm_days.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2017 Phillip Hsu 3 | # 4 | # This file is part of ClockPlus. 5 | # 6 | # ClockPlus is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # ClockPlus is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with ClockPlus. If not, see . 18 | # 19 | 20 | #Fri Feb 24 23:57:57 PST 2017 21 | distributionBase=GRADLE_USER_HOME 22 | distributionPath=wrapper/dists 23 | zipStoreBase=GRADLE_USER_HOME 24 | zipStorePath=wrapper/dists 25 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 26 | -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles_timer.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/values/ids.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/color/numeric_keypad_fab_color.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/color/numeric_keypad_fab_color_dark.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/values-land/aosp_datetimepicker_dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 20 | 252dp 21 | 250dip 22 | 23 | -------------------------------------------------------------------------------- /app/src/main/res/color/icon_color.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/color/icon_color_dark.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/color/numeric_keypad_button_text.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/color/numeric_keypad_button_text_dark.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_timer_viewholder.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 23 | 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/list/OnListItemInteractionListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2.list; 21 | 22 | /** 23 | * Created by Phillip Hsu on 5/31/2016. 24 | */ 25 | public interface OnListItemInteractionListener { 26 | void onListItemClick(T item, int position); 27 | void onListItemDeleted(T item); 28 | void onListItemUpdate(T item, int position); 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_start_24dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_stop_24dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_stop_40dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_stop_48dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_settings.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/util/Preconditions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2.util; 21 | 22 | /** 23 | * Created by Phillip Hsu on 5/28/2016. 24 | */ 25 | public final class Preconditions { 26 | private Preconditions() {} 27 | 28 | public static T checkNotNull(T obj) { 29 | if (null == obj) 30 | throw new NullPointerException(); 31 | return obj; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/res/color/fab_icon_color.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/color/on_enabled_change_fab.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_add_24dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_add_48dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_pause_24dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_header_timesup_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_collapse_24dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_done_24dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/test/java/com/philliphsu/clock2/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2; 21 | 22 | import org.junit.Test; 23 | 24 | import static org.junit.Assert.*; 25 | 26 | /** 27 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 28 | */ 29 | public class ExampleUnitTest { 30 | @Test 31 | public void addition_isCorrect() throws Exception { 32 | assertEquals(4, 2 + 2); 33 | } 34 | } -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 21 | 24 | 64dp 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/values-v21/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 23 | 328dp 24 | 56dp 25 | 16dp 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/color/tab_icon_color.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 23 | 25 | 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/util/ConfigurationUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2.util; 21 | 22 | import android.content.res.Resources; 23 | 24 | /** 25 | * Created by Phillip Hsu on 8/30/2016. 26 | */ 27 | public final class ConfigurationUtils { 28 | 29 | public static int getOrientation(Resources res) { 30 | return res.getConfiguration().orientation; 31 | } 32 | 33 | private ConfigurationUtils() {} 34 | 35 | } 36 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/philliphsu/clock2/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2; 21 | 22 | import android.app.Application; 23 | import android.test.ApplicationTestCase; 24 | 25 | /** 26 | * Testing Fundamentals 27 | */ 28 | public class ApplicationTest extends ApplicationTestCase { 29 | public ApplicationTest() { 30 | super(Application.class); 31 | } 32 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/content_header_alarm_activity.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_minus_circle_24dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_ringtone_24dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_add_circle_24dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_snooze_24dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 21 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_snooze_48dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 21 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_error_outline_96dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/test/java/com/philliphsu/clock2/RingtoneServiceTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2; 21 | 22 | import org.junit.runner.RunWith; 23 | import org.robolectric.RobolectricGradleTestRunner; 24 | import org.robolectric.annotation.Config; 25 | 26 | /** 27 | * Created by Phillip Hsu on 5/28/2016. 28 | * 29 | * TODO: Write unit tests... 30 | */ 31 | @RunWith(RobolectricGradleTestRunner.class) 32 | @Config(constants = BuildConfig.class) 33 | public class RingtoneServiceTest { 34 | 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/list/ScrollHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2.list; 21 | 22 | /** 23 | * Created by Phillip Hsu on 7/6/2016. 24 | */ 25 | public interface ScrollHandler { 26 | /** 27 | * Specifies the stable id of the item we should scroll to in the list. 28 | * This does not scroll the list. This is useful for preparing to scroll 29 | * to the item when it does not yet exist in the list. 30 | */ 31 | void setScrollToStableId(long id); 32 | 33 | void scrollToPosition(int position); 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/data/ObjectWithId.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2.data; 21 | 22 | /** 23 | * Created by Phillip Hsu on 7/29/2016. 24 | * 25 | * Superclass for objects that can be persisted in SQLite. 26 | */ 27 | public abstract class ObjectWithId { 28 | private long id; 29 | 30 | public final long getId() { 31 | return id; 32 | } 33 | 34 | public final void setId(long id) { 35 | this.id = id; 36 | } 37 | 38 | public final int getIntId() { 39 | return (int) id; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_cancel_snooze.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 21 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 24 | 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_add_lap_40dp.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 26 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_overflow_24dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_clock_24dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_add_lap_24dp.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_vibrate_24dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_backspace_24dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/values/prefs_timers.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | Timers 23 | 24 | key_timer_ringtone 25 | Ringtone 26 | 27 | key_timer_vibrate 28 | Vibrate 29 | 30 | key_timer_silence_after 31 | @string/title_silence_after 32 | -------------------------------------------------------------------------------- /app/src/main/res/values/prefs_world_clock.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | World Clock 23 | 24 | key_show_time_offsets_from 25 | Show time offsets from 26 | Local time 27 | GMT 28 | 29 | @string/local_time 30 | @string/gmt 31 | 32 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_stopwatch_24dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_alarm_24dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/test/java/com/philliphsu/clock2/DurationUtilsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2; 21 | 22 | import com.philliphsu.clock2.util.DurationUtils; 23 | 24 | import org.junit.Test; 25 | 26 | import java.util.Arrays; 27 | import java.util.concurrent.TimeUnit; 28 | 29 | /** 30 | * Created by Phillip Hsu on 6/10/2016. 31 | */ 32 | public class DurationUtilsTest { 33 | 34 | @Test 35 | public void testBreakdown() { 36 | long duration = TimeUnit.HOURS.toMillis(45) 37 | + TimeUnit.MINUTES.toMillis(97); 38 | long[] l = DurationUtils.breakdown(duration); 39 | System.out.println(Arrays.toString(l)); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_alarm_96dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/alarms/background/OnBootUpReceiver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2.alarms.background; 21 | 22 | import android.content.BroadcastReceiver; 23 | import android.content.Context; 24 | import android.content.Intent; 25 | 26 | public class OnBootUpReceiver extends BroadcastReceiver { 27 | @Override 28 | public void onReceive(Context context, Intent intent) { 29 | // Note that this will be called when the device boots up, not when the app first launches. 30 | // We may have a lot of alarms to reschedule, so do this in the background using an IntentService. 31 | context.startService(new Intent(context, OnBootUpAlarmScheduler.class)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/res/values/aosp_datetimepicker_styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 16 | 17 | 18 | false 19 | 20 | 24 | 25 | 31 | 32 | 28 | 33 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_timer_24dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/values/prefs_general.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | General 23 | System date \u0026 time settings 24 | 25 | key_theme 26 | Theme 27 | 28 | Light 29 | Dark 30 | Black 31 | 32 | @string/theme_light 33 | @string/theme_dark 34 | @string/theme_black 35 | 36 | 37 | last_tab 38 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_timer_96dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 29 | 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/util/TimeFormatUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2.util; 21 | 22 | import android.content.Context; 23 | 24 | import java.util.Calendar; 25 | import java.util.Date; 26 | 27 | import static android.text.format.DateFormat.getTimeFormat; 28 | 29 | /** 30 | * Created by Phillip Hsu on 6/3/2016. 31 | */ 32 | public final class TimeFormatUtils { 33 | 34 | private TimeFormatUtils() {} 35 | 36 | public static String formatTime(Context context, long millis) { 37 | return getTimeFormat(context).format(new Date(millis)); 38 | } 39 | 40 | public static String formatTime(Context context, int hourOfDay, int minute) { 41 | Calendar cal = Calendar.getInstance(); 42 | cal.set(Calendar.HOUR_OF_DAY, hourOfDay); 43 | cal.set(Calendar.MINUTE, minute); 44 | return formatTime(context, cal.getTimeInMillis()); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/UntouchableSeekBar.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2; 21 | 22 | import android.content.Context; 23 | import android.support.v7.widget.AppCompatSeekBar; 24 | import android.util.AttributeSet; 25 | import android.view.MotionEvent; 26 | 27 | /** 28 | * A SeekBar that cannot be touch controlled. 29 | */ 30 | public class UntouchableSeekBar extends AppCompatSeekBar { 31 | 32 | public UntouchableSeekBar(Context context) { 33 | super(context); 34 | } 35 | 36 | public UntouchableSeekBar(Context context, AttributeSet attrs) { 37 | super(context, attrs); 38 | } 39 | 40 | public UntouchableSeekBar(Context context, AttributeSet attrs, int defStyleAttr) { 41 | super(context, attrs, defStyleAttr); 42 | } 43 | 44 | @Override 45 | public final boolean onTouchEvent(MotionEvent event) { 46 | return true; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # https://guides.codepath.com/android/Publishing-to-the-Play-Store 20 | -assumenosideeffects class android.util.Log { 21 | public static boolean isLoggable(java.lang.String, int); 22 | public static int v(...); 23 | public static int i(...); 24 | public static int w(...); 25 | public static int d(...); 26 | public static int e(...); 27 | } 28 | 29 | # https://github.com/JakeWharton/butterknife/issues/409 30 | # https://github.com/JakeWharton/butterknife/blob/master/butterknife/proguard-rules.txt 31 | # Retain generated class which implement Unbinder. 32 | -keep public class * implements butterknife.Unbinder { public (...); } 33 | 34 | # Prevent obfuscation of types which use ButterKnife annotations since the simple name 35 | # is used to reflectively look up the generated ViewBinding. 36 | -keep class butterknife.* 37 | -keepclasseswithmembernames class * { @butterknife.* ; } 38 | -keepclasseswithmembernames class * { @butterknife.* ; } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2017 Phillip Hsu 3 | # 4 | # This file is part of ClockPlus. 5 | # 6 | # ClockPlus is free software: you can redistribute it and/or modify 7 | # it under the terms of the GNU General Public License as published by 8 | # the Free Software Foundation, either version 3 of the License, or 9 | # (at your option) any later version. 10 | # 11 | # ClockPlus is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with ClockPlus. If not, see . 18 | # 19 | 20 | # Project-wide Gradle settings. 21 | 22 | # IDE (e.g. Android Studio) users: 23 | # Gradle settings configured through the IDE *will override* 24 | # any settings specified in this file. 25 | 26 | # For more details on how to configure your build environment visit 27 | # http://www.gradle.org/docs/current/userguide/build_environment.html 28 | 29 | # Specifies the JVM arguments used for the daemon process. 30 | # The setting is particularly useful for tweaking memory settings. 31 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 32 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 33 | 34 | # When configured, Gradle will run in incubating parallel mode. 35 | # This option should only be used with decoupled projects. More details, visit 36 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 37 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 21 | 22 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/stopwatch/data/LapsCursorLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2.stopwatch.data; 21 | 22 | import android.content.Context; 23 | 24 | import com.philliphsu.clock2.data.SQLiteCursorLoader; 25 | import com.philliphsu.clock2.stopwatch.Lap; 26 | 27 | /** 28 | * Created by Phillip Hsu on 8/9/2016. 29 | */ 30 | public class LapsCursorLoader extends SQLiteCursorLoader { 31 | public static final String ACTION_CHANGE_CONTENT 32 | = "com.philliphsu.clock2.stopwatch.data.action.CHANGE_CONTENT"; 33 | 34 | public LapsCursorLoader(Context context) { 35 | super(context); 36 | } 37 | 38 | @Override 39 | protected LapCursor loadCursor() { 40 | return new LapsTableManager(getContext()).queryItems(); 41 | } 42 | 43 | @Override 44 | protected String getOnContentChangeAction() { 45 | return ACTION_CHANGE_CONTENT; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_dismiss_alarm_24dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_dismiss_alarm_48dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/alarms/data/AlarmsListCursorLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2.alarms.data; 21 | 22 | import android.content.Context; 23 | 24 | import com.philliphsu.clock2.alarms.Alarm; 25 | import com.philliphsu.clock2.data.SQLiteCursorLoader; 26 | 27 | /** 28 | * Created by Phillip Hsu on 6/28/2016. 29 | */ 30 | public class AlarmsListCursorLoader extends SQLiteCursorLoader { 31 | public static final String ACTION_CHANGE_CONTENT 32 | = "com.philliphsu.clock2.alarms.data.action.CHANGE_CONTENT"; 33 | 34 | public AlarmsListCursorLoader(Context context) { 35 | super(context); 36 | } 37 | 38 | @Override 39 | protected AlarmCursor loadCursor() { 40 | return new AlarmsTableManager(getContext()).queryItems(); 41 | } 42 | 43 | @Override 44 | protected String getOnContentChangeAction() { 45 | return ACTION_CHANGE_CONTENT; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/timers/data/TimersListCursorLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2.timers.data; 21 | 22 | import android.content.Context; 23 | 24 | import com.philliphsu.clock2.timers.Timer; 25 | import com.philliphsu.clock2.data.SQLiteCursorLoader; 26 | 27 | /** 28 | * Created by Phillip Hsu on 7/29/2016. 29 | */ 30 | public class TimersListCursorLoader extends SQLiteCursorLoader { 31 | public static final String ACTION_CHANGE_CONTENT 32 | = "com.philliphsu.clock2.timers.data.action.CHANGE_CONTENT"; 33 | 34 | public TimersListCursorLoader(Context context) { 35 | super(context); 36 | } 37 | 38 | @Override 39 | protected TimerCursor loadCursor() { 40 | return new TimersTableManager(getContext()).queryItems(); 41 | } 42 | 43 | @Override 44 | protected String getOnContentChangeAction() { 45 | return ACTION_CHANGE_CONTENT; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/stopwatch/data/LapCursor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2.stopwatch.data; 21 | 22 | import android.database.Cursor; 23 | 24 | import com.philliphsu.clock2.data.BaseItemCursor; 25 | import com.philliphsu.clock2.stopwatch.Lap; 26 | 27 | /** 28 | * Created by Phillip Hsu on 8/8/2016. 29 | */ 30 | public class LapCursor extends BaseItemCursor { 31 | 32 | public LapCursor(Cursor cursor) { 33 | super(cursor); 34 | } 35 | 36 | @Override 37 | public Lap getItem() { 38 | Lap lap = new Lap(); 39 | lap.setId(getLong(getColumnIndexOrThrow(LapsTable.COLUMN_ID))); 40 | lap.setT1(getLong(getColumnIndexOrThrow(LapsTable.COLUMN_T1))); 41 | lap.setT2(getLong(getColumnIndexOrThrow(LapsTable.COLUMN_T2))); 42 | lap.setPauseTime(getLong(getColumnIndexOrThrow(LapsTable.COLUMN_PAUSE_TIME))); 43 | lap.setTotalTimeText(getString(getColumnIndexOrThrow(LapsTable.COLUMN_TOTAL_TIME_TEXT))); 44 | return lap; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles_stopwatch.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 27 | 34 | 37 | 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/util/ParcelableUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2.util; 21 | 22 | import android.os.Parcel; 23 | import android.os.Parcelable; 24 | 25 | /** 26 | * Utilities to marshall and unmarshall a {@code Parcelable} to and from a byte array. 27 | */ 28 | public final class ParcelableUtil { 29 | public static byte[] marshall(Parcelable parcelable) { 30 | Parcel parcel = Parcel.obtain(); 31 | parcelable.writeToParcel(parcel, 0); 32 | byte[] bytes = parcel.marshall(); 33 | parcel.recycle(); 34 | return bytes; 35 | } 36 | 37 | public static Parcel unmarshall(byte[] bytes) { 38 | Parcel parcel = Parcel.obtain(); 39 | parcel.unmarshall(bytes, 0, bytes.length); 40 | parcel.setDataPosition(0); // This is extremely important! 41 | return parcel; 42 | } 43 | 44 | public static T unmarshall(byte[] bytes, Parcelable.Creator creator) { 45 | Parcel parcel = unmarshall(bytes); 46 | T result = creator.createFromParcel(parcel); 47 | parcel.recycle(); 48 | return result; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/util/KeyboardUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2.util; 21 | 22 | import android.app.Activity; 23 | import android.content.Context; 24 | import android.view.View; 25 | import android.view.inputmethod.InputMethodManager; 26 | 27 | /** 28 | * Created by Phillip Hsu on 6/5/2016. 29 | */ 30 | public class KeyboardUtils { 31 | 32 | public static void hideKeyboard(Activity a) { 33 | View view = a.getCurrentFocus(); 34 | if (view != null) { 35 | InputMethodManager imm = (InputMethodManager) 36 | a.getSystemService(Context.INPUT_METHOD_SERVICE); 37 | imm.hideSoftInputFromWindow(view.getWindowToken(), 0); 38 | } 39 | } 40 | 41 | /** 42 | * @param c The Context to retrieve the system's input method service 43 | * @param v The currently focused view, which would like to receive soft keyboard input. 44 | */ 45 | public static void showKeyboard(Context c, View v) { 46 | InputMethodManager imm = (InputMethodManager) c.getSystemService(Context.INPUT_METHOD_SERVICE); 47 | imm.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/dialogs/AddLabelDialogController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2.dialogs; 21 | 22 | import android.support.v4.app.FragmentManager; 23 | import android.util.Log; 24 | 25 | /** 26 | * Created by Phillip Hsu on 9/6/2016. 27 | */ 28 | public final class AddLabelDialogController extends DialogFragmentController { 29 | private static final String TAG = "AddLabelController"; 30 | 31 | private final AddLabelDialog.OnLabelSetListener mListener; 32 | 33 | public AddLabelDialogController(FragmentManager fragmentManager, AddLabelDialog.OnLabelSetListener listener) { 34 | super(fragmentManager); 35 | mListener = listener; 36 | } 37 | 38 | public void show(CharSequence initialText, String tag) { 39 | AddLabelDialog dialog = AddLabelDialog.newInstance(mListener, initialText); 40 | show(dialog, tag); 41 | } 42 | 43 | @Override 44 | public void tryRestoreCallback(String tag) { 45 | AddLabelDialog labelDialog = findDialog(tag); 46 | if (labelDialog != null) { 47 | Log.i(TAG, "Restoring add label callback"); 48 | labelDialog.setOnLabelSetListener(mListener); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_settings_24dp.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 25 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/stopwatch/ui/ChronometerWithMillis.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.philliphsu.clock2.stopwatch.ui; 18 | 19 | import android.annotation.TargetApi; 20 | import android.content.Context; 21 | import android.util.AttributeSet; 22 | 23 | import com.philliphsu.clock2.chronometer.BaseChronometer; 24 | 25 | /** 26 | * Created by Phillip Hsu on 8/9/2016. 27 | * 28 | * A modified version of the framework's Chronometer widget that shows 29 | * up to hundredths of a second. 30 | */ 31 | public class ChronometerWithMillis extends BaseChronometer { 32 | private static final String TAG = "ChronometerWithMillis"; 33 | 34 | public ChronometerWithMillis(Context context) { 35 | this(context, null, 0); 36 | } 37 | 38 | public ChronometerWithMillis(Context context, AttributeSet attrs) { 39 | this(context, attrs, 0); 40 | } 41 | 42 | public ChronometerWithMillis(Context context, AttributeSet attrs, int defStyleAttr) { 43 | super(context, attrs, defStyleAttr); 44 | init(); 45 | } 46 | 47 | @TargetApi(21) 48 | public ChronometerWithMillis(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 49 | super(context, attrs, defStyleAttr, defStyleRes); 50 | init(); 51 | } 52 | 53 | private void init() { 54 | setShowCentiseconds(true, false); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/timers/ui/TimersCursorAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2.timers.ui; 21 | 22 | import android.view.ViewGroup; 23 | 24 | import com.philliphsu.clock2.timers.data.AsyncTimersTableUpdateHandler; 25 | import com.philliphsu.clock2.list.BaseCursorAdapter; 26 | import com.philliphsu.clock2.list.OnListItemInteractionListener; 27 | import com.philliphsu.clock2.timers.Timer; 28 | import com.philliphsu.clock2.timers.data.TimerCursor; 29 | 30 | /** 31 | * Created by Phillip Hsu on 7/29/2016. 32 | */ 33 | public class TimersCursorAdapter extends BaseCursorAdapter { 34 | 35 | private final AsyncTimersTableUpdateHandler mAsyncTimersTableUpdateHandler; 36 | 37 | public TimersCursorAdapter(OnListItemInteractionListener listener, 38 | AsyncTimersTableUpdateHandler asyncTimersTableUpdateHandler) { 39 | super(listener); 40 | mAsyncTimersTableUpdateHandler = asyncTimersTableUpdateHandler; 41 | } 42 | 43 | @Override 44 | protected TimerViewHolder onCreateViewHolder(ViewGroup parent, OnListItemInteractionListener listener, int viewType) { 45 | return new TimerViewHolder(parent, listener, mAsyncTimersTableUpdateHandler); 46 | } 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/timers/ui/CountdownChronometer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2008 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.philliphsu.clock2.timers.ui; 18 | 19 | import android.annotation.TargetApi; 20 | import android.content.Context; 21 | import android.util.AttributeSet; 22 | 23 | import com.philliphsu.clock2.chronometer.BaseChronometer; 24 | 25 | /** 26 | * Created by Phillip Hsu on 7/25/2016. 27 | * 28 | * A modified version of the framework's Chronometer widget to count down 29 | * towards the base time. The ability to count down was added to Chronometer 30 | * in API 24. 31 | */ 32 | public class CountdownChronometer extends BaseChronometer { 33 | private static final String TAG = "CountdownChronometer"; 34 | 35 | public CountdownChronometer(Context context) { 36 | this(context, null, 0); 37 | } 38 | 39 | public CountdownChronometer(Context context, AttributeSet attrs) { 40 | this(context, attrs, 0); 41 | } 42 | 43 | public CountdownChronometer(Context context, AttributeSet attrs, int defStyleAttr) { 44 | super(context, attrs, defStyleAttr); 45 | init(); 46 | } 47 | 48 | @TargetApi(21) 49 | public CountdownChronometer(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 50 | super(context, attrs, defStyleAttr, defStyleRes); 51 | init(); 52 | } 53 | 54 | private void init() { 55 | setCountDown(true); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/data/BaseItemCursor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2.data; 21 | 22 | import android.database.Cursor; 23 | import android.database.CursorWrapper; 24 | import android.util.Log; 25 | 26 | /** 27 | * Created by Phillip Hsu on 7/29/2016. 28 | */ 29 | public abstract class BaseItemCursor extends CursorWrapper { 30 | private static final String TAG = "BaseItemCursor"; 31 | 32 | public BaseItemCursor(Cursor cursor) { 33 | super(cursor); 34 | } 35 | 36 | /** 37 | * @return an item instance configured for the current row, 38 | * or null if the current row is invalid 39 | */ 40 | public abstract T getItem(); 41 | 42 | public long getId() { 43 | if (isBeforeFirst() || isAfterLast()) { 44 | Log.e(TAG, "Failed to retrieve id, cursor out of range"); 45 | return -1; 46 | } 47 | return getLong(getColumnIndexOrThrow("_id")); // TODO: Refer to a constant instead of a hardcoded value 48 | } 49 | 50 | /** 51 | * Helper method to determine boolean-valued columns. 52 | * SQLite does not support a BOOLEAN data type. 53 | */ 54 | protected boolean isTrue(String columnName) { 55 | return getInt(getColumnIndexOrThrow(columnName)) == 1; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/util/ContentIntentUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2.util; 21 | 22 | import android.app.PendingIntent; 23 | import android.content.Context; 24 | import android.content.Intent; 25 | import android.support.annotation.NonNull; 26 | 27 | import com.philliphsu.clock2.MainActivity; 28 | import com.philliphsu.clock2.list.RecyclerViewFragment; 29 | 30 | import static android.app.PendingIntent.FLAG_CANCEL_CURRENT; 31 | 32 | /** 33 | * Created by Phillip Hsu on 9/28/2016. 34 | * 35 | * Helper to create content intents for e.g. notifications that should 36 | * open the app, scroll to the specified page, and then scroll to the 37 | * item with the specified stable id. 38 | */ 39 | public final class ContentIntentUtils { 40 | 41 | public static PendingIntent create(@NonNull Context context, int targetPage, long stableId) { 42 | Intent intent = new Intent(context, MainActivity.class) 43 | .setAction(RecyclerViewFragment.ACTION_SCROLL_TO_STABLE_ID) 44 | .putExtra(MainActivity.EXTRA_SHOW_PAGE, targetPage) 45 | .putExtra(RecyclerViewFragment.EXTRA_SCROLL_TO_STABLE_ID, stableId); 46 | return PendingIntent.getActivity(context, (int) stableId, intent, FLAG_CANCEL_CURRENT); 47 | } 48 | 49 | private ContentIntentUtils() {} 50 | } 51 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_lap.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 26 | 27 | 34 | 35 | 42 | 43 | 50 | 51 | -------------------------------------------------------------------------------- /app/src/main/res/values-land/dimens.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 21 | 24sp 22 | 23 | 24 | 42dp 25 | 26 | 27 | 28 | 29 | 30 | 31 | 55dp 32 | 44dp 33 | 34 | 72dp 35 | 26sp 36 | 20sp 37 | 38 | 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Clock+ 2 | Clock+ is a simple alarm clock, timer, and stopwatch app that offers a delightful user experience 3 | for all your timing needs. 4 | 5 | Highlights: 6 | 7 | - **Clean, minimalistic design:** Features Material Design throughout. 8 | - **New time pickers:** Enjoy setting alarms with two new time pickers! Beautifully crafted and 9 | intuitively designed for ease of use. 10 | - **List of timers:** See all of your timers in one scrollable list, and control each one individually. 11 | - **Themes:** Choose between light, dark, and black themes. 12 | 13 | [Get it on Google Play](https://play.google.com/store/apps/details?id=com.philliphsu.clock2) 16 | [Get it on F-Droid](https://f-droid.org/app/com.philliphsu.clock2) 19 | 20 | 21 | 22 | 23 | 24 | ## License 25 | ``` 26 | Copyright 2017 Phillip Hsu 27 | 28 | This file is part of ClockPlus. 29 | 30 | ClockPlus is free software: you can redistribute it and/or modify 31 | it under the terms of the GNU General Public License as published by 32 | the Free Software Foundation, either version 3 of the License, or 33 | (at your option) any later version. 34 | 35 | ClockPlus is distributed in the hope that it will be useful, 36 | but WITHOUT ANY WARRANTY; without even the implied warranty of 37 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 38 | GNU General Public License for more details. 39 | 40 | You should have received a copy of the GNU General Public License 41 | along with ClockPlus. If not, see . 42 | ``` 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/util/TimeTextUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2.util; 21 | 22 | import android.text.SpannableString; 23 | import android.text.Spanned; 24 | import android.text.style.RelativeSizeSpan; 25 | import android.widget.TextView; 26 | 27 | /** 28 | * Created by Phillip Hsu on 7/16/2016. 29 | */ 30 | public class TimeTextUtils { 31 | 32 | private TimeTextUtils() {} 33 | 34 | private static final RelativeSizeSpan AMPM_SIZE_SPAN = new RelativeSizeSpan(0.5f); 35 | 36 | /** 37 | * Sets the given String on the TextView. 38 | * If the given String contains the "AM" or "PM" label, 39 | * this first applies a size span on the label. 40 | * @param textTime the time String that may contain "AM" or "PM" 41 | * @param textView the TextView to display {@code textTime} 42 | */ 43 | public static void setText(String textTime, TextView textView) { 44 | if (textTime.contains("AM") || textTime.contains("PM")) { 45 | SpannableString s = new SpannableString(textTime); 46 | s.setSpan(AMPM_SIZE_SPAN, textTime.indexOf(" "), textTime.length(), 47 | Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); 48 | textView.setText(s, TextView.BufferType.SPANNABLE); 49 | } else { 50 | textView.setText(textTime); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | #1C46A0 23 | #143782 24 | #FF5252 25 | #2355BE 26 | 27 | #212121 28 | @android:color/black 29 | 30 | #FF5252 31 | #303030 32 | 33 | #FF5252 34 | 35 | @color/alert_dialog_background_color 36 | @color/alert_dialog_background_color_inverse 37 | @color/alert_dialog_background_color_black 38 | 39 | @color/colorPrimaryFallback 40 | @color/colorPrimaryFallbackInverse 41 | @android:color/black 42 | 43 | #4dffffff 44 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/dialogs/RingtonePickerDialogController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2.dialogs; 21 | 22 | import android.net.Uri; 23 | import android.support.v4.app.FragmentManager; 24 | import android.util.Log; 25 | 26 | import com.philliphsu.clock2.dialogs.DialogFragmentController; 27 | import com.philliphsu.clock2.dialogs.RingtonePickerDialog; 28 | 29 | /** 30 | * Created by Phillip Hsu on 9/20/2016. 31 | */ 32 | public class RingtonePickerDialogController extends DialogFragmentController { 33 | private static final String TAG = "RingtonePickerCtrller"; 34 | 35 | private final RingtonePickerDialog.OnRingtoneSelectedListener mListener; 36 | 37 | public RingtonePickerDialogController(FragmentManager fragmentManager, RingtonePickerDialog.OnRingtoneSelectedListener l) { 38 | super(fragmentManager); 39 | mListener = l; 40 | } 41 | 42 | public void show(Uri initialUri, String tag) { 43 | RingtonePickerDialog dialog = RingtonePickerDialog.newInstance(mListener, initialUri); 44 | show(dialog, tag); 45 | } 46 | 47 | @Override 48 | public void tryRestoreCallback(String tag) { 49 | RingtonePickerDialog dialog = findDialog(tag); 50 | if (dialog != null) { 51 | Log.i(TAG, "Restoring on ringtone selected callback"); 52 | dialog.setOnRingtoneSelectedListener(mListener); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/timers/data/TimerCursor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2.timers.data; 21 | 22 | import android.database.Cursor; 23 | 24 | import com.philliphsu.clock2.timers.Timer; 25 | import com.philliphsu.clock2.data.BaseItemCursor; 26 | 27 | /** 28 | * Created by Phillip Hsu on 7/30/2016. 29 | */ 30 | public class TimerCursor extends BaseItemCursor { 31 | 32 | public TimerCursor(Cursor cursor) { 33 | super(cursor); 34 | } 35 | 36 | @Override 37 | public Timer getItem() { 38 | if (isBeforeFirst() || isAfterLast()) 39 | return null; 40 | int hour = getInt(getColumnIndexOrThrow(TimersTable.COLUMN_HOUR)); 41 | int minute = getInt(getColumnIndexOrThrow(TimersTable.COLUMN_MINUTE)); 42 | int second = getInt(getColumnIndexOrThrow(TimersTable.COLUMN_SECOND)); 43 | String label = getString(getColumnIndexOrThrow(TimersTable.COLUMN_LABEL)); 44 | // String group = getString(getColumnIndexOrThrow(COLUMN_GROUP)); 45 | Timer t = Timer.create(hour, minute, second, ""/*group*/, label); 46 | t.setId(getLong(getColumnIndexOrThrow(TimersTable.COLUMN_ID))); 47 | t.setEndTime(getLong(getColumnIndexOrThrow(TimersTable.COLUMN_END_TIME))); 48 | t.setPauseTime(getLong(getColumnIndexOrThrow(TimersTable.COLUMN_PAUSE_TIME))); 49 | t.setDuration(getLong(getColumnIndexOrThrow(TimersTable.COLUMN_DURATION))); 50 | return t; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /app/src/main/java/com/philliphsu/clock2/alarms/misc/AlarmPreferences.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Phillip Hsu 3 | * 4 | * This file is part of ClockPlus. 5 | * 6 | * ClockPlus is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation, either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * ClockPlus is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with ClockPlus. If not, see . 18 | */ 19 | 20 | package com.philliphsu.clock2.alarms.misc; 21 | 22 | import android.content.Context; 23 | import android.preference.PreferenceManager; 24 | import android.support.annotation.StringRes; 25 | 26 | import com.philliphsu.clock2.R; 27 | 28 | /** 29 | * Created by Phillip Hsu on 6/3/2016. 30 | * 31 | * Utilities for reading alarm preferences. 32 | */ 33 | public final class AlarmPreferences { 34 | private static final String TAG = "AlarmPreferences"; 35 | 36 | private AlarmPreferences() {} 37 | 38 | public static int snoozeDuration(Context c) { 39 | return readPreference(c, R.string.key_snooze_duration, 10); 40 | } 41 | 42 | // TODO: Consider renaming to hoursToNotifyInAdvance() 43 | public static int hoursBeforeUpcoming(Context c) { 44 | return readPreference(c, R.string.key_notify_me_of_upcoming_alarms, 2); 45 | } 46 | 47 | public static int minutesToSilenceAfter(Context c) { 48 | return readPreference(c, R.string.key_silence_after, 15); 49 | } 50 | 51 | public static int firstDayOfWeek(Context c) { 52 | return readPreference(c, R.string.key_first_day_of_week, 0 /* Sunday */); 53 | } 54 | 55 | public static int readPreference(Context c, @StringRes int key, int defaultValue) { 56 | String value = PreferenceManager.getDefaultSharedPreferences(c).getString(c.getString(key), null); 57 | return null == value ? defaultValue : Integer.parseInt(value); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/src/main/res/layout/alarm_time_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 27 | 28 | 36 | 37 | 41 | 42 | 47 | 48 | 50 | 55 | 56 | -------------------------------------------------------------------------------- /app/src/main/res/layout/content_grid_layout_numpad.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 23 |