Steampunk watch face (not yet functional)
This commit is contained in:
parent
2d3333deda
commit
c3aef7b6f2
4 changed files with 359 additions and 331 deletions
|
@ -21,6 +21,7 @@ import android.view.Display;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowInsets;
|
import android.view.WindowInsets;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -50,6 +51,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
||||||
public final static IntentFilter INTENT_FILTER;
|
public final static IntentFilter INTENT_FILTER;
|
||||||
public static final long[] vibratePattern = {0,400,300,400,300,400};
|
public static final long[] vibratePattern = {0,400,300,400,300,400};
|
||||||
public TextView mTime, mSgv, mDirection, mTimestamp, mUploaderBattery, mRigBattery, mDelta, mAvgDelta, mStatus, mBasalRate, mIOB1, mIOB2, mCOB1, mCOB2, mBgi, mLoop, mDay, mMonth, isAAPSv2, mHighLight, mLowLight;
|
public TextView mTime, mSgv, mDirection, mTimestamp, mUploaderBattery, mRigBattery, mDelta, mAvgDelta, mStatus, mBasalRate, mIOB1, mIOB2, mCOB1, mCOB2, mBgi, mLoop, mDay, mMonth, isAAPSv2, mHighLight, mLowLight;
|
||||||
|
public ImageView mGlucoseDial, mDeltaGauge;
|
||||||
public long datetime;
|
public long datetime;
|
||||||
public RelativeLayout mRelativeLayout;
|
public RelativeLayout mRelativeLayout;
|
||||||
public LinearLayout mLinearLayout, mLinearLayout2, mDate;
|
public LinearLayout mLinearLayout, mLinearLayout2, mDate;
|
||||||
|
@ -160,10 +162,13 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
||||||
mRelativeLayout = (RelativeLayout) stub.findViewById(R.id.main_layout);
|
mRelativeLayout = (RelativeLayout) stub.findViewById(R.id.main_layout);
|
||||||
mLinearLayout = (LinearLayout) stub.findViewById(R.id.secondary_layout);
|
mLinearLayout = (LinearLayout) stub.findViewById(R.id.secondary_layout);
|
||||||
mLinearLayout2 = (LinearLayout) stub.findViewById(R.id.tertiary_layout);
|
mLinearLayout2 = (LinearLayout) stub.findViewById(R.id.tertiary_layout);
|
||||||
|
mGlucoseDial = (ImageView) stub.findViewById(R.id.glucose_dial);
|
||||||
|
mDeltaGauge = (ImageView) stub.findViewById(R.id.delta_gauge);
|
||||||
chart = (LineChartView) stub.findViewById(R.id.chart);
|
chart = (LineChartView) stub.findViewById(R.id.chart);
|
||||||
layoutSet = true;
|
layoutSet = true;
|
||||||
|
|
||||||
setDataFields();
|
setDataFields();
|
||||||
|
setColor();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -225,6 +230,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
||||||
wakeLock.acquire(50);
|
wakeLock.acquire(50);
|
||||||
|
|
||||||
setDataFields();
|
setDataFields();
|
||||||
|
setColor();
|
||||||
missedReadingAlert();
|
missedReadingAlert();
|
||||||
|
|
||||||
mRelativeLayout.measure(specW, specH);
|
mRelativeLayout.measure(specW, specH);
|
||||||
|
@ -273,6 +279,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
||||||
}
|
}
|
||||||
|
|
||||||
setDataFields();
|
setDataFields();
|
||||||
|
setColor();
|
||||||
|
|
||||||
bundle = intent.getBundleExtra("basals");
|
bundle = intent.getBundleExtra("basals");
|
||||||
if (layoutSet && bundle != null) {
|
if (layoutSet && bundle != null) {
|
||||||
|
@ -285,7 +292,6 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
||||||
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
|
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
|
||||||
mRelativeLayout.getMeasuredHeight());
|
mRelativeLayout.getMeasuredHeight());
|
||||||
invalidate();
|
invalidate();
|
||||||
setColor();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,20 +2,18 @@ package info.nightscout.androidaps.watchfaces;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.wearable.view.WatchViewStub;
|
|
||||||
import android.support.wearable.watchface.WatchFaceStyle;
|
import android.support.wearable.watchface.WatchFaceStyle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
|
||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
import android.view.animation.LinearInterpolator;
|
import android.view.animation.LinearInterpolator;
|
||||||
import android.view.animation.RotateAnimation;
|
import android.view.animation.RotateAnimation;
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.interaction.menus.MainMenuActivity;
|
import info.nightscout.androidaps.interaction.menus.MainMenuActivity;
|
||||||
|
|
||||||
|
import static android.view.View.GONE;
|
||||||
|
import static android.view.View.VISIBLE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by andrew-warrington on 01/12/2017.
|
* Created by andrew-warrington on 01/12/2017.
|
||||||
*/
|
*/
|
||||||
|
@ -23,7 +21,6 @@ import info.nightscout.androidaps.interaction.menus.MainMenuActivity;
|
||||||
public class Steampunk extends BaseWatchFace {
|
public class Steampunk extends BaseWatchFace {
|
||||||
|
|
||||||
private long sgvTapTime = 0;
|
private long sgvTapTime = 0;
|
||||||
public ImageView mGlucoseDial;
|
|
||||||
private float lastEndDegrees = 0f;
|
private float lastEndDegrees = 0f;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,7 +29,6 @@ public class Steampunk extends BaseWatchFace {
|
||||||
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
|
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
|
||||||
layoutView = inflater.inflate(R.layout.activity_steampunk, null);
|
layoutView = inflater.inflate(R.layout.activity_steampunk, null);
|
||||||
performViewSetup();
|
performViewSetup();
|
||||||
mGlucoseDial = (ImageView) layoutView.findViewById(R.id.glucose_dial);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -64,10 +60,8 @@ public class Steampunk extends BaseWatchFace {
|
||||||
protected void setColorDark() {
|
protected void setColorDark() {
|
||||||
|
|
||||||
//rotate glucose dial.
|
//rotate glucose dial.
|
||||||
float rotationAngle = 0;
|
float rotationAngle = 0f;
|
||||||
if (sSgv != "---") {
|
if (!sSgv.equals("---")) rotationAngle = Float.valueOf(sSgv);
|
||||||
rotationAngle = Float.valueOf(sSgv);
|
|
||||||
}
|
|
||||||
if (rotationAngle > 330) rotationAngle = 330;
|
if (rotationAngle > 330) rotationAngle = 330;
|
||||||
if (rotationAngle != 0 && rotationAngle < 30) rotationAngle = 30;
|
if (rotationAngle != 0 && rotationAngle < 30) rotationAngle = 30;
|
||||||
|
|
||||||
|
@ -81,6 +75,24 @@ public class Steampunk extends BaseWatchFace {
|
||||||
mGlucoseDial.startAnimation(rotate);
|
mGlucoseDial.startAnimation(rotate);
|
||||||
lastEndDegrees = rotationAngle;
|
lastEndDegrees = rotationAngle;
|
||||||
|
|
||||||
|
//rotate delta gauge.
|
||||||
|
rotationAngle = 0f;
|
||||||
|
//for each 10 in avgDelta we need to move 15 degrees, hence multiply avgDelta by 1.5.
|
||||||
|
if (!sAvgDelta.equals("--")) rotationAngle = (Float.valueOf(sAvgDelta.substring(1)) * 1.5f);
|
||||||
|
if (rotationAngle > 35 || rotationAngle < -35) { //if the needle will go off the chart in either direction...
|
||||||
|
mDeltaGauge.setVisibility(GONE);
|
||||||
|
} else {
|
||||||
|
mDeltaGauge.setVisibility(VISIBLE);
|
||||||
|
rotate = new RotateAnimation(
|
||||||
|
0f, rotationAngle * -1,
|
||||||
|
Animation.RELATIVE_TO_SELF, 0.5f,
|
||||||
|
Animation.RELATIVE_TO_SELF, 0.5f);
|
||||||
|
rotate.setFillAfter(true);
|
||||||
|
rotate.setInterpolator(new LinearInterpolator());
|
||||||
|
rotate.setDuration(2000);
|
||||||
|
mDeltaGauge.startAnimation(rotate);
|
||||||
|
}
|
||||||
|
|
||||||
setTextSizes();
|
setTextSizes();
|
||||||
|
|
||||||
if (mLoop != null) {
|
if (mLoop != null) {
|
||||||
|
@ -103,7 +115,7 @@ public class Steampunk extends BaseWatchFace {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setColorLowRes() {
|
protected void setColorLowRes() {
|
||||||
return;
|
setColorDark();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setColorBright() {
|
protected void setColorBright() {
|
||||||
|
|
|
@ -29,11 +29,20 @@
|
||||||
android:background="@drawable/steampunk_gauge"
|
android:background="@drawable/steampunk_gauge"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/delta_gauge"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:src="@drawable/steampunk_pointer"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/tertiary_layout"
|
android:id="@+id/tertiary_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/steampunk_pointer"
|
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:weightSum="1">
|
android:weightSum="1">
|
||||||
|
|
||||||
|
@ -211,8 +220,6 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/cover_plate_layout"
|
android:id="@+id/cover_plate_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -221,20 +228,18 @@
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<ImageView
|
||||||
android:id="@+id/hour_hand"
|
android:id="@+id/hour_hand"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/steampunk_hour_hand"
|
android:background="@drawable/steampunk_hour_hand"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"/>
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
<ImageView
|
||||||
android:id="@+id/minute_hand"
|
android:id="@+id/minute_hand"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/steampunk_minute_hand"
|
android:background="@drawable/steampunk_minute_hand"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"/>
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
|
@ -29,11 +29,20 @@
|
||||||
android:background="@drawable/steampunk_gauge"
|
android:background="@drawable/steampunk_gauge"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/delta_gauge"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:src="@drawable/steampunk_pointer"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/tertiary_layout"
|
android:id="@+id/tertiary_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/steampunk_pointer"
|
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:weightSum="1">
|
android:weightSum="1">
|
||||||
|
|
||||||
|
@ -211,8 +220,6 @@
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/cover_plate_layout"
|
android:id="@+id/cover_plate_layout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -221,20 +228,18 @@
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<ImageView
|
||||||
android:id="@+id/hour_hand"
|
android:id="@+id/hour_hand"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/steampunk_hour_hand"
|
android:background="@drawable/steampunk_hour_hand"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"/>
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
<ImageView
|
||||||
android:id="@+id/minute_hand"
|
android:id="@+id/minute_hand"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@drawable/steampunk_minute_hand"
|
android:background="@drawable/steampunk_minute_hand"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"/>
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
Loading…
Reference in a new issue