This commit is contained in:
aminecmi 2021-01-09 15:01:59 +01:00
parent 6fa8c901fc
commit 41c14362a8
17 changed files with 93 additions and 69 deletions

View File

@ -24,12 +24,12 @@ def versionNameFromGit() {
return gitVersion() return gitVersion()
} }
apply plugin: 'kotlin-kapt'
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
apply plugin: 'kotlin-android' apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-android-extensions'
android { android {
@ -37,12 +37,12 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8
} }
compileSdkVersion 28 compileSdkVersion 30
buildToolsVersion '28.0.3' buildToolsVersion '30.0.3'
defaultConfig { defaultConfig {
applicationId "apps.amine.bou.readerforselfoss" applicationId "apps.amine.bou.readerforselfoss"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 28 targetSdkVersion 30
versionCode versionCodeFromGit() versionCode versionCodeFromGit()
versionName versionNameFromGit() versionName versionNameFromGit()
@ -85,23 +85,23 @@ android {
dependencies { dependencies {
// Testing // Testing
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-beta01' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0-alpha02'
androidTestImplementation 'androidx.test:runner:1.2.0-beta01' androidTestImplementation 'androidx.test:runner:1.3.1-alpha02'
// Espresso-contrib for DatePicker, RecyclerView, Drawer actions, Accessibility checks, CountingIdlingResource // Espresso-contrib for DatePicker, RecyclerView, Drawer actions, Accessibility checks, CountingIdlingResource
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.2.0-beta01' androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0-alpha02'
// Espresso-intents for validation and stubbing of Intents // Espresso-intents for validation and stubbing of Intents
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.2.0-beta01' androidTestImplementation 'androidx.test.espresso:espresso-intents:3.4.0-alpha02'
implementation fileTree(include: ['*.jar'], dir: 'libs') implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// Android Support // Android Support
implementation "androidx.appcompat:appcompat:$androidx_version" implementation "androidx.appcompat:appcompat:1.3.0-alpha02"
implementation "com.google.android.material:material:1.1.0-alpha06" implementation 'com.google.android.material:material:1.3.0-beta01'
implementation "androidx.recyclerview:recyclerview:1.1.0-alpha05" implementation 'androidx.recyclerview:recyclerview:1.2.0-beta01'
implementation "androidx.legacy:legacy-support-v4:$android_version" implementation "androidx.legacy:legacy-support-v4:$android_version"
implementation "androidx.vectordrawable:vectordrawable:1.1.0-beta01" implementation 'androidx.vectordrawable:vectordrawable:1.2.0-alpha02'
implementation "androidx.browser:browser:$android_version" implementation "androidx.browser:browser:1.3.0"
implementation "androidx.cardview:cardview:$android_version" implementation "androidx.cardview:cardview:$android_version"
implementation 'androidx.constraintlayout:constraintlayout:2.1.0-alpha1' implementation 'androidx.constraintlayout:constraintlayout:2.1.0-alpha2'
implementation 'org.jsoup:jsoup:1.13.1' implementation 'org.jsoup:jsoup:1.13.1'
//multidex //multidex
@ -141,13 +141,13 @@ dependencies {
//PhotoView //PhotoView
implementation 'com.github.chrisbanes:PhotoView:2.0.0' implementation 'com.github.chrisbanes:PhotoView:2.0.0'
implementation 'androidx.core:core-ktx:1.1.0-beta01' implementation 'androidx.core:core-ktx:1.5.0-alpha05'
implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version" implementation "androidx.lifecycle:lifecycle-livedata:2.3.0-rc01"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version" implementation "androidx.lifecycle:lifecycle-common-java8:2.3.0-rc01"
implementation "androidx.room:room-runtime:$room_version" implementation "androidx.room:room-runtime:2.3.0-alpha04"
kapt "androidx.room:room-compiler:$room_version" kapt "androidx.room:room-compiler:2.3.0-alpha04"
implementation "android.arch.work:work-runtime-ktx:$work_version" implementation "android.arch.work:work-runtime-ktx:$work_version"
} }

View File

@ -92,7 +92,7 @@ class AddSourceActivity : AppCompatActivity() {
this, this,
this@AddSourceActivity, this@AddSourceActivity,
settings.getBoolean("isSelfSignedCert", false), settings.getBoolean("isSelfSignedCert", false),
prefs.getString("api_timeout", "-1").toLong() prefs.getString("api_timeout", "-1")!!.toLong()
) )
} catch (e: IllegalArgumentException) { } catch (e: IllegalArgumentException) {
mustLoginToAddSource() mustLoginToAddSource()

View File

@ -177,7 +177,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
this, this,
this@HomeActivity, this@HomeActivity,
settings.getBoolean("isSelfSignedCert", false), settings.getBoolean("isSelfSignedCert", false),
sharedPref.getString("api_timeout", "-1").toLong() sharedPref.getString("api_timeout", "-1")!!.toLong()
) )
items = ArrayList() items = ArrayList()
allItems = ArrayList() allItems = ArrayList()
@ -389,19 +389,19 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
displayUnreadCount = sharedPref.getBoolean("display_unread_count", true) displayUnreadCount = sharedPref.getBoolean("display_unread_count", true)
displayAllCount = sharedPref.getBoolean("display_other_count", false) displayAllCount = sharedPref.getBoolean("display_other_count", false)
fullHeightCards = sharedPref.getBoolean("full_height_cards", false) fullHeightCards = sharedPref.getBoolean("full_height_cards", false)
itemsNumber = sharedPref.getString("prefer_api_items_number", "200").toInt() itemsNumber = sharedPref.getString("prefer_api_items_number", "200")!!.toInt()
userIdentifier = sharedPref.getString("unique_id", "") userIdentifier = sharedPref.getString("unique_id", "")!!
displayAccountHeader = sharedPref.getBoolean("account_header_displaying", false) displayAccountHeader = sharedPref.getBoolean("account_header_displaying", false)
infiniteScroll = sharedPref.getBoolean("infinite_loading", false) infiniteScroll = sharedPref.getBoolean("infinite_loading", false)
itemsCaching = sharedPref.getBoolean("items_caching", false) itemsCaching = sharedPref.getBoolean("items_caching", false)
hiddenTags = if (sharedPref.getString("hidden_tags", "").isNotEmpty()) { hiddenTags = if (sharedPref.getString("hidden_tags", "")!!.isNotEmpty()) {
sharedPref.getString("hidden_tags", "").replace("\\s".toRegex(), "").split(",") sharedPref.getString("hidden_tags", "")!!.replace("\\s".toRegex(), "").split(",")
} else { } else {
emptyList() emptyList()
} }
periodicRefresh = sharedPref.getBoolean("periodic_refresh", false) periodicRefresh = sharedPref.getBoolean("periodic_refresh", false)
refreshWhenChargingOnly = sharedPref.getBoolean("refresh_when_charging", false) refreshWhenChargingOnly = sharedPref.getBoolean("refresh_when_charging", false)
refreshMinutes = sharedPref.getString("periodic_refresh_minutes", "360").toLong() refreshMinutes = sharedPref.getString("periodic_refresh_minutes", "360")!!.toLong()
if (refreshMinutes <= 15) { if (refreshMinutes <= 15) {
refreshMinutes = 15 refreshMinutes = 15
@ -450,7 +450,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
if (displayAccountHeader) { if (displayAccountHeader) {
accountHeader { accountHeader {
background = R.drawable.bg background = R.drawable.bg
profile(settings.getString("url", "")) { profile(settings.getString("url", "")!!) {
iconDrawable = resources.getDrawable(R.mipmap.ic_launcher) iconDrawable = resources.getDrawable(R.mipmap.ic_launcher)
} }
selectionListEnabledForSingleProfile = false selectionListEnabledForSingleProfile = false
@ -684,13 +684,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
.withIconTintingEnabled(true) .withIconTintingEnabled(true)
.withOnDrawerItemClickListener { _, _, _ -> .withOnDrawerItemClickListener { _, _, _ ->
LibsBuilder() LibsBuilder()
.withActivityStyle(
if (appColors.isDarkTheme) {
Libs.ActivityStyle.DARK
} else {
Libs.ActivityStyle.LIGHT_DARK_TOOLBAR
}
)
.withAboutIconShown(true) .withAboutIconShown(true)
.withAboutVersionShown(true) .withAboutVersionShown(true)
.start(this@HomeActivity) .start(this@HomeActivity)

View File

@ -52,11 +52,11 @@ class LoginActivity : AppCompatActivity() {
handleBaseUrlFail() handleBaseUrlFail()
settings = getSharedPreferences(Config.settingsName, Context.MODE_PRIVATE) settings = getSharedPreferences(Config.settingsName, Context.MODE_PRIVATE)
userIdentifier = settings.getString("unique_id", "") userIdentifier = settings.getString("unique_id", "")!!
editor = settings.edit() editor = settings.edit()
if (settings.getString("url", "").isNotEmpty()) { if (settings.getString("url", "")!!.isNotEmpty()) {
goToMain() goToMain()
} }
@ -284,7 +284,6 @@ class LoginActivity : AppCompatActivity() {
return when (item.itemId) { return when (item.itemId) {
R.id.about -> { R.id.about -> {
LibsBuilder() LibsBuilder()
.withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR)
.withAboutIconShown(true) .withAboutIconShown(true)
.withAboutVersionShown(true) .withAboutVersionShown(true)
.start(this) .start(this)

View File

@ -26,7 +26,7 @@ class MyApp : MultiDexApplication() {
config = Config(baseContext) config = Config(baseContext)
val prefs = getSharedPreferences(Config.settingsName, Context.MODE_PRIVATE) val prefs = getSharedPreferences(Config.settingsName, Context.MODE_PRIVATE)
if (prefs.getString("unique_id", "").isEmpty()) { if (prefs.getString("unique_id", "")!!.isEmpty()) {
val editor = prefs.edit() val editor = prefs.edit()
editor.putString("unique_id", randomUUID().toString()) editor.putString("unique_id", randomUUID().toString())
editor.apply() editor.apply()

View File

@ -100,7 +100,7 @@ class ReaderActivity : AppCompatActivity() {
prefs = PreferenceManager.getDefaultSharedPreferences(this) prefs = PreferenceManager.getDefaultSharedPreferences(this)
editor = prefs.edit() editor = prefs.edit()
userIdentifier = prefs.getString("unique_id", "") userIdentifier = prefs.getString("unique_id", "")!!
markOnScroll = prefs.getBoolean("mark_on_scroll", false) markOnScroll = prefs.getBoolean("mark_on_scroll", false)
activeAlignment = prefs.getInt("text_align", JUSTIFY) activeAlignment = prefs.getInt("text_align", JUSTIFY)
@ -108,7 +108,7 @@ class ReaderActivity : AppCompatActivity() {
this, this,
this@ReaderActivity, this@ReaderActivity,
settings.getBoolean("isSelfSignedCert", false), settings.getBoolean("isSelfSignedCert", false),
prefs.getString("api_timeout", "-1").toLong() prefs.getString("api_timeout", "-1")!!.toLong()
) )
if (allItems.isEmpty()) { if (allItems.isEmpty()) {

View File

@ -64,7 +64,7 @@ class SourcesActivity : AppCompatActivity() {
this, this,
this@SourcesActivity, this@SourcesActivity,
settings.getBoolean("isSelfSignedCert", false), settings.getBoolean("isSelfSignedCert", false),
prefs.getString("api_timeout", "-1").toLong() prefs.getString("api_timeout", "-1")!!.toLong()
) )
var items: ArrayList<Source> = ArrayList() var items: ArrayList<Source> = ArrayList()

View File

@ -9,6 +9,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.ImageView.ScaleType import android.widget.ImageView.ScaleType
import android.widget.Toast import android.widget.Toast
import androidx.core.content.ContextCompat
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
@ -34,6 +35,10 @@ import com.bumptech.glide.Glide
import com.like.LikeButton import com.like.LikeButton
import com.like.OnLikeListener import com.like.OnLikeListener
import kotlinx.android.synthetic.main.card_item.view.* import kotlinx.android.synthetic.main.card_item.view.*
import kotlinx.android.synthetic.main.card_item.view.itemImage
import kotlinx.android.synthetic.main.card_item.view.sourceTitleAndDate
import kotlinx.android.synthetic.main.card_item.view.title
import kotlinx.android.synthetic.main.list_item.view.*
import retrofit2.Call import retrofit2.Call
import retrofit2.Callback import retrofit2.Callback
import retrofit2.Response import retrofit2.Response
@ -69,12 +74,21 @@ class ItemCardAdapter(
holder.mView.favButton.isLiked = itm.starred holder.mView.favButton.isLiked = itm.starred
holder.mView.title.text = itm.getTitleDecoded() holder.mView.title.text = itm.getTitleDecoded()
holder.mView.title.setTextColor(ContextCompat.getColor(
c,
appColors.textColor
))
holder.mView.title.setOnTouchListener(LinkOnTouchListener()) holder.mView.title.setOnTouchListener(LinkOnTouchListener())
holder.mView.title.setLinkTextColor(appColors.colorAccent) holder.mView.title.setLinkTextColor(appColors.colorAccent)
holder.mView.sourceTitleAndDate.text = itm.sourceAndDateText() holder.mView.sourceTitleAndDate.text = itm.sourceAndDateText()
holder.mView.sourceTitleAndDate.setTextColor(ContextCompat.getColor(
c,
appColors.textColor
))
if (!fullHeightCards) { if (!fullHeightCards) {
holder.mView.itemImage.maxHeight = imageMaxHeight holder.mView.itemImage.maxHeight = imageMaxHeight
holder.mView.itemImage.scaleType = ScaleType.CENTER_CROP holder.mView.itemImage.scaleType = ScaleType.CENTER_CROP

View File

@ -13,6 +13,7 @@ import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.TextView import android.widget.TextView
import android.widget.Toast import android.widget.Toast
import androidx.core.content.ContextCompat
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
@ -72,12 +73,22 @@ class ItemListAdapter(
holder.mView.title.text = itm.getTitleDecoded() holder.mView.title.text = itm.getTitleDecoded()
holder.mView.title.setTextColor(ContextCompat.getColor(
c,
appColors.textColor
))
holder.mView.title.setOnTouchListener(LinkOnTouchListener()) holder.mView.title.setOnTouchListener(LinkOnTouchListener())
holder.mView.title.setLinkTextColor(appColors.colorAccent) holder.mView.title.setLinkTextColor(appColors.colorAccent)
holder.mView.sourceTitleAndDate.text = itm.sourceAndDateText() holder.mView.sourceTitleAndDate.text = itm.sourceAndDateText()
holder.mView.sourceTitleAndDate.setTextColor(ContextCompat.getColor(
c,
appColors.textColor
))
if (itm.getThumbnail(c).isEmpty()) { if (itm.getThumbnail(c).isEmpty()) {
if (itm.getIcon(c).isEmpty()) { if (itm.getIcon(c).isEmpty()) {

View File

@ -28,17 +28,17 @@ class ParsedContent(
} }
constructor(source: Parcel) : this( constructor(source: Parcel) : this(
title = source.readString(), title = source.readString().orEmpty(),
content = source.readString(), content = source.readString(),
date_published = source.readString(), date_published = source.readString().orEmpty(),
lead_image_url = source.readString(), lead_image_url = source.readString(),
dek = source.readString(), dek = source.readString().orEmpty(),
url = source.readString(), url = source.readString().orEmpty(),
domain = source.readString(), domain = source.readString().orEmpty(),
excerpt = source.readString(), excerpt = source.readString().orEmpty(),
total_pages = source.readInt(), total_pages = source.readInt(),
rendered_pages = source.readInt(), rendered_pages = source.readInt(),
next_page_url = source.readString() next_page_url = source.readString().orEmpty()
) )
override fun describeContents() = 0 override fun describeContents() = 0

View File

@ -94,17 +94,17 @@ data class Item(
} }
constructor(source: Parcel) : this( constructor(source: Parcel) : this(
id = source.readString(), id = source.readString().orEmpty(),
datetime = source.readString(), datetime = source.readString().orEmpty(),
title = source.readString(), title = source.readString().orEmpty(),
content = source.readString(), content = source.readString().orEmpty(),
unread = 0.toByte() != source.readByte(), unread = 0.toByte() != source.readByte(),
starred = 0.toByte() != source.readByte(), starred = 0.toByte() != source.readByte(),
thumbnail = source.readString(), thumbnail = source.readString(),
icon = source.readString(), icon = source.readString(),
link = source.readString(), link = source.readString().orEmpty(),
sourcetitle = source.readString(), sourcetitle = source.readString().orEmpty(),
tags = source.readParcelable(ClassLoader.getSystemClassLoader()) tags = if (source.readParcelable<SelfossTagType>(ClassLoader.getSystemClassLoader()) != null) source.readParcelable(ClassLoader.getSystemClassLoader())!! else SelfossTagType("")
) )
override fun describeContents() = 0 override fun describeContents() = 0
@ -216,7 +216,7 @@ data class SelfossTagType(val tags: String) : Parcelable {
} }
constructor(source: Parcel) : this( constructor(source: Parcel) : this(
tags = source.readString() tags = source.readString().orEmpty()
) )
override fun describeContents() = 0 override fun describeContents() = 0

View File

@ -63,7 +63,7 @@ class LoadingWorker(val context: Context, params: WorkerParameters) : Worker(con
this.context, this.context,
null, null,
settings.getBoolean("isSelfSignedCert", false), settings.getBoolean("isSelfSignedCert", false),
sharedPref.getString("api_timeout", "-1").toLong() sharedPref.getString("api_timeout", "-1")!!.toLong()
) )
api.allItems().enqueue(object : Callback<List<Item>> { api.allItems().enqueue(object : Callback<List<Item>> {

View File

@ -100,7 +100,7 @@ class ArticleFragment : Fragment() {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
pageNumber = arguments!!.getInt(ARG_POSITION) pageNumber = arguments!!.getInt(ARG_POSITION)
allItems = arguments!!.getParcelableArrayList(ARG_ITEMS) allItems = arguments!!.getParcelableArrayList<Item>(ARG_ITEMS) as ArrayList<Item>
db = Room.databaseBuilder( db = Room.databaseBuilder(
context!!, context!!,
@ -126,9 +126,9 @@ class ArticleFragment : Fragment() {
prefs = PreferenceManager.getDefaultSharedPreferences(activity) prefs = PreferenceManager.getDefaultSharedPreferences(activity)
editor = prefs.edit() editor = prefs.edit()
fontSize = prefs.getString("reader_font_size", "16").toInt() fontSize = prefs.getString("reader_font_size", "16")!!.toInt()
font = prefs.getString("reader_font", "") font = prefs.getString("reader_font", "")!!
if (font.isNotEmpty()) { if (font.isNotEmpty()) {
resId = context!!.resources.getIdentifier(font, "font", context!!.packageName) resId = context!!.resources.getIdentifier(font, "font", context!!.packageName)
typeface = try { typeface = try {
@ -148,7 +148,7 @@ class ArticleFragment : Fragment() {
context!!, context!!,
activity!!, activity!!,
settings.getBoolean("isSelfSignedCert", false), settings.getBoolean("isSelfSignedCert", false),
prefs.getString("api_timeout", "-1").toLong() prefs.getString("api_timeout", "-1")!!.toLong()
) )
fab = rootView!!.fab fab = rootView!!.fab

View File

@ -17,7 +17,7 @@ class ImageFragment : Fragment() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
imageUrl = arguments!!.getString("imageUrl") imageUrl = arguments!!.getString("imageUrl")!!
} }
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {

View File

@ -18,6 +18,7 @@ class AppColors(a: Activity) {
@ColorInt val colorAccentDark: Int @ColorInt val colorAccentDark: Int
@ColorInt val cardBackgroundColor: Int @ColorInt val cardBackgroundColor: Int
@ColorInt val colorBackground: Int @ColorInt val colorBackground: Int
@ColorInt val textColor: Int
val isDarkTheme: Boolean val isDarkTheme: Boolean
init { init {
@ -57,6 +58,12 @@ class AppColors(a: Activity) {
android.R.color.background_light android.R.color.background_light
} }
textColor = if (isDarkTheme) {
R.color.md_white_1000
} else {
R.color.md_grey_900
}
val wrapper = Context::class.java val wrapper = Context::class.java
val method = wrapper!!.getMethod("getThemeResId") val method = wrapper!!.getMethod("getThemeResId")
method.isAccessible = true method.isAccessible = true

View File

@ -11,19 +11,19 @@ class Config(c: Context) {
val settings: SharedPreferences = c.getSharedPreferences(settingsName, Context.MODE_PRIVATE) val settings: SharedPreferences = c.getSharedPreferences(settingsName, Context.MODE_PRIVATE)
val baseUrl: String val baseUrl: String
get() = settings.getString("url", "") get() = settings.getString("url", "")!!
val userLogin: String val userLogin: String
get() = settings.getString("login", "") get() = settings.getString("login", "")!!
val userPassword: String val userPassword: String
get() = settings.getString("password", "") get() = settings.getString("password", "")!!
val httpUserLogin: String val httpUserLogin: String
get() = settings.getString("httpUserName", "") get() = settings.getString("httpUserName", "")!!
val httpUserPassword: String val httpUserPassword: String
get() = settings.getString("httpPassword", "") get() = settings.getString("httpPassword", "")!!
companion object { companion object {
const val settingsName = "paramsselfoss" const val settingsName = "paramsselfoss"

View File

@ -2,7 +2,7 @@
buildscript { buildscript {
ext { ext {
kotlin_version = '1.3.31' kotlin_version = '1.4.21'
android_version = '1.0.0' android_version = '1.0.0'
androidx_version = '1.1.0-alpha05' androidx_version = '1.1.0-alpha05'
lifecycle_version = '2.2.0-alpha01' lifecycle_version = '2.2.0-alpha01'