Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ulaval2 #7

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
519 changes: 15 additions & 504 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion android/.idea/misc.xml

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

Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ class MapPingApplication : Application() {
super.onCreate()

netComponent = DaggerNetComponent.builder()
.appModule(AppModule(this))
.netModule(NetModule(DATA_SOURCE_URL))
.build()
.appModule(AppModule(this))
.netModule(NetModule(DATA_SOURCE_URL))
.build()
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,8 @@ import android.view.MotionEvent
import android.view.View
import android.view.WindowManager
import android.widget.Toast

import com.google.ar.core.Anchor
import com.google.ar.core.ArCoreApk
import com.google.ar.core.Config
import com.google.ar.core.Plane
import com.google.ar.core.Point
import com.google.ar.core.*
import com.google.ar.core.Point.OrientationMode
import com.google.ar.core.Session
import com.google.ar.core.TrackingState
import com.google.ar.core.exceptions.UnavailableApkTooOldException
import com.google.ar.core.exceptions.UnavailableArcoreNotInstalledException
import com.google.ar.core.exceptions.UnavailableSdkTooOldException
Expand All @@ -48,12 +41,10 @@ import com.mirego.csmapapplication.rendering.BackgroundRenderer
import com.mirego.csmapapplication.rendering.ObjectRenderer
import com.mirego.csmapapplication.rendering.PlaneRenderer
import com.mirego.csmapapplication.rendering.PointCloudRenderer
import kotlinx.android.synthetic.main.activity_ar.surfaceView

import kotlinx.android.synthetic.main.activity_ar.*
import java.io.IOException
import java.util.ArrayList
import java.util.*
import java.util.concurrent.ArrayBlockingQueue

import javax.microedition.khronos.egl.EGLConfig
import javax.microedition.khronos.opengles.GL10

Expand Down Expand Up @@ -93,17 +84,17 @@ class ArActivity : AppCompatActivity(), GLSurfaceView.Renderer {

// Set up tap listener.
gestureDetector = GestureDetector(
this,
object : GestureDetector.SimpleOnGestureListener() {
override fun onSingleTapUp(e: MotionEvent): Boolean {
onSingleTap(e)
return true
}
this,
object : GestureDetector.SimpleOnGestureListener() {
override fun onSingleTapUp(e: MotionEvent): Boolean {
onSingleTap(e)
return true
}

override fun onDown(e: MotionEvent): Boolean {
return true
}
})
override fun onDown(e: MotionEvent): Boolean {
return true
}
})

surfaceView!!.setOnTouchListener { v, event -> gestureDetector!!.onTouchEvent(event) }

Expand Down Expand Up @@ -194,17 +185,17 @@ class ArActivity : AppCompatActivity(), GLSurfaceView.Renderer {
}

override fun onRequestPermissionsResult(
requestCode: Int,
permissions: Array<String>,
results: IntArray
requestCode: Int,
permissions: Array<String>,
results: IntArray
) {
if (!CameraPermissionHelper.hasCameraPermission(this)) {
Toast.makeText(
this,
"Camera permission is needed to run this application",
Toast.LENGTH_LONG
this,
"Camera permission is needed to run this application",
Toast.LENGTH_LONG
)
.show()
.show()
if (!CameraPermissionHelper.shouldShowRequestPermissionRationale(this)) {
// Permission denied with checking "Do not ask again".
CameraPermissionHelper.launchPermissionSettings(this)
Expand All @@ -218,7 +209,7 @@ class ArActivity : AppCompatActivity(), GLSurfaceView.Renderer {
if (hasFocus) {
// Standard Android full-screen functionality.
window
.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
Expand All @@ -245,8 +236,8 @@ class ArActivity : AppCompatActivity(), GLSurfaceView.Renderer {
virtualObject.setMaterialProperties(0.0f, 3.5f, 1.0f, 6.0f)

virtualObjectShadow.createOnGlThread(/*context=*/this,
"andy_shadow.obj",
"andy_shadow.png"
"andy_shadow.obj",
"andy_shadow.png"
)
virtualObjectShadow.setBlendMode(ObjectRenderer.BlendMode.Shadow)
virtualObjectShadow.setMaterialProperties(1.0f, 0.0f, 0.0f, 1.0f)
Expand Down Expand Up @@ -354,7 +345,7 @@ class ArActivity : AppCompatActivity(), GLSurfaceView.Renderer {

// Visualize planes.
planeRenderer.drawPlanes(
session!!.getAllTrackables(Plane::class.java), camera.displayOrientedPose, projmtx
session!!.getAllTrackables(Plane::class.java), camera.displayOrientedPose, projmtx
)

// Visualize anchors created by touch.
Expand Down Expand Up @@ -383,22 +374,22 @@ class ArActivity : AppCompatActivity(), GLSurfaceView.Renderer {

private fun showSnackbarMessage(message: String, finishOnDismiss: Boolean) {
messageSnackbar = Snackbar.make(
[email protected](android.R.id.content),
message,
Snackbar.LENGTH_INDEFINITE
[email protected](android.R.id.content),
message,
Snackbar.LENGTH_INDEFINITE
)
messageSnackbar!!.view.setBackgroundColor(-0x40cdcdce)
if (finishOnDismiss) {
messageSnackbar!!.setAction(
"Dismiss"
"Dismiss"
) { messageSnackbar!!.dismiss() }
messageSnackbar!!.addCallback(
object : BaseTransientBottomBar.BaseCallback<Snackbar>() {
override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {
super.onDismissed(transientBottomBar, event)
finish()
}
})
object : BaseTransientBottomBar.BaseCallback<Snackbar>() {
override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {
super.onDismissed(transientBottomBar, event)
finish()
}
})
}
messageSnackbar!!.show()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import com.mirego.csmapapplication.MapPingApplication
import com.mirego.csmapapplication.R
import com.mirego.csmapapplication.fragment.ListSegmentFragment
import com.mirego.csmapapplication.fragment.MapSegmentFragment
import com.mirego.csmapapplication.model.Repo
import com.mirego.csmapapplication.model.VesselPart
import com.mirego.csmapapplication.service.MappingService
import kotlinx.android.synthetic.main.activity_main.*
import retrofit2.Retrofit
import javax.inject.Inject
import com.mirego.csmapapplication.service.GitHubService
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import retrofit2.Retrofit
import javax.inject.Inject


class MainActivity : FragmentActivity() {
Expand Down Expand Up @@ -53,21 +53,21 @@ class MainActivity : FragmentActivity() {
}

private fun downloadData() {
retrofit.create(GitHubService::class.java).listRepos("olivierpineau").enqueue(object : Callback<List<Repo>> {
override fun onFailure(call: Call<List<Repo>>?, t: Throwable?) {
Log.d("street's test", "Oops")
retrofit.create(MappingService::class.java).listVesselParts().enqueue(object : Callback<List<VesselPart>> {
override fun onFailure(call: Call<List<VesselPart>>?, t: Throwable?) {
Log.d("Main Activity", "Fail")
}

override fun onResponse(call: Call<List<Repo>>?, response: Response<List<Repo>>?) {
Log.d("street's test", "That's it")
override fun onResponse(call: Call<List<VesselPart>>?, response: Response<List<VesselPart>>?) {
mapFragment.setVesselParts(response?.body())
}
})
}

private fun setupMainView() {
supportFragmentManager.beginTransaction()
.add(fragmentRoot.id, listFragment)
.commit()
.add(fragmentRoot.id, listFragment)
.commit()
}

private fun onSegmentButtonClicked(button: ImageButton) {
Expand Down Expand Up @@ -136,10 +136,10 @@ class MainActivity : FragmentActivity() {

private fun tintSegmentButton(button: ImageButton, selected: Boolean) {
button.setColorFilter(
ContextCompat.getColor(
this,
if (selected) R.color.brightSunYellow else R.color.cloudGray
)
ContextCompat.getColor(
this,
if (selected) R.color.brightSunYellow else R.color.cloudGray
)
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package com.mirego.csmapapplication.fragment

import android.support.v4.app.Fragment
import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.mirego.csmapapplication.R

class ListSegmentFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_list, container, false)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,58 +1,68 @@
package com.mirego.csmapapplication.fragment

import android.support.v4.app.Fragment
import android.graphics.Bitmap
import android.graphics.Canvas
import android.os.Bundle
import android.support.annotation.DrawableRes
import android.support.v4.app.Fragment
import android.support.v4.content.res.ResourcesCompat
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.google.android.gms.maps.GoogleMap
import com.google.android.gms.maps.OnMapReadyCallback
import com.google.android.gms.maps.model.BitmapDescriptor
import com.mirego.csmapapplication.R
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.BitmapDescriptorFactory
import com.google.android.gms.maps.model.LatLng
import com.google.android.gms.maps.model.MarkerOptions
import kotlinx.android.synthetic.main.fragment_map.mapView
import kotlinx.android.synthetic.main.fragment_map.view.mapView
import android.opengl.ETC1.getHeight
import android.opengl.ETC1.getWidth
import android.graphics.Canvas
import android.graphics.Bitmap
import android.support.v4.content.res.ResourcesCompat
import android.graphics.drawable.Drawable
import android.support.annotation.DrawableRes

import com.mirego.csmapapplication.R
import com.mirego.csmapapplication.model.VesselPart
import kotlinx.android.synthetic.main.fragment_map.*
import kotlinx.android.synthetic.main.fragment_map.view.*


class MapSegmentFragment : Fragment(), OnMapReadyCallback {

private var vesselParts: List<VesselPart>? = emptyList()

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_map, container, false).also { mapSegmentView ->
mapSegmentView.mapView.onCreate(savedInstanceState)
mapSegmentView.mapView.getMapAsync { map ->
map.addMarker(
MarkerOptions()
.position(LatLng(46.7794201,-71.2778703))
.title("Test Opin")
.icon(createPinForPart(R.drawable.ic_part_bulb))
)
}
}
}

override fun onResume() {
super.onResume()
mapView.onResume()
vesselParts?.forEach { vesselPart ->
if (vesselPart.lat != null && vesselPart.lon != null) {
val resourceId = context?.resources?.getIdentifier("ic_part_" + vesselPart.type, "drawable", context?.packageName)
val latlng = LatLng(vesselPart.lat.toDouble(), vesselPart.lon.toDouble())
mapView.getMapAsync { map ->
map.addMarker(
MarkerOptions()
.position(latlng)
.title(vesselPart.name + " - " + vesselPart.component)
.icon(createPinForPart(resourceId!!))
)
}
}
}
}

override fun onMapReady(p0: GoogleMap?) {
// Nothing to do here
}

fun setVesselParts(vesselParts: List<VesselPart>?) {
this.vesselParts = vesselParts
}

private fun createPinForPart(@DrawableRes partResId: Int): BitmapDescriptor {
val pinDrawable = ResourcesCompat.getDrawable(resources, R.drawable.ic_pin, null)
val partDrawable = ResourcesCompat.getDrawable(resources, partResId, null)!!
Expand Down
Loading