Added reading article log.
This commit is contained in:
parent
286dda7f80
commit
b39d510e07
@ -80,6 +80,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
|||||||
|
|
||||||
private var items: ArrayList<Item> = ArrayList()
|
private var items: ArrayList<Item> = ArrayList()
|
||||||
private var clickBehavior = false
|
private var clickBehavior = false
|
||||||
|
private var debugReadingItems = false
|
||||||
private var internalBrowser = false
|
private var internalBrowser = false
|
||||||
private var articleViewer = false
|
private var articleViewer = false
|
||||||
private var shouldBeCardView = false
|
private var shouldBeCardView = false
|
||||||
@ -277,6 +278,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
|||||||
|
|
||||||
|
|
||||||
private fun handleSharedPrefs() {
|
private fun handleSharedPrefs() {
|
||||||
|
debugReadingItems = sharedPref.getBoolean("read_debug", false)
|
||||||
clickBehavior = sharedPref.getBoolean("tab_on_tap", false)
|
clickBehavior = sharedPref.getBoolean("tab_on_tap", false)
|
||||||
internalBrowser = sharedPref.getBoolean("prefer_internal_browser", true)
|
internalBrowser = sharedPref.getBoolean("prefer_internal_browser", true)
|
||||||
articleViewer = sharedPref.getBoolean("prefer_article_viewer", true)
|
articleViewer = sharedPref.getBoolean("prefer_article_viewer", true)
|
||||||
@ -641,7 +643,8 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
|||||||
internalBrowser,
|
internalBrowser,
|
||||||
articleViewer,
|
articleViewer,
|
||||||
fullHeightCards,
|
fullHeightCards,
|
||||||
appColors)
|
appColors,
|
||||||
|
debugReadingItems)
|
||||||
} else {
|
} else {
|
||||||
mAdapter =
|
mAdapter =
|
||||||
ItemListAdapter(
|
ItemListAdapter(
|
||||||
@ -651,7 +654,8 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
|||||||
customTabActivityHelper,
|
customTabActivityHelper,
|
||||||
clickBehavior,
|
clickBehavior,
|
||||||
internalBrowser,
|
internalBrowser,
|
||||||
articleViewer)
|
articleViewer,
|
||||||
|
debugReadingItems)
|
||||||
}
|
}
|
||||||
recyclerView.adapter = mAdapter
|
recyclerView.adapter = mAdapter
|
||||||
mAdapter.notifyDataSetChanged()
|
mAdapter.notifyDataSetChanged()
|
||||||
|
@ -2,15 +2,12 @@ package apps.amine.bou.readerforselfoss.adapters
|
|||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Bitmap
|
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.support.constraint.ConstraintLayout
|
import android.support.constraint.ConstraintLayout
|
||||||
import android.support.design.widget.Snackbar
|
import android.support.design.widget.Snackbar
|
||||||
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory
|
|
||||||
import android.support.v7.widget.CardView
|
import android.support.v7.widget.CardView
|
||||||
import android.support.v7.widget.RecyclerView
|
import android.support.v7.widget.RecyclerView
|
||||||
import android.text.Html
|
import android.text.Html
|
||||||
import android.text.format.DateUtils
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.ImageButton
|
import android.widget.ImageButton
|
||||||
@ -22,15 +19,11 @@ import android.widget.Toast
|
|||||||
import com.amulyakhare.textdrawable.TextDrawable
|
import com.amulyakhare.textdrawable.TextDrawable
|
||||||
import com.amulyakhare.textdrawable.util.ColorGenerator
|
import com.amulyakhare.textdrawable.util.ColorGenerator
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.request.target.BitmapImageViewTarget
|
|
||||||
import com.like.LikeButton
|
import com.like.LikeButton
|
||||||
import com.like.OnLikeListener
|
import com.like.OnLikeListener
|
||||||
import retrofit2.Call
|
import retrofit2.Call
|
||||||
import retrofit2.Callback
|
import retrofit2.Callback
|
||||||
import retrofit2.Response
|
import retrofit2.Response
|
||||||
import java.text.ParseException
|
|
||||||
import java.text.SimpleDateFormat
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
import apps.amine.bou.readerforselfoss.R
|
import apps.amine.bou.readerforselfoss.R
|
||||||
import apps.amine.bou.readerforselfoss.api.selfoss.Item
|
import apps.amine.bou.readerforselfoss.api.selfoss.Item
|
||||||
@ -39,6 +32,8 @@ import apps.amine.bou.readerforselfoss.api.selfoss.SuccessResponse
|
|||||||
import apps.amine.bou.readerforselfoss.themes.AppColors
|
import apps.amine.bou.readerforselfoss.themes.AppColors
|
||||||
import apps.amine.bou.readerforselfoss.utils.*
|
import apps.amine.bou.readerforselfoss.utils.*
|
||||||
import apps.amine.bou.readerforselfoss.utils.customtabs.CustomTabActivityHelper
|
import apps.amine.bou.readerforselfoss.utils.customtabs.CustomTabActivityHelper
|
||||||
|
import com.crashlytics.android.Crashlytics
|
||||||
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
class ItemCardAdapter(private val app: Activity,
|
class ItemCardAdapter(private val app: Activity,
|
||||||
private val items: ArrayList<Item>,
|
private val items: ArrayList<Item>,
|
||||||
@ -47,7 +42,8 @@ class ItemCardAdapter(private val app: Activity,
|
|||||||
private val internalBrowser: Boolean,
|
private val internalBrowser: Boolean,
|
||||||
private val articleViewer: Boolean,
|
private val articleViewer: Boolean,
|
||||||
private val fullHeightCards: Boolean,
|
private val fullHeightCards: Boolean,
|
||||||
private val appColors: AppColors) : RecyclerView.Adapter<ItemCardAdapter.ViewHolder>() {
|
private val appColors: AppColors,
|
||||||
|
val debugReadingItems: Boolean) : RecyclerView.Adapter<ItemCardAdapter.ViewHolder>() {
|
||||||
private val c: Context = app.baseContext
|
private val c: Context = app.baseContext
|
||||||
private val generator: ColorGenerator = ColorGenerator.MATERIAL
|
private val generator: ColorGenerator = ColorGenerator.MATERIAL
|
||||||
|
|
||||||
@ -130,11 +126,21 @@ class ItemCardAdapter(private val app: Activity,
|
|||||||
|
|
||||||
api.markItem(i.id).enqueue(object : Callback<SuccessResponse> {
|
api.markItem(i.id).enqueue(object : Callback<SuccessResponse> {
|
||||||
override fun onResponse(call: Call<SuccessResponse>, response: Response<SuccessResponse>) {
|
override fun onResponse(call: Call<SuccessResponse>, response: Response<SuccessResponse>) {
|
||||||
|
if (debugReadingItems) {
|
||||||
|
val message =
|
||||||
|
"message: ${response.message()} body: ${response.body()} raw body string: ${response.raw()?.body()?.toString()}"
|
||||||
|
Crashlytics.log(100, "READ_DEBUG_SUCCESS", message)
|
||||||
|
Toast.makeText(c, message, Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
doUnmark(i, position)
|
doUnmark(i, position)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFailure(call: Call<SuccessResponse>, t: Throwable) {
|
override fun onFailure(call: Call<SuccessResponse>, t: Throwable) {
|
||||||
|
if (debugReadingItems) {
|
||||||
|
Crashlytics.log(100, "READ_DEBUG_ERROR", t.message)
|
||||||
|
Crashlytics.logException(t)
|
||||||
|
Toast.makeText(c, t.message, Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
Toast.makeText(app, app.getString(R.string.cant_mark_read), Toast.LENGTH_SHORT).show()
|
Toast.makeText(app, app.getString(R.string.cant_mark_read), Toast.LENGTH_SHORT).show()
|
||||||
items.add(i)
|
items.add(i)
|
||||||
notifyItemInserted(position)
|
notifyItemInserted(position)
|
||||||
|
@ -3,16 +3,11 @@ package apps.amine.bou.readerforselfoss.adapters
|
|||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
|
||||||
import android.graphics.Bitmap
|
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.net.Uri
|
|
||||||
import android.support.constraint.ConstraintLayout
|
import android.support.constraint.ConstraintLayout
|
||||||
import android.support.design.widget.Snackbar
|
import android.support.design.widget.Snackbar
|
||||||
import android.support.v4.graphics.drawable.RoundedBitmapDrawableFactory
|
|
||||||
import android.support.v7.widget.RecyclerView
|
import android.support.v7.widget.RecyclerView
|
||||||
import android.text.Html
|
import android.text.Html
|
||||||
import android.text.format.DateUtils
|
|
||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
@ -21,24 +16,21 @@ import android.widget.*
|
|||||||
|
|
||||||
import com.amulyakhare.textdrawable.TextDrawable
|
import com.amulyakhare.textdrawable.TextDrawable
|
||||||
import com.amulyakhare.textdrawable.util.ColorGenerator
|
import com.amulyakhare.textdrawable.util.ColorGenerator
|
||||||
import com.bumptech.glide.Glide
|
|
||||||
import com.bumptech.glide.request.target.BitmapImageViewTarget
|
|
||||||
import com.like.LikeButton
|
import com.like.LikeButton
|
||||||
import com.like.OnLikeListener
|
import com.like.OnLikeListener
|
||||||
import retrofit2.Call
|
import retrofit2.Call
|
||||||
import retrofit2.Callback
|
import retrofit2.Callback
|
||||||
import retrofit2.Response
|
import retrofit2.Response
|
||||||
import java.text.ParseException
|
|
||||||
import java.text.SimpleDateFormat
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
import apps.amine.bou.readerforselfoss.R
|
import apps.amine.bou.readerforselfoss.R
|
||||||
import apps.amine.bou.readerforselfoss.api.selfoss.Item
|
import apps.amine.bou.readerforselfoss.api.selfoss.Item
|
||||||
import apps.amine.bou.readerforselfoss.api.selfoss.SelfossApi
|
import apps.amine.bou.readerforselfoss.api.selfoss.SelfossApi
|
||||||
import apps.amine.bou.readerforselfoss.api.selfoss.SuccessResponse
|
import apps.amine.bou.readerforselfoss.api.selfoss.SuccessResponse
|
||||||
import apps.amine.bou.readerforselfoss.themes.AppColors
|
|
||||||
import apps.amine.bou.readerforselfoss.utils.*
|
import apps.amine.bou.readerforselfoss.utils.*
|
||||||
import apps.amine.bou.readerforselfoss.utils.customtabs.CustomTabActivityHelper
|
import apps.amine.bou.readerforselfoss.utils.customtabs.CustomTabActivityHelper
|
||||||
|
import com.crashlytics.android.Crashlytics
|
||||||
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
|
|
||||||
class ItemListAdapter(private val app: Activity,
|
class ItemListAdapter(private val app: Activity,
|
||||||
@ -47,7 +39,8 @@ class ItemListAdapter(private val app: Activity,
|
|||||||
private val helper: CustomTabActivityHelper,
|
private val helper: CustomTabActivityHelper,
|
||||||
private val clickBehavior: Boolean,
|
private val clickBehavior: Boolean,
|
||||||
private val internalBrowser: Boolean,
|
private val internalBrowser: Boolean,
|
||||||
private val articleViewer: Boolean) : RecyclerView.Adapter<ItemListAdapter.ViewHolder>() {
|
private val articleViewer: Boolean,
|
||||||
|
val debugReadingItems: Boolean) : RecyclerView.Adapter<ItemListAdapter.ViewHolder>() {
|
||||||
private val generator: ColorGenerator = ColorGenerator.MATERIAL
|
private val generator: ColorGenerator = ColorGenerator.MATERIAL
|
||||||
private val c: Context = app.baseContext
|
private val c: Context = app.baseContext
|
||||||
private val bars: ArrayList<Boolean> = ArrayList(Collections.nCopies(items.size + 1, false))
|
private val bars: ArrayList<Boolean> = ArrayList(Collections.nCopies(items.size + 1, false))
|
||||||
@ -142,11 +135,22 @@ class ItemListAdapter(private val app: Activity,
|
|||||||
|
|
||||||
api.markItem(i.id).enqueue(object : Callback<SuccessResponse> {
|
api.markItem(i.id).enqueue(object : Callback<SuccessResponse> {
|
||||||
override fun onResponse(call: Call<SuccessResponse>, response: Response<SuccessResponse>) {
|
override fun onResponse(call: Call<SuccessResponse>, response: Response<SuccessResponse>) {
|
||||||
|
if (debugReadingItems) {
|
||||||
|
val message =
|
||||||
|
"message: ${response.message()} body: ${response.body()} raw body string: ${response.raw()?.body()?.toString()}"
|
||||||
|
Crashlytics.log(100, "READ_DEBUG_SUCCESS", message)
|
||||||
|
Toast.makeText(c, message, Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
doUnmark(i, position)
|
doUnmark(i, position)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onFailure(call: Call<SuccessResponse>, t: Throwable) {
|
override fun onFailure(call: Call<SuccessResponse>, t: Throwable) {
|
||||||
|
if (debugReadingItems) {
|
||||||
|
Crashlytics.log(100, "READ_DEBUG_ERROR", t.message)
|
||||||
|
Crashlytics.logException(t)
|
||||||
|
Toast.makeText(c, t.message, Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
Toast.makeText(app, app.getString(R.string.cant_mark_read), Toast.LENGTH_SHORT).show()
|
Toast.makeText(app, app.getString(R.string.cant_mark_read), Toast.LENGTH_SHORT).show()
|
||||||
items.add(i)
|
items.add(i)
|
||||||
notifyItemInserted(position)
|
notifyItemInserted(position)
|
||||||
|
@ -140,4 +140,7 @@
|
|||||||
<string name="self_signed_cert_warning">Pour des raisons de sécurités, les certificats auto-signés sont désactivés par défaut. En les activant, je ne serais pas responsable de quelconques problèmes de sécurité rencontrés.</string>
|
<string name="self_signed_cert_warning">Pour des raisons de sécurités, les certificats auto-signés sont désactivés par défaut. En les activant, je ne serais pas responsable de quelconques problèmes de sécurité rencontrés.</string>
|
||||||
<string name="pref_selfoss_category">Api Selfoss</string>
|
<string name="pref_selfoss_category">Api Selfoss</string>
|
||||||
<string name="pref_api_items_number_title">Nombre d\'articles chargés</string>
|
<string name="pref_api_items_number_title">Nombre d\'articles chargés</string>
|
||||||
|
<string name="read_debug_title">Des articles lus marqués comme non lus ?</string>
|
||||||
|
<string name="read_debug_on">Les appels API vont être logués lorsequ\'un article est marqué comme lu</string>
|
||||||
|
<string name="read_debug_off">Aucun log quand un article est marqué comme lu</string>
|
||||||
</resources>
|
</resources>
|
@ -140,4 +140,7 @@
|
|||||||
<string name="self_signed_cert_warning">Due to security reasons, self signed certificates are not supported by default. By activating this, I\'ll not be responsible of any security problem you encounter.</string>
|
<string name="self_signed_cert_warning">Due to security reasons, self signed certificates are not supported by default. By activating this, I\'ll not be responsible of any security problem you encounter.</string>
|
||||||
<string name="pref_selfoss_category">Selfoss Api</string>
|
<string name="pref_selfoss_category">Selfoss Api</string>
|
||||||
<string name="pref_api_items_number_title">Loaded items number</string>
|
<string name="pref_api_items_number_title">Loaded items number</string>
|
||||||
|
<string name="read_debug_title">Read articles appearing as unread ?</string>
|
||||||
|
<string name="read_debug_on">Api calls will be logged when marking an article as read</string>
|
||||||
|
<string name="read_debug_off">No log when marking an item as read</string>
|
||||||
</resources>
|
</resources>
|
@ -142,4 +142,7 @@
|
|||||||
<string name="self_signed_cert_warning">Due to security reasons, self signed certificates are not supported by default. By activating this, I\'ll not be responsible of any security problem you encounter.</string>
|
<string name="self_signed_cert_warning">Due to security reasons, self signed certificates are not supported by default. By activating this, I\'ll not be responsible of any security problem you encounter.</string>
|
||||||
<string name="pref_selfoss_category">Selfoss Api</string>
|
<string name="pref_selfoss_category">Selfoss Api</string>
|
||||||
<string name="pref_api_items_number_title">Loaded items number</string>
|
<string name="pref_api_items_number_title">Loaded items number</string>
|
||||||
|
<string name="read_debug_title">Read articles appearing as unread ?</string>
|
||||||
|
<string name="read_debug_off">No log when marking an item as read</string>
|
||||||
|
<string name="read_debug_on">Api calls will be logged when marking an article as read</string>
|
||||||
</resources>
|
</resources>
|
@ -7,4 +7,12 @@
|
|||||||
android:summaryOff="@string/login_debug_off"
|
android:summaryOff="@string/login_debug_off"
|
||||||
android:summaryOn="@string/login_debug_on"
|
android:summaryOn="@string/login_debug_on"
|
||||||
android:title="@string/login_debug_title" />
|
android:title="@string/login_debug_title" />
|
||||||
|
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="read_debug"
|
||||||
|
android:summaryOff="@string/read_debug_off"
|
||||||
|
android:summaryOn="@string/read_debug_on"
|
||||||
|
android:title="@string/read_debug_title" />
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user