From e90b1868b02bf38c8eb3fe1a9a813729e9bd7ff7 Mon Sep 17 00:00:00 2001 From: Gianluca Bettega Date: Sat, 7 Sep 2024 14:16:26 -0300 Subject: [PATCH] 5.1.3 --- CHANGELOG.md | 4 ++ example/.metadata | 12 ++-- example/android/.gitignore | 13 ++++ example/android/app/build.gradle | 65 ++++++++----------- .../android/app/src/debug/AndroidManifest.xml | 7 ++ .../android/app/src/main/AndroidManifest.xml | 50 +++++++++++--- .../com/example/example/MainActivity.kt | 5 ++ .../monthpickerdialogexample/MainActivity.kt | 6 -- .../res/drawable-v21/launch_background.xml | 12 ++++ .../app/src/main/res/values-night/styles.xml | 18 +++++ .../app/src/main/res/values/styles.xml | 14 +++- .../app/src/profile/AndroidManifest.xml | 7 ++ example/android/build.gradle | 19 +----- example/android/gradle.properties | 5 +- .../gradle/wrapper/gradle-wrapper.properties | 3 +- example/android/settings.gradle | 30 ++++++--- lib/src/helpers/providers.dart | 13 ++-- lib/src/month_picker_dialog.dart | 1 - lib/src/pickers/show_month_picker.dart | 1 + lib/src/pickers/show_month_range_picker.dart | 1 + pubspec.yaml | 2 +- 21 files changed, 189 insertions(+), 99 deletions(-) create mode 100644 example/android/.gitignore create mode 100644 example/android/app/src/debug/AndroidManifest.xml create mode 100644 example/android/app/src/main/kotlin/com/example/example/MainActivity.kt delete mode 100644 example/android/app/src/main/kotlin/edu/hm/krivoj/monthpickerdialogexample/MainActivity.kt create mode 100644 example/android/app/src/main/res/drawable-v21/launch_background.xml create mode 100644 example/android/app/src/main/res/values-night/styles.xml create mode 100644 example/android/app/src/profile/AndroidManifest.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a280f0..69b3c9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 5.1.3 - 2024-09-07 +- Fixed [#106](https://github.com/Macacoazul01/month_picker_dialog/issues/106). +- Updated android sample. + ## 5.1.2 - 2024-08-20 - Fixed [#104](https://github.com/Macacoazul01/month_picker_dialog/issues/104). diff --git a/example/.metadata b/example/.metadata index d00a406..e720147 100644 --- a/example/.metadata +++ b/example/.metadata @@ -4,7 +4,7 @@ # This file should be version controlled and should not be manually edited. version: - revision: "d211f42860350d914a5ad8102f9ec32764dc6d06" + revision: "b0850beeb25f6d5b10426284f506557f66181b36" channel: "stable" project_type: app @@ -13,11 +13,11 @@ project_type: app migration: platforms: - platform: root - create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 - base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 - - platform: web - create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 - base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06 + create_revision: b0850beeb25f6d5b10426284f506557f66181b36 + base_revision: b0850beeb25f6d5b10426284f506557f66181b36 + - platform: android + create_revision: b0850beeb25f6d5b10426284f506557f66181b36 + base_revision: b0850beeb25f6d5b10426284f506557f66181b36 # User provided section diff --git a/example/android/.gitignore b/example/android/.gitignore new file mode 100644 index 0000000..6f56801 --- /dev/null +++ b/example/android/.gitignore @@ -0,0 +1,13 @@ +gradle-wrapper.jar +/.gradle +/captures/ +/gradlew +/gradlew.bat +/local.properties +GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app +key.properties +**/*.keystore +**/*.jks diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 7090ea6..3baa1d3 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -1,67 +1,58 @@ +plugins { + id "com.android.application" + id "kotlin-android" + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id "dev.flutter.flutter-gradle-plugin" +} + def localProperties = new Properties() -def localPropertiesFile = rootProject.file('local.properties') +def localPropertiesFile = rootProject.file("local.properties") if (localPropertiesFile.exists()) { - localPropertiesFile.withReader('UTF-8') { reader -> + localPropertiesFile.withReader("UTF-8") { reader -> localProperties.load(reader) } } -def flutterRoot = localProperties.getProperty('flutter.sdk') -if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") -} - -def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +def flutterVersionCode = localProperties.getProperty("flutter.versionCode") if (flutterVersionCode == null) { - flutterVersionCode = '1' + flutterVersionCode = "1" } -def flutterVersionName = localProperties.getProperty('flutter.versionName') +def flutterVersionName = localProperties.getProperty("flutter.versionName") if (flutterVersionName == null) { - flutterVersionName = '1.0' + flutterVersionName = "1.0" } -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - android { - compileSdkVersion 31 + namespace = "com.example.monthpickerdialogexample" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } - - lintOptions { - disable 'InvalidPackage' + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "edu.hm.krivoj.monthpickerdialogexample" - minSdkVersion flutter.minSdkVersion - targetSdkVersion 30 - versionCode flutterVersionCode.toInteger() - versionName flutterVersionName - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + applicationId = "com.example.monthpickerdialogexample" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutterVersionCode.toInteger() + versionName = flutterVersionName } buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig signingConfigs.debug + signingConfig = signingConfigs.debug } } } flutter { - source '../..' -} - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test:runner:1.1.0' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0' + source = "../.." } diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/example/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index d1a6699..361b24a 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,13 +1,45 @@ - - - - - + + + + + - - + + + + - - \ No newline at end of file + + + + + + + + diff --git a/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt b/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt new file mode 100644 index 0000000..3b5fe18 --- /dev/null +++ b/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt @@ -0,0 +1,5 @@ +package com.example.monthpickerdialogexample + +import io.flutter.embedding.android.FlutterActivity + +class MainActivity: FlutterActivity() diff --git a/example/android/app/src/main/kotlin/edu/hm/krivoj/monthpickerdialogexample/MainActivity.kt b/example/android/app/src/main/kotlin/edu/hm/krivoj/monthpickerdialogexample/MainActivity.kt deleted file mode 100644 index 9e99224..0000000 --- a/example/android/app/src/main/kotlin/edu/hm/krivoj/monthpickerdialogexample/MainActivity.kt +++ /dev/null @@ -1,6 +0,0 @@ -package edu.hm.krivoj.monthpickerdialogexample - -import io.flutter.embedding.android.FlutterActivity - -class MainActivity: FlutterActivity() { -} diff --git a/example/android/app/src/main/res/drawable-v21/launch_background.xml b/example/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/example/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/example/android/app/src/main/res/values-night/styles.xml b/example/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..06952be --- /dev/null +++ b/example/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml index 00fa441..cb1ef88 100644 --- a/example/android/app/src/main/res/values/styles.xml +++ b/example/android/app/src/main/res/values/styles.xml @@ -1,8 +1,18 @@ - + + diff --git a/example/android/app/src/profile/AndroidManifest.xml b/example/android/app/src/profile/AndroidManifest.xml new file mode 100644 index 0000000..399f698 --- /dev/null +++ b/example/android/app/src/profile/AndroidManifest.xml @@ -0,0 +1,7 @@ + + + + diff --git a/example/android/build.gradle b/example/android/build.gradle index 1765dbf..d2ffbff 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,29 +1,16 @@ -buildscript { - ext.kotlin_version = '1.6.20' - repositories { - google() - jcenter() - } - - dependencies { - classpath 'com.android.tools.build:gradle:7.1.2' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - allprojects { repositories { google() - jcenter() + mavenCentral() } } -rootProject.buildDir = '../build' +rootProject.buildDir = "../build" subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { - project.evaluationDependsOn(':app') + project.evaluationDependsOn(":app") } tasks.register("clean", Delete) { diff --git a/example/android/gradle.properties b/example/android/gradle.properties index a5965ab..3b5b324 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1,4 +1,3 @@ -org.gradle.jvmargs=-Xmx1536M -android.enableR8=true +org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError android.useAndroidX=true -android.enableJetifier=true \ No newline at end of file +android.enableJetifier=true diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index cc5527d..e1ca574 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Fri Jun 23 08:50:38 CEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-all.zip diff --git a/example/android/settings.gradle b/example/android/settings.gradle index 5a2f14f..536165d 100644 --- a/example/android/settings.gradle +++ b/example/android/settings.gradle @@ -1,15 +1,25 @@ -include ':app' +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + }() -def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() + includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") -def plugins = new Properties() -def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') -if (pluginsFile.exists()) { - pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) } + repositories { + google() + mavenCentral() + gradlePluginPortal() + } } -plugins.each { name, path -> - def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() - include ":$name" - project(":$name").projectDir = pluginDirectory +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "7.3.0" apply false + id "org.jetbrains.kotlin.android" version "1.7.10" apply false } + +include ":app" diff --git a/lib/src/helpers/providers.dart b/lib/src/helpers/providers.dart index 550c1d8..f9d000c 100644 --- a/lib/src/helpers/providers.dart +++ b/lib/src/helpers/providers.dart @@ -1,17 +1,19 @@ import 'package:flutter/material.dart'; import '/month_picker_dialog.dart'; +final UpDownPageLimit _yearUpDownPageLimit = UpDownPageLimit(0, 0); +final UpDownPageLimit _monthUpDownPageLimit = UpDownPageLimit(0, 0); + ///Provider that controlls the up down state of the header when the year selector is on the dialog class YearUpDownPageProvider extends ChangeNotifier { - final UpDownPageLimit _pageLimit = UpDownPageLimit(0, 0); final UpDownButtonEnableState _enableState = UpDownButtonEnableState(true, true); - UpDownPageLimit get pageLimit => _pageLimit; + UpDownPageLimit get pageLimit => _yearUpDownPageLimit; UpDownButtonEnableState get enableState => _enableState; void changePage(int downLimit, int upLimit, bool? downState, bool? upState) { - _pageLimit + _yearUpDownPageLimit ..downLimit = downLimit ..upLimit = upLimit; @@ -27,15 +29,14 @@ class YearUpDownPageProvider extends ChangeNotifier { ///Provider that controlls the up down state of the header when the monyh selector is on the dialog class MonthUpDownPageProvider extends ChangeNotifier { - final UpDownPageLimit _pageLimit = UpDownPageLimit(0, 0); final UpDownButtonEnableState _enableState = UpDownButtonEnableState(true, true); - UpDownPageLimit get pageLimit => _pageLimit; + UpDownPageLimit get pageLimit => _monthUpDownPageLimit; UpDownButtonEnableState get enableState => _enableState; void changePage(int downLimit, int upLimit, bool? downState, bool? upState) { - _pageLimit + _monthUpDownPageLimit ..downLimit = downLimit ..upLimit = upLimit; diff --git a/lib/src/month_picker_dialog.dart b/lib/src/month_picker_dialog.dart index ac23bb7..471012f 100644 --- a/lib/src/month_picker_dialog.dart +++ b/lib/src/month_picker_dialog.dart @@ -16,7 +16,6 @@ class MonthPickerDialogState extends State { @override void initState() { super.initState(); - widget.controller.initialize(); _selector = widget.controller.monthPickerDialogSettings.dialogSettings.yearFirst || widget.controller.onlyYear diff --git a/lib/src/pickers/show_month_picker.dart b/lib/src/pickers/show_month_picker.dart index 65ebd65..4bad05c 100644 --- a/lib/src/pickers/show_month_picker.dart +++ b/lib/src/pickers/show_month_picker.dart @@ -66,6 +66,7 @@ Future showMonthPicker({ headerTitle: headerTitle, onlyYear: onlyYear, ); + controller.initialize(); final DateTime? dialogDate = await showDialog( context: context, barrierDismissible: monthPickerDialogSettings.dialogSettings.dismissible, diff --git a/lib/src/pickers/show_month_range_picker.dart b/lib/src/pickers/show_month_range_picker.dart index de0b89d..8c9a498 100644 --- a/lib/src/pickers/show_month_range_picker.dart +++ b/lib/src/pickers/show_month_range_picker.dart @@ -71,6 +71,7 @@ Future?> showMonthRangePicker({ rangeList: rangeList, monthPickerDialogSettings: monthPickerDialogSettings, ); + controller.initialize(); final List? dialogDate = await showDialog>( context: context, barrierDismissible: monthPickerDialogSettings.dialogSettings.dismissible, diff --git a/pubspec.yaml b/pubspec.yaml index 16dcf3e..6b4ed72 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: month_picker_dialog description: Internationalized dialog for picking a single month from an infinite list of years. -version: 5.1.2 +version: 5.1.3 homepage: https://github.com/hmkrivoj/month_picker_dialog environment: