Skip to content

Commit

Permalink
Merge pull request #70 from Z3r0byte/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Z3r0byte committed Nov 12, 2017
2 parents 20a5d69 + d1e2de9 commit bd94eec
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 16 deletions.
15 changes: 1 addition & 14 deletions .idea/misc.xml

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

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ android {
applicationId "com.z3r0byte.magis"
minSdkVersion 15
targetSdkVersion 24
versionCode 163
versionName "1.6.3"
versionCode 164
versionName "1.6.4"
}
buildTypes {
release {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_LOGS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
<uses-permission android:name="com.android.vending.BILLING" />


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@

package com.z3r0byte.magis.Services;

import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.media.AudioManager;
import android.os.Build;
import android.os.IBinder;
import android.support.v4.app.TaskStackBuilder;
import android.support.v7.app.NotificationCompat;
import android.util.Log;

import com.mikepenz.google_material_typeface_library.GoogleMaterial;
import com.mikepenz.iconics.IconicsDrawable;
import com.z3r0byte.magis.CalendarActivity;
import com.z3r0byte.magis.R;
import com.z3r0byte.magis.Utils.ConfigUtil;
import com.z3r0byte.magis.Utils.DB_Handlers.CalendarDB;

Expand Down Expand Up @@ -65,6 +72,31 @@ private void setup() {
TimerTask notificationTask = new TimerTask() {
@Override
public void run() {
NotificationManager notificationManager =
(NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
&& !notificationManager.isNotificationPolicyAccessGranted()) {
Log.w(TAG, "run: Not allowed to change state of do not disturb!");
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getApplicationContext());
mBuilder.setSmallIcon(R.drawable.magis512);

Intent resultIntent = new Intent(android.provider.Settings
.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(getApplicationContext());
stackBuilder.addParentStack(CalendarActivity.class);
stackBuilder.addNextIntent(resultIntent);
PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
mBuilder.setContentIntent(resultPendingIntent);

mBuilder.setContentTitle("Magis kan de telefoon niet op stil zetten");
mBuilder.setContentText("Klik om op te lossen");
mBuilder.setAutoCancel(true);
mBuilder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);

NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(9999, mBuilder.build());
return;
}
appointments = calendarDB.getSilentAppointments(getMargin());
if (doSilent(appointments)) {
silenced(true);
Expand Down

0 comments on commit bd94eec

Please sign in to comment.