Skip to content

Commit

Permalink
Finally , Redoing the project!
Browse files Browse the repository at this point in the history
Re-making everything! Made a brand new QT Python app with PySide6
  • Loading branch information
justaCasualCoder committed Sep 28, 2023
1 parent 8d8cd65 commit 35f26fd
Show file tree
Hide file tree
Showing 25 changed files with 451 additions and 101 deletions.
12 changes: 12 additions & 0 deletions About.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<center>SamsungFlashGUI<center>
Made By [<i>justaCasualCoder<i>](https://github.com/justaCasualCoder/SamsungFlashGUI)

This project would not be possible without:

[Heimdall](https://github.com/Benjamin-Dobell/Heimdall) (Used to Flash Images)

[Pyside6](https://doc.qt.io/qtforpython-6/quickstart.html) (Used for the GUI)

[Python](https://www.python.org/) (What it is coded in)

![](https://s3.dualstack.us-east-2.amazonaws.com/pythondotorg-assets/media/files/python-logo-only.svg)
Binary file removed Images/FileSelect.png
Binary file not shown.
Binary file removed Images/FileSelectPy.png
Binary file not shown.
Binary file removed Images/PartSelectPy.png
Binary file not shown.
Binary file removed Images/SelectPart.png
Binary file not shown.
19 changes: 19 additions & 0 deletions LICENSE.mit
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2010-2017 Benjamin Dobell, Glass Echidna

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
4 changes: 4 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
This project is licensed under the GNU General Public License version 3 (GPLv3), except for the following portions:

- Portions of this project are licensed under the MIT License, as indicated in individual files.

GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Expand Down
68 changes: 45 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,55 @@
# SamsungFlashGUI

A Python Script that can be used to easily flash .img files to any Samsung phone

## WARNING!!

THIS PROJECT IS CURRENTLY BEING REDONE AND IS VERY UNSTABLE!

### Running
Download the file corresponding to your OS.

To run on Windows , open a Command Prompt in the directory where it was downloaded and run
```
SamsungFlashGUI.exe
```
To run on Linux , open a Terminal in the directory where it was downloaded and run
Install PySide6

```bash
pip install PySide6
```
./SamsungFlashGUILinux

Install Heimdall (Example on Debian):

```bash
sudo apt install heimdall
```

Download / save `gui.py` and run it.

#### Building

In order to build the Python file into a portable executable , you have to install [Pyinstaller](https://pyinstaller.org/en/stable/) and run the following command:

On Windows
```
pyinstaller --collect-all customtkinter -w --onefile --noconsole --add-data "%cd%\heimdall:heimdall" SamsungFlashGUI.py
```
On Linux
```bash
pyinstaller --onefile --noconsole --add-binary "/bin/heimdall:." --add-data "$(pwd)/python-logo-only.svg:." gui.py
```
pyinstaller --collect-all customtkinter -w --onefile --noconsole --add-data "$(pwd)/heimdall:heimdall" SamsungFlashGUI.py
```
## Features
- Ability to run on Linux and Windows
- Can be built into a Linux executable or Windows EXE
## Known Issues
- It dosent look the greatest in Linux
## Screenshots
<img src="Images/FileSelect.png" width="600px" > <img src="Images/SelectPart.png" width="600px" >
<img src="Images/FileSelectPy.png" width="600px">
<img src="Images/PartSelectPy.png" width="600px">

# Credits

The following programs were used in the code:

[Heimdall](https://github.com/Benjamin-Dobell/Heimdall) (Used to Flash Images)

[Pyside6](https://doc.qt.io/qtforpython-6/quickstart.html) (Used for the GUI)

[Python](https://www.python.org/) (What it is coded in)

# Screenshots

![](screenshots/main_window.png "Main Window")

![](screenshots/about_window.png "About Window")

# Why?

- I wanted a easy way to flash `*IMG`'s to Samsung devices

- The already made Heimdall-Frontend is awesome , but was overcomplicated for me.

- WHY NOT
76 changes: 0 additions & 76 deletions SamsungFlashGUI.py

This file was deleted.

4 changes: 2 additions & 2 deletions download.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
print("E: Couldn't find a TWRP image for " + device)
sys.exit(1)

dlurl = "https://dl.twrp.me" + dllinks[0]["href"].replace(".html", "")
dlurl = "https://dl.twrp.me" + dllinks[1]["href"].replace(".html", "")

imgname = dlurl.split("/")[-1]

Expand All @@ -33,4 +33,4 @@
print("I: Checksum matches")
else:
print("I: Download failed, file is corrupted")
sys.exit(1)
sys.exit(1)
104 changes: 104 additions & 0 deletions gui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import sys
import os
from PySide6.QtWidgets import *
from PySide6.QtGui import *
cwd = os.path.dirname(os.path.abspath(__file__))
os.chdir(cwd)
class Form(QMainWindow):

def __init__(self, parent=None):
super(Form, self).__init__(parent)
self.setWindowTitle("SamsungFlashGUI")
# Create widgets
self.label = QLabel(self)
self.label.setText("Please select your IMG to Flash & partiton")
self.filenameentry = QLineEdit("twrp.img")
self.chooseimage = QPushButton("Choose Image")
self.flash = QPushButton("Flash")
self.buttoncheck = QComboBox()
self.buttoncheck.addItems(["BOOT", "RECOVERY", "DATA" , "SYSTEM"])
layout = QVBoxLayout()
hbox = QHBoxLayout()
buttonbox = QHBoxLayout()
# Set up Menu Buttons
aboutbutton = QAction("About", self)
aboutbutton.setStatusTip("About this project")
aboutbutton.triggered.connect(self.aboutdialog)
aboutbutton.setCheckable(False)
# AutoDetctedButton = QAction("Auto Mode", self)
# AutoDetctedButton.setStatusTip("Auto-Detcted Device")
# AutoDetctedButton.triggered.connect(self.detectdevice)
# AutoDetctedButton.setCheckable(False)
quitbutton = QAction("Quit", self)
quitbutton.setStatusTip("Exit this program")
quitbutton.triggered.connect(lambda: quit())
quitbutton.setCheckable(False)
menu = self.menuBar()
file_menu = menu.addMenu("File")
file_menu.addAction(aboutbutton)
file_menu.addAction(quitbutton)
# file_menu.addAction(AutoDetctedButton)
widget = QWidget()
widget.setLayout(layout)
self.setCentralWidget(widget)
layout.addWidget(self.label)
hbox.addWidget(self.filenameentry)
hbox.addWidget(self.chooseimage)
hbox.addWidget(self.buttoncheck)
layout.addLayout( buttonbox )
layout.addLayout( hbox )
layout.addWidget(self.flash)
self.chooseimage.clicked.connect(self.Image)
self.flash.clicked.connect(self.flashimage)
def Image(self):
global filename
file_dialog = QFileDialog()
file_dialog.setFileMode(QFileDialog.ExistingFile)
file_dialog.setNameFilter("Image Files (*.img)")
file_dialog.setViewMode(QFileDialog.List)
if file_dialog.exec():
filenames = file_dialog.selectedFiles()
if filenames:
filename = filenames[0]
print(f"File {filename} chosen")
self.filenameentry.setText(filename)
def flashimage(self):
try:
filename
except NameError:
filename = self.filenameentry.text()
print(f"Flashing {filename} to {self.buttoncheck.currentText()}")
print(f"heimdall flash --{self.buttoncheck.currentText()} {filename}")
# Portions of this project are using code from the Heimdall project, developed by Benjamin Dobell and other contributors, which is licensed under the MIT License.
heimdallbin = os.path.abspath(os.path.join(cwd,'heimdall'))
os.system(f"if [ ! -f /bin/heimdall ]; then echo 'Using Local Heimdall' && {heimdallbin} flash --{self.buttoncheck.currentText()} {filename} ; else echo 'Using /bin/heimdall' && heimdall flash --{self.buttoncheck.currentText()} {filename} ; fi")
def aboutdialog(self):
logo = os.path.abspath(os.path.join(cwd,'python-logo-only.svg'))
text = f"""
<p><center>SamsungFlashGUI<center><p>
<p><center><img src="{logo}" alt=""><center></p>
Made By <a href="https://github.com/justaCasualCoder/SamsungFlashGUI"><i>justaCasualCoder<i></a></p>
<p>This project would not be possible without:</p>
<p><a href="https://github.com/Benjamin-Dobell/Heimdall">Heimdall</a> (Used to Flash Images)</p>
<p><a href="https://doc.qt.io/qtforpython-6/quickstart.html">Pyside6</a> (Used for the GUI)</p>
<p><a href="https://www.python.org/">Python</a> (What it is coded in)</p>
"""
dlg = QMessageBox(self)
dlg.setWindowTitle("About")
dlg.setText(text)
button = dlg.exec()
# def detectdevice(self):
# print("")




if __name__ == '__main__':
# Create the Qt Application
app = QApplication(sys.argv)
# Create and show the form
form = Form()
form.show()
# Run the main Qt loop
sys.exit(app.exec())
Binary file removed heimdall/Drivers/zadig.exe
Binary file not shown.
Binary file removed heimdall/Heimdall.exe
Binary file not shown.
Binary file removed heimdall/Heimdall.iobj
Binary file not shown.
Binary file removed heimdall/Heimdall.ipdb
Binary file not shown.
Binary file removed heimdall/Heimdall.pdb
Binary file not shown.
Binary file removed heimdall/QtCore4.dll
Binary file not shown.
Binary file removed heimdall/QtGui4.dll
Binary file not shown.
Binary file removed heimdall/QtXml4.dll
Binary file not shown.
Binary file removed heimdall/libpit.lib
Binary file not shown.
Binary file removed heimdall/libusb-1.0.dll
Binary file not shown.
Binary file removed heimdall/zadig-2.4.exe
Binary file not shown.
Loading

0 comments on commit 35f26fd

Please sign in to comment.