Skip to content

Commit

Permalink
Update to API 34
Browse files Browse the repository at this point in the history
  • Loading branch information
AguilarLagunasArturo committed Jul 28, 2024
1 parent 17159fd commit bbc6d3e
Show file tree
Hide file tree
Showing 23 changed files with 297 additions and 195 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions BlueDino/Arduino_bluetooth_controller_BlueDuino/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 30
buildToolsVersion '28.0.3'
compileSdk 34
buildToolsVersion '34.0.0'

defaultConfig {
applicationId "aal.arduino_bluetooth_controller_blueduino"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "0.1.0"
targetSdkVersion 34
versionCode 2
versionName "1.0.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
namespace 'aal.arduino_bluetooth_controller_blueduino'
}

dependencies {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="aal.arduino_bluetooth_controller_blueduino">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE"/>


<application
android:allowBackup="true"
Expand All @@ -15,6 +18,7 @@
android:theme="@style/AppTheme">
<activity
android:name=".BluetoothConnection"
android:exported="true"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -24,6 +28,7 @@
</activity>
<activity
android:name=".Devices"
android:exported="false"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar">
Expand All @@ -35,6 +40,7 @@
</activity>
<activity
android:name=".Mode"
android:exported="false"
android:label="@string/title_activity_mode"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar">
Expand All @@ -46,6 +52,7 @@
</activity>
<activity
android:name=".Terminal"
android:exported="false"
android:label="@string/title_activity_terminal"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"
Expand All @@ -58,6 +65,7 @@
</activity>
<activity
android:name=".Analog"
android:exported="false"
android:label="@string/title_activity_analog"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar">
Expand All @@ -69,6 +77,7 @@
</activity>
<activity
android:name=".Digital"
android:exported="false"
android:label="@string/title_activity_digital"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar">
Expand All @@ -80,6 +89,7 @@
</activity>
<activity
android:name=".Joystick"
android:exported="false"
android:label="@string/title_activity_joystick"
android:screenOrientation="sensorLandscape"
android:theme="@style/AppTheme.NoActionBar">
Expand All @@ -91,6 +101,7 @@
</activity>
<activity
android:name=".JoystickConfigure"
android:exported="false"
android:label="@string/title_activity_joystick_configure"
android:screenOrientation="portrait"
android:theme="@style/AppTheme.NoActionBar"
Expand All @@ -103,6 +114,7 @@
</activity>
<activity
android:name=".GlobalSettings"
android:exported="false"
android:label="@string/title_activity_global_settings"
android:screenOrientation="portrait">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ private void show_about_alert(){
AlertDialog.Builder alert_builder = new AlertDialog.Builder(Analog.this);
View alert_about_view = Analog.this.getLayoutInflater().inflate(R.layout.alert_about, null);

String version = BuildConfig.VERSION_NAME;
String version = ""; // BuildConfig.VERSION_NAME;
String[] developers = getResources().getStringArray(R.array.developers);
String[] translators = getResources().getStringArray(R.array.translators);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,46 @@
package aal.arduino_bluetooth_controller_blueduino;

import android.Manifest;
import android.bluetooth.BluetoothAdapter;
import android.content.Intent;

import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.core.app.ActivityCompat;
import androidx.preference.PreferenceManager;

import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

@RequiresApi(api = Build.VERSION_CODES.S)
public class BluetoothConnection extends AppCompatActivity {
private String TAG = "BluetoothConnection";

// ** Variables **
BluetoothAdapter bt;
private static final int REQUEST_CODE_PERMISSIONS = 1001;
private static final String[] REQUIRED_PERMISSIONS = {
Manifest.permission.BLUETOOTH,
Manifest.permission.BLUETOOTH_ADMIN,
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION,
Manifest.permission.BLUETOOTH_CONNECT,
Manifest.permission.BLUETOOTH_SCAN,
Manifest.permission.BLUETOOTH_ADVERTISE
};

@Override
protected void onCreate(Bundle savedInstanceState) {
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("theme", false)){
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean("theme", false)) {
AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_YES
);
}else{
} else {
AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_NO
);
Expand All @@ -34,8 +51,36 @@ protected void onCreate(Bundle savedInstanceState) {

setTitle(R.string.title_activity_bluetooth_connection);
setContentView(R.layout.activity_bluetooth_connection);
bt = BluetoothAdapter.getDefaultAdapter();
try_to_enable_bt();

if (allPermissionsGranted(REQUIRED_PERMISSIONS)) {
open(Devices.class);
} else {
ActivityCompat.requestPermissions(this, REQUIRED_PERMISSIONS, REQUEST_CODE_PERMISSIONS);
}

}

private boolean allPermissionsGranted(String[] permissions) {
for (String permission : permissions) {
if (ActivityCompat.checkSelfPermission(this, permission) != PackageManager.PERMISSION_GRANTED) {
return false;
}
}
return true;
}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);

if (requestCode == REQUEST_CODE_PERMISSIONS) {
if (allPermissionsGranted(REQUIRED_PERMISSIONS)) {
open(Devices.class);
} else {
Toast.makeText(BluetoothConnection.this, R.string.bt_not_granted, Toast.LENGTH_SHORT).show();
BluetoothConnection.this.finish();
}
}
}

@Override
Expand All @@ -56,38 +101,6 @@ protected void onPause() {
Log.d(TAG, "===============APP IN FOREGROUND===============");
}

// ** Enable bluetooth **
public static int BLUETOOTH_ENABLED = 1;
private void try_to_enable_bt() {
if (bt == null){
Log.d(TAG, "Device unable to use bluetooth");
Toast.makeText(BluetoothConnection.this, R.string.bt_unable, Toast.LENGTH_SHORT).show();
this.finish();
}else if (bt.isEnabled()){
Log.d(TAG, "Bluetooth enabled.");
open(Devices.class);
}else{
Log.d(TAG, "Needs to enable bluetooth.");
Intent enable_bt = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enable_bt, BLUETOOTH_ENABLED);
}
}

// ** Ensure that user enabled bluetooth **
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == BLUETOOTH_ENABLED){
if (resultCode == RESULT_OK) {
Log.d(TAG, "User: OK");
open(Devices.class);
} else if (resultCode == RESULT_CANCELED){
Log.d(TAG, "User: CANCELED");
BluetoothConnection.this.finish();
}
}
}

// ** This opens activities **
private void open(Class target){
Intent go = new Intent(BluetoothConnection.this, target);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ private void show_about_alert(){
AlertDialog.Builder alert_builder = new AlertDialog.Builder(Devices.this);
View alert_about_view = Devices.this.getLayoutInflater().inflate(R.layout.alert_about, null);

String version = BuildConfig.VERSION_NAME;
String version = ""; // BuildConfig.VERSION_NAME;
String[] developers = getResources().getStringArray(R.array.developers);
String[] translators = getResources().getStringArray(R.array.translators);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ private void show_about_alert(){
AlertDialog.Builder alert_builder = new AlertDialog.Builder(Digital.this);
View alert_about_view = Digital.this.getLayoutInflater().inflate(R.layout.alert_about, null);

String version = BuildConfig.VERSION_NAME;
String version = ""; // BuildConfig.VERSION_NAME;
String[] developers = getResources().getStringArray(R.array.developers);
String[] translators = getResources().getStringArray(R.array.translators);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ private void show_about_alert(){
AlertDialog.Builder alert_builder = new AlertDialog.Builder(Joystick.this);
View alert_about_view = Joystick.this.getLayoutInflater().inflate(R.layout.alert_about, null);

String version = BuildConfig.VERSION_NAME;
String version = ""; // BuildConfig.VERSION_NAME;
String[] developers = getResources().getStringArray(R.array.developers);
String[] translators = getResources().getStringArray(R.array.translators);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private void show_about_alert(){
AlertDialog.Builder alert_builder = new AlertDialog.Builder(JoystickConfigure.this);
View alert_about_view = JoystickConfigure.this.getLayoutInflater().inflate(R.layout.alert_about, null);

String version = BuildConfig.VERSION_NAME;
String version = ""; // BuildConfig.VERSION_NAME;
String[] developers = getResources().getStringArray(R.array.developers);
String[] translators = getResources().getStringArray(R.array.translators);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private void show_about_alert(){
AlertDialog.Builder alert_builder = new AlertDialog.Builder(Mode.this);
View alert_about_view = Mode.this.getLayoutInflater().inflate(R.layout.alert_about, null);

String version = BuildConfig.VERSION_NAME;
String version = ""; // BuildConfig.VERSION_NAME;
String[] developers = getResources().getStringArray(R.array.developers);
String[] translators = getResources().getStringArray(R.array.translators);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ private void show_about_alert(){
AlertDialog.Builder alert_builder = new AlertDialog.Builder(Terminal.this);
View alert_about_view = Terminal.this.getLayoutInflater().inflate(R.layout.alert_about, null);

String version = BuildConfig.VERSION_NAME;
String version = ""; // BuildConfig.VERSION_NAME;
String[] developers = getResources().getStringArray(R.array.developers);
String[] translators = getResources().getStringArray(R.array.translators);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<!-- BluetoothConnection.java -->
<string name="title_activity_bluetooth_connection">BlueDuino</string> <!-- No modificar -->
<string name="bt_unable">Tu dispositivo no puede usar bluetooth</string>
<string name="bt_not_granted">Permisos bluetooth no fueron otorgados</string>

<!-- Mode.java -->
<string name="title_activity_mode">Selecciona un modo</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<!-- BluetoothConnection.java -->
<string name="title_activity_bluetooth_connection">BlueDuino</string> <!-- No modificar -->
<string name="bt_unable">Votre diapositifs ne peut pas utiliser Bluetooth</string>
<string name="bt_not_granted">Les autorisations Bluetooth n\'ont pas été accordées</string>

<!-- Mode.java -->
<string name="title_activity_mode">Sélectionner un mode</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<!-- BluetoothConnection.java -->
<string name="title_activity_bluetooth_connection">BlueDuino</string> <!-- No modificar -->
<string name="bt_unable">Device unable to use bluetooth</string>
<string name="bt_not_granted">Device bluetooth permissions not granted</string>

<!-- Mode.java -->
<string name="title_activity_mode">Choose a mode</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath 'com.android.tools.build:gradle:8.5.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.defaults.buildfeatures.buildconfig=true
android.enableJetifier=true
android.nonFinalResIds=false
android.nonTransitiveRClass=false
android.useAndroidX=true
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Fri Apr 17 16:20:41 CDT 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
Loading

0 comments on commit bbc6d3e

Please sign in to comment.