-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
274 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
app/src/main/java/nethical/digipaws/ui/fragments/bedtime/SetupBedtimeMode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package nethical.digipaws.ui.fragments.bedtime | ||
|
||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.fragment.app.Fragment | ||
import nethical.digipaws.databinding.FragmentConfigureBedtimeBinding | ||
import nl.joery.timerangepicker.TimeRangePicker | ||
|
||
class SetupBedtimeMode : Fragment() { | ||
|
||
companion object { | ||
const val FRAGMENT_ID = "setup_bedtime_mode" | ||
} | ||
|
||
private var _binding: FragmentConfigureBedtimeBinding? = null | ||
private val binding get() = _binding!! // Safe getter for binding | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
_binding = FragmentConfigureBedtimeBinding.inflate(inflater, container, false) | ||
return binding.root | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
var endTimeInMins: Int? = null | ||
var startTimeInMins: Int? = null | ||
|
||
binding.picker.hourFormat = TimeRangePicker.HourFormat.FORMAT_24 | ||
binding.picker.setOnTimeChangeListener(object : | ||
TimeRangePicker.OnTimeChangeListener { | ||
override fun onStartTimeChange(startTime: TimeRangePicker.Time) { | ||
binding.fromTime.text = | ||
binding.picker.startTime.toString() | ||
startTimeInMins = binding.picker.startTimeMinutes | ||
} | ||
|
||
override fun onEndTimeChange(endTime: TimeRangePicker.Time) { | ||
binding.endTime.text = | ||
binding.picker.endTime.toString() | ||
endTimeInMins = binding.picker.endTimeMinutes | ||
} | ||
|
||
override fun onDurationChange(duration: TimeRangePicker.TimeDuration) { | ||
} | ||
}) | ||
|
||
} | ||
|
||
override fun onDestroyView() { | ||
super.onDestroyView() | ||
_binding = null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:background="?attr/colorSurface"> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:orientation="vertical" | ||
android:padding="16dp"> | ||
|
||
|
||
<TextView | ||
android:id="@+id/textView23" | ||
style="@style/TextAppearance.Material3.HeadlineLarge" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:gravity="center" | ||
android:padding="16dp" | ||
android:text="Bedtime Mode" | ||
android:textStyle="bold" /> | ||
|
||
<TextView | ||
android:id="@+id/textView25" | ||
style="@style/TextAppearance.Material3.BodyMedium" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:layout_marginTop="16dp" | ||
android:text="Configure Time" /> | ||
|
||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="8dp" | ||
android:layout_marginBottom="8dp"> | ||
|
||
<nl.joery.timerangepicker.TimeRangePicker | ||
android:id="@+id/picker" | ||
android:layout_width="wrap_content" | ||
android:layout_height="300dp" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
app:trp_thumbIconEnd="@drawable/baseline_stop_24" | ||
app:trp_thumbIconStart="@drawable/baseline_start_24" /> | ||
|
||
<LinearLayout | ||
android:layout_width="wrap_content" | ||
android:layout_height="match_parent" | ||
android:gravity="center" | ||
android:orientation="vertical" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent"> | ||
|
||
<TextView | ||
android:id="@+id/from_time" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:gravity="center" | ||
android:padding="4dp" | ||
android:text="6:30" | ||
android:textStyle="bold" | ||
tools:ignore="HardcodedText" /> | ||
|
||
<TextView | ||
android:id="@+id/textView8" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:gravity="center" | ||
android:padding="4dp" | ||
android:text="@string/to" /> | ||
|
||
<TextView | ||
android:id="@+id/end_time" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:gravity="center" | ||
android:padding="4dp" | ||
android:text="22:00" | ||
android:textStyle="bold" | ||
tools:ignore="HardcodedText" /> | ||
</LinearLayout> | ||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
|
||
<TextView | ||
android:id="@+id/textView26" | ||
style="@style/TextAppearance.Material3.BodyMedium" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:layout_marginTop="16dp" | ||
android:layout_marginBottom="16dp" | ||
android:gravity="center" | ||
android:text="Options" /> | ||
|
||
<LinearLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_weight="1" | ||
android:orientation="vertical"> | ||
|
||
<CheckBox | ||
android:id="@+id/checkBox" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="Dim the screen brightness" /> | ||
|
||
<CheckBox | ||
android:id="@+id/checkBox2" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="Turn on DND" /> | ||
|
||
<CheckBox | ||
android:id="@+id/checkBox3" | ||
android:layout_width="match_parent" | ||
android:layout_height="wrap_content" | ||
android:text="Turn on Gray Scale Mode" /> | ||
</LinearLayout> | ||
|
||
<Button | ||
android:id="@+id/button2" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="end" | ||
android:layout_margin="8dp" | ||
android:text="Enable" | ||
app:icon="@drawable/baseline_done_24" /> | ||
|
||
</LinearLayout> | ||
</ScrollView> |