From 97ca4fa9879f49365a7f73144d8fa75469e47c5a Mon Sep 17 00:00:00 2001 From: Apostolof Date: Sun, 22 Jan 2017 18:57:01 +0200 Subject: [PATCH] Intent filter, user's personal text and links targeting topics fixes. --- app/src/main/AndroidManifest.xml | 3 ++ .../mthmmy/activities/main/MainActivity.java | 1 - .../activities/profile/ProfileActivity.java | 11 ++-- .../activities/topic/TopicActivity.java | 7 ++- .../mthmmy/activities/topic/TopicAdapter.java | 51 ++++++++++--------- .../java/gr/thmmy/mthmmy/model/ThmmyPage.java | 3 +- 6 files changed, 40 insertions(+), 36 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1ad2d90b..f95392f4 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -46,6 +46,9 @@ + + tbody:nth-child(1) > tr:nth-child(2) tr"). first().select("td").last().text(); } - Log.d(TAG, "thumbnailUrl = " + thumbnailUrl); if (thumbnailUrl == null || Objects.equals(thumbnailUrl, "")) { //Maybe there is an avatar - Log.d(TAG, "thumbnailUrl = " + thumbnailUrl); Element profileAvatar = profilePage .select(".bordercolor > tbody:nth-child(1) > tr:nth-child(2) img.avatar") .first(); if (profileAvatar != null) thumbnailUrl = profileAvatar.attr("abs:src"); } - Log.d(TAG, "thumbnailUrl = " + thumbnailUrl); - ; - { //Finds personal text Element tmpEl = profilePage.select("td.windowbg:nth-child(2)").first(); if (tmpEl != null) { @@ -294,7 +288,10 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment , R.drawable.ic_default_user_thumbnail, null)) .transform(new CircleTransform()) .into(thumbnailView); - if (personalText != null) personalTextView.setText(personalText); + if (personalText != null) { + personalTextView.setText(personalText); + personalTextView.setVisibility(View.VISIBLE); + } setupViewPager(viewPager, profilePage); TabLayout tabLayout = (TabLayout) findViewById(R.id.profile_tabs); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java index 8bf4c7ac..8ca6f707 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java @@ -9,6 +9,7 @@ import android.support.design.widget.FloatingActionButton; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.Toolbar; +import android.util.Log; import android.util.SparseArray; import android.view.MotionEvent; import android.view.View; @@ -432,10 +433,9 @@ public class TopicActivity extends BaseActivity { postFocus = Integer.parseInt(tmp.substring(0, tmp.indexOf("#"))); } } - //Checks if the page to be loaded is the one already shown if (!Objects.equals(loadedPageUrl, "") && loadedPageUrl.contains(base_url)) { - if (newPageUrl.contains("topicseen#new")) + if (newPageUrl.contains("topicseen#new") || newPageUrl.contains("#new")) if (thisPage == numberOfPages) return SAME_PAGE; if (newPageUrl.contains("msg")) { @@ -448,8 +448,7 @@ public class TopicActivity extends BaseActivity { return SAME_PAGE; } } - } - if (Integer.parseInt(newPageUrl.substring(base_url.length() + 1)) / 15 + 1 == thisPage) + } else if (Integer.parseInt(newPageUrl.substring(base_url.length() + 1)) / 15 + 1 == thisPage) return SAME_PAGE; } else if (!Objects.equals(loadedPageUrl, "")) topicTitle = null; 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 b03b56e5..2ea65fb9 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 @@ -389,30 +389,35 @@ class TopicAdapter extends RecyclerView.Adapter { holder.subject.setMaxLines(1); holder.subject.setEllipsize(TextUtils.TruncateAt.END); } - if (viewProperties.get(position)[isQuoteButtonChecked]) - holder.quoteToggle.setImageResource(R.drawable.ic_format_quote_checked); - else - holder.quoteToggle.setImageResource(R.drawable.ic_format_quote_unchecked); - //Sets graphics behavior - holder.quoteToggle.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - boolean[] tmp = viewProperties.get(holder.getAdapterPosition()); - if (tmp[isQuoteButtonChecked]) { - if (toQuoteList.contains(currentPost.getPostNumber())) { - toQuoteList.remove(toQuoteList.indexOf(currentPost.getPostNumber())); - } else - Report.i(TAG, "An error occurred while trying to exclude post from" + - "toQuoteList, post wasn't there!"); - holder.quoteToggle.setImageResource(R.drawable.ic_format_quote_unchecked); - } else { - toQuoteList.add(currentPost.getPostNumber()); - holder.quoteToggle.setImageResource(R.drawable.ic_format_quote_checked); + //noinspection PointlessBooleanExpression,ConstantConditions + if (!BaseActivity.getSessionManager().isLoggedIn() || true) //Hide it until reply is implemented + holder.quoteToggle.setVisibility(View.GONE); + else { + if (viewProperties.get(position)[isQuoteButtonChecked]) + holder.quoteToggle.setImageResource(R.drawable.ic_format_quote_checked); + else + holder.quoteToggle.setImageResource(R.drawable.ic_format_quote_unchecked); + //Sets graphics behavior + holder.quoteToggle.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + boolean[] tmp = viewProperties.get(holder.getAdapterPosition()); + if (tmp[isQuoteButtonChecked]) { + if (toQuoteList.contains(currentPost.getPostNumber())) { + toQuoteList.remove(toQuoteList.indexOf(currentPost.getPostNumber())); + } else + Report.i(TAG, "An error occurred while trying to exclude post from" + + "toQuoteList, post wasn't there!"); + holder.quoteToggle.setImageResource(R.drawable.ic_format_quote_unchecked); + } else { + toQuoteList.add(currentPost.getPostNumber()); + holder.quoteToggle.setImageResource(R.drawable.ic_format_quote_checked); + } + tmp[isQuoteButtonChecked] = !tmp[isQuoteButtonChecked]; + viewProperties.set(holder.getAdapterPosition(), tmp); } - tmp[isQuoteButtonChecked] = !tmp[isQuoteButtonChecked]; - viewProperties.set(holder.getAdapterPosition(), tmp); - } - }); + }); + } //Card expand/collapse when card is touched holder.cardView.setOnClickListener(new View.OnClickListener() { @Override diff --git a/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java b/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java index c4bc5272..cc9a1781 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java +++ b/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java @@ -140,7 +140,8 @@ public class ThmmyPage { final String host = uri.getHost(); final String uriString = uri.toString(); - if (Objects.equals(uriString, "thmmy.gr")) return PageCategory.INDEX; + if (Objects.equals(uriString, "http://thmmy.gr") + || Objects.equals(uriString, "https://thmmy.gr")) return PageCategory.INDEX; if (Objects.equals(host, "www.thmmy.gr")) { if (uriString.contains("topic=")) return PageCategory.TOPIC; else if (uriString.contains("board=")) return PageCategory.BOARD;