Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gui: Add Support To Remove Torch #86

Open
wants to merge 1 commit into
base: android-9.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,9 @@ endif
ifeq ($(TW_EXCLUDE_NANO), true)
LOCAL_CFLAGS += -DTW_EXCLUDE_NANO
endif
ifeq ($(PB_EXCLUDE_TORCH), true)
LOCAL_CFLAGS += -DPB_EXCLUDE_TORCH
endif

TWRP_REQUIRED_MODULES += \
dump_image \
Expand Down
6 changes: 6 additions & 0 deletions data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,12 @@ void DataManager::SetDefaultValues()
LOGINFO("TW_EXCLUDE_NANO := true\n");
mConst.SetValue("tw_include_nano", "0");
#endif
#ifndef PB_EXCLUDE_TORCH
mConst.SetValue("pb_torch_support", "1");
#else
LOGINFO("PB_EXCLUDE_TORCH := true\n");
mConst.SetValue("pb_torch_support", "0");
#endif

mData.SetValue("tw_enable_adb_backup", "0");

Expand Down
3 changes: 3 additions & 0 deletions gui/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ endif
ifeq ($(TW_EXCLUDE_NANO), true)
LOCAL_CFLAGS += -DTW_EXCLUDE_NANO
endif
ifeq ($(PB_EXCLUDE_TORCH), true)
LOCAL_CFLAGS += -DPB_EXCLUDE_TORCH
endif

LOCAL_C_INCLUDES += \
bionic \
Expand Down
4 changes: 4 additions & 0 deletions gui/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ GUIAction::GUIAction(xml_node<>* node)
ADD_ACTION(getpartitiondetails);
ADD_ACTION(screenshot);
ADD_ACTION(setbrightness);
#ifndef PB_EXCLUDE_TORCH
ADD_ACTION(flashlight);
#endif
ADD_ACTION(fileexists);
ADD_ACTION(killterminal);
ADD_ACTION(checkbackupname);
Expand Down Expand Up @@ -2450,6 +2452,7 @@ int GUIAction::repack(std::string arg __unused)
return 0;
}

#ifndef PB_EXCLUDE_TORCH
int GUIAction::flashlight(std::string arg __unused)
{
int br_value = DataManager::GetIntValue("pb_bright_value");
Expand Down Expand Up @@ -2520,6 +2523,7 @@ int GUIAction::flashlight(std::string arg __unused)
}
return 0;
}
#endif

int GUIAction::repackimage(std::string arg __unused)
{
Expand Down
2 changes: 2 additions & 0 deletions gui/objects.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,9 @@ class GUIAction : public GUIObject, public ActionObject
int setlanguage(std::string arg);
int togglebacklight(std::string arg);
int twcmd(std::string arg);
#ifndef PB_EXCLUDE_TORCH
int flashlight(std::string arg);
#endif
int setbootslot(std::string arg);
int readfile(std::string arg);
int installapp(std::string arg);
Expand Down
15 changes: 12 additions & 3 deletions gui/theme/common/portrait.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4052,7 +4052,10 @@
</slidervalue>

<slidervalue>
<condition var1="pb_torch_brightness_slider" op="!=" var2="0"/>
<conditions>
<condition var1="pb_torch_brightness_slider" op="!=" var2="0"/>
<condition var1="pb_torch_support" var2="1"/>
</conditions>
<placement x="90" y="%row16_y%" w="900"/>
<text>{@sel_br_val=Flashlight Brightness Value: %pb_bright_value%%}</text>
<data variable="pb_bright_value" min="1" max="255"/>
Expand Down Expand Up @@ -4820,15 +4823,21 @@
</image>

<button>
<condition var1="pb_torch_on" var2="0"/>
<conditions>
<condition var1="pb_torch_on" var2="0"/>
<condition var1="pb_torch_support" var2="1"/>
</conditions>
<placement x="%row4_header_y%" y="%row11_y%" />
<!--<highlight color="#1E1E1E30" />-->
<image resource="button_torch_off"/>
<action function="flashlight" />
</button>

<button>
<condition var1="pb_torch_on" var2="1"/>
<conditions>
<condition var1="pb_torch_on" var2="1"/>
<condition var1="pb_torch_support" var2="1"/>
</conditions>
<placement x="%row4_header_y%" y="%row11_y%" />
<!--<highlight color="#1E1E1E30" />-->
<image resource="button_torch_on"/>
Expand Down
3 changes: 3 additions & 0 deletions gui/theme/portrait_hdpi/ui.xml
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,9 @@
</button>

<button style="main_button_back2">
<conditions>
<condition var1="pb_torch_support" var2="1"/>
</conditions>
<placement x="380" y="%row24_y%"/>
<highlight color="%highlight_color%"/>
<icon resource="flash"/>
Expand Down