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
android:host="thmmy.gr"
android:scheme="https"/>
<data
android:host="thmmy.gr"/>
</intent-filter>
</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) {
Uri uri = intent.getData();
if (uri != null) {
Log.d(TAG, uri.toString());
ThmmyPage.PageCategory page = ThmmyPage.resolvePageCategory(uri);
if (!page.is(ThmmyPage.PageCategory.NOT_THMMY)) {
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();
thumbnailUrl = extras.getString(BUNDLE_PROFILE_THUMBNAIL_URL);
if (thumbnailUrl == null) thumbnailUrl = "";
Log.d(TAG, "thumbnailUrl = " + thumbnailUrl);
username = extras.getString(BUNDLE_PROFILE_USERNAME);
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").
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);

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.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;

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.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

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 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;

Loading…
Cancel
Save