Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/baumpfleger.yml
Original file line number Diff line number Diff line change
@@ -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
59 changes: 59 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions .github/workflows/Android-CI.yml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions .github/workflows/gradle-wrapper-validation.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion app/.gitignore

This file was deleted.

3 changes: 0 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
Expand All @@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
50 changes: 25 additions & 25 deletions app/src/main/java/com/saurabh/androidslices/MySliceProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -59,21 +59,21 @@ 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)
}
.build()
}

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))
Expand All @@ -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()
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -198,7 +198,7 @@ class MySliceProvider : SliceProvider() {

private fun loadSliceContents() {
contentLoaded = true
context.contentResolver.notifyChange(delayContentSliceUri, null)
context?.contentResolver?.notifyChange(delayContentSliceUri, null)
}
//endregion

Expand Down Expand Up @@ -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."
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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")
}

Expand Down
9 changes: 2 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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"
}
}

Expand Down
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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