Skip to content

Commit

Permalink
Adding the current version of the GDG Watch Face
Browse files Browse the repository at this point in the history
Signed-off-by: Jomar Tigcal <[email protected]>
  • Loading branch information
jomartigcal committed Jan 14, 2016
1 parent 84de36c commit a95ec05
Show file tree
Hide file tree
Showing 48 changed files with 1,327 additions and 1 deletion.
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,9 @@ dependencies {
//Local
compile fileTree(dir: 'libs', include: ['*.jar'])

// Android Wear
wearApp project(':wear')

// Dependencies for local unit tests
testCompile "junit:junit:$rootProject.junitVersion"
testCompile "org.mockito:mockito-all:$rootProject.mockitoVersion"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.NFC"/>
<uses-permission android:name="android.permission.GET_TASKS"/>
<uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND"/>

<permission
android:name="${applicationId}.permission.MAPS_RECEIVE"
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include ':app'
include ':app', ':wear'
1 change: 1 addition & 0 deletions wear/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
27 changes: 27 additions & 0 deletions wear/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apply plugin: 'com.android.application'


android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "org.gdg.frisbee.android"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:1.3.0'
compile 'com.google.android.gms:play-services-wearable:8.4.0'
}
17 changes: 17 additions & 0 deletions wear/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/jomartigcal/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
57 changes: 57 additions & 0 deletions wear/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.gdg.frisbee.android">
<uses-feature android:name="android.hardware.type.watch" />
<uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@android:style/Theme.DeviceDefault">
<service
android:name=".GdgWatchFace"
android:label="@string/app_name"
android:permission="android.permission.BIND_WALLPAPER">
<meta-data
android:name="android.service.wallpaper"
android:resource="@xml/watch_face"/>
<meta-data
android:name="com.google.android.wearable.watchface.preview"
android:resource="@drawable/preview_square"/>
<meta-data
android:name="com.google.android.wearable.watchface.preview_circular"
android:resource="@drawable/preview_round"/>
<meta-data
android:name="com.google.android.wearable.watchface.wearableConfigurationAction"
android:value="org.gdgph.watchface.CONFIG"/>

<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService"/>

<category android:name="com.google.android.wearable.watchface.category.WATCH_FACE"/>
</intent-filter>
</service>

<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>

<activity
android:name=".WearableConfigurationActivity"
android:label="@string/label_configure">
<intent-filter>
<action android:name="org.gdgph.watchface.CONFIG"/>

<category android:name="com.google.android.wearable.watchface.category.WEARABLE_CONFIGURATION"/>
<category android:name="android.intent.category.DEFAULT"/>

</intent-filter>
</activity>
<activity
android:name=".ColorConfigActivity"
android:label="@string/label_configure"/>
</application>

</manifest>
Binary file added wear/src/main/ic_launcher-web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package org.gdg.frisbee.android;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.wearable.view.CircledImageView;
import android.support.wearable.view.WearableListView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

public class ColorConfigActivity extends Activity {
public static final String CONFIG_HEADER = "org.gdgph.watchface.CONFIG_HEADER";
public static final String CONFIG_COLOR = "org.gdgph.watchface.CONFIG_COLOR";

private String mHeader;

private WearableListView mListView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_wearable_configuration);

final TextView headerText = (TextView) findViewById(R.id.settings_header);
if (getIntent().getExtras().containsKey(CONFIG_HEADER)) {
mHeader = getIntent().getStringExtra(CONFIG_HEADER);
headerText.setText(mHeader);
} else {
finish();
}

mListView = (WearableListView) findViewById(R.id.settings_list);
mListView.addOnScrollListener(new WearableListView.OnScrollListener() {
@Override
public void onScroll(int i) {

}

@Override
public void onAbsoluteScrollChange(int scroll) {
float translation = Math.min(-scroll, 0);
headerText.setTranslationY(translation);
}

@Override
public void onScrollStateChanged(int i) {

}

@Override
public void onCentralPositionChanged(int i) {

}
});

displayColorSelections();
}

private void displayColorSelections() {
List<String> colorList = new ArrayList<>();

if (mHeader.contains("Background")) {
String[] backgrounds = getResources().getStringArray(R.array.background_selection);
for (String background : backgrounds) {
colorList.add(background);
}
} else {
String[] colors = getResources().getStringArray(R.array.color_selection);
for (String color : colors) {
colorList.add(color);
}
}

ColorConfigAdapter adapter = new ColorConfigAdapter(this, colorList);
mListView.setAdapter(adapter);
mListView.setClickListener(new WearableListView.ClickListener() {
@Override
public void onClick(WearableListView.ViewHolder viewHolder) {
WearableListItemLayout layout = (WearableListItemLayout) viewHolder.itemView;
CircledImageView circleImage = (CircledImageView) layout.findViewById(R.id.setting_circle);

Intent intent = new Intent();
intent.putExtra(CONFIG_HEADER, mHeader);
intent.putExtra(CONFIG_COLOR, circleImage.getDefaultCircleColor());
setResult(RESULT_OK, intent);
finish();
}

@Override
public void onTopEmptyRegionClick() {

}
});
}
}
49 changes: 49 additions & 0 deletions wear/src/main/java/org/gdg/frisbee/android/ColorConfigAdapter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package org.gdg.frisbee.android;

import android.content.Context;
import android.graphics.Color;
import android.support.wearable.view.CircledImageView;
import android.support.wearable.view.WearableListView;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

public class ColorConfigAdapter extends WearableListView.Adapter {

private final Context mContext;
private final List<String> mColors;

public ColorConfigAdapter(Context context, List<String> mColors) {
mContext = context;
this.mColors = mColors;
}

@Override
public WearableListView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new WearableListView.ViewHolder(new WearableListItemLayout(mContext));
}

@Override
public void onBindViewHolder(WearableListView.ViewHolder holder, int position) {
WearableListItemLayout layout = (WearableListItemLayout) holder.itemView;

TextView nameTextView = (TextView) layout.findViewById(R.id.setting_text_view);
nameTextView.setText(mColors.get(position));

CircledImageView circleImage = (CircledImageView) layout.findViewById(R.id.setting_circle);
String color = mColors.get(position);
if("Dark".equals(color)) {
circleImage.setCircleColor(Color.BLACK);
} else if("Light".equals(color)) {
circleImage.setCircleColor(Color.WHITE);
} else {
circleImage.setCircleColor(Color.parseColor(mColors.get(position)));
}
}

@Override
public int getItemCount() {
return mColors.size();
}
}
Loading

0 comments on commit a95ec05

Please sign in to comment.