├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── gradle.xml ├── misc.xml ├── modules.xml └── vcs.xml ├── DotLineWatchface.iml ├── README.md ├── app ├── .gitignore ├── app.iml ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── co │ │ └── mobiwise │ │ └── dotlinewatchface │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── assets │ ├── robotolight.ttf │ └── robotothin.ttf │ ├── java │ ├── co │ │ └── mobiwise │ │ │ └── dotlinewatchface │ │ │ ├── WearControlActivity.java │ │ │ ├── adapter │ │ │ └── MyRecyclerAdapter.java │ │ │ └── ui │ │ │ ├── DotLineView.java │ │ │ ├── RobotoTextView.java │ │ │ └── SquareColorView.java │ └── model │ │ └── DotLinePreferences.java │ └── res │ ├── drawable │ ├── icon_selected.png │ └── logo.png │ ├── layout │ ├── activity_wear_control.xml │ └── row_watch_colors.xml │ ├── menu │ └── menu_wear_control.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── values-v21 │ └── styles.xml │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── arrays.xml │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── commons ├── .gitignore ├── build.gradle ├── commons.iml └── src │ └── main │ └── java │ └── com │ └── mobiwise │ └── Commons.java ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── images ├── dotline_mockup.png └── wf.png ├── settings.gradle └── wear ├── .gitignore ├── build.gradle ├── proguard-rules.pro ├── src └── main │ ├── AndroidManifest.xml │ ├── java │ └── co │ │ └── mobiwise │ │ └── dotlinewatchface │ │ └── DotLineWatchfaceService.java │ └── res │ ├── drawable-nodpi │ ├── preview_analog.png │ └── wf_logo.png │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── values │ ├── colors.xml │ ├── dimens.xml │ └── strings.xml │ └── xml │ └── watch_face.xml └── wear.iml /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | /captures 8 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | DotLine Watchface -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 | 24 | 25 | 26 | Android API 22 Platform 27 | 28 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /DotLineWatchface.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DotLineWatchface 2 | Android wear watchface 3 | [Available on Play Store](https://play.google.com/store/apps/details?id=co.mobiwise.dotlinewatchface) 4 | 5 | ![alt tag](http://i62.tinypic.com/2wp14rp.png) 6 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 22 5 | buildToolsVersion "22.0.1" 6 | 7 | defaultConfig { 8 | applicationId "co.mobiwise.dotlinewatchface" 9 | minSdkVersion 9 10 | targetSdkVersion 22 11 | versionCode 2 12 | versionName "1.1" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | compile "com.android.support:appcompat-v7:21.0.+" 25 | compile 'com.jakewharton:butterknife:6.1.0' 26 | compile 'com.android.support:recyclerview-v7:+' 27 | compile 'com.google.android.gms:play-services-wearable:7.5.0' 28 | wearApp project(':wear') 29 | compile project(':commons') 30 | } 31 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/mertsimsek/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/co/mobiwise/dotlinewatchface/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package co.mobiwise.dotlinewatchface; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 13 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/assets/robotolight.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iammert/DotLineWatchface/35d73c2b1afc914aef57cd7840746873c6de1931/app/src/main/assets/robotolight.ttf -------------------------------------------------------------------------------- /app/src/main/assets/robotothin.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iammert/DotLineWatchface/35d73c2b1afc914aef57cd7840746873c6de1931/app/src/main/assets/robotothin.ttf -------------------------------------------------------------------------------- /app/src/main/java/co/mobiwise/dotlinewatchface/WearControlActivity.java: -------------------------------------------------------------------------------- 1 | package co.mobiwise.dotlinewatchface; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.ActionBarActivity; 5 | import android.support.v7.widget.LinearLayoutManager; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.support.v7.widget.Toolbar; 8 | import android.util.Log; 9 | import android.view.Menu; 10 | import android.view.MenuItem; 11 | import android.view.View; 12 | 13 | import com.google.android.gms.wearable.PutDataRequest; 14 | import com.mobiwise.Commons; 15 | import com.google.android.gms.common.ConnectionResult; 16 | import com.google.android.gms.common.api.GoogleApiClient; 17 | import com.google.android.gms.wearable.PutDataMapRequest; 18 | import com.google.android.gms.wearable.Wearable; 19 | 20 | import butterknife.ButterKnife; 21 | import butterknife.InjectView; 22 | import co.mobiwise.dotlinewatchface.adapter.MyRecyclerAdapter; 23 | import co.mobiwise.dotlinewatchface.ui.DotLineView; 24 | import model.DotLinePreferences; 25 | 26 | public class WearControlActivity extends ActionBarActivity implements MyRecyclerAdapter.OnItemClickListener, 27 | GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { 28 | 29 | @InjectView(R.id.toolbar) 30 | Toolbar mToolbar; 31 | 32 | @InjectView(R.id.recycler_view) 33 | RecyclerView mRecyclerView; 34 | 35 | @InjectView(R.id.view_dotline) 36 | DotLineView mDotLineView; 37 | 38 | private MyRecyclerAdapter mAdapter; 39 | private LinearLayoutManager mLinearLayoutManager; 40 | 41 | private DotLinePreferences mDotLinePreferences; 42 | 43 | private GoogleApiClient mGoogleApiClient; 44 | 45 | @Override 46 | protected void onCreate(Bundle savedInstanceState) { 47 | super.onCreate(savedInstanceState); 48 | setContentView(R.layout.activity_wear_control); 49 | 50 | ButterKnife.inject(this); 51 | setSupportActionBar(mToolbar); 52 | getSupportActionBar().setDisplayShowTitleEnabled(false); 53 | 54 | mAdapter = new MyRecyclerAdapter(getDefaultColors(),getApplicationContext()); 55 | mLinearLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false); 56 | mRecyclerView.setLayoutManager(mLinearLayoutManager); 57 | mRecyclerView.setHasFixedSize(true); 58 | mRecyclerView.setAdapter(mAdapter); 59 | mAdapter.setOnItemClickListener(this); 60 | 61 | mDotLinePreferences = DotLinePreferences.newInstance(getApplicationContext()); 62 | mDotLineView.changeDotLineColor(mDotLinePreferences.getBackgroundColour()); 63 | 64 | mGoogleApiClient = new GoogleApiClient.Builder(this) 65 | .addConnectionCallbacks(this) 66 | .addOnConnectionFailedListener(this) 67 | .addApi(Wearable.API) 68 | .build(); 69 | 70 | } 71 | 72 | private int[] getDefaultColors(){ 73 | int[] colorset = getApplicationContext().getResources().getIntArray(R.array.colorset); 74 | return colorset; 75 | } 76 | 77 | @Override 78 | public void onItemClicked(View view, int position) { 79 | mDotLinePreferences.setBackgroundColour(getDefaultColors()[position]); 80 | mDotLineView.changeDotLineColor(getDefaultColors()[position]); 81 | 82 | //Sends data to wear 83 | PutDataMapRequest putDataMapReq = PutDataMapRequest.create(Commons.PATH); 84 | putDataMapReq.getDataMap().putInt(Commons.KEY_BACKGROUND_COLOUR, getDefaultColors()[position]); 85 | PutDataRequest putDataReq = putDataMapReq.asPutDataRequest(); 86 | Wearable.DataApi.putDataItem(mGoogleApiClient, putDataReq); 87 | } 88 | 89 | @Override 90 | public void onConnected(Bundle bundle) { 91 | Log.v("TEST","onConnected"); 92 | 93 | } 94 | 95 | @Override 96 | public void onConnectionSuspended(int i) { 97 | Log.v("TEST","onConnectionSuspended"); 98 | 99 | } 100 | 101 | @Override 102 | public void onConnectionFailed(ConnectionResult connectionResult) { 103 | Log.v("TEST","onConnectionFailed"); 104 | } 105 | 106 | @Override 107 | protected void onStart() { 108 | super.onStart(); 109 | mGoogleApiClient.connect(); 110 | } 111 | 112 | @Override 113 | protected void onStop() { 114 | super.onStop(); 115 | if(mGoogleApiClient != null && mGoogleApiClient.isConnected()) 116 | mGoogleApiClient.disconnect(); 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /app/src/main/java/co/mobiwise/dotlinewatchface/adapter/MyRecyclerAdapter.java: -------------------------------------------------------------------------------- 1 | package co.mobiwise.dotlinewatchface.adapter; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.util.Log; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import butterknife.ButterKnife; 11 | import butterknife.InjectView; 12 | import co.mobiwise.dotlinewatchface.R; 13 | import co.mobiwise.dotlinewatchface.ui.SquareColorView; 14 | import model.DotLinePreferences; 15 | 16 | /** 17 | * Created by mertsimsek on 22/06/15. 18 | */ 19 | public class MyRecyclerAdapter extends RecyclerView.Adapter{ 20 | 21 | public interface OnItemClickListener{ 22 | public void onItemClicked(View view, int position); 23 | } 24 | 25 | private int[] mColorArray; 26 | private Context mContext; 27 | private OnItemClickListener mListener; 28 | 29 | private int mSelectedPosition = -1; 30 | 31 | private ViewHolder currentHolder; 32 | 33 | private DotLinePreferences mPreferences; 34 | 35 | public MyRecyclerAdapter(int[] mColorArray, Context mContext) { 36 | this.mColorArray = mColorArray; 37 | this.mContext = mContext; 38 | mPreferences = DotLinePreferences.newInstance(mContext); 39 | } 40 | 41 | @Override 42 | public MyRecyclerAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { 43 | View view = LayoutInflater.from(mContext).inflate(R.layout.row_watch_colors,viewGroup,false); 44 | ViewHolder viewHolder = new ViewHolder(view); 45 | return viewHolder; 46 | } 47 | 48 | @Override 49 | public void onBindViewHolder(MyRecyclerAdapter.ViewHolder viewHolder, int i) { 50 | viewHolder.colorView.setColor(mColorArray[i]); 51 | if(i != mSelectedPosition) 52 | viewHolder.colorView.setSelected(false); 53 | else 54 | viewHolder.colorView.setSelected(true); 55 | } 56 | 57 | @Override 58 | public int getItemCount() { 59 | return mColorArray.length; 60 | } 61 | 62 | public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{ 63 | 64 | @InjectView(R.id.colorview) 65 | SquareColorView colorView; 66 | 67 | public ViewHolder(View itemView) { 68 | super(itemView); 69 | ButterKnife.inject(this, itemView); 70 | itemView.setOnClickListener(this); 71 | } 72 | 73 | @Override 74 | public void onClick(View v) { 75 | if(mListener != null){ 76 | mListener.onItemClicked(v, getPosition()); 77 | mSelectedPosition = getPosition(); 78 | 79 | if(currentHolder!=null) 80 | currentHolder.colorView.setSelected(false); 81 | currentHolder = this; 82 | this.colorView.setSelected(true); 83 | } 84 | } 85 | } 86 | 87 | public void setOnItemClickListener(OnItemClickListener mListener){ 88 | this.mListener = mListener; 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /app/src/main/java/co/mobiwise/dotlinewatchface/ui/DotLineView.java: -------------------------------------------------------------------------------- 1 | package co.mobiwise.dotlinewatchface.ui; 2 | 3 | import android.annotation.TargetApi; 4 | import android.content.Context; 5 | import android.content.res.Resources; 6 | import android.graphics.Canvas; 7 | import android.graphics.Paint; 8 | import android.os.Build; 9 | import android.util.AttributeSet; 10 | import android.view.View; 11 | 12 | import co.mobiwise.dotlinewatchface.R; 13 | 14 | /** 15 | * Created by mertsimsek on 22/06/15. 16 | */ 17 | public class DotLineView extends View{ 18 | 19 | private Paint mBackgroundPaint; 20 | private Paint mDotPaint; 21 | private Paint mLinePaint; 22 | 23 | private int mWidth; 24 | private int mHeight; 25 | private float mCenterX; 26 | private float mCenterY; 27 | 28 | public DotLineView(Context context) { 29 | super(context); 30 | init(); 31 | } 32 | 33 | public DotLineView(Context context, AttributeSet attrs) { 34 | super(context, attrs); 35 | init(); 36 | } 37 | 38 | public DotLineView(Context context, AttributeSet attrs, int defStyleAttr) { 39 | super(context, attrs, defStyleAttr); 40 | init(); 41 | } 42 | 43 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 44 | public DotLineView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 45 | super(context, attrs, defStyleAttr, defStyleRes); 46 | init(); 47 | } 48 | 49 | private void init(){ 50 | 51 | Resources resources = getContext().getResources(); 52 | 53 | mBackgroundPaint = new Paint(); 54 | mBackgroundPaint.setColor(resources.getColor(R.color.analog_background)); 55 | mBackgroundPaint.setAntiAlias(true); 56 | 57 | mDotPaint = new Paint(); 58 | mDotPaint.setColor(resources.getColor(R.color.color_white)); 59 | mDotPaint.setStyle(Paint.Style.FILL); 60 | mDotPaint.setAntiAlias(true); 61 | mDotPaint.setShadowLayer(2.0f, 1.5f, 1.5f, resources.getColor(R.color.color_shadow)); 62 | 63 | mLinePaint = new Paint(); 64 | mLinePaint.setColor(resources.getColor(R.color.color_white)); 65 | mLinePaint.setStrokeWidth(resources.getDimension(R.dimen.analog_hand_stroke)); 66 | mLinePaint.setAntiAlias(true); 67 | mLinePaint.setStrokeCap(Paint.Cap.ROUND); 68 | mLinePaint.setShadowLayer(2.0f, 1.5f, 1.5f, resources.getColor(R.color.color_shadow)); 69 | } 70 | 71 | public void changeDotLineColor(int color){ 72 | mBackgroundPaint.setColor(color); 73 | postInvalidate(); 74 | } 75 | 76 | @Override 77 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 78 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 79 | mWidth = getMeasuredWidth(); 80 | mHeight = getMeasuredHeight(); 81 | 82 | mCenterX = mWidth / 2f; 83 | mCenterY = mHeight / 2f; 84 | } 85 | 86 | @Override 87 | protected void onDraw(Canvas canvas) { 88 | super.onDraw(canvas); 89 | 90 | canvas.drawCircle(mCenterX, mCenterY, mCenterX, mBackgroundPaint); 91 | 92 | int minutes = 54; 93 | float minRot = minutes / 30f * (float) Math.PI; 94 | float hrRot = ((12 + (minutes / 60f)) / 6f) * (float) Math.PI; 95 | 96 | float minLength = mCenterX - 100f; 97 | float hrLength = mCenterY - 100f; 98 | 99 | float hrX = (float) Math.sin(hrRot) * hrLength; 100 | float hrY = (float) -Math.cos(hrRot) * hrLength; 101 | canvas.drawLine(mCenterX, mCenterY, mCenterX + hrX, mCenterY + hrY, mLinePaint); 102 | 103 | float minX = (float) Math.sin(minRot) * minLength; 104 | float minY = (float) -Math.cos(minRot) * minLength; 105 | canvas.drawCircle(mCenterX + minX, mCenterY + minY, getResources().getDimension(R.dimen.analog_hand_stroke), mDotPaint); 106 | 107 | canvas.save(); 108 | canvas.restore(); 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /app/src/main/java/co/mobiwise/dotlinewatchface/ui/RobotoTextView.java: -------------------------------------------------------------------------------- 1 | package co.mobiwise.dotlinewatchface.ui; 2 | 3 | import android.content.Context; 4 | import android.graphics.Typeface; 5 | import android.util.AttributeSet; 6 | import android.widget.TextView; 7 | 8 | /** 9 | * Created by mertsimsek on 22/06/15. 10 | */ 11 | public class RobotoTextView extends TextView{ 12 | 13 | public RobotoTextView(Context context) { 14 | super(context); 15 | } 16 | 17 | public RobotoTextView(Context context, AttributeSet attrs) { 18 | super(context, attrs); 19 | init(); 20 | } 21 | 22 | public RobotoTextView(Context context, AttributeSet attrs, int defStyleAttr) { 23 | super(context, attrs, defStyleAttr); 24 | init(); 25 | } 26 | 27 | public RobotoTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 28 | super(context, attrs, defStyleAttr, defStyleRes); 29 | init(); 30 | } 31 | 32 | private void init(){ 33 | Typeface tf = Typeface.createFromAsset(getContext().getResources().getAssets(), "robotolight.ttf"); 34 | setTypeface(tf); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/co/mobiwise/dotlinewatchface/ui/SquareColorView.java: -------------------------------------------------------------------------------- 1 | package co.mobiwise.dotlinewatchface.ui; 2 | 3 | import android.annotation.TargetApi; 4 | import android.content.Context; 5 | import android.graphics.Bitmap; 6 | import android.graphics.BitmapFactory; 7 | import android.graphics.Canvas; 8 | import android.graphics.Color; 9 | import android.graphics.Paint; 10 | import android.graphics.RectF; 11 | import android.os.Build; 12 | import android.util.AttributeSet; 13 | import android.view.View; 14 | 15 | import co.mobiwise.dotlinewatchface.R; 16 | 17 | /** 18 | * Created by mertsimsek on 22/06/15. 19 | */ 20 | public class SquareColorView extends View{ 21 | 22 | private Paint mBackgroundPaint; 23 | 24 | private static int DEFAULT_COLOR = Color.WHITE; 25 | 26 | private int mColor; 27 | 28 | private int mWidth; 29 | private int mHeight; 30 | 31 | private float mCenterX; 32 | private float mCenterY; 33 | 34 | private Bitmap mSelectedBitmap; 35 | 36 | private boolean isSelected; 37 | 38 | private float mScale = 1; 39 | 40 | public SquareColorView(Context context) { 41 | super(context); 42 | init(); 43 | } 44 | 45 | public SquareColorView(Context context, AttributeSet attrs) { 46 | super(context, attrs); 47 | init(); 48 | } 49 | 50 | public SquareColorView(Context context, AttributeSet attrs, int defStyleAttr) { 51 | super(context, attrs, defStyleAttr); 52 | init(); 53 | } 54 | 55 | @TargetApi(Build.VERSION_CODES.LOLLIPOP) 56 | public SquareColorView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 57 | super(context, attrs, defStyleAttr, defStyleRes); 58 | init(); 59 | } 60 | 61 | private void init(){ 62 | mColor = DEFAULT_COLOR; 63 | isSelected = false; 64 | mSelectedBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.icon_selected); 65 | updatePaint(); 66 | } 67 | 68 | private void updatePaint(){ 69 | mBackgroundPaint = new Paint(); 70 | mBackgroundPaint.setColor(mColor); 71 | mBackgroundPaint.setAntiAlias(true); 72 | mBackgroundPaint.setStyle(Paint.Style.FILL); 73 | } 74 | 75 | public void setColor(int mColor){ 76 | this.mColor = mColor; 77 | updatePaint(); 78 | postInvalidate(); 79 | } 80 | 81 | @Override 82 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 83 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 84 | mWidth = getMeasuredWidth(); 85 | mHeight = getMeasuredHeight(); 86 | 87 | mCenterX = mWidth / 2f; 88 | mCenterY = mHeight / 2f; 89 | 90 | mScale = ((float) mWidth) / (float) mSelectedBitmap.getWidth(); 91 | mSelectedBitmap = Bitmap.createScaledBitmap(mSelectedBitmap, 92 | (int) (mSelectedBitmap.getWidth() * mScale / 3), 93 | (int) (mSelectedBitmap.getHeight() * mScale / 3), true); 94 | 95 | } 96 | 97 | @Override 98 | protected void onDraw(Canvas canvas) { 99 | super.onDraw(canvas); 100 | 101 | RectF rectF = new RectF(0, 0, mWidth, mHeight); 102 | canvas.drawRoundRect(rectF, 60, 60, mBackgroundPaint); 103 | 104 | if(isSelected) 105 | canvas.drawBitmap(mSelectedBitmap, mCenterX - (mSelectedBitmap.getWidth()/2f), mCenterY - (mSelectedBitmap.getHeight()/2f), null); 106 | 107 | canvas.save(); 108 | canvas.restore(); 109 | } 110 | 111 | public void setSelected(boolean isSelected){ 112 | this.isSelected = isSelected; 113 | postInvalidate(); 114 | } 115 | 116 | public boolean isSelected(){ 117 | return isSelected; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /app/src/main/java/model/DotLinePreferences.java: -------------------------------------------------------------------------------- 1 | package model; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.graphics.Color; 6 | 7 | import co.mobiwise.dotlinewatchface.R; 8 | 9 | /** 10 | * Created by mertsimsek on 23/06/15. 11 | */ 12 | public class DotLinePreferences { 13 | 14 | private static final String NAME = "DotLinePreferences"; 15 | private static final String KEY_BACKGROUND_COLOUR = NAME + ".KEY_BACKGROUND_COLOUR"; 16 | 17 | private final SharedPreferences mPreferences; 18 | private Context mContext; 19 | 20 | public static DotLinePreferences newInstance(Context mContext) { 21 | SharedPreferences preferences = mContext.getSharedPreferences(NAME, Context.MODE_PRIVATE); 22 | return new DotLinePreferences(preferences, mContext); 23 | } 24 | 25 | DotLinePreferences(SharedPreferences mPreferences, Context mContext) { 26 | this.mPreferences = mPreferences; 27 | this.mContext = mContext; 28 | } 29 | 30 | public int getBackgroundColour() { 31 | return mPreferences.getInt(KEY_BACKGROUND_COLOUR, mContext.getResources().getColor(R.color.color_default)); 32 | } 33 | 34 | public void setBackgroundColour(int color) { 35 | mPreferences.edit().putInt(KEY_BACKGROUND_COLOUR, color).apply(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/icon_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iammert/DotLineWatchface/35d73c2b1afc914aef57cd7840746873c6de1931/app/src/main/res/drawable/icon_selected.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iammert/DotLineWatchface/35d73c2b1afc914aef57cd7840746873c6de1931/app/src/main/res/drawable/logo.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_wear_control.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 13 | 14 | 20 | 21 | 22 | 23 | 34 | 35 | 42 | 43 | 44 | 55 | 56 | 57 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /app/src/main/res/layout/row_watch_colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_wear_control.xml: -------------------------------------------------------------------------------- 1 | 3 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iammert/DotLineWatchface/35d73c2b1afc914aef57cd7840746873c6de1931/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iammert/DotLineWatchface/35d73c2b1afc914aef57cd7840746873c6de1931/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iammert/DotLineWatchface/35d73c2b1afc914aef57cd7840746873c6de1931/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iammert/DotLineWatchface/35d73c2b1afc914aef57cd7840746873c6de1931/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-v21/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/arrays.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | @color/color_1 6 | @color/color_2 7 | @color/color_3 8 | @color/color_4 9 | @color/color_5 10 | @color/color_6 11 | @color/color_7 12 | @color/color_8 13 | @color/color_9 14 | @color/color_10 15 | @color/color_11 16 | @color/color_12 17 | @color/color_13 18 | @color/color_14 19 | @color/color_15 20 | @color/color_16 21 | @color/color_17 22 | @color/color_18 23 | @color/color_19 24 | @color/color_20 25 | @color/color_21 26 | @color/color_22 27 | @color/color_23 28 | @color/color_24 29 | @color/color_25 30 | 31 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #009c8a 4 | #ff000000 5 | #D1000000 6 | #cccccc 7 | #ffffff 8 | #FF9800 9 | #ffbb5e00 10 | 11 | 12 | 13 | #009c8a 14 | #ef5350 15 | #5d4037 16 | #9e9e9e 17 | #363636 18 | #1abc9c 19 | #16a085 20 | #f1c71b 21 | #f39c12 22 | #2ecc71 23 | #27ae60 24 | #e67e22 25 | #d35400 26 | #3498db 27 | #2980b9 28 | #e74c3c 29 | #c0392b 30 | #9b59b6 31 | #34495e 32 | #2c3e50 33 | #7f8c8d 34 | #F2784B 35 | #2C3E50 36 | #96281B 37 | #1E824C 38 | 39 | 40 | #009c8a 41 | 42 | 43 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 12dp 6 | 20sp 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | DotLine Watchface 3 | 4 | Hello world! 5 | Settings 6 | MY WATCHFACE 7 | WATCHFACE COLORS 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.2.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /commons/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /commons/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | 3 | dependencies { 4 | compile fileTree(dir: 'libs', include: ['*.jar']) 5 | } -------------------------------------------------------------------------------- /commons/commons.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /commons/src/main/java/com/mobiwise/Commons.java: -------------------------------------------------------------------------------- 1 | package com.mobiwise; 2 | 3 | public class Commons { 4 | 5 | public static final String PATH = "/face_config"; 6 | public static final String KEY_BACKGROUND_COLOUR = "KEY_BACKGROUND_COLOUR"; 7 | } 8 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iammert/DotLineWatchface/35d73c2b1afc914aef57cd7840746873c6de1931/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /images/dotline_mockup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iammert/DotLineWatchface/35d73c2b1afc914aef57cd7840746873c6de1931/images/dotline_mockup.png -------------------------------------------------------------------------------- /images/wf.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iammert/DotLineWatchface/35d73c2b1afc914aef57cd7840746873c6de1931/images/wf.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':wear', ':commons' 2 | -------------------------------------------------------------------------------- /wear/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /wear/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | 4 | android { 5 | compileSdkVersion 22 6 | buildToolsVersion "22.0.1" 7 | 8 | defaultConfig { 9 | applicationId "co.mobiwise.dotlinewatchface" 10 | minSdkVersion 21 11 | targetSdkVersion 22 12 | versionCode 2 13 | versionName "1.1" 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | compile fileTree(dir: 'libs', include: ['*.jar']) 25 | compile 'com.google.android.support:wearable:1.2.0' 26 | compile 'com.google.android.gms:play-services-wearable:7.5.0' 27 | compile project(':commons') 28 | } 29 | -------------------------------------------------------------------------------- /wear/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/mertsimsek/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /wear/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 16 | 20 | 23 | 26 | 29 | 30 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /wear/src/main/java/co/mobiwise/dotlinewatchface/DotLineWatchfaceService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package co.mobiwise.dotlinewatchface; 18 | 19 | import android.content.BroadcastReceiver; 20 | import android.content.Context; 21 | import android.content.Intent; 22 | import android.content.IntentFilter; 23 | import android.content.res.Resources; 24 | import android.graphics.Canvas; 25 | import android.graphics.Color; 26 | import android.graphics.Paint; 27 | import android.graphics.Rect; 28 | import android.os.Bundle; 29 | import android.os.Handler; 30 | import android.os.Message; 31 | import android.support.wearable.watchface.CanvasWatchFaceService; 32 | import android.support.wearable.watchface.WatchFaceStyle; 33 | import android.text.format.Time; 34 | import android.util.Log; 35 | import android.view.SurfaceHolder; 36 | 37 | import com.google.android.gms.common.ConnectionResult; 38 | import com.google.android.gms.common.api.GoogleApiClient; 39 | import com.google.android.gms.common.api.ResultCallback; 40 | import com.google.android.gms.wearable.DataApi; 41 | import com.google.android.gms.wearable.DataEvent; 42 | import com.google.android.gms.wearable.DataEventBuffer; 43 | import com.google.android.gms.wearable.DataItem; 44 | import com.google.android.gms.wearable.DataItemBuffer; 45 | import com.google.android.gms.wearable.DataMap; 46 | import com.google.android.gms.wearable.DataMapItem; 47 | import com.google.android.gms.wearable.Wearable; 48 | import com.mobiwise.Commons; 49 | 50 | import java.util.TimeZone; 51 | import java.util.concurrent.TimeUnit; 52 | 53 | /** 54 | * Analog watch face with a ticking second hand. In ambient mode, the second hand isn't shown. On 55 | * devices with low-bit ambient mode, the hands are drawn without anti-aliasing in ambient mode. 56 | */ 57 | public class DotLineWatchfaceService extends CanvasWatchFaceService { 58 | /** 59 | * Update rate in milliseconds for interactive mode. We update once a second to advance the 60 | * second hand. 61 | */ 62 | private static final long INTERACTIVE_UPDATE_RATE_MS = TimeUnit.SECONDS.toMillis(1); 63 | 64 | @Override 65 | public Engine onCreateEngine() { 66 | return new Engine(); 67 | } 68 | 69 | private class Engine extends CanvasWatchFaceService.Engine implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { 70 | static final int MSG_UPDATE_TIME = 0; 71 | 72 | Paint mBackgroundPaint; 73 | Paint mBackgroundAmbientPaint; 74 | Paint mHandPaint; 75 | Paint mPaintDot; 76 | boolean mAmbient; 77 | Time mTime; 78 | 79 | private GoogleApiClient mGoogleApiClient; 80 | 81 | /** 82 | * Handler to update the time once a second in interactive mode. 83 | */ 84 | final Handler mUpdateTimeHandler = new Handler() { 85 | @Override 86 | public void handleMessage(Message message) { 87 | switch (message.what) { 88 | case MSG_UPDATE_TIME: 89 | invalidate(); 90 | if (shouldTimerBeRunning()) { 91 | long timeMs = System.currentTimeMillis(); 92 | long delayMs = INTERACTIVE_UPDATE_RATE_MS 93 | - (timeMs % INTERACTIVE_UPDATE_RATE_MS); 94 | mUpdateTimeHandler.sendEmptyMessageDelayed(MSG_UPDATE_TIME, delayMs); 95 | } 96 | break; 97 | } 98 | } 99 | }; 100 | 101 | final BroadcastReceiver mTimeZoneReceiver = new BroadcastReceiver() { 102 | @Override 103 | public void onReceive(Context context, Intent intent) { 104 | mTime.clear(intent.getStringExtra("time-zone")); 105 | mTime.setToNow(); 106 | } 107 | }; 108 | boolean mRegisteredTimeZoneReceiver = false; 109 | 110 | /** 111 | * Whether the display supports fewer bits for each color in ambient mode. When true, we 112 | * disable anti-aliasing in ambient mode. 113 | */ 114 | boolean mLowBitAmbient; 115 | 116 | @Override 117 | public void onCreate(SurfaceHolder holder) { 118 | super.onCreate(holder); 119 | 120 | setWatchFaceStyle(new WatchFaceStyle.Builder(DotLineWatchfaceService.this) 121 | .setCardPeekMode(WatchFaceStyle.PEEK_MODE_SHORT) 122 | .setBackgroundVisibility(WatchFaceStyle.BACKGROUND_VISIBILITY_INTERRUPTIVE) 123 | .setShowSystemUiTime(false) 124 | .build()); 125 | 126 | Resources resources = DotLineWatchfaceService.this.getResources(); 127 | 128 | mBackgroundPaint = new Paint(); 129 | mBackgroundPaint.setColor(resources.getColor(R.color.analog_background)); 130 | 131 | mBackgroundAmbientPaint = new Paint(); 132 | mBackgroundAmbientPaint.setColor(resources.getColor(R.color.analog_background_ambient)); 133 | 134 | mPaintDot = new Paint(); 135 | mPaintDot.setColor(resources.getColor(R.color.analog_hands)); 136 | mPaintDot.setStyle(Paint.Style.FILL); 137 | mPaintDot.setAntiAlias(true); 138 | mPaintDot.setShadowLayer(2.0f, 1.5f, 1.5f, resources.getColor(R.color.color_shadow)); 139 | 140 | mHandPaint = new Paint(); 141 | mHandPaint.setColor(resources.getColor(R.color.analog_hands)); 142 | mHandPaint.setStrokeWidth(resources.getDimension(R.dimen.analog_hand_stroke)); 143 | mHandPaint.setAntiAlias(true); 144 | mHandPaint.setStrokeCap(Paint.Cap.ROUND); 145 | mHandPaint.setShadowLayer(2.0f, 1.5f, 1.5f, resources.getColor(R.color.color_shadow)); 146 | 147 | mTime = new Time(); 148 | 149 | mGoogleApiClient = new GoogleApiClient.Builder(DotLineWatchfaceService.this) 150 | .addApi(Wearable.API) 151 | .addConnectionCallbacks(this) 152 | .addOnConnectionFailedListener(this) 153 | .build(); 154 | } 155 | 156 | @Override 157 | public void onDestroy() { 158 | mUpdateTimeHandler.removeMessages(MSG_UPDATE_TIME); 159 | releaseGoogleApiClient(); 160 | super.onDestroy(); 161 | } 162 | 163 | @Override 164 | public void onPropertiesChanged(Bundle properties) { 165 | super.onPropertiesChanged(properties); 166 | mLowBitAmbient = properties.getBoolean(PROPERTY_LOW_BIT_AMBIENT, false); 167 | } 168 | 169 | @Override 170 | public void onTimeTick() { 171 | super.onTimeTick(); 172 | invalidate(); 173 | } 174 | 175 | @Override 176 | public void onAmbientModeChanged(boolean inAmbientMode) { 177 | super.onAmbientModeChanged(inAmbientMode); 178 | if (mAmbient != inAmbientMode) { 179 | mAmbient = inAmbientMode; 180 | if (mLowBitAmbient) { 181 | mHandPaint.setAntiAlias(!inAmbientMode); 182 | mPaintDot.setAntiAlias(!inAmbientMode); 183 | } 184 | invalidate(); 185 | } 186 | 187 | // Whether the timer should be running depends on whether we're visible (as well as 188 | // whether we're in ambient mode), so we may need to start or stop the timer. 189 | updateTimer(); 190 | } 191 | 192 | private void updateBackgroundColour(int color){ 193 | mBackgroundPaint.setColor(color); 194 | postInvalidate(); 195 | } 196 | 197 | @Override 198 | public void onDraw(Canvas canvas, Rect bounds) { 199 | mTime.setToNow(); 200 | 201 | int width = bounds.width(); 202 | int height = bounds.height(); 203 | 204 | // Draw the background. 205 | if(!mAmbient) 206 | canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), mBackgroundPaint); 207 | else 208 | canvas.drawRect(0, 0, canvas.getWidth(), canvas.getHeight(), mBackgroundAmbientPaint); 209 | 210 | // Find the center. Ignore the window insets so that, on round watches with a 211 | // "chin", the watch face is centered on the entire screen, not just the usable 212 | // portion. 213 | float centerX = width / 2f; 214 | float centerY = height / 2f; 215 | 216 | int minutes = mTime.minute; 217 | float minRot = minutes / 30f * (float) Math.PI; 218 | float hrRot = ((mTime.hour + (minutes / 60f)) / 6f) * (float) Math.PI; 219 | 220 | float minLength = centerX - 40; 221 | float hrLength = centerX - 40; 222 | 223 | float hrX = (float) Math.sin(hrRot) * hrLength; 224 | float hrY = (float) -Math.cos(hrRot) * hrLength; 225 | canvas.drawCircle(centerX + hrX, centerY + hrY, 12f,mPaintDot); 226 | 227 | float minX = (float) Math.sin(minRot) * minLength; 228 | float minY = (float) -Math.cos(minRot) * minLength; 229 | canvas.drawLine(centerX, centerY, centerX + minX, centerY + minY, mHandPaint); 230 | } 231 | 232 | @Override 233 | public void onVisibilityChanged(boolean visible) { 234 | super.onVisibilityChanged(visible); 235 | 236 | if (visible) { 237 | registerReceiver(); 238 | 239 | // Update time zone in case it changed while we weren't visible. 240 | mTime.clear(TimeZone.getDefault().getID()); 241 | mTime.setToNow(); 242 | mGoogleApiClient.connect(); 243 | } else { 244 | unregisterReceiver(); 245 | releaseGoogleApiClient(); 246 | } 247 | 248 | // Whether the timer should be running depends on whether we're visible (as well as 249 | // whether we're in ambient mode), so we may need to start or stop the timer. 250 | updateTimer(); 251 | } 252 | 253 | private void registerReceiver() { 254 | if (mRegisteredTimeZoneReceiver) { 255 | return; 256 | } 257 | mRegisteredTimeZoneReceiver = true; 258 | IntentFilter filter = new IntentFilter(Intent.ACTION_TIMEZONE_CHANGED); 259 | DotLineWatchfaceService.this.registerReceiver(mTimeZoneReceiver, filter); 260 | } 261 | 262 | private void unregisterReceiver() { 263 | if (!mRegisteredTimeZoneReceiver) { 264 | return; 265 | } 266 | mRegisteredTimeZoneReceiver = false; 267 | DotLineWatchfaceService.this.unregisterReceiver(mTimeZoneReceiver); 268 | } 269 | 270 | /** 271 | * Starts the {@link #mUpdateTimeHandler} timer if it should be running and isn't currently 272 | * or stops it if it shouldn't be running but currently is. 273 | */ 274 | private void updateTimer() { 275 | mUpdateTimeHandler.removeMessages(MSG_UPDATE_TIME); 276 | if (shouldTimerBeRunning()) { 277 | mUpdateTimeHandler.sendEmptyMessage(MSG_UPDATE_TIME); 278 | } 279 | } 280 | 281 | /** 282 | * Returns whether the {@link #mUpdateTimeHandler} timer should be running. The timer should 283 | * only run when we're visible and in interactive mode. 284 | */ 285 | private boolean shouldTimerBeRunning() { 286 | return isVisible() && !isInAmbientMode(); 287 | } 288 | 289 | @Override 290 | public void onConnected(Bundle bundle) { 291 | Log.v("TEST","onConnected"); 292 | Wearable.DataApi.addListener(mGoogleApiClient, onDataChangedListener); 293 | Wearable.DataApi.getDataItems(mGoogleApiClient).setResultCallback(onConnectedResultCallback); 294 | } 295 | 296 | @Override 297 | public void onConnectionSuspended(int i) { 298 | Log.v("TEST","onConnectionSuspended"); 299 | } 300 | 301 | @Override 302 | public void onConnectionFailed(ConnectionResult connectionResult) { 303 | Log.v("TEST","onConnectionFailed"); 304 | } 305 | 306 | private void releaseGoogleApiClient() { 307 | if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) { 308 | Wearable.DataApi.removeListener(mGoogleApiClient, onDataChangedListener); 309 | mGoogleApiClient.disconnect(); 310 | } 311 | } 312 | 313 | private final DataApi.DataListener onDataChangedListener = new DataApi.DataListener() { 314 | @Override 315 | public void onDataChanged(DataEventBuffer dataEvents) { 316 | for (DataEvent event : dataEvents) { 317 | if (event.getType() == DataEvent.TYPE_CHANGED) { 318 | DataItem item = event.getDataItem(); 319 | processConfigurationFor(item); 320 | } 321 | } 322 | 323 | dataEvents.release(); 324 | invalidate(); 325 | } 326 | }; 327 | 328 | private final ResultCallback onConnectedResultCallback = new ResultCallback() { 329 | @Override 330 | public void onResult(DataItemBuffer dataItems) { 331 | for (DataItem item : dataItems) { 332 | processConfigurationFor(item); 333 | } 334 | 335 | dataItems.release(); 336 | invalidate(); 337 | } 338 | }; 339 | 340 | private void processConfigurationFor(DataItem item) { 341 | if (Commons.PATH.equals(item.getUri().getPath())) { 342 | DataMap dataMap = DataMapItem.fromDataItem(item).getDataMap(); 343 | if (dataMap.containsKey(Commons.KEY_BACKGROUND_COLOUR)) { 344 | int backgroundColour = dataMap.getInt(Commons.KEY_BACKGROUND_COLOUR); 345 | updateBackgroundColour(backgroundColour); 346 | } 347 | } 348 | } 349 | } 350 | } 351 | -------------------------------------------------------------------------------- /wear/src/main/res/drawable-nodpi/preview_analog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iammert/DotLineWatchface/35d73c2b1afc914aef57cd7840746873c6de1931/wear/src/main/res/drawable-nodpi/preview_analog.png -------------------------------------------------------------------------------- /wear/src/main/res/drawable-nodpi/wf_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iammert/DotLineWatchface/35d73c2b1afc914aef57cd7840746873c6de1931/wear/src/main/res/drawable-nodpi/wf_logo.png -------------------------------------------------------------------------------- /wear/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iammert/DotLineWatchface/35d73c2b1afc914aef57cd7840746873c6de1931/wear/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /wear/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iammert/DotLineWatchface/35d73c2b1afc914aef57cd7840746873c6de1931/wear/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /wear/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iammert/DotLineWatchface/35d73c2b1afc914aef57cd7840746873c6de1931/wear/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /wear/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iammert/DotLineWatchface/35d73c2b1afc914aef57cd7840746873c6de1931/wear/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /wear/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #009c8a 4 | #ff000000 5 | #D1000000 6 | #cccccc 7 | 8 | -------------------------------------------------------------------------------- /wear/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12dp 4 | 5 | -------------------------------------------------------------------------------- /wear/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | DotLine Watchface 3 | DotLine Watchface 4 | 5 | -------------------------------------------------------------------------------- /wear/src/main/res/xml/watch_face.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /wear/wear.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | --------------------------------------------------------------------------------