diff --git a/app/build.gradle b/app/build.gradle index 97458029b9..5fb1ec0fe6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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 @@ -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' diff --git a/app/src/main/java/org/ole/planet/myplanet/base/BaseDialogFragment.kt b/app/src/main/java/org/ole/planet/myplanet/base/BaseDialogFragment.kt index 298697e04f..76ea2a2eba 100644 --- a/app/src/main/java/org/ole/planet/myplanet/base/BaseDialogFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/base/BaseDialogFragment.kt @@ -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") } } diff --git a/app/src/main/java/org/ole/planet/myplanet/base/BaseResourceFragment.kt b/app/src/main/java/org/ole/planet/myplanet/base/BaseResourceFragment.kt index bf9c5e2fc5..9cd57e0149 100644 --- a/app/src/main/java/org/ole/planet/myplanet/base/BaseResourceFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/base/BaseResourceFragment.kt @@ -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() } diff --git a/app/src/main/java/org/ole/planet/myplanet/model/RealmStepExam.kt b/app/src/main/java/org/ole/planet/myplanet/model/RealmStepExam.kt index 54bf32ae29..f35413787e 100644 --- a/app/src/main/java/org/ole/planet/myplanet/model/RealmStepExam.kt +++ b/app/src/main/java/org/ole/planet/myplanet/model/RealmStepExam.kt @@ -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> = mutableListOf() @@ -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) @@ -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) } @@ -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) } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/community/ServicesFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/community/ServicesFragment.kt index 1eb4515e97..ee713c4d8c 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/community/ServicesFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/community/ServicesFragment.kt @@ -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) @@ -75,25 +83,27 @@ class ServicesFragment : BaseTeamFragment() { private fun setRecyclerView(links: RealmResults?) { 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) } } } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/courses/AdapterCourses.kt b/app/src/main/java/org/ole/planet/myplanet/ui/courses/AdapterCourses.kt index 760cc284ed..d066902cbb 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/courses/AdapterCourses.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/courses/AdapterCourses.kt @@ -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 { diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/courses/CourseStepFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/courses/CourseStepFragment.kt index 2bd0edf5e2..2a9d992d01 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/courses/CourseStepFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/courses/CourseStepFragment.kt @@ -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 = cRealm.where(RealmMyLibrary::class.java).equalTo("stepId", stepId).equalTo("resourceOffline", true).isNotNull("resourceLocalAddress").findAll() diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/courses/CoursesFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/courses/CoursesFragment.kt index 8d0cfebeb0..bf35d3613c 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/courses/CoursesFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/courses/CoursesFragment.kt @@ -63,6 +63,7 @@ class CoursesFragment : BaseRecyclerFragment(), OnCourseItemSele lateinit var spnSubject: Spinner lateinit var searchTags: MutableList private lateinit var confirmation: AlertDialog + private var isCheckboxChangedByCode = false override fun getLayout(): Int { return R.layout.fragment_my_course } @@ -156,7 +157,7 @@ class CoursesFragment : BaseRecyclerFragment(), 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() @@ -212,7 +213,7 @@ class CoursesFragment : BaseRecyclerFragment(), OnCourseItemSele requireView().findViewById(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) @@ -221,7 +222,7 @@ class CoursesFragment : BaseRecyclerFragment(), 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 @@ -229,17 +230,20 @@ class CoursesFragment : BaseRecyclerFragment(), OnCourseItemSele 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() } @@ -338,16 +342,20 @@ class CoursesFragment : BaseRecyclerFragment(), 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) } } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/BaseDashboardFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/BaseDashboardFragment.kt index a098a68874..27898343f9 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/BaseDashboardFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/BaseDashboardFragment.kt @@ -73,7 +73,7 @@ open class BaseDashboardFragment : BaseDashboardFragmentPlugin(), NotificationCa v.findViewById(R.id.ll_prompt).visibility = View.VISIBLE v.findViewById(R.id.ll_prompt).setOnClickListener { if (!childFragmentManager.isStateSaved) { - UserInformationFragment.getInstance("").show(childFragmentManager, "") + UserInformationFragment.getInstance("", "").show(childFragmentManager, "") } } } else { diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/BellDashboardFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/BellDashboardFragment.kt index 8c30778460..a8b0e42b54 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/BellDashboardFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/BellDashboardFragment.kt @@ -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() @@ -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 diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/notification/NotificationsFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/notification/NotificationsFragment.kt index 8b7214309e..e63f4a689d 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/notification/NotificationsFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/dashboard/notification/NotificationsFragment.kt @@ -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" -> { diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/enterprises/FinanceFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/enterprises/FinanceFragment.kt index e2be64e8bc..ee06e2e013 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/enterprises/FinanceFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/enterprises/FinanceFragment.kt @@ -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) } @@ -191,11 +190,19 @@ class FinanceFragment : BaseTeamFragment() { private fun updatedFinanceList(results: RealmResults) { 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 + + } } } + } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/exam/BaseExamFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/exam/BaseExamFragment.kt index 5a7a0402be..b0986ae8a7 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/exam/BaseExamFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/exam/BaseExamFragment.kt @@ -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()) @@ -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() } @@ -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) @@ -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" diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/exam/UserInformationFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/exam/UserInformationFragment.kt index 6fa96ca8b4..ddc5621e92 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/exam/UserInformationFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/exam/UserInformationFragment.kt @@ -16,11 +16,13 @@ import io.realm.Realm import org.ole.planet.myplanet.MainApplication import org.ole.planet.myplanet.R import org.ole.planet.myplanet.base.BaseDialogFragment +import org.ole.planet.myplanet.callback.OnHomeItemClickListener import org.ole.planet.myplanet.databinding.FragmentUserInformationBinding import org.ole.planet.myplanet.datamanager.DatabaseService import org.ole.planet.myplanet.model.RealmSubmission import org.ole.planet.myplanet.model.RealmUserModel import org.ole.planet.myplanet.service.UserProfileDbHandler +import org.ole.planet.myplanet.ui.team.TeamDetailFragment import org.ole.planet.myplanet.utilities.Utilities import java.util.Calendar import java.util.Locale @@ -31,6 +33,7 @@ class UserInformationFragment : BaseDialogFragment(), View.OnClickListener { lateinit var mRealm: Realm private var submissions: RealmSubmission? = null var userModel: RealmUserModel? = null + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { fragmentUserInformationBinding = FragmentUserInformationBinding.inflate(inflater, container, false) mRealm = DatabaseService(requireActivity()).realmInstance @@ -45,16 +48,8 @@ class UserInformationFragment : BaseDialogFragment(), View.OnClickListener { private fun initViews() { val langArray = resources.getStringArray(R.array.language).toMutableList() val levelArray = resources.getStringArray(R.array.level).toMutableList() - val adapterLang = ArrayAdapter( - requireContext(), - R.layout.spinner_item_white, - langArray - ) - val adapterLevel = ArrayAdapter( - requireContext(), - R.layout.spinner_item_white, - levelArray - ) + val adapterLang = ArrayAdapter(requireContext(), R.layout.spinner_item_white, langArray) + val adapterLevel = ArrayAdapter(requireContext(), R.layout.spinner_item_white, levelArray) adapterLang.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) adapterLevel.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) fragmentUserInformationBinding.spnLang.adapter = adapterLang @@ -67,13 +62,18 @@ class UserInformationFragment : BaseDialogFragment(), View.OnClickListener { val selectedView = fragmentUserInformationBinding.spnLevel.selectedView as? TextView selectedView?.setTextColor(ContextCompat.getColor(requireContext(), R.color.daynight_textColor)) } - fragmentUserInformationBinding.etEmail.setText(getString(R.string.message_placeholder, userModel?.email)) - fragmentUserInformationBinding.etFname.setText(getString(R.string.message_placeholder, userModel?.firstName)) - fragmentUserInformationBinding.etLname.setText(getString(R.string.message_placeholder, userModel?.lastName)) - fragmentUserInformationBinding.etPhone.setText(getString(R.string.message_placeholder, userModel?.phoneNumber)) - fragmentUserInformationBinding.txtDob.text = getString(R.string.message_placeholder, userModel?.dob) - dob = userModel?.dob - fragmentUserInformationBinding.btnCancel.setOnClickListener(this) +// fragmentUserInformationBinding.etEmail.setText(getString(R.string.message_placeholder, userModel?.email)) +// fragmentUserInformationBinding.etFname.setText(getString(R.string.message_placeholder, userModel?.firstName)) +// fragmentUserInformationBinding.etLname.setText(getString(R.string.message_placeholder, userModel?.lastName)) +// fragmentUserInformationBinding.etPhone.setText(getString(R.string.message_placeholder, userModel?.phoneNumber)) +// fragmentUserInformationBinding.txtDob.text = getString(R.string.message_placeholder, userModel?.dob) +// dob = userModel?.dob + if (teamId != null) { + fragmentUserInformationBinding.btnCancel.visibility = View.GONE + } else { + fragmentUserInformationBinding.btnCancel.setOnClickListener(this) + } + fragmentUserInformationBinding.btnSubmit.setOnClickListener(this) fragmentUserInformationBinding.txtDob.setOnClickListener(this) } @@ -157,7 +157,19 @@ class UserInformationFragment : BaseDialogFragment(), View.OnClickListener { override fun onDismiss(dialog: DialogInterface) { super.onDismiss(dialog) Utilities.toast(activity, getString(R.string.thank_you_for_taking_this_survey)) - BaseExamFragment.navigateToSurveyList(requireActivity()) + if (teamId == null) { + BaseExamFragment.navigateToSurveyList(requireActivity()) + } else { + if (context is OnHomeItemClickListener) { + val f = TeamDetailFragment() + val b = Bundle() + b.putString("id", teamId) + b.putBoolean("isMyTeam", true) + b.putInt("navigateToPage", 6) + f.arguments = b + (context as OnHomeItemClickListener).openCallFragment(f) + } + } } private fun showDatePickerDialog() { @@ -173,15 +185,16 @@ class UserInformationFragment : BaseDialogFragment(), View.OnClickListener { get() = "sub_id" companion object { - fun getInstance(id: String?): UserInformationFragment { + fun getInstance(id: String?, teamId: String?): UserInformationFragment { val f = UserInformationFragment() - setArgs(f, id) + setArgs(f, id, teamId) return f } - private fun setArgs(f: UserInformationFragment, id: String?) { + private fun setArgs(f: UserInformationFragment, id: String?, teamId: String?) { val b = Bundle() b.putString("sub_id", id) + b.putString("teamId", teamId) f.arguments = b } } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/myhealth/MyHealthFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/myhealth/MyHealthFragment.kt index 51b0c4b61b..7e3cdb78ad 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/myhealth/MyHealthFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/myhealth/MyHealthFragment.kt @@ -117,7 +117,7 @@ class MyHealthFragment : Fragment() { dialog?.dismiss() } sortList(alertHealthListBinding.spnSort, alertHealthListBinding.list) - dialog = AlertDialog.Builder(requireActivity()) + dialog = AlertDialog.Builder(requireActivity(),R.style.AlertDialogTheme) .setTitle(getString(R.string.select_health_member)).setView(alertHealthListBinding.root) .setCancelable(false).setNegativeButton(R.string.dismiss, null).create() dialog?.show() diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/submission/AdapterMySubmission.kt b/app/src/main/java/org/ole/planet/myplanet/ui/submission/AdapterMySubmission.kt index 32bea6baf2..19d8e38c49 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/submission/AdapterMySubmission.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/submission/AdapterMySubmission.kt @@ -54,7 +54,7 @@ class AdapterMySubmission(private val context: Context, private val list: List() { +class AdapterSurvey(private val context: Context, private val mRealm: Realm, private val userId: String, private val isTeam: Boolean, val teamId: String?) : RecyclerView.Adapter() { private var examList: List = emptyList() private var listener: OnHomeItemClickListener? = null - private var user: RealmUserModel? = null init { if (context is OnHomeItemClickListener) { listener = context } - user = UserProfileDbHandler(context).userModel } fun updateData(newList: List) { @@ -63,7 +59,7 @@ class AdapterSurvey(private val context: Context, private val mRealm: Realm, pri binding.apply { tvTitle.text = exam.name startSurvey.setOnClickListener { - AdapterMySubmission.openSurvey(listener, exam.id, false) + AdapterMySubmission.openSurvey(listener, exam.id, false, isTeam, teamId) } val questions = mRealm.where(RealmExamQuestion::class.java) @@ -81,12 +77,12 @@ class AdapterSurvey(private val context: Context, private val mRealm: Realm, pri context.getString(R.string.record_survey) } - if (user?.id?.startsWith("guest") == true) { + if (userId.startsWith("guest") == true) { startSurvey.visibility = View.GONE } - tvNoSubmissions.text = getNoOfSubmissionByUser(exam.id, exam.courseId, user?.id, mRealm) - tvDateCompleted.text = getRecentSubmissionDate(exam.id, exam.courseId, user?.id, mRealm) + tvNoSubmissions.text = getNoOfSubmissionByUser(exam.id, exam.courseId, userId, mRealm) + tvDateCompleted.text = getRecentSubmissionDate(exam.id, exam.courseId, userId, mRealm) tvDate.text = formatDate(RealmStepExam.getSurveyCreationTime(exam.id!!, mRealm)!!, "MMM dd, yyyy") } } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/survey/SurveyFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/survey/SurveyFragment.kt index 3d935e0dae..189fe4942a 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/survey/SurveyFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/survey/SurveyFragment.kt @@ -17,6 +17,8 @@ class SurveyFragment : BaseRecyclerFragment() { private lateinit var spn: CustomSpinner private var isTitleAscending = true private lateinit var adapter: AdapterSurvey + private var isTeam: Boolean = false + private var teamId: String? = null override fun getLayout(): Int { return R.layout.fragment_survey @@ -24,7 +26,9 @@ class SurveyFragment : BaseRecyclerFragment() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - adapter = AdapterSurvey(requireActivity(), mRealm, model?.id ?: "") + isTeam = arguments?.getBoolean("isTeam", false) == true + teamId = arguments?.getString("teamId", null) + adapter = AdapterSurvey(requireActivity(), mRealm, model?.id ?: "", isTeam, teamId) } override fun getAdapter(): RecyclerView.Adapter<*> { @@ -78,8 +82,18 @@ class SurveyFragment : BaseRecyclerFragment() { } private fun updateAdapterData(sort: Sort = Sort.ASCENDING, field: String = "name") { - val newList = getList(RealmStepExam::class.java, field, sort) - adapter.updateData(safeCastList(newList, RealmStepExam::class.java)) + val query = mRealm.where(RealmStepExam::class.java) + + val surveys = if (teamId != null && isTeam) { + query.equalTo("teamId", teamId) + .sort(field, sort) + .findAll() + } else { + query.sort(field, sort) + .findAll() + } + + adapter.updateData(safeCastList(surveys, RealmStepExam::class.java)) updateUIState() } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/sync/LoginActivity.kt b/app/src/main/java/org/ole/planet/myplanet/ui/sync/LoginActivity.kt index d0eed59e4f..3292f759c4 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/sync/LoginActivity.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/sync/LoginActivity.kt @@ -236,7 +236,7 @@ class LoginActivity : SyncActivity(), TeamListAdapter.OnItemClickListener { if (!teams.isNullOrEmpty()) { activityLoginBinding.team.visibility = View.VISIBLE teamAdapter = ArrayAdapter(this, R.layout.spinner_item_white, teamList) - teamAdapter?.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item) + teamAdapter?.setDropDownViewResource(R.layout.custom_simple_list_item_1) teamList.clear() teamList.add(getString(R.string.select_team)) for (team in teams) { diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/team/TeamPagerAdapter.kt b/app/src/main/java/org/ole/planet/myplanet/ui/team/TeamPagerAdapter.kt index fe671d9457..f3e678cf0e 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/team/TeamPagerAdapter.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/team/TeamPagerAdapter.kt @@ -12,6 +12,7 @@ import org.ole.planet.myplanet.model.RealmMyTeam import org.ole.planet.myplanet.ui.enterprises.EnterpriseCalendarFragment import org.ole.planet.myplanet.ui.enterprises.FinanceFragment import org.ole.planet.myplanet.ui.enterprises.ReportsFragment +import org.ole.planet.myplanet.ui.survey.SurveyFragment import org.ole.planet.myplanet.ui.team.teamCourse.TeamCourseFragment import org.ole.planet.myplanet.ui.team.teamDiscussion.DiscussionListFragment import org.ole.planet.myplanet.ui.team.teamMember.JoinedMemberFragment @@ -25,20 +26,22 @@ class TeamPagerAdapter(fm: FragmentActivity, team: RealmMyTeam?, isInMyTeam: Boo private val isEnterprise: Boolean = TextUtils.equals(team?.type, "enterprise") init { - list.add(context.getString(if (isEnterprise) R.string.mission else R.string.plan)) - list.add(context.getString(if (isEnterprise) R.string.team else R.string.members)) if (isInMyTeam || team?.isPublic == true) { list.add(context.getString(R.string.chat)) + list.add(context.getString(if (isEnterprise) R.string.mission else R.string.plan)) + list.add(context.getString(if (isEnterprise) R.string.team else R.string.members)) list.add(context.getString(R.string.tasks)) list.add(context.getString(R.string.calendar)) + list.add(context.getString(R.string.survey)) list.add(context.getString(if (isEnterprise) R.string.finances else R.string.courses)) - if (isEnterprise) list.add(context.getString(R.string.reports)) + if (isEnterprise) { + list.add(context.getString(R.string.reports)) + } list.add(context.getString(if (isEnterprise) R.string.documents else R.string.resources)) list.add(context.getString(if (isEnterprise) R.string.applicants else R.string.join_requests)) - list.removeAt(0) - list.removeAt(0) - list.add(1, context.getString(if (isEnterprise) R.string.mission else R.string.plan)) - list.add(2, context.getString(if (isEnterprise) R.string.team else R.string.members)) + } else { + list.add(context.getString(if (isEnterprise) R.string.mission else R.string.plan)) + list.add(context.getString(if (isEnterprise) R.string.team else R.string.members)) } } @@ -56,6 +59,12 @@ class TeamPagerAdapter(fm: FragmentActivity, team: RealmMyTeam?, isInMyTeam: Boo context.getString(R.string.members), context.getString(R.string.team) -> JoinedMemberFragment() context.getString(R.string.tasks) -> TeamTaskFragment() context.getString(R.string.calendar) -> EnterpriseCalendarFragment() + context.getString(R.string.survey) -> SurveyFragment().apply { + arguments = Bundle().apply { + putBoolean("isTeam", true) + putString("teamId", teamId) + } + } context.getString(R.string.courses) -> TeamCourseFragment() context.getString(R.string.finances) -> FinanceFragment() context.getString(R.string.reports) -> ReportsFragment() @@ -63,10 +72,11 @@ class TeamPagerAdapter(fm: FragmentActivity, team: RealmMyTeam?, isInMyTeam: Boo context.getString(R.string.join_requests), context.getString(R.string.applicants) -> MembersFragment() else -> throw IllegalArgumentException("Invalid fragment type for position: $position") } - - val bundle = Bundle() - bundle.putString("id", teamId) - fragment.arguments = bundle + if (fragment.arguments == null) { + fragment.arguments = Bundle().apply { + putString("id", teamId) + } + } return fragment } diff --git a/app/src/main/res/color/toggle_text_color.xml b/app/src/main/res/color/toggle_text_color.xml new file mode 100644 index 0000000000..3f993e5998 --- /dev/null +++ b/app/src/main/res/color/toggle_text_color.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/bg_submission_toggle_button.xml b/app/src/main/res/drawable/bg_submission_toggle_button.xml new file mode 100644 index 0000000000..fbb8fd0f73 --- /dev/null +++ b/app/src/main/res/drawable/bg_submission_toggle_button.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/submission_toggle.xml b/app/src/main/res/drawable/submission_toggle.xml new file mode 100644 index 0000000000..8ae1811f43 --- /dev/null +++ b/app/src/main/res/drawable/submission_toggle.xml @@ -0,0 +1,9 @@ + + + + + + diff --git a/app/src/main/res/layout/alert_health_list.xml b/app/src/main/res/layout/alert_health_list.xml index c702b703cd..be4c90eca7 100644 --- a/app/src/main/res/layout/alert_health_list.xml +++ b/app/src/main/res/layout/alert_health_list.xml @@ -4,21 +4,24 @@ android:layout_width="match_parent" android:layout_height="fill_parent" android:gravity="center" + android:background="@color/secondary_bg" android:orientation="vertical"> - -