Skip to content
This repository was archived by the owner on Mar 24, 2024. It is now read-only.

Commit 17c9c9d

Browse files
author
adwardstark
committed
Added two-widget samples [ launch, like ]
0 parents  commit 17c9c9d

File tree

65 files changed

+1191
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1191
-0
lines changed

.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx

.idea/codeStyles/Project.xml

+138
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/codeStyles/codeStyleConfig.xml

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/copyright/profiles_settings.xml

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

+20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/jarRepositories.xml

+25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Widgets-Android-Example
2+
=======================
3+
4+
Widgets are an essential aspect of home screen customization. You can imagine them as “at-a-glance” views of an app’s most important data and functionality that is accessible right from the user’s home screen.
5+
6+
Following are the types of widgets you can create using code in this repository:
7+
8+
1. `Simple Widget` — Called launch-widget, launches the app.
9+
2. `Broadcast Widget` - Called like-widget, likes/unlikes on tap, shows a toast.
10+
11+
<br />
12+
<img src="screenshot.png" height=200 alt="Art Image"/>

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
apply plugin: 'com.android.application'
2+
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-android-extensions'
4+
5+
android {
6+
compileSdkVersion 29
7+
8+
defaultConfig {
9+
applicationId "com.adwardstark.widgets_android_example"
10+
minSdkVersion 16
11+
targetSdkVersion 29
12+
versionCode 1
13+
versionName "1.0"
14+
15+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16+
}
17+
18+
buildTypes {
19+
release {
20+
minifyEnabled false
21+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
22+
}
23+
}
24+
}
25+
26+
dependencies {
27+
implementation fileTree(dir: "libs", include: ["*.jar"])
28+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
29+
implementation 'androidx.core:core-ktx:1.3.2'
30+
implementation 'androidx.appcompat:appcompat:1.2.0'
31+
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
32+
testImplementation 'junit:junit:4.12'
33+
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
34+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
35+
36+
}

app/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.adwardstark.widgets_android_example
2+
3+
import androidx.test.platform.app.InstrumentationRegistry
4+
import androidx.test.ext.junit.runners.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("com.adwardstark.widgets_android_example", appContext.packageName)
23+
}
24+
}

app/src/main/AndroidManifest.xml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.adwardstark.widgets_android_example">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@style/AppTheme">
12+
<receiver android:name=".LaunchWidget">
13+
<intent-filter>
14+
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
15+
</intent-filter>
16+
17+
<meta-data
18+
android:name="android.appwidget.provider"
19+
android:resource="@xml/launch_widget_info" />
20+
</receiver>
21+
<receiver android:name=".LikeWidget">
22+
<intent-filter>
23+
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
24+
</intent-filter>
25+
26+
<meta-data
27+
android:name="android.appwidget.provider"
28+
android:resource="@xml/like_widget_info" />
29+
</receiver>
30+
31+
<activity android:name=".MainActivity">
32+
<intent-filter>
33+
<action android:name="android.intent.action.MAIN" />
34+
35+
<category android:name="android.intent.category.LAUNCHER" />
36+
</intent-filter>
37+
</activity>
38+
</application>
39+
40+
</manifest>

0 commit comments

Comments
 (0)