Skip to content

Commit 61a9c3d

Browse files
initial release
0 parents  commit 61a9c3d

File tree

78 files changed

+3802
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+3802
-0
lines changed

Diff for: app/build.gradle

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 29
5+
6+
defaultConfig {
7+
applicationId "com.next.googlemapapi"
8+
minSdkVersion 19
9+
targetSdkVersion 29
10+
versionCode 1
11+
versionName "1.0"
12+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
13+
}
14+
buildTypes {
15+
release {
16+
minifyEnabled false
17+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
implementation fileTree(dir: 'libs', include: ['*.jar'])
24+
testImplementation 'junit:junit:4.12'
25+
androidTestImplementation 'androidx.test:runner:1.2.0'
26+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
27+
implementation 'androidx.appcompat:appcompat:1.0.2'
28+
implementation 'com.google.android.gms:play-services-maps:17.0.0'
29+
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
30+
}

Diff for: app/proguard-rules.pro

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.next.googlemapapi;
2+
3+
import android.content.Context;
4+
5+
import androidx.test.InstrumentationRegistry;
6+
import androidx.test.runner.AndroidJUnit4;
7+
8+
import org.junit.Test;
9+
import org.junit.runner.RunWith;
10+
11+
import static org.junit.Assert.*;
12+
13+
/**
14+
* Instrumented test, which will execute on an Android device.
15+
*
16+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
17+
*/
18+
@RunWith(AndroidJUnit4.class)
19+
public class ExampleInstrumentedTest
20+
{
21+
@Test
22+
public void useAppContext()
23+
{
24+
// Context of the app under test.
25+
Context appContext = InstrumentationRegistry.getTargetContext();
26+
27+
assertEquals("com.next.googlemapapi", appContext.getPackageName());
28+
}
29+
}

Diff for: app/src/debug/res/values/google_maps_api.xml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<resources>
2+
<!--
3+
TODO: Before you run your application, you need a Google Maps API key.
4+
5+
To get one, follow this link, follow the directions and press "Create" at the end:
6+
7+
https://console.developers.google.com/
8+
9+
You can also add your credentials to an existing key, using these values:
10+
11+
Package name:
12+
13+
14+
SHA-1 certificate fingerprint:
15+
16+
17+
Alternatively, follow the directions here:
18+
https://developers.google.com/maps/documentation/android/start#get-key
19+
20+
Once you have your key (it starts with "AIza"), replace the "google_maps_key"
21+
string in this file.
22+
-->
23+
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false"></string>
24+
</resources>

Diff for: app/src/main/AndroidManifest.xml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
package="com.next.googlemapapi">
5+
6+
<!--
7+
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
8+
Google Maps Android API v2, but you must specify either coarse or fine
9+
location permissions for the 'MyLocation' functionality.
10+
-->
11+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
12+
13+
<application
14+
android:allowBackup="true"
15+
android:icon="@mipmap/ic_launcher"
16+
android:label="@string/app_name"
17+
android:roundIcon="@mipmap/ic_launcher_round"
18+
android:supportsRtl="true"
19+
android:theme="@style/AppTheme"
20+
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
21+
22+
<!--
23+
The API key for Google Maps-based APIs is defined as a string resource.
24+
(See the file "res/values/google_maps_api.xml").
25+
Note that the API key is linked to the encryption key used to sign the APK.
26+
You need a different API key for each encryption key, including the release key that is used to
27+
sign the APK for publishing.
28+
You can define the keys for the debug and release targets in src/debug/ and src/release/.
29+
-->
30+
<meta-data
31+
android:name="com.google.android.geo.API_KEY"
32+
android:value="@string/google_maps_key" />
33+
34+
<activity
35+
android:name=".MainActivity"
36+
android:label="@string/app_name">
37+
<intent-filter>
38+
<action android:name="android.intent.action.MAIN" />
39+
40+
<category android:name="android.intent.category.LAUNCHER" />
41+
</intent-filter>
42+
</activity>
43+
<activity android:name=".map.MapBasicActivity" />
44+
<activity android:name=".map.MapNavigationActivity" />
45+
<activity android:name=".map.MapCameraEventsActivity" />
46+
<activity android:name=".map.MarkerActivity" />
47+
<activity android:name=".map.ShapeActivity" />
48+
<activity android:name=".map.MapTypeAndStyleActivity" />
49+
<activity android:name=".map.MapSettingsActivity" />
50+
<activity android:name=".map.SnapshotActivity" />
51+
<activity android:name=".map.MyLocationActivity" />
52+
<activity android:name=".map.LocationSourceActivity" />
53+
<activity android:name=".streetview.StreetViewBasicActivity" />
54+
<activity android:name=".streetview.StreetViewNavigationActivity" />
55+
<activity android:name=".streetview.StreetViewEventsActivity" />
56+
<activity android:name=".streetview.StreetViewSettingsActivity" />
57+
<activity android:name=".streetview.StreetViewAndMapActivity" />
58+
</application>
59+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package com.next.googlemapapi;
2+
3+
import android.app.Activity;
4+
import android.view.View;
5+
import android.widget.ImageView;
6+
import android.widget.TextView;
7+
8+
import com.google.android.gms.maps.GoogleMap;
9+
import com.google.android.gms.maps.model.Marker;
10+
11+
public class CustomInfoWindowAdapter implements GoogleMap.InfoWindowAdapter
12+
{
13+
private final View window;
14+
private final View content;
15+
16+
public static Marker brisbane;
17+
public static Marker adelaide;
18+
public static boolean useDefaultInfoWindow;
19+
20+
public CustomInfoWindowAdapter(Activity activity)
21+
{
22+
window = activity.getLayoutInflater().inflate(R.layout.custom_info_window, null);
23+
content = activity.getLayoutInflater().inflate(R.layout.custom_info_contents, null);
24+
}
25+
26+
@Override
27+
public View getInfoWindow(Marker marker)
28+
{
29+
if (useDefaultInfoWindow)
30+
{
31+
// This means that getInfoContents will be called.
32+
return null;
33+
}
34+
render(marker, window);
35+
return window;
36+
}
37+
38+
@Override
39+
public View getInfoContents(Marker marker)
40+
{
41+
if (useDefaultInfoWindow)
42+
{
43+
// This means that the default info contents will be used.
44+
return null;
45+
}
46+
render(marker, content);
47+
return content;
48+
}
49+
50+
private void render(Marker marker, View view)
51+
{
52+
int badge;
53+
if (marker.equals(brisbane))
54+
{
55+
badge = R.drawable.brisbane;
56+
} else if (marker.equals(adelaide))
57+
{
58+
badge = R.drawable.adelaide;
59+
} else
60+
{
61+
// Passing 0 to setImageResource will clear the image view.
62+
badge = 0;
63+
}
64+
((ImageView) view.findViewById(R.id.badge)).setImageResource(badge);
65+
66+
String title = marker.getTitle();
67+
TextView tvTitle = view.findViewById(R.id.tvTitle);
68+
tvTitle.setText(title);
69+
70+
String snippet = marker.getSnippet();
71+
TextView tvSnippet = view.findViewById(R.id.tvSnippet);
72+
tvSnippet.setText(snippet);
73+
}
74+
}
+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.next.googlemapapi;
2+
3+
import androidx.appcompat.app.AppCompatActivity;
4+
5+
import android.content.Intent;
6+
import android.os.Bundle;
7+
import android.view.View;
8+
import android.widget.Button;
9+
import android.widget.Spinner;
10+
import android.widget.Toast;
11+
12+
public class MainActivity extends AppCompatActivity implements View.OnClickListener
13+
{
14+
public static final String TAG = "GoogleMapAPI";
15+
private String[] activityNames = {
16+
"MapBasic", "MapNavigation", "MapCameraEvents", "Marker", "Shape",
17+
"MapTypeAndStyle", "MapSettings", "Snapshot", "MyLocation", "LocationSource",
18+
"Basic", "Navigation", "Events", "Settings", "AndMap"
19+
};
20+
private Spinner sActivity;
21+
22+
@Override
23+
protected void onCreate(Bundle savedInstanceState)
24+
{
25+
super.onCreate(savedInstanceState);
26+
setContentView(R.layout.activity_main);
27+
28+
sActivity = findViewById(R.id.sActivity);
29+
Button bStart = findViewById(R.id.bStart);
30+
bStart.setOnClickListener(this);
31+
}
32+
33+
@Override
34+
public void onClick(View view)
35+
{
36+
int activityId = (int) sActivity.getSelectedItemId();
37+
38+
String activityToStart;
39+
if (activityId < 10)
40+
activityToStart = "com.next.googlemapapi.map." + activityNames[activityId] + "Activity";
41+
else
42+
activityToStart = "com.next.googlemapapi.streetview.StreetView" + activityNames[activityId] + "Activity";
43+
try
44+
{
45+
Class<?> c = Class.forName(activityToStart);
46+
Intent intent = new Intent(this, c);
47+
startActivity(intent);
48+
} catch (ClassNotFoundException ignored)
49+
{
50+
Toast.makeText(MainActivity.this, "Class Not Found, Wrong class or package name.", Toast.LENGTH_SHORT).show();
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)