Skip to content

Commit 26c981f

Browse files
committed
added wallpaper sample
1 parent 565d78e commit 26c981f

File tree

14 files changed

+119
-1
lines changed

14 files changed

+119
-1
lines changed

studio/apps/wallpaper/build.gradle

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 26
5+
buildToolsVersion '27.0.3'
6+
defaultConfig {
7+
applicationId "processing.tests.wallpaper"
8+
minSdkVersion 17
9+
targetSdkVersion 21
10+
versionCode 1
11+
versionName "1.0"
12+
}
13+
buildTypes {
14+
release {
15+
minifyEnabled false
16+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17+
}
18+
}
19+
productFlavors {
20+
}
21+
compileOptions {
22+
sourceCompatibility JavaVersion.VERSION_1_7
23+
targetCompatibility JavaVersion.VERSION_1_7
24+
}
25+
}
26+
27+
dependencies {
28+
implementation fileTree(include: ['*.jar'], dir: 'libs')
29+
testImplementation 'junit:junit:4.12'
30+
implementation project(':libs:processing-core')
31+
implementation 'com.android.support:appcompat-v7:26.0.2'
32+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="wallpaper">
3+
<uses-sdk android:minSdkVersion="17" android:targetSdkVersion="26"/>
4+
<uses-feature android:name="android.software.live_wallpaper"/>
5+
<application android:icon="@mipmap/ic_launcher" android:label="wallpaper">
6+
<service android:label="wallpaper" android:name=".MainService" android:permission="android.permission.BIND_WALLPAPER">
7+
<intent-filter>
8+
<action android:name="android.service.wallpaper.WallpaperService"/>
9+
</intent-filter>
10+
<meta-data android:name="android.service.wallpaper" android:resource="@xml/wallpaper"/>
11+
</service>
12+
<activity android:name="processing.android.PermissionRequestor"/>
13+
</application>
14+
</manifest>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package wallpaper;
2+
3+
import processing.android.PWallpaper;
4+
import processing.core.PApplet;
5+
6+
public class MainService extends PWallpaper {
7+
@Override
8+
public PApplet createSketch() {
9+
PApplet sketch = new Sketch();
10+
return sketch;
11+
}
12+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package wallpaper;
2+
3+
import processing.core.PApplet;
4+
5+
public class Sketch extends PApplet {
6+
7+
float currH, currB;
8+
float nextH, nextB;
9+
float easing = 0.001f;
10+
int lastChange = 0;
11+
12+
public void settings() {
13+
fullScreen();
14+
}
15+
16+
public void setup() {
17+
colorMode(HSB, 100);
18+
currH = nextH = 100;
19+
currB = nextB = 100;
20+
}
21+
22+
public void draw() {
23+
background(currH, currB, 100);
24+
updateCurrColor();
25+
if (5000 < millis() - lastChange) {
26+
pickNextColor();
27+
lastChange = millis();
28+
}
29+
}
30+
31+
public void pickNextColor() {
32+
nextH = random(100);
33+
nextB = random(100);
34+
}
35+
36+
public void updateCurrColor() {
37+
// Easing between current and next colors
38+
currH += easing * (nextH - currH);
39+
currB += easing * (nextB - currB);
40+
}
41+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
3+
android:id="@+id/fragment"
4+
android:name=".wallpaper"
5+
tools:layout="@layout/fragment_main"
6+
android:layout_width="match_parent"
7+
android:layout_height="match_parent" />
3.34 KB
Loading
2.15 KB
Loading
4.73 KB
Loading
7.54 KB
Loading
10.2 KB
Loading

0 commit comments

Comments
 (0)