Skip to content

Commit

Permalink
Version 3.22.3
Browse files Browse the repository at this point in the history
- Update out of date jQuery library.
- Added preference for resetting to default subreddit.
- Changed mail check service to JobIntentService to comply with new
  background task restrictions in Android.
- Fixed "unknown activity" exception for unknown app urls.
  • Loading branch information
micwallace committed Jan 5, 2020
1 parent 5492749 commit 24b2e70
Show file tree
Hide file tree
Showing 15 changed files with 88 additions and 48 deletions.
7 changes: 4 additions & 3 deletions reddinator/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="au.com.wallaceit.reddinator"
android:versionCode="66"
android:versionName="3.22.2">
android:versionCode="67"
android:versionName="3.22.3">

<uses-permission android:name="android.permission.INTERNET" />
<!-- Needed by some activity_webview HTML5 video implementations (Bug report received for Android 4.1) -->
Expand Down Expand Up @@ -125,7 +125,8 @@
android:permission="android.permission.BIND_REMOTEVIEWS" />
<service
android:name=".service.MailCheckService"
android:enabled="true" />
android:enabled="true"
android:permission="android.permission.BIND_JOB_SERVICE" />

<receiver
android:name=".service.WidgetProvider"
Expand Down
2 changes: 1 addition & 1 deletion reddinator/src/main/assets/account.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<link href="file:///android_asset/css/font-awesome.min.css" rel="stylesheet">
<link href="file:///android_asset/css/reddit-markdown.css" rel="stylesheet">
<link href="file:///android_asset/css/core.css" rel="stylesheet">
<script src="file:///android_asset/js/jquery-2.1.3.min.js"></script>
<script src="file:///android_asset/js/jquery-2.2.4.min.js"></script>
<script src="file:///android_asset/js/prosemirror.js"></script>
<script src="file:///android_asset/js/common.js"></script>
<script src="file:///android_asset/js/account.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions reddinator/src/main/assets/comments.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
<link href="file:///android_asset/css/font-awesome.min.css" rel="stylesheet">
<link href="file:///android_asset/css/reddit-markdown.css" rel="stylesheet">
<link href="file:///android_asset/css/core.css" rel="stylesheet">
<script src="file:///android_asset/js/jquery-2.1.3.min.js"></script>
<script src="file:///android_asset/js/jquery-2.2.4.min.js"></script>
<script src="file:///android_asset/js/prosemirror.js"></script>
<script src="file:///android_asset/js/common.js"></script>
<script src="file:///android_asset/js/comments.js"></script>
<!--<link href="css/font-awesome.min.css" rel="stylesheet">
<link href="css/reddit-markdown.css" rel="stylesheet">
<link href="css/core.css" rel="stylesheet">
<script src="js/jquery-2.1.3.min.js"></script>
<script src="js/jquery-2.2.4.min.js"></script>
<script src="js/prosemirror.js"></script>
<script src="js/common.js"></script>
<script src="js/comments.js"></script>-->
Expand Down
2 changes: 1 addition & 1 deletion reddinator/src/main/assets/comments_context.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<link href="file:///android_asset/css/font-awesome.min.css" rel="stylesheet">
<link href="file:///android_asset/css/reddit-markdown.css" rel="stylesheet">
<link href="file:///android_asset/css/core.css" rel="stylesheet">
<script src="file:///android_asset/js/jquery-2.1.3.min.js"></script>
<script src="file:///android_asset/js/jquery-2.2.4.min.js"></script>
<script src="file:///android_asset/js/prosemirror.js"></script>
<script src="file:///android_asset/js/common.js"></script>
<script src="file:///android_asset/js/comments.js"></script>
Expand Down
4 changes: 4 additions & 0 deletions reddinator/src/main/assets/js/jquery-2.2.4.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion reddinator/src/main/assets/js/prosemirror-test.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<html>
<head>
<meta charset="UTF-8">
<script src="jquery-2.1.3.min.js"></script>
<script src="jquery-2.2.4.min.js"></script>
<style type="text/css">
.ProseMirror {
border: 1px solid #999999;
Expand Down
2 changes: 1 addition & 1 deletion reddinator/src/main/assets/messages.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<link href="file:///android_asset/css/font-awesome.min.css" rel="stylesheet">
<link href="file:///android_asset/css/reddit-markdown.css" rel="stylesheet">
<link href="file:///android_asset/css/core.css" rel="stylesheet">
<script src="file:///android_asset/js/jquery-2.1.3.min.js"></script>
<script src="file:///android_asset/js/jquery-2.2.4.min.js"></script>
<script src="file:///android_asset/js/prosemirror.js"></script>
<script src="file:///android_asset/js/common.js"></script>
<script src="file:///android_asset/js/account.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,15 @@ public void onItemClick(AdapterView<?> parent, View view,
String url = subData.has("url") ? subData.getString("url") : null;
global.getSubredditManager().setFeedSubreddit(mAppWidgetId, subreddit, url);

if (!userSelSort) {
String path = global.getSubredditManager().getCurrentFeedPath(mAppWidgetId);
// Only reset sort if:
// 1. current sort is best and the subreddit isn't the front page. OR
// 2. The reset sort preference is enabled and the user hasn't specified a sort.
String path = global.getSubredditManager().getCurrentFeedPath(mAppWidgetId);
String curSort = mSharedPreferences.getString("sort-" + (mAppWidgetId == 0 ? "app" : mAppWidgetId), "");

if (("best".equals(curSort) && !path.equals("") && !path.equals("/default")) ||
(!userSelSort && mSharedPreferences.getBoolean("resetsortpref", false))) {

String sort = (path.equals("") || path.equals("/default") ? "best" : "hot");
global.mSharedPreferences.edit().putString("sort-" + (mAppWidgetId == 0 ? "app" : mAppWidgetId), sort).apply();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.AsyncTask;
import android.os.IBinder;
import android.support.annotation.NonNull;
import android.support.v4.app.JobIntentService;
import android.support.v4.app.NotificationCompat;

import org.json.JSONArray;
Expand All @@ -36,17 +36,18 @@
import au.com.wallaceit.reddinator.activity.MessagesActivity;
import au.com.wallaceit.reddinator.core.RedditData;

public class MailCheckService extends Service {
public class MailCheckService extends JobIntentService {
public static String MAIL_CHECK_COMPLETE = "reddinator.mail.check.complete";
public static String ACTIVITY_CHECK_ACTION = "reddinator.mail.check";
public static String NOTIFY_CHECK_ACTION = "reddinator.mail.check.notify";
private Reddinator global;
private String action;
public static final int JOB_ID = 1;

public static void checkMail(Context context, String action){
Intent intent = new Intent(context, MailCheckService.class);
intent.setAction(action);
context.startService(intent);

MailCheckService.enqueueWork(context, MailCheckService.class, JOB_ID, intent);
}

@Override
Expand All @@ -55,16 +56,25 @@ public void onCreate(){
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
action = intent.getAction();
protected void onHandleWork(@NonNull Intent intent) {
String action = intent.getAction();
if (global.mRedditData.isLoggedIn())
if (action.equals(ACTIVITY_CHECK_ACTION) || action.equals(NOTIFY_CHECK_ACTION)) {
(new MailCheckTask()).execute();
if (ACTIVITY_CHECK_ACTION.equals(action) || NOTIFY_CHECK_ACTION.equals(action)) {
(new MailCheckTask(global, action)).execute();
}
return START_NOT_STICKY;
}

private class MailCheckTask extends AsyncTask<String, Void, Boolean> {
private static class MailCheckTask extends AsyncTask<String, Void, Boolean> {

Reddinator global;
String action;

MailCheckTask(Reddinator global, String action){
super();

this.global = global;
this.action = action;
}

@Override
protected Boolean doInBackground(String... params) {
Expand Down Expand Up @@ -97,33 +107,28 @@ protected void onPostExecute(Boolean result){
if (action.equals(ACTIVITY_CHECK_ACTION)) {
// notify activity
Intent bIntent = new Intent(MAIL_CHECK_COMPLETE);
sendBroadcast(bIntent);
global.sendBroadcast(bIntent);
} else {
// show notification
if (global.mRedditData.getInboxCount()>0) setNotification();
}
}
}

private void setNotification(){
int nummessages = global.mRedditData.getInboxCount();
Intent notifyIntent = new Intent(this, MessagesActivity.class);
notifyIntent.setAction(MessagesActivity.ACTION_UNREAD);
Notification notification = new NotificationCompat.Builder(this)
.setContentTitle(getResources().getQuantityString(R.plurals.new_messages, nummessages, nummessages))
.setContentText(getResources().getString(R.string.new_messages_text))
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.reddinator_logo))
.setSmallIcon(R.drawable.ic_notify)
.setContentIntent(PendingIntent.getActivity(this, 0 ,notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT))
.build();

NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(1, notification);
}
private void setNotification(){
int nummessages = global.mRedditData.getInboxCount();
Intent notifyIntent = new Intent(global, MessagesActivity.class);
notifyIntent.setAction(MessagesActivity.ACTION_UNREAD);
Notification notification = new NotificationCompat.Builder(global)
.setContentTitle(global.getResources().getQuantityString(R.plurals.new_messages, nummessages, nummessages))
.setContentText(global.getResources().getString(R.string.new_messages_text))
.setLargeIcon(BitmapFactory.decodeResource(global.getResources(), R.drawable.reddinator_logo))
.setSmallIcon(R.drawable.ic_notify)
.setContentIntent(PendingIntent.getActivity(global, 0 ,notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT))
.build();

@Override
public IBinder onBind(Intent intent) {
return null;
NotificationManager notificationManager = (NotificationManager) global.getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(1, notification);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class SyncUserDataTask extends AsyncTask<String, String, Boolean> {
private Context context;
private Runnable callback;
private boolean showUI;
private ProgressDialog progressDialog;
private ProgressDialog progressDialog = null;
private int mode;

public SyncUserDataTask(Context context, Runnable callback, boolean showUI, int mode){
Expand Down Expand Up @@ -87,7 +87,8 @@ protected void onProgressUpdate(String... statusText){
@Override
protected void onPostExecute(Boolean result) {
if (showUI) {
progressDialog.dismiss();
if (progressDialog != null)
progressDialog.dismiss();
if (!result){
// check login required
if (exception.isAuthError()) global.mRedditData.initiateLogin(context, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
mActivity = this.getActivity();
mActivity.getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
ll = (LinearLayout) inflater.inflate(R.layout.webtab, container, false);
mWebView = (WebView) ll.findViewById(R.id.webView1);
mWebView = ll.findViewById(R.id.webView1);
// fixes for activity_webview not taking keyboard input on some devices
mWebView.getSettings().setLoadWithOverviewMode(true);
mWebView.getSettings().setUseWideViewPort(true);
Expand Down Expand Up @@ -154,8 +154,13 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
return false;
}

// handle app urls; prevents 404 page displaying for unknown schemas
view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
// handle app urls; prevents 404 page displaying for unknown schemas.
// catch activity not found exceptions
try {
view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
} catch (Exception ignored){
// no op
}

return true;
}
Expand Down Expand Up @@ -242,7 +247,7 @@ public void onShowCustomView(View view, CustomViewCallback callback) {
((Activity) mContext).getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
mVideoFrame.setVisibility(View.VISIBLE);
// add view to root layout
rootLayout = (LinearLayout) ((Activity) mContext).findViewById(R.id.contentview);
rootLayout = ((Activity) mContext).findViewById(R.id.contentview);
rootLayout.addView(mVideoFrame);
// get main content view and hide
mTabcontainer = ((Activity) mContext).findViewById(R.id.sliding_layout);
Expand Down
2 changes: 2 additions & 0 deletions reddinator/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -333,4 +333,6 @@
<string name="download_nativeui_title">Mostrar Descargas</string>
<string name="download_notify_complete_summary">Mostrar notificación para las descargas completadas</string>
<string name="download_notify_complete_title">Notificación completada</string>
<string name="reset_sort_title">Restablecer ordenación</string>
<string name="reset_sort_summary">Restablecer la ordenación predeterminada al cambiar subreddit</string>
</resources>
3 changes: 3 additions & 0 deletions reddinator/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -392,4 +392,7 @@
<string name="download_nativeui_summary">Show completed in the \"downloads\" app</string>
<string name="download_notify_complete_title">Completed Notification</string>
<string name="download_notify_complete_summary">Show notification for completed downloads</string>
<string name="reset_sort_pref" translatable="false">resetsortpref</string>
<string name="reset_sort_title">Reset sorting</string>
<string name="reset_sort_summary">Reset to default sorting when changing subreddit</string>
</resources>
6 changes: 6 additions & 0 deletions reddinator/src/main/res/xml/changelog_master.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<changelog>
<release version="3.22.3" versioncode="67">
<change>Update out of date jQuery library.</change>
<change>Added preference for resetting to default subreddit.</change>
<change>Changed mail check service to JobIntentService to comply with new background task restrictions in Android.</change>
<change>Fixed "unknown activity" exception for unknown app urls.</change>
</release>
<release version="3.22.2" versioncode="66">
<change>Updated logo (snoo was removed because it is now a reddit trademark).</change>
<change>Added subscribe/unsubscribe functionality to subreddit feed menus.</change>
Expand Down
6 changes: 6 additions & 0 deletions reddinator/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
android:entryValues="@array/reddit_item_load"
android:dialogTitle="@string/num_item_load_pref_summary" />

<CheckBoxPreference
android:key="@string/reset_sort_pref"
android:title="@string/reset_sort_title"
android:defaultValue="false"
android:summary="@string/reset_sort_summary" />

<CheckBoxPreference
android:key="@string/filter_duplicates_pref"
android:title="@string/feed_filter_duplicates_title"
Expand Down

0 comments on commit 24b2e70

Please sign in to comment.