Skip to content

Commit

Permalink
actions: less warnings is more (fixes #3654) (#3655)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
Co-authored-by: Gideon Okuro <[email protected]>
  • Loading branch information
3 people authored Jun 24, 2024
1 parent 4bfcf13 commit f4b2858
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 50 deletions.
24 changes: 8 additions & 16 deletions .github/workflows/android-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,22 @@ jobs:
- name: checkout repository code
uses: actions/checkout@v4

- name: ensure *.lite also change
- name: check for .lite diffs
if: matrix.build == 'lite'
run: |
git fetch origin master > /dev/null 2>&1
files=(
"app/src/main/AndroidManifest.xml"
"app/src/main/AndroidManifest.xml.lite"
"app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt"
"app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt.lite"
"app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt"
"app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt.lite"
"app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt"
"app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt"
"app/src/main/java/org/ole/planet/myplanet/ui/dashboard/DashboardActivity.kt.lite"
)
errors=()
for ((i=0; i<${#files[@]}; i+=2)); do
file1=${files[i]}
file2=${files[i+1]}
changes=$(git diff --name-only HEAD origin/master | grep -E "^($file1|$file2)$")
if [ -n "$changes" ] && (! echo "$changes" | grep -qE "^($file1)$" || ! echo "$changes" | grep -qE "^($file2)$"); then
errors+=("Error: Both $file1 and $file2 must be changed together.")
fi
for file in "${files[@]}"; do
echo "$file .lite"
ls -al "$file"
ls -al "$file.lite"
diff "$file" "$file.lite" || true
echo "next"
done
[ ${#errors[@]} -gt 0 ] && { printf "%s\n" "${errors[@]}"; exit 1; }
- name: diff the code to get lite
if: matrix.build == 'lite'
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "org.ole.planet.myplanet"
minSdkVersion 21
targetSdkVersion 34
versionCode 1611
versionName "0.16.11"
versionCode 1612
versionName "0.16.12"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:mimeType="application/vnd.android.package-archive" />
</intent>
</queries>
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
<uses-permission
android:name="android.permission.BLUETOOTH"
Expand Down
7 changes: 6 additions & 1 deletion app/src/main/AndroidManifest.xml.lite
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:mimeType="application/vnd.android.package-archive" />
</intent>
</queries>
<!-- <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>-->
<uses-permission
android:name="android.permission.BLUETOOTH"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import android.app.Activity
import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import android.content.SharedPreferences
import android.net.Uri
import android.os.Build
import android.os.Bundle
Expand Down Expand Up @@ -51,6 +50,7 @@ abstract class BaseContainerFragment : BaseResourceFragment() {
private lateinit var installApkLauncher: ActivityResultLauncher<Intent>
lateinit var prefData: SharedPrefManager

@RequiresApi(Build.VERSION_CODES.O)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
profileDbHandler = UserProfileDbHandler(requireActivity())
Expand All @@ -73,7 +73,7 @@ abstract class BaseContainerFragment : BaseResourceFragment() {
}
}
fun getUrlsAndStartDownload(
lib: List<RealmMyLibrary?>, settings: SharedPreferences?, urls: ArrayList<String>
lib: List<RealmMyLibrary?>, urls: ArrayList<String>
) {
for (library in lib) {
val url = Utilities.getUrl(library)
Expand All @@ -87,11 +87,16 @@ abstract class BaseContainerFragment : BaseResourceFragment() {
timesRated = requireView().findViewById(R.id.times_rated)
rating = requireView().findViewById(R.id.tv_rating)
ratingBar = requireView().findViewById(R.id.rating_bar)
ratingBar?.setOnTouchListener { _: View?, e: MotionEvent ->
if (e.action == MotionEvent.ACTION_UP) homeItemClickListener?.showRatingDialog(
type, id, title, listener
)
true
ratingBar?.apply {
setOnTouchListener { view, e: MotionEvent ->
if (e.action == MotionEvent.ACTION_UP) {
view.performClick()
}
true
}
setOnClickListener {
homeItemClickListener?.showRatingDialog(type, id, title, listener)
}
}
}
override fun onAttach(context: Context) {
Expand All @@ -117,6 +122,7 @@ abstract class BaseContainerFragment : BaseResourceFragment() {
fileOpenIntent.putExtra("resourceId", item.id)
startActivity(fileOpenIntent)
}
@RequiresApi(Build.VERSION_CODES.O)
fun openResource(items: RealmMyLibrary) {
val matchingItems = mRealm.where(RealmMyLibrary::class.java)
.equalTo("resourceLocalAddress", items.resourceLocalAddress)
Expand Down Expand Up @@ -245,17 +251,18 @@ abstract class BaseContainerFragment : BaseResourceFragment() {
intent.putExtras(bundle)
startActivity(intent)
}
@RequiresApi(Build.VERSION_CODES.O)
private fun showResourceList(downloadedResources: List<RealmMyLibrary>?) {
val builderSingle = AlertDialog.Builder(requireActivity())
builderSingle.setTitle(getString(R.string.select_resource_to_open))
val arrayAdapter: ArrayAdapter<RealmMyLibrary?> = object : ArrayAdapter<RealmMyLibrary?>(
requireActivity(), android.R.layout.select_dialog_item, downloadedResources!!
) {
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
var convertView = convertView
if (convertView == null) convertView = LayoutInflater.from(activity)
var view = convertView
if (view == null) view = LayoutInflater.from(activity)
.inflate(android.R.layout.select_dialog_item, parent, false)
val tv = convertView as TextView
val tv = view as TextView
val library = getItem(position)
tv.setCompoundDrawablesWithIntrinsicBounds(0, 0,
if (library?.isResourceOffline() == true) {
Expand All @@ -273,6 +280,7 @@ abstract class BaseContainerFragment : BaseResourceFragment() {
}
builderSingle.setNegativeButton(R.string.dismiss, null).show()
}
@RequiresApi(Build.VERSION_CODES.O)
fun setOpenResourceButton(downloadedResources: List<RealmMyLibrary>?, btnOpen: Button) {
if (downloadedResources.isNullOrEmpty()) {
btnOpen.visibility = View.GONE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package org.ole.planet.myplanet.base
import android.content.Context
import android.content.DialogInterface
import android.content.Intent
import android.content.SharedPreferences
import android.net.Uri
import android.os.Build
import android.os.Bundle
Expand Down Expand Up @@ -51,6 +50,7 @@ abstract class BaseContainerFragment : BaseResourceFragment() {
// private lateinit var installApkLauncher: ActivityResultLauncher<Intent>
lateinit var prefData: SharedPrefManager

@RequiresApi(Build.VERSION_CODES.O)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
profileDbHandler = UserProfileDbHandler(requireActivity())
Expand All @@ -73,7 +73,7 @@ abstract class BaseContainerFragment : BaseResourceFragment() {
}
}
fun getUrlsAndStartDownload(
lib: List<RealmMyLibrary?>, settings: SharedPreferences?, urls: ArrayList<String>
lib: List<RealmMyLibrary?>, urls: ArrayList<String>
) {
for (library in lib) {
val url = Utilities.getUrl(library)
Expand All @@ -87,11 +87,16 @@ abstract class BaseContainerFragment : BaseResourceFragment() {
timesRated = requireView().findViewById(R.id.times_rated)
rating = requireView().findViewById(R.id.tv_rating)
ratingBar = requireView().findViewById(R.id.rating_bar)
ratingBar?.setOnTouchListener { _: View?, e: MotionEvent ->
if (e.action == MotionEvent.ACTION_UP) homeItemClickListener?.showRatingDialog(
type, id, title, listener
)
true
ratingBar?.apply {
setOnTouchListener { view, e: MotionEvent ->
if (e.action == MotionEvent.ACTION_UP) {
view.performClick()
}
true
}
setOnClickListener {
homeItemClickListener?.showRatingDialog(type, id, title, listener)
}
}
}
override fun onAttach(context: Context) {
Expand All @@ -117,6 +122,7 @@ abstract class BaseContainerFragment : BaseResourceFragment() {
fileOpenIntent.putExtra("resourceId", item.id)
startActivity(fileOpenIntent)
}
@RequiresApi(Build.VERSION_CODES.O)
fun openResource(items: RealmMyLibrary) {
val matchingItems = mRealm.where(RealmMyLibrary::class.java)
.equalTo("resourceLocalAddress", items.resourceLocalAddress)
Expand Down Expand Up @@ -245,17 +251,18 @@ abstract class BaseContainerFragment : BaseResourceFragment() {
intent.putExtras(bundle)
startActivity(intent)
}
@RequiresApi(Build.VERSION_CODES.O)
private fun showResourceList(downloadedResources: List<RealmMyLibrary>?) {
val builderSingle = AlertDialog.Builder(requireActivity())
builderSingle.setTitle(getString(R.string.select_resource_to_open))
val arrayAdapter: ArrayAdapter<RealmMyLibrary?> = object : ArrayAdapter<RealmMyLibrary?>(
requireActivity(), android.R.layout.select_dialog_item, downloadedResources!!
) {
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
var convertView = convertView
if (convertView == null) convertView = LayoutInflater.from(activity)
var view = convertView
if (view == null) view = LayoutInflater.from(activity)
.inflate(android.R.layout.select_dialog_item, parent, false)
val tv = convertView as TextView
val tv = view as TextView
val library = getItem(position)
tv.setCompoundDrawablesWithIntrinsicBounds(0, 0,
if (library?.isResourceOffline() == true) {
Expand All @@ -273,6 +280,7 @@ abstract class BaseContainerFragment : BaseResourceFragment() {
}
builderSingle.setNegativeButton(R.string.dismiss, null).show()
}
@RequiresApi(Build.VERSION_CODES.O)
fun setOpenResourceButton(downloadedResources: List<RealmMyLibrary>?, btnOpen: Button) {
if (downloadedResources.isNullOrEmpty()) {
btnOpen.visibility = View.GONE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ open class BaseDashboardFragment : BaseDashboardFragmentPlugin(), NotificationCa
.greaterThan("createdDate", now.timeInMillis).equalTo("mediaType", "image")
.findAll()
val urls = ArrayList<String>()
getUrlsAndStartDownload(imageList, settings, urls) },
getUrlsAndStartDownload(imageList, urls) },
now[Calendar.YEAR], now[Calendar.MONTH], now[Calendar.DAY_OF_MONTH]
)
dpd.setTitle(getString(R.string.read_offline_news_from))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,14 +397,14 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N
}

private fun changeUX(iconText: Int, drawable: Drawable?): PrimaryDrawerItem {
return PrimaryDrawerItem().withName(iconText)
.withIcon(drawable)
.withTextColor(ContextCompat.getColor(this, R.color.textColorPrimary))
.withSelectedTextColor(ContextCompat.getColor(this, R.color.primary_dark))
.withIconColor(ContextCompat.getColor(this, R.color.textColorPrimary))
.withSelectedIconColor(ContextCompat.getColor(this, R.color.primary_dark))
.withSelectedColor(ContextCompat.getColor(this, R.color.textColorPrimary))
.withIconTintingEnabled(true)
return PrimaryDrawerItem().withName(iconText)
.withIcon(drawable)
.withTextColor(ContextCompat.getColor(this, R.color.textColorPrimary))
.withSelectedTextColor(ContextCompat.getColor(this, R.color.primary_dark))
.withIconColor(ContextCompat.getColor(this, R.color.textColorPrimary))
.withSelectedIconColor(ContextCompat.getColor(this, R.color.primary_dark))
.withSelectedColor(ContextCompat.getColor(this, R.color.textColorPrimary))
.withIconTintingEnabled(true)
}

override fun onNavigationItemSelected(item: MenuItem): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class NewsFragment : BaseNewsFragment() {
val lib: List<RealmMyLibrary?> = mRealm.where(RealmMyLibrary::class.java)
.`in`("_id", stringArray)
.findAll()
getUrlsAndStartDownload(lib, settings, urls)
getUrlsAndStartDownload(lib, urls)
adapterNews = activity?.let {
AdapterNews(
it,
Expand Down

0 comments on commit f4b2858

Please sign in to comment.