diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java index 19118e068c..efb3caa631 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/BaseWatchFace.java @@ -72,7 +72,8 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc 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 ImageView mGlucoseDial, mDeltaGauge, mHourHand, mMinuteHand; public RelativeLayout mRelativeLayout; - public LinearLayout mLinearLayout, mLinearLayout2, mDate, mChartTap, mMainMenuTap; + public LinearLayout mLinearLayout, mLinearLayout2, mLinearLayout3, mDate, mChartTap, + mMainMenuTap; public int ageLevel = 1; public int loopLevel = 1; public int highColor = Color.YELLOW; @@ -167,6 +168,7 @@ public abstract class BaseWatchFace extends WatchFace implements SharedPreferenc mHighLight = stub.findViewById(R.id.highLight); mLowLight = stub.findViewById(R.id.lowLight); mRelativeLayout = stub.findViewById(R.id.main_layout); + mLinearLayout3 = stub.findViewById(R.id.primary_layout); mLinearLayout = stub.findViewById(R.id.secondary_layout); mLinearLayout2 = stub.findViewById(R.id.tertiary_layout); mGlucoseDial = stub.findViewById(R.id.glucose_dial); diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Home2.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Home2.java index f83c7f2b5b..458fa048cd 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Home2.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Home2.java @@ -1,11 +1,18 @@ package info.nightscout.androidaps.watchfaces; import android.content.Intent; +import android.content.IntentFilter; import android.graphics.Color; + import androidx.annotation.ColorInt; import androidx.core.content.ContextCompat; + +import android.os.BatteryManager; import android.support.wearable.watchface.WatchFaceStyle; +import android.util.TypedValue; import android.view.LayoutInflater; +import android.view.View; +import android.widget.LinearLayout; import com.ustwo.clockwise.common.WatchMode; @@ -28,23 +35,23 @@ public class Home2 extends BaseWatchFace { @Override protected void onTapCommand(int tapType, int x, int y, long eventTime) { - int extra = mSgv!=null?(mSgv.getRight() - mSgv.getLeft())/2:0; + int extra = mSgv != null ? (mSgv.getRight() - mSgv.getLeft()) / 2 : 0; - if (tapType == TAP_TYPE_TAP&& - x >=chart.getLeft() && - x <= chart.getRight()&& + if (tapType == TAP_TYPE_TAP && + x >= chart.getLeft() && + x <= chart.getRight() && y >= chart.getTop() && - y <= chart.getBottom()){ - if (eventTime - chartTapTime < 800){ + y <= chart.getBottom()) { + if (eventTime - chartTapTime < 800) { changeChartTimeframe(); } chartTapTime = eventTime; - } else if (tapType == TAP_TYPE_TAP&& - x + extra >=mSgv.getLeft() && - x - extra <= mSgv.getRight()&& + } else if (tapType == TAP_TYPE_TAP && + x + extra >= mSgv.getLeft() && + x - extra <= mSgv.getRight() && y >= mSgv.getTop() && - y <= mSgv.getBottom()){ - if (eventTime - sgvTapTime < 800){ + y <= mSgv.getBottom()) { + if (eventTime - sgvTapTime < 800) { Intent intent = new Intent(this, MainMenuActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); @@ -55,12 +62,12 @@ public class Home2 extends BaseWatchFace { private void changeChartTimeframe() { int timeframe = Integer.parseInt(sharedPrefs.getString("chart_timeframe", "3")); - timeframe = (timeframe%5) + 1; + timeframe = (timeframe % 5) + 1; sharedPrefs.edit().putString("chart_timeframe", "" + timeframe).apply(); } @Override - protected WatchFaceStyle getWatchFaceStyle(){ + protected WatchFaceStyle getWatchFaceStyle() { return new WatchFaceStyle.Builder(this).setAcceptsTapEvents(true).build(); } @@ -176,7 +183,7 @@ public class Home2 extends BaseWatchFace { if (getCurrentWatchMode() == WatchMode.INTERACTIVE) { - @ColorInt final int dividerTxtColor = dividerMatchesBg ? Color.BLACK : + @ColorInt final int dividerTxtColor = dividerMatchesBg ? Color.BLACK : ContextCompat.getColor(getApplicationContext(), R.color.dark_midColor); @ColorInt final int dividerBgColor = ContextCompat.getColor(getApplicationContext(), dividerMatchesBg ? R.color.light_background : R.color.light_stripe_background); @@ -257,4 +264,59 @@ public class Home2 extends BaseWatchFace { } } } + + + @Override + public void setDataFields() { + super.setDataFields(); + if (sharedPrefs.getBoolean("simplify_ui_charging", false) && isCharging()) { + LinearLayout.LayoutParams param = new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, + 0, + 0.5f + ); + mLinearLayout3.setLayoutParams(param); + mLinearLayout3.setWeightSum(0.7f); + mLinearLayout.setVisibility(View.GONE); + mLoop.setVisibility(View.INVISIBLE); + chart.setVisibility(View.GONE); + mIOB1.setVisibility(View.GONE); + mIOB2.setVisibility(View.GONE); + mCOB1.setVisibility(View.GONE); + mCOB2.setVisibility(View.GONE); + mTimestamp.setVisibility(View.GONE); + mTime.setTextSize(35); + mDirection.setTextSize(35); + mSgv.setTextSize(50); + } else { + TypedValue outValue = new TypedValue(); + getResources().getValue(R.dimen.home2_primary_layout_height, outValue, true); + float layoutHeight = outValue.getFloat(); + LinearLayout.LayoutParams param = new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, + 0, + layoutHeight + ); + mLinearLayout3.setLayoutParams(param); + mLinearLayout.setVisibility(View.VISIBLE); + mLoop.setVisibility(View.VISIBLE); + chart.setVisibility(View.VISIBLE); + mIOB1.setVisibility(View.VISIBLE); + mIOB2.setVisibility(View.VISIBLE); + mCOB1.setVisibility(View.VISIBLE); + mCOB2.setVisibility(View.VISIBLE); + mTimestamp.setVisibility(View.VISIBLE); + mDirection.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.home2_direction_text_size)); + mSgv.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.home2_sgv_text_size)); + mTime.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.home2_time_text_size)); + } + } + + private boolean isCharging() { + IntentFilter iFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); + Intent batteryStatus = this.registerReceiver(null, iFilter); + int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1); + return status == BatteryManager.BATTERY_STATUS_CHARGING || + status == BatteryManager.BATTERY_STATUS_FULL; + } } diff --git a/wear/src/main/res/layout/rect_activity_home_2.xml b/wear/src/main/res/layout/rect_activity_home_2.xml index 3708761c1f..d3e7c1fdb9 100644 --- a/wear/src/main/res/layout/rect_activity_home_2.xml +++ b/wear/src/main/res/layout/rect_activity_home_2.xml @@ -1,9 +1,12 @@ + tools:context=".watchfaces.Home2" + tools:deviceIds="wear_square"> @@ -42,11 +46,11 @@ android:layout_marginBottom="-2dp" android:gravity="bottom|right" android:paddingLeft="5dp" - android:paddingRight="5dp" android:paddingTop="-2dp" + android:paddingRight="5dp" android:text="---" android:textColor="#FFFFFF" - android:textSize="38sp" /> + android:textSize="@dimen/home2_sgv_text_size" /> + android:textSize="@dimen/home2_time_text_size" /> + tools:context=".watchfaces.Home2" + tools:deviceIds="wear_round"> - + android:layout_weight="0.05" + android:orientation="vertical" /> @@ -49,11 +52,11 @@ android:layout_marginBottom="-2dp" android:gravity="bottom|right" android:paddingLeft="5dp" - android:paddingRight="5dp" android:paddingTop="-2dp" + android:paddingRight="5dp" android:text="---" android:textColor="#FFFFFF" - android:textSize="38sp" /> + android:textSize="@dimen/home2_sgv_text_size" /> + android:textSize="@dimen/home2_time_text_size" /> - + android:layout_weight="0.05" + android:orientation="vertical" /> - \ No newline at end of file + diff --git a/wear/src/main/res/values/dimens.xml b/wear/src/main/res/values/dimens.xml new file mode 100644 index 0000000000..e612a04d25 --- /dev/null +++ b/wear/src/main/res/values/dimens.xml @@ -0,0 +1,8 @@ + + + + 0.27 + 38sp + 22sp + 30sp + diff --git a/wear/src/main/res/values/strings.xml b/wear/src/main/res/values/strings.xml index 9c4bca91da..cf78cc7339 100644 --- a/wear/src/main/res/values/strings.xml +++ b/wear/src/main/res/values/strings.xml @@ -136,6 +136,8 @@ white black multicolor + Simplify Charging UI + Only show time and BG when charging Vibrate hourly diff --git a/wear/src/main/res/xml/watch_face_configuration_home2.xml b/wear/src/main/res/xml/watch_face_configuration_home2.xml index 76379ba9dd..efc27df610 100644 --- a/wear/src/main/res/xml/watch_face_configuration_home2.xml +++ b/wear/src/main/res/xml/watch_face_configuration_home2.xml @@ -8,7 +8,7 @@ android:summary="Dark theme" android:title="@string/pref_dark" app:wear_iconOff="@drawable/settings_off" - app:wear_iconOn="@drawable/settings_on"/> + app:wear_iconOn="@drawable/settings_on" /> + app:wear_iconOn="@drawable/settings_on" /> + + +