commit 2363ec3cdee7749908f14a199e72932565edaceb Author: Arti Zirk Date: Sat Apr 21 23:59:40 2018 +0300 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..39b6783 --- /dev/null +++ b/.gitignore @@ -0,0 +1,65 @@ +# Built application files +*.apk +*.ap_ + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +.idea/caches + +# Keystore files +# Uncomment the following line if you do not want to check your keystore files in. +#*.jks + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild + +# Google Services (e.g. APIs or Firebase) +google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..30aa626 --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..99202cc --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..7939b67 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..0eca1d7 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,29 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 27 + defaultConfig { + applicationId "ee.rasks.vabaloodus.vabaloodustest" + minSdkVersion 23 + targetSdkVersion 27 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'com.android.support.constraint:constraint-layout:1.1.0' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.1' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' + implementation 'com.google.android.gms:play-services-maps:15.0.0' + implementation 'com.google.android.gms:play-services-location:15.0.0' +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/ee/rasks/vabaloodus/vabaloodustest/ExampleInstrumentedTest.java b/app/src/androidTest/java/ee/rasks/vabaloodus/vabaloodustest/ExampleInstrumentedTest.java new file mode 100644 index 0000000..3a3847f --- /dev/null +++ b/app/src/androidTest/java/ee/rasks/vabaloodus/vabaloodustest/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package ee.rasks.vabaloodus.vabaloodustest; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.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.getTargetContext(); + + assertEquals("ee.rasks.vabaloodus.vabaloodustest", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..74a3964 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/ee/rasks/vabaloodus/vabaloodustest/ExploreMapActivity.java b/app/src/main/java/ee/rasks/vabaloodus/vabaloodustest/ExploreMapActivity.java new file mode 100644 index 0000000..4417b2c --- /dev/null +++ b/app/src/main/java/ee/rasks/vabaloodus/vabaloodustest/ExploreMapActivity.java @@ -0,0 +1,148 @@ +package ee.rasks.vabaloodus.vabaloodustest; + + +import android.Manifest; +import android.content.Context; +import android.content.pm.PackageManager; +import android.hardware.Sensor; +import android.hardware.SensorEvent; +import android.hardware.SensorEventListener; +import android.hardware.SensorManager; +import android.support.constraint.ConstraintLayout; +import android.support.v4.app.FragmentActivity; +import android.os.Bundle; +import android.support.v4.content.ContextCompat; +import android.util.Log; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.PopupWindow; +import android.widget.Toast; + +import com.google.android.gms.location.LocationServices; +import com.google.android.gms.maps.CameraUpdateFactory; +import com.google.android.gms.maps.GoogleMap; +import com.google.android.gms.maps.SupportMapFragment; +import com.google.android.gms.maps.OnMapReadyCallback; +import com.google.android.gms.maps.model.LatLng; +import com.google.android.gms.maps.model.PolylineOptions; + + +public class ExploreMapActivity extends FragmentActivity implements OnMapReadyCallback { + private static final String TAG = "ExploreMapActivity"; + private GoogleMap mMap; + + private SensorManager mSensorManager; + private float mAccel; // acceleration apart from gravity + private float mAccelCurrent; // current acceleration including gravity + private float mAccelLast; // last acceleration including gravity + + private PopupWindow mPopupWindow; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_explore_map); + SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() + .findFragmentById(R.id.map); + mapFragment.getMapAsync(this); + + mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); + mSensorManager.registerListener(mSensorListener, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL); + mAccel = 0.00f; + mAccelCurrent = SensorManager.GRAVITY_EARTH; + mAccelLast = SensorManager.GRAVITY_EARTH; + } + + @Override + public void onMapReady(GoogleMap googleMap) { + mMap = googleMap; + Log.d(TAG, "Map Ready"); + PolylineOptions lineOpts = new PolylineOptions(); + String lineStr = "24.6600768,59.3952051,0\n" + + " 24.6610813,59.3950262,0\n" + + " 24.6616566,59.3949129,0\n" + + " 24.6617364,59.3948689,0\n" + + " 24.6617787,59.3948166,0\n" + + " 24.6618846,59.3946193,0\n" + + " 24.6616969,59.3945742,0\n" + + " 24.6613455,59.3945319,0\n" + + " 24.6612006,59.3946712,0\n" + + " 24.6606266,59.3946043,0\n" + + " 24.6603477,59.3946528,0\n" + + " 24.6601063,59.3947395,0\n" + + " 24.6599896,59.3948712,0\n" + + " 24.6599481,59.395003,0\n" + + " 24.6600768,59.3952051,0"; + for (String line : lineStr.split("\n")) { + String[] point = line.split(","); + lineOpts.add(new LatLng(Double.parseDouble(point[1]), Double.parseDouble(point[0]))); + } + + //Polyline polyLine = googleMap.addPolyline(lineOpts); + mMap.addPolyline(lineOpts); + mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(lineOpts.getPoints().get(7), 17)); + + if (ContextCompat.checkSelfPermission(this, + Manifest.permission.ACCESS_FINE_LOCATION) + == PackageManager.PERMISSION_GRANTED) { + mMap.setMyLocationEnabled(true); + } + + } + + private final SensorEventListener mSensorListener = new SensorEventListener() { + + public void onSensorChanged(SensorEvent se) { + float x = se.values[0]; + float y = se.values[1]; + float z = se.values[2]; + mAccelLast = mAccelCurrent; + mAccelCurrent = (float) Math.sqrt((double) (x*x + y*y + z*z)); + float delta = mAccelCurrent - mAccelLast; + mAccel = mAccel * 0.9f + delta; // perform low-cut filter + Log.d(TAG, "mAccel: "+mAccel); + if (mAccel > 12) { + + if (mPopupWindow == null || !mPopupWindow.isShowing()){ + LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(LAYOUT_INFLATER_SERVICE); + View customView = inflater.inflate(R.layout.popup_creature_near,null); + mPopupWindow = new PopupWindow( + customView, + ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.WRAP_CONTENT + ); + mPopupWindow.setElevation(5.0f); + } + + if (mPopupWindow != null) { + if (!mPopupWindow.isShowing()) { + mPopupWindow.showAtLocation((ConstraintLayout) findViewById(R.id.activity_explore_map_layout), Gravity.CENTER, 0, 0); + } else { + mPopupWindow.dismiss(); + } + } + } + } + + public void onAccuracyChanged(Sensor sensor, int accuracy) { + } + }; + + @Override + protected void onResume() { + super.onResume(); + mSensorManager.registerListener(mSensorListener, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_NORMAL); + } + + @Override + protected void onPause() { + mSensorManager.unregisterListener(mSensorListener); + if (mPopupWindow != null && mPopupWindow.isShowing()) { + mPopupWindow.dismiss(); + } + super.onPause(); + } + +} diff --git a/app/src/main/java/ee/rasks/vabaloodus/vabaloodustest/WelcomeActivity.java b/app/src/main/java/ee/rasks/vabaloodus/vabaloodustest/WelcomeActivity.java new file mode 100644 index 0000000..516baf2 --- /dev/null +++ b/app/src/main/java/ee/rasks/vabaloodus/vabaloodustest/WelcomeActivity.java @@ -0,0 +1,41 @@ +package ee.rasks.vabaloodus.vabaloodustest; + +import android.Manifest; +import android.app.Activity; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.os.Bundle; +import android.support.v4.app.ActivityCompat; +import android.support.v4.content.ContextCompat; +import android.util.Log; +import android.view.View; + +public class WelcomeActivity extends Activity { + private static final String TAG = "WelcomeActivity"; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_welcome); + if (ContextCompat.checkSelfPermission(this, + Manifest.permission.ACCESS_FINE_LOCATION) + != PackageManager.PERMISSION_GRANTED) { + + + // No explanation needed; request the permission + ActivityCompat.requestPermissions(this, + new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, + 1); + + // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an + // app-defined int constant. The callback method gets the + // result of the request. + } + } + + public void exploreMap(View view) { + Log.d(TAG, "exploreMap"); + Intent intent = new Intent(this, ExploreMapActivity.class); + startActivity(intent); + } +} diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..c7bd21d --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/app/src/main/res/drawable/hommik_viru_rabas.jpg b/app/src/main/res/drawable/hommik_viru_rabas.jpg new file mode 100644 index 0000000..0774a70 Binary files /dev/null and b/app/src/main/res/drawable/hommik_viru_rabas.jpg differ diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..d5fccc5 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_explore_map.xml b/app/src/main/res/layout/activity_explore_map.xml new file mode 100644 index 0000000..a946e66 --- /dev/null +++ b/app/src/main/res/layout/activity_explore_map.xml @@ -0,0 +1,19 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_welcome.xml b/app/src/main/res/layout/activity_welcome.xml new file mode 100644 index 0000000..ab29b49 --- /dev/null +++ b/app/src/main/res/layout/activity_welcome.xml @@ -0,0 +1,37 @@ + + + + + +