Skip to content

Commit

Permalink
Fix android release builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Rarisma committed Jun 6, 2024
1 parent 8dbeb7d commit 7aecd53
Show file tree
Hide file tree
Showing 13 changed files with 180 additions and 209 deletions.
27 changes: 20 additions & 7 deletions Firehose/App.xaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Application x:Class="Firehose.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wasm="http://platform.uno/wasm"
xmlns:utum="using:Uno.Toolkit.UI.Material"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="wasm">
<Application x:Class="Firehose.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wasm="http://platform.uno/wasm"
xmlns:utum="using:Uno.Toolkit.UI.Material"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="wasm">

<Application.Resources>
<ResourceDictionary>
Expand All @@ -14,6 +14,19 @@
<!-- Load Uno.UI.Toolkit resources -->
<ToolkitResources xmlns="using:Uno.Toolkit.UI" />
</ResourceDictionary.MergedDictionaries>

<!-- Define the transparent brush -->
<SolidColorBrush x:Key="TransparentBrush" Color="Transparent" />

<!-- Override the ExpanderHeaderBackground resource -->
<StaticResource x:Key="ExpanderHeaderBackground" ResourceKey="TransparentBrush" />
<StaticResource x:Key="ExpanderHeaderBorderBrush" ResourceKey="TransparentBrush" />
<StaticResource x:Key="ExpanderHeaderBorderPointerOverBrush" ResourceKey="TransparentBrush" />
<StaticResource x:Key="ExpanderChevronBorderBrush" ResourceKey="TransparentBrush" />
<StaticResource x:Key="ExpanderChevronForeground" ResourceKey="TransparentBrush" />
<StaticResource x:Key="ExpanderContentBackground" ResourceKey="TransparentBrush" />
<StaticResource x:Key="ExpanderContentBorderBrush" ResourceKey="TransparentBrush" />
<x:Double x:Key="ExpanderChevronButtonSize">0</x:Double>
</ResourceDictionary>
</Application.Resources>

Expand Down
2 changes: 0 additions & 2 deletions Firehose/Firehose.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
net8.0-android;
net8.0-ios;
net8.0-maccatalyst;
net8.0-windows10.0.19041;
net8.0-desktop;
</TargetFrameworks>

<OutputType>Exe</OutputType>
Expand Down
5 changes: 3 additions & 2 deletions Firehose/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
IgnorableNamespaces="uap rescap">

<Identity
Name="Firehose"
Name="FirehoseNews"
Publisher="CN=RARI"
Version="1.0.1.0" />
Version="1.0.2.0" />

<Properties>
<DisplayName>Firehose</DisplayName>
Expand All @@ -33,6 +33,7 @@
DisplayName="Firehose"
Description="Firehose">
<uap:SplashScreen />
<uap:DefaultTile/>
</uap:VisualElements>
</Application>
</Applications>
Expand Down
4 changes: 4 additions & 0 deletions Firehose/Platforms/Android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:allowBackup="true" android:supportsRtl="true"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-sdk android:targetSdkVersion="34" />
</manifest>
200 changes: 104 additions & 96 deletions Firehose/UI/ArticleList.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,115 +13,124 @@
Loaded="ArticleList_OnLoaded">

<Page.Resources>
<Style x:Key="BorderTemplate" TargetType="Border">
<Setter Property="BorderBrush" Value="#555555"/>
<Setter Property="Opacity" Value="0.2"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Margin" Value="10"/>
</Style>

<!-- Common Border Style -->
<ControlTemplate x:Key="CommonBorderTemplate">
<Border Background="Transparent" BorderBrush="Gray"
BorderThickness="1" Margin="20,10"/>
</ControlTemplate>

<DataTemplate x:Key="ExpanderContentTemplate" x:DataType="hydrant:Article">
<StackPanel>
<TextBlock Text="{x:Bind Summary}" TextWrapping="WrapWholeWords"/>
<Button Content="Read full article" HorizontalAlignment="Stretch"
Margin="20,20,20,5" Click="OpenArticle"/>
</StackPanel>
</DataTemplate>

<!-- Article Layout Views -->
<Style x:Key="ExpanderStyle" TargetType="Expander">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
</Style>

<!-- No Image - When the Article lacks an image, this will show the RSS Summary in its place.-->
<DataTemplate x:Key="NoImageTemplate" x:DataType="hydrant:Article">
<StackPanel HorizontalAlignment="Stretch">
<!-- Spacing border -->
<Border Style="{StaticResource BorderTemplate}"/>
<SwipeControl Tag="{x:Bind Url}">
<SwipeControl.RightItems>
<SwipeItems Mode="Execute">
<SwipeItem BehaviorOnInvoked="Close" Invoked="OpenQuickViewSwipe" Background="Transparent">
<SwipeItem.IconSource>
<FontIconSource />
</SwipeItem.IconSource>
</SwipeItem>
</SwipeItems>
</SwipeControl.RightItems>
<StackPanel>
<StackPanel HorizontalAlignment="Stretch">
<!-- Spacing border -->
<ContentControl Template="{StaticResource CommonBorderTemplate}"/>
<Expander Background="Transparent" HorizontalAlignment="Stretch">
<Expander.Header >
<StackPanel Padding="0,20">
<!-- Publication info, Title and Summary -->
<controls:PublisherInformation ItemSource="{x:Bind}"/>
<TextBlock Text="{x:Bind Title}" FontSize="16" TextWrapping="Wrap"
MaxWidth="500" HorizontalAlignment="Left"/>
MaxWidth="500" HorizontalAlignment="Left"/>
<TextBlock Text="{x:Bind RSSSummary}" MaxLines="3" FontSize="11"
TextWrapping="Wrap" MaxWidth="500" HorizontalAlignment="Left"/>
TextWrapping="Wrap" MaxWidth="500" HorizontalAlignment="Left"/>
</StackPanel>
</SwipeControl>
</Expander.Header>
<Expander.Content>
<StackPanel>
<TextBlock Text="{x:Bind Summary}" TextWrapping="WrapWholeWords"/>
<Button Content="Read full article" HorizontalAlignment="Stretch"
Margin="20,20,20,5" Click="OpenArticle"
Padding="0,15"/>
</StackPanel>
</Expander.Content>
</Expander>
</StackPanel>
</DataTemplate>
</DataTemplate>

<!-- Headline Template - These are the hard hitting stories, so they have large images. -->
<DataTemplate x:Key="HeadlineTemplate" x:DataType="hydrant:Article">
<StackPanel>
<!-- Spacing boarder -->
<Border Style="{StaticResource BorderTemplate}"/>
<SwipeControl Tag="{x:Bind Url}">
<SwipeControl.RightItems>
<SwipeItems Mode="Execute">
<SwipeItem BehaviorOnInvoked="Close" Invoked="OpenQuickViewSwipe" Background="Transparent">
<SwipeItem.IconSource>
<FontIconSource />
</SwipeItem.IconSource>
</SwipeItem>
</SwipeItems>
</SwipeControl.RightItems>

<StackPanel>
<!-- Show publication Info -->
<controls:PublisherInformation ItemSource="{x:Bind}"/>

<!-- Image + Text -->
<Border CornerRadius="4" HorizontalAlignment="Center" MaxHeight="200"
BorderThickness="0" VerticalAlignment="Stretch">
<Image Source="{x:Bind ImageURL}" />
</Border>

<TextBlock Text="{x:Bind Title}" Margin="0,10" FontSize="16" TextWrapping="Wrap"
HorizontalAlignment="Left" VerticalAlignment="Center" />
</StackPanel>
</SwipeControl>
<DataTemplate x:Key="HeadlineTemplate" x:DataType="hydrant:Article">
<StackPanel HorizontalAlignment="Stretch" >
<!-- Spacing border -->
<ContentControl Template="{StaticResource CommonBorderTemplate}"/>
<Expander Background="Transparent" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch">
<Expander.Header>
<StackPanel Background="Transparent" HorizontalAlignment="Center">
<!-- Show publication Info -->
<controls:PublisherInformation ItemSource="{x:Bind}"/>

<!-- Image + Text -->
<Border CornerRadius="4" HorizontalAlignment="Center" MaxHeight="200"
BorderThickness="0" VerticalAlignment="Stretch">
<Image Source="{x:Bind ImageURL}" />
</Border>

<TextBlock Text="{x:Bind Title}" Margin="0,10" FontSize="16" TextWrapping="Wrap"
HorizontalAlignment="Left" VerticalAlignment="Center" />
</StackPanel>
</Expander.Header>
<Expander.Content>
<StackPanel>
<TextBlock Text="{x:Bind Summary}" TextWrapping="WrapWholeWords"/>
<Button Content="Read full article" HorizontalAlignment="Stretch"
Margin="20,20,20,5" Click="OpenArticle"
Padding="0,15"/>
</StackPanel>
</Expander.Content>
</Expander>
</StackPanel>
</DataTemplate>
</DataTemplate>

<!-- Minimal - When the Article isn't a major story, so it should take up less space. -->
<DataTemplate x:Key="MinimalTemplate" x:DataType="hydrant:Article">
<StackPanel>
<!-- Separating boarder -->
<Border Style="{StaticResource BorderTemplate}"/>

<SwipeControl Tag="{x:Bind Url}">
<SwipeControl.RightItems>
<SwipeItems Mode="Execute">
<SwipeItem BehaviorOnInvoked="Close" Invoked="OpenQuickViewSwipe" Background="Transparent">
<SwipeItem.IconSource>
<FontIconSource />
</SwipeItem.IconSource>
</SwipeItem>
</SwipeItems>
</SwipeControl.RightItems>
<StackPanel>
<controls:PublisherInformation ItemSource="{x:Bind}"/>

<!-- Title - [Image] -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>

<TextBlock Grid.Column="0" HorizontalAlignment="Left" Text="{x:Bind Title}" FontSize="16"
TextWrapping="Wrap" VerticalAlignment="Center" Padding="0,0,10,10"/>

<Border CornerRadius="4" HorizontalAlignment="Right" MaxHeight="100" MinWidth="100"
BorderThickness="0" VerticalAlignment="Stretch" Grid.Column="1">
<Image Source="{x:Bind ImageURL}" MinWidth="100"/>
</Border>
</Grid>
</StackPanel>
</SwipeControl>
<DataTemplate x:Key="MinimalTemplate" x:DataType="hydrant:Article">
<StackPanel HorizontalAlignment="Stretch">
<!-- Separating border -->
<ContentControl Template="{StaticResource CommonBorderTemplate}"/>
<Expander Background="Transparent" HorizontalAlignment="Stretch">
<Expander.Header>
<StackPanel>
<controls:PublisherInformation ItemSource="{x:Bind}"/>

<!-- Title - [Image] -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="2*"/>
</Grid.ColumnDefinitions>

<TextBlock Grid.Column="0" HorizontalAlignment="Left" Text="{x:Bind Title}" FontSize="16"
TextWrapping="Wrap" VerticalAlignment="Center" Padding="0,0,10,10"/>

<Border CornerRadius="4" HorizontalAlignment="Right" MaxHeight="100" MinWidth="100"
BorderThickness="0" VerticalAlignment="Stretch" Grid.Column="1">
<Image Source="{x:Bind ImageURL}" MinWidth="100"/>
</Border>
</Grid>
</StackPanel>
</Expander.Header>
<Expander.Content>
<StackPanel>
<TextBlock Text="{x:Bind Summary}" TextWrapping="WrapWholeWords"/>
<Button Content="Read full article" HorizontalAlignment="Stretch"
Margin="20,20,20,5" Click="OpenArticle"
Padding="0,15"/>
</StackPanel>
</Expander.Content>
</Expander>
</StackPanel>
</DataTemplate>
</DataTemplate>

<!-- Article Selector Decides which article type should be used -->
<controls:ArticleSelector x:Key="ArticleSelector"
Expand Down Expand Up @@ -168,9 +177,8 @@
</ScrollViewer>

<StackPanel>
<ItemsControl ItemsSource="{x:Bind ShellVM.Articles}" Tapped="ArticleTapped"
ItemTemplateSelector="{StaticResource ArticleSelector}"
RightTapped="OpenQuickViewHold"/>
<ItemsControl ItemsSource="{x:Bind ShellVM.Articles}"
ItemTemplateSelector="{StaticResource ArticleSelector}"/>

<TextBlock Text="You have no bookmarked stories." Name="NoBookmarks" VerticalAlignment="Center"
HorizontalAlignment="Center" Margin="10"/>
Expand Down
55 changes: 2 additions & 53 deletions Firehose/UI/ArticleList.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Firehose.Viewmodels;
using HYDRANT.Definitions;
using Microsoft.UI;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media.Imaging;
using Uno.Extensions;

Expand Down Expand Up @@ -54,18 +53,6 @@ public ArticleList()
ChangeFilter(ShellVM.Filters[0], new());
}


/// <summary>
/// Opens a tapped article object.
/// </summary>
private void ArticleTapped(object sender, TappedRoutedEventArgs e)
{
//Get article object
Article Data = (Article)((FrameworkElement)e.OriginalSource).DataContext;
ShellVM.OpenArticle(Data); //Open article.
}


private void OpenSettings(object sender, RoutedEventArgs e)
{
Glob.NaviStack.Push(new Preferences());
Expand Down Expand Up @@ -134,46 +121,6 @@ private void ChangeFilter(object sender, RoutedEventArgs e)
ShellVM.LoadArticleDataCommand.Execute(null);
}

#region QuickView

/// <summary>
/// Opens a quick view of an article showing the title,
/// image and the AI Summary of the article.
/// </summary>
private async Task QuickViewMenu(Article Article)
{
// Save scroll position
double previousScrollPosition = ArticleScroller.VerticalOffset;

await ShellVM.OpenQuickView(Article);

// Restore scroll position
ArticleScroller.ChangeView(null, previousScrollPosition, null);
}


/// <summary>
/// Opens article quick view menu when held
/// </summary>
private async void OpenQuickViewHold(object sender, RightTappedRoutedEventArgs e)
{
//Get article object
Article article = ((e.OriginalSource as FrameworkElement)?.DataContext as Article)!;

//Open article
await QuickViewMenu(article);
}

/// <summary>
/// Opens article quick view menu when swiped.
/// </summary>
private async void OpenQuickViewSwipe(object sender, SwipeItemInvokedEventArgs args)
{
//Open menu with appropriate article found via tag.
await QuickViewMenu(ShellVM.Articles.First(x => x.Url == args.SwipeControl.Tag.ToString()));
}
#endregion

private void ArticleList_OnLoaded(object sender, RoutedEventArgs e) => Glob.XamlRoot = this.XamlRoot;

private void ShowBookmarks(object sender, RoutedEventArgs e)
Expand All @@ -192,4 +139,6 @@ private void ShowBookmarks(object sender, RoutedEventArgs e)
}

private async void FilterSource(object sender, RoutedEventArgs e) => await SetPublisherFilter();

private void OpenArticle(object sender, RoutedEventArgs e) => ShellVM.OpenArticle(((sender as Button)!.DataContext) as Article);
}
Loading

0 comments on commit 7aecd53

Please sign in to comment.