diff --git a/.idea/misc.xml b/.idea/misc.xml
index 8794001..840032b 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,7 +3,7 @@
-
+
diff --git a/AndroidRivers.iml b/AndroidRivers.iml
index c53b6c0..125ebb3 100644
--- a/AndroidRivers.iml
+++ b/AndroidRivers.iml
@@ -2,7 +2,9 @@
-
+
+
+
@@ -11,7 +13,7 @@
-
+
diff --git a/HoloEverywhere-master/addons/preferences/preferences.iml b/HoloEverywhere-master/addons/preferences/preferences.iml
index 33e2320..3fe5507 100644
--- a/HoloEverywhere-master/addons/preferences/preferences.iml
+++ b/HoloEverywhere-master/addons/preferences/preferences.iml
@@ -4,6 +4,7 @@
+
@@ -13,7 +14,7 @@
-
+
diff --git a/HoloEverywhere-master/addons/preferences/project.properties b/HoloEverywhere-master/addons/preferences/project.properties
index 9471d3f..dcc6dd2 100644
--- a/HoloEverywhere-master/addons/preferences/project.properties
+++ b/HoloEverywhere-master/addons/preferences/project.properties
@@ -11,7 +11,7 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
-target=android-16
+target=android-17
android.library=true
android.library.reference.1=../../library
android.library.reference.2=../../contrib/ActionBarSherlock
diff --git a/HoloEverywhere-master/addons/slidingmenu/project.properties b/HoloEverywhere-master/addons/slidingmenu/project.properties
index f530560..0caf902 100644
--- a/HoloEverywhere-master/addons/slidingmenu/project.properties
+++ b/HoloEverywhere-master/addons/slidingmenu/project.properties
@@ -9,6 +9,6 @@
android.library=true
# Project target.
-target=android-16
+target=android-17
android.library.reference.1=../../library
android.library.reference.2=../../contrib/ActionBarSherlock
diff --git a/HoloEverywhere-master/addons/slidingmenu/slidingmenu.iml b/HoloEverywhere-master/addons/slidingmenu/slidingmenu.iml
index 33e2320..3fe5507 100644
--- a/HoloEverywhere-master/addons/slidingmenu/slidingmenu.iml
+++ b/HoloEverywhere-master/addons/slidingmenu/slidingmenu.iml
@@ -4,6 +4,7 @@
+
@@ -13,7 +14,7 @@
-
+
diff --git a/HoloEverywhere-master/contrib/ActionBarSherlock/ActionBarSherlock.iml b/HoloEverywhere-master/contrib/ActionBarSherlock/ActionBarSherlock.iml
index dbdb581..dbfeabb 100644
--- a/HoloEverywhere-master/contrib/ActionBarSherlock/ActionBarSherlock.iml
+++ b/HoloEverywhere-master/contrib/ActionBarSherlock/ActionBarSherlock.iml
@@ -4,6 +4,7 @@
+
@@ -14,7 +15,7 @@
-
+
diff --git a/HoloEverywhere-master/contrib/ActionBarSherlock/project.properties b/HoloEverywhere-master/contrib/ActionBarSherlock/project.properties
index 616f300..0e58ae1 100644
--- a/HoloEverywhere-master/contrib/ActionBarSherlock/project.properties
+++ b/HoloEverywhere-master/contrib/ActionBarSherlock/project.properties
@@ -9,4 +9,4 @@
android.library=true
# Project target.
-target=android-16
+target=android-17
diff --git a/HoloEverywhere-master/library/library.iml b/HoloEverywhere-master/library/library.iml
index 8617842..64e51bc 100644
--- a/HoloEverywhere-master/library/library.iml
+++ b/HoloEverywhere-master/library/library.iml
@@ -4,6 +4,7 @@
+
@@ -13,7 +14,7 @@
-
+
diff --git a/HoloEverywhere-master/library/project.properties b/HoloEverywhere-master/library/project.properties
index 23b8a45..741a743 100644
--- a/HoloEverywhere-master/library/project.properties
+++ b/HoloEverywhere-master/library/project.properties
@@ -8,7 +8,7 @@
# project structure.
# Project target.
-target=android-16
+target=android-17
android.library=true
android.library.reference.1=../contrib/ActionBarSherlock
diff --git a/NewsEngine/NewsEngine.iml b/NewsEngine/NewsEngine.iml
index 802296d..5b9fffc 100644
--- a/NewsEngine/NewsEngine.iml
+++ b/NewsEngine/NewsEngine.iml
@@ -4,6 +4,7 @@
+
@@ -13,7 +14,7 @@
-
+
diff --git a/NewsEngine/project.properties b/NewsEngine/project.properties
index b2ed0b0..4a46b9d 100644
--- a/NewsEngine/project.properties
+++ b/NewsEngine/project.properties
@@ -12,4 +12,4 @@
android.library=true
# Project target.
-target=android-16
+target=android-17
diff --git a/README.md b/README.md
index 7254e6b..4be6f23 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,10 @@ The mailing list for this project is at groups.google.com/group/news-and-protoco
This code is licensed under GPL version 3. Please read license.txt.
-I develop Android Rivers using Kotlin programming language
+I develop Android Rivers using Kotlin programming language. It might not be
+obvious that this is Kotlin project since there are a lot of Java code in the project. Most of these Java code are open source
+libraries that Android Rivers include in source form by necessity. Most of the Kotlin code is located at NewsEngine module and
+com.silverkeytech.android_rivers package at the main project.
By reading Android Rivers source code, you will learn about:
diff --git a/lib/kotlin-runtime.jar b/lib/kotlin-runtime.jar
index 2621bef..339f42c 100644
Binary files a/lib/kotlin-runtime.jar and b/lib/kotlin-runtime.jar differ
diff --git a/project.properties b/project.properties
index c00bf08..e888255 100644
--- a/project.properties
+++ b/project.properties
@@ -11,7 +11,7 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
-target=android-16
+target=android-17
android.library.reference.1=HoloEverywhere-master/contrib/ActionBarSherlock
android.library.reference.2=HoloEverywhere-master/library
android.library.reference.3=HoloEverywhere-master/addons/preferences
diff --git a/src/com/silverkeytech/android_rivers/InfinityProgressDialog.kt b/src/com/silverkeytech/android_rivers/InfinityProgressDialog.kt
index 6eb0e9c..4e66b3e 100644
--- a/src/com/silverkeytech/android_rivers/InfinityProgressDialog.kt
+++ b/src/com/silverkeytech/android_rivers/InfinityProgressDialog.kt
@@ -22,6 +22,9 @@ import android.content.Context
import android.content.DialogInterface
import org.holoeverywhere.app.ProgressDialog
+/*
+This is a progress dialog that show indeterminate progress (there is no 0..100 % progress indicator)
+ */
public class InfinityProgressDialog(ctx: Context, val message: String): ProgressDialog(ctx){
{
super.setCancelable(true)
diff --git a/src/com/silverkeytech/android_rivers/Result.kt b/src/com/silverkeytech/android_rivers/Result.kt
index 85b4da1..9cdd6f1 100644
--- a/src/com/silverkeytech/android_rivers/Result.kt
+++ b/src/com/silverkeytech/android_rivers/Result.kt
@@ -20,6 +20,10 @@ package com.silverkeytech.android_rivers
public class None(){
}
+/*
+This is a common class used to hold result of an operation. If the operation throws an exception, the exception is available
+on .exception property
+ */
public data class Result(p1: T?, p2: Exception? = null){
class object{
//return True result
diff --git a/src/com/silverkeytech/android_rivers/ScrollMotionDetector.kt b/src/com/silverkeytech/android_rivers/ScrollMotionDetector.kt
index 978a070..94cb630 100644
--- a/src/com/silverkeytech/android_rivers/ScrollMotionDetector.kt
+++ b/src/com/silverkeytech/android_rivers/ScrollMotionDetector.kt
@@ -23,6 +23,9 @@ import android.view.View
import android.view.MotionEvent
import android.util.Log
+/*
+This is a utility class to handle user scroll/swipe movement and to differentiate a click with a swipe motion
+ */
public class ScrollMotionDetector (scrollTreshold : Float = 10.0){
class object {
public val TAG: String = javaClass().getSimpleName()
diff --git a/src/com/silverkeytech/android_rivers/Texts.kt b/src/com/silverkeytech/android_rivers/Texts.kt
index a0f75de..f08a1a2 100644
--- a/src/com/silverkeytech/android_rivers/Texts.kt
+++ b/src/com/silverkeytech/android_rivers/Texts.kt
@@ -47,9 +47,7 @@ fun scrubHtml(text: String?): String {
for(i in 0..(spannedObjects.size - 1)){
if (spannedObjects[i] is ImageSpan){
val img = spannedObjects[i] as ImageSpan
- if (img != null){
- spanned.replace(spanned.getSpanStart(img), spanned.getSpanEnd(img), "")
- }
+ spanned.replace(spanned.getSpanStart(img), spanned.getSpanEnd(img), "")
}
}
diff --git a/src/com/silverkeytech/android_rivers/UrlShortener.kt b/src/com/silverkeytech/android_rivers/UrlShortener.kt
index 030b6fb..3a43925 100644
--- a/src/com/silverkeytech/android_rivers/UrlShortener.kt
+++ b/src/com/silverkeytech/android_rivers/UrlShortener.kt
@@ -21,14 +21,11 @@ package com.silverkeytech.android_rivers
import com.github.kevinsawicki.http.HttpRequest
import com.google.gson.Gson
-public class shortenData (public val longUrl: String){
-}
-
-public class shortenDataReply(public val kind: String, public val id: String, public longUrl: String){
-}
-
public fun googleShorten(url: String): Result
{
+ class shortenData (public val longUrl: String)
+ class shortenDataReply(public val kind: String, public val id: String, public longUrl: String)
+
try
{
val gson = Gson()
diff --git a/src/com/silverkeytech/android_rivers/Utils.kt b/src/com/silverkeytech/android_rivers/Utils.kt
index 8eb1241..ef6d902 100644
--- a/src/com/silverkeytech/android_rivers/Utils.kt
+++ b/src/com/silverkeytech/android_rivers/Utils.kt
@@ -167,7 +167,7 @@ fun isModernAndroid(): Boolean {
}
fun Dialog?.findView(id : Int) : T{
- return this!!.findViewById(id) as T
+ return this!!.findView(id) as T
}
fun View?.findView(id : Int) : T{
diff --git a/src/com/silverkeytech/android_rivers/activities/Activities.kt b/src/com/silverkeytech/android_rivers/activities/Activities.kt
index 63ebe09..a2effbf 100644
--- a/src/com/silverkeytech/android_rivers/activities/Activities.kt
+++ b/src/com/silverkeytech/android_rivers/activities/Activities.kt
@@ -54,7 +54,10 @@ public fun Activity.getStandardDialogBackgroundColor(): Int {
*/
}
-public fun Activity.findView(id: Int): T {
+public fun Activity?.findView(id: Int): T {
+ if (this == null)
+ throw Exception("Activity cannot be null");
+
return (this.findViewById(id) as T)
}
diff --git a/src/com/silverkeytech/android_rivers/activities/BookmarkCollectionRenderer.kt b/src/com/silverkeytech/android_rivers/activities/BookmarkCollectionRenderer.kt
index adf2b53..6fae361 100644
--- a/src/com/silverkeytech/android_rivers/activities/BookmarkCollectionRenderer.kt
+++ b/src/com/silverkeytech/android_rivers/activities/BookmarkCollectionRenderer.kt
@@ -39,6 +39,7 @@ import com.silverkeytech.android_rivers.getVisualPref
import com.silverkeytech.android_rivers.startFeedActivity
import com.silverkeytech.android_rivers.handleFontResize
import com.silverkeytech.android_rivers.createConfirmationDialog
+import com.silverkeytech.android_rivers.findView
public class BookmarkCollectionRenderer(val context: BookmarkCollectionActivity){
class object {
@@ -49,7 +50,7 @@ public class BookmarkCollectionRenderer(val context: BookmarkCollectionActivity)
val textSize = context.getVisualPref().listTextSize
if (bookmarks.count() == 0){
- var msg = context.findViewById(R.id.collection_message_tv)!! as TextView
+ var msg = context.findView(R.id.collection_message_tv)
handleFontResize(msg, context.getString(R.string.empty_bookmark_collection_items_list)!!, textSize.toFloat())
}
@@ -89,7 +90,7 @@ public class BookmarkCollectionRenderer(val context: BookmarkCollectionActivity)
if (vw == null){
vw = inflater().inflate(android.R.layout.simple_list_item_1, parent, false)
- holder = ViewHolder(vw!!.findViewById(android.R.id.text1) as TextView)
+ holder = ViewHolder(vw.findView(android.R.id.text1))
vw!!.setTag(holder)
}else{
holder = vw!!.getTag() as ViewHolder
@@ -119,7 +120,7 @@ fun showCollectionQuickActionPopup(context: BookmarkCollectionActivity, bookmark
pp.dismiss()
}
- val icon = x.findViewById(R.id.collection_quick_action_delete_icon) as ImageView
+ val icon = x.findView(R.id.collection_quick_action_delete_icon)
icon.setOnClickListener {
val dlg = createConfirmationDialog(context = context, message = "Are you sure about removing this collection bookmark?", positive = {
try{
diff --git a/src/com/silverkeytech/android_rivers/activities/RiverContentRenderer.kt b/src/com/silverkeytech/android_rivers/activities/RiverContentRenderer.kt
index 9985ab8..f773cd2 100644
--- a/src/com/silverkeytech/android_rivers/activities/RiverContentRenderer.kt
+++ b/src/com/silverkeytech/android_rivers/activities/RiverContentRenderer.kt
@@ -177,7 +177,7 @@ public class RiverContentRenderer(val context: Activity, val language: String){
body.setOnTouchListener(listener)
- var source = dlg.findViewById(R.id.news_details_source_tv)!! as TextView
+ var source = dlg.findView(R.id.news_details_source_tv)
handleForeignText(language, body, msg)
handleForeignTextStyle(context, language, body, textSize.toFloat())
handleTextColorBasedOnTheme(context, body)
diff --git a/src/com/silverkeytech/android_rivers/activities/RiverSourcesRenderer.kt b/src/com/silverkeytech/android_rivers/activities/RiverSourcesRenderer.kt
index 2312606..be87d66 100644
--- a/src/com/silverkeytech/android_rivers/activities/RiverSourcesRenderer.kt
+++ b/src/com/silverkeytech/android_rivers/activities/RiverSourcesRenderer.kt
@@ -31,6 +31,7 @@ import android.widget.TextView
import com.silverkeytech.android_rivers.getVisualPref
import com.silverkeytech.android_rivers.startFeedActivity
import com.silverkeytech.android_rivers.handleFontResize
+import com.silverkeytech.android_rivers.findView
public class RiverSourcesRenderer(val context: RiverSourcesActivity, val language: String){
class object {
@@ -68,7 +69,7 @@ public class RiverSourcesRenderer(val context: RiverSourcesActivity, val languag
if (vw == null){
vw = inflater.inflate(android.R.layout.simple_list_item_1, parent, false)
- holder = ViewHolder(vw!!.findViewById(android.R.id.text1) as TextView)
+ holder = ViewHolder(vw!!.findView(android.R.id.text1))
vw!!.setTag(holder)
}else{
holder = vw!!.getTag() as ViewHolder
diff --git a/src/com/silverkeytech/android_rivers/asyncs/DownloadImageAsync.kt b/src/com/silverkeytech/android_rivers/asyncs/DownloadImageAsync.kt
index 66bb3c9..0adfdc0 100644
--- a/src/com/silverkeytech/android_rivers/asyncs/DownloadImageAsync.kt
+++ b/src/com/silverkeytech/android_rivers/asyncs/DownloadImageAsync.kt
@@ -39,6 +39,7 @@ import com.silverkeytech.android_rivers.InfinityProgressDialog
import com.silverkeytech.android_rivers.R
import com.silverkeytech.android_rivers.generateThrowawayName
import com.silverkeytech.android_rivers.imageMimeTypeToFileExtension
+import com.silverkeytech.android_rivers.findView
public data class DownloadedFile(val contentType: String, val filePath: String)
@@ -97,7 +98,7 @@ public class DownloadImageAsync(it: Context?): AsyncTask(R.id.image_view_main_iv)
var bmp: Bitmap?
try{
diff --git a/src/com/silverkeytech/android_rivers/fragments/PodcastListFragment.kt b/src/com/silverkeytech/android_rivers/fragments/PodcastListFragment.kt
index 26fa402..120dffd 100644
--- a/src/com/silverkeytech/android_rivers/fragments/PodcastListFragment.kt
+++ b/src/com/silverkeytech/android_rivers/fragments/PodcastListFragment.kt
@@ -147,7 +147,7 @@ public class PodcastListFragment(): MainListFragment() {
}
fun showMessage(msg: String) {
- val txt = getView()!!.findViewById(R.id.podcast_list_fragment_message_tv) as TextView
+ val txt = getView()!!.findView(R.id.podcast_list_fragment_message_tv)
if (msg.isNullOrEmpty()){
txt.setVisibility(View.INVISIBLE)
txt.setText("")
@@ -176,7 +176,7 @@ public class PodcastListFragment(): MainListFragment() {
//show and prepare the interaction for each individual news item
fun renderFileListing(podcasts: List) {
//now sort it so people always have the latest news first
- val list = getView()!!.findViewById(android.R.id.list) as ListView
+ val list = getView()!!.findView(android.R.id.list)
val textSize = parent.getVisualPref().listTextSize
@@ -240,7 +240,7 @@ public class PodcastListFragment(): MainListFragment() {
pp.dismiss()
}
- val icon = x.findViewById(R.id.podcast_quick_action_delete_icon) as ImageView
+ val icon = x.findView(R.id.podcast_quick_action_delete_icon)
icon.setOnClickListener {
val dlg = createConfirmationDialog(context = context, message = "Are you sure about deleting this podcast?", positive = {
try{
diff --git a/src/com/silverkeytech/android_rivers/fragments/RiverListFragment.kt b/src/com/silverkeytech/android_rivers/fragments/RiverListFragment.kt
index 7fa1365..5b0f781 100644
--- a/src/com/silverkeytech/android_rivers/fragments/RiverListFragment.kt
+++ b/src/com/silverkeytech/android_rivers/fragments/RiverListFragment.kt
@@ -70,7 +70,7 @@ import com.silverkeytech.android_rivers.isLocalUrl
import com.silverkeytech.android_rivers.extractIdFromLocalUrl
import com.silverkeytech.android_rivers.startDownloadAllRiverService
import com.silverkeytech.android_rivers.createConfirmationDialog
-import com.silverkeytech.android_rivers.MessageEvent
+import com.silverkeytech.android_rivers.findView
public class RiverListFragment(): MainListFragment() {
class object {
@@ -131,7 +131,7 @@ public class RiverListFragment(): MainListFragment() {
setSortButtonText(sort, nextSort)
val refresh = menu.findItem(R.id.river_list_fragment_menu_refresh)!!
- val list = getView()!!.findViewById(android.R.id.list) as ListView
+ val list = getView()!!.findView(android.R.id.list)
if (list.getCount() != 0)
refresh.setVisible(false)