Skip to content

Commit

Permalink
Merge branch 'release/0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrimault committed Sep 4, 2021
2 parents 9e354a6 + 1033eb4 commit 4700c28
Show file tree
Hide file tree
Showing 43 changed files with 667 additions and 246 deletions.
9 changes: 0 additions & 9 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 0 additions & 12 deletions .idea/runConfigurations.xml

This file was deleted.

21 changes: 10 additions & 11 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

version = "0.2.9"
version = "0.3.0"

android {
compileSdkVersion 29
compileSdkVersion 30

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -14,7 +14,7 @@ android {
defaultConfig {
applicationId "fr.geonature.maps.sample"
minSdkVersion 21
targetSdkVersion 29
targetSdkVersion 30
versionCode updateVersionCode(module.name)
versionName version
buildConfigField "String", "BUILD_DATE", "\"" + new Date().getTime() + "\""
Expand All @@ -23,6 +23,9 @@ android {
}

buildTypes {
debug {
versionNameSuffix ".${defaultConfig.versionCode}-DEV"
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
Expand All @@ -46,16 +49,12 @@ dependencies {
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1'

implementation 'androidx.appcompat:appcompat:1.3.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0-beta01'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.0"
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.preference:preference-ktx:1.1.1'
implementation 'androidx.recyclerview:recyclerview:1.2.0-beta02'
implementation 'androidx.recyclerview:recyclerview:1.2.1'

testImplementation 'androidx.test:core:1.3.0'
testImplementation 'androidx.test:core:1.4.0'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:3.0.0'
testImplementation 'org.robolectric:robolectric:4.3.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0-alpha05'
androidTestImplementation 'androidx.test:runner:1.4.0-alpha05'
testImplementation 'org.robolectric:robolectric:4.5.1'
}
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">

<activity android:name=".ui.home.HomeActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Expand All @@ -25,6 +25,7 @@
<activity
android:name=".ui.settings.PreferencesActivity"
android:label="@string/activity_preferences_title" />

</application>

</manifest>
11 changes: 11 additions & 0 deletions app/src/main/java/fr/geonature/maps/sample/ui/home/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import androidx.appcompat.app.AppCompatActivity
import fr.geonature.maps.sample.R
import fr.geonature.maps.sample.ui.map.MapActivity
import fr.geonature.maps.settings.io.MapSettingsReader
import fr.geonature.mountpoint.util.FileUtils
import java.io.InputStreamReader

/**
* Home screen Activity.
*
* @author S. Grimault
* @see HomeListFragment
*/
class HomeActivity : AppCompatActivity(), HomeListFragment.OnHomeListFragmentListener {
Expand All @@ -33,6 +35,15 @@ class HomeActivity : AppCompatActivity(), HomeListFragment.OnHomeListFragmentLis
.commit()
}

val osmdroidFile = FileUtils.getFile(
FileUtils.getExternalStorageDirectory(application),
"osmdroid"
)
Log.d(
TAG,
"${osmdroidFile.absolutePath}: (exists: ${osmdroidFile.exists()}, ${if (osmdroidFile.canRead()) "r" else ""}${if (osmdroidFile.canWrite()) "w" else ""}${if (osmdroidFile.canExecute()) "x" else ""})"
)

mapSettingsResultLauncher = registerForActivityResult(StartActivityForResult()) { result ->
when (result.resultCode) {
RESULT_CANCELED -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import fr.geonature.maps.settings.MapSettings

/**
* A fragment representing a list of [MenuItem].
*
* @author S. Grimault
*/
class HomeListFragment : Fragment() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ import fr.geonature.maps.settings.MapSettings

/**
* Describes a menu entry.
*
* @author S. Grimault
*/
data class MenuItem(val label: String, val mapSettings: MapSettings? = null)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package fr.geonature.maps.sample.ui.home

import android.annotation.SuppressLint
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.TextView
Expand All @@ -9,6 +10,8 @@ import fr.geonature.maps.sample.R

/**
* [RecyclerView.Adapter] that can display a menu entry.
*
* @author S. Grimault
*/
class MenuItemRecyclerViewAdapter(private val listener: OnMenuItemRecyclerViewAdapterListener) :
RecyclerView.Adapter<MenuItemRecyclerViewAdapter.MenuItemViewHolder>() {
Expand All @@ -28,6 +31,7 @@ class MenuItemRecyclerViewAdapter(private val listener: OnMenuItemRecyclerViewAd
/**
* Sets new menu items.
*/
@SuppressLint("NotifyDataSetChanged")
fun setItems(newItems: List<MenuItem>) {
if (this.items.isEmpty()) {
this.items.addAll(newItems)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ import fr.geonature.maps.settings.MapSettings
import fr.geonature.maps.ui.MapFragment

/**
* Home screen Activity.
* Map Activity.
*
* @author S. Grimault
* @see MapFragment
*/
class MapActivity : AppCompatActivity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import fr.geonature.maps.settings.MapSettings
/**
* Global settings.
*
* @author S. Grimault
* @see PreferencesFragment
*
* @author [S. Grimault](mailto:[email protected])
*/
class PreferencesActivity : AppCompatActivity() {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package fr.geonature.maps.sample.ui.settings

import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.provider.Settings
import androidx.preference.Preference
import androidx.preference.PreferenceFragmentCompat
import fr.geonature.maps.sample.R
import fr.geonature.maps.sample.util.PreferencesUtils.updatePreferences
Expand All @@ -10,7 +14,7 @@ import fr.geonature.maps.util.MapSettingsPreferencesUtils
/**
* Global settings.
*
* @author [S. Grimault](mailto:[email protected])
* @author S. Grimault
*/
class PreferencesFragment : PreferenceFragmentCompat() {

Expand All @@ -19,26 +23,52 @@ class PreferencesFragment : PreferenceFragmentCompat() {

setDefaultPreferences(arguments?.getParcelable(ARG_MAP_SETTINGS))
updatePreferences(preferenceScreen)
configurePermissions()
}

override fun onCreatePreferences(
savedInstanceState: Bundle?,
rootKey: String?
) {
addPreferencesFromResource(fr.geonature.maps.R.xml.map_preferences)
addPreferencesFromResource(R.xml.preferences)
addPreferencesFromResource(R.xml.preferences_permissions)
addPreferencesFromResource(R.xml.preferences_storage)
addPreferencesFromResource(R.xml.preferences_about)
}

private fun setDefaultPreferences(appSettings: MapSettings?) {
val context = context ?: return

MapSettingsPreferencesUtils.setDefaultPreferences(
context,
MapSettings.Builder.newInstance().from(appSettings).build(),
MapSettings.Builder.newInstance()
.from(appSettings)
.build(),
preferenceScreen
)
}

private fun configurePermissions() {
preferenceScreen
.findPreference<Preference>(getString(R.string.preference_category_permissions_configure_key))
?.apply {
onPreferenceClickListener = Preference.OnPreferenceClickListener {
startActivity(
Intent(
Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
Uri.fromParts(
"package",
it.context.packageName,
null
)
)
)

true
}
}
}

companion object {

private const val ARG_MAP_SETTINGS = "arg_map_settings"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import java.util.Date
/**
* Helper about application settings through [Preference].
*
* @author [S. Grimault](mailto:[email protected])
* @author S. Grimault
*/
object PreferencesUtils {

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-fr/prefs.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="preference_category_permissions">Permissions</string>
<string name="preference_category_permissions_configure">Gérer les permissions</string>
<string name="preference_category_storage">Mémoire</string>
<string name="preference_category_storage_internal">Mémoire interne</string>
<string name="preference_category_storage_external">Mémoire externe</string>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/prefs.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="preference_category_permissions">Permissions</string>
<string name="preference_category_permissions_configure">Manage permissions</string>
<string name="preference_category_permissions_configure_key" translatable="false">permissions</string>
<string name="preference_category_storage">Storage</string>
<string name="preference_category_storage_key" translatable="false">storage</string>
<string name="preference_category_storage_internal">Internal storage</string>
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/res/xml/preferences_about.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">

<PreferenceCategory android:title="@string/preference_category_about">
<Preference
android:key="@string/preference_category_about_app_version_key"
android:selectable="false"
android:title="@string/preference_category_about_app_version" />
</PreferenceCategory>

</PreferenceScreen>
11 changes: 11 additions & 0 deletions app/src/main/res/xml/preferences_permissions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">

<PreferenceCategory android:title="@string/preference_category_permissions">
<Preference
android:key="@string/preference_category_permissions_configure_key"
android:title="@string/preference_category_permissions_configure" />
</PreferenceCategory>

</PreferenceScreen>
Loading

0 comments on commit 4700c28

Please sign in to comment.