* Some more bug fixes.

* Cleaning travis file.

* Fixes #51
This commit is contained in:
Amine Bou 2017-07-22 13:12:13 +02:00 committed by GitHub
parent 4924ddd172
commit 69a2418afc
9 changed files with 44 additions and 30 deletions

View File

@ -28,15 +28,6 @@ android:
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'
#install:
# - echo y | android update sdk --no-ui --filter "android-26,build-tools-26.0.0"
# - echo y | android update sdk --no-ui --all --filter "platform-tools, tools"
# - echo y | android update sdk --no-ui --all --filter "android-26, build-tools-26.0.0"
# - echo y | android update sdk --no-ui --all --filter "extra-android-m2repository"
# - echo y | android update sdk --no-ui --all --filter "extra-android-support"
# - echo y | android update sdk --no-ui --all --filter "extra-google-m2repository"
# - echo y | android update sdk --no-ui --all --filter "extra-google-google_play_services"
before_script:
- mkdir app/src/main/res/mipmap-hdpi
- convert -size 72x72 xc:white app/src/main/res/mipmap-hdpi/ic_launcher.png

View File

@ -16,7 +16,7 @@ import apps.amine.bou.readerforselfoss.api.selfoss.SelfossApi
import apps.amine.bou.readerforselfoss.api.selfoss.Spout
import apps.amine.bou.readerforselfoss.api.selfoss.SuccessResponse
import apps.amine.bou.readerforselfoss.utils.Config
import apps.amine.bou.readerforselfoss.utils.isUrlValid
import apps.amine.bou.readerforselfoss.utils.isBaseUrlValid
import com.ftinc.scoop.Scoop
@ -73,7 +73,7 @@ class AddSourceActivity : AppCompatActivity() {
val config = Config(this)
if (config.baseUrl.isEmpty() || !config.baseUrl.isUrlValid()) {
if (config.baseUrl.isEmpty() || !config.baseUrl.isBaseUrlValid()) {
mustLoginToAddSource()
} else {

View File

@ -185,9 +185,10 @@ class HomeActivity : AppCompatActivity(), SearchView.OnQueryTextListener {
} else {
(recyclerView.adapter as ItemListAdapter).removeItemAtIndex(position)
}
if (items.size > 0)
tabNewBadge.setText("${items.size}").maybeShow()
mayBeEmpty()
else
tabNewBadge.hide()
} catch (e: IndexOutOfBoundsException) {}

View File

@ -31,7 +31,7 @@ import apps.amine.bou.readerforselfoss.api.selfoss.SelfossApi
import apps.amine.bou.readerforselfoss.api.selfoss.SuccessResponse
import apps.amine.bou.readerforselfoss.utils.Config
import apps.amine.bou.readerforselfoss.utils.checkAndDisplayStoreApk
import apps.amine.bou.readerforselfoss.utils.isUrlValid
import apps.amine.bou.readerforselfoss.utils.isBaseUrlValid
import com.ftinc.scoop.Scoop
@ -149,7 +149,7 @@ class LoginActivity : AppCompatActivity() {
var cancel = false
var focusView: View? = null
if (!url.isUrlValid()) {
if (!url.isBaseUrlValid()) {
mUrlView.error = getString(R.string.login_url_problem)
focusView = mUrlView
cancel = true

View File

@ -23,17 +23,31 @@ class MyApp : MultiDexApplication() {
if (!BuildConfig.DEBUG)
Fabric.with(this, Crashlytics())
initAmplify()
initCache()
initDrawerImageLoader()
initTheme()
}
private fun initAmplify() {
Amplify.initSharedInstance(this)
.setFeedbackEmailAddress(getString(R.string.feedback_email))
.setAlwaysShow(BuildConfig.DEBUG)
.applyAllDefaultRules()
}
private fun initCache() {
try {
Reservoir.init(this, 8192) //in bytes
} catch (e: IOException) {
//failure
}
}
private fun initDrawerImageLoader() {
DrawerImageLoader.init(object : AbstractDrawerImageLoader() {
override fun set(imageView: ImageView?, uri: Uri?, placeholder: Drawable?, tag: String?) {
Glide.with(imageView?.context).load(uri).placeholder(placeholder).into(imageView)
@ -47,6 +61,9 @@ class MyApp : MultiDexApplication() {
return baseContext.resources.getDrawable(R.mipmap.ic_launcher)
}
})
}
private fun initTheme() {
Scoop.waffleCone()
.addFlavor(getString(R.string.default_theme), R.style.NoBar, true)
.addFlavor(getString(R.string.default_dark_theme), R.style.NoBarDark)
@ -64,6 +81,5 @@ class MyApp : MultiDexApplication() {
.addFlavor(getString(R.string.red_teal_dark_theme), R.style.NoBarRedTealDark)
.setSharedPreferences(PreferenceManager.getDefaultSharedPreferences(this))
.initialize()
}
}

View File

@ -100,12 +100,13 @@ class ReaderActivity : DragDismissActivity() {
override fun onFailure(call: Call<ParsedContent>, t: Throwable) = openInBrowserAfterFailing()
private fun openInBrowserAfterFailing() {
CustomTabActivityHelper.openCustomTab(this@ReaderActivity, customTabsIntent, Uri.parse(url)
) { _, uri ->
val intent = Intent(Intent.ACTION_VIEW, uri)
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(intent)
}
this@ReaderActivity.openItemUrl(
url,
customTabsIntent,
true,
false,
this@ReaderActivity
)
finish()
}
})

View File

@ -206,7 +206,9 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
public void onHeaderClick(Header header, int position) {
super.onHeaderClick(header, position);
if (header.id == R.id.theme_change) {
getApplicationContext().startActivity(ScoopSettingsActivity.createIntent(getApplicationContext()));
Intent intent = ScoopSettingsActivity.createIntent(getApplicationContext());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplicationContext().startActivity(intent);
finish();
}
}

View File

@ -36,7 +36,10 @@ fun Context.checkAndDisplayStoreApk() = {
} else Unit
}
fun String.isUrlValid(): Boolean {
fun String.isUrlValid(): Boolean =
HttpUrl.parse(this) != null && Patterns.WEB_URL.matcher(this).matches()
fun String.isBaseUrlValid(): Boolean {
val baseUrl = HttpUrl.parse(this)
var existsAndEndsWithSlash = false
if (baseUrl != null) {

View File

@ -55,7 +55,7 @@ fun Context.openItemUrl(linkDecoded: String,
internalBrowser: Boolean,
articleViewer: Boolean,
app: Activity) {
if (!internalBrowser) {
if (!internalBrowser || !linkDecoded.isUrlValid()) {
openInBrowser(linkDecoded, app)
} else {
if (articleViewer) {