Skip to content

Commit

Permalink
7.5.2: Fixed: workaround for annoyance with Android 7.0 shrinking
Browse files Browse the repository at this point in the history
context menus; Now using SDK25 to fix context menus issue; Workaround
for notifications in SDK25.
  • Loading branch information
Guillaume authored and Guillaume committed Aug 22, 2017
1 parent 86cea21 commit 7d16de1
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
2 changes: 1 addition & 1 deletion AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="nl.asymmetrics.droidshows"
android:versionCode="751" android:versionName="7.5.1">
android:versionCode="752" android:versionName="7.5.2">
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="11"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Expand Down
2 changes: 1 addition & 1 deletion project.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Project target.
target=android-19
target=android-25
9 changes: 9 additions & 0 deletions res/values-v24/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="ds">
<item name="android:contextPopupMenuStyle">@style/cp</item>
</style>
<style name="cp" parent="@android:style/Widget.Holo.PopupMenu">
<item name="android:overlapAnchor">true</item>
</style>
</resources>
30 changes: 26 additions & 4 deletions src/nl/asymmetrics/droidshows/DroidShows.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.channels.FileChannel;
Expand Down Expand Up @@ -49,6 +50,7 @@
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Looper;
Expand Down Expand Up @@ -1186,14 +1188,34 @@ public void onClick(DialogInterface dialog, int which) {
}
}

@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
private void errorNotify(String error) {
NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
PendingIntent appIntent = PendingIntent.getActivity(DroidShows.this, 0, new Intent(), 0);
Notification notification = new Notification(R.drawable.noposter,
getString(R.string.messages_thetvdb_con_error), System.currentTimeMillis());
notification.setLatestEventInfo(getApplicationContext(), getString(R.string.messages_thetvdb_con_error),
error, appIntent);

Notification notification = null;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
notification = new Notification(R.drawable.noposter,
getString(R.string.messages_thetvdb_con_error), System.currentTimeMillis());
try {
Method deprecatedMethod = notification.getClass().getMethod("setLatestEventInfo", Context.class, CharSequence.class, CharSequence.class, PendingIntent.class);
deprecatedMethod.invoke(notification, getApplicationContext(), getString(R.string.messages_thetvdb_con_error), error, appIntent);
} catch (Exception e) {
Log.e(SQLiteStore.TAG, "Method setLatestEventInfo not found", e);
}
} else {
Notification.Builder builder = new Notification.Builder(getApplicationContext())
.setContentIntent(appIntent)
.setSmallIcon(R.drawable.noposter)
.setContentTitle(getString(R.string.messages_thetvdb_con_error))
.setContentText(error);
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
notification = builder.getNotification();
else
notification = builder.build();
}

notification.flags |= Notification.FLAG_AUTO_CANCEL;
mNotificationManager.notify(0, notification);
}
Expand Down

0 comments on commit 7d16de1

Please sign in to comment.