Skip to content

Commit

Permalink
Merge branch 'master' into 4916-teams-resource-removal
Browse files Browse the repository at this point in the history
  • Loading branch information
Okuro3499 committed Jan 28, 2025
2 parents ef167fe + e9408e9 commit 57b0b27
Show file tree
Hide file tree
Showing 92 changed files with 1,246 additions and 540 deletions.
29 changes: 18 additions & 11 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 2181
versionName "0.21.81"
versionCode 2245
versionName "0.22.45"
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,17 +89,18 @@ 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\""
Expand All @@ -106,6 +109,8 @@ android {
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,16 +121,18 @@ 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}\""
//it.buildConfigField 'String', 'PLANET_EGDIRBMAC_PIN', "\"${planetEgdirbmacPin}\""
it.buildConfigField 'String', 'PLANET_PALMBAY_URL', "\"${planetPalmBayUrl}\""
it.buildConfigField 'String', 'PLANET_PALMBAY_PIN', "\"${planetPalmBayPin}\""
}
}

Expand Down Expand Up @@ -159,7 +166,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,14 +189,14 @@ 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'
}

implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'de.rtner:PBKDF2:1.1.4'
implementation 'org.osmdroid:osmdroid-android:6.1.20'
implementation 'org.jetbrains:annotations:26.0.1'
implementation 'org.jetbrains:annotations:26.0.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0"
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.29'
Expand All @@ -208,7 +215,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 @@ -171,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 @@ -191,14 +191,13 @@ abstract class BaseResourceFragment : Fragment() {
return
}

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

resourceNotFoundDialog?.setOnDismissListener {
resourceNotFoundDialog = null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import org.ole.planet.myplanet.model.RealmMyLibrary
import org.ole.planet.myplanet.model.RealmStepExam

interface OnHomeItemClickListener {
fun openMyFragment(f: Fragment)
fun openCallFragment(f: Fragment)
fun openLibraryDetailFragment(library: RealmMyLibrary?)
fun showRatingDialog(type: String?, resourceId: String?, title: String?, listener: OnRatingChangeListener?)
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 @@ -12,7 +12,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 @@ -23,7 +22,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 @@ -218,16 +216,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 57b0b27

Please sign in to comment.