Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle update to 8.2.1 #6

Merged
merged 3 commits into from
Jul 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up our JDK environment
uses: actions/[email protected]
with:
java-version: 1.8
java-version: 17

- name: Build all artifacts
id: buildAllApks
Expand Down
25 changes: 21 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 16
buildToolsVersion "26.0.2"
compileSdkVersion 33
namespace 'de.ubuntix.android.birthdayreminder'

defaultConfig {
applicationId "de.ubuntix.android.birthdayreminder"
minSdkVersion 7
targetSdkVersion 16
versionCode 9
versionName "1.0.0"

minSdkVersion 14
targetSdkVersion 33
}

buildTypes {
Expand All @@ -16,4 +19,18 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}

lint {
disable 'Instantiatable'
}
}

allprojects {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation"
}
}

dependencies {
implementation 'androidx.preference:preference:1.2.0'
}
13 changes: 6 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.ubuntix.android.birthdayreminder"
android:versionCode="9"
android:versionName="1.0.0">
package="de.ubuntix.android.birthdayreminder">

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
Expand All @@ -13,21 +12,21 @@
android:label="@string/app_name">
<activity
android:name=".BirthdayReminder"
android:label="@string/app_name">
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=".BirthdayEditor"
android:label="@string/app_name"/>
android:name=".BirthdayEditor" />
<activity
android:name=".PreferenceWindow"
android:label="@string/preferences_name"/>

<receiver android:name=".service.BirthdayBroadcastReceiver">
<receiver android:name=".service.BirthdayBroadcastReceiver"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package de.ubuntix.android.birthdayreminder;

import android.Manifest;
import android.annotation.SuppressLint;
import android.app.ListActivity;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.Toast;

import java.text.DateFormatSymbols;
import java.util.Calendar;
Expand All @@ -34,6 +38,7 @@ public class BirthdayReminder extends ListActivity {
// TODO: call/write message on birthday
// TODO: hideNotificationPref

private static final int PERMISSIONS_REQUEST_WRITE_CONTACTS = 1;
private final DateFormatSymbols dateSymbols = new DateFormatSymbols();

private Database db;
Expand All @@ -53,13 +58,41 @@ public void onCreate(Bundle savedInstanceState) {
if (prefs.getActivateService()) {
BirthdayBroadcastReceiver.restart(getApplicationContext());
}

// request runtime permission
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (!isContactsPermissionGranted()) {
requestPermissions(new String[]{Manifest.permission.WRITE_CONTACTS}, PERMISSIONS_REQUEST_WRITE_CONTACTS);
}
}
}

private boolean isContactsPermissionGranted() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return true;
}

return checkSelfPermission(Manifest.permission.WRITE_CONTACTS) == PackageManager.PERMISSION_GRANTED;
}

@Override
protected void onResume() {
super.onResume();

updateView();
if (isContactsPermissionGranted()) {
updateView();
}
}

@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (requestCode == PERMISSIONS_REQUEST_WRITE_CONTACTS) {
if (isContactsPermissionGranted()) {
updateView();
} else {
Toast.makeText(this, R.string.no_contacts_permission, Toast.LENGTH_LONG).show();
}
}
}

private void updateView() {
Expand Down Expand Up @@ -121,22 +154,24 @@ protected void onListItemClick(ListView l, View v, int position, long id) {
@SuppressLint("ResourceType")
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.layout.menu, menu);
inflater.inflate(R.menu.menu, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.preferences:
startActivity(new Intent(this, PreferenceWindow.class));
return true;
case R.id.quit:
finish();
return true;
default:
return super.onOptionsItemSelected(item);
int itemId = item.getItemId();

if (itemId == R.id.preferences) {
startActivity(new Intent(this, PreferenceWindow.class));
return true;
}
if (itemId == R.id.quit) {
finish();
return true;
}

return super.onOptionsItemSelected(item);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
package de.ubuntix.android.birthdayreminder.service;

import java.sql.Time;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.SortedMap;
import java.util.TreeMap;

import android.app.AlarmManager;
import android.app.Notification;
import android.app.NotificationManager;
Expand All @@ -15,6 +8,14 @@
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;

import java.sql.Time;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.SortedMap;
import java.util.TreeMap;

import de.ubuntix.android.birthdayreminder.BirthdayReminder;
import de.ubuntix.android.birthdayreminder.R;
import de.ubuntix.android.birthdayreminder.database.Database;
Expand All @@ -41,7 +42,7 @@ public void onReceive(Context context, Intent intent) {
private static PendingIntent createPendingIntent(Context context) {
Intent intent = new Intent(context, BirthdayBroadcastReceiver.class);
intent.putExtra(TIMED, true);
return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_IMMUTABLE);
}

public static void start(Context context) {
Expand Down Expand Up @@ -126,15 +127,23 @@ private void notifyBirthdays(Context context) {

// create new notification
if (notificationTexts.size() > 0) {
String titleText = String.format(res.getQuantityString(R.plurals.notificationTitle, countBirthdays),
countBirthdays);
String titleText = String.format(res.getQuantityString(R.plurals.notificationTitle, countBirthdays), countBirthdays);

Intent intent = new Intent(context, BirthdayReminder.class);
Notification notification = new Notification(R.drawable.balloons, titleText, System.currentTimeMillis());
PendingIntent pi = PendingIntent.getActivity(
context, 0, intent, PendingIntent.FLAG_IMMUTABLE);

Notification.Builder builder = new Notification.Builder(context);

builder.setContentIntent(pi);
builder.setSmallIcon(R.drawable.balloons);
builder.setTicker(titleText);
builder.setContentText(StringUtils.join(notificationTexts, ", "));

if (countBirthdays > 1) {
notification.number = countBirthdays;
builder.setNumber(countBirthdays);
}
PendingIntent pi = PendingIntent.getActivity(context, 0, intent, Intent.FLAG_ACTIVITY_NEW_TASK);
notification.setLatestEventInfo(context, titleText, StringUtils.join(notificationTexts, ", "), pi);
Notification notification = builder.getNotification();
notificationManager.notify(0, notification);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_width="match_parent"
android:layout_height="match_parent">

<item
android:id="@+id/preferences"
Expand All @@ -17,4 +17,4 @@
android:icon="@android:drawable/ic_menu_close_clear_cancel"
android:title="@string/quit"/>

</menu>
</menu>
3 changes: 2 additions & 1 deletion app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
<string name="ok">OK</string>
<string name="cancel">Abbrechen</string>
<string name="editor_phone">Telefon</string>
<string name="no_contacts_permission">Keine Berechtigung zum Lesen und Ändern von Kontakten</string>

</resources>
</resources>
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
<string name="add_date_of_birth">add date of birth</string>
<string name="new_birthday">+</string>
<string name="editor_phone">Phone</string>
<string name="no_contacts_permission">No permission to read and write contacts</string>

</resources>
</resources>
8 changes: 5 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:8.0.2'
}
}

allprojects {
repositories {
jcenter()
google()
mavenCentral()
}
}
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
org.gradle.jvmargs=-Xmx1536M
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sat Oct 14 09:48:46 CEST 2017
#Sun Jul 16 07:55:26 CEST 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Loading