1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-03 17:02:13 +01:00

Multi-battery: further improvements:

- add new icons
- ensure correct default icon
- modify Battery Info activity
This commit is contained in:
vanous 2021-11-02 18:16:41 +01:00
parent 64b52e5edf
commit a7fbda5fe1
15 changed files with 379 additions and 21 deletions

View File

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="34.999996mm"
height="67.499672mm"
viewBox="0 0 34.999996 67.499672"
version="1.1"
id="svg1584"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
sodipodi:docname="tws_bud.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview1586"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="mm"
showgrid="false"
showguides="true"
inkscape:guide-bbox="true"
fit-margin-top="5"
fit-margin-left="5"
fit-margin-right="5"
fit-margin-bottom="5"
inkscape:zoom="1.7965552"
inkscape:cx="20.873281"
inkscape:cy="96.017091"
inkscape:window-width="1920"
inkscape:window-height="1035"
inkscape:window-x="0"
inkscape:window-y="45"
inkscape:window-maximized="1"
inkscape:current-layer="layer1">
<sodipodi:guide
position="56.822358,-42.871949"
orientation="0,-1"
id="guide12345" />
<sodipodi:guide
position="44.960927,-48.473189"
orientation="1,0"
id="guide12613" />
<sodipodi:guide
position="62.862338,-51.411219"
orientation="1,0"
id="guide12653" />
<sodipodi:guide
position="55.621618,-48.425059"
orientation="0,-1"
id="guide13329" />
</sodipodi:namedview>
<defs
id="defs1581" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-57.520553,-52.18693)">
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 66.393093,113.75676 c 0,0 -2.756884,-1.09093 -2.872459,-3.68865 l 0.142728,-39.164751 c 0.01936,-5.31142 3.361305,-12.810634 11.661174,-12.715563 6.576003,0.07532 11.083155,1.743367 11.108851,5.086109 l 0.08706,11.325221 c 0.04024,5.235233 -11.549838,8.121118 -14.518479,6.272204 -2.668401,-1.661919 -2.100534,7.911615 -2.100534,7.911615"
id="path1690"
sodipodi:nodetypes="ccsssssc" />
<path
id="rect9302"
style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;paint-order:fill markers stroke;stop-color:#000000"
d="m 72.801341,91.173713 h 2.007465 c 0,0 0,-1.120076 0,-1.680114 h 5.186597 v 1.665678 l 2.076559,0.01443 c 1.462007,0.01017 2.63906,1.218552 2.63906,2.732177 v 15.226926 c 0,1.51363 -1.177022,2.73218 -2.63906,2.73218 h -9.270621 c -1.462039,0 -2.63906,-1.21855 -2.63906,-2.73218 V 93.905881 c 0,-1.513625 1.177021,-2.732177 2.63906,-2.732177 z"
sodipodi:nodetypes="sccccssssssss" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="20.824697mm"
height="33.370094mm"
viewBox="0 0 20.824698 33.370094"
version="1.1"
id="svg1584"
sodipodi:docname="tws_bud_l.svg"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview1586"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="mm"
showgrid="false"
showguides="true"
inkscape:guide-bbox="true"
fit-margin-top="5"
fit-margin-left="5"
fit-margin-right="5"
fit-margin-bottom="5"
inkscape:zoom="7.2407734"
inkscape:cx="2.8311893"
inkscape:cy="77.408858"
inkscape:window-width="1920"
inkscape:window-height="1035"
inkscape:window-x="0"
inkscape:window-y="45"
inkscape:window-maximized="1"
inkscape:current-layer="layer1"
inkscape:snap-nodes="false">
<sodipodi:guide
position="60.230277,-77.001526"
orientation="0,-1"
id="guide12345" />
<sodipodi:guide
position="48.368846,-82.602765"
orientation="1,0"
id="guide12613" />
<sodipodi:guide
position="66.270257,-85.540793"
orientation="1,0"
id="guide12653" />
<sodipodi:guide
position="59.029537,-82.554635"
orientation="0,-1"
id="guide13329" />
</sodipodi:namedview>
<defs
id="defs1581" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-54.112633,-52.186932)">
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 66.055074,76.803636 c -0.244298,3.556234 2.977704,4.111332 2.879953,-0.991401 l -0.05475,-12.382282 c -0.0097,-2.189912 -1.289342,-5.281881 -4.473037,-5.242683 -2.522448,0.03106 -4.251319,0.718798 -4.261175,2.097025 l -0.03339,4.669439 c -0.01544,2.158509 4.351931,3.889198 5.490653,3.126882 1.023556,-0.685216 0.439063,8.854415 0.439063,8.854415"
id="path1690"
sodipodi:nodetypes="ccsssssc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="20.824697mm"
height="33.370094mm"
viewBox="0 0 20.824698 33.370094"
version="1.1"
id="svg1584"
sodipodi:docname="tws_bud_r.svg"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview1586"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="mm"
showgrid="false"
showguides="true"
inkscape:guide-bbox="true"
fit-margin-top="5"
fit-margin-left="5"
fit-margin-right="5"
fit-margin-bottom="5"
inkscape:zoom="7.2407734"
inkscape:cx="2.8311893"
inkscape:cy="77.408858"
inkscape:window-width="1920"
inkscape:window-height="1035"
inkscape:window-x="0"
inkscape:window-y="45"
inkscape:window-maximized="1"
inkscape:current-layer="layer1"
inkscape:snap-nodes="false">
<sodipodi:guide
position="60.230277,-77.001526"
orientation="0,-1"
id="guide12345" />
<sodipodi:guide
position="48.368846,-82.602765"
orientation="1,0"
id="guide12613" />
<sodipodi:guide
position="66.270257,-85.540793"
orientation="1,0"
id="guide12653" />
<sodipodi:guide
position="59.029537,-82.554635"
orientation="0,-1"
id="guide13329" />
</sodipodi:namedview>
<defs
id="defs1581" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-54.112633,-52.186932)">
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 62.994889,76.803636 c 0.244298,3.556234 -2.977704,4.111332 -2.879953,-0.991401 l 0.05475,-12.382282 c 0.0097,-2.189912 1.289342,-5.281881 4.473037,-5.242683 2.522448,0.03106 4.251319,0.718798 4.261175,2.097025 l 0.03339,4.669439 c 0.01544,2.158509 -4.351931,3.889198 -5.490653,3.126882 -1.023556,-0.685216 -0.439063,8.854415 -0.439063,8.854415"
id="path1690"
sodipodi:nodetypes="ccsssssc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="32.062386mm"
height="31mm"
viewBox="0 0 32.062385 31"
version="1.1"
id="svg5"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
sodipodi:docname="tws_case.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="mm"
showgrid="false"
inkscape:zoom="2.5407127"
inkscape:cx="6.4942408"
inkscape:cy="59.235348"
inkscape:window-width="1920"
inkscape:window-height="1035"
inkscape:window-x="0"
inkscape:window-y="45"
inkscape:window-maximized="1"
inkscape:current-layer="layer1"
fit-margin-top="5"
fit-margin-left="5"
fit-margin-right="5"
fit-margin-bottom="5" />
<defs
id="defs2" />
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-35.169857,-38.996456)">
<rect
style="fill:none;stroke:#000000;stroke-width:3;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;paint-order:fill markers stroke;stop-color:#000000"
id="rect846"
width="20.062387"
height="19"
x="41.169857"
y="44.996456"
ry="5.7287159" />
<path
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:3;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 41.119145,50.610107 H 61.291496"
id="path1465" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -19,8 +19,11 @@ import java.util.Date;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.DeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.BatteryConfig;
import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
import nodomain.freeyourgadget.gadgetbridge.util.DeviceHelper;
public class
BatteryInfoActivity extends AbstractGBActivity {
@ -62,6 +65,7 @@ BatteryInfoActivity extends AbstractGBActivity {
TextView battery_status_device_name_text = (TextView) findViewById(R.id.battery_status_device_name);
TextView battery_status_battery_voltage = (TextView) findViewById(R.id.battery_status_battery_voltage);
TextView battery_status_extra_name = (TextView) findViewById(R.id.battery_status_extra_name);
final TextView battery_status_date_from_text = (TextView) findViewById(R.id.battery_status_date_from_text);
final TextView battery_status_date_to_text = (TextView) findViewById(R.id.battery_status_date_to_text);
final SeekBar battery_status_time_span_seekbar = (SeekBar) findViewById(R.id.battery_status_time_span_seekbar);
@ -164,6 +168,17 @@ BatteryInfoActivity extends AbstractGBActivity {
battery_status_device_name_text.setText(gbDevice.getName());
battery_status_battery_level_text.setText(level);
battery_status_battery_voltage.setText(voltage);
DeviceCoordinator coordinator = DeviceHelper.getInstance().getCoordinator(gbDevice);
for (BatteryConfig batteryConfig : coordinator.getBatteryConfig()) {
if (batteryConfig.getBatteryIndex() == batteryIndex) {
battery_status_extra_name.setText(batteryConfig.getBatteryLabel());
battery_status_device_icon.setImageResource(batteryConfig.getBatteryIcon());
if (gbDevice.isInitialized()) {
battery_status_device_icon.setColorFilter(this.getResources().getColor(R.color.accent));
}
}
}
}
}

View File

@ -161,9 +161,8 @@ public class GBDeviceAdapterv2 extends RecyclerView.Adapter<GBDeviceAdapterv2.Vi
float batteryVoltage = device.getBatteryVoltage(batteryIndex);
BatteryState batteryState = device.getBatteryState(batteryIndex);
int batteryIcon = device.getBatteryIcon(batteryIndex);
int batteryLabel = device.getBatteryLabel(batteryIndex);
LOG.debug("battery icon: " + batteryIcon);
LOG.debug("battery index: " + batteryIndex);
int batteryLabel = device.getBatteryLabel(batteryIndex); //unused for now
batteryIcons[batteryIndex].setImageResource(R.drawable.level_list_battery);
if (batteryIcon != GBDevice.BATTERY_ICON_DEFAULT){
batteryIcons[batteryIndex].setImageResource(batteryIcon);

View File

@ -48,8 +48,8 @@ public class GalaxyBudsDeviceCoordinator extends AbstractDeviceCoordinator {
@Override
public BatteryConfig[] getBatteryConfig() {
BatteryConfig battery1 = new BatteryConfig(0, R.drawable.ic_earbuds_battery, R.string.left);
BatteryConfig battery2 = new BatteryConfig(1, R.drawable.ic_earbuds_battery, R.string.right);
BatteryConfig battery1 = new BatteryConfig(0, R.drawable.ic_tws_bud_l, R.string.left_earbud);
BatteryConfig battery2 = new BatteryConfig(1, R.drawable.ic_tws_bud_r, R.string.right_earbud);
return new BatteryConfig[]{battery1, battery2};
}
@ -142,7 +142,6 @@ public class GalaxyBudsDeviceCoordinator extends AbstractDeviceCoordinator {
}
@Override
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
return new int[]{

View File

@ -128,9 +128,9 @@ public class Ear1Coordinator extends AbstractDeviceCoordinator {
@Override
public BatteryConfig[] getBatteryConfig() {
BatteryConfig battery1 = new BatteryConfig(0, R.drawable.ic_cases, R.string.box);
BatteryConfig battery2 = new BatteryConfig(1, R.drawable.ic_earbuds_battery, R.string.right);
BatteryConfig battery3 = new BatteryConfig(2, R.drawable.ic_earbuds_battery, R.string.left);
BatteryConfig battery1 = new BatteryConfig(0, R.drawable.ic_tws_case, R.string.battery_case);
BatteryConfig battery2 = new BatteryConfig(1, R.drawable.ic_tws_bud_l, R.string.left_earbud);
BatteryConfig battery3 = new BatteryConfig(2, R.drawable.ic_tws_bud_r, R.string.right_earbud);
return new BatteryConfig[]{battery1, battery2, battery3};
}

View File

@ -1,27 +1,44 @@
/* Copyright (C) 2015-2021 Petr Vaněk
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.model;
public class BatteryConfig {
private final int batteryIndex;
private final int icon;
private final int label;
private final int batteryIcon;
private final int batteryLabel;
public BatteryConfig(int batteryIndex, int icon, int label) {
public BatteryConfig(int batteryIndex, int batteryIcon, int batteryLabel) {
this.batteryIndex = batteryIndex;
this.icon = icon;
this.label = label;
this.batteryIcon = batteryIcon;
this.batteryLabel = batteryLabel;
}
public int getBatteryIndex() {
return batteryIndex;
}
public int icon() {
return icon;
public int getBatteryIcon() {
return batteryIcon;
}
public int label() {
return label;
public int getBatteryLabel() {
return batteryLabel;
}
}

View File

@ -343,8 +343,8 @@ public class DeviceHelper {
GBDevice gbDevice = new GBDevice(dbDevice.getIdentifier(), dbDevice.getName(), dbDevice.getAlias(), deviceType);
DeviceCoordinator coordinator = getCoordinator(gbDevice);
for (BatteryConfig batteryConfig : coordinator.getBatteryConfig()) {
gbDevice.setBatteryIcon(batteryConfig.icon(), batteryConfig.getBatteryIndex());
gbDevice.setBatteryLabel(batteryConfig.label(), batteryConfig.getBatteryIndex());
gbDevice.setBatteryIcon(batteryConfig.getBatteryIcon(), batteryConfig.getBatteryIndex());
gbDevice.setBatteryLabel(batteryConfig.getBatteryLabel(), batteryConfig.getBatteryIndex());
}
List<DeviceAttributes> deviceAttributesList = dbDevice.getDeviceAttributesList();

View File

@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20.824697dp"
android:height="33.370094dp"
android:viewportWidth="20.824697"
android:viewportHeight="33.370094"
android:tint="#7E7E7E">
<path
android:fillType="evenOdd"
android:pathData="M11.942 24.617c-0.244 3.556 2.978 4.111 2.88-0.992l-0.054-12.382c-0.01-2.19-1.29-5.282-4.473-5.243-2.523 0.031-4.252 0.72-4.262 2.097L6 12.767c-0.015 2.158 4.352 3.889 5.49 3.127 1.024-0.686 0.44 8.854 0.44 8.854"
android:strokeWidth="2"
android:strokeColor="#000000" />
</vector>

View File

@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20.824697dp"
android:height="33.370094dp"
android:viewportWidth="20.824697"
android:viewportHeight="33.370094"
android:tint="#7E7E7E">
<path
android:fillType="evenOdd"
android:pathData="M8.882 24.617c0.245 3.556-2.977 4.111-2.88-0.992l0.055-12.382C6.067 9.053 7.347 5.961 10.53 6c2.522 0.031 4.251 0.72 4.261 2.097l0.034 4.67c0.015 2.158-4.352 3.889-5.491 3.127-1.024-0.686-0.44 8.854-0.44 8.854"
android:strokeWidth="2"
android:strokeColor="#000000" />
</vector>

View File

@ -0,0 +1,18 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="32.062386dp"
android:height="31dp"
android:viewportWidth="32.062386"
android:viewportHeight="31"
android:tint="#7E7E7E">
<path
android:pathData="M11.729 6h8.605a5.729 5.729 0 0 1 5.728 5.729v7.542A5.729 5.729 0 0 1 20.334 25h-8.605A5.729 5.729 0 0 1 6 19.271V11.73A5.729 5.729 0 0 1 11.729 6z"
android:strokeWidth="3"
android:strokeColor="#000000"
android:strokeLineCap="round"
android:strokeLineJoin="round" />
<path
android:fillType="evenOdd"
android:pathData="M5.95 11.614h20.172"
android:strokeWidth="3"
android:strokeColor="#000000" />
</vector>

View File

@ -61,6 +61,11 @@
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/battery_status_extra_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/battery_status_battery_voltage"
android:layout_width="wrap_content"

View File

@ -383,7 +383,6 @@
<string name="other">Other</string>
<string name="left">Left</string>
<string name="right">Right</string>
<string name="box">Case</string>
<string name="horizontal">Horizontal</string>
<string name="vertical">Vertical</string>
<string name="miband_pairing_using_dummy_userdata">No valid user data given, using dummy user data for now.</string>
@ -1310,4 +1309,7 @@
<string name="prefs_left">Left</string>
<string name="prefs_right">Right</string>
<string name="prefs_galaxy_touch_options">Touch Options</string>
<string name="battery_case">Battery case</string>
<string name="left_earbud">Left earbud</string>
<string name="right_earbud">Right earbud</string>
</resources>