diff --git a/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt b/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt index 83545b2d85..f9b8db427b 100644 --- a/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt @@ -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 @@ -152,29 +150,14 @@ 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) } @@ -182,35 +165,17 @@ abstract class BaseContainerFragment : BaseResourceFragment() { } 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() diff --git a/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt.lite b/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt.lite index 8a64f08109..2b983ca27f 100644 --- a/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt.lite +++ b/app/src/main/java/org/ole/planet/myplanet/base/BaseContainerFragment.kt.lite @@ -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 @@ -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 @@ -152,29 +150,14 @@ 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) } @@ -182,35 +165,17 @@ abstract class BaseContainerFragment : BaseResourceFragment() { } 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() diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/chat/ChatDetailFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/chat/ChatDetailFragment.kt index a1b1696a1b..98e5ba502d 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/chat/ChatDetailFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/chat/ChatDetailFragment.kt @@ -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 @@ -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"){ diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/sync/SyncActivity.kt b/app/src/main/java/org/ole/planet/myplanet/ui/sync/SyncActivity.kt index 10b8f3f4db..6f6efc9145 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/sync/SyncActivity.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/sync/SyncActivity.kt @@ -6,7 +6,6 @@ import android.graphics.drawable.AnimationDrawable import android.os.Build import android.os.Bundle import android.text.* -import android.util.Log import android.view.* import android.webkit.URLUtil import android.widget.* @@ -38,7 +37,6 @@ import org.ole.planet.myplanet.datamanager.* import org.ole.planet.myplanet.datamanager.ApiClient.client import org.ole.planet.myplanet.datamanager.Service.* import org.ole.planet.myplanet.model.* -import org.ole.planet.myplanet.model.RealmUserChallengeActions.Companion.createAction import org.ole.planet.myplanet.service.* import org.ole.planet.myplanet.ui.dashboard.DashboardActivity import org.ole.planet.myplanet.ui.team.AdapterTeam.OnUserSelectedListener @@ -413,25 +411,6 @@ abstract class SyncActivity : ProcessUserDataActivity(), SyncListener, CheckVers fun onLogin() { val handler = UserProfileDbHandler(this) - - val userId = handler.userModel?.id - if (userId != null && userId.startsWith("guest") == false) { - Log.d("okuro", "called") - val latestAction = mRealm.where(RealmUserChallengeActions::class.java) - .equalTo("userId", userId).sort("time", Sort.DESCENDING).findFirst() - - val currentTime = System.currentTimeMillis() - val thresholdTime = 24 * 60 * 60 * 1000 - - if (latestAction == null) { - createAction(mRealm, userId, null, "login") - } else { - if (currentTime - latestAction.time >= thresholdTime) { - createAction(mRealm, userId, null, "login") - } - } - } - handler.onLogin() handler.onDestroy() editor.putBoolean(Constants.KEY_LOGIN, true).commit()