Skip to content

Commit

Permalink
Merge pull request #56 from NordicSemiconductor/develop
Browse files Browse the repository at this point in the history
Splash screen fixed
  • Loading branch information
philips77 authored Nov 4, 2021
2 parents 605a493 + 54bc7d6 commit 69d9917
Show file tree
Hide file tree
Showing 15 changed files with 892 additions and 119 deletions.
5 changes: 3 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ android {
}

dependencies {
implementation 'androidx.activity:activity:1.3.1'
implementation 'androidx.activity:activity:1.4.0'
implementation 'androidx.fragment:fragment:1.3.6'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel:2.3.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel:2.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.core:core-splashscreen:1.0.0-alpha02'

// Brings the new BluetoothLeScanner API to older platforms
implementation 'no.nordicsemi.android.support.v18:scanner:1.6.0'
Expand Down
20 changes: 14 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="true"/>
<uses-sdk tools:overrideLibrary="androidx.core.splashscreen"/>

<queries>
<!-- Allow logging in nRF Logger. -->
Expand All @@ -87,19 +88,26 @@
android:label="@string/app_name"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">

<activity
android:name=".SplashScreenActivity"
android:name=".ScannerActivity"
android:theme="@style/AppTheme.SplashScreen"
android:noHistory="true"
android:launchMode="singleTop"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".ScannerActivity"

<!--
This activity alias is used to allow opening nRF Blinky from nRF Toolbox.
This is not required if this feature is not desired.
nRF Toolbox is displaying a different name and an icon, which are taken from this alias.
-->
<activity-alias
android:name="SplashScreenActivity"
android:targetActivity=".ScannerActivity"
android:icon="@drawable/ic_blinky_feature"
android:label="@string/feature_name"
android:launchMode="singleTop"
Expand All @@ -108,13 +116,13 @@
<action android:name="android.intent.action.MAIN"/>
<category android:name="no.nordicsemi.android.nrftoolbox.LAUNCHER"/>
</intent-filter>
</activity>
</activity-alias>

<activity
android:name=".BlinkyActivity"
android:launchMode="singleTop"
android:parentActivityName=".ScannerActivity">
</activity>

</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import android.bluetooth.BluetoothAdapter;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.view.Menu;
Expand All @@ -40,6 +41,7 @@
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.splashscreen.SplashScreen;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
Expand All @@ -53,12 +55,44 @@
import no.nordicsemi.android.blinky.viewmodels.ScannerViewModel;

public class ScannerActivity extends AppCompatActivity implements DevicesAdapter.OnItemClickListener {
// This flag is false when the app is first started (cold start).
// In this case, the animation will be fully shown (1 sec).
// Subsequent launches will display it only briefly.
// It is only used on API 31+
public static boolean coldStart = true;

private ScannerViewModel scannerViewModel;
private ActivityScannerBinding binding;

@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Set up the splash screen.
// The app is using SplashScreen compat library, which is supported on Android 5+.
// On Android 12+ the splash screen will be animated, while on 5-11 will present a still
// image. See more: https://developer.android.com/guide/topics/ui/splash-screen/
//
// As nRF Blinky supports Android 4.3+, on older platforms a 9-patch image is presented
// without the use of SplashScreen compat library.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
final SplashScreen splashScreen = SplashScreen.installSplashScreen(this);

// Animated Vector Drawable is only supported on API 31+.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
if (coldStart) {
coldStart = false;
// Keep the splash screen on-screen for longer periods.
// Handle the splash screen transition.
final long then = System.currentTimeMillis();
splashScreen.setKeepVisibleCondition(() -> {
final long now = System.currentTimeMillis();
return now < then + 900;
});
}
}
}

binding = ActivityScannerBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());

Expand Down

This file was deleted.

103 changes: 103 additions & 0 deletions app/src/main/res/drawable-anydpi-v21/ic_splash_screen.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="142dp"
android:height="121dp"
android:viewportWidth="142.4"
android:viewportHeight="121.7">
<group
android:name="group"
android:pivotX="76"
android:pivotY="47"
android:scaleX="0.53"
android:scaleY="0.43">
<path
android:fillAlpha="0.6"
android:fillColor="@color/colorNordicLogo"
android:pathData="M82.9,0.4c0,0 -0.1,0 -0.1,0.1c-0.2,0.1 -0.3,0.2 -0.5,0.2L66.8,9.6l18,10.4V0C84.2,0 83.5,0.2 82.9,0.4z"
android:strokeAlpha="0.6" />
<path
android:fillAlpha="0.8"
android:fillColor="@color/colorNordicLogo"
android:pathData="M51.2,63.1l16.4,-9.5l-18,-10.4l0,20.3C50.1,63.6 50.6,63.4 51.2,63.1z"
android:strokeAlpha="0.8" />
<path
android:fillAlpha="0.5"
android:fillColor="@color/colorNordicLogo"
android:pathData="M103.2,52.5L66.3,31.2l0,0l-1.7,-1L31.3,10.9c-0.2,0.6 -0.4,1.2 -0.4,1.9c0,0.1 0,0.3 0,0.4v38.2c0,1.2 0.7,2.3 1.7,2.9l15.2,8.9c0.5,0.3 1.1,0.4 1.7,0.4l0,-19.5l0,-0.8L84,63.2c0.1,0.1 0.2,0.1 0.3,0.1c0,0 0.1,0 0.1,0c1,0.4 1.8,0.1 2.7,-0.5l5.8,-3.3l9.2,-5.5C102.6,53.7 103,53.1 103.2,52.5z"
android:strokeAlpha="0.5" />
<path
android:fillColor="@color/colorNordicLogo"
android:pathData="M103.4,27.3V12.8c0,-1.9 -1,-3.6 -2.6,-4.5L87.4,0.6C86.6,0.2 85.7,0 84.8,0v20.1L54.7,2.6l-3.4,-1.9c-1.5,-0.8 -2.8,-0.9 -4.3,-0.2c0,0 -0.1,0 -0.1,0.1c-0.2,0.1 -0.3,0.2 -0.5,0.3l-5.3,3.1l-7.6,4.4c0,0 0,0 0,0c-1,0.6 -1.8,1.5 -2.3,2.6c0,0 33.3,19.2 33.3,19.2l1.7,1l0,0l36.9,21.3c0.2,-0.7 0.2,-1.9 0.2,-1.9V27.3z" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M28.4,121.5h-1.7l-0.9,-5.8h0l-1.7,4.5H23l-1.7,-4.5h0l-0.9,5.8h-1.7l1.6,-9h1.2l2,5.1h0l2,-5.1h1.2L28.4,121.5z" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M21,106.1l-4.1,0L5,89.5h0l0,16.7l-4.4,0l0,-24.3l4.1,0l11.8,16.7h0l0,-16.7l4.4,0L21,106.1z" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M50.8,94c0,7.5 -5.5,12.7 -12.7,12.7c-7.2,0 -12.7,-5.1 -12.7,-12.7c0,-7.5 5.5,-12.7 12.7,-12.7C45.3,81.3 50.8,86.5 50.8,94zM30.3,94c0,4.8 3.3,8.1 7.8,8.1c4.6,0 7.8,-3.3 7.8,-8.1c0,-4.8 -3.3,-8.1 -7.8,-8.1C33.6,85.9 30.3,89.2 30.3,94z" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M61.7,96.4l-1.7,0l0,9.7l-4.4,0l0,-24.3l8.9,0c4.8,0 7.8,3 7.8,7.4c0,3.6 -2.1,6.3 -5.7,7l7.2,9.9l-5.6,0L61.7,96.4zM60.1,92.5l3.8,0c2.6,0 3.8,-1.2 3.8,-3.3c0,-2 -1.2,-3.3 -3.8,-3.3l-3.8,0L60.1,92.5z" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M98.1,94c0,7.6 -5.3,12.1 -12.6,12.1l-7.8,0l0,-24.3l7.8,0C92.8,81.8 98.1,86.4 98.1,94zM82.2,85.9l0,16.1l3.5,0c4.4,0 7.6,-2.8 7.6,-8s-3.3,-8 -7.6,-8L82.2,85.9z" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M107.3,106.1l-4.5,0l0,-24.3l4.5,0L107.3,106.1z" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M112.1,94c0,-7.7 5.4,-12.7 13.1,-12.7c3.7,0 6.5,1.1 8.7,2.7l-2.6,3.9c-1.5,-1 -3.5,-2 -6.1,-2c-4.7,0 -8.2,3.2 -8.2,8.1c0,5 3.5,8.1 8.2,8.1c2.6,0 4.6,-1 6.1,-2l2.6,3.9c-2.2,1.5 -4.9,2.7 -8.7,2.7C117.6,106.6 112.1,101.6 112.1,94z" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M0,120.8l0.7,-1.5c0.7,0.4 1.6,0.8 2.4,0.8c0.8,0 1.3,-0.4 1.3,-0.9c0,-0.5 -0.3,-0.8 -0.9,-1.2l-1.5,-1c-1,-0.7 -1.4,-1.4 -1.4,-2.4c0,-1.4 1,-2.3 2.7,-2.3c0.9,0 1.8,0.2 2.6,0.6l-0.7,1.5c-0.7,-0.3 -1.3,-0.6 -1.9,-0.6c-0.7,0 -0.9,0.3 -0.9,0.7c0,0.3 0.2,0.6 0.7,0.9l1.6,1.1c1,0.7 1.5,1.4 1.5,2.5c0,1.7 -1.2,2.6 -3.1,2.6C1.9,121.7 0.8,121.4 0,120.8" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M15.2,120l0,1.5l-5.4,0l0,-9l5.3,0l0,1.5l-3.7,0l0,1.8h3.4l0,1.5l-3.4,0l0,2.6H15.2z" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M33.7,121.5h-1.7l0,-9h1.7L33.7,121.5z" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M33.7,121.5H32l0,-9h1.7L33.7,121.5z" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M37.1,117c0,-2.8 2,-4.7 4.9,-4.7c1.4,0 2.4,0.4 3.2,1l-0.9,1.4c-0.6,-0.4 -1.3,-0.7 -2.3,-0.7c-1.7,0 -3,1.2 -3,3c0,1.8 1.3,3 3,3c1,0 1.7,-0.4 2.3,-0.7l0.9,1.4c-0.8,0.6 -1.8,1 -3.2,1C39.1,121.7 37.1,119.9 37.1,117z" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M57.3,117c0,2.8 -2,4.7 -4.7,4.7c-2.7,0 -4.7,-1.9 -4.7,-4.7s2,-4.7 4.7,-4.7C55.2,112.3 57.3,114.2 57.3,117zM49.7,117c0,1.8 1.2,3 2.9,3c1.7,0 2.9,-1.2 2.9,-3c0,-1.8 -1.2,-3 -2.9,-3C50.9,114 49.7,115.2 49.7,117z" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M68.3,121.5h-1.5l-4.4,-6.2h0l0,6.2h-1.6l0,-9h1.5l4.4,6.2h0l0,-6.2h1.6L68.3,121.5z" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M79.9,117c0,2.8 -2,4.5 -4.7,4.5l-2.9,0l0,-9l2.9,0C77.9,112.5 79.9,114.2 79.9,117zM74,114l0,6l1.3,0c1.6,0 2.8,-1 2.8,-3c0,-1.9 -1.2,-3 -2.8,-3H74z" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M90.7,117.9c0,2.3 -1.3,3.7 -3.7,3.7c-2.4,0 -3.7,-1.5 -3.7,-3.7l0,-5.4l1.7,0l0,5.3c0,1.3 0.8,2.1 2,2.1c1.2,0 2,-0.8 2,-2.1l0,-5.3l1.7,0L90.7,117.9z" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M94.1,117c0,-2.8 2,-4.7 4.9,-4.7c1.4,0 2.4,0.4 3.2,1l-0.9,1.4c-0.6,-0.4 -1.3,-0.7 -2.3,-0.7c-1.7,0 -3,1.2 -3,3c0,1.8 1.3,3 3,3c1,0 1.7,-0.4 2.3,-0.7l0.9,1.4c-0.8,0.6 -1.8,1 -3.2,1C96.2,121.7 94.1,119.8 94.1,117z" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M111.4,114H109l0,7.4l-1.6,0l0,-7.4l-2.5,0v-1.5l6.5,0V114z" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M123.4,117c0,2.8 -2,4.7 -4.7,4.7c-2.7,0 -4.7,-1.9 -4.7,-4.7c0,-2.8 2,-4.7 4.7,-4.7C121.3,112.3 123.4,114.2 123.4,117zM115.8,117c0,1.8 1.2,3 2.9,3c1.7,0 2.9,-1.2 2.9,-3c0,-1.8 -1.2,-3 -2.9,-3C117,114 115.8,115.2 115.8,117z" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M129,117.9h-0.6v3.6h-1.6l0,-9l3.3,0c1.8,0 2.9,1.1 2.9,2.7c0,1.3 -0.8,2.3 -2.1,2.6l2.7,3.7h-2.1L129,117.9zM128.4,116.5h1.4c0.9,0 1.4,-0.4 1.4,-1.2c0,-0.7 -0.4,-1.2 -1.4,-1.2h-1.4L128.4,116.5z" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M138.9,84.8v1.3h-0.2l0,-2.8l1.2,0c0.5,0 0.9,0.2 0.9,0.7c0,0.3 -0.1,0.6 -0.5,0.7c0.2,0.1 0.5,0.2 0.5,0.7v0.1c0,0.2 0,0.5 0,0.6h-0.3c0,-0.1 0,-0.4 0,-0.6v-0.1c0,-0.5 -0.2,-0.6 -0.7,-0.6H138.9zM138.9,84.6h0.9c0.5,0 0.7,-0.2 0.7,-0.6c0,-0.3 -0.3,-0.5 -0.7,-0.5h-0.9V84.6z" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M140.9,86.2h-0.4l0,-0.1c0,-0.1 0,-0.3 0,-0.5l0,-0.2c0,-0.4 -0.1,-0.5 -0.7,-0.5H139v1.3h-0.4v-3h1.3c0.6,0 1,0.3 1,0.8c0,0.3 -0.1,0.5 -0.4,0.7c0.2,0.1 0.3,0.4 0.3,0.7v0.1C140.8,85.7 140.8,86 140.9,86.2L140.9,86.2zM140.6,86h0.1c0,-0.1 0,-0.3 0,-0.5v-0.1c0,-0.5 -0.2,-0.6 -0.4,-0.6l-0.3,-0.1l0.3,-0.1c0.3,-0.1 0.5,-0.3 0.5,-0.6c0,-0.6 -0.6,-0.7 -0.9,-0.7h-1.2V86h0.1v-1.3h1c0.5,0 0.8,0.1 0.8,0.7l0,0.2C140.6,85.8 140.6,85.9 140.6,86zM139.8,84.7h-1v-1.2h1c0.7,0 0.8,0.3 0.8,0.6C140.6,84.5 140.3,84.7 139.8,84.7zM139,84.5l0.8,0c0.6,0 0.7,-0.3 0.7,-0.5c0,-0.1 0,-0.4 -0.7,-0.4H139V84.5z" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M139.7,87.3c-1.5,0 -2.7,-1.2 -2.7,-2.7c0,-1.5 1.2,-2.7 2.7,-2.7c1.5,0 2.7,1.2 2.7,2.7C142.3,86.1 141.1,87.3 139.7,87.3zM139.7,82.3c-1.3,0 -2.4,1.1 -2.4,2.4c0,1.3 1.1,2.4 2.4,2.4c1.3,0 2.4,-1.1 2.4,-2.4C142.1,83.3 141,82.3 139.7,82.3z" />
<path
android:fillColor="@color/colorNordicLogoText"
android:pathData="M139.7,87.4c-1.5,0 -2.7,-1.2 -2.7,-2.7c0,-1.5 1.2,-2.7 2.7,-2.7c1.5,0 2.7,1.2 2.7,2.7C142.4,86.2 141.2,87.4 139.7,87.4zM139.7,82.1c-1.4,0 -2.6,1.2 -2.6,2.6c0,1.4 1.2,2.6 2.6,2.6c1.4,0 2.6,-1.2 2.6,-2.6C142.2,83.2 141.1,82.1 139.7,82.1zM139.7,87.1c-1.4,0 -2.5,-1.1 -2.5,-2.5c0,-1.4 1.1,-2.5 2.5,-2.5c1.4,0 2.5,1.1 2.5,2.5C142.2,86 141,87.1 139.7,87.1zM139.7,82.3c-1.3,0 -2.3,1 -2.3,2.3c0,1.3 1,2.3 2.3,2.3c1.3,0 2.3,-1 2.3,-2.3S141,82.3 139.7,82.3z" />
</group>
</vector>
Loading

0 comments on commit 69d9917

Please sign in to comment.