Skip to content

Commit

Permalink
Upgrade to targetSdk 33
Browse files Browse the repository at this point in the history
  • Loading branch information
jeisfeld committed Mar 27, 2023
1 parent 653d890 commit 1fd53de
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
10 changes: 5 additions & 5 deletions LifxTools/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -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'
}
2 changes: 1 addition & 1 deletion LifxTools/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<application
android:name="de.jeisfeld.lifx.app.Application"
Expand All @@ -23,7 +24,6 @@
<activity
android:name="de.jeisfeld.lifx.app.MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
21 changes: 17 additions & 4 deletions LifxTools/app/src/main/java/de/jeisfeld/lifx/app/MainActivity.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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.
*/
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down

0 comments on commit 1fd53de

Please sign in to comment.