Skip to content

Commit

Permalink
Merge branch 'master' into 5046-broken-nav
Browse files Browse the repository at this point in the history
  • Loading branch information
Okuro3499 committed Jan 16, 2025
2 parents 2b3b6ce + b32cc6f commit 1f78e83
Show file tree
Hide file tree
Showing 29 changed files with 358 additions and 172 deletions.
6 changes: 3 additions & 3 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 2202
versionName "0.22.2"
versionCode 2213
versionName "0.22.13"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -170,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 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 @@ -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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ open class RealmStepExam : RealmObject() {
var passingPercentage: String? = null
var noOfQuestions = 0
var isFromNation = false
var teamId: String? = null

companion object {
val examDataList: MutableList<Array<String>> = mutableListOf()
Expand Down Expand Up @@ -66,6 +67,7 @@ open class RealmStepExam : RealmObject() {
myExam?.totalMarks = JsonUtils.getInt("totalMarks", exam)
myExam?.noOfQuestions = JsonUtils.getJsonArray("questions", exam).size()
myExam?.isFromNation = !TextUtils.isEmpty(parentId)
myExam.teamId = JsonUtils.getString("teamId", exam)
val oldQuestions: RealmResults<*>? = mRealm.where(RealmExamQuestion::class.java).equalTo("examId", JsonUtils.getString("_id", exam)).findAll()
if (oldQuestions == null || oldQuestions.isEmpty()) {
RealmExamQuestion.insertExamQuestions(JsonUtils.getJsonArray("questions", exam), JsonUtils.getString("_id", exam), mRealm)
Expand All @@ -84,8 +86,10 @@ open class RealmStepExam : RealmObject() {
JsonUtils.getString("updatedDate", exam),
JsonUtils.getString("totalMarks", exam),
JsonUtils.getString("noOfQuestions", exam),
JsonUtils.getString("isFromNation", exam)
JsonUtils.getString("isFromNation", exam),
JsonUtils.getString("teamId", exam)
)

examDataList.add(csvRow)
}

Expand All @@ -94,7 +98,7 @@ open class RealmStepExam : RealmObject() {
val file = File(filePath)
file.parentFile?.mkdirs()
val writer = CSVWriter(FileWriter(file))
writer.writeNext(arrayOf("_id", "_rev", "name", "passingPercentage", "type", "createdBy", "sourcePlanet", "createdDate", "updatedDate", "totalMarks", "noOfQuestions", "isFromNation"))
writer.writeNext(arrayOf("_id", "_rev", "name", "passingPercentage", "type", "createdBy", "sourcePlanet", "createdDate", "updatedDate", "totalMarks", "noOfQuestions", "isFromNation", "teamId"))
for (row in data) {
writer.writeNext(row)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,19 @@ class ServicesFragment : BaseTeamFragment() {

if (links?.size == 0) {
fragmentServicesBinding.llServices.visibility = View.GONE
fragmentServicesBinding.tvNoLinks.visibility = View.VISIBLE
} else {
fragmentServicesBinding.llServices.visibility = View.VISIBLE
}

val description = team?.description ?: ""
fragmentServicesBinding.llServices.visibility = View.VISIBLE
fragmentServicesBinding.tvDescription.visibility = View.VISIBLE
if (description.isEmpty()) {
fragmentServicesBinding.tvDescription.visibility = View.GONE
fragmentServicesBinding.tvNoDescription.visibility = View.VISIBLE
} else {
fragmentServicesBinding.tvDescription.visibility = View.VISIBLE
fragmentServicesBinding.tvNoDescription.visibility = View.GONE
}
val markdownContentWithLocalPaths = CourseStepFragment.prependBaseUrlToImages(description, "file://${MainApplication.context.getExternalFilesDir(null)}/ole/")
setMarkdownText(fragmentServicesBinding.tvDescription, markdownContentWithLocalPaths)
setRecyclerView(links)
Expand All @@ -75,25 +83,27 @@ class ServicesFragment : BaseTeamFragment() {

private fun setRecyclerView(links: RealmResults<RealmMyTeam>?) {
fragmentServicesBinding.llServices.removeAllViews()
links?.forEach { team ->
val b: TextView = LayoutInflater.from(activity).inflate(R.layout.button_single, fragmentServicesBinding.llServices, false) as TextView
b.setPadding(8, 8, 8, 8)
b.text = team.title
b.setOnClickListener {
val route = team.route?.split("/")
if (route != null) {
if (route.size >= 3) {
val f = TeamDetailFragment()
val c = Bundle()
val teamObject = mRealm.where(RealmMyTeam::class.java)?.equalTo("_id", route[3])?.findFirst()
c.putString("id", route[3])
teamObject?.isMyTeam(user?.id, mRealm)?.let { it1 -> c.putBoolean("isMyTeam", it1) }
f.arguments = c
(context as OnHomeItemClickListener).openCallFragment(f)
if (links != null) {
links.forEach { team ->
val b: TextView = LayoutInflater.from(activity).inflate(R.layout.button_single, fragmentServicesBinding.llServices, false) as TextView
b.setPadding(8, 8, 8, 8)
b.text = team.title
b.setOnClickListener {
val route = team.route?.split("/")
if (route != null) {
if (route.size >= 3) {
val f = TeamDetailFragment()
val c = Bundle()
val teamObject = mRealm.where(RealmMyTeam::class.java)?.equalTo("_id", route[3])?.findFirst()
c.putString("id", route[3])
teamObject?.isMyTeam(user?.id, mRealm)?.let { it1 -> c.putBoolean("isMyTeam", it1) }
f.arguments = c
(context as OnHomeItemClickListener).openCallFragment(f)
}
}
}
fragmentServicesBinding.llServices.addView(b)
}
fragmentServicesBinding.llServices.addView(b)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class AdapterCourses(private val context: Context, private var courseList: List<
private val config: ChipCloudConfig
private var isAscending = true
private var isTitleAscending = false
private var areAllSelected = true
private var areAllSelected = false
var userModel: RealmUserModel?= null

init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class CourseStepFragment : BaseContainerFragment(), ImageCaptureCallback {

fragmentCourseStepBinding.btnTakeSurvey.setOnClickListener {
if (stepSurvey.isNotEmpty()) {
AdapterMySubmission.openSurvey(homeItemClickListener, stepSurvey[0].id, false)
AdapterMySubmission.openSurvey(homeItemClickListener, stepSurvey[0].id, false, false, "")
}
}
val downloadedResources: List<RealmMyLibrary> = cRealm.where(RealmMyLibrary::class.java).equalTo("stepId", stepId).equalTo("resourceOffline", true).isNotNull("resourceLocalAddress").findAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class CoursesFragment : BaseRecyclerFragment<RealmMyCourse?>(), OnCourseItemSele
lateinit var spnSubject: Spinner
lateinit var searchTags: MutableList<RealmTag>
private lateinit var confirmation: AlertDialog
private var isCheckboxChangedByCode = false
override fun getLayout(): Int {
return R.layout.fragment_my_course
}
Expand Down Expand Up @@ -156,7 +157,7 @@ class CoursesFragment : BaseRecyclerFragment<RealmMyCourse?>(), OnCourseItemSele
clearTags()
showNoData(tvMessage, adapterCourses.itemCount, "courses")
setupUI(requireView().findViewById(R.id.my_course_parent_layout), requireActivity())
changeButtonStatus()

if (!isMyCourseLib) tvFragmentInfo.setText(R.string.our_courses)
additionalSetup()

Expand Down Expand Up @@ -212,7 +213,7 @@ class CoursesFragment : BaseRecyclerFragment<RealmMyCourse?>(), OnCourseItemSele
requireView().findViewById<View>(R.id.tl_tags).visibility = View.GONE
tvFragmentInfo = requireView().findViewById(R.id.tv_fragment_info)
val gradeAdapter = ArrayAdapter.createFromResource(requireContext(), R.array.grade_level, R.layout.spinner_item)
gradeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
gradeAdapter.setDropDownViewResource(R.layout.custom_simple_list_item_1)
spnGrade.adapter = gradeAdapter

val subjectAdapter = ArrayAdapter.createFromResource(requireContext(), R.array.subject_level, R.layout.spinner_item)
Expand All @@ -221,25 +222,28 @@ class CoursesFragment : BaseRecyclerFragment<RealmMyCourse?>(), OnCourseItemSele

spnGrade.onItemSelectedListener = itemSelectedListener
spnSubject.onItemSelectedListener = itemSelectedListener
selectAll = requireView().findViewById(R.id.selectAll)
selectAll = requireView().findViewById(R.id.selectAllCourse)
if (userModel?.isGuest() == true) {
tvAddToLib.visibility = View.GONE
btnRemove.visibility = View.GONE
btnArchive.visibility = View.GONE
selectAll.visibility = View.GONE
}
checkList()
selectAll.setOnClickListener {
val allSelected = selectedItems?.size == adapterCourses.getCourseList().size
adapterCourses.selectAllItems(!allSelected)
if (allSelected) {
selectAll.isChecked = false
selectAll.text = getString(R.string.select_all)
} else {
selectAll.isChecked = true
selectAll.setOnCheckedChangeListener { _, isChecked ->
if (isCheckboxChangedByCode) {
isCheckboxChangedByCode = false
return@setOnCheckedChangeListener
}
if (isChecked) {
adapterCourses.selectAllItems(true)
selectAll.text = getString(R.string.unselect_all)
} else {
adapterCourses.selectAllItems(false)
selectAll.text = getString(R.string.select_all)
}
}

checkList()
}

Expand Down Expand Up @@ -338,16 +342,20 @@ class CoursesFragment : BaseRecyclerFragment<RealmMyCourse?>(), OnCourseItemSele
showTagText(searchTags, tvSelected)
showNoData(tvMessage, adapterCourses.itemCount, "courses")
}

private fun updateCheckBoxState(programmaticState: Boolean) {
isCheckboxChangedByCode = true
selectAll.isChecked = programmaticState
isCheckboxChangedByCode = false
}
private fun changeButtonStatus() {
tvAddToLib.isEnabled = (selectedItems?.size ?: 0) > 0
btnRemove.isEnabled = (selectedItems?.size ?: 0) > 0
btnArchive.isEnabled = (selectedItems?.size ?: 0) > 0
if (adapterCourses.areAllSelected()) {
selectAll.isChecked = true
updateCheckBoxState(true)
selectAll.text = getString(R.string.unselect_all)
} else {
selectAll.isChecked = false
updateCheckBoxState(false)
selectAll.text = getString(R.string.select_all)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ open class BaseDashboardFragment : BaseDashboardFragmentPlugin(), NotificationCa
v.findViewById<LinearLayout>(R.id.ll_prompt).visibility = View.VISIBLE
v.findViewById<LinearLayout>(R.id.ll_prompt).setOnClickListener {
if (!childFragmentManager.isStateSaved) {
UserInformationFragment.getInstance("").show(childFragmentManager, "")
UserInformationFragment.getInstance("", "").show(childFragmentManager, "")
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class BellDashboardFragment : BaseDashboardFragment() {
checkPendingSurveys()

if (model?.id?.startsWith("guest") == false && TextUtils.isEmpty(model?.key) && MainApplication.showHealthDialog) {
AlertDialog.Builder(requireActivity())
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()
Expand Down Expand Up @@ -144,7 +144,7 @@ class BellDashboardFragment : BaseDashboardFragment() {

val adapter = SurveyAdapter(surveyTitles, { position ->
val selectedSurvey = pendingSurveys[position].id
AdapterMySubmission.openSurvey(homeItemClickListener, selectedSurvey, true)
AdapterMySubmission.openSurvey(homeItemClickListener, selectedSurvey, true, false, "")
}, alertDialog)

recyclerView.adapter = adapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ class NotificationsFragment : Fragment() {
"survey" -> {
val currentStepExam = mRealm.where(RealmStepExam::class.java).equalTo("name", notification.relatedId)
.findFirst()
if(context is OnHomeItemClickListener) {
AdapterMySubmission.openSurvey(context as OnHomeItemClickListener, currentStepExam?.id, false)
if (context is OnHomeItemClickListener) {
AdapterMySubmission.openSurvey(context as OnHomeItemClickListener, currentStepExam?.id, false, false, "")
}
}
"task" -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ class FinanceFragment : BaseTeamFragment() {
list = fRealm.where(RealmMyTeam::class.java).notEqualTo("status", "archived")
.equalTo("teamId", teamId).equalTo("docType", "transaction")
.sort("date", Sort.DESCENDING).findAllAsync()

list?.addChangeListener { results ->
updatedFinanceList(results)
}
Expand Down Expand Up @@ -191,11 +190,19 @@ class FinanceFragment : BaseTeamFragment() {

private fun updatedFinanceList(results: RealmResults<RealmMyTeam>) {
activity?.runOnUiThread {
adapterFinance = AdapterFinance(requireActivity(), results)
fragmentFinanceBinding.rvFinance.layoutManager = LinearLayoutManager(activity)
fragmentFinanceBinding.rvFinance.adapter = adapterFinance
adapterFinance?.notifyDataSetChanged()
calculateTotal(results)
if (!results.isEmpty()) {
adapterFinance = AdapterFinance(requireActivity(), results)
fragmentFinanceBinding.rvFinance.layoutManager = LinearLayoutManager(activity)
fragmentFinanceBinding.rvFinance.adapter = adapterFinance
adapterFinance?.notifyDataSetChanged()
calculateTotal(results)
} else {
fragmentFinanceBinding.rvFinance.adapter = null
fragmentFinanceBinding.dataLayout.visibility= View.GONE
fragmentFinanceBinding.tvNodata.visibility= View.VISIBLE

}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ abstract class BaseExamFragment : Fragment(), ImageCaptureCallback {
var date = Date().toString()
private var photoPath: String? = ""
var submitId = ""
private var isTeam: Boolean = false
private var teamId: String? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
db = DatabaseService(requireActivity())
Expand All @@ -60,6 +63,8 @@ abstract class BaseExamFragment : Fragment(), ImageCaptureCallback {
stepId = requireArguments().getString("stepId")
stepNumber = requireArguments().getInt("stepNum")
isMySurvey = requireArguments().getBoolean("isMySurvey")
isTeam = requireArguments().getBoolean("isTeam", false)
teamId = requireArguments().getString("teamId")
checkId()
checkType()
}
Expand Down Expand Up @@ -108,6 +113,8 @@ abstract class BaseExamFragment : Fragment(), ImageCaptureCallback {
private fun continueExam() {
if (currentIndex < (questions?.size ?: 0)) {
startExam(questions?.get(currentIndex))
} else if (isTeam == true && type?.startsWith("survey") == true) {
showUserInfoDialog()
} else {
saveCourseProgress()
AlertDialog.Builder(requireActivity(), R.style.AlertDialogTheme)
Expand All @@ -131,7 +138,7 @@ abstract class BaseExamFragment : Fragment(), ImageCaptureCallback {

private fun showUserInfoDialog() {
if (!isMySurvey && !exam?.isFromNation!!) {
UserInformationFragment.getInstance(sub?.id).show(childFragmentManager, "")
UserInformationFragment.getInstance(sub?.id, teamId).show(childFragmentManager, "")
} else {
if (!mRealm.isInTransaction) mRealm.beginTransaction()
sub?.status = "complete"
Expand Down
Loading

0 comments on commit 1f78e83

Please sign in to comment.