Skip to content

Commit

Permalink
Preparations for next release (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelvogt authored Feb 15, 2019
1 parent 553e2dc commit 572726f
Show file tree
Hide file tree
Showing 24 changed files with 349 additions and 207 deletions.
38 changes: 19 additions & 19 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
// 24 is the minimum since ARCore only works with 24 and higher.
minSdkVersion 24
targetSdkVersion 28
versionCode 3
versionName '0.2 - prototype'
versionCode 5
versionName '0.4 - prototype'

testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'

Expand Down Expand Up @@ -75,15 +75,15 @@ dependencies {
implementation 'androidx.cardview:cardview:1.0.0'
implementation "androidx.constraintlayout:constraintlayout:2.0.0-alpha3"
// implementation "androidx.core:core-ktx:1.0.1"
implementation 'androidx.fragment:fragment:1.1.0-alpha03'
implementation 'androidx.fragment:fragment:1.1.0-alpha04'

implementation "androidx.lifecycle:lifecycle-common-java8:$androidx_lifecycle"
implementation "androidx.lifecycle:lifecycle-extensions:$androidx_lifecycle"
implementation "androidx.lifecycle:lifecycle-reactivestreams:$androidx_lifecycle"
kapt "androidx.lifecycle:lifecycle-compiler:$androidx_lifecycle"

implementation 'androidx.preference:preference:1.1.0-alpha02'
implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha01'
implementation 'androidx.preference:preference:1.1.0-alpha03'
implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha02'

implementation "androidx.room:room-runtime:$androidx_room"
implementation "androidx.room:room-migration:$androidx_room"
Expand All @@ -95,12 +95,12 @@ dependencies {

implementation 'com.android.volley:volley:1.1.1'

implementation('com.github.bumptech.glide:glide:4.8.0') {
implementation('com.github.bumptech.glide:glide:4.9.0') {
exclude group: 'com.android.support'
}

implementation 'com.google.android.material:material:1.1.0-alpha02'
// implementation 'com.google.android.play:core:1.3.6'
implementation 'com.google.android.material:material:1.1.0-alpha03'
implementation 'com.google.android.play:core:1.3.7'

implementation "com.google.ar.sceneform:core:$sceneform_version"
implementation "com.google.ar.sceneform.ux:sceneform-ux:$sceneform_version"
Expand All @@ -109,27 +109,27 @@ dependencies {
exclude group: 'com.github.bumptech.glide'
}

implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'

implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version"
implementation "org.jetbrains.anko:anko-commons:0.10.8"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:1.3.21"

implementation "uk.co.samuelwall:material-tap-target-prompt:2.14.0"

testImplementation 'junit:junit:4.13-beta-1'
testImplementation 'junit:junit:4.13-beta-2'
testImplementation 'org.hamcrest:hamcrest-all:1.3'
testImplementation 'io.mockk:mockk:1.9.kotlin12'
testImplementation 'io.mockk:mockk:1.9.1.kotlin12'

androidTestImplementation "androidx.test:core:1.1.0"
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test:rules:1.1.1'
androidTestUtil 'androidx.test:orchestrator:1.1.1'
androidTestImplementation 'androidx.test:core:1.1.1-alpha01'
androidTestImplementation 'androidx.test:runner:1.1.2-alpha01'
androidTestImplementation 'androidx.test:rules:1.1.2-alpha01'
androidTestUtil 'androidx.test:orchestrator:1.1.2-alpha01'

androidTestImplementation "androidx.test.ext:junit:1.1.0"
androidTestImplementation 'androidx.annotation:annotation:1.0.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.1-alpha01'
androidTestImplementation 'androidx.annotation:annotation:1.1.0-alpha01'

androidTestImplementation 'androidx.arch.core:core-testing:2.0.0'
androidTestImplementation "androidx.room:room-testing:$androidx_room"
Expand Down
44 changes: 31 additions & 13 deletions app/src/main/assets/locations.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,63 @@
},
{
"name": "Iwami Ginzan",
"description": "World Heritage silver mine area",
"description": "The Iwami Ginzan (石見銀山) was an underground silver mine in the city of Ōda, in Shimane Prefecture on the main island of Honshu, Japan.[1] It was the largest silver mine in Japanese history. It was active for almost four hundred years, from its discovery in 1526 to its closing in 1923.",
"module_id": "location_iwamiginzan",
"content_size": "1234MB",
"content_size": "234 MB",
"thumb_path": "/module_asset/iwami_ginzan/iwamiginzanthumb.webp",
"intro_html_path": "/module_asset/iwami_ginzan/site/iwamiginzan.html",
"is_active": true
},
{
"name": "Izumo Taisha",
"description": "Japanese Grand Shrine",
"description": "Izumo-taisha (出雲大社, Izumo Grand Shrine), officially Izumo Ōyashiro, is one of the most ancient and important Shinto shrines in Japan. No record gives the date of establishment. Located in Izumo, Shimane Prefecture, it is believed by many to be the oldest Shinto shrine in Japan, even predating the Ise Grand Shrine.",
"module_id": "location_izumotaisha",
"content_size": "1234MB",
"content_size": "234 MB",
"thumb_path": "/module_asset/izumo_taisha/images/izumotaishathumb.webp",
"intro_html_path": "/module_asset/izumo_taisha/izumotaisha.html",
"is_active": true
},
{
"name": "Nara",
"description": "",
"description": "Nara (奈良市 Nara-shi, Japanese: [naꜜɾa]) is the capital city of Nara Prefecture located in the Kansai region of Japan. The city occupies the northern part of Nara Prefecture, bordering Kyoto Prefecture. During 710 CE - 784 CE, Nara was the capital of Japan, and the Emperor (天皇) lived there before moving the capital to Kyoto.",
"module_id": "location_nara",
"content_size": "1234MB",
"content_size": "234 MB",
"thumb_path": "",
"intro_html_path": "",
"is_active": false
},
{
"name": "Hiroshima",
"description": "",
"description": "Hiroshima (広島市 Hiroshima-shi, Japanese: [çiɾoɕima]) is the capital of Hiroshima Prefecture and the largest city in the Chūgoku region of western Honshu, the largest island of Japan. On April 1, 1980, Hiroshima became a designated city. Hiroshima was the first city targeted by a nuclear weapon, when the United States Army Air Forces (USAAF) dropped an atomic bomb on the city at 8:15 a.m. on August 6, 1945, near the end of World War II.",
"module_id": "location_hiroshima",
"content_size": "1234MB",
"content_size": "234 MB",
"thumb_path": "",
"intro_html_path": "",
"is_active": false
},
{
"name": "Niigata",
"description": "",
"name": "Sado Island",
"description": "Sado (佐渡市 Sado-shi) is a city located on Sado Island (佐渡ヶ島 Sadogashima) in Niigata Prefecture, Japan. Sado experienced a sudden economic boom during the Edo period when gold was found in 1601 at Aikawa (相川). A major source of revenue for the Tokugawa shogunate.",
"module_id": "location_niigata",
"content_size": "1234MB",
"content_size": "234 MB",
"thumb_path": "",
"intro_html_path": "",
"is_active": false
},
{
"name": "Germany",
"description": "",
"module_id": "",
"is_title": true,
"thumb_path": "",
"intro_html_path": "",
"is_active": false
},
{
"name": "Kloster Hirsau",
"description": "Hirsau Abbey, formerly known as Hirschau Abbey, was once one of the most important Benedictine abbeys of Germany. It is located in the Hirsau borough of Calw on the northern slopes of the Black Forest mountain range. In the 11th and 12th century, the monastery was a centre of the Cluniac Reforms, implemented as \"Hirsau\" Reforms in the German lands. The complex was devastated during the War of the Palatine Succession in 1692 and not rebuilt.",
"module_id": "location_kloster_hirsau",
"content_size": "234 MB",
"thumb_path": "",
"intro_html_path": "",
"is_active": false
Expand All @@ -64,9 +82,9 @@
},
{
"name": "Machu Picchu",
"description": "",
"description": "Machu Picchu is a 15th-century Inca citadel, located in the Eastern Cordillera of southern Peru, on a mountain ridge 2,430 metres above sea level. Most archaeologists believe that Machu Picchu was constructed as an estate for the Inca emperor Pachacuti (1438–1472).",
"module_id": "location_machupicchu",
"content_size": "1234MB",
"content_size": "234 MB",
"thumb_path": "",
"intro_html_path": "",
"is_active": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class Location(
companion object {
fun getDefaultLocation(): Location {
return Location(
"My location",
"Current location",
"Your current location",
"",
"/module_asset/location/images/mylocationthumb.webp",
Expand Down
101 changes: 101 additions & 0 deletions app/src/main/java/eu/michaelvogt/ar/author/data/utils/Json.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
ARTester - AR for tourists by tourists
Copyright (C) 2018, 2019 Michael Vogt
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package eu.michaelvogt.ar.author.data.utils

import android.content.Context
import android.util.Log
import com.google.ar.sceneform.math.Vector3
import eu.michaelvogt.ar.author.data.*
import org.json.JSONObject

class Json {
companion object {
private val TAG = Json::class.java.simpleName

fun importLocation(context: Context?, viewModel: AuthorViewModel, location: Location, onFinished: () -> Unit) {
val assetManager = context?.assets

if (assetManager != null) {
val moduleId = location.moduleId.also {
when (it) {
null, "" -> {
Log.e(TAG, "Module ID of location ${location.name} is missing. Required to access content")
}
}
}

val reader = assetManager.open("$moduleId.json").bufferedReader()
val contentString = reader.readText()
reader.close()

if (location.isLoaded == false) {
// Insert content
val locationObject = JSONObject(contentString).getJSONObject("location")
val groupArray = locationObject.getJSONArray("groups")

for (groupIndex in 0 until groupArray.length()) {
val groupObject = groupArray.getJSONObject(groupIndex)

viewModel.insertTitleGroup(TitleGroup(groupObject.getString("name"))).thenAccept { groupId ->
val markersArray = groupObject.getJSONArray("markers")

for (markerIndex in 0 until markersArray.length()) {
val markerObject = markersArray.getJSONObject(markerIndex)

// TODO: Load complete Marker into DB
viewModel.insertMarker(Marker(location.uId, groupId,
markerObject.getString("title"),
zeroPoint = Converters().vector3FromString(markerObject.getString("zero_point"))
?: Vector3.zero())
).thenAccept { markerId ->
val areasArray = markerObject.getJSONArray("areas")

for (areaIndex in 0 until areasArray.length()) {
val areaObject = areasArray.getJSONObject(areaIndex)

// TODO: Load complete Area into DB
viewModel.insertArea(Area(areaObject.getString("title"))).thenAccept { areaId ->
viewModel.insertMarkerArea(MarkerArea(markerId, areaId))
}.exceptionally {
Log.e(TAG, "Unable to insert area.", it)
null
}
}
}.exceptionally {
Log.e(TAG, "Unable to insert marker.", it)
null
}
}
}.exceptionally {
Log.e(TAG, "Unable to insert group", it)
null
}
}

location.isLoaded = true
viewModel.updateLocation(location).thenAccept {
onFinished()
}
} else {
// TODO: Update content
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ open class AppFragment : Fragment() {
viewModel = ViewModelProviders.of(activity!!).get(AuthorViewModel::class.java)
}

fun setupFab(@DrawableRes iconRes: Int, listener: View.OnClickListener) {
if (!Preferences.getPreference(context, R.string.allow_edit_pref, false)) {
fun setupFab(@DrawableRes iconRes: Int, visibility: FabVisibility, listener: View.OnClickListener) {
if (visibility != FabVisibility.ALWAYS
&& !Preferences.getPreference(context, R.string.allow_edit_pref, false)) {
hideFab()
return
}
Expand Down Expand Up @@ -72,4 +73,10 @@ open class AppFragment : Fragment() {
fun hideBottomBar() {
activity!!.bottom_nav.visibility = View.GONE
}

companion object {
enum class FabVisibility {
ALWAYS, EDITING
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ class AreaEditFragment : AppFragment(), AreaCardEditHandler {
fun onResume() {
super.onResume()

setupFab(android.R.drawable.ic_menu_save, View.OnClickListener {
setupFab(android.R.drawable.ic_menu_save,
AppFragment.Companion.FabVisibility.EDITING, View.OnClickListener {
// TODO: Save complete AreaVisual
if (areaVisual.area.uId != 0L) {
viewModel.updateArea(areaVisual.area).thenAccept {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CropFragment : AppFragment() {
fun onResume() {
super.onResume()

setupFab(android.R.drawable.ic_menu_save, View.OnClickListener {
setupFab(android.R.drawable.ic_menu_save, Companion.FabVisibility.EDITING, View.OnClickListener {
FileUtils.saveImageToExternalStorage(crop_view.crop()!!, imagePath)
navController.popBackStack()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ class ImagePreviewFragment : PreviewFragment() {
arFragment.onUpdate(frameTime)

val frame = arFragment.arSceneView.arFrame
val updatedAugmentedImages = frame.getUpdatedTrackables(AugmentedImage::class.java)
val updatedAugmentedImages = frame?.getUpdatedTrackables(AugmentedImage::class.java)
?: emptyList()

for (image in updatedAugmentedImages) {
val trackingState = arFragment.arSceneView.arFrame.camera.trackingState
val trackingState = arFragment.arSceneView.arFrame?.camera?.trackingState
if (trackingState == TrackingState.TRACKING && !handledImages.contains(image.name)) {
handledImages.plus(image.name)
val anchor: Anchor?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class LocationEditFragment : AppFragment() {
override fun onResume() {
super.onResume()

setupFab(android.R.drawable.ic_menu_save, fabListener)
setupFab(android.R.drawable.ic_menu_save, AppFragment.Companion.FabVisibility.EDITING, fabListener)
setupBottomNav(R.menu.actionbar_locationedit_menu, Toolbar.OnMenuItemClickListener {
when (it.itemId) {
R.id.actionbar_location_delete -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class LocationSearchFragment : AppFragment(), CardLinkListener {
fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

binder.locationList.setHasFixedSize(true)
binder.locationList.setHasFixedSize(false)

adapter = LocationSearchAdapter(context, this)
binder.locationList.adapter = adapter
Expand Down Expand Up @@ -84,7 +84,7 @@ class LocationSearchFragment : AppFragment(), CardLinkListener {
override fun onResume() {
super.onResume()

setupFab(android.R.drawable.ic_input_add, View.OnClickListener {
setupFab(android.R.drawable.ic_input_add, AppFragment.Companion.FabVisibility.EDITING, View.OnClickListener {
navController.navigate(LocationSearchFragmentDirections.actionToLocationEdit())
})

Expand Down
Loading

0 comments on commit 572726f

Please sign in to comment.