-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding the current version of the GDG Watch Face
Signed-off-by: Jomar Tigcal <[email protected]>
- Loading branch information
1 parent
84de36c
commit a95ec05
Showing
48 changed files
with
1,327 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
include ':app' | ||
include ':app', ':wear' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 *; | ||
#} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
97 changes: 97 additions & 0 deletions
97
wear/src/main/java/org/gdg/frisbee/android/ColorConfigActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
49
wear/src/main/java/org/gdg/frisbee/android/ColorConfigAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
Oops, something went wrong.