Compare commits
	
		
			2 Commits
		
	
	
		
			v171810290
			...
			v171810292
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					c5511880bc | ||
| 
						 | 
					5fe76d735e | 
							
								
								
									
										21
									
								
								app/proguard-rules.pro
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								app/proguard-rules.pro
									
									
									
									
										vendored
									
									
								
							@@ -30,22 +30,6 @@
 | 
			
		||||
    <fields>;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
##Retrofit
 | 
			
		||||
#-keep class com.google.gson.** { *; }
 | 
			
		||||
#-keep class com.google.inject.** { *; }
 | 
			
		||||
#-keep class org.apache.http.** { *; }
 | 
			
		||||
#-keep class org.apache.james.mime4j.** { *; }
 | 
			
		||||
#-keep class javax.inject.** { *; }
 | 
			
		||||
#-keep class retrofit.** { *; }
 | 
			
		||||
#-keepclassmembernames interface * {
 | 
			
		||||
#    @retrofit.http.* <methods>;
 | 
			
		||||
#}
 | 
			
		||||
#-keep class retrofit.** { *; }
 | 
			
		||||
#-keep class apps.amine.bou.readerforselfoss.api.selfoss.model.** { *; }
 | 
			
		||||
#-keepclassmembernames interface * {
 | 
			
		||||
#    @retrofit.http.* <methods>;
 | 
			
		||||
#}
 | 
			
		||||
-dontwarn okio.**
 | 
			
		||||
-dontwarn retrofit2.Platform$Java8
 | 
			
		||||
-keep class retrofit.** { *; }
 | 
			
		||||
@@ -75,4 +59,7 @@
 | 
			
		||||
 | 
			
		||||
-dontwarn javax.annotation.**
 | 
			
		||||
 | 
			
		||||
-keep class android.support.v7.widget.SearchView { *; }
 | 
			
		||||
-keep class android.support.v7.widget.SearchView { *; }
 | 
			
		||||
 | 
			
		||||
# maybe remove later ?
 | 
			
		||||
-keep class * extends androidx.fragment.app.Fragment
 | 
			
		||||
 
 | 
			
		||||
@@ -1034,6 +1034,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
 | 
			
		||||
                            this,
 | 
			
		||||
                            items,
 | 
			
		||||
                            api,
 | 
			
		||||
                            db,
 | 
			
		||||
                            customTabActivityHelper,
 | 
			
		||||
                            internalBrowser,
 | 
			
		||||
                            articleViewer,
 | 
			
		||||
@@ -1050,6 +1051,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
 | 
			
		||||
                            this,
 | 
			
		||||
                            items,
 | 
			
		||||
                            api,
 | 
			
		||||
                            db,
 | 
			
		||||
                            customTabActivityHelper,
 | 
			
		||||
                            internalBrowser,
 | 
			
		||||
                            articleViewer,
 | 
			
		||||
 
 | 
			
		||||
@@ -13,14 +13,18 @@ import android.view.Menu
 | 
			
		||||
import android.view.MenuItem
 | 
			
		||||
import android.view.ViewGroup
 | 
			
		||||
import android.widget.Toast
 | 
			
		||||
import androidx.room.Room
 | 
			
		||||
import apps.amine.bou.readerforselfoss.api.selfoss.Item
 | 
			
		||||
import apps.amine.bou.readerforselfoss.api.selfoss.SelfossApi
 | 
			
		||||
import apps.amine.bou.readerforselfoss.api.selfoss.SuccessResponse
 | 
			
		||||
import apps.amine.bou.readerforselfoss.fragments.ArticleFragment
 | 
			
		||||
import apps.amine.bou.readerforselfoss.persistence.database.AppDatabase
 | 
			
		||||
import apps.amine.bou.readerforselfoss.persistence.migrations.MIGRATION_1_2
 | 
			
		||||
import apps.amine.bou.readerforselfoss.themes.AppColors
 | 
			
		||||
import apps.amine.bou.readerforselfoss.themes.Toppings
 | 
			
		||||
import apps.amine.bou.readerforselfoss.transformers.DepthPageTransformer
 | 
			
		||||
import apps.amine.bou.readerforselfoss.utils.maybeHandleSilentException
 | 
			
		||||
import apps.amine.bou.readerforselfoss.utils.persistence.toEntity
 | 
			
		||||
import apps.amine.bou.readerforselfoss.utils.succeeded
 | 
			
		||||
import apps.amine.bou.readerforselfoss.utils.toggleStar
 | 
			
		||||
import com.ftinc.scoop.Scoop
 | 
			
		||||
@@ -30,6 +34,7 @@ import org.acra.ACRA
 | 
			
		||||
import retrofit2.Call
 | 
			
		||||
import retrofit2.Callback
 | 
			
		||||
import retrofit2.Response
 | 
			
		||||
import kotlin.concurrent.thread
 | 
			
		||||
 | 
			
		||||
class ReaderActivity : AppCompatActivity() {
 | 
			
		||||
 | 
			
		||||
@@ -42,6 +47,8 @@ class ReaderActivity : AppCompatActivity() {
 | 
			
		||||
 | 
			
		||||
    private lateinit var toolbarMenu: Menu
 | 
			
		||||
 | 
			
		||||
    private lateinit var db: AppDatabase
 | 
			
		||||
 | 
			
		||||
    private fun showMenuItem(willAddToFavorite: Boolean) {
 | 
			
		||||
        toolbarMenu.findItem(R.id.save).isVisible = willAddToFavorite
 | 
			
		||||
        toolbarMenu.findItem(R.id.unsave).isVisible = !willAddToFavorite
 | 
			
		||||
@@ -60,6 +67,11 @@ class ReaderActivity : AppCompatActivity() {
 | 
			
		||||
 | 
			
		||||
        setContentView(R.layout.activity_reader)
 | 
			
		||||
 | 
			
		||||
        db = Room.databaseBuilder(
 | 
			
		||||
            applicationContext,
 | 
			
		||||
            AppDatabase::class.java, "selfoss-database"
 | 
			
		||||
        ).addMigrations(MIGRATION_1_2).build()
 | 
			
		||||
 | 
			
		||||
        val scoop = Scoop.getInstance()
 | 
			
		||||
        scoop.bind(this, Toppings.PRIMARY.value, toolBar)
 | 
			
		||||
        if  (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
 | 
			
		||||
@@ -89,7 +101,7 @@ class ReaderActivity : AppCompatActivity() {
 | 
			
		||||
 | 
			
		||||
        currentItem = intent.getIntExtra("currentItem", 0)
 | 
			
		||||
 | 
			
		||||
        readItem(allItems[currentItem].id)
 | 
			
		||||
        readItem(allItems[currentItem])
 | 
			
		||||
 | 
			
		||||
        pager.adapter = ScreenSlidePagerAdapter(supportFragmentManager, AppColors(this@ReaderActivity))
 | 
			
		||||
        pager.currentItem = currentItem
 | 
			
		||||
@@ -113,15 +125,18 @@ class ReaderActivity : AppCompatActivity() {
 | 
			
		||||
                    } else {
 | 
			
		||||
                        canFavorite()
 | 
			
		||||
                    }
 | 
			
		||||
                    readItem(allItems[pager.currentItem].id)
 | 
			
		||||
                    readItem(allItems[pager.currentItem])
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fun readItem(id: String) {
 | 
			
		||||
    fun readItem(item: Item) {
 | 
			
		||||
        if (markOnScroll) {
 | 
			
		||||
            api.markItem(id).enqueue(
 | 
			
		||||
            thread {
 | 
			
		||||
                db.itemsDao().delete(item.toEntity())
 | 
			
		||||
            }
 | 
			
		||||
            api.markItem(item.id).enqueue(
 | 
			
		||||
                object : Callback<SuccessResponse> {
 | 
			
		||||
                    override fun onResponse(
 | 
			
		||||
                        call: Call<SuccessResponse>,
 | 
			
		||||
@@ -145,6 +160,9 @@ class ReaderActivity : AppCompatActivity() {
 | 
			
		||||
                        call: Call<SuccessResponse>,
 | 
			
		||||
                        t: Throwable
 | 
			
		||||
                    ) {
 | 
			
		||||
                        thread {
 | 
			
		||||
                            db.itemsDao().insertAllItems(item.toEntity())
 | 
			
		||||
                        }
 | 
			
		||||
                        if (debugReadingItems) {
 | 
			
		||||
                            ACRA.getErrorReporter().maybeHandleSilentException(t, this@ReaderActivity)
 | 
			
		||||
                        }
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,7 @@ import apps.amine.bou.readerforselfoss.R
 | 
			
		||||
import apps.amine.bou.readerforselfoss.api.selfoss.Item
 | 
			
		||||
import apps.amine.bou.readerforselfoss.api.selfoss.SelfossApi
 | 
			
		||||
import apps.amine.bou.readerforselfoss.api.selfoss.SuccessResponse
 | 
			
		||||
import apps.amine.bou.readerforselfoss.persistence.database.AppDatabase
 | 
			
		||||
import apps.amine.bou.readerforselfoss.themes.AppColors
 | 
			
		||||
import apps.amine.bou.readerforselfoss.utils.buildCustomTabsIntent
 | 
			
		||||
import apps.amine.bou.readerforselfoss.utils.customtabs.CustomTabActivityHelper
 | 
			
		||||
@@ -38,6 +39,7 @@ class ItemCardAdapter(
 | 
			
		||||
    override val app: Activity,
 | 
			
		||||
    override var items: ArrayList<Item>,
 | 
			
		||||
    override val api: SelfossApi,
 | 
			
		||||
    override val db: AppDatabase,
 | 
			
		||||
    private val helper: CustomTabActivityHelper,
 | 
			
		||||
    private val internalBrowser: Boolean,
 | 
			
		||||
    private val articleViewer: Boolean,
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,7 @@ import apps.amine.bou.readerforselfoss.R
 | 
			
		||||
import apps.amine.bou.readerforselfoss.api.selfoss.Item
 | 
			
		||||
import apps.amine.bou.readerforselfoss.api.selfoss.SelfossApi
 | 
			
		||||
import apps.amine.bou.readerforselfoss.api.selfoss.SuccessResponse
 | 
			
		||||
import apps.amine.bou.readerforselfoss.persistence.database.AppDatabase
 | 
			
		||||
import apps.amine.bou.readerforselfoss.themes.AppColors
 | 
			
		||||
import apps.amine.bou.readerforselfoss.utils.buildCustomTabsIntent
 | 
			
		||||
import apps.amine.bou.readerforselfoss.utils.customtabs.CustomTabActivityHelper
 | 
			
		||||
@@ -39,6 +40,7 @@ class ItemListAdapter(
 | 
			
		||||
    override val app: Activity,
 | 
			
		||||
    override var items: ArrayList<Item>,
 | 
			
		||||
    override val api: SelfossApi,
 | 
			
		||||
    override val db: AppDatabase,
 | 
			
		||||
    private val helper: CustomTabActivityHelper,
 | 
			
		||||
    private val internalBrowser: Boolean,
 | 
			
		||||
    private val articleViewer: Boolean,
 | 
			
		||||
 
 | 
			
		||||
@@ -10,17 +10,21 @@ import apps.amine.bou.readerforselfoss.R
 | 
			
		||||
import apps.amine.bou.readerforselfoss.api.selfoss.Item
 | 
			
		||||
import apps.amine.bou.readerforselfoss.api.selfoss.SelfossApi
 | 
			
		||||
import apps.amine.bou.readerforselfoss.api.selfoss.SuccessResponse
 | 
			
		||||
import apps.amine.bou.readerforselfoss.persistence.database.AppDatabase
 | 
			
		||||
import apps.amine.bou.readerforselfoss.themes.AppColors
 | 
			
		||||
import apps.amine.bou.readerforselfoss.utils.maybeHandleSilentException
 | 
			
		||||
import apps.amine.bou.readerforselfoss.utils.persistence.toEntity
 | 
			
		||||
import apps.amine.bou.readerforselfoss.utils.succeeded
 | 
			
		||||
import org.acra.ACRA
 | 
			
		||||
import retrofit2.Call
 | 
			
		||||
import retrofit2.Callback
 | 
			
		||||
import retrofit2.Response
 | 
			
		||||
import kotlin.concurrent.thread
 | 
			
		||||
 | 
			
		||||
abstract class ItemsAdapter<VH : RecyclerView.ViewHolder?> : RecyclerView.Adapter<VH>() {
 | 
			
		||||
    abstract var items: ArrayList<Item>
 | 
			
		||||
    abstract val api: SelfossApi
 | 
			
		||||
    abstract val db: AppDatabase
 | 
			
		||||
    abstract val debugReadingItems: Boolean
 | 
			
		||||
    abstract val userIdentifier: String
 | 
			
		||||
    abstract val app: Activity
 | 
			
		||||
@@ -42,6 +46,9 @@ abstract class ItemsAdapter<VH : RecyclerView.ViewHolder?> : RecyclerView.Adapte
 | 
			
		||||
            )
 | 
			
		||||
            .setAction(R.string.undo_string) {
 | 
			
		||||
                items.add(position, i)
 | 
			
		||||
                thread {
 | 
			
		||||
                    db.itemsDao().insertAllItems(i.toEntity())
 | 
			
		||||
                }
 | 
			
		||||
                notifyItemInserted(position)
 | 
			
		||||
                updateItems(items)
 | 
			
		||||
 | 
			
		||||
@@ -54,6 +61,9 @@ abstract class ItemsAdapter<VH : RecyclerView.ViewHolder?> : RecyclerView.Adapte
 | 
			
		||||
 | 
			
		||||
                    override fun onFailure(call: Call<SuccessResponse>, t: Throwable) {
 | 
			
		||||
                        items.remove(i)
 | 
			
		||||
                        thread {
 | 
			
		||||
                            db.itemsDao().delete(i.toEntity())
 | 
			
		||||
                        }
 | 
			
		||||
                        notifyItemRemoved(position)
 | 
			
		||||
                        updateItems(items)
 | 
			
		||||
                        doUnmark(i, position)
 | 
			
		||||
@@ -75,6 +85,12 @@ abstract class ItemsAdapter<VH : RecyclerView.ViewHolder?> : RecyclerView.Adapte
 | 
			
		||||
        notifyItemRemoved(position)
 | 
			
		||||
        updateItems(items)
 | 
			
		||||
 | 
			
		||||
        // TODO: Handle network status.
 | 
			
		||||
        // IF offline, delete from cached articles, and add to some table that will replay the calls on network activation.
 | 
			
		||||
 | 
			
		||||
        thread {
 | 
			
		||||
            db.itemsDao().delete(i.toEntity())
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        api.markItem(i.id).enqueue(object : Callback<SuccessResponse> {
 | 
			
		||||
            override fun onResponse(
 | 
			
		||||
@@ -93,6 +109,7 @@ abstract class ItemsAdapter<VH : RecyclerView.ViewHolder?> : RecyclerView.Adapte
 | 
			
		||||
                    ACRA.getErrorReporter().maybeHandleSilentException(Exception(message), app)
 | 
			
		||||
                    Toast.makeText(app.baseContext, message, Toast.LENGTH_LONG).show()
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                doUnmark(i, position)
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
@@ -110,6 +127,9 @@ abstract class ItemsAdapter<VH : RecyclerView.ViewHolder?> : RecyclerView.Adapte
 | 
			
		||||
                notifyItemInserted(position)
 | 
			
		||||
                updateItems(items)
 | 
			
		||||
 | 
			
		||||
                thread {
 | 
			
		||||
                    db.itemsDao().insertAllItems(i.toEntity())
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
package apps.amine.bou.readerforselfoss.persistence.dao
 | 
			
		||||
 | 
			
		||||
import androidx.room.Dao
 | 
			
		||||
import androidx.room.Delete
 | 
			
		||||
import androidx.room.Insert
 | 
			
		||||
import androidx.room.OnConflictStrategy
 | 
			
		||||
import androidx.room.Query
 | 
			
		||||
@@ -15,11 +16,14 @@ interface ItemsDao {
 | 
			
		||||
    fun items(): List<ItemEntity>
 | 
			
		||||
 | 
			
		||||
    @Insert(onConflict = OnConflictStrategy.REPLACE)
 | 
			
		||||
    fun insertAllItems(vararg tags: ItemEntity)
 | 
			
		||||
    fun insertAllItems(vararg items: ItemEntity)
 | 
			
		||||
 | 
			
		||||
    @Query("DELETE FROM items")
 | 
			
		||||
    fun deleteAllItems()
 | 
			
		||||
 | 
			
		||||
    @Delete
 | 
			
		||||
    fun delete(item: ItemEntity)
 | 
			
		||||
 | 
			
		||||
    @Update
 | 
			
		||||
    fun updateItem(item: ItemEntity)
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user