Skip to content

Commit ec9f7f8

Browse files
authored
Merge pull request #4 AndroidDebloater V2.0
AndroidDebloater V2.0
2 parents 60dc6ce + f05e65d commit ec9f7f8

File tree

9 files changed

+201
-48
lines changed

9 files changed

+201
-48
lines changed

.DS_Store

0 Bytes
Binary file not shown.

.idea/.idea.AndroidDebloater/.idea/avalonia.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.idea.AndroidDebloater/.idea/workspace.xml

Lines changed: 2 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Components/.DS_Store

0 Bytes
Binary file not shown.

Components/AndroidPackage.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System.ComponentModel;
2+
3+
namespace AndroidDebloater.Components;
4+
5+
public class AndroidPackage : INotifyPropertyChanged
6+
{
7+
private string _text;
8+
private bool _isChecked;
9+
10+
public event PropertyChangedEventHandler PropertyChanged;
11+
12+
public string Text
13+
{
14+
get => _text;
15+
set
16+
{
17+
_text = value;
18+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Text)));
19+
}
20+
}
21+
22+
public bool IsChecked
23+
{
24+
get => _isChecked;
25+
set
26+
{
27+
_isChecked = value;
28+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsChecked)));
29+
}
30+
}
31+
}

Components/ShellExecutor.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ public static string ListADB()
1414
return AdbHelper.ExecuteAdbCommand("devices"); //Execute(command);
1515
}
1616

17+
public static string GetPackages()
18+
{
19+
return AdbHelper.ExecuteAdbCommand("shell cmd package list packages");
20+
}
21+
22+
public static string RemovePackage(string packageName)
23+
{
24+
return AdbHelper.ExecuteAdbCommand("shell pm uninstall --user 0 " + packageName);
25+
}
26+
1727
public static string StartDebloat(int package)
1828
{
1929
switch (package)

MainWindow.axaml

Lines changed: 65 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
66
x:Class="AndroidDebloater.MainWindow"
7+
xmlns:components="clr-namespace:AndroidDebloater.Components"
78
Title="AndroidDebloater"
89
Width="800" Height="450">
910
<Grid Margin="10">
1011
<Grid.RowDefinitions>
12+
<RowDefinition Height="auto"/>
1113
<RowDefinition Height="*"/>
1214
</Grid.RowDefinitions>
1315
<Grid.ColumnDefinitions>
@@ -16,11 +18,27 @@
1618
</Grid.ColumnDefinitions>
1719

1820
<!--Left Column-->
19-
<Grid Grid.Row="0" Grid.Column="0">
21+
<Grid Grid.Row="0">
2022
<Grid.RowDefinitions>
2123
<RowDefinition Height="auto"/>
2224
<RowDefinition Height="auto"/>
2325
<RowDefinition Height="auto"/>
26+
</Grid.RowDefinitions>
27+
<Grid.ColumnDefinitions>
28+
<ColumnDefinition Width="*"/>
29+
<ColumnDefinition Width="*"/>
30+
</Grid.ColumnDefinitions>
31+
<Label Grid.Row="0" Grid.Column="0" Content="See Connected Devices"/>
32+
<Button Click="ListDevices" Grid.Row="1" Grid.Column="0" Content="List ADB Devices"/>
33+
<RadioButton x:Name="sSelector" Click="ShowScripts" Grid.Row="2" IsChecked="True" Grid.Column="0" Content="Use Scripts"/>
34+
<RadioButton x:Name="cSelector" Click="ShowCustomSelector" Grid.Row="2" Grid.Column="1" Content="Custom Select"/>
35+
</Grid>
36+
37+
38+
<StackPanel x:Name="ScriptPanel" Grid.Column="0" Grid.Row="1">
39+
<Grid>
40+
<Grid.RowDefinitions>
41+
<RowDefinition Height="auto"/>
2442
<RowDefinition Height="auto"/>
2543
<RowDefinition Height="auto"/>
2644
<RowDefinition Height="auto"/>
@@ -31,18 +49,15 @@
3149
<ColumnDefinition Width="auto"/>
3250
<ColumnDefinition Width="auto"/>
3351
</Grid.ColumnDefinitions>
34-
35-
<Label Grid.Row="0" Grid.Column="0" Content="See Connected Devices"/>
36-
<Button Click="ListDevices" Grid.Row="1" Grid.Column="0" Content="List ADB Devices"/>
37-
38-
<Label Grid.Row="2" Grid.Column="0" Margin="0 20 0 0" Content="Select your Debloat Package"/>
39-
<RadioButton Click="DisableSelector" x:Name="gDebloat" IsChecked="True" Grid.Row="3" Grid.Column="0" Content="Google Bloatware"/>
40-
<RadioButton Click="DisableSelector" x:Name="aDebloat" Grid.Row="3" Grid.Column="1" Content="Android System Bloat"/>
41-
<RadioButton Click="DisableSelector" x:Name="tpDebloat" Grid.Row="4" Grid.Column="0" Content="Third-Party Bloat"/>
52+
53+
<Label Grid.Row="0" Grid.Column="0" Margin="0 20 0 0" Content="Select your Debloat Package"/>
54+
<RadioButton Click="DisableSelector" x:Name="gDebloat" IsChecked="True" Grid.Row="1" Grid.Column="0" Content="Google Bloatware"/>
55+
<RadioButton Click="DisableSelector" x:Name="aDebloat" Grid.Row="1" Grid.Column="1" Content="Android System Bloat"/>
56+
<RadioButton Click="DisableSelector" x:Name="tpDebloat" Grid.Row="2" Grid.Column="0" Content="Third-Party Bloat"/>
4257

43-
<Label Grid.Row="5" Grid.Column="0" Margin="0 20 0 0" Content="Manufacturer Debloat"/>
44-
<RadioButton Click="EnableSelector" x:Name="mDebloat" Grid.Row="6" Grid.Column="0" Content="Manufacturer Specific"/>
45-
<ComboBox x:Name="mSelector" Grid.Row="6" Grid.Column="1">
58+
<Label Grid.Row="3" Grid.Column="0" Margin="0 20 0 0" Content="Manufacturer Debloat"/>
59+
<RadioButton Click="EnableSelector" x:Name="mDebloat" Grid.Row="4" Grid.Column="0" Content="Manufacturer Specific"/>
60+
<ComboBox x:Name="mSelector" Grid.Row="4" Grid.Column="1">
4661
<ComboBoxItem Content="Google" IsSelected="True"/>
4762
<ComboBoxItem Content="Huawei"/>
4863
<ComboBoxItem Content="OnePlus"/>
@@ -53,23 +68,56 @@
5368
<ComboBoxItem Content="Xiaomi"/>
5469
</ComboBox>
5570

56-
<Button x:Name="DebloatBtn" Click="StartDebloater" Grid.Row="7" Grid.Column="0" VerticalAlignment="Bottom" Content="Start Debloat"/>
57-
<Button Click="ShowHelp" Grid.Row="7" Grid.Column="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Content="Help"/>
71+
<Button x:Name="DebloatBtn" Click="StartDebloater" Grid.Row="5" Grid.Column="0" VerticalAlignment="Bottom" Content="Start Debloat"/>
72+
<Button Click="ShowHelp" Grid.Row="5" Grid.Column="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Content="Help"/>
73+
5874
</Grid>
75+
</StackPanel>
5976

60-
77+
<StackPanel x:Name="CustomPanel" Grid.Row="1" IsVisible="false">
78+
79+
<Grid>
80+
<Grid.RowDefinitions>
81+
<RowDefinition Height="*"/>
82+
<RowDefinition Height="auto"/>
83+
</Grid.RowDefinitions>
84+
<Grid.ColumnDefinitions>
85+
<ColumnDefinition Width="*"/>
86+
<ColumnDefinition Width="*"/>
87+
</Grid.ColumnDefinitions>
88+
89+
<ScrollViewer Grid.Row="0" Grid.ColumnSpan="2" MaxHeight="300" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto" Margin="0 10 0 10">
90+
<ItemsControl Name="PackageList">
91+
<ItemsControl.ItemTemplate>
92+
<DataTemplate DataType="{x:Type components:AndroidPackage}">
93+
<CheckBox Content="{Binding Text}"
94+
IsChecked="{Binding IsChecked}"
95+
Margin="0,5,0,0"/>
96+
</DataTemplate>
97+
</ItemsControl.ItemTemplate>
98+
</ItemsControl>
99+
</ScrollViewer>
100+
101+
<Button x:Name="CDebloatBtn" Click="RemoveSelected" Grid.Row="1" Grid.Column="0" VerticalAlignment="Bottom" Content="Start Debloat"/>
102+
<Button Click="ShowHelp" Grid.Row="1" Grid.Column="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Content="Help"/>
103+
104+
</Grid>
105+
106+
107+
108+
</StackPanel>
61109

62110

63111

64112
<!--Right Column-->
65-
<Border Grid.Column="1" BorderThickness="1" BorderBrush="Black">
113+
<Border Grid.Column="1" BorderThickness="1" BorderBrush="Black" Grid.RowSpan="5">
66114
<Grid>
67115
<Grid.RowDefinitions>
68116
<RowDefinition Height="auto"/>
69117
<RowDefinition Height="*"/>
70118
</Grid.RowDefinitions>
71119
<Label Grid.Row="0" Content="Commandline Output"/>
72-
<TextBox x:Name="clOutput" Grid.Row="1" Background="Black" Foreground="White" IsReadOnly="True" Text=""/>
120+
<TextBox x:Name="clOutput" Grid.Row="1" Background="Black" Foreground="White" IsReadOnly="True" Text="" TextWrapping="Wrap"/>
73121
</Grid>
74122
</Border>
75123
</Grid>

MainWindow.axaml.cs

Lines changed: 87 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,42 @@
11
using System;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
24
using System.Reflection;
35
using System.Text.RegularExpressions;
6+
using System.Threading.Tasks;
47
using AndroidDebloater.Components;
58
using Avalonia.Controls;
69
using Avalonia.Interactivity;
10+
using Avalonia.Media.TextFormatting.Unicode;
711
using MsBox.Avalonia;
812

913
namespace AndroidDebloater
1014
{
1115
public partial class MainWindow : Window
1216
{
17+
private ObservableCollection<AndroidPackage> _items;
18+
1319
public MainWindow()
1420
{
1521
InitializeComponent();
1622
DebloatBtn.IsEnabled = false;
23+
CDebloatBtn.IsEnabled = false;
1724
mSelector.IsEnabled = false;
25+
sSelector.IsEnabled = false;
26+
ScriptPanel.IsVisible = false;
27+
CustomPanel.IsVisible = false;
28+
cSelector.IsEnabled = false;
29+
clOutput.Text = BuildHelp();
1830
}
1931

2032
public void ShowHelp(object sender, RoutedEventArgs args)
2133
{
22-
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);
34+
var helpBox = MessageBoxManager.GetMessageBoxStandard("Help", "Welcome to AndroidDebloater!\n\n"
35+
+ "To get started, please enable USB-Debugging on your Phone.\n"
36+
+ "To do this, go to the about page in your settings and click the 'Build number' 7 times.\n"
37+
+ "Next, go to Developer Settings and Enable USB-Debugging.\n\n"
38+
+ "Now connect your phone, allow Debugging for your PC on your Phone and Click the 'List ADB Devices' button.\n\n"
39+
+ "If there are any problems when using this App, feel free to open an Issue on GitHub.", MsBox.Avalonia.Enums.ButtonEnum.Ok);
2340
var result = helpBox.ShowAsPopupAsync(this);
2441
}
2542

@@ -36,13 +53,16 @@ public void ListDevices(object sender, RoutedEventArgs args)
3653
{
3754
Console.WriteLine($"Matched: {line.Trim()}");
3855
DebloatBtn.IsEnabled = true;
56+
CDebloatBtn.IsEnabled = true;
57+
cSelector.IsEnabled = true;
58+
sSelector.IsEnabled = true;
59+
ScriptPanel.IsVisible = true;
3960
}
4061
}
4162
}
4263

4364
public void StartDebloater(object sender, RoutedEventArgs args)
4465
{
45-
int packageValue;
4666

4767
if ((bool)gDebloat.IsChecked)
4868
{
@@ -106,5 +126,70 @@ public void DisableSelector(object sender, RoutedEventArgs args)
106126
{
107127
mSelector.IsEnabled = false;
108128
}
129+
130+
public void ShowScripts(object sender, RoutedEventArgs args)
131+
{
132+
ScriptPanel.IsVisible = true;
133+
CustomPanel.IsVisible = false;
134+
}
135+
136+
public void ShowCustomSelector(object sender, RoutedEventArgs args)
137+
{
138+
CustomPanel.IsVisible = true;
139+
ScriptPanel.IsVisible = false;
140+
141+
_items = new ObservableCollection<AndroidPackage>(CreateObservableCollection(ShellExecutor.GetPackages()));
142+
143+
// Get the ItemsControl by name and set its ItemsSource
144+
var packageControl = this.FindControl<ItemsControl>("PackageList");
145+
packageControl.ItemsSource = _items;
146+
}
147+
148+
private void RemoveSelected(object sender, RoutedEventArgs e)
149+
{
150+
var selectedItems = new List<string>();
151+
foreach (var item in _items)
152+
{
153+
if (item.IsChecked)
154+
{
155+
selectedItems.Add(item.Text);
156+
}
157+
}
158+
159+
clOutput.Text = "Uninstalling " + selectedItems.Count + " packages... \n";
160+
161+
foreach (var item in selectedItems)
162+
{
163+
clOutput.Text += item + ": " +ShellExecutor.RemovePackage(item);
164+
}
165+
}
166+
167+
public ObservableCollection<AndroidPackage> CreateObservableCollection(string input)
168+
{
169+
var collection = new ObservableCollection<AndroidPackage>();
170+
171+
// Split the input into lines
172+
var lines = input.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
173+
174+
foreach (var line in lines)
175+
{
176+
// Remove the "package:" prefix and add to the collection
177+
var cleanedLine = line.Replace("package:", "").Trim();
178+
collection.Add(new AndroidPackage { Text = cleanedLine, IsChecked = false });
179+
}
180+
181+
return collection;
182+
}
183+
184+
public string BuildHelp()
185+
{
186+
string help = "Welcome to AndroidDebloater!\n\n"
187+
+ "To get started, please enable USB-Debugging on your Phone.\n"
188+
+ "To do this, go to the about page in your settings and click the 'Build number' 7 times.\n"
189+
+ "Next, go to Developer Settings and Enable USB-Debugging.\n\n"
190+
+ "Now connect your phone, allow Debugging for your PC on your Phone and Click the 'List ADB Devices' button.\n\n"
191+
+ "If there are any problems when using this App, feel free to open an Issue on GitHub.";
192+
return help;
193+
}
109194
}
110195
}

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
![Stars](https://img.shields.io/github/stars/massimo-rnd/AndroidDebloater)
99
![Last Commit](https://img.shields.io/github/last-commit/massimo-rnd/AndroidDebloater)
1010
![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/massimo-rnd/AndroidDebloater?include_prereleases)
11+
![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/massimo-rnd/AndroidDebloater/total?label=Total%20Users)
12+
1113

1214
</div>
1315

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

4850
## 🚧 AndroidDebloater 2.0 Roadmap
4951

50-
- [ ] Individual Package Selection
51-
- [ ] More detailed help section
52-
- [ ] Rework UI (adjust for new Feature-Set)
52+
- [x] Individual Package Selection
53+
- [x] More detailed help section
54+
- [x] Rework UI (adjust for new Feature-Set)
5355

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

0 commit comments

Comments
 (0)