Skip to content

Commit

Permalink
Update android splash screen for Android 12.0 (#510)
Browse files Browse the repository at this point in the history
* Add v31 Splash Screen

* Update GitTrends.Android.csproj

* Update GitTrends.Android.csproj

* Add splash_theme.xml

* Add `AndroidX.Core.SplashScreen.SplashScreen.InstallSplashScreen()`

* Fix GitTrendWhite

* Fix GitTrendWhite

* Update Splash Screen

* Fix Icon Sizes
  • Loading branch information
TheCodeTraveler authored Aug 13, 2022
1 parent 527857b commit 77d8fda
Show file tree
Hide file tree
Showing 22 changed files with 284 additions and 825 deletions.
Binary file modified Artwork/Icon.sketch
Binary file not shown.
813 changes: 132 additions & 681 deletions GitTrends.Android/GitTrends.Android.csproj

Large diffs are not rendered by default.

180 changes: 89 additions & 91 deletions GitTrends.Android/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,95 +14,93 @@

namespace GitTrends.Droid
{
[Activity(Label = "GitTrends", Exported = true, Icon = "@mipmap/icon", RoundIcon = "@mipmap/icon_round", Theme = "@style/LaunchTheme", LaunchMode = LaunchMode.SingleTop, MainLauncher = true, ScreenOrientation = ScreenOrientation.Portrait)]
[IntentFilter(new string[] { Intent.ActionView }, Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable }, DataSchemes = new[] { "gittrends" })]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults)
{
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);

this.ShinyOnRequestPermissionsResult(requestCode, permissions, grantResults);
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}

protected override void OnCreate(Bundle savedInstanceState)
{
this.ShinyOnCreate();

TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;

base.SetTheme(Resource.Style.MainTheme);
base.OnCreate(savedInstanceState);

Forms.Init(this, savedInstanceState);

var app = ContainerService.Container.Resolve<App>();
LoadApplication(app);

TryHandleOpenedFromUri(Intent?.Data);
TryHandleOpenedFromNotification(Intent);
}

protected override async void OnNewIntent(Intent intent)
{
base.OnNewIntent(intent);

if (intent?.Data is Android.Net.Uri callbackUri)
{
await AuthorizeGitHubSession(callbackUri).ConfigureAwait(false);
}

TryHandleOpenedFromNotification(intent);
}

static async Task AuthorizeGitHubSession(Android.Net.Uri callbackUri)
{
try
{
var gitHubAuthenticationService = ContainerService.Container.Resolve<GitHubAuthenticationService>();

await gitHubAuthenticationService.AuthorizeSession(new Uri(callbackUri.ToString()), CancellationToken.None).ConfigureAwait(false);
}
catch (Exception ex)
{
ContainerService.Container.Resolve<IAnalyticsService>().Report(ex);
}
}

async void TryHandleOpenedFromNotification(Intent? intent)
{
try
{
if (intent?.GetStringExtra("ShinyNotification") is string notificationString)
{
var notification = JsonConvert.DeserializeObject<Shiny.Notifications.Notification>(notificationString);

var analyticsService = ContainerService.Container.Resolve<IAnalyticsService>();
var notificationService = ContainerService.Container.Resolve<NotificationService>();

if (notification?.Title is string notificationTitle
&& notification?.Message is string notificationMessage
&& notification?.BadgeCount is int badgeCount
&& badgeCount > 0)
{
await notificationService.HandleNotification(notificationTitle, notificationMessage, badgeCount).ConfigureAwait(false);
}
}
}
catch (ObjectDisposedException)
{

}
}

async void TryHandleOpenedFromUri(Android.Net.Uri? callbackUri)
{
if (callbackUri != null)
{
await AuthorizeGitHubSession(callbackUri).ConfigureAwait(false);
}
}
}
[Activity(Label = "GitTrends", Exported = true, Icon = "@mipmap/icon", RoundIcon = "@mipmap/icon_round", Theme = "@style/LaunchTheme", LaunchMode = LaunchMode.SingleTop, MainLauncher = true, ScreenOrientation = ScreenOrientation.Portrait)]
[IntentFilter(new string[] { Intent.ActionView }, Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable }, DataSchemes = new[] { "gittrends" })]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults)
{
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);

this.ShinyOnRequestPermissionsResult(requestCode, permissions, grantResults);
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}

protected override void OnCreate(Bundle savedInstanceState)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;

base.SetTheme(Resource.Style.MainTheme);
base.OnCreate(savedInstanceState);

Forms.Init(this, savedInstanceState);

var app = ContainerService.Container.Resolve<App>();
LoadApplication(app);

TryHandleOpenedFromUri(Intent?.Data);
TryHandleOpenedFromNotification(Intent);
}

protected override async void OnNewIntent(Intent intent)
{
base.OnNewIntent(intent);

if (intent?.Data is Android.Net.Uri callbackUri)
{
await AuthorizeGitHubSession(callbackUri).ConfigureAwait(false);
}

TryHandleOpenedFromNotification(intent);
}

static async Task AuthorizeGitHubSession(Android.Net.Uri callbackUri)
{
try
{
var gitHubAuthenticationService = ContainerService.Container.Resolve<GitHubAuthenticationService>();

await gitHubAuthenticationService.AuthorizeSession(new Uri(callbackUri.ToString()), CancellationToken.None).ConfigureAwait(false);
}
catch (Exception ex)
{
ContainerService.Container.Resolve<IAnalyticsService>().Report(ex);
}
}

async void TryHandleOpenedFromNotification(Intent? intent)
{
try
{
if (intent?.GetStringExtra("ShinyNotification") is string notificationString)
{
var notification = JsonConvert.DeserializeObject<Shiny.Notifications.Notification>(notificationString);

var analyticsService = ContainerService.Container.Resolve<IAnalyticsService>();
var notificationService = ContainerService.Container.Resolve<NotificationService>();

if (notification?.Title is string notificationTitle
&& notification?.Message is string notificationMessage
&& notification?.BadgeCount is int badgeCount
&& badgeCount > 0)
{
await notificationService.HandleNotification(notificationTitle, notificationMessage, badgeCount).ConfigureAwait(false);
}
}
}
catch (ObjectDisposedException)
{

}
}

async void TryHandleOpenedFromUri(Android.Net.Uri? callbackUri)
{
if (callbackUri != null)
{
await AuthorizeGitHubSession(callbackUri).ConfigureAwait(false);
}
}
}
}
1 change: 1 addition & 0 deletions GitTrends.Android/MainApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public MainApplication(IntPtr handle, JniHandleOwnership transfer) : base(handle
public override void OnCreate()
{
this.ShinyOnCreate(new ShinyStartup(new DeviceNotificationsService_Android()));

base.OnCreate();

AndroidOptions.DefaultSmallIconResourceName = nameof(Resource.Drawable.icon);
Expand Down
2 changes: 1 addition & 1 deletion GitTrends.Android/Properties/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="55" android:versionName="2.5.1" package="com.minnick.gittrends" android:installLocation="auto">
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="31" />
<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="32" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<application android:label="GitTrends" android:fullBackupContent="@xml/auto_backup_rules">
<receiver android:name="com.google.firebase.iid.FirebaseInstanceIdInternalReceiver" android:exported="false" />
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/splash_screen_background" />
<foreground android:drawable="@drawable/splashscreenanimatedicon" />
</adaptive-icon>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 28 additions & 26 deletions GitTrends.Android/Resources/values-night/styles.xml
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MainTheme" parent="MainTheme.Base">
</style>
<!-- Base theme applied no matter what API -->
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette -->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#1E2423</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#121212</item>
<!-- colorAccent is used as the default value for colorControlActivated
<style name="MainTheme" parent="MainTheme.Base">
</style>
<!-- Base theme applied no matter what API -->
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette -->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#1E2423</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#121212</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#338F82</item>
<!-- You can also set colorControlNormal, colorControlActivated
<item name="colorAccent">#338F82</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal. -->
<item name="windowActionModeOverlay">true</item>
<item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#338F82</item>
</style>
<style name="LaunchTheme" parent="Theme.AppCompat">
<item name="android:windowBackground">@drawable/splash_screen</item>
<item name="android:windowNoTitle">true</item>
</style>
<item name="windowActionModeOverlay">true</item>
<item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#338F82</item>
</style>
<style name="LaunchTheme" parent="Theme.AppCompat">
<item name="android:windowBackground">@drawable/splash_screen</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowSplashScreenBackground">@color/splash_screen_background</item>
<item name="android:windowSplashScreenAnimatedIcon">@drawable/splashscreenanimatedicon</item>
</style>
</resources>
54 changes: 28 additions & 26 deletions GitTrends.Android/Resources/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MainTheme" parent="MainTheme.Base">
</style>
<!-- Base theme applied no matter what API -->
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette -->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#338F82</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#1C473D</item>
<!-- colorAccent is used as the default value for colorControlActivated
<style name="MainTheme" parent="MainTheme.Base">
</style>
<!-- Base theme applied no matter what API -->
<style name="MainTheme.Base" parent="Theme.AppCompat.Light.DarkActionBar">
<!--If you are using revision 22.1 please use just windowNoTitle. Without android:-->
<item name="windowNoTitle">true</item>
<!--We will be using the toolbar so no need to show ActionBar-->
<item name="windowActionBar">false</item>
<!-- Set theme colors from http://www.google.com/design/spec/style/color.html#color-color-palette -->
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">#338F82</item>
<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">#1C473D</item>
<!-- colorAccent is used as the default value for colorControlActivated
which is used to tint widgets -->
<item name="colorAccent">#338F82</item>
<!-- You can also set colorControlNormal, colorControlActivated
<item name="colorAccent">#338F82</item>
<!-- You can also set colorControlNormal, colorControlActivated
colorControlHighlight and colorSwitchThumbNormal. -->
<item name="windowActionModeOverlay">true</item>
<item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#F97B4F</item>
</style>
<style name="LaunchTheme" parent="Theme.AppCompat">
<item name="android:windowBackground">@drawable/splash_screen</item>
<item name="android:windowNoTitle">true</item>
</style>
<item name="windowActionModeOverlay">true</item>
<item name="android:datePickerDialogTheme">@style/AppCompatDialogStyle</item>
</style>
<style name="AppCompatDialogStyle" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#F97B4F</item>
</style>
<style name="LaunchTheme" parent="Theme.AppCompat">
<item name="android:windowBackground">@drawable/splash_screen</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowSplashScreenBackground">@color/splash_screen_background</item>
<item name="android:windowSplashScreenAnimatedIcon">@drawable/splashscreenanimatedicon</item>
</style>
</resources>

0 comments on commit 77d8fda

Please sign in to comment.