Skip to content

Commit

Permalink
Merge branch 'master' into 4649-remove-photo-and-video-permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
dogi authored Oct 16, 2024
2 parents 5ffffba + e6c4d89 commit 2718164
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 15 deletions.
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
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 2718164

Please sign in to comment.