Kwgt Clock Widget -

class KWGTClockWidget : AppWidgetProvider()

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()

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) kwgt clock widget

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)

package com.yourpackage.kwgtclockwidget import android.appwidget.AppWidgetManager import android.appwidget.AppWidgetProvider import android.content.Context import android.widget.RemoteViews import java.text.SimpleDateFormat import java.util.* import android.os.Handler import android.os.Looper defaultColor: Int) val button = findViewById&lt

<TextView android:id="@+id/clockDate" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:text="Monday, January 1" android:textSize="18sp" android:textColor="#B0B0B0" /> </LinearLayout> package com.yourpackage.kwgtclockwidget import android.appwidget.AppWidgetManager import android.content.Context import android.content.Intent import android.content.SharedPreferences import android.graphics.Color import android.os.Bundle import android.widget.* import androidx.appcompat.app.AppCompatActivity import com.google.android.material.slider.Slider

override fun onDisabled(context: Context) super.onDisabled(context) runnable?.let handler.removeCallbacks(it) (buttonId) val currentColor = prefs.getInt(prefKey

private var appWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID private lateinit var prefs: SharedPreferences

private fun setupSizeSlider(sliderId: Int, textViewId: Int, prefKey: String, defaultValue: Int) val slider = findViewById<Slider>(sliderId) val valueText = findViewById<TextView>(textViewId) val savedValue = prefs.getInt(prefKey, defaultValue).toFloat() slider.value = savedValue valueText.text = "$savedValue.toInt()sp" slider.addOnChangeListener _, value, _ -> valueText.text = "$value.toInt()sp" prefs.edit().putInt(prefKey, value.toInt()).apply()

class WidgetConfigureActivity : AppCompatActivity() {

override fun onUpdate( context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray ) appWidgetIds.forEach appWidgetId -> updateAppWidget(context, appWidgetManager, appWidgetId) startClockUpdates(context, appWidgetManager, appWidgetIds)