Skip to content

Commit

Permalink
- #84, further UI improvements for smaller screens.
Browse files Browse the repository at this point in the history
- Better dark mode handling for MacOS and Linux.
- #86, improved handling of space characters in paths.
  • Loading branch information
Bing committed Jul 16, 2023
1 parent e18b12f commit 52023b9
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 12 deletions.
8 changes: 6 additions & 2 deletions Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,8 @@ def _on_resize(self, event):
self.fastboot_verbose_checkBox.SetLabel("Verbose")
self.temporary_root_checkBox.SetLabel("Temporary\nRoot")
self.no_reboot_checkBox.SetLabel("No\nreboot")
self.staticline1.Hide()
self.staticline2.Hide()
else:
self.set_active_slot_button.SetLabel("Set Active Slot")
self.reboot_bootloader_button.SetLabel("Reboot to Bootloader")
Expand All @@ -592,6 +594,8 @@ def _on_resize(self, event):
self.fastboot_verbose_checkBox.SetLabel("Verbose")
self.temporary_root_checkBox.SetLabel("Temporary Root")
self.no_reboot_checkBox.SetLabel("No reboot")
self.staticline1.Show()
self.staticline2.Show()

self.Layout()
event.Skip(True)
Expand Down Expand Up @@ -2833,7 +2837,7 @@ def _on_clear(event):
(adb_label_sizer, 0, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, 5), (device_sizer, 1, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL),
(active_slot_sizer, 0, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, 5), (self.reboot_sizer, 1, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL),
# (wx.StaticText(panel, label="")), (wx.StaticText(panel, label="")),
self.staticline1, (self.staticline2, 0, wx.ALIGN_CENTER_VERTICAL|wx.BOTTOM|wx.EXPAND|wx.TOP, 20),
self.staticline1, (self.staticline2, 0, wx.ALIGN_CENTER_VERTICAL|wx.BOTTOM|wx.EXPAND|wx.TOP, 5),
(firmware_label_sizer, 0, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, 5), (self.firmware_sizer, 1, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL),
(self.custom_rom_checkbox, 0, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL, 5), (custom_rom_sizer, 1, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL),
(boot_label_v_sizer, 0, wx.EXPAND), (list_sizer, 1, wx.EXPAND|wx.ALIGN_CENTER_VERTICAL),
Expand All @@ -2853,7 +2857,7 @@ def _on_clear(event):
fgs1.AddGrowableRow(NUMROWS - 2, 1)

# add flexgrid to vbox
vbox.Add(fgs1, proportion=1, flag=wx.ALL | wx.EXPAND, border=15)
vbox.Add(fgs1, proportion=1, flag=wx.ALL | wx.EXPAND, border=10)

# set the panel
panel.SetSizer(vbox)
Expand Down
2 changes: 1 addition & 1 deletion build-on-mac.spec
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ exe = EXE(pyz,
icon='images/icon-256.icns')
app = BUNDLE(exe,
name='PixelFlasher.app',
version='5.5.1.0',
version='5.5.1.1',
icon='./images/icon-256.icns',
bundle_identifier='com.badabing.pixelflasher')
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
rm -rf build dist
VERSION=5.5.1.0
VERSION=5.5.1.1
NAME="PixelFlasher"
DIST_NAME="PixelFlasher"

Expand Down
2 changes: 1 addition & 1 deletion constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

APPNAME = 'PixelFlasher'
CONFIG_FILE_NAME = 'PixelFlasher.json'
VERSION = '5.5.1.0'
VERSION = '5.5.1.1'
SDKVERSION = '33.0.3'
WIDTH = 1400
HEIGHT = 1040
Expand Down
20 changes: 18 additions & 2 deletions message_box_ex.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import webbrowser

import darkdetect
import markdown
import wx
import wx.html

from runtime import *


class MessageBoxEx(wx.Dialog):
def __init__(self, *args, title=None, message=None, button_texts=None, default_button=None, disable_buttons=None, is_md=False, size=(800, 600), checkbox_labels=None, **kwargs):
wx.Dialog.__init__(self, *args, **kwargs)
Expand All @@ -26,7 +26,23 @@ def __init__(self, *args, title=None, message=None, button_texts=None, default_b
if is_md:
self.html = wx.html.HtmlWindow(self, wx.ID_ANY, size=size)
md_html = markdown.markdown(message)
self.html.SetPage(md_html)

# Adjust colors for dark mode on Mac and Linux
if darkdetect.isDark() and sys.platform != "win32":
dark_html = f"""
<!DOCTYPE html>
<html>
<body style="background-color:#656565; color:#ffffff;">
{md_html}
</body>
</html>
"""
self.html.SetPage(dark_html)
if "gtk2" in wx.PlatformInfo or "gtk3" in wx.PlatformInfo or sys.platform == "darwin":
self.html.SetStandardFonts()
else:
self.html.SetPage(md_html)

self.html.Bind(wx.html.EVT_HTML_LINK_CLICKED, self._onLinkClicked)
message_sizer.Add(self.html, 1, wx.ALL | wx.EXPAND, 20)
else:
Expand Down
15 changes: 15 additions & 0 deletions phone.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,7 @@ def delete(self, file_path: str, with_su = False, dir = False) -> int:
print(f"\n{datetime.now():%Y-%m-%d %H:%M:%S} ERROR: Could not delete {file_path}. Device is not in ADB mode.")
return -1
try:
file_path = remove_quotes(file_path)
if with_su:
if self.rooted:
print(f"Deleting {file_path} from the device as root ...")
Expand Down Expand Up @@ -992,6 +993,8 @@ def su_cp_on_device(self, source: str, dest) -> int:
print(f"\n{datetime.now():%Y-%m-%d %H:%M:%S} ERROR: Could not copy. Device is not in ADB mode or is not rooted.")
return -1
try:
source = remove_quotes(source)
dest = remove_quotes(dest)
print(f"Copying {source} to {dest} ...")
theCmd = f"\"{get_adb()}\" -s {self.id} shell \"su -c \'cp \"{source}\" \"{dest}\"\'\""
res = run_shell(theCmd)
Expand Down Expand Up @@ -1025,6 +1028,7 @@ def check_file(self, file_path: str, with_su = False) -> int:
print(f"\n{datetime.now():%Y-%m-%d %H:%M:%S} ERROR: Could not check {file_path}. Device is not in ADB mode.")
return -1, None
try:
file_path = remove_quotes(file_path)
if with_su:
if self.rooted:
print(f"Checking for {file_path} on the device as root ...")
Expand Down Expand Up @@ -1064,6 +1068,7 @@ def create_dir(self, dir_path: str, with_su = False) -> int:
print(f"\n{datetime.now():%Y-%m-%d %H:%M:%S} ERROR: Could not check {dir_path}. Device is not in ADB mode.")
return -1
try:
dir_path = remove_quotes(dir_path)
if with_su:
if self.rooted:
print(f"Creating directory {dir_path} on the device as root ...")
Expand Down Expand Up @@ -1103,6 +1108,7 @@ def file_content(self, file_path: str, with_su = False) -> int:
print(f"\n{datetime.now():%Y-%m-%d %H:%M:%S} ERROR: Could not get file content of {file_path}. Device is not in ADB mode.")
return -1
try:
file_path = remove_quotes(file_path)
if with_su:
if self.rooted:
print(f"Getting file content of {file_path} on the device as root ...")
Expand Down Expand Up @@ -1143,6 +1149,8 @@ def push_file(self, local_file: str, file_path: str, with_su = False) -> int:
print(f"\n{datetime.now():%Y-%m-%d %H:%M:%S} ERROR: Could not push {file_path}. Device is not in ADB mode.")
return -1
try:
local_file = remove_quotes(local_file)
file_path = remove_quotes(file_path)
if with_su:
if self.rooted:
print(f"Pushing local file as root: {local_file} to the device: {file_path} ...")
Expand Down Expand Up @@ -1197,6 +1205,8 @@ def pull_file(self, remote_file: str, local_file: str, with_su = False) -> int:
print(f"\n{datetime.now():%Y-%m-%d %H:%M:%S} ERROR: Could not pull {remote_file}. Device is not in ADB mode.")
return -1
try:
remote_file = remove_quotes(remote_file)
local_file = remove_quotes(local_file)
if with_su:
if self.rooted:
filename = os.path.basename(urlparse(remote_file).path)
Expand Down Expand Up @@ -1247,6 +1257,7 @@ def set_file_permissions(self, file_path: str, permissions: str = "755", with_su
print(f"\n{datetime.now():%Y-%m-%d %H:%M:%S} ERROR: Could not set permissions on {file_path}. Device is not in ADB mode.")
return -1
try:
file_path = remove_quotes(file_path)
if with_su:
if self.rooted:
print(f"Setting permissions {permissions} on {file_path} as root ...")
Expand Down Expand Up @@ -1753,6 +1764,10 @@ def rooted(self):
if res.returncode == 0:
self._rooted = True
else:
theCmd = f"\"{get_adb()}\" -s {self.id} shell busybox --version"
res = run_shell(theCmd)
if res.returncode == 0:
print(f"\n{datetime.now():%Y-%m-%d %H:%M:%S} ERROR: Device appears to be rooted, however adb root access is not granted.\Please grant root access to adb and scan again.")
self._rooted = False
else:
print(f"\n{datetime.now():%Y-%m-%d %H:%M:%S} ERROR: adb command is not found!")
Expand Down
10 changes: 10 additions & 0 deletions runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,16 @@ def is_exe(fpath):
return None


# ============================================================================
# Function remove_quotes
# ============================================================================
def remove_quotes(string):
if string.startswith('"') and string.endswith('"'):
# Remove existing double quotes
string = string[1:-1]
return string


# ============================================================================
# Function create_support_zip
# ============================================================================
Expand Down
2 changes: 1 addition & 1 deletion windows-metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# https://github.com/DudeNr33/pyinstaller-versionfile
# create-version-file windows-metadata.yaml --outfile windows-version-info.txt
Version: 5.5.1.0
Version: 5.5.1.1
FileDescription: PixelFlasher
InternalName: PixelFlasher
OriginalFilename: PixelFlasher.exe
Expand Down
8 changes: 4 additions & 4 deletions windows-version-info.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ VSVersionInfo(
ffi=FixedFileInfo(
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
# Set not needed items to zero 0. Must always contain 4 elements.
filevers=(5,5,1,0),
prodvers=(5,5,1,0),
filevers=(5,5,1,1),
prodvers=(5,5,1,1),
# Contains a bitmask that specifies the valid bits 'flags'r
mask=0x3f,
# Contains a bitmask that specifies the Boolean attributes of the file.
Expand All @@ -32,12 +32,12 @@ VSVersionInfo(
u'040904B0',
[StringStruct(u'CompanyName', u''),
StringStruct(u'FileDescription', u'PixelFlasher'),
StringStruct(u'FileVersion', u'5.5.1.0'),
StringStruct(u'FileVersion', u'5.5.1.1'),
StringStruct(u'InternalName', u'PixelFlasher'),
StringStruct(u'LegalCopyright', u''),
StringStruct(u'OriginalFilename', u'PixelFlasher.exe'),
StringStruct(u'ProductName', u'PixelFlasher'),
StringStruct(u'ProductVersion', u'5.5.1.0')])
StringStruct(u'ProductVersion', u'5.5.1.1')])
]),
VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
]
Expand Down

0 comments on commit 52023b9

Please sign in to comment.