diff --git a/app/src/google-services.json b/app/google-services.json similarity index 100% rename from app/src/google-services.json rename to app/google-services.json diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index e938999..7a2499d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,7 +1,6 @@ + xmlns:tools="http://schemas.android.com/tools" > + tools:targetApi="31" > - + + To get one, follow the directions here: - - - - - + https://developers.google.com/maps/documentation/android-sdk/get-api-key + Once you have your API key (it starts with "AIza"), define a new property in your + project's local.properties file (e.g. MAPS_API_KEY=Aiza...), and replace the + "YOUR_API_KEY" string in this file with "${MAPS_API_KEY}". + --> - + android:value="YOUR_API_KEY" /> + android:name=".MapActivity" + android:exported="false" /> @@ -44,21 +42,18 @@ android:name=".RootSearchActivity" android:exported="false" /> - - - + tools:ignore="DuplicateActivity" > @@ -67,12 +62,4 @@ - - - - - - - - - + \ No newline at end of file diff --git a/app/src/main/java/com/example/oplogy/MainActivity.java b/app/src/main/java/com/example/oplogy/MainActivity.java index e5bc0e8..630d0b3 100644 --- a/app/src/main/java/com/example/oplogy/MainActivity.java +++ b/app/src/main/java/com/example/oplogy/MainActivity.java @@ -68,7 +68,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe // セットアップのクリック処理 if(view == setUp){ imageSetup.setImageResource(R.drawable.ischecked_uuid); - Intent toSetup = new Intent(MainActivity.this,SetupActivity.class); + Intent toSetup = new Intent(MainActivity.this,SetUpActivity.class); startActivity(toSetup); } diff --git a/app/src/main/java/com/example/oplogy/MapActivity.java b/app/src/main/java/com/example/oplogy/MapActivity.java new file mode 100644 index 0000000..abe8c78 --- /dev/null +++ b/app/src/main/java/com/example/oplogy/MapActivity.java @@ -0,0 +1,14 @@ +package com.example.oplogy; + +import androidx.appcompat.app.AppCompatActivity; + +import android.os.Bundle; + +public class MapActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.map_activity); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/oplogy/Maps.java b/app/src/main/java/com/example/oplogy/Maps.java deleted file mode 100644 index 0a35d6a..0000000 --- a/app/src/main/java/com/example/oplogy/Maps.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.example.oplogy; - -import androidx.fragment.app.FragmentActivity; - -import android.os.Bundle; - -import com.google.android.gms.maps.CameraUpdateFactory; -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 com.example.oplogy.databinding.MapsBinding; - -public class Maps extends FragmentActivity implements OnMapReadyCallback { - - private GoogleMap mMap; - private MapsBinding binding; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - binding = MapsBinding.inflate(getLayoutInflater()); - setContentView(binding.getRoot()); - - // Obtain the SupportMapFragment and get notified when the map is ready to be used. - SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() - .findFragmentById(R.id.map); - 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 - public void onMapReady(GoogleMap googleMap) { - mMap = googleMap; - - // Add a marker in Sydney and move the camera - LatLng sydney = new LatLng(-34, 151); - mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney")); - mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)); - } -} \ No newline at end of file diff --git a/app/src/main/java/com/example/oplogy/MapsFragment.java b/app/src/main/java/com/example/oplogy/MapsFragment.java new file mode 100644 index 0000000..07bcf41 --- /dev/null +++ b/app/src/main/java/com/example/oplogy/MapsFragment.java @@ -0,0 +1,57 @@ +package com.example.oplogy; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; + +import com.google.android.gms.maps.CameraUpdateFactory; +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; + +public class MapsFragment extends Fragment { + + private OnMapReadyCallback callback = new OnMapReadyCallback() { + + /** + * 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 + public void onMapReady(GoogleMap googleMap) { + LatLng sydney = new LatLng(-34, 151); + googleMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney")); + googleMap.moveCamera(CameraUpdateFactory.newLatLng(sydney)); + } + }; + + @Nullable + @Override + public View onCreateView(@NonNull LayoutInflater inflater, + @Nullable ViewGroup container, + @Nullable Bundle savedInstanceState) { + return inflater.inflate(R.layout.maps_fragment, container, false); + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + SupportMapFragment mapFragment = + (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map); + if (mapFragment != null) { + mapFragment.getMapAsync(callback); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/oplogy/SetupActivity.java b/app/src/main/java/com/example/oplogy/SetupActivity.java index 13a4902..f775443 100644 --- a/app/src/main/java/com/example/oplogy/SetupActivity.java +++ b/app/src/main/java/com/example/oplogy/SetupActivity.java @@ -4,11 +4,11 @@ import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; -public class SetupActivity extends AppCompatActivity { +public class SetUpActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.setup); + setContentView(R.layout.activity_set_up); } } \ No newline at end of file diff --git a/app/src/main/res/layout/map_activity.xml b/app/src/main/res/layout/map_activity.xml new file mode 100644 index 0000000..d596091 --- /dev/null +++ b/app/src/main/res/layout/map_activity.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/maps.xml b/app/src/main/res/layout/maps_fragment.xml similarity index 79% rename from app/src/main/res/layout/maps.xml rename to app/src/main/res/layout/maps_fragment.xml index 519682a..a81efc5 100644 --- a/app/src/main/res/layout/maps.xml +++ b/app/src/main/res/layout/maps_fragment.xml @@ -1,9 +1,8 @@ \ No newline at end of file + android:id="@+id/map" + tools:context=".MapsFragment" + android:name="com.google.android.gms.maps.SupportMapFragment"/> \ No newline at end of file diff --git a/app/src/main/res/layout/setup.xml b/app/src/main/res/layout/setup.xml deleted file mode 100644 index eeacfd1..0000000 --- a/app/src/main/res/layout/setup.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - \ No newline at end of file