From 2f81bfa09db8a879d3232786f7c70be896b3d04d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dennis=20Thie=C3=9Fen?= Date: Sat, 2 Jan 2016 14:14:06 +0100 Subject: [PATCH] =?UTF-8?q?DT=20@02.01.2016:=20ReportWF=20refactored=20und?= =?UTF-8?q?=20erweitert.=20Kategorien=20in=20strings.xml=20hinzugef=C3=BCg?= =?UTF-8?q?t.=20InAppBillingService=20hinzugef=C3=BCgt=20(muss=20jedoch=20?= =?UTF-8?q?noch=20implementiert=20werden)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/app.iml | 34 +- app/build.gradle | 14 +- .../vending/billing/IInAppBillingService.aidl | 144 +++++++ .../org/deke/risk/riskahead/MainActivity.java | 2 + .../org/deke/risk/riskahead/MapsActivity.java | 28 +- .../deke/risk/riskahead/ReportWFActivity.java | 51 +-- .../risk/riskahead/SubscriptionsActivity.java | 68 +++- .../risk/riskahead/ViewReportActivity.java | 44 ++- .../riskahead/adapter/ReportListAdapter.java | 7 +- .../fragment/ReportWF_1_Fragment.java | 178 +++++---- .../fragment/ReportWF_2_Fragment.java | 353 +++++++++--------- .../fragment/ReportWF_3_Fragment.java | 141 ++++--- .../fragment/ReportWF_4_Fragment.java | 148 ++++++++ .../risk/riskahead/helper/BaseActivity.java | 9 +- app/src/main/res/layout/activity_login.xml | 2 +- app/src/main/res/layout/activity_main.xml | 6 +- .../main/res/layout/activity_report_wf.xml | 76 ++-- app/src/main/res/layout/activity_settings.xml | 3 +- .../contact_spinner_row_nothing_selected.xml | 2 +- .../main/res/layout/fragment_reportwf_1.xml | 23 +- .../main/res/layout/fragment_reportwf_2.xml | 2 +- .../main/res/layout/fragment_reportwf_3.xml | 7 +- .../main/res/layout/fragment_reportwf_4.xml | 57 +++ app/src/main/res/values-de/strings.xml | 100 ++++- app/src/main/res/values/colors.xml | 5 +- app/src/main/res/values/strings.xml | 101 ++++- 26 files changed, 1106 insertions(+), 499 deletions(-) create mode 100644 app/src/main/aidl/com/android/vending/billing/IInAppBillingService.aidl create mode 100644 app/src/main/java/org/deke/risk/riskahead/fragment/ReportWF_4_Fragment.java create mode 100644 app/src/main/res/layout/fragment_reportwf_4.xml diff --git a/app/app.iml b/app/app.iml index 81c682e..fca2a6a 100644 --- a/app/app.iml +++ b/app/app.iml @@ -78,14 +78,14 @@ - - - - - - - - + + + + + + + + @@ -105,32 +105,32 @@ + - - - + - + - - + - + + - + + - + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 0e61857..8229c19 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -40,13 +40,16 @@ dependencies { compile('com.twitter.sdk.android:twitter-core:1.4.1@aar') { transitive = true; } + compile('com.mikepenz:materialdrawer:4.5.8@aar') { + transitive = true + } compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.mikepenz:iconics-core:2.5.1@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-plus:8.3.0' - compile 'com.google.android.gms:play-services-location:8.3.0' - compile 'com.google.android.gms:play-services-ads:8.3.0' + compile 'com.google.android.gms:play-services-gcm:8.4.0' + compile 'com.google.android.gms:play-services-plus:8.4.0' + compile 'com.google.android.gms:play-services-location:8.4.0' + compile 'com.google.android.gms:play-services-ads:8.4.0' compile 'com.facebook.android:facebook-android-sdk:4.8.1' compile 'com.beardedhen:androidbootstrap:2.0.1' compile 'com.mcxiaoke.volley:library:1.0.19' @@ -54,7 +57,4 @@ dependencies { compile 'com.google.code.gson:gson:2.4' compile 'com.google.maps.android:android-maps-utils:0.4' compile 'com.android.support:support-v4:23.1.1' - compile('com.mikepenz:materialdrawer:4.5.8@aar') { - transitive = true - } } diff --git a/app/src/main/aidl/com/android/vending/billing/IInAppBillingService.aidl b/app/src/main/aidl/com/android/vending/billing/IInAppBillingService.aidl new file mode 100644 index 0000000..2a492f7 --- /dev/null +++ b/app/src/main/aidl/com/android/vending/billing/IInAppBillingService.aidl @@ -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); +} diff --git a/app/src/main/java/org/deke/risk/riskahead/MainActivity.java b/app/src/main/java/org/deke/risk/riskahead/MainActivity.java index 1cf22b4..895175d 100644 --- a/app/src/main/java/org/deke/risk/riskahead/MainActivity.java +++ b/app/src/main/java/org/deke/risk/riskahead/MainActivity.java @@ -75,6 +75,7 @@ public class MainActivity extends BaseActivity{ Drawable reportIcon = new IconicsDrawable(this) .icon(GoogleMaterial.Icon.gmd_room) + .color(getResources().getColor(R.color.white)) .sizeDp(24); report.setCompoundDrawables(reportIcon, null, null, null); @@ -90,6 +91,7 @@ public class MainActivity extends BaseActivity{ Drawable mapIcon = new IconicsDrawable(this) .icon(GoogleMaterial.Icon.gmd_map) + .color(getResources().getColor(R.color.white)) .sizeDp(24); map.setCompoundDrawables(null,null, mapIcon, null); diff --git a/app/src/main/java/org/deke/risk/riskahead/MapsActivity.java b/app/src/main/java/org/deke/risk/riskahead/MapsActivity.java index c7f54c8..972c5d6 100644 --- a/app/src/main/java/org/deke/risk/riskahead/MapsActivity.java +++ b/app/src/main/java/org/deke/risk/riskahead/MapsActivity.java @@ -52,6 +52,7 @@ import org.json.JSONObject; import java.util.ArrayList; import java.util.HashMap; +import java.util.Locale; import java.util.Map; @@ -76,9 +77,9 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa private LatLng markedLocation; 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 curSouthwestBounds; @@ -94,6 +95,8 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa findViewById(R.id.btn_maps_confirm_position).setVisibility(View.GONE); navDrawer.setSelection(mapAvtivityID, false); + System.gc(); + initMap(); handleIntent(getIntent()); initClustering(); @@ -102,6 +105,12 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa } + @Override + public void onLowMemory() { + super.onLowMemory(); + System.gc(); + } + private void initMap() { mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.frag_maps_map)).getMap(); mMap.getUiSettings().setZoomControlsEnabled(true); @@ -517,10 +526,23 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(point, DEFAULT_ZOOM_LEVEL)); } else { myPosition = session.getLocation(); - if (myPosition != null) + if ((myPosition != null) && (myPosition.latitude != 0.0) && (myPosition.longitude != 0.0)) { mMap.animateCamera(CameraUpdateFactory.newLatLngZoom( 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)); + } } } diff --git a/app/src/main/java/org/deke/risk/riskahead/ReportWFActivity.java b/app/src/main/java/org/deke/risk/riskahead/ReportWFActivity.java index fb1ed83..9124643 100644 --- a/app/src/main/java/org/deke/risk/riskahead/ReportWFActivity.java +++ b/app/src/main/java/org/deke/risk/riskahead/ReportWFActivity.java @@ -1,8 +1,8 @@ package org.deke.risk.riskahead; import android.app.AlertDialog; -import android.app.Fragment; -import android.app.FragmentTransaction; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentTransaction; import android.content.DialogInterface; import android.content.Intent; 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_2_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.AppConfig; import org.deke.risk.riskahead.helper.AppController; @@ -41,16 +42,17 @@ import java.util.List; import java.util.Locale; 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 TAG = ReportWFActivity.class.getSimpleName(); - private List fragList = new ArrayList(); + private List fragList = new ArrayList<>(); private Fragment frag_report_1 = new ReportWF_1_Fragment(); private Fragment frag_report_2 = new ReportWF_2_Fragment(); private Fragment frag_report_3 = new ReportWF_3_Fragment(); + private Fragment frag_report_4 = new ReportWF_4_Fragment(); private BootstrapButton btnContinue; private BootstrapButton btnReportNow; @@ -62,8 +64,8 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen public boolean resetSignal = false; - SharedPreferences mPrefs; - SharedPreferences.Editor prefsEditor; + private SharedPreferences mPrefs; + private SharedPreferences.Editor prefsEditor; @Override 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_2); fragList.add(frag_report_3); + fragList.add(frag_report_4); initFragment(currentState); @@ -105,7 +108,6 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen } }); - mPrefs = getPreferences(MODE_PRIVATE); prefsEditor = mPrefs.edit(); } @@ -156,7 +158,7 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen } public void setIncident(IncidentReport newIncident){ - if(resetSignal == false){ + if(!resetSignal){ incident = newIncident; } } @@ -165,7 +167,7 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen findViewById(R.id.atvStatus).setVisibility(View.INVISIBLE); currentState = state; - FragmentTransaction transaction = getFragmentManager().beginTransaction(); + FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); transaction.replace(R.id.fragment_reportwf, fragList.get(state)); transaction.addToBackStack(null); @@ -182,16 +184,6 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen return true; } - @Override - protected int getLayoutResourceId() { - return R.layout.activity_report_wf; - } - - @Override - protected String getActivityName() { - return mActivityTitle; - } - @Override public void onInputFinished(boolean finished) { if(finished) { @@ -215,7 +207,7 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen public void onStop(){ super.onStop(); - if(resetSignal == false){ + if(!resetSignal){ Gson gson = new Gson(); prefsEditor.putString("incident", gson.toJson(incident)); prefsEditor.putInt("currentState", currentState); @@ -263,9 +255,6 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen }) .setIcon(android.R.drawable.ic_dialog_alert) .show(); - - - } return super.onOptionsItemSelected(item); @@ -277,7 +266,14 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen }else{ btnMap.setVisibility(View.INVISIBLE); } + } + public void onBackPressed(){ + if(currentState > 0) { + initFragment(currentState - 1); + }else{ + super.onBackPressed(); + } } 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; + } } diff --git a/app/src/main/java/org/deke/risk/riskahead/SubscriptionsActivity.java b/app/src/main/java/org/deke/risk/riskahead/SubscriptionsActivity.java index ac01f2d..9b9f903 100644 --- a/app/src/main/java/org/deke/risk/riskahead/SubscriptionsActivity.java +++ b/app/src/main/java/org/deke/risk/riskahead/SubscriptionsActivity.java @@ -1,27 +1,73 @@ 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.IBinder; +import android.view.View; +import android.widget.Button; + +import com.android.vending.billing.IInAppBillingService; 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 TAG = StartActivity.class.getSimpleName(); + private Button btnPurchaseNoAds; + private Button btnPurchaseExtraFunctions; + + IInAppBillingService mService; + ServiceConnection mServiceConn; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); 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 protected void onResume() { super.onResume(); - navDrawer.setSelection(subscriptionsAvtivityID,false); + navDrawer.setSelection(subscriptionsAvtivityID, false); } + + @Override protected int getLayoutResourceId() { return R.layout.activity_subscriptions; @@ -29,4 +75,22 @@ public class SubscriptionsActivity extends BaseActivity { @Override 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); + } + } } diff --git a/app/src/main/java/org/deke/risk/riskahead/ViewReportActivity.java b/app/src/main/java/org/deke/risk/riskahead/ViewReportActivity.java index b2a1723..5b2507e 100644 --- a/app/src/main/java/org/deke/risk/riskahead/ViewReportActivity.java +++ b/app/src/main/java/org/deke/risk/riskahead/ViewReportActivity.java @@ -41,33 +41,33 @@ public class ViewReportActivity extends BaseActivity { private TextView txtPosition; private BootstrapLabel scorelabel; + private IncidentReport incident; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); userHasToBeLoggedIn(); - Intent intent = getIntent(); - final Integer uid = intent.getIntExtra(BaseActivity.EXTRA_MESSAGE, 0); - txtIncidentCategory = (EditText) findViewById(R.id.txt_viewreport_incidentcategory); txtIncidentSubCategory = (EditText) findViewById(R.id.txt_viewreport_incidentsubcategory); txtPosition = (TextView) findViewById(R.id.txt_viewreport_position); 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() { @Override public void onClick(View v) { - makeUpvote(uid); + makeUpvote(id); } }); findViewById(R.id.btn_viewreport_downvote).setOnClickListener(new View.OnClickListener() { @Override 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?") .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { - deleteReport(uid); + deleteReport(id); } }) .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { @@ -185,9 +185,7 @@ public class ViewReportActivity extends BaseActivity { if (!error) { JSONObject jIncident = jObj.getJSONObject("msg"); - IncidentReport incident = new IncidentReport(jIncident); - - initReport(incident); + initReport(new IncidentReport(jIncident)); } else { String errorMsg = jObj.getString("error_msg"); @@ -229,6 +227,8 @@ public class ViewReportActivity extends BaseActivity { txtIncidentCategory.setText(incident.getIncidentCategoryName(getApplicationContext())); txtIncidentSubCategory.setText(incident.getIncidentSubCategoryName(getApplicationContext())); + this.incident = incident; + Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault()); try { @@ -265,16 +265,24 @@ public class ViewReportActivity extends BaseActivity { } } - public void makeUpvote(Integer uid) { - String tag_string_req = "addvote"; - StringRequest strReq = getStringRequestAddVote(uid, "1"); - AppController.getInstance().addToRequestQueue(strReq, tag_string_req); + public void makeUpvote(Integer incidentid) { + if(user.get(SessionManager.KEY_UID).equals(Integer.toString(incident.getFidFromUser()))){ + showMessage("You can not vote your own incidents"); + }else { + String tag_string_req = "addvote"; + StringRequest strReq = getStringRequestAddVote(incidentid, "1"); + AppController.getInstance().addToRequestQueue(strReq, tag_string_req); + } } - public void makeDownvote(Integer uid) { - String tag_string_req = "addvote"; - StringRequest strReq = getStringRequestAddVote(uid, "2"); - AppController.getInstance().addToRequestQueue(strReq, tag_string_req); + public void makeDownvote(Integer incidentid) { + if(user.get(SessionManager.KEY_UID).equals(Integer.toString(incident.getFidFromUser()))){ + showMessage("You can not vote your own incidents"); + }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) { diff --git a/app/src/main/java/org/deke/risk/riskahead/adapter/ReportListAdapter.java b/app/src/main/java/org/deke/risk/riskahead/adapter/ReportListAdapter.java index 3915b5e..20a7889 100644 --- a/app/src/main/java/org/deke/risk/riskahead/adapter/ReportListAdapter.java +++ b/app/src/main/java/org/deke/risk/riskahead/adapter/ReportListAdapter.java @@ -3,6 +3,7 @@ package org.deke.risk.riskahead.adapter; import android.content.Context; import android.graphics.Color; import android.graphics.Typeface; +import android.os.Build; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -67,7 +68,11 @@ public class ReportListAdapter extends BaseAdapter { titleText.setTypeface(null, Typeface.BOLD); 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; } diff --git a/app/src/main/java/org/deke/risk/riskahead/fragment/ReportWF_1_Fragment.java b/app/src/main/java/org/deke/risk/riskahead/fragment/ReportWF_1_Fragment.java index e6d1686..764e1e5 100644 --- a/app/src/main/java/org/deke/risk/riskahead/fragment/ReportWF_1_Fragment.java +++ b/app/src/main/java/org/deke/risk/riskahead/fragment/ReportWF_1_Fragment.java @@ -1,7 +1,7 @@ package org.deke.risk.riskahead.fragment; -import android.app.Activity; -import android.app.Fragment; +import android.support.v4.app.Fragment; +import android.content.Context; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -13,15 +13,13 @@ import android.widget.RelativeLayout; import android.widget.Spinner; import android.widget.TextView; -import com.beardedhen.androidbootstrap.BootstrapButton; - import org.deke.risk.riskahead.R; import org.deke.risk.riskahead.ReportWFActivity; import org.deke.risk.riskahead.helper.IncidentReport; 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{ @@ -41,11 +39,9 @@ public class ReportWF_1_Fragment extends Fragment{ private RelativeLayout timeLayout; private TextView txtPositionInformation; - private boolean isMandatoryCategoryFilled; + private IncidentReport incident; - IncidentReport incident; - - OnInputFinishedListener mCallbackFinished; + private OnInputFinishedListener mCallbackFinished; public interface OnInputFinishedListener { void onInputFinished(boolean finished); @@ -60,93 +56,71 @@ public class ReportWF_1_Fragment extends Fragment{ public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) { viewFragment = inflater.inflate(R.layout.fragment_reportwf_1, container, false); - initSpinnerOneMain(); - initSpinnerOneSub(); - initLayerPosition(); - - crimeSubOther = (EditText) viewFragment.findViewById(R.id.txt_reportwf_1_cat_etc); - crimeSubOther.setVisibility(View.INVISIBLE); + initInputElements(); + setMainSpinnerValues(R.array.cat_situation_main); return viewFragment; } - private void checkIfFinished(){ - 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() { + private void initInputElements() { 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 adapter_main_1 = ArrayAdapter.createFromResource(getActivity(), - R.array.cat_situation_main, android.R.layout.simple_spinner_dropdown_item); - adapter_main_1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - crimeCategory.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, getActivity())); + crimeSubCategory.setVisibility(View.INVISIBLE); + crimeSubOther.setVisibility(View.INVISIBLE); + timeLayout.setVisibility(View.INVISIBLE); + ((ReportWFActivity)getActivity()).setMapButtonVisibility(false); crimeCategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { - int stringid = 0; + int stringId; switch (position) { case 1: - stringid = R.array.cat_situation_sub_general; + stringId = R.array.cat_situation_sub_general; break; case 2: - stringid = R.array.cat_situation_sub_verbal; + stringId = R.array.cat_situation_sub_verbal; break; case 3: - stringid = R.array.cat_situation_sub_force; + stringId = R.array.cat_situation_sub_force; break; case 4: - stringid = R.array.cat_situation_sub_force_serious; + stringId = R.array.cat_situation_sub_force_serious; break; case 5: - stringid = R.array.cat_situation_sub_nature; + stringId = R.array.cat_situation_sub_nature; break; case 6: - stringid = R.array.cat_situation_sub_infrastructure; + stringId = R.array.cat_situation_sub_infrastructure; break; default: - stringid = R.array.cat_situation_sub_general; + stringId = R.array.cat_situation_sub_general; break; } - Spinner spinner_sub_1 = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_1_cat_sub); - ArrayAdapter 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); - 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); + if (((SpinnerHintAdapter) parent.getAdapter()).isInInitialState()) { + crimeSubCategory.setVisibility(View.INVISIBLE); } else { - spinner_sub_1.setVisibility(View.VISIBLE); + crimeSubCategory.setVisibility(View.VISIBLE); + incident.setFidIncidentCategory(position); + setSubSpinnerValues(stringId); } - incident.setFidIncidentCategory(position); - isMandatoryCategoryFilled = false; checkIfFinished(); } @Override 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() { - @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { int i = 99; @@ -172,38 +146,60 @@ public class ReportWF_1_Fragment extends Fragment{ break; } - if (position == i) { - viewFragment.findViewById(R.id.txt_reportwf_1_cat_etc).setVisibility(View.VISIBLE); + if (((SpinnerHintAdapter) parent.getAdapter()).isInInitialState()) { + crimeSubOther.setVisibility(View.INVISIBLE); } 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()) { - isMandatoryCategoryFilled = false; - checkIfFinished(); - } else { - isMandatoryCategoryFilled = true; - checkIfFinished(); - } - - if ((position == 0) && (incident.getFidIncidentSubCategory() != 0)) - crimeSubCategory.setSelection(incident.getFidIncidentSubCategory()); - - incident.setFidIncidentSubCategory(position); + checkIfFinished(); } @Override public void onNothingSelected(AdapterView parent) { + // do nothing } }); } - private void initLayerPosition(){ - timeLayout = (RelativeLayout) viewFragment.findViewById(R.id.ll_pos); - timeLayout.setVisibility(View.INVISIBLE); - ((ReportWFActivity)getActivity()).setMapButtonVisibility(false); + private void setMainSpinnerValues(int stringId) { + ArrayAdapter adapter_main_1 = ArrayAdapter.createFromResource(getActivity(),stringId, android.R.layout.simple_spinner_dropdown_item); + crimeCategory.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, getActivity())); + } - txtPositionInformation = (TextView) viewFragment.findViewById(R.id.lbl_reportwf_position_detail); + private void setSubSpinnerValues(int stringId) { + ArrayAdapter 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 @@ -213,23 +209,20 @@ public class ReportWF_1_Fragment extends Fragment{ incident = ((ReportWFActivity)getActivity()).getIncident(); 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){ timeLayout.setVisibility(View.VISIBLE); txtPositionInformation.setText(incident.getIncidentPositionDescription()); ((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(); @@ -246,15 +239,14 @@ public class ReportWF_1_Fragment extends Fragment{ ((ReportWFActivity)getActivity()).setIncident(incident); } - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); + public void onAttach(Context context) { + super.onAttach(context); try { - mCallbackFinished = (OnInputFinishedListener) activity; + mCallbackFinished = (OnInputFinishedListener) context; } catch (ClassCastException e) { - throw new ClassCastException(activity.toString() + throw new ClassCastException(context.toString() + " must implement all Listeners"); } } diff --git a/app/src/main/java/org/deke/risk/riskahead/fragment/ReportWF_2_Fragment.java b/app/src/main/java/org/deke/risk/riskahead/fragment/ReportWF_2_Fragment.java index 59c29be..889f803 100644 --- a/app/src/main/java/org/deke/risk/riskahead/fragment/ReportWF_2_Fragment.java +++ b/app/src/main/java/org/deke/risk/riskahead/fragment/ReportWF_2_Fragment.java @@ -1,11 +1,11 @@ package org.deke.risk.riskahead.fragment; -import android.app.Activity; import android.app.DatePickerDialog; import android.app.Dialog; -import android.app.DialogFragment; -import android.app.Fragment; +import android.support.v4.app.DialogFragment; +import android.support.v4.app.Fragment; import android.app.TimePickerDialog; +import android.content.Context; import android.os.Bundle; import android.text.format.DateFormat; import android.view.LayoutInflater; @@ -28,7 +28,7 @@ import java.text.SimpleDateFormat; import java.util.Calendar; /** - * Created by Dennis on 08.12.2015. + * @author Dennis Thießen */ public class ReportWF_2_Fragment extends Fragment { @@ -51,93 +51,42 @@ public class ReportWF_2_Fragment extends Fragment { private EditText tmpInput; private IncidentReport incident; - private boolean isMandatoryCategoryFilled; - OnInputFinishedListener mCallback; + 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_2, container, false); - initSpinnerOneMain(); - initSpinnerOneSub(); - - 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); - } - }); + initInputElements(); + setMainSpinnerValues(R.array.cat_time_main); return viewFragment; } - private void initLayoutToTime() { - RelativeLayout rlFromTime = (RelativeLayout) viewFragment.findViewById(R.id.ll_report_to_time); - rlFromTime.setVisibility(View.INVISIBLE); - } + private void initInputElements() { + initLayoutFromDateTime(); + 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); + timeSubCategory = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_2_time_sub); - ArrayAdapter adapter_main_1 = ArrayAdapter.createFromResource(getActivity(), - 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())); + timeSubCategory.setVisibility(View.INVISIBLE); timeCategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { - int stringid = 0; + int stringId = 0; + resetDates(); switch (position) { case NOW: @@ -147,77 +96,58 @@ public class ReportWF_2_Fragment extends Fragment { inputDateFrom.setText(new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime())); inputTimeFrom.setText(new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime())); - - isMandatoryCategoryFilled = true; break; case PERIODIC: viewFragment.findViewById(R.id.ll_report_from_time).setVisibility(View.INVISIBLE); viewFragment.findViewById(R.id.ll_report_to_time).setVisibility(View.INVISIBLE); - incident.resetDatetime(); - - stringid = R.array.cat_time_sub_periodical; - isMandatoryCategoryFilled = false; + stringId = R.array.cat_time_sub_periodical; break; case DATETIME: 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.dd_reportwf_2_time_sub).setVisibility(View.INVISIBLE); - isMandatoryCategoryFilled = false; break; case DATETIMEAREA: 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.dd_reportwf_2_time_sub).setVisibility(View.INVISIBLE); - isMandatoryCategoryFilled = false; break; case DONTKNOW: 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.dd_reportwf_2_time_sub).setVisibility(View.INVISIBLE); - isMandatoryCategoryFilled = true; break; } - checkIfFinished(); - - if (!((SpinnerHintAdapter) timeCategory.getAdapter()).isInInitialState() && stringid != 0) { - ArrayAdapter 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()) { - isMandatoryCategoryFilled = false; - checkIfFinished(); + timeSubCategory.setVisibility(View.INVISIBLE); + } else { + incident.setFidTimeCategory(position); + + if (stringId != 0) { + timeSubCategory.setVisibility(View.VISIBLE); + setSubSpinnerValues(stringId); + } } - incident.setFidTimeCategory(position); + checkIfFinished(); } @Override 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() { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { - isMandatoryCategoryFilled = !((SpinnerHintAdapter) timeSubCategory.getAdapter()).isInInitialState(); - - if ((position == 0) && (incident.getFidTimeSubCategory() != 0)) + if ((position < 1) && (incident.getFidTimeSubCategory() != 0)) timeSubCategory.setSelection(incident.getFidTimeSubCategory()); - checkIfFinished(); incident.setFidTimeSubCategory(position); + checkIfFinished(); } @Override @@ -227,16 +157,157 @@ public class ReportWF_2_Fragment extends Fragment { }); } - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); + private void setMainSpinnerValues(int stringId) { + ArrayAdapter adapter_main_1 = ArrayAdapter.createFromResource(getActivity(), stringId , android.R.layout.simple_spinner_dropdown_item); + timeCategory.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, getActivity())); + } - try { - mCallback = (OnInputFinishedListener) activity; - } catch (ClassCastException e) { - throw new ClassCastException(activity.toString() - + " must implement OnInputFinishedListener"); + private void setSubSpinnerValues(int stringId) { + ArrayAdapter adapter_sub_1 = ArrayAdapter.createFromResource(viewFragment.getContext(), stringId, android.R.layout.simple_spinner_dropdown_item); + timeSubCategory.setAdapter(new SpinnerHintAdapter(adapter_sub_1, R.layout.contact_spinner_row_nothing_selected, getActivity())); + + 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 @@ -248,10 +319,7 @@ public class ReportWF_2_Fragment extends Fragment { if(incident != null){ if(incident.getFidTimeCategory() != 0){ timeCategory.setSelection(incident.getFidTimeCategory()); - } - - if(incident.getFidTimeSubCategory() != 0){ - timeSubCategory.setSelection(incident.getFidTimeSubCategory()); + //SubCategory is automatically initialized } if(incident.getFromDate() != null && !incident.getFromDate().equals("")){ @@ -288,69 +356,18 @@ public class ReportWF_2_Fragment extends Fragment { ((ReportWFActivity)getActivity()).setIncident(incident); } - public class TimePickerFragment extends DialogFragment implements TimePickerDialog.OnTimeSetListener { + @Override + public void onAttach(Context context) { + super.onAttach(context); - @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(); + try { + mCallback = (OnInputFinishedListener) context; + } catch (ClassCastException e) { + throw new ClassCastException(context.toString() + + " must implement OnInputFinishedListener"); } } - 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 public void onDetach() { super.onDetach(); diff --git a/app/src/main/java/org/deke/risk/riskahead/fragment/ReportWF_3_Fragment.java b/app/src/main/java/org/deke/risk/riskahead/fragment/ReportWF_3_Fragment.java index 4ebc96c..f5bb2ba 100644 --- a/app/src/main/java/org/deke/risk/riskahead/fragment/ReportWF_3_Fragment.java +++ b/app/src/main/java/org/deke/risk/riskahead/fragment/ReportWF_3_Fragment.java @@ -1,7 +1,7 @@ package org.deke.risk.riskahead.fragment; -import android.app.Activity; -import android.app.Fragment; +import android.support.v4.app.Fragment; +import android.content.Context; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -17,7 +17,7 @@ import org.deke.risk.riskahead.helper.IncidentReport; 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 { @@ -33,144 +33,133 @@ public class ReportWF_3_Fragment extends Fragment { private View viewFragment; private Spinner suspectCategory; - private Spinner suspectOriginCategory; + private Spinner suspectSubCategory; private EditText suspectEtcInput; private IncidentReport incident; - private boolean isMandatoryCategoryFilled; - OnInputFinishedListener mCallback; + 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_3, container, false); - initSpinnerOneMain(); - initSpinnerOneSub(); - - suspectEtcInput = (EditText) viewFragment.findViewById(R.id.txt_reportwf_3_suspect_etc); + initInputElements(); + setMainSpinnerValues(R.array.cat_suspect_main); return viewFragment; } - - private void initSpinnerOneMain() { + private void initInputElements() { 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 adapter_main_1 = ArrayAdapter.createFromResource(getActivity(), - R.array.cat_suspect_main, android.R.layout.simple_spinner_dropdown_item); - 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())); + suspectSubCategory.setVisibility(View.INVISIBLE); + suspectEtcInput.setVisibility(View.INVISIBLE); suspectCategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { - int stringid = 0; + int stringId = 0; switch (position) { case GANGS: - isMandatoryCategoryFilled = true; break; case POLICE: - isMandatoryCategoryFilled = true; break; case MOB: - isMandatoryCategoryFilled = true; break; case PARAMILITARY: - stringid = R.array.cat_suspect_sub_location; - isMandatoryCategoryFilled = false; + stringId = R.array.cat_suspect_sub_location; break; case MILITARY: - stringid = R.array.cat_suspect_sub_location; - isMandatoryCategoryFilled = false; + stringId = R.array.cat_suspect_sub_location; break; case TERRORIST: - stringid = R.array.cat_suspect_sub_location; - isMandatoryCategoryFilled = false; + stringId = R.array.cat_suspect_sub_location; break; case ETC: suspectEtcInput.setVisibility(View.VISIBLE); - isMandatoryCategoryFilled = false; break; case DONTKNOW: - isMandatoryCategoryFilled = true; break; } - if (position != ETC) { - suspectEtcInput.setVisibility(View.INVISIBLE); - } - - - if (!((SpinnerHintAdapter) suspectCategory.getAdapter()).isInInitialState() && stringid != 0) { - ArrayAdapter 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()) { - 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(); - incident.setFidSuspectCategory(position); } @Override public void onNothingSelected(AdapterView parentView) { - // your code here + // do nothing } }); - } - private void initSpinnerOneSub() { - suspectOriginCategory = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_3_suspect_sub); - suspectOriginCategory.setVisibility(View.INVISIBLE); - suspectOriginCategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + suspectSubCategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override 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); + checkIfFinished(); } @Override public void onNothingSelected(AdapterView parent) { - + // do nothing } }); } - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); + private void setMainSpinnerValues(int stringId) { + ArrayAdapter adapter_main_1 = ArrayAdapter.createFromResource(getActivity(),stringId, android.R.layout.simple_spinner_dropdown_item); + suspectCategory.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, getActivity())); + } - try { - mCallback = (OnInputFinishedListener) activity; - } catch (ClassCastException e) { - throw new ClassCastException(activity.toString() - + " must implement OnInputFinishedListener"); + private void setSubSpinnerValues(int stringId) { + ArrayAdapter adapter_sub_1 = ArrayAdapter.createFromResource(viewFragment.getContext(), stringId, android.R.layout.simple_spinner_dropdown_item); + suspectSubCategory.setAdapter(new SpinnerHintAdapter(adapter_sub_1, R.layout.contact_spinner_row_nothing_selected, getActivity())); + } + + 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 @@ -181,7 +170,7 @@ public class ReportWF_3_Fragment extends Fragment { if(incident != null){ 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()); } @@ -193,22 +182,28 @@ public class ReportWF_3_Fragment extends Fragment { super.onPause(); incident.setFidSuspectCategory(suspectCategory.getSelectedItemPosition()); - incident.setFidSuspectSubCategory(suspectOriginCategory.getSelectedItemPosition()); + incident.setFidSuspectSubCategory(suspectSubCategory.getSelectedItemPosition()); incident.setEtcSuspectCategory(suspectEtcInput.getText().toString()); ((ReportWFActivity)getActivity()).setIncident(incident); } + @Override + public void onAttach(Context context) { + super.onAttach(context); - - private void checkIfFinished(){ - mCallback.onInputFinished(isMandatoryCategoryFilled); + try { + mCallback = (OnInputFinishedListener) context; + } catch (ClassCastException e) { + throw new ClassCastException(context.toString() + + " must implement OnInputFinishedListener"); + } } - @Override public void onDetach() { super.onDetach(); } + } diff --git a/app/src/main/java/org/deke/risk/riskahead/fragment/ReportWF_4_Fragment.java b/app/src/main/java/org/deke/risk/riskahead/fragment/ReportWF_4_Fragment.java new file mode 100644 index 0000000..9fd2739 --- /dev/null +++ b/app/src/main/java/org/deke/risk/riskahead/fragment/ReportWF_4_Fragment.java @@ -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 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(); + } + + +} diff --git a/app/src/main/java/org/deke/risk/riskahead/helper/BaseActivity.java b/app/src/main/java/org/deke/risk/riskahead/helper/BaseActivity.java index 6a6efeb..6e76ac4 100644 --- a/app/src/main/java/org/deke/risk/riskahead/helper/BaseActivity.java +++ b/app/src/main/java/org/deke/risk/riskahead/helper/BaseActivity.java @@ -20,6 +20,7 @@ import android.util.Log; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.widget.EditText; import android.widget.Toast; import com.google.android.gms.ads.AdListener; @@ -287,9 +288,9 @@ public abstract class BaseActivity extends AppCompatActivity { } public void showAd(){ - // TODO: 03.12.2015 activate when needed 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(); + private boolean isEmpty(EditText etText) { + return etText.getText().toString().trim().length() == 0; + } + public void showDialog() { if (!pDialog.isShowing()) pDialog.show(); diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index d71f82b..476d834 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -64,7 +64,7 @@ android:background="@color/btn_login_bg" android:minWidth="120dp" android:text="@string/btn_start_login" - android:textColor="@color/btn_login" /> + android:textColor="@color/white" /> diff --git a/app/src/main/res/layout/activity_report_wf.xml b/app/src/main/res/layout/activity_report_wf.xml index 3f98ee2..b9bc853 100644 --- a/app/src/main/res/layout/activity_report_wf.xml +++ b/app/src/main/res/layout/activity_report_wf.xml @@ -17,7 +17,7 @@ android:layout_alignParentTop="true" android:layout_centerHorizontal="true" /> - - + android:layout_weight="1" + android:layout_gravity="center_horizontal" > - - - - - - - - - - - - + - + + + + + + + diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 1b03a93..cea257c 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -140,7 +140,8 @@