diff --git a/.idea/androidTestResultsUserPreferences.xml b/.idea/androidTestResultsUserPreferences.xml index 1cbf69f..6407dff 100644 --- a/.idea/androidTestResultsUserPreferences.xml +++ b/.idea/androidTestResultsUserPreferences.xml @@ -29,6 +29,19 @@ + + + + + + + diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml index a3c1b03..6b0a26e 100644 --- a/.idea/deploymentTargetDropDown.xml +++ b/.idea/deploymentTargetDropDown.xml @@ -12,6 +12,6 @@ - + \ No newline at end of file diff --git a/app/release/app-release.apk b/app/release/app-release.apk new file mode 100644 index 0000000..a711ae4 Binary files /dev/null and b/app/release/app-release.apk differ diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json new file mode 100644 index 0000000..972cbda --- /dev/null +++ b/app/release/output-metadata.json @@ -0,0 +1,20 @@ +{ + "version": 3, + "artifactType": { + "type": "APK", + "kind": "Directory" + }, + "applicationId": "com.example.demo5", + "variantName": "release", + "elements": [ + { + "type": "SINGLE", + "filters": [], + "attributes": [], + "versionCode": 1, + "versionName": "1.0", + "outputFile": "app-release.apk" + } + ], + "elementType": "File" +} \ No newline at end of file diff --git a/app/src/androidTest/java/com/example/demo5/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/example/demo5/ExampleInstrumentedTest.java deleted file mode 100644 index 193cedf..0000000 --- a/app/src/androidTest/java/com/example/demo5/ExampleInstrumentedTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.example.demo5; - -import android.content.Context; - -import androidx.test.platform.app.InstrumentationRegistry; -import androidx.test.ext.junit.runners.AndroidJUnit4; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.*; - -/** - * Instrumented test, which will execute on an Android device. - * - * @see Testing documentation - */ -@RunWith(AndroidJUnit4.class) -public class ExampleInstrumentedTest { - @Test - public void useAppContext() { - // Context of the app under test. - Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); - assertEquals("com.example.demo5", appContext.getPackageName()); - } -} \ No newline at end of file diff --git a/app/src/androidTest/java/com/example/demo5/MainActivityTest.java b/app/src/androidTest/java/com/example/demo5/MainActivityTest.java index 1d611cd..ab6a7dd 100644 --- a/app/src/androidTest/java/com/example/demo5/MainActivityTest.java +++ b/app/src/androidTest/java/com/example/demo5/MainActivityTest.java @@ -51,7 +51,7 @@ public void mainActivityTest() { childAtPosition( childAtPosition( withId(android.R.id.content), - 0), + 2), 2), isDisplayed())); appCompatEditText.perform(replaceText("my parent's house"), closeSoftKeyboard()); diff --git a/app/src/androidTest/java/com/example/demo5/ParentHouseLocationTest.java b/app/src/androidTest/java/com/example/demo5/ParentHouseLocationTest.java deleted file mode 100644 index 170da5f..0000000 --- a/app/src/androidTest/java/com/example/demo5/ParentHouseLocationTest.java +++ /dev/null @@ -1,157 +0,0 @@ -package com.example.demo5; - - -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewParent; - -import org.hamcrest.Description; -import org.hamcrest.Matcher; -import org.hamcrest.TypeSafeMatcher; -import org.hamcrest.core.IsInstanceOf; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; - -import androidx.test.espresso.ViewInteraction; -import androidx.test.ext.junit.rules.ActivityScenarioRule; -import androidx.test.ext.junit.runners.AndroidJUnit4; -import androidx.test.filters.LargeTest; -import androidx.test.rule.GrantPermissionRule; - -import static androidx.test.espresso.Espresso.onView; -import static androidx.test.espresso.action.ViewActions.closeSoftKeyboard; -import static androidx.test.espresso.action.ViewActions.replaceText; -import static androidx.test.espresso.assertion.ViewAssertions.matches; -import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed; -import static androidx.test.espresso.matcher.ViewMatchers.withId; -import static androidx.test.espresso.matcher.ViewMatchers.withParent; -import static androidx.test.espresso.matcher.ViewMatchers.withText; -import static org.hamcrest.Matchers.allOf; - -@LargeTest -@RunWith(AndroidJUnit4.class) -public class ParentHouseLocationTest { - - /*@Rule - public ActivityScenarioRule mActivityScenarioRule = - new ActivityScenarioRule<>(MainActivity.class); - - @Rule - public GrantPermissionRule mGrantPermissionRule = - GrantPermissionRule.grant( - "android.permission.ACCESS_FINE_LOCATION", - "android.permission.ACCESS_COARSE_LOCATION"); - - @Test - public void parentHouseLocationTest() { - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - - ViewInteraction textView = onView( - allOf(withId(R.id.locationText), withText("0° 12' 12\" N, 0° 3' 3\" W"), - withParent(withParent(withId(android.R.id.content))), - isDisplayed())); - textView.check(matches(withText("0° 12' 12\" N, 0° 3' 3\" W"))); - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - - ViewInteraction appCompatEditText = onView( - allOf(withId(R.id.parentLatitude), withText("0"), - childAtPosition( - childAtPosition( - withId(android.R.id.content), - 0), - 3), - isDisplayed())); - appCompatEditText.perform(replaceText("1")); - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - - ViewInteraction appCompatEditText2 = onView( - allOf(withId(R.id.parentLatitude), withText("1"), - childAtPosition( - childAtPosition( - withId(android.R.id.content), - 0), - 3), - isDisplayed())); - appCompatEditText2.perform(closeSoftKeyboard()); - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - - ViewInteraction appCompatEditText3 = onView( - allOf(withId(R.id.parentLongitude), withText("0"), - childAtPosition( - childAtPosition( - withId(android.R.id.content), - 0), - 1), - isDisplayed())); - appCompatEditText3.perform(replaceText("1")); - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - - ViewInteraction appCompatEditText4 = onView( - allOf(withId(R.id.parentLongitude), withText("1"), - childAtPosition( - childAtPosition( - withId(android.R.id.content), - 0), - 1), - isDisplayed())); - appCompatEditText4.perform(closeSoftKeyboard()); - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - - ViewInteraction imageView = onView( - allOf(withId(R.id.parentHouse), - withParent(allOf(withId(R.id.compass), - withParent(IsInstanceOf.instanceOf(android.view.ViewGroup.class)))), - isDisplayed())); - imageView.check(matches(isDisplayed())); - } - - private static Matcher childAtPosition( - final Matcher parentMatcher, final int position) { - - return new TypeSafeMatcher() { - @Override - public void describeTo(Description description) { - description.appendText("Child at position " + position + " in parent "); - parentMatcher.describeTo(description); - } - - @Override - public boolean matchesSafely(View view) { - ViewParent parent = view.getParent(); - return parent instanceof ViewGroup && parentMatcher.matches(parent) - && view.equals(((ViewGroup) parent).getChildAt(position)); - } - }; - }*/ -} diff --git a/app/src/main/java/com/example/demo5/MainActivity.java b/app/src/main/java/com/example/demo5/MainActivity.java index 7195089..464177e 100644 --- a/app/src/main/java/com/example/demo5/MainActivity.java +++ b/app/src/main/java/com/example/demo5/MainActivity.java @@ -19,23 +19,15 @@ public class MainActivity extends AppCompatActivity { private static final String HOUSE_LABEL_STRING = "houseLabel"; private LocationService locationService; private OrientationService orientationService; + private bestFriend bestFriend = new bestFriend(); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main); + setContentView(R.layout.activity_compass); locationService = LocationService.singleton(this); this.reobserveLocation(); - - orientationService = OrientationService.singleton(this); - this.reobserveOrientation(); - - var timeService = TimeService.singleton(); - var timeData = timeService.getTimeData(); - timeData.observe(this, this::onTimeChanged); - - loadProfile(); } private void reobserveLocation() { @@ -43,162 +35,209 @@ private void reobserveLocation() { locationData.observe(this, this::onLocationChanged); } - public void reobserveOrientation() { - var orientationData = orientationService.getOrientation(); - orientationData.observe(this, this::onOrientationChanged); - } - private void onLocationChanged(Pair latLong) { TextView locationText = findViewById(R.id.locationText); locationText.setText(Utilities.formatLocation(latLong.first, latLong.second)); - updateCompassWhenLocationChanges(latLong.first, latLong.second); + whenFriendLocationChanges(latLong.first, latLong.second); } - private void onOrientationChanged(Float orientation) { - updateCompassWhenOrientationChanges(orientation); - } - - public void updateCompassWhenLocationChanges(Double latitude, Double longitude) { + public void whenFriendLocationChanges(Double latitude, Double longitude) { double ang = angleCalculation(latitude, longitude); - //US-2b - String newLabel = retrieveParentLabel(); - updateParentHouseLabel(newLabel); - updateParentHouseLabel(ang); - - updateParentHouse(ang); - } - - public void updateCompassWhenOrientationChanges(Float orientation) { - float deg = (float) Math.toDegrees(orientation); - ConstraintLayout compass = findViewById(R.id.compass); - - //US-10 - float new_angle = retrieveManualOrientation(); - - compass.setRotation(DEGREES_IN_A_CIRCLE - new_angle - deg); - } - - public float retrieveManualOrientation() { - TextView orientationLabelView = findViewById(R.id.orientation_text); - String orientationLabelText = orientationLabelView.getText().toString(); - Float orientationLabelValue; - - try { - orientationLabelValue = Float.parseFloat(orientationLabelText); - } catch (Exception e) { - orientationLabelValue = Float.valueOf(0); - - } - - if (orientationLabelValue > DEGREES_IN_A_CIRCLE - 1) { - orientationLabelValue = Float.valueOf(DEGREES_IN_A_CIRCLE - 1); - orientationLabelView.setText(BLANK_STRING); - } else if (orientationLabelValue < 0) { - orientationLabelValue = Float.valueOf(0); - orientationLabelView.setText(BLANK_STRING); - } - - return orientationLabelValue; - } - - public double angleCalculation(Double latitude, Double longitude) { - Pair parentLocation = retrieveParentLocation(); - String parentLatText = parentLocation.first; - String parentLongText = parentLocation.second; - - double plat; - double plong; - - try { - plat = Double.parseDouble(parentLatText); - plong = Double.parseDouble(parentLongText); - } catch (Exception e) { - plat = 0; - plong = 0; - } - - return Math.atan2(plong - longitude, plat - latitude); - } - - private void updateParentHouseLabel(String newLabel) { - TextView label = findViewById(R.id.labelTextView); - label.setText(newLabel); - } - - private void updateParentHouseLabel(double ang) { - TextView label = findViewById(R.id.labelTextView); - ConstraintLayout.LayoutParams houseLabelParam = (ConstraintLayout.LayoutParams) - label.getLayoutParams(); - houseLabelParam.circleAngle = (float) Math.toDegrees(ang); - label.setLayoutParams(houseLabelParam); + updateFriendDirection(ang); } - private void updateParentHouse(double ang) { - ImageView parentHouse = findViewById(R.id.parentHouse); + public void updateFriendDirection(double ang) { + TextView bestFriend = findViewById(R.id.best_friend); ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) - parentHouse.getLayoutParams(); + bestFriend.getLayoutParams(); layoutParams.circleAngle = (float) Math.toDegrees(ang); - parentHouse.setLayoutParams(layoutParams); - } - - private Pair retrieveParentLocation() { - TextView parentLatView = findViewById(R.id.parentLatitude); - TextView parentLongView = findViewById(R.id.parentLongitude); - - String parentLatText = parentLatView.getText().toString(); - String parentLongText = parentLongView.getText().toString(); - - if (parentLatText.equals(BLANK_STRING)) { - parentLatText = ZERO_STRING; - } - if (parentLongText.equals(BLANK_STRING)) { - parentLongText = ZERO_STRING; - } - - savePLatAndPLong(parentLatText, parentLongText); - - return new Pair<>(parentLatText, parentLongText); - } - - private String retrieveParentLabel() { - TextView parentLabelView = findViewById(R.id.house_label); - String parentLabelText = parentLabelView.getText().toString(); - savePLabel(parentLabelText); - return parentLabelText; + bestFriend.setLayoutParams(layoutParams); } - private void savePLatAndPLong(String parentLatText, String parentLongText) { - SharedPreferences preferences = getPreferences(MODE_PRIVATE); - SharedPreferences.Editor editor = preferences.edit(); - editor.putString(P_LAT_STRING, parentLatText); - editor.putString(P_LONG_STRING, parentLongText); - editor.apply(); - } - - private void savePLabel(String parentLabelText) { - SharedPreferences preferences = getPreferences(MODE_PRIVATE); - SharedPreferences.Editor editor = preferences.edit(); - editor.putString(HOUSE_LABEL_STRING, parentLabelText); - editor.apply(); - } - - private void onTimeChanged(Long time) {} - - public void loadProfile() { - SharedPreferences preferences = getPreferences(MODE_PRIVATE); - String s = preferences.getString(P_LAT_STRING, ZERO_STRING); - String t = preferences.getString(P_LONG_STRING, ZERO_STRING); - TextView parentLatitude = findViewById(R.id.parentLatitude); - TextView parentLongitude = findViewById(R.id.parentLongitude); - parentLatitude.setText(s); - parentLongitude.setText(t); - - // US-2b - String u = preferences.getString(HOUSE_LABEL_STRING, BLANK_STRING); - TextView parentLabel = findViewById(R.id.labelTextView); - TextView parentLabelField = findViewById(R.id.house_label); - parentLabel.setText(u); - parentLabelField.setText(u); - } + public double angleCalculation(Double latitude, Double longitude) { + return Math.atan2(bestFriend.getLongitude() - longitude, bestFriend.getLatitude() - latitude); + } + + // @Override +// protected void onCreate(Bundle savedInstanceState) { +// super.onCreate(savedInstanceState); +// setContentView(R.layout.activity_main); +// +// locationService = LocationService.singleton(this); +// this.reobserveLocation(); +// +// orientationService = OrientationService.singleton(this); +// this.reobserveOrientation(); +// +// var timeService = TimeService.singleton(); +// var timeData = timeService.getTimeData(); +// timeData.observe(this, this::onTimeChanged); +// +// loadProfile(); +// } + +// private void reobserveLocation() { +// var locationData = locationService.getLocation(); +// locationData.observe(this, this::onLocationChanged); +// } +// +// public void reobserveOrientation() { +// var orientationData = orientationService.getOrientation(); +// orientationData.observe(this, this::onOrientationChanged); +// } +// +// private void onLocationChanged(Pair latLong) { +// TextView locationText = findViewById(R.id.locationText); +// locationText.setText(Utilities.formatLocation(latLong.first, latLong.second)); +// updateCompassWhenLocationChanges(latLong.first, latLong.second); +// } +// +// private void onOrientationChanged(Float orientation) { +// updateCompassWhenOrientationChanges(orientation); +// } +// +// public void updateCompassWhenLocationChanges(Double latitude, Double longitude) { +// double ang = angleCalculation(latitude, longitude); +// +// //US-2b +// String newLabel = retrieveParentLabel(); +// updateParentHouseLabel(newLabel); +// updateParentHouseLabel(ang); +// +// updateParentHouse(ang); +// } +// +// public void updateCompassWhenOrientationChanges(Float orientation) { +// float deg = (float) Math.toDegrees(orientation); +// ConstraintLayout compass = findViewById(R.id.compass); +// +// //US-10 +// float new_angle = retrieveManualOrientation(); +// +// compass.setRotation(DEGREES_IN_A_CIRCLE - new_angle - deg); +// } +// +// public float retrieveManualOrientation() { +// TextView orientationLabelView = findViewById(R.id.orientation_text); +// String orientationLabelText = orientationLabelView.getText().toString(); +// Float orientationLabelValue; +// +// try { +// orientationLabelValue = Float.parseFloat(orientationLabelText); +// } catch (Exception e) { +// orientationLabelValue = Float.valueOf(0); +// +// } +// +// if (orientationLabelValue > DEGREES_IN_A_CIRCLE - 1) { +// orientationLabelValue = Float.valueOf(DEGREES_IN_A_CIRCLE - 1); +// orientationLabelView.setText(BLANK_STRING); +// } else if (orientationLabelValue < 0) { +// orientationLabelValue = Float.valueOf(0); +// orientationLabelView.setText(BLANK_STRING); +// } +// +// return orientationLabelValue; +// } +// +// public double angleCalculation(Double latitude, Double longitude) { +// Pair parentLocation = retrieveParentLocation(); +// String parentLatText = parentLocation.first; +// String parentLongText = parentLocation.second; +// +// double plat; +// double plong; +// +// try { +// plat = Double.parseDouble(parentLatText); +// plong = Double.parseDouble(parentLongText); +// } catch (Exception e) { +// plat = 0; +// plong = 0; +// } +// +// return Math.atan2(plong - longitude, plat - latitude); +// } +// +// private void updateParentHouseLabel(String newLabel) { +// TextView label = findViewById(R.id.labelTextView); +// label.setText(newLabel); +// } +// +// private void updateParentHouseLabel(double ang) { +// TextView label = findViewById(R.id.labelTextView); +// ConstraintLayout.LayoutParams houseLabelParam = (ConstraintLayout.LayoutParams) +// label.getLayoutParams(); +// houseLabelParam.circleAngle = (float) Math.toDegrees(ang); +// label.setLayoutParams(houseLabelParam); +// } +// +// private void updateParentHouse(double ang) { +// ImageView parentHouse = findViewById(R.id.parentHouse); +// ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) +// parentHouse.getLayoutParams(); +// layoutParams.circleAngle = (float) Math.toDegrees(ang); +// parentHouse.setLayoutParams(layoutParams); +// } +// +// private Pair retrieveParentLocation() { +// TextView parentLatView = findViewById(R.id.parentLatitude); +// TextView parentLongView = findViewById(R.id.parentLongitude); +// +// String parentLatText = parentLatView.getText().toString(); +// String parentLongText = parentLongView.getText().toString(); +// +// if (parentLatText.equals(BLANK_STRING)) { +// parentLatText = ZERO_STRING; +// } +// if (parentLongText.equals(BLANK_STRING)) { +// parentLongText = ZERO_STRING; +// } +// +// savePLatAndPLong(parentLatText, parentLongText); +// +// return new Pair<>(parentLatText, parentLongText); +// } +// +// private String retrieveParentLabel() { +// TextView parentLabelView = findViewById(R.id.house_label); +// String parentLabelText = parentLabelView.getText().toString(); +// savePLabel(parentLabelText); +// return parentLabelText; +// } +// +// private void savePLatAndPLong(String parentLatText, String parentLongText) { +// SharedPreferences preferences = getPreferences(MODE_PRIVATE); +// SharedPreferences.Editor editor = preferences.edit(); +// editor.putString(P_LAT_STRING, parentLatText); +// editor.putString(P_LONG_STRING, parentLongText); +// editor.apply(); +// } +// +// private void savePLabel(String parentLabelText) { +// SharedPreferences preferences = getPreferences(MODE_PRIVATE); +// SharedPreferences.Editor editor = preferences.edit(); +// editor.putString(HOUSE_LABEL_STRING, parentLabelText); +// editor.apply(); +// } +// +// private void onTimeChanged(Long time) {} +// +// public void loadProfile() { +// SharedPreferences preferences = getPreferences(MODE_PRIVATE); +// String s = preferences.getString(P_LAT_STRING, ZERO_STRING); +// String t = preferences.getString(P_LONG_STRING, ZERO_STRING); +// TextView parentLatitude = findViewById(R.id.parentLatitude); +// TextView parentLongitude = findViewById(R.id.parentLongitude); +// parentLatitude.setText(s); +// parentLongitude.setText(t); +// +// // US-2b +// String u = preferences.getString(HOUSE_LABEL_STRING, BLANK_STRING); +// TextView parentLabel = findViewById(R.id.labelTextView); +// TextView parentLabelField = findViewById(R.id.house_label); +// parentLabel.setText(u); +// parentLabelField.setText(u); +// } } \ No newline at end of file diff --git a/app/src/main/java/com/example/demo5/MainActivity2.java b/app/src/main/java/com/example/demo5/MainActivity2.java deleted file mode 100644 index 914b5f1..0000000 --- a/app/src/main/java/com/example/demo5/MainActivity2.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.example.demo5; - -import android.app.Activity; -import android.content.Intent; -import android.content.SharedPreferences; -import android.content.pm.PackageManager; -import android.os.Bundle; -import android.view.View; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.TextView; - -import androidx.appcompat.app.AppCompatActivity; -import androidx.constraintlayout.widget.ConstraintLayout; -import androidx.core.app.ActivityCompat; -import androidx.lifecycle.LiveData; - -public class MainActivity2 extends AppCompatActivity { - private TimeService timeService; - private OrientationService orientationService; - private LocationService locationService; - - public static final int DEGREES_IN_A_CIRCLE = 360; - - @Override - protected void onCreate(Bundle savedInstanceState){ - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_main2); - - - orientationService = OrientationService.singleton(this); - - ConstraintLayout compass = findViewById(R.id.compass2); - - - - - - - if(ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION)!= PackageManager.PERMISSION_GRANTED - && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED){ - ActivityCompat.requestPermissions(this,new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION}, 200); - } - - locationService = LocationService.singleton(this); - - ImageView parentHouse = findViewById(R.id.parentHouse2); - TextView textView = findViewById(R.id.timeTextView2); - locationService.getLocation().observe(this,loc->{ - textView.setText(Double.toString(loc.first)+" , "+ - Double.toString(loc.second)); - - SharedPreferences preferences = getPreferences(MODE_PRIVATE); - Double pLat = Double.parseDouble(preferences.getString("parentLatitude", "123")); - Double pLong = Double.parseDouble(preferences.getString("parentLongitude", "123")); - - double adjacent = (pLong - loc.second); - double hypotenuse = Math.sqrt(((pLat - loc.first)*(pLat - loc.first)) + ((pLong - loc.second)*(pLong - loc.second))); - - double ang = Math.acos(adjacent/hypotenuse); - - ConstraintLayout.LayoutParams layoutParams = (ConstraintLayout.LayoutParams) parentHouse.getLayoutParams(); - layoutParams.circleAngle = DEGREES_IN_A_CIRCLE - (float)Math.toDegrees(ang); - }); - - loadProfile(); - - orientationService.getOrientation().observe(this, orientation ->{ - float deg = (float) Math.toDegrees(orientation); - compass.setRotation(DEGREES_IN_A_CIRCLE - deg); - }); - } - - @Override - protected void onPause(){ - super.onPause(); - orientationService.unregisterSensorListeners(); - } - - public void loadProfile () { - SharedPreferences preferences = getPreferences(MODE_PRIVATE); - String s = preferences.getString("parentLatitude", "123"); - String t = preferences.getString("parentLongitude", "123"); - TextView parentLatitude = findViewById(R.id.parentLatitude2); - TextView parentLongitude = findViewById(R.id.parentLongitude2); - parentLatitude.setText(s); - parentLongitude.setText(t); - System.out.println(preferences.getAll().toString()); - } - - public void saveProfile () { - SharedPreferences preferences = getPreferences(MODE_PRIVATE); - SharedPreferences.Editor editor = preferences.edit(); - TextView parentLatitude = findViewById(R.id.parentLatitude2); - editor.putString("parentLatitude", parentLatitude.getText().toString()); - TextView parentLongitude = findViewById(R.id.parentLongitude2); - editor.putString("parentLongitude", parentLongitude.getText().toString()); - editor.apply(); - } - - public void save(View view) { - saveProfile(); - loadProfile(); - Intent intent = new Intent(this, MainActivity.class); - startActivity(intent); - } -} \ No newline at end of file diff --git a/app/src/main/java/com/example/demo5/bestFriend.java b/app/src/main/java/com/example/demo5/bestFriend.java new file mode 100644 index 0000000..735413a --- /dev/null +++ b/app/src/main/java/com/example/demo5/bestFriend.java @@ -0,0 +1,28 @@ +package com.example.demo5; + +public class bestFriend { + double latitude; + double longitude; + + bestFriend() { + latitude = 0; + longitude = 0; + } + + public double getLatitude() { + return latitude; + } + + public double getLongitude() { + return longitude; + } + +/* public void testMove() throws InterruptedException { + for (int i = 0; i < 10; ++i) { + latitude++; + longitude++; + + Thread.sleep(10000); + } + }*/ +} diff --git a/app/src/main/res/drawable/circle.png b/app/src/main/res/drawable/circle.png new file mode 100644 index 0000000..d194117 Binary files /dev/null and b/app/src/main/res/drawable/circle.png differ diff --git a/app/src/main/res/drawable/circular.png b/app/src/main/res/drawable/circular.png new file mode 100644 index 0000000..f80c525 Binary files /dev/null and b/app/src/main/res/drawable/circular.png differ diff --git a/app/src/main/res/drawable/dot.png b/app/src/main/res/drawable/dot.png new file mode 100644 index 0000000..7eb72b5 Binary files /dev/null and b/app/src/main/res/drawable/dot.png differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml index 07d5da9..1498a8b 100644 --- a/app/src/main/res/drawable/ic_launcher_background.xml +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -167,4 +167,18 @@ android:pathData="M79,19L79,89" android:strokeWidth="0.8" android:strokeColor="#33FFFFFF" /> + + + + + + + + diff --git a/app/src/main/res/drawable/person.png b/app/src/main/res/drawable/person.png new file mode 100644 index 0000000..5a0a0ea Binary files /dev/null and b/app/src/main/res/drawable/person.png differ diff --git a/app/src/main/res/layout/activity_compass.xml b/app/src/main/res/layout/activity_compass.xml new file mode 100644 index 0000000..94cde5d --- /dev/null +++ b/app/src/main/res/layout/activity_compass.xml @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 94191d6..2dc32d2 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,173 +1,9 @@ + - - - - - - - - - - - - - - - - - - - - - -