diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-09-02 16:17:14 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-09-02 16:17:14 +1200 |
commit | 49344e8b68c856b0edbd26407179088b7bfe7541 (patch) | |
tree | 2eaf84b1a0af07296fbee788f29fed4165ef1c18 /app | |
download | etbsa-traccar-manager-android-49344e8b68c856b0edbd26407179088b7bfe7541.tar.gz etbsa-traccar-manager-android-49344e8b68c856b0edbd26407179088b7bfe7541.tar.bz2 etbsa-traccar-manager-android-49344e8b68c856b0edbd26407179088b7bfe7541.zip |
Commit template Android project
Diffstat (limited to 'app')
-rw-r--r-- | app/.gitignore | 1 | ||||
-rw-r--r-- | app/build.gradle | 26 | ||||
-rw-r--r-- | app/src/androidTest/java/org/traccar/manager/ApplicationTest.java | 13 | ||||
-rw-r--r-- | app/src/debug/res/values/google_maps_api.xml | 5 | ||||
-rw-r--r-- | app/src/main/AndroidManifest.xml | 39 | ||||
-rw-r--r-- | app/src/main/java/org/traccar/manager/MainActivity.java | 65 | ||||
-rw-r--r-- | app/src/main/res/layout/activity_main.xml | 4 | ||||
-rw-r--r-- | app/src/main/res/mipmap-hdpi/ic_launcher.png | bin | 0 -> 3418 bytes | |||
-rw-r--r-- | app/src/main/res/mipmap-mdpi/ic_launcher.png | bin | 0 -> 2206 bytes | |||
-rw-r--r-- | app/src/main/res/mipmap-xhdpi/ic_launcher.png | bin | 0 -> 4842 bytes | |||
-rw-r--r-- | app/src/main/res/mipmap-xxhdpi/ic_launcher.png | bin | 0 -> 7718 bytes | |||
-rw-r--r-- | app/src/main/res/values/strings.xml | 4 | ||||
-rw-r--r-- | app/src/main/res/values/styles.xml | 8 | ||||
-rw-r--r-- | app/src/release/res/values/google_maps_api.xml | 18 |
14 files changed, 183 insertions, 0 deletions
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; + +/** + * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> + */ +public class ApplicationTest extends ApplicationTestCase<Application> { + 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 @@ +<resources> + + <string name="google_maps_key" translatable="false" templateMergeStrategy="preserve">AIzaSyB2sTYAPuWFpWHCP-cbGBYL2qJVmsMnfrQ</string> + +</resources> 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 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="org.traccar.manager" > + + <uses-permission android:name="android.permission.INTERNET" /> + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> + <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> + <!-- + The ACCESS_COARSE/FINE_LOCATION permissions are not required to use + Google Maps Android API v2, but are recommended. + --> + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> + + <application + android:allowBackup="true" + android:icon="@mipmap/ic_launcher" + android:label="@string/app_name" + android:theme="@style/AppTheme" > + <meta-data + android:name="com.google.android.gms.version" + android:value="@integer/google_play_services_version" /> + <meta-data + android:name="com.google.android.maps.v2.API_KEY" + android:value="@string/google_maps_key" /> + + <activity + android:name=".MainActivity" + android:label="@string/title_activity_main" > + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + + <category android:name="android.intent.category.LAUNCHER" /> + </intent-filter> + </activity> + </application> + +</manifest> 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. + * <p/> + * 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. + * <p/> + * 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. + * <p/> + * 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 @@ +<fragment xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" + android:layout_height="match_parent" android:id="@+id/map" tools:context=".MainActivity" + android:name="com.google.android.gms.maps.SupportMapFragment" /> diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..cde69bc --- /dev/null +++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..c133a0c --- /dev/null +++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..bfa42f0 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..324e72c --- /dev/null +++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png 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 @@ +<resources> + <string name="app_name">TraccarManager</string> + <string name="title_activity_main">Main</string> +</resources> 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 @@ +<resources> + + <!-- Base application theme. --> + <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> + <!-- Customize your theme here. --> + </style> + +</resources> 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 @@ +<resources> + <!-- + TODO: Before you run your application, you need a Google Maps API key. + + To get one, follow this link, follow the directions and press "Create" at the end: + +https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=CC:52:01:6E:7D:18:68:C6:89:42:DE:13:CB:F5:83:FC:C6:E3:81:64%3Borg.traccar.manager + + You can also add your credentials to an existing key, using this line: + CC:52:01:6E:7D:18:68:C6:89:42:DE:13:CB:F5:83:FC:C6:E3:81:64;org.traccar.manager + + Once you have your key (it starts with "AIza"), replace the "google_maps_key" + string in this file. + --> + <string name="google_maps_key" translatable="false" templateMergeStrategy="preserve"> + YOUR_KEY_HERE + </string> +</resources> |