Merge pull request #1125 from Andries-Smit/wear-digital-12-clock
wear: add watchface digtal support 12h clock
This commit is contained in:
commit
c075db6f4b
3 changed files with 75 additions and 25 deletions
|
@ -69,7 +69,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Point displaySize = new Point();
|
public final Point displaySize = new Point();
|
||||||
public TextView mTime, mHour, mMinute, mSgv, mDirection, mTimestamp, mUploaderBattery, mRigBattery, mDelta, mAvgDelta, mStatus, mBasalRate, mIOB1, mIOB2, mCOB1, mCOB2, mBgi, mLoop, mDay, mDayName, mMonth, isAAPSv2, mHighLight, mLowLight;
|
public TextView mTime, mHour, mMinute, mTimePeriod, mSgv, mDirection, mTimestamp, mUploaderBattery, mRigBattery, mDelta, mAvgDelta, mStatus, mBasalRate, mIOB1, mIOB2, mCOB1, mCOB2, mBgi, mLoop, mDay, mDayName, mMonth, isAAPSv2, mHighLight, mLowLight;
|
||||||
public TextView mSimpleSvg, mSimpleDirection, mSimpleTime;
|
public TextView mSimpleSvg, mSimpleDirection, mSimpleTime;
|
||||||
public ImageView mGlucoseDial, mDeltaGauge, mHourHand, mMinuteHand;
|
public ImageView mGlucoseDial, mDeltaGauge, mHourHand, mMinuteHand;
|
||||||
public View mSimpleUi;
|
public View mSimpleUi;
|
||||||
|
@ -166,6 +166,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
|
||||||
mTime = stub.findViewById(R.id.watch_time);
|
mTime = stub.findViewById(R.id.watch_time);
|
||||||
mHour = stub.findViewById(R.id.hour);
|
mHour = stub.findViewById(R.id.hour);
|
||||||
mMinute = stub.findViewById(R.id.minute);
|
mMinute = stub.findViewById(R.id.minute);
|
||||||
|
mTimePeriod = stub.findViewById(R.id.timePeriod);
|
||||||
mDay = stub.findViewById(R.id.day);
|
mDay = stub.findViewById(R.id.day);
|
||||||
mDayName = stub.findViewById(R.id.dayname);
|
mDayName = stub.findViewById(R.id.dayname);
|
||||||
mMonth = stub.findViewById(R.id.month);
|
mMonth = stub.findViewById(R.id.month);
|
||||||
|
@ -517,6 +518,11 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void on24HourFormatChanged(boolean is24HourFormat) {
|
||||||
|
setDateAndTime();
|
||||||
|
}
|
||||||
|
|
||||||
public void setDateAndTime() {
|
public void setDateAndTime() {
|
||||||
|
|
||||||
final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BaseWatchFace.this);
|
final java.text.DateFormat timeFormat = DateFormat.getTimeFormat(BaseWatchFace.this);
|
||||||
|
@ -525,8 +531,13 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
|
||||||
}
|
}
|
||||||
|
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
SimpleDateFormat sdfHour = new SimpleDateFormat("HH");
|
SimpleDateFormat sdfHour;
|
||||||
SimpleDateFormat sdfMinute = new SimpleDateFormat("mm");
|
SimpleDateFormat sdfMinute = new SimpleDateFormat("mm");
|
||||||
|
if (DateFormat.is24HourFormat(this)) {
|
||||||
|
sdfHour = new SimpleDateFormat("HH");
|
||||||
|
} else {
|
||||||
|
sdfHour = new SimpleDateFormat("hh");
|
||||||
|
}
|
||||||
sHour = sdfHour.format(now);
|
sHour = sdfHour.format(now);
|
||||||
sMinute = sdfMinute.format(now);
|
sMinute = sdfMinute.format(now);
|
||||||
|
|
||||||
|
@ -535,6 +546,16 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc
|
||||||
mMinute.setText(sMinute);
|
mMinute.setText(sMinute);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(mTimePeriod != null) {
|
||||||
|
if (!DateFormat.is24HourFormat(this)) {
|
||||||
|
mTimePeriod.setVisibility(View.VISIBLE);
|
||||||
|
SimpleDateFormat sdfPeriod = new SimpleDateFormat("a");
|
||||||
|
mTimePeriod.setText(sdfPeriod.format(now).toUpperCase());
|
||||||
|
} else {
|
||||||
|
mTimePeriod.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (mDate != null && mDay != null && mMonth != null) {
|
if (mDate != null && mDay != null && mMonth != null) {
|
||||||
if (sharedPrefs.getBoolean("show_date", false)) {
|
if (sharedPrefs.getBoolean("show_date", false)) {
|
||||||
if (mDayName != null) {
|
if (mDayName != null) {
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
tools:context=".watchfaces.DigitalStyle"
|
tools:context=".watchfaces.DigitalStyle"
|
||||||
tools:deviceIds="wear_square">
|
tools:deviceIds="wear_square">
|
||||||
|
|
||||||
|
|
||||||
<!-- background-image with shapes elements-->
|
<!-- background-image with shapes elements-->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/shapes_elements"
|
android:id="@+id/shapes_elements"
|
||||||
|
@ -265,7 +264,6 @@
|
||||||
android:layout_weight="13.95" />
|
android:layout_weight="13.95" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
<!-- right side 5/8 width -->
|
<!-- right side 5/8 width -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -385,14 +383,13 @@
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="4"
|
android:layout_weight="4"
|
||||||
android:gravity="left|center_vertical"
|
android:gravity="left|center_vertical"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal">
|
||||||
android:weightSum="1">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="-5dp"
|
android:layout_marginTop="-5dp">
|
||||||
android:layout_weight="1">
|
|
||||||
<!-- hour -->
|
<!-- hour -->
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/hour"
|
android:id="@+id/hour"
|
||||||
|
@ -405,6 +402,13 @@
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:textSize="40sp"
|
android:textSize="40sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<!-- minute -->
|
<!-- minute -->
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -413,15 +417,27 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="left"
|
android:layout_gravity="left"
|
||||||
android:layout_marginLeft="6sp"
|
android:layout_marginLeft="6sp"
|
||||||
|
android:layout_marginBottom="-8sp"
|
||||||
android:fontFamily="@font/roboto_condensed_bold"
|
android:fontFamily="@font/roboto_condensed_bold"
|
||||||
android:paddingTop="5sp"
|
|
||||||
android:text="MI"
|
android:text="MI"
|
||||||
android:textColor="@color/light_grey"
|
android:textColor="@color/light_grey"
|
||||||
android:textSize="26sp"
|
android:textSize="26sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<!-- 12h period AM / PM-->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/timePeriod"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:layout_marginLeft="8sp"
|
||||||
|
android:fontFamily="@font/roboto_condensed_bold"
|
||||||
|
android:text="AM"
|
||||||
|
android:textColor="@color/light_grey"
|
||||||
|
android:textSize="10sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- right side 1/2 height - bottom halft -->
|
<!-- right side 1/2 height - bottom halft -->
|
||||||
|
@ -549,7 +565,6 @@
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
<!-- FLAGs -->
|
<!-- FLAGs -->
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/AAPSv2"
|
android:id="@+id/AAPSv2"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -558,5 +573,4 @@
|
||||||
android:text=""
|
android:text=""
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
</RelativeLayout>
|
|
||||||
|
|
|
@ -9,7 +9,6 @@
|
||||||
tools:context=".watchfaces.DigitalStyle"
|
tools:context=".watchfaces.DigitalStyle"
|
||||||
tools:deviceIds="wear_round">
|
tools:deviceIds="wear_round">
|
||||||
|
|
||||||
|
|
||||||
<!-- background-image with shapes elements-->
|
<!-- background-image with shapes elements-->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/shapes_elements"
|
android:id="@+id/shapes_elements"
|
||||||
|
@ -266,7 +265,6 @@
|
||||||
android:layout_weight="13.95" />
|
android:layout_weight="13.95" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
<!-- right side 5/8 width -->
|
<!-- right side 5/8 width -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
@ -386,14 +384,12 @@
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="4"
|
android:layout_weight="4"
|
||||||
android:gravity="left|center_vertical"
|
android:gravity="left|center_vertical"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal">
|
||||||
android:weightSum="1">
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="0dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="-5dp"
|
android:layout_marginTop="-5dp">
|
||||||
android:layout_weight="1">
|
|
||||||
<!-- hour -->
|
<!-- hour -->
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/hour"
|
android:id="@+id/hour"
|
||||||
|
@ -406,6 +402,13 @@
|
||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:textSize="40sp"
|
android:textSize="40sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
<!-- minute -->
|
<!-- minute -->
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -414,15 +417,27 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="left"
|
android:layout_gravity="left"
|
||||||
android:layout_marginLeft="6sp"
|
android:layout_marginLeft="6sp"
|
||||||
|
android:layout_marginBottom="-8sp"
|
||||||
android:fontFamily="@font/roboto_condensed_bold"
|
android:fontFamily="@font/roboto_condensed_bold"
|
||||||
android:paddingTop="5sp"
|
|
||||||
android:text="MI"
|
android:text="MI"
|
||||||
android:textColor="@color/light_grey"
|
android:textColor="@color/light_grey"
|
||||||
android:textSize="26sp"
|
android:textSize="26sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<!-- 12h period AM / PM -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/timePeriod"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="8sp"
|
||||||
|
android:fontFamily="@font/roboto_condensed_bold"
|
||||||
|
android:gravity="top"
|
||||||
|
android:text="AM"
|
||||||
|
android:textColor="@color/light_grey"
|
||||||
|
android:textSize="10sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<!-- right side 1/2 height - bottom halft -->
|
<!-- right side 1/2 height - bottom halft -->
|
||||||
|
@ -549,8 +564,8 @@
|
||||||
android:id="@+id/simple_ui"
|
android:id="@+id/simple_ui"
|
||||||
layout="@layout/simple_ui"
|
layout="@layout/simple_ui"
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
<!-- FLAGs -->
|
|
||||||
|
|
||||||
|
<!-- FLAGs -->
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/AAPSv2"
|
android:id="@+id/AAPSv2"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
|
@ -559,4 +574,4 @@
|
||||||
android:text=""
|
android:text=""
|
||||||
android:visibility="gone" />
|
android:visibility="gone" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
Loading…
Reference in a new issue