diff --git a/.github/baumpfleger.yml b/.github/baumpfleger.yml new file mode 100644 index 0000000..655ebe3 --- /dev/null +++ b/.github/baumpfleger.yml @@ -0,0 +1,13 @@ +# Configuration for probot-baumfleger + +# Enabled? (optional, default false) +enabled: true + +# glob or regex patterns that specify branches to ignore (optional) +ignore_branches: + - sandfox/patch-* + - /^sandfox-[0-9]/i + +# list of labels that if found on a pull Request cause it to be ignored (optional) +ignore_labels: + - keep-branch \ No newline at end of file diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000..15eb879 --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,59 @@ +# Configuration for probot-stale - https://github.com/probot/stale + +# Number of days of inactivity before an Issue or Pull Request becomes stale +daysUntilStale: 360 + +# Number of days of inactivity before an Issue or Pull Request with the stale label is closed. +# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale. +daysUntilClose: 90 + +# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled) +onlyLabels: [] + +# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable +exemptLabels: + - pinned + +# Set to true to ignore issues in a project (defaults to false) +exemptProjects: false + +# Set to true to ignore issues in a milestone (defaults to false) +exemptMilestones: false + +# Set to true to ignore issues with an assignee (defaults to false) +exemptAssignees: false + +# Label to use when marking as stale +staleLabel: "stale" + +# Comment to post when marking as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. Please comment here if it is still valid so that we can + reprioritize. Thank you! + +# Comment to post when removing the stale label. +# unmarkComment: > +# Your comment here. + +# Comment to post when closing a stale Issue or Pull Request. +closeComment: > + Closing this. Please reopen if you believe it should be addressed. Thank you for your contribution. + +# Limit the number of actions per hour, from 1-30. Default is 30 +limitPerRun: 20 + +# Limit to only `issues` or `pulls` +# only: issues + +# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls': +# pulls: +# daysUntilStale: 30 +# markComment: > +# This pull request has been automatically marked as stale because it has not had +# recent activity. It will be closed if no further activity occurs. Thank you +# for your contributions. + +# issues: +# exemptLabels: +# - confirmed diff --git a/.github/workflows/Android-CI.yml b/.github/workflows/Android-CI.yml new file mode 100644 index 0000000..17dd68f --- /dev/null +++ b/.github/workflows/Android-CI.yml @@ -0,0 +1,23 @@ +name: CI Android + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Build with Gradle + run: ./gradlew assembleDebug lint diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml new file mode 100644 index 0000000..f552c8d --- /dev/null +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -0,0 +1,10 @@ +name: "Validate Gradle Wrapper" +on: [push] + +jobs: + validation: + name: "Validation" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: gradle/wrapper-validation-action@v1 diff --git a/app/.gitignore b/app/.gitignore deleted file mode 100644 index 796b96d..0000000 --- a/app/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/build diff --git a/app/build.gradle b/app/build.gradle index a8b0599..80228b4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,7 +1,5 @@ apply plugin: 'com.android.application' - apply plugin: 'kotlin-android' - apply plugin: 'kotlin-android-extensions' android { @@ -27,7 +25,6 @@ android { } dependencies { - implementation fileTree(include: ['*.jar'], dir: 'libs') implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.10' implementation 'androidx.appcompat:appcompat:1.1.0-alpha01' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' diff --git a/app/src/main/java/com/saurabh/androidslices/MainActivity.kt b/app/src/main/java/com/saurabh/androidslices/MainActivity.kt index 0b85d66..0fb1a03 100644 --- a/app/src/main/java/com/saurabh/androidslices/MainActivity.kt +++ b/app/src/main/java/com/saurabh/androidslices/MainActivity.kt @@ -1,7 +1,7 @@ package com.saurabh.androidslices -import androidx.appcompat.app.AppCompatActivity import android.os.Bundle +import androidx.appcompat.app.AppCompatActivity class MainActivity : AppCompatActivity() { diff --git a/app/src/main/java/com/saurabh/androidslices/MyBroadcastReceiver.kt b/app/src/main/java/com/saurabh/androidslices/MyBroadcastReceiver.kt index 7bac7bb..a46617f 100644 --- a/app/src/main/java/com/saurabh/androidslices/MyBroadcastReceiver.kt +++ b/app/src/main/java/com/saurabh/androidslices/MyBroadcastReceiver.kt @@ -20,19 +20,19 @@ class MyBroadcastReceiver : BroadcastReceiver() { override fun onReceive(context: Context?, intent: Intent?) { if (intent?.action?.equals(TOGGLE_WIFI) == true) { - val wifiManager = context?.applicationContext?.getSystemService(Context.WIFI_SERVICE); + val wifiManager = context?.applicationContext?.getSystemService(Context.WIFI_SERVICE) if (wifiManager is WifiManager) { val wifiState = intent.getBooleanExtra(EXTRA_VALUE_KEY, wifiManager.isWifiEnabled) - wifiManager.setWifiEnabled(!wifiState) + wifiManager.isWifiEnabled = !wifiState // Actually, wifiManager.setWifiEnabled is an async call, so you can wait or listen to the wifi state change with help of any broadcast and update the slice later for the accurate results. context.contentResolver?.notifyChange(wifiToggleUri, null) } } else if (intent?.action?.equals(DECREMENT_COUNTER_ACTION) == true && intent.hasExtra(EXTRA_VALUE_KEY)) { - currentValue = intent.getIntExtra(EXTRA_VALUE_KEY, 0); + currentValue = intent.getIntExtra(EXTRA_VALUE_KEY, 0) context?.contentResolver?.notifyChange(dynamicSliceUri, null) } else if (intent?.action?.equals(INCREMENT_COUNTER_ACTION) == true && intent.hasExtra(EXTRA_VALUE_KEY)) { - currentValue = intent.getIntExtra(EXTRA_VALUE_KEY, 0); + currentValue = intent.getIntExtra(EXTRA_VALUE_KEY, 0) context?.contentResolver?.notifyChange(dynamicSliceUri, null) } } diff --git a/app/src/main/java/com/saurabh/androidslices/MySliceProvider.kt b/app/src/main/java/com/saurabh/androidslices/MySliceProvider.kt index 64d9bc6..308d82f 100644 --- a/app/src/main/java/com/saurabh/androidslices/MySliceProvider.kt +++ b/app/src/main/java/com/saurabh/androidslices/MySliceProvider.kt @@ -26,7 +26,7 @@ class MySliceProvider : SliceProvider() { } override fun onMapIntentToUri(intent: Intent?): Uri { - Log.d("MySliceProvider", "onMapIntentToUri"); + Log.d("MySliceProvider", "onMapIntentToUri") return super.onMapIntentToUri(intent) } @@ -59,10 +59,10 @@ class MySliceProvider : SliceProvider() { //region Basic Slices private fun createBasicRowSlice(sliceUri: Uri): Slice { - return ListBuilder(context, sliceUri, ListBuilder.INFINITY) + return ListBuilder(context, sliceUri, INFINITY) .addRow { - it.setTitle("Welcome Android Slice") - it.setSubtitle("Row of Slice") + it.title = "Welcome Android Slice" + it.subtitle = "Row of Slice" // comment the following line to get the exception. it.primaryAction = createActivityAction(Intent(context, MainActivity::class.java), R.drawable.ic_pizza_slice_24, SliceHints.ICON_IMAGE) } @@ -70,10 +70,10 @@ class MySliceProvider : SliceProvider() { } private fun createRowSliceWithStartItem(sliceUri: Uri): Slice { - return ListBuilder(context, sliceUri, ListBuilder.INFINITY) + return ListBuilder(context, sliceUri, INFINITY) .addRow { - it.setTitle("Welcome Android Slice") - it.setSubtitle("It has Start Item") + it.title = "Welcome Android Slice" + it.subtitle = "It has Start Item" // comment the following line to get the exception. //it.primaryAction = createActivityAction(Intent(context, MainActivity::class.java), R.drawable.ic_pizza_slice_24, SliceHints.ICON_IMAGE) it.setTitleItem(createActivityAction(Intent(context, MainActivity::class.java), R.drawable.ic_pizza_slice_24, SliceHints.ICON_IMAGE)) @@ -82,21 +82,21 @@ class MySliceProvider : SliceProvider() { } private fun createRowSliceWithStartItem1(sliceUri: Uri): Slice { - return list(context, sliceUri, ListBuilder.INFINITY) { + return list(context, sliceUri, INFINITY) { row { setTitleItem(createActivityAction(Intent(context, MainActivity::class.java), R.drawable.ic_pizza_slice_24, SliceHints.ICON_IMAGE)) - setTitle("Welcome Android Slice") - setSubtitle("It has Start Item") + title = "Welcome Android Slice" + subtitle = "It has Start Item" } } } private fun createBasicHeaderSlice(sliceUri: Uri): Slice { - return ListBuilder(context, sliceUri, ListBuilder.INFINITY) + return ListBuilder(context, sliceUri, INFINITY) .setHeader { - it.setTitle("Welcome Android Slice") - it.setSubtitle("Header of Slice") - it.setSubtitle("Header of Slice") + it.title = "Welcome Android Slice" + it.subtitle = "Header of Slice" + it.subtitle = "Header of Slice" } .build() } @@ -129,9 +129,9 @@ class MySliceProvider : SliceProvider() { val wifiManager = context.getSystemService(Context.WIFI_SERVICE) val isWifiEnabled = wifiManager is WifiManager && wifiManager.isWifiEnabled if (isWifiEnabled) { - subTitle = "Enabled"; + subTitle = "Enabled" } else { - subTitle = "Not Enabled"; + subTitle = "Not Enabled" } return list(context, sliceUri, INFINITY) { @@ -144,7 +144,7 @@ class MySliceProvider : SliceProvider() { } private fun createWiFiToggleAction(wifiEnabled: Boolean): SliceAction { - val intent = Intent(context, MyBroadcastReceiver::class.java).setAction(MyBroadcastReceiver.TOGGLE_WIFI).putExtra(MyBroadcastReceiver.EXTRA_VALUE_KEY, wifiEnabled); + val intent = Intent(context, MyBroadcastReceiver::class.java).setAction(MyBroadcastReceiver.TOGGLE_WIFI).putExtra(MyBroadcastReceiver.EXTRA_VALUE_KEY, wifiEnabled) return SliceAction(PendingIntent.getBroadcast(context, 0, intent, 0), "Toggle Wi-Fi", wifiEnabled) } //endregion @@ -183,7 +183,7 @@ class MySliceProvider : SliceProvider() { // We’re waiting to load the time to work so indicate that on the slice by // setting the subtitle with the overloaded method and indicate true. Timer("SettingUp", false).schedule(2000) { loadSliceContents() } - return list(context, sliceUri, ListBuilder.INFINITY) { + return list(context, sliceUri, INFINITY) { row { title = "Ride to work" if (contentLoaded) { @@ -198,7 +198,7 @@ class MySliceProvider : SliceProvider() { private fun loadSliceContents() { contentLoaded = true - context.contentResolver.notifyChange(delayContentSliceUri, null) + context?.contentResolver?.notifyChange(delayContentSliceUri, null) } //endregion @@ -247,7 +247,7 @@ class MySliceProvider : SliceProvider() { } private fun createSliceWithHeaderAndRow(sliceUri: Uri): Slice? { - return list(context, sliceUri, ListBuilder.INFINITY) { + return list(context, sliceUri, INFINITY) { header { title = "Get a ride." subtitle = "Ride in 4 min." @@ -277,7 +277,7 @@ class MySliceProvider : SliceProvider() { //region GridRowBuilder examples private fun createSliceWithGridRow(sliceUri: Uri): Slice { - return list(context, sliceUri, ListBuilder.INFINITY) { + return list(context, sliceUri, INFINITY) { header { title = "Famous restaurants" primaryAction = createActivityAction(Intent(context, MainActivity::class.java), R.drawable.ic_restaurant_24, SliceHints.ICON_IMAGE) @@ -326,7 +326,7 @@ class MySliceProvider : SliceProvider() { mapIntent.setPackage("com.google.android.apps.maps") - return list(context, sliceUri, ListBuilder.INFINITY) { + return list(context, sliceUri, INFINITY) { header { title = "Near by restaurants" primaryAction = createPrimaryOpenMainActivityAction() @@ -354,7 +354,7 @@ class MySliceProvider : SliceProvider() { //region Combine Row/Item tempaltes private fun createCombineSlices(sliceUri: Uri): Slice { - return list(context, sliceUri, ListBuilder.INFINITY) { + return list(context, sliceUri, INFINITY) { row { title = "Upcoming Trip: Seattle" subtitle = "Aug 15-20 • 5 Guests" @@ -384,7 +384,7 @@ class MySliceProvider : SliceProvider() { val mapIntent = Intent(Intent.ACTION_VIEW, gmmIntentUri) mapIntent.setPackage("com.google.android.apps.maps") - return list(context, sliceUri, ListBuilder.INFINITY) { + return list(context, sliceUri, INFINITY) { header { title = "Heavy traffic in your area" subtitle = "Typical conditions delays up to 28" @@ -463,7 +463,7 @@ class MySliceProvider : SliceProvider() { } private fun createErrorSlice(sliceUri: Uri): Slice { - return ListBuilder(context, sliceUri, ListBuilder.INFINITY) + return ListBuilder(context, sliceUri, INFINITY) .addRow { it.title = "URI not found, Error." it.primaryAction = createPrimaryOpenMainActivityAction() diff --git a/app/src/main/java/com/saurabh/androidslices/SliceProblemProvider.kt b/app/src/main/java/com/saurabh/androidslices/SliceProblemProvider.kt index a6882a2..187e165 100644 --- a/app/src/main/java/com/saurabh/androidslices/SliceProblemProvider.kt +++ b/app/src/main/java/com/saurabh/androidslices/SliceProblemProvider.kt @@ -17,9 +17,9 @@ class SliceProblemProvider : SliceProvider() { } override fun onBindSlice(sliceUri: Uri): Slice? { - return when { - sliceUri.path == "/basicRowSliceKTX" -> createRowSliceWithStartItemKTX(sliceUri) - sliceUri.path == "/inputRangePrimaryAction" -> createInputRangeSlice(sliceUri) + return when (sliceUri.path) { + "/basicRowSliceKTX" -> createRowSliceWithStartItemKTX(sliceUri) + "/inputRangePrimaryAction" -> createInputRangeSlice(sliceUri) else -> { return null } @@ -65,7 +65,7 @@ class SliceProblemProvider : SliceProvider() { val intent = Intent(context, MyBroadcastReceiver::class.java) return SliceAction.create(PendingIntent.getBroadcast(context, 0, intent, 0), IconCompat.createWithResource(context, R.drawable.ic_brightness_auto_24), - SliceHints.ICON_IMAGE, + ListBuilder.ICON_IMAGE, "Toggle adaptive brightness") } diff --git a/app/src/main/res/drawable/restaurant1.png b/app/src/main/res/drawable/restaurant1.jpg similarity index 100% rename from app/src/main/res/drawable/restaurant1.png rename to app/src/main/res/drawable/restaurant1.jpg diff --git a/build.gradle b/build.gradle index 8d957e4..1af677a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,16 +1,11 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - buildscript { repositories { jcenter() google() } dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.10" - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files + classpath 'com.android.tools.build:gradle:3.6.1' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.70" } } diff --git a/gradle.properties b/gradle.properties index 743d692..e92519f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,3 +11,7 @@ org.gradle.jvmargs=-Xmx1536m # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true + + +android.enableJetifier=true +android.useAndroidX=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fa7190d..5120dad 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Aug 20 09:19:39 PDT 2018 +#Mon Mar 23 07:02:15 CET 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip