Skip to content

Commit

Permalink
Fixed bugs with Toast in setAlarms() method,
Browse files Browse the repository at this point in the history
changed icon for settings button
  • Loading branch information
Djonique committed Nov 13, 2017
1 parent 2becdaf commit a897ade
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
</receiver>

<!-- BirdaysWidget -->
<receiver
<!--<receiver
android:name=".widget.BirdaysWidget"
android:label="@string/app_name">
<intent-filter>
Expand All @@ -126,6 +126,6 @@
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/widget" />
</receiver>
</receiver>-->
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void onClick(DialogInterface dialog, int which) {
@OnClick(R.id.button_help_whitelist)
void openBatteryOptimization() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
startActivity(new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS));
startActivity(Intent.createChooser(new Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS), null));
} else {
Toast.makeText(this, R.string.help_whitelist_error, Toast.LENGTH_LONG).show();
}
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/java/com/djonique/birdays/alarm/AlarmHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.djonique.birdays.alarm;

import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
Expand Down Expand Up @@ -59,7 +60,14 @@ public void setAlarms(Person person) {
setAdditionalAlarm(person);
}
} catch (SecurityException e) {
Toast.makeText(context, R.string.security_exception, Toast.LENGTH_LONG).show();
if (context instanceof Activity) {
((Activity) context).runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(context, R.string.security_exception, Toast.LENGTH_LONG).show();
}
});
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

import com.djonique.birdays.R;
import com.djonique.birdays.database.DbHelper;
import com.djonique.birdays.models.Person;

Expand All @@ -39,7 +41,11 @@ public void onReceive(Context context, Intent intent) {
persons.addAll(dbHelper.query().getPersons());

for (Person person : persons) {
alarmHelper.setAlarms(person);
try {
alarmHelper.setAlarms(person);
} catch (SecurityException e) {
Toast.makeText(context, R.string.security_exception, Toast.LENGTH_LONG).show();
}
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_settings_white_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FFF"
android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98s-0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.12,-0.22 -0.39,-0.3 -0.61,-0.22l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.23,-0.09 -0.49,0 -0.61,0.22l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98s0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.12,0.22 0.39,0.3 0.61,0.22l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.23,0.09 0.49,0 0.61,-0.22l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM12,15.5c-1.93,0 -3.5,-1.57 -3.5,-3.5s1.57,-3.5 3.5,-3.5 3.5,1.57 3.5,3.5 -1.57,3.5 -3.5,3.5z" />
</vector>
3 changes: 2 additions & 1 deletion app/src/main/res/menu/menu_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
app:showAsAction="never" />-->
<item
android:id="@+id/action_settings"
android:icon="@drawable/ic_settings_white_24dp"
android:orderInCategory="99"
android:title="@string/action_settings"
app:showAsAction="never" />
app:showAsAction="always" />
</menu>

0 comments on commit a897ade

Please sign in to comment.