Skip to content

Commit

Permalink
UI Upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
ShortDevelopment committed May 16, 2024
1 parent 1ecec7b commit 6ef5cc0
Show file tree
Hide file tree
Showing 14 changed files with 158 additions and 77 deletions.
2 changes: 1 addition & 1 deletion lib/ShortDev.Android.Preferences
10 changes: 9 additions & 1 deletion src/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:installLocation="auto">
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme" android:localeConfig="@xml/locales_config">
<provider
android:name="androidx.core.content.FileProvider"
Expand All @@ -10,5 +10,13 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge">
<meta-data android:name="app.rive.runtime.kotlin.RiveInitializer"
android:value="androidx.startup" />
</provider>
</application>
</manifest>
1 change: 0 additions & 1 deletion src/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using AndroidX.AppCompat.App;
using Google.Android.Material.Color;
using NearShare.Droid.Settings;
using Sentry;

[assembly: UsesPermission(ManifestPermission.Bluetooth)]
[assembly: UsesPermission(ManifestPermission.BluetoothAdmin)]
Expand Down
22 changes: 7 additions & 15 deletions src/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using Android.Content;
using Android.Bluetooth;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using AndroidX.AppCompat.App;
using Google.Android.Material.FloatingActionButton;
using Google.Android.Material.Card;

namespace NearShare.Droid;

Expand All @@ -15,26 +16,17 @@ protected override void OnCreate(Bundle? savedInstanceState)
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.activity_main);

//FloatingActionButton openNearbySharingFab = FindViewById<FloatingActionButton>(Resource.Id.open_nearby_share_android_fab);
//openNearbySharingFab.Click += delegate
//{
// Intent intent = new Intent("com.google.android.gms.SHARE_NEARBY");
// intent.SetPackage("com.google.android.gms");
// StartActivity(intent);
//};

UIHelper.SetupToolBar(this, GetString(Resource.String.app_titlebar_title_default));

FindViewById<TextView>(Resource.Id.infoTextView)!.TextFormatted = UIHelper.LoadHtmlAsset(this, "Welcome");
UIHelper.SetupToolBar(this);

Button sendButton = FindViewById<Button>(Resource.Id.sendButton)!;
sendButton.Click += SendButton_Click;

Button receiveButton = FindViewById<Button>(Resource.Id.receiveButton)!;
receiveButton.Click += ReceiveButton_Click;

FloatingActionButton floatingReceiveButton = FindViewById<FloatingActionButton>(Resource.Id.floating_receive_button)!;
floatingReceiveButton.Click += ReceiveButton_Click;
FindViewById<MaterialCardView>(Resource.Id.enableBluetoothButton)!.Click += (_, _) => StartActivity(new Intent(BluetoothAdapter.ActionRequestEnable));
FindViewById<MaterialCardView>(Resource.Id.setupWindowButton)!.Click += (_, _) => UIHelper.OpenSetup(this);
FindViewById<MaterialCardView>(Resource.Id.openFAQButton)!.Click += (_, _) => UIHelper.OpenFAQ(this);
}

private void ReceiveButton_Click(object? sender, EventArgs e)
Expand Down
12 changes: 8 additions & 4 deletions src/NearShare.Droid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@
<PublishTrimmed>false</PublishTrimmed>
<AndroidPackageFormat>aab</AndroidPackageFormat>
</PropertyGroup>
<ItemGroup>
<None Remove="Resources\raw\animation_welcome.riv" />
</ItemGroup>
<ItemGroup Label="Nuget">
<PackageReference Include="Sentry" Version="3.41.0" />
<PackageReference Include="Rive.Android" Version="1.0.0" />
<PackageReference Include="Sentry" Version="4.6.2" />
<PackageReference Include="ShortDev.Android.FluentIcons" Version="1.1.203" />
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.6.1.6" />
<PackageReference Include="Xamarin.AndroidX.Browser" Version="1.7.0.1" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.10.0.2" />
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.6.1.8" />
<PackageReference Include="Xamarin.AndroidX.Browser" Version="1.8.0.1" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.10.0.4" />
</ItemGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\lib\ShortDev.Android.Preferences\ShortDev.Android.Preferences.csproj" />
Expand Down
113 changes: 95 additions & 18 deletions src/Resources/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<include
android:layout_width="match_parent"
Expand All @@ -22,13 +23,15 @@
android:layout_height="wrap_content"
android:padding="10dp">

<TextView
android:id="@+id/infoTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoLink="web"
android:linksClickable="true" />
<!-- Welcome animation -->
<app.rive.runtime.kotlin.RiveAnimationView
android:layout_width="300dp"
android:layout_height="300dp"
android:layout_gravity="center"
android:layout_margin="10dp"
app:riveResource="@raw/animation_welcome" />

<!-- Send / Receive buttons -->
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
Expand All @@ -50,19 +53,93 @@
android:text="@string/generic_receive"
app:icon="@drawable/ic_fluent_mail_inbox_24_regular" />
</LinearLayout>
</LinearLayout>

</androidx.core.widget.NestedScrollView>
<!-- Enable Bluetooth -->
<com.google.android.material.card.MaterialCardView
style="?attr/materialCardViewFilledStyle"
android:id="@+id/enableBluetoothButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:layout_margin="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_margin="12dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
android:src="@drawable/ic_fluent_bluetooth_24_regular"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/request_enable_bluetooth"
android:layout_gravity="center_vertical"
android:textAppearance="?attr/textAppearanceBodyMedium"
android:textColor="?android:attr/textColorSecondary" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>

<!-- Setup Windows -->
<com.google.android.material.card.MaterialCardView
style="?attr/materialCardViewFilledStyle"
android:id="@+id/setupWindowButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:layout_margin="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_margin="12dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
android:src="@drawable/ic_fluent_window_new_24_regular"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/open_setup_summary"
android:layout_gravity="center_vertical"
android:textAppearance="?attr/textAppearanceBodyMedium"
android:textColor="?android:attr/textColorSecondary" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>

<!-- Open FAQ -->
<com.google.android.material.card.MaterialCardView
style="?attr/materialCardViewFilledStyle"
android:id="@id/openFAQButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:layout_margin="8dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_margin="12dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="8dp"
android:src="@drawable/ic_fluent_question_circle_24_regular"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/open_faq_summary"
android:layout_gravity="center_vertical"
android:textAppearance="?attr/textAppearanceBodyMedium"
android:textColor="?android:attr/textColorSecondary" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/floating_receive_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="16dp"
android:src="@drawable/ic_fluent_mail_inbox_24_regular"
app:tint="?attr/colorOnPrimary"
app:backgroundTint="?attr/colorPrimary"/>
</LinearLayout>

</androidx.core.widget.NestedScrollView>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
3 changes: 2 additions & 1 deletion src/Resources/layout/activity_receive.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<include
android:layout_width="match_parent"
Expand Down
8 changes: 2 additions & 6 deletions src/Resources/layout/layout_appbar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:liftOnScroll="true"
android:fitsSystemWindows="true">

<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
style="@style/Widget.Material3.Toolbar.Surface"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:title="Nearby Sharing"
app:titleCentered="true"
app:subtitle="@string/app_titlebar_title_default"
app:subtitleCentered="true"
app:menu="@menu/menu_main" />
app:title="@string/app_name" />

</com.google.android.material.appbar.AppBarLayout>
15 changes: 3 additions & 12 deletions src/Resources/menu/menu_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,9 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<item
android:id="@+id/action_help"
android:icon="@drawable/ic_fluent_question_circle_24_regular"
android:title="@string/open_faq_title"
android:showAsAction="ifRoom" />
<item
android:id="@+id/action_sponsor"
android:icon="@drawable/ic_fluent_handshake_24_selector"
android:title="@string/open_sponsor_title"
android:showAsAction="ifRoom" />
<item
android:id="@+id/action_settings"
android:icon="@drawable/ic_fluent_settings_24_selector"
android:icon="@drawable/ic_fluent_settings_24_regular"
app:iconTint="?attr/colorOnSurface"
android:title="@string/generic_settings"
android:showAsAction="ifRoom" />
app:showAsAction="always" />
</menu>
Binary file added src/Resources/raw/animation_welcome.riv
Binary file not shown.
2 changes: 2 additions & 0 deletions src/Resources/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
<string name="request_permissions_title">Berechtigungen anfragen</string>
<string name="request_permissions_summary">Notwendige Berechtigungen erlauben</string>

<string name="request_enable_bluetooth">Bluetooth aktivieren</string>

<string name="open_sponsor_title">Sponsor</string>
<string name="open_sponsor_summary">Sponsor the app creator</string>

Expand Down
3 changes: 3 additions & 0 deletions src/Resources/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
<string name="request_permissions_title">Request Permissions</string>
<string name="request_permissions_summary">Grant necessary permissions to app</string>

<string name="request_enable_bluetooth">Enable Bluetooth</string>

<string name="open_sponsor_title">Sponsor</string>
<string name="open_sponsor_summary">Sponsor the app creator</string>

Expand All @@ -69,6 +71,7 @@
<string name="preference_cdp_title">Connected Devices Platform</string>
<string name="preference_cdp_summary">Setup sending and receiving</string>

<string name="open_setup">Setup Windows PC</string>
<string name="open_setup_title">PC Setup</string>
<string name="open_setup_summary">Tutorial about the necessary PC Settings</string>

Expand Down
33 changes: 23 additions & 10 deletions src/Resources/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
<resources>
<style name="AppTheme" parent="Theme.Material3.DayNight.NoActionBar">
<item name="dynamicColorThemeOverlay">@style/ThemeOverlay.Material3.DynamicColors.DayNight</item>
<item name="actionBarTheme">@style/ThemeOverlay.Material3.Dark.ActionBar</item>
<item name="preferenceTheme">@style/App.Preferences</item>
<item name="android:windowTranslucentStatus">true</item>

<!-- Title bar -->
<item name="elevationOverlayEnabled">false</item>

<!-- Status bar -->
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowLightStatusBar">?attr/isLightTheme</item>

<!-- Navigation bar -->
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:windowLightNavigationBar">?attr/isLightTheme</item>

<item name="preferenceTheme">@style/AppTheme.Preferences</item>
<item name="switchStyle">@style/Widget.Material3.CompoundButton.MaterialSwitch</item>
<item name="alertDialogTheme">@style/ThemeOverlay.Material3.MaterialAlertDialog</item>
<item name="dialogCornerRadius">28dp</item>
<item name="android:tint">?attr/colorOnSurface</item>
</style>

<style name="App.Preferences" parent="@style/PreferenceTheme.SettingsLib">
<item name="preferenceCategoryTitleTextAppearance">?attr/textAppearanceTitleSmall</item>
<item name="preferenceCategoryTitleTextColor">?attr/colorSecondary</item>
<item name="android:tint">?attr/colorPrimary</item>
</style>
<style name="AppTheme.Preferences" parent="@style/PreferenceTheme.SettingsLib" />

<style name="AppTheme.TranslucentOverlay" parent="AppTheme">
<item name="android:windowBackground">#80000000</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowNoTitle">true</item>
<item name="android:background">@android:color/transparent</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
</style>

</resources>
11 changes: 3 additions & 8 deletions src/UIHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ public static bool OnOptionsItemSelected(Activity activity, IMenuItem item)
{
switch (item.ItemId)
{
case Resource.Id.action_help:
OpenFAQ(activity);
return true;
case Resource.Id.action_sponsor:
OpenSponsor(activity);
return true;
case Resource.Id.action_settings:
activity.StartActivity(new Intent(activity, typeof(SettingsActivity)));
return true;
Expand Down Expand Up @@ -100,11 +94,12 @@ public static void ViewDownloads(this Activity activity)
activity.StartActivity(intent);
}

public static void SetupToolBar(AppCompatActivity activity, string? subtitle = null)
public static void SetupToolBar(AppCompatActivity activity, string? title = null)
{
var toolbar = activity.FindViewById<CompatToolbar>(Resource.Id.toolbar)!;
activity.SetSupportActionBar(toolbar);
activity.SupportActionBar!.Subtitle = subtitle;
if (title is not null)
activity.SupportActionBar!.Title = title;
}

#region Permissions
Expand Down

0 comments on commit 6ef5cc0

Please sign in to comment.