diff --git a/app/build.gradle b/app/build.gradle index b4bc7e8f5d..c5f9673ae6 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "org.ole.planet.myplanet" minSdkVersion 26 targetSdkVersion 34 - versionCode 2135 - versionName "0.21.35" + versionCode 2142 + versionName "0.21.42" ndkVersion '21.3.6528147' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true 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 3c6520dc5e..716fb4d104 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 @@ -78,9 +78,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) 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 12c5a5218e..d7e142c378 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 @@ -78,9 +78,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) diff --git a/app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt b/app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt index 5d516fd5b8..f623c37051 100644 --- a/app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt +++ b/app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt @@ -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() ActivityCompat.requestPermissions(this, permissionsArray, PERMISSION_REQUEST_CODE_FILE) - } else { - Toast.makeText(this, R.string.permissions_granted, Toast.LENGTH_SHORT).show() } } diff --git a/app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt.lite b/app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt.lite index 4229f08651..97ccedad8d 100644 --- a/app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt.lite +++ b/app/src/main/java/org/ole/planet/myplanet/base/PermissionActivity.kt.lite @@ -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() ActivityCompat.requestPermissions(this, permissionsArray, PERMISSION_REQUEST_CODE_FILE) - } else { - Toast.makeText(this, R.string.permissions_granted, Toast.LENGTH_SHORT).show() } } diff --git a/app/src/main/java/org/ole/planet/myplanet/datamanager/Service.kt b/app/src/main/java/org/ole/planet/myplanet/datamanager/Service.kt index 5c25ffc82c..0343e2bf4f 100644 --- a/app/src/main/java/org/ole/planet/myplanet/datamanager/Service.kt +++ b/app/src/main/java/org/ole/planet/myplanet/datamanager/Service.kt @@ -311,6 +311,12 @@ class Service(private val context: Context) { name = JsonUtils.getString("name", jsonDoc) parentDomain = JsonUtils.getString("parentDomain", jsonDoc) registrationRequest = JsonUtils.getString("registrationRequest", jsonDoc) + }, { + realm.close() + callback.onSuccess("Server sync successfully") + }) { error: Throwable -> + realm.close() + error.printStackTrace() } copyToRealm(community) } @@ -321,6 +327,12 @@ class Service(private val context: Context) { error.printStackTrace() callback.onSuccess("Unable to connect to planet earth") } + + + override fun onFailure(call: Call, t: Throwable) { + realm.close() + } + }) } fun getMinApk(listener: ConfigurationIdListener?, url: String, pin: String, activity: SyncActivity) { diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/SettingActivity.kt b/app/src/main/java/org/ole/planet/myplanet/ui/SettingActivity.kt index d1ff4a965f..085c918c0b 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/SettingActivity.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/SettingActivity.kt @@ -10,8 +10,10 @@ import android.view.MenuItem import android.view.View import android.view.ViewGroup import android.widget.ArrayAdapter +import android.widget.ListView import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity +import androidx.appcompat.app.AppCompatDelegate import androidx.core.content.ContextCompat import androidx.preference.Preference import androidx.preference.Preference.OnPreferenceChangeListener @@ -23,6 +25,7 @@ import io.realm.Realm import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import org.ole.planet.myplanet.MainApplication.Companion.context import org.ole.planet.myplanet.MainApplication.Companion.mRealm import org.ole.planet.myplanet.MainApplication.Companion.setThemeMode import org.ole.planet.myplanet.R @@ -107,7 +110,7 @@ class SettingActivity : AppCompatActivity() { val darkMode = findPreference("dark_mode") darkMode?.setOnPreferenceClickListener { - darkMode() + darkMode(requireActivity()) true } @@ -267,36 +270,56 @@ class SettingActivity : AppCompatActivity() { dialog.show() } - private fun darkMode() { - val options = arrayOf(getString(R.string.dark_mode_off), getString(R.string.dark_mode_on), getString(R.string.dark_mode_follow_system)) - val currentMode = getCurrentThemeMode() - val checkedItem = when (currentMode) { - ThemeMode.LIGHT -> 0 - ThemeMode.DARK -> 1 - else -> 2 - } + companion object { + fun darkMode(context: Context) { + val options = arrayOf(context.getString(R.string.dark_mode_off), context.getString(R.string.dark_mode_on),context.getString(R.string.dark_mode_follow_system)) + val currentMode = getCurrentThemeMode(context) + val checkedItem = when (currentMode) { + ThemeMode.LIGHT -> 0 + ThemeMode.DARK -> 1 + else -> 2 + } - val builder = AlertDialog.Builder(requireContext()) - .setTitle(getString(R.string.select_theme_mode)) - .setSingleChoiceItems(ArrayAdapter(requireContext(), R.layout.checked_list_item, options), checkedItem) { dialog, which -> - val selectedMode = when (which) { - 0 -> ThemeMode.LIGHT - 1 -> ThemeMode.DARK - 2 -> ThemeMode.FOLLOW_SYSTEM - else -> ThemeMode.FOLLOW_SYSTEM + val builder = AlertDialog.Builder(context, R.style.CustomAlertDialogStyle) + .setTitle(context.getString(R.string.select_theme_mode)) + .setSingleChoiceItems(ArrayAdapter(context, R.layout.checked_list_item, options), checkedItem) { dialog, which -> + val selectedMode = when (which) { + 0 -> ThemeMode.LIGHT + 1 -> ThemeMode.DARK + 2 -> ThemeMode.FOLLOW_SYSTEM + else -> ThemeMode.FOLLOW_SYSTEM + } + setThemeMode(context, selectedMode) + dialog.dismiss() } - setThemeMode(selectedMode) - dialog.dismiss() - } - .setNegativeButton(R.string.cancel, null) + .setNegativeButton(R.string.cancel, null) - val dialog = builder.create() - dialog.show() - } + val dialog = builder.create() + dialog.show() - private fun getCurrentThemeMode(): String { - val sharedPreferences = requireContext().getSharedPreferences(PREFS_NAME, MODE_PRIVATE) - return sharedPreferences.getString("theme_mode", ThemeMode.FOLLOW_SYSTEM) ?: ThemeMode.FOLLOW_SYSTEM + val window = dialog.window + window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) + } + + private fun getCurrentThemeMode(context: Context): String { + val sharedPreferences = context.getSharedPreferences(PREFS_NAME, MODE_PRIVATE) + return sharedPreferences.getString("theme_mode", ThemeMode.FOLLOW_SYSTEM) ?: ThemeMode.FOLLOW_SYSTEM + } + + private fun setThemeMode(context: Context, themeMode: String) { + val sharedPreferences = context.getSharedPreferences(PREFS_NAME, MODE_PRIVATE) + with(sharedPreferences.edit()) { + putString("theme_mode", themeMode) + apply() + } + AppCompatDelegate.setDefaultNightMode( + when (themeMode) { + ThemeMode.LIGHT -> AppCompatDelegate.MODE_NIGHT_NO + ThemeMode.DARK -> AppCompatDelegate.MODE_NIGHT_YES + else -> AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM + } + ) + } } } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/resources/AdapterResource.kt b/app/src/main/java/org/ole/planet/myplanet/ui/resources/AdapterResource.kt index a259a71a4a..e38f8b7491 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/resources/AdapterResource.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/resources/AdapterResource.kt @@ -72,6 +72,10 @@ class AdapterResource(private val context: Context, private var libraryList: Lis holder.bind() holder.rowLibraryBinding.title.text = libraryList[position]?.title setMarkdownText(holder.rowLibraryBinding.description, libraryList[position]?.description!!) + holder.rowLibraryBinding.description.setOnClickListener { + val library = libraryList[position] + openLibrary(library) + } holder.rowLibraryBinding.timesRated.text = context.getString(R.string.num_total, libraryList[position]?.timesRated) holder.rowLibraryBinding.checkbox.isChecked = selectedItems.contains(libraryList[position]) holder.rowLibraryBinding.checkbox.contentDescription = "${context.getString(R.string.selected)} ${libraryList[position]?.title}" diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/sync/DashboardElementActivity.kt b/app/src/main/java/org/ole/planet/myplanet/ui/sync/DashboardElementActivity.kt index d6e2042da8..3198454964 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/sync/DashboardElementActivity.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/sync/DashboardElementActivity.kt @@ -64,11 +64,7 @@ abstract class DashboardElementActivity : SyncActivity(), FragmentManager.OnBack 4 -> openEnterpriseFragment() 3 -> openCallFragment(TeamFragment(), "survey") 5 -> { - if (profileDbHandler.userModel?.isGuest() == true) { - showGuestUserDialog() - } else { - openCallFragment(CommunityTabFragment(), "community") - } + openCallFragment(CommunityTabFragment(), "community") } } } diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/sync/LoginActivity.kt b/app/src/main/java/org/ole/planet/myplanet/ui/sync/LoginActivity.kt index 1432276248..d0eed59e4f 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/sync/LoginActivity.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/sync/LoginActivity.kt @@ -19,6 +19,7 @@ import org.ole.planet.myplanet.callback.SyncListener import org.ole.planet.myplanet.databinding.* import org.ole.planet.myplanet.datamanager.* import org.ole.planet.myplanet.model.* +import org.ole.planet.myplanet.ui.SettingActivity import org.ole.planet.myplanet.ui.community.HomeCommunityDialogFragment import org.ole.planet.myplanet.ui.feedback.FeedbackFragment import org.ole.planet.myplanet.ui.userprofile.* @@ -110,6 +111,10 @@ class LoginActivity : SyncActivity(), TeamListAdapter.OnItemClickListener { } } }) + val selectDarkModeButton = findViewById(R.id.themeToggleButton) + selectDarkModeButton?.setOnClickListener{ + SettingActivity.SettingFragment.darkMode(this) + } } private fun declareElements() { diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/team/TeamFragment.kt b/app/src/main/java/org/ole/planet/myplanet/ui/team/TeamFragment.kt index 43ee9e29f3..f96b0cfc0a 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/team/TeamFragment.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/team/TeamFragment.kt @@ -242,7 +242,7 @@ class TeamFragment : Fragment(), AdapterTeamList.OnClickTeamItem { fragmentTeamBinding.rvTeamList.adapter = adapterTeamList listContentDescription(conditionApplied) val itemCount = adapterTeamList.itemCount - showNoData(fragmentTeamBinding.tvMessage, itemCount, "teams") + showNoData(fragmentTeamBinding.tvMessage, itemCount, "$type") if (itemCount == 0) { fragmentTeamBinding.etSearch.visibility = View.GONE fragmentTeamBinding.tableTitle.visibility = View.GONE diff --git a/app/src/main/res/drawable/moon_24dp.png b/app/src/main/res/drawable/moon_24dp.png new file mode 100644 index 0000000000..26ac0d8fa2 Binary files /dev/null and b/app/src/main/res/drawable/moon_24dp.png differ diff --git a/app/src/main/res/drawable/moon_35.png b/app/src/main/res/drawable/moon_35.png new file mode 100644 index 0000000000..4f748d24fa Binary files /dev/null and b/app/src/main/res/drawable/moon_35.png differ diff --git a/app/src/main/res/drawable/sun_24dp.png b/app/src/main/res/drawable/sun_24dp.png new file mode 100644 index 0000000000..7272d70af8 Binary files /dev/null and b/app/src/main/res/drawable/sun_24dp.png differ diff --git a/app/src/main/res/drawable/sun_35.png b/app/src/main/res/drawable/sun_35.png new file mode 100644 index 0000000000..1599faeff8 Binary files /dev/null and b/app/src/main/res/drawable/sun_35.png differ diff --git a/app/src/main/res/drawable/white_moon_24dp.png b/app/src/main/res/drawable/white_moon_24dp.png new file mode 100644 index 0000000000..56bca0d0e9 Binary files /dev/null and b/app/src/main/res/drawable/white_moon_24dp.png differ diff --git a/app/src/main/res/layout-large-land/activity_login.xml b/app/src/main/res/layout-large-land/activity_login.xml index a058ffce53..54904c34a7 100644 --- a/app/src/main/res/layout-large-land/activity_login.xml +++ b/app/src/main/res/layout-large-land/activity_login.xml @@ -211,12 +211,25 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + + android:layout_height="match_parent"> + + + + android:layout_height="match_parent"> + + + + + + + + diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index e6aaf8079f..405073d31a 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -30,6 +30,7 @@ تسجيل الخروج ملاحظات myPlanet + يختار مكتبتي دوراتي تجمعاتي @@ -1210,5 +1211,6 @@ مشاركة مع الفريق/المؤسسة فرق مجتمع + المؤسسات غير متوفرة diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 4f01459850..23c877cb17 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -30,6 +30,7 @@ Cerrar sesión Retroalimentación myPlanet + Seleccionar miBiblioteca misCursos misEncuentros @@ -1210,5 +1211,6 @@ compartir con el equipo/empresa equipos comunidad + empresas no disponibles diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index c5e32d4b9a..045d857083 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -30,6 +30,7 @@ Déconnexion Retour d\'information myPlanet + Sélectionner maBibliothèque mesCours mesRencontres @@ -1210,5 +1211,6 @@ partager avec l\'équipe/l\'entreprise équipes communauté + entreprises non disponibles diff --git a/app/src/main/res/values-ne/strings.xml b/app/src/main/res/values-ne/strings.xml index ed4b98b562..d9920520c4 100644 --- a/app/src/main/res/values-ne/strings.xml +++ b/app/src/main/res/values-ne/strings.xml @@ -30,6 +30,7 @@ लगआउट प्रतिक्रिया myPlanet + चयन गर्नुहोस् मेरो पुस्तकालय मेरो पाठ्यक्रमहरू मेरो मिठिङहरू @@ -1210,5 +1211,6 @@ टोली/उद्यमसँग साझा गर्नुहोस् टोलीहरू समुदाय + उद्यमहरू उपलब्ध छैनन् diff --git a/app/src/main/res/values-so/strings.xml b/app/src/main/res/values-so/strings.xml index 109e3c18bb..2f87ff661c 100644 --- a/app/src/main/res/values-so/strings.xml +++ b/app/src/main/res/values-so/strings.xml @@ -30,6 +30,7 @@ ka bax jawaab celin myPlanet + Dooro maktabadayda coursyadayda myMeetups @@ -1210,5 +1211,6 @@ la wadaag kooxda/ganacsiga kooxo bulsho + ganacsiyo lama heli karo diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 29cb5e35ee..c23eed13c0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1210,5 +1210,6 @@ share with team/enterprise teams community + enteprises not available