Browse Source

Timber init (Report class was removed), library updates

pull/24/head
Ezerous 8 years ago
parent
commit
a67adf2058
  1. 11
      app/build.gradle
  2. 81
      app/src/debug/java/mthmmy/utils/Report.java
  3. 4
      app/src/main/assets/apache_libraries.html
  4. 2
      app/src/main/assets/mit_libraries.html
  5. 9
      app/src/main/java/gr/thmmy/mthmmy/activities/LoginActivity.java
  6. 20
      app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardActivity.java
  7. 1
      app/src/main/java/gr/thmmy/mthmmy/activities/board/BoardAdapter.java
  8. 18
      app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsActivity.java
  9. 5
      app/src/main/java/gr/thmmy/mthmmy/activities/downloads/DownloadsAdapter.java
  10. 1
      app/src/main/java/gr/thmmy/mthmmy/activities/main/MainActivity.java
  11. 14
      app/src/main/java/gr/thmmy/mthmmy/activities/main/forum/ForumFragment.java
  12. 14
      app/src/main/java/gr/thmmy/mthmmy/activities/main/recent/RecentFragment.java
  13. 29
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/ProfileActivity.java
  14. 5
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsAdapter.java
  15. 25
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/latestPosts/LatestPostsFragment.java
  16. 27
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/stats/StatsFragment.java
  17. 25
      app/src/main/java/gr/thmmy/mthmmy/activities/profile/summary/SummaryFragment.java
  18. 6
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/ReplyParser.java
  19. 31
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
  20. 11
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  21. 13
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicParser.java
  22. 9
      app/src/main/java/gr/thmmy/mthmmy/base/BaseApplication.java
  23. 12
      app/src/main/java/gr/thmmy/mthmmy/base/BaseFragment.java
  24. 4
      app/src/main/java/gr/thmmy/mthmmy/model/ThmmyPage.java
  25. 6
      app/src/main/java/gr/thmmy/mthmmy/receiver/Receiver.java
  26. 25
      app/src/main/java/gr/thmmy/mthmmy/services/DownloadService.java
  27. 43
      app/src/main/java/gr/thmmy/mthmmy/session/SessionManager.java
  28. 34
      app/src/main/java/gr/thmmy/mthmmy/utils/CrashReportingTree.java
  29. 96
      app/src/release/java/mthmmy.utils/Report.java
  30. 2
      build.gradle
  31. 4
      gradle/wrapper/gradle-wrapper.properties

11
app/build.gradle

@ -2,7 +2,7 @@ apply plugin: 'com.android.application'
android { android {
compileSdkVersion 25 compileSdkVersion 25
buildToolsVersion "25.0.1" buildToolsVersion "25.0.2"
defaultConfig { defaultConfig {
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
@ -33,20 +33,21 @@ dependencies {
compile 'com.android.support:support-v4:25.2.0' compile 'com.android.support:support-v4:25.2.0'
compile 'com.android.support:cardview-v7:25.2.0' compile 'com.android.support:cardview-v7:25.2.0'
compile 'com.android.support:recyclerview-v7:25.2.0' compile 'com.android.support:recyclerview-v7:25.2.0'
compile 'com.google.firebase:firebase-crash:10.0.1' compile 'com.google.firebase:firebase-crash:10.2.0'
compile 'com.squareup.okhttp3:okhttp:3.5.0' compile 'com.squareup.okhttp3:okhttp:3.6.0'
compile 'com.squareup.picasso:picasso:2.5.2' compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0' compile 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'
compile 'org.jsoup:jsoup:1.10.2' compile 'org.jsoup:jsoup:1.10.2'
compile 'com.github.franmontiel:PersistentCookieJar:v1.0.0' compile 'com.github.franmontiel:PersistentCookieJar:v1.0.0'
compile 'com.github.PhilJay:MPAndroidChart:v3.0.1' 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 transitive = true
} }
compile 'com.mikepenz:fontawesome-typeface:4.7.0.0@aar' 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 'com.bignerdranch.android:expandablerecyclerview:3.0.0-RC1'
compile 'me.zhanghai.android.materialprogressbar:library:1.3.0' compile 'me.zhanghai.android.materialprogressbar:library:1.3.0'
compile 'com.jakewharton.timber:timber:4.5.1'
} }
apply plugin: 'com.google.gms.google-services' apply plugin: 'com.google.gms.google-services'

81
app/src/debug/java/mthmmy/utils/Report.java

@ -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));
}
}
}

4
app/src/main/assets/apache_libraries.html

@ -39,7 +39,7 @@
<body> <body>
<ul> <ul>
<li> <li>
<h5><a href="https://square.github.io/okhttp/">OkHttp</a>&nbsp;v3.5.0 (Copyright ©2016 Square, Inc.)</h5> <h5><a href="https://square.github.io/okhttp/">OkHttp</a>&nbsp;v3.6.0 (Copyright ©2016 Square, Inc.)</h5>
</li> </li>
<li> <li>
<h5><a href="https://square.github.io/picasso/">Picasso</a>&nbsp;v2.5.2 (Copyright ©2013 Square, Inc.)</h5> <h5><a href="https://square.github.io/picasso/">Picasso</a>&nbsp;v2.5.2 (Copyright ©2013 Square, Inc.)</h5>
@ -51,7 +51,7 @@
<h5><a href="https://github.com/PhilJay/MPAndroidChart">MPAndroidChart</a>&nbsp;v3.0.1 (Copyright ©2016 Philipp Jahoda)</h5> <h5><a href="https://github.com/PhilJay/MPAndroidChart">MPAndroidChart</a>&nbsp;v3.0.1 (Copyright ©2016 Philipp Jahoda)</h5>
</li> </li>
<li> <li>
<h5><a href="https://github.com/mikepenz/MaterialDrawer">MaterialDrawer</a>&nbsp;v5.8.1 (Copyright ©2016 Mike Penz)</h5> <h5><a href="https://github.com/mikepenz/MaterialDrawer">MaterialDrawer</a>&nbsp;v5.8.2 (Copyright ©2016 Mike Penz)</h5>
</li> </li>
<li> <li>
<h5><a href="https://github.com/mikepenz/Android-Iconics/tree/develop/fontawesome-typeface-library">Fontawesome Typeface Library</a>&nbsp;v4.7.0.0 (Copyright ©2016 Mike Penz)</h5> <h5><a href="https://github.com/mikepenz/Android-Iconics/tree/develop/fontawesome-typeface-library">Fontawesome Typeface Library</a>&nbsp;v4.7.0.0 (Copyright ©2016 Mike Penz)</h5>

2
app/src/main/assets/mit_libraries.html

@ -42,7 +42,7 @@
<h5><a href="https://jsoup.org//">jsoup</a>&nbsp;v1.10.2 (Copyright ©2009-2017, Jonathan Hedley &lt;jonathan@hedley.net&gt;)</h5> <h5><a href="https://jsoup.org//">jsoup</a>&nbsp;v1.10.2 (Copyright ©2009-2017, Jonathan Hedley &lt;jonathan@hedley.net&gt;)</h5>
</li> </li>
<li> <li>
<h5><a href="https://github.com/koral--/android-gif-drawable">android-gif-drawable</a>&nbsp;v1.2.3 (Copyright ©2016 Karol Wrótniak, Droids on Roids)</h5> <h5><a href="https://github.com/koral--/android-gif-drawable">android-gif-drawable</a>&nbsp;v1.2.5 (Copyright ©2016 Karol Wrótniak, Droids on Roids)</h5>
</li> </li>
<li> <li>
<h5><a href="https://github.com/bignerdranch/expandable-recycler-view">Expandable RecyclerView</a>&nbsp;v3.0.0-RC1 (Copyright ©2015, Big Nerd Ranch)</h5> <h5><a href="https://github.com/bignerdranch/expandable-recycler-view">Expandable RecyclerView</a>&nbsp;v3.0.0-RC1 (Copyright ©2015, Big Nerd Ranch)</h5>

9
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.R;
import gr.thmmy.mthmmy.activities.main.MainActivity; import gr.thmmy.mthmmy.activities.main.MainActivity;
import gr.thmmy.mthmmy.base.BaseActivity; 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.CONNECTION_ERROR;
import static gr.thmmy.mthmmy.session.SessionManager.EXCEPTION; import static gr.thmmy.mthmmy.session.SessionManager.EXCEPTION;
@ -34,12 +35,8 @@ public class LoginActivity extends BaseActivity {
private String password; private String password;
/* --Graphics End-- */ /* --Graphics End-- */
//Other variables
private static final String TAG = "LoginActivity";
private LoginTask loginTask; private LoginTask loginTask;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -55,7 +52,7 @@ public class LoginActivity extends BaseActivity {
btnLogin.setOnClickListener(new View.OnClickListener() { btnLogin.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) { public void onClick(View view) {
Report.d(TAG, "Login"); Timber.d("Login");
//Get username and password strings //Get username and password strings
username = inputUsername.getText().toString().trim(); username = inputUsername.getText().toString().trim();

20
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.ThmmyPage;
import gr.thmmy.mthmmy.model.Topic; import gr.thmmy.mthmmy.model.Topic;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
import mthmmy.utils.Report;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import timber.log.Timber;
public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMoreListener { 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. * 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); boardUrl = extras.getString(BUNDLE_BOARD_URL);
ThmmyPage.PageCategory target = ThmmyPage.resolvePageCategory(Uri.parse(boardUrl)); ThmmyPage.PageCategory target = ThmmyPage.resolvePageCategory(Uri.parse(boardUrl));
if (!target.is(ThmmyPage.PageCategory.BOARD)) { 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(); Toast.makeText(this, "An error has occurred\nAborting.", Toast.LENGTH_SHORT).show();
finish(); finish();
} }
@ -181,13 +176,6 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
* parameter!</p> * parameter!</p>
*/ */
public class BoardTask extends AsyncTask<String, Void, Void> { public class BoardTask extends AsyncTask<String, Void, Void> {
//Class variables
/**
* Debug Tag for logging debug output to LogCat
*/
@SuppressWarnings("unused")
private static final String TAG = "BoardTask"; //Separate tag for AsyncTask
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
if (!isLoadingMore) progressBar.setVisibility(ProgressBar.VISIBLE); if (!isLoadingMore) progressBar.setVisibility(ProgressBar.VISIBLE);
@ -203,9 +191,9 @@ public class BoardActivity extends BaseActivity implements BoardAdapter.OnLoadMo
Response response = client.newCall(request).execute(); Response response = client.newCall(request).execute();
parseBoard(Jsoup.parse(response.body().string())); parseBoard(Jsoup.parse(response.body().string()));
} catch (SSLHandshakeException e) { } 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) { } catch (Exception e) {
Report.e("TAG", "ERROR", e); Timber.e("ERROR", e);
} }
return null; return null;
} }

1
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}. * {@link RecyclerView.Adapter} that can display a {@link gr.thmmy.mthmmy.model.Board}.
*/ */
class BoardAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { class BoardAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static final String TAG = "BoardAdapter";
private final int VIEW_TYPE_SUB_BOARD_TITLE = 0; private final int VIEW_TYPE_SUB_BOARD_TITLE = 0;
private final int VIEW_TYPE_SUB_BOARD = 1; private final int VIEW_TYPE_SUB_BOARD = 1;
private final int VIEW_TYPE_TOPIC_TITLE = 2; private final int VIEW_TYPE_TOPIC_TITLE = 2;

18
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.Download;
import gr.thmmy.mthmmy.model.ThmmyPage; import gr.thmmy.mthmmy.model.ThmmyPage;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
import mthmmy.utils.Report;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import timber.log.Timber;
public class DownloadsActivity extends BaseActivity implements DownloadsAdapter.OnLoadMoreListener { 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. * 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, "")) { if (downloadsUrl != null && !Objects.equals(downloadsUrl, "")) {
ThmmyPage.PageCategory target = ThmmyPage.resolvePageCategory(Uri.parse(downloadsUrl)); ThmmyPage.PageCategory target = ThmmyPage.resolvePageCategory(Uri.parse(downloadsUrl));
if (!target.is(ThmmyPage.PageCategory.DOWNLOADS)) { 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(); Toast.makeText(this, "An error has occurred\nAborting.", Toast.LENGTH_SHORT).show();
finish(); finish();
} }
@ -173,10 +169,6 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter.
* as String parameter!</p> * as String parameter!</p>
*/ */
class ParseDownloadPageTask extends AsyncTask<String, Void, Void> { class ParseDownloadPageTask extends AsyncTask<String, Void, Void> {
/**
* Debug Tag for logging debug output to LogCat
*/
private static final String TAG = "ParseDownloadPageTask"; //Separate tag for AsyncTask
private String thisPageUrl; private String thisPageUrl;
@Override @Override
@ -195,9 +187,9 @@ public class DownloadsActivity extends BaseActivity implements DownloadsAdapter.
Response response = client.newCall(request).execute(); Response response = client.newCall(request).execute();
parseDownloads(Jsoup.parse(response.body().string())); parseDownloads(Jsoup.parse(response.body().string()));
} catch (SSLHandshakeException e) { } 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) { } catch (Exception e) {
Report.e("TAG", "ERROR", e); Timber.e("ERROR", e);
} }
return null; return null;
} }

5
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; import static gr.thmmy.mthmmy.activities.downloads.DownloadsActivity.BUNDLE_DOWNLOADS_URL;
class DownloadsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { class DownloadsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
/**
* 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_DOWNLOAD = 0;
private final int VIEW_TYPE_LOADING = 1; private final int VIEW_TYPE_LOADING = 1;

1
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 { public class MainActivity extends BaseActivity implements RecentFragment.RecentFragmentInteractionListener, ForumFragment.ForumFragmentInteractionListener {
//----------------------------------------CLASS VARIABLES----------------------------------------- //----------------------------------------CLASS VARIABLES-----------------------------------------
private static final String TAG = "MainActivity";
private static final int TIME_INTERVAL = 2000; private static final int TIME_INTERVAL = 2000;
private long mBackPressed; private long mBackPressed;

14
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.model.Category;
import gr.thmmy.mthmmy.session.SessionManager; import gr.thmmy.mthmmy.session.SessionManager;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
import mthmmy.utils.Report;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import timber.log.Timber;
/** /**
* A {@link BaseFragment} subclass. * A {@link BaseFragment} subclass.
@ -87,7 +88,7 @@ public class ForumFragment extends BaseFragment
forumTask.execute(); forumTask.execute();
} }
Report.d(TAG, "onActivityCreated"); Timber.d("onActivityCreated");
} }
@Override @Override
@ -151,8 +152,7 @@ public class ForumFragment extends BaseFragment
//---------------------------------------ASYNC TASK----------------------------------- //---------------------------------------ASYNC TASK-----------------------------------
public class ForumTask extends AsyncTask<Void, Void, Integer> { private class ForumTask extends AsyncTask<Void, Void, Integer> {
private static final String TAG = "ForumTask";
private HttpUrl forumUrl = SessionManager.forumUrl; //may change upon collapse/expand private HttpUrl forumUrl = SessionManager.forumUrl; //may change upon collapse/expand
private Document document; private Document document;
@ -179,10 +179,10 @@ public class ForumFragment extends BaseFragment
fetchedCategories.clear(); fetchedCategories.clear();
return 0; return 0;
} catch (IOException e) { } catch (IOException e) {
Report.d(TAG, "Network Error", e); Timber.d("Network Error", e);
return 1; return 1;
} catch (Exception e) { } catch (Exception e) {
Report.d(TAG, "Exception", e); Timber.d("Exception", e);
return 2; return 2;
} }
@ -225,7 +225,7 @@ public class ForumFragment extends BaseFragment
} }
} }
else else
Report.e(TAG, "Parsing failed!"); Timber.e("Parsing failed!");
} }
public void setUrl(String string) public void setUrl(String string)

14
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.CustomRecyclerView;
import gr.thmmy.mthmmy.utils.exceptions.ParseException; import gr.thmmy.mthmmy.utils.exceptions.ParseException;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
import mthmmy.utils.Report;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import timber.log.Timber;
/** /**
* A {@link BaseFragment} subclass. * A {@link BaseFragment} subclass.
@ -86,7 +87,7 @@ public class RecentFragment extends BaseFragment {
recentTask.execute(); recentTask.execute();
} }
Report.d(TAG, "onActivityCreated"); Timber.d("onActivityCreated");
} }
@ -141,8 +142,7 @@ public class RecentFragment extends BaseFragment {
//---------------------------------------ASYNC TASK----------------------------------- //---------------------------------------ASYNC TASK-----------------------------------
public class RecentTask extends AsyncTask<Void, Void, Integer> { private class RecentTask extends AsyncTask<Void, Void, Integer> {
private static final String TAG = "RecentTask";
private final HttpUrl thmmyUrl = SessionManager.indexUrl; private final HttpUrl thmmyUrl = SessionManager.indexUrl;
private Document document; private Document document;
@ -161,13 +161,13 @@ public class RecentFragment extends BaseFragment {
parse(document); parse(document);
return 0; return 0;
} catch (ParseException e) { } catch (ParseException e) {
Report.e(TAG, "ParseException", e); Timber.e("ParseException", e);
return 1; return 1;
} catch (IOException e) { } catch (IOException e) {
Report.i(TAG, "Network Error", e); Timber.i("Network Error", e);
return 2; return 2;
} catch (Exception e) { } catch (Exception e) {
Report.e(TAG, "Exception", e); Timber.e("Exception", e);
return 3; return 3;
} }

29
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.Spanned;
import android.text.style.ForegroundColorSpan; import android.text.style.ForegroundColorSpan;
import android.text.style.RelativeSizeSpan; import android.text.style.RelativeSizeSpan;
import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.ProgressBar; 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.CenterVerticalSpan;
import gr.thmmy.mthmmy.utils.CircleTransform; import gr.thmmy.mthmmy.utils.CircleTransform;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
import mthmmy.utils.Report;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; 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_TITLE;
import static gr.thmmy.mthmmy.activities.topic.TopicActivity.BUNDLE_TOPIC_URL; 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}. * the username using the key {@link #BUNDLE_PROFILE_USERNAME}.
*/ */
public class ProfileActivity extends BaseActivity implements LatestPostsFragment.LatestPostsFragmentInteractionListener { 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. * 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)); ThmmyPage.PageCategory target = ThmmyPage.resolvePageCategory(Uri.parse(profileUrl));
if (!target.is(ThmmyPage.PageCategory.PROFILE)) { 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(); Toast.makeText(this, "An error has occurred\n Aborting.", Toast.LENGTH_SHORT).show();
finish(); finish();
} }
@ -222,11 +218,6 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
*/ */
public class ProfileTask extends AsyncTask<String, Void, Boolean> { public class ProfileTask extends AsyncTask<String, Void, Boolean> {
//Class variables //Class variables
/**
* Debug Tag for logging debug output to LogCat
*/
@SuppressWarnings("unused")
private static final String TAG = "ProfileTask"; //Separate tag for AsyncTask
Document profilePage; Document profilePage;
Spannable usernameSpan; Spannable usernameSpan;
@ -262,7 +253,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
} else { } else {
//Should never get here! //Should never get here!
//Something is wrong. //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; personalText = null;
} }
} }
@ -283,16 +274,16 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
} }
return true; return true;
} catch (SSLHandshakeException e) { } 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) { } catch (Exception e) {
Report.e("TAG", "ERROR", e); Timber.e("ERROR", e);
} }
return false; return false;
} }
protected void onPostExecute(Boolean result) { protected void onPostExecute(Boolean result) {
if (!result) { //Parse failed! if (!result) { //Parse failed! //TODO report as ParseException?
Report.d(TAG, "Parse failed!"); Timber.d("Parse failed!");
Toast.makeText(getBaseContext(), "Fatal error!\n Aborting..." Toast.makeText(getBaseContext(), "Fatal error!\n Aborting..."
, Toast.LENGTH_LONG).show(); , Toast.LENGTH_LONG).show();
finish(); finish();
@ -344,7 +335,7 @@ public class ProfileActivity extends BaseActivity implements LatestPostsFragment
viewPager.setAdapter(adapter); viewPager.setAdapter(adapter);
} }
class ViewPagerAdapter extends FragmentPagerAdapter { private class ViewPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>(); private final List<Fragment> mFragmentList = new ArrayList<>();
private final List<String> mFragmentTitleList = new ArrayList<>(); private final List<String> mFragmentTitleList = new ArrayList<>();

5
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}. * specified {@link LatestPostsFragment.LatestPostsFragmentInteractionListener}.
*/ */
class LatestPostsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { class LatestPostsAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
/**
* 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_ITEM = 0;
private final int VIEW_TYPE_LOADING = 1; private final int VIEW_TYPE_LOADING = 1;
final private LatestPostsFragment.LatestPostsFragmentInteractionListener interactionListener; final private LatestPostsFragment.LatestPostsFragmentInteractionListener interactionListener;

25
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.model.PostSummary;
import gr.thmmy.mthmmy.utils.ParseHelpers; import gr.thmmy.mthmmy.utils.ParseHelpers;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
import mthmmy.utils.Report;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
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{
/**
* 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. * 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"); profileLatestPostsTask.execute(profileUrl + ";sa=showPosts");
pagesLoaded = 1; pagesLoaded = 1;
} }
Report.d(TAG, "onActivityCreated"); Timber.d("onActivityCreated");
} }
@Override @Override
@ -156,14 +152,7 @@ public class LatestPostsFragment extends BaseFragment implements LatestPostsAdap
* <p>LatestPostsTask's {@link AsyncTask#execute execute} method needs a profile's url as String * <p>LatestPostsTask's {@link AsyncTask#execute execute} method needs a profile's url as String
* parameter!</p> * parameter!</p>
*/ */
public class LatestPostsTask extends AsyncTask<String, Void, Boolean> { private class LatestPostsTask extends AsyncTask<String, Void, Boolean> {
//Class variables
/**
* Debug Tag for logging debug output to LogCat
*/
@SuppressWarnings("unused")
private static final String TAG = "LatestPostsTask"; //Separate tag for AsyncTask
protected void onPreExecute() { protected void onPreExecute() {
if (!isLoadingMore) progressBar.setVisibility(ProgressBar.VISIBLE); if (!isLoadingMore) progressBar.setVisibility(ProgressBar.VISIBLE);
} }
@ -176,16 +165,16 @@ public class LatestPostsFragment extends BaseFragment implements LatestPostsAdap
Response response = BaseActivity.getClient().newCall(request).execute(); Response response = BaseActivity.getClient().newCall(request).execute();
return parseLatestPosts(Jsoup.parse(response.body().string())); return parseLatestPosts(Jsoup.parse(response.body().string()));
} catch (SSLHandshakeException e) { } 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) { } catch (Exception e) {
Report.e("TAG", "ERROR", e); Timber.e("ERROR", e);
} }
return false; return false;
} }
protected void onPostExecute(Boolean result) { protected void onPostExecute(Boolean result) {
if (!result) { //Parse failed! if (!result) { //Parse failed!
Report.d(TAG, "Parse failed!"); Timber.d("Parse failed!");
Toast.makeText(getContext() Toast.makeText(getContext()
, "Fatal error!\n Aborting...", Toast.LENGTH_LONG).show(); , "Fatal error!\n Aborting...", Toast.LENGTH_LONG).show();
getActivity().finish(); getActivity().finish();

27
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.R;
import gr.thmmy.mthmmy.base.BaseActivity; import gr.thmmy.mthmmy.base.BaseActivity;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
import mthmmy.utils.Report;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import timber.log.Timber;
public class StatsFragment extends Fragment { 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. * 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 = new ProfileStatsTask();
profileStatsTask.execute(profileUrl + ";sa=statPanel"); profileStatsTask.execute(profileUrl + ";sa=statPanel");
} }
Report.d(TAG, "onActivityCreated"); Timber.d("onActivityCreated");
} }
@Override @Override
@ -127,14 +123,7 @@ public class StatsFragment extends Fragment {
* <p>Calling SummaryTask's {@link AsyncTask#execute execute} method needs to have profile's url * <p>Calling SummaryTask's {@link AsyncTask#execute execute} method needs to have profile's url
* as String parameter!</p> * as String parameter!</p>
*/ */
public class ProfileStatsTask extends AsyncTask<String, Void, Boolean> { private class ProfileStatsTask extends AsyncTask<String, Void, Boolean> {
//Class variables
/**
* Debug Tag for logging debug output to LogCat
*/
@SuppressWarnings("unused")
private static final String TAG = "ProfileStatsTask"; //Separate tag for AsyncTask
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {
progressBar.setVisibility(ProgressBar.VISIBLE); progressBar.setVisibility(ProgressBar.VISIBLE);
@ -150,9 +139,9 @@ public class StatsFragment extends Fragment {
Response response = BaseActivity.getClient().newCall(request).execute(); Response response = BaseActivity.getClient().newCall(request).execute();
return parseStats(Jsoup.parse(response.body().string())); return parseStats(Jsoup.parse(response.body().string()));
} catch (SSLHandshakeException e) { } 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) { } catch (Exception e) {
Report.e("TAG", "ERROR", e); Timber.e("ERROR", e);
} }
return false; return false;
} }
@ -160,7 +149,7 @@ public class StatsFragment extends Fragment {
@Override @Override
protected void onPostExecute(Boolean result) { protected void onPostExecute(Boolean result) {
if (!result) { //Parse failed! if (!result) { //Parse failed!
Report.d(TAG, "Parse failed!"); Timber.d("Parse failed!");
Toast.makeText(getContext() Toast.makeText(getContext()
, "Fatal error!\n Aborting...", Toast.LENGTH_LONG).show(); , "Fatal error!\n Aborting...", Toast.LENGTH_LONG).show();
getActivity().finish(); getActivity().finish();
@ -348,7 +337,7 @@ public class StatsFragment extends Fragment {
mostPopularBoardsByActivityChart.invalidate(); mostPopularBoardsByActivityChart.invalidate();
} }
class MyXAxisValueFormatter implements IAxisValueFormatter { private class MyXAxisValueFormatter implements IAxisValueFormatter {
private final ArrayList<String> mValues; private final ArrayList<String> mValues;
MyXAxisValueFormatter(ArrayList<String> values) { MyXAxisValueFormatter(ArrayList<String> values) {

25
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.support.v4.app.Fragment;
import android.text.Html; import android.text.Html;
import android.text.method.LinkMovementMethod; import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -25,18 +25,14 @@ import java.util.Objects;
import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.R;
import gr.thmmy.mthmmy.utils.ParseHelpers; 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. * Use the {@link SummaryFragment#newInstance} factory method to create an instance of this fragment.
*/ */
public class SummaryFragment extends 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. * 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 = new SummaryTask();
summaryTask.execute(profileSummaryDocument); summaryTask.execute(profileSummaryDocument);
} }
Report.d(TAG, "onActivityCreated"); Timber.d("onActivityCreated");
} }
@Override @Override
@ -114,14 +110,7 @@ public class SummaryFragment extends Fragment {
* <p>Calling SummaryTask's {@link AsyncTask#execute execute} method needs to have profile's url * <p>Calling SummaryTask's {@link AsyncTask#execute execute} method needs to have profile's url
* as String parameter!</p> * as String parameter!</p>
*/ */
public class SummaryTask extends AsyncTask<Document, Void, Void> { private class SummaryTask extends AsyncTask<Document, Void, Void> {
//Class variables
/**
* Debug Tag for logging debug output to LogCat
*/
@SuppressWarnings("unused")
private static final String TAG = "SummaryTask"; //Separate tag for AsyncTask
protected Void doInBackground(Document... profileSummaryPage) { protected Void doInBackground(Document... profileSummaryPage) {
parsedProfileSummaryData = parseProfileSummary(profileSummaryPage[0]); parsedProfileSummaryData = parseProfileSummary(profileSummaryPage[0]);
return null; return null;
@ -193,8 +182,8 @@ public class SummaryFragment extends Fragment {
if (profileSummaryRow.contains("@") && if (profileSummaryRow.contains("@") &&
(profileSummaryRow.contains("Email") || profileSummaryRow.contains("E-mail"))) { (profileSummaryRow.contains("Email") || profileSummaryRow.contains("E-mail"))) {
Log.d(TAG, "mpika"); Timber.d("mpika");
Log.d(TAG, profileSummaryRow); Timber.d(profileSummaryRow);
String email = profileSummaryRow.substring(profileSummaryRow.indexOf(":</b> ") + 6); String email = profileSummaryRow.substring(profileSummaryRow.indexOf(":</b> ") + 6);
profileSummaryRow = profileSummaryRow.replace(email, profileSummaryRow = profileSummaryRow.replace(email,
"<a href=\"mailto:" + email + "\">" + email + "</a>"); "<a href=\"mailto:" + email + "\">" + email + "</a>");

6
app/src/main/java/gr/thmmy/mthmmy/activities/topic/ReplyParser.java

@ -10,12 +10,6 @@ import java.io.IOException;
import okhttp3.Response; import okhttp3.Response;
class ReplyParser { class ReplyParser {
/**
* Debug Tag for logging debug output to LogCat
*/
@SuppressWarnings("unused")
private static final String TAG = "ReplyParser";
enum REPLY_STATUS { enum REPLY_STATUS {
SUCCESSFUL, NO_SUBJECT, EMPTY_BODY, NEW_REPLY_WHILE_POSTING, NOT_FOUND, SESSION_ENDED, OTHER_ERROR SUCCESSFUL, NO_SUBJECT, EMPTY_BODY, NEW_REPLY_WHILE_POSTING, NOT_FOUND, SESSION_ENDED, OTHER_ERROR
} }

31
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.model.ThmmyPage;
import gr.thmmy.mthmmy.utils.ParseHelpers; import gr.thmmy.mthmmy.utils.ParseHelpers;
import me.zhanghai.android.materialprogressbar.MaterialProgressBar; import me.zhanghai.android.materialprogressbar.MaterialProgressBar;
import mthmmy.utils.Report;
import okhttp3.MultipartBody; import okhttp3.MultipartBody;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
import timber.log.Timber;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE; 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") @SuppressWarnings("unchecked")
public class TopicActivity extends BaseActivity { public class TopicActivity extends BaseActivity {
//Class variables //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. * 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( ThmmyPage.PageCategory target = ThmmyPage.resolvePageCategory(
Uri.parse(topicPageUrl)); Uri.parse(topicPageUrl));
if (!target.is(ThmmyPage.PageCategory.TOPIC)) { 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(); Toast.makeText(this, "An error has occurred\n Aborting.", Toast.LENGTH_SHORT).show();
finish(); finish();
} }
@ -455,11 +451,6 @@ public class TopicActivity extends BaseActivity {
* as String parameter!</p> * as String parameter!</p>
*/ */
class TopicTask extends AsyncTask<String, Void, Integer> { class TopicTask extends AsyncTask<String, Void, Integer> {
//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 SUCCESS = 0;
private static final int NETWORK_ERROR = 1; private static final int NETWORK_ERROR = 1;
private static final int OTHER_ERROR = 2; private static final int OTHER_ERROR = 2;
@ -518,10 +509,10 @@ public class TopicActivity extends BaseActivity {
parse(document); parse(document);
return SUCCESS; return SUCCESS;
} catch (IOException e) { } catch (IOException e) {
Report.i(TAG, "IO Exception", e); Timber.i("IO Exception", e);
return NETWORK_ERROR; return NETWORK_ERROR;
} catch (Exception e) { } catch (Exception e) {
Report.e(TAG, "Exception", e); Timber.e("Exception", e);
return OTHER_ERROR; return OTHER_ERROR;
} }
} }
@ -570,7 +561,7 @@ public class TopicActivity extends BaseActivity {
break; break;
default: default:
//Parse failed - should never happen //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(); Toast.makeText(getBaseContext(), "Fatal Error", Toast.LENGTH_SHORT).show();
finish(); finish();
break; break;
@ -609,7 +600,7 @@ public class TopicActivity extends BaseActivity {
} else { } else {
parsedTitle = parsedTitle.substring(parsedTitle.indexOf("Θέμα:") + 6 parsedTitle = parsedTitle.substring(parsedTitle.indexOf("Θέμα:") + 6
, parsedTitle.indexOf("(Αναγνώστηκε") - 2); , 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"); subject = document.select("input[name=subject]").first().attr("value");
topic = document.select("input[name=topic]").first().attr("value"); topic = document.select("input[name=topic]").first().attr("value");
} catch (IOException e) { } catch (IOException e) {
Report.e(TAG, "Post failed.", e); Timber.e("Post failed.", e);
return false; return false;
} catch (Selector.SelectorParseException e) { } catch (Selector.SelectorParseException e) {
Report.e(TAG, "Post failed.", e); Timber.e("Post failed.", e);
return false; return false;
} }
@ -733,11 +724,11 @@ public class TopicActivity extends BaseActivity {
//TODO this... //TODO this...
return true; return true;
default: default:
Report.e(TAG, "Malformed post. Request string:\n" + post.toString()); Timber.e("Malformed post. Request string:\n" + post.toString());
return true; return true;
} }
} catch (IOException e) { } catch (IOException e) {
Report.e(TAG, "Post failed.", e); Timber.e("Post failed.", e);
return false; return false;
} }
} }

11
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.Editable;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; 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.ThmmyFile;
import gr.thmmy.mthmmy.model.ThmmyPage; import gr.thmmy.mthmmy.model.ThmmyPage;
import gr.thmmy.mthmmy.utils.CircleTransform; 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 android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
import static gr.thmmy.mthmmy.activities.board.BoardActivity.BUNDLE_BOARD_TITLE; 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. * Custom {@link android.support.v7.widget.RecyclerView.Adapter} used for topics.
*/ */
class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
/**
* Debug Tag for logging debug output to LogCat
*/
private static final String TAG = "TopicAdapter";
/** /**
* Int that holds thumbnail's size defined in R.dimen * Int that holds thumbnail's size defined in R.dimen
*/ */
@ -415,7 +412,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
if (toQuoteList.contains(postsList.indexOf(currentPost))) { if (toQuoteList.contains(postsList.indexOf(currentPost))) {
toQuoteList.remove(toQuoteList.indexOf(postsList.indexOf(currentPost))); toQuoteList.remove(toQuoteList.indexOf(postsList.indexOf(currentPost)));
} else } 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!"); "toQuoteList, post wasn't there!");
holder.quoteToggle.setImageResource(R.drawable.ic_format_quote_unchecked); holder.quoteToggle.setImageResource(R.drawable.ic_format_quote_unchecked);
} else { } else {

13
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.Post;
import gr.thmmy.mthmmy.model.ThmmyFile; import gr.thmmy.mthmmy.model.ThmmyFile;
import gr.thmmy.mthmmy.utils.ParseHelpers; import gr.thmmy.mthmmy.utils.ParseHelpers;
import mthmmy.utils.Report; import timber.log.Timber;
/** /**
* Singleton used for parsing a topic. * Singleton used for parsing a topic.
@ -36,12 +37,6 @@ class TopicParser {
static final int USER_COLOR_PINK = Color.parseColor("#FF4081"); static final int USER_COLOR_PINK = Color.parseColor("#FF4081");
private static final int USER_COLOR_YELLOW = Color.parseColor("#FFEB3B"); 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. * Returns users currently viewing this topic.
* *
@ -257,7 +252,7 @@ class TopicParser {
try { try {
attachedUrl = new URL(tmpAttachedFileUrlAndName.attr("href")); attachedUrl = new URL(tmpAttachedFileUrlAndName.attr("href"));
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
Report.e(TAG, "Attached file malformed url", e); Timber.e("Attached file malformed url", e);
break; break;
} }
String attachedFileName = tmpAttachedFileUrlAndName.text().substring(1); String attachedFileName = tmpAttachedFileUrlAndName.text().substring(1);
@ -317,7 +312,7 @@ class TopicParser {
try { try {
attachedUrl = new URL(tmpAttachedFileUrlAndName.attr("href")); attachedUrl = new URL(tmpAttachedFileUrlAndName.attr("href"));
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
Report.e(TAG, "Attached file malformed url", e); Timber.e("Attached file malformed url", e);
break; break;
} }
String attachedFileName = tmpAttachedFileUrlAndName.text().substring(1); String attachedFileName = tmpAttachedFileUrlAndName.text().substring(1);

9
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.Objects;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import gr.thmmy.mthmmy.BuildConfig;
import gr.thmmy.mthmmy.R; import gr.thmmy.mthmmy.R;
import gr.thmmy.mthmmy.session.SessionManager; import gr.thmmy.mthmmy.session.SessionManager;
import gr.thmmy.mthmmy.utils.CrashReportingTree;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;
import okhttp3.Interceptor; import okhttp3.Interceptor;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import timber.log.Timber;
public class BaseApplication extends Application { public class BaseApplication extends Application {
@ -55,6 +58,12 @@ public class BaseApplication extends Application {
super.onCreate(); super.onCreate();
baseApplication = this; //init singleton 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); SharedPreferences sharedPrefs = getSharedPreferences(SHARED_PREFS_NAME, MODE_PRIVATE);
SharedPrefsCookiePersistor sharedPrefsCookiePersistor = new SharedPrefsCookiePersistor(getApplicationContext()); SharedPrefsCookiePersistor sharedPrefsCookiePersistor = new SharedPrefsCookiePersistor(getApplicationContext());
PersistentCookieJar cookieJar = new PersistentCookieJar(new SetCookieCache(), sharedPrefsCookiePersistor); PersistentCookieJar cookieJar = new PersistentCookieJar(new SetCookieCache(), sharedPrefsCookiePersistor);

12
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.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import mthmmy.utils.Report;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import timber.log.Timber;
public abstract class BaseFragment extends Fragment { public abstract class BaseFragment extends Fragment {
protected static final String ARG_SECTION_NUMBER = "SectionNumber"; protected static final String ARG_SECTION_NUMBER = "SectionNumber";
@ -26,31 +26,31 @@ public abstract class BaseFragment extends Fragment {
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
Report.d(TAG, "onCreate"); Timber.d("onCreate");
} }
@Override @Override
public void onStart() { public void onStart() {
super.onStart(); super.onStart();
Report.d(TAG, "onStart"); Timber.d("onStart");
} }
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
Report.d(TAG, "onResume"); Timber.d("onResume");
} }
@Override @Override
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
Report.d(TAG, "onPause"); Timber.d("onPause");
} }
@Override @Override
public void onStop() { public void onStop() {
super.onStop(); super.onStop();
Report.d(TAG, "onStop"); Timber.d("onStop");
} }
@Override @Override

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

@ -4,7 +4,7 @@ import android.net.Uri;
import java.util.Objects; 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 * 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")
|| 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;
Report.v(TAG, "Unknown thmmy link found, link: " + uriString); Timber.v("Unknown thmmy link found, link: " + uriString);
return PageCategory.UNKNOWN_THMMY; return PageCategory.UNKNOWN_THMMY;
} }
return PageCategory.NOT_THMMY; return PageCategory.NOT_THMMY;

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

@ -14,7 +14,8 @@ import android.webkit.MimeTypeMap;
import java.io.File; import java.io.File;
import gr.thmmy.mthmmy.R; 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.ACTION_DOWNLOAD;
import static gr.thmmy.mthmmy.services.DownloadService.COMPLETED; 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; import static gr.thmmy.mthmmy.services.DownloadService.STARTED;
public class Receiver extends BroadcastReceiver { public class Receiver extends BroadcastReceiver {
private static final String TAG = "BroadcastReceiver";
public Receiver() { public Receiver() {
} }
@ -72,7 +72,7 @@ public class Receiver extends BroadcastReceiver {
builder.setContentIntent(pendingIntent); builder.setContentIntent(pendingIntent);
} else } else
Report.w(TAG, "File doesn't exist."); Timber.w("File doesn't exist.");
} }
Notification notification = builder.build(); Notification notification = builder.build();
notificationManager.notify(id, notification); notificationManager.notify(id, notification);

25
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.base.BaseApplication;
import gr.thmmy.mthmmy.receiver.Receiver; import gr.thmmy.mthmmy.receiver.Receiver;
import mthmmy.utils.Report;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import okio.BufferedSink; import okio.BufferedSink;
import okio.Okio; import okio.Okio;
import timber.log.Timber;
/** /**
* An {@link IntentService} subclass for handling asynchronous task requests in * An {@link IntentService} subclass for handling asynchronous task requests in
@ -116,9 +117,9 @@ public class DownloadService extends IntentService {
if(!dirPath.isDirectory()) if(!dirPath.isDirectory())
{ {
if(dirPath.mkdirs()) if(dirPath.mkdirs())
Report.i(TAG, "mTHMMY's directory created successfully!"); Timber.i("mTHMMY's directory created successfully!");
else 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) if(tokens.length!=2)
{ {
Report.w(TAG, "Couldn't get file extension..."); Timber.w("Couldn't get file extension...");
nameFormat = fileName + "(%d)"; nameFormat = fileName + "(%d)";
} }
else else
@ -148,26 +149,26 @@ public class DownloadService extends IntentService {
fileName = file.getName(); fileName = file.getName();
Report.v(TAG, "Started saving file " + fileName); Timber.v("Started saving file " + fileName);
sendNotification(downloadId, STARTED, fileName); sendNotification(downloadId, STARTED, fileName);
sink = Okio.buffer(Okio.sink(file)); sink = Okio.buffer(Okio.sink(file));
sink.writeAll(response.body().source()); sink.writeAll(response.body().source());
sink.flush(); sink.flush();
Report.i(TAG, "Download OK!"); Timber.i("Download OK!");
sendNotification(downloadId, COMPLETED, fileName); sendNotification(downloadId, COMPLETED, fileName);
} }
else else
Report.e(TAG, "Response not a binary file!"); Timber.e("Response not a binary file!");
} }
catch (FileNotFoundException e){ catch (FileNotFoundException e){
Report.i(TAG, "Download failed..."); Timber.i("Download failed...");
Report.e(TAG, "FileNotFound", e); Timber.e("FileNotFound", e);
sendNotification(downloadId, FAILED, fileName); sendNotification(downloadId, FAILED, fileName);
} }
catch (IOException e){ catch (IOException e){
Report.i(TAG, "Download failed..."); Timber.i("Download failed...");
Report.e(TAG, "IOException", e); Timber.e("IOException", e);
sendNotification(downloadId, FAILED, fileName); sendNotification(downloadId, FAILED, fileName);
} finally { } finally {
if (sink!= null) { if (sink!= null) {
@ -203,7 +204,7 @@ public class DownloadService extends IntentService {
break; break;
} }
default:{ default:{
Report.wtf(TAG, "Invalid notification case!"); Timber.e("Invalid notification case!");
return; return;
} }
} }

43
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 java.util.regex.Pattern;
import gr.thmmy.mthmmy.utils.exceptions.ParseException; import gr.thmmy.mthmmy.utils.exceptions.ParseException;
import mthmmy.utils.Report;
import okhttp3.Cookie; import okhttp3.Cookie;
import okhttp3.FormBody; import okhttp3.FormBody;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;
@ -26,15 +25,13 @@ import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
import timber.log.Timber;
/** /**
* This class handles all session related operations (e.g. login, logout) * This class handles all session related operations (e.g. login, logout)
* and stores data to SharedPreferences (session information and cookies). * and stores data to SharedPreferences (session information and cookies).
*/ */
public class SessionManager { public class SessionManager {
//Class TAG
private static final String TAG = "SessionManager";
//Generic constants //Generic constants
public static final HttpUrl indexUrl = HttpUrl.parse("https://www.thmmy.gr/smf/index.php?theme=4"); 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"); 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. * Always call it in a separate thread.
*/ */
public int login(String... strings) { public int login(String... strings) {
Report.i(TAG, "Logging in..."); Timber.i("Logging in...");
//Build the login request for each case //Build the login request for each case
Request request; 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 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 setPersistentCookieSession(); //Store cookies
//Edit SharedPreferences, save session's data //Edit SharedPreferences, save session's data
@ -133,18 +130,18 @@ public class SessionManager {
return SUCCESS; return SUCCESS;
} else { } else {
Report.i(TAG, "Login failed."); Timber.i("Login failed.");
//Investigate login failure //Investigate login failure
Elements error = document.select("b:contains(That username does not exist.)"); Elements error = document.select("b:contains(That username does not exist.)");
if (error.size() == 1) { //Wrong username if (error.size() == 1) { //Wrong username
Report.i(TAG, "Wrong Username"); Timber.i("Wrong Username");
return WRONG_USER; return WRONG_USER;
} }
error = document.select("body:contains(Password incorrect)"); error = document.select("body:contains(Password incorrect)");
if (error.size() == 1) { //Wrong password if (error.size() == 1) { //Wrong password
Report.i(TAG, "Wrong Password"); Timber.i("Wrong Password");
return WRONG_PASSWORD; return WRONG_PASSWORD;
} }
@ -154,13 +151,13 @@ public class SessionManager {
} }
//Handle exception //Handle exception
} catch (InterruptedIOException e) { } catch (InterruptedIOException e) {
Report.i(TAG, "Login InterruptedIOException"); //users cancels LoginTask Timber.i("Login InterruptedIOException"); //users cancels LoginTask
return CANCELLED; return CANCELLED;
} catch (IOException e) { } catch (IOException e) {
Report.w(TAG, "Login IOException", e); Timber.w("Login IOException", e);
return CONNECTION_ERROR; return CONNECTION_ERROR;
} catch (Exception e) { } catch (Exception e) {
Report.w(TAG, "Login Exception (other)", e); Timber.w("Login Exception (other)", e);
return EXCEPTION; return EXCEPTION;
} }
} }
@ -175,7 +172,7 @@ public class SessionManager {
* fragments' data are retrieved). * fragments' data are retrieved).
*/ */
public void validateSession() { public void validateSession() {
Report.i(TAG, "Validating session..."); Timber.i("Validating session...");
if (isLoggedIn()) { if (isLoggedIn()) {
int loginResult = login(); int loginResult = login();
@ -192,7 +189,7 @@ public class SessionManager {
* Call this function when user explicitly chooses to continue as a guest (UI thread). * Call this function when user explicitly chooses to continue as a guest (UI thread).
*/ */
public void guestLogin() { 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(); clearSessionData();
sharedPrefs.edit().putBoolean(LOGIN_SCREEN_AS_DEFAULT, false).apply(); 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. * Logout function. Always call it in a separate thread.
*/ */
public int logout() { public int logout() {
Report.i(TAG, "Logging out..."); Timber.i("Logging out...");
Request request = new Request.Builder() Request request = new Request.Builder()
.url(sharedPrefs.getString(LOGOUT_LINK, "LogoutLink")) .url(sharedPrefs.getString(LOGOUT_LINK, "LogoutLink"))
@ -216,17 +213,17 @@ public class SessionManager {
Elements loginButton = document.select("[value=Login]"); //Attempt to find login button Elements loginButton = document.select("[value=Login]"); //Attempt to find login button
if (!loginButton.isEmpty()) //If login button exists, logout was successful if (!loginButton.isEmpty()) //If login button exists, logout was successful
{ {
Report.i(TAG, "Logout successful!"); Timber.i("Logout successful!");
return SUCCESS; return SUCCESS;
} else { } else {
Report.i(TAG, "Logout failed."); Timber.i("Logout failed.");
return FAILURE; return FAILURE;
} }
} catch (IOException e) { } catch (IOException e) {
Report.w(TAG, "Logout IOException", e); Timber.w("Logout IOException", e);
return CONNECTION_ERROR; return CONNECTION_ERROR;
} catch (Exception e) { } catch (Exception e) {
Report.w(TAG, "Logout Exception", e); Timber.w("Logout Exception", e);
return EXCEPTION; return EXCEPTION;
} finally { } finally {
//All data should always be cleared from device regardless the result of logout //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().clear().apply(); //Clear session data
sharedPrefs.edit().putString(USERNAME, guestName).apply(); sharedPrefs.edit().putString(USERNAME, guestName).apply();
sharedPrefs.edit().putBoolean(LOGGED_IN, false).apply(); //User logs out sharedPrefs.edit().putBoolean(LOGGED_IN, false).apply(); //User logs out
Report.i(TAG, "Session data cleared."); Timber.i("Session data cleared.");
} }
@NonNull @NonNull
@ -321,7 +318,7 @@ public class SessionManager {
if(userName != null && !userName.isEmpty()) if(userName != null && !userName.isEmpty())
return userName; 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 return "User"; //return a default username
} }
@ -332,7 +329,7 @@ public class SessionManager {
if (!avatar.isEmpty()) if (!avatar.isEmpty())
return avatar.first().attr("src"); return avatar.first().attr("src");
Report.i(TAG, "Extracting avatar's link failed!"); Timber.i("Extracting avatar's link failed!");
return null; return null;
} }
@ -346,7 +343,7 @@ public class SessionManager {
if(link != null && !link.isEmpty()) if(link != null && !link.isEmpty())
return link; 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 return "https://www.thmmy.gr/smf/index.php?action=logout"; //return a default link
} }
//----------------------------------OTHER FUNCTIONS END----------------------------------------- //----------------------------------OTHER FUNCTIONS END-----------------------------------------

34
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);
}
}

96
app/src/release/java/mthmmy.utils/Report.java

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

2
build.gradle

@ -6,7 +6,7 @@ buildscript {
maven { url "https://jitpack.io" } maven { url "https://jitpack.io" }
} }
dependencies { 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' classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files

4
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 distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists 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

Loading…
Cancel
Save