From 56ba2440f89e57f87a355e66295f31597bbd1fe2 Mon Sep 17 00:00:00 2001 From: Ezerous Date: Thu, 28 May 2020 20:27:02 +0300 Subject: [PATCH] UnreadFragment improvements --- .../main/unread/UnreadFragment.java | 227 +++++++++--------- .../thmmy/mthmmy/session/SessionManager.java | 96 ++++++-- .../mthmmy/session/ValidateSessionTask.java | 18 ++ .../utils/parsing/ThmmyDateTimeParser.java | 8 +- app/src/main/res/layout/fragment_unread.xml | 3 +- 5 files changed, 208 insertions(+), 144 deletions(-) create mode 100644 app/src/main/java/gr/thmmy/mthmmy/session/ValidateSessionTask.java diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java index e388dc2e..7a4dd005 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/unread/UnreadFragment.java @@ -1,4 +1,3 @@ - package gr.thmmy.mthmmy.activities.main.unread; import android.os.AsyncTask; @@ -23,20 +22,20 @@ import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; -import java.io.IOException; import java.util.ArrayList; import java.util.List; import gr.thmmy.mthmmy.R; +import gr.thmmy.mthmmy.base.BaseApplication; import gr.thmmy.mthmmy.base.BaseFragment; import gr.thmmy.mthmmy.model.TopicSummary; import gr.thmmy.mthmmy.session.SessionManager; +import gr.thmmy.mthmmy.session.ValidateSessionTask; import gr.thmmy.mthmmy.utils.NetworkResultCodes; import gr.thmmy.mthmmy.utils.parsing.NewParseTask; import gr.thmmy.mthmmy.utils.parsing.ParseException; import gr.thmmy.mthmmy.views.CustomRecyclerView; import me.zhanghai.android.materialprogressbar.MaterialProgressBar; -import okhttp3.Request; import okhttp3.Response; import timber.log.Timber; @@ -60,12 +59,13 @@ public class UnreadFragment extends BaseFragment { private UnreadAdapter unreadAdapter; private List topicSummaries; - private String markAsReadUrl = ""; + private String markAsReadUrl; private int numberOfPages = 0; private int loadedPages = 0; private UnreadTask unreadTask; private MarkReadTask markReadTask; + private ValidateSessionTask validateSessionTask; // Required empty public constructor public UnreadFragment() {} @@ -89,18 +89,22 @@ public class UnreadFragment extends BaseFragment { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); topicSummaries = new ArrayList<>(); + markAsReadUrl = BaseApplication.getInstance().getSessionManager().getMarkAllAsReadLink(); + if(markAsReadUrl==null){ + Timber.i("MarkAsRead URL is null."); + startValidateSessionTask(); + } } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - if (topicSummaries.isEmpty()) { - unreadTask = new UnreadTask(this::onUnreadTaskStarted, this::onUnreadTaskFinished); + if (topicSummaries.isEmpty()){ + unreadTask = new UnreadTask(this::onUnreadTaskStarted, UnreadFragment.this::onUnreadTaskCancelled, this::onUnreadTaskFinished); assert SessionManager.unreadUrl != null; unreadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, SessionManager.unreadUrl.toString()); } - markReadTask = new MarkReadTask(); - Timber.d("onActivityCreated"); + markReadTask = new MarkReadTask(this::onMarkReadTaskStarted, this::onMarkReadTaskFinished); } @@ -139,15 +143,7 @@ public class UnreadFragment extends BaseFragment { swipeRefreshLayout.setProgressBackgroundColorSchemeResource(R.color.primary); swipeRefreshLayout.setColorSchemeResources(R.color.accent); swipeRefreshLayout.setOnRefreshListener( - () -> { - if (!unreadTask.isRunning()) { - numberOfPages = 0; - loadedPages = 0; - unreadTask = new UnreadTask(this::onUnreadTaskStarted, this::onUnreadTaskFinished); - assert SessionManager.unreadUrl != null; - unreadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, SessionManager.unreadUrl.toString()); - } - } + this::startUnreadTask ); } @@ -157,17 +153,18 @@ public class UnreadFragment extends BaseFragment { @Override public void onDestroy() { super.onDestroy(); - if (unreadTask!=null){ + cancelUnreadTaskIfRunning(); + if (markReadTask!=null){ try{ - if(unreadTask.isRunning()) - unreadTask.cancel(true); + if(markReadTask.isRunning()) + markReadTask.cancel(true); } // Yes, it happens even though we checked catch (NullPointerException ignored){ } } - if (markReadTask!=null){ + if (validateSessionTask!=null){ try{ - if(markReadTask.isRunning()) - markReadTask.cancel(true); + if(validateSessionTask.isRunning()) + validateSessionTask.cancel(true); } // Yes, it happens even though we checked catch (NullPointerException ignored){ } } @@ -175,15 +172,42 @@ public class UnreadFragment extends BaseFragment { topicSummaries.clear(); } + private void startUnreadTask(){ + if (unreadTask!=null) { + try{ + if(!unreadTask.isRunning()){ + numberOfPages = 0; + loadedPages = 0; + unreadTask = new UnreadTask(UnreadFragment.this::onUnreadTaskStarted, UnreadFragment.this::onUnreadTaskCancelled, UnreadFragment.this::onUnreadTaskFinished); + assert SessionManager.unreadUrl != null; + unreadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, SessionManager.unreadUrl.toString()); + } + } + catch (NullPointerException ignored){ } + } + } + + private void startValidateSessionTask(){ + validateSessionTask = new ValidateSessionTask(); + validateSessionTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + } + + private void cancelUnreadTaskIfRunning(){ + if (unreadTask!=null){ + try{ + if(unreadTask.isRunning()) + unreadTask.cancel(true); + } // Yes, it happens even though we checked + catch (NullPointerException ignored){ } + } + } + public interface UnreadFragmentInteractionListener extends FragmentInteractionListener { void onUnreadFragmentInteraction(TopicSummary topicSummary); } private void showMarkAsReadFAB() { - markAsReadFAB.setOnClickListener(v -> { - if (!markReadTask.isRunning() && !unreadTask.isRunning()) - showMarkAsReadConfirmationDialog(); - }); + markAsReadFAB.setOnClickListener(v -> showMarkAsReadConfirmationDialog()); markAsReadFAB.show(); markAsReadFAB.setTag(true); } @@ -199,27 +223,36 @@ public class UnreadFragment extends BaseFragment { builder.setTitle("Mark all as read"); builder.setMessage("Are you sure that you want to mark ALL topics as read?"); builder.setPositiveButton("Yep", (dialogInterface, i) -> { - markReadTask = new MarkReadTask(); - markReadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, markAsReadUrl); + if (!markReadTask.isRunning() && markAsReadUrl!=null){ + markReadTask = new MarkReadTask(this::onMarkReadTaskStarted, this::onMarkReadTaskFinished); + markReadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, markAsReadUrl); + } }); builder.setNegativeButton("Nope", (dialogInterface, i) -> {}); builder.create().show(); } - //---------------------------------------ASYNC TASK----------------------------------- + private void hideProgressUI(){ + progressBar.setVisibility(ProgressBar.INVISIBLE); + swipeRefreshLayout.setRefreshing(false); + } + + //---------------------------------------UNREAD TASK----------------------------------- private void onUnreadTaskStarted() { progressBar.setVisibility(ProgressBar.VISIBLE); } - private void onUnreadTaskFinished(int resultCode, UnreadTaskData unreadTaskData) { + private void onUnreadTaskCancelled() { + swipeRefreshLayout.setRefreshing(false); + } + + private void onUnreadTaskFinished(int resultCode, ArrayList fetchedUnread) { if (resultCode == NetworkResultCodes.SUCCESSFUL) { - ArrayList fetchedUnread = unreadTaskData.getTopicSummaries(); if(!fetchedUnread.isEmpty()){ if(loadedPages==0) topicSummaries.clear(); topicSummaries.addAll(fetchedUnread); - markAsReadUrl = unreadTaskData.getMarkAsReadUrl(); noUnreadTopicsTextView.setVisibility(View.INVISIBLE); showMarkAsReadFAB(); } @@ -231,18 +264,15 @@ public class UnreadFragment extends BaseFragment { unreadAdapter.notifyDataSetChanged(); loadedPages++; if (loadedPages < numberOfPages) { - unreadTask = new UnreadTask(this::onUnreadTaskStarted, this::onUnreadTaskFinished); + unreadTask = new UnreadTask(this::onUnreadTaskStarted, UnreadFragment.this::onUnreadTaskCancelled, this::onUnreadTaskFinished); assert SessionManager.unreadUrl != null; unreadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, SessionManager.unreadUrl.toString() + ";start=" + loadedPages * 20); } - else { - progressBar.setVisibility(ProgressBar.INVISIBLE); - swipeRefreshLayout.setRefreshing(false); - } + else + hideProgressUI(); } else{ - progressBar.setVisibility(ProgressBar.INVISIBLE); - swipeRefreshLayout.setRefreshing(false); + hideProgressUI(); if (resultCode == NetworkResultCodes.NETWORK_ERROR) Toast.makeText(getContext(), "Network error", Toast.LENGTH_SHORT).show(); else @@ -251,16 +281,15 @@ public class UnreadFragment extends BaseFragment { } } - private class UnreadTask extends NewParseTask { - UnreadTask(OnTaskStartedListener onTaskStartedListener, OnNetworkTaskFinishedListener onParseTaskFinishedListener) { - super(onTaskStartedListener, onParseTaskFinishedListener); + private class UnreadTask extends NewParseTask> { + UnreadTask(OnTaskStartedListener onTaskStartedListener, OnTaskCancelledListener onTaskCancelledListener, OnNetworkTaskFinishedListener> onParseTaskFinishedListener) { + super(onTaskStartedListener, onTaskCancelledListener, onParseTaskFinishedListener); } @Override - protected UnreadTaskData parse(Document document, Response response) throws ParseException { + protected ArrayList parse(Document document, Response response) throws ParseException { Elements unread = document.select("table.bordercolor[cellspacing=1] tr:not(.titlebg)"); ArrayList fetchedTopicSummaries = new ArrayList<>(); - String markAsReadUrl=""; if (!unread.isEmpty()) { for (Element row : unread) { Elements information = row.select("td"); @@ -278,12 +307,9 @@ public class UnreadFragment extends BaseFragment { } Element topBar = document.select("table:not(.bordercolor):not(#bodyarea):has(td.middletext)").first(); - Element pagesElement = null, markRead = null; - if (topBar != null) { + Element pagesElement = null; + if (topBar != null) pagesElement = topBar.select("td.middletext").first(); - markRead = document.select("table:not(.bordercolor):not([width])").select("a") - .first(); - } if (numberOfPages == 0 && pagesElement != null) { Elements pages = pagesElement.select("a"); @@ -293,91 +319,60 @@ public class UnreadFragment extends BaseFragment { numberOfPages = 1; } - if (markRead != null && loadedPages == numberOfPages - 1) - markAsReadUrl = markRead.attr("href"); - - return new UnreadTaskData(fetchedTopicSummaries, markAsReadUrl); + return fetchedTopicSummaries; } - - return new UnreadTaskData(new ArrayList<>(), markAsReadUrl); + return new ArrayList<>(); } @Override - protected int getResultCode(Response response, UnreadTaskData data) { + protected int getResultCode(Response response, ArrayList topicSummaries) { return NetworkResultCodes.SUCCESSFUL; } } - private class UnreadTaskData { - ArrayList topicSummaries; - String markAsReadUrl; - - UnreadTaskData(ArrayList topicSummaries, String markAsReadUrl){ - this.topicSummaries = topicSummaries; - this.markAsReadUrl = markAsReadUrl; - } + //---------------------------------------MARKREAD TASK------------------------------------------ + private void onMarkReadTaskStarted() { + cancelUnreadTaskIfRunning(); + progressBar.setVisibility(ProgressBar.VISIBLE); + } - ArrayList getTopicSummaries() { - return topicSummaries; + private void onMarkReadTaskFinished(int resultCode, Boolean isSessionVerified) { + hideProgressUI(); + if (resultCode == NetworkResultCodes.SUCCESSFUL) { + if (!isSessionVerified){ + Toast.makeText(getContext(), "Session verification failed", Toast.LENGTH_SHORT).show(); + startValidateSessionTask(); + } + else + startUnreadTask(); } - - String getMarkAsReadUrl() { - return markAsReadUrl; + else{ + hideProgressUI(); + if (resultCode == NetworkResultCodes.NETWORK_ERROR) + Toast.makeText(getContext(), "Network error", Toast.LENGTH_SHORT).show(); + else + Toast.makeText(getContext(), "Unexpected error," + + " please contact the developers with the details", Toast.LENGTH_LONG).show(); } } - private class MarkReadTask extends AsyncTask { - private static final int SUCCESS = 0; - private static final int NETWORK_ERROR = 1; - private static final int OTHER_ERROR = 2; - - @Override - protected void onPreExecute() { - progressBar.setVisibility(ProgressBar.VISIBLE); + private class MarkReadTask extends NewParseTask { + MarkReadTask(OnTaskStartedListener onTaskStartedListener, OnNetworkTaskFinishedListener onParseTaskFinishedListener) { + super(onTaskStartedListener, onParseTaskFinishedListener); } @Override - protected Integer doInBackground(String... strings) { - Request request = new Request.Builder() - .url(strings[0]) - .build(); - try { - client.newCall(request).execute(); - return SUCCESS; - } catch (IOException e) { - Timber.i(e, "IO Exception"); - return NETWORK_ERROR; - } catch (Exception e) { - Timber.e(e, "Exception"); - return OTHER_ERROR; - } + protected Boolean parse(Document document, Response response) throws ParseException { + Elements sessionVerificationFailed = document.select("td:containsOwn(Session " + + "verification failed. Please try logging out and back in again, and then try " + + "again.), td:containsOwn(Η επαλήθευση συνόδου απέτυχε. Παρακαλούμε κάντε " + + "αποσύνδεση, επανασύνδεση και ξαναδοκιμάστε.)"); + return sessionVerificationFailed.isEmpty(); } @Override - protected void onPostExecute(Integer result) { - progressBar.setVisibility(ProgressBar.GONE); - - if (result == NETWORK_ERROR) { - Toast.makeText(getContext() - , "Task was unsuccessful!\n Please check your internet conneciton.", - Toast.LENGTH_LONG).show(); - } else if (result == OTHER_ERROR) { - Toast.makeText(getContext() - , "Fatal error!\n Task aborted...", Toast.LENGTH_LONG).show(); - } else { - if (!unreadTask.isRunning()) { - numberOfPages = 0; - loadedPages = 0; - unreadTask = new UnreadTask(UnreadFragment.this::onUnreadTaskStarted, UnreadFragment.this::onUnreadTaskFinished); - assert SessionManager.unreadUrl != null; - unreadTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, SessionManager.unreadUrl.toString()); - } - } - } - - //TODO: Maybe extend this task and use isRunning() from ExternalAsyncTask instead (?) - public boolean isRunning(){ - return getStatus() == AsyncTask.Status.RUNNING; + protected int getResultCode(Response response, Boolean isSessionVerified) { + return NetworkResultCodes.SUCCESSFUL; } } } diff --git a/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java b/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java index 36def1de..81dd2f31 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java +++ b/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java @@ -39,6 +39,8 @@ public class SessionManager { private static final HttpUrl loginUrl = HttpUrl.parse("https://www.thmmy.gr/smf/index.php?action=login2"); public static final HttpUrl unreadUrl = HttpUrl.parse("https://www.thmmy.gr/smf/index.php?action=unread;all;start=0;theme=4"); public static final HttpUrl shoutboxUrl = HttpUrl.parse("https://www.thmmy.gr/smf/index.php?action=tpmod;sa=shoutbox;theme=4"); + private static final String baseLogoutLink = "https://www.thmmy.gr/smf/index.php?action=logout;sesc="; + private static final String baseMarkAllAsReadLink = "https://www.thmmy.gr/smf/index.php?action=markasread;sa=all;sesc="; private static final String guestName = "Guest"; //Response Codes @@ -63,7 +65,9 @@ public class SessionManager { private static final String USER_ID = "UserID"; private static final String AVATAR_LINK = "AvatarLink"; private static final String HAS_AVATAR = "HasAvatar"; + private static final String SESC = "Sesc"; private static final String LOGOUT_LINK = "LogoutLink"; + private static final String MARK_ALL_AS_READ_LINK = "MarkAllAsReadLink"; private static final String LOGGED_IN = "LoggedIn"; private static final String LOGIN_SCREEN_AS_DEFAULT = "LoginScreenAsDefault"; @@ -84,7 +88,7 @@ public class SessionManager { * Always call it in a separate thread. */ public int login(String... strings) { - Timber.i("Logging in..."); + Timber.d("Logging in..."); //Build the login request for each case Request request; @@ -114,8 +118,7 @@ public class SessionManager { Response response = client.newCall(request).execute(); Document document = Jsoup.parse(response.body().string()); - if (validateRetrievedCookies()) - { + if (validateRetrievedCookies()) { Timber.i("Login successful!"); setPersistentCookieSession(); //Store cookies @@ -129,7 +132,10 @@ public class SessionManager { if (avatar != null) editor.putString(AVATAR_LINK, avatar); editor.putBoolean(HAS_AVATAR, avatar != null); - editor.putString(LOGOUT_LINK, extractLogoutLink(document)); + String sesc = extractSesc(document); + editor.putString(SESC, sesc); + editor.putString(LOGOUT_LINK, generateLogoutLink(sesc)); + editor.putString(MARK_ALL_AS_READ_LINK, generateMarkAllAsReadLink(sesc)); editor.apply(); return SUCCESS; @@ -181,10 +187,10 @@ public class SessionManager { * Always call it in a separate thread in a way that won't hinder performance (e.g. after * fragments' data are retrieved). */ - public void validateSession() { - Timber.i("Validating session..."); - + void validateSession() { + Timber.e("Validating session..."); if (isLoggedIn()) { + Timber.e("Refreshing session..."); int loginResult = login(); if (loginResult != FAILURE) return; @@ -204,18 +210,15 @@ public class SessionManager { setLoginScreenAsDefault(false); } - /** * Logout function. Always call it in a separate thread. */ public int logout() { Timber.i("Logging out..."); - - Request request = new Request.Builder() - .url(sharedPrefs.getString(LOGOUT_LINK, "LogoutLink")) - .build(); - try { + Request request = new Request.Builder() + .url(getLogoutLink()) + .build(); //Make request & handle response Response response = client.newCall(request).execute(); Document document = Jsoup.parse(response.body().string()); @@ -258,14 +261,31 @@ public class SessionManager { public Cookie getThmmyCookie() { List cookieList = cookieJar.loadForRequest(indexUrl); - for(Cookie cookie: cookieList) - { + for(Cookie cookie: cookieList) { if(cookie.name().equals("THMMYgrC00ki3")) return cookie; } return null; } + public String getMarkAllAsReadLink() { + String markAsReadLink = sharedPrefs.getString(MARK_ALL_AS_READ_LINK, null); + if(markAsReadLink == null){ //For older versions, extract it from logout link (otherwise user would have to login again) + String sesc = extractSescFromLogoutLink(getLogoutLink()); + if(sesc!=null) { + setSesc(sesc); + markAsReadLink = generateMarkAllAsReadLink(sesc); + setMarkAsReadLink(markAsReadLink); + return markAsReadLink; + } + } + return markAsReadLink; // Warning: it can be null + } + + private String getLogoutLink() { + return sharedPrefs.getString(LOGOUT_LINK, null); + } + public boolean hasAvatar() { return sharedPrefs.getBoolean(HAS_AVATAR, false); } @@ -280,6 +300,21 @@ public class SessionManager { //--------------------------------------GETTERS END--------------------------------------------- + //---------------------------------------SETTERS------------------------------------------------ + private void setSesc(String sesc){ + SharedPreferences.Editor editor = sharedPrefs.edit(); + editor.putString(SESC, sesc); + editor.apply(); + } + + private void setMarkAsReadLink(String markAllAsReadLink){ + SharedPreferences.Editor editor = sharedPrefs.edit(); + editor.putString(MARK_ALL_AS_READ_LINK, markAllAsReadLink); + editor.apply(); + } + + //--------------------------------------SETTERS END--------------------------------------------- + //------------------------------------OTHER FUNCTIONS------------------------------------------- private boolean validateRetrievedCookies() { List cookieList = cookieJar.loadForRequest(indexUrl); @@ -353,7 +388,6 @@ public class SessionManager { return "User"; //return a default username } - @NonNull private int extractUserId(@NonNull Document doc) { try{ Elements elements = doc.select("a:containsOwn(Εμφάνιση των μηνυμάτων σας), a:containsOwn(Show own posts)"); @@ -383,17 +417,33 @@ public class SessionManager { return null; } - @NonNull - private String extractLogoutLink(@NonNull Document doc) { + private String extractSesc(@NonNull Document doc) { Elements logoutLink = doc.select("a[href^=https://www.thmmy.gr/smf/index.php?action=logout;sesc=]"); - if (!logoutLink.isEmpty()) { String link = logoutLink.first().attr("href"); - if (link != null && !link.isEmpty()) - return link; + return extractSescFromLogoutLink(link); + } + Timber.e(new ParseException("Parsing failed(extractSesc)"),"ParseException"); + return null; + } + + private String extractSescFromLogoutLink(String logoutLink){ + if (logoutLink != null){ + Pattern pattern = Pattern.compile(".+;sesc=(\\w+)"); + Matcher matcher = pattern.matcher(logoutLink); + if (matcher.find()) + return matcher.group(1); } - Timber.e(new ParseException("Parsing failed(logoutLink extraction)"),"ParseException"); - return "https://www.thmmy.gr/smf/index.php?action=logout"; //return a default link + Timber.e(new ParseException("Parsing failed(extractSescFromLogoutLink)"),"ParseException"); + return null; + } + + private String generateLogoutLink(String sesc){ + return baseLogoutLink + sesc; + } + + private String generateMarkAllAsReadLink(String sesc){ + return baseMarkAllAsReadLink + sesc; } //----------------------------------OTHER FUNCTIONS END----------------------------------------- diff --git a/app/src/main/java/gr/thmmy/mthmmy/session/ValidateSessionTask.java b/app/src/main/java/gr/thmmy/mthmmy/session/ValidateSessionTask.java new file mode 100644 index 00000000..b5c1392f --- /dev/null +++ b/app/src/main/java/gr/thmmy/mthmmy/session/ValidateSessionTask.java @@ -0,0 +1,18 @@ +package gr.thmmy.mthmmy.session; + +import android.os.AsyncTask; + +import gr.thmmy.mthmmy.base.BaseApplication; + + +public class ValidateSessionTask extends AsyncTask { + @Override + protected Void doInBackground(String... params) { + BaseApplication.getInstance().getSessionManager().validateSession(); + return null; + } + + public boolean isRunning(){ + return getStatus() == AsyncTask.Status.RUNNING; + } +} diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParser.java b/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParser.java index 3c398bd1..6e27ca61 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParser.java +++ b/app/src/main/java/gr/thmmy/mthmmy/utils/parsing/ThmmyDateTimeParser.java @@ -42,7 +42,7 @@ public class ThmmyDateTimeParser { private ThmmyDateTimeParser(){} public static String convertToTimestamp(String thmmyDateTime){ - Timber.d("Will attempt to convert %s to timestamp.", thmmyDateTime); + Timber.v("Will attempt to convert %s to timestamp.", thmmyDateTime); String originalDateTime = thmmyDateTime; DateTimeZone dtz = getDtz(); @@ -67,12 +67,12 @@ public class ThmmyDateTimeParser { dateTime=formatter.withZone(dtz).withLocale(englishLocale).parseDateTime(thmmyDateTime); } catch (IllegalArgumentException e1){ - Timber.d("Parsing DateTime %s using English Locale failed.", thmmyDateTime); + Timber.v("Parsing DateTime %s using English Locale failed.", thmmyDateTime); try{ DateFormatSymbols dfs = DateTimeUtils.getDateFormatSymbols(greekLocale); thmmyDateTime = thmmyDateTime.replace("am",dfs.getAmPmStrings()[0]); thmmyDateTime = thmmyDateTime.replace("pm",dfs.getAmPmStrings()[1]); - Timber.d("Attempting to parse DateTime %s using Greek Locale...", thmmyDateTime); + Timber.v("Attempting to parse DateTime %s using Greek Locale...", thmmyDateTime); dateTime=formatter.withZone(dtz).withLocale(greekLocale).parseDateTime(thmmyDateTime); } catch (IllegalArgumentException e2){ @@ -82,7 +82,7 @@ public class ThmmyDateTimeParser { } } String timestamp = Long.toString(dateTime.getMillis()); - Timber.d("DateTime %s was converted to %s, or %s", originalDateTime, timestamp, dateTime.toString()); + Timber.v("DateTime %s was converted to %s, or %s", originalDateTime, timestamp, dateTime.toString()); return timestamp; } diff --git a/app/src/main/res/layout/fragment_unread.xml b/app/src/main/res/layout/fragment_unread.xml index 363bb734..3a89ebc8 100644 --- a/app/src/main/res/layout/fragment_unread.xml +++ b/app/src/main/res/layout/fragment_unread.xml @@ -37,7 +37,8 @@ android:layout_height="wrap_content" android:visibility="invisible" android:text="@string/no_unread_topics" - android:textColor="@color/primary_text" + android:textColor="@color/accent" + android:textSize="@dimen/medium_text" app:layout_anchor="@+id/relativeLayout" app:layout_anchorGravity="center" />