Skip to content

Commit

Permalink
Merge branch 'master' into 4933-voices-button
Browse files Browse the repository at this point in the history
  • Loading branch information
dogi authored Jan 6, 2025
2 parents 75f0431 + 21d9a95 commit 387d4c4
Show file tree
Hide file tree
Showing 20 changed files with 197 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class SettingActivity : AppCompatActivity() {
else -> 2
}

val builder = AlertDialog.Builder(context, R.style.CustomAlertDialogStyle)
val builder = AlertDialog.Builder(context, R.style.AlertDialogTheme)
.setTitle(context.getString(R.string.select_theme_mode))
.setSingleChoiceItems(ArrayAdapter(context, R.layout.checked_list_item, options), checkedItem) { dialog, which ->
val selectedMode = when (which) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N
createDrawer()
if (!(user?.id?.startsWith("guest") == true && profileDbHandler.offlineVisits >= 3) && resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
result?.openDrawer()
} //Opens drawer by default
result?.stickyFooter?.setPadding(0, 0, 0, 0) // moves logout button to the very bottom of the drawer. Without it, the "logout" button suspends a little.
}
result?.stickyFooter?.setPadding(0, 0, 0, 0)
result?.actionBarDrawerToggle?.isDrawerIndicatorEnabled = true
dl = result?.drawerLayout
topbarSetting()
Expand Down Expand Up @@ -469,7 +469,7 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N
val pendingSurveys = getPendingSurveys(user?.id)
val surveyTitles = getSurveyTitlesFromSubmissions(pendingSurveys)
surveyTitles.forEach { title ->
createNotificationIfNotExists("survey", "you have a pending survey: $title", title)
createNotificationIfNotExists("survey", "$title", title)
}

val tasks = mRealm.where(RealmTeamTask::class.java)
Expand All @@ -478,18 +478,11 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N
.equalTo("assignee", user?.id)
.findAll()
tasks.forEach { task ->
createNotificationIfNotExists("task", "${task.title} is due in ${formatDate(task.deadline)}", task.id)
createNotificationIfNotExists("task","${task.title} ${formatDate(task.deadline)}", task.id)
}

val storageRatio = totalAvailableMemoryRatio
when {
storageRatio <= 10 -> {
createNotificationIfNotExists("storage", "${getString(R.string.storage_critically_low)} $storageRatio% ${getString(R.string.available_please_free_up_space)}", "storage")
}
storageRatio <= 40 -> {
createNotificationIfNotExists("storage", "${getString(R.string.storage_running_low)} $storageRatio% ${getString(R.string.available)}", "storage")
}
}
createNotificationIfNotExists("storage", "$storageRatio" , "storage")
}

private fun updateResourceNotification() {
Expand All @@ -501,10 +494,10 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N
.findFirst()

if (existingNotification != null) {
existingNotification.message = "you have $resourceCount resources not downloaded"
existingNotification.message = "$resourceCount"
existingNotification.relatedId = "$resourceCount"
} else {
createNotificationIfNotExists("resource", "you have $resourceCount resources not downloaded", "$resourceCount")
createNotificationIfNotExists("resource", "$resourceCount", "$resourceCount")
}
} else {
mRealm.where(RealmNotification::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N
createDrawer()
if (!(user?.id?.startsWith("guest") == true && profileDbHandler.offlineVisits >= 3) && resources.configuration.orientation == Configuration.ORIENTATION_PORTRAIT) {
result?.openDrawer()
} //Opens drawer by default
result?.stickyFooter?.setPadding(0, 0, 0, 0) // moves logout button to the very bottom of the drawer. Without it, the "logout" button suspends a little.
}
result?.stickyFooter?.setPadding(0, 0, 0, 0)
result?.actionBarDrawerToggle?.isDrawerIndicatorEnabled = true
dl = result?.drawerLayout
topbarSetting()
Expand Down Expand Up @@ -469,7 +469,7 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N
val pendingSurveys = getPendingSurveys(user?.id)
val surveyTitles = getSurveyTitlesFromSubmissions(pendingSurveys)
surveyTitles.forEach { title ->
createNotificationIfNotExists("survey", "you have a pending survey: $title", title)
createNotificationIfNotExists("survey", "$title", title)
}

val tasks = mRealm.where(RealmTeamTask::class.java)
Expand All @@ -478,18 +478,11 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N
.equalTo("assignee", user?.id)
.findAll()
tasks.forEach { task ->
createNotificationIfNotExists("task", "${task.title} is due in ${formatDate(task.deadline)}", task.id)
createNotificationIfNotExists("task","${task.title} ${formatDate(task.deadline)}", task.id)
}

val storageRatio = totalAvailableMemoryRatio
when {
storageRatio <= 10 -> {
createNotificationIfNotExists("storage", "${getString(R.string.storage_critically_low)} $storageRatio% ${getString(R.string.available_please_free_up_space)}", "storage")
}
storageRatio <= 40 -> {
createNotificationIfNotExists("storage", "${getString(R.string.storage_running_low)} $storageRatio% ${getString(R.string.available)}", "storage")
}
}
createNotificationIfNotExists("storage", "$storageRatio" , "storage")
}

private fun updateResourceNotification() {
Expand All @@ -501,10 +494,10 @@ class DashboardActivity : DashboardElementActivity(), OnHomeItemClickListener, N
.findFirst()

if (existingNotification != null) {
existingNotification.message = "you have $resourceCount resources not downloaded"
existingNotification.message = "$resourceCount"
existingNotification.relatedId = "$resourceCount"
} else {
createNotificationIfNotExists("resource", "you have $resourceCount resources not downloaded", "$resourceCount")
createNotificationIfNotExists("resource", "$resourceCount", "$resourceCount")
}
} else {
mRealm.where(RealmNotification::class.java)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package org.ole.planet.myplanet.ui.dashboard.notification

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import org.ole.planet.myplanet.R
import org.ole.planet.myplanet.databinding.RowNotificationsBinding
import org.ole.planet.myplanet.model.RealmNotification

class AdapterNotification(var notificationList: List<RealmNotification>, private val onMarkAsReadClick: (Int) -> Unit, private val onNotificationClick: (RealmNotification) -> Unit) : RecyclerView.Adapter<AdapterNotification.ViewHolderNotifications>() {
class AdapterNotification(
var notificationList: List<RealmNotification>,
private val onMarkAsReadClick: (Int) -> Unit,
private val onNotificationClick: (RealmNotification) -> Unit
) : RecyclerView.Adapter<AdapterNotification.ViewHolderNotifications>() {

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolderNotifications {
val rowNotificationsBinding = RowNotificationsBinding.inflate(LayoutInflater.from(parent.context), parent, false)
return ViewHolderNotifications(rowNotificationsBinding)
Expand All @@ -25,9 +32,14 @@ class AdapterNotification(var notificationList: List<RealmNotification>, private
notifyDataSetChanged()
}

inner class ViewHolderNotifications(private val rowNotificationsBinding: RowNotificationsBinding) : RecyclerView.ViewHolder(rowNotificationsBinding.root) {
inner class ViewHolderNotifications(private val rowNotificationsBinding: RowNotificationsBinding) :
RecyclerView.ViewHolder(rowNotificationsBinding.root) {

fun bind(notification: RealmNotification, position: Int) {
rowNotificationsBinding.title.text = notification.message
val context = rowNotificationsBinding.root.context
val currentNotification = formatNotificationMessage(notification, context)
rowNotificationsBinding.title.text = currentNotification

if (notification.isRead) {
rowNotificationsBinding.btnMarkAsRead.visibility = View.GONE
rowNotificationsBinding.root.alpha = 0.5f
Expand All @@ -43,5 +55,38 @@ class AdapterNotification(var notificationList: List<RealmNotification>, private
onNotificationClick(notification)
}
}

private fun formatNotificationMessage(notification: RealmNotification, context: Context): String {
return when (notification.type.lowercase()) {
"survey" -> context.getString(R.string.pending_survey_notification) + " ${notification.message}"
"task" -> {
val parts = notification.message.split(" ")
if (parts.size >= 2) {
val taskTitle = parts[0]
val dateValue = parts.subList(1, parts.size).joinToString(" ")
context.getString(R.string.task_notification, taskTitle, dateValue)
} else {
"INVALID"
}
}
"resource" -> {
val resourceCount = notification.message.toIntOrNull()
resourceCount?.let {
context.getString(R.string.resource_notification, it)
} ?: "INVALID"
}
"storage" -> {
val storageValue = notification.message.toIntOrNull()
storageValue?.let {
when {
it <= 10 -> context.getString(R.string.storage_running_low) +" ${it}%"
it <= 40 -> context.getString(R.string.storage_running_low)+ " ${it}%"
else -> "INVALID"
}
} ?: "INVALID"
}
else -> "INVALID"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ class TeamFragment : Fragment(), AdapterTeamList.OnClickTeamItem {
}

fragmentTeamBinding.addTeam.setOnClickListener { createTeamAlert(null) }

fragmentTeamBinding.tvFragmentInfo.text = if (TextUtils.equals(type, "enterprise")) {
getString(R.string.enterprises)
} else {
getString(R.string.team)
}
teamList = mRealm.where(RealmMyTeam::class.java).isEmpty("teamId")
.notEqualTo("status", "archived").findAllAsync()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.ole.planet.myplanet.ui.viewer

import android.content.pm.ActivityInfo
import android.graphics.Bitmap
import android.net.Uri
import android.os.Build
Expand Down Expand Up @@ -27,7 +28,6 @@ class WebViewActivity : AppCompatActivity() {
val title: String? = intent.getStringExtra("title")
link = intent.getStringExtra("link") ?: ""
val resourceId = intent.getStringExtra("RESOURCE_ID")

clearCookie()
if (!TextUtils.isEmpty(title)) {
activityWebViewBinding.contentWebView.webTitle.text = title
Expand All @@ -43,6 +43,7 @@ class WebViewActivity : AppCompatActivity() {
val indexFile = File(directory, "index.html")

if (indexFile.exists()) {
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
activityWebViewBinding.contentWebView.wv.loadUrl("file://${indexFile.absolutePath}")
}
} else {
Expand Down
27 changes: 19 additions & 8 deletions app/src/main/res/layout-large-land/activity_login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:background="@color/light_dark"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
Expand All @@ -43,7 +44,8 @@
android:textAlignment="center"
app:layout_constraintEnd_toStartOf="@+id/imgBtnSetting"
app:layout_constraintStart_toEndOf="@+id/syncIcon"
app:layout_constraintTop_toTopOf="parent" />
app:layout_constraintTop_toTopOf="parent"
android:textColor="@color/daynight_textColor" />
<ImageButton
android:id="@+id/imgBtnSetting"
android:layout_width="wrap_content"
Expand All @@ -57,7 +59,8 @@
android:paddingEnd="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_settings_black_24dp" />
app:srcCompat="@drawable/ic_settings_black_24dp"
app:tint="@color/daynight_textColor"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand All @@ -81,6 +84,7 @@
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="@string/hint_name"
android:textColorHint="@color/hint_color"
app:boxBackgroundColor="@color/md_white_1000"
app:boxStrokeColor="@color/md_white_1000"
app:boxStrokeWidth="0dp"
Expand All @@ -99,11 +103,11 @@
android:drawablePadding="12dp"
android:contentDescription="@string/hint_name"
android:hint="@string/hint_name"
android:textColorHint="@color/hint_color"
android:textColorHint="@color/daynight_textColor"
android:inputType="text"
android:paddingStart="10dp"
android:paddingEnd="8dp"
android:textColor="@color/md_black_1000" />
android:textColor="@color/daynight_textColor" />
</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
Expand All @@ -112,14 +116,16 @@
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="@string/password"
android:textColorHint="@color/hint_color"
app:boxBackgroundColor="@color/md_white_1000"
app:boxStrokeColor="@color/md_white_1000"
app:boxStrokeWidth="0dp"
app:boxStrokeWidthFocused="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ltInputName"
app:passwordToggleEnabled="true">
app:passwordToggleEnabled="true"
app:passwordToggleTint="@color/daynight_textColor">

<EditText
android:id="@+id/input_password"
Expand All @@ -128,21 +134,22 @@
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:autofillHints=""
android:backgroundTint="@color/daynight_textColor"
android:drawablePadding="12dp"
android:hint="password"
android:textColorHint="@color/hint_color"
android:inputType="textPassword"
android:paddingStart="10dp"
android:paddingEnd="8dp"
android:textColor="@color/md_black_1000" />
android:textColor="@color/daynight_textColor"/>
</com.google.android.material.textfield.TextInputLayout>

<Button
android:id="@+id/btn_signin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@color/colorPrimary"
android:background="@color/mainColor"
android:contentDescription="@string/btn_sign_in"
android:text="@string/btn_sign_in"
android:textColor="@android:color/white"
Expand All @@ -165,6 +172,7 @@
android:layout_height="wrap_content"
android:contentDescription="@string/btn_guest_login"
android:text="@string/btn_guest_login"
android:textColor="@color/daynight_textColor"
android:textSize="14sp"
android:theme="@style/PrimaryFlatButton" />
<Button
Expand All @@ -174,6 +182,7 @@
android:layout_gravity="center"
android:contentDescription="@string/become_a_member"
android:text="@string/become_a_member"
android:textColor="@color/daynight_textColor"
android:theme="@style/PrimaryFlatButton" />
<Button
android:id="@+id/btn_feedback"
Expand All @@ -182,6 +191,7 @@
android:layout_gravity="center"
android:contentDescription="@string/feedback"
android:text="@string/feedback"
android:textColor="@color/daynight_textColor"
android:theme="@style/PrimaryFlatButton" />
</LinearLayout>

Expand All @@ -191,6 +201,7 @@
android:layout_height="wrap_content"
android:contentDescription="@string/open_community"
android:text="@string/open_community"
android:textColor="@color/daynight_textColor"
android:textSize="14sp"
android:theme="@style/PrimaryFlatButton"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down Expand Up @@ -221,7 +232,7 @@
android:paddingStart="@dimen/_10dp"
android:paddingTop="6dp"
android:paddingEnd="@dimen/_10dp"
app:srcCompat="@drawable/sun_35"
app:srcCompat="@drawable/moon_35"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
Expand Down
Loading

0 comments on commit 387d4c4

Please sign in to comment.