Skip to content
This repository has been archived by the owner on Jul 23, 2023. It is now read-only.

Commit

Permalink
Disable app feature and minor bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorenzoantonelli committed Sep 27, 2020
1 parent 0846868 commit 76d8c37
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Project exclude paths
/target/
/target/
/releases/
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ public class MainController {
@FXML
Button uninstallCurrentAppButton;

@FXML
Button disableCurrentAppButton;

@FXML
Button uninstallCustomAppButton;

@FXML
Button disableCustomAppButton;

@FXML
Button uninstallFacebookButton;

Expand All @@ -47,7 +53,9 @@ public void initialize(){
Runnable currentApp=()->{
boolean buttonStatus=!utils.findDevice();
uninstallCurrentAppButton.setDisable(buttonStatus);
disableCurrentAppButton.setDisable(buttonStatus);
uninstallCustomAppButton.setDisable(buttonStatus);
disableCustomAppButton.setDisable(buttonStatus);
customApp.setDisable(buttonStatus);
uninstallFacebookButton.setDisable(buttonStatus);
updateCurrentApp();
Expand All @@ -71,6 +79,12 @@ public void uninstallCurrentApp(){
new Alert(Alert.AlertType.NONE,(utils.removeApp(packageName)? "Operazione completata con successo!":"Operazione fallita!"), ButtonType.OK).show();
}

@FXML
public void disableCurrentApp(){
String packageName=utils.getPackageName();
new Alert(Alert.AlertType.NONE,(utils.disableApp(packageName)? "Operazione completata con successo!":"Operazione fallita!"), ButtonType.OK).show();
}

@FXML
public void uninstallCustomApp(){
boolean status=utils.removeApp(customApp.getText());
Expand All @@ -80,6 +94,15 @@ public void uninstallCustomApp(){
}
}

@FXML
public void disableCustomApp(){
boolean status=utils.disableApp(customApp.getText());
new Alert(Alert.AlertType.NONE,((status)? "Operazione completata con successo!":"Operazione fallita!"), ButtonType.OK).show();
if (status) {
customApp.clear();
}
}

@FXML
public void uninstallFacebook(){
boolean status=utils.removeApp("com.facebook.appmanager") ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ public boolean removeApp(String packageName){
return (!runShell(adbPath+" shell pm uninstall -k --user 0 "+packageName).equals("-1"));
}

/**
* Disables the application whose package name was given in input.
* @param packageName the package name of the app to disable.
* @return true if the application has been disabled, false otherwise.
*/
public boolean disableApp(String packageName){
return (!runShell(adbPath+" shell pm disable-user --user 0 "+packageName).equals("-1"));
}

/**
* Copy aapt-arm-pie (taken from https://github.com/Calsign/APDE/blob/master/APDE/src/main/assets/aapt-binaries/aapt-arm-pie)
* in /data/local/tmp with 0755 permissions.
Expand Down
40 changes: 23 additions & 17 deletions src/main/resources/org/lorenzoantonelli/tapdebloater/mainFxml.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,29 @@
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.Separator?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>

<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="241.0"
prefWidth="415.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="org.lorenzoantonelli.tapdebloater.MainController">
<Label text="Disinstalla app corrente:"/>
<Label fx:id="appNameLabel" text="App corrente:"/>
<Label fx:id="packageNameLabel" text="Package Name:"/>
<Button fx:id="uninstallCurrentAppButton" mnemonicParsing="false" onAction="#uninstallCurrentApp" prefWidth="146.0"
text="Dininstalla "/>
<Separator prefHeight="21.0" prefWidth="415.0"/>
<Label text="Disinstalla dal PackageName:"/>
<TextField fx:id="customApp" prefHeight="27.0" prefWidth="309.0"/>
<Button fx:id="uninstallCustomAppButton" mnemonicParsing="false" onAction="#uninstallCustomApp" prefHeight="27.0"
prefWidth="146.0" text="Disinstalla"/>
<Separator prefHeight="21.0" prefWidth="415.0"/>
<Label text="Disinstalla Facebook Services:"/>
<Button fx:id="uninstallFacebookButton" mnemonicParsing="false" onAction="#uninstallFacebook" prefHeight="27.0"
prefWidth="146.0" text="Disinstalla"/>
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="241.0" prefWidth="415.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.lorenzoantonelli.tapdebloater.MainController">
<Label text="Disinstalla app corrente:" />
<Label fx:id="appNameLabel" text="App corrente:" />
<Label fx:id="packageNameLabel" text="Package name:" />
<HBox prefWidth="200.0" spacing="5.0">
<Button fx:id="uninstallCurrentAppButton" mnemonicParsing="false" onAction="#uninstallCurrentApp"
prefWidth="146.0" text="Dininstalla "/>
<Button fx:id="disableCurrentAppButton" mnemonicParsing="false" onAction="#disableCurrentApp" prefWidth="146.0"
text="Disabilita"/>
</HBox>
<Separator prefHeight="21.0" prefWidth="415.0" />
<Label text="Disinstalla dal package name:" />
<TextField fx:id="customApp" prefHeight="27.0" prefWidth="309.0" />
<HBox prefWidth="200.0" spacing="5.0">
<Button fx:id="uninstallCustomAppButton" mnemonicParsing="false" onAction="#uninstallCustomApp" prefHeight="27.0"
prefWidth="146.0" text="Disinstalla"/>
<Button fx:id="disableCustomAppButton" mnemonicParsing="false" onAction="#disableCustomApp" prefWidth="146.0"
text="Disabilita"/>
</HBox>
<Separator prefHeight="21.0" prefWidth="415.0" />
<Label text="Disinstalla Facebook Services:" />
<Button fx:id="uninstallFacebookButton" mnemonicParsing="false" onAction="#uninstallFacebook" prefHeight="27.0" prefWidth="146.0" text="Disinstalla" />
</VBox>

0 comments on commit 76d8c37

Please sign in to comment.