diff --git a/News-Android-App/src/main/java/com/bumptech/glide/samples/svg/SvgDecoder.java b/News-Android-App/src/main/java/com/bumptech/glide/samples/svg/SvgDecoder.java deleted file mode 100644 index 5dbe506c9..000000000 --- a/News-Android-App/src/main/java/com/bumptech/glide/samples/svg/SvgDecoder.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.bumptech.glide.samples.svg; - -import static com.bumptech.glide.request.target.Target.SIZE_ORIGINAL; - -import androidx.annotation.NonNull; - -import com.bumptech.glide.load.Options; -import com.bumptech.glide.load.ResourceDecoder; -import com.bumptech.glide.load.engine.Resource; -import com.bumptech.glide.load.resource.SimpleResource; -import com.caverock.androidsvg.SVG; -import com.caverock.androidsvg.SVGParseException; - -import java.io.IOException; -import java.io.InputStream; - -/** - * Decodes an SVG internal representation from an {@link InputStream}. - */ -public class SvgDecoder implements ResourceDecoder { - - @Override - public boolean handles(@NonNull InputStream source, @NonNull Options options) { - return true; - } - - public Resource decode(@NonNull InputStream source, int width, int height, @NonNull Options options) - throws IOException { - try { - SVG svg = SVG.getFromInputStream(source); - if (width != SIZE_ORIGINAL) { - svg.setDocumentWidth(width); - } - if (height != SIZE_ORIGINAL) { - svg.setDocumentHeight(height); - } - return new SimpleResource<>(svg); - } catch (SVGParseException ex) { - throw new IOException("Cannot load SVG from stream", ex); - } - } -} \ No newline at end of file diff --git a/News-Android-App/src/main/java/com/bumptech/glide/samples/svg/SvgDecoder.kt b/News-Android-App/src/main/java/com/bumptech/glide/samples/svg/SvgDecoder.kt new file mode 100644 index 000000000..59033b278 --- /dev/null +++ b/News-Android-App/src/main/java/com/bumptech/glide/samples/svg/SvgDecoder.kt @@ -0,0 +1,44 @@ +package com.bumptech.glide.samples.svg + +import com.bumptech.glide.load.Options +import com.bumptech.glide.load.ResourceDecoder +import com.bumptech.glide.load.engine.Resource +import com.bumptech.glide.load.resource.SimpleResource +import com.bumptech.glide.request.target.Target +import com.caverock.androidsvg.SVG +import com.caverock.androidsvg.SVGParseException +import java.io.IOException +import java.io.InputStream + +/** + * Decodes an SVG internal representation from an [InputStream]. + */ +class SvgDecoder : ResourceDecoder { + override fun handles( + source: InputStream, + options: Options, + ): Boolean { + return true + } + + @Throws(IOException::class) + override fun decode( + source: InputStream, + width: Int, + height: Int, + options: Options, + ): Resource? { + return try { + val svg = SVG.getFromInputStream(source) + if (width != Target.SIZE_ORIGINAL) { + svg.documentWidth = width.toFloat() + } + if (height != Target.SIZE_ORIGINAL) { + svg.documentHeight = height.toFloat() + } + SimpleResource(svg) + } catch (ex: SVGParseException) { + throw IOException("Cannot load SVG from stream", ex) + } + } +} diff --git a/News-Android-App/src/main/java/com/bumptech/glide/samples/svg/SvgDrawableTranscoder.java b/News-Android-App/src/main/java/com/bumptech/glide/samples/svg/SvgDrawableTranscoder.java deleted file mode 100644 index cf543c0f8..000000000 --- a/News-Android-App/src/main/java/com/bumptech/glide/samples/svg/SvgDrawableTranscoder.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.bumptech.glide.samples.svg; - -import android.graphics.Picture; -import android.graphics.drawable.PictureDrawable; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import com.bumptech.glide.load.Options; -import com.bumptech.glide.load.engine.Resource; -import com.bumptech.glide.load.resource.SimpleResource; -import com.bumptech.glide.load.resource.transcode.ResourceTranscoder; -import com.caverock.androidsvg.SVG; - -/** - * Convert the {@link SVG}'s internal representation to an Android-compatible one ({@link Picture}). - */ -public class SvgDrawableTranscoder implements ResourceTranscoder { - @Nullable - @Override - public Resource transcode(@NonNull Resource toTranscode, @NonNull Options options) { - SVG svg = toTranscode.get(); - Picture picture = svg.renderToPicture(); - PictureDrawable drawable = new PictureDrawable(picture); - return new SimpleResource<>(drawable); - } -} \ No newline at end of file diff --git a/News-Android-App/src/main/java/com/bumptech/glide/samples/svg/SvgDrawableTranscoder.kt b/News-Android-App/src/main/java/com/bumptech/glide/samples/svg/SvgDrawableTranscoder.kt new file mode 100644 index 000000000..f2f2d942f --- /dev/null +++ b/News-Android-App/src/main/java/com/bumptech/glide/samples/svg/SvgDrawableTranscoder.kt @@ -0,0 +1,24 @@ +package com.bumptech.glide.samples.svg + +import android.graphics.Picture +import android.graphics.drawable.PictureDrawable +import com.bumptech.glide.load.Options +import com.bumptech.glide.load.engine.Resource +import com.bumptech.glide.load.resource.SimpleResource +import com.bumptech.glide.load.resource.transcode.ResourceTranscoder +import com.caverock.androidsvg.SVG + +/** + * Convert the [SVG]'s internal representation to an Android-compatible one ([Picture]). + */ +class SvgDrawableTranscoder : ResourceTranscoder { + override fun transcode( + toTranscode: Resource, + options: Options, + ): Resource { + val svg = toTranscode.get() + val picture = svg.renderToPicture() + val drawable = PictureDrawable(picture) + return SimpleResource(drawable) + } +} diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/ListView/PodcastArrayAdapter.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/ListView/PodcastArrayAdapter.java index 3d2b69eda..815270295 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/ListView/PodcastArrayAdapter.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/ListView/PodcastArrayAdapter.java @@ -53,7 +53,7 @@ public View getView(final int position, View view, ViewGroup parent) { Toast.makeText(getContext(), "Starting download.. Please wait", Toast.LENGTH_SHORT).show(); - eventBus.post(new StartDownloadPodcast() {{ podcast = podcastItem; }}); + eventBus.post(new StartDownloadPodcast(podcastItem)); }); holder.binding.flDeletePodcastWrapper.setOnClickListener(view13 -> { diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/ListView/PodcastFeedArrayAdapter.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/ListView/PodcastFeedArrayAdapter.java index d87363ff2..16ca157b0 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/ListView/PodcastFeedArrayAdapter.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/ListView/PodcastFeedArrayAdapter.java @@ -47,8 +47,7 @@ public View getView(final int position, View view, ViewGroup parent) { view.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - PodcastFeedClicked podcastFeedClicked = new PodcastFeedClicked(); - podcastFeedClicked.position = position; + PodcastFeedClicked podcastFeedClicked = new PodcastFeedClicked(position); eventBus.post(podcastFeedClicked); } }); diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PodcastFragment.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PodcastFragment.java index 5dd264cb4..7fe78ec57 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PodcastFragment.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PodcastFragment.java @@ -167,7 +167,7 @@ protected void tryOpeningPictureinPictureMode() { @Subscribe public void onEvent(StartDownloadPodcast podcast) { - PodcastDownloadService.startPodcastDownload(getActivity(), podcast.podcast);//, new DownloadReceiver(new Handler(), new WeakReference(holder.pbDownloadPodcast))); + PodcastDownloadService.startPodcastDownload(getActivity(), podcast.getPodcast()); } @Subscribe diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/events/podcast/PodcastFeedClicked.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/events/podcast/PodcastFeedClicked.java deleted file mode 100644 index a4c1452fb..000000000 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/events/podcast/PodcastFeedClicked.java +++ /dev/null @@ -1,5 +0,0 @@ -package de.luhmer.owncloudnewsreader.events.podcast; - -public class PodcastFeedClicked { - public int position; -} diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/events/podcast/PodcastFeedClicked.kt b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/events/podcast/PodcastFeedClicked.kt new file mode 100644 index 000000000..b1c16fc33 --- /dev/null +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/events/podcast/PodcastFeedClicked.kt @@ -0,0 +1,3 @@ +package de.luhmer.owncloudnewsreader.events.podcast + +class PodcastFeedClicked(val position: Int) diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/events/podcast/StartDownloadPodcast.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/events/podcast/StartDownloadPodcast.java deleted file mode 100644 index 127244b84..000000000 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/events/podcast/StartDownloadPodcast.java +++ /dev/null @@ -1,7 +0,0 @@ -package de.luhmer.owncloudnewsreader.events.podcast; - -import de.luhmer.owncloudnewsreader.model.PodcastItem; - -public class StartDownloadPodcast { - public PodcastItem podcast; -} diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/events/podcast/StartDownloadPodcast.kt b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/events/podcast/StartDownloadPodcast.kt new file mode 100644 index 000000000..b9c5e8e4a --- /dev/null +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/events/podcast/StartDownloadPodcast.kt @@ -0,0 +1,5 @@ +package de.luhmer.owncloudnewsreader.events.podcast + +import de.luhmer.owncloudnewsreader.model.PodcastItem + +class StartDownloadPodcast(val podcast: PodcastItem) diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/services/OwnCloudAuthenticatorService.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/services/OwnCloudAuthenticatorService.java deleted file mode 100644 index 219bed688..000000000 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/services/OwnCloudAuthenticatorService.java +++ /dev/null @@ -1,27 +0,0 @@ -package de.luhmer.owncloudnewsreader.services; - -import android.app.Service; -import android.content.Intent; -import android.os.IBinder; - -import de.luhmer.owncloudnewsreader.authentication.OwnCloudAccountAuthenticator; - -public class OwnCloudAuthenticatorService extends Service { - - // Instance field that stores the authenticator object - private OwnCloudAccountAuthenticator mAuthenticator; - - @Override - public void onCreate() { - // Create a new authenticator object - mAuthenticator = new OwnCloudAccountAuthenticator(this); - } - /* - * When the system binds to this Service to make the RPC call - * return the authenticator's IBinder. - */ - @Override - public IBinder onBind(Intent intent) { - return mAuthenticator.getIBinder(); - } -} diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/services/OwnCloudAuthenticatorService.kt b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/services/OwnCloudAuthenticatorService.kt new file mode 100644 index 000000000..604dd76f4 --- /dev/null +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/services/OwnCloudAuthenticatorService.kt @@ -0,0 +1,24 @@ +package de.luhmer.owncloudnewsreader.services + +import android.app.Service +import android.content.Intent +import android.os.IBinder +import de.luhmer.owncloudnewsreader.authentication.OwnCloudAccountAuthenticator + +class OwnCloudAuthenticatorService : Service() { + // Instance field that stores the authenticator object + private var mAuthenticator: OwnCloudAccountAuthenticator? = null + + override fun onCreate() { + // Create a new authenticator object + mAuthenticator = OwnCloudAccountAuthenticator(this) + } + + /* + * When the system binds to this Service to make the RPC call + * return the authenticator's IBinder. + */ + override fun onBind(intent: Intent): IBinder? { + return mAuthenticator?.iBinder + } +} diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/view/ChangeLogFileListView.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/view/ChangeLogFileListView.java deleted file mode 100644 index 832ae11b9..000000000 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/view/ChangeLogFileListView.java +++ /dev/null @@ -1,38 +0,0 @@ -package de.luhmer.owncloudnewsreader.view; - -import android.content.Context; -import android.util.AttributeSet; - -import it.gmariotti.changelibs.library.view.ChangeLogListView; - -/** - * Thin wrapper around changeloglib to load local xml files by path - * after the view has already been instanciated. - */ -public class ChangeLogFileListView extends ChangeLogListView { - - public ChangeLogFileListView(Context context) { - this(context, null); - } - - public ChangeLogFileListView(Context context, AttributeSet attrs) { - this(context, attrs, 0); - } - - public ChangeLogFileListView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - /** - * @param path local xml path staring with "file://" - */ - public void loadFile(String path) { - mChangeLogFileResourceUrl = path; - super.initAdapter(); - } - - @Override - protected void initAdapter() { - // do nothing yet - will be called in loadFile() - } -} diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/view/ChangeLogFileListView.kt b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/view/ChangeLogFileListView.kt new file mode 100644 index 000000000..a06afc3a7 --- /dev/null +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/view/ChangeLogFileListView.kt @@ -0,0 +1,29 @@ +package de.luhmer.owncloudnewsreader.view + +import android.content.Context +import android.util.AttributeSet +import it.gmariotti.changelibs.library.view.ChangeLogListView + +/** + * Thin wrapper around changeloglib to load local xml files by path + * after the view has already been instantiated. + */ +class ChangeLogFileListView + @JvmOverloads + constructor( + context: Context?, + attrs: AttributeSet? = null, + defStyle: Int = 0, + ) : ChangeLogListView(context, attrs, defStyle) { + /** + * @param path local xml path staring with "file://" + */ + fun loadFile(path: String) { + mChangeLogFileResourceUrl = path + super.initAdapter() + } + + override fun initAdapter() { + // do nothing yet - will be called in loadFile() + } + }