├── snap-time-picker ├── gradle.properties ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ ├── res │ │ ├── drawable │ │ │ ├── snap_time_picker_shape_background_white.xml │ │ │ ├── snap_time_picker_shadow_bottom_translucent_white.xml │ │ │ ├── snap_time_picker_shadow_top_translucent_white.xml │ │ │ ├── snap_time_picker_shape_button_disable_round.xml │ │ │ ├── snap_time_picker_shape_button_translucent_black_round_pressed.xml │ │ │ ├── snap_time_picker_shape_button_transparent_round_normal.xml │ │ │ └── snap_time_picker_selector_button_translucent_black_round.xml │ │ ├── values │ │ │ ├── strings.xml │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ └── styles.xml │ │ ├── drawable-v21 │ │ │ └── snap_time_picker_selector_button_translucent_black_round.xml │ │ └── layout │ │ │ ├── layout_snap_time_picker_number_item.xml │ │ │ └── layout_snap_time_picker_dialog.xml │ │ └── java │ │ └── com │ │ └── akexorcist │ │ └── snaptimepicker │ │ ├── TimeValue.kt │ │ ├── TimeRange.kt │ │ ├── extension │ │ ├── SnapTimePickerViewModel.kt │ │ ├── TimePickedEvent.kt │ │ ├── SnapTimePickerUtil.kt │ │ └── TimePickedLiveData.kt │ │ ├── TimeNumberViewHolder.kt │ │ ├── TimePickerAdapter.kt │ │ ├── BaseSnapTimePickerDialogFragment.kt │ │ └── SnapTimePickerDialog.kt ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── image ├── 02_text.jpg ├── 03_color.jpg ├── 00_header.gif ├── 01_default.jpg └── 04_time_range.jpg ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── app ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── drawable │ │ │ │ ├── shape_gradient_bottom.xml │ │ │ │ └── ic_launcher_background.xml │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── styles.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── strings.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ │ └── layout │ │ │ │ └── activity_main.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── akexorcist │ │ │ └── snaptimepicker │ │ │ └── sample │ │ │ └── MainActivity.kt │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── akexorcist │ │ │ └── snaptimepicker │ │ │ └── ExampleUnitTest.kt │ └── androidTest │ │ └── java │ │ └── com │ │ └── akexorcist │ │ └── snaptimepicker │ │ └── ExampleInstrumentedTest.kt ├── proguard-rules.pro └── build.gradle ├── .github └── workflows │ └── android.yml ├── gradle.properties ├── .gitignore ├── gradlew.bat ├── publish └── mavencentral.gradle ├── README.md ├── gradlew └── LICENSE.txt /snap-time-picker/gradle.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':snap-time-picker' 2 | -------------------------------------------------------------------------------- /image/02_text.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/SnapTimePicker/HEAD/image/02_text.jpg -------------------------------------------------------------------------------- /image/03_color.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/SnapTimePicker/HEAD/image/03_color.jpg -------------------------------------------------------------------------------- /image/00_header.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/SnapTimePicker/HEAD/image/00_header.gif -------------------------------------------------------------------------------- /image/01_default.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/SnapTimePicker/HEAD/image/01_default.jpg -------------------------------------------------------------------------------- /image/04_time_range.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/SnapTimePicker/HEAD/image/04_time_range.jpg -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/SnapTimePicker/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/SnapTimePicker/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/SnapTimePicker/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/SnapTimePicker/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/SnapTimePicker/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/SnapTimePicker/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/SnapTimePicker/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/SnapTimePicker/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/SnapTimePicker/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/SnapTimePicker/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akexorcist/SnapTimePicker/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /snap-time-picker/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /snap-time-picker/src/main/res/drawable/snap_time_picker_shape_background_white.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Jan 10 00:57:30 ICT 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip 7 | -------------------------------------------------------------------------------- /snap-time-picker/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | @android:string/cancel 3 | @android:string/ok 4 | : 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_gradient_bottom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /snap-time-picker/src/main/java/com/akexorcist/snaptimepicker/TimeValue.kt: -------------------------------------------------------------------------------- 1 | package com.akexorcist.snaptimepicker 2 | 3 | import android.os.Parcelable 4 | import kotlinx.parcelize.Parcelize 5 | 6 | @Parcelize 7 | data class TimeValue( 8 | var hour: Int, 9 | var minute: Int 10 | ) : Parcelable -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | #FFFFFF 7 | 8 | -------------------------------------------------------------------------------- /snap-time-picker/src/main/java/com/akexorcist/snaptimepicker/TimeRange.kt: -------------------------------------------------------------------------------- 1 | package com.akexorcist.snaptimepicker 2 | 3 | import android.os.Parcelable 4 | import kotlinx.parcelize.Parcelize 5 | 6 | @Parcelize 7 | data class TimeRange( 8 | var start: TimeValue?, 9 | var end: TimeValue? 10 | ) : Parcelable 11 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /snap-time-picker/src/main/res/drawable/snap_time_picker_shadow_bottom_translucent_white.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /snap-time-picker/src/main/res/drawable/snap_time_picker_shadow_top_translucent_white.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /snap-time-picker/src/main/java/com/akexorcist/snaptimepicker/extension/SnapTimePickerViewModel.kt: -------------------------------------------------------------------------------- 1 | package com.akexorcist.snaptimepicker.extension 2 | 3 | import androidx.lifecycle.ViewModel 4 | 5 | class SnapTimePickerViewModel : ViewModel() { 6 | val timePickedEvent = 7 | TimePickedLiveData() 8 | 9 | fun onTimePicked(hour: Int, minute: Int) { 10 | timePickedEvent.value = TimePickedEvent(hour, minute) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /app/src/test/java/com/akexorcist/snaptimepicker/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.akexorcist.snaptimepicker 2 | 3 | import org.junit.Test 4 | 5 | import org.junit.Assert.* 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * See [testing documentation](http://d.android.com/tools/testing). 11 | */ 12 | class ExampleUnitTest { 13 | @Test 14 | fun addition_isCorrect() { 15 | assertEquals(4, 2 + 2) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /snap-time-picker/src/main/java/com/akexorcist/snaptimepicker/TimeNumberViewHolder.kt: -------------------------------------------------------------------------------- 1 | package com.akexorcist.snaptimepicker 2 | 3 | import androidx.recyclerview.widget.RecyclerView 4 | import com.akexorcist.snaptimepicker.databinding.LayoutSnapTimePickerNumberItemBinding 5 | 6 | class TimeNumberViewHolder( 7 | private val binding: LayoutSnapTimePickerNumberItemBinding 8 | ) : RecyclerView.ViewHolder(binding.root) { 9 | fun setNumber(number: String?) { 10 | binding.textViewNumber.text = number ?: "-" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8dp 4 | 16dp 5 | 24dp 6 | 32dp 7 | 16sp 8 | 48sp 9 | 8dp 10 | 200dp 11 | -------------------------------------------------------------------------------- /.github/workflows/android.yml: -------------------------------------------------------------------------------- 1 | name: Android CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | test: 11 | name: Unit Test 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: set up JDK 1.8 17 | uses: actions/setup-java@v1 18 | with: 19 | java-version: 1.8 20 | - name: Grant execute permission for gradlew 21 | run: chmod +x gradlew 22 | 23 | - name: Run Unit test 24 | run: ./gradlew test 25 | -------------------------------------------------------------------------------- /snap-time-picker/src/main/res/drawable-v21/snap_time_picker_selector_button_translucent_black_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /snap-time-picker/src/main/res/drawable/snap_time_picker_shape_button_disable_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | -------------------------------------------------------------------------------- /snap-time-picker/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #00ffffff 4 | #FFFFFF 5 | #333333 6 | #0c000000 7 | #008577 8 | #D81B60 9 | #c2c2c2 10 | #ebebeb 11 | -------------------------------------------------------------------------------- /snap-time-picker/src/main/res/drawable/snap_time_picker_shape_button_translucent_black_round_pressed.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | -------------------------------------------------------------------------------- /snap-time-picker/src/main/res/drawable/snap_time_picker_shape_button_transparent_round_normal.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | -------------------------------------------------------------------------------- /snap-time-picker/src/main/res/drawable/snap_time_picker_selector_button_translucent_black_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/akexorcist/snaptimepicker/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.akexorcist.snaptimepicker 2 | 3 | import androidx.test.InstrumentationRegistry 4 | import androidx.test.runner.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getTargetContext() 22 | assertEquals("com.akexorcist.snaptimepicker", appContext.packageName) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /snap-time-picker/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Snap Time Picker 3 | Please select the time 4 | Your selected time is 5 | - 6 | %1$s:%2$s 7 | >> 8 | << 9 | No Custom 10 | Full Custom 11 | Pre-selected Time 12 | Time Range 13 | ViewModel Callback 14 | Time Interval 15 | 16 | -------------------------------------------------------------------------------- /snap-time-picker/src/main/java/com/akexorcist/snaptimepicker/extension/TimePickedEvent.kt: -------------------------------------------------------------------------------- 1 | package com.akexorcist.snaptimepicker.extension 2 | 3 | import android.os.Parcel 4 | import android.os.Parcelable 5 | 6 | data class TimePickedEvent(val hour: Int, val minute: Int) : Parcelable { 7 | constructor(parcel: Parcel) : this( 8 | parcel.readInt(), 9 | parcel.readInt() 10 | ) 11 | 12 | override fun writeToParcel(parcel: Parcel, flags: Int) { 13 | parcel.writeInt(hour) 14 | parcel.writeInt(minute) 15 | } 16 | 17 | override fun describeContents(): Int { 18 | return 0 19 | } 20 | 21 | companion object CREATOR : Parcelable.Creator { 22 | override fun createFromParcel(parcel: Parcel): TimePickedEvent { 23 | return TimePickedEvent(parcel) 24 | } 25 | 26 | override fun newArray(size: Int): Array { 27 | return arrayOfNulls(size) 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /snap-time-picker/src/main/java/com/akexorcist/snaptimepicker/extension/SnapTimePickerUtil.kt: -------------------------------------------------------------------------------- 1 | package com.akexorcist.snaptimepicker.extension 2 | 3 | import androidx.fragment.app.Fragment 4 | import androidx.fragment.app.FragmentActivity 5 | import androidx.lifecycle.ViewModelProvider 6 | 7 | @Suppress("unused") 8 | object SnapTimePickerUtil { 9 | fun observe(activity: FragmentActivity, onPickedEvent: (hour: Int, minute: Int) -> Unit): Unit = 10 | ViewModelProvider(activity) 11 | .get(SnapTimePickerViewModel::class.java) 12 | .timePickedEvent 13 | .observe(activity, { event: TimePickedEvent -> 14 | onPickedEvent(event.hour, event.minute) 15 | }) 16 | 17 | fun observe(fragment: Fragment, onPickedEvent: (hour: Int, minute: Int) -> Unit) = 18 | ViewModelProvider(fragment) 19 | .get(SnapTimePickerViewModel::class.java) 20 | .timePickedEvent 21 | .observe(fragment, { event: TimePickedEvent -> 22 | onPickedEvent(event.hour, event.minute) 23 | }) 24 | } 25 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # IntelliJ 36 | *.iml 37 | .idea/workspace.xml 38 | .idea/tasks.xml 39 | .idea/gradle.xml 40 | .idea/assetWizardSettings.xml 41 | .idea/dictionaries 42 | .idea/libraries 43 | .idea/caches 44 | 45 | # Keystore files 46 | # Uncomment the following line if you do not want to check your keystore files in. 47 | #*.jks 48 | 49 | # External native build folder generated in Android Studio 2.2 and later 50 | .externalNativeBuild 51 | 52 | # Google Services (e.g. APIs or Firebase) 53 | google-services.json 54 | 55 | # Freeline 56 | freeline.py 57 | freeline/ 58 | freeline_project_description.json 59 | 60 | # fastlane 61 | fastlane/report.xml 62 | fastlane/Preview.html 63 | fastlane/screenshots 64 | fastlane/test_output 65 | fastlane/readme.md 66 | .idea 67 | *.gpg 68 | -------------------------------------------------------------------------------- /snap-time-picker/src/main/res/layout/layout_snap_time_picker_number_item.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 23 | 24 | -------------------------------------------------------------------------------- /snap-time-picker/src/main/java/com/akexorcist/snaptimepicker/extension/TimePickedLiveData.kt: -------------------------------------------------------------------------------- 1 | package com.akexorcist.snaptimepicker.extension 2 | 3 | import android.util.Log 4 | import androidx.annotation.MainThread 5 | import androidx.lifecycle.LifecycleOwner 6 | import androidx.lifecycle.MutableLiveData 7 | import androidx.lifecycle.Observer 8 | import java.util.concurrent.atomic.AtomicBoolean 9 | 10 | class TimePickedLiveData : MutableLiveData() { 11 | private val mPending = AtomicBoolean(false) 12 | 13 | companion object { 14 | private const val TAG = "TimePickedLiveData" 15 | } 16 | 17 | @MainThread 18 | override fun observe(owner: LifecycleOwner, observer: Observer) { 19 | 20 | if (hasActiveObservers()) { 21 | Log.w(TAG, "Multiple observers registered but only one will be notified of changes.") 22 | } 23 | 24 | // Observe the internal MutableLiveData 25 | super.observe(owner, { value -> 26 | if (mPending.compareAndSet(true, false)) { 27 | observer.onChanged(value) 28 | } 29 | }) 30 | } 31 | 32 | @MainThread 33 | override fun setValue(value: T?) { 34 | mPending.set(true) 35 | super.setValue(value) 36 | } 37 | 38 | @Suppress("unused") 39 | @MainThread 40 | fun call() { 41 | value = null 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /snap-time-picker/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 300dp 4 | 300dp 5 | 64dp 6 | 8dp 7 | 16dp 8 | 4dp 9 | 2dp 10 | 1dp 11 | 60dp 12 | 80dp 13 | 50dp 14 | 36dp 15 | 4dp 16 | 1dp 17 | 18 | 12sp 19 | 14sp 20 | 16sp 21 | 18sp 22 | 22sp 23 | 28sp 24 | -------------------------------------------------------------------------------- /snap-time-picker/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 | 26 | 27 | 32 | -------------------------------------------------------------------------------- /snap-time-picker/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-parcelize' 4 | apply plugin: 'org.jetbrains.dokka-android' 5 | 6 | android { 7 | compileSdkVersion project.compileSdkVersion 8 | 9 | defaultConfig { 10 | minSdkVersion project.minSdkVersion 11 | targetSdkVersion project.targetSdkVersion 12 | versionCode project.versionCode 13 | versionName project.versionName 14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | compileOptions { 23 | sourceCompatibility JavaVersion.VERSION_1_8 24 | targetCompatibility JavaVersion.VERSION_1_8 25 | } 26 | kotlinOptions { 27 | jvmTarget = '1.8' 28 | } 29 | buildFeatures { 30 | viewBinding = true 31 | } 32 | } 33 | 34 | dokka { 35 | outputFormat = 'html' 36 | outputDirectory = "$buildDir/javadoc" 37 | } 38 | 39 | dependencies { 40 | implementation fileTree(include: ['*.jar'], dir: 'libs') 41 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 42 | implementation 'androidx.appcompat:appcompat:1.2.0' 43 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4' 44 | implementation "androidx.recyclerview:recyclerview:1.2.0" 45 | implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" 46 | } 47 | 48 | //apply from: '../publish/mavencentral.gradle' 49 | -------------------------------------------------------------------------------- /snap-time-picker/src/main/java/com/akexorcist/snaptimepicker/TimePickerAdapter.kt: -------------------------------------------------------------------------------- 1 | package com.akexorcist.snaptimepicker 2 | 3 | import android.view.LayoutInflater 4 | import android.view.ViewGroup 5 | import androidx.recyclerview.widget.RecyclerView 6 | import com.akexorcist.snaptimepicker.databinding.LayoutSnapTimePickerNumberItemBinding 7 | 8 | class TimePickerAdapter : RecyclerView.Adapter() { 9 | private var itemList: List? = null 10 | 11 | override fun onCreateViewHolder(parent: ViewGroup, type: Int): TimeNumberViewHolder = 12 | TimeNumberViewHolder( 13 | LayoutSnapTimePickerNumberItemBinding.inflate( 14 | LayoutInflater.from( 15 | parent.context 16 | ), parent, false 17 | ) 18 | ) 19 | 20 | override fun getItemCount(): Int = itemList?.size ?: 0 21 | 22 | override fun onBindViewHolder(holder: TimeNumberViewHolder, position: Int) { 23 | val item = itemList?.get(position) 24 | holder.setNumber(item?.toString()?.padStart(2, '0')) 25 | } 26 | 27 | fun setItemList(itemList: List?) { 28 | this.itemList = itemList 29 | notifyDataSetChanged() 30 | } 31 | 32 | fun getPositionByValue(value: Int): Int { 33 | itemList?.forEachIndexed { index, item -> 34 | if (value == item) { 35 | return index 36 | } 37 | } 38 | return -1 39 | } 40 | 41 | fun getValueByPosition(position: Int): Int { 42 | itemList?.forEachIndexed { index, item -> 43 | if (position == index) { 44 | return item 45 | } 46 | } 47 | return -1 48 | } 49 | } -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-parcelize' 4 | 5 | android { 6 | compileSdkVersion project.compileSdkVersion 7 | defaultConfig { 8 | applicationId "com.akexorcist.snaptimepicker.sample" 9 | minSdkVersion project.minSdkVersion 10 | targetSdkVersion project.targetSdkVersion 11 | versionCode project.versionCode 12 | versionName project.versionName 13 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | compileOptions { 22 | sourceCompatibility JavaVersion.VERSION_1_8 23 | targetCompatibility JavaVersion.VERSION_1_8 24 | } 25 | kotlinOptions { 26 | jvmTarget = '1.8' 27 | } 28 | buildFeatures { 29 | viewBinding = true 30 | } 31 | } 32 | 33 | dependencies { 34 | implementation fileTree(include: ['*.jar'], dir: 'libs') 35 | implementation project(':snap-time-picker') 36 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 37 | implementation 'androidx.appcompat:appcompat:1.2.0' 38 | implementation 'androidx.core:core-ktx:1.3.2' 39 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4' 40 | implementation "androidx.lifecycle:lifecycle-extensions:2.2.0" 41 | testImplementation 'junit:junit:4.13.2' 42 | androidTestImplementation 'androidx.test:runner:1.3.0' 43 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /snap-time-picker/src/main/java/com/akexorcist/snaptimepicker/BaseSnapTimePickerDialogFragment.kt: -------------------------------------------------------------------------------- 1 | package com.akexorcist.snaptimepicker 2 | 3 | import android.app.Dialog 4 | import android.graphics.Color 5 | import android.graphics.drawable.ColorDrawable 6 | import android.os.Bundle 7 | import android.view.LayoutInflater 8 | import android.view.View 9 | import android.view.Window 10 | import androidx.annotation.LayoutRes 11 | import androidx.appcompat.app.AlertDialog 12 | import androidx.fragment.app.DialogFragment 13 | 14 | abstract class BaseSnapTimePickerDialogFragment : DialogFragment() { 15 | 16 | lateinit var rootView: View 17 | 18 | override fun onCreate(savedInstanceState: Bundle?) { 19 | super.onCreate(savedInstanceState) 20 | savedInstanceState?.let { bundle -> 21 | restoreInstanceState(bundle) 22 | } ?: run { 23 | restoreArgument(arguments) 24 | } 25 | } 26 | 27 | override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { 28 | val builder = AlertDialog.Builder(requireContext()) 29 | val view = setupLayoutView() 30 | rootView = view 31 | builder.setView(view) 32 | val dialog = builder.create() 33 | dialog.requestWindowFeature(Window.FEATURE_NO_TITLE) 34 | dialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) 35 | return dialog 36 | } 37 | 38 | override fun onActivityCreated(savedInstanceState: Bundle?) { 39 | super.onActivityCreated(savedInstanceState) 40 | prepare() 41 | savedInstanceState?.let { 42 | restore() 43 | } ?: run { 44 | initialize() 45 | } 46 | setup() 47 | } 48 | 49 | override fun onSaveInstanceState(outState: Bundle) { 50 | super.onSaveInstanceState(outState) 51 | saveInstanceState(outState) 52 | } 53 | 54 | abstract fun setupLayoutView(): View 55 | 56 | abstract fun prepare() 57 | 58 | abstract fun restoreArgument(bundle: Bundle?) 59 | 60 | abstract fun initialize() 61 | 62 | abstract fun restoreInstanceState(savedInstanceState: Bundle?) 63 | 64 | abstract fun restore() 65 | 66 | abstract fun saveInstanceState(outState: Bundle?) 67 | 68 | abstract fun setup() 69 | } 70 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /publish/mavencentral.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'maven-publish' 2 | apply plugin: 'signing' 3 | 4 | 5 | task androidJavadocJar(type: Jar) { 6 | archiveClassifier.set('javadoc') 7 | from("$buildDir/javadoc") 8 | } 9 | 10 | task androidSourcesJar(type: Jar) { 11 | archiveClassifier.set('sources') 12 | if (project.plugins.findPlugin("com.android.library")) { 13 | from android.sourceSets.main.java.srcDirs 14 | from android.sourceSets.main.kotlin.srcDirs 15 | } else { 16 | from sourceSets.main.java.srcDirs 17 | from sourceSets.main.kotlin.srcDirs 18 | } 19 | } 20 | 21 | group = project.groupId 22 | version = project.versionName 23 | 24 | ext["signing.keyId"] = '' 25 | ext["signing.password"] = '' 26 | ext["signing.secretKeyRingFile"] = '' 27 | ext["ossrhUsername"] = '' 28 | ext["ossrhPassword"] = '' 29 | ext["sonatypeStagingProfileId"] = '' 30 | 31 | File secretPropsFile = project.rootProject.file('local.properties') 32 | if (secretPropsFile.exists()) { 33 | Properties p = new Properties() 34 | p.load(new FileInputStream(secretPropsFile)) 35 | p.each { name, value -> 36 | ext[name] = value 37 | } 38 | } else { 39 | ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') 40 | ext["signing.password"] = System.getenv('SIGNING_PASSWORD') 41 | ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE') 42 | ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME') 43 | ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD') 44 | ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID') 45 | } 46 | 47 | publishing { 48 | publications { 49 | release(MavenPublication) { 50 | groupId project.groupId 51 | artifactId project.artifactId 52 | version project.versionName 53 | 54 | if (project.plugins.findPlugin("com.android.library")) { 55 | artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") 56 | } else { 57 | artifact("$buildDir/libs/${project.getName()}-${version}.jar") 58 | } 59 | 60 | artifact androidJavadocJar 61 | artifact androidSourcesJar 62 | 63 | pom { 64 | name = project.libraryName 65 | description = project.libraryDescription 66 | url = project.siteUrl 67 | licenses { 68 | license { 69 | name = project.licenseName 70 | url = project.licenseUrl 71 | } 72 | } 73 | developers { 74 | developer { 75 | id = project.developerId 76 | name = project.developName 77 | email = project.developerEmail 78 | } 79 | } 80 | scm { 81 | connection = project.gitUrl 82 | developerConnection = project.gitUrl 83 | url = project.siteUrl 84 | } 85 | withXml { 86 | def dependenciesNode = asNode().appendNode('dependencies') 87 | project.configurations.implementation.allDependencies.each { 88 | if (it.name != 'unspecified') { 89 | def dependencyNode = dependenciesNode.appendNode('dependency') 90 | dependencyNode.appendNode('groupId', it.group) 91 | dependencyNode.appendNode('artifactId', it.name) 92 | dependencyNode.appendNode('version', it.version) 93 | } 94 | } 95 | } 96 | } 97 | } 98 | } 99 | repositories { 100 | maven { 101 | name = "sonatype" 102 | url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/" 103 | credentials { 104 | username ossrhUsername 105 | password ossrhPassword 106 | } 107 | } 108 | } 109 | } 110 | 111 | signing { 112 | sign publishing.publications 113 | } 114 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 19 | 20 | 25 | 26 | 32 | 33 | 34 | 38 | 39 |