Browse Source

Version 1.3.1

master v1.3.1
Ezerous 8 years ago
parent
commit
ea0a575461
  1. 4
      .gitlab-ci.yml
  2. 2
      VERSION
  3. 20
      app/build.gradle
  4. 1
      app/src/main/AndroidManifest.xml
  5. 13
      app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java
  6. 5
      app/src/main/java/gr/thmmy/mthmmy/activities/BookmarkActivity.java
  7. 12
      app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java
  8. 17
      app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
  9. 30
      app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java
  10. 9
      app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java
  11. 18
      app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java
  12. 40
      app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java
  13. 4
      app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumAdapter.java
  14. 6
      app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java
  15. 6
      app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentAdapter.java
  16. 6
      app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java
  17. 28
      app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadAdapter.java
  18. 6
      app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java
  19. 17
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java
  20. 10
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java
  21. 6
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java
  22. 10
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java
  23. 2
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java
  24. 60
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
  25. 50
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  26. 11
      app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java
  27. 5
      app/src/main/java/gr/thmmy/mthmmy/base/BaseFragment.java
  28. 10
      app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java
  29. 12
      app/src/main/java/gr/thmmy/mthmmy/receiver/Receiver.java
  30. 8
      app/src/main/java/gr/thmmy/mthmmy/services/DownloadService.java
  31. 5
      app/src/main/java/gr/thmmy/mthmmy/utils/CustomLinearLayoutManager.java
  32. 22
      app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareFABBehavior.java
  33. 15
      app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareLinearBehavior.java
  34. 9
      app/src/main/res/drawable/ic_file_download.xml
  35. 1
      app/src/main/res/layout/dialog_topic_info.xml
  36. 1
      app/src/main/res/layout/fragment_unread_mark_read_row.xml
  37. 1
      build.gradle

4
.gitlab-ci.yml

@ -1,8 +1,8 @@
image: openjdk:8-jdk image: openjdk:8-jdk
variables: variables:
ANDROID_TARGET_SDK: "25" ANDROID_TARGET_SDK: "26"
ANDROID_BUILD_TOOLS: "25.0.3" ANDROID_BUILD_TOOLS: "26.0.1"
ANDROID_SDK_TOOLS: "25.2.5" ANDROID_SDK_TOOLS: "25.2.5"
before_script: before_script:

2
VERSION

@ -1 +1 @@
1.3.0 1.3.1

20
app/build.gradle

@ -1,16 +1,16 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
android { android {
compileSdkVersion 25 compileSdkVersion 26
buildToolsVersion "25.0.3" buildToolsVersion "26.0.1"
defaultConfig { defaultConfig {
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
applicationId "gr.thmmy.mthmmy" applicationId "gr.thmmy.mthmmy"
minSdkVersion 19 minSdkVersion 19
targetSdkVersion 25 targetSdkVersion 26
versionCode 8 versionCode 9
versionName "1.3.0" versionName "1.3.1"
archivesBaseName = "mTHMMY-v$versionName" archivesBaseName = "mTHMMY-v$versionName"
} }
@ -28,11 +28,11 @@ android {
dependencies { dependencies {
compile fileTree(dir: 'libs', include: ['*.jar']) compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.3.1' compile 'com.android.support:appcompat-v7:26.0.0'
compile 'com.android.support:design:25.3.1' compile 'com.android.support:design:26.0.0'
compile 'com.android.support:support-v4:25.3.1' compile 'com.android.support:support-v4:26.0.0'
compile 'com.android.support:cardview-v7:25.3.1' compile 'com.android.support:cardview-v7:26.0.0'
compile 'com.android.support:recyclerview-v7:25.3.1' compile 'com.android.support:recyclerview-v7:26.0.0'
compile 'com.google.firebase:firebase-crash:10.2.6' compile 'com.google.firebase:firebase-crash:10.2.6'
compile 'com.squareup.okhttp3:okhttp:3.8.0' compile 'com.squareup.okhttp3:okhttp:3.8.0'
compile 'com.squareup.picasso:picasso:2.5.2' compile 'com.squareup.picasso:picasso:2.5.2'

1
app/src/main/AndroidManifest.xml

@ -90,7 +90,6 @@
</activity> </activity>
<activity <activity
android:name=".activities.downloads.DownloadsActivity" android:name=".activities.downloads.DownloadsActivity"
android:launchMode="singleInstance"
android:parentActivityName=".activities.main.MainActivity" android:parentActivityName=".activities.main.MainActivity"
android:theme="@style/AppTheme.NoActionBar"> android:theme="@style/AppTheme.NoActionBar">
<meta-data <meta-data

13
app/src/main/java/gr/thmmy/mthmmy/activities/AboutActivity.java

@ -6,7 +6,6 @@ import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout; import android.support.design.widget.CoordinatorLayout;
import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.webkit.WebView; import android.webkit.WebView;
@ -36,10 +35,10 @@ public class AboutActivity extends BaseActivity {
String versionName = BuildConfig.VERSION_NAME; String versionName = BuildConfig.VERSION_NAME;
//Initialize appbar //Initialize appbar
appBar = (AppBarLayout) findViewById(R.id.appbar); appBar = findViewById(R.id.appbar);
coordinatorLayout = (CoordinatorLayout) findViewById(R.id.main_content); coordinatorLayout = findViewById(R.id.main_content);
//Initialize toolbar //Initialize toolbar
toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar = findViewById(R.id.toolbar);
toolbar.setTitle(R.string.about); toolbar.setTitle(R.string.about);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
if (getSupportActionBar() != null) { if (getSupportActionBar() != null) {
@ -50,10 +49,10 @@ public class AboutActivity extends BaseActivity {
createDrawer(); createDrawer();
drawer.setSelection(ABOUT_ID); drawer.setSelection(ABOUT_ID);
final ScrollView mainContent = (ScrollView) findViewById(R.id.scrollview); final ScrollView mainContent = findViewById(R.id.scrollview);
trollGif = (FrameLayout) findViewById(R.id.trollPicFrame); trollGif = findViewById(R.id.trollPicFrame);
TextView tv = (TextView) findViewById(R.id.version); TextView tv = findViewById(R.id.version);
if (tv != null) if (tv != null)
tv.setText(getString(R.string.version, versionName)); tv.setText(getString(R.string.version, versionName));

5
app/src/main/java/gr/thmmy/mthmmy/activities/BookmarkActivity.java

@ -4,7 +4,6 @@ import android.content.Intent;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.LinearLayout; import android.widget.LinearLayout;
@ -34,7 +33,7 @@ public class BookmarkActivity extends BaseActivity {
setContentView(R.layout.activity_bookmark); setContentView(R.layout.activity_bookmark);
//Initialize toolbar //Initialize toolbar
toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar = findViewById(R.id.toolbar);
toolbar.setTitle("Bookmarks"); toolbar.setTitle("Bookmarks");
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
if (getSupportActionBar() != null) { if (getSupportActionBar() != null) {
@ -45,7 +44,7 @@ public class BookmarkActivity extends BaseActivity {
createDrawer(); createDrawer();
drawer.setSelection(BOOKMARKS_ID); drawer.setSelection(BOOKMARKS_ID);
LinearLayout bookmarksLinearView = (LinearLayout) findViewById(R.id.bookmarks_container); LinearLayout bookmarksLinearView = findViewById(R.id.bookmarks_container);
LayoutInflater layoutInflater = getLayoutInflater(); LayoutInflater layoutInflater = getLayoutInflater();
if(!getBoardsBookmarked().isEmpty()) { if(!getBoardsBookmarked().isEmpty()) {

12
app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java

@ -42,10 +42,10 @@ public class LoginActivity extends BaseActivity {
setContentView(R.layout.activity_login); setContentView(R.layout.activity_login);
//Variables initialization //Variables initialization
inputUsername = (EditText) findViewById(R.id.username); inputUsername = findViewById(R.id.username);
inputPassword = (EditText) findViewById(R.id.password); inputPassword = findViewById(R.id.password);
btnLogin = (AppCompatButton) findViewById(R.id.btnLogin); btnLogin = findViewById(R.id.btnLogin);
AppCompatButton btnGuest = (AppCompatButton) findViewById(R.id.btnContinueAsGuest); AppCompatButton btnGuest = findViewById(R.id.btnContinueAsGuest);
//Login button Click Event //Login button Click Event
btnLogin.setOnClickListener(new View.OnClickListener() { btnLogin.setOnClickListener(new View.OnClickListener() {
@ -138,8 +138,8 @@ public class LoginActivity extends BaseActivity {
protected void onPreExecute() { //Show a progress dialog until done protected void onPreExecute() { //Show a progress dialog until done
btnLogin.setEnabled(false); //Login button shouldn't be pressed during this btnLogin.setEnabled(false); //Login button shouldn't be pressed during this
spinner = (LinearLayout) findViewById(R.id.login_progress_bar); spinner = findViewById(R.id.login_progress_bar);
loginContent = (ScrollView) findViewById(R.id.inner_scroll_view); loginContent = findViewById(R.id.inner_scroll_view);
View view = getCurrentFocus(); View view = getCurrentFocus();
if (view != null) { if (view != null) {

17
app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java

@ -7,8 +7,6 @@ import android.support.design.widget.FloatingActionButton;
import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.DividerItemDecoration;
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.util.Log;
import android.view.View; import android.view.View;
import android.widget.ImageButton; import android.widget.ImageButton;
import android.widget.ProgressBar; import android.widget.ProgressBar;
@ -74,9 +72,15 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
Toast.makeText(this, "An error has occurred\nAborting.", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "An error has occurred\nAborting.", Toast.LENGTH_SHORT).show();
finish(); finish();
} }
//Fixes url
{
String tmpUrlSbstr = boardUrl.replaceAll("(.+)(board=)([0-9]*)(\\.*[0-9]*).*", "$1$2$3");
if (!tmpUrlSbstr.substring(tmpUrlSbstr.indexOf("board=")).contains("."))
boardUrl = tmpUrlSbstr + ".0";
}
//Initializes graphics //Initializes graphics
toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar = findViewById(R.id.toolbar);
if (boardTitle != null && !Objects.equals(boardTitle, "")) toolbar.setTitle(boardTitle); if (boardTitle != null && !Objects.equals(boardTitle, "")) toolbar.setTitle(boardTitle);
else toolbar.setTitle("Board"); else toolbar.setTitle("Board");
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
@ -89,8 +93,8 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
setBoardBookmark((ImageButton) findViewById(R.id.bookmark)); setBoardBookmark((ImageButton) findViewById(R.id.bookmark));
createDrawer(); createDrawer();
progressBar = (MaterialProgressBar) findViewById(R.id.progressBar); progressBar = findViewById(R.id.progressBar);
newTopicFAB = (FloatingActionButton) findViewById(R.id.board_fab); newTopicFAB = findViewById(R.id.board_fab);
newTopicFAB.setEnabled(false); newTopicFAB.setEnabled(false);
newTopicFAB.hide(); newTopicFAB.hide();
/*if (!sessionManager.isLoggedIn()) newTopicFAB.hide(); /*if (!sessionManager.isLoggedIn()) newTopicFAB.hide();
@ -124,7 +128,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
}*/ }*/
boardAdapter = new BoardAdapter(getApplicationContext(), parsedSubBoards, parsedTopics); boardAdapter = new BoardAdapter(getApplicationContext(), parsedSubBoards, parsedTopics);
RecyclerView mainContent = (RecyclerView) findViewById(R.id.board_recycler_view); RecyclerView mainContent = findViewById(R.id.board_recycler_view);
mainContent.setAdapter(boardAdapter); mainContent.setAdapter(boardAdapter);
final LinearLayoutManager layoutManager = new LinearLayoutManager(this); final LinearLayoutManager layoutManager = new LinearLayoutManager(this);
mainContent.setLayoutManager(layoutManager); mainContent.setLayoutManager(layoutManager);
@ -165,7 +169,6 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
Log.d("Boardaa", "onResume called!");
refreshBoardBookmark((ImageButton) findViewById(R.id.bookmark)); refreshBoardBookmark((ImageButton) findViewById(R.id.bookmark));
} }

30
app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java

@ -275,13 +275,13 @@ class BoardAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
SubBoardViewHolder(View board) { SubBoardViewHolder(View board) {
super(board); super(board);
boardRow = (LinearLayout) board.findViewById(R.id.child_board_row); boardRow = board.findViewById(R.id.child_board_row);
boardExpandable = (LinearLayout) board.findViewById(R.id.child_board_expandable); boardExpandable = board.findViewById(R.id.child_board_expandable);
showHideExpandable = (ImageButton) board.findViewById(R.id.child_board_expand_collapse_button); showHideExpandable = board.findViewById(R.id.child_board_expand_collapse_button);
boardTitle = (TextView) board.findViewById(R.id.child_board_title); boardTitle = board.findViewById(R.id.child_board_title);
boardMods = (TextView) board.findViewById(R.id.child_board_mods); boardMods = board.findViewById(R.id.child_board_mods);
boardStats = (TextView) board.findViewById(R.id.child_board_stats); boardStats = board.findViewById(R.id.child_board_stats);
boardLastPost = (TextView) board.findViewById(R.id.child_board_last_post); boardLastPost = board.findViewById(R.id.child_board_last_post);
} }
} }
@ -292,13 +292,13 @@ class BoardAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
TopicViewHolder(View topic) { TopicViewHolder(View topic) {
super(topic); super(topic);
topicRow = (LinearLayout) topic.findViewById(R.id.topic_row_linear); topicRow = topic.findViewById(R.id.topic_row_linear);
topicExpandable = (LinearLayout) topic.findViewById(R.id.topic_expandable); topicExpandable = topic.findViewById(R.id.topic_expandable);
showHideExpandable = (ImageButton) topic.findViewById(R.id.topic_expand_collapse_button); showHideExpandable = topic.findViewById(R.id.topic_expand_collapse_button);
topicSubject = (TextView) topic.findViewById(R.id.topic_subject); topicSubject = topic.findViewById(R.id.topic_subject);
topicStartedBy = (TextView) topic.findViewById(R.id.topic_started_by); topicStartedBy = topic.findViewById(R.id.topic_started_by);
topicStats = (TextView) topic.findViewById(R.id.topic_stats); topicStats = topic.findViewById(R.id.topic_stats);
topicLastPost = (TextView) topic.findViewById(R.id.topic_last_post); topicLastPost = topic.findViewById(R.id.topic_last_post);
} }
} }
@ -313,7 +313,7 @@ class BoardAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
LoadingViewHolder(View itemView) { LoadingViewHolder(View itemView) {
super(itemView); super(itemView);
progressBar = (MaterialProgressBar) itemView.findViewById(R.id.recycler_progress_bar); progressBar = itemView.findViewById(R.id.recycler_progress_bar);
} }
} }
} }

9
app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java

@ -7,7 +7,6 @@ import android.support.design.widget.FloatingActionButton;
import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.DividerItemDecoration;
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.view.View; import android.view.View;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.Toast; import android.widget.Toast;
@ -75,7 +74,7 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter.
} else downloadsUrl = downloadsIndexUrl; } else downloadsUrl = downloadsIndexUrl;
//Initialize toolbar //Initialize toolbar
toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar = findViewById(R.id.toolbar);
if (downloadsTitle == null || Objects.equals(downloadsTitle, "")) if (downloadsTitle == null || Objects.equals(downloadsTitle, ""))
toolbar.setTitle("Downloads"); toolbar.setTitle("Downloads");
toolbar.setTitle(downloadsTitle); toolbar.setTitle(downloadsTitle);
@ -88,9 +87,9 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter.
createDrawer(); createDrawer();
drawer.setSelection(DOWNLOADS_ID); drawer.setSelection(DOWNLOADS_ID);
progressBar = (MaterialProgressBar) findViewById(R.id.progressBar); progressBar = findViewById(R.id.progressBar);
recyclerView = (RecyclerView) findViewById(R.id.downloads_recycler_view); recyclerView = findViewById(R.id.downloads_recycler_view);
recyclerView.setHasFixedSize(true); recyclerView.setHasFixedSize(true);
final LinearLayoutManager layoutManager = new LinearLayoutManager(getApplicationContext()); final LinearLayoutManager layoutManager = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(layoutManager); recyclerView.setLayoutManager(layoutManager);
@ -113,7 +112,7 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter.
} }
}); });
uploadFAB = (FloatingActionButton) findViewById(R.id.download_fab); uploadFAB = findViewById(R.id.download_fab);
uploadFAB.setEnabled(false); uploadFAB.setEnabled(false);
uploadFAB.hide(); uploadFAB.hide();

18
app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java

@ -174,14 +174,14 @@ class DownloadsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
DownloadViewHolder(View download) { DownloadViewHolder(View download) {
super(download); super(download);
upperLinear = (LinearLayout) download.findViewById(R.id.upper_linear); upperLinear = download.findViewById(R.id.upper_linear);
downloadRow = (LinearLayout) download.findViewById(R.id.download_row); downloadRow = download.findViewById(R.id.download_row);
informationExpandable = (LinearLayout) download.findViewById(R.id.child_board_expandable); informationExpandable = download.findViewById(R.id.child_board_expandable);
title = (TextView) download.findViewById(R.id.download_title); title = download.findViewById(R.id.download_title);
subTitle = (TextView) download.findViewById(R.id.download_sub_title); subTitle = download.findViewById(R.id.download_sub_title);
uploaderDate = (TextView) download.findViewById(R.id.download_extra_info); uploaderDate = download.findViewById(R.id.download_extra_info);
extraInfo = (TextView) download.findViewById(R.id.download_uploader_date); extraInfo = download.findViewById(R.id.download_uploader_date);
informationExpandableBtn = (ImageButton) download.findViewById(R.id.download_information_button); informationExpandableBtn = download.findViewById(R.id.download_information_button);
} }
} }
@ -190,7 +190,7 @@ class DownloadsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
LoadingViewHolder(View itemView) { LoadingViewHolder(View itemView) {
super(itemView); super(itemView);
progressBar = (MaterialProgressBar) itemView.findViewById(R.id.recycler_progress_bar); progressBar = itemView.findViewById(R.id.recycler_progress_bar);
} }
} }
} }

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

@ -26,6 +26,7 @@ import gr.thmmy.mthmmy.base.BaseActivity;
import gr.thmmy.mthmmy.model.Board; import gr.thmmy.mthmmy.model.Board;
import gr.thmmy.mthmmy.model.ThmmyPage; import gr.thmmy.mthmmy.model.ThmmyPage;
import gr.thmmy.mthmmy.model.TopicSummary; import gr.thmmy.mthmmy.model.TopicSummary;
import timber.log.Timber;
import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE; import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE;
import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_URL; import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_URL;
@ -39,7 +40,7 @@ import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL;
public class MainActivity extends BaseActivity implements RecentFragment.RecentFragmentInteractionListener, ForumFragment.ForumFragmentInteractionListener, UnreadFragment.UnreadFragmentInteractionListener { public class MainActivity extends BaseActivity implements RecentFragment.RecentFragmentInteractionListener, ForumFragment.ForumFragmentInteractionListener, UnreadFragment.UnreadFragmentInteractionListener {
//-----------------------------------------CLASS VARIABLES------------------------------------------ //-----------------------------------------CLASS VARIABLES------------------------------------------
private static final int TIME_INTERVAL = 2000; private static final int TIME_INTERVAL = 2000;
private long mBackPressed; private long mBackPressed;
private SectionsPagerAdapter sectionsPagerAdapter; private SectionsPagerAdapter sectionsPagerAdapter;
@ -52,8 +53,7 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF
redirectToActivityFromIntent(intentFilter); redirectToActivityFromIntent(intentFilter);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
if (sessionManager.isLoginScreenDefault()) if (sessionManager.isLoginScreenDefault()) {
{
//Go to login //Go to login
Intent intent = new Intent(MainActivity.this, LoginActivity.class); Intent intent = new Intent(MainActivity.this, LoginActivity.class);
startActivity(intent); startActivity(intent);
@ -68,15 +68,15 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF
sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
sectionsPagerAdapter.addFragment(RecentFragment.newInstance(1), "RECENT"); sectionsPagerAdapter.addFragment(RecentFragment.newInstance(1), "RECENT");
sectionsPagerAdapter.addFragment(ForumFragment.newInstance(2), "FORUM"); sectionsPagerAdapter.addFragment(ForumFragment.newInstance(2), "FORUM");
if(sessionManager.isLoggedIn()) if (sessionManager.isLoggedIn())
sectionsPagerAdapter.addFragment(UnreadFragment.newInstance(3), "UNREAD"); sectionsPagerAdapter.addFragment(UnreadFragment.newInstance(3), "UNREAD");
//Set up the ViewPager with the sections adapter. //Set up the ViewPager with the sections adapter.
viewPager = (ViewPager) findViewById(R.id.container); viewPager = findViewById(R.id.container);
viewPager.setAdapter(sectionsPagerAdapter); viewPager.setAdapter(sectionsPagerAdapter);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); TabLayout tabLayout = findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager); tabLayout.setupWithViewPager(viewPager);
setMainActivity(this); setMainActivity(this);
@ -129,13 +129,13 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF
@Override @Override
public void onUnreadFragmentInteraction(TopicSummary topicSummary) { public void onUnreadFragmentInteraction(TopicSummary topicSummary) {
if (topicSummary.getLastUser() == null && topicSummary.getDateTimeModified() == null) { if (topicSummary.getTopicUrl() != null) {
return; //TODO! Intent i = new Intent(MainActivity.this, TopicActivity.class);
} i.putExtra(BUNDLE_TOPIC_URL, topicSummary.getTopicUrl());
Intent i = new Intent(MainActivity.this, TopicActivity.class); i.putExtra(BUNDLE_TOPIC_TITLE, topicSummary.getSubject());
i.putExtra(BUNDLE_TOPIC_URL, topicSummary.getTopicUrl()); startActivity(i);
i.putExtra(BUNDLE_TOPIC_TITLE, topicSummary.getSubject()); } else
startActivity(i); Timber.e("onUnreadFragmentInteraction TopicSummary came without a link");
} }
//---------------------------------FragmentPagerAdapter--------------------------------------------- //---------------------------------FragmentPagerAdapter---------------------------------------------
@ -164,8 +164,8 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF
fragmentList.remove(position); fragmentList.remove(position);
fragmentTitleList.remove(position); fragmentTitleList.remove(position);
notifyDataSetChanged(); notifyDataSetChanged();
if(viewPager.getCurrentItem()==position) if (viewPager.getCurrentItem() == position)
viewPager.setCurrentItem(position-1); viewPager.setCurrentItem(position - 1);
} }
@Override @Override
@ -185,16 +185,16 @@ public class MainActivity extends BaseActivity implements RecentFragment.RecentF
@Override @Override
public int getItemPosition(Object object) { public int getItemPosition(Object object) {
int position = fragmentList.indexOf(object); @SuppressWarnings("RedundantCast")
int position = fragmentList.indexOf((Fragment) object);
return position == -1 ? POSITION_NONE : position; return position == -1 ? POSITION_NONE : position;
} }
} }
public void updateTabs() public void updateTabs() {
{ if (!sessionManager.isLoggedIn() && sectionsPagerAdapter.getCount() == 3)
if(!sessionManager.isLoggedIn()&&sectionsPagerAdapter.getCount()==3)
sectionsPagerAdapter.removeFragment(2); sectionsPagerAdapter.removeFragment(2);
else if(sessionManager.isLoggedIn()&&sectionsPagerAdapter.getCount()==2) else if (sessionManager.isLoggedIn() && sectionsPagerAdapter.getCount() == 2)
sectionsPagerAdapter.addFragment(UnreadFragment.newInstance(3), "UNREAD"); sectionsPagerAdapter.addFragment(UnreadFragment.newInstance(3), "UNREAD");
} }
//-------------------------------FragmentPagerAdapter END------------------------------------------- //-------------------------------FragmentPagerAdapter END-------------------------------------------

4
app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumAdapter.java

@ -70,7 +70,7 @@ class ForumAdapter extends ExpandableRecyclerAdapter<Category, Board, ForumAdapt
CategoryViewHolder(View itemView) { CategoryViewHolder(View itemView) {
super(itemView); super(itemView);
categoryTextview = (TextView) itemView.findViewById(R.id.category); categoryTextview = itemView.findViewById(R.id.category);
} }
void bind(Category category) { void bind(Category category) {
@ -86,7 +86,7 @@ class ForumAdapter extends ExpandableRecyclerAdapter<Category, Board, ForumAdapt
BoardViewHolder(View itemView) { BoardViewHolder(View itemView) {
super(itemView); super(itemView);
boardTextView = (TextView) itemView.findViewById(R.id.board); boardTextView = itemView.findViewById(R.id.board);
} }
void bind(final Board board) { void bind(final Board board) {

6
app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java

@ -98,7 +98,7 @@ public class ForumFragment extends BaseFragment {
// Set the adapter // Set the adapter
if (rootView instanceof RelativeLayout) { if (rootView instanceof RelativeLayout) {
progressBar = (MaterialProgressBar) rootView.findViewById(R.id.progressBar); progressBar = rootView.findViewById(R.id.progressBar);
forumAdapter = new ForumAdapter(getContext(), categories, fragmentInteractionListener); forumAdapter = new ForumAdapter(getContext(), categories, fragmentInteractionListener);
forumAdapter.setExpandCollapseListener(new ExpandableRecyclerAdapter.ExpandCollapseListener() { forumAdapter.setExpandCollapseListener(new ExpandableRecyclerAdapter.ExpandCollapseListener() {
@Override @Override
@ -124,7 +124,7 @@ public class ForumFragment extends BaseFragment {
} }
}); });
CustomRecyclerView recyclerView = (CustomRecyclerView) rootView.findViewById(R.id.list); CustomRecyclerView recyclerView = rootView.findViewById(R.id.list);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(rootView.findViewById(R.id.list).getContext()); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(rootView.findViewById(R.id.list).getContext());
recyclerView.setLayoutManager(linearLayoutManager); recyclerView.setLayoutManager(linearLayoutManager);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(), DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
@ -132,7 +132,7 @@ public class ForumFragment extends BaseFragment {
recyclerView.addItemDecoration(dividerItemDecoration); recyclerView.addItemDecoration(dividerItemDecoration);
recyclerView.setAdapter(forumAdapter); recyclerView.setAdapter(forumAdapter);
swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swiperefresh); swipeRefreshLayout = rootView.findViewById(R.id.swiperefresh);
swipeRefreshLayout.setOnRefreshListener( swipeRefreshLayout.setOnRefreshListener(
new SwipeRefreshLayout.OnRefreshListener() { new SwipeRefreshLayout.OnRefreshListener() {
@Override @Override

6
app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentAdapter.java

@ -77,9 +77,9 @@ class RecentAdapter extends RecyclerView.Adapter<RecentAdapter.ViewHolder> {
ViewHolder(View view) { ViewHolder(View view) {
super(view); super(view);
mView = view; mView = view;
mTitleView = (TextView) view.findViewById(R.id.title); mTitleView = view.findViewById(R.id.title);
mUserView = (TextView) view.findViewById(R.id.lastUser); mUserView = view.findViewById(R.id.lastUser);
mDateTimeView = (TextView) view.findViewById(R.id.dateTime); mDateTimeView = view.findViewById(R.id.dateTime);
} }
} }
} }

6
app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java

@ -95,10 +95,10 @@ public class RecentFragment extends BaseFragment {
// Set the adapter // Set the adapter
if (rootView instanceof RelativeLayout) { if (rootView instanceof RelativeLayout) {
progressBar = (MaterialProgressBar) rootView.findViewById(R.id.progressBar); progressBar = rootView.findViewById(R.id.progressBar);
recentAdapter = new RecentAdapter(getActivity(), topicSummaries, fragmentInteractionListener); recentAdapter = new RecentAdapter(getActivity(), topicSummaries, fragmentInteractionListener);
CustomRecyclerView recyclerView = (CustomRecyclerView) rootView.findViewById(R.id.list); CustomRecyclerView recyclerView = rootView.findViewById(R.id.list);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(rootView.findViewById(R.id.list).getContext()); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(rootView.findViewById(R.id.list).getContext());
recyclerView.setLayoutManager(linearLayoutManager); recyclerView.setLayoutManager(linearLayoutManager);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(), DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
@ -106,7 +106,7 @@ public class RecentFragment extends BaseFragment {
recyclerView.addItemDecoration(dividerItemDecoration); recyclerView.addItemDecoration(dividerItemDecoration);
recyclerView.setAdapter(recentAdapter); recyclerView.setAdapter(recentAdapter);
swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swiperefresh); swipeRefreshLayout = rootView.findViewById(R.id.swiperefresh);
swipeRefreshLayout.setOnRefreshListener( swipeRefreshLayout.setOnRefreshListener(
new SwipeRefreshLayout.OnRefreshListener() { new SwipeRefreshLayout.OnRefreshListener() {
@Override @Override

28
app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadAdapter.java

@ -58,18 +58,18 @@ class UnreadAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
} }
@Override @Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) { public void onBindViewHolder(final RecyclerView.ViewHolder holder, final int position) {
if (holder instanceof UnreadAdapter.EmptyViewHolder) { if (holder instanceof UnreadAdapter.EmptyViewHolder) {
final UnreadAdapter.EmptyViewHolder emptyViewHolder = (UnreadAdapter.EmptyViewHolder) holder; final UnreadAdapter.EmptyViewHolder emptyViewHolder = (UnreadAdapter.EmptyViewHolder) holder;
emptyViewHolder.text.setText(unreadList.get(position).getDateTimeModified()); emptyViewHolder.text.setText(unreadList.get(holder.getAdapterPosition()).getDateTimeModified());
} else if (holder instanceof UnreadAdapter.ViewHolder) { } else if (holder instanceof UnreadAdapter.ViewHolder) {
final UnreadAdapter.ViewHolder viewHolder = (UnreadAdapter.ViewHolder) holder; final UnreadAdapter.ViewHolder viewHolder = (UnreadAdapter.ViewHolder) holder;
viewHolder.mTitleView.setText(unreadList.get(position).getSubject()); viewHolder.mTitleView.setText(unreadList.get(holder.getAdapterPosition()).getSubject());
viewHolder.mDateTimeView.setText(unreadList.get(position).getDateTimeModified()); viewHolder.mDateTimeView.setText(unreadList.get(holder.getAdapterPosition()).getDateTimeModified());
viewHolder.mUserView.setText(context.getString(R.string.byUser, unreadList.get(position).getLastUser())); viewHolder.mUserView.setText(context.getString(R.string.byUser, unreadList.get(position).getLastUser()));
viewHolder.topic = unreadList.get(position); viewHolder.topic = unreadList.get(holder.getAdapterPosition());
viewHolder.mView.setOnClickListener(new View.OnClickListener() { viewHolder.mView.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -83,8 +83,8 @@ class UnreadAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
}); });
} else if (holder instanceof UnreadAdapter.MarkReadViewHolder) { } else if (holder instanceof UnreadAdapter.MarkReadViewHolder) {
final UnreadAdapter.MarkReadViewHolder markReadViewHolder = (UnreadAdapter.MarkReadViewHolder) holder; final UnreadAdapter.MarkReadViewHolder markReadViewHolder = (UnreadAdapter.MarkReadViewHolder) holder;
markReadViewHolder.text.setText(unreadList.get(position).getSubject()); markReadViewHolder.text.setText(unreadList.get(holder.getAdapterPosition()).getSubject());
markReadViewHolder.topic = unreadList.get(position); markReadViewHolder.topic = unreadList.get(holder.getAdapterPosition());
markReadViewHolder.mView.setOnClickListener(new View.OnClickListener() { markReadViewHolder.mView.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -92,7 +92,7 @@ class UnreadAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
if (null != mListener) { if (null != mListener) {
// Notify the active callbacks interface (the activity, if the // Notify the active callbacks interface (the activity, if the
// fragment is attached to one) that an item has been selected. // fragment is attached to one) that an item has been selected.
markReadListener.onMarkReadInteraction(unreadList.get(position).getTopicUrl()); markReadListener.onMarkReadInteraction(unreadList.get(holder.getAdapterPosition()).getTopicUrl());
} }
} }
}); });
@ -114,9 +114,9 @@ class UnreadAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
ViewHolder(View view) { ViewHolder(View view) {
super(view); super(view);
mView = view; mView = view;
mTitleView = (TextView) view.findViewById(R.id.title); mTitleView = view.findViewById(R.id.title);
mUserView = (TextView) view.findViewById(R.id.lastUser); mUserView = view.findViewById(R.id.lastUser);
mDateTimeView = (TextView) view.findViewById(R.id.dateTime); mDateTimeView = view.findViewById(R.id.dateTime);
} }
} }
@ -125,7 +125,7 @@ class UnreadAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
EmptyViewHolder(View view) { EmptyViewHolder(View view) {
super(view); super(view);
text = (TextView) view.findViewById(R.id.text); text = view.findViewById(R.id.text);
} }
} }
@ -137,11 +137,11 @@ class UnreadAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
MarkReadViewHolder(View view) { MarkReadViewHolder(View view) {
super(view); super(view);
mView = view; mView = view;
text = (TextView) view.findViewById(R.id.mark_read); text = view.findViewById(R.id.mark_read);
} }
} }
public interface MarkReadInteractionListener { interface MarkReadInteractionListener {
void onMarkReadInteraction(String markReadLinkUrl); void onMarkReadInteraction(String markReadLinkUrl);
} }
} }

6
app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java

@ -98,7 +98,7 @@ public class UnreadFragment extends BaseFragment {
// Set the adapter // Set the adapter
if (rootView instanceof RelativeLayout) { if (rootView instanceof RelativeLayout) {
progressBar = (MaterialProgressBar) rootView.findViewById(R.id.progressBar); progressBar = rootView.findViewById(R.id.progressBar);
unreadAdapter = new UnreadAdapter(getActivity(), topicSummaries, unreadAdapter = new UnreadAdapter(getActivity(), topicSummaries,
fragmentInteractionListener, new UnreadAdapter.MarkReadInteractionListener() { fragmentInteractionListener, new UnreadAdapter.MarkReadInteractionListener() {
@Override @Override
@ -110,7 +110,7 @@ public class UnreadFragment extends BaseFragment {
} }
}); });
CustomRecyclerView recyclerView = (CustomRecyclerView) rootView.findViewById(R.id.list); CustomRecyclerView recyclerView = rootView.findViewById(R.id.list);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(rootView.findViewById(R.id.list).getContext()); LinearLayoutManager linearLayoutManager = new LinearLayoutManager(rootView.findViewById(R.id.list).getContext());
recyclerView.setLayoutManager(linearLayoutManager); recyclerView.setLayoutManager(linearLayoutManager);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(), DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(),
@ -118,7 +118,7 @@ public class UnreadFragment extends BaseFragment {
recyclerView.addItemDecoration(dividerItemDecoration); recyclerView.addItemDecoration(dividerItemDecoration);
recyclerView.setAdapter(unreadAdapter); recyclerView.setAdapter(unreadAdapter);
swipeRefreshLayout = (SwipeRefreshLayout) rootView.findViewById(R.id.swiperefresh); swipeRefreshLayout = rootView.findViewById(R.id.swiperefresh);
swipeRefreshLayout.setOnRefreshListener( swipeRefreshLayout.setOnRefreshListener(
new SwipeRefreshLayout.OnRefreshListener() { new SwipeRefreshLayout.OnRefreshListener() {
@Override @Override

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

@ -13,7 +13,6 @@ import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter; import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.content.res.ResourcesCompat; import android.support.v4.content.res.ResourcesCompat;
import android.support.v4.view.ViewPager; import android.support.v4.view.ViewPager;
import android.support.v7.widget.Toolbar;
import android.text.Spannable; import android.text.Spannable;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.Spanned; import android.text.Spanned;
@ -105,7 +104,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
profileUrl = extras.getString(BUNDLE_PROFILE_URL); profileUrl = extras.getString(BUNDLE_PROFILE_URL);
//Initializes graphic elements //Initializes graphic elements
toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar = findViewById(R.id.toolbar);
toolbar.setTitle(null); toolbar.setTitle(null);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
if (getSupportActionBar() != null) { if (getSupportActionBar() != null) {
@ -115,9 +114,9 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
createDrawer(); createDrawer();
progressBar = (MaterialProgressBar) findViewById(R.id.progressBar); progressBar = findViewById(R.id.progressBar);
thumbnailView = (ImageView) findViewById(R.id.user_thumbnail); thumbnailView = findViewById(R.id.user_thumbnail);
if (!Objects.equals(thumbnailUrl, "")) if (!Objects.equals(thumbnailUrl, ""))
//noinspection ConstantConditions //noinspection ConstantConditions
Picasso.with(this) Picasso.with(this)
@ -130,15 +129,15 @@ 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);
usernameView = (TextView) findViewById(R.id.profile_activity_username); usernameView = findViewById(R.id.profile_activity_username);
usernameView.setTypeface(Typeface.createFromAsset(this.getAssets() usernameView.setTypeface(Typeface.createFromAsset(this.getAssets()
, "fonts/fontawesome-webfont.ttf")); , "fonts/fontawesome-webfont.ttf"));
if (username != null && !Objects.equals(username, "")) usernameView.setText(username); if (username != null && !Objects.equals(username, "")) usernameView.setText(username);
personalTextView = (TextView) findViewById(R.id.profile_activity_personal_text); personalTextView = findViewById(R.id.profile_activity_personal_text);
viewPager = (ViewPager) findViewById(R.id.profile_tab_container); viewPager = findViewById(R.id.profile_tab_container);
pmFAB = (FloatingActionButton) findViewById(R.id.profile_fab); pmFAB = findViewById(R.id.profile_fab);
pmFAB.setEnabled(false); pmFAB.setEnabled(false);
pmFAB.hide(); pmFAB.hide();
/*if (!sessionManager.isLoggedIn()) pmFAB.hide(); /*if (!sessionManager.isLoggedIn()) pmFAB.hide();
@ -311,7 +310,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
} }
setupViewPager(viewPager, profilePage); setupViewPager(viewPager, profilePage);
TabLayout tabLayout = (TabLayout) findViewById(R.id.profile_tabs); TabLayout tabLayout = findViewById(R.id.profile_tabs);
tabLayout.setupWithViewPager(viewPager); tabLayout.setupWithViewPager(viewPager);
if (tabSelect != 0) { if (tabSelect != 0) {
TabLayout.Tab tab = tabLayout.getTabAt(tabSelect); TabLayout.Tab tab = tabLayout.getTabAt(tabSelect);

10
app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java

@ -97,10 +97,10 @@ class LatestPostsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
LatestPostViewHolder(View itemView) { LatestPostViewHolder(View itemView) {
super(itemView); super(itemView);
latestPostsRow = (RelativeLayout) itemView.findViewById(R.id.latest_posts_row); latestPostsRow = itemView.findViewById(R.id.latest_posts_row);
postTitle = (TextView) itemView.findViewById(R.id.title); postTitle = itemView.findViewById(R.id.title);
postDate = (TextView) itemView.findViewById(R.id.date); postDate = itemView.findViewById(R.id.date);
post = (WebView) itemView.findViewById(R.id.post); post = itemView.findViewById(R.id.post);
} }
} }
@ -109,7 +109,7 @@ class LatestPostsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
LoadingViewHolder(View itemView) { LoadingViewHolder(View itemView) {
super(itemView); super(itemView);
progressBar = (MaterialProgressBar) itemView.findViewById(R.id.recycler_progress_bar); progressBar = itemView.findViewById(R.id.recycler_progress_bar);
} }
} }
} }

6
app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java

@ -33,7 +33,7 @@ import timber.log.Timber;
/** /**
* Use the {@link LatestPostsFragment#newInstance} factory method to create an instance of this fragment. * Use the {@link LatestPostsFragment#newInstance} factory method to create an instance of this fragment.
*/ */
public class LatestPostsFragment extends BaseFragment implements LatestPostsAdapter.OnLoadMoreListener{ public class LatestPostsFragment extends BaseFragment implements LatestPostsAdapter.OnLoadMoreListener {
/** /**
* The key to use when putting profile's url String to {@link LatestPostsFragment}'s Bundle. * The key to use when putting profile's url String to {@link LatestPostsFragment}'s Bundle.
*/ */
@ -84,7 +84,7 @@ public class LatestPostsFragment extends BaseFragment implements LatestPostsAdap
Bundle savedInstanceState) { Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.fragment_latest_posts, container, false); final View rootView = inflater.inflate(R.layout.fragment_latest_posts, container, false);
latestPostsAdapter = new LatestPostsAdapter(fragmentInteractionListener, parsedTopicSummaries); latestPostsAdapter = new LatestPostsAdapter(fragmentInteractionListener, parsedTopicSummaries);
RecyclerView mainContent = (RecyclerView) rootView.findViewById(R.id.profile_latest_posts_recycler); RecyclerView mainContent = rootView.findViewById(R.id.profile_latest_posts_recycler);
mainContent.setAdapter(latestPostsAdapter); mainContent.setAdapter(latestPostsAdapter);
final LinearLayoutManager layoutManager = new LinearLayoutManager(getContext()); final LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
mainContent.setLayoutManager(layoutManager); mainContent.setLayoutManager(layoutManager);
@ -106,7 +106,7 @@ public class LatestPostsFragment extends BaseFragment implements LatestPostsAdap
} }
} }
}); });
progressBar = (MaterialProgressBar) rootView.findViewById(R.id.progressBar); progressBar = rootView.findViewById(R.id.progressBar);
return rootView; return rootView;
} }

10
app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java

@ -90,8 +90,8 @@ public class StatsFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.fragment_stats, container, false); final View rootView = inflater.inflate(R.layout.fragment_stats, container, false);
mainContent = (LinearLayout) rootView.findViewById(R.id.main_content); mainContent = rootView.findViewById(R.id.main_content);
progressBar = (MaterialProgressBar) rootView.findViewById(R.id.progressBar); progressBar = rootView.findViewById(R.id.progressBar);
if (haveParsed) if (haveParsed)
populateLayout(); populateLayout();
return rootView; return rootView;
@ -224,7 +224,7 @@ public class StatsFragment extends Fragment {
((TextView) mainContent.findViewById(R.id.posting_activity_by_time_title)) ((TextView) mainContent.findViewById(R.id.posting_activity_by_time_title))
.setText(postingActivityByTimeTitle); .setText(postingActivityByTimeTitle);
LineChart postingActivityByTimeChart = (LineChart) mainContent LineChart postingActivityByTimeChart = mainContent
.findViewById(R.id.posting_activity_by_time_chart); .findViewById(R.id.posting_activity_by_time_chart);
postingActivityByTimeChart.setDescription(null); postingActivityByTimeChart.setDescription(null);
postingActivityByTimeChart.getLegend().setEnabled(false); postingActivityByTimeChart.getLegend().setEnabled(false);
@ -257,7 +257,7 @@ public class StatsFragment extends Fragment {
((TextView) mainContent.findViewById(R.id.most_popular_boards_by_posts_title)) ((TextView) mainContent.findViewById(R.id.most_popular_boards_by_posts_title))
.setText(mostPopularBoardsByPostsTitle); .setText(mostPopularBoardsByPostsTitle);
HorizontalBarChart mostPopularBoardsByPostsChart = (HorizontalBarChart) mainContent. HorizontalBarChart mostPopularBoardsByPostsChart = mainContent.
findViewById(R.id.most_popular_boards_by_posts_chart); findViewById(R.id.most_popular_boards_by_posts_chart);
mostPopularBoardsByPostsChart.setDescription(null); mostPopularBoardsByPostsChart.setDescription(null);
mostPopularBoardsByPostsChart.getLegend().setEnabled(false); mostPopularBoardsByPostsChart.getLegend().setEnabled(false);
@ -298,7 +298,7 @@ public class StatsFragment extends Fragment {
((TextView) mainContent.findViewById(R.id.most_popular_boards_by_activity_title)) ((TextView) mainContent.findViewById(R.id.most_popular_boards_by_activity_title))
.setText(mostPopularBoardsByActivityTitle); .setText(mostPopularBoardsByActivityTitle);
HorizontalBarChart mostPopularBoardsByActivityChart = (HorizontalBarChart) mainContent. HorizontalBarChart mostPopularBoardsByActivityChart = mainContent.
findViewById(R.id.most_popular_boards_by_activity_chart); findViewById(R.id.most_popular_boards_by_activity_chart);
mostPopularBoardsByActivityChart.setDescription(null); mostPopularBoardsByActivityChart.setDescription(null);
mostPopularBoardsByActivityChart.getLegend().setEnabled(false); mostPopularBoardsByActivityChart.getLegend().setEnabled(false);

2
app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java

@ -77,7 +77,7 @@ public class SummaryFragment extends Fragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
final View rootView = inflater.inflate(R.layout.fragment_summary, container, false); final View rootView = inflater.inflate(R.layout.fragment_summary, container, false);
mainContent = (LinearLayout) rootView.findViewById(R.id.profile_activity_content); mainContent = rootView.findViewById(R.id.profile_activity_content);
if (!parsedProfileSummaryData.isEmpty() && isAdded()) if (!parsedProfileSummaryData.isEmpty() && isAdded())
populateLayout(); populateLayout();
return rootView; return rootView;

60
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java

@ -11,7 +11,6 @@ import android.os.Handler;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.text.Html; import android.text.Html;
import android.text.SpannableStringBuilder; import android.text.SpannableStringBuilder;
import android.text.TextUtils; import android.text.TextUtils;
@ -143,8 +142,8 @@ public class TopicActivity extends BaseActivity {
thisPageBookmark = new Bookmark(topicTitle, ThmmyPage.getTopicId(topicPageUrl)); thisPageBookmark = new Bookmark(topicTitle, ThmmyPage.getTopicId(topicPageUrl));
//Initializes graphics //Initializes graphics
toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar = findViewById(R.id.toolbar);
toolbarTitle = (TextView) toolbar.findViewById(R.id.toolbar_title); toolbarTitle = toolbar.findViewById(R.id.toolbar_title);
toolbarTitle.setSingleLine(true); toolbarTitle.setSingleLine(true);
toolbarTitle.setEllipsize(TextUtils.TruncateAt.MARQUEE); toolbarTitle.setEllipsize(TextUtils.TruncateAt.MARQUEE);
toolbarTitle.setMarqueeRepeatLimit(-1); toolbarTitle.setMarqueeRepeatLimit(-1);
@ -162,11 +161,11 @@ public class TopicActivity extends BaseActivity {
createDrawer(); createDrawer();
progressBar = (MaterialProgressBar) findViewById(R.id.progressBar); progressBar = findViewById(R.id.progressBar);
postsList = new ArrayList<>(); postsList = new ArrayList<>();
recyclerView = (RecyclerView) findViewById(R.id.topic_recycler_view); recyclerView = findViewById(R.id.topic_recycler_view);
recyclerView.setHasFixedSize(true); recyclerView.setHasFixedSize(true);
recyclerView.setOnTouchListener( recyclerView.setOnTouchListener(
new View.OnTouchListener() { new View.OnTouchListener() {
@ -183,9 +182,9 @@ public class TopicActivity extends BaseActivity {
topicAdapter = new TopicAdapter(this, postsList, topicTask); topicAdapter = new TopicAdapter(this, postsList, topicTask);
recyclerView.setAdapter(topicAdapter); recyclerView.setAdapter(topicAdapter);
replyFAB = (FloatingActionButton) findViewById(R.id.topic_fab); replyFAB = findViewById(R.id.topic_fab);
replyFAB.setEnabled(false); replyFAB.setEnabled(false);
bottomNavBar = (LinearLayout) findViewById(R.id.bottom_navigation_bar); bottomNavBar = findViewById(R.id.bottom_navigation_bar);
if (!sessionManager.isLoggedIn()) replyFAB.hide(); if (!sessionManager.isLoggedIn()) replyFAB.hide();
else { else {
replyFAB.setOnClickListener(new View.OnClickListener() { replyFAB.setOnClickListener(new View.OnClickListener() {
@ -204,11 +203,11 @@ public class TopicActivity extends BaseActivity {
} }
//Sets bottom navigation bar //Sets bottom navigation bar
firstPage = (ImageButton) findViewById(R.id.page_first_button); firstPage = findViewById(R.id.page_first_button);
previousPage = (ImageButton) findViewById(R.id.page_previous_button); previousPage = findViewById(R.id.page_previous_button);
pageIndicator = (TextView) findViewById(R.id.page_indicator); pageIndicator = findViewById(R.id.page_indicator);
nextPage = (ImageButton) findViewById(R.id.page_next_button); nextPage = findViewById(R.id.page_next_button);
lastPage = (ImageButton) findViewById(R.id.page_last_button); lastPage = findViewById(R.id.page_last_button);
initDecrementButton(firstPage, LARGE_STEP); initDecrementButton(firstPage, LARGE_STEP);
initDecrementButton(previousPage, SMALL_STEP); initDecrementButton(previousPage, SMALL_STEP);
@ -242,11 +241,10 @@ public class TopicActivity extends BaseActivity {
LayoutInflater inflater = this.getLayoutInflater(); LayoutInflater inflater = this.getLayoutInflater();
LinearLayout infoDialog = (LinearLayout) inflater.inflate(R.layout.dialog_topic_info LinearLayout infoDialog = (LinearLayout) inflater.inflate(R.layout.dialog_topic_info
, null); , null);
((TextView) infoDialog.findViewById(R.id.dialog_title)).setText("Info"); TextView treeAndMods = infoDialog.findViewById(R.id.topic_tree_and_mods);
TextView treeAndMods = (TextView) infoDialog.findViewById(R.id.topic_tree_and_mods);
treeAndMods.setText(topicTreeAndMods); treeAndMods.setText(topicTreeAndMods);
treeAndMods.setMovementMethod(LinkMovementMethod.getInstance()); treeAndMods.setMovementMethod(LinkMovementMethod.getInstance());
TextView usersViewing = (TextView) infoDialog.findViewById(R.id.users_viewing); TextView usersViewing = infoDialog.findViewById(R.id.users_viewing);
usersViewing.setText(topicViewers); usersViewing.setText(topicViewers);
usersViewing.setMovementMethod(LinkMovementMethod.getInstance()); usersViewing.setMovementMethod(LinkMovementMethod.getInstance());
@ -318,25 +316,25 @@ public class TopicActivity extends BaseActivity {
lastPage.setEnabled(enabled); lastPage.setEnabled(enabled);
} }
private void paginationEnabledExcept(boolean enabled, View exception) { private void paginationDisable(View exception) {
if (exception == firstPage) { if (exception == firstPage) {
previousPage.setEnabled(enabled); previousPage.setEnabled(false);
nextPage.setEnabled(enabled); nextPage.setEnabled(false);
lastPage.setEnabled(enabled); lastPage.setEnabled(false);
} else if (exception == previousPage) { } else if (exception == previousPage) {
firstPage.setEnabled(enabled); firstPage.setEnabled(false);
nextPage.setEnabled(enabled); nextPage.setEnabled(false);
lastPage.setEnabled(enabled); lastPage.setEnabled(false);
} else if (exception == nextPage) { } else if (exception == nextPage) {
firstPage.setEnabled(enabled); firstPage.setEnabled(false);
previousPage.setEnabled(enabled); previousPage.setEnabled(false);
lastPage.setEnabled(enabled); lastPage.setEnabled(false);
} else if (exception == lastPage) { } else if (exception == lastPage) {
firstPage.setEnabled(enabled); firstPage.setEnabled(false);
previousPage.setEnabled(enabled); previousPage.setEnabled(false);
nextPage.setEnabled(enabled); nextPage.setEnabled(false);
} else { } else {
paginationEnabled(enabled); paginationEnabled(false);
} }
} }
@ -357,7 +355,7 @@ public class TopicActivity extends BaseActivity {
increment.setOnLongClickListener( increment.setOnLongClickListener(
new View.OnLongClickListener() { new View.OnLongClickListener() {
public boolean onLongClick(View arg0) { public boolean onLongClick(View arg0) {
paginationEnabledExcept(false, arg0); paginationDisable(arg0);
autoIncrement = true; autoIncrement = true;
repeatUpdateHandler.postDelayed(new RepetitiveUpdater(step), INITIAL_DELAY); repeatUpdateHandler.postDelayed(new RepetitiveUpdater(step), INITIAL_DELAY);
return false; return false;
@ -405,7 +403,7 @@ public class TopicActivity extends BaseActivity {
decrement.setOnLongClickListener( decrement.setOnLongClickListener(
new View.OnLongClickListener() { new View.OnLongClickListener() {
public boolean onLongClick(View arg0) { public boolean onLongClick(View arg0) {
paginationEnabledExcept(false, arg0); paginationDisable(arg0);
autoDecrement = true; autoDecrement = true;
repeatUpdateHandler.postDelayed(new RepetitiveUpdater(step), INITIAL_DELAY); repeatUpdateHandler.postDelayed(new RepetitiveUpdater(step), INITIAL_DELAY);
return false; return false;

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

@ -139,7 +139,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
inflate(R.layout.activity_topic_quick_reply_row, parent, false); inflate(R.layout.activity_topic_quick_reply_row, parent, false);
view.findViewById(R.id.quick_reply_submit).setEnabled(true); view.findViewById(R.id.quick_reply_submit).setEnabled(true);
final EditText quickReplyText = (EditText) view.findViewById(R.id.quick_reply_text); final EditText quickReplyText = view.findViewById(R.id.quick_reply_text);
quickReplyText.setFocusableInTouchMode(true); quickReplyText.setFocusableInTouchMode(true);
quickReplyText.setOnFocusChangeListener(new View.OnFocusChangeListener() { quickReplyText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override @Override
@ -511,29 +511,29 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
super(view); super(view);
//Initializes layout's graphic elements //Initializes layout's graphic elements
//Standard stuff //Standard stuff
cardView = (CardView) view.findViewById(R.id.card_view); cardView = view.findViewById(R.id.card_view);
cardChildLinear = (LinearLayout) view.findViewById(R.id.card_child_linear); cardChildLinear = view.findViewById(R.id.card_child_linear);
postDateAndNumber = (FrameLayout) view.findViewById(R.id.post_date_and_number_exp); postDateAndNumber = view.findViewById(R.id.post_date_and_number_exp);
postDate = (TextView) view.findViewById(R.id.post_date); postDate = view.findViewById(R.id.post_date);
postNum = (TextView) view.findViewById(R.id.post_number); postNum = view.findViewById(R.id.post_number);
thumbnail = (ImageView) view.findViewById(R.id.thumbnail); thumbnail = view.findViewById(R.id.thumbnail);
username = (TextView) view.findViewById(R.id.username); username = view.findViewById(R.id.username);
subject = (TextView) view.findViewById(R.id.subject); subject = view.findViewById(R.id.subject);
post = (WebView) view.findViewById(R.id.post); post = view.findViewById(R.id.post);
post.setBackgroundColor(Color.argb(1, 255, 255, 255)); post.setBackgroundColor(Color.argb(1, 255, 255, 255));
quoteToggle = (ImageButton) view.findViewById(R.id.toggle_quote_button); quoteToggle = view.findViewById(R.id.toggle_quote_button);
bodyFooterDivider = view.findViewById(R.id.body_footer_divider); bodyFooterDivider = view.findViewById(R.id.body_footer_divider);
postFooter = (LinearLayout) view.findViewById(R.id.post_footer); postFooter = view.findViewById(R.id.post_footer);
//User's extra info //User's extra info
header = (RelativeLayout) view.findViewById(R.id.header); header = view.findViewById(R.id.header);
userExtraInfo = (LinearLayout) view.findViewById(R.id.user_extra_info); userExtraInfo = view.findViewById(R.id.user_extra_info);
specialRank = (TextView) view.findViewById(R.id.special_rank); specialRank = view.findViewById(R.id.special_rank);
rank = (TextView) view.findViewById(R.id.rank); rank = view.findViewById(R.id.rank);
gender = (TextView) view.findViewById(R.id.gender); gender = view.findViewById(R.id.gender);
numberOfPosts = (TextView) view.findViewById(R.id.number_of_posts); numberOfPosts = view.findViewById(R.id.number_of_posts);
personalText = (TextView) view.findViewById(R.id.personal_text); personalText = view.findViewById(R.id.personal_text);
stars = (TextView) view.findViewById(R.id.stars); stars = view.findViewById(R.id.stars);
} }
} }
@ -550,15 +550,15 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
QuickReplyViewHolder(View quickReply, CustomEditTextListener replySubject QuickReplyViewHolder(View quickReply, CustomEditTextListener replySubject
, CustomEditTextListener replyText) { , CustomEditTextListener replyText) {
super(quickReply); super(quickReply);
thumbnail = (ImageView) quickReply.findViewById(R.id.thumbnail); thumbnail = quickReply.findViewById(R.id.thumbnail);
username = (TextView) quickReply.findViewById(R.id.username); username = quickReply.findViewById(R.id.username);
this.quickReply = (EditText) quickReply.findViewById(R.id.quick_reply_text); this.quickReply = quickReply.findViewById(R.id.quick_reply_text);
this.replyText = replyText; this.replyText = replyText;
this.quickReply.addTextChangedListener(replyText); this.quickReply.addTextChangedListener(replyText);
quickReplySubject = (EditText) quickReply.findViewById(R.id.quick_reply_subject); quickReplySubject = quickReply.findViewById(R.id.quick_reply_subject);
this.replySubject = replySubject; this.replySubject = replySubject;
quickReplySubject.addTextChangedListener(replySubject); quickReplySubject.addTextChangedListener(replySubject);
submitButton = (AppCompatImageButton) quickReply.findViewById(R.id.quick_reply_submit); submitButton = quickReply.findViewById(R.id.quick_reply_submit);
} }
} }

11
app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java

@ -138,10 +138,8 @@ public abstract class BaseActivity extends AppCompatActivity {
private AccountHeader accountHeader; private AccountHeader accountHeader;
private ProfileDrawerItem profileDrawerItem; private ProfileDrawerItem profileDrawerItem;
private PrimaryDrawerItem homeItem, downloadsItem, bookmarksItem, loginLogoutItem, aboutItem; private PrimaryDrawerItem downloadsItem, loginLogoutItem;
private IconicsDrawable homeIcon, homeIconSelected, downloadsIcon, downloadsIconSelected, private IconicsDrawable loginIcon, logoutIcon;
bookmarksIcon, bookmarksIconSelected, loginIcon, logoutIcon, aboutIcon,
aboutIconSelected;
/** /**
* Call only after initializing Toolbar * Call only after initializing Toolbar
@ -151,6 +149,11 @@ public abstract class BaseActivity extends AppCompatActivity {
final int selectedPrimaryColor = ContextCompat.getColor(this, R.color.primary_dark); final int selectedPrimaryColor = ContextCompat.getColor(this, R.color.primary_dark);
final int selectedSecondaryColor = ContextCompat.getColor(this, R.color.accent); final int selectedSecondaryColor = ContextCompat.getColor(this, R.color.accent);
PrimaryDrawerItem homeItem, bookmarksItem, aboutItem;
IconicsDrawable homeIcon, homeIconSelected, downloadsIcon, downloadsIconSelected,
bookmarksIcon, bookmarksIconSelected, aboutIcon,
aboutIconSelected;
//Drawer Icons //Drawer Icons
homeIcon = new IconicsDrawable(this) homeIcon = new IconicsDrawable(this)
.icon(FontAwesome.Icon.faw_home) .icon(FontAwesome.Icon.faw_home)

5
app/src/main/java/gr/thmmy/mthmmy/base/BaseFragment.java

@ -13,15 +13,12 @@ public abstract class BaseFragment extends Fragment {
protected FragmentInteractionListener fragmentInteractionListener; protected FragmentInteractionListener fragmentInteractionListener;
private String TAG;
private int sectionNumber;
protected static OkHttpClient client; protected static OkHttpClient client;
@Override @Override
public void onCreate(@Nullable Bundle savedInstanceState) { public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
TAG = getArguments().getString(ARG_TAG); //int sectionNumber = getArguments().getInt(ARG_SECTION_NUMBER);
sectionNumber = getArguments().getInt(ARG_SECTION_NUMBER);
if (client == null) if (client == null)
client = BaseApplication.getInstance().getClient(); //must check every time - e.g. client = BaseApplication.getInstance().getClient(); //must check every time - e.g.
// becomes null when app restarts after crash // becomes null when app restarts after crash

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

@ -162,7 +162,7 @@ public class ThmmyPage {
|| Objects.equals(uriString, "https://www.thmmy.gr") || Objects.equals(uriString, "https://www.thmmy.gr")
|| Objects.equals(uriString, "https://www.thmmy.gr/smf/index.php")) || Objects.equals(uriString, "https://www.thmmy.gr/smf/index.php"))
return PageCategory.INDEX; return PageCategory.INDEX;
Timber.v("Unknown thmmy link found, link: %s" , uriString); Timber.v("Unknown thmmy link found, link: %s", uriString);
return PageCategory.UNKNOWN_THMMY; return PageCategory.UNKNOWN_THMMY;
} }
return PageCategory.NOT_THMMY; return PageCategory.NOT_THMMY;
@ -172,7 +172,7 @@ public class ThmmyPage {
if (resolvePageCategory(Uri.parse(boardUrl)) == PageCategory.BOARD) { if (resolvePageCategory(Uri.parse(boardUrl)) == PageCategory.BOARD) {
String returnString = boardUrl.substring(boardUrl.indexOf("board=") + 6); String returnString = boardUrl.substring(boardUrl.indexOf("board=") + 6);
if (returnString.contains(".")) if (returnString.contains("."))
returnString = boardUrl.substring(boardUrl.indexOf("board=") + 6, boardUrl.lastIndexOf(".")); returnString = returnString.substring(0, returnString.indexOf("."));
return returnString; return returnString;
} }
return null; return null;
@ -180,8 +180,10 @@ public class ThmmyPage {
public static String getTopicId(String topicUrl) { public static String getTopicId(String topicUrl) {
if (resolvePageCategory(Uri.parse(topicUrl)) == PageCategory.TOPIC) { if (resolvePageCategory(Uri.parse(topicUrl)) == PageCategory.TOPIC) {
String tmp = topicUrl.substring(topicUrl.indexOf("topic=") + 6); String returnString = topicUrl.substring(topicUrl.indexOf("topic=") + 6);
return tmp.substring(0, tmp.indexOf(".")); if (returnString.contains("."))
returnString = returnString.substring(0, returnString.indexOf("."));
return returnString;
} }
return null; return null;
} }

12
app/src/main/java/gr/thmmy/mthmmy/receiver/Receiver.java

@ -29,8 +29,7 @@ import static gr.thmmy.mthmmy.services.DownloadService.STARTED;
public class Receiver extends BroadcastReceiver { public class Receiver extends BroadcastReceiver {
public Receiver() { public Receiver() {}
}
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
@ -48,11 +47,11 @@ public class Receiver extends BroadcastReceiver {
builder.setContentTitle(title) builder.setContentTitle(title)
.setContentText(text) .setContentText(text)
.setTicker(ticker) .setTicker(ticker)
.setAutoCancel(true) .setAutoCancel(true);
.setSmallIcon(R.drawable.ic_file_download);
if (state.equals(STARTED)) if (state.equals(STARTED))
builder.setOngoing(true); builder.setOngoing(true)
.setSmallIcon(android.R.drawable.stat_sys_download);
else if (state.equals(COMPLETED)) { else if (state.equals(COMPLETED)) {
String fileName = extras.getString(EXTRA_FILE_NAME, "NONE"); String fileName = extras.getString(EXTRA_FILE_NAME, "NONE");
@ -68,7 +67,8 @@ public class Receiver extends BroadcastReceiver {
Intent chooser = Intent.createChooser(chooserIntent, "Open With..."); Intent chooser = Intent.createChooser(chooserIntent, "Open With...");
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, chooser, PendingIntent.FLAG_CANCEL_CURRENT); PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, chooser, PendingIntent.FLAG_CANCEL_CURRENT);
builder.setContentIntent(pendingIntent); builder.setContentIntent(pendingIntent)
.setSmallIcon(android.R.drawable.stat_sys_download_done);
} else } else
Timber.w("File doesn't exist."); Timber.w("File doesn't exist.");

8
app/src/main/java/gr/thmmy/mthmmy/services/DownloadService.java

@ -106,9 +106,9 @@ public class DownloadService extends IntentService {
Request request = new Request.Builder().url(downloadLink).build(); Request request = new Request.Builder().url(downloadLink).build();
Response response = client.newCall(request).execute(); Response response = client.newCall(request).execute();
String contentType = response.headers("Content-Type").toString(); //check if link provides a binary file String contentDisposition = response.headers("Content-Disposition").toString(); //check if link provides an attachment
if (contentType.equals("[application/octet-stream]")) { if (contentDisposition.contains("attachment")){
fileName = response.headers("Content-Disposition").toString().split("\"")[1]; fileName = contentDisposition.split("\"")[1];
File dirPath = new File(SAVE_DIR); File dirPath = new File(SAVE_DIR);
if (!dirPath.isDirectory()) { if (!dirPath.isDirectory()) {
@ -150,7 +150,7 @@ public class DownloadService extends IntentService {
Timber.i("Download OK!"); Timber.i("Download OK!");
sendNotification(downloadId, COMPLETED, fileName); sendNotification(downloadId, COMPLETED, fileName);
} else } else
Timber.e("Response not a binary file!"); Timber.e("No attachment in response!");
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
Timber.i("Download failed..."); Timber.i("Download failed...");
Timber.e(e, "FileNotFound"); Timber.e(e, "FileNotFound");

5
app/src/main/java/gr/thmmy/mthmmy/utils/CustomLinearLayoutManager.java

@ -3,12 +3,11 @@ package gr.thmmy.mthmmy.utils;
import android.content.Context; import android.content.Context;
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.util.Log;
import timber.log.Timber; import timber.log.Timber;
public class CustomLinearLayoutManager extends LinearLayoutManager { public class CustomLinearLayoutManager extends LinearLayoutManager {
private String pageUrl; private final String pageUrl;
public CustomLinearLayoutManager(Context context, String pageUrl) { public CustomLinearLayoutManager(Context context, String pageUrl) {
super(context); super(context);
@ -21,8 +20,6 @@ public class CustomLinearLayoutManager extends LinearLayoutManager {
super.onLayoutChildren(recycler, state); super.onLayoutChildren(recycler, state);
} catch (IndexOutOfBoundsException e) { } catch (IndexOutOfBoundsException e) {
Timber.wtf(e, "Inconsistency detected: topic_requested = \"" + pageUrl + "\""); Timber.wtf(e, "Inconsistency detected: topic_requested = \"" + pageUrl + "\"");
Log.d("CustomLinearLayoutMan", "Inconsistency detected: topic_requested = \""
+ pageUrl + "\"", e);
} }
} }

22
app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareFABBehavior.java

@ -1,6 +1,7 @@
package gr.thmmy.mthmmy.utils; package gr.thmmy.mthmmy.utils;
import android.content.Context; import android.content.Context;
import android.support.annotation.NonNull;
import android.support.design.widget.CoordinatorLayout; import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton; import android.support.design.widget.FloatingActionButton;
import android.support.v4.view.ViewCompat; import android.support.v4.view.ViewCompat;
@ -11,27 +12,28 @@ import android.view.View;
* Extends FloatingActionButton's behavior so the button will hide when scrolling down and show * Extends FloatingActionButton's behavior so the button will hide when scrolling down and show
* otherwise. * otherwise.
*/ */
@SuppressWarnings("WeakerAccess") @SuppressWarnings("unused")
public class ScrollAwareFABBehavior extends CoordinatorLayout.Behavior<FloatingActionButton> { public class ScrollAwareFABBehavior extends CoordinatorLayout.Behavior<FloatingActionButton> {
String TAG = "ScrollAwareFABBehavior";
@SuppressWarnings("UnusedParameters")
public ScrollAwareFABBehavior(Context context, AttributeSet attrs) { public ScrollAwareFABBehavior(Context context, AttributeSet attrs) {
super(); super();
} }
@Override @Override
public boolean onStartNestedScroll(final CoordinatorLayout coordinatorLayout, final FloatingActionButton child, public boolean onStartNestedScroll(@NonNull final CoordinatorLayout coordinatorLayout,
final View directTargetChild, final View target, final int nestedScrollAxes) { @NonNull final FloatingActionButton child,
@NonNull final View directTargetChild, @NonNull final View target,
final int nestedScrollAxes, int type) {
return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL; return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL;
} }
@Override @Override
public void onNestedScroll(final CoordinatorLayout coordinatorLayout, public void onNestedScroll(@NonNull final CoordinatorLayout coordinatorLayout,
final FloatingActionButton child, @NonNull final FloatingActionButton child,
final View target, final int dxConsumed, final int dyConsumed, @NonNull final View target, final int dxConsumed, final int dyConsumed,
final int dxUnconsumed, final int dyUnconsumed) { final int dxUnconsumed, final int dyUnconsumed, int type) {
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed); super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed,
dyUnconsumed, type);
if ((dyConsumed > 0 || (!target.canScrollVertically(-1) && dyConsumed == 0 if ((dyConsumed > 0 || (!target.canScrollVertically(-1) && dyConsumed == 0
&& dyUnconsumed < 40)) && child.getVisibility() == View.VISIBLE) { && dyUnconsumed < 40)) && child.getVisibility() == View.VISIBLE) {
child.hide(new FloatingActionButton.OnVisibilityChangedListener() { child.hide(new FloatingActionButton.OnVisibilityChangedListener() {

15
app/src/main/java/gr/thmmy/mthmmy/utils/ScrollAwareLinearBehavior.java

@ -2,6 +2,7 @@ package gr.thmmy.mthmmy.utils;
import android.animation.Animator; import android.animation.Animator;
import android.content.Context; import android.content.Context;
import android.support.annotation.NonNull;
import android.support.design.widget.CoordinatorLayout; import android.support.design.widget.CoordinatorLayout;
import android.support.v4.view.ViewCompat; import android.support.v4.view.ViewCompat;
import android.support.v4.view.animation.FastOutSlowInInterpolator; import android.support.v4.view.animation.FastOutSlowInInterpolator;
@ -14,7 +15,7 @@ import android.view.ViewPropertyAnimator;
* <p>When a nested ScrollView is scrolled down, the view will disappear. * <p>When a nested ScrollView is scrolled down, the view will disappear.
* When the ScrollView is scrolled back up, the view will reappear.</p> * When the ScrollView is scrolled back up, the view will reappear.</p>
*/ */
@SuppressWarnings("WeakerAccess") @SuppressWarnings("unused")
public class ScrollAwareLinearBehavior extends CoordinatorLayout.Behavior<View> { public class ScrollAwareLinearBehavior extends CoordinatorLayout.Behavior<View> {
private static final int ANIMATION_DURATION = 100; private static final int ANIMATION_DURATION = 100;
@ -23,15 +24,19 @@ public class ScrollAwareLinearBehavior extends CoordinatorLayout.Behavior<View>
} }
@Override @Override
public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, View child, View directTargetChild, View target, int nestedScrollAxes) { public boolean onStartNestedScroll(@NonNull CoordinatorLayout coordinatorLayout,
@NonNull View child, @NonNull View directTargetChild,
@NonNull View target, int nestedScrollAxes, int type) {
return (nestedScrollAxes & ViewCompat.SCROLL_AXIS_VERTICAL) != 0; return (nestedScrollAxes & ViewCompat.SCROLL_AXIS_VERTICAL) != 0;
} }
@Override @Override
public void onNestedScroll(CoordinatorLayout coordinatorLayout, View bottomNavBar, View target, public void onNestedScroll(@NonNull CoordinatorLayout coordinatorLayout,
@NonNull View bottomNavBar, @NonNull View target,
int dxConsumed, int dyConsumed, int dxConsumed, int dyConsumed,
int dxUnconsumed, int dyUnconsumed) { int dxUnconsumed, int dyUnconsumed, int type) {
super.onNestedScroll(coordinatorLayout, bottomNavBar, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed); super.onNestedScroll(coordinatorLayout, bottomNavBar, target, dxConsumed, dyConsumed,
dxUnconsumed, dyUnconsumed, type);
if ((dyConsumed > 0 || (!target.canScrollVertically(-1) && dyConsumed == 0 if ((dyConsumed > 0 || (!target.canScrollVertically(-1) && dyConsumed == 0
&& dyUnconsumed < 40)) && bottomNavBar.getVisibility() == View.VISIBLE) { && dyUnconsumed < 40)) && bottomNavBar.getVisibility() == View.VISIBLE) {
hide(bottomNavBar); hide(bottomNavBar);

9
app/src/main/res/drawable/ic_file_download.xml

@ -1,9 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#ffffff"
android:pathData="M19,9h-4V3H9v6H5l7,7 7,-7zM5,18v2h14v-2H5z"/>
</vector>

1
app/src/main/res/layout/dialog_topic_info.xml

@ -8,6 +8,7 @@
<TextView <TextView
android:id="@+id/dialog_title" android:id="@+id/dialog_title"
android:text="@string/info"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="20dp" android:layout_marginBottom="20dp"

1
app/src/main/res/layout/fragment_unread_mark_read_row.xml

@ -4,6 +4,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical"
android:paddingEnd="10dp" android:paddingEnd="10dp"
android:paddingStart="10dp"
android:paddingTop="7dp"> android:paddingTop="7dp">
<TextView <TextView

1
build.gradle

@ -17,6 +17,7 @@ allprojects {
repositories { repositories {
jcenter() jcenter()
maven { url "https://jitpack.io" } maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
} }
} }

Loading…
Cancel
Save