Compare commits

..

11 Commits

Author SHA1 Message Date
9b45365441 Changelog. Previous commit should close #238. 2018-11-11 12:25:45 +01:00
91a7464bce Added experimental settings with a custom timeout setting. 2018-11-11 12:23:59 +01:00
51add226eb New Crowdin translations (#241)
* New translations strings.xml (Spanish)

* New translations strings.xml (Galician)
2018-11-08 08:59:37 +01:00
332e9f5108 New Crowdin translations (#240)
* New translations strings.xml (Catalan)

* New translations strings.xml (Japanese)

* New translations strings.xml (Vietnamese)

* New translations strings.xml (Ukrainian)

* New translations strings.xml (Turkish)

* New translations strings.xml (Swedish)

* New translations strings.xml (Spanish)

* New translations strings.xml (Serbian (Cyrillic))

* New translations strings.xml (Russian)

* New translations strings.xml (Romanian)

* New translations strings.xml (Portuguese, Brazilian)

* New translations strings.xml (Portuguese)

* New translations strings.xml (Polish)

* New translations strings.xml (Norwegian)

* New translations strings.xml (Korean)

* New translations strings.xml (Italian)

* New translations strings.xml (Afrikaans)

* New translations strings.xml (Indonesian)

* New translations strings.xml (Hungarian)

* New translations strings.xml (Hebrew)

* New translations strings.xml (Greek)

* New translations strings.xml (German)

* New translations strings.xml (French)

* New translations strings.xml (Finnish)

* New translations strings.xml (Dutch)

* New translations strings.xml (Danish)

* New translations strings.xml (Czech)

* New translations strings.xml (Chinese Traditional)

* New translations strings.xml (Chinese Simplified)

* New translations strings.xml (Arabic)

* New translations strings.xml (Galician)

* New translations strings.xml (French)
2018-11-07 21:25:14 +01:00
0b91087c07 CHANGELOG. 2018-11-07 21:22:19 +01:00
ebbb1ba0f8 Closes #220. 2018-11-07 21:22:06 +01:00
e9143ae852 Initial changes for #238. 2018-11-07 21:07:29 +01:00
42e8ecee78 Offline shortcut. 2018-11-07 21:05:23 +01:00
4efd76fcbc Tab selection from app shortcut. 2018-11-07 20:45:51 +01:00
fb1614070e Inital app shortcuts. 2018-11-07 20:25:48 +01:00
c473dd7227 Fixes #239. 2018-11-07 19:32:10 +01:00
54 changed files with 220 additions and 35 deletions

View File

@ -1,5 +1,11 @@
**1.7.x** **1.7.x**
- Added experimental issue to set a default timeout. Should work for #238.
- Closing #220.
- Start of #238. "Add a quick shortcut to open the app on offline mode ?"
- Closes #216. Issue with selfoss version 2.19. - Closes #216. Issue with selfoss version 2.19.
- Closes #179. Sync of read/unread/star/unstar items on background task or on app reload with network available. - Closes #179. Sync of read/unread/star/unstar items on background task or on app reload with network available.

View File

@ -75,7 +75,6 @@ android {
buildConfigField "String", "LOGIN_URL", appLoginUrl buildConfigField "String", "LOGIN_URL", appLoginUrl
buildConfigField "String", "LOGIN_USERNAME", appLoginUsername buildConfigField "String", "LOGIN_USERNAME", appLoginUsername
buildConfigField "String", "LOGIN_PASSWORD", appLoginPassword buildConfigField "String", "LOGIN_PASSWORD", appLoginPassword
applicationIdSuffix ".dev"
} }
} }
flavorDimensions "build" flavorDimensions "build"

View File

@ -21,6 +21,9 @@
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
<meta-data android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity> </activity>
<activity <activity
android:name=".LoginActivity" android:name=".LoginActivity"

View File

@ -89,6 +89,7 @@ class AddSourceActivity : AppCompatActivity() {
this, this,
this@AddSourceActivity, this@AddSourceActivity,
prefs.getBoolean("isSelfSignedCert", false), prefs.getBoolean("isSelfSignedCert", false),
prefs.getString("api_timeout", "-1").toLong(),
prefs.getBoolean("should_log_everything", false) prefs.getBoolean("should_log_everything", false)
) )
} catch (e: IllegalArgumentException) { } catch (e: IllegalArgumentException) {

View File

@ -145,6 +145,9 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
private var badgeAll: Int = -1 private var badgeAll: Int = -1
private var badgeFavs: Int = -1 private var badgeFavs: Int = -1
private var fromTabShortcut: Boolean = false
private var offlineShortcut: Boolean = false
private lateinit var tagsBadge: Map<Long, Int> private lateinit var tagsBadge: Map<Long, Int>
private lateinit var db: AppDatabase private lateinit var db: AppDatabase
@ -161,6 +164,13 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
fromTabShortcut = intent.getIntExtra("shortcutTab", -1) != -1
offlineShortcut = intent.getBooleanExtra("startOffline", false)
if (fromTabShortcut) {
elementsShown = intent.getIntExtra("shortcutTab", UNREAD_SHOWN)
}
setContentView(R.layout.activity_home) setContentView(R.layout.activity_home)
handleThemeBinding() handleThemeBinding()
@ -185,6 +195,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(),
shouldLogEverything shouldLogEverything
) )
items = ArrayList() items = ArrayList()
@ -203,6 +214,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
R.color.refresh_progress_3 R.color.refresh_progress_3
) )
swipeRefreshLayout.setOnRefreshListener { swipeRefreshLayout.setOnRefreshListener {
offlineShortcut = false
allItems = ArrayList() allItems = ArrayList()
lastFetchDone = false lastFetchDone = false
handleDrawerItems() handleDrawerItems()
@ -318,6 +330,10 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
bottomBar.setMode(BottomNavigationBar.MODE_SHIFTING) bottomBar.setMode(BottomNavigationBar.MODE_SHIFTING)
bottomBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_STATIC) bottomBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_STATIC)
if (fromTabShortcut) {
bottomBar.selectTab(elementsShown - 1)
}
} }
override fun onResume() { override fun onResume() {
@ -628,14 +644,6 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
false false
} }
) )
drawer.addItem(DividerDrawerItem())
drawer.addItem(
SecondaryDrawerItem()
.withName(getString(R.string.drawer_item_tags))
.withIdentifier(DRAWER_ID_TAGS)
.withSelectable(false)
)
handleTags(maybeDrawerData.tags)
if (hiddenTags.isNotEmpty()) { if (hiddenTags.isNotEmpty()) {
drawer.addItem(DividerDrawerItem()) drawer.addItem(DividerDrawerItem())
drawer.addItem( drawer.addItem(
@ -647,6 +655,14 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
handleHiddenTags(maybeDrawerData.tags) handleHiddenTags(maybeDrawerData.tags)
} }
drawer.addItem(DividerDrawerItem()) drawer.addItem(DividerDrawerItem())
drawer.addItem(
SecondaryDrawerItem()
.withName(getString(R.string.drawer_item_tags))
.withIdentifier(DRAWER_ID_TAGS)
.withSelectable(false)
)
handleTags(maybeDrawerData.tags)
drawer.addItem(DividerDrawerItem())
drawer.addItem( drawer.addItem(
SecondaryDrawerItem() SecondaryDrawerItem()
.withName(getString(R.string.drawer_item_sources)) .withName(getString(R.string.drawer_item_sources))
@ -721,7 +737,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
var sources: List<Source>? var sources: List<Source>?
fun sourcesApiCall() { fun sourcesApiCall() {
if (this@HomeActivity.isNetworkAccessible(null)) { if (this@HomeActivity.isNetworkAccessible(null, offlineShortcut)) {
api.sources.enqueue(object : Callback<List<Source>> { api.sources.enqueue(object : Callback<List<Source>> {
override fun onResponse( override fun onResponse(
call: Call<List<Source>>?, call: Call<List<Source>>?,
@ -744,7 +760,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
} }
} }
if (this@HomeActivity.isNetworkAccessible(null)) { if (this@HomeActivity.isNetworkAccessible(null, offlineShortcut)) {
api.tags.enqueue(object : Callback<List<Tag>> { api.tags.enqueue(object : Callback<List<Tag>> {
override fun onResponse( override fun onResponse(
call: Call<List<Tag>>, call: Call<List<Tag>>,
@ -875,7 +891,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
else -> Unit else -> Unit
} }
} else { } else {
if (this@HomeActivity.isNetworkAccessible(this@HomeActivity.findViewById(R.id.coordLayout))) { if (this@HomeActivity.isNetworkAccessible(this@HomeActivity.findViewById(R.id.coordLayout), offlineShortcut)) {
when (position) { when (position) {
0 -> getUnRead() 0 -> getUnRead()
1 -> getRead() 1 -> getRead()
@ -972,7 +988,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
handleListResult() handleListResult()
doGetAccordingToTab() doGetAccordingToTab()
} else { } else {
if (this@HomeActivity.isNetworkAccessible(this@HomeActivity.findViewById(R.id.coordLayout))) { if (this@HomeActivity.isNetworkAccessible(this@HomeActivity.findViewById(R.id.coordLayout), offlineShortcut)) {
doGetAccordingToTab() doGetAccordingToTab()
getAndStoreAllItems() getAndStoreAllItems()
} }
@ -1031,7 +1047,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
swipeRefreshLayout.post { swipeRefreshLayout.isRefreshing = true } swipeRefreshLayout.post { swipeRefreshLayout.isRefreshing = true }
} }
if (this@HomeActivity.isNetworkAccessible(this@HomeActivity.findViewById(R.id.coordLayout))) { if (this@HomeActivity.isNetworkAccessible(this@HomeActivity.findViewById(R.id.coordLayout), offlineShortcut)) {
call(maybeTagFilter?.tag, maybeSourceFilter?.id?.toLong(), maybeSearchFilter) call(maybeTagFilter?.tag, maybeSourceFilter?.id?.toLong(), maybeSearchFilter)
.enqueue(object : Callback<List<Item>> { .enqueue(object : Callback<List<Item>> {
override fun onResponse( override fun onResponse(
@ -1161,7 +1177,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
} }
private fun reloadBadges() { private fun reloadBadges() {
if (this@HomeActivity.isNetworkAccessible(null) && (displayUnreadCount || displayAllCount)) { if (this@HomeActivity.isNetworkAccessible(null, offlineShortcut) && (displayUnreadCount || displayAllCount)) {
api.stats.enqueue(object : Callback<Stats> { api.stats.enqueue(object : Callback<Stats> {
override fun onResponse(call: Call<Stats>, response: Response<Stats>) { override fun onResponse(call: Call<Stats>, response: Response<Stats>) {
if (response.body() != null) { if (response.body() != null) {
@ -1267,7 +1283,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) { when (item.itemId) {
R.id.refresh -> { R.id.refresh -> {
if (this@HomeActivity.isNetworkAccessible(null)) { if (this@HomeActivity.isNetworkAccessible(null, offlineShortcut)) {
needsConfirmation(R.string.menu_home_refresh, R.string.refresh_dialog_message) { 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(
@ -1311,7 +1327,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
ACRA.getErrorReporter().maybeHandleSilentException(e, this@HomeActivity) ACRA.getErrorReporter().maybeHandleSilentException(e, this@HomeActivity)
} }
if (ids.isNotEmpty() && this@HomeActivity.isNetworkAccessible(null)) { if (ids.isNotEmpty() && this@HomeActivity.isNetworkAccessible(null, offlineShortcut)) {
api.readAll(ids).enqueue(object : Callback<SuccessResponse> { api.readAll(ids).enqueue(object : Callback<SuccessResponse> {
override fun onResponse( override fun onResponse(
call: Call<SuccessResponse>, call: Call<SuccessResponse>,
@ -1455,7 +1471,7 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
}) })
} }
if (this@HomeActivity.isNetworkAccessible(null)) { if (this@HomeActivity.isNetworkAccessible(null, offlineShortcut)) {
thread { thread {
val actions = db.actionsDao().actions() val actions = db.actionsDao().actions()

View File

@ -195,6 +195,7 @@ class LoginActivity : AppCompatActivity() {
this, this,
this@LoginActivity, this@LoginActivity,
isWithSelfSignedCert, isWithSelfSignedCert,
-1L,
isWithSelfSignedCert isWithSelfSignedCert
) )

View File

@ -95,6 +95,7 @@ class ReaderActivity : AppCompatActivity() {
this, this,
this@ReaderActivity, this@ReaderActivity,
prefs.getBoolean("isSelfSignedCert", false), prefs.getBoolean("isSelfSignedCert", false),
prefs.getString("api_timeout", "-1").toLong(),
prefs.getBoolean("should_log_everything", false) prefs.getBoolean("should_log_everything", false)
) )

View File

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

View File

@ -18,11 +18,13 @@ import retrofit2.Call
import retrofit2.Retrofit import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory import retrofit2.converter.gson.GsonConverterFactory
import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.TimeUnit
class SelfossApi( class SelfossApi(
c: Context, c: Context,
callingActivity: Activity?, callingActivity: Activity?,
isWithSelfSignedCert: Boolean, isWithSelfSignedCert: Boolean,
timeout: Long,
shouldLog: Boolean shouldLog: Boolean
) { ) {
@ -38,16 +40,25 @@ class SelfossApi(
this this
} }
fun OkHttpClient.Builder.maybeWithSettingsTimeout(timeout: Long): OkHttpClient.Builder =
if (timeout != -1L) {
this.readTimeout(timeout, TimeUnit.SECONDS)
.connectTimeout(timeout, TimeUnit.SECONDS)
} else {
this
}
fun Credentials.createAuthenticator(): DispatchingAuthenticator = fun Credentials.createAuthenticator(): DispatchingAuthenticator =
DispatchingAuthenticator.Builder() DispatchingAuthenticator.Builder()
.with("digest", DigestAuthenticator(this)) .with("digest", DigestAuthenticator(this))
.with("basic", BasicAuthenticator(this)) .with("basic", BasicAuthenticator(this))
.build() .build()
fun DispatchingAuthenticator.getHttpClien(isWithSelfSignedCert: Boolean): OkHttpClient.Builder { fun DispatchingAuthenticator.getHttpClien(isWithSelfSignedCert: Boolean, timeout: Long): OkHttpClient.Builder {
val authCache = ConcurrentHashMap<String, CachingAuthenticator>() val authCache = ConcurrentHashMap<String, CachingAuthenticator>()
return OkHttpClient return OkHttpClient
.Builder() .Builder()
.maybeWithSettingsTimeout(timeout)
.maybeWithSelfSigned(isWithSelfSignedCert) .maybeWithSelfSigned(isWithSelfSignedCert)
.authenticator(CachingAuthenticatorDecorator(this, authCache)) .authenticator(CachingAuthenticatorDecorator(this, authCache))
.addInterceptor(AuthenticationCacheInterceptor(authCache)) .addInterceptor(AuthenticationCacheInterceptor(authCache))
@ -78,7 +89,7 @@ class SelfossApi(
HttpLoggingInterceptor.Level.NONE HttpLoggingInterceptor.Level.NONE
} }
val httpClient = authenticator.getHttpClien(isWithSelfSignedCert) val httpClient = authenticator.getHttpClien(isWithSelfSignedCert, timeout)
httpClient.addInterceptor(logging) httpClient.addInterceptor(logging)

View File

@ -1,7 +1,9 @@
package apps.amine.bou.readerforselfoss.background package apps.amine.bou.readerforselfoss.background
import android.app.NotificationManager import android.app.NotificationManager
import android.app.PendingIntent
import android.content.Context import android.content.Context
import android.content.Intent
import android.preference.PreferenceManager import android.preference.PreferenceManager
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationCompat.PRIORITY_DEFAULT import androidx.core.app.NotificationCompat.PRIORITY_DEFAULT
@ -9,6 +11,7 @@ import androidx.core.app.NotificationCompat.PRIORITY_LOW
import androidx.room.Room import androidx.room.Room
import androidx.work.Worker import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import apps.amine.bou.readerforselfoss.MainActivity
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
@ -50,7 +53,6 @@ class LoadingWorker(val context: Context, params: WorkerParameters) : Worker(con
val settings = val settings =
this.context.getSharedPreferences(Config.settingsName, Context.MODE_PRIVATE) this.context.getSharedPreferences(Config.settingsName, Context.MODE_PRIVATE)
val sharedPref = PreferenceManager.getDefaultSharedPreferences(this.context) val sharedPref = PreferenceManager.getDefaultSharedPreferences(this.context)
val shouldLogEverything = sharedPref.getBoolean("should_log_everything", false)
val notifyNewItems = sharedPref.getBoolean("notify_new_items", false) val notifyNewItems = sharedPref.getBoolean("notify_new_items", false)
db = Room.databaseBuilder( db = Room.databaseBuilder(
@ -62,7 +64,8 @@ class LoadingWorker(val context: Context, params: WorkerParameters) : Worker(con
this.context, this.context,
null, null,
settings.getBoolean("isSelfSignedCert", false), settings.getBoolean("isSelfSignedCert", false),
shouldLogEverything sharedPref.getString("api_timeout", "-1").toLong(),
sharedPref.getBoolean("should_log_everything", false)
) )
api.allItems().enqueue(object : Callback<List<Item>> { api.allItems().enqueue(object : Callback<List<Item>> {
@ -85,11 +88,19 @@ class LoadingWorker(val context: Context, params: WorkerParameters) : Worker(con
val newSize = apiItems.filter { it.unread }.size val newSize = apiItems.filter { it.unread }.size
if (notifyNewItems && newSize > 0) { if (notifyNewItems && newSize > 0) {
val intent = Intent(context, MainActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
}
val pendingIntent: PendingIntent = PendingIntent.getActivity(context, 0, intent, 0)
val newItemsNotification = NotificationCompat.Builder(applicationContext, Config.newItemsChannelId) val newItemsNotification = NotificationCompat.Builder(applicationContext, Config.newItemsChannelId)
.setContentTitle(context.getString(R.string.new_items_notification_title)) .setContentTitle(context.getString(R.string.new_items_notification_title))
.setContentText(context.getString(R.string.new_items_notification_text, newSize)) .setContentText(context.getString(R.string.new_items_notification_text, newSize))
.setPriority(PRIORITY_DEFAULT) .setPriority(PRIORITY_DEFAULT)
.setChannelId(Config.newItemsChannelId) .setChannelId(Config.newItemsChannelId)
.setContentIntent(pendingIntent)
.setAutoCancel(true)
.setSmallIcon(R.drawable.ic_fiber_new_black_24dp) .setSmallIcon(R.drawable.ic_fiber_new_black_24dp)
Timer("", false).schedule(4000) { Timer("", false).schedule(4000) {

View File

@ -114,6 +114,7 @@ class ArticleFragment : Fragment() {
context!!, context!!,
activity!!, activity!!,
settings.getBoolean("isSelfSignedCert", false), settings.getBoolean("isSelfSignedCert", false),
prefs.getString("api_timeout", "-1").toLong(),
prefs.getBoolean("should_log_everything", false) prefs.getBoolean("should_log_everything", false)
) )

View File

@ -136,6 +136,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
|| GeneralPreferenceFragment.class.getName().equals(fragmentName) || GeneralPreferenceFragment.class.getName().equals(fragmentName)
|| ArticleViewerPreferenceFragment.class.getName().equals(fragmentName) || ArticleViewerPreferenceFragment.class.getName().equals(fragmentName)
|| OfflinePreferenceFragment.class.getName().equals(fragmentName) || OfflinePreferenceFragment.class.getName().equals(fragmentName)
|| ExperimentalPreferenceFragment.class.getName().equals(fragmentName)
|| DebugPreferenceFragment.class.getName().equals(fragmentName) || DebugPreferenceFragment.class.getName().equals(fragmentName)
|| LinksPreferenceFragment.class.getName().equals(fragmentName) || LinksPreferenceFragment.class.getName().equals(fragmentName)
|| ThemePreferenceFragment.class.getName().equals(fragmentName); || ThemePreferenceFragment.class.getName().equals(fragmentName);
@ -384,6 +385,26 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
} }
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static class ExperimentalPreferenceFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.pref_experimental);
setHasOptionsMenu(true);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == android.R.id.home) {
getActivity().finish();
return true;
}
return super.onOptionsItemSelected(item);
}
}
@Override @Override
public boolean onOptionsItemSelected(MenuItem item) { public boolean onOptionsItemSelected(MenuItem item) {

View File

@ -11,15 +11,16 @@ import com.google.android.material.snackbar.Snackbar
var snackBarShown = false var snackBarShown = false
var view: View? = null var view: View? = null
lateinit var s: Snackbar
fun Context.isNetworkAccessible(v: View?): Boolean { fun Context.isNetworkAccessible(v: View?, overrideOffline: Boolean = false): Boolean {
val cm = this.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager val cm = this.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val activeNetwork: NetworkInfo? = cm.activeNetworkInfo val activeNetwork: NetworkInfo? = cm.activeNetworkInfo
val networkIsAccessible = activeNetwork != null && activeNetwork.isConnectedOrConnecting val networkIsAccessible = activeNetwork != null && activeNetwork.isConnectedOrConnecting
if (v != null && !networkIsAccessible && (!snackBarShown || v != view)) { if (v != null && (!networkIsAccessible || overrideOffline) && (!snackBarShown || v != view)) {
view = v view = v
val s = Snackbar s = Snackbar
.make( .make(
v, v,
R.string.no_network_connectivity, R.string.no_network_connectivity,
@ -37,5 +38,8 @@ fun Context.isNetworkAccessible(v: View?): Boolean {
s.show() s.show()
snackBarShown = true snackBarShown = true
} }
return networkIsAccessible if (snackBarShown && networkIsAccessible && !overrideOffline) {
s.dismiss()
}
return if(overrideOffline) overrideOffline else networkIsAccessible
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 683 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 409 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 871 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -161,8 +161,9 @@
<string name="loading_notification_title">Cargando...</string> <string name="loading_notification_title">Cargando...</string>
<string name="loading_notification_text">Selfoss está sincronizando tus artículos</string> <string name="loading_notification_text">Selfoss está sincronizando tus artículos</string>
<string name="notification_channel_sync">Notificación de sincronización</string> <string name="notification_channel_sync">Notificación de sincronización</string>
<string name="new_items_channel_sync">New items notification</string> <string name="new_items_channel_sync">Notificación de elementos nuevos</string>
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">¡Nuevos artículos!</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d artículos cargados.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notificarme cuando se sincronicen nuevos artículos.</string>
<string name="shortcut_offline">Sin conexión</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">Nouveaux articles !</string> <string name="new_items_notification_title">Nouveaux articles !</string>
<string name="new_items_notification_text">%1$d nouveaux articles synchronisés.</string> <string name="new_items_notification_text">%1$d nouveaux articles synchronisés.</string>
<string name="pref_switch_notify_new_items">Notification quand des nouveaux articles sont synchronisés.</string> <string name="pref_switch_notify_new_items">Notification quand des nouveaux articles sont synchronisés.</string>
<string name="shortcut_offline">Hors ligne</string>
</resources> </resources>

View File

@ -161,8 +161,9 @@
<string name="loading_notification_title">Cargando...</string> <string name="loading_notification_title">Cargando...</string>
<string name="loading_notification_text">Selfoss está sincronizando os teus ar tigos</string> <string name="loading_notification_text">Selfoss está sincronizando os teus ar tigos</string>
<string name="notification_channel_sync">Notificación de sincronización</string> <string name="notification_channel_sync">Notificación de sincronización</string>
<string name="new_items_channel_sync">New items notification</string> <string name="new_items_channel_sync">Notificación de actualizacións</string>
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">Novo(s) elemento(s)!</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d novos elementos cargados.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notificarme cando se sincronicen novos elementos.</string>
<string name="shortcut_offline">Sen conexión</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,5 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
</resources> </resources>

View File

@ -165,4 +165,7 @@
<string name="new_items_notification_title">New items !</string> <string name="new_items_notification_title">New items !</string>
<string name="new_items_notification_text">%1$d new items loaded.</string> <string name="new_items_notification_text">%1$d new items loaded.</string>
<string name="pref_switch_notify_new_items">Notify on new items synced.</string> <string name="pref_switch_notify_new_items">Notify on new items synced.</string>
<string name="shortcut_offline">Offline</string>
<string name="pref_api_timeout">Api Timeout</string>
<string name="pref_header_experimental">Experimental</string>
</resources> </resources>

View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:shortcutId="new"
android:enabled="true"
android:icon="@drawable/ic_fiber_new_black_24dp"
android:shortcutShortLabel="@string/tab_new">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="apps.amine.bou.readerforselfoss"
android:targetClass="apps.amine.bou.readerforselfoss.HomeActivity">
<extra
android:name="shortcutTab"
android:value="1" />
</intent>
</shortcut>
<shortcut
android:shortcutId="read"
android:enabled="true"
android:icon="@drawable/ic_archive_black_24dp"
android:shortcutShortLabel="@string/tab_read">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="apps.amine.bou.readerforselfoss"
android:targetClass="apps.amine.bou.readerforselfoss.HomeActivity">
<extra
android:name="shortcutTab"
android:value="2" />
</intent>
</shortcut>
<shortcut
android:shortcutId="favs"
android:enabled="true"
android:icon="@drawable/ic_favorite_black_24dp"
android:shortcutShortLabel="@string/tab_favs">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="apps.amine.bou.readerforselfoss"
android:targetClass="apps.amine.bou.readerforselfoss.HomeActivity">
<extra
android:name="shortcutTab"
android:value="3" />
</intent>
</shortcut>
<shortcut
android:shortcutId="offline"
android:enabled="true"
android:icon="@drawable/ic_signal_wifi_statusbar_not_connected"
android:shortcutShortLabel="@string/shortcut_offline">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="apps.amine.bou.readerforselfoss"
android:targetClass="apps.amine.bou.readerforselfoss.HomeActivity">
<extra
android:name="startOffline"
android:value="true" />
</intent>
</shortcut>
</shortcuts>

View File

@ -0,0 +1,9 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<EditTextPreference
android:inputType="number"
android:key="api_timeout"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/pref_api_timeout" />
</PreferenceScreen>

View File

@ -32,4 +32,9 @@
android:icon="@drawable/ic_info_black_24" android:icon="@drawable/ic_info_black_24"
android:title="@string/pref_header_links"/> android:title="@string/pref_header_links"/>
<header
android:fragment="apps.amine.bou.readerforselfoss.settings.SettingsActivity$ExperimentalPreferenceFragment"
android:icon="@drawable/ic_action_lab"
android:title="@string/pref_header_experimental"/>
</preference-headers> </preference-headers>

View File

@ -5,7 +5,9 @@ TODAYS_VERSION="1"
VERSION="${BASE_VERSION//./}$(date '+%y%m%j')$TODAYS_VERSION" VERSION="${BASE_VERSION//./}$(date '+%y%m%j')$TODAYS_VERSION"
./version.sh ${VERSION} $1 PARAMS_EXCEPT_PUBLISH=$(echo $1 | sed 's/\-\-publish//')
./version.sh ${VERSION} ${PARAMS_EXCEPT_PUBLISH}
if [[ "$@" == *'--publish'* ]] if [[ "$@" == *'--publish'* ]]
then then