Skip to content

Commit

Permalink
Re-Built Design
Browse files Browse the repository at this point in the history
RE-Built Design for new Featureset
  • Loading branch information
massimo-rnd committed Jan 22, 2025
1 parent 2b54ecf commit 786e89a
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 158 deletions.
11 changes: 5 additions & 6 deletions .idea/.idea.AndroidDebloater/.idea/workspace.xml

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

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)));
}
}
}
81 changes: 64 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,17 +68,49 @@
<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 Click="ShowSelector" Grid.Row="7" Grid.Column="1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Content="Test"/>
<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"/>
Expand Down
69 changes: 66 additions & 3 deletions MainWindow.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Reflection;
using System.Text.RegularExpressions;
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;
}

public void ShowHelp(object sender, RoutedEventArgs args)
Expand All @@ -36,6 +46,10 @@ 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;
}
}
}
Expand Down Expand Up @@ -107,10 +121,59 @@ public void DisableSelector(object sender, RoutedEventArgs args)
mSelector.IsEnabled = false;
}

public void ShowSelector(object sender, RoutedEventArgs args)
public void ShowScripts(object sender, RoutedEventArgs args)
{
var window = new PackageSelector();
window.Show();
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;
}
}
}
37 changes: 0 additions & 37 deletions PackageSelector.axaml

This file was deleted.

Loading

0 comments on commit 786e89a

Please sign in to comment.