diff --git a/.github/edit2MakeNewCanary b/.github/edit2MakeNewCanary index 04ad0604c..65aeddb0b 100644 --- a/.github/edit2MakeNewCanary +++ b/.github/edit2MakeNewCanary @@ -1 +1 @@ -Editing this file will trigger the build script for a new canary.. \ No newline at end of file +Editing this file will trigger the build script for a new canary. \ No newline at end of file diff --git a/app/src/main/java/sh/siava/pixelxpert/modpacks/utils/batteryStyles/BatteryBarView.java b/app/src/main/java/sh/siava/pixelxpert/modpacks/utils/batteryStyles/BatteryBarView.java index 70f2451df..d38184cdd 100644 --- a/app/src/main/java/sh/siava/pixelxpert/modpacks/utils/batteryStyles/BatteryBarView.java +++ b/app/src/main/java/sh/siava/pixelxpert/modpacks/utils/batteryStyles/BatteryBarView.java @@ -194,6 +194,11 @@ private void animateChargingIndicator() { public BatteryBarView(Context context) { super(context); instance = this; + + chargingIndicatorView = new ImageView(context); + chargingIndicatorViewForCenter = new ImageView(context); + initChargingAnimationView(); + this.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); mDrawable.setShape(new RectShape()); @@ -203,16 +208,6 @@ public BatteryBarView(Context context) { barView = new ImageView(context); barView.setImageDrawable(mDrawable); - chargingIndicatorView = new ImageView(context); - chargingIndicatorView.setLayoutParams(new LayoutParams(20, barHeight)); - chargingIndicatorView.setBackgroundColor(singleColorTone); - chargingIndicatorView.setAlpha(alphaPct / 100f); - - chargingIndicatorViewForCenter = new ImageView(context); - chargingIndicatorViewForCenter.setLayoutParams(new LayoutParams(20, barHeight)); - chargingIndicatorViewForCenter.setBackgroundColor(singleColorTone); - chargingIndicatorViewForCenter.setAlpha(alphaPct / 100f); - maskLayout = new FrameLayout(context); maskLayout.addView(barView); maskLayout.setClipChildren(true); @@ -231,6 +226,17 @@ public BatteryBarView(Context context) { BatteryBarView instance = this; BatteryDataProvider.registerInfoCallback(() -> instance.post(instance::refreshLayout)); } + + private void initChargingAnimationView() { + ViewGroup.LayoutParams lp = new LayoutParams(20, barHeight); + + chargingIndicatorView.setLayoutParams(lp); + chargingIndicatorViewForCenter.setLayoutParams(lp); + + chargingIndicatorView.setBackgroundColor(singleColorTone); + chargingIndicatorViewForCenter.setBackgroundColor(singleColorTone); + } + @Override public void setLayoutDirection(int direction) { super.setLayoutDirection(direction); @@ -346,8 +352,9 @@ private static void refreshShadeColors() { public void setAlphaPct(int alphaPct) { this.alphaPct = alphaPct; mDrawable.setAlpha(Math.round(alphaPct * 2.55f)); - if (chargingIndicatorView != null) chargingIndicatorView.setAlpha(alphaPct / 100f); - if (chargingIndicatorViewForCenter != null) chargingIndicatorViewForCenter.setAlpha(alphaPct / 100f); + + chargingIndicatorView.setAlpha(alphaPct / 100f); + chargingIndicatorViewForCenter.setAlpha(alphaPct / 100f); }