diff --git a/app/build.gradle b/app/build.gradle index 8701f14..591e1f6 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -28,6 +28,8 @@ dependencies { }) implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" implementation 'com.android.support:appcompat-v7:25.4.0' + compile 'com.android.support:design:25.4.0' + implementation 'com.android.support.constraint:constraint-layout:1.0.2' testImplementation 'junit:junit:4.12' implementation 'com.google.android.gms:play-services-maps:10.2.1' implementation 'com.google.android.gms:play-services-location:10.2.1' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 3e3cd5c..f6469a4 100755 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -30,7 +30,8 @@ + android:label="@string/title_activity_maps" + android:theme="@style/AppTheme.NoActionBar"> diff --git a/app/src/main/java/fishrungames/yelpmapapp/DataProvider.kt b/app/src/main/java/fishrungames/yelpmapapp/DataProvider.kt index 2237a6c..9ede51f 100755 --- a/app/src/main/java/fishrungames/yelpmapapp/DataProvider.kt +++ b/app/src/main/java/fishrungames/yelpmapapp/DataProvider.kt @@ -1,17 +1,8 @@ package fishrungames.yelpmapapp import android.content.Context -import com.google.gson.JsonArray -import com.koushikdutta.ion.Ion -import java.io.BufferedInputStream -import java.net.HttpURLConnection -import java.net.URL -import java.security.AccessController.getContext -import com.google.gson.JsonObject -import com.koushikdutta.async.future.FutureCallback -import android.os.AsyncTask -import org.json.JSONObject +import com.koushikdutta.ion.Ion /** * Created by mephi on 09.06.2017. diff --git a/app/src/main/java/fishrungames/yelpmapapp/DetailFragment.kt b/app/src/main/java/fishrungames/yelpmapapp/DetailFragment.kt new file mode 100755 index 0000000..64e8a9c --- /dev/null +++ b/app/src/main/java/fishrungames/yelpmapapp/DetailFragment.kt @@ -0,0 +1,26 @@ +package fishrungames.yelpmapapp + +import android.support.v4.app.Fragment +import android.os.Bundle + +import android.view.ViewGroup +import android.view.LayoutInflater +import android.view.View + + + + + +/** + * Created by mephi on 10.06.2017. + */ + +class DetailFragment : Fragment() +{ + override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? { + + val rootView = inflater!!.inflate(R.layout.detail_fragment, container, false) + + return rootView + } +} \ No newline at end of file diff --git a/app/src/main/java/fishrungames/yelpmapapp/MapsActivity.kt b/app/src/main/java/fishrungames/yelpmapapp/MapsActivity.kt index ac13933..6aa4eaf 100755 --- a/app/src/main/java/fishrungames/yelpmapapp/MapsActivity.kt +++ b/app/src/main/java/fishrungames/yelpmapapp/MapsActivity.kt @@ -11,7 +11,7 @@ import com.google.android.gms.location.LocationListener; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; -import android.support.v4.app.FragmentActivity + import android.os.Bundle import android.support.v4.content.ContextCompat @@ -20,14 +20,15 @@ import com.google.android.gms.maps.GoogleMap import com.google.android.gms.maps.OnMapReadyCallback import com.google.android.gms.maps.SupportMapFragment import com.google.android.gms.maps.model.LatLng -import com.google.android.gms.maps.model.MarkerOptions import android.widget.Toast import android.support.v4.app.ActivityCompat import android.content.DialogInterface import android.support.v7.app.AlertDialog +import android.support.v7.app.AppCompatActivity -open class MapsActivity : FragmentActivity(), OnMapReadyCallback, LocationListener, + +open class MapsActivity : AppCompatActivity(), OnMapReadyCallback, LocationListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener { @@ -42,37 +43,26 @@ open class MapsActivity : FragmentActivity(), OnMapReadyCallback, LocationListen override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_maps) - // Obtain the SupportMapFragment and get notified when the map is ready to be used. - val mapFragment = supportFragmentManager - .findFragmentById(R.id.map) as SupportMapFragment + + val mapFragment = supportFragmentManager.findFragmentById(R.id.map) as SupportMapFragment + + //val mapFragment = SupportMapFragment() + + //supportFragmentManager.beginTransaction().add(R.id.container, mapFragment).commit() + mapFragment.getMapAsync(this) } - /** - * Manipulates the map once available. - * This callback is triggered when the map is ready to be used. - * This is where we can add markers or lines, add listeners or move the camera. In this case, - * we just add a marker near Sydney, Australia. - * If Google Play services is not installed on the device, the user will be prompted to install - * it inside the SupportMapFragment. This method will only be triggered once the user has - * installed Google Play services and returned to the app. - */ + override fun onMapReady(googleMap: GoogleMap) { - // Add a marker in Sydney and move the camera - //val sydney = LatLng(-34.0, 151.0) - //googleMap.addMarker(MarkerOptions().position(sydney).title("Marker in Sydney")) - //googleMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)) - - - if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) { - //Location Permission already granted + buildGoogleApiClient() googleMap.isMyLocationEnabled = true } else { - //Request Location Permission + checkLocationPermission() } @@ -128,18 +118,16 @@ open class MapsActivity : FragmentActivity(), OnMapReadyCallback, LocationListen private fun checkLocationPermission() { if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { - // Should we show an explanation? + if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_FINE_LOCATION)) { - // Show an explanation to the user *asynchronously* -- don't block - // this thread waiting for the user's response! After the user - // sees the explanation, try again to request the permission. + AlertDialog.Builder(this) .setTitle("Location Permission Needed") .setMessage("This app needs the Location permission, please accept to use location functionality") .setPositiveButton("OK", DialogInterface.OnClickListener { dialogInterface, i -> - //Prompt the user once explanation has been shown + ActivityCompat.requestPermissions(this, arrayOf(Manifest.permission.ACCESS_FINE_LOCATION), PERMISSIONS_REQUEST_LOCATION_CODE) diff --git a/app/src/main/java/fishrungames/yelpmapapp/YelpMapActivity.kt b/app/src/main/java/fishrungames/yelpmapapp/YelpMapActivity.kt index e31dcc4..59899c8 100755 --- a/app/src/main/java/fishrungames/yelpmapapp/YelpMapActivity.kt +++ b/app/src/main/java/fishrungames/yelpmapapp/YelpMapActivity.kt @@ -4,16 +4,8 @@ import android.location.Location import android.os.Handler import com.google.android.gms.maps.GoogleMap import com.google.android.gms.maps.model.Marker -import com.google.android.gms.maps.model.BitmapDescriptorFactory -import com.google.android.gms.maps.model.MarkerOptions -import com.google.android.gms.maps.model.LatLng import java.util.* import com.google.maps.android.clustering.ClusterManager -import com.google.android.gms.maps.CameraUpdateFactory -import android.widget.Toast - - - @@ -137,21 +129,20 @@ class YelpMapActivity : MapsActivity(), GoogleMap.OnInfoWindowClickListener private fun setUpClusterer(googleMap: GoogleMap) { - // Initialize the manager with the context and the map. - // (Activity extends context, so we can pass 'this' in the constructor.) + mClusterManager = ClusterManager(this, googleMap) - // Point the map's listeners at the listeners implemented by the cluster - // manager. googleMap.setOnCameraIdleListener(mClusterManager) googleMap.setOnMarkerClickListener(mClusterManager) } override fun onInfoWindowClick(marker: Marker) { - Toast.makeText(this, "Info window clicked", - Toast.LENGTH_SHORT).show() + + val detailFragment = DetailFragment() + + supportFragmentManager.beginTransaction().add(R.id.container, detailFragment).addToBackStack("detailFragment").commit() + } - } \ No newline at end of file diff --git a/app/src/main/res/drawable/bkgtest.jpg b/app/src/main/res/drawable/bkgtest.jpg new file mode 100755 index 0000000..fcf2b4e Binary files /dev/null and b/app/src/main/res/drawable/bkgtest.jpg differ diff --git a/app/src/main/res/layout/activity_maps.xml b/app/src/main/res/layout/activity_maps.xml index 569b781..700efd3 100755 --- a/app/src/main/res/layout/activity_maps.xml +++ b/app/src/main/res/layout/activity_maps.xml @@ -1,8 +1,47 @@ - + + + android:background="@android:color/background_light"> + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/detail_fragment.xml b/app/src/main/res/layout/detail_fragment.xml new file mode 100755 index 0000000..8bd06b4 --- /dev/null +++ b/app/src/main/res/layout/detail_fragment.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 6f19b47..80f09db 100755 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -8,4 +8,13 @@ @color/colorAccent + + +