Merge tag '1.6.4.1'

This commit is contained in:
Martin Fietz 2017-10-24 21:01:36 +02:00
commit 717a1ec00e
9 changed files with 109 additions and 31 deletions

View File

@ -2,8 +2,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.danoeh.antennapod"
android:installLocation="auto"
android:versionCode="1060400"
android:versionName="1.6.4.0">
android:versionCode="1060401"
android:versionName="1.6.4.1">
<!--
Version code schema:
"1.2.3-SNAPSHOT" -> 1020300
@ -371,6 +371,16 @@
android:scheme="package"/>
</intent-filter>
</receiver>
<provider
android:authorities="de.danoeh.antennapod.provider"
android:name="android.support.v4.content.FileProvider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
<meta-data
android:name="de.danoeh.antennapod.core.glide.ApGlideModule"

View File

@ -24,7 +24,10 @@ public class OpmlImportFromIntentActivity extends OpmlImportBaseActivity {
if (uri != null && uri.toString().startsWith("/")) {
uri = Uri.parse("file://" + uri.toString());
} else {
uri = Uri.parse(getIntent().getStringExtra(Intent.EXTRA_TEXT));
String extraText = getIntent().getStringExtra(Intent.EXTRA_TEXT);
if(extraText != null) {
uri = Uri.parse(extraText);
}
}
importUri(uri);
}

View File

@ -116,6 +116,9 @@ public class ItunesSearchFragment extends Fragment {
//Show information about the podcast when the list item is clicked
gridView.setOnItemClickListener((parent, view1, position, id) -> {
Podcast podcast = searchResults.get(position);
if(podcast.feedUrl == null) {
return;
}
if (!podcast.feedUrl.contains("itunes.apple.com")) {
Intent intent = new Intent(getActivity(), OnlineFeedViewActivity.class);
intent.putExtra(OnlineFeedViewActivity.ARG_FEEDURL, podcast.feedUrl);

View File

@ -400,6 +400,9 @@ public class QueueFragment extends Fragment {
int from = viewHolder.getAdapterPosition();
int to = target.getAdapterPosition();
Log.d(TAG, "move(" + from + ", " + to + ")");
if(from >= queue.size() || to >= queue.size()) {
return false;
}
queue.add(to, queue.remove(from));
recyclerAdapter.notifyItemMoved(from, to);
DBWriter.moveQueueItem(from, to, true);

View File

@ -10,6 +10,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.net.Uri;
import android.net.wifi.WifiConfiguration;
@ -24,6 +25,7 @@ import android.preference.PreferenceScreen;
import android.support.design.widget.Snackbar;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.FileProvider;
import android.support.v7.app.AlertDialog;
import android.text.Editable;
import android.text.Html;
@ -59,6 +61,7 @@ import de.danoeh.antennapod.activity.PreferenceActivity;
import de.danoeh.antennapod.activity.PreferenceActivityGingerbread;
import de.danoeh.antennapod.activity.StatisticsActivity;
import de.danoeh.antennapod.asynctask.ExportWorker;
import de.danoeh.antennapod.core.BuildConfig;
import de.danoeh.antennapod.core.export.ExportWriter;
import de.danoeh.antennapod.core.export.html.HtmlWriter;
import de.danoeh.antennapod.core.export.opml.OpmlWriter;
@ -158,7 +161,7 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
public void onCreate() {
final Activity activity = ui.getActivity();
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
// disable expanded notification option on unsupported android versions
ui.findPreference(PreferenceController.PREF_EXPANDED_NOTIFICATION).setEnabled(false);
ui.findPreference(PreferenceController.PREF_EXPANDED_NOTIFICATION).setOnPreferenceClickListener(
@ -230,8 +233,12 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
.setOnPreferenceChangeListener(
(preference, newValue) -> {
Intent i = new Intent(activity, MainActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK
| Intent.FLAG_ACTIVITY_NEW_TASK);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK
| Intent.FLAG_ACTIVITY_NEW_TASK);
} else {
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
activity.finish();
activity.startActivity(i);
return true;
@ -441,14 +448,25 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
return true;
});
ui.findPreference(PREF_SEND_CRASH_REPORT).setOnPreferenceClickListener(preference -> {
Context context = ui.getActivity().getApplicationContext();
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setType("text/plain");
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"Martin.Fietz@gmail.com"});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "AntennaPod Crash Report");
emailIntent.putExtra(Intent.EXTRA_TEXT, "Please describe what you were doing when the app crashed");
// the attachment
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(CrashReportWriter.getFile()));
Uri fileUri = FileProvider.getUriForFile(context, "de.danoeh.antennapod.provider",
CrashReportWriter.getFile());
emailIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
emailIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
String intentTitle = ui.getActivity().getString(R.string.send_email);
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
List<ResolveInfo> resInfoList = context.getPackageManager().queryIntentActivities(emailIntent, PackageManager.MATCH_DEFAULT_ONLY);
for (ResolveInfo resolveInfo : resInfoList) {
String packageName = resolveInfo.activityInfo.packageName;
context.grantUriPermission(packageName, fileUri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
}
}
ui.getActivity().startActivity(Intent.createChooser(emailIntent, intentTitle));
return true;
});
@ -475,12 +493,21 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
String message = context.getString(R.string.opml_export_success_sum) + output.toString();
alert.setMessage(message);
alert.setPositiveButton(R.string.send_label, (dialog, which) -> {
Uri outputUri = Uri.fromFile(output);
Uri fileUri = FileProvider.getUriForFile(context.getApplicationContext(),
"de.danoeh.antennapod.provider", output);
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT,
context.getResources().getText(R.string.opml_export_label));
sendIntent.putExtra(Intent.EXTRA_STREAM, outputUri);
sendIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
sendIntent.setType("text/plain");
sendIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
List<ResolveInfo> resInfoList = context.getPackageManager().queryIntentActivities(sendIntent, PackageManager.MATCH_DEFAULT_ONLY);
for (ResolveInfo resolveInfo : resInfoList) {
String packageName = resolveInfo.activityInfo.packageName;
context.grantUriPermission(packageName, fileUri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
}
}
context.startActivity(Intent.createChooser(sendIntent,
context.getResources().getText(R.string.send_label)));
});

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
<external-path name="external_files" path="."/>
</paths>

View File

@ -20,6 +20,9 @@ public class MediaButtonReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "Received intent");
if (intent == null || intent.getExtras() == null) {
return;
}
KeyEvent event = (KeyEvent) intent.getExtras().get(Intent.EXTRA_KEY_EVENT);
if (event != null && event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount()==0) {
ClientConfig.initialize(context);

View File

@ -11,6 +11,7 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.media.MediaMetadataRetriever;
import android.os.Binder;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.support.annotation.NonNull;
@ -156,7 +157,7 @@ public class DownloadService extends Service {
private final IBinder mBinder = new LocalBinder();
public class LocalBinder extends Binder {
private class LocalBinder extends Binder {
public DownloadService getService() {
return DownloadService.this;
}
@ -345,8 +346,10 @@ public class DownloadService extends Service {
.setOngoing(true)
.setContentIntent(ClientConfig.downloadServiceCallbacks.getNotificationContentIntent(this))
.setLargeIcon(icon)
.setSmallIcon(R.drawable.stat_notify_sync)
.setVisibility(Notification.VISIBILITY_PUBLIC);
.setSmallIcon(R.drawable.stat_notify_sync);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
notificationCompatBuilder.setVisibility(Notification.VISIBILITY_PUBLIC);
}
Log.d(TAG, "Notification set up");
}
@ -498,7 +501,7 @@ public class DownloadService extends Service {
if (createReport) {
Log.d(TAG, "Creating report");
// create notification object
Notification notification = new NotificationCompat.Builder(this)
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setTicker(getString(R.string.download_report_title))
.setContentTitle(getString(R.string.download_report_content_title))
.setContentText(
@ -514,11 +517,12 @@ public class DownloadService extends Service {
.setContentIntent(
ClientConfig.downloadServiceCallbacks.getReportNotificationContentIntent(this)
)
.setAutoCancel(true)
.setVisibility(Notification.VISIBILITY_PUBLIC)
.build();
.setAutoCancel(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder.setVisibility(Notification.VISIBILITY_PUBLIC);
}
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(REPORT_ID, notification);
nm.notify(REPORT_ID, builder.build());
} else {
Log.d(TAG, "No report is created");
}
@ -562,11 +566,12 @@ public class DownloadService extends Service {
.setSmallIcon(R.drawable.ic_stat_authentication)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_stat_authentication))
.setAutoCancel(true)
.setContentIntent(ClientConfig.downloadServiceCallbacks.getAuthentificationNotificationContentIntent(DownloadService.this, downloadRequest))
.setVisibility(Notification.VISIBILITY_PUBLIC);
Notification n = builder.build();
.setContentIntent(ClientConfig.downloadServiceCallbacks.getAuthentificationNotificationContentIntent(DownloadService.this, downloadRequest));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
builder.setVisibility(Notification.VISIBILITY_PUBLIC);
}
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(downloadRequest.getSource().hashCode(), n);
nm.notify(downloadRequest.getSource().hashCode(), builder.build());
});
}
@ -595,7 +600,7 @@ public class DownloadService extends Service {
* Takes a single Feed, parses the corresponding file and refreshes
* information in the manager
*/
class FeedSyncThread extends Thread {
private class FeedSyncThread extends Thread {
private static final String TAG = "FeedSyncThread";
private BlockingQueue<DownloadRequest> completedRequests = new LinkedBlockingDeque<>();
@ -891,7 +896,7 @@ public class DownloadService extends Service {
}
}
public void submitCompletedDownload(DownloadRequest request) {
void submitCompletedDownload(DownloadRequest request) {
completedRequests.offer(request);
if (isCollectingRequests) {
interrupt();
@ -908,7 +913,7 @@ public class DownloadService extends Service {
* <p/>
* Currently, this handler only handles FeedMedia objects, because Feeds and FeedImages are deleted if the download fails.
*/
class FailedDownloadHandler implements Runnable {
private class FailedDownloadHandler implements Runnable {
private DownloadRequest request;
private DownloadStatus status;
@ -929,6 +934,9 @@ public class DownloadService extends Service {
if (dest.exists() && request.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) {
Log.d(TAG, "File has been partially downloaded. Writing file url");
FeedMedia media = DBReader.getFeedMedia(request.getFeedfileId());
if (media == null) {
return;
}
media.setFile_url(request.getDestination());
try {
DBWriter.setFeedMedia(media).get();
@ -945,13 +953,13 @@ public class DownloadService extends Service {
/**
* Handles a completed media download.
*/
class MediaHandlerThread implements Runnable {
private class MediaHandlerThread implements Runnable {
private DownloadRequest request;
private DownloadStatus status;
public MediaHandlerThread(@NonNull DownloadStatus status,
@NonNull DownloadRequest request) {
MediaHandlerThread(@NonNull DownloadStatus status,
@NonNull DownloadRequest request) {
this.status = status;
this.request = request;
}
@ -980,7 +988,7 @@ public class DownloadService extends Service {
Log.d(TAG, "Duration of file is " + media.getDuration());
} catch (NumberFormatException e) {
Log.d(TAG, "Invalid file duration: " + durationStr);
} catch(Exception e) {
} catch (Exception e) {
Log.e(TAG, "Get duration failed", e);
} finally {
mmr.release();
@ -1086,7 +1094,7 @@ public class DownloadService extends Service {
*/
@VisibleForTesting
public static void removeDuplicateImages(Feed feed) {
Set<String> known = new HashSet<String>();
Set<String> known = new HashSet<>();
for (FeedItem item : feed.getItems()) {
String url = item.hasItemImage() ? item.getImage().getDownload_url() : null;
if (url != null) {
@ -1123,6 +1131,6 @@ public class DownloadService extends Service {
}
lines.add(line.toString());
}
return StringUtils.join(lines, '\n');
return TextUtils.join("\n", lines);
}
}

View File

@ -3,13 +3,20 @@ package de.danoeh.antennapod.core.util;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Build;
import android.support.v4.content.FileProvider;
import android.util.Log;
import de.danoeh.antennapod.core.R;
import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.feed.FeedMedia;
import java.io.File;
import java.util.List;
/** Utility methods for sharing data */
public class ShareUtils {
@ -65,8 +72,18 @@ public class ShareUtils {
public static void shareFeedItemFile(Context context, FeedMedia media) {
Intent i = new Intent(Intent.ACTION_SEND);
i.setType(media.getMime_type());
i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(media.getLocalMediaUrl())));
Uri fileUri = FileProvider.getUriForFile(context, "de.danoeh.antennapod.provider",
new File(media.getLocalMediaUrl()));
i.putExtra(Intent.EXTRA_STREAM, fileUri);
i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
List<ResolveInfo> resInfoList = context.getPackageManager().queryIntentActivities(i, PackageManager.MATCH_DEFAULT_ONLY);
for (ResolveInfo resolveInfo : resInfoList) {
String packageName = resolveInfo.activityInfo.packageName;
context.grantUriPermission(packageName, fileUri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
}
}
context.startActivity(Intent.createChooser(i, context.getString(R.string.share_file_label)));
Log.e(TAG, "Foo");
}
}