From a67adf20583055bb3ad6ff057bfeb518cd274daf Mon Sep 17 00:00:00 2001
From: Ezerous
Date: Sun, 12 Mar 2017 12:20:33 +0200
Subject: [PATCH] Timber init (Report class was removed), library updates
---
app/build.gradle | 11 ++-
app/src/debug/java/mthmmy/utils/Report.java | 81 ----------------
app/src/main/assets/apache_libraries.html | 4 +-
app/src/main/assets/mit_libraries.html | 2 +-
.../mthmmy/activities/LoginActivity.java | 9 +-
.../activities/board/BoardActivity.java | 20 +---
.../mthmmy/activities/board/BoardAdapter.java | 1 -
.../downloads/DownloadsActivity.java | 18 +---
.../downloads/DownloadsAdapter.java | 5 -
.../mthmmy/activities/main/MainActivity.java | 1 -
.../activities/main/forum/ForumFragment.java | 14 +--
.../main/recent/RecentFragment.java | 14 +--
.../activities/profile/ProfileActivity.java | 29 ++----
.../latestPosts/LatestPostsAdapter.java | 5 -
.../latestPosts/LatestPostsFragment.java | 25 ++---
.../profile/stats/StatsFragment.java | 27 ++----
.../profile/summary/SummaryFragment.java | 25 ++---
.../mthmmy/activities/topic/ReplyParser.java | 6 --
.../activities/topic/TopicActivity.java | 31 +++---
.../mthmmy/activities/topic/TopicAdapter.java | 11 +--
.../mthmmy/activities/topic/TopicParser.java | 13 +--
.../gr/thmmy/mthmmy/base/BaseApplication.java | 9 ++
.../gr/thmmy/mthmmy/base/BaseFragment.java | 12 +--
.../java/gr/thmmy/mthmmy/model/ThmmyPage.java | 4 +-
.../gr/thmmy/mthmmy/receiver/Receiver.java | 6 +-
.../mthmmy/services/DownloadService.java | 25 ++---
.../thmmy/mthmmy/session/SessionManager.java | 43 ++++-----
.../mthmmy/utils/CrashReportingTree.java | 34 +++++++
app/src/release/java/mthmmy.utils/Report.java | 96 -------------------
build.gradle | 2 +-
gradle/wrapper/gradle-wrapper.properties | 4 +-
31 files changed, 176 insertions(+), 411 deletions(-)
delete mode 100644 app/src/debug/java/mthmmy/utils/Report.java
create mode 100644 app/src/main/java/gr/thmmy/mthmmy/utils/CrashReportingTree.java
delete mode 100644 app/src/release/java/mthmmy.utils/Report.java
diff --git a/app/build.gradle b/app/build.gradle
index 2469aa31..522c3627 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 25
- buildToolsVersion "25.0.1"
+ buildToolsVersion "25.0.2"
defaultConfig {
vectorDrawables.useSupportLibrary = true
@@ -33,20 +33,21 @@ dependencies {
compile 'com.android.support:support-v4:25.2.0'
compile 'com.android.support:cardview-v7:25.2.0'
compile 'com.android.support:recyclerview-v7:25.2.0'
- compile 'com.google.firebase:firebase-crash:10.0.1'
- compile 'com.squareup.okhttp3:okhttp:3.5.0'
+ compile 'com.google.firebase:firebase-crash:10.2.0'
+ compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'
compile 'org.jsoup:jsoup:1.10.2'
compile 'com.github.franmontiel:PersistentCookieJar:v1.0.0'
compile 'com.github.PhilJay:MPAndroidChart:v3.0.1'
- compile('com.mikepenz:materialdrawer:5.8.1@aar') {
+ compile('com.mikepenz:materialdrawer:5.8.2@aar') {
transitive = true
}
compile 'com.mikepenz:fontawesome-typeface:4.7.0.0@aar'
- compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.3'
+ compile 'pl.droidsonroids.gif:android-gif-drawable:1.2.5'
compile 'com.bignerdranch.android:expandablerecyclerview:3.0.0-RC1'
compile 'me.zhanghai.android.materialprogressbar:library:1.3.0'
+ compile 'com.jakewharton.timber:timber:4.5.1'
}
apply plugin: 'com.google.gms.google-services'
diff --git a/app/src/debug/java/mthmmy/utils/Report.java b/app/src/debug/java/mthmmy/utils/Report.java
deleted file mode 100644
index 6e6a906f..00000000
--- a/app/src/debug/java/mthmmy/utils/Report.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package mthmmy.utils;
-
-import android.util.Log;
-
-public class Report
-{
-
- public static void v (String TAG, String message)
- {
- Log.v(TAG,message);
- }
-
- public static void v (String TAG, String message, Throwable tr)
- {
- Log.v(TAG,message + ": " + tr.getMessage(),tr);
- }
-
- public static void d (String TAG, String message)
- {
- Log.d(TAG,message);
- }
-
- public static void d (String TAG, String message, Throwable tr)
- {
- Log.d(TAG,message + ": " + tr.getMessage(),tr);
- }
-
- public static void i (String TAG, String message)
- {
- Log.i(TAG,message);
- }
-
- public static void i (String TAG, String message, Throwable tr)
- {
- Log.i(TAG,message + ": " + tr.getMessage(),tr);
- }
-
- public static void w (String TAG, String message)
- {
- Log.w(TAG,message);
- }
-
- public static void w (String TAG, String message, Throwable tr)
- {
- Log.w(TAG,message + ": " + tr.getMessage(),tr);
- }
-
- public static void e (String TAG, String message)
- {
- Log.e(TAG,message);
- }
-
- public static void e (String TAG, String message, Throwable tr)
- {
- Log.e(TAG,message + ": " + tr.getMessage(),tr);
- }
-
- public static void wtf (String TAG, String message)
- {
- Log.wtf(TAG,message);
- }
-
- public static void wtf (String TAG, String message, Throwable tr)
- {
- Log.wtf(TAG,message + ": " + tr.getMessage(),tr);
- }
-
- /**
- * Prints long messages in logcat (debug level).
- */
- public static void longMessage(String TAG, String message)
- {
- int maxLogSize = 1000;
- for(int i = 0; i <= message.length() / maxLogSize; i++) {
- int start = i * maxLogSize;
- int end = (i+1) * maxLogSize;
- end = end > message.length() ? message.length() : end;
- Report.d(TAG, message.substring(start, end));
- }
- }
-}
\ No newline at end of file
diff --git a/app/src/main/assets/apache_libraries.html b/app/src/main/assets/apache_libraries.html
index 10867db3..2c0ceabc 100644
--- a/app/src/main/assets/apache_libraries.html
+++ b/app/src/main/assets/apache_libraries.html
@@ -39,7 +39,7 @@
-
-
OkHttp v3.5.0 (Copyright ©2016 Square, Inc.)
+ OkHttp v3.6.0 (Copyright ©2016 Square, Inc.)
-
Picasso v2.5.2 (Copyright ©2013 Square, Inc.)
@@ -51,7 +51,7 @@
MPAndroidChart v3.0.1 (Copyright ©2016 Philipp Jahoda)
-
-
MaterialDrawer v5.8.1 (Copyright ©2016 Mike Penz)
+ MaterialDrawer v5.8.2 (Copyright ©2016 Mike Penz)
-
diff --git a/app/src/main/assets/mit_libraries.html b/app/src/main/assets/mit_libraries.html
index 6d72c330..2c6cf3bb 100644
--- a/app/src/main/assets/mit_libraries.html
+++ b/app/src/main/assets/mit_libraries.html
@@ -42,7 +42,7 @@
jsoup v1.10.2 (Copyright ©2009-2017, Jonathan Hedley <jonathan@hedley.net>)
-
-
android-gif-drawable v1.2.3 (Copyright ©2016 Karol Wrótniak, Droids on Roids)
+ android-gif-drawable v1.2.5 (Copyright ©2016 Karol Wrótniak, Droids on Roids)
-
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java
index 7dacd734..39a770c2 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java
@@ -14,7 +14,8 @@ import android.widget.Toast;
import gr.thmmy.mthmmy.R;
import gr.thmmy.mthmmy.activities.main.MainActivity;
import gr.thmmy.mthmmy.base.BaseActivity;
-import mthmmy.utils.Report;
+
+import timber.log.Timber;
import static gr.thmmy.mthmmy.session.SessionManager.CONNECTION_ERROR;
import static gr.thmmy.mthmmy.session.SessionManager.EXCEPTION;
@@ -34,12 +35,8 @@ public class LoginActivity extends BaseActivity {
private String password;
/* --Graphics End-- */
- //Other variables
- private static final String TAG = "LoginActivity";
-
private LoginTask loginTask;
-
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -55,7 +52,7 @@ public class LoginActivity extends BaseActivity {
btnLogin.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
- Report.d(TAG, "Login");
+ Timber.d("Login");
//Get username and password strings
username = inputUsername.getText().toString().trim();
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
index c44afe1b..d4cf2236 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
@@ -30,16 +30,11 @@ import gr.thmmy.mthmmy.model.Bookmark;
import gr.thmmy.mthmmy.model.ThmmyPage;
import gr.thmmy.mthmmy.model.Topic;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
-import mthmmy.utils.Report;
import okhttp3.Request;
import okhttp3.Response;
+import timber.log.Timber;
public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMoreListener {
- /**
- * Debug Tag for logging debug output to LogCat
- */
- @SuppressWarnings("unused")
- private static final String TAG = "BoardActivity";
/**
* The key to use when putting board's url String to {@link BoardActivity}'s Bundle.
*/
@@ -76,7 +71,7 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
boardUrl = extras.getString(BUNDLE_BOARD_URL);
ThmmyPage.PageCategory target = ThmmyPage.resolvePageCategory(Uri.parse(boardUrl));
if (!target.is(ThmmyPage.PageCategory.BOARD)) {
- Report.e(TAG, "Bundle came with a non board url!\nUrl:\n" + boardUrl);
+ Timber.e("Bundle came with a non board url!\nUrl:\n%s" , boardUrl);
Toast.makeText(this, "An error has occurred\nAborting.", Toast.LENGTH_SHORT).show();
finish();
}
@@ -181,13 +176,6 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
* parameter!
*/
public class BoardTask extends AsyncTask {
- //Class variables
- /**
- * Debug Tag for logging debug output to LogCat
- */
- @SuppressWarnings("unused")
- private static final String TAG = "BoardTask"; //Separate tag for AsyncTask
-
@Override
protected void onPreExecute() {
if (!isLoadingMore) progressBar.setVisibility(ProgressBar.VISIBLE);
@@ -203,9 +191,9 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
Response response = client.newCall(request).execute();
parseBoard(Jsoup.parse(response.body().string()));
} catch (SSLHandshakeException e) {
- Report.w(TAG, "Certificate problem (please switch to unsafe connection).");
+ Timber.w("Certificate problem (please switch to unsafe connection).");
} catch (Exception e) {
- Report.e("TAG", "ERROR", e);
+ Timber.e("ERROR", e);
}
return null;
}
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java
index 306302fe..b6b716be 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java
@@ -32,7 +32,6 @@ import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL;
* {@link RecyclerView.Adapter} that can display a {@link gr.thmmy.mthmmy.model.Board}.
*/
class BoardAdapter extends RecyclerView.Adapter {
- private static final String TAG = "BoardAdapter";
private final int VIEW_TYPE_SUB_BOARD_TITLE = 0;
private final int VIEW_TYPE_SUB_BOARD = 1;
private final int VIEW_TYPE_TOPIC_TITLE = 2;
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java
index ea02b7b8..b4339f14 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java
@@ -27,16 +27,12 @@ import gr.thmmy.mthmmy.base.BaseActivity;
import gr.thmmy.mthmmy.model.Download;
import gr.thmmy.mthmmy.model.ThmmyPage;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
-import mthmmy.utils.Report;
+
import okhttp3.Request;
import okhttp3.Response;
+import timber.log.Timber;
public class DownloadsActivity extends BaseActivity implements DownloadsAdapter.OnLoadMoreListener {
- /**
- * Debug Tag for logging debug output to LogCat
- */
- @SuppressWarnings("unused")
- private static final String TAG = "DownloadsActivity";
/**
* The key to use when putting download's url String to {@link DownloadsActivity}'s Bundle.
*/
@@ -73,7 +69,7 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter.
if (downloadsUrl != null && !Objects.equals(downloadsUrl, "")) {
ThmmyPage.PageCategory target = ThmmyPage.resolvePageCategory(Uri.parse(downloadsUrl));
if (!target.is(ThmmyPage.PageCategory.DOWNLOADS)) {
- Report.e(TAG, "Bundle came with a non board url!\nUrl:\n" + downloadsUrl);
+ Timber.e("Bundle came with a non board url!\nUrl:\n%s" , downloadsUrl);
Toast.makeText(this, "An error has occurred\nAborting.", Toast.LENGTH_SHORT).show();
finish();
}
@@ -173,10 +169,6 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter.
* as String parameter!
*/
class ParseDownloadPageTask extends AsyncTask {
- /**
- * Debug Tag for logging debug output to LogCat
- */
- private static final String TAG = "ParseDownloadPageTask"; //Separate tag for AsyncTask
private String thisPageUrl;
@Override
@@ -195,9 +187,9 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter.
Response response = client.newCall(request).execute();
parseDownloads(Jsoup.parse(response.body().string()));
} catch (SSLHandshakeException e) {
- Report.w(TAG, "Certificate problem (please switch to unsafe connection).");
+ Timber.w("Certificate problem (please switch to unsafe connection).");
} catch (Exception e) {
- Report.e("TAG", "ERROR", e);
+ Timber.e("ERROR", e);
}
return null;
}
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java
index a46dfeea..0253359b 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java
@@ -29,11 +29,6 @@ import static gr.thmmy.mthmmy.activities.downloads.DownloadsActivity.BUNDLE_DOWN
import static gr.thmmy.mthmmy.activities.downloads.DownloadsActivity.BUNDLE_DOWNLOADS_URL;
class DownloadsAdapter extends RecyclerView.Adapter {
- /**
- * Debug Tag for logging debug output to LogCat
- */
- @SuppressWarnings("unused")
- private static final String TAG = "DownloadsAdapter";
private final int VIEW_TYPE_DOWNLOAD = 0;
private final int VIEW_TYPE_LOADING = 1;
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java
index 5e701d6e..d3d38870 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java
@@ -38,7 +38,6 @@ import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL;
public class MainActivity extends BaseActivity implements RecentFragment.RecentFragmentInteractionListener, ForumFragment.ForumFragmentInteractionListener {
//----------------------------------------CLASS VARIABLES-----------------------------------------
- private static final String TAG = "MainActivity";
private static final int TIME_INTERVAL = 2000;
private long mBackPressed;
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java
index d9777cf7..8bcecc25 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java
@@ -30,10 +30,11 @@ import gr.thmmy.mthmmy.model.Board;
import gr.thmmy.mthmmy.model.Category;
import gr.thmmy.mthmmy.session.SessionManager;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
-import mthmmy.utils.Report;
+
import okhttp3.HttpUrl;
import okhttp3.Request;
import okhttp3.Response;
+import timber.log.Timber;
/**
* A {@link BaseFragment} subclass.
@@ -87,7 +88,7 @@ public class ForumFragment extends BaseFragment
forumTask.execute();
}
- Report.d(TAG, "onActivityCreated");
+ Timber.d("onActivityCreated");
}
@Override
@@ -151,8 +152,7 @@ public class ForumFragment extends BaseFragment
//---------------------------------------ASYNC TASK-----------------------------------
- public class ForumTask extends AsyncTask {
- private static final String TAG = "ForumTask";
+ private class ForumTask extends AsyncTask {
private HttpUrl forumUrl = SessionManager.forumUrl; //may change upon collapse/expand
private Document document;
@@ -179,10 +179,10 @@ public class ForumFragment extends BaseFragment
fetchedCategories.clear();
return 0;
} catch (IOException e) {
- Report.d(TAG, "Network Error", e);
+ Timber.d("Network Error", e);
return 1;
} catch (Exception e) {
- Report.d(TAG, "Exception", e);
+ Timber.d("Exception", e);
return 2;
}
@@ -225,7 +225,7 @@ public class ForumFragment extends BaseFragment
}
}
else
- Report.e(TAG, "Parsing failed!");
+ Timber.e("Parsing failed!");
}
public void setUrl(String string)
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java
index 7cd9ef63..d9e92599 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java
@@ -29,10 +29,11 @@ import gr.thmmy.mthmmy.session.SessionManager;
import gr.thmmy.mthmmy.utils.CustomRecyclerView;
import gr.thmmy.mthmmy.utils.exceptions.ParseException;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
-import mthmmy.utils.Report;
+
import okhttp3.HttpUrl;
import okhttp3.Request;
import okhttp3.Response;
+import timber.log.Timber;
/**
* A {@link BaseFragment} subclass.
@@ -86,7 +87,7 @@ public class RecentFragment extends BaseFragment {
recentTask.execute();
}
- Report.d(TAG, "onActivityCreated");
+ Timber.d("onActivityCreated");
}
@@ -141,8 +142,7 @@ public class RecentFragment extends BaseFragment {
//---------------------------------------ASYNC TASK-----------------------------------
- public class RecentTask extends AsyncTask {
- private static final String TAG = "RecentTask";
+ private class RecentTask extends AsyncTask {
private final HttpUrl thmmyUrl = SessionManager.indexUrl;
private Document document;
@@ -161,13 +161,13 @@ public class RecentFragment extends BaseFragment {
parse(document);
return 0;
} catch (ParseException e) {
- Report.e(TAG, "ParseException", e);
+ Timber.e("ParseException", e);
return 1;
} catch (IOException e) {
- Report.i(TAG, "Network Error", e);
+ Timber.i("Network Error", e);
return 2;
} catch (Exception e) {
- Report.e(TAG, "Exception", e);
+ Timber.e("Exception", e);
return 3;
}
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java
index 2444bf95..08495dd9 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java
@@ -19,7 +19,7 @@ import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.text.style.RelativeSizeSpan;
-import android.util.Log;
+
import android.view.View;
import android.widget.ImageView;
import android.widget.ProgressBar;
@@ -50,9 +50,10 @@ import gr.thmmy.mthmmy.model.ThmmyPage;
import gr.thmmy.mthmmy.utils.CenterVerticalSpan;
import gr.thmmy.mthmmy.utils.CircleTransform;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
-import mthmmy.utils.Report;
+
import okhttp3.Request;
import okhttp3.Response;
+import timber.log.Timber;
import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_TITLE;
import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL;
@@ -64,11 +65,6 @@ import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL;
* the username using the key {@link #BUNDLE_PROFILE_USERNAME}.
*/
public class ProfileActivity extends BaseActivity implements LatestPostsFragment.LatestPostsFragmentInteractionListener {
- /**
- * Debug Tag for logging debug output to LogCat
- */
- @SuppressWarnings("unused")
- private static final String TAG = "ProfileActivity";
/**
* The key to use when putting profile's url String to {@link ProfileActivity}'s Bundle.
*/
@@ -179,7 +175,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
ThmmyPage.PageCategory target = ThmmyPage.resolvePageCategory(Uri.parse(profileUrl));
if (!target.is(ThmmyPage.PageCategory.PROFILE)) {
- Report.e(TAG, "Bundle came with a non profile url!\nUrl:\n" + profileUrl);
+ Timber.e("Bundle came with a non profile url!\nUrl:\n%s" , profileUrl);
Toast.makeText(this, "An error has occurred\n Aborting.", Toast.LENGTH_SHORT).show();
finish();
}
@@ -222,11 +218,6 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
*/
public class ProfileTask extends AsyncTask {
//Class variables
- /**
- * Debug Tag for logging debug output to LogCat
- */
- @SuppressWarnings("unused")
- private static final String TAG = "ProfileTask"; //Separate tag for AsyncTask
Document profilePage;
Spannable usernameSpan;
@@ -262,7 +253,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
} else {
//Should never get here!
//Something is wrong.
- Report.e(TAG, "An error occurred while trying to find profile's personal text.");
+ Timber.e("An error occurred while trying to find profile's personal text.");
personalText = null;
}
}
@@ -283,16 +274,16 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
}
return true;
} catch (SSLHandshakeException e) {
- Report.w(TAG, "Certificate problem (please switch to unsafe connection).");
+ Timber.w("Certificate problem (please switch to unsafe connection).");
} catch (Exception e) {
- Report.e("TAG", "ERROR", e);
+ Timber.e("ERROR", e);
}
return false;
}
protected void onPostExecute(Boolean result) {
- if (!result) { //Parse failed!
- Report.d(TAG, "Parse failed!");
+ if (!result) { //Parse failed! //TODO report as ParseException?
+ Timber.d("Parse failed!");
Toast.makeText(getBaseContext(), "Fatal error!\n Aborting..."
, Toast.LENGTH_LONG).show();
finish();
@@ -344,7 +335,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
viewPager.setAdapter(adapter);
}
- class ViewPagerAdapter extends FragmentPagerAdapter {
+ private class ViewPagerAdapter extends FragmentPagerAdapter {
private final List mFragmentList = new ArrayList<>();
private final List mFragmentTitleList = new ArrayList<>();
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java
index 5f0f77d2..13319607 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java
@@ -21,11 +21,6 @@ import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
* specified {@link LatestPostsFragment.LatestPostsFragmentInteractionListener}.
*/
class LatestPostsAdapter extends RecyclerView.Adapter {
- /**
- * Debug Tag for logging debug output to LogCat
- */
- @SuppressWarnings("unused")
- private static final String TAG = "LatestPostsAdapter";
private final int VIEW_TYPE_ITEM = 0;
private final int VIEW_TYPE_LOADING = 1;
final private LatestPostsFragment.LatestPostsFragmentInteractionListener interactionListener;
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java
index ccdb5593..5c3f8d40 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java
@@ -26,19 +26,15 @@ import gr.thmmy.mthmmy.base.BaseFragment;
import gr.thmmy.mthmmy.model.PostSummary;
import gr.thmmy.mthmmy.utils.ParseHelpers;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
-import mthmmy.utils.Report;
+
import okhttp3.Request;
import okhttp3.Response;
+import timber.log.Timber;
/**
* Use the {@link LatestPostsFragment#newInstance} factory method to create an instance of this fragment.
*/
public class LatestPostsFragment extends BaseFragment implements LatestPostsAdapter.OnLoadMoreListener{
- /**
- * Debug Tag for logging debug output to LogCat
- */
- @SuppressWarnings("unused")
- private static final String TAG = "LatestPostsFragment";
/**
* The key to use when putting profile's url String to {@link LatestPostsFragment}'s Bundle.
*/
@@ -136,7 +132,7 @@ public class LatestPostsFragment extends BaseFragment implements LatestPostsAdap
profileLatestPostsTask.execute(profileUrl + ";sa=showPosts");
pagesLoaded = 1;
}
- Report.d(TAG, "onActivityCreated");
+ Timber.d("onActivityCreated");
}
@Override
@@ -156,14 +152,7 @@ public class LatestPostsFragment extends BaseFragment implements LatestPostsAdap
* LatestPostsTask's {@link AsyncTask#execute execute} method needs a profile's url as String
* parameter!
*/
- public class LatestPostsTask extends AsyncTask {
- //Class variables
- /**
- * Debug Tag for logging debug output to LogCat
- */
- @SuppressWarnings("unused")
- private static final String TAG = "LatestPostsTask"; //Separate tag for AsyncTask
-
+ private class LatestPostsTask extends AsyncTask {
protected void onPreExecute() {
if (!isLoadingMore) progressBar.setVisibility(ProgressBar.VISIBLE);
}
@@ -176,16 +165,16 @@ public class LatestPostsFragment extends BaseFragment implements LatestPostsAdap
Response response = BaseActivity.getClient().newCall(request).execute();
return parseLatestPosts(Jsoup.parse(response.body().string()));
} catch (SSLHandshakeException e) {
- Report.w(TAG, "Certificate problem (please switch to unsafe connection).");
+ Timber.w("Certificate problem (please switch to unsafe connection).");
} catch (Exception e) {
- Report.e("TAG", "ERROR", e);
+ Timber.e("ERROR", e);
}
return false;
}
protected void onPostExecute(Boolean result) {
if (!result) { //Parse failed!
- Report.d(TAG, "Parse failed!");
+ Timber.d("Parse failed!");
Toast.makeText(getContext()
, "Fatal error!\n Aborting...", Toast.LENGTH_LONG).show();
getActivity().finish();
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java
index 2e102c0e..f573f3db 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java
@@ -41,16 +41,12 @@ import javax.net.ssl.SSLHandshakeException;
import gr.thmmy.mthmmy.R;
import gr.thmmy.mthmmy.base.BaseActivity;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
-import mthmmy.utils.Report;
+
import okhttp3.Request;
import okhttp3.Response;
+import timber.log.Timber;
public class StatsFragment extends Fragment {
- /**
- * Debug Tag for logging debug output to LogCat
- */
- @SuppressWarnings("unused")
- private static final String TAG = "StatsFragment";
/**
* The key to use when putting profile's url String to {@link StatsFragment}'s Bundle.
*/
@@ -109,7 +105,7 @@ public class StatsFragment extends Fragment {
profileStatsTask = new ProfileStatsTask();
profileStatsTask.execute(profileUrl + ";sa=statPanel");
}
- Report.d(TAG, "onActivityCreated");
+ Timber.d("onActivityCreated");
}
@Override
@@ -127,14 +123,7 @@ public class StatsFragment extends Fragment {
* Calling SummaryTask's {@link AsyncTask#execute execute} method needs to have profile's url
* as String parameter!
*/
- public class ProfileStatsTask extends AsyncTask {
- //Class variables
- /**
- * Debug Tag for logging debug output to LogCat
- */
- @SuppressWarnings("unused")
- private static final String TAG = "ProfileStatsTask"; //Separate tag for AsyncTask
-
+ private class ProfileStatsTask extends AsyncTask {
@Override
protected void onPreExecute() {
progressBar.setVisibility(ProgressBar.VISIBLE);
@@ -150,9 +139,9 @@ public class StatsFragment extends Fragment {
Response response = BaseActivity.getClient().newCall(request).execute();
return parseStats(Jsoup.parse(response.body().string()));
} catch (SSLHandshakeException e) {
- Report.w(TAG, "Certificate problem (please switch to unsafe connection).");
+ Timber.w("Certificate problem (please switch to unsafe connection).");
} catch (Exception e) {
- Report.e("TAG", "ERROR", e);
+ Timber.e("ERROR", e);
}
return false;
}
@@ -160,7 +149,7 @@ public class StatsFragment extends Fragment {
@Override
protected void onPostExecute(Boolean result) {
if (!result) { //Parse failed!
- Report.d(TAG, "Parse failed!");
+ Timber.d("Parse failed!");
Toast.makeText(getContext()
, "Fatal error!\n Aborting...", Toast.LENGTH_LONG).show();
getActivity().finish();
@@ -348,7 +337,7 @@ public class StatsFragment extends Fragment {
mostPopularBoardsByActivityChart.invalidate();
}
- class MyXAxisValueFormatter implements IAxisValueFormatter {
+ private class MyXAxisValueFormatter implements IAxisValueFormatter {
private final ArrayList mValues;
MyXAxisValueFormatter(ArrayList values) {
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java
index f876b6ff..70644bf4 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java
@@ -7,7 +7,7 @@ import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.Html;
import android.text.method.LinkMovementMethod;
-import android.util.Log;
+
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -25,18 +25,14 @@ import java.util.Objects;
import gr.thmmy.mthmmy.R;
import gr.thmmy.mthmmy.utils.ParseHelpers;
-import mthmmy.utils.Report;
+
+import timber.log.Timber;
/**
* Use the {@link SummaryFragment#newInstance} factory method to create an instance of this fragment.
*/
public class SummaryFragment extends Fragment {
- /**
- * Debug Tag for logging debug output to LogCat
- */
- @SuppressWarnings("unused")
- private static final String TAG = "SummaryFragment";
/**
* The key to use when putting profile's source code String to {@link SummaryFragment}'s Bundle.
*/
@@ -96,7 +92,7 @@ public class SummaryFragment extends Fragment {
summaryTask = new SummaryTask();
summaryTask.execute(profileSummaryDocument);
}
- Report.d(TAG, "onActivityCreated");
+ Timber.d("onActivityCreated");
}
@Override
@@ -114,14 +110,7 @@ public class SummaryFragment extends Fragment {
* Calling SummaryTask's {@link AsyncTask#execute execute} method needs to have profile's url
* as String parameter!
*/
- public class SummaryTask extends AsyncTask {
- //Class variables
- /**
- * Debug Tag for logging debug output to LogCat
- */
- @SuppressWarnings("unused")
- private static final String TAG = "SummaryTask"; //Separate tag for AsyncTask
-
+ private class SummaryTask extends AsyncTask {
protected Void doInBackground(Document... profileSummaryPage) {
parsedProfileSummaryData = parseProfileSummary(profileSummaryPage[0]);
return null;
@@ -193,8 +182,8 @@ public class SummaryFragment extends Fragment {
if (profileSummaryRow.contains("@") &&
(profileSummaryRow.contains("Email") || profileSummaryRow.contains("E-mail"))) {
- Log.d(TAG, "mpika");
- Log.d(TAG, profileSummaryRow);
+ Timber.d("mpika");
+ Timber.d(profileSummaryRow);
String email = profileSummaryRow.substring(profileSummaryRow.indexOf(": ") + 6);
profileSummaryRow = profileSummaryRow.replace(email,
"" + email + "");
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/ReplyParser.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/ReplyParser.java
index 4950478b..ca47585a 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/ReplyParser.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/ReplyParser.java
@@ -10,12 +10,6 @@ import java.io.IOException;
import okhttp3.Response;
class ReplyParser {
- /**
- * Debug Tag for logging debug output to LogCat
- */
- @SuppressWarnings("unused")
- private static final String TAG = "ReplyParser";
-
enum REPLY_STATUS {
SUCCESSFUL, NO_SUBJECT, EMPTY_BODY, NEW_REPLY_WHILE_POSTING, NOT_FOUND, SESSION_ENDED, OTHER_ERROR
}
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
index 710170fa..942dd50c 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
@@ -47,11 +47,12 @@ import gr.thmmy.mthmmy.model.Post;
import gr.thmmy.mthmmy.model.ThmmyPage;
import gr.thmmy.mthmmy.utils.ParseHelpers;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
-import mthmmy.utils.Report;
+
import okhttp3.MultipartBody;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
+import timber.log.Timber;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE;
@@ -69,11 +70,6 @@ import static gr.thmmy.mthmmy.activities.topic.ReplyParser.replyStatus;
@SuppressWarnings("unchecked")
public class TopicActivity extends BaseActivity {
//Class variables
- /**
- * Debug Tag for logging debug output to LogCat
- */
- @SuppressWarnings("unused")
- private static final String TAG = "TopicActivity";
/**
* The key to use when putting topic's url String to {@link TopicActivity}'s Bundle.
*/
@@ -134,7 +130,7 @@ public class TopicActivity extends BaseActivity {
ThmmyPage.PageCategory target = ThmmyPage.resolvePageCategory(
Uri.parse(topicPageUrl));
if (!target.is(ThmmyPage.PageCategory.TOPIC)) {
- Report.e(TAG, "Bundle came with a non topic url!\nUrl:\n" + topicPageUrl);
+ Timber.e("Bundle came with a non topic url!\nUrl:\n" + topicPageUrl);
Toast.makeText(this, "An error has occurred\n Aborting.", Toast.LENGTH_SHORT).show();
finish();
}
@@ -455,11 +451,6 @@ public class TopicActivity extends BaseActivity {
* as String parameter!
*/
class TopicTask extends AsyncTask {
- //Class variables
- /**
- * Debug Tag for logging debug output to LogCat
- */
- private static final String TAG = "TopicTask"; //Separate tag for AsyncTask
private static final int SUCCESS = 0;
private static final int NETWORK_ERROR = 1;
private static final int OTHER_ERROR = 2;
@@ -518,10 +509,10 @@ public class TopicActivity extends BaseActivity {
parse(document);
return SUCCESS;
} catch (IOException e) {
- Report.i(TAG, "IO Exception", e);
+ Timber.i("IO Exception", e);
return NETWORK_ERROR;
} catch (Exception e) {
- Report.e(TAG, "Exception", e);
+ Timber.e("Exception", e);
return OTHER_ERROR;
}
}
@@ -570,7 +561,7 @@ public class TopicActivity extends BaseActivity {
break;
default:
//Parse failed - should never happen
- Report.d(TAG, "Parse failed!");
+ Timber.d("Parse failed!"); //TODO report ParseException?
Toast.makeText(getBaseContext(), "Fatal Error", Toast.LENGTH_SHORT).show();
finish();
break;
@@ -609,7 +600,7 @@ public class TopicActivity extends BaseActivity {
} else {
parsedTitle = parsedTitle.substring(parsedTitle.indexOf("Θέμα:") + 6
, parsedTitle.indexOf("(Αναγνώστηκε") - 2);
- Report.d(TAG, parsedTitle);
+ Timber.d(parsedTitle);
}
}
@@ -700,10 +691,10 @@ public class TopicActivity extends BaseActivity {
subject = document.select("input[name=subject]").first().attr("value");
topic = document.select("input[name=topic]").first().attr("value");
} catch (IOException e) {
- Report.e(TAG, "Post failed.", e);
+ Timber.e("Post failed.", e);
return false;
} catch (Selector.SelectorParseException e) {
- Report.e(TAG, "Post failed.", e);
+ Timber.e("Post failed.", e);
return false;
}
@@ -733,11 +724,11 @@ public class TopicActivity extends BaseActivity {
//TODO this...
return true;
default:
- Report.e(TAG, "Malformed post. Request string:\n" + post.toString());
+ Timber.e("Malformed post. Request string:\n" + post.toString());
return true;
}
} catch (IOException e) {
- Report.e(TAG, "Post failed.", e);
+ Timber.e("Post failed.", e);
return false;
}
}
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
index 59c529af..3f5154fb 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
@@ -18,7 +18,7 @@ import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
-import android.util.Log;
+
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
@@ -54,7 +54,8 @@ import gr.thmmy.mthmmy.model.Post;
import gr.thmmy.mthmmy.model.ThmmyFile;
import gr.thmmy.mthmmy.model.ThmmyPage;
import gr.thmmy.mthmmy.utils.CircleTransform;
-import mthmmy.utils.Report;
+
+import timber.log.Timber;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE;
@@ -68,10 +69,6 @@ import static gr.thmmy.mthmmy.base.BaseActivity.getSessionManager;
* Custom {@link android.support.v7.widget.RecyclerView.Adapter} used for topics.
*/
class TopicAdapter extends RecyclerView.Adapter {
- /**
- * Debug Tag for logging debug output to LogCat
- */
- private static final String TAG = "TopicAdapter";
/**
* Int that holds thumbnail's size defined in R.dimen
*/
@@ -415,7 +412,7 @@ class TopicAdapter extends RecyclerView.Adapter {
if (toQuoteList.contains(postsList.indexOf(currentPost))) {
toQuoteList.remove(toQuoteList.indexOf(postsList.indexOf(currentPost)));
} else
- Report.i(TAG, "An error occurred while trying to exclude post from" +
+ Timber.i("An error occurred while trying to exclude post from" +
"toQuoteList, post wasn't there!");
holder.quoteToggle.setImageResource(R.drawable.ic_format_quote_unchecked);
} else {
diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java
index 9229c6b9..7d21196a 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java
@@ -17,7 +17,8 @@ import java.util.Objects;
import gr.thmmy.mthmmy.model.Post;
import gr.thmmy.mthmmy.model.ThmmyFile;
import gr.thmmy.mthmmy.utils.ParseHelpers;
-import mthmmy.utils.Report;
+import timber.log.Timber;
+
/**
* Singleton used for parsing a topic.
@@ -36,12 +37,6 @@ class TopicParser {
static final int USER_COLOR_PINK = Color.parseColor("#FF4081");
private static final int USER_COLOR_YELLOW = Color.parseColor("#FFEB3B");
- /**
- * Debug Tag for logging debug output to LogCat
- */
- @SuppressWarnings("unused")
- private static final String TAG = "TopicParser";
-
/**
* Returns users currently viewing this topic.
*
@@ -257,7 +252,7 @@ class TopicParser {
try {
attachedUrl = new URL(tmpAttachedFileUrlAndName.attr("href"));
} catch (MalformedURLException e) {
- Report.e(TAG, "Attached file malformed url", e);
+ Timber.e("Attached file malformed url", e);
break;
}
String attachedFileName = tmpAttachedFileUrlAndName.text().substring(1);
@@ -317,7 +312,7 @@ class TopicParser {
try {
attachedUrl = new URL(tmpAttachedFileUrlAndName.attr("href"));
} catch (MalformedURLException e) {
- Report.e(TAG, "Attached file malformed url", e);
+ Timber.e("Attached file malformed url", e);
break;
}
String attachedFileName = tmpAttachedFileUrlAndName.text().substring(1);
diff --git a/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java b/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java
index b119dabe..3030cce0 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java
@@ -23,13 +23,16 @@ import java.io.IOException;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
+import gr.thmmy.mthmmy.BuildConfig;
import gr.thmmy.mthmmy.R;
import gr.thmmy.mthmmy.session.SessionManager;
+import gr.thmmy.mthmmy.utils.CrashReportingTree;
import okhttp3.HttpUrl;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
+import timber.log.Timber;
public class BaseApplication extends Application {
@@ -55,6 +58,12 @@ public class BaseApplication extends Application {
super.onCreate();
baseApplication = this; //init singleton
+ if (BuildConfig.DEBUG) {
+ Timber.plant(new Timber.DebugTree());
+ } else {
+ Timber.plant(new CrashReportingTree());
+ }
+
SharedPreferences sharedPrefs = getSharedPreferences(SHARED_PREFS_NAME, MODE_PRIVATE);
SharedPrefsCookiePersistor sharedPrefsCookiePersistor = new SharedPrefsCookiePersistor(getApplicationContext());
PersistentCookieJar cookieJar = new PersistentCookieJar(new SetCookieCache(), sharedPrefsCookiePersistor);
diff --git a/app/src/main/java/gr/thmmy/mthmmy/base/BaseFragment.java b/app/src/main/java/gr/thmmy/mthmmy/base/BaseFragment.java
index c7b3d477..c33ffdf6 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/base/BaseFragment.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/base/BaseFragment.java
@@ -5,8 +5,8 @@ import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
-import mthmmy.utils.Report;
import okhttp3.OkHttpClient;
+import timber.log.Timber;
public abstract class BaseFragment extends Fragment {
protected static final String ARG_SECTION_NUMBER = "SectionNumber";
@@ -26,31 +26,31 @@ public abstract class BaseFragment extends Fragment {
if(client==null)
client = BaseApplication.getInstance().getClient(); //must check every time - e.g.
// becomes null when app restarts after crash
- Report.d(TAG, "onCreate");
+ Timber.d("onCreate");
}
@Override
public void onStart() {
super.onStart();
- Report.d(TAG, "onStart");
+ Timber.d("onStart");
}
@Override
public void onResume() {
super.onResume();
- Report.d(TAG, "onResume");
+ Timber.d("onResume");
}
@Override
public void onPause() {
super.onPause();
- Report.d(TAG, "onPause");
+ Timber.d("onPause");
}
@Override
public void onStop() {
super.onStop();
- Report.d(TAG, "onStop");
+ Timber.d("onStop");
}
@Override
diff --git a/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java b/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java
index cc9a1781..38f95867 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java
@@ -4,7 +4,7 @@ import android.net.Uri;
import java.util.Objects;
-import mthmmy.utils.Report;
+import timber.log.Timber;
/**
* This class consists exclusively of static classes (enums) and methods (excluding methods of inner
@@ -162,7 +162,7 @@ public class ThmmyPage {
|| Objects.equals(uriString, "https://www.thmmy.gr")
|| Objects.equals(uriString, "https://www.thmmy.gr/smf/index.php"))
return PageCategory.INDEX;
- Report.v(TAG, "Unknown thmmy link found, link: " + uriString);
+ Timber.v("Unknown thmmy link found, link: " + uriString);
return PageCategory.UNKNOWN_THMMY;
}
return PageCategory.NOT_THMMY;
diff --git a/app/src/main/java/gr/thmmy/mthmmy/receiver/Receiver.java b/app/src/main/java/gr/thmmy/mthmmy/receiver/Receiver.java
index 3e811134..d93f4272 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/receiver/Receiver.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/receiver/Receiver.java
@@ -14,7 +14,8 @@ import android.webkit.MimeTypeMap;
import java.io.File;
import gr.thmmy.mthmmy.R;
-import mthmmy.utils.Report;
+
+import timber.log.Timber;
import static gr.thmmy.mthmmy.services.DownloadService.ACTION_DOWNLOAD;
import static gr.thmmy.mthmmy.services.DownloadService.COMPLETED;
@@ -28,7 +29,6 @@ import static gr.thmmy.mthmmy.services.DownloadService.SAVE_DIR;
import static gr.thmmy.mthmmy.services.DownloadService.STARTED;
public class Receiver extends BroadcastReceiver {
- private static final String TAG = "BroadcastReceiver";
public Receiver() {
}
@@ -72,7 +72,7 @@ public class Receiver extends BroadcastReceiver {
builder.setContentIntent(pendingIntent);
} else
- Report.w(TAG, "File doesn't exist.");
+ Timber.w("File doesn't exist.");
}
Notification notification = builder.build();
notificationManager.notify(id, notification);
diff --git a/app/src/main/java/gr/thmmy/mthmmy/services/DownloadService.java b/app/src/main/java/gr/thmmy/mthmmy/services/DownloadService.java
index 7339fa73..cd878b25 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/services/DownloadService.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/services/DownloadService.java
@@ -13,12 +13,13 @@ import java.io.IOException;
import gr.thmmy.mthmmy.base.BaseApplication;
import gr.thmmy.mthmmy.receiver.Receiver;
-import mthmmy.utils.Report;
+
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okio.BufferedSink;
import okio.Okio;
+import timber.log.Timber;
/**
* An {@link IntentService} subclass for handling asynchronous task requests in
@@ -116,9 +117,9 @@ public class DownloadService extends IntentService {
if(!dirPath.isDirectory())
{
if(dirPath.mkdirs())
- Report.i(TAG, "mTHMMY's directory created successfully!");
+ Timber.i("mTHMMY's directory created successfully!");
else
- Report.e(TAG, "Couldn't create mTHMMY's directory...");
+ Timber.e("Couldn't create mTHMMY's directory...");
}
@@ -127,7 +128,7 @@ public class DownloadService extends IntentService {
if(tokens.length!=2)
{
- Report.w(TAG, "Couldn't get file extension...");
+ Timber.w("Couldn't get file extension...");
nameFormat = fileName + "(%d)";
}
else
@@ -148,26 +149,26 @@ public class DownloadService extends IntentService {
fileName = file.getName();
- Report.v(TAG, "Started saving file " + fileName);
+ Timber.v("Started saving file " + fileName);
sendNotification(downloadId, STARTED, fileName);
sink = Okio.buffer(Okio.sink(file));
sink.writeAll(response.body().source());
sink.flush();
- Report.i(TAG, "Download OK!");
+ Timber.i("Download OK!");
sendNotification(downloadId, COMPLETED, fileName);
}
else
- Report.e(TAG, "Response not a binary file!");
+ Timber.e("Response not a binary file!");
}
catch (FileNotFoundException e){
- Report.i(TAG, "Download failed...");
- Report.e(TAG, "FileNotFound", e);
+ Timber.i("Download failed...");
+ Timber.e("FileNotFound", e);
sendNotification(downloadId, FAILED, fileName);
}
catch (IOException e){
- Report.i(TAG, "Download failed...");
- Report.e(TAG, "IOException", e);
+ Timber.i("Download failed...");
+ Timber.e("IOException", e);
sendNotification(downloadId, FAILED, fileName);
} finally {
if (sink!= null) {
@@ -203,7 +204,7 @@ public class DownloadService extends IntentService {
break;
}
default:{
- Report.wtf(TAG, "Invalid notification case!");
+ Timber.e("Invalid notification case!");
return;
}
}
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 c6bbd713..ce0f9228 100644
--- a/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java
+++ b/app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java
@@ -18,7 +18,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import gr.thmmy.mthmmy.utils.exceptions.ParseException;
-import mthmmy.utils.Report;
import okhttp3.Cookie;
import okhttp3.FormBody;
import okhttp3.HttpUrl;
@@ -26,15 +25,13 @@ import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
+import timber.log.Timber;
/**
* This class handles all session related operations (e.g. login, logout)
* and stores data to SharedPreferences (session information and cookies).
*/
public class SessionManager {
- //Class TAG
- private static final String TAG = "SessionManager";
-
//Generic constants
public static final HttpUrl indexUrl = HttpUrl.parse("https://www.thmmy.gr/smf/index.php?theme=4");
public static final HttpUrl forumUrl = HttpUrl.parse("https://www.thmmy.gr/smf/index.php?action=forum;theme=4");
@@ -80,7 +77,7 @@ public class SessionManager {
* Always call it in a separate thread.
*/
public int login(String... strings) {
- Report.i(TAG, "Logging in...");
+ Timber.i("Logging in...");
//Build the login request for each case
Request request;
@@ -114,7 +111,7 @@ public class SessionManager {
if (unreadRepliesLinks.size()>=2) //Normally it's just == 2, but who knows what can be posted by users
{
- Report.i(TAG, "Login successful!");
+ Timber.i("Login successful!");
setPersistentCookieSession(); //Store cookies
//Edit SharedPreferences, save session's data
@@ -133,18 +130,18 @@ public class SessionManager {
return SUCCESS;
} else {
- Report.i(TAG, "Login failed.");
+ Timber.i("Login failed.");
//Investigate login failure
Elements error = document.select("b:contains(That username does not exist.)");
if (error.size() == 1) { //Wrong username
- Report.i(TAG, "Wrong Username");
+ Timber.i("Wrong Username");
return WRONG_USER;
}
error = document.select("body:contains(Password incorrect)");
if (error.size() == 1) { //Wrong password
- Report.i(TAG, "Wrong Password");
+ Timber.i("Wrong Password");
return WRONG_PASSWORD;
}
@@ -154,13 +151,13 @@ public class SessionManager {
}
//Handle exception
} catch (InterruptedIOException e) {
- Report.i(TAG, "Login InterruptedIOException"); //users cancels LoginTask
+ Timber.i("Login InterruptedIOException"); //users cancels LoginTask
return CANCELLED;
} catch (IOException e) {
- Report.w(TAG, "Login IOException", e);
+ Timber.w("Login IOException", e);
return CONNECTION_ERROR;
} catch (Exception e) {
- Report.w(TAG, "Login Exception (other)", e);
+ Timber.w("Login Exception (other)", e);
return EXCEPTION;
}
}
@@ -175,7 +172,7 @@ public class SessionManager {
* fragments' data are retrieved).
*/
public void validateSession() {
- Report.i(TAG, "Validating session...");
+ Timber.i("Validating session...");
if (isLoggedIn()) {
int loginResult = login();
@@ -192,7 +189,7 @@ public class SessionManager {
* Call this function when user explicitly chooses to continue as a guest (UI thread).
*/
public void guestLogin() {
- Report.i("TAG", "Continuing as a guest, as chosen by the user.");
+ Timber.i("Continuing as a guest, as chosen by the user.");
clearSessionData();
sharedPrefs.edit().putBoolean(LOGIN_SCREEN_AS_DEFAULT, false).apply();
}
@@ -202,7 +199,7 @@ public class SessionManager {
* Logout function. Always call it in a separate thread.
*/
public int logout() {
- Report.i(TAG, "Logging out...");
+ Timber.i("Logging out...");
Request request = new Request.Builder()
.url(sharedPrefs.getString(LOGOUT_LINK, "LogoutLink"))
@@ -216,17 +213,17 @@ public class SessionManager {
Elements loginButton = document.select("[value=Login]"); //Attempt to find login button
if (!loginButton.isEmpty()) //If login button exists, logout was successful
{
- Report.i(TAG, "Logout successful!");
+ Timber.i("Logout successful!");
return SUCCESS;
} else {
- Report.i(TAG, "Logout failed.");
+ Timber.i("Logout failed.");
return FAILURE;
}
} catch (IOException e) {
- Report.w(TAG, "Logout IOException", e);
+ Timber.w("Logout IOException", e);
return CONNECTION_ERROR;
} catch (Exception e) {
- Report.w(TAG, "Logout Exception", e);
+ Timber.w("Logout Exception", e);
return EXCEPTION;
} finally {
//All data should always be cleared from device regardless the result of logout
@@ -288,7 +285,7 @@ public class SessionManager {
sharedPrefs.edit().clear().apply(); //Clear session data
sharedPrefs.edit().putString(USERNAME, guestName).apply();
sharedPrefs.edit().putBoolean(LOGGED_IN, false).apply(); //User logs out
- Report.i(TAG, "Session data cleared.");
+ Timber.i("Session data cleared.");
}
@NonNull
@@ -321,7 +318,7 @@ public class SessionManager {
if(userName != null && !userName.isEmpty())
return userName;
- Report.e(TAG, "ParseException", new ParseException("Parsing failed(username extraction)"));
+ Timber.e("ParseException", new ParseException("Parsing failed(username extraction)"));
return "User"; //return a default username
}
@@ -332,7 +329,7 @@ public class SessionManager {
if (!avatar.isEmpty())
return avatar.first().attr("src");
- Report.i(TAG, "Extracting avatar's link failed!");
+ Timber.i("Extracting avatar's link failed!");
return null;
}
@@ -346,7 +343,7 @@ public class SessionManager {
if(link != null && !link.isEmpty())
return link;
}
- Report.e(TAG, "ParseException", new ParseException("Parsing failed(logoutLink extraction)"));
+ Timber.e("ParseException", new ParseException("Parsing failed(logoutLink extraction)"));
return "https://www.thmmy.gr/smf/index.php?action=logout"; //return a default link
}
//----------------------------------OTHER FUNCTIONS END-----------------------------------------
diff --git a/app/src/main/java/gr/thmmy/mthmmy/utils/CrashReportingTree.java b/app/src/main/java/gr/thmmy/mthmmy/utils/CrashReportingTree.java
new file mode 100644
index 00000000..2aeca9a2
--- /dev/null
+++ b/app/src/main/java/gr/thmmy/mthmmy/utils/CrashReportingTree.java
@@ -0,0 +1,34 @@
+package gr.thmmy.mthmmy.utils;
+
+import android.util.Log;
+
+import com.google.firebase.crash.FirebaseCrash;
+
+import gr.thmmy.mthmmy.utils.exceptions.UnknownException;
+import timber.log.Timber;
+
+public class CrashReportingTree extends Timber.Tree {
+ @Override
+ protected void log(int priority, String tag, String message, Throwable t) {
+ if (priority == Log.VERBOSE || priority == Log.DEBUG) {
+ return;
+ }
+
+ String level="A";
+
+ if (priority == Log.INFO)
+ level = "I";
+ else if (priority == Log.WARN)
+ level = "W";
+ else if(priority == Log.ERROR)
+ level = "E";
+
+ FirebaseCrash.log(level + "/" + tag + ": " + message);
+
+ if(t==null)
+ t = new UnknownException("UnknownException");
+
+ if ((priority == Log.ERROR))
+ FirebaseCrash.report(t);
+ }
+}
diff --git a/app/src/release/java/mthmmy.utils/Report.java b/app/src/release/java/mthmmy.utils/Report.java
deleted file mode 100644
index 4a6a46b8..00000000
--- a/app/src/release/java/mthmmy.utils/Report.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package mthmmy.utils;
-
-import com.google.firebase.crash.FirebaseCrash;
-
-import gr.thmmy.mthmmy.utils.exceptions.UnknownException;
-
-public class Report
-{
-
- public static void v (String TAG, String message)
- {
- log("V", TAG, message);
- }
-
- public static void v (String TAG, String message, Throwable tr)
- {
- exception("V", TAG, message, tr);
- }
-
- public static void d (String TAG, String message)
- {
- log("D", TAG, message);
- }
-
- public static void d (String TAG, String message, Throwable tr)
- {
- exception("D", TAG, message, tr);
- }
-
- public static void i (String TAG, String message)
- {
- log("I", TAG, message);
- }
-
- public static void i (String TAG, String message, Throwable tr)
- {
- exception("I", TAG, message, tr);
- }
-
- public static void w (String TAG, String message)
- {
- log("W", TAG, message);
- }
-
- public static void w (String TAG, String message, Throwable tr)
- {
- exception("W", TAG, message, tr);
- }
-
- public static void e (String TAG, String message)
- {
- log("E", TAG, message);
- }
-
- public static void e (String TAG, String message, Throwable tr)
- {
- exception("E", TAG, message, tr);
- }
-
- public static void wtf (String TAG, String message)
- {
- log("WTF", TAG, message);
- }
-
- public static void wtf (String TAG, String message, Throwable tr)
- {
- exception("WTF", TAG, message, tr);
- }
-
- private static void log(String level, String TAG, String message)
- {
- if(!level.equals("V")&&!level.equals("D")) //don't log V and D levels
- {
- FirebaseCrash.log(level + "/" + TAG + ": " + message);
- if(level.equals("E")||level.equals("WTF")) //report only serious exceptions
- FirebaseCrash.report(new UnknownException("UnknownException"));
- }
- }
-
- private static void exception(String level, String TAG, String message, Throwable tr)
- {
- if(!level.equals("V")&&!level.equals("D")) //don't log V and D levels
- {
- FirebaseCrash.log(level + "/" + TAG + ": " + message + ": " + tr.getMessage());
- if(level.equals("E")||level.equals("WTF")) //report only serious exceptions
- FirebaseCrash.report(tr);
- }
- }
-
- /**
- * Does nothing in release.
- */
- public static void longMessage(String TAG, String level, String message) {return;}
-
-
-}
diff --git a/build.gradle b/build.gradle
index 25e7e862..a40a0e30 100644
--- a/build.gradle
+++ b/build.gradle
@@ -6,7 +6,7 @@ buildscript {
maven { url "https://jitpack.io" }
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.2.3'
+ classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 04e285f3..8b6dacea 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Mon Dec 28 10:00:20 PST 2015
+#Wed Mar 08 11:25:21 EET 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip