Skip to content

Commit

Permalink
Merge branch 'master' into 4654-display-image-in-community-service
Browse files Browse the repository at this point in the history
  • Loading branch information
dogi authored Oct 16, 2024
2 parents 91fdd6f + b463adf commit 790d8ab
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 28 deletions.
7 changes: 4 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
<action android:name="android.intent.action.GET_CONTENT" />
<data android:mimeType="video/*" />
</intent>
<intent>
<action android:name="android.intent.action.GET_CONTENT" />
<data android:mimeType="audio/*" />
</intent>
</queries>
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
<uses-permission
Expand All @@ -22,8 +26,6 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.SEND_DOWNLOAD_COMPLETED_INTENTS" />
Expand All @@ -37,7 +39,6 @@
<uses-permission
android:name="android.permission.PACKAGE_USAGE_STATS"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />

<uses-feature
android:name="android.hardware.camera"
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/AndroidManifest.xml.lite
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
<action android:name="android.intent.action.GET_CONTENT" />
<data android:mimeType="video/*" />
</intent>
<intent>
<action android:name="android.intent.action.GET_CONTENT" />
<data android:mimeType="audio/*" />
</intent>
</queries>
<!-- <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>-->
<uses-permission
Expand All @@ -22,8 +26,6 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.SEND_DOWNLOAD_COMPLETED_INTENTS" />
Expand All @@ -37,7 +39,6 @@
<uses-permission
android:name="android.permission.PACKAGE_USAGE_STATS"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />

<uses-feature
android:name="android.hardware.camera"
Expand Down
11 changes: 8 additions & 3 deletions app/src/main/java/org/ole/planet/myplanet/ui/SettingActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceManager
import androidx.preference.SwitchPreference
import io.realm.Realm
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.ole.planet.myplanet.MainApplication.Companion.mRealm
import org.ole.planet.myplanet.MainApplication.Companion.setThemeMode
import org.ole.planet.myplanet.R
Expand Down Expand Up @@ -135,9 +138,11 @@ class SettingActivity : AppCompatActivity() {
preference.onPreferenceClickListener = OnPreferenceClickListener {
AlertDialog.Builder(requireActivity()).setTitle(R.string.are_you_sure)
.setPositiveButton(R.string.yes) { _: DialogInterface?, _: Int ->
clearRealmDb()
clearSharedPref()
restartApp()
CoroutineScope(Dispatchers.Main).launch {
clearRealmDb()
clearSharedPref()
restartApp()
}
}.setNegativeButton(R.string.no, null).show()
false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class CoursesFragment : BaseRecyclerFragment<RealmMyCourse?>(), OnCourseItemSele
}

private fun createAlertDialog(): AlertDialog {
val builder = AlertDialog.Builder(requireContext(), R.style.AlertDialogTheme)
val builder = AlertDialog.Builder(requireContext(), R.style.CustomAlertDialog)
var msg = getString(R.string.success_you_have_added_the_following_courses)
if ((selectedItems?.size ?: 0) <= 5) {
for (i in selectedItems?.indices!!) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class ResourcesFragment : BaseRecyclerFragment<RealmMyLibrary?>(), OnLibraryItem
}

private fun createAlertDialog(): AlertDialog {
val builder = AlertDialog.Builder(requireContext(), R.style.AlertDialogTheme)
val builder = AlertDialog.Builder(requireContext(), R.style.CustomAlertDialog)
var msg = getString(R.string.success_you_have_added_these_resources_to_your_mylibrary)
if ((selectedItems?.size ?: 0) <= 5) {
for (i in selectedItems?.indices ?: emptyList()) {
Expand Down
27 changes: 19 additions & 8 deletions app/src/main/java/org/ole/planet/myplanet/ui/sync/SyncActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import androidx.recyclerview.widget.RecyclerView
import com.afollestad.materialdialogs.*
import com.google.android.material.textfield.TextInputLayout
import io.realm.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import kotlinx.coroutines.launch
import kotlinx.serialization.json.Json
import okhttp3.ResponseBody
Expand Down Expand Up @@ -144,9 +148,11 @@ abstract class SyncActivity : ProcessUserDataActivity(), SyncListener, CheckVers
AlertDialog.Builder(this, R.style.AlertDialogTheme)
.setMessage(message)
.setPositiveButton(getString(R.string.clear_data)) { _, _ ->
clearRealmDb()
clearSharedPref()
restartApp()
CoroutineScope(Dispatchers.Main).launch {
clearRealmDb()
clearSharedPref()
restartApp()
}
}
.setNegativeButton(getString(R.string.cancel)) { _, _ ->
onCancel()
Expand Down Expand Up @@ -850,12 +856,17 @@ abstract class SyncActivity : ProcessUserDataActivity(), SyncListener, CheckVers
lateinit var cal_today: Calendar
lateinit var cal_last_Sync: Calendar

fun clearRealmDb() {
val realm = Realm.getDefaultInstance()
realm.executeTransaction { transactionRealm ->
transactionRealm.deleteAll()
suspend fun clearRealmDb() {
withContext(Dispatchers.IO) {
val realm = Realm.getDefaultInstance()
try {
realm.executeTransaction { transactionRealm ->
transactionRealm.deleteAll()
}
} finally {
realm.close()
}
}
realm.close()
}

fun clearSharedPref() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package org.ole.planet.myplanet.ui.viewer

import android.os.Bundle
import android.text.Spannable
import android.text.SpannableStringBuilder
import android.text.style.ForegroundColorSpan
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import com.opencsv.CSVParserBuilder
import com.opencsv.CSVReaderBuilder
import org.ole.planet.myplanet.R
Expand Down Expand Up @@ -32,22 +36,28 @@ class CSVViewerActivity : AppCompatActivity() {
}

try {
val csvFile: File = if (fileName!!.startsWith("/")) {
val csvFile: File = if (fileName?.startsWith("/") == true) {
File(fileName)
} else {
val basePath = getExternalFilesDir(null)
File(basePath, "ole/$fileName")
}
val reader = CSVReaderBuilder(FileReader(csvFile)).withCSVParser(CSVParserBuilder()
.withSeparator(',')
.withQuoteChar('"')
val reader = CSVReaderBuilder(FileReader(csvFile))
.withCSVParser(CSVParserBuilder().withSeparator(',').withQuoteChar('"').build())
.build()
).build()

val allRows = reader.readAll()
val spannableContent = SpannableStringBuilder()
for (row in allRows) {
activityCsvViewerBinding.csvFileContent.append(row.contentToString())
activityCsvViewerBinding.csvFileContent.append("\n")
val rowText = row.contentToString() + "\n"
val start = spannableContent.length
spannableContent.append(rowText)
spannableContent.setSpan(
ForegroundColorSpan(ContextCompat.getColor(this, R.color.daynight_textColor)),
start, spannableContent.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
)
}
activityCsvViewerBinding.csvFileContent.text = spannableContent
} catch (e: Exception) {
e.printStackTrace()
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/activity_feedback_detail.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
android:id="@+id/feedback_reply_edit_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="3"
android:layout_weight="2.3"
android:hint="@string/please_enter_reply"
android:textColorHint="@color/hint_color"
android:textColor="@color/daynight_textColor"
Expand All @@ -52,7 +52,7 @@
style="@style/PrimaryButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="0.8"
android:text="@string/close" />
</LinearLayout>

Expand Down

0 comments on commit 790d8ab

Please sign in to comment.