Fixes #323.
This commit is contained in:
parent
6fa8c901fc
commit
41c14362a8
@ -24,12 +24,12 @@ def versionNameFromGit() {
|
||||
return gitVersion()
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin-kapt'
|
||||
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
apply plugin: 'kotlin-android'
|
||||
|
||||
apply plugin: 'kotlin-kapt'
|
||||
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
|
||||
android {
|
||||
@ -37,12 +37,12 @@ android {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
compileSdkVersion 28
|
||||
buildToolsVersion '28.0.3'
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion '30.0.3'
|
||||
defaultConfig {
|
||||
applicationId "apps.amine.bou.readerforselfoss"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 28
|
||||
targetSdkVersion 30
|
||||
versionCode versionCodeFromGit()
|
||||
versionName versionNameFromGit()
|
||||
|
||||
@ -85,23 +85,23 @@ android {
|
||||
|
||||
dependencies {
|
||||
// Testing
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-beta01'
|
||||
androidTestImplementation 'androidx.test:runner:1.2.0-beta01'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0-alpha02'
|
||||
androidTestImplementation 'androidx.test:runner:1.3.1-alpha02'
|
||||
// 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
|
||||
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 "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||
// Android Support
|
||||
implementation "androidx.appcompat:appcompat:$androidx_version"
|
||||
implementation "com.google.android.material:material:1.1.0-alpha06"
|
||||
implementation "androidx.recyclerview:recyclerview:1.1.0-alpha05"
|
||||
implementation "androidx.appcompat:appcompat:1.3.0-alpha02"
|
||||
implementation 'com.google.android.material:material:1.3.0-beta01'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.2.0-beta01'
|
||||
implementation "androidx.legacy:legacy-support-v4:$android_version"
|
||||
implementation "androidx.vectordrawable:vectordrawable:1.1.0-beta01"
|
||||
implementation "androidx.browser:browser:$android_version"
|
||||
implementation 'androidx.vectordrawable:vectordrawable:1.2.0-alpha02'
|
||||
implementation "androidx.browser:browser:1.3.0"
|
||||
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'
|
||||
|
||||
//multidex
|
||||
@ -141,13 +141,13 @@ dependencies {
|
||||
//PhotoView
|
||||
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-common-java8:$lifecycle_version"
|
||||
implementation "androidx.lifecycle:lifecycle-livedata:2.3.0-rc01"
|
||||
implementation "androidx.lifecycle:lifecycle-common-java8:2.3.0-rc01"
|
||||
|
||||
implementation "androidx.room:room-runtime:$room_version"
|
||||
kapt "androidx.room:room-compiler:$room_version"
|
||||
implementation "androidx.room:room-runtime:2.3.0-alpha04"
|
||||
kapt "androidx.room:room-compiler:2.3.0-alpha04"
|
||||
|
||||
implementation "android.arch.work:work-runtime-ktx:$work_version"
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ class AddSourceActivity : AppCompatActivity() {
|
||||
this,
|
||||
this@AddSourceActivity,
|
||||
settings.getBoolean("isSelfSignedCert", false),
|
||||
prefs.getString("api_timeout", "-1").toLong()
|
||||
prefs.getString("api_timeout", "-1")!!.toLong()
|
||||
)
|
||||
} catch (e: IllegalArgumentException) {
|
||||
mustLoginToAddSource()
|
||||
|
@ -177,7 +177,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
||||
this,
|
||||
this@HomeActivity,
|
||||
settings.getBoolean("isSelfSignedCert", false),
|
||||
sharedPref.getString("api_timeout", "-1").toLong()
|
||||
sharedPref.getString("api_timeout", "-1")!!.toLong()
|
||||
)
|
||||
items = ArrayList()
|
||||
allItems = ArrayList()
|
||||
@ -389,19 +389,19 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
||||
displayUnreadCount = sharedPref.getBoolean("display_unread_count", true)
|
||||
displayAllCount = sharedPref.getBoolean("display_other_count", false)
|
||||
fullHeightCards = sharedPref.getBoolean("full_height_cards", false)
|
||||
itemsNumber = sharedPref.getString("prefer_api_items_number", "200").toInt()
|
||||
userIdentifier = sharedPref.getString("unique_id", "")
|
||||
itemsNumber = sharedPref.getString("prefer_api_items_number", "200")!!.toInt()
|
||||
userIdentifier = sharedPref.getString("unique_id", "")!!
|
||||
displayAccountHeader = sharedPref.getBoolean("account_header_displaying", false)
|
||||
infiniteScroll = sharedPref.getBoolean("infinite_loading", false)
|
||||
itemsCaching = sharedPref.getBoolean("items_caching", false)
|
||||
hiddenTags = if (sharedPref.getString("hidden_tags", "").isNotEmpty()) {
|
||||
sharedPref.getString("hidden_tags", "").replace("\\s".toRegex(), "").split(",")
|
||||
hiddenTags = if (sharedPref.getString("hidden_tags", "")!!.isNotEmpty()) {
|
||||
sharedPref.getString("hidden_tags", "")!!.replace("\\s".toRegex(), "").split(",")
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
periodicRefresh = sharedPref.getBoolean("periodic_refresh", 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) {
|
||||
refreshMinutes = 15
|
||||
@ -450,7 +450,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
||||
if (displayAccountHeader) {
|
||||
accountHeader {
|
||||
background = R.drawable.bg
|
||||
profile(settings.getString("url", "")) {
|
||||
profile(settings.getString("url", "")!!) {
|
||||
iconDrawable = resources.getDrawable(R.mipmap.ic_launcher)
|
||||
}
|
||||
selectionListEnabledForSingleProfile = false
|
||||
@ -684,13 +684,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
||||
.withIconTintingEnabled(true)
|
||||
.withOnDrawerItemClickListener { _, _, _ ->
|
||||
LibsBuilder()
|
||||
.withActivityStyle(
|
||||
if (appColors.isDarkTheme) {
|
||||
Libs.ActivityStyle.DARK
|
||||
} else {
|
||||
Libs.ActivityStyle.LIGHT_DARK_TOOLBAR
|
||||
}
|
||||
)
|
||||
.withAboutIconShown(true)
|
||||
.withAboutVersionShown(true)
|
||||
.start(this@HomeActivity)
|
||||
|
@ -52,11 +52,11 @@ class LoginActivity : AppCompatActivity() {
|
||||
handleBaseUrlFail()
|
||||
|
||||
settings = getSharedPreferences(Config.settingsName, Context.MODE_PRIVATE)
|
||||
userIdentifier = settings.getString("unique_id", "")
|
||||
userIdentifier = settings.getString("unique_id", "")!!
|
||||
|
||||
editor = settings.edit()
|
||||
|
||||
if (settings.getString("url", "").isNotEmpty()) {
|
||||
if (settings.getString("url", "")!!.isNotEmpty()) {
|
||||
goToMain()
|
||||
}
|
||||
|
||||
@ -284,7 +284,6 @@ class LoginActivity : AppCompatActivity() {
|
||||
return when (item.itemId) {
|
||||
R.id.about -> {
|
||||
LibsBuilder()
|
||||
.withActivityStyle(Libs.ActivityStyle.LIGHT_DARK_TOOLBAR)
|
||||
.withAboutIconShown(true)
|
||||
.withAboutVersionShown(true)
|
||||
.start(this)
|
||||
|
@ -26,7 +26,7 @@ class MyApp : MultiDexApplication() {
|
||||
config = Config(baseContext)
|
||||
|
||||
val prefs = getSharedPreferences(Config.settingsName, Context.MODE_PRIVATE)
|
||||
if (prefs.getString("unique_id", "").isEmpty()) {
|
||||
if (prefs.getString("unique_id", "")!!.isEmpty()) {
|
||||
val editor = prefs.edit()
|
||||
editor.putString("unique_id", randomUUID().toString())
|
||||
editor.apply()
|
||||
|
@ -100,7 +100,7 @@ class ReaderActivity : AppCompatActivity() {
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(this)
|
||||
editor = prefs.edit()
|
||||
|
||||
userIdentifier = prefs.getString("unique_id", "")
|
||||
userIdentifier = prefs.getString("unique_id", "")!!
|
||||
markOnScroll = prefs.getBoolean("mark_on_scroll", false)
|
||||
activeAlignment = prefs.getInt("text_align", JUSTIFY)
|
||||
|
||||
@ -108,7 +108,7 @@ class ReaderActivity : AppCompatActivity() {
|
||||
this,
|
||||
this@ReaderActivity,
|
||||
settings.getBoolean("isSelfSignedCert", false),
|
||||
prefs.getString("api_timeout", "-1").toLong()
|
||||
prefs.getString("api_timeout", "-1")!!.toLong()
|
||||
)
|
||||
|
||||
if (allItems.isEmpty()) {
|
||||
|
@ -64,7 +64,7 @@ class SourcesActivity : AppCompatActivity() {
|
||||
this,
|
||||
this@SourcesActivity,
|
||||
settings.getBoolean("isSelfSignedCert", false),
|
||||
prefs.getString("api_timeout", "-1").toLong()
|
||||
prefs.getString("api_timeout", "-1")!!.toLong()
|
||||
)
|
||||
var items: ArrayList<Source> = ArrayList()
|
||||
|
||||
|
@ -9,6 +9,7 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView.ScaleType
|
||||
import android.widget.Toast
|
||||
import androidx.core.content.ContextCompat
|
||||
import apps.amine.bou.readerforselfoss.R
|
||||
import apps.amine.bou.readerforselfoss.api.selfoss.Item
|
||||
import apps.amine.bou.readerforselfoss.api.selfoss.SelfossApi
|
||||
@ -34,6 +35,10 @@ import com.bumptech.glide.Glide
|
||||
import com.like.LikeButton
|
||||
import com.like.OnLikeListener
|
||||
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.Callback
|
||||
import retrofit2.Response
|
||||
@ -69,12 +74,21 @@ class ItemCardAdapter(
|
||||
|
||||
holder.mView.favButton.isLiked = itm.starred
|
||||
holder.mView.title.text = itm.getTitleDecoded()
|
||||
holder.mView.title.setTextColor(ContextCompat.getColor(
|
||||
c,
|
||||
appColors.textColor
|
||||
))
|
||||
holder.mView.title.setOnTouchListener(LinkOnTouchListener())
|
||||
|
||||
holder.mView.title.setLinkTextColor(appColors.colorAccent)
|
||||
|
||||
holder.mView.sourceTitleAndDate.text = itm.sourceAndDateText()
|
||||
|
||||
holder.mView.sourceTitleAndDate.setTextColor(ContextCompat.getColor(
|
||||
c,
|
||||
appColors.textColor
|
||||
))
|
||||
|
||||
if (!fullHeightCards) {
|
||||
holder.mView.itemImage.maxHeight = imageMaxHeight
|
||||
holder.mView.itemImage.scaleType = ScaleType.CENTER_CROP
|
||||
|
@ -13,6 +13,7 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.core.content.ContextCompat
|
||||
import apps.amine.bou.readerforselfoss.R
|
||||
import apps.amine.bou.readerforselfoss.api.selfoss.Item
|
||||
import apps.amine.bou.readerforselfoss.api.selfoss.SelfossApi
|
||||
@ -72,12 +73,22 @@ class ItemListAdapter(
|
||||
|
||||
holder.mView.title.text = itm.getTitleDecoded()
|
||||
|
||||
holder.mView.title.setTextColor(ContextCompat.getColor(
|
||||
c,
|
||||
appColors.textColor
|
||||
))
|
||||
|
||||
holder.mView.title.setOnTouchListener(LinkOnTouchListener())
|
||||
|
||||
holder.mView.title.setLinkTextColor(appColors.colorAccent)
|
||||
|
||||
holder.mView.sourceTitleAndDate.text = itm.sourceAndDateText()
|
||||
|
||||
holder.mView.sourceTitleAndDate.setTextColor(ContextCompat.getColor(
|
||||
c,
|
||||
appColors.textColor
|
||||
))
|
||||
|
||||
if (itm.getThumbnail(c).isEmpty()) {
|
||||
|
||||
if (itm.getIcon(c).isEmpty()) {
|
||||
|
@ -28,17 +28,17 @@ class ParsedContent(
|
||||
}
|
||||
|
||||
constructor(source: Parcel) : this(
|
||||
title = source.readString(),
|
||||
title = source.readString().orEmpty(),
|
||||
content = source.readString(),
|
||||
date_published = source.readString(),
|
||||
date_published = source.readString().orEmpty(),
|
||||
lead_image_url = source.readString(),
|
||||
dek = source.readString(),
|
||||
url = source.readString(),
|
||||
domain = source.readString(),
|
||||
excerpt = source.readString(),
|
||||
dek = source.readString().orEmpty(),
|
||||
url = source.readString().orEmpty(),
|
||||
domain = source.readString().orEmpty(),
|
||||
excerpt = source.readString().orEmpty(),
|
||||
total_pages = source.readInt(),
|
||||
rendered_pages = source.readInt(),
|
||||
next_page_url = source.readString()
|
||||
next_page_url = source.readString().orEmpty()
|
||||
)
|
||||
|
||||
override fun describeContents() = 0
|
||||
|
@ -94,17 +94,17 @@ data class Item(
|
||||
}
|
||||
|
||||
constructor(source: Parcel) : this(
|
||||
id = source.readString(),
|
||||
datetime = source.readString(),
|
||||
title = source.readString(),
|
||||
content = source.readString(),
|
||||
id = source.readString().orEmpty(),
|
||||
datetime = source.readString().orEmpty(),
|
||||
title = source.readString().orEmpty(),
|
||||
content = source.readString().orEmpty(),
|
||||
unread = 0.toByte() != source.readByte(),
|
||||
starred = 0.toByte() != source.readByte(),
|
||||
thumbnail = source.readString(),
|
||||
icon = source.readString(),
|
||||
link = source.readString(),
|
||||
sourcetitle = source.readString(),
|
||||
tags = source.readParcelable(ClassLoader.getSystemClassLoader())
|
||||
link = source.readString().orEmpty(),
|
||||
sourcetitle = source.readString().orEmpty(),
|
||||
tags = if (source.readParcelable<SelfossTagType>(ClassLoader.getSystemClassLoader()) != null) source.readParcelable(ClassLoader.getSystemClassLoader())!! else SelfossTagType("")
|
||||
)
|
||||
|
||||
override fun describeContents() = 0
|
||||
@ -216,7 +216,7 @@ data class SelfossTagType(val tags: String) : Parcelable {
|
||||
}
|
||||
|
||||
constructor(source: Parcel) : this(
|
||||
tags = source.readString()
|
||||
tags = source.readString().orEmpty()
|
||||
)
|
||||
|
||||
override fun describeContents() = 0
|
||||
|
@ -63,7 +63,7 @@ class LoadingWorker(val context: Context, params: WorkerParameters) : Worker(con
|
||||
this.context,
|
||||
null,
|
||||
settings.getBoolean("isSelfSignedCert", false),
|
||||
sharedPref.getString("api_timeout", "-1").toLong()
|
||||
sharedPref.getString("api_timeout", "-1")!!.toLong()
|
||||
)
|
||||
|
||||
api.allItems().enqueue(object : Callback<List<Item>> {
|
||||
|
@ -100,7 +100,7 @@ class ArticleFragment : Fragment() {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
pageNumber = arguments!!.getInt(ARG_POSITION)
|
||||
allItems = arguments!!.getParcelableArrayList(ARG_ITEMS)
|
||||
allItems = arguments!!.getParcelableArrayList<Item>(ARG_ITEMS) as ArrayList<Item>
|
||||
|
||||
db = Room.databaseBuilder(
|
||||
context!!,
|
||||
@ -126,9 +126,9 @@ class ArticleFragment : Fragment() {
|
||||
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(activity)
|
||||
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()) {
|
||||
resId = context!!.resources.getIdentifier(font, "font", context!!.packageName)
|
||||
typeface = try {
|
||||
@ -148,7 +148,7 @@ class ArticleFragment : Fragment() {
|
||||
context!!,
|
||||
activity!!,
|
||||
settings.getBoolean("isSelfSignedCert", false),
|
||||
prefs.getString("api_timeout", "-1").toLong()
|
||||
prefs.getString("api_timeout", "-1")!!.toLong()
|
||||
)
|
||||
|
||||
fab = rootView!!.fab
|
||||
|
@ -17,7 +17,7 @@ class ImageFragment : Fragment() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
imageUrl = arguments!!.getString("imageUrl")
|
||||
imageUrl = arguments!!.getString("imageUrl")!!
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
||||
|
@ -18,6 +18,7 @@ class AppColors(a: Activity) {
|
||||
@ColorInt val colorAccentDark: Int
|
||||
@ColorInt val cardBackgroundColor: Int
|
||||
@ColorInt val colorBackground: Int
|
||||
@ColorInt val textColor: Int
|
||||
val isDarkTheme: Boolean
|
||||
|
||||
init {
|
||||
@ -57,6 +58,12 @@ class AppColors(a: Activity) {
|
||||
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 method = wrapper!!.getMethod("getThemeResId")
|
||||
method.isAccessible = true
|
||||
|
@ -11,19 +11,19 @@ class Config(c: Context) {
|
||||
val settings: SharedPreferences = c.getSharedPreferences(settingsName, Context.MODE_PRIVATE)
|
||||
|
||||
val baseUrl: String
|
||||
get() = settings.getString("url", "")
|
||||
get() = settings.getString("url", "")!!
|
||||
|
||||
val userLogin: String
|
||||
get() = settings.getString("login", "")
|
||||
get() = settings.getString("login", "")!!
|
||||
|
||||
val userPassword: String
|
||||
get() = settings.getString("password", "")
|
||||
get() = settings.getString("password", "")!!
|
||||
|
||||
val httpUserLogin: String
|
||||
get() = settings.getString("httpUserName", "")
|
||||
get() = settings.getString("httpUserName", "")!!
|
||||
|
||||
val httpUserPassword: String
|
||||
get() = settings.getString("httpPassword", "")
|
||||
get() = settings.getString("httpPassword", "")!!
|
||||
|
||||
companion object {
|
||||
const val settingsName = "paramsselfoss"
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
buildscript {
|
||||
ext {
|
||||
kotlin_version = '1.3.31'
|
||||
kotlin_version = '1.4.21'
|
||||
android_version = '1.0.0'
|
||||
androidx_version = '1.1.0-alpha05'
|
||||
lifecycle_version = '2.2.0-alpha01'
|
||||
|
Loading…
Reference in New Issue
Block a user