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

ULaval 1 #20

Open
wants to merge 10 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
Binary file added .DS_Store
Binary file not shown.
38 changes: 38 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Logs
logs
*.log
npm-debug.log*

# Dependency directories
node_modules

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

# Compiled files
dist

#maven
dependency-reduced-pom.xml

# IDE
.idea

**/target/
/target/
*/target/*
.classpath
.project
.settings

Package Files #
*.jar
*.war
*.ear
*.iml

/frontend/src/**/*.js
/frontend/src/**/*.js.map
3 changes: 1 addition & 2 deletions android/.gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
/.idea/*
.DS_Store
/build
/captures
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.

62 changes: 19 additions & 43 deletions android/README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,29 @@
# CS Games 2018 - Mobile - Android App
## Équipe

This project serves as a starting base for the CS Games 2018 Mobile Competition.
**Nom de l'équipe:** Délé ULaval 1

You may edit it as much as you like – as long as you make something awesome!
**Code de l'équipe:** 1

## Prerequisites
**Université:** Université Laval

Make sure you have the following software installed before beginning:
**Auteurs:**
- Daphnée Pateneaude
- Philippe Dupuis

- Latest version of Android Studio (3.0.1)
- Recent version of the Android SDK (at least API 21)
## Solution

You can download these from the [Android Developer website](https://developer.android.com/studio/index.html).
**Plateforme:** Android

> **NOTE:** If you have a Mac computer running macOS 10.12.6 or later, you may also be interested in our [iOS app](https://github.com/mirego/csgames18-competition/tree/master/ios), which uses Xcode and the latest iOS SDK.
**Fonctionnalités:**
1. Mode carte: connexion de la data source et affichage de toutes les pins
2. Liste des pièces perdues

## Getting started
**Étapes de build:**
- Rien de nouveau

First, make sure you have cloned the project from GitHub:
**Ce qui a bien été ou mal été:**
- Le projet de base était vraiment bien fait, ça a aidé pour commencer ;)
- Très nice défi !

```
git clone http://github.com/mirego/csgames18-competition.git
```

Then, in Android Studio:

- Select **Import project (Eclipse, ADT, Gradle, etc.)** in the Welcome Screen, go find the `android` folder in the repository you just cloned, and click **OK**.
- Once the project is open, click on **Sync Project with Gradle Files** in the main toolbar (or navigate to `Tools -> Android` in the application menu and select the same option).

<p align="center"><img src="https://cloud.githubusercontent.com/assets/4378424/24182187/64981e3e-0e96-11e7-8fcb-f03f14d78c59.png" width="208"></p>

Once you see a `BUILD SUCCESSFUL` notice in the Gradle Console, your environment should be ready to build and run the project.

## Building the project

The project should have already been configured as an Android project in Android Studio, therefore you should see a target named `app` in the main toolbar, with **Play** and **Debug** buttons on its right.

Press on the **Debug** icon, and if you don't already have one, [create a new Android Virtual Device](https://developer.android.com/studio/run/managing-avds.html), then select it to run the project.

Once the app appears running in your Virtual Device, your environment is ready for the competition.

## License

This competition is © 2018 [Mirego](http://www.mirego.com) and may be freely
distributed under the [New BSD license](http://opensource.org/licenses/BSD-3-Clause).
See the [`LICENSE.md`](https://github.com/mirego/csgames18-competition/blob/master/LICENSE.md) file.

## About Mirego

[Mirego](http://mirego.com) is a team of passionate people who believe that work is a place where you can innovate and have fun. We're a team of [talented people](http://life.mirego.com) who imagine and build beautiful Web and mobile applications. We come together to share ideas and [change the world](http://mirego.org).

We also [love open-source software](http://open.mirego.com) and we try to give back to the community as much as we can.
**Fiertés et déceptions:**
-
2 changes: 2 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ kapt {
}

dependencies {
compile 'com.android.volley:volley:1.0.0'

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class MainActivity : FragmentActivity() {
}

private fun downloadData() {
retrofit.create(GitHubService::class.java).listRepos("olivierpineau").enqueue(object : Callback<List<Repo>> {
retrofit.create(GitHubService::class.java).listRepos("olivierpineuau").enqueue(object : Callback<List<Repo>> {
override fun onFailure(call: Call<List<Repo>>?, t: Throwable?) {
Log.d("street's test", "Oops")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.mirego.csmapapplication.component

import android.app.Activity
import android.content.Context
import android.support.v4.app.FragmentActivity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import com.mirego.csmapapplication.R
import android.widget.ImageView
import android.widget.TextView

/**
* Created by Sagold on 2018-03-24.
*/
class LostObjectsAdapter(private val objects: ArrayList<String>, private val activity: FragmentActivity) : BaseAdapter() {

override fun getView(i: Int, p0: View?, viewGroup: ViewGroup?): View {
var view = p0
if (view == null) {
view = View.inflate(activity,R.layout.item,null)
}


val s = this.getItem(i) as String

val img = view!!.findViewById(R.id.imageIcon) as ImageView
var description = view!!.findViewById(R.id.txtDescription) as TextView
var position = view!!.findViewById(R.id.txtPosition) as TextView
var distance = view!!.findViewById(R.id.txtDistance) as TextView
var name = view!!.findViewById(R.id.txtObjectName) as TextView

description.text = "..."
position.text = "jhdfhg"
distance.text = "hjbfdh"
name.text = "djfbhgbf"

return view
}

override fun getItem(p0: Int): Any {
return objects.get(p0)
}

override fun getItemId(p0: Int): Long {
return p0.toLong()
}

override fun getCount(): Int {
return objects.size;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,30 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import android.widget.ListView
import com.mirego.csmapapplication.R
import com.mirego.csmapapplication.component.LostObjectsAdapter


class ListSegmentFragment : Fragment() {

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_list, container, false)
val view = inflater.inflate(R.layout.fragment_list, container, false)
val listView = view.findViewById(R.id.listContainer) as ListView

val list = ArrayList<String>()
var adapterlist : ArrayAdapter<String>?=null
list.add("Hello")
list.add("Hello 1")
list.add("Hello 2")
adapterlist = ArrayAdapter(activity!!,android.R.layout.simple_list_item_1,list)
val adapter = LostObjectsAdapter(list, activity!!)
listView.adapter = adapter
return view
}
}
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
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.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.android.volley.Request
import com.android.volley.Response
import com.android.volley.toolbox.JsonArrayRequest
import com.android.volley.toolbox.Volley
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 kotlinx.android.synthetic.main.fragment_map.*
import kotlinx.android.synthetic.main.fragment_map.view.*


class MapSegmentFragment : Fragment(), OnMapReadyCallback {
Expand All @@ -47,13 +47,50 @@ class MapSegmentFragment : Fragment(), OnMapReadyCallback {
override fun onResume() {
super.onResume()
mapView.onResume()

var requestQueue = Volley.newRequestQueue(this.context)

val jsonArrayRequest = JsonArrayRequest(Request.Method.GET, resources.getString(R.string.pieces_url), null,
Response.Listener { response ->
for (i in 0 until response.length()) {

val piece = response.getJSONObject(i)
val name = piece.getString("name")
val type = piece.getString("type")
if (!piece.isNull("lat") && !piece.isNull("lon")) {
val lat = piece.getDouble("lat")
val lon = piece.getDouble("lon")
println(name)
var resourceId = context?.resources?.getIdentifier("ic_part_" + type, "drawable", context?.packageName)
resourceId?.let {
this.mapView.getMapAsync { map ->
map.addMarker(
MarkerOptions()
.position(LatLng(lat, lon))
.title(name)
.icon(createPinForPart(resourceId))
)
}
}

}
}
},
Response.ErrorListener { error ->
println("Something here")
// TODO: Handle error
}
)

requestQueue.add(jsonArrayRequest)
}

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

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 All @@ -71,4 +108,4 @@ class MapSegmentFragment : Fragment(), OnMapReadyCallback {

return BitmapDescriptorFactory.fromBitmap(bitmap)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.mirego.csmapapplication.service


Loading