Skip to content

Commit

Permalink
Merge pull request #225 from vicolo-dev/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
AhsanSarwar45 authored May 11, 2024
2 parents 75f3bc5 + 8b5f620 commit 12ef920
Show file tree
Hide file tree
Showing 174 changed files with 7,385 additions and 1,639 deletions.
40 changes: 0 additions & 40 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,42 +52,6 @@ android {
}

defaultConfig {
// Map for the version code that gives each ABI a value.

// // For per-density APKs, create a similar map:
// // ext.densityCodes = ['mdpi': 1, 'hdpi': 2, 'xhdpi': 3]


// // For each APK output variant, override versionCode with a combination of
// // ext.abiCodes * 1000 + variant.versionCode. In this example, variant.versionCode
// // is equal to defaultConfig.versionCode. If you configure product flavors that
// // define their own versionCode, variant.versionCode uses that value instead.
// project.android.applicationVariants.all { variant ->

// // Assigns a different version code for each output APK
// // other than the universal APK.
// variant.outputs.each { output ->

// // Stores the value of ext.abiCodes that is associated with the ABI for this variant.
// def baseAbiVersionCode =
// // Determines the ABI for this variant and returns the mapped value.
// project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))

// // Because abiCodes.get() returns null for ABIs that are not mapped by ext.abiCodes,
// // the following code doesn't override the version code for universal APKs.
// // However, because you want universal APKs to have the lowest version code,
// // this outcome is desirable.
// if (baseAbiVersionCode != null) {

// // Assigns the new version code to versionCodeOverride, which changes the
// // version code for only the output APK, not for the variant itself. Skipping
// // this step causes Gradle to use the value of variant.versionCode for the APK.
// output.versionCodeOverride =
// variant.versionCode * 10 + baseAbiVersionCode
// }
// }
// }

applicationId "com.vicolo.chrono"
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
Expand Down Expand Up @@ -155,7 +119,3 @@ flutter {
source '../..'
}

dependencies {
// implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
//
}
23 changes: 23 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,28 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
<receiver android:name="AnalogueClockWidgetProvider" android:exported="true" android:label="Analogue">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/analogue_clock_widget" />
</receiver>
<receiver android:name="DigitalClockWidgetProvider" android:exported="true" android:label="Digital">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/digital_clock_widget" />
</receiver>
<!-- <receiver android:name="DigitalClockDateWidgetProvider" android:exported="true" android:label="Digital with Date"> -->
<!-- <intent-filter> -->
<!-- <action android:name="android.appwidget.action.APPWIDGET_UPDATE" /> -->
<!-- </intent-filter> -->
<!-- <meta-data android:name="android.appwidget.provider" -->
<!-- android:resource="@xml/digital_clock_date_widget" /> -->
<!-- </receiver> -->


</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.vicolo.chrono

import android.app.PendingIntent
import android.appwidget.AppWidgetManager
import android.appwidget.AppWidgetProvider
import android.content.Context
import android.content.Intent
import android.widget.RemoteViews
// import es.antonborri.home_widget.HomeWidgetBackgroundIntent
// import es.antonborri.home_widget.HomeWidgetLaunchIntent
// import es.antonborri.home_widget.HomeWidgetProvider

class AnalogueClockWidgetProvider : AppWidgetProvider() {
override fun onUpdate(
context: Context,
appWidgetManager: AppWidgetManager,
appWidgetIds: IntArray,
) { // Perform this loop procedure for each widget that belongs to this
// provider.
appWidgetIds.forEach { appWidgetId ->
// Create an Intent to launch ExampleActivity.
// Open App on Widget Click
val views =
RemoteViews(context.packageName, R.layout.analogue_clock_widget).apply {
// Open App on Widget Click
val pendingIntent: PendingIntent =
PendingIntent.getActivity(
// context =
context,
// requestCode =
0,
// intent =
Intent(context, MainActivity::class.java),
// flags =
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
)
// Swap Title Text by calling Dart Code in the Background
// setTextViewText(R.id.widget_title, widgetData.getString("title", null)
// ?: "No Title Set")
// val backgroundIntent = HomeWidgetBackgroundIntent.getBroadcast(
// context,
// Uri.parse("homeWidgetExample://titleClicked")
// )
// setOnClickPendingIntent(R.id.widget_title, backgroundIntent)
//
// val message = widgetData.getString("message", null)
// setTextViewText(R.id.widget_message, message
// ?: "No Message Set")
// // Show Images saved with `renderFlutterWidget`
// val image = widgetData.getString("dashIcon", null)
// if (image != null) {
// setImageViewBitmap(R.id.widget_img, BitmapFactory.decodeFile(image))
// setViewVisibility(R.id.widget_img, View.VISIBLE)
// } else {
// setViewVisibility(R.id.widget_img, View.GONE)
// }
//
// // Detect App opened via Click inside Flutter
// val pendingIntentWithData = HomeWidgetLaunchIntent.getActivity(
// context,
// MainActivity::class.java,
// Uri.parse("homeWidgetExample://message?message=$message"))
// setOnClickPendingIntent(R.id.widget_message, pendingIntentWithData)
}
// Get the layout for the widget and attach an onClick listener to
// the button.
// val views: RemoteViews = RemoteViews(
// context.packageName,
// R.layout.appwidget_provider_layout
// ).apply {
// setOnClickPendingIntent(R.id.button, pendingIntent)
// }

// Tell the AppWidgetManager to perform an update on the current
// widget.
appWidgetManager.updateAppWidget(appWidgetId, views)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package com.vicolo.chrono

import android.app.PendingIntent
import android.appwidget.AppWidgetManager
import android.appwidget.AppWidgetProvider
import android.content.Context
import android.content.Intent
import android.widget.RemoteViews
import android.content.SharedPreferences
import es.antonborri.home_widget.HomeWidgetBackgroundIntent
import es.antonborri.home_widget.HomeWidgetLaunchIntent
import es.antonborri.home_widget.HomeWidgetProvider
import es.antonborri.home_widget.HomeWidgetPlugin
import android.util.Log

class DigitalClockDateWidgetProvider : HomeWidgetProvider() {
override fun onUpdate(
context: Context,
appWidgetManager: AppWidgetManager,
appWidgetIds: IntArray,
widgetData: SharedPreferences,
) { // Perform this loop procedure for each widget that belongs to this
// provider.
Log.d("TAG", "======================================YOO")

appWidgetIds.forEach { appWidgetId ->
// Create an Intent to launch ExampleActivity.
// Open App on Widget Click
val views =
RemoteViews(context.packageName, R.layout.digital_clock_date_widget).apply {
// Open App on Widget Click
val pendingIntent: PendingIntent =
PendingIntent.getActivity(
// context =
context,
// requestCode =
0,
// intent =
Intent(context, MainActivity::class.java),
// flags =
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
)
val dateFormat = widgetData.getString("dateFormat", "EEE, d MMM")
val timeFormat = widgetData.getString("timeFormat", "HH:mm")
setCharSequence (R.id.widget_text_clock, "setFormat24Hour", timeFormat)
setCharSequence (R.id.widget_text_clock, "setFormat12Hour", timeFormat)
setCharSequence (R.id.widget_date, "setFormat24Hour", dateFormat)
setCharSequence (R.id.widget_date, "setFormat12Hour", dateFormat)
// Swap Title Text by calling Dart Code in the Background
// setTextViewText(R.id.widget_title, widgetData.getString("title", null)
// ?: "No Title Set")
// val backgroundIntent = HomeWidgetBackgroundIntent.getBroadcast(
// context,
// Uri.parse("homeWidgetExample://titleClicked")
// )
// setOnClickPendingIntent(R.id.widget_title, backgroundIntent)
//
// val message = widgetData.getString("message", null)
// setTextViewText(R.id.widget_message, message
// ?: "No Message Set")
// // Show Images saved with `renderFlutterWidget`
// val image = widgetData.getString("dashIcon", null)
// if (image != null) {
// setImageViewBitmap(R.id.widget_img, BitmapFactory.decodeFile(image))
// setViewVisibility(R.id.widget_img, View.VISIBLE)
// } else {
// setViewVisibility(R.id.widget_img, View.GONE)
// }
//
// // Detect App opened via Click inside Flutter
// val pendingIntentWithData = HomeWidgetLaunchIntent.getActivity(
// context,
// MainActivity::class.java,
// Uri.parse("homeWidgetExample://message?message=$message"))
// setOnClickPendingIntent(R.id.widget_message, pendingIntentWithData)
}
// Get the layout for the widget and attach an onClick listener to
// the button.
// val views: RemoteViews = RemoteViews(
// context.packageName,
// R.layout.appwidget_provider_layout
// ).apply {
// setOnClickPendingIntent(R.id.button, pendingIntent)
// }

// Tell the AppWidgetManager to perform an update on the current
// widget.
appWidgetManager.updateAppWidget(appWidgetId, views)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package com.vicolo.chrono

import android.app.PendingIntent
import android.appwidget.AppWidgetManager
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.util.Log
import android.widget.RemoteViews
import android.graphics.Color
import es.antonborri.home_widget.HomeWidgetProvider
import android.view.ViewGroup.LayoutParams
import android.view.View
import android.util.TypedValue

class DigitalClockWidgetProvider : HomeWidgetProvider() {
override fun onUpdate(
context: Context,
appWidgetManager: AppWidgetManager,
appWidgetIds: IntArray,
widgetData: SharedPreferences,
) { // Perform this loop procedure for each widget that belongs to this
// provider.
Log.d("TAG", "Updating Digital Clock Widget");

appWidgetIds.forEach { appWidgetId ->
// Create an Intent to launch ExampleActivity.
// Open App on Widget Click
val views =
RemoteViews(context.packageName, R.layout.digital_clock_widget).apply {
// Open App on Widget Click
val pendingIntent: PendingIntent =
PendingIntent.getActivity(
// context =
context,
// requestCode =
0,
// intent =
Intent(context, MainActivity::class.java),
// flags =
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
)
val dateFormat = widgetData.getString("dateFormat", "EEE, d MMM")
val timeFormat = widgetData.getString("timeFormat", "HH:mm")
val dateSize = widgetData.getInt("dateSize", 25)
val timeSize = widgetData.getInt("timeSize", 100)
val textColor = widgetData.getString("textColor", "#FFFFFF")
// val shadowColor = widgetData.getString("shadowColor", "#000000")
// val shadowElevation = widgetData.getFloat("shadowElevation", 1.0f)
// val shadowBlur = widgetData.getFloat("shadowBlur", 1.0f)
val showDate = widgetData.getBoolean("showDate", true)

setCharSequence(R.id.widget_text_clock, "setFormat24Hour", timeFormat)
setCharSequence(R.id.widget_text_clock, "setFormat12Hour", timeFormat)
setCharSequence(R.id.widget_date, "setFormat24Hour", "EEE, d MMM")
setCharSequence(R.id.widget_date, "setFormat12Hour", "EEE, d MMM")
setColorInt(R.id.widget_text_clock, "setTextColor", Color.parseColor(textColor), Color.parseColor(textColor))
setColorInt(R.id.widget_date, "setTextColor", Color.parseColor(textColor), Color.parseColor(textColor))
// setFloat(R.id.widget_text_clock, "setTextSize", timeSize.toFloat())
// setFloat(R.id.widget_date, "setTextSize", dateSize.toFloat())
setViewLayoutHeight(R.id.widget_text_clock, timeSize.toFloat(), TypedValue.COMPLEX_UNIT_SP)
setViewLayoutHeight(R.id.widget_date, dateSize.toFloat(), TypedValue.COMPLEX_UNIT_SP)
setViewVisibility(R.id.widget_date, if(showDate) View.VISIBLE else View.GONE)
//
// R.layout.digital_clock_widget.findViewById(R.id.widget_text_clock).apply {
// val param =
// LinearLayout.LayoutParams(
// LayoutParams.MATCH_PARENT,
// LayoutParams.MATCH_PARENT,
// timeSize,
// )
// setLayoutParams(param)
// setShadowLayer(shadowBlur, 0f, shadowElevation, shadowColor)
// }
//
// R.layout.digital_clock_widget.findViewById(R.id.widget_date).apply {
// val param =
// LinearLayout.LayoutParams(
// LayoutParams.MATCH_PARENT,
// LayoutParams.MATCH_PARENT,
// dateSize,
// )
// setLayoutParams(param)
// setTextColor(textColor)
// setShadowLayer(shadowBlur, 0f, shadowElevation, shadowColor)
// }

// Swap Title Text by calling Dart Code in the Background
// setTextViewText(R.id.widget_title, widgetData.getString("title", null)
// ?: "No Title Set")
// val backgroundIntent = HomeWidgetBackgroundIntent.getBroadcast(
// context,
// Uri.parse("homeWidgetExample://titleClicked")
// )
// setOnClickPendingIntent(R.id.widget_title, backgroundIntent)
//
// val message = widgetData.getString("message", null)
// setTextViewText(R.id.widget_message, message
// ?: "No Message Set")
// // Show Images saved with `renderFlutterWidget`
// val image = widgetData.getString("dashIcon", null)
// if (image != null) {
// setImageViewBitmap(R.id.widget_img, BitmapFactory.decodeFile(image))
// setViewVisibility(R.id.widget_img, View.VISIBLE)
// } else {
// setViewVisibility(R.id.widget_img, View.GONE)
// }
//
// // Detect App opened via Click inside Flutter
// val pendingIntentWithData = HomeWidgetLaunchIntent.getActivity(
// context,
// MainActivity::class.java,
// Uri.parse("homeWidgetExample://message?message=$message"))
// setOnClickPendingIntent(R.id.widget_message, pendingIntentWithData)
}
// Get the layout for the widget and attach an onClick listener to
// the button.
// val views: RemoteViews = RemoteViews(
// context.packageName,
// R.layout.appwidget_provider_layout
// ).apply {
// setOnClickPendingIntent(R.id.button, pendingIntent)
// }

// Tell the AppWidgetManager to perform an update on the current
// widget.
appWidgetManager.updateAppWidget(appWidgetId, views)
}
}
}
Loading

0 comments on commit 12ef920

Please sign in to comment.