Skip to content

Commit

Permalink
Merge branch 'master' into 4526-viewicon-library
Browse files Browse the repository at this point in the history
  • Loading branch information
dogi authored Oct 15, 2024
2 parents f66d96b + 50c14c4 commit f7d5f17
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import io.realm.Case
import io.realm.Realm
import org.ole.planet.myplanet.MainApplication
import org.ole.planet.myplanet.R
Expand Down Expand Up @@ -127,40 +126,34 @@ class CourseStepFragment : BaseContainerFragment(), ImageCaptureCallback {
fragmentCourseStepBinding.btnTakeSurvey.visibility = View.GONE
if (stepExams.isNotEmpty()) {
val firstStepId = stepExams[0].id
val questions = cRealm.where(RealmExamQuestion::class.java).equalTo("examId", firstStepId).findAll()
val submissionsCount = step.courseId?.let {
cRealm.where(RealmSubmission::class.java).equalTo("userId",user?.id).contains("parentId", it)
.notEqualTo("status", "pending", Case.INSENSITIVE).count()
}
if (questions != null && questions.size > 0) {
val examId=questions[0]?.examId

val isSubmitted = step.courseId?.let { courseId ->
val parentId = "$examId@$courseId"
cRealm.where(RealmSubmission::class.java)
.equalTo("userId",user?.id)
.equalTo("parentId", parentId)
.equalTo("type", "exam")
.findFirst() != null
} ?: false
fragmentCourseStepBinding.btnTakeTest.text = if (isSubmitted) { getString(R.string.retake_test, stepExams.size) } else { getString(R.string.take_test, stepExams.size) }
fragmentCourseStepBinding.btnTakeTest.visibility = View.VISIBLE
}
val isTestPersent = existsSubmission(firstStepId, "exam")
fragmentCourseStepBinding.btnTakeTest.text = if (isTestPersent) { getString(R.string.retake_test, stepExams.size) } else { getString(R.string.take_test, stepExams.size) }
fragmentCourseStepBinding.btnTakeTest.visibility = View.VISIBLE
}
if (stepSurvey.isNotEmpty()) {
val firstStepId = stepSurvey[0].id
val questions = cRealm.where(RealmExamQuestion::class.java).equalTo("examId", firstStepId).findAll()
val submissionsCount = step.courseId?.let {
cRealm.where(RealmSubmission::class.java).contains("parentId", it)
.notEqualTo("status", "pending", Case.INSENSITIVE).count()
}
if (questions != null && questions.size > 0) {
if (submissionsCount != null) {
fragmentCourseStepBinding.btnTakeSurvey.text = if (submissionsCount > 0) { "redo survey" } else { "record survey" }
}
fragmentCourseStepBinding.btnTakeSurvey.visibility = View.VISIBLE
val isSurveyPresent = existsSubmission(firstStepId, "survey")
fragmentCourseStepBinding.btnTakeSurvey.text = if (isSurveyPresent) { "redo survey" } else { "record survey" }
fragmentCourseStepBinding.btnTakeSurvey.visibility = View.VISIBLE
}
}

private fun existsSubmission(firstStepId:String? , submissionType: String): Boolean{
val questions = cRealm.where(RealmExamQuestion::class.java).equalTo("examId", firstStepId).findAll()
var isPresent=false
if (questions != null && questions.size > 0) {
val examId=questions[0]?.examId
val isSubmitted = step.courseId?.let { courseId ->
val parentId = "$examId@$courseId"
cRealm.where(RealmSubmission::class.java)
.equalTo("userId",user?.id)
.equalTo("parentId", parentId)
.equalTo("type", submissionType)
.findFirst() != null
} ?: false
isPresent= isSubmitted
}
return isPresent
}

override fun setMenuVisibility(visible: Boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ class NotificationsFragment : Fragment() {

override fun onDestroy() {
super.onDestroy()
mRealm.close()
if (::mRealm.isInitialized) {
mRealm.close()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import org.ole.planet.myplanet.model.FeedbackReply
import org.ole.planet.myplanet.model.RealmFeedback
import org.ole.planet.myplanet.ui.dashboard.DashboardActivity
import org.ole.planet.myplanet.ui.feedback.FeedbackDetailActivity.RvFeedbackAdapter.ReplyViewHolder
import org.ole.planet.myplanet.utilities.LocaleHelper
import org.ole.planet.myplanet.utilities.TimeUtils.getFormatedDateWithTime
import java.util.Date

Expand All @@ -33,6 +34,10 @@ class FeedbackDetailActivity : AppCompatActivity() {
lateinit var realm: Realm
private lateinit var rowFeedbackReplyBinding: RowFeedbackReplyBinding

override fun attachBaseContext(base: Context) {
super.attachBaseContext(LocaleHelper.onAttach(base))
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
activityFeedbackDetailBinding = ActivityFeedbackDetailBinding.inflate(layoutInflater)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import android.os.Bundle
import android.text.TextUtils
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import android.widget.Spinner
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import com.google.gson.Gson
import io.realm.Realm
Expand All @@ -19,6 +23,7 @@ import org.ole.planet.myplanet.utilities.AndroidDecrypter.Companion.encrypt
import org.ole.planet.myplanet.utilities.AndroidDecrypter.Companion.generateKey
import org.ole.planet.myplanet.utilities.Utilities


class AddMyHealthActivity : AppCompatActivity() {
private lateinit var activityAddMyHealthBinding: ActivityAddMyHealthBinding
lateinit var realm: Realm
Expand Down Expand Up @@ -47,6 +52,24 @@ class AddMyHealthActivity : AppCompatActivity() {
createMyHealth()
Utilities.toast(this@AddMyHealthActivity, getString(R.string.my_health_saved_successfully))
}
val spinner: Spinner = findViewById(R.id.spn_contact_type)

val adapter = object : ArrayAdapter<String>(
this, R.layout.spinner_item, resources.getStringArray(R.array.contact_type)
) {
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
val view = super.getView(position, convertView, parent) as TextView
return view
}

override fun getDropDownView(position: Int, convertView: View?, parent: ViewGroup): View {
val view = super.getDropDownView(position, convertView, parent) as TextView
return view
}
}

spinner.adapter = adapter

initViews()
}

Expand Down
80 changes: 52 additions & 28 deletions app/src/main/res/layout/activity_add_my_health.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/padding_large"
tools:context=".ui.myhealth.AddMyHealthActivity">
tools:context=".ui.myhealth.AddMyHealthActivity"
android:background="@color/secondary_bg">

<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="@color/secondary_bg">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:orientation="vertical"
android:background="@color/secondary_bg">

<LinearLayout
android:layout_width="match_parent"
Expand All @@ -24,44 +27,49 @@
android:id="@+id/et_fname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
android:layout_weight="1"
android:textColorHint="@color/hint_color">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/first_name"
android:padding="@dimen/padding_normal"
android:backgroundTint="@color/daynight_textColor" />
android:backgroundTint="@color/daynight_textColor"
android:textColor="@color/daynight_textColor" />
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/et_mname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
android:layout_weight="1"
android:textColorHint="@color/hint_color">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/middle_name"
android:padding="@dimen/padding_normal"
android:backgroundTint="@color/daynight_textColor" />
android:backgroundTint="@color/daynight_textColor"
android:textColor="@color/daynight_textColor" />
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/et_lname"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
android:layout_weight="1"
android:textColorHint="@color/hint_color">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/last_name"
android:padding="@dimen/padding_normal"
android:backgroundTint="@color/daynight_textColor" />
android:backgroundTint="@color/daynight_textColor"
android:textColor="@color/daynight_textColor" />
</com.google.android.material.textfield.TextInputLayout>

</LinearLayout>

<LinearLayout
Expand All @@ -72,30 +80,34 @@
android:id="@+id/et_email"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
android:layout_weight="1"
android:textColorHint="@color/hint_color">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/email"
android:inputType="textEmailAddress"
android:padding="@dimen/padding_normal"
android:backgroundTint="@color/daynight_textColor" />
android:backgroundTint="@color/daynight_textColor"
android:textColor="@color/daynight_textColor" />
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/et_phone"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
android:layout_weight="1"
android:textColorHint="@color/hint_color">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/phone_number"
android:inputType="phone"
android:padding="@dimen/padding_normal"
android:backgroundTint="@color/daynight_textColor" />
android:backgroundTint="@color/daynight_textColor"
android:textColor="@color/daynight_textColor" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>

Expand All @@ -107,28 +119,32 @@
android:id="@+id/et_birthplace"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
android:layout_weight="1"
android:textColorHint="@color/hint_color">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/birth_place"
android:padding="@dimen/padding_normal"
android:backgroundTint="@color/daynight_textColor" />
android:backgroundTint="@color/daynight_textColor"
android:textColor="@color/daynight_textColor" />
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/et_birthdate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
android:layout_weight="1"
android:textColorHint="@color/hint_color">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/birth_date"
android:padding="@dimen/padding_normal"
android:backgroundTint="@color/daynight_textColor" />
android:backgroundTint="@color/daynight_textColor"
android:textColor="@color/daynight_textColor" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>

Expand All @@ -140,65 +156,73 @@
android:id="@+id/et_emergency"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
android:layout_weight="1"
android:textColorHint="@color/hint_color">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/emergency_contact"
android:padding="@dimen/padding_normal"
android:backgroundTint="@color/daynight_textColor" />
android:backgroundTint="@color/daynight_textColor"
android:textColor="@color/daynight_textColor" />
</com.google.android.material.textfield.TextInputLayout>

<Spinner
android:id="@+id/spn_contact_type"
style="@style/SpinnerItemStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:entries="@array/contact_type"
android:padding="@dimen/padding_normal" />
android:padding="@dimen/padding_large" />
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/et_contact"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
android:layout_weight="1"
android:textColorHint="@color/hint_color">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/contact"
android:padding="@dimen/padding_normal"
android:backgroundTint="@color/daynight_textColor" />
android:backgroundTint="@color/daynight_textColor"
android:textColor="@color/daynight_textColor" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/et_special_need"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:textColorHint="@color/hint_color">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/special_needs"
android:lines="2"
android:padding="@dimen/padding_normal"
android:backgroundTint="@color/daynight_textColor" />
android:backgroundTint="@color/daynight_textColor"
android:textColor="@color/daynight_textColor" />
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/et_other_need"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:textColorHint="@color/hint_color">

<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/other_need"
android:lines="2"
android:padding="@dimen/padding_normal"
android:backgroundTint="@color/daynight_textColor" />
android:backgroundTint="@color/daynight_textColor"
android:textColor="@color/daynight_textColor" />
</com.google.android.material.textfield.TextInputLayout>

<Button
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,11 @@
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="350dp"
android:layout_marginTop="@dimen/_10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/team" />
app:layout_constraintTop_toBottomOf="@+id/team"
app:layout_constraintVertical_bias="0.1" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</LinearLayout>
Expand Down

0 comments on commit f7d5f17

Please sign in to comment.