Skip to content

Commit

Permalink
Merge pull request #4 AndroidDebloater V2.0
Browse files Browse the repository at this point in the history
AndroidDebloater V2.0
  • Loading branch information
massimo-rnd authored Jan 24, 2025
2 parents 60dc6ce + f05e65d commit ec9f7f8
Show file tree
Hide file tree
Showing 9 changed files with 201 additions and 48 deletions.
Binary file modified .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .idea/.idea.AndroidDebloater/.idea/avalonia.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 2 additions & 26 deletions .idea/.idea.AndroidDebloater/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Components/.DS_Store
Binary file not shown.
31 changes: 31 additions & 0 deletions Components/AndroidPackage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.ComponentModel;

namespace AndroidDebloater.Components;

public class AndroidPackage : INotifyPropertyChanged
{
private string _text;
private bool _isChecked;

public event PropertyChangedEventHandler PropertyChanged;

public string Text
{
get => _text;
set
{
_text = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Text)));
}
}

public bool IsChecked
{
get => _isChecked;
set
{
_isChecked = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsChecked)));
}
}
}
10 changes: 10 additions & 0 deletions Components/ShellExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ public static string ListADB()
return AdbHelper.ExecuteAdbCommand("devices"); //Execute(command);
}

public static string GetPackages()
{
return AdbHelper.ExecuteAdbCommand("shell cmd package list packages");
}

public static string RemovePackage(string packageName)
{
return AdbHelper.ExecuteAdbCommand("shell pm uninstall --user 0 " + packageName);
}

public static string StartDebloat(int package)
{
switch (package)
Expand Down
82 changes: 65 additions & 17 deletions MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="AndroidDebloater.MainWindow"
xmlns:components="clr-namespace:AndroidDebloater.Components"
Title="AndroidDebloater"
Width="800" Height="450">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
Expand All @@ -16,11 +18,27 @@
</Grid.ColumnDefinitions>

<!--Left Column-->
<Grid Grid.Row="0" Grid.Column="0">
<Grid Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Content="See Connected Devices"/>
<Button Click="ListDevices" Grid.Row="1" Grid.Column="0" Content="List ADB Devices"/>
<RadioButton x:Name="sSelector" Click="ShowScripts" Grid.Row="2" IsChecked="True" Grid.Column="0" Content="Use Scripts"/>
<RadioButton x:Name="cSelector" Click="ShowCustomSelector" Grid.Row="2" Grid.Column="1" Content="Custom Select"/>
</Grid>


<StackPanel x:Name="ScriptPanel" Grid.Column="0" Grid.Row="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
Expand All @@ -31,18 +49,15 @@
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
</Grid.ColumnDefinitions>

<Label Grid.Row="0" Grid.Column="0" Content="See Connected Devices"/>
<Button Click="ListDevices" Grid.Row="1" Grid.Column="0" Content="List ADB Devices"/>

<Label Grid.Row="2" Grid.Column="0" Margin="0 20 0 0" Content="Select your Debloat Package"/>
<RadioButton Click="DisableSelector" x:Name="gDebloat" IsChecked="True" Grid.Row="3" Grid.Column="0" Content="Google Bloatware"/>
<RadioButton Click="DisableSelector" x:Name="aDebloat" Grid.Row="3" Grid.Column="1" Content="Android System Bloat"/>
<RadioButton Click="DisableSelector" x:Name="tpDebloat" Grid.Row="4" Grid.Column="0" Content="Third-Party Bloat"/>

<Label Grid.Row="0" Grid.Column="0" Margin="0 20 0 0" Content="Select your Debloat Package"/>
<RadioButton Click="DisableSelector" x:Name="gDebloat" IsChecked="True" Grid.Row="1" Grid.Column="0" Content="Google Bloatware"/>
<RadioButton Click="DisableSelector" x:Name="aDebloat" Grid.Row="1" Grid.Column="1" Content="Android System Bloat"/>
<RadioButton Click="DisableSelector" x:Name="tpDebloat" Grid.Row="2" Grid.Column="0" Content="Third-Party Bloat"/>

<Label Grid.Row="5" Grid.Column="0" Margin="0 20 0 0" Content="Manufacturer Debloat"/>
<RadioButton Click="EnableSelector" x:Name="mDebloat" Grid.Row="6" Grid.Column="0" Content="Manufacturer Specific"/>
<ComboBox x:Name="mSelector" Grid.Row="6" Grid.Column="1">
<Label Grid.Row="3" Grid.Column="0" Margin="0 20 0 0" Content="Manufacturer Debloat"/>
<RadioButton Click="EnableSelector" x:Name="mDebloat" Grid.Row="4" Grid.Column="0" Content="Manufacturer Specific"/>
<ComboBox x:Name="mSelector" Grid.Row="4" Grid.Column="1">
<ComboBoxItem Content="Google" IsSelected="True"/>
<ComboBoxItem Content="Huawei"/>
<ComboBoxItem Content="OnePlus"/>
Expand All @@ -53,23 +68,56 @@
<ComboBoxItem Content="Xiaomi"/>
</ComboBox>

<Button x:Name="DebloatBtn" Click="StartDebloater" Grid.Row="7" Grid.Column="0" VerticalAlignment="Bottom" Content="Start Debloat"/>
<Button Click="ShowHelp" Grid.Row="7" Grid.Column="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Content="Help"/>
<Button x:Name="DebloatBtn" Click="StartDebloater" Grid.Row="5" Grid.Column="0" VerticalAlignment="Bottom" Content="Start Debloat"/>
<Button Click="ShowHelp" Grid.Row="5" Grid.Column="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Content="Help"/>

</Grid>
</StackPanel>


<StackPanel x:Name="CustomPanel" Grid.Row="1" IsVisible="false">

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>

<ScrollViewer Grid.Row="0" Grid.ColumnSpan="2" MaxHeight="300" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto" Margin="0 10 0 10">
<ItemsControl Name="PackageList">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type components:AndroidPackage}">
<CheckBox Content="{Binding Text}"
IsChecked="{Binding IsChecked}"
Margin="0,5,0,0"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>

<Button x:Name="CDebloatBtn" Click="RemoveSelected" Grid.Row="1" Grid.Column="0" VerticalAlignment="Bottom" Content="Start Debloat"/>
<Button Click="ShowHelp" Grid.Row="1" Grid.Column="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Content="Help"/>

</Grid>



</StackPanel>



<!--Right Column-->
<Border Grid.Column="1" BorderThickness="1" BorderBrush="Black">
<Border Grid.Column="1" BorderThickness="1" BorderBrush="Black" Grid.RowSpan="5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="Commandline Output"/>
<TextBox x:Name="clOutput" Grid.Row="1" Background="Black" Foreground="White" IsReadOnly="True" Text=""/>
<TextBox x:Name="clOutput" Grid.Row="1" Background="Black" Foreground="White" IsReadOnly="True" Text="" TextWrapping="Wrap"/>
</Grid>
</Border>
</Grid>
Expand Down
89 changes: 87 additions & 2 deletions MainWindow.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,42 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using AndroidDebloater.Components;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Media.TextFormatting.Unicode;
using MsBox.Avalonia;

namespace AndroidDebloater
{
public partial class MainWindow : Window
{
private ObservableCollection<AndroidPackage> _items;

public MainWindow()
{
InitializeComponent();
DebloatBtn.IsEnabled = false;
CDebloatBtn.IsEnabled = false;
mSelector.IsEnabled = false;
sSelector.IsEnabled = false;
ScriptPanel.IsVisible = false;
CustomPanel.IsVisible = false;
cSelector.IsEnabled = false;
clOutput.Text = BuildHelp();
}

public void ShowHelp(object sender, RoutedEventArgs args)
{
var helpBox = MessageBoxManager.GetMessageBoxStandard("Help", "Please Enable Developer-Mode on your Android Device by clicking the Build-Number 7 Times, then in Developer-Options enable USB Debugging.\nWhen plugging your device into your PC it should show a message about trusting the PC. Click allow.", MsBox.Avalonia.Enums.ButtonEnum.Ok);
var helpBox = MessageBoxManager.GetMessageBoxStandard("Help", "Welcome to AndroidDebloater!\n\n"
+ "To get started, please enable USB-Debugging on your Phone.\n"
+ "To do this, go to the about page in your settings and click the 'Build number' 7 times.\n"
+ "Next, go to Developer Settings and Enable USB-Debugging.\n\n"
+ "Now connect your phone, allow Debugging for your PC on your Phone and Click the 'List ADB Devices' button.\n\n"
+ "If there are any problems when using this App, feel free to open an Issue on GitHub.", MsBox.Avalonia.Enums.ButtonEnum.Ok);
var result = helpBox.ShowAsPopupAsync(this);
}

Expand All @@ -36,13 +53,16 @@ public void ListDevices(object sender, RoutedEventArgs args)
{
Console.WriteLine($"Matched: {line.Trim()}");
DebloatBtn.IsEnabled = true;
CDebloatBtn.IsEnabled = true;
cSelector.IsEnabled = true;
sSelector.IsEnabled = true;
ScriptPanel.IsVisible = true;
}
}
}

public void StartDebloater(object sender, RoutedEventArgs args)
{
int packageValue;

if ((bool)gDebloat.IsChecked)
{
Expand Down Expand Up @@ -106,5 +126,70 @@ public void DisableSelector(object sender, RoutedEventArgs args)
{
mSelector.IsEnabled = false;
}

public void ShowScripts(object sender, RoutedEventArgs args)
{
ScriptPanel.IsVisible = true;
CustomPanel.IsVisible = false;
}

public void ShowCustomSelector(object sender, RoutedEventArgs args)
{
CustomPanel.IsVisible = true;
ScriptPanel.IsVisible = false;

_items = new ObservableCollection<AndroidPackage>(CreateObservableCollection(ShellExecutor.GetPackages()));

// Get the ItemsControl by name and set its ItemsSource
var packageControl = this.FindControl<ItemsControl>("PackageList");
packageControl.ItemsSource = _items;
}

private void RemoveSelected(object sender, RoutedEventArgs e)
{
var selectedItems = new List<string>();
foreach (var item in _items)
{
if (item.IsChecked)
{
selectedItems.Add(item.Text);
}
}

clOutput.Text = "Uninstalling " + selectedItems.Count + " packages... \n";

foreach (var item in selectedItems)
{
clOutput.Text += item + ": " +ShellExecutor.RemovePackage(item);
}
}

public ObservableCollection<AndroidPackage> CreateObservableCollection(string input)
{
var collection = new ObservableCollection<AndroidPackage>();

// Split the input into lines
var lines = input.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);

foreach (var line in lines)
{
// Remove the "package:" prefix and add to the collection
var cleanedLine = line.Replace("package:", "").Trim();
collection.Add(new AndroidPackage { Text = cleanedLine, IsChecked = false });
}

return collection;
}

public string BuildHelp()
{
string help = "Welcome to AndroidDebloater!\n\n"
+ "To get started, please enable USB-Debugging on your Phone.\n"
+ "To do this, go to the about page in your settings and click the 'Build number' 7 times.\n"
+ "Next, go to Developer Settings and Enable USB-Debugging.\n\n"
+ "Now connect your phone, allow Debugging for your PC on your Phone and Click the 'List ADB Devices' button.\n\n"
+ "If there are any problems when using this App, feel free to open an Issue on GitHub.";
return help;
}
}
}
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
![Stars](https://img.shields.io/github/stars/massimo-rnd/AndroidDebloater)
![Last Commit](https://img.shields.io/github/last-commit/massimo-rnd/AndroidDebloater)
![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/massimo-rnd/AndroidDebloater?include_prereleases)
![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/massimo-rnd/AndroidDebloater/total?label=Total%20Users)


</div>

Expand Down Expand Up @@ -47,9 +49,9 @@ If sucessful, you can choose your Package and click "Start Debloat"

## 🚧 AndroidDebloater 2.0 Roadmap

- [ ] Individual Package Selection
- [ ] More detailed help section
- [ ] Rework UI (adjust for new Feature-Set)
- [x] Individual Package Selection
- [x] More detailed help section
- [x] Rework UI (adjust for new Feature-Set)

Check out the [open issues](https://github.com/massimo-rnd/AndroidDebloater/issues) for more.

Expand Down

0 comments on commit ec9f7f8

Please sign in to comment.