mirror of
https://github.com/googlemaps/android-samples.git
synced 2025-12-08 18:02:20 +00:00
feat: modernization ApiDemos (#2288)
* feat: modernization ApiDemos * feat: Gradle
This commit is contained in:
parent
3c4fb12231
commit
f44422bd95
@ -26,7 +26,7 @@
|
||||
android:layout_weight="1"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
|
||||
@ -31,9 +31,8 @@
|
||||
app:title="@string/advanced_markers_demo_label"
|
||||
app:titleTextColor="?attr/colorOnPrimary" />
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
class="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
class="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="0dp"
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
app:title="@string/basic_map_demo_label"
|
||||
app:titleTextColor="?attr/colorOnPrimary" />
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
class="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:title="@string/background_color_customization_demo_label"
|
||||
app:titleTextColor="?attr/colorOnPrimary" />
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/container"
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:title="@string/background_color_customization_demo_label"
|
||||
app:titleTextColor="?attr/colorOnPrimary" />
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
@ -133,7 +133,7 @@
|
||||
|
||||
</TableLayout>
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
class="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
app:titleTextColor="?attr/colorOnPrimary"
|
||||
style="@style/Widget.MaterialComponents.Toolbar.Primary"
|
||||
/>
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
class="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:title="@string/events_demo_label" />
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
class="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:title="@string/ground_overlay_demo_label" />
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
class="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:title="@string/indoor_demo_label" />
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:title="@string/layers_demo_label" />
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
class="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="0dp"
|
||||
|
||||
@ -66,7 +66,7 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/go_to_adelaide" />
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
class="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:title="@string/map_color_scheme_demo_label" />
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
class="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
class="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
class="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:title="@string/multi_map_demo_label" />
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map1"
|
||||
class="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="0dp"
|
||||
@ -43,7 +43,7 @@
|
||||
app:cameraTargetLng="-74.00"
|
||||
app:cameraZoom="8" />
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map2"
|
||||
class="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="0dp"
|
||||
@ -56,7 +56,7 @@
|
||||
app:cameraTargetLng="-0.12"
|
||||
app:cameraZoom="8" />
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map3"
|
||||
class="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="0dp"
|
||||
@ -69,7 +69,7 @@
|
||||
app:cameraTargetLng="2.35"
|
||||
app:cameraZoom="8" />
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map4"
|
||||
class="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="0dp"
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:title="@string/my_location_demo_label" />
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
class="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="0dp"
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.fragment.app.FragmentContainerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:map="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/map"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@ -117,7 +117,7 @@
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
class="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="0dp"
|
||||
|
||||
@ -128,7 +128,7 @@
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
class="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="0dp"
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/top_bar" />
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
class="com.example.mapdemo.SaveStateDemoActivity$SaveStateMapFragment"
|
||||
android:layout_width="0dp"
|
||||
|
||||
@ -39,7 +39,7 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/topAppBar">
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
class="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:title="@string/split_street_view_panorama_and_map_demo_label" />
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/streetviewpanorama"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
@ -41,7 +41,7 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHeight_percent="0.5" />
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/streetviewpanorama"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
|
||||
android:id="@+id/streetviewpanorama"
|
||||
class="com.google.android.gms.maps.SupportStreetViewPanoramaFragment"
|
||||
|
||||
@ -199,7 +199,7 @@
|
||||
android:text="@string/go_to_invalid" />
|
||||
</LinearLayout>
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/streetviewpanorama"
|
||||
class="com.google.android.gms.maps.SupportStreetViewPanoramaFragment"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/streetviewpanorama"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
app:title="@string/styled_map_demo_label" />
|
||||
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
class="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
class="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.fragment.app.FragmentContainerView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/map"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<fragment
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/map"
|
||||
class="com.google.android.gms.maps.SupportMapFragment"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@ -1,27 +1,25 @@
|
||||
[versions]
|
||||
activity = "1.10.1"
|
||||
activityKtx = "1.10.1"
|
||||
androidxJunit = "1.2.1"
|
||||
activity = "1.11.0"
|
||||
androidxJunit = "1.3.0"
|
||||
appcompat = "1.7.1"
|
||||
cardview = "1.0.0"
|
||||
easypermissions = "3.0.0"
|
||||
espresso = "3.6.1"
|
||||
gradle = "8.10.1"
|
||||
espresso = "3.7.0"
|
||||
gradle = "8.13.0"
|
||||
junit = "4.13.2"
|
||||
kotlin = "2.2.0"
|
||||
lifecycle = "2.9.1"
|
||||
kotlin = "2.2.20"
|
||||
lifecycle = "2.9.4"
|
||||
mapsKtx = "5.2.0"
|
||||
material = "1.12.0"
|
||||
material = "1.13.0"
|
||||
multidex = "2.0.1"
|
||||
playServicesMaps = "19.2.0"
|
||||
recyclerview = "1.4.0"
|
||||
secretsGradlePlugin = "2.0.1"
|
||||
volley = "1.2.1"
|
||||
coreKtx = "1.16.0"
|
||||
coreKtx = "1.17.0"
|
||||
|
||||
[libraries]
|
||||
activity = { module = "androidx.activity:activity", version.ref = "activity" }
|
||||
activityKtx = { module = "androidx.activity:activity-ktx", version.ref = "activityKtx" }
|
||||
androidxJunit = { group = "androidx.test.ext", name = "junit", version.ref = "androidxJunit" }
|
||||
appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
|
||||
cardview = { group = "androidx.cardview", name = "cardview", version.ref = "cardview" }
|
||||
|
||||
BIN
ApiDemos/project/gradle/wrapper/gradle-wrapper.jar
vendored
BIN
ApiDemos/project/gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
9
ApiDemos/project/gradlew
vendored
9
ApiDemos/project/gradlew
vendored
@ -86,8 +86,7 @@ done
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
||||
' "$PWD" ) || exit
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@ -115,7 +114,7 @@ case "$( uname )" in #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
CLASSPATH="\\\"\\\""
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@ -206,7 +205,7 @@ fi
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
@ -214,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
|
||||
4
ApiDemos/project/gradlew.bat
vendored
4
ApiDemos/project/gradlew.bat
vendored
@ -70,11 +70,11 @@ goto fail
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
set CLASSPATH=
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
||||
@ -21,12 +21,12 @@ plugins {
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = 35
|
||||
compileSdk = 36
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.example.mapdemo"
|
||||
minSdk = 21
|
||||
targetSdk = 35
|
||||
targetSdk = 36
|
||||
versionCode = 1
|
||||
versionName = "1.16.0"
|
||||
multiDexEnabled = true
|
||||
|
||||
@ -16,11 +16,7 @@ package com.example.mapdemo;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.widget.CheckBox;
|
||||
|
||||
import androidx.activity.EdgeToEdge;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import com.google.android.gms.maps.GoogleMap;
|
||||
import com.google.android.gms.maps.GoogleMapOptions;
|
||||
@ -28,6 +24,7 @@ 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 com.google.android.material.switchmaterial.SwitchMaterial;
|
||||
|
||||
/**
|
||||
* This shows how to to instantiate a SupportMapFragment programmatically with a custom background
|
||||
@ -70,7 +67,7 @@ public class BackgroundColorCustomizationProgrammaticDemoActivity extends Sample
|
||||
public void onMapReady(GoogleMap map) {
|
||||
map.setMapType(GoogleMap.MAP_TYPE_NONE);
|
||||
|
||||
CheckBox mapTypeToggleCheckbox = findViewById(com.example.common_ui.R.id.map_type_toggle);
|
||||
SwitchMaterial mapTypeToggleCheckbox = findViewById(com.example.common_ui.R.id.map_type_toggle);
|
||||
mapTypeToggleCheckbox.setOnCheckedChangeListener(
|
||||
(view, isChecked) -> map.setMapType(isChecked ? GoogleMap.MAP_TYPE_NORMAL : GoogleMap.MAP_TYPE_NONE));
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@ public class GroundOverlayDemoActivity extends SamplesBaseActivity
|
||||
private static final LatLng NEAR_NEWARK =
|
||||
new LatLng(NEWARK.latitude - 0.001, NEWARK.longitude - 0.025);
|
||||
|
||||
private final List<BitmapDescriptor> images = new ArrayList<BitmapDescriptor>();
|
||||
private final List<BitmapDescriptor> images = new ArrayList<>();
|
||||
|
||||
private GroundOverlay groundOverlay;
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
@ -71,17 +71,14 @@ public class MapInPagerDemoActivity extends SamplesBaseActivity {
|
||||
return 3;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
case 1:
|
||||
return new TextFragment();
|
||||
case 2:
|
||||
return SupportMapFragment.newInstance();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return switch (position) {
|
||||
case 0, 1 -> new TextFragment();
|
||||
case 2 -> SupportMapFragment.newInstance();
|
||||
default -> throw new IllegalStateException("Unexpected value: " + position);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,7 +198,7 @@ public class MarkerDemoActivity extends SamplesBaseActivity implements
|
||||
*/
|
||||
private Marker mLastSelectedMarker;
|
||||
|
||||
private final List<Marker> mMarkerRainbow = new ArrayList<Marker>();
|
||||
private final List<Marker> mMarkerRainbow = new ArrayList<>();
|
||||
|
||||
private TextView mTopText;
|
||||
|
||||
|
||||
@ -30,8 +30,6 @@ import android.os.Bundle;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
@ -70,7 +68,7 @@ public class SaveStateDemoActivity extends SamplesBaseActivity {
|
||||
static class MarkerInfo implements Parcelable {
|
||||
|
||||
public static final Parcelable.Creator<MarkerInfo> CREATOR =
|
||||
new Parcelable.Creator<MarkerInfo>() {
|
||||
new Parcelable.Creator<>() {
|
||||
@Override
|
||||
public MarkerInfo createFromParcel(Parcel in) {
|
||||
return new MarkerInfo(in);
|
||||
|
||||
@ -22,15 +22,14 @@ import com.google.android.gms.maps.SupportMapFragment;
|
||||
import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.android.gms.maps.model.MapStyleOptions;
|
||||
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -85,7 +84,7 @@ public class StyledMapDemoActivity extends SamplesBaseActivity implements OnMapR
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapReady(GoogleMap map) {
|
||||
public void onMapReady(@NonNull GoogleMap map) {
|
||||
mMap = map;
|
||||
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(SYDNEY, 14));
|
||||
setSelectedStyle();
|
||||
@ -122,15 +121,12 @@ public class StyledMapDemoActivity extends SamplesBaseActivity implements OnMapR
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(getString(com.example.common_ui.R.string.style_choose));
|
||||
builder.setItems(styleNames.toArray(new CharSequence[styleNames.size()]),
|
||||
new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
mSelectedStyleId = mStyleIds[which];
|
||||
String msg = getString(com.example.common_ui.R.string.style_set_to, getString(mSelectedStyleId));
|
||||
Toast.makeText(getBaseContext(), msg, Toast.LENGTH_SHORT).show();
|
||||
Log.d(TAG, msg);
|
||||
setSelectedStyle();
|
||||
}
|
||||
(dialog, which) -> {
|
||||
mSelectedStyleId = mStyleIds[which];
|
||||
String msg = getString(com.example.common_ui.R.string.style_set_to, getString(mSelectedStyleId));
|
||||
Toast.makeText(getBaseContext(), msg, Toast.LENGTH_SHORT).show();
|
||||
Log.d(TAG, msg);
|
||||
setSelectedStyle();
|
||||
});
|
||||
builder.show();
|
||||
}
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
|
||||
/*
|
||||
* Copyright 2025 Google LLC
|
||||
*
|
||||
@ -22,12 +24,12 @@ plugins {
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = 35
|
||||
compileSdk = 36
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.example.kotlindemos"
|
||||
minSdk = 21
|
||||
targetSdk = 35
|
||||
targetSdk = 36
|
||||
versionCode = 1
|
||||
versionName = "1.16.0"
|
||||
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
|
||||
@ -54,15 +56,13 @@ android {
|
||||
abortOnError = false
|
||||
}
|
||||
|
||||
kotlinOptions {
|
||||
freeCompilerArgs = listOf("-Xopt-in=kotlin.RequiresOptIn")
|
||||
jvmTarget = JavaVersion.VERSION_21.toString()
|
||||
}
|
||||
|
||||
namespace = "com.example.kotlindemos"
|
||||
}
|
||||
|
||||
kotlin {
|
||||
compilerOptions {
|
||||
jvmTarget.set(JvmTarget.JVM_21)
|
||||
}
|
||||
jvmToolchain(21) // Specify the JVM toolchain version
|
||||
}
|
||||
|
||||
|
||||
@ -180,7 +180,7 @@
|
||||
android:name=".VisibleRegionDemoActivity"
|
||||
android:exported="true" />
|
||||
<activity
|
||||
android:name=".polyline.PolylineDemoActivity"
|
||||
android:name=".PolylineDemoActivity"
|
||||
android:exported="true" />
|
||||
</application>
|
||||
|
||||
|
||||
@ -25,8 +25,6 @@ import android.widget.CheckBox
|
||||
import com.google.android.gms.maps.model.MarkerOptions
|
||||
import com.google.android.gms.maps.model.LatLng
|
||||
import com.example.common_ui.R
|
||||
import com.google.android.material.checkbox.MaterialCheckBox
|
||||
import com.google.android.material.switchmaterial.SwitchMaterial
|
||||
|
||||
/**
|
||||
* This shows how to to instantiate a SupportMapFragment programmatically with a custom background
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
package com.example.kotlindemos
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
@ -28,12 +27,9 @@ import com.google.android.gms.maps.SupportMapFragment
|
||||
import com.google.android.gms.maps.model.CameraPosition
|
||||
import com.google.android.gms.maps.model.LatLng
|
||||
import com.google.android.gms.maps.model.LatLngBounds
|
||||
import com.google.maps.android.ktx.CameraIdleEvent
|
||||
import com.google.maps.android.ktx.awaitMap
|
||||
import com.google.maps.android.ktx.cameraEvents
|
||||
import com.google.maps.android.ktx.cameraIdleEvents
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
|
||||
@ -277,9 +277,9 @@ class DataDrivenDatasetStylingActivity : SamplesBaseActivity(), OnMapReadyCallba
|
||||
val styleFactory = FeatureLayer.StyleFactory { feature: Feature ->
|
||||
|
||||
// Set default colors to to yellow and point radius to 8.
|
||||
var fillColor = Color.GREEN
|
||||
var strokeColor = Color.YELLOW
|
||||
var pointRadius = 8F
|
||||
var fillColor: Int
|
||||
var strokeColor: Int
|
||||
val pointRadius = 8F
|
||||
var strokeWidth = 3F
|
||||
// Check if the feature is an instance of DatasetFeature.
|
||||
if (feature is DatasetFeature) {
|
||||
|
||||
@ -16,8 +16,6 @@
|
||||
|
||||
package com.example.kotlindemos
|
||||
|
||||
import com.example.kotlindemos.polyline.PolylineDemoActivity
|
||||
|
||||
/**
|
||||
* A list of all the demos we have available.
|
||||
*/
|
||||
|
||||
@ -13,7 +13,6 @@
|
||||
// limitations under the License.
|
||||
package com.example.kotlindemos
|
||||
|
||||
import android.Manifest
|
||||
import android.Manifest.permission
|
||||
import android.app.AlertDialog
|
||||
import android.app.Dialog
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.example.kotlindemos.polyline
|
||||
package com.example.kotlindemos
|
||||
|
||||
import com.google.android.gms.maps.CameraUpdateFactory
|
||||
import com.google.android.gms.maps.GoogleMap
|
||||
@ -43,8 +43,6 @@ import android.widget.CheckBox
|
||||
import android.widget.SeekBar
|
||||
import android.widget.Spinner
|
||||
|
||||
import com.example.kotlindemos.R
|
||||
import com.example.kotlindemos.SamplesBaseActivity
|
||||
import java.util.Arrays
|
||||
|
||||
/**
|
||||
|
||||
@ -17,8 +17,6 @@ import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.example.common_ui.R
|
||||
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.maps.android.ktx.addMarker
|
||||
|
||||
@ -24,12 +24,9 @@ import com.google.android.gms.maps.SupportMapFragment
|
||||
import com.google.android.gms.maps.model.BitmapDescriptorFactory
|
||||
import com.google.android.gms.maps.model.LatLng
|
||||
import com.google.android.gms.maps.model.Marker
|
||||
import com.google.maps.android.ktx.CameraEvent
|
||||
import com.google.maps.android.ktx.addMarker
|
||||
import com.google.maps.android.ktx.awaitMap
|
||||
import com.google.maps.android.ktx.cameraEvents
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import java.util.Random
|
||||
|
||||
/**
|
||||
|
||||
@ -15,7 +15,6 @@ package com.example.kotlindemos
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import android.widget.CheckBox
|
||||
import android.widget.ImageView
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@ import com.google.android.gms.maps.model.Tile
|
||||
import com.google.android.gms.maps.model.TileOverlayOptions
|
||||
import com.google.android.gms.maps.model.TileProvider
|
||||
import java.io.ByteArrayOutputStream
|
||||
import androidx.core.graphics.createBitmap
|
||||
|
||||
/**
|
||||
* This demonstrates tile overlay coordinates.
|
||||
@ -47,19 +48,23 @@ class TileCoordinateDemoActivity : SamplesBaseActivity(), OnMapReadyCallback {
|
||||
}
|
||||
|
||||
private class CoordTileProvider(context: Context) : TileProvider {
|
||||
private val scaleFactor: Float
|
||||
/* Scale factor based on density, with a 0.6 multiplier to increase tile generation
|
||||
* speed */
|
||||
private val scaleFactor: Float = context.resources.displayMetrics.density * 0.6f
|
||||
override fun getTile(x: Int, y: Int, zoom: Int): Tile {
|
||||
val coordTile = createTile(x, y, zoom)
|
||||
val stream = ByteArrayOutputStream()
|
||||
coordTile!!.compress(Bitmap.CompressFormat.PNG, 0, stream)
|
||||
coordTile.compress(Bitmap.CompressFormat.PNG, 0, stream)
|
||||
val bitmapData = stream.toByteArray()
|
||||
return Tile((TILE_SIZE_DP * scaleFactor).toInt(),
|
||||
(TILE_SIZE_DP * scaleFactor).toInt(), bitmapData)
|
||||
}
|
||||
|
||||
private fun createTile(x: Int, y: Int, zoom: Int): Bitmap {
|
||||
val tile = Bitmap.createBitmap((TILE_SIZE_DP * scaleFactor).toInt(),
|
||||
(TILE_SIZE_DP * scaleFactor).toInt(), Bitmap.Config.ARGB_8888)
|
||||
val tile = createBitmap(
|
||||
(TILE_SIZE_DP * scaleFactor).toInt(),
|
||||
(TILE_SIZE_DP * scaleFactor).toInt()
|
||||
)
|
||||
val canvas = Canvas(tile)
|
||||
|
||||
// Draw the tile borders.
|
||||
@ -85,11 +90,5 @@ class TileCoordinateDemoActivity : SamplesBaseActivity(), OnMapReadyCallback {
|
||||
companion object {
|
||||
private const val TILE_SIZE_DP = 256
|
||||
}
|
||||
|
||||
init {
|
||||
/* Scale factor based on density, with a 0.6 multiplier to increase tile generation
|
||||
* speed */
|
||||
scaleFactor = context.resources.displayMetrics.density * 0.6f
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user