Fixes #180.
This commit is contained in:
parent
403ecc4521
commit
320924b4ed
@ -117,7 +117,7 @@ dependencies {
|
|||||||
|
|
||||||
|
|
||||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
|
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||||||
|
|
||||||
// Android Support
|
// Android Support
|
||||||
compile 'com.android.support:appcompat-v7:27.0.2'
|
compile 'com.android.support:appcompat-v7:27.0.2'
|
||||||
|
@ -2,6 +2,7 @@ package apps.amine.bou.readerforselfoss
|
|||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.DialogInterface
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.SharedPreferences
|
import android.content.SharedPreferences
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
@ -10,6 +11,7 @@ import android.net.Uri
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.preference.PreferenceManager
|
import android.preference.PreferenceManager
|
||||||
import android.support.v4.view.MenuItemCompat
|
import android.support.v4.view.MenuItemCompat
|
||||||
|
import android.support.v7.app.AlertDialog
|
||||||
import android.support.v7.app.AppCompatActivity
|
import android.support.v7.app.AppCompatActivity
|
||||||
import android.support.v7.widget.DividerItemDecoration
|
import android.support.v7.widget.DividerItemDecoration
|
||||||
import android.support.v7.widget.GridLayoutManager
|
import android.support.v7.widget.GridLayoutManager
|
||||||
@ -1006,9 +1008,20 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun needsConfirmation(titleRes: Int, messageRes: Int, doFn: () -> Unit) {
|
||||||
|
AlertDialog.Builder(this@HomeActivity)
|
||||||
|
.setMessage(messageRes)
|
||||||
|
.setTitle(titleRes)
|
||||||
|
.setPositiveButton(android.R.string.ok) { _, _ -> doFn() }
|
||||||
|
.setNegativeButton(android.R.string.cancel) { _, _ -> }
|
||||||
|
.create()
|
||||||
|
.show()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
when (item.itemId) {
|
||||||
R.id.refresh -> {
|
R.id.refresh -> {
|
||||||
|
needsConfirmation(R.string.menu_home_refresh, R.string.refresh_dialog_message, {
|
||||||
api.update().enqueue(object : Callback<String> {
|
api.update().enqueue(object : Callback<String> {
|
||||||
override fun onResponse(
|
override fun onResponse(
|
||||||
call: Call<String>,
|
call: Call<String>,
|
||||||
@ -1030,10 +1043,12 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
Toast.makeText(this, R.string.refresh_in_progress, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, R.string.refresh_in_progress, Toast.LENGTH_SHORT).show()
|
||||||
|
})
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
R.id.readAll -> {
|
R.id.readAll -> {
|
||||||
if (elementsShown == UNREAD_SHOWN) {
|
if (elementsShown == UNREAD_SHOWN) {
|
||||||
|
needsConfirmation(R.string.readAll, R.string.markall_dialog_message, {
|
||||||
swipeRefreshLayout.isRefreshing = false
|
swipeRefreshLayout.isRefreshing = false
|
||||||
val ids = items.map { it.id }
|
val ids = items.map { it.id }
|
||||||
|
|
||||||
@ -1078,6 +1093,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
|
|||||||
).show()
|
).show()
|
||||||
}
|
}
|
||||||
handleListResult()
|
handleListResult()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -163,4 +163,6 @@
|
|||||||
<string name="remove_to_favs_reader">Supprimer des favoris</string>
|
<string name="remove_to_favs_reader">Supprimer des favoris</string>
|
||||||
<string name="pref_content_reader_font_size">Taille du texte du contenu du lecteur d\'articles</string>
|
<string name="pref_content_reader_font_size">Taille du texte du contenu du lecteur d\'articles</string>
|
||||||
<string name="pref_header_viewer">Lecteur d\'articles</string>
|
<string name="pref_header_viewer">Lecteur d\'articles</string>
|
||||||
|
<string name="refresh_dialog_message">En validant, votre instance Selfoss sera mise à jour.</string>
|
||||||
|
<string name="markall_dialog_message">Marquer tous les éléments comme lus ?</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -166,4 +166,6 @@
|
|||||||
<string name="remove_to_favs_reader">Remove from favorites</string>
|
<string name="remove_to_favs_reader">Remove from favorites</string>
|
||||||
<string name="pref_content_reader_font_size">Article reader content font size</string>
|
<string name="pref_content_reader_font_size">Article reader content font size</string>
|
||||||
<string name="pref_header_viewer">Article viewer</string>
|
<string name="pref_header_viewer">Article viewer</string>
|
||||||
|
<string name="refresh_dialog_message">This will refresh your Selfoss instance.</string>
|
||||||
|
<string name="markall_dialog_message">This will mark all the items as read.</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user