Compare commits

..

5 Commits

Author SHA1 Message Date
9e0fdf30ec Prevent Glide from opening svg images 2021-01-09 23:43:31 +01:00
0d84a2d7e9 Update to support rebase 2021-01-09 23:41:57 +01:00
41c14362a8 Fixes #323. 2021-01-09 15:01:59 +01:00
6fa8c901fc Decode the title of sources containing special html characters (#326)
#325
2021-01-07 21:22:01 +01:00
db124ab9de Changelog. 2020-12-24 13:49:32 +01:00
22 changed files with 131 additions and 82 deletions

View File

@ -26,6 +26,16 @@
- Closing #38. Only doing api calls on network available.
- Closing #298 and #287. Issues with Listview rendering
- Closing #290. Fixing back button issue in Settings
- Closing #300. Fixing issues when displaying some special characters.
- Closing #310. Some feeds don't have icons nor thumbnails.
- Closing #178. Expending images on tap.
**1.6.x**
- Handling hidden tags.

View File

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

View File

@ -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()

View File

@ -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
@ -604,7 +604,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
} else {
for (tag in maybeSources) {
val item = PrimaryDrawerItem()
.withName(tag.title)
.withName(tag.getTitleDecoded())
.withIdentifier(tag.id.toLong())
.withOnDrawerItemClickListener { _, _, _ ->
allItems = ArrayList()
@ -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)

View File

@ -21,7 +21,7 @@ class ImageActivity : AppCompatActivity() {
supportActionBar?.setDisplayShowTitleEnabled(false)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
allImages = intent.getStringArrayListExtra("allImages")
allImages = intent.getStringArrayListExtra("allImages") as ArrayList<String>
position = intent.getIntExtra("position", 0)
pager.adapter = ScreenSlidePagerAdapter(supportFragmentManager)

View File

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

View File

@ -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()

View File

@ -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()) {

View File

@ -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()

View File

@ -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
@ -90,13 +104,13 @@ class ItemCardAdapter(
}
if (itm.getIcon(c).isEmpty()) {
val color = generator.getColor(itm.sourcetitle)
val color = generator.getColor(itm.getSourceTitle())
val drawable =
TextDrawable
.builder()
.round()
.build(itm.sourcetitle.toTextDrawableString(c), color)
.build(itm.getSourceTitle().toTextDrawableString(c), color)
holder.mView.sourceImage.setImageDrawable(drawable)
} else {
c.circularBitmapDrawable(config, itm.getIcon(c), holder.mView.sourceImage)

View File

@ -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,22 +73,32 @@ 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()) {
val color = generator.getColor(itm.sourcetitle)
val color = generator.getColor(itm.getSourceTitle())
val drawable =
TextDrawable
.builder()
.round()
.build(itm.sourcetitle.toTextDrawableString(c), color)
.build(itm.getSourceTitle().toTextDrawableString(c), color)
holder.mView.itemImage.setImageDrawable(drawable)
} else {

View File

@ -46,19 +46,19 @@ class SourcesListAdapter(
config = Config(c)
if (itm.getIcon(c).isEmpty()) {
val color = generator.getColor(itm.title)
val color = generator.getColor(itm.getTitleDecoded())
val drawable =
TextDrawable
.builder()
.round()
.build(itm.title.toTextDrawableString(c), color)
.build(itm.getTitleDecoded().toTextDrawableString(c), color)
holder.mView.itemImage.setImageDrawable(drawable)
} else {
c.circularBitmapDrawable(config, itm.getIcon(c), holder.mView.itemImage)
}
holder.mView.sourceTitle.text = itm.title
holder.mView.sourceTitle.text = itm.getTitleDecoded()
}
override fun getItemCount(): Int = items.size

View File

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

View File

@ -64,6 +64,10 @@ data class Source(
}
return constructUrl(config, "favicons", icon)
}
fun getTitleDecoded(): String {
return Html.fromHtml(title).toString()
}
}
data class Item(
@ -90,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
@ -137,7 +141,14 @@ data class Item(
var allImages = ArrayList<String>()
for ( image in Jsoup.parse(content).getElementsByTag("img")) {
allImages.add(image.attr("src"))
val url = image.attr("src")
if (url.toLowerCase().contains(".jpg") ||
url.toLowerCase().contains(".jpeg") ||
url.toLowerCase().contains(".png") ||
url.toLowerCase().contains(".webp"))
{
allImages.add(url)
}
}
return allImages
}
@ -167,6 +178,10 @@ data class Item(
return Html.fromHtml(title).toString()
}
fun getSourceTitle(): String {
return Html.fromHtml(sourcetitle).toString()
}
// TODO: maybe find a better way to handle these kind of urls
fun getLinkDecoded(): String {
var stringUrl: String
@ -208,7 +223,7 @@ data class SelfossTagType(val tags: String) : Parcelable {
}
constructor(source: Parcel) : this(
tags = source.readString()
tags = source.readString().orEmpty()
)
override fun describeContents() = 0

View File

@ -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>> {

View File

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

View File

@ -17,7 +17,7 @@ class ImageFragment : Fragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
imageUrl = arguments!!.getString("imageUrl")
imageUrl = requireArguments().getString("imageUrl")!!
}
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 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

View File

@ -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"

View File

@ -32,7 +32,7 @@ fun Item.sourceAndDateText(): String {
""
}
return this.sourcetitle + formattedDate
return this.getSourceTitle() + formattedDate
}
fun Item.toggleStar(): Item {

View File

@ -28,7 +28,7 @@ fun SourceEntity.toView(): Source =
fun Source.toEntity(): SourceEntity =
SourceEntity(
this.id,
this.title,
this.getTitleDecoded(),
this.tags.tags,
this.spout,
this.error,
@ -68,6 +68,6 @@ fun Item.toEntity(): ItemEntity =
this.thumbnail,
this.icon,
this.link,
this.sourcetitle,
this.getSourceTitle(),
this.tags.tags
)

View File

@ -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'