DT @02.01.2016: ReportWF refactored und erweitert. Kategorien in strings.xml hinzugefügt. InAppBillingService hinzugefügt (muss jedoch noch implementiert werden)

This commit is contained in:
Dennis Thießen
2016-01-02 14:14:06 +01:00
parent ebfab3a534
commit 2f81bfa09d
26 changed files with 1106 additions and 499 deletions

View File

@@ -78,14 +78,14 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.1/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.1.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.beardedhen/androidbootstrap/2.0.1/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.beardedhen/androidbootstrap/2.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.facebook.android/facebook-android-sdk/4.8.1/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.facebook.android/facebook-android-sdk/4.8.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-ads/8.3.0/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-ads/8.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/8.3.0/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/8.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-basement/8.3.0/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-basement/8.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-gcm/8.3.0/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-gcm/8.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-location/8.3.0/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-location/8.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-maps/8.3.0/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-maps/8.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-measurement/8.3.0/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-measurement/8.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-plus/8.3.0/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-plus/8.4.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.maps.android/android-maps-utils/0.4/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.maps.android/android-maps-utils/0.4/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.mikepenz/google-material-typeface/2.1.0.1.original/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.mikepenz/google-material-typeface/2.1.0.1.original/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.mikepenz/iconics-core/2.5.1/jars" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.mikepenz/iconics-core/2.5.1/jars" />
@@ -105,32 +105,32 @@
</content> </content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" /> <orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="play-services-base-8.4.0" level="project" />
<orderEntry type="library" exported="" name="design-23.1.1" level="project" /> <orderEntry type="library" exported="" name="design-23.1.1" level="project" />
<orderEntry type="library" exported="" name="play-services-ads-8.3.0" level="project" />
<orderEntry type="library" exported="" name="materialize-0.5.1" level="project" /> <orderEntry type="library" exported="" name="materialize-0.5.1" level="project" />
<orderEntry type="library" exported="" name="facebook-android-sdk-4.8.1" level="project" /> <orderEntry type="library" exported="" name="facebook-android-sdk-4.8.1" level="project" />
<orderEntry type="library" exported="" name="multidex-1.0.1" level="project" /> <orderEntry type="library" exported="" name="multidex-1.0.1" level="project" />
<orderEntry type="library" exported="" name="play-services-measurement-8.3.0" level="project" />
<orderEntry type="library" exported="" name="retrofit-1.6.1" level="project" />
<orderEntry type="library" exported="" name="androidbootstrap-2.0.1" level="project" /> <orderEntry type="library" exported="" name="androidbootstrap-2.0.1" level="project" />
<orderEntry type="library" exported="" name="retrofit-1.6.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.1.1" level="project" /> <orderEntry type="library" exported="" name="appcompat-v7-23.1.1" level="project" />
<orderEntry type="library" exported="" name="materialdrawer-4.5.8" level="project" /> <orderEntry type="library" exported="" name="materialdrawer-4.5.8" level="project" />
<orderEntry type="library" exported="" name="library-1.0.19" level="project" /> <orderEntry type="library" exported="" name="library-1.0.19" level="project" />
<orderEntry type="library" exported="" name="play-services-base-8.3.0" level="project" /> <orderEntry type="library" exported="" name="play-services-location-8.4.0" level="project" />
<orderEntry type="library" exported="" name="fabric-1.3.4" level="project" /> <orderEntry type="library" exported="" name="fabric-1.3.4" level="project" />
<orderEntry type="library" exported="" name="android-maps-utils-0.4" level="project" /> <orderEntry type="library" exported="" name="android-maps-utils-0.4" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" /> <orderEntry type="library" exported="" name="support-annotations-23.1.1" level="project" />
<orderEntry type="library" exported="" name="play-services-location-8.3.0" level="project" />
<orderEntry type="library" exported="" name="twitter-core-1.4.1" level="project" /> <orderEntry type="library" exported="" name="twitter-core-1.4.1" level="project" />
<orderEntry type="library" exported="" name="play-services-plus-8.3.0" level="project" /> <orderEntry type="library" exported="" name="play-services-basement-8.4.0" level="project" />
<orderEntry type="library" exported="" name="bolts-android-1.2.1" level="project" /> <orderEntry type="library" exported="" name="bolts-android-1.2.1" level="project" />
<orderEntry type="library" exported="" name="play-services-maps-8.3.0" level="project" /> <orderEntry type="library" exported="" name="play-services-maps-8.4.0" level="project" />
<orderEntry type="library" exported="" name="google-material-typeface-2.1.0.1.original" level="project" /> <orderEntry type="library" exported="" name="google-material-typeface-2.1.0.1.original" level="project" />
<orderEntry type="library" exported="" name="play-services-ads-8.4.0" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.1.1" level="project" /> <orderEntry type="library" exported="" name="recyclerview-v7-23.1.1" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.1.1" level="project" /> <orderEntry type="library" exported="" name="support-v4-23.1.1" level="project" />
<orderEntry type="library" exported="" name="play-services-gcm-8.3.0" level="project" /> <orderEntry type="library" exported="" name="play-services-gcm-8.4.0" level="project" />
<orderEntry type="library" exported="" name="play-services-plus-8.4.0" level="project" />
<orderEntry type="library" exported="" name="iconics-core-2.5.1" level="project" /> <orderEntry type="library" exported="" name="iconics-core-2.5.1" level="project" />
<orderEntry type="library" exported="" name="gson-2.4" level="project" /> <orderEntry type="library" exported="" name="gson-2.4" level="project" />
<orderEntry type="library" exported="" name="play-services-basement-8.3.0" level="project" /> <orderEntry type="library" exported="" name="play-services-measurement-8.4.0" level="project" />
</component> </component>
</module> </module>

View File

@@ -40,13 +40,16 @@ dependencies {
compile('com.twitter.sdk.android:twitter-core:1.4.1@aar') { compile('com.twitter.sdk.android:twitter-core:1.4.1@aar') {
transitive = true; transitive = true;
} }
compile('com.mikepenz:materialdrawer:4.5.8@aar') {
transitive = true
}
compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.mikepenz:iconics-core:2.5.1@aar' compile 'com.mikepenz:iconics-core:2.5.1@aar'
compile 'com.mikepenz:google-material-typeface:2.1.0.1.original@aar' compile 'com.mikepenz:google-material-typeface:2.1.0.1.original@aar'
compile 'com.google.android.gms:play-services-gcm:8.3.0' compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-plus:8.3.0' compile 'com.google.android.gms:play-services-plus:8.4.0'
compile 'com.google.android.gms:play-services-location:8.3.0' compile 'com.google.android.gms:play-services-location:8.4.0'
compile 'com.google.android.gms:play-services-ads:8.3.0' compile 'com.google.android.gms:play-services-ads:8.4.0'
compile 'com.facebook.android:facebook-android-sdk:4.8.1' compile 'com.facebook.android:facebook-android-sdk:4.8.1'
compile 'com.beardedhen:androidbootstrap:2.0.1' compile 'com.beardedhen:androidbootstrap:2.0.1'
compile 'com.mcxiaoke.volley:library:1.0.19' compile 'com.mcxiaoke.volley:library:1.0.19'
@@ -54,7 +57,4 @@ dependencies {
compile 'com.google.code.gson:gson:2.4' compile 'com.google.code.gson:gson:2.4'
compile 'com.google.maps.android:android-maps-utils:0.4' compile 'com.google.maps.android:android-maps-utils:0.4'
compile 'com.android.support:support-v4:23.1.1' compile 'com.android.support:support-v4:23.1.1'
compile('com.mikepenz:materialdrawer:4.5.8@aar') {
transitive = true
}
} }

View File

@@ -0,0 +1,144 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.vending.billing;
import android.os.Bundle;
/**
* InAppBillingService is the service that provides in-app billing version 3 and beyond.
* This service provides the following features:
* 1. Provides a new API to get details of in-app items published for the app including
* price, type, title and description.
* 2. The purchase flow is synchronous and purchase information is available immediately
* after it completes.
* 3. Purchase information of in-app purchases is maintained within the Google Play system
* till the purchase is consumed.
* 4. An API to consume a purchase of an inapp item. All purchases of one-time
* in-app items are consumable and thereafter can be purchased again.
* 5. An API to get current purchases of the user immediately. This will not contain any
* consumed purchases.
*
* All calls will give a response code with the following possible values
* RESULT_OK = 0 - success
* RESULT_USER_CANCELED = 1 - user pressed back or canceled a dialog
* RESULT_BILLING_UNAVAILABLE = 3 - this billing API version is not supported for the type requested
* RESULT_ITEM_UNAVAILABLE = 4 - requested SKU is not available for purchase
* RESULT_DEVELOPER_ERROR = 5 - invalid arguments provided to the API
* RESULT_ERROR = 6 - Fatal error during the API action
* RESULT_ITEM_ALREADY_OWNED = 7 - Failure to purchase since item is already owned
* RESULT_ITEM_NOT_OWNED = 8 - Failure to consume since item is not owned
*/
interface IInAppBillingService {
/**
* Checks support for the requested billing API version, package and in-app type.
* Minimum API version supported by this interface is 3.
* @param apiVersion the billing version which the app is using
* @param packageName the package name of the calling app
* @param type type of the in-app item being purchased "inapp" for one-time purchases
* and "subs" for subscription.
* @return RESULT_OK(0) on success, corresponding result code on failures
*/
int isBillingSupported(int apiVersion, String packageName, String type);
/**
* Provides details of a list of SKUs
* Given a list of SKUs of a valid type in the skusBundle, this returns a bundle
* with a list JSON strings containing the productId, price, title and description.
* This API can be called with a maximum of 20 SKUs.
* @param apiVersion billing API version that the Third-party is using
* @param packageName the package name of the calling app
* @param skusBundle bundle containing a StringArrayList of SKUs with key "ITEM_ID_LIST"
* @return Bundle containing the following key-value pairs
* "RESPONSE_CODE" with int value, RESULT_OK(0) if success, other response codes on
* failure as listed above.
* "DETAILS_LIST" with a StringArrayList containing purchase information
* in JSON format similar to:
* '{ "productId" : "exampleSku", "type" : "inapp", "price" : "$5.00",
* "title : "Example Title", "description" : "This is an example description" }'
*/
Bundle getSkuDetails(int apiVersion, String packageName, String type, in Bundle skusBundle);
/**
* Returns a pending intent to launch the purchase flow for an in-app item by providing a SKU,
* the type, a unique purchase token and an optional developer payload.
* @param apiVersion billing API version that the app is using
* @param packageName package name of the calling app
* @param sku the SKU of the in-app item as published in the developer console
* @param type the type of the in-app item ("inapp" for one-time purchases
* and "subs" for subscription).
* @param developerPayload optional argument to be sent back with the purchase information
* @return Bundle containing the following key-value pairs
* "RESPONSE_CODE" with int value, RESULT_OK(0) if success, other response codes on
* failure as listed above.
* "BUY_INTENT" - PendingIntent to start the purchase flow
*
* The Pending intent should be launched with startIntentSenderForResult. When purchase flow
* has completed, the onActivityResult() will give a resultCode of OK or CANCELED.
* If the purchase is successful, the result data will contain the following key-value pairs
* "RESPONSE_CODE" with int value, RESULT_OK(0) if success, other response codes on
* failure as listed above.
* "INAPP_PURCHASE_DATA" - String in JSON format similar to
* '{"orderId":"12999763169054705758.1371079406387615",
* "packageName":"com.example.app",
* "productId":"exampleSku",
* "purchaseTime":1345678900000,
* "purchaseToken" : "122333444455555",
* "developerPayload":"example developer payload" }'
* "INAPP_DATA_SIGNATURE" - String containing the signature of the purchase data that
* was signed with the private key of the developer
* TODO: change this to app-specific keys.
*/
Bundle getBuyIntent(int apiVersion, String packageName, String sku, String type,
String developerPayload);
/**
* Returns the current SKUs owned by the user of the type and package name specified along with
* purchase information and a signature of the data to be validated.
* This will return all SKUs that have been purchased in V3 and managed items purchased using
* V1 and V2 that have not been consumed.
* @param apiVersion billing API version that the app is using
* @param packageName package name of the calling app
* @param type the type of the in-app items being requested
* ("inapp" for one-time purchases and "subs" for subscription).
* @param continuationToken to be set as null for the first call, if the number of owned
* skus are too many, a continuationToken is returned in the response bundle.
* This method can be called again with the continuation token to get the next set of
* owned skus.
* @return Bundle containing the following key-value pairs
* "RESPONSE_CODE" with int value, RESULT_OK(0) if success, other response codes on
* failure as listed above.
* "INAPP_PURCHASE_ITEM_LIST" - StringArrayList containing the list of SKUs
* "INAPP_PURCHASE_DATA_LIST" - StringArrayList containing the purchase information
* "INAPP_DATA_SIGNATURE_LIST"- StringArrayList containing the signatures
* of the purchase information
* "INAPP_CONTINUATION_TOKEN" - String containing a continuation token for the
* next set of in-app purchases. Only set if the
* user has more owned skus than the current list.
*/
Bundle getPurchases(int apiVersion, String packageName, String type, String continuationToken);
/**
* Consume the last purchase of the given SKU. This will result in this item being removed
* from all subsequent responses to getPurchases() and allow re-purchase of this item.
* @param apiVersion billing API version that the app is using
* @param packageName package name of the calling app
* @param purchaseToken token in the purchase information JSON that identifies the purchase
* to be consumed
* @return 0 if consumption succeeded. Appropriate error values for failures.
*/
int consumePurchase(int apiVersion, String packageName, String purchaseToken);
}

View File

@@ -75,6 +75,7 @@ public class MainActivity extends BaseActivity{
Drawable reportIcon = new IconicsDrawable(this) Drawable reportIcon = new IconicsDrawable(this)
.icon(GoogleMaterial.Icon.gmd_room) .icon(GoogleMaterial.Icon.gmd_room)
.color(getResources().getColor(R.color.white))
.sizeDp(24); .sizeDp(24);
report.setCompoundDrawables(reportIcon, null, null, null); report.setCompoundDrawables(reportIcon, null, null, null);
@@ -90,6 +91,7 @@ public class MainActivity extends BaseActivity{
Drawable mapIcon = new IconicsDrawable(this) Drawable mapIcon = new IconicsDrawable(this)
.icon(GoogleMaterial.Icon.gmd_map) .icon(GoogleMaterial.Icon.gmd_map)
.color(getResources().getColor(R.color.white))
.sizeDp(24); .sizeDp(24);
map.setCompoundDrawables(null,null, mapIcon, null); map.setCompoundDrawables(null,null, mapIcon, null);

View File

@@ -52,6 +52,7 @@ import org.json.JSONObject;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale;
import java.util.Map; import java.util.Map;
@@ -76,9 +77,9 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
private LatLng markedLocation; private LatLng markedLocation;
private static final int DEFAULT_ZOOM_LEVEL = 14; private static final int DEFAULT_ZOOM_LEVEL = 14;
private static final int THRESHOLD_ZOOM_LEVEL = 7; private static final int THRESHOLD_ZOOM_LEVEL = 10;
private static final int MIN_ZOOM_LEVEL = 5; private static final int MIN_ZOOM_LEVEL = 7;
private LatLng curNortheastBounds; private LatLng curNortheastBounds;
private LatLng curSouthwestBounds; private LatLng curSouthwestBounds;
@@ -94,6 +95,8 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
findViewById(R.id.btn_maps_confirm_position).setVisibility(View.GONE); findViewById(R.id.btn_maps_confirm_position).setVisibility(View.GONE);
navDrawer.setSelection(mapAvtivityID, false); navDrawer.setSelection(mapAvtivityID, false);
System.gc();
initMap(); initMap();
handleIntent(getIntent()); handleIntent(getIntent());
initClustering(); initClustering();
@@ -102,6 +105,12 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
} }
@Override
public void onLowMemory() {
super.onLowMemory();
System.gc();
}
private void initMap() { private void initMap() {
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.frag_maps_map)).getMap(); mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.frag_maps_map)).getMap();
mMap.getUiSettings().setZoomControlsEnabled(true); mMap.getUiSettings().setZoomControlsEnabled(true);
@@ -517,10 +526,23 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(point, DEFAULT_ZOOM_LEVEL)); mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(point, DEFAULT_ZOOM_LEVEL));
} else { } else {
myPosition = session.getLocation(); myPosition = session.getLocation();
if (myPosition != null) if ((myPosition != null) && (myPosition.latitude != 0.0) && (myPosition.longitude != 0.0))
{ {
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom( mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(myPosition.latitude, myPosition.longitude), DEFAULT_ZOOM_LEVEL)); new LatLng(myPosition.latitude, myPosition.longitude), DEFAULT_ZOOM_LEVEL));
}else{
String sDefSystemLanguage = Locale.getDefault().getLanguage();
if(sDefSystemLanguage.equals("en")){
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(52.603048, -2.298889), DEFAULT_ZOOM_LEVEL));
} else if (sDefSystemLanguage.equals("de")){
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(53.090725, 14.268494), DEFAULT_ZOOM_LEVEL));
} else {
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
new LatLng(19.432608, -99.133209), DEFAULT_ZOOM_LEVEL));
}
} }
} }

View File

@@ -1,8 +1,8 @@
package org.deke.risk.riskahead; package org.deke.risk.riskahead;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Fragment; import android.support.v4.app.Fragment;
import android.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@@ -26,6 +26,7 @@ import com.google.gson.Gson;
import org.deke.risk.riskahead.fragment.ReportWF_1_Fragment; import org.deke.risk.riskahead.fragment.ReportWF_1_Fragment;
import org.deke.risk.riskahead.fragment.ReportWF_2_Fragment; import org.deke.risk.riskahead.fragment.ReportWF_2_Fragment;
import org.deke.risk.riskahead.fragment.ReportWF_3_Fragment; import org.deke.risk.riskahead.fragment.ReportWF_3_Fragment;
import org.deke.risk.riskahead.fragment.ReportWF_4_Fragment;
import org.deke.risk.riskahead.helper.IncidentReport; import org.deke.risk.riskahead.helper.IncidentReport;
import org.deke.risk.riskahead.helper.AppConfig; import org.deke.risk.riskahead.helper.AppConfig;
import org.deke.risk.riskahead.helper.AppController; import org.deke.risk.riskahead.helper.AppController;
@@ -41,16 +42,17 @@ import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragment.OnInputFinishedListener, ReportWF_2_Fragment.OnInputFinishedListener, ReportWF_3_Fragment.OnInputFinishedListener { public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragment.OnInputFinishedListener, ReportWF_2_Fragment.OnInputFinishedListener, ReportWF_3_Fragment.OnInputFinishedListener, ReportWF_4_Fragment.OnInputFinishedListener {
private final static String mActivityTitle = "Report Incident"; private final static String mActivityTitle = "Report Incident";
private final static String TAG = ReportWFActivity.class.getSimpleName(); private final static String TAG = ReportWFActivity.class.getSimpleName();
private List<Fragment> fragList = new ArrayList<Fragment>(); private List<Fragment> fragList = new ArrayList<>();
private Fragment frag_report_1 = new ReportWF_1_Fragment(); private Fragment frag_report_1 = new ReportWF_1_Fragment();
private Fragment frag_report_2 = new ReportWF_2_Fragment(); private Fragment frag_report_2 = new ReportWF_2_Fragment();
private Fragment frag_report_3 = new ReportWF_3_Fragment(); private Fragment frag_report_3 = new ReportWF_3_Fragment();
private Fragment frag_report_4 = new ReportWF_4_Fragment();
private BootstrapButton btnContinue; private BootstrapButton btnContinue;
private BootstrapButton btnReportNow; private BootstrapButton btnReportNow;
@@ -62,8 +64,8 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
public boolean resetSignal = false; public boolean resetSignal = false;
SharedPreferences mPrefs; private SharedPreferences mPrefs;
SharedPreferences.Editor prefsEditor; private SharedPreferences.Editor prefsEditor;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@@ -72,6 +74,7 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
fragList.add(frag_report_1); fragList.add(frag_report_1);
fragList.add(frag_report_2); fragList.add(frag_report_2);
fragList.add(frag_report_3); fragList.add(frag_report_3);
fragList.add(frag_report_4);
initFragment(currentState); initFragment(currentState);
@@ -105,7 +108,6 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
} }
}); });
mPrefs = getPreferences(MODE_PRIVATE); mPrefs = getPreferences(MODE_PRIVATE);
prefsEditor = mPrefs.edit(); prefsEditor = mPrefs.edit();
} }
@@ -156,7 +158,7 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
} }
public void setIncident(IncidentReport newIncident){ public void setIncident(IncidentReport newIncident){
if(resetSignal == false){ if(!resetSignal){
incident = newIncident; incident = newIncident;
} }
} }
@@ -165,7 +167,7 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
findViewById(R.id.atvStatus).setVisibility(View.INVISIBLE); findViewById(R.id.atvStatus).setVisibility(View.INVISIBLE);
currentState = state; currentState = state;
FragmentTransaction transaction = getFragmentManager().beginTransaction(); FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.fragment_reportwf, fragList.get(state)); transaction.replace(R.id.fragment_reportwf, fragList.get(state));
transaction.addToBackStack(null); transaction.addToBackStack(null);
@@ -182,16 +184,6 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
return true; return true;
} }
@Override
protected int getLayoutResourceId() {
return R.layout.activity_report_wf;
}
@Override
protected String getActivityName() {
return mActivityTitle;
}
@Override @Override
public void onInputFinished(boolean finished) { public void onInputFinished(boolean finished) {
if(finished) { if(finished) {
@@ -215,7 +207,7 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
public void onStop(){ public void onStop(){
super.onStop(); super.onStop();
if(resetSignal == false){ if(!resetSignal){
Gson gson = new Gson(); Gson gson = new Gson();
prefsEditor.putString("incident", gson.toJson(incident)); prefsEditor.putString("incident", gson.toJson(incident));
prefsEditor.putInt("currentState", currentState); prefsEditor.putInt("currentState", currentState);
@@ -263,9 +255,6 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
}) })
.setIcon(android.R.drawable.ic_dialog_alert) .setIcon(android.R.drawable.ic_dialog_alert)
.show(); .show();
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
@@ -277,7 +266,14 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
}else{ }else{
btnMap.setVisibility(View.INVISIBLE); btnMap.setVisibility(View.INVISIBLE);
} }
}
public void onBackPressed(){
if(currentState > 0) {
initFragment(currentState - 1);
}else{
super.onBackPressed();
}
} }
private StringRequest getStringRequestAddIncidentWithPosition(final IncidentReport incident) { private StringRequest getStringRequestAddIncidentWithPosition(final IncidentReport incident) {
@@ -358,4 +354,13 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
}; };
} }
@Override
protected int getLayoutResourceId() {
return R.layout.activity_report_wf;
}
@Override
protected String getActivityName() {
return mActivityTitle;
}
} }

View File

@@ -1,27 +1,73 @@
package org.deke.risk.riskahead; package org.deke.risk.riskahead;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder;
import android.view.View;
import android.widget.Button;
import com.android.vending.billing.IInAppBillingService;
import org.deke.risk.riskahead.helper.BaseActivity; import org.deke.risk.riskahead.helper.BaseActivity;
public class SubscriptionsActivity extends BaseActivity { public class SubscriptionsActivity extends BaseActivity implements ServiceConnection{
private final static String mActivityTitle = "Subscriptions"; private final static String mActivityTitle = "Subscriptions";
private final static String TAG = StartActivity.class.getSimpleName(); private final static String TAG = StartActivity.class.getSimpleName();
private Button btnPurchaseNoAds;
private Button btnPurchaseExtraFunctions;
IInAppBillingService mService;
ServiceConnection mServiceConn;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
userHasToBeLoggedIn(); userHasToBeLoggedIn();
btnPurchaseNoAds = (Button) findViewById(R.id.btn_subscription_1);
btnPurchaseExtraFunctions = (Button) findViewById(R.id.btn_subscription_2);
Intent serviceIntent =
new Intent("com.android.vending.billing.InAppBillingService.BIND");
serviceIntent.setPackage("com.android.vending");
bindService(serviceIntent, mServiceConn, Context.BIND_AUTO_CREATE);
// Bundle activeSubs = mService.getPurchases(3, "org.deke.risk.riskahead", "subs", continueToken);
btnPurchaseNoAds.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
/*
Bundle bundle = mService.getBuyIntent(3, "org.deke.risk.riskahead",MY_SKU, "subs", developerPayload);
PendingIntent pendingIntent = bundle.getParcelable(RESPONSE_BUY_INTENT);
if (bundle.getInt(RESPONSE_CODE) == BILLING_RESPONSE_RESULT_OK) {
// Start purchase flow (this brings up the Google Play UI).
// Result will be delivered through onActivityResult().
startIntentSenderForResult(pendingIntent, RC_BUY, new Intent(),
Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
}
*/
}
});
} }
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
navDrawer.setSelection(subscriptionsAvtivityID,false); navDrawer.setSelection(subscriptionsAvtivityID, false);
} }
@Override @Override
protected int getLayoutResourceId() { protected int getLayoutResourceId() {
return R.layout.activity_subscriptions; return R.layout.activity_subscriptions;
@@ -29,4 +75,22 @@ public class SubscriptionsActivity extends BaseActivity {
@Override @Override
protected String getActivityName() { return mActivityTitle; } protected String getActivityName() { return mActivityTitle; }
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
mService = IInAppBillingService.Stub.asInterface(service);
}
@Override
public void onServiceDisconnected(ComponentName name) {
mService = null;
}
@Override
public void onDestroy() {
super.onDestroy();
if (mService != null) {
unbindService(mServiceConn);
}
}
} }

View File

@@ -41,33 +41,33 @@ public class ViewReportActivity extends BaseActivity {
private TextView txtPosition; private TextView txtPosition;
private BootstrapLabel scorelabel; private BootstrapLabel scorelabel;
private IncidentReport incident;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
userHasToBeLoggedIn(); userHasToBeLoggedIn();
Intent intent = getIntent();
final Integer uid = intent.getIntExtra(BaseActivity.EXTRA_MESSAGE, 0);
txtIncidentCategory = (EditText) findViewById(R.id.txt_viewreport_incidentcategory); txtIncidentCategory = (EditText) findViewById(R.id.txt_viewreport_incidentcategory);
txtIncidentSubCategory = (EditText) findViewById(R.id.txt_viewreport_incidentsubcategory); txtIncidentSubCategory = (EditText) findViewById(R.id.txt_viewreport_incidentsubcategory);
txtPosition = (TextView) findViewById(R.id.txt_viewreport_position); txtPosition = (TextView) findViewById(R.id.txt_viewreport_position);
scorelabel = (BootstrapLabel) findViewById(R.id.txt_viewreport_points); scorelabel = (BootstrapLabel) findViewById(R.id.txt_viewreport_points);
getIncident(uid); Intent intent = getIntent();
final Integer id = intent.getIntExtra(BaseActivity.EXTRA_MESSAGE, 0);
getIncident(id);
findViewById(R.id.btn_viewreport_upvote).setOnClickListener(new View.OnClickListener() { findViewById(R.id.btn_viewreport_upvote).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
makeUpvote(uid); makeUpvote(id);
} }
}); });
findViewById(R.id.btn_viewreport_downvote).setOnClickListener(new View.OnClickListener() { findViewById(R.id.btn_viewreport_downvote).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
makeDownvote(uid); makeDownvote(id);
} }
}); });
@@ -79,7 +79,7 @@ public class ViewReportActivity extends BaseActivity {
.setMessage("Do you really want to delete this incident?") .setMessage("Do you really want to delete this incident?")
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
deleteReport(uid); deleteReport(id);
} }
}) })
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
@@ -185,9 +185,7 @@ public class ViewReportActivity extends BaseActivity {
if (!error) { if (!error) {
JSONObject jIncident = jObj.getJSONObject("msg"); JSONObject jIncident = jObj.getJSONObject("msg");
IncidentReport incident = new IncidentReport(jIncident); initReport(new IncidentReport(jIncident));
initReport(incident);
} else { } else {
String errorMsg = jObj.getString("error_msg"); String errorMsg = jObj.getString("error_msg");
@@ -229,6 +227,8 @@ public class ViewReportActivity extends BaseActivity {
txtIncidentCategory.setText(incident.getIncidentCategoryName(getApplicationContext())); txtIncidentCategory.setText(incident.getIncidentCategoryName(getApplicationContext()));
txtIncidentSubCategory.setText(incident.getIncidentSubCategoryName(getApplicationContext())); txtIncidentSubCategory.setText(incident.getIncidentSubCategoryName(getApplicationContext()));
this.incident = incident;
Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault()); Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault());
try { try {
@@ -265,16 +265,24 @@ public class ViewReportActivity extends BaseActivity {
} }
} }
public void makeUpvote(Integer uid) { public void makeUpvote(Integer incidentid) {
String tag_string_req = "addvote"; if(user.get(SessionManager.KEY_UID).equals(Integer.toString(incident.getFidFromUser()))){
StringRequest strReq = getStringRequestAddVote(uid, "1"); showMessage("You can not vote your own incidents");
AppController.getInstance().addToRequestQueue(strReq, tag_string_req); }else {
String tag_string_req = "addvote";
StringRequest strReq = getStringRequestAddVote(incidentid, "1");
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
}
} }
public void makeDownvote(Integer uid) { public void makeDownvote(Integer incidentid) {
String tag_string_req = "addvote"; if(user.get(SessionManager.KEY_UID).equals(Integer.toString(incident.getFidFromUser()))){
StringRequest strReq = getStringRequestAddVote(uid, "2"); showMessage("You can not vote your own incidents");
AppController.getInstance().addToRequestQueue(strReq, tag_string_req); }else {
String tag_string_req = "addvote";
StringRequest strReq = getStringRequestAddVote(incidentid, "2");
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
}
} }
private StringRequest getStringRequestAddVote(final Integer incidentid, final String votetype) { private StringRequest getStringRequestAddVote(final Integer incidentid, final String votetype) {

View File

@@ -3,6 +3,7 @@ package org.deke.risk.riskahead.adapter;
import android.content.Context; import android.content.Context;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.os.Build;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@@ -67,7 +68,11 @@ public class ReportListAdapter extends BaseAdapter {
titleText.setTypeface(null, Typeface.BOLD); titleText.setTypeface(null, Typeface.BOLD);
ll.setBackgroundColor(item.getCategoryColor()); ll.setBackgroundColor(item.getCategoryColor());
iv.setBackground(parent.getContext().getDrawable(item.getIconDrawable())); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
iv.setBackground(parent.getContext().getDrawable(item.getIconDrawable()));
} else {
iv.setBackgroundDrawable(parent.getResources().getDrawable(item.getIconDrawable()));
}
return vi; return vi;
} }

View File

@@ -1,7 +1,7 @@
package org.deke.risk.riskahead.fragment; package org.deke.risk.riskahead.fragment;
import android.app.Activity; import android.support.v4.app.Fragment;
import android.app.Fragment; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@@ -13,15 +13,13 @@ import android.widget.RelativeLayout;
import android.widget.Spinner; import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import com.beardedhen.androidbootstrap.BootstrapButton;
import org.deke.risk.riskahead.R; import org.deke.risk.riskahead.R;
import org.deke.risk.riskahead.ReportWFActivity; import org.deke.risk.riskahead.ReportWFActivity;
import org.deke.risk.riskahead.helper.IncidentReport; import org.deke.risk.riskahead.helper.IncidentReport;
import org.deke.risk.riskahead.adapter.SpinnerHintAdapter; import org.deke.risk.riskahead.adapter.SpinnerHintAdapter;
/** /**
* Created by Dennis on 04.12.2015. * @author Dennis Thießen
*/ */
public class ReportWF_1_Fragment extends Fragment{ public class ReportWF_1_Fragment extends Fragment{
@@ -41,11 +39,9 @@ public class ReportWF_1_Fragment extends Fragment{
private RelativeLayout timeLayout; private RelativeLayout timeLayout;
private TextView txtPositionInformation; private TextView txtPositionInformation;
private boolean isMandatoryCategoryFilled; private IncidentReport incident;
IncidentReport incident; private OnInputFinishedListener mCallbackFinished;
OnInputFinishedListener mCallbackFinished;
public interface OnInputFinishedListener { public interface OnInputFinishedListener {
void onInputFinished(boolean finished); void onInputFinished(boolean finished);
@@ -60,93 +56,71 @@ public class ReportWF_1_Fragment extends Fragment{
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
viewFragment = inflater.inflate(R.layout.fragment_reportwf_1, container, false); viewFragment = inflater.inflate(R.layout.fragment_reportwf_1, container, false);
initSpinnerOneMain(); initInputElements();
initSpinnerOneSub(); setMainSpinnerValues(R.array.cat_situation_main);
initLayerPosition();
crimeSubOther = (EditText) viewFragment.findViewById(R.id.txt_reportwf_1_cat_etc);
crimeSubOther.setVisibility(View.INVISIBLE);
return viewFragment; return viewFragment;
} }
private void checkIfFinished(){ private void initInputElements() {
boolean isFinished = isMandatoryCategoryFilled && (incident != null) && (incident.getPosition() != null);
if(isMandatoryCategoryFilled){
viewFragment.findViewById(R.id.ll_pos).setVisibility(View.VISIBLE);
((ReportWFActivity)getActivity()).setMapButtonVisibility(true);
}
mCallbackFinished.onInputFinished(isFinished);
}
private void initSpinnerOneMain() {
crimeCategory = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_1_cat_main); crimeCategory = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_1_cat_main);
crimeSubCategory = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_1_cat_sub);
crimeSubOther = (EditText) viewFragment.findViewById(R.id.txt_reportwf_1_cat_etc);
timeLayout = (RelativeLayout) viewFragment.findViewById(R.id.ll_pos);
txtPositionInformation = (TextView) viewFragment.findViewById(R.id.lbl_reportwf_position_detail);
ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(getActivity(), crimeSubCategory.setVisibility(View.INVISIBLE);
R.array.cat_situation_main, android.R.layout.simple_spinner_dropdown_item); crimeSubOther.setVisibility(View.INVISIBLE);
adapter_main_1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); timeLayout.setVisibility(View.INVISIBLE);
crimeCategory.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, getActivity())); ((ReportWFActivity)getActivity()).setMapButtonVisibility(false);
crimeCategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { crimeCategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
int stringid = 0; int stringId;
switch (position) { switch (position) {
case 1: case 1:
stringid = R.array.cat_situation_sub_general; stringId = R.array.cat_situation_sub_general;
break; break;
case 2: case 2:
stringid = R.array.cat_situation_sub_verbal; stringId = R.array.cat_situation_sub_verbal;
break; break;
case 3: case 3:
stringid = R.array.cat_situation_sub_force; stringId = R.array.cat_situation_sub_force;
break; break;
case 4: case 4:
stringid = R.array.cat_situation_sub_force_serious; stringId = R.array.cat_situation_sub_force_serious;
break; break;
case 5: case 5:
stringid = R.array.cat_situation_sub_nature; stringId = R.array.cat_situation_sub_nature;
break; break;
case 6: case 6:
stringid = R.array.cat_situation_sub_infrastructure; stringId = R.array.cat_situation_sub_infrastructure;
break; break;
default: default:
stringid = R.array.cat_situation_sub_general; stringId = R.array.cat_situation_sub_general;
break; break;
} }
Spinner spinner_sub_1 = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_1_cat_sub); if (((SpinnerHintAdapter) parent.getAdapter()).isInInitialState()) {
ArrayAdapter<CharSequence> adapter_sub_1 = ArrayAdapter.createFromResource(viewFragment.getContext(), crimeSubCategory.setVisibility(View.INVISIBLE);
stringid, android.R.layout.simple_spinner_dropdown_item);
adapter_sub_1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner_sub_1.setAdapter(new SpinnerHintAdapter(adapter_sub_1, R.layout.contact_spinner_row_nothing_selected, getActivity()));
if (((SpinnerHintAdapter) crimeCategory.getAdapter()).isInInitialState()) {
spinner_sub_1.setVisibility(View.INVISIBLE);
} else { } else {
spinner_sub_1.setVisibility(View.VISIBLE); crimeSubCategory.setVisibility(View.VISIBLE);
incident.setFidIncidentCategory(position);
setSubSpinnerValues(stringId);
} }
incident.setFidIncidentCategory(position);
isMandatoryCategoryFilled = false;
checkIfFinished(); checkIfFinished();
} }
@Override @Override
public void onNothingSelected(AdapterView<?> parentView) { public void onNothingSelected(AdapterView<?> parentView) {
// your code here // do nothing
} }
}); });
}
private void initSpinnerOneSub() {
crimeSubCategory = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_1_cat_sub);
crimeSubCategory.setVisibility(View.INVISIBLE);
crimeSubCategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { crimeSubCategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
int i = 99; int i = 99;
@@ -172,38 +146,60 @@ public class ReportWF_1_Fragment extends Fragment{
break; break;
} }
if (position == i) { if (((SpinnerHintAdapter) parent.getAdapter()).isInInitialState()) {
viewFragment.findViewById(R.id.txt_reportwf_1_cat_etc).setVisibility(View.VISIBLE); crimeSubOther.setVisibility(View.INVISIBLE);
} else { } else {
viewFragment.findViewById(R.id.txt_reportwf_1_cat_etc).setVisibility(View.INVISIBLE); timeLayout.setVisibility(View.VISIBLE);
if (position == i){
crimeSubOther.setVisibility(View.VISIBLE);
}else{
crimeSubOther.setVisibility(View.INVISIBLE);
crimeSubOther.setText("");
}
((ReportWFActivity)getActivity()).setMapButtonVisibility(true);
incident.setFidIncidentSubCategory(position);
} }
if (((SpinnerHintAdapter) crimeSubCategory.getAdapter()).isInInitialState()) { checkIfFinished();
isMandatoryCategoryFilled = false;
checkIfFinished();
} else {
isMandatoryCategoryFilled = true;
checkIfFinished();
}
if ((position == 0) && (incident.getFidIncidentSubCategory() != 0))
crimeSubCategory.setSelection(incident.getFidIncidentSubCategory());
incident.setFidIncidentSubCategory(position);
} }
@Override @Override
public void onNothingSelected(AdapterView<?> parent) { public void onNothingSelected(AdapterView<?> parent) {
// do nothing
} }
}); });
} }
private void initLayerPosition(){ private void setMainSpinnerValues(int stringId) {
timeLayout = (RelativeLayout) viewFragment.findViewById(R.id.ll_pos); ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(getActivity(),stringId, android.R.layout.simple_spinner_dropdown_item);
timeLayout.setVisibility(View.INVISIBLE); crimeCategory.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, getActivity()));
((ReportWFActivity)getActivity()).setMapButtonVisibility(false); }
txtPositionInformation = (TextView) viewFragment.findViewById(R.id.lbl_reportwf_position_detail); private void setSubSpinnerValues(int stringId) {
ArrayAdapter<CharSequence> adapter_sub_1 = ArrayAdapter.createFromResource(viewFragment.getContext(),stringId, android.R.layout.simple_spinner_dropdown_item);
crimeSubCategory.setAdapter(new SpinnerHintAdapter(adapter_sub_1, R.layout.contact_spinner_row_nothing_selected, getActivity()));
if(incident.getFidIncidentSubCategory() > 0) crimeSubCategory.setSelection(incident.getFidIncidentSubCategory());
}
private void checkIfFinished(){
boolean mainCategoryIsFilled = false;
boolean subCategoryIsFilled = false;
boolean positionIsFilled = false;
if(incident != null){
mainCategoryIsFilled = (crimeCategory.getSelectedItemPosition() > 0) && (incident.getFidIncidentCategory() > 0);
subCategoryIsFilled = (crimeSubCategory.isShown()) && (crimeSubCategory.getSelectedItemPosition() > 0) && (incident.getFidIncidentSubCategory() > 0);
positionIsFilled = (timeLayout.isShown()) && (incident.getPosition() != null);
}
boolean isFinished = mainCategoryIsFilled && subCategoryIsFilled && positionIsFilled;
mCallbackFinished.onInputFinished(isFinished);
} }
@Override @Override
@@ -213,23 +209,20 @@ public class ReportWF_1_Fragment extends Fragment{
incident = ((ReportWFActivity)getActivity()).getIncident(); incident = ((ReportWFActivity)getActivity()).getIncident();
if(incident != null){ if(incident != null){
if(incident.getFidIncidentCategory() > 0){
crimeCategory.setSelection(incident.getFidIncidentCategory());
// The IncidentSubCategory gets automatically initialized
}
if (!incident.getEtcIncidentCategory().equals("")){
crimeSubOther.setText(incident.getEtcIncidentCategory());
}
if(incident.getPosition() != null){ if(incident.getPosition() != null){
timeLayout.setVisibility(View.VISIBLE); timeLayout.setVisibility(View.VISIBLE);
txtPositionInformation.setText(incident.getIncidentPositionDescription()); txtPositionInformation.setText(incident.getIncidentPositionDescription());
((ReportWFActivity)getActivity()).setMapButtonVisibility(true); ((ReportWFActivity)getActivity()).setMapButtonVisibility(true);
} }
if(incident.getFidIncidentCategory() != 0){
crimeCategory.setSelection(incident.getFidIncidentCategory());
}
if(incident.getFidIncidentSubCategory() != 0){
crimeSubCategory.setSelection(incident.getFidIncidentSubCategory());
}
if(!incident.getEtcIncidentCategory().toString().equals("")){
crimeSubOther.setText(incident.getEtcIncidentCategory());
}
} }
checkIfFinished(); checkIfFinished();
@@ -246,15 +239,14 @@ public class ReportWF_1_Fragment extends Fragment{
((ReportWFActivity)getActivity()).setIncident(incident); ((ReportWFActivity)getActivity()).setIncident(incident);
} }
@Override @Override
public void onAttach(Activity activity) { public void onAttach(Context context) {
super.onAttach(activity); super.onAttach(context);
try { try {
mCallbackFinished = (OnInputFinishedListener) activity; mCallbackFinished = (OnInputFinishedListener) context;
} catch (ClassCastException e) { } catch (ClassCastException e) {
throw new ClassCastException(activity.toString() throw new ClassCastException(context.toString()
+ " must implement all Listeners"); + " must implement all Listeners");
} }
} }

View File

@@ -1,11 +1,11 @@
package org.deke.risk.riskahead.fragment; package org.deke.risk.riskahead.fragment;
import android.app.Activity;
import android.app.DatePickerDialog; import android.app.DatePickerDialog;
import android.app.Dialog; import android.app.Dialog;
import android.app.DialogFragment; import android.support.v4.app.DialogFragment;
import android.app.Fragment; import android.support.v4.app.Fragment;
import android.app.TimePickerDialog; import android.app.TimePickerDialog;
import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.text.format.DateFormat; import android.text.format.DateFormat;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@@ -28,7 +28,7 @@ import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
/** /**
* Created by Dennis on 08.12.2015. * @author Dennis Thießen
*/ */
public class ReportWF_2_Fragment extends Fragment { public class ReportWF_2_Fragment extends Fragment {
@@ -51,93 +51,42 @@ public class ReportWF_2_Fragment extends Fragment {
private EditText tmpInput; private EditText tmpInput;
private IncidentReport incident; private IncidentReport incident;
private boolean isMandatoryCategoryFilled;
OnInputFinishedListener mCallback; private OnInputFinishedListener mCallback;
public interface OnInputFinishedListener { public interface OnInputFinishedListener {
void onInputFinished(boolean finished); void onInputFinished(boolean finished);
} }
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
} }
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
viewFragment = inflater.inflate(R.layout.fragment_reportwf_2, container, false); viewFragment = inflater.inflate(R.layout.fragment_reportwf_2, container, false);
initSpinnerOneMain(); initInputElements();
initSpinnerOneSub(); setMainSpinnerValues(R.array.cat_time_main);
initLayoutFromTime();
initLayoutToTime();
inputTimeFrom = ((EditText) viewFragment.findViewById(R.id.input_report_from_time));
inputTimeTo = ((EditText) viewFragment.findViewById(R.id.input_report_to_time));
inputDateFrom = ((EditText) viewFragment.findViewById(R.id.input_report_from_date));
inputDateTo = ((EditText) viewFragment.findViewById(R.id.input_report_to_date));
inputTimeFrom.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tmpInput = inputTimeFrom;
showTimePickerDialog(v);
}
});
inputTimeTo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tmpInput = inputTimeTo;
showTimePickerDialog(v);
}
});
inputDateTo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tmpInput = inputDateTo;
showDatePickerDialog(v);
}
});
inputDateFrom.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tmpInput = inputDateFrom;
showDatePickerDialog(v);
}
});
return viewFragment; return viewFragment;
} }
private void initLayoutToTime() { private void initInputElements() {
RelativeLayout rlFromTime = (RelativeLayout) viewFragment.findViewById(R.id.ll_report_to_time); initLayoutFromDateTime();
rlFromTime.setVisibility(View.INVISIBLE); initLayoutToDateTime();
}
private void initLayoutFromTime() {
RelativeLayout rlFromTime = (RelativeLayout) viewFragment.findViewById(R.id.ll_report_from_time);
rlFromTime.setVisibility(View.INVISIBLE);
}
private void initSpinnerOneMain() {
timeCategory = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_2_time_main); timeCategory = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_2_time_main);
timeSubCategory = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_2_time_sub);
ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(getActivity(), timeSubCategory.setVisibility(View.INVISIBLE);
R.array.cat_time_main, android.R.layout.simple_spinner_dropdown_item);
adapter_main_1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
timeCategory.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, getActivity()));
timeCategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { timeCategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
int stringid = 0; int stringId = 0;
resetDates();
switch (position) { switch (position) {
case NOW: case NOW:
@@ -147,77 +96,58 @@ public class ReportWF_2_Fragment extends Fragment {
inputDateFrom.setText(new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime())); inputDateFrom.setText(new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime()));
inputTimeFrom.setText(new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime())); inputTimeFrom.setText(new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()));
isMandatoryCategoryFilled = true;
break; break;
case PERIODIC: case PERIODIC:
viewFragment.findViewById(R.id.ll_report_from_time).setVisibility(View.INVISIBLE); viewFragment.findViewById(R.id.ll_report_from_time).setVisibility(View.INVISIBLE);
viewFragment.findViewById(R.id.ll_report_to_time).setVisibility(View.INVISIBLE); viewFragment.findViewById(R.id.ll_report_to_time).setVisibility(View.INVISIBLE);
incident.resetDatetime(); stringId = R.array.cat_time_sub_periodical;
stringid = R.array.cat_time_sub_periodical;
isMandatoryCategoryFilled = false;
break; break;
case DATETIME: case DATETIME:
viewFragment.findViewById(R.id.ll_report_from_time).setVisibility(View.VISIBLE); viewFragment.findViewById(R.id.ll_report_from_time).setVisibility(View.VISIBLE);
viewFragment.findViewById(R.id.ll_report_to_time).setVisibility(View.INVISIBLE); viewFragment.findViewById(R.id.ll_report_to_time).setVisibility(View.INVISIBLE);
viewFragment.findViewById(R.id.dd_reportwf_2_time_sub).setVisibility(View.INVISIBLE); viewFragment.findViewById(R.id.dd_reportwf_2_time_sub).setVisibility(View.INVISIBLE);
isMandatoryCategoryFilled = false;
break; break;
case DATETIMEAREA: case DATETIMEAREA:
viewFragment.findViewById(R.id.ll_report_from_time).setVisibility(View.VISIBLE); viewFragment.findViewById(R.id.ll_report_from_time).setVisibility(View.VISIBLE);
viewFragment.findViewById(R.id.ll_report_to_time).setVisibility(View.VISIBLE); viewFragment.findViewById(R.id.ll_report_to_time).setVisibility(View.VISIBLE);
viewFragment.findViewById(R.id.dd_reportwf_2_time_sub).setVisibility(View.INVISIBLE); viewFragment.findViewById(R.id.dd_reportwf_2_time_sub).setVisibility(View.INVISIBLE);
isMandatoryCategoryFilled = false;
break; break;
case DONTKNOW: case DONTKNOW:
viewFragment.findViewById(R.id.ll_report_from_time).setVisibility(View.INVISIBLE); viewFragment.findViewById(R.id.ll_report_from_time).setVisibility(View.INVISIBLE);
viewFragment.findViewById(R.id.ll_report_to_time).setVisibility(View.INVISIBLE); viewFragment.findViewById(R.id.ll_report_to_time).setVisibility(View.INVISIBLE);
viewFragment.findViewById(R.id.dd_reportwf_2_time_sub).setVisibility(View.INVISIBLE); viewFragment.findViewById(R.id.dd_reportwf_2_time_sub).setVisibility(View.INVISIBLE);
isMandatoryCategoryFilled = true;
break; break;
} }
checkIfFinished();
if (!((SpinnerHintAdapter) timeCategory.getAdapter()).isInInitialState() && stringid != 0) {
ArrayAdapter<CharSequence> adapter_sub_1 = ArrayAdapter.createFromResource(viewFragment.getContext(),stringid, android.R.layout.simple_spinner_dropdown_item);
adapter_sub_1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
timeSubCategory.setAdapter(new SpinnerHintAdapter(adapter_sub_1, R.layout.contact_spinner_row_nothing_selected, getActivity()));
timeSubCategory.setVisibility(View.VISIBLE);
} else if (stringid == 0) {
timeSubCategory.setVisibility(View.INVISIBLE);
}
if (((SpinnerHintAdapter) timeCategory.getAdapter()).isInInitialState()) { if (((SpinnerHintAdapter) timeCategory.getAdapter()).isInInitialState()) {
isMandatoryCategoryFilled = false; timeSubCategory.setVisibility(View.INVISIBLE);
checkIfFinished(); } else {
incident.setFidTimeCategory(position);
if (stringId != 0) {
timeSubCategory.setVisibility(View.VISIBLE);
setSubSpinnerValues(stringId);
}
} }
incident.setFidTimeCategory(position); checkIfFinished();
} }
@Override @Override
public void onNothingSelected(AdapterView<?> parentView) { public void onNothingSelected(AdapterView<?> parentView) {
// your code here // do nothing
} }
}); });
}
private void initSpinnerOneSub() {
timeSubCategory = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_2_time_sub);
timeSubCategory.setVisibility(View.INVISIBLE);
timeSubCategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { timeSubCategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
isMandatoryCategoryFilled = !((SpinnerHintAdapter) timeSubCategory.getAdapter()).isInInitialState(); if ((position < 1) && (incident.getFidTimeSubCategory() != 0))
if ((position == 0) && (incident.getFidTimeSubCategory() != 0))
timeSubCategory.setSelection(incident.getFidTimeSubCategory()); timeSubCategory.setSelection(incident.getFidTimeSubCategory());
checkIfFinished();
incident.setFidTimeSubCategory(position); incident.setFidTimeSubCategory(position);
checkIfFinished();
} }
@Override @Override
@@ -227,16 +157,157 @@ public class ReportWF_2_Fragment extends Fragment {
}); });
} }
@Override private void setMainSpinnerValues(int stringId) {
public void onAttach(Activity activity) { ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(getActivity(), stringId , android.R.layout.simple_spinner_dropdown_item);
super.onAttach(activity); timeCategory.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, getActivity()));
}
try { private void setSubSpinnerValues(int stringId) {
mCallback = (OnInputFinishedListener) activity; ArrayAdapter<CharSequence> adapter_sub_1 = ArrayAdapter.createFromResource(viewFragment.getContext(), stringId, android.R.layout.simple_spinner_dropdown_item);
} catch (ClassCastException e) { timeSubCategory.setAdapter(new SpinnerHintAdapter(adapter_sub_1, R.layout.contact_spinner_row_nothing_selected, getActivity()));
throw new ClassCastException(activity.toString()
+ " must implement OnInputFinishedListener"); if(incident.getFidTimeSubCategory() > 0) timeSubCategory.setSelection(incident.getFidTimeSubCategory());
}
private void initLayoutFromDateTime() {
RelativeLayout rlFromTime = (RelativeLayout) viewFragment.findViewById(R.id.ll_report_from_time);
rlFromTime.setVisibility(View.INVISIBLE);
inputDateFrom = ((EditText) viewFragment.findViewById(R.id.input_report_from_date));
inputTimeFrom = ((EditText) viewFragment.findViewById(R.id.input_report_from_time));
inputDateFrom.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tmpInput = inputDateFrom;
showDatePickerDialog();
}
});
inputTimeFrom.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tmpInput = inputTimeFrom;
showTimePickerDialog();
}
});
}
private void initLayoutToDateTime() {
RelativeLayout rlFromTime = (RelativeLayout) viewFragment.findViewById(R.id.ll_report_to_time);
rlFromTime.setVisibility(View.INVISIBLE);
inputDateTo = ((EditText) viewFragment.findViewById(R.id.input_report_to_date));
inputTimeTo = ((EditText) viewFragment.findViewById(R.id.input_report_to_time));
inputDateTo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tmpInput = inputDateTo;
showDatePickerDialog();
}
});
inputTimeTo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tmpInput = inputTimeTo;
showTimePickerDialog();
}
});
}
public class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Calendar c = Calendar.getInstance();
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
return new TimePickerDialog(getActivity(), this, hour, minute,DateFormat.is24HourFormat(getActivity()));
} }
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
tmpInput.setText(new StringBuilder().append(hourOfDay)
.append(":").append(minute).append(" "));
checkIfFinished();
}
}
public void showTimePickerDialog() {
DialogFragment newFragment = new TimePickerFragment();
newFragment.show(getActivity().getSupportFragmentManager(), "Pick Time");
}
public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
return new DatePickerDialog(getActivity(), this, year, month, day);
}
public void onDateSet(DatePicker view, int year, int month, int day) {
tmpInput.setText(new StringBuilder()
.append(year).append("-").append(month + 1).append("-")
.append(day).append(" "));
checkIfFinished();
}
}
public void showDatePickerDialog() {
DialogFragment newFragment = new DatePickerFragment();
newFragment.show(getActivity().getSupportFragmentManager(), "Pick Date");
}
private void checkIfFinished(){
boolean isTimeCategoryFilled = false;
boolean isSubCategoryFilled = false;
boolean isFromDateFilled = false;
boolean isToDateFilled = false;
if(incident != null){
if((timeCategory.getSelectedItemPosition() > 0) && timeCategory.getVisibility() == View.VISIBLE){
isTimeCategoryFilled = true;
}
if(timeSubCategory.isShown()){
isSubCategoryFilled = (timeSubCategory.getSelectedItemPosition() > 0) && (incident.getFidTimeSubCategory() > 0);
}else{
isSubCategoryFilled = true;
}
if(inputDateFrom.isShown()){
isFromDateFilled = inputDateFrom.getText().toString().trim().length() > 0;
}else{
isFromDateFilled = true;
}
if(inputDateTo.isShown()){
isToDateFilled = inputDateTo.getText().toString().trim().length() > 0;
}else{
isToDateFilled = true;
}
}
mCallback.onInputFinished(isTimeCategoryFilled && isSubCategoryFilled && isFromDateFilled && isToDateFilled);
}
private void resetDates() {
incident.resetDatetime();
inputDateFrom.setText("");
inputTimeFrom.setText("");
inputDateTo.setText("");
inputDateFrom.setText("");
} }
@Override @Override
@@ -248,10 +319,7 @@ public class ReportWF_2_Fragment extends Fragment {
if(incident != null){ if(incident != null){
if(incident.getFidTimeCategory() != 0){ if(incident.getFidTimeCategory() != 0){
timeCategory.setSelection(incident.getFidTimeCategory()); timeCategory.setSelection(incident.getFidTimeCategory());
} //SubCategory is automatically initialized
if(incident.getFidTimeSubCategory() != 0){
timeSubCategory.setSelection(incident.getFidTimeSubCategory());
} }
if(incident.getFromDate() != null && !incident.getFromDate().equals("")){ if(incident.getFromDate() != null && !incident.getFromDate().equals("")){
@@ -288,69 +356,18 @@ public class ReportWF_2_Fragment extends Fragment {
((ReportWFActivity)getActivity()).setIncident(incident); ((ReportWFActivity)getActivity()).setIncident(incident);
} }
public class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener { @Override
public void onAttach(Context context) {
super.onAttach(context);
@Override try {
public Dialog onCreateDialog(Bundle savedInstanceState) { mCallback = (OnInputFinishedListener) context;
final Calendar c = Calendar.getInstance(); } catch (ClassCastException e) {
int hour = c.get(Calendar.HOUR_OF_DAY); throw new ClassCastException(context.toString()
int minute = c.get(Calendar.MINUTE); + " must implement OnInputFinishedListener");
return new TimePickerDialog(getActivity(), this, hour, minute,DateFormat.is24HourFormat(getActivity()));
}
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
tmpInput.setText(new StringBuilder().append(hourOfDay)
.append(":").append(minute).append(" "));
checkIfFinished();
} }
} }
public void showTimePickerDialog(View v) {
DialogFragment newFragment = new TimePickerFragment();
newFragment.show(getFragmentManager(),"Pick Time");
}
public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
return new DatePickerDialog(getActivity(), this, year, month, day);
}
public void onDateSet(DatePicker view, int year, int month, int day) {
tmpInput.setText(new StringBuilder()
.append(year).append("-").append(month + 1).append("-")
.append(day).append(" "));
checkIfFinished();
}
}
public void showDatePickerDialog(View v) {
DialogFragment newFragment = new DatePickerFragment();
newFragment.show(getFragmentManager(), "Pick Date");
}
private void checkIfFinished(){
if( viewFragment.findViewById(R.id.ll_report_from_time).getVisibility() == View.VISIBLE) {
isMandatoryCategoryFilled = !inputDateFrom.getText().toString().matches("");
}
if (isMandatoryCategoryFilled && viewFragment.findViewById(R.id.ll_report_to_time).getVisibility() == View.VISIBLE){
isMandatoryCategoryFilled = !inputDateTo.getText().toString().matches("");
}
mCallback.onInputFinished(isMandatoryCategoryFilled);
}
@Override @Override
public void onDetach() { public void onDetach() {
super.onDetach(); super.onDetach();

View File

@@ -1,7 +1,7 @@
package org.deke.risk.riskahead.fragment; package org.deke.risk.riskahead.fragment;
import android.app.Activity; import android.support.v4.app.Fragment;
import android.app.Fragment; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@@ -17,7 +17,7 @@ import org.deke.risk.riskahead.helper.IncidentReport;
import org.deke.risk.riskahead.adapter.SpinnerHintAdapter; import org.deke.risk.riskahead.adapter.SpinnerHintAdapter;
/** /**
* Created by Dennis on 08.12.2015. * @author Dennis Thießen
*/ */
public class ReportWF_3_Fragment extends Fragment { public class ReportWF_3_Fragment extends Fragment {
@@ -33,144 +33,133 @@ public class ReportWF_3_Fragment extends Fragment {
private View viewFragment; private View viewFragment;
private Spinner suspectCategory; private Spinner suspectCategory;
private Spinner suspectOriginCategory; private Spinner suspectSubCategory;
private EditText suspectEtcInput; private EditText suspectEtcInput;
private IncidentReport incident; private IncidentReport incident;
private boolean isMandatoryCategoryFilled;
OnInputFinishedListener mCallback; private OnInputFinishedListener mCallback;
public interface OnInputFinishedListener { public interface OnInputFinishedListener {
void onInputFinished(boolean finished); void onInputFinished(boolean finished);
} }
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
} }
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
viewFragment = inflater.inflate(R.layout.fragment_reportwf_3, container, false); viewFragment = inflater.inflate(R.layout.fragment_reportwf_3, container, false);
initSpinnerOneMain(); initInputElements();
initSpinnerOneSub(); setMainSpinnerValues(R.array.cat_suspect_main);
suspectEtcInput = (EditText) viewFragment.findViewById(R.id.txt_reportwf_3_suspect_etc);
return viewFragment; return viewFragment;
} }
private void initInputElements() {
private void initSpinnerOneMain() {
suspectCategory = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_3_suspect); suspectCategory = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_3_suspect);
suspectSubCategory = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_3_suspect_sub);
suspectEtcInput = (EditText) viewFragment.findViewById(R.id.txt_reportwf_3_suspect_etc);
ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(getActivity(), suspectSubCategory.setVisibility(View.INVISIBLE);
R.array.cat_suspect_main, android.R.layout.simple_spinner_dropdown_item); suspectEtcInput.setVisibility(View.INVISIBLE);
adapter_main_1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
suspectCategory.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, getActivity()));
suspectCategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { suspectCategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
int stringid = 0; int stringId = 0;
switch (position) { switch (position) {
case GANGS: case GANGS:
isMandatoryCategoryFilled = true;
break; break;
case POLICE: case POLICE:
isMandatoryCategoryFilled = true;
break; break;
case MOB: case MOB:
isMandatoryCategoryFilled = true;
break; break;
case PARAMILITARY: case PARAMILITARY:
stringid = R.array.cat_suspect_sub_location; stringId = R.array.cat_suspect_sub_location;
isMandatoryCategoryFilled = false;
break; break;
case MILITARY: case MILITARY:
stringid = R.array.cat_suspect_sub_location; stringId = R.array.cat_suspect_sub_location;
isMandatoryCategoryFilled = false;
break; break;
case TERRORIST: case TERRORIST:
stringid = R.array.cat_suspect_sub_location; stringId = R.array.cat_suspect_sub_location;
isMandatoryCategoryFilled = false;
break; break;
case ETC: case ETC:
suspectEtcInput.setVisibility(View.VISIBLE); suspectEtcInput.setVisibility(View.VISIBLE);
isMandatoryCategoryFilled = false;
break; break;
case DONTKNOW: case DONTKNOW:
isMandatoryCategoryFilled = true;
break; break;
} }
if (position != ETC) {
suspectEtcInput.setVisibility(View.INVISIBLE);
}
if (!((SpinnerHintAdapter) suspectCategory.getAdapter()).isInInitialState() && stringid != 0) {
ArrayAdapter<CharSequence> adapter_sub_1 = ArrayAdapter.createFromResource(viewFragment.getContext(), stringid, android.R.layout.simple_spinner_dropdown_item);
adapter_sub_1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
suspectOriginCategory.setAdapter(new SpinnerHintAdapter(adapter_sub_1, R.layout.contact_spinner_row_nothing_selected, getActivity()));
suspectOriginCategory.setVisibility(View.VISIBLE);
} else if (stringid == 0) {
suspectOriginCategory.setVisibility(View.INVISIBLE);
}
if (((SpinnerHintAdapter) suspectCategory.getAdapter()).isInInitialState()) { if (((SpinnerHintAdapter) suspectCategory.getAdapter()).isInInitialState()) {
isMandatoryCategoryFilled = false; suspectSubCategory.setVisibility(View.INVISIBLE);
} else {
incident.setFidSuspectCategory(position);
if (stringId != 0) {
suspectSubCategory.setVisibility(View.VISIBLE);
setSubSpinnerValues(stringId);
}
if (position != ETC){
suspectEtcInput.setVisibility(View.INVISIBLE);
}
} }
checkIfFinished(); checkIfFinished();
incident.setFidSuspectCategory(position);
} }
@Override @Override
public void onNothingSelected(AdapterView<?> parentView) { public void onNothingSelected(AdapterView<?> parentView) {
// your code here // do nothing
} }
}); });
}
private void initSpinnerOneSub() { suspectSubCategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
suspectOriginCategory = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_3_suspect_sub);
suspectOriginCategory.setVisibility(View.INVISIBLE);
suspectOriginCategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override @Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
if ((position < 1) && (incident.getFidSuspectSubCategory() != 0))
suspectSubCategory.setSelection(incident.getFidTimeSubCategory());
isMandatoryCategoryFilled = !((SpinnerHintAdapter) suspectOriginCategory.getAdapter()).isInInitialState();
if ((position == 0) && (incident.getFidSuspectSubCategory() != 0))
suspectOriginCategory.setSelection(incident.getFidSuspectSubCategory());
checkIfFinished();
incident.setFidSuspectSubCategory(position); incident.setFidSuspectSubCategory(position);
checkIfFinished();
} }
@Override @Override
public void onNothingSelected(AdapterView<?> parent) { public void onNothingSelected(AdapterView<?> parent) {
// do nothing
} }
}); });
} }
@Override private void setMainSpinnerValues(int stringId) {
public void onAttach(Activity activity) { ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(getActivity(),stringId, android.R.layout.simple_spinner_dropdown_item);
super.onAttach(activity); suspectCategory.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, getActivity()));
}
try { private void setSubSpinnerValues(int stringId) {
mCallback = (OnInputFinishedListener) activity; ArrayAdapter<CharSequence> adapter_sub_1 = ArrayAdapter.createFromResource(viewFragment.getContext(), stringId, android.R.layout.simple_spinner_dropdown_item);
} catch (ClassCastException e) { suspectSubCategory.setAdapter(new SpinnerHintAdapter(adapter_sub_1, R.layout.contact_spinner_row_nothing_selected, getActivity()));
throw new ClassCastException(activity.toString() }
+ " must implement OnInputFinishedListener");
private void checkIfFinished(){
boolean isSuspectCategoryFilled = false;
if(incident != null){
if(suspectCategory.getSelectedItemPosition() > 0){
isSuspectCategoryFilled = true;
}
if(suspectSubCategory.isShown()){
isSuspectCategoryFilled = suspectSubCategory.getSelectedItemPosition() > 0;
}
} }
mCallback.onInputFinished(isSuspectCategoryFilled);
} }
@Override @Override
@@ -181,7 +170,7 @@ public class ReportWF_3_Fragment extends Fragment {
if(incident != null){ if(incident != null){
if(incident.getFidSuspectCategory() != 0) suspectCategory.setSelection(incident.getFidSuspectCategory()); if(incident.getFidSuspectCategory() != 0) suspectCategory.setSelection(incident.getFidSuspectCategory());
if(incident.getFidSuspectSubCategory() != 0) suspectOriginCategory.setSelection(incident.getFidSuspectSubCategory()); if(incident.getFidSuspectSubCategory() != 0) suspectSubCategory.setSelection(incident.getFidSuspectSubCategory());
if(incident.getEtcSuspectCategory() != null && !incident.getEtcSuspectCategory().equals("")) suspectEtcInput.setText(incident.getEtcSuspectCategory()); if(incident.getEtcSuspectCategory() != null && !incident.getEtcSuspectCategory().equals("")) suspectEtcInput.setText(incident.getEtcSuspectCategory());
} }
@@ -193,22 +182,28 @@ public class ReportWF_3_Fragment extends Fragment {
super.onPause(); super.onPause();
incident.setFidSuspectCategory(suspectCategory.getSelectedItemPosition()); incident.setFidSuspectCategory(suspectCategory.getSelectedItemPosition());
incident.setFidSuspectSubCategory(suspectOriginCategory.getSelectedItemPosition()); incident.setFidSuspectSubCategory(suspectSubCategory.getSelectedItemPosition());
incident.setEtcSuspectCategory(suspectEtcInput.getText().toString()); incident.setEtcSuspectCategory(suspectEtcInput.getText().toString());
((ReportWFActivity)getActivity()).setIncident(incident); ((ReportWFActivity)getActivity()).setIncident(incident);
} }
@Override
public void onAttach(Context context) {
super.onAttach(context);
try {
private void checkIfFinished(){ mCallback = (OnInputFinishedListener) context;
mCallback.onInputFinished(isMandatoryCategoryFilled); } catch (ClassCastException e) {
throw new ClassCastException(context.toString()
+ " must implement OnInputFinishedListener");
}
} }
@Override @Override
public void onDetach() { public void onDetach() {
super.onDetach(); super.onDetach();
} }
} }

View File

@@ -0,0 +1,148 @@
package org.deke.risk.riskahead.fragment;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import org.deke.risk.riskahead.R;
import org.deke.risk.riskahead.ReportWFActivity;
import org.deke.risk.riskahead.adapter.SpinnerHintAdapter;
import org.deke.risk.riskahead.helper.IncidentReport;
/**
* @author Dennis Thießen
*/
public class ReportWF_4_Fragment extends Fragment {
private final static int COMMON_OBJECTS = 1;
private final static int FIREARM = 2;
private final static int EXPLOSIONS = 3;
private final static int MIL= 4;
private final static int ETC = 5;
private final static int DONTKNOW = 6;
private View viewFragment;
private Spinner suspectWeapon;
private EditText suspectWeaponEtcInput;
private IncidentReport incident;
private OnInputFinishedListener mCallback;
public interface OnInputFinishedListener {
void onInputFinished(boolean finished);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
viewFragment = inflater.inflate(R.layout.fragment_reportwf_4, container, false);
initInputElements();
setMainSpinnerValues(R.array.cat_suspect_weapons);
return viewFragment;
}
private void initInputElements() {
suspectWeapon = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_4_weapon);
suspectWeaponEtcInput = (EditText) viewFragment.findViewById(R.id.txt_reportwf_4_weapon_etc);
suspectWeapon.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
switch (position) {
case DONTKNOW:
suspectWeaponEtcInput.setVisibility(View.INVISIBLE);
break;
default:
suspectWeaponEtcInput.setVisibility(View.VISIBLE);
break;
}
if (position > 0) {
incident.setFidSuspectWeaponCategory(position);
}
checkIfFinished();
}
@Override
public void onNothingSelected(AdapterView<?> parentView) {
// do nothing
}
});
}
private void setMainSpinnerValues(int stringId){
ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(getActivity(), stringId, android.R.layout.simple_spinner_dropdown_item);
suspectWeapon.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, getActivity()));
}
private void checkIfFinished(){
boolean isMainCategoryFilled = false;
if(incident != null){
isMainCategoryFilled = (suspectWeapon.getSelectedItemPosition() > 0) && (incident.getFidSuspectWeaponCategory() > 0);
}
mCallback.onInputFinished(isMainCategoryFilled);
}
@Override
public void onResume() {
super.onResume();
incident = ((ReportWFActivity)getActivity()).getIncident();
if(incident != null){
if(incident.getFidSuspectWeaponCategory() != 0) suspectWeapon.setSelection(incident.getFidSuspectWeaponCategory());
if(incident.getEtcSuspectWeaponCategory() != null && !incident.getEtcSuspectWeaponCategory().equals("")) suspectWeaponEtcInput.setText(incident.getEtcSuspectWeaponCategory());
}
checkIfFinished();
}
@Override
public void onPause() {
super.onPause();
incident.setFidSuspectWeaponCategory(suspectWeapon.getSelectedItemPosition());
incident.setEtcSuspectWeaponCategory(suspectWeaponEtcInput.getText().toString());
((ReportWFActivity)getActivity()).setIncident(incident);
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
try {
mCallback = (OnInputFinishedListener) context;
} catch (ClassCastException e) {
throw new ClassCastException(context.toString()
+ " must implement OnInputFinishedListener");
}
}
@Override
public void onDetach() {
super.onDetach();
}
}

View File

@@ -20,6 +20,7 @@ import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.widget.EditText;
import android.widget.Toast; import android.widget.Toast;
import com.google.android.gms.ads.AdListener; import com.google.android.gms.ads.AdListener;
@@ -287,9 +288,9 @@ public abstract class BaseActivity extends AppCompatActivity {
} }
public void showAd(){ public void showAd(){
// TODO: 03.12.2015 activate when needed
if (mInterstitialAd.isLoaded()) { if (mInterstitialAd.isLoaded()) {
// mInterstitialAd.show(); //TODO: ACTIVATE WHEN NEEDED
//mInterstitialAd.show();
} }
} }
@@ -417,6 +418,10 @@ public abstract class BaseActivity extends AppCompatActivity {
protected abstract String getActivityName(); protected abstract String getActivityName();
private boolean isEmpty(EditText etText) {
return etText.getText().toString().trim().length() == 0;
}
public void showDialog() { public void showDialog() {
if (!pDialog.isShowing()) if (!pDialog.isShowing())
pDialog.show(); pDialog.show();

View File

@@ -64,7 +64,7 @@
android:background="@color/btn_login_bg" android:background="@color/btn_login_bg"
android:minWidth="120dp" android:minWidth="120dp"
android:text="@string/btn_start_login" android:text="@string/btn_start_login"
android:textColor="@color/btn_login" /> android:textColor="@color/white" />
<TextView <TextView
android:id="@+id/lbl_login_policy" android:id="@+id/lbl_login_policy"

View File

@@ -72,7 +72,8 @@
<Button <Button
android:id="@+id/btn_main_report" android:id="@+id/btn_main_report"
android:layout_weight="1" android:layout_weight="1"
android:background="#651a1111" android:background="@color/bg_common_trans"
android:textColor="@color/white"
android:layout_marginRight="1dp" android:layout_marginRight="1dp"
android:paddingLeft="10dp" android:paddingLeft="10dp"
android:layout_width="0dp" android:layout_width="0dp"
@@ -85,7 +86,8 @@
style="?android:attr/borderlessButtonStyle" style="?android:attr/borderlessButtonStyle"
android:layout_weight="1" android:layout_weight="1"
android:paddingRight="10dp" android:paddingRight="10dp"
android:background="#651a1111" android:textColor="@color/white"
android:background="@color/bg_common_trans"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Show Map" /> android:text="Show Map" />

View File

@@ -17,7 +17,7 @@
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" /> android:layout_centerHorizontal="true" />
<LinearLayout <RelativeLayout
android:id="@+id/layoutMain" android:id="@+id/layoutMain"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@@ -25,53 +25,14 @@
android:animateLayoutChanges="true" android:animateLayoutChanges="true"
android:orientation="vertical"> android:orientation="vertical">
<RelativeLayout <FrameLayout
android:id="@+id/layoutContent" android:id="@+id/fragment_reportwf"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1"> android:layout_weight="1"
android:layout_gravity="center_horizontal" >
<FrameLayout </FrameLayout>
android:id="@+id/fragment_reportwf"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal" >
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_reportwf_map"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:clickable="true"
android:src="@android:drawable/ic_dialog_map"
app:layout_anchor="@+id/layoutStatus"
app:layout_anchorGravity="top|right|end"
android:layout_gravity="right|bottom" />
</FrameLayout>
<com.beardedhen.androidbootstrap.AwesomeTextView
android:id="@+id/atvStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:padding="5dp"
android:textSize="50dp"
bootstrap:bootstrapBrand="success"
bootstrap:fontAwesomeIcon="fa_check_circle_o" />
</RelativeLayout>
<LinearLayout
android:id="@+id/layoutStatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:animateLayoutChanges="true"
android:gravity="center_horizontal"
android:orientation="horizontal">
</LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/layoutFooter" android:id="@+id/layoutFooter"
@@ -101,7 +62,30 @@
</LinearLayout> </LinearLayout>
</LinearLayout> <android.support.design.widget.FloatingActionButton
android:id="@+id/fab_reportwf_map"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_above="@+id/layoutFooter"
android:layout_alignParentEnd="true"
android:clickable="true"
android:src="@android:drawable/ic_dialog_map" />
<com.beardedhen.androidbootstrap.AwesomeTextView
android:id="@+id/atvStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/layoutFooter"
android:layout_centerInParent="true"
android:padding="5dp"
android:textSize="40dp"
bootstrap:bootstrapBrand="success"
bootstrap:fontAwesomeIcon="fa_check_circle_o" />
</RelativeLayout>
</RelativeLayout> </RelativeLayout>

View File

@@ -140,7 +140,8 @@
<Button <Button
android:id="@+id/btn_settings_change" android:id="@+id/btn_settings_change"
android:layout_weight="1" android:layout_weight="1"
android:background="#651a1111" android:textColor="@color/white"
android:background="@color/bg_common_trans"
android:layout_marginRight="1dp" android:layout_marginRight="1dp"
android:paddingLeft="10dp" android:paddingLeft="10dp"
android:layout_width="0dp" android:layout_width="0dp"

View File

@@ -3,7 +3,7 @@
android:id="@android:id/text1" android:id="@android:id/text1"
style="?android:attr/spinnerItemStyle" style="?android:attr/spinnerItemStyle"
android:layout_width="150dp" android:layout_width="150dp"
android:layout_height="47dp" android:layout_height="45dp"
android:layout_margin="5dp" android:layout_margin="5dp"
android:gravity="left|center" android:gravity="left|center"
android:background="@drawable/dd_bg" android:background="@drawable/dd_bg"

View File

@@ -8,14 +8,14 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <RelativeLayout
android:id="@+id/layoutMainContent" android:id="@+id/layoutMainContent"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center" android:gravity="center"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <RelativeLayout
android:id="@+id/ll_01_01" android:id="@+id/ll_01_01"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
@@ -27,7 +27,7 @@
<TextView <TextView
android:id="@+id/lbl_reportwf_1_question" android:id="@+id/lbl_reportwf_1_question"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:text="What happened?" android:text="@string/lbl_question_situation"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" android:textAppearance="?android:attr/textAppearanceLarge"
@@ -37,6 +37,7 @@
<Spinner <Spinner
android:id="@+id/dd_reportwf_1_cat_main" android:id="@+id/dd_reportwf_1_cat_main"
android:background="@drawable/dropdown_4" android:background="@drawable/dropdown_4"
android:layout_centerInParent="true"
android:layout_width="300dp" android:layout_width="300dp"
android:layout_height="52dp" android:layout_height="52dp"
android:layout_margin="5dp" android:layout_margin="5dp"
@@ -47,6 +48,7 @@
<Spinner <Spinner
android:id="@+id/dd_reportwf_1_cat_sub" android:id="@+id/dd_reportwf_1_cat_sub"
android:background="@drawable/dropdown_4" android:background="@drawable/dropdown_4"
android:layout_centerInParent="true"
android:layout_width="300dp" android:layout_width="300dp"
android:layout_height="52dp" android:layout_height="52dp"
android:layout_margin="5dp" android:layout_margin="5dp"
@@ -57,7 +59,8 @@
<EditText <EditText
android:layout_width="300dp" android:layout_width="300dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="Please enter your info here" android:layout_centerInParent="true"
android:hint="@string/cat_hint"
android:id="@+id/txt_reportwf_1_cat_etc" android:id="@+id/txt_reportwf_1_cat_etc"
android:layout_below="@id/dd_reportwf_1_cat_sub" /> android:layout_below="@id/dd_reportwf_1_cat_sub" />
@@ -65,13 +68,14 @@
android:id="@+id/ll_pos" android:id="@+id/ll_pos"
android:paddingLeft="20dp" android:paddingLeft="20dp"
android:paddingRight="20dp" android:paddingRight="20dp"
android:layout_below="@+id/txt_reportwf_1_cat_etc"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<TextView <TextView
android:id="@+id/lbl_reportwf_1_question_2" android:id="@+id/lbl_reportwf_1_question_2"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:text="Can you tell us the place?" android:text="@string/lbl_question_place"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge" android:textAppearance="?android:attr/textAppearanceLarge"
@@ -82,19 +86,16 @@
android:layout_width="250dp" android:layout_width="250dp"
android:layout_height="70dp" android:layout_height="70dp"
android:background="@drawable/layout_bg" android:background="@drawable/layout_bg"
android:hint="No position choosen yet" android:hint="@string/hint_place"
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/lbl_reportwf_position_detail" android:id="@+id/lbl_reportwf_position_detail"
android:layout_below="@+id/lbl_reportwf_1_question_2" android:layout_below="@+id/lbl_reportwf_1_question_2"
android:layout_centerInParent="true" android:layout_centerInParent="true"
android:layout_marginLeft="20dp" /> android:layout_marginLeft="20dp" />
</RelativeLayout> </RelativeLayout>
</LinearLayout> </RelativeLayout>
</LinearLayout> </RelativeLayout>
</ScrollView> </ScrollView>

View File

@@ -30,7 +30,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_margin="20dp" android:layout_margin="20dp"
android:text="When did it happen?" android:text="@string/lbl_question_time"
android:textAppearance="?android:attr/textAppearanceLarge" android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/bg_common" /> android:textColor="@color/bg_common" />

View File

@@ -30,13 +30,14 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" android:layout_gravity="center_horizontal"
android:layout_margin="20dp" android:layout_margin="20dp"
android:text="Who is the suspect?" android:text="@string/lbl_question_suspect"
android:textAppearance="?android:attr/textAppearanceLarge" android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/bg_common" /> android:textColor="@color/bg_common" />
<Spinner <Spinner
android:id="@+id/dd_reportwf_3_suspect" android:id="@+id/dd_reportwf_3_suspect"
android:background="@drawable/dropdown_4" android:background="@drawable/dropdown_4"
android:layout_centerInParent="true"
android:layout_width="300dp" android:layout_width="300dp"
android:layout_height="52dp" android:layout_height="52dp"
android:layout_margin="5dp" android:layout_margin="5dp"
@@ -47,6 +48,7 @@
<Spinner <Spinner
android:id="@+id/dd_reportwf_3_suspect_sub" android:id="@+id/dd_reportwf_3_suspect_sub"
android:background="@drawable/dropdown_4" android:background="@drawable/dropdown_4"
android:layout_centerInParent="true"
android:layout_width="300dp" android:layout_width="300dp"
android:layout_height="52dp" android:layout_height="52dp"
android:layout_margin="5dp" android:layout_margin="5dp"
@@ -57,7 +59,8 @@
<EditText <EditText
android:layout_width="300dp" android:layout_width="300dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="Please enter your info here" android:layout_centerInParent="true"
android:hint="@string/cat_hint"
android:id="@+id/txt_reportwf_3_suspect_etc" android:id="@+id/txt_reportwf_3_suspect_etc"
android:layout_gravity="center_horizontal" /> android:layout_gravity="center_horizontal" />
</LinearLayout> </LinearLayout>

View File

@@ -0,0 +1,57 @@
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:bootstrap="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:background="@drawable/layout_bg_gradient"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:orientation="vertical">
<LinearLayout
android:id="@+id/layoutMainContent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:id="@+id/layoutSubContent"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/lbl_reportwf_4_question"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="20dp"
android:text="@string/lbl_question_weapon"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/bg_common" />
<Spinner
android:id="@+id/dd_reportwf_4_weapon"
android:background="@drawable/dropdown_4"
android:layout_centerInParent="true"
android:layout_width="300dp"
android:layout_height="52dp"
android:layout_margin="5dp"
android:spinnerMode="dialog"
android:prompt="@string/lbl_spinner_choose"
android:layout_gravity="center_horizontal" />
<EditText
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:hint="@string/cat_hint"
android:id="@+id/txt_reportwf_4_weapon_etc"
android:layout_gravity="center_horizontal" />
</LinearLayout>
</LinearLayout>
</ScrollView>

View File

@@ -122,22 +122,37 @@
<string name="lbl_report_to_date">To date (yyyy-MM-dd)</string> <string name="lbl_report_to_date">To date (yyyy-MM-dd)</string>
<string name="lbl_report_to_time">To time</string> <string name="lbl_report_to_time">To time</string>
<string name="lbl_question_situation">Was ist passiert?</string>
<string name="lbl_question_place">Wo passiert es?</string>
<string name="lbl_question_time">Wann passiert es?</string>
<string name="lbl_question_suspect">Wer tut das?</string>
<string name="lbl_question_weapon">Mit welchen Waffen passiert es?</string>
<string name="lbl_question_count">Wie viele tun das?</string>
<string name="lbl_question_victim">Wer ist betroffen?</string>
<string name="lbl_question_victimorigin">Kommen die Opfer aus der Umgebung?</string>
<string name="lbl_question_etc">Weißt du noch mehr?</string>
<string name="lbl_question_etc_vehicle">Weißt du noch mehr?</string>
<string name="lbl_question_etc_victimaff">Weißt du noch mehr?</string>
<string name="lbl_question_etc_recon">Wie erkennt man die Täter?</string>
<string name="lbl_question_etc_etc">Weiteres?</string>
<string-array name="cat_situation_main"> <string-array name="cat_situation_main">
<item>Allgemeiner Vorfall/Situation</item> <item>Allgemeiner Vorfall/Situation</item>
<item>Mündliche Gewalt</item> <item>Mündliche Gewalt</item>
<item>Leichte bis schwere körperliche Gewalt</item> <item>Leichte / schwere körperliche Gewalt</item>
<item>Lebensgefährliche Gewalt</item> <item>Lebensgefährliche Gewalt</item>
<item>Naturkatastrophe</item> <item>Naturkatastrophe</item>
<item>Menschliche Katastrophe &amp; Infrastruktur</item> <item>Menschl. Katastrophe &amp; Infrastruktur</item>
</string-array> </string-array>
<string-array name="cat_situation_sub_general"> <string-array name="cat_situation_sub_general">
<item>Diebstahl, Betrug</item> <item>Diebstahl, Betrug</item>
<item>Drogen in Getränk/Speise, Drogenmissbrauch</item> <item>Drogenmissbrauch z.B.Getränk</item>
<item>Demonstration, Unruhen, Straßenblockade</item> <item>Protest, Unruhe, Straßenblockade</item>
<item>Checkpoint, Kontrollen</item> <item>Checkpoint, Kontrollen</item>
<item>Korruption, Erpressung, Schutzgeld</item> <item>Korruption, Erpressung</item>
<item>Einflussgebiet Kriminalität, Milizen, Terroristen</item> <item>Einfluss Kriminalität, Milizen, Terror</item>
<item>Sonstiges...</item> <item>Sonstiges...</item>
</string-array> </string-array>
@@ -164,7 +179,7 @@
<item>Schießerei</item> <item>Schießerei</item>
<item>Explosion, Selbstmordattentat</item> <item>Explosion, Selbstmordattentat</item>
<item>Mord, Tötung, Hinrichtung</item> <item>Mord, Tötung, Hinrichtung</item>
<item>Leichenzurschaustellung zur Abschreckung</item> <item>Leiche in Öffentlichkeit</item>
<item>Sonstiges...</item> <item>Sonstiges...</item>
</string-array> </string-array>
@@ -173,7 +188,7 @@
<item>Wind, Sturm, Orkan, Tornado</item> <item>Wind, Sturm, Orkan, Tornado</item>
<item>Überschwemmung/-flutung</item> <item>Überschwemmung/-flutung</item>
<item>Erdbeben, Berghang Einsturz</item> <item>Erdbeben, Berghang Einsturz</item>
<item>Feuer, Rauch-, Aschewolken, Vulkanausbruch</item> <item>Feuer, Rauch, Vulkanausbruch</item>
<item>Hungersnot, Tierplage</item> <item>Hungersnot, Tierplage</item>
<item>Sonstiges...</item> <item>Sonstiges...</item>
</string-array> </string-array>
@@ -205,20 +220,81 @@
</string-array> </string-array>
<string-array name="cat_suspect_main"> <string-array name="cat_suspect_main">
<item>Straßenkriminelle/Gangs</item> <item>Kriminelle/Gangs </item>
<item>Polizei</item> <item>Polizei</item>
<item>Volksmenge</item> <item>Volksmenge</item>
<item>Miliz, Kartell, Guerilla (Paramilitär)</item> <item>Auftragskiller, Kartell, Miliz, Guerilla</item>
<item>Soldaten (Militär)</item> <item>Soldaten (Militär)</item>
<item>Terroristen (religiöse oder politische)</item> <item>Terroristen (religiöse oder politische)</item>
<item>Sonstige:</item> <item>Sonstiges</item>
<item>Weiß ich nicht</item> <item>Weiß ich nicht</item>
</string-array> </string-array>
<string-array name="cat_suspect_sub_location"> <string-array name="cat_suspect_sub_location">
<item>Lokale aus dem Land (National)</item> <item>Lokale aus dem Land</item>
<item>Ausländische</item> <item>Ausländische</item>
</string-array> </string-array>
<string-array name="cat_suspect_weapons">
<item>Alltagsgegenstände</item>
<item>Schusswaffe</item>
<item>Explosionswaffen oder Sprengkörper</item>
<item>Großkaliber z.B. Panzer, Flugbombe</item>
<item>Sonstiges…</item>
<item>Weiß ich nicht</item>
</string-array>
<string-array name="cat_suspect_count">
<item>Einzelperson</item>
<item>Kleine Gruppe (2-5)</item>
<item>Große Gruppe (mehr als 5)</item>
<item>Sonstiges…</item>
<item>Weiß ich nicht</item>
</string-array>
<string-array name="cat_victim">
<item>Frauen</item>
<item>Kinder</item>
<item>Männer</item>
<item>Tieren</item>
<item>Gebäude/Infrastruktur</item>
</string-array>
<string-array name="cat_victim_origin">
<item>Heimische Bevölkerung</item>
<item>Touristen</item>
<item>Ausländer, der dort arbeitet z.B. Expat</item>
<item>Sonstiges…</item>
<item>Weiß ich nicht</item>
</string-array>
<string-array name="cat_details_vehicle">
<item>Zu Fuß</item>
<item>Motorrad</item>
<item>Auto, Jeep, Pick-up</item>
<item>Lkw, Bus</item>
<item>Militärfahrzeug, Panzer</item>
<item>Flugzeug, Helikopter</item>
<item>Sonstiges…</item>
</string-array>
<string-array name="cat_details_victimaff">
<item>Religion</item>
<item>Volksgruppe/Ethnie z.B. Hautfarbe</item>
<item>Politische Zugehörigkeit</item>
<item>Soziale Gruppe z.B. Einwanderer</item>
<item>Beruf z.B. Journalisten, Prostituierte</item>
<item>Sprachzugehörigkeit</item>
<item>Sonstiges…</item>
</string-array>
<string-array name="cat_details_suspect_recon">
<item>Männer</item>
<item>Frauen</item>
<item>Kinder</item>
<item>Tiere</item>
<item>Sonstiges…</item>
</string-array>
</resources> </resources>

View File

@@ -1,10 +1,11 @@
<resources> <resources>
<color name="bg_login">#26ae90</color> <color name="bg_login">#a9a9a9</color>
<color name="bg_register">#2e3237</color> <color name="bg_register">#2e3237</color>
<color name="bg_common">#1175b7</color> <color name="bg_common">#1175b7</color>
<color name="bg_common_trans">#9e1175b7</color>
<color name="bg_common_2">#0461a8</color> <color name="bg_common_2">#0461a8</color>
<color name="common_text">#333333</color> <color name="common_text">#333333</color>
<color name="actionbar_text">#fdfdfd</color> <color name="actionbar_text">#fdfdfd</color>
@@ -22,7 +23,7 @@
<color name="input_register_bg">#3b4148</color> <color name="input_register_bg">#3b4148</color>
<color name="input_register_hint">#5e6266</color> <color name="input_register_hint">#5e6266</color>
<color name="btn_login">#26ae90</color> <color name="btn_login">#26ae90</color>
<color name="btn_login_bg">#eceef1</color> <color name="btn_login_bg">#1175b7</color>
<color name="lbl_name">#333333</color> <color name="lbl_name">#333333</color>
<color name="btn_logut_bg">#ff6861</color> <color name="btn_logut_bg">#ff6861</color>

View File

@@ -79,7 +79,6 @@
<string name="btn_profile_viewposts">{fa_search} View Posts</string> <string name="btn_profile_viewposts">{fa_search} View Posts</string>
<string name="lbl_profile_top10">Top 10</string> <string name="lbl_profile_top10">Top 10</string>
<string name="btn_maps_confirm_position">{fa_paint_brush} Report this position!</string> <string name="btn_maps_confirm_position">{fa_paint_brush} Report this position!</string>
<string name="navigation_start">Home</string> <string name="navigation_start">Home</string>
@@ -126,22 +125,38 @@
<string name="lbl_viewreport_incidentcategory">Incident Category</string> <string name="lbl_viewreport_incidentcategory">Incident Category</string>
<string name="lbl_viewreport_incidentsubcategory">Incident Subcategory</string> <string name="lbl_viewreport_incidentsubcategory">Incident Subcategory</string>
<string name="lbl_question_situation">Was ist passiert?</string>
<string name="lbl_question_place">Wo passiert es?</string>
<string name="lbl_question_time">Wann passiert es?</string>
<string name="lbl_question_suspect">Wer tut das?</string>
<string name="lbl_question_weapon">Mit welchen Waffen passiert es?</string>
<string name="lbl_question_count">Wie viele tun das?</string>
<string name="lbl_question_victim">Wer ist betroffen?</string>
<string name="lbl_question_victimorigin">Kommen die Opfer aus der Umgebung?</string>
<string name="lbl_question_etc">Weißt du noch mehr?</string>
<string name="lbl_question_etc_vehicle">Weißt du noch mehr?</string>
<string name="lbl_question_etc_victimaff">Weißt du noch mehr?</string>
<string name="lbl_question_etc_recon">Wie erkennt man die Täter?</string>
<string name="lbl_question_etc_etc">Weiteres?</string>
<string name="cat_hint">Weitere Details...</string>
<string name="hint_place">Bitte wähle zunächst einen Ort auf der Karte aus</string>
<string-array name="cat_situation_main"> <string-array name="cat_situation_main">
<item>Allgemeiner Vorfall/Situation</item> <item>Allgemeiner Vorfall/Situation</item>
<item>Mündliche Gewalt</item> <item>Mündliche Gewalt</item>
<item>Leichte bis schwere körperliche Gewalt</item> <item>Leichte / schwere körperliche Gewalt</item>
<item>Lebensgefährliche Gewalt</item> <item>Lebensgefährliche Gewalt</item>
<item>Naturkatastrophe</item> <item>Naturkatastrophe</item>
<item>Menschliche Katastrophe &amp; Infrastruktur</item> <item>Menschl. Katastrophe &amp; Infrastruktur</item>
</string-array> </string-array>
<string-array name="cat_situation_sub_general"> <string-array name="cat_situation_sub_general">
<item>Diebstahl, Betrug</item> <item>Diebstahl, Betrug</item>
<item>Drogen in Getränk/Speise, Drogenmissbrauch</item> <item>Drogenmissbrauch z.B.Getränk</item>
<item>Demonstration, Unruhen, Straßenblockade</item> <item>Protest, Unruhe, Straßenblockade</item>
<item>Checkpoint, Kontrollen</item> <item>Checkpoint, Kontrollen</item>
<item>Korruption, Erpressung, Schutzgeld</item> <item>Korruption, Erpressung</item>
<item>Einflussgebiet Kriminalität, Milizen, Terroristen</item> <item>Einfluss Kriminalität, Milizen, Terror</item>
<item>Sonstiges...</item> <item>Sonstiges...</item>
</string-array> </string-array>
@@ -168,7 +183,7 @@
<item>Schießerei</item> <item>Schießerei</item>
<item>Explosion, Selbstmordattentat</item> <item>Explosion, Selbstmordattentat</item>
<item>Mord, Tötung, Hinrichtung</item> <item>Mord, Tötung, Hinrichtung</item>
<item>Leichenzurschaustellung zur Abschreckung</item> <item>Leiche in Öffentlichkeit</item>
<item>Sonstiges...</item> <item>Sonstiges...</item>
</string-array> </string-array>
@@ -177,7 +192,7 @@
<item>Wind, Sturm, Orkan, Tornado</item> <item>Wind, Sturm, Orkan, Tornado</item>
<item>Überschwemmung/-flutung</item> <item>Überschwemmung/-flutung</item>
<item>Erdbeben, Berghang Einsturz</item> <item>Erdbeben, Berghang Einsturz</item>
<item>Feuer, Rauch-, Aschewolken, Vulkanausbruch</item> <item>Feuer, Rauch, Vulkanausbruch</item>
<item>Hungersnot, Tierplage</item> <item>Hungersnot, Tierplage</item>
<item>Sonstiges...</item> <item>Sonstiges...</item>
</string-array> </string-array>
@@ -209,20 +224,80 @@
</string-array> </string-array>
<string-array name="cat_suspect_main"> <string-array name="cat_suspect_main">
<item>Straßenkriminelle/Gangs</item> <item>Kriminelle/Gangs </item>
<item>Polizei</item> <item>Polizei</item>
<item>Volksmenge</item> <item>Volksmenge</item>
<item>Miliz, Kartell, Guerilla (Paramilitär)</item> <item>Auftragskiller, Kartell, Miliz, Guerilla</item>
<item>Soldaten (Militär)</item> <item>Soldaten (Militär)</item>
<item>Terroristen (religiöse oder politische)</item> <item>Terroristen (religiöse oder politische)</item>
<item>Sonstige:</item> <item>Sonstiges</item>
<item>Weiß ich nicht</item> <item>Weiß ich nicht</item>
</string-array> </string-array>
<string-array name="cat_suspect_sub_location"> <string-array name="cat_suspect_sub_location">
<item>Lokale aus dem Land (National)</item> <item>Lokale aus dem Land</item>
<item>Ausländische</item> <item>Ausländische</item>
</string-array> </string-array>
<string-array name="cat_suspect_weapons">
<item>Alltagsgegenstände</item>
<item>Schusswaffe</item>
<item>Explosionswaffen oder Sprengkörper</item>
<item>Großkaliber z.B. Panzer, Flugbombe</item>
<item>Sonstiges…</item>
<item>Weiß ich nicht</item>
</string-array>
<string-array name="cat_suspect_count">
<item>Einzelperson</item>
<item>Kleine Gruppe (2-5)</item>
<item>Große Gruppe (mehr als 5)</item>
<item>Sonstiges…</item>
<item>Weiß ich nicht</item>
</string-array>
<string-array name="cat_victim">
<item>Frauen</item>
<item>Kinder</item>
<item>Männer</item>
<item>Tieren</item>
<item>Gebäude/Infrastruktur</item>
</string-array>
<string-array name="cat_victim_origin">
<item>Heimische Bevölkerung</item>
<item>Touristen</item>
<item>Ausländer, der dort arbeitet z.B. Expat</item>
<item>Sonstiges…</item>
<item>Weiß ich nicht</item>
</string-array>
<string-array name="cat_details_vehicle">
<item>Zu Fuß</item>
<item>Motorrad</item>
<item>Auto, Jeep, Pick-up</item>
<item>Lkw, Bus</item>
<item>Militärfahrzeug, Panzer</item>
<item>Flugzeug, Helikopter</item>
<item>Sonstiges…</item>
</string-array>
<string-array name="cat_details_victimaff">
<item>Religion</item>
<item>Volksgruppe/Ethnie z.B. Hautfarbe</item>
<item>Politische Zugehörigkeit</item>
<item>Soziale Gruppe z.B. Einwanderer</item>
<item>Beruf z.B. Journalisten, Prostituierte</item>
<item>Sprachzugehörigkeit</item>
<item>Sonstiges…</item>
</string-array>
<string-array name="cat_details_suspect_recon">
<item>Männer</item>
<item>Frauen</item>
<item>Kinder</item>
<item>Tiere</item>
<item>Sonstiges…</item>
</string-array>
</resources> </resources>