Skip to content

Commit 786e89a

Browse files
committed
Re-Built Design
RE-Built Design for new Featureset
1 parent 2b54ecf commit 786e89a

File tree

6 files changed

+166
-158
lines changed

6 files changed

+166
-158
lines changed

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

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

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+
}

MainWindow.axaml

Lines changed: 64 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,17 +68,49 @@
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"/>-->
58-
<Button Click="ShowSelector" Grid.Row="7" Grid.Column="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Content="Test"/>
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+
5974
</Grid>
75+
</StackPanel>
6076

61-
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>
62109

63110

64111

65112
<!--Right Column-->
66-
<Border Grid.Column="1" BorderThickness="1" BorderBrush="Black">
113+
<Border Grid.Column="1" BorderThickness="1" BorderBrush="Black" Grid.RowSpan="5">
67114
<Grid>
68115
<Grid.RowDefinitions>
69116
<RowDefinition Height="auto"/>

MainWindow.axaml.cs

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
11
using System;
2+
using System.Collections.Generic;
3+
using System.Collections.ObjectModel;
24
using System.Reflection;
35
using System.Text.RegularExpressions;
46
using AndroidDebloater.Components;
57
using Avalonia.Controls;
68
using Avalonia.Interactivity;
9+
using Avalonia.Media.TextFormatting.Unicode;
710
using MsBox.Avalonia;
811

912
namespace AndroidDebloater
1013
{
1114
public partial class MainWindow : Window
1215
{
16+
private ObservableCollection<AndroidPackage> _items;
17+
1318
public MainWindow()
1419
{
1520
InitializeComponent();
1621
DebloatBtn.IsEnabled = false;
22+
CDebloatBtn.IsEnabled = false;
1723
mSelector.IsEnabled = false;
24+
sSelector.IsEnabled = false;
25+
ScriptPanel.IsVisible = false;
26+
CustomPanel.IsVisible = false;
27+
cSelector.IsEnabled = false;
1828
}
1929

2030
public void ShowHelp(object sender, RoutedEventArgs args)
@@ -36,6 +46,10 @@ public void ListDevices(object sender, RoutedEventArgs args)
3646
{
3747
Console.WriteLine($"Matched: {line.Trim()}");
3848
DebloatBtn.IsEnabled = true;
49+
CDebloatBtn.IsEnabled = true;
50+
cSelector.IsEnabled = true;
51+
sSelector.IsEnabled = true;
52+
ScriptPanel.IsVisible = true;
3953
}
4054
}
4155
}
@@ -107,10 +121,59 @@ public void DisableSelector(object sender, RoutedEventArgs args)
107121
mSelector.IsEnabled = false;
108122
}
109123

110-
public void ShowSelector(object sender, RoutedEventArgs args)
124+
public void ShowScripts(object sender, RoutedEventArgs args)
111125
{
112-
var window = new PackageSelector();
113-
window.Show();
126+
ScriptPanel.IsVisible = true;
127+
CustomPanel.IsVisible = false;
128+
}
129+
130+
public void ShowCustomSelector(object sender, RoutedEventArgs args)
131+
{
132+
CustomPanel.IsVisible = true;
133+
ScriptPanel.IsVisible = false;
134+
135+
_items = new ObservableCollection<AndroidPackage>(CreateObservableCollection(ShellExecutor.GetPackages()));
136+
137+
// Get the ItemsControl by name and set its ItemsSource
138+
var packageControl = this.FindControl<ItemsControl>("PackageList");
139+
packageControl.ItemsSource = _items;
140+
}
141+
142+
private void RemoveSelected(object sender, RoutedEventArgs e)
143+
{
144+
145+
var selectedItems = new List<string>();
146+
foreach (var item in _items)
147+
{
148+
if (item.IsChecked)
149+
{
150+
selectedItems.Add(item.Text);
151+
}
152+
}
153+
154+
clOutput.Text = "Uninstalling " + selectedItems.Count + " packages... \n";
155+
156+
foreach (var item in selectedItems)
157+
{
158+
clOutput.Text += item + ": " +ShellExecutor.RemovePackage(item);
159+
}
160+
}
161+
162+
public ObservableCollection<AndroidPackage> CreateObservableCollection(string input)
163+
{
164+
var collection = new ObservableCollection<AndroidPackage>();
165+
166+
// Split the input into lines
167+
var lines = input.Split(new[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
168+
169+
foreach (var line in lines)
170+
{
171+
// Remove the "package:" prefix and add to the collection
172+
var cleanedLine = line.Replace("package:", "").Trim();
173+
collection.Add(new AndroidPackage { Text = cleanedLine, IsChecked = false });
174+
}
175+
176+
return collection;
114177
}
115178
}
116179
}

PackageSelector.axaml

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)