[Android General] asc1977:
How to make a option to choose between Stock and 3Minit battery

1. First of all be sure you added Global context for android application from [MENTION=4714483]daxgirl[/MENTION] in your SystemUI.apk

If its didnt done follow guide here

2. Add 3Minit Battery to your rom like guided here

So now after i thought many days and hour about how to hide the stock battery icon because a normal method like on MM or Lollipop never work after a reboot on Nougat i had a great idea. Why we dont do it like we do it in System_icons.xml ??? We set the width and high of icon to 0.0dip. So we come to next step

3. Look in system_icons.xml for that line

<com.android.systemui.BatteryMeterView android:id="@id/battery" android:layout_width="@dimen/status_bar_battery_icon_width" android:layout_height="@dimen/status_bar_battery_icon_height" android:layout_marginBottom="@dimen/battery_margin_bottom" />

It must be look like that. So we see the high and width is in dimens.xml. Now we can search the ids for that in public.xml. in my case its like that

<public type="dimen" name="status_bar_battery_icon_height" id="0x7f0d01b1" />
<public type="dimen" name="status_bar_battery_icon_width" id="0x7f0d01b2" />

Now go to com/android/systemui/statusbar/phone/StatusBarIconController and search for one of this ids and you found position where both ids are and looks like that

const v7, 0x7f0d01b1

invoke-virtual {v4, v7}, Landroid/content/res/Resources;->getDimensionPixelSize(I)I

move-result v0

const v7, 0x7f0d01b2

invoke-virtual {v4, v7}, Landroid/content/res/Resources;->getDimensionPixelSize(I)I

move-result v1

So replace that lines with followed lines. There you see blue IDs. This IDs are any ID of a dimens with 0.0dip. In my case i took

<dimen name="status_bar_clock_end_padding">0.0dip</dimen>
<public type="dimen" name="status_bar_clock_end_padding" id="0x7f0d01b5" />

const/4 v10, 0x0

const-string v11, "stock_battery_visibility"

invoke-static {v11, v10}, Lcom/android/wubydax/GearUtils;->getDbIntForKey(Ljava/lang/String;I)I

move-result v11

if-nez v11, :cond_7

const v7, [COLOR="Blue"]0x7f0d01b5[/COLOR]

invoke-virtual {v4, v7}, Landroid/content/res/Resources;->getDimensionPixelSize(I)I

move-result v0

const v7, [COLOR="blue"]0x7f0d01b5[/COLOR]

invoke-virtual {v4, v7}, Landroid/content/res/Resources;->getDimensionPixelSize(I)I

move-result v1

goto :goto_25

:cond_7

const v7, 0x7f0d01b1

invoke-virtual {v4, v7}, Landroid/content/res/Resources;->getDimensionPixelSize(I)I

move-result v0

const v7, 0x7f0d01b2

invoke-virtual {v4, v7}, Landroid/content/res/Resources;->getDimensionPixelSize(I)I

move-result v1

:goto_25

this edits work with daxgirls mod for global context. now you see i took for this lines at begin two new locals. V10 and V11 because they not used before in that method. Now go to begin of method and increase locals from V10 to V12.

4. Recompile and push to phone

5. RomControl preferences

<com.wubydax.romcontrol.v2.prefs.OpenAppPreference android:title="3Minit Battery Mod" android:summary="Custom battery chooser" app:componentName="com.three.minit.minitbatterysettings.free/com.three.minit.minitbatterysettings.MainActivity"/>
<com.wubydax.romcontrol.v2.prefs.MySwitchPreference android:title="3Minit battery show/hide" android:key="minit_battery_visible" android:defaultValue="true" android:summaryOn="shown" android:summaryOff="hidden" />
<com.wubydax.romcontrol.v2.prefs.MySwitchPreference android:title="Stock battery show/hide" android:key="stock_battery_visibility" android:defaultValue="false" android:summaryOn="shown" android:summaryOff="hidden" app:packageNameToKill="com.android.systemui" app:isSilent="false"/>

First line is the OpenAppPreference to launch 3Minit apk

Second line is to show/hide 3MinitBattery on the fly

Third line is to show/hide stock battery with Systemui reboot

The stock battery is now default hidden in this mod so if users only see one battery at clean install

HAVE FUN WITH THAT MOD !!!

Thx to [MENTION=4619873]gharrington[/MENTION] for 3Minit and [MENTION=4714483]daxgirl[/MENTION] for global context