From 1fd53de5ee59fa540e1ca985eee983854fff04a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Eisfeld?= Date: Fri, 24 Mar 2023 11:13:34 +0100 Subject: [PATCH] Upgrade to targetSdk 33 --- LifxTools/app/build.gradle | 10 ++++----- LifxTools/app/src/main/AndroidManifest.xml | 2 +- .../de/jeisfeld/lifx/app/MainActivity.java | 21 +++++++++++++++---- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/LifxTools/app/build.gradle b/LifxTools/app/build.gradle index 7a589fe..086a8e2 100644 --- a/LifxTools/app/build.gradle +++ b/LifxTools/app/build.gradle @@ -6,8 +6,8 @@ android { defaultConfig { applicationId "de.jeisfeld.lifx.app" minSdkVersion 24 - targetSdkVersion 31 - versionCode 26 + targetSdkVersion 33 + versionCode 27 versionName "0.4.17" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } @@ -29,13 +29,13 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'androidx.appcompat:appcompat:1.6.0' + implementation 'androidx.appcompat:appcompat:1.6.1' implementation 'com.google.android.material:material:1.8.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.navigation:navigation-fragment:2.5.3' implementation 'androidx.navigation:navigation-ui:2.5.3' - implementation 'androidx.fragment:fragment:1.5.5' + implementation 'androidx.fragment:fragment:1.5.6' implementation 'androidx.preference:preference:1.2.0' - implementation 'androidx.recyclerview:recyclerview:1.2.1' + implementation 'androidx.recyclerview:recyclerview:1.3.0' implementation 'com.github.skydoves:colorpickerview:2.2.1' } diff --git a/LifxTools/app/src/main/AndroidManifest.xml b/LifxTools/app/src/main/AndroidManifest.xml index b1394f8..e4b6f22 100644 --- a/LifxTools/app/src/main/AndroidManifest.xml +++ b/LifxTools/app/src/main/AndroidManifest.xml @@ -9,6 +9,7 @@ + diff --git a/LifxTools/app/src/main/java/de/jeisfeld/lifx/app/MainActivity.java b/LifxTools/app/src/main/java/de/jeisfeld/lifx/app/MainActivity.java index f73fa21..de8ea7c 100644 --- a/LifxTools/app/src/main/java/de/jeisfeld/lifx/app/MainActivity.java +++ b/LifxTools/app/src/main/java/de/jeisfeld/lifx/app/MainActivity.java @@ -1,8 +1,11 @@ package de.jeisfeld.lifx.app; +import android.Manifest.permission; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; import android.net.wifi.WifiManager; +import android.os.Build; import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; import android.os.Bundle; @@ -15,6 +18,8 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatDelegate; import androidx.appcompat.widget.Toolbar; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; import androidx.drawerlayout.widget.DrawerLayout; import androidx.navigation.NavController; import androidx.navigation.Navigation; @@ -27,6 +32,10 @@ * The main activity of the app. */ public class MainActivity extends AppCompatActivity { + /** + * The request code used to query for permission. + */ + protected static final int REQUEST_CODE_PERMISSION = 1; /** * The resource key for the navigation page. */ @@ -76,6 +85,12 @@ protected final void onCreate(final Bundle savedInstanceState) { navController.navigate(navigationPageId); } + if (Build.VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) { + if (ContextCompat.checkSelfPermission(this, permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) { + ActivityCompat.requestPermissions(this, new String[]{permission.POST_NOTIFICATIONS}, REQUEST_CODE_PERMISSION); + } + } + WifiManager wifiManager = (WifiManager) this.getApplicationContext().getSystemService(Context.WIFI_SERVICE); if (wifiManager != null && !wifiManager.isWifiEnabled()) { if (VERSION.SDK_INT >= VERSION_CODES.Q) { @@ -96,14 +111,12 @@ public final boolean onCreateOptionsMenu(final Menu menu) { @Override public final boolean onOptionsItemSelected(final MenuItem item) { - switch (item.getItemId()) { - case R.id.action_refresh: + if (item.getItemId() == R.id.action_refresh) { finish(); startActivity(new Intent(this, MainActivity.class)); return true; - default: - return super.onOptionsItemSelected(item); } + return super.onOptionsItemSelected(item); } @Override