Skip to content

Commit

Permalink
Merge branch 'master' into record-not-found-debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
Okuro3499 committed Jan 23, 2025
2 parents 7225bc0 + aacacd4 commit d1ce969
Show file tree
Hide file tree
Showing 86 changed files with 1,200 additions and 492 deletions.
23 changes: 17 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "org.ole.planet.myplanet"
minSdkVersion 26
targetSdkVersion 34
versionCode 2175
versionName "0.21.75"
versionCode 2229
versionName "0.22.29"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -77,6 +77,8 @@ android {
def planetGuatemalaPin = project.findProperty('PLANET_GUATEMALA_PIN') ?: ""
def planetSanPabloUrl = project.findProperty('PLANET_SANPABLO_URL') ?: ""
def planetSanPabloPin = project.findProperty('PLANET_SANPABLO_PIN') ?: ""
def planetSanPabloCloneUrl = project.findProperty('PLANET_SANPABLO_CLONE_URL') ?: ""
def planetSanPabloClonePin = project.findProperty('PLANET_SANPABLO_CLONE_PIN') ?: ""
def planetEarthUrl = project.findProperty('PLANET_EARTH_URL') ?: ""
def planetEarthPin = project.findProperty('PLANET_EARTH_PIN') ?: ""
def planetSomaliaUrl = project.findProperty('PLANET_SOMALIA_URL') ?: ""
Expand All @@ -87,25 +89,30 @@ android {
def planetXelaPin = project.findProperty('PLANET_XELA_PIN') ?: ""
def planetUriurUrl = project.findProperty('PLANET_URIUR_URL') ?: ""
def planetUriurPin = project.findProperty('PLANET_URIUR_PIN') ?: ""
def planetUriurCloneUrl = project.findProperty('PLANET_URIUR_CLONE_URL') ?: ""
def planetUriurClonePin = project.findProperty('PLANET_URIUR_CLONE_PIN') ?: ""
def planetRuiruUrl = project.findProperty('PLANET_RUIRU_URL') ?: ""
def planetRuiruPin = project.findProperty('PLANET_RUIRU_PIN') ?: ""
def planetEmbakasiUrl = project.findProperty('PLANET_EMBAKASI_URL') ?: ""
def planetEmbakasiPin = project.findProperty('PLANET_EMBAKASI_PIN') ?: ""
def planetEmbakasiCloneUrl = project.findProperty('PLANET_EMBAKASI_CLONE_URL') ?: ""
def planetEmbakasiClonePin = project.findProperty('PLANET_EMBAKASI_CLONE_PIN') ?: ""
def planetCambridgeUrl = project.findProperty('PLANET_CAMBRIDGE_URL') ?: ""
def planetCambridgePin = project.findProperty('PLANET_CAMBRIDGE_PIN') ?: ""
//def planetEgdirbmacUrl = project.findProperty('PLANET_EGDIRBMAC_URL') ?: ""
//def planetEgdirbmacPin = project.findProperty('PLANET_EGDIRBMAC_PIN') ?: ""
def planetPalmBayUrl = project.findProperty('PLANET_PALMBAY_URL') ?: ""
def planetPalmBayPin = project.findProperty('PLANET_PALMBAY_PIN') ?: ""


buildTypes.each {
it.buildConfigField 'String', 'PLANET_LEARNING_URL', "\"$planetLearningUrl\""
it.buildConfigField 'String', 'PLANET_LEARNING_PIN', "\"${planetLearningPin}\""
it.buildConfigField 'String', 'PLANET_GUATEMALA_URL', "\"${planetGuatemalaUrl}\""
it.buildConfigField 'String', 'PLANET_GUATEMALA_PIN', "\"${planetGuatemalaPin}\""
it.buildConfigField 'String', 'PLANET_SANPABLO_URL', "\"${planetSanPabloUrl}\""
it.buildConfigField 'String', 'PLANET_SANPABLO_PIN', "\"${planetSanPabloPin}\""
it.buildConfigField 'String', 'PLANET_SANPABLO_CLONE_URL', "\"${planetSanPabloCloneUrl}\""
it.buildConfigField 'String', 'PLANET_SANPABLO_CLONE_PIN', "\"${planetSanPabloClonePin}\""
it.buildConfigField 'String', 'PLANET_EARTH_URL', "\"${planetEarthUrl}\""
it.buildConfigField 'String', 'PLANET_EARTH_PIN', "\"${planetEarthPin}\""
it.buildConfigField 'String', 'PLANET_SOMALIA_URL', "\"${planetSomaliaUrl}\""
Expand All @@ -116,10 +123,14 @@ android {
it.buildConfigField 'String', 'PLANET_XELA_PIN', "\"${planetXelaPin}\""
it.buildConfigField 'String', 'PLANET_URIUR_URL', "\"${planetUriurUrl}\""
it.buildConfigField 'String', 'PLANET_URIUR_PIN', "\"${planetUriurPin}\""
it.buildConfigField 'String', 'PLANET_URIUR_CLONE_URL', "\"${planetUriurCloneUrl}\""
it.buildConfigField 'String', 'PLANET_URIUR_CLONE_PIN', "\"${planetUriurClonePin}\""
it.buildConfigField 'String', 'PLANET_RUIRU_URL', "\"${planetRuiruUrl}\""
it.buildConfigField 'String', 'PLANET_RUIRU_PIN', "\"${planetRuiruPin}\""
it.buildConfigField 'String', 'PLANET_EMBAKASI_URL', "\"${planetEmbakasiUrl}\""
it.buildConfigField 'String', 'PLANET_EMBAKASI_PIN', "\"${planetEmbakasiPin}\""
it.buildConfigField 'String', 'PLANET_EMBAKASI_CLONE_URL', "\"${planetEmbakasiCloneUrl}\""
it.buildConfigField 'String', 'PLANET_EMBAKASI_CLONE_PIN', "\"${planetEmbakasiClonePin}\""
it.buildConfigField 'String', 'PLANET_CAMBRIDGE_URL', "\"${planetCambridgeUrl}\""
it.buildConfigField 'String', 'PLANET_CAMBRIDGE_PIN', "\"${planetCambridgePin}\""
//it.buildConfigField 'String', 'PLANET_EGDIRBMAC_URL', "\"${planetEgdirbmacUrl}\""
Expand Down Expand Up @@ -159,7 +170,7 @@ dependencies {
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'androidx.recyclerview:recyclerview:1.4.0'
implementation 'androidx.annotation:annotation:1.9.1'
implementation 'androidx.exifinterface:exifinterface:1.3.7'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
Expand All @@ -182,7 +193,7 @@ dependencies {
implementation 'com.borax12.materialdaterangepicker:library:2.0'
implementation 'com.nex3z:toggle-button-group:1.2.3'
implementation 'com.caverock:androidsvg-aar:1.4'
implementation('com.opencsv:opencsv:5.9') {
implementation('com.opencsv:opencsv:5.10') {
exclude group: 'commons-logging', module: 'commons-logging'
}

Expand All @@ -208,7 +219,7 @@ dependencies {
implementation "androidx.camera:camera-lifecycle:$camera_version"
implementation "androidx.camera:camera-view:$camera_version"

def dagger_hilt_version = "2.54"
def dagger_hilt_version = "2.55"
implementation "com.google.dagger:hilt-android:$dagger_hilt_version"
kapt "com.google.dagger:hilt-android-compiler:$dagger_hilt_version"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import org.ole.planet.myplanet.MainApplication
import org.ole.planet.myplanet.base.BaseResourceFragment.Companion.backgroundDownload
import org.ole.planet.myplanet.base.BaseResourceFragment.Companion.getAllLibraryList
import org.ole.planet.myplanet.callback.TeamPageListener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import androidx.fragment.app.DialogFragment
abstract class BaseDialogFragment : DialogFragment() {
@JvmField
var id: String? = null
var teamId: String? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(STYLE_NO_TITLE, R.style.AppTheme_Dialog_NoActionBar_MinWidth)
if (arguments != null) {
id = requireArguments().getString(key)
teamId = requireArguments().getString("teamId")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,25 +177,31 @@ abstract class BaseRecyclerFragment<LI> : BaseRecyclerParentFragment<Any?>(), On
}

private fun <LI : RealmModel> getData(s: String, c: Class<LI>): List<LI> {
if (s.isEmpty()) return mRealm.where(c).findAll()

val queryParts = s.split(" ").filterNot { it.isEmpty() }
return if (s.contains(" ")) {
val fieldName = if (c == RealmMyLibrary::class.java) "title" else "courseTitle"

return if (queryParts.size > 1) {
val data: RealmResults<LI> = mRealm.where(c).findAll()
data.filter { item ->
searchAndMatch(item, c, queryParts)
}
} else {
mRealm.where(c).contains(if (c == RealmMyLibrary::class.java) "title" else "courseTitle", s, Case.INSENSITIVE).findAll()
mRealm.where(c)
.contains(fieldName, s, Case.INSENSITIVE)
.findAll()
}
}

private fun <LI : RealmModel> searchAndMatch(item: LI, c: Class<out RealmModel>, queryParts: List<String>): Boolean {
val title = if (c.isAssignableFrom(RealmMyLibrary::class.java)) {
(item as RealmMyLibrary).title
} else {
(item as RealmMyCourse).courseTitle
}
val title = when {
c.isAssignableFrom(RealmMyLibrary::class.java) -> (item as RealmMyLibrary).title
else -> (item as RealmMyCourse).courseTitle
}?.lowercase(Locale.getDefault()) ?: return false

return queryParts.all { queryPart ->
title?.lowercase(Locale.getDefault())?.contains(queryPart.lowercase(Locale.getDefault())) == true
title.contains(queryPart.lowercase(Locale.getDefault()))
}
}

Expand All @@ -206,14 +212,22 @@ abstract class BaseRecyclerFragment<LI> : BaseRecyclerParentFragment<Any?>(), On
} else {
getOurLibrary(model?.id, list)
}
if (tags.isEmpty()) {
return list
}
val libraries = mutableListOf<RealmMyLibrary>()
for (library in list) {
filter(tags, library, libraries)

val libraries = if (tags.isNotEmpty()) {
val filteredLibraries = mutableListOf<RealmMyLibrary>()
for (library in list) {
filter(tags, library, filteredLibraries)
}
filteredLibraries
} else {
list
}
return libraries

return libraries.sortedWith(compareBy<RealmMyLibrary> { library ->
!library.title?.lowercase()?.startsWith(s.lowercase())!! ?: true
}.thenBy { library ->
library.title?.lowercase() ?: ""
})
}

fun filterCourseByTag(s: String, tags: List<RealmTag>): List<RealmMyCourse> {
Expand Down Expand Up @@ -301,7 +315,8 @@ abstract class BaseRecyclerFragment<LI> : BaseRecyclerParentFragment<Any?>(), On
"members" -> (v as TextView).setText(R.string.no_join_request_available)
"discussions" -> (v as TextView).setText(R.string.no_news)
"survey" -> (v as TextView).setText(R.string.no_surveys)
"submission" -> (v as TextView).setText(R.string.no_submissions)
"survey_submission" -> (v as TextView).setText(R.string.no_survey_submissions)
"exam_submission" -> (v as TextView).setText(R.string.no_exam_submissions)
"team" -> (v as TextView).setText(R.string.no_teams)
"enterprise" -> (v as TextView).setText(R.string.no_enterprise)
"chatHistory" -> (v as TextView).setText(R.string.no_chats)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ abstract class BaseResourceFragment : Fragment() {
var lv: CheckboxListView? = null
var convertView: View? = null
private lateinit var prgDialog: DialogUtils.CustomProgressDialog
private var resourceNotFoundDialog: AlertDialog? = null

private var receiver: BroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
Expand Down Expand Up @@ -170,7 +171,7 @@ abstract class BaseResourceFragment : Fragment() {
}
AlertDialog.Builder(requireActivity()).setTitle("Pending Surveys")
.setAdapter(arrayAdapter) { _: DialogInterface?, i: Int ->
AdapterMySubmission.openSurvey(homeItemClickListener, list[i].id, true)
AdapterMySubmission.openSurvey(homeItemClickListener, list[i].id, true, false, "")
}.setPositiveButton(R.string.dismiss, null).show()
}

Expand All @@ -185,13 +186,24 @@ abstract class BaseResourceFragment : Fragment() {
if (prgDialog.isShowing()) {
prgDialog.dismiss()
}
AlertDialog.Builder(requireContext())

if (resourceNotFoundDialog?.isShowing == true) {
return
}

resourceNotFoundDialog = AlertDialog.Builder(requireContext())
.setTitle(R.string.resource_not_found)
.setMessage(R.string.resource_not_found_message)
.setNegativeButton(R.string.close) { dialog, _ ->
dialog.dismiss()
}
.show()
.create()

resourceNotFoundDialog?.setOnDismissListener {
resourceNotFoundDialog = null
}

resourceNotFoundDialog?.show()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@ object ApiClient {
.readTimeout(30, TimeUnit.SECONDS).writeTimeout(30, TimeUnit.SECONDS).build()
if (retrofit == null) {
retrofit = Retrofit.Builder()
.baseUrl(BASE_URL)
.client(client)
.addConverterFactory(
.baseUrl(BASE_URL).client(client).addConverterFactory(
GsonConverterFactory.create(
GsonBuilder()
.excludeFieldsWithModifiers(Modifier.FINAL, Modifier.TRANSIENT, Modifier.STATIC)
.serializeNulls()
.create()
.serializeNulls().create()
)
).build()
}
return retrofit
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import io.realm.Realm
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import okhttp3.ResponseBody
import org.ole.planet.myplanet.model.Download
import org.ole.planet.myplanet.model.RealmMyLibrary
Expand All @@ -24,7 +23,6 @@ import org.ole.planet.myplanet.utilities.FileUtils.getSDPathFromUrl
import org.ole.planet.myplanet.utilities.Utilities.header
import retrofit2.Call
import java.io.*
import kotlin.math.pow
import kotlin.math.roundToInt

class MyDownloadService : Service() {
Expand Down Expand Up @@ -252,16 +250,20 @@ class MyDownloadService : Service() {
CoroutineScope(Dispatchers.IO).launch {
if (urls.isNotEmpty() && currentIndex >= 0 && currentIndex < urls.size) {
val currentFileName = getFileNameFromUrl(urls[currentIndex])
withContext(Dispatchers.Main) {
mRealm.executeTransaction { realm ->
realm.where(RealmMyLibrary::class.java)
.equalTo("resourceLocalAddress", currentFileName)
.findAll()
?.forEach {
it.resourceOffline = true
it.downloadedRev = it._rev
}
try {
val backgroundRealm = Realm.getDefaultInstance()
backgroundRealm.use { realm ->
realm.executeTransaction {
realm.where(RealmMyLibrary::class.java)
.equalTo("resourceLocalAddress", currentFileName).findAll()
?.forEach {
it.resourceOffline = true
it.downloadedRev = it._rev
}
}
}
} catch (e: Exception) {
e.printStackTrace()
}
}
}
Expand Down
Loading

0 comments on commit d1ce969

Please sign in to comment.