Steampunk watchface (moto360 support - ignores the chin)
This commit is contained in:
parent
7475b1ba3a
commit
5609fbf738
4 changed files with 37 additions and 22 deletions
|
@ -45,8 +45,9 @@ import lecho.lib.hellocharts.view.LineChartView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by emmablack on 12/29/14.
|
* Created by emmablack on 12/29/14.
|
||||||
* Updated by andrew-warrington on 11/15/17.
|
* Updated by andrew-warrington on 02-Jan-2018.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract class BaseWatchFace extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener {
|
public abstract class BaseWatchFace extends WatchFace implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||||
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};
|
||||||
|
@ -87,6 +88,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
||||||
|
|
||||||
public boolean detailedIOB = false;
|
public boolean detailedIOB = false;
|
||||||
public boolean showBGI = false;
|
public boolean showBGI = false;
|
||||||
|
public boolean forceSquareCanvas = false; //set to true by the Steampunk watch face.
|
||||||
public long openApsStatus;
|
public long openApsStatus;
|
||||||
public String externalStatusString = "no status";
|
public String externalStatusString = "no status";
|
||||||
public String sSgv = "---";
|
public String sSgv = "---";
|
||||||
|
@ -108,17 +110,17 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE))
|
Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
|
||||||
.getDefaultDisplay();
|
|
||||||
display.getSize(displaySize);
|
display.getSize(displaySize);
|
||||||
wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Clock");
|
wakeLock = ((PowerManager) getSystemService(Context.POWER_SERVICE)).newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Clock");
|
||||||
|
|
||||||
specW = View.MeasureSpec.makeMeasureSpec(displaySize.x,
|
specW = View.MeasureSpec.makeMeasureSpec(displaySize.x, View.MeasureSpec.EXACTLY);
|
||||||
View.MeasureSpec.EXACTLY);
|
if (forceSquareCanvas) {
|
||||||
specH = View.MeasureSpec.makeMeasureSpec(displaySize.y,
|
specH = specW;
|
||||||
View.MeasureSpec.EXACTLY);
|
} else {
|
||||||
sharedPrefs = PreferenceManager
|
specH = View.MeasureSpec.makeMeasureSpec(displaySize.y, View.MeasureSpec.EXACTLY);
|
||||||
.getDefaultSharedPreferences(this);
|
}
|
||||||
|
sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
sharedPrefs.registerOnSharedPreferenceChangeListener(this);
|
sharedPrefs.registerOnSharedPreferenceChangeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,7 +226,14 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
||||||
protected void onDraw(Canvas canvas) {
|
protected void onDraw(Canvas canvas) {
|
||||||
if (layoutSet) {
|
if (layoutSet) {
|
||||||
setupCharts();
|
setupCharts();
|
||||||
this.mRelativeLayout.draw(canvas);
|
|
||||||
|
mRelativeLayout.measure(specW, specH);
|
||||||
|
if (forceSquareCanvas) {
|
||||||
|
mRelativeLayout.layout(0, 0, displaySize.x, displaySize.x); //force a square for Steampunk watch face.
|
||||||
|
} else {
|
||||||
|
mRelativeLayout.layout(0, 0, displaySize.x, displaySize.y);
|
||||||
|
}
|
||||||
|
mRelativeLayout.draw(canvas);
|
||||||
Log.d("onDraw", "draw");
|
Log.d("onDraw", "draw");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -239,8 +248,12 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
||||||
missedReadingAlert();
|
missedReadingAlert();
|
||||||
|
|
||||||
mRelativeLayout.measure(specW, specH);
|
mRelativeLayout.measure(specW, specH);
|
||||||
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
|
if (forceSquareCanvas) {
|
||||||
mRelativeLayout.getMeasuredHeight());
|
mRelativeLayout.layout(0, 0, displaySize.x, displaySize.x); //force a square for Steampunk watch face.
|
||||||
|
} else {
|
||||||
|
mRelativeLayout.layout(0, 0, displaySize.x, displaySize.y);
|
||||||
|
}
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,8 +308,11 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferen
|
||||||
}
|
}
|
||||||
|
|
||||||
mRelativeLayout.measure(specW, specH);
|
mRelativeLayout.measure(specW, specH);
|
||||||
mRelativeLayout.layout(0, 0, mRelativeLayout.getMeasuredWidth(),
|
if (forceSquareCanvas) {
|
||||||
mRelativeLayout.getMeasuredHeight());
|
mRelativeLayout.layout(0, 0, displaySize.x, displaySize.x); //force a square for Steampunk watch face.
|
||||||
|
} else {
|
||||||
|
mRelativeLayout.layout(0, 0, displaySize.x, displaySize.y);
|
||||||
|
}
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package info.nightscout.androidaps.watchfaces;
|
package info.nightscout.androidaps.watchfaces;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Canvas;
|
|
||||||
import android.graphics.Rect;
|
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.wearable.watchface.WatchFaceStyle;
|
import android.support.wearable.watchface.WatchFaceStyle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -25,6 +23,7 @@ public class Steampunk extends BaseWatchFace {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
|
forceSquareCanvas = true;
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
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);
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
android:id="@+id/glucose_dial"
|
android:id="@+id/glucose_dial"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:src="@drawable/steampunk_dial_mgdl"
|
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:gravity="center"/>
|
android:gravity="center"
|
||||||
|
android:src="@drawable/steampunk_dial_mgdl" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@
|
||||||
android:text="-'"
|
android:text="-'"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textColor="@color/black_86p"
|
android:textColor="@color/black_86p"
|
||||||
android:textSize="12sp"
|
android:textSize="11sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
@ -303,7 +303,7 @@
|
||||||
android:text="-'"
|
android:text="-'"
|
||||||
android:textAlignment="center"
|
android:textAlignment="center"
|
||||||
android:textColor="@color/black_86p"
|
android:textColor="@color/black_86p"
|
||||||
android:textSize="12sp"
|
android:textSize="11sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
android:id="@+id/glucose_dial"
|
android:id="@+id/glucose_dial"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:src="@drawable/steampunk_dial_mgdl"
|
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:gravity="center"/>
|
android:gravity="center"
|
||||||
|
android:src="@drawable/steampunk_dial_mgdl" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue