Skip to content

Commit

Permalink
Merge branch 'master' into 4770-remove-jvmstatic-annotations-from-com…
Browse files Browse the repository at this point in the history
…panion-object-functions
  • Loading branch information
Okuro3499 committed Jan 21, 2025
2 parents ff8ed66 + fd4376e commit 3eb1668
Show file tree
Hide file tree
Showing 17 changed files with 54 additions and 49 deletions.
4 changes: 2 additions & 2 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 2213
versionName "0.22.13"
versionCode 2225
versionName "0.22.25"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ class MainApplication : Application(), Application.ActivityLifecycleCallbacks {
var isCollectionSwitchOn = false
var showDownload = false
var isSyncRunning = false
var showHealthDialog = true
var listener: TeamPageListener? = null
val androidId: String get() {
try {
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 @@ -91,7 +91,7 @@ class SyncManager private constructor(private val context: Context) {
settings.edit().putString("LastWifiSSID", wifiInfo.ssid).apply()
}
isSyncing = true
create(context, R.mipmap.ic_launcher, " Syncing data", "Please wait...")
create(context, R.mipmap.ic_launcher, "Syncing data", "Please wait...")
mRealm = dbService.realmInstance
TransactionSyncManager.syncDb(mRealm, "tablet_users")
myLibraryTransactionSync()
Expand Down Expand Up @@ -168,7 +168,7 @@ class SyncManager private constructor(private val context: Context) {
private fun myLibraryTransactionSync() {
val apiInterface = client?.create(ApiInterface::class.java)
try {
val res = apiInterface?.getDocuments(Utilities.header, Utilities.getUrl() + "/shelf/_all_docs")?.execute()?.body()
val res = apiInterface?.getDocuments(Utilities.header, "${Utilities.getUrl()}/shelf/_all_docs")?.execute()?.body()
for (i in res?.rows!!.indices) {
shelfDoc = res.rows!![i]
populateShelfItems(apiInterface)
Expand All @@ -180,7 +180,7 @@ class SyncManager private constructor(private val context: Context) {

private fun populateShelfItems(apiInterface: ApiInterface) {
try {
val jsonDoc = apiInterface.getJsonObject(Utilities.header, Utilities.getUrl() + "/shelf/" + shelfDoc?.id).execute().body()
val jsonDoc = apiInterface.getJsonObject(Utilities.header, "${Utilities.getUrl()}/shelf/${shelfDoc?.id}").execute().body()
for (i in Constants.shelfDataList.indices) {
val shelfData = Constants.shelfDataList[i]
val array = getJsonArray(shelfData.key, jsonDoc)
Expand Down Expand Up @@ -216,7 +216,7 @@ class SyncManager private constructor(private val context: Context) {
private fun validateDocument(arrayCategoryIds: JsonArray, x: Int) {
val apiInterface = client!!.create(ApiInterface::class.java)
try {
val resourceDoc = apiInterface.getJsonObject(Utilities.header, Utilities.getUrl() + "/" + stringArray[2] + "/" + arrayCategoryIds[x].asString).execute().body()
val resourceDoc = apiInterface.getJsonObject(Utilities.header, "${Utilities.getUrl()}/${stringArray[2]}/${arrayCategoryIds[x].asString}").execute().body()
resourceDoc?.let { triggerInsert(stringArray, it) }
} catch (e: IOException) {
e.printStackTrace()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class CoursesFragment : BaseRecyclerFragment<RealmMyCourse?>(), OnCourseItemSele
spnGrade.adapter = gradeAdapter

val subjectAdapter = ArrayAdapter.createFromResource(requireContext(), R.array.subject_level, R.layout.spinner_item)
subjectAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
subjectAdapter.setDropDownViewResource(R.layout.custom_simple_list_item_1)
spnSubject.adapter = subjectAdapter

spnGrade.onItemSelectedListener = itemSelectedListener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,6 @@ open class BaseDashboardFragment : BaseDashboardFragmentPlugin(), NotificationCa
}

override fun syncKeyId() {
di = DialogUtils.CustomProgressDialog(requireContext())
di?.setText(getString(R.string.syncing_health_please_wait))
if (model?.getRoleAsString()?.contains("health") == true) {
settings?.let { TransactionSyncManager.syncAllHealthData(mRealm, it, this) }
} else {
Expand All @@ -399,12 +397,10 @@ open class BaseDashboardFragment : BaseDashboardFragmentPlugin(), NotificationCa

override fun onSyncComplete() {
di?.dismiss()
Utilities.toast(activity, getString(R.string.myhealth_synced_successfully))
}

override fun onSyncFailed(msg: String?) {
di?.dismiss()
Utilities.toast(activity, getString(R.string.myhealth_synced_failed))
}

override fun showTaskListDialog() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.ole.planet.myplanet.ui.dashboard

import android.content.DialogInterface
import android.os.Bundle
import android.text.TextUtils
import android.view.LayoutInflater
Expand All @@ -19,7 +18,6 @@ import androidx.recyclerview.widget.RecyclerView
import io.realm.Case
import io.realm.Realm
import kotlinx.coroutines.*
import org.ole.planet.myplanet.MainApplication
import org.ole.planet.myplanet.R
import org.ole.planet.myplanet.databinding.FragmentHomeBellBinding
import org.ole.planet.myplanet.model.RealmCertification
Expand Down Expand Up @@ -66,13 +64,8 @@ class BellDashboardFragment : BaseDashboardFragment() {
showBadges()
checkPendingSurveys()

if (model?.id?.startsWith("guest") == false && TextUtils.isEmpty(model?.key) && MainApplication.showHealthDialog) {
AlertDialog.Builder(requireActivity(), R.style.CustomAlertDialog)
.setMessage(getString(R.string.health_record_not_available_sync_health_data))
.setPositiveButton(getString(R.string.sync)) { _: DialogInterface?, _: Int ->
syncKeyId()
MainApplication.showHealthDialog = false
}.setNegativeButton(getString(R.string.cancel), null).show()
if (model?.id?.startsWith("guest") == false && TextUtils.isEmpty(model?.key)) {
syncKeyId()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,9 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N
val b = Bundle()
b.putBoolean("isMyCourseLib", true)
f.arguments = b
openCallFragment(f, "shelf")
val fragmentName = f::class.java.simpleName
val tag = "My$fragmentName"
openCallFragment(f, tag)
}

override fun onDestroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,9 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N
val b = Bundle()
b.putBoolean("isMyCourseLib", true)
f.arguments = b
openCallFragment(f, "shelf")
val fragmentName = f::class.java.simpleName
val tag = "My$fragmentName"
openCallFragment(f, tag)
}

override fun onDestroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class ResourceDetailFragment : BaseContainerFragment(), OnRatingChangeListener {
}

override fun onDownloadComplete() {
super.onDownloadComplete()

fragmentLibraryDetailBinding.btnDownload.setImageResource(R.drawable.ic_play)
if (!library.userId?.contains(profileDbHandler.userModel?.id)!!) {
if (!lRealm.isInTransaction) lRealm.beginTransaction()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ class ResourcesFragment : BaseRecyclerFragment<RealmMyLibrary?>(), OnLibraryItem
selectAll = view.findViewById(R.id.selectAll)
filter = view.findViewById(R.id.filter)
addResourceButton = view.findViewById(R.id.addResource)

if (tvSelected.text.isNullOrEmpty()) {
tvSelected.visibility = View.GONE
} else {
tvSelected.visibility = View.VISIBLE
}
initArrays()
updateTvDelete()

Expand Down Expand Up @@ -237,6 +241,7 @@ class ResourcesFragment : BaseRecyclerFragment<RealmMyLibrary?>(), OnLibraryItem
}

override fun onTagClicked(realmTag: RealmTag) {
tvSelected.visibility = View.VISIBLE
flexBoxTags.removeAllViews()
val chipCloud = ChipCloud(activity, flexBoxTags, config)
chipCloud.setDeleteListener(this)
Expand All @@ -248,6 +253,7 @@ class ResourcesFragment : BaseRecyclerFragment<RealmMyLibrary?>(), OnLibraryItem
}

override fun onTagSelected(tag: RealmTag) {
tvSelected.visibility = View.VISIBLE
val li: MutableList<RealmTag> = ArrayList()
li.add(tag)
searchTags = li
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,13 @@ class MySubmissionFragment : Fragment(), CompoundButton.OnCheckedChangeListener

val adapter = AdapterMySubmission(requireActivity(), submissions, exams)
val itemCount = adapter.itemCount
BaseRecyclerFragment.showNoData(fragmentMySubmissionBinding.tvMessage, itemCount, "submission")

if (itemCount == 0) {
fragmentMySubmissionBinding.llSearch.visibility = View.GONE
fragmentMySubmissionBinding.title.visibility = View.GONE
if (s.isEmpty()) {
BaseRecyclerFragment.showNoData(fragmentMySubmissionBinding.tvMessage, itemCount, "submission")
if (itemCount == 0) {
fragmentMySubmissionBinding.llSearch.visibility = View.GONE
fragmentMySubmissionBinding.title.visibility = View.GONE
}
}
adapter.setmRealm(mRealm)
adapter.setType(type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ abstract class DashboardElementActivity : SyncActivity(), FragmentManager.OnBack
profileDbHandler = UserProfileDbHandler(this)
settings = applicationContext.getSharedPreferences(PREFS_NAME, MODE_PRIVATE)
prefData = SharedPrefManager(this)
supportFragmentManager.addOnBackStackChangedListener(this)
}

fun onClickTabItems(position: Int) {
Expand Down Expand Up @@ -246,13 +247,13 @@ abstract class DashboardElementActivity : SyncActivity(), FragmentManager.OnBack
val f = supportFragmentManager.findFragmentById(R.id.fragment_container)
val fragmentTag = f?.tag
if (f is CoursesFragment) {
if ("shelf" == fragmentTag) {
if ("MyCoursesFragment" == fragmentTag) {
navigationView.menu.findItem(R.id.menu_mycourses).isChecked = true
} else {
navigationView.menu.findItem(R.id.menu_courses).isChecked = true
}
} else if (f is ResourcesFragment) {
if ("shelf" == fragmentTag) {
if ("MyResourcesFragment" == fragmentTag) {
navigationView.menu.findItem(R.id.menu_mylibrary).isChecked = true
} else {
navigationView.menu.findItem(R.id.menu_library).isChecked = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ object JsonUtils {
return try {
if (jsonObject?.has(fieldName) == true) {
val el: JsonElement = jsonObject.get(fieldName)
if (el is JsonNull) 0 else el.asInt
if (el is JsonNull || el.asString.isEmpty()) 0 else el.asInt
} else {
0
}
Expand All @@ -96,7 +96,7 @@ object JsonUtils {
return try {
if (jsonObject?.has(fieldName) == true) {
val el: JsonElement = jsonObject.get(fieldName)
if (el is JsonNull) 0f else el.asFloat
if (el is JsonNull || el.asString.isEmpty()) 0f else el.asFloat
} else {
getInt(fieldName, jsonObject).toFloat()
}
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/layout/alert_create_team.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
android:layout_height="match_parent"
android:hint="@string/entServices"
android:padding="@dimen/padding_normal"
android:textColor="@color/daynight_textColor" />
android:textColor="@color/daynight_textColor"
android:backgroundTint="@color/hint_color" />
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
Expand All @@ -60,7 +61,8 @@
android:layout_height="match_parent"
android:hint="@string/entRules"
android:padding="@dimen/padding_normal"
android:textColor="@color/daynight_textColor" />
android:textColor="@color/daynight_textColor"
android:backgroundTint="@color/hint_color" />
</com.google.android.material.textfield.TextInputLayout>

<Spinner
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/layout/fragment_library_filter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
android:layout_width="@dimen/_40dp"
android:layout_height="@dimen/_40dp"
android:layout_gravity="right"
android:layout_marginEnd="35dp"
app:tint="@color/daynight_textColor"
android:src="@drawable/close_x" />
</LinearLayout>

Expand Down
19 changes: 10 additions & 9 deletions app/src/main/res/layout/fragment_my_library.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,18 @@
android:layout_height="wrap_content"
android:layout_gravity="end"
android:background="@color/colorPrimary"
android:gravity="end"
android:gravity="center"
android:orientation="vertical"
android:padding="@dimen/padding_large">
android:padding="@dimen/padding_small">

<TextView
android:id="@+id/tv_selected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/padding_small"
android:textColor="@color/textColorPrimary"
android:textSize="@dimen/text_size_mid"
android:gravity="center"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -57,13 +65,6 @@
app:drawableLeftCompat="@drawable/ic_add_library"
app:drawableTint="@color/daynight_textColor"
android:width="170dp" />
<TextView
android:id="@+id/tv_selected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="@dimen/padding_small"
android:textColor="@color/textColorPrimary"
android:textSize="@dimen/text_size_mid" />
<TextView
android:id="@+id/tv_delete"
android:layout_width="wrap_content"
Expand Down

0 comments on commit 3eb1668

Please sign in to comment.