Skip to content

Commit

Permalink
Merge pull request #55 from NordicSemiconductor/develop
Browse files Browse the repository at this point in the history
Version 2.6.0
  • Loading branch information
philips77 authored Oct 7, 2021
2 parents 2f3a06b + 3ca0704 commit 4fb8437
Show file tree
Hide file tree
Showing 32 changed files with 798 additions and 292 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/deploy-to-play-store.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Deploy to Play Store Internal
on:
workflow_dispatch:
jobs:
deployAabToGooglePlayInternal:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- shell: bash
env:
# The following env variables are used by signing configuration in sample/build.gradle
KEYSTORE_ALIAS: ${{ secrets.KEYSTORE_ALIAS }}
KEYSTORE_KEY_PSWD: ${{ secrets.KEYSTORE_KEY_PSWD }}
KEYSTORE_PSWD: ${{ secrets.KEYSTORE_PSWD }}
# The script decodes keystore (required by sample/build.gradle) and fastlane-api.json
# needed by fastlane (see fastlane/Appfile).
run: |
echo "${{ secrets.KEYSTORE_FILE }}" > keystore.asc
gpg -d --passphrase "${{ secrets.KEYSTORE_FILE_PSWD }}" --batch keystore.asc > keystore
echo "${{ secrets.API_KEY_FILE }}" > fastlane-api.json.asc
gpg -d --passphrase "${{ secrets.API_KEY_FILE_PSWD }}" --batch fastlane-api.json.asc > fastlane-api.json
fastlane deployInternal
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source "https://rubygems.org"

gem "fastlane"
58 changes: 31 additions & 27 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
apply plugin: 'com.android.application'
apply from: rootProject.file("gradle/git-tag-version.gradle")

android {
compileSdkVersion 29
buildToolsVersion '29.0.3'
compileSdkVersion 31

defaultConfig {
applicationId "no.nordicsemi.android.nrfblinky"
minSdkVersion 18
targetSdkVersion 29
versionCode 14
versionName "2.5.1"
targetSdkVersion 31
versionCode getVersionCodeFromTags()
versionName getVersionNameFromTags()
resConfigs "en"

vectorDrawables.useSupportLibrary = true
}

signingConfigs {
release {
storeFile file('../keystore')
storePassword System.env.KEYSTORE_PSWD
keyAlias System.env.KEYSTORE_ALIAS
keyPassword System.env.KEYSTORE_KEY_PSWD
}
}

buildFeatures {
viewBinding true
}

buildTypes {
debug {
minifyEnabled false
Expand All @@ -23,35 +36,26 @@ android {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}

compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.2.0-alpha06'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.activity:activity:1.3.1'
implementation 'androidx.fragment:fragment:1.3.6'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta6'
// Lifecycle extensions
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
// Butter Knife
implementation 'com.jakewharton:butterknife:10.2.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel:2.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'com.google.android.material:material:1.4.0'

// Brings the new BluetoothLeScanner API to older platforms
implementation 'no.nordicsemi.android.support.v18:scanner:1.4.3'
//implementation project(":scanner")
implementation 'no.nordicsemi.android.support.v18:scanner:1.6.0'

// Log Bluetooth LE events in nRF Logger
implementation 'no.nordicsemi.android:log:2.2.0'
implementation 'no.nordicsemi.android:log:2.3.0'

// BLE library
implementation 'no.nordicsemi.android:ble-livedata:2.2.0'
// To add BLE Library as a module, replace the above dependency with the following
// and uncomment 2 lines in settings.gradle file.
// implementation project(":ble-livedata")
implementation 'no.nordicsemi.android:ble-livedata:2.3.1'
}
58 changes: 52 additions & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,59 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="no.nordicsemi.android.LOG"/>
<!--
Bluetooth permission is required on Android 4.3 - 11 in order to communicate with
Bluetooth LE devices.
-->
<uses-permission
android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30"/>
<!--
Bluetooth Admin permission is required on Android 4.3 - 11 in order to scan for
Bluetooth LE devices.
-->
<uses-permission
android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30"/>
<!--
Location permission is required from Android 6 to 11 to be able to scan for advertising
Bluetooth LE devices. Some BLE devices, called beacons, may be used to position the phone.
This is to ensure that the user agrees to do so.
This app does not use this location information in any way.
Since Android 10 ACCESS_FINE_LOCATION is required and for that, the COARSE one also needs
to be specified.
-->
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"
android:maxSdkVersion="30"/>
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"
android:maxSdkVersion="30"/>
<!--
On Android 12 new set of Bluetooth permissions were added. BLUETOOTH_SCAN permission is
needed to scan for Bluetooth LE devices. The "never for location" flag is set, as we are not
interested in finding the user location, and we are OK with the fact, that beacons info
will be removed from the scan results.
-->
<uses-permission
android:name="android.permission.BLUETOOTH_SCAN"
android:usesPermissionFlags="neverForLocation"
tools:targetApi="s" />
<!--
This permission is required in order to connect to a Bluetooth LE device on Android 12
onwards.
-->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="true"/>

<queries>
<!-- Allow logging in nRF Logger. -->
<package android:name="no.nordicsemi.android.log" />
</queries>

<application
android:name=".BlinkyApplication"
android:allowBackup="true"
Expand All @@ -47,7 +91,8 @@
android:name=".SplashScreenActivity"
android:theme="@style/AppTheme.SplashScreen"
android:noHistory="true"
android:launchMode="singleTop">
android:launchMode="singleTop"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand All @@ -57,7 +102,8 @@
android:name=".ScannerActivity"
android:icon="@drawable/ic_blinky_feature"
android:label="@string/feature_name"
android:launchMode="singleTop">
android:launchMode="singleTop"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="no.nordicsemi.android.nrftoolbox.LAUNCHER"/>
Expand Down
72 changes: 30 additions & 42 deletions app/src/main/java/no/nordicsemi/android/blinky/BlinkyActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,35 @@
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.ViewModelProvider;

import com.google.android.material.appbar.MaterialToolbar;
import com.google.android.material.switchmaterial.SwitchMaterial;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.ViewModelProvider;
import no.nordicsemi.android.ble.livedata.state.ConnectionState;
import no.nordicsemi.android.ble.observer.ConnectionObserver;
import no.nordicsemi.android.blinky.adapter.DiscoveredBluetoothDevice;
import no.nordicsemi.android.blinky.databinding.ActivityBlinkyBinding;
import no.nordicsemi.android.blinky.viewmodels.BlinkyViewModel;

@SuppressWarnings("ConstantConditions")
public class BlinkyActivity extends AppCompatActivity {
public static final String EXTRA_DEVICE = "no.nordicsemi.android.blinky.EXTRA_DEVICE";

private BlinkyViewModel viewModel;

@BindView(R.id.led_switch) SwitchMaterial led;
@BindView(R.id.button_state) TextView buttonState;
private ActivityBlinkyBinding binding;

@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_blinky);
ButterKnife.bind(this);
binding = ActivityBlinkyBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());

final Intent intent = getIntent();
final DiscoveredBluetoothDevice device = intent.getParcelableExtra(EXTRA_DEVICE);
final String deviceName = device.getName();
final String deviceAddress = device.getAddress();

final MaterialToolbar toolbar = findViewById(R.id.toolbar);
final MaterialToolbar toolbar = binding.toolbar;
toolbar.setTitle(deviceName != null ? deviceName : getString(R.string.unknown_device));
toolbar.setSubtitle(deviceAddress);
setSupportActionBar(toolbar);
Expand All @@ -72,34 +64,35 @@ protected void onCreate(final Bundle savedInstanceState) {
viewModel.connect(device);

// Set up views.
final TextView ledState = findViewById(R.id.led_state);
final LinearLayout progressContainer = findViewById(R.id.progress_container);
final TextView connectionState = findViewById(R.id.connection_state);
final View content = findViewById(R.id.device_container);
final View notSupported = findViewById(R.id.not_supported);
binding.ledSwitch.setOnCheckedChangeListener((buttonView, isChecked) -> viewModel.setLedState(isChecked));
binding.infoNotSupported.actionRetry.setOnClickListener(v -> viewModel.reconnect());
binding.infoTimeout.actionRetry.setOnClickListener(v -> viewModel.reconnect());

led.setOnCheckedChangeListener((buttonView, isChecked) -> viewModel.setLedState(isChecked));
viewModel.getConnectionState().observe(this, state -> {
switch (state.getState()) {
case CONNECTING:
progressContainer.setVisibility(View.VISIBLE);
notSupported.setVisibility(View.GONE);
connectionState.setText(R.string.state_connecting);
binding.progressContainer.setVisibility(View.VISIBLE);
binding.infoNotSupported.container.setVisibility(View.GONE);
binding.infoTimeout.container.setVisibility(View.GONE);
binding.connectionState.setText(R.string.state_connecting);
break;
case INITIALIZING:
connectionState.setText(R.string.state_initializing);
binding.connectionState.setText(R.string.state_initializing);
break;
case READY:
progressContainer.setVisibility(View.GONE);
content.setVisibility(View.VISIBLE);
binding.progressContainer.setVisibility(View.GONE);
binding.deviceContainer.setVisibility(View.VISIBLE);
onConnectionStateChanged(true);
break;
case DISCONNECTED:
if (state instanceof ConnectionState.Disconnected) {
binding.deviceContainer.setVisibility(View.GONE);
binding.progressContainer.setVisibility(View.GONE);
final ConnectionState.Disconnected stateWithReason = (ConnectionState.Disconnected) state;
if (stateWithReason.isNotSupported()) {
progressContainer.setVisibility(View.GONE);
notSupported.setVisibility(View.VISIBLE);
if (stateWithReason.getReason() == ConnectionObserver.REASON_NOT_SUPPORTED) {
binding.infoNotSupported.container.setVisibility(View.VISIBLE);
} else {
binding.infoTimeout.container.setVisibility(View.VISIBLE);
}
}
// fallthrough
Expand All @@ -109,24 +102,19 @@ protected void onCreate(final Bundle savedInstanceState) {
}
});
viewModel.getLedState().observe(this, isOn -> {
ledState.setText(isOn ? R.string.turn_on : R.string.turn_off);
led.setChecked(isOn);
binding.ledState.setText(isOn ? R.string.turn_on : R.string.turn_off);
binding.ledSwitch.setChecked(isOn);
});
viewModel.getButtonState().observe(this,
pressed -> buttonState.setText(pressed ?
pressed -> binding.buttonState.setText(pressed ?
R.string.button_pressed : R.string.button_released));
}

@OnClick(R.id.action_clear_cache)
public void onTryAgainClicked() {
viewModel.reconnect();
}

private void onConnectionStateChanged(final boolean connected) {
led.setEnabled(connected);
binding.ledSwitch.setEnabled(connected);
if (!connected) {
led.setChecked(false);
buttonState.setText(R.string.button_unknown);
binding.ledSwitch.setChecked(false);
binding.buttonState.setText(R.string.button_unknown);
}
}
}
Loading

0 comments on commit 4fb8437

Please sign in to comment.