@@ -82,21 +82,6 @@ class HomeFragment : BaseFragment() {
8282 HomeFragmentDefaultBinding .inflate(layoutInflater, container, false ).root
8383 }
8484
85- private fun listenForChangesToClockType (binding : HomeFragmentContentBinding ): Observer <CorePreferences > {
86- var currentClockType: ClockType ? = null
87- return Observer { corePrefs ->
88- if (corePrefs.clockType == currentClockType) {
89- return @Observer
90- }
91-
92- currentClockType = corePrefs.clockType
93- binding.clockWrapper.removeAllViews()
94- val clock = createNewClock(requireContext(), corePrefs.clockType)
95- clockReceiver.clock = clock
96- binding.clockWrapper.addView(clock)
97- }
98- }
99-
10085 override fun onViewCreated (view : View , savedInstanceState : Bundle ? ) {
10186 super .onViewCreated(view, savedInstanceState)
10287 val adapter1 = HomeAdapter (this , corePreferencesRepo)
@@ -126,41 +111,6 @@ class HomeFragment : BaseFragment() {
126111 corePreferencesRepo.observe { corePreferences ->
127112 homeFragmentContent.appDrawerEditText
128113 .visibility = if (corePreferences.showSearchBar) View .VISIBLE else View .GONE
129-
130- // val clockType = corePreferences.clockType
131- // when (clockType) {
132- // ClockType.analog_0,
133- // ClockType.analog_1,
134- // ClockType.analog_2,
135- // ClockType.analog_3,
136- // ClockType.analog_4,
137- // ClockType.analog_6,
138- // ClockType.analog_12,
139- // ClockType.analog_60 -> {
140- // digitalClockView.update()
141- // }
142- // else -> {
143- // }
144- // }
145-
146- // homeFragmentContent.homeFragmentTime
147- // .visibility = if (clockType == ClockType.digital) View.VISIBLE else View.GONE
148- // homeFragmentContent.homeFragmentAnalogTime
149- // .visibility = when (clockType) {
150- // ClockType.analog_0,
151- // ClockType.analog_1,
152- // ClockType.analog_2,
153- // ClockType.analog_3,
154- // ClockType.analog_4,
155- // ClockType.analog_6,
156- // ClockType.analog_12,
157- // ClockType.analog_60 -> View.VISIBLE
158- // else -> View.GONE
159- // }
160- // homeFragmentContent.homeFragmentBinTime
161- // .visibility = if (clockType == ClockType.binary) View.VISIBLE else View.GONE
162- // homeFragmentContent.homeFragmentDate
163- // .visibility = if (clockType != ClockType.none) View.VISIBLE else View.GONE
164114 }
165115 }
166116
@@ -203,31 +153,7 @@ class HomeFragment : BaseFragment() {
203153 }
204154
205155 private fun setEventListeners () {
206- // val launchShowAlarms = OnClickListener {
207- // try {
208- // val intent = Intent(AlarmClock.ACTION_SHOW_ALARMS)
209- // intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
210- // launchActivity(it, intent)
211- // } catch (e: ActivityNotFoundException) {
212- // e.printStackTrace()
213- // // Do nothing, we've failed :(
214- // }
215- // }
216156 val homeFragmentContent = HomeFragmentContentBinding .bind(requireView())
217- // homeFragmentContent.homeFragmentTime.setOnClickListener(launchShowAlarms)
218- // homeFragmentContent.homeFragmentAnalogTime.setOnClickListener(launchShowAlarms)
219- // homeFragmentContent.homeFragmentBinTime.setOnClickListener(launchShowAlarms)
220- //
221- // homeFragmentContent.homeFragmentDate.setOnClickListener {
222- // try {
223- // val builder = CalendarContract.CONTENT_URI.buildUpon().appendPath("time")
224- // val intent = Intent(Intent.ACTION_VIEW, builder.build())
225- // intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
226- // launchActivity(it, intent)
227- // } catch (e: ActivityNotFoundException) {
228- // // Do nothing, we've failed :(
229- // }
230- // }
231157
232158 quickButtonPreferencesRepo.observe { prefs ->
233159 val leftButtonIcon = getIconResourceId(prefs.leftButton.iconId)
@@ -339,43 +265,6 @@ class HomeFragment : BaseFragment() {
339265 })
340266 }
341267
342- // fun updateClock() {
343- // // updateDate()
344- // // val homeFragmentContent = HomeFragmentContentBinding.bind(requireView())
345- // // val corePrefs = corePreferencesRepo.get()
346- // // when (corePrefs.clockType) {
347- // // ClockType.digital -> updateClockDigital(corePrefs)
348- // // ClockType.analog_0,
349- // // ClockType.analog_1,
350- // // ClockType.analog_2,
351- // // ClockType.analog_3,
352- // // ClockType.analog_4,
353- // // ClockType.analog_6,
354- // // ClockType.analog_12,
355- // // ClockType.analog_60 -> {
356- // // homeFragmentContent.homeFragmentAnalogTime.updateClock(corePrefs)
357- // // }
358- // // ClockType.binary -> homeFragmentContent.homeFragmentBinTime.updateClock(corePrefs)
359- // // else -> {}
360- // // }
361- // }
362-
363- // private fun updateClockDigital(corePrefs: CorePreferences) {
364- // val fWatchTime = when (corePrefs.timeFormat) {
365- // TimeFormat.twenty_four_hour -> SimpleDateFormat("H:mm", Locale.getDefault())
366- // TimeFormat.twelve_hour -> SimpleDateFormat("h:mm aa", Locale.getDefault())
367- // else -> DateFormat.getTimeFormat(context)
368- // }
369- // val homeFragmentContent = HomeFragmentContentBinding.bind(requireView())
370- // homeFragmentContent.homeFragmentTime.text = fWatchTime.format(Date())
371- // }
372- //
373- // private fun updateDate() {
374- // val fWatchDate = SimpleDateFormat(getString(R.string.main_date_format), Locale.getDefault())
375- // val homeFragmentContent = HomeFragmentContentBinding.bind(requireView())
376- // homeFragmentContent.homeFragmentDate.text = fWatchDate.format(Date())
377- // }
378-
379268 fun onLaunch (app : UnlauncherApp , view : View ) {
380269 launchApp(app.packageName, app.className, app.userSerial)
381270 }
@@ -407,6 +296,21 @@ class HomeFragment : BaseFragment() {
407296 }
408297 }
409298
299+ private fun listenForChangesToClockType (binding : HomeFragmentContentBinding ): Observer <CorePreferences > {
300+ var currentClockType: ClockType ? = null
301+ return Observer { corePrefs ->
302+ if (corePrefs.clockType == currentClockType) {
303+ return @Observer
304+ }
305+
306+ currentClockType = corePrefs.clockType
307+ binding.clockWrapper.removeAllViews()
308+ val clock = createNewClock(requireContext(), corePrefs.clockType)
309+ clockReceiver.clock = clock
310+ binding.clockWrapper.addView(clock)
311+ }
312+ }
313+
410314 private fun resetAppDrawerEditText () {
411315 val homeFragmentContent = HomeFragmentContentBinding .bind(requireView())
412316 homeFragmentContent.appDrawerEditText.clearComposingText()
0 commit comments