From 667371ca3a1394a729b2292af693d51f3ce7dfd4 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Wed, 2 Aug 2017 20:07:57 +0300 Subject: [PATCH 1/5] Minor layout & ParseTask changes --- .../downloads/DownloadsActivity.java | 64 +++++++------------ .../main/recent/RecentFragment.java | 1 + .../gr/thmmy/mthmmy/receiver/Receiver.java | 1 - .../java/gr/thmmy/mthmmy/utils/ParseTask.java | 4 +- .../main/res/layout-sw600dp/activity_main.xml | 34 ---------- .../layout-v21/activity_topic_post_row.xml | 2 +- app/src/main/res/layout/activity_main.xml | 3 + app/src/main/res/layout/activity_topic.xml | 1 + .../res/layout/activity_topic_post_row.xml | 2 +- 9 files changed, 32 insertions(+), 80 deletions(-) delete mode 100644 app/src/main/res/layout-sw600dp/activity_main.xml diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java index 292c4050..3df917af 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java @@ -11,7 +11,6 @@ import android.view.View; import android.widget.ProgressBar; import android.widget.Toast; -import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; @@ -19,15 +18,13 @@ import org.jsoup.select.Elements; import java.util.ArrayList; import java.util.Objects; -import javax.net.ssl.SSLHandshakeException; - import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.base.BaseActivity; import gr.thmmy.mthmmy.model.Download; import gr.thmmy.mthmmy.model.ThmmyPage; +import gr.thmmy.mthmmy.utils.ParseTask; +import gr.thmmy.mthmmy.utils.exceptions.ParseException; import me.zhanghai.android.materialprogressbar.MaterialProgressBar; -import okhttp3.Request; -import okhttp3.Response; import timber.log.Timber; public class DownloadsActivity extends BaseActivity implements DownloadsAdapter.OnLoadMoreListener { @@ -159,16 +156,14 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter. } /** - * An {@link AsyncTask} that handles asynchronous fetching of a downloads page and parsing it's - * data. {@link AsyncTask#onPostExecute(Object) OnPostExecute} method calls {@link RecyclerView#swapAdapter} + * An {@link ParseTask} that handles asynchronous fetching of a downloads page and parsing it's + * data. {@link ParseTask#postParsing(ResultCode) postParsing} method calls {@link RecyclerView#swapAdapter} * to build graphics. *

- *

Calling TopicTask's {@link AsyncTask#execute execute} method needs to have profile's url + *

Calling TopicTask's {@link ParseTask#execute execute} method needs to have profile's url * as String parameter!

*/ - class ParseDownloadPageTask extends AsyncTask { - private String thisPageUrl; - + private class ParseDownloadPageTask extends ParseTask { @Override protected void onPreExecute() { if (!isLoadingMore) progressBar.setVisibility(ProgressBar.VISIBLE); @@ -176,36 +171,7 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter. } @Override - protected Void doInBackground(String... downloadsUrl) { - thisPageUrl = downloadsUrl[0]; - Request request = new Request.Builder() - .url(downloadsUrl[0]) - .build(); - try { - Response response = client.newCall(request).execute(); - parseDownloads(Jsoup.parse(response.body().string())); - } catch (SSLHandshakeException e) { - Timber.w("Certificate problem (please switch to unsafe connection)."); - } catch (Exception e) { - Timber.e(e, "Exception"); - } - return null; - } - - @Override - protected void onPostExecute(Void voids) { - if (downloadsTitle != null && !Objects.equals(downloadsTitle, "") && - toolbar.getTitle() != downloadsTitle) - toolbar.setTitle(downloadsTitle); - - ++pagesLoaded; - if (uploadFAB.getVisibility() != View.GONE) uploadFAB.setEnabled(true); - progressBar.setVisibility(ProgressBar.INVISIBLE); - downloadsAdapter.notifyDataSetChanged(); - isLoadingMore = false; - } - - private void parseDownloads(Document downloadPage) { + protected void parse(Document downloadPage) throws ParseException { if (downloadsTitle == null || Objects.equals(downloadsTitle, "")) downloadsTitle = downloadPage.select("div.nav>b>a.nav").last().text(); @@ -215,7 +181,7 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter. } Download.DownloadItemType type; - if (ThmmyPage.resolvePageCategory(Uri.parse(thisPageUrl)).is(ThmmyPage. + if (ThmmyPage.resolvePageCategory(Uri.parse(url)).is(ThmmyPage. PageCategory.DOWNLOADS_CATEGORY)) type = Download.DownloadItemType.DOWNLOADS_CATEGORY; else type = Download.DownloadItemType.DOWNLOADS_FILE; @@ -265,5 +231,19 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter. rows.select("span:has(a)").first().text())); } } + + + @Override + protected void postParsing(ResultCode result) { + if (downloadsTitle != null && !Objects.equals(downloadsTitle, "") && + toolbar.getTitle() != downloadsTitle) + toolbar.setTitle(downloadsTitle); + + ++pagesLoaded; + if (uploadFAB.getVisibility() != View.GONE) uploadFAB.setEnabled(true); + progressBar.setVisibility(ProgressBar.INVISIBLE); + downloadsAdapter.notifyDataSetChanged(); + isLoadingMore = false; + } } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java index 89aa027b..ce940cd2 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java @@ -138,6 +138,7 @@ public class RecentFragment extends BaseFragment { //---------------------------------------ASYNC TASK----------------------------------- private class RecentTask extends ParseTask { + @Override protected void onPreExecute() { progressBar.setVisibility(ProgressBar.VISIBLE); } diff --git a/app/src/main/java/gr/thmmy/mthmmy/receiver/Receiver.java b/app/src/main/java/gr/thmmy/mthmmy/receiver/Receiver.java index a36916ea..971475ff 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/receiver/Receiver.java +++ b/app/src/main/java/gr/thmmy/mthmmy/receiver/Receiver.java @@ -13,7 +13,6 @@ import android.webkit.MimeTypeMap; import java.io.File; -import gr.thmmy.mthmmy.R; import timber.log.Timber; import static gr.thmmy.mthmmy.services.DownloadService.ACTION_DOWNLOAD; diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/ParseTask.java b/app/src/main/java/gr/thmmy/mthmmy/utils/ParseTask.java index 9ce5a882..ce7df62a 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/ParseTask.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/ParseTask.java @@ -21,6 +21,7 @@ import timber.log.Timber; * and modify prepareRequest() as needed. */ public abstract class ParseTask extends AsyncTask { + protected String url; protected enum ResultCode { SUCCESS, PARSING_ERROR, NETWORK_ERROR, OTHER_ERROR } @@ -29,8 +30,9 @@ public abstract class ParseTask extends AsyncTask - - - - - - - - - diff --git a/app/src/main/res/layout-v21/activity_topic_post_row.xml b/app/src/main/res/layout-v21/activity_topic_post_row.xml index 2362427d..a4c6ee2d 100644 --- a/app/src/main/res/layout-v21/activity_topic_post_row.xml +++ b/app/src/main/res/layout-v21/activity_topic_post_row.xml @@ -189,7 +189,7 @@ diff --git a/app/src/main/res/layout/activity_topic.xml b/app/src/main/res/layout/activity_topic.xml index e726d372..e7aa2a66 100644 --- a/app/src/main/res/layout/activity_topic.xml +++ b/app/src/main/res/layout/activity_topic.xml @@ -39,6 +39,7 @@ android:layout_gravity="top|start" android:background="@color/background" android:paddingTop="4dp" + android:paddingBottom="4dp" android:clipToPadding="false" android:scrollbars="none" tools:context="gr.thmmy.mthmmy.activities.topic.TopicActivity" diff --git a/app/src/main/res/layout/activity_topic_post_row.xml b/app/src/main/res/layout/activity_topic_post_row.xml index 99eeefd6..4581ac89 100644 --- a/app/src/main/res/layout/activity_topic_post_row.xml +++ b/app/src/main/res/layout/activity_topic_post_row.xml @@ -188,7 +188,7 @@ Date: Mon, 28 Aug 2017 19:37:14 +0300 Subject: [PATCH 2/5] WebView hardware acceleration fix --- .../gr/thmmy/mthmmy/activities/topic/TopicAdapter.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java index 64526741..cc5d596b 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java @@ -181,7 +181,6 @@ class TopicAdapter extends RecyclerView.Adapter { //Post's WebView parameters holder.post.setClickable(true); holder.post.setWebViewClient(new LinkLauncher()); - holder.post.setLayerType(View.LAYER_TYPE_SOFTWARE, null); //Avoids errors about layout having 0 width/height holder.thumbnail.setMinimumWidth(1); @@ -484,6 +483,14 @@ class TopicAdapter extends RecyclerView.Adapter { //notifyDataSetChanged(); } + //Fix for WebView not rendering with Hardware Acceleration + @Override + public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) { + super.onViewAttachedToWindow(holder); + if (holder instanceof PostViewHolder) + ((PostViewHolder) holder).post.reload(); + } + @Override public int getItemCount() { return postsList.size(); From 20e880415ba0a8f66d589337aeeb4e172a1379d6 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Mon, 28 Aug 2017 20:49:26 +0300 Subject: [PATCH 3/5] Obfuscation disabled, removed unused templates --- .gitlab/issue_templates/Bug.md | 24 ------------------------ .gitlab/issue_templates/Improvement.md | 5 ----- app/proguard-rules.pro | 5 ++++- 3 files changed, 4 insertions(+), 30 deletions(-) delete mode 100644 .gitlab/issue_templates/Bug.md delete mode 100644 .gitlab/issue_templates/Improvement.md diff --git a/.gitlab/issue_templates/Bug.md b/.gitlab/issue_templates/Bug.md deleted file mode 100644 index d13fb1d2..00000000 --- a/.gitlab/issue_templates/Bug.md +++ /dev/null @@ -1,24 +0,0 @@ -### Summary - -(Summarize the bug encountered concisely) - -### Steps to reproduce - -(How one can reproduce the issue) - -### Expected behavior - -(What should normally happen) - -### Actual behavior - -(What actually happens instead) - -### Relevant logs and/or screenshots - -(Paste any relevant logs using code blocks (```) to format console output, -logs, and code) - -### Possible fixes - -(If you can, link to the line of code that might be responsible for the problem) diff --git a/.gitlab/issue_templates/Improvement.md b/.gitlab/issue_templates/Improvement.md deleted file mode 100644 index bce0589e..00000000 --- a/.gitlab/issue_templates/Improvement.md +++ /dev/null @@ -1,5 +0,0 @@ -### Description - -### Proposal - -### Links / references diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index b00af7bc..5b6e2458 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -16,6 +16,9 @@ # public *; #} +# Don't obfuscate code (due to issues in Firebase) +-dontobfuscate + # OkHttp -dontwarn okio.** -dontwarn javax.annotation.Nullable @@ -33,5 +36,5 @@ # android-gif-drawable -keep public class pl.droidsonroids.gif.GifIOException{(int, java.lang.String);} -#JSoup +# JSoup -keep class org.jsoup.** \ No newline at end of file From ee52ff2ba6cb6684551180d87728c0fdb31551c4 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Wed, 30 Aug 2017 10:50:42 +0300 Subject: [PATCH 4/5] Rolled back TopicAdapter changes, AboutActivity additions --- app/build.gradle | 2 +- .../mthmmy/activities/topic/TopicAdapter.java | 8 ----- app/src/main/res/layout/activity_about.xml | 33 ++++++++++++++++--- app/src/main/res/values/strings.xml | 16 ++++----- 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 571dd5b2..caf6949a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -45,7 +45,7 @@ dependencies { } compile 'com.mikepenz:fontawesome-typeface:4.7.0.0@aar' compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.7' - compile 'com.bignerdranch.android:expandablerecyclerview:3.0.0-RC1' //Deprecated! + compile 'com.bignerdranch.android:expandablerecyclerview:3.0.0-RC1' //TODO: Deprecated - needs replacement! compile 'me.zhanghai.android.materialprogressbar:library:1.4.1' compile 'com.jakewharton.timber:timber:4.5.1' } diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java index cc5d596b..fd95cc71 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java @@ -483,14 +483,6 @@ class TopicAdapter extends RecyclerView.Adapter { //notifyDataSetChanged(); } - //Fix for WebView not rendering with Hardware Acceleration - @Override - public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) { - super.onViewAttachedToWindow(holder); - if (holder instanceof PostViewHolder) - ((PostViewHolder) holder).post.reload(); - } - @Override public int getItemCount() { return postsList.size(); diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index 797665a2..306d2b76 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -70,20 +70,43 @@ android:textStyle="italic"/> + + + + v%1$s Logo - You should see a funny pic! - - - Remove - Boards - Topics - - Libraries mTHMMY uses the following open-source libraries: Apache v2.0 License libraries The MIT License libraries Contact Do not hesitate to contact us for any matter either by email at thmmynolife@gmail.com, or by joining our discord server at https://discord.gg/CVt3yrn. + Open Source + The source code of mTHMMY can be found on GitLab (https://gitlab.com/ThmmyNoLife/mTHMMY) along with further details of how one can contribute. + You should see a funny pic! + + + Remove + Boards + Topics From 27a3bd930da2c3584b135c69d5ac82ab8fd655e5 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Wed, 27 Sep 2017 20:16:24 +0300 Subject: [PATCH 5/5] Up version --- VERSION | 2 +- app/build.gradle | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 3a3cd8cc..1892b926 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3.1 +1.3.2 diff --git a/app/build.gradle b/app/build.gradle index caf6949a..719a0366 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "gr.thmmy.mthmmy" minSdkVersion 19 targetSdkVersion 26 - versionCode 9 - versionName "1.3.1" + versionCode 10 + versionName "1.3.2" archivesBaseName = "mTHMMY-v$versionName" }