From 49344e8b68c856b0edbd26407179088b7bfe7541 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 2 Sep 2015 16:17:14 +1200 Subject: Commit template Android project --- app/.gitignore | 1 + app/build.gradle | 26 +++++++++ .../java/org/traccar/manager/ApplicationTest.java | 13 +++++ app/src/debug/res/values/google_maps_api.xml | 5 ++ app/src/main/AndroidManifest.xml | 39 +++++++++++++ .../java/org/traccar/manager/MainActivity.java | 65 +++++++++++++++++++++ app/src/main/res/layout/activity_main.xml | 4 ++ app/src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3418 bytes app/src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2206 bytes app/src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4842 bytes app/src/main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 7718 bytes app/src/main/res/values/strings.xml | 4 ++ app/src/main/res/values/styles.xml | 8 +++ app/src/release/res/values/google_maps_api.xml | 18 ++++++ 14 files changed, 183 insertions(+) create mode 100644 app/.gitignore create mode 100644 app/build.gradle create mode 100644 app/src/androidTest/java/org/traccar/manager/ApplicationTest.java create mode 100644 app/src/debug/res/values/google_maps_api.xml create mode 100644 app/src/main/AndroidManifest.xml create mode 100644 app/src/main/java/org/traccar/manager/MainActivity.java create mode 100644 app/src/main/res/layout/activity_main.xml create mode 100644 app/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 app/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 app/src/main/res/values/strings.xml create mode 100644 app/src/main/res/values/styles.xml create mode 100644 app/src/release/res/values/google_maps_api.xml (limited to 'app') 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..b11e645 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,26 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 22 + buildToolsVersion "22.0.1" + + defaultConfig { + applicationId "org.traccar.manager" + minSdkVersion 10 + targetSdkVersion 22 + versionCode 1 + versionName "1.0" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.android.support:appcompat-v7:22.2.1' + compile 'com.google.android.gms:play-services:7.5.0' +} diff --git a/app/src/androidTest/java/org/traccar/manager/ApplicationTest.java b/app/src/androidTest/java/org/traccar/manager/ApplicationTest.java new file mode 100644 index 0000000..25062ea --- /dev/null +++ b/app/src/androidTest/java/org/traccar/manager/ApplicationTest.java @@ -0,0 +1,13 @@ +package org.traccar.manager; + +import android.app.Application; +import android.test.ApplicationTestCase; + +/** + * Testing Fundamentals + */ +public class ApplicationTest extends ApplicationTestCase { + public ApplicationTest() { + super(Application.class); + } +} \ No newline at end of file diff --git a/app/src/debug/res/values/google_maps_api.xml b/app/src/debug/res/values/google_maps_api.xml new file mode 100644 index 0000000..27fc920 --- /dev/null +++ b/app/src/debug/res/values/google_maps_api.xml @@ -0,0 +1,5 @@ + + + AIzaSyB2sTYAPuWFpWHCP-cbGBYL2qJVmsMnfrQ + + diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..8f1e8cd --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/java/org/traccar/manager/MainActivity.java b/app/src/main/java/org/traccar/manager/MainActivity.java new file mode 100644 index 0000000..7b6e202 --- /dev/null +++ b/app/src/main/java/org/traccar/manager/MainActivity.java @@ -0,0 +1,65 @@ +package org.traccar.manager; + +import android.support.v4.app.FragmentActivity; +import android.os.Bundle; + +import com.google.android.gms.maps.GoogleMap; +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 MainActivity extends FragmentActivity { + + private GoogleMap mMap; // Might be null if Google Play services APK is not available. + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + setUpMapIfNeeded(); + } + + @Override + protected void onResume() { + super.onResume(); + setUpMapIfNeeded(); + } + + /** + * Sets up the map if it is possible to do so (i.e., the Google Play services APK is correctly + * installed) and the map has not already been instantiated.. This will ensure that we only ever + * call {@link #setUpMap()} once when {@link #mMap} is not null. + *

+ * If it isn't installed {@link SupportMapFragment} (and + * {@link com.google.android.gms.maps.MapView MapView}) will show a prompt for the user to + * install/update the Google Play services APK on their device. + *

+ * A user can return to this FragmentActivity after following the prompt and correctly + * installing/updating/enabling the Google Play services. Since the FragmentActivity may not + * have been completely destroyed during this process (it is likely that it would only be + * stopped or paused), {@link #onCreate(Bundle)} may not be called again so we should call this + * method in {@link #onResume()} to guarantee that it will be called. + */ + private void setUpMapIfNeeded() { + // Do a null check to confirm that we have not already instantiated the map. + if (mMap == null) { + // Try to obtain the map from the SupportMapFragment. + mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)) + .getMap(); + // Check if we were successful in obtaining the map. + if (mMap != null) { + setUpMap(); + } + } + } + + /** + * This is where we can add markers or lines, add listeners or move the camera. In this case, we + * just add a marker near Africa. + *

+ * This should only be called once and when we are sure that {@link #mMap} is not null. + */ + private void setUpMap() { + mMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker")); + } +} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..c036319 --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,4 @@ + diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..cde69bc Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c133a0c Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..bfa42f0 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..324e72c Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..6b4abc1 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,4 @@ + + TraccarManager + Main + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..766ab99 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/app/src/release/res/values/google_maps_api.xml b/app/src/release/res/values/google_maps_api.xml new file mode 100644 index 0000000..66e392a --- /dev/null +++ b/app/src/release/res/values/google_maps_api.xml @@ -0,0 +1,18 @@ + + + + YOUR_KEY_HERE + + -- cgit v1.2.3