Browse Source

Intent filter, user's personal text and links targeting topics fixes.

pull/24/head
Apostolos Fanakis 8 years ago
parent
commit
97ca4fa987
  1. 3
      app/src/main/AndroidManifest.xml
  2. 1
      app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java
  3. 11
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java
  4. 7
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
  5. 51
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  6. 3
      app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java

3
app/src/main/AndroidManifest.xml

@ -46,6 +46,9 @@
<data <data
android:host="thmmy.gr" android:host="thmmy.gr"
android:scheme="https"/> android:scheme="https"/>
<data
android:host="thmmy.gr"/>
</intent-filter> </intent-filter>
</activity> </activity>
<activity <activity

1
app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java

@ -174,7 +174,6 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF
if (intent != null) { if (intent != null) {
Uri uri = intent.getData(); Uri uri = intent.getData();
if (uri != null) { if (uri != null) {
Log.d(TAG, uri.toString());
ThmmyPage.PageCategory page = ThmmyPage.resolvePageCategory(uri); ThmmyPage.PageCategory page = ThmmyPage.resolvePageCategory(uri);
if (!page.is(ThmmyPage.PageCategory.NOT_THMMY)) { if (!page.is(ThmmyPage.PageCategory.NOT_THMMY)) {
if (page.is(ThmmyPage.PageCategory.BOARD)) { if (page.is(ThmmyPage.PageCategory.BOARD)) {

11
app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java

@ -98,7 +98,6 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
Bundle extras = getIntent().getExtras(); Bundle extras = getIntent().getExtras();
thumbnailUrl = extras.getString(BUNDLE_PROFILE_THUMBNAIL_URL); thumbnailUrl = extras.getString(BUNDLE_PROFILE_THUMBNAIL_URL);
if (thumbnailUrl == null) thumbnailUrl = ""; if (thumbnailUrl == null) thumbnailUrl = "";
Log.d(TAG, "thumbnailUrl = " + thumbnailUrl);
username = extras.getString(BUNDLE_PROFILE_USERNAME); username = extras.getString(BUNDLE_PROFILE_USERNAME);
profileUrl = extras.getString(BUNDLE_PROFILE_URL); profileUrl = extras.getString(BUNDLE_PROFILE_URL);
@ -239,17 +238,12 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
select(".bordercolor > tbody:nth-child(1) > tr:nth-child(2) tr"). select(".bordercolor > tbody:nth-child(1) > tr:nth-child(2) tr").
first().select("td").last().text(); first().select("td").last().text();
} }
Log.d(TAG, "thumbnailUrl = " + thumbnailUrl);
if (thumbnailUrl == null || Objects.equals(thumbnailUrl, "")) { //Maybe there is an avatar if (thumbnailUrl == null || Objects.equals(thumbnailUrl, "")) { //Maybe there is an avatar
Log.d(TAG, "thumbnailUrl = " + thumbnailUrl);
Element profileAvatar = profilePage Element profileAvatar = profilePage
.select(".bordercolor > tbody:nth-child(1) > tr:nth-child(2) img.avatar") .select(".bordercolor > tbody:nth-child(1) > tr:nth-child(2) img.avatar")
.first(); .first();
if (profileAvatar != null) thumbnailUrl = profileAvatar.attr("abs:src"); if (profileAvatar != null) thumbnailUrl = profileAvatar.attr("abs:src");
} }
Log.d(TAG, "thumbnailUrl = " + thumbnailUrl);
;
{ //Finds personal text { //Finds personal text
Element tmpEl = profilePage.select("td.windowbg:nth-child(2)").first(); Element tmpEl = profilePage.select("td.windowbg:nth-child(2)").first();
if (tmpEl != null) { if (tmpEl != null) {
@ -294,7 +288,10 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
, R.drawable.ic_default_user_thumbnail, null)) , R.drawable.ic_default_user_thumbnail, null))
.transform(new CircleTransform()) .transform(new CircleTransform())
.into(thumbnailView); .into(thumbnailView);
if (personalText != null) personalTextView.setText(personalText); if (personalText != null) {
personalTextView.setText(personalText);
personalTextView.setVisibility(View.VISIBLE);
}
setupViewPager(viewPager, profilePage); setupViewPager(viewPager, profilePage);
TabLayout tabLayout = (TabLayout) findViewById(R.id.profile_tabs); TabLayout tabLayout = (TabLayout) findViewById(R.id.profile_tabs);

7
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.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.util.SparseArray; import android.util.SparseArray;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
@ -432,10 +433,9 @@ public class TopicActivity extends BaseActivity {
postFocus = Integer.parseInt(tmp.substring(0, tmp.indexOf("#"))); postFocus = Integer.parseInt(tmp.substring(0, tmp.indexOf("#")));
} }
} }
//Checks if the page to be loaded is the one already shown //Checks if the page to be loaded is the one already shown
if (!Objects.equals(loadedPageUrl, "") && loadedPageUrl.contains(base_url)) { if (!Objects.equals(loadedPageUrl, "") && loadedPageUrl.contains(base_url)) {
if (newPageUrl.contains("topicseen#new")) if (newPageUrl.contains("topicseen#new") || newPageUrl.contains("#new"))
if (thisPage == numberOfPages) if (thisPage == numberOfPages)
return SAME_PAGE; return SAME_PAGE;
if (newPageUrl.contains("msg")) { if (newPageUrl.contains("msg")) {
@ -448,8 +448,7 @@ public class TopicActivity extends BaseActivity {
return SAME_PAGE; return SAME_PAGE;
} }
} }
} } else if (Integer.parseInt(newPageUrl.substring(base_url.length() + 1)) / 15 + 1 == thisPage)
if (Integer.parseInt(newPageUrl.substring(base_url.length() + 1)) / 15 + 1 == thisPage)
return SAME_PAGE; return SAME_PAGE;
} else if (!Objects.equals(loadedPageUrl, "")) topicTitle = null; } else if (!Objects.equals(loadedPageUrl, "")) topicTitle = null;

51
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java

@ -389,30 +389,35 @@ class TopicAdapter extends RecyclerView.Adapter<TopicAdapter.MyViewHolder> {
holder.subject.setMaxLines(1); holder.subject.setMaxLines(1);
holder.subject.setEllipsize(TextUtils.TruncateAt.END); holder.subject.setEllipsize(TextUtils.TruncateAt.END);
} }
if (viewProperties.get(position)[isQuoteButtonChecked]) //noinspection PointlessBooleanExpression,ConstantConditions
holder.quoteToggle.setImageResource(R.drawable.ic_format_quote_checked); if (!BaseActivity.getSessionManager().isLoggedIn() || true) //Hide it until reply is implemented
else holder.quoteToggle.setVisibility(View.GONE);
holder.quoteToggle.setImageResource(R.drawable.ic_format_quote_unchecked); else {
//Sets graphics behavior if (viewProperties.get(position)[isQuoteButtonChecked])
holder.quoteToggle.setOnClickListener(new View.OnClickListener() { holder.quoteToggle.setImageResource(R.drawable.ic_format_quote_checked);
@Override else
public void onClick(View view) { holder.quoteToggle.setImageResource(R.drawable.ic_format_quote_unchecked);
boolean[] tmp = viewProperties.get(holder.getAdapterPosition()); //Sets graphics behavior
if (tmp[isQuoteButtonChecked]) { holder.quoteToggle.setOnClickListener(new View.OnClickListener() {
if (toQuoteList.contains(currentPost.getPostNumber())) { @Override
toQuoteList.remove(toQuoteList.indexOf(currentPost.getPostNumber())); public void onClick(View view) {
} else boolean[] tmp = viewProperties.get(holder.getAdapterPosition());
Report.i(TAG, "An error occurred while trying to exclude post from" + if (tmp[isQuoteButtonChecked]) {
"toQuoteList, post wasn't there!"); if (toQuoteList.contains(currentPost.getPostNumber())) {
holder.quoteToggle.setImageResource(R.drawable.ic_format_quote_unchecked); toQuoteList.remove(toQuoteList.indexOf(currentPost.getPostNumber()));
} else { } else
toQuoteList.add(currentPost.getPostNumber()); Report.i(TAG, "An error occurred while trying to exclude post from" +
holder.quoteToggle.setImageResource(R.drawable.ic_format_quote_checked); "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 //Card expand/collapse when card is touched
holder.cardView.setOnClickListener(new View.OnClickListener() { holder.cardView.setOnClickListener(new View.OnClickListener() {
@Override @Override

3
app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java

@ -140,7 +140,8 @@ public class ThmmyPage {
final String host = uri.getHost(); final String host = uri.getHost();
final String uriString = uri.toString(); 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 (Objects.equals(host, "www.thmmy.gr")) {
if (uriString.contains("topic=")) return PageCategory.TOPIC; if (uriString.contains("topic=")) return PageCategory.TOPIC;
else if (uriString.contains("board=")) return PageCategory.BOARD; else if (uriString.contains("board=")) return PageCategory.BOARD;

Loading…
Cancel
Save