Skip to content

Commit e16778b

Browse files
committed
added watchface sample
1 parent d91792d commit e16778b

File tree

13 files changed

+113
-0
lines changed

13 files changed

+113
-0
lines changed

studio/apps/watchface/build.gradle

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 27
5+
defaultConfig {
6+
applicationId "processing.tests.watchface"
7+
minSdkVersion 25
8+
targetSdkVersion 27
9+
versionCode 1
10+
versionName "1.0"
11+
multiDexEnabled true
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:palette-v7:26.0.2'
32+
implementation 'com.android.support:support-v4:26.0.2'
33+
implementation 'com.google.android.gms:play-services-wearable:11.0.4'
34+
implementation 'com.android.support:percent:26.0.2'
35+
implementation 'com.android.support:recyclerview-v7:26.0.2'
36+
implementation 'com.google.android.support:wearable:2.1.0'
37+
compileOnly 'com.google.android.wearable:wearable:2.1.0'
38+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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="watchface">
3+
<uses-sdk android:minSdkVersion="25" android:targetSdkVersion="26"/>
4+
<uses-feature android:name="android.hardware.type.watch"/>
5+
<uses-permission android:name="android.permission.WAKE_LOCK"/>
6+
<application android:icon="@mipmap/ic_launcher" android:label="watchface" android:supportsRtl="true" android:theme="@android:style/Theme.DeviceDefault">
7+
<uses-library android:name="com.google.android.wearable" android:required="false"/>
8+
<meta-data android:name="com.google.android.wearable.standalone" android:value="true"/>
9+
<service android:label="watchface" android:name=".MainService" android:permission="android.permission.BIND_WALLPAPER">
10+
<meta-data android:name="android.service.wallpaper" android:resource="@xml/watch_face"/>
11+
<meta-data android:name="com.google.android.wearable.watchface.preview" android:resource="@drawable/preview_analog"/>
12+
<meta-data android:name="com.google.android.wearable.watchface.preview_circular" android:resource="@drawable/preview_analog"/>
13+
<meta-data android:name="com.google.android.wearable.watchface.companionConfigurationAction" android:value="com.catinean.simpleandroidwatchface.CONFIG_DIGITAL"/>
14+
<intent-filter>
15+
<action android:name="android.service.wallpaper.WallpaperService"/>
16+
<category android:name="com.google.android.wearable.watchface.category.WATCH_FACE"/>
17+
</intent-filter>
18+
</service>
19+
<activity android:name="processing.android.PermissionRequestor"/>
20+
</application>
21+
</manifest>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package watchface;
2+
3+
import processing.android.PWatchFaceCanvas;
4+
//import processing.android.PWatchFaceGLES;
5+
import processing.core.PApplet;
6+
7+
// The service needs to extend PWatchFaceCanvas if the renderer in the sketch is P2D or P3D.
8+
//public class MainService extends PWatchFaceGLES {
9+
public class MainService extends PWatchFaceCanvas {
10+
@Override
11+
public PApplet createSketch() {
12+
PApplet sketch = new Sketch();
13+
return sketch;
14+
}
15+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package watchface;
2+
3+
import processing.core.PApplet;
4+
5+
6+
public class Sketch extends PApplet {
7+
public void settings() {
8+
fullScreen();
9+
}
10+
11+
public void setup() {
12+
frameRate(1);
13+
textFont(createFont("Serif-Bold", 48 * displayDensity));
14+
textAlign(CENTER, CENTER);
15+
fill(255);
16+
}
17+
18+
public void draw() {
19+
background(0);
20+
if (wearInteractive()) {
21+
String str = hour() + ":" + nfs(minute(), 2) + ":" + nfs(second(), 2);
22+
text(str, width/2, height/2);
23+
}
24+
}
25+
}
3.03 KB
Loading
4.5 KB
Loading
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=".test_watchface"
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

0 commit comments

Comments
 (0)