Kwgt Clock Widget Today

private fun startClockUpdates( context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray ) runnable?.let handler.removeCallbacks(it) runnable = Runnable appWidgetIds.forEach appWidgetId -> updateAppWidget(context, appWidgetManager, appWidgetId) handler.postDelayed(runnable!!, UPDATE_INTERVAL) handler.post(runnable!!)

private fun setupColorPicker(buttonId: Int, prefKey: String, defaultColor: Int) val button = findViewById<Button>(buttonId) val currentColor = prefs.getInt(prefKey, defaultColor) button.setBackgroundColor(currentColor) button.setOnClickListener val colorPicker = ColorPickerDialog(this, currentColor) color -> button.setBackgroundColor(color) prefs.edit().putInt(prefKey, color).apply() colorPicker.show() kwgt clock widget

private fun applyWidgetSettings(context: Context, views: RemoteViews) val prefs = context.getSharedPreferences("widget_prefs", Context.MODE_PRIVATE) // Color settings val textColor = prefs.getInt("text_color", -1) val accentColor = prefs.getInt("accent_color", -1) val bgColor = prefs.getInt("bg_color", -1) if (textColor != -1) views.setTextColor(R.id.clockTime, textColor) views.setTextColor(R.id.clockDate, textColor) if (accentColor != -1) views.setTextColor(R.id.clockAmPm, accentColor) if (bgColor != -1) views.setInt(R.id.widgetBackground, "setBackgroundColor", bgColor) // Font size settings val timeSize = prefs.getInt("time_size", 80) val dateSize = prefs.getInt("date_size", 18) val ampmSize = prefs.getInt("ampm_size", 24) views.setFloat(R.id.clockTime, "setTextSize", timeSize.toFloat()) views.setFloat(R.id.clockDate, "setTextSize", dateSize.toFloat()) views.setFloat(R.id.clockAmPm, "setTextSize", ampmSize.toFloat()) // Font family val fontFamily = prefs.getString("font_family", "sans-serif-medium") views.setString(R.id.clockTime, "setTypeface", fontFamily) private fun startClockUpdates( context: Context

private fun updateAppWidget( context: Context, appWidgetManager: AppWidgetManager, appWidgetId: Int ) val views = RemoteViews(context.packageName, R.layout.widget_clock) // Get current time and date val calendar = Calendar.getInstance() val timeFormat = SimpleDateFormat("hh:mm", Locale.getDefault()) val amPmFormat = SimpleDateFormat("a", Locale.getDefault()) val dateFormat = SimpleDateFormat("EEEE, MMMM d", Locale.getDefault()) val currentTime = timeFormat.format(calendar.time) val amPm = amPmFormat.format(calendar.time) val currentDate = dateFormat.format(calendar.time).capitalize() // Set text views views.setTextViewText(R.id.clockTime, currentTime) views.setTextViewText(R.id.clockAmPm, amPm) views.setTextViewText(R.id.clockDate, currentDate) // Apply settings from SharedPreferences applyWidgetSettings(context, views) appWidgetManager.updateAppWidget(appWidgetId, views) defaultColor: Int) val button = findViewById&lt