Skip to content

Commit

Permalink
Merge branch 'master' into cloudCommunityV4
Browse files Browse the repository at this point in the history
  • Loading branch information
Okuro3499 authored Dec 17, 2024
2 parents 1fd0d45 + f3c7b30 commit 0ccda0e
Show file tree
Hide file tree
Showing 24 changed files with 134 additions and 191 deletions.
8 changes: 4 additions & 4 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 2124
versionName "0.21.24"
versionCode 2140
versionName "0.21.40"
ndkVersion '21.3.6528147'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -202,13 +202,13 @@ dependencies {
implementation 'com.mikepenz:crossfadedrawerlayout:1.1.0@aar'
implementation('com.mikepenz:materialdrawer:6.1.1@aar') { transitive = true}

def camera_version = "1.4.0"
def camera_version = "1.4.1"
implementation "androidx.camera:camera-core:$camera_version"
implementation "androidx.camera:camera-camera2:$camera_version"
implementation "androidx.camera:camera-lifecycle:$camera_version"
implementation "androidx.camera:camera-view:$camera_version"

def dagger_hilt_version = "2.53"
def dagger_hilt_version = "2.53.1"
implementation "com.google.dagger:hilt-android:$dagger_hilt_version"
kapt "com.google.dagger:hilt-android-compiler:$dagger_hilt_version"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import org.ole.planet.myplanet.base.PermissionActivity.Companion.hasInstallPermi
import org.ole.planet.myplanet.callback.OnHomeItemClickListener
import org.ole.planet.myplanet.callback.OnRatingChangeListener
import org.ole.planet.myplanet.model.RealmMyLibrary
import org.ole.planet.myplanet.model.RealmUserChallengeActions
import org.ole.planet.myplanet.model.RealmUserChallengeActions.Companion.createAction
import org.ole.planet.myplanet.service.UserProfileDbHandler
import org.ole.planet.myplanet.service.UserProfileDbHandler.Companion.KEY_RESOURCE_DOWNLOAD
import org.ole.planet.myplanet.service.UserProfileDbHandler.Companion.KEY_RESOURCE_OPEN
Expand Down Expand Up @@ -79,9 +77,7 @@ abstract class BaseContainerFragment : BaseResourceFragment() {
val url = Utilities.getUrl(library)
if (!FileUtils.checkFileExist(url) && !TextUtils.isEmpty(url)) urls.add(url)
}
if (urls.isNotEmpty()) startDownload(urls) else Utilities.toast(
activity, getString(R.string.no_images_to_download)
)
if (urls.isNotEmpty()) startDownload(urls)
}
fun initRatingView(type: String?, id: String?, title: String?, listener: OnRatingChangeListener?) {
timesRated = requireView().findViewById(R.id.times_rated)
Expand Down Expand Up @@ -152,65 +148,32 @@ abstract class BaseContainerFragment : BaseResourceFragment() {
val filenameArray = items.resourceLocalAddress?.split("\\.".toRegex())?.toTypedArray()
val extension = filenameArray?.get(filenameArray.size - 1)
val mimetype = Utilities.getMimeType(items.resourceLocalAddress)
val userId = "${model?.id}"

val existingAction = mRealm.where(RealmUserChallengeActions::class.java)
.equalTo("userId", userId)
.equalTo("resourceId", items.resourceId)
.findFirst()

if (mimetype != null) {
if (mimetype.contains("image")) {
openIntent(items, ImageViewerActivity::class.java)
if (existingAction == null) {
createAction(mRealm, userId, items.resourceId, "resourceOpen")
}
} else if (mimetype.contains("pdf")) {
openPdf(items)
if (existingAction == null) {
createAction(mRealm, userId, items.resourceId, "resourceOpen")
}
} else if (mimetype.contains("audio")) {
openIntent(items, AudioPlayerActivity::class.java)
if (existingAction == null) {
createAction(mRealm, userId, items.resourceId, "resourceOpen")
}
} else {
checkMoreFileExtensions(extension, items)
}
}
}

private fun checkMoreFileExtensions(extension: String?, items: RealmMyLibrary) {
val userId = "${model?.id}"
val existingAction = mRealm.where(RealmUserChallengeActions::class.java)
.equalTo("userId", userId)
.equalTo("resourceId", items.resourceId)
.findFirst()

when (extension) {
"txt" -> {
if (existingAction == null) {
createAction(mRealm, userId, items.resourceId, "resourceOpen")
}
openIntent(items, TextFileViewerActivity::class.java)
}
"md" -> {
if (existingAction == null) {
createAction(mRealm, userId, items.resourceId, "resourceOpen")
}
openIntent(items, MarkdownViewerActivity::class.java)
}
"csv" -> {
if (existingAction == null) {
createAction(mRealm, userId, items.resourceId, "resourceOpen")
}
openIntent(items, CSVViewerActivity::class.java)
}
"apk" -> {
if (existingAction == null) {
createAction(mRealm, userId, items.resourceId, "resourceOpen")
}
installApk(items)
}
else -> Toast.makeText(activity, getString(R.string.this_file_type_is_currently_unsupported), Toast.LENGTH_LONG).show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import android.widget.ArrayAdapter
import android.widget.Button
import android.widget.TextView
import android.widget.Toast
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
//import androidx.activity.result.ActivityResultLauncher
//import androidx.activity.result.contract.ActivityResultContracts
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.view.ContextThemeWrapper
import androidx.appcompat.widget.AppCompatRatingBar
Expand All @@ -29,8 +29,6 @@ import org.ole.planet.myplanet.R
import org.ole.planet.myplanet.callback.OnHomeItemClickListener
import org.ole.planet.myplanet.callback.OnRatingChangeListener
import org.ole.planet.myplanet.model.RealmMyLibrary
import org.ole.planet.myplanet.model.RealmUserChallengeActions
import org.ole.planet.myplanet.model.RealmUserChallengeActions.Companion.createAction
import org.ole.planet.myplanet.service.UserProfileDbHandler
import org.ole.planet.myplanet.service.UserProfileDbHandler.Companion.KEY_RESOURCE_DOWNLOAD
import org.ole.planet.myplanet.service.UserProfileDbHandler.Companion.KEY_RESOURCE_OPEN
Expand Down Expand Up @@ -79,9 +77,7 @@ abstract class BaseContainerFragment : BaseResourceFragment() {
val url = Utilities.getUrl(library)
if (!FileUtils.checkFileExist(url) && !TextUtils.isEmpty(url)) urls.add(url)
}
if (urls.isNotEmpty()) startDownload(urls) else Utilities.toast(
activity, getString(R.string.no_images_to_download)
)
if (urls.isNotEmpty()) startDownload(urls)
}
fun initRatingView(type: String?, id: String?, title: String?, listener: OnRatingChangeListener?) {
timesRated = requireView().findViewById(R.id.times_rated)
Expand Down Expand Up @@ -152,65 +148,32 @@ abstract class BaseContainerFragment : BaseResourceFragment() {
val filenameArray = items.resourceLocalAddress?.split("\\.".toRegex())?.toTypedArray()
val extension = filenameArray?.get(filenameArray.size - 1)
val mimetype = Utilities.getMimeType(items.resourceLocalAddress)
val userId = "${model?.id}"

val existingAction = mRealm.where(RealmUserChallengeActions::class.java)
.equalTo("userId", userId)
.equalTo("resourceId", items.resourceId)
.findFirst()

if (mimetype != null) {
if (mimetype.contains("image")) {
openIntent(items, ImageViewerActivity::class.java)
if (existingAction == null) {
createAction(mRealm, userId, items.resourceId, "resourceOpen")
}
} else if (mimetype.contains("pdf")) {
openPdf(items)
if (existingAction == null) {
createAction(mRealm, userId, items.resourceId, "resourceOpen")
}
} else if (mimetype.contains("audio")) {
openIntent(items, AudioPlayerActivity::class.java)
if (existingAction == null) {
createAction(mRealm, userId, items.resourceId, "resourceOpen")
}
} else {
checkMoreFileExtensions(extension, items)
}
}
}

private fun checkMoreFileExtensions(extension: String?, items: RealmMyLibrary) {
val userId = "${model?.id}"
val existingAction = mRealm.where(RealmUserChallengeActions::class.java)
.equalTo("userId", userId)
.equalTo("resourceId", items.resourceId)
.findFirst()

when (extension) {
"txt" -> {
if (existingAction == null) {
createAction(mRealm, userId, items.resourceId, "resourceOpen")
}
openIntent(items, TextFileViewerActivity::class.java)
}
"md" -> {
if (existingAction == null) {
createAction(mRealm, userId, items.resourceId, "resourceOpen")
}
openIntent(items, MarkdownViewerActivity::class.java)
}
"csv" -> {
if (existingAction == null) {
createAction(mRealm, userId, items.resourceId, "resourceOpen")
}
openIntent(items, CSVViewerActivity::class.java)
}
// "apk" -> {
// if (existingAction == null) {
// createAction(mRealm, userId, items.resourceId, "resourceOpen")
// }
// installApk(items)
// }
else -> Toast.makeText(activity, getString(R.string.this_file_type_is_currently_unsupported), Toast.LENGTH_LONG).show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import android.content.SharedPreferences
import android.net.wifi.WifiManager
import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
Expand Down Expand Up @@ -177,9 +175,6 @@ abstract class BaseResourceFragment : Fragment() {
if (urls.isNotEmpty()) {
prgDialog.show()
Utilities.openDownloadService(activity, urls, false)
Handler(Looper.getMainLooper()).postDelayed({
prgDialog.dismiss()
}, 1000)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,9 @@ abstract class PermissionActivity : AppCompatActivity() {
permissions.add(Manifest.permission.READ_EXTERNAL_STORAGE)
}
}
if (permissions.isNotEmpty()) {
if (permissions.isNotEmpty() && !checkPermission(Manifest.permission.RECORD_AUDIO) &&!checkPermission(Manifest.permission.CAMERA)) {
val permissionsArray = permissions.toTypedArray<String>()
ActivityCompat.requestPermissions(this, permissionsArray, PERMISSION_REQUEST_CODE_FILE)
} else {
Toast.makeText(this, R.string.permissions_granted, Toast.LENGTH_SHORT).show()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,9 @@ abstract class PermissionActivity : AppCompatActivity() {
permissions.add(Manifest.permission.READ_EXTERNAL_STORAGE)
}
}
if (permissions.isNotEmpty()) {
if (permissions.isNotEmpty() && !checkPermission(Manifest.permission.RECORD_AUDIO) &&!checkPermission(Manifest.permission.CAMERA)) {
val permissionsArray = permissions.toTypedArray<String>()
ActivityCompat.requestPermissions(this, permissionsArray, PERMISSION_REQUEST_CODE_FILE)
} else {
Toast.makeText(this, R.string.permissions_granted, Toast.LENGTH_SHORT).show()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,13 @@ class Service(private val context: Context) {
}) { error: Throwable ->
realm.close()
error.printStackTrace()
callback.onSuccess("Unable to connect to planet earth")
}
}
}
}

override fun onFailure(call: Call<JsonObject?>, t: Throwable) {
realm.close()
callback.onSuccess("Unable to connect to planet earth")
}
})
}
Expand Down
27 changes: 20 additions & 7 deletions app/src/main/java/org/ole/planet/myplanet/model/RealmSubmission.kt
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,25 @@ open class RealmSubmission : RealmObject() {
}
}

fun generateParentId(courseId: String?, examId: String?): String? {
return if (!examId.isNullOrEmpty()) {
if (!courseId.isNullOrEmpty()) {
"$examId@$courseId"
} else {
examId
}
} else {
null
}
}

@JvmStatic
fun getNoOfSubmissionByUser(id: String?, userId: String?, mRealm: Realm): String {
fun getNoOfSubmissionByUser(id: String?, courseId:String?, userId: String?, mRealm: Realm): String {
if (id == null || userId == null) return "No Submissions Found"

val submissionParentId= generateParentId(courseId, id)
if(submissionParentId.isNullOrEmpty()) return "No Submissions Found"
val submissionCount = mRealm.where(RealmSubmission::class.java)
.equalTo("parentId", id)
.equalTo("parentId", submissionParentId)
.equalTo("userId", userId)
.equalTo("status", "complete")
.count().toInt()
Expand All @@ -230,15 +243,15 @@ open class RealmSubmission : RealmObject() {
}

@JvmStatic
fun getRecentSubmissionDate(id: String?, userId: String?, mRealm: Realm): String {
fun getRecentSubmissionDate(id: String?, courseId:String?, userId: String?, mRealm: Realm): String {
if (id == null || userId == null) return ""

val submissionParentId= generateParentId(courseId, id)
if(submissionParentId.isNullOrEmpty()) return ""
val recentSubmission = mRealm.where(RealmSubmission::class.java)
.equalTo("parentId", id)
.equalTo("parentId", submissionParentId)
.equalTo("userId", userId)
.sort("startTime", Sort.DESCENDING)
.findFirst()

return recentSubmission?.startTime?.let { TimeUtils.getFormatedDateWithTime(it) } ?: ""
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import org.ole.planet.myplanet.databinding.FragmentChatDetailBinding
import org.ole.planet.myplanet.datamanager.*
import org.ole.planet.myplanet.model.*
import org.ole.planet.myplanet.model.RealmChatHistory.Companion.addConversationToChatHistory
import org.ole.planet.myplanet.model.RealmUserChallengeActions.Companion.createAction
import org.ole.planet.myplanet.service.UserProfileDbHandler
import org.ole.planet.myplanet.ui.dashboard.DashboardActivity
import org.ole.planet.myplanet.utilities.Utilities
Expand Down Expand Up @@ -342,8 +341,6 @@ class ChatDetailFragment : Fragment() {
}
(requireActivity() as? DashboardActivity)?.refreshChatHistoryList()
}

createAction(mRealm, "${user?.id}", "${response.body()?.couchDBResponse?.id}", "ai research")
} else {
fragmentChatDetailBinding.textGchatIndicator.visibility = View.VISIBLE
fragmentChatDetailBinding.textGchatIndicator.text = if (response.message() == "null"){
Expand Down
Loading

0 comments on commit 0ccda0e

Please sign in to comment.