Merge branch 'develop' into 'master'
Firebase implemented, loggin improved and trying to avoid all kind of NPE See merge request RiskAhead/RiskAhead-Android!2
This commit is contained in:
15
.idea/misc.xml
generated
15
.idea/misc.xml
generated
@@ -1,8 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="EntryPointsManager">
|
|
||||||
<entry_points version="2.0" />
|
|
||||||
</component>
|
|
||||||
<component name="NullableNotNullManager">
|
<component name="NullableNotNullManager">
|
||||||
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
|
<option name="myDefaultNullable" value="android.support.annotation.Nullable" />
|
||||||
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
|
||||||
@@ -27,17 +24,7 @@
|
|||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
||||||
<OptionsSetting value="true" id="Add" />
|
|
||||||
<OptionsSetting value="true" id="Remove" />
|
|
||||||
<OptionsSetting value="true" id="Checkout" />
|
|
||||||
<OptionsSetting value="true" id="Update" />
|
|
||||||
<OptionsSetting value="true" id="Status" />
|
|
||||||
<OptionsSetting value="true" id="Edit" />
|
|
||||||
<ConfirmationsSetting value="0" id="Add" />
|
|
||||||
<ConfirmationsSetting value="0" id="Remove" />
|
|
||||||
</component>
|
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
|
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|||||||
13
app/app.iml
13
app/app.iml
@@ -120,8 +120,10 @@
|
|||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Android API 27 Platform" jdkType="Android SDK" />
|
<orderEntry type="jdk" jdkName="Android API 27 Platform" jdkType="Android SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="com.google.firebase:firebase-crash-11.8.0" level="project" />
|
||||||
<orderEntry type="library" name="com.android.support:appcompat-v7-27.1.0" level="project" />
|
<orderEntry type="library" name="com.android.support:appcompat-v7-27.1.0" level="project" />
|
||||||
<orderEntry type="library" name="com.google.code.gson:gson:2.8.0@jar" level="project" />
|
<orderEntry type="library" name="com.google.code.gson:gson:2.8.0@jar" level="project" />
|
||||||
|
<orderEntry type="library" name="com.google.android.gms:play-services-auth-11.8.0" level="project" />
|
||||||
<orderEntry type="library" name="com.android.support:design-27.1.0" level="project" />
|
<orderEntry type="library" name="com.android.support:design-27.1.0" level="project" />
|
||||||
<orderEntry type="library" name="com.google.firebase:firebase-iid-11.8.0" level="project" />
|
<orderEntry type="library" name="com.google.firebase:firebase-iid-11.8.0" level="project" />
|
||||||
<orderEntry type="library" name="com.google.android.gms:play-services-gcm-license-11.8.0" level="project" />
|
<orderEntry type="library" name="com.google.android.gms:play-services-gcm-license-11.8.0" level="project" />
|
||||||
@@ -138,10 +140,9 @@
|
|||||||
<orderEntry type="library" name="com.mikepenz:materialize-1.1.2" level="project" />
|
<orderEntry type="library" name="com.mikepenz:materialize-1.1.2" level="project" />
|
||||||
<orderEntry type="library" name="com.mikepenz:fastadapter-extensions-expandable-3.2.4" level="project" />
|
<orderEntry type="library" name="com.mikepenz:fastadapter-extensions-expandable-3.2.4" level="project" />
|
||||||
<orderEntry type="library" name="com.mikepenz:google-material-typeface-3.0.1.2.original" level="project" />
|
<orderEntry type="library" name="com.mikepenz:google-material-typeface-3.0.1.2.original" level="project" />
|
||||||
<orderEntry type="library" name="com.android.support:customtabs-27.0.2" level="project" />
|
|
||||||
<orderEntry type="library" name="com.google.android.gms:play-services-plus-11.8.0" level="project" />
|
<orderEntry type="library" name="com.google.android.gms:play-services-plus-11.8.0" level="project" />
|
||||||
<orderEntry type="library" name="com.google.android.gms:play-services-iid-license-11.8.0" level="project" />
|
<orderEntry type="library" name="com.google.android.gms:play-services-iid-license-11.8.0" level="project" />
|
||||||
<orderEntry type="library" name="com.android.support:cardview-v7-27.0.2" level="project" />
|
<orderEntry type="library" name="com.google.firebase:firebase-appindexing-license-11.8.0" level="project" />
|
||||||
<orderEntry type="library" name="com.twitter.sdk.android:twitter-core-1.4.1" level="project" />
|
<orderEntry type="library" name="com.twitter.sdk.android:twitter-core-1.4.1" level="project" />
|
||||||
<orderEntry type="library" name="com.google.android.gms:play-services-ads-11.8.0" level="project" />
|
<orderEntry type="library" name="com.google.android.gms:play-services-ads-11.8.0" level="project" />
|
||||||
<orderEntry type="library" name="com.google.android.gms:play-services-basement-11.8.0" level="project" />
|
<orderEntry type="library" name="com.google.android.gms:play-services-basement-11.8.0" level="project" />
|
||||||
@@ -157,6 +158,7 @@
|
|||||||
<orderEntry type="library" name="com.google.zxing:core:3.3.0@jar" level="project" />
|
<orderEntry type="library" name="com.google.zxing:core:3.3.0@jar" level="project" />
|
||||||
<orderEntry type="library" name="com.google.android.gms:play-services-ads-lite-license-11.8.0" level="project" />
|
<orderEntry type="library" name="com.google.android.gms:play-services-ads-lite-license-11.8.0" level="project" />
|
||||||
<orderEntry type="library" name="com.facebook.android:facebook-share-4.31.0" level="project" />
|
<orderEntry type="library" name="com.facebook.android:facebook-share-4.31.0" level="project" />
|
||||||
|
<orderEntry type="library" name="com.google.android.gms:play-services-auth-api-phone-license-11.8.0" level="project" />
|
||||||
<orderEntry type="library" name="com.mikepenz:fastadapter-3.2.4" level="project" />
|
<orderEntry type="library" name="com.mikepenz:fastadapter-3.2.4" level="project" />
|
||||||
<orderEntry type="library" name="com.google.android.gms:play-services-base-11.8.0" level="project" />
|
<orderEntry type="library" name="com.google.android.gms:play-services-base-11.8.0" level="project" />
|
||||||
<orderEntry type="library" name="com.google.firebase:firebase-analytics-impl-11.8.0" level="project" />
|
<orderEntry type="library" name="com.google.firebase:firebase-analytics-impl-11.8.0" level="project" />
|
||||||
@@ -168,12 +170,14 @@
|
|||||||
<orderEntry type="library" name="com.mcxiaoke.volley:library:1.0.19@jar" level="project" />
|
<orderEntry type="library" name="com.mcxiaoke.volley:library:1.0.19@jar" level="project" />
|
||||||
<orderEntry type="library" name="com.android.support:support-core-utils-27.1.0" level="project" />
|
<orderEntry type="library" name="com.android.support:support-core-utils-27.1.0" level="project" />
|
||||||
<orderEntry type="library" name="android.arch.core:common:1.1.0@jar" level="project" />
|
<orderEntry type="library" name="android.arch.core:common:1.1.0@jar" level="project" />
|
||||||
|
<orderEntry type="library" name="com.google.android.gms:play-services-auth-api-phone-11.8.0" level="project" />
|
||||||
<orderEntry type="library" name="com.android.support:support-annotations:27.1.0@jar" level="project" />
|
<orderEntry type="library" name="com.android.support:support-annotations:27.1.0@jar" level="project" />
|
||||||
<orderEntry type="library" name="com.google.android.gms:play-services-gass-license-11.8.0" level="project" />
|
<orderEntry type="library" name="com.google.android.gms:play-services-gass-license-11.8.0" level="project" />
|
||||||
<orderEntry type="library" name="com.parse.bolts:bolts-applinks:1.4.0@jar" level="project" />
|
<orderEntry type="library" name="com.parse.bolts:bolts-applinks:1.4.0@jar" level="project" />
|
||||||
<orderEntry type="library" name="com.google.android.gms:play-services-maps-license-11.8.0" level="project" />
|
<orderEntry type="library" name="com.google.android.gms:play-services-maps-license-11.8.0" level="project" />
|
||||||
<orderEntry type="library" name="com.google.firebase:firebase-analytics-11.8.0" level="project" />
|
<orderEntry type="library" name="com.google.firebase:firebase-analytics-11.8.0" level="project" />
|
||||||
<orderEntry type="library" name="com.beardedhen:androidbootstrap-2.3.2" level="project" />
|
<orderEntry type="library" name="com.beardedhen:androidbootstrap-2.3.2" level="project" />
|
||||||
|
<orderEntry type="library" name="com.android.support:customtabs-27.1.0" level="project" />
|
||||||
<orderEntry type="library" name="com.google.android.gms:play-services-ads-license-11.8.0" level="project" />
|
<orderEntry type="library" name="com.google.android.gms:play-services-ads-license-11.8.0" level="project" />
|
||||||
<orderEntry type="library" name="com.facebook.android:facebook-android-sdk-4.31.0" level="project" />
|
<orderEntry type="library" name="com.facebook.android:facebook-android-sdk-4.31.0" level="project" />
|
||||||
<orderEntry type="library" name="com.facebook.android:facebook-places-4.31.0" level="project" />
|
<orderEntry type="library" name="com.facebook.android:facebook-places-4.31.0" level="project" />
|
||||||
@@ -181,15 +185,20 @@
|
|||||||
<orderEntry type="library" name="com.android.support:support-vector-drawable-27.1.0" level="project" />
|
<orderEntry type="library" name="com.android.support:support-vector-drawable-27.1.0" level="project" />
|
||||||
<orderEntry type="library" name="com.facebook.android:facebook-login-4.31.0" level="project" />
|
<orderEntry type="library" name="com.facebook.android:facebook-login-4.31.0" level="project" />
|
||||||
<orderEntry type="library" name="android.arch.lifecycle:common:1.1.0@jar" level="project" />
|
<orderEntry type="library" name="android.arch.lifecycle:common:1.1.0@jar" level="project" />
|
||||||
|
<orderEntry type="library" name="com.android.support:cardview-v7-27.1.0" level="project" />
|
||||||
<orderEntry type="library" name="com.google.android.gms:play-services-maps-11.8.0" level="project" />
|
<orderEntry type="library" name="com.google.android.gms:play-services-maps-11.8.0" level="project" />
|
||||||
<orderEntry type="library" name="com.parse.bolts:bolts-android:1.4.0@jar" level="project" />
|
<orderEntry type="library" name="com.parse.bolts:bolts-android:1.4.0@jar" level="project" />
|
||||||
<orderEntry type="library" name="com.android.support:support-compat-27.1.0" level="project" />
|
<orderEntry type="library" name="com.android.support:support-compat-27.1.0" level="project" />
|
||||||
<orderEntry type="library" name="com.android.support:support-core-ui-27.1.0" level="project" />
|
<orderEntry type="library" name="com.android.support:support-core-ui-27.1.0" level="project" />
|
||||||
|
<orderEntry type="library" name="com.google.android.gms:play-services-auth-base-11.8.0" level="project" />
|
||||||
|
<orderEntry type="library" name="com.google.android.gms:play-services-auth-base-license-11.8.0" level="project" />
|
||||||
<orderEntry type="library" name="android.arch.lifecycle:livedata-core-1.1.0" level="project" />
|
<orderEntry type="library" name="android.arch.lifecycle:livedata-core-1.1.0" level="project" />
|
||||||
<orderEntry type="library" name="com.google.android.gms:play-services-location-11.8.0" level="project" />
|
<orderEntry type="library" name="com.google.android.gms:play-services-location-11.8.0" level="project" />
|
||||||
<orderEntry type="library" name="com.android.support:support-media-compat-27.1.0" level="project" />
|
<orderEntry type="library" name="com.android.support:support-media-compat-27.1.0" level="project" />
|
||||||
|
<orderEntry type="library" name="com.google.firebase:firebase-crash-license-11.8.0" level="project" />
|
||||||
<orderEntry type="library" name="com.google.android.gms:play-services-gass-11.8.0" level="project" />
|
<orderEntry type="library" name="com.google.android.gms:play-services-gass-11.8.0" level="project" />
|
||||||
<orderEntry type="library" name="com.android.support:support-fragment-27.1.0" level="project" />
|
<orderEntry type="library" name="com.android.support:support-fragment-27.1.0" level="project" />
|
||||||
|
<orderEntry type="library" name="com.google.firebase:firebase-appindexing-11.8.0" level="project" />
|
||||||
<orderEntry type="library" name="com.google.android.gms:play-services-gcm-11.8.0" level="project" />
|
<orderEntry type="library" name="com.google.android.gms:play-services-gcm-11.8.0" level="project" />
|
||||||
<orderEntry type="library" name="com.google.maps.android:android-maps-utils-0.5" level="project" />
|
<orderEntry type="library" name="com.google.maps.android:android-maps-utils-0.5" level="project" />
|
||||||
<orderEntry type="library" name="com.google.firebase:firebase-analytics-license-11.8.0" level="project" />
|
<orderEntry type="library" name="com.google.firebase:firebase-analytics-license-11.8.0" level="project" />
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ android {
|
|||||||
applicationId "org.deke.risk.riskahead"
|
applicationId "org.deke.risk.riskahead"
|
||||||
minSdkVersion 15
|
minSdkVersion 15
|
||||||
targetSdkVersion 25
|
targetSdkVersion 25
|
||||||
versionCode 43
|
versionCode 44
|
||||||
versionName "3.1"
|
versionName "3.1.1"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
@@ -35,6 +35,9 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation 'com.google.firebase:firebase-crash:11.8.0'
|
||||||
|
implementation 'com.google.firebase:firebase-core:11.8.0'
|
||||||
|
implementation 'com.google.firebase:firebase-appindexing:11.8.0'
|
||||||
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
|
compile fileTree(dir: 'libs', include: 'Parse-*.jar')
|
||||||
implementation 'com.facebook.android:facebook-android-sdk:4.31.0'
|
implementation 'com.facebook.android:facebook-android-sdk:4.31.0'
|
||||||
compile('com.twitter.sdk.android:twitter-core:1.4.1@aar') {
|
compile('com.twitter.sdk.android:twitter-core:1.4.1@aar') {
|
||||||
@@ -48,10 +51,13 @@ dependencies {
|
|||||||
transitive = true
|
transitive = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
implementation 'com.android.support:customtabs:27.1.0'
|
||||||
|
implementation 'com.android.support:cardview-v7:27.1.0'
|
||||||
compile 'com.android.support:appcompat-v7:27.1.0'
|
compile 'com.android.support:appcompat-v7:27.1.0'
|
||||||
compile 'com.android.support:support-v4:27.1.0'
|
compile 'com.android.support:support-v4:27.1.0'
|
||||||
compile 'com.android.support:design:27.1.0'
|
compile 'com.android.support:design:27.1.0'
|
||||||
|
|
||||||
|
compile 'com.google.android.gms:play-services-auth:11.8.0'
|
||||||
compile 'com.google.android.gms:play-services-gcm:11.8.0'
|
compile 'com.google.android.gms:play-services-gcm:11.8.0'
|
||||||
compile 'com.google.android.gms:play-services-plus:11.8.0'
|
compile 'com.google.android.gms:play-services-plus:11.8.0'
|
||||||
compile 'com.google.android.gms:play-services-location:11.8.0'
|
compile 'com.google.android.gms:play-services-location:11.8.0'
|
||||||
|
|||||||
Binary file not shown.
@@ -1 +1 @@
|
|||||||
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":43},"path":"app-release.apk","properties":{"packageId":"org.deke.risk.riskahead","split":"","minSdkVersion":"15"}}]
|
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":44},"path":"app-release.apk","properties":{"packageId":"org.deke.risk.riskahead","split":"","minSdkVersion":"15"}}]
|
||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
<uses-permission android:name="org.deke.risk.riskahead.permission.MAPS_RECEIVE" />
|
<uses-permission android:name="org.deke.risk.riskahead.permission.MAPS_RECEIVE" />
|
||||||
@@ -30,6 +29,9 @@
|
|||||||
android:theme="@style/MyRiskAheadTheme">
|
android:theme="@style/MyRiskAheadTheme">
|
||||||
|
|
||||||
<!-- Google Maps Fragment API Key Data -->
|
<!-- Google Maps Fragment API Key Data -->
|
||||||
|
<meta-data
|
||||||
|
android:name="asset_statements"
|
||||||
|
android:resource="@string/asset_statements" />
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.google.android.gms.version"
|
android:name="com.google.android.gms.version"
|
||||||
android:value="@integer/google_play_services_version" />
|
android:value="@integer/google_play_services_version" />
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ import com.android.volley.Response;
|
|||||||
import com.android.volley.VolleyError;
|
import com.android.volley.VolleyError;
|
||||||
import com.android.volley.toolbox.StringRequest;
|
import com.android.volley.toolbox.StringRequest;
|
||||||
import com.beardedhen.androidbootstrap.BootstrapButton;
|
import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -56,7 +57,6 @@ import java.util.Map;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class LoginActivity extends AppCompatActivity implements FacebookButtonFragment.OnFragmentInteractionListener, GooglePlusButtonFragment.OnFragmentInteractionListener, TwitterButtonFragment.OnFragmentInteractionListener{
|
public class LoginActivity extends AppCompatActivity implements FacebookButtonFragment.OnFragmentInteractionListener, GooglePlusButtonFragment.OnFragmentInteractionListener, TwitterButtonFragment.OnFragmentInteractionListener{
|
||||||
|
|
||||||
private final static String TAG = LoginActivity.class.getSimpleName();
|
private final static String TAG = LoginActivity.class.getSimpleName();
|
||||||
|
|
||||||
private TextView input_email;
|
private TextView input_email;
|
||||||
@@ -99,8 +99,15 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void isNetworkAvailable() {
|
public void isNetworkAvailable() {
|
||||||
|
NetworkInfo activeNetworkInfo = null;
|
||||||
|
|
||||||
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
|
if(connectivityManager != null){
|
||||||
|
activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get connectivityManager");
|
||||||
|
}
|
||||||
|
|
||||||
if(activeNetworkInfo == null){
|
if(activeNetworkInfo == null){
|
||||||
new AlertDialog.Builder(this)
|
new AlertDialog.Builder(this)
|
||||||
.setTitle(getString(R.string.alert_internetconnection_title))
|
.setTitle(getString(R.string.alert_internetconnection_title))
|
||||||
@@ -136,15 +143,15 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
private void initLoginView() {
|
private void initLoginView() {
|
||||||
setContentView(R.layout.activity_login);
|
setContentView(R.layout.activity_login);
|
||||||
|
|
||||||
input_email = (TextView) findViewById(R.id.input_register_email);
|
input_email = findViewById(R.id.input_register_email);
|
||||||
inputLayoutEmail = (TextInputLayout) findViewById(R.id.input_layout_email);
|
inputLayoutEmail = findViewById(R.id.input_layout_email);
|
||||||
|
|
||||||
input_password = (TextView) findViewById(R.id.input_register_password);
|
input_password = findViewById(R.id.input_register_password);
|
||||||
inputLayoutPassword = (TextInputLayout) findViewById(R.id.input_layout_password);
|
inputLayoutPassword = findViewById(R.id.input_layout_password);
|
||||||
|
|
||||||
TextView btn_requestPW = (TextView) findViewById(R.id.lbl_login_resendPW);
|
TextView btn_requestPW = findViewById(R.id.lbl_login_resendPW);
|
||||||
|
|
||||||
BootstrapButton btn_gotoregistration = (BootstrapButton) findViewById(R.id.btn_switchtoregistration);
|
BootstrapButton btn_gotoregistration = findViewById(R.id.btn_switchtoregistration);
|
||||||
btn_gotoregistration.setOnClickListener(new View.OnClickListener() {
|
btn_gotoregistration.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@@ -152,7 +159,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
BootstrapButton btn_login = (BootstrapButton) findViewById(R.id.btn_login);
|
BootstrapButton btn_login = findViewById(R.id.btn_login);
|
||||||
btn_login.setOnClickListener(new View.OnClickListener() {
|
btn_login.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@@ -202,14 +209,14 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
private void initRegisterView() {
|
private void initRegisterView() {
|
||||||
setContentView(R.layout.activity_register);
|
setContentView(R.layout.activity_register);
|
||||||
|
|
||||||
input_username = (TextView) findViewById(R.id.input_register_name);
|
input_username = findViewById(R.id.input_register_name);
|
||||||
final TextInputLayout inputLayoutUsername = (TextInputLayout) findViewById(R.id.input_layout_username);
|
final TextInputLayout inputLayoutUsername = findViewById(R.id.input_layout_username);
|
||||||
input_email = (TextView) findViewById(R.id.input_register_email);
|
input_email = findViewById(R.id.input_register_email);
|
||||||
final TextInputLayout inputLayoutEmail = (TextInputLayout) findViewById(R.id.input_layout_email);
|
final TextInputLayout inputLayoutEmail = findViewById(R.id.input_layout_email);
|
||||||
input_password = (TextView) findViewById(R.id.input_register_password);
|
input_password = findViewById(R.id.input_register_password);
|
||||||
final TextInputLayout inputLayoutPassword = (TextInputLayout) findViewById(R.id.input_layout_password);
|
final TextInputLayout inputLayoutPassword = findViewById(R.id.input_layout_password);
|
||||||
BootstrapButton btn_login = (BootstrapButton) findViewById(R.id.btn_register);
|
BootstrapButton btn_login = findViewById(R.id.btn_register);
|
||||||
TextView btn_switchtologin = (TextView) findViewById(R.id.lbl_register_switchtologin);
|
TextView btn_switchtologin = findViewById(R.id.lbl_register_switchtologin);
|
||||||
|
|
||||||
input_username.addTextChangedListener(new TextValidator(input_username, inputLayoutUsername, getApplicationContext()) {
|
input_username.addTextChangedListener(new TextValidator(input_username, inputLayoutUsername, getApplicationContext()) {
|
||||||
@Override
|
@Override
|
||||||
@@ -302,7 +309,8 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new Response.ErrorListener() {
|
}, new Response.ErrorListener() {
|
||||||
@@ -357,7 +365,8 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new Response.ErrorListener() {
|
}, new Response.ErrorListener() {
|
||||||
@@ -375,7 +384,8 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
try {
|
try {
|
||||||
versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
|
versionCode = getPackageManager().getPackageInfo(getPackageName(), 0).versionCode;
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
params.put("version", Integer.toString(versionCode));
|
params.put("version", Integer.toString(versionCode));
|
||||||
@@ -549,11 +559,12 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
finish();
|
finish();
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error at social media login (Server returned error): " + errorMsg);
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error at social media login (Server returned error): " + errorMsg);
|
||||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.txt_errormsg_login)+getResources().getString(R.string.txt_errormsg_suffix), Toast.LENGTH_LONG).show();
|
Toast.makeText(getApplicationContext(), getResources().getString(R.string.txt_errormsg_login)+getResources().getString(R.string.txt_errormsg_suffix), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -561,7 +572,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "Social Media Login Error: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Social Media Login Error: " + error.getMessage());
|
||||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.txt_errormsg_login)+getResources().getString(R.string.txt_errormsg_suffix), Toast.LENGTH_LONG).show();
|
Toast.makeText(getApplicationContext(), getResources().getString(R.string.txt_errormsg_login)+getResources().getString(R.string.txt_errormsg_suffix), Toast.LENGTH_LONG).show();
|
||||||
hideDialog();
|
hideDialog();
|
||||||
}
|
}
|
||||||
@@ -655,18 +666,19 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error at login (Server returned error): " + errorMsg);
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error at login (Server returned error): " + errorMsg);
|
||||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.txt_errormsg_login), Toast.LENGTH_LONG).show();
|
Toast.makeText(getApplicationContext(), getResources().getString(R.string.txt_errormsg_login), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new Response.ErrorListener() {
|
}, new Response.ErrorListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "Login Error: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Login Error: " + error.getMessage());
|
||||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.txt_errormsg_login), Toast.LENGTH_LONG).show();
|
Toast.makeText(getApplicationContext(), getResources().getString(R.string.txt_errormsg_login), Toast.LENGTH_LONG).show();
|
||||||
hideDialog();
|
hideDialog();
|
||||||
}
|
}
|
||||||
@@ -706,18 +718,19 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error occured: "+errorMsg);
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error occured: "+errorMsg);
|
||||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.txt_errormsg_register), Toast.LENGTH_LONG).show();
|
Toast.makeText(getApplicationContext(), getResources().getString(R.string.txt_errormsg_register), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Exception caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new Response.ErrorListener() {
|
}, new Response.ErrorListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "Registration Error: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Registration Error: " + error.getMessage());
|
||||||
Toast.makeText(getApplicationContext(),
|
Toast.makeText(getApplicationContext(),
|
||||||
getResources().getString(R.string.txt_errormsg_register), Toast.LENGTH_LONG).show();
|
getResources().getString(R.string.txt_errormsg_register), Toast.LENGTH_LONG).show();
|
||||||
hideDialog();
|
hideDialog();
|
||||||
@@ -755,18 +768,19 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error occured: "+errorMsg);
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error occured: "+errorMsg);
|
||||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.txt_errormsg_register), Toast.LENGTH_LONG).show();
|
Toast.makeText(getApplicationContext(), getResources().getString(R.string.txt_errormsg_register), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new Response.ErrorListener() {
|
}, new Response.ErrorListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "Registration Error: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Registration Error: " + error.getMessage());
|
||||||
Toast.makeText(getApplicationContext(),
|
Toast.makeText(getApplicationContext(),
|
||||||
getResources().getString(R.string.txt_errormsg_register), Toast.LENGTH_LONG).show();
|
getResources().getString(R.string.txt_errormsg_register), Toast.LENGTH_LONG).show();
|
||||||
hideDialog();
|
hideDialog();
|
||||||
@@ -919,12 +933,13 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
showMessage(getString(R.string.alert_passwordreset_confirmation));
|
showMessage(getString(R.string.alert_passwordreset_confirmation));
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Reset PW returned error value: "+errorMsg);
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Reset PW returned error value: "+errorMsg);
|
||||||
Toast.makeText(getApplicationContext(),
|
Toast.makeText(getApplicationContext(),
|
||||||
getResources().getString(R.string.txt_errormsg_getpwreset), Toast.LENGTH_LONG).show();
|
getResources().getString(R.string.txt_errormsg_getpwreset), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -932,7 +947,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "E-Mail pw resend Error: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "E-Mail pw resend Error: " + error.getMessage());
|
||||||
Toast.makeText(getApplicationContext(),
|
Toast.makeText(getApplicationContext(),
|
||||||
getResources().getString(R.string.txt_errormsg_getpwreset), Toast.LENGTH_LONG).show();
|
getResources().getString(R.string.txt_errormsg_getpwreset), Toast.LENGTH_LONG).show();
|
||||||
hideDialog();
|
hideDialog();
|
||||||
@@ -962,12 +977,13 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
boolean error = jObj.getBoolean("error");
|
boolean error = jObj.getBoolean("error");
|
||||||
if (error) {
|
if (error) {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG,"Resend E-Mail returned error value: "+errorMsg);
|
FirebaseCrash.logcat(Log.ERROR, TAG,"Resend E-Mail returned error value: "+errorMsg);
|
||||||
Toast.makeText(getApplicationContext(),
|
Toast.makeText(getApplicationContext(),
|
||||||
getResources().getString(R.string.txt_errormsg_getactivationlink) + ":"+errorMsg, Toast.LENGTH_LONG).show();
|
getResources().getString(R.string.txt_errormsg_getactivationlink) + ":"+errorMsg, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -975,7 +991,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "E-Mail pw resend error: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "E-Mail pw resend error: " + error.getMessage());
|
||||||
Toast.makeText(getApplicationContext(),
|
Toast.makeText(getApplicationContext(),
|
||||||
getResources().getString(R.string.txt_errormsg_getactivationlink), Toast.LENGTH_LONG).show();
|
getResources().getString(R.string.txt_errormsg_getactivationlink), Toast.LENGTH_LONG).show();
|
||||||
hideDialog();
|
hideDialog();
|
||||||
@@ -1021,18 +1037,19 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
.show();
|
.show();
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error occured: "+errorMsg);
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error occured: "+errorMsg);
|
||||||
Toast.makeText(getApplicationContext(), getResources().getString(R.string.txt_errormsg_register), Toast.LENGTH_LONG).show();
|
Toast.makeText(getApplicationContext(), getResources().getString(R.string.txt_errormsg_register), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new Response.ErrorListener() {
|
}, new Response.ErrorListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "Registration Error: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Registration Error: " + error.getMessage());
|
||||||
Toast.makeText(getApplicationContext(),
|
Toast.makeText(getApplicationContext(),
|
||||||
getResources().getString(R.string.txt_errormsg_register), Toast.LENGTH_LONG).show();
|
getResources().getString(R.string.txt_errormsg_register), Toast.LENGTH_LONG).show();
|
||||||
hideDialog();
|
hideDialog();
|
||||||
@@ -1098,7 +1115,7 @@ public class LoginActivity extends AppCompatActivity implements FacebookButtonFr
|
|||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
Log.d(TAG, "testest");
|
||||||
if (requestCode == GooglePlusButtonFragment.RC_SIGN_IN) {
|
if (requestCode == GooglePlusButtonFragment.RC_SIGN_IN) {
|
||||||
GooglePlusButtonFragment fragment = (GooglePlusButtonFragment) getSupportFragmentManager().findFragmentById(R.id.frag_login_btnGP);
|
GooglePlusButtonFragment fragment = (GooglePlusButtonFragment) getSupportFragmentManager().findFragmentById(R.id.frag_login_btnGP);
|
||||||
fragment.onActivityResult(requestCode, resultCode, data);
|
fragment.onActivityResult(requestCode, resultCode, data);
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ import com.google.android.gms.maps.model.Marker;
|
|||||||
import com.google.android.gms.maps.model.MarkerOptions;
|
import com.google.android.gms.maps.model.MarkerOptions;
|
||||||
import com.google.android.gms.maps.model.TileOverlay;
|
import com.google.android.gms.maps.model.TileOverlay;
|
||||||
import com.google.android.gms.maps.model.TileOverlayOptions;
|
import com.google.android.gms.maps.model.TileOverlayOptions;
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
import com.google.maps.android.clustering.Cluster;
|
import com.google.maps.android.clustering.Cluster;
|
||||||
import com.google.maps.android.clustering.ClusterManager;
|
import com.google.maps.android.clustering.ClusterManager;
|
||||||
import com.google.maps.android.heatmaps.HeatmapTileProvider;
|
import com.google.maps.android.heatmaps.HeatmapTileProvider;
|
||||||
@@ -215,7 +216,7 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(point, DEFAULT_ZOOM_LEVEL));
|
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(point, DEFAULT_ZOOM_LEVEL));
|
||||||
}
|
}
|
||||||
|
|
||||||
addButton = (FloatingActionButton) findViewById(R.id.fab_reportwf_map);
|
addButton = findViewById(R.id.fab_reportwf_map);
|
||||||
addButton.setVisibility(View.VISIBLE);
|
addButton.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
if (getIntent().hasExtra(AppConfig.EXTRA_MAP_TYPE)) {
|
if (getIntent().hasExtra(AppConfig.EXTRA_MAP_TYPE)) {
|
||||||
@@ -375,7 +376,8 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
try {
|
try {
|
||||||
mClusterManager.addItem(new IncidentReport(incidents.getJSONObject(i)));
|
mClusterManager.addItem(new IncidentReport(incidents.getJSONObject(i)));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -397,7 +399,8 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
try {
|
try {
|
||||||
heatMapPositions.add(new WeightedLatLng(new LatLng(incidents.getJSONObject(i).getDouble("latitude"), incidents.getJSONObject(i).getDouble("longitude")), 1.0));
|
heatMapPositions.add(new WeightedLatLng(new LatLng(incidents.getJSONObject(i).getDouble("latitude"), incidents.getJSONObject(i).getDouble("longitude")), 1.0));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -432,10 +435,11 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
addIncidentMarkersOnHeatMap(incidents);
|
addIncidentMarkersOnHeatMap(incidents);
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error getting map heat map positions (server returned error): " + errorMsg);
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error getting map heat map positions (server returned error): " + errorMsg);
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -443,7 +447,7 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
hideProgress();
|
hideProgress();
|
||||||
Log.e(TAG, "Error getting map positions: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error getting map positions: " + error.getMessage());
|
||||||
handleVolleyErrorResponse();
|
handleVolleyErrorResponse();
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
@@ -479,10 +483,11 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
addIncidentMarkersOnMap(incidents);
|
addIncidentMarkersOnMap(incidents);
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error getting map positions (server returned error): " + errorMsg);
|
FirebaseCrash.logcat(Log.INFO, TAG, "Error getting map positions (server returned error): " + errorMsg);
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -490,7 +495,7 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
hideProgress();
|
hideProgress();
|
||||||
Log.e(TAG, "Error getting map positions: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error getting map positions: " + error.getMessage());
|
||||||
showMessage(getString(R.string.errormsg_couldnotretrieve));
|
showMessage(getString(R.string.errormsg_couldnotretrieve));
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
@@ -558,8 +563,8 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
JSONObject incident = jObj.getJSONObject("msg");
|
JSONObject incident = jObj.getJSONObject("msg");
|
||||||
clickedClusterItem = new IncidentReport(incident);
|
clickedClusterItem = new IncidentReport(incident);
|
||||||
|
|
||||||
TextView tvUsername = ((TextView) infoView.findViewById(R.id.txt_infowindow_fromuser));
|
TextView tvUsername = infoView.findViewById(R.id.txt_infowindow_fromuser);
|
||||||
RatingBar rbScore = ((RatingBar) infoView.findViewById(R.id.rb_infowindow_rating));
|
RatingBar rbScore = infoView.findViewById(R.id.rb_infowindow_rating);
|
||||||
|
|
||||||
tvUsername.setText(String.format("%s %s", getString(R.string.lbl_mapsinfowindow_author), clickedClusterItem.getFromUsername()));
|
tvUsername.setText(String.format("%s %s", getString(R.string.lbl_mapsinfowindow_author), clickedClusterItem.getFromUsername()));
|
||||||
rbScore.setRating(clickedClusterItem.getScoreStars());
|
rbScore.setRating(clickedClusterItem.getScoreStars());
|
||||||
@@ -574,7 +579,8 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
showMessage(getResources().getString(R.string.txt_errormsg_getinfowindow));
|
showMessage(getResources().getString(R.string.txt_errormsg_getinfowindow));
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -582,7 +588,7 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
hideProgress();
|
hideProgress();
|
||||||
Log.e(TAG, "Error getting incident details: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error getting incident details: " + error.getMessage());
|
||||||
handleVolleyErrorResponse();
|
handleVolleyErrorResponse();
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
@@ -614,13 +620,13 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
@Override
|
@Override
|
||||||
public View getInfoWindow(Marker marker) {
|
public View getInfoWindow(Marker marker) {
|
||||||
markerShowingInfoWindow = marker;
|
markerShowingInfoWindow = marker;
|
||||||
LinearLayout layCategoryColor = ((LinearLayout) myContentsView.findViewById(R.id.lay_infowindow_color));
|
LinearLayout layCategoryColor = myContentsView.findViewById(R.id.lay_infowindow_color);
|
||||||
|
|
||||||
TextView tvCategory = ((TextView) myContentsView.findViewById(R.id.txt_infowindow_category));
|
TextView tvCategory = myContentsView.findViewById(R.id.txt_infowindow_category);
|
||||||
TextView tvSubcategory = ((TextView) myContentsView.findViewById(R.id.txt_infowindow_subcategory));
|
TextView tvSubcategory = myContentsView.findViewById(R.id.txt_infowindow_subcategory);
|
||||||
TextView tvVictim = ((TextView) myContentsView.findViewById(R.id.txt_infowindow_victim));
|
TextView tvVictim = myContentsView.findViewById(R.id.txt_infowindow_victim);
|
||||||
TextView tvSuspect = ((TextView) myContentsView.findViewById(R.id.txt_infowindow_subject));
|
TextView tvSuspect = myContentsView.findViewById(R.id.txt_infowindow_subject);
|
||||||
TextView tvTime = ((TextView) myContentsView.findViewById(R.id.txt_infowindow_time));
|
TextView tvTime = myContentsView.findViewById(R.id.txt_infowindow_time);
|
||||||
|
|
||||||
|
|
||||||
if (clickedClusterItem != null) {
|
if (clickedClusterItem != null) {
|
||||||
@@ -731,13 +737,14 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Loader<Cursor> onCreateLoader(int arg0, Bundle query) {
|
public Loader<Cursor> onCreateLoader(int arg0, Bundle query) {
|
||||||
CursorLoader cLoader = null;
|
CursorLoader cLoader;
|
||||||
|
|
||||||
if (arg0 == 0)
|
if (arg0 == 0)
|
||||||
cLoader = new CursorLoader(getBaseContext(), PlaceProvider.SEARCH_URI, null, null, new String[]{query.getString("query")}, null);
|
cLoader = new CursorLoader(getBaseContext(), PlaceProvider.SEARCH_URI, null, null, new String[]{query.getString("query")}, null);
|
||||||
else if (arg0 == 1)
|
else //if (arg0 == 1)
|
||||||
cLoader = new CursorLoader(getBaseContext(), PlaceProvider.DETAILS_URI, null, null, new String[]{query.getString("query")}, null);
|
cLoader = new CursorLoader(getBaseContext(), PlaceProvider.DETAILS_URI, null, null, new String[]{query.getString("query")}, null);
|
||||||
return cLoader;
|
|
||||||
|
|
||||||
|
return cLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MyLocationListener implements LocationListener {
|
private class MyLocationListener implements LocationListener {
|
||||||
@@ -827,9 +834,9 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
mMap.moveCamera(CameraUpdateFactory.newLatLng(myLocation));
|
mMap.moveCamera(CameraUpdateFactory.newLatLng(myLocation));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Exception caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -859,14 +866,18 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
getMenuInflater().inflate(R.menu.menu_common, menu);
|
getMenuInflater().inflate(R.menu.menu_common, menu);
|
||||||
|
|
||||||
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
|
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
|
||||||
SearchView searchView = (SearchView) menu.findItem(R.id.location_search).getActionView();
|
if(searchManager != null){
|
||||||
SearchableInfo searchInfo = searchManager.getSearchableInfo(getComponentName());
|
SearchableInfo searchInfo = searchManager.getSearchableInfo(getComponentName());
|
||||||
searchView.setSearchableInfo(searchInfo);
|
SearchView searchView = (SearchView) menu.findItem(R.id.location_search).getActionView();
|
||||||
|
searchView.setSearchableInfo(searchInfo);
|
||||||
|
|
||||||
EditText txtSearch = ((EditText) searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text));
|
EditText txtSearch = searchView.findViewById(android.support.v7.appcompat.R.id.search_src_text);
|
||||||
txtSearch.setHint(getResources().getString(R.string.search_hint));
|
txtSearch.setHint(getResources().getString(R.string.search_hint));
|
||||||
txtSearch.setHintTextColor(Color.DKGRAY);
|
txtSearch.setHintTextColor(Color.DKGRAY);
|
||||||
txtSearch.setTextColor(Color.BLACK);
|
txtSearch.setTextColor(Color.BLACK);
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get searchManager");
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -874,15 +885,14 @@ public class MapsActivity extends BaseActivity implements LoaderManager.LoaderCa
|
|||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
Log.d(TAG,"onPause executed: LM: "+(locationManager != null)+" LL: "+(locationListener!=null));
|
Log.d(TAG,"onPause executed: LM: "+(locationManager != null)+" LL: "+(locationListener!=null));
|
||||||
|
|
||||||
if(locationManager != null && locationListener != null) {
|
if(locationManager != null && locationListener != null) {
|
||||||
locationManager.removeUpdates(locationListener);
|
locationManager.removeUpdates(locationListener);
|
||||||
locationListener = null;
|
locationListener = null;
|
||||||
locationManager = null;
|
locationManager = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
|
||||||
if (showAdd) showAd();
|
if (showAdd) showAd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class ProfileActivity extends BaseActivity{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initProfileFromUserID(String userId) {
|
private void initProfileFromUserID(String userId) {
|
||||||
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
|
TabLayout tabLayout = findViewById(R.id.tab_layout);
|
||||||
|
|
||||||
tabLayout.addTab(tabLayout.newTab().setText(getResources().getString(R.string.lbl_profile_stats)));
|
tabLayout.addTab(tabLayout.newTab().setText(getResources().getString(R.string.lbl_profile_stats)));
|
||||||
tabLayout.addTab(tabLayout.newTab().setText(getResources().getString(R.string.lbl_profile_reports)));
|
tabLayout.addTab(tabLayout.newTab().setText(getResources().getString(R.string.lbl_profile_reports)));
|
||||||
@@ -52,7 +52,7 @@ public class ProfileActivity extends BaseActivity{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initOwnProfileView() {
|
private void initOwnProfileView() {
|
||||||
TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);
|
TabLayout tabLayout = findViewById(R.id.tab_layout);
|
||||||
|
|
||||||
tabLayout.addTab(tabLayout.newTab().setText(getResources().getString(R.string.lbl_profile_stats)));
|
tabLayout.addTab(tabLayout.newTab().setText(getResources().getString(R.string.lbl_profile_stats)));
|
||||||
tabLayout.addTab(tabLayout.newTab().setText(getResources().getString(R.string.lbl_profile_top10)));
|
tabLayout.addTab(tabLayout.newTab().setText(getResources().getString(R.string.lbl_profile_top10)));
|
||||||
@@ -64,12 +64,12 @@ public class ProfileActivity extends BaseActivity{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initViewPager(TabLayout tabLayout, String userId) {
|
private void initViewPager(TabLayout tabLayout, String userId) {
|
||||||
final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
|
final ViewPager viewPager = findViewById(R.id.pager);
|
||||||
final PagerAdapter adapter = new ProfilePagerAdapter(getSupportFragmentManager(), tabLayout.getTabCount(), userId);
|
final PagerAdapter adapter = new ProfilePagerAdapter(getSupportFragmentManager(), tabLayout.getTabCount(), userId);
|
||||||
|
|
||||||
viewPager.setAdapter(adapter);
|
viewPager.setAdapter(adapter);
|
||||||
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
|
||||||
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onTabSelected(TabLayout.Tab tab) {
|
public void onTabSelected(TabLayout.Tab tab) {
|
||||||
viewPager.setCurrentItem(tab.getPosition());
|
viewPager.setCurrentItem(tab.getPosition());
|
||||||
@@ -101,6 +101,4 @@ public class ProfileActivity extends BaseActivity{
|
|||||||
return getResources().getString(R.string.title_activity_user_config);
|
return getResources().getString(R.string.title_activity_user_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import android.view.Menu;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import com.android.volley.Request;
|
import com.android.volley.Request;
|
||||||
import com.android.volley.Response;
|
import com.android.volley.Response;
|
||||||
@@ -29,6 +30,7 @@ import com.android.volley.toolbox.StringRequest;
|
|||||||
import com.beardedhen.androidbootstrap.BootstrapButton;
|
import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||||
import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand;
|
import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand;
|
||||||
import com.google.android.gms.maps.model.LatLng;
|
import com.google.android.gms.maps.model.LatLng;
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
import org.deke.risk.riskahead.fragment.BaseReportWFFragment;
|
import org.deke.risk.riskahead.fragment.BaseReportWFFragment;
|
||||||
@@ -120,7 +122,7 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initButtonsAndElements() {
|
private void initButtonsAndElements() {
|
||||||
btnContinue = (BootstrapButton) findViewById(R.id.btn_reportwf_next);
|
btnContinue = findViewById(R.id.btn_reportwf_next);
|
||||||
btnContinue.setEnabled(false);
|
btnContinue.setEnabled(false);
|
||||||
btnContinue.setOnClickListener(new View.OnClickListener() {
|
btnContinue.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -130,7 +132,7 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
btnReportNow = (BootstrapButton) findViewById(R.id.btn_reportwf_reportnow);
|
btnReportNow = findViewById(R.id.btn_reportwf_reportnow);
|
||||||
btnReportNow.setEnabled(false);
|
btnReportNow.setEnabled(false);
|
||||||
btnReportNow.setOnClickListener(new View.OnClickListener() {
|
btnReportNow.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -140,9 +142,9 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
siteIndicator = (TextView) findViewById(R.id.lbl_reportwf_site);
|
siteIndicator = findViewById(R.id.lbl_reportwf_site);
|
||||||
|
|
||||||
btnMap = (FloatingActionButton) findViewById(R.id.fab_reportwf_map);
|
btnMap = findViewById(R.id.fab_reportwf_map);
|
||||||
btnMap.setOnClickListener(new View.OnClickListener() {
|
btnMap.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@@ -213,7 +215,8 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
incident.setIncidentPositionDescription("Latitude: " + latlngpos.latitude + "\nLongitude: " + latlngpos.longitude);
|
incident.setIncidentPositionDescription("Latitude: " + latlngpos.latitude + "\nLongitude: " + latlngpos.longitude);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -328,11 +331,12 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
|||||||
showShareDialog(incident);
|
showShareDialog(incident);
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error adding incident (Server returned error): " + errorMsg);
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error adding incident (Server returned error): " + errorMsg);
|
||||||
showMessage(getResources().getString(R.string.txt_errormsg_createincident));
|
showMessage(getResources().getString(R.string.txt_errormsg_createincident));
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
hideDialog();
|
hideDialog();
|
||||||
@@ -340,7 +344,7 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
|||||||
}, new Response.ErrorListener() {
|
}, new Response.ErrorListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "Error adding incident: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error adding incident: " + error.getMessage());
|
||||||
handleVolleyErrorResponse();
|
handleVolleyErrorResponse();
|
||||||
hideDialog();
|
hideDialog();
|
||||||
}
|
}
|
||||||
@@ -390,7 +394,7 @@ public class ReportWFActivity extends BaseActivity implements ReportWF_1_Fragmen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
|
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case MY_PERMISSIONS_REQUEST_STORAGE: {
|
case MY_PERMISSIONS_REQUEST_STORAGE: {
|
||||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||||
|
|||||||
@@ -14,10 +14,8 @@ import org.deke.risk.riskahead.helper.BaseActivity;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SettingsActivity extends BaseActivity {
|
public class SettingsActivity extends BaseActivity {
|
||||||
|
|
||||||
private final static String TAG = SettingsActivity.class.getSimpleName();
|
private final static String TAG = SettingsActivity.class.getSimpleName();
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -27,8 +25,6 @@ public class SettingsActivity extends BaseActivity {
|
|||||||
Log.d(TAG, "SettingsActivity created");
|
Log.d(TAG, "SettingsActivity created");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import com.android.volley.Request;
|
|||||||
import com.android.volley.Response;
|
import com.android.volley.Response;
|
||||||
import com.android.volley.VolleyError;
|
import com.android.volley.VolleyError;
|
||||||
import com.android.volley.toolbox.StringRequest;
|
import com.android.volley.toolbox.StringRequest;
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
import org.deke.risk.riskahead.adapter.SubscriptionsPagerAdapter;
|
import org.deke.risk.riskahead.adapter.SubscriptionsPagerAdapter;
|
||||||
import org.deke.risk.riskahead.fragment.SubscriptionItemFragment;
|
import org.deke.risk.riskahead.fragment.SubscriptionItemFragment;
|
||||||
@@ -45,7 +46,6 @@ import java.util.Map;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SubscriptionsActivity extends BaseActivity{
|
public class SubscriptionsActivity extends BaseActivity{
|
||||||
|
|
||||||
private final static String TAG = SubscriptionsActivity.class.getSimpleName();
|
private final static String TAG = SubscriptionsActivity.class.getSimpleName();
|
||||||
|
|
||||||
IInAppBillingService mService;
|
IInAppBillingService mService;
|
||||||
@@ -79,14 +79,14 @@ public class SubscriptionsActivity extends BaseActivity{
|
|||||||
|
|
||||||
|
|
||||||
private void initViewPager() {
|
private void initViewPager() {
|
||||||
subscriptionsViewPager = (ViewPager) findViewById(R.id.subs_viewpager);
|
subscriptionsViewPager = findViewById(R.id.subs_viewpager);
|
||||||
subscriptionsAdapter = new SubscriptionsPagerAdapter(getSupportFragmentManager(), 2);
|
subscriptionsAdapter = new SubscriptionsPagerAdapter(getSupportFragmentManager(), 2);
|
||||||
subscriptionsViewPager.setAdapter(subscriptionsAdapter);
|
subscriptionsViewPager.setAdapter(subscriptionsAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDots() {
|
public void addDots() {
|
||||||
dots = new ArrayList<>();
|
dots = new ArrayList<>();
|
||||||
LinearLayout dotsLayout = (LinearLayout)findViewById(R.id.dots);
|
LinearLayout dotsLayout = findViewById(R.id.dots);
|
||||||
|
|
||||||
for(int i = 0; i < subscriptionsAdapter.getCount(); i++) {
|
for(int i = 0; i < subscriptionsAdapter.getCount(); i++) {
|
||||||
ImageView dot = new ImageView(this);
|
ImageView dot = new ImageView(this);
|
||||||
@@ -103,7 +103,7 @@ public class SubscriptionsActivity extends BaseActivity{
|
|||||||
dots.add(dot);
|
dots.add(dot);
|
||||||
}
|
}
|
||||||
|
|
||||||
subscriptionsViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
subscriptionsViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
|
||||||
}
|
}
|
||||||
@@ -193,7 +193,8 @@ public class SubscriptionsActivity extends BaseActivity{
|
|||||||
|
|
||||||
}
|
}
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "RemoteException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,17 +240,21 @@ public class SubscriptionsActivity extends BaseActivity{
|
|||||||
if (response == 0) {
|
if (response == 0) {
|
||||||
ArrayList<String> responseList= skuDetails.getStringArrayList("DETAILS_LIST");
|
ArrayList<String> responseList= skuDetails.getStringArrayList("DETAILS_LIST");
|
||||||
|
|
||||||
for (String thisResponse : responseList) {
|
if(responseList != null){
|
||||||
JSONObject object = new JSONObject(thisResponse);
|
for (String thisResponse : responseList) {
|
||||||
|
JSONObject object = new JSONObject(thisResponse);
|
||||||
|
|
||||||
final String sku = object.getString("productId");
|
final String sku = object.getString("productId");
|
||||||
final String price = object.getString("price");
|
final String price = object.getString("price");
|
||||||
final String title = object.getString("title");
|
final String title = object.getString("title");
|
||||||
final String description = object.getString("description");
|
final String description = object.getString("description");
|
||||||
|
|
||||||
purchaseMap.put(sku, object);
|
purchaseMap.put(sku, object);
|
||||||
|
|
||||||
Log.d(TAG,"Product: "+sku+" Price: "+price+" Title: "+title+" Description: "+description);
|
Log.d(TAG,"Product: "+sku+" Price: "+price+" Title: "+title+" Description: "+description);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get responseList");
|
||||||
}
|
}
|
||||||
|
|
||||||
((SubscriptionItemFragment) subscriptionsAdapter.getItem(0)).initSubscription(purchaseMap.get("no_ads_03"));
|
((SubscriptionItemFragment) subscriptionsAdapter.getItem(0)).initSubscription(purchaseMap.get("no_ads_03"));
|
||||||
@@ -257,7 +262,8 @@ public class SubscriptionsActivity extends BaseActivity{
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Exception caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +278,8 @@ public class SubscriptionsActivity extends BaseActivity{
|
|||||||
startIntentSenderForResult(pendingIntent.getIntentSender(),1001, new Intent(), 0, 0, 0);
|
startIntentSenderForResult(pendingIntent.getIntentSender(),1001, new Intent(), 0, 0, 0);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Exception caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,7 +302,8 @@ public class SubscriptionsActivity extends BaseActivity{
|
|||||||
}
|
}
|
||||||
catch (JSONException e) {
|
catch (JSONException e) {
|
||||||
showMessage(getResources().getString(R.string.txt_errormsg_subs));
|
showMessage(getResources().getString(R.string.txt_errormsg_subs));
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught while purchasing!");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -320,14 +328,15 @@ public class SubscriptionsActivity extends BaseActivity{
|
|||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error adding subscription (Server returned error): " + errorMsg);
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error adding subscription (Server returned error): " + errorMsg);
|
||||||
showMessage(getResources().getString(R.string.txt_errormsg_subs));
|
showMessage(getResources().getString(R.string.txt_errormsg_subs));
|
||||||
} else {
|
} else {
|
||||||
gotoSubscriptionsActivity();
|
gotoSubscriptionsActivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
hideDialog();
|
hideDialog();
|
||||||
@@ -336,7 +345,7 @@ public class SubscriptionsActivity extends BaseActivity{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "Error adding subscription: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error adding subscription: " + error.getMessage());
|
||||||
showMessage(getResources().getString(R.string.txt_errormsg_subs));
|
showMessage(getResources().getString(R.string.txt_errormsg_subs));
|
||||||
hideDialog();
|
hideDialog();
|
||||||
}
|
}
|
||||||
@@ -391,14 +400,15 @@ public class SubscriptionsActivity extends BaseActivity{
|
|||||||
syncWithDatabase(ownedSkus);
|
syncWithDatabase(ownedSkus);
|
||||||
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new Response.ErrorListener() {
|
}, new Response.ErrorListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "Error getting subscription: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error getting subscription: " + error.getMessage());
|
||||||
handleVolleyErrorResponse();
|
handleVolleyErrorResponse();
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
@@ -435,20 +445,21 @@ public class SubscriptionsActivity extends BaseActivity{
|
|||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error deactivating subscription (Server returned error): " + errorMsg);
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error deactivating subscription (Server returned error): " + errorMsg);
|
||||||
}else{
|
}else{
|
||||||
Log.d(TAG,"Sub with uid: "+subscriptionId+" deactivated in DB");
|
Log.d(TAG,"Sub with uid: "+subscriptionId+" deactivated in DB");
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new Response.ErrorListener() {
|
}, new Response.ErrorListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "Error deactivating subscription: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error deactivating subscription: " + error.getMessage());
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import com.android.volley.VolleyError;
|
|||||||
import com.android.volley.toolbox.StringRequest;
|
import com.android.volley.toolbox.StringRequest;
|
||||||
import com.beardedhen.androidbootstrap.AwesomeTextView;
|
import com.beardedhen.androidbootstrap.AwesomeTextView;
|
||||||
import com.beardedhen.androidbootstrap.BootstrapLabel;
|
import com.beardedhen.androidbootstrap.BootstrapLabel;
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
|
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
|
||||||
import com.mikepenz.iconics.IconicsDrawable;
|
import com.mikepenz.iconics.IconicsDrawable;
|
||||||
|
|
||||||
@@ -45,7 +46,6 @@ import java.util.Map;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ViewReportActivity extends BaseActivity {
|
public class ViewReportActivity extends BaseActivity {
|
||||||
|
|
||||||
private final static String TAG = ViewReportActivity.class.getSimpleName();
|
private final static String TAG = ViewReportActivity.class.getSimpleName();
|
||||||
|
|
||||||
private EditText txtIncidentCategory;
|
private EditText txtIncidentCategory;
|
||||||
@@ -78,23 +78,23 @@ public class ViewReportActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initViewsAndButtons() {
|
private void initViewsAndButtons() {
|
||||||
txtIncidentCategory = (EditText) findViewById(R.id.txt_viewreport_incidentcategory);
|
txtIncidentCategory = findViewById(R.id.txt_viewreport_incidentcategory);
|
||||||
txtIncidentSubCategory = (EditText) findViewById(R.id.txt_viewreport_incidentsubcategory);
|
txtIncidentSubCategory = findViewById(R.id.txt_viewreport_incidentsubcategory);
|
||||||
txtPosition = (EditText) findViewById(R.id.txt_viewreport_position);
|
txtPosition = findViewById(R.id.txt_viewreport_position);
|
||||||
txtTime = (EditText) findViewById(R.id.txt_viewreport_time);
|
txtTime = findViewById(R.id.txt_viewreport_time);
|
||||||
scorelabel = (BootstrapLabel) findViewById(R.id.txt_viewreport_points);
|
scorelabel = findViewById(R.id.txt_viewreport_points);
|
||||||
txtSuspect = (EditText) findViewById(R.id.txt_viewreport_suspect);
|
txtSuspect = findViewById(R.id.txt_viewreport_suspect);
|
||||||
txtWeapons = (EditText) findViewById(R.id.txt_viewreport_suspectweapon);
|
txtWeapons = findViewById(R.id.txt_viewreport_suspectweapon);
|
||||||
txtNumOfSuspects = (EditText) findViewById(R.id.txt_viewreport_suspectcount);
|
txtNumOfSuspects = findViewById(R.id.txt_viewreport_suspectcount);
|
||||||
txtVictim = (EditText) findViewById(R.id.txt_viewreport_victim);
|
txtVictim = findViewById(R.id.txt_viewreport_victim);
|
||||||
txtVictimOrigin = (EditText) findViewById(R.id.txt_viewreport_victimorigin);
|
txtVictimOrigin = findViewById(R.id.txt_viewreport_victimorigin);
|
||||||
txtSuspectTransport = (EditText) findViewById(R.id.txt_viewreport_suspecttransport);
|
txtSuspectTransport = findViewById(R.id.txt_viewreport_suspecttransport);
|
||||||
txtVictimAffiliation = (EditText) findViewById(R.id.txt_viewreport_victimaff);
|
txtVictimAffiliation = findViewById(R.id.txt_viewreport_victimaff);
|
||||||
txtSuspectRecognition = (EditText) findViewById(R.id.txt_viewreport_suspectrecon);
|
txtSuspectRecognition = findViewById(R.id.txt_viewreport_suspectrecon);
|
||||||
txtEtcEtc = (EditText) findViewById(R.id.txt_viewreport_etcetc);
|
txtEtcEtc = findViewById(R.id.txt_viewreport_etcetc);
|
||||||
txtReportedFrom = (EditText) findViewById(R.id.txt_viewreport_reportedfrom);
|
txtReportedFrom = findViewById(R.id.txt_viewreport_reportedfrom);
|
||||||
btnUpvote = (AwesomeTextView) findViewById(R.id.btn_viewreport_upvote);
|
btnUpvote = findViewById(R.id.btn_viewreport_upvote);
|
||||||
btnDownvote = (AwesomeTextView) findViewById(R.id.btn_viewreport_downvote);
|
btnDownvote = findViewById(R.id.btn_viewreport_downvote);
|
||||||
|
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
@@ -174,18 +174,19 @@ public class ViewReportActivity extends BaseActivity {
|
|||||||
gotoProfileActivity();
|
gotoProfileActivity();
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error deleting incident (Server returned error): " + errorMsg);
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error deleting incident (Server returned error): " + errorMsg);
|
||||||
showMessage(getResources().getString(R.string.txt_errormsg_deleteincident));
|
showMessage(getResources().getString(R.string.txt_errormsg_deleteincident));
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new Response.ErrorListener() {
|
}, new Response.ErrorListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "Error deleting incident: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error deleting incident: " + error.getMessage());
|
||||||
handleVolleyErrorResponse();
|
handleVolleyErrorResponse();
|
||||||
hideDialog();
|
hideDialog();
|
||||||
}
|
}
|
||||||
@@ -231,18 +232,19 @@ public class ViewReportActivity extends BaseActivity {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error get incident (Server returned error): " + errorMsg);
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error get incident (Server returned error): " + errorMsg);
|
||||||
showMessage(getResources().getString(R.string.txt_errormsg_getincidentdetail));
|
showMessage(getResources().getString(R.string.txt_errormsg_getincidentdetail));
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new Response.ErrorListener() {
|
}, new Response.ErrorListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "Error get incident: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error get incident: " + error.getMessage());
|
||||||
handleVolleyErrorResponse();
|
handleVolleyErrorResponse();
|
||||||
hideDialog();
|
hideDialog();
|
||||||
}
|
}
|
||||||
@@ -360,7 +362,7 @@ public class ViewReportActivity extends BaseActivity {
|
|||||||
private void initReport(IncidentReport incident) {
|
private void initReport(IncidentReport incident) {
|
||||||
Context tmpContext = getApplicationContext();
|
Context tmpContext = getApplicationContext();
|
||||||
|
|
||||||
scorelabel.setText(String.format("%d", incident.getVotedScore()));
|
scorelabel.setText(String.format(Locale.US, "%d", incident.getVotedScore()));
|
||||||
txtIncidentCategory.setText(incident.getIncidentCategoryName(tmpContext));
|
txtIncidentCategory.setText(incident.getIncidentCategoryName(tmpContext));
|
||||||
txtIncidentSubCategory.setText(checkIfTextEmptyAndReturnString(incident.getIncidentSubCategoryName(tmpContext)));
|
txtIncidentSubCategory.setText(checkIfTextEmptyAndReturnString(incident.getIncidentSubCategoryName(tmpContext)));
|
||||||
txtTime.setText(checkIfTextEmptyAndReturnString(incident.getTimeString(tmpContext)));
|
txtTime.setText(checkIfTextEmptyAndReturnString(incident.getTimeString(tmpContext)));
|
||||||
@@ -395,7 +397,8 @@ public class ViewReportActivity extends BaseActivity {
|
|||||||
txtPosition.setText(sb.toString());
|
txtPosition.setText(sb.toString());
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "IOException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String latitude = Double.toString(incident.getPosition().latitude);
|
final String latitude = Double.toString(incident.getPosition().latitude);
|
||||||
@@ -463,18 +466,19 @@ public class ViewReportActivity extends BaseActivity {
|
|||||||
checkVotetypeAndSetVoteButtons(jPoints);
|
checkVotetypeAndSetVoteButtons(jPoints);
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error voting incident (Server returned error): " + errorMsg);
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error voting incident (Server returned error): " + errorMsg);
|
||||||
showMessage(getResources().getString(R.string.txt_errormsg_couldnotvote));
|
showMessage(getResources().getString(R.string.txt_errormsg_couldnotvote));
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new Response.ErrorListener() {
|
}, new Response.ErrorListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "Error voting incident: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error voting incident: " + error.getMessage());
|
||||||
handleVolleyErrorResponse();
|
handleVolleyErrorResponse();
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
@@ -516,17 +520,18 @@ public class ViewReportActivity extends BaseActivity {
|
|||||||
checkVotetypeAndSetVoteButtons(jPoints);
|
checkVotetypeAndSetVoteButtons(jPoints);
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error deleting voting incident (Server returned error): " + errorMsg);
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error deleting voting incident (Server returned error): " + errorMsg);
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new Response.ErrorListener() {
|
}, new Response.ErrorListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "Error deleting voting incident: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error deleting voting incident: " + error.getMessage());
|
||||||
handleVolleyErrorResponse();
|
handleVolleyErrorResponse();
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ import org.deke.risk.riskahead.fragment.Top10Fragment;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ProfilePagerAdapter extends FragmentStatePagerAdapter {
|
public class ProfilePagerAdapter extends FragmentStatePagerAdapter {
|
||||||
int mNumOfTabs;
|
private int mNumOfTabs;
|
||||||
String userID;
|
private String userID;
|
||||||
|
|
||||||
public ProfilePagerAdapter(FragmentManager fm, int NumOfTabs, String userID) {
|
public ProfilePagerAdapter(FragmentManager fm, int NumOfTabs, String userID) {
|
||||||
super(fm);
|
super(fm);
|
||||||
@@ -57,11 +57,10 @@ public class ProfilePagerAdapter extends FragmentStatePagerAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return returnFragment;
|
return returnFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Fragment newProfileStatisticsInstance(String uid) {
|
private static Fragment newProfileStatisticsInstance(String uid) {
|
||||||
ProfileStatisticsFragment myFragment = new ProfileStatisticsFragment();
|
ProfileStatisticsFragment myFragment = new ProfileStatisticsFragment();
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
@@ -71,7 +70,7 @@ public class ProfilePagerAdapter extends FragmentStatePagerAdapter {
|
|||||||
return myFragment;
|
return myFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Fragment newReportListInstance(String uid) {
|
private static Fragment newReportListInstance(String uid) {
|
||||||
ReportListFragment myFragment = new ReportListFragment();
|
ReportListFragment myFragment = new ReportListFragment();
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ 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.os.Build;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -13,6 +14,8 @@ import android.widget.ImageView;
|
|||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
import org.deke.risk.riskahead.R;
|
import org.deke.risk.riskahead.R;
|
||||||
import org.deke.risk.riskahead.helper.IncidentReport;
|
import org.deke.risk.riskahead.helper.IncidentReport;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@@ -28,9 +31,10 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ReportListAdapter extends BaseAdapter {
|
public class ReportListAdapter extends BaseAdapter {
|
||||||
|
private final static String TAG = ReportListAdapter.class.getSimpleName();
|
||||||
|
|
||||||
Context context;
|
private Context context;
|
||||||
List<JSONObject> data;
|
private List<JSONObject> data;
|
||||||
|
|
||||||
private static LayoutInflater inflater = null;
|
private static LayoutInflater inflater = null;
|
||||||
|
|
||||||
@@ -61,12 +65,12 @@ public class ReportListAdapter extends BaseAdapter {
|
|||||||
View vi = convertView;
|
View vi = convertView;
|
||||||
if (vi == null) vi = inflater.inflate(R.layout.fragment_reportlist_row, null);
|
if (vi == null) vi = inflater.inflate(R.layout.fragment_reportlist_row, null);
|
||||||
|
|
||||||
TextView itemText = (TextView) vi.findViewById(R.id.txt_reportlist_lvrow_text);
|
TextView itemText = vi.findViewById(R.id.txt_reportlist_lvrow_text);
|
||||||
TextView titleText = (TextView) vi.findViewById(R.id.txt_reportlist_lvrow_title);
|
TextView titleText = vi.findViewById(R.id.txt_reportlist_lvrow_title);
|
||||||
TextView categoryText = (TextView) vi.findViewById(R.id.txt_reportlist_lvrow_category);
|
TextView categoryText = vi.findViewById(R.id.txt_reportlist_lvrow_category);
|
||||||
LinearLayout ll = (LinearLayout) vi.findViewById(R.id.lay_reportlist_color);
|
LinearLayout ll = vi.findViewById(R.id.lay_reportlist_color);
|
||||||
ImageView iv = (ImageView) vi.findViewById(R.id.ic_reportlist_row);
|
ImageView iv = vi.findViewById(R.id.ic_reportlist_row);
|
||||||
LinearLayout bglayout = (LinearLayout) vi.findViewById(R.id.lay_reportlist_bgcolor);
|
LinearLayout bglayout = vi.findViewById(R.id.lay_reportlist_bgcolor);
|
||||||
|
|
||||||
boolean status = true;
|
boolean status = true;
|
||||||
|
|
||||||
@@ -75,7 +79,8 @@ public class ReportListAdapter extends BaseAdapter {
|
|||||||
status = false;
|
status = false;
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!status){
|
if(!status){
|
||||||
@@ -89,7 +94,7 @@ public class ReportListAdapter extends BaseAdapter {
|
|||||||
|
|
||||||
ll.setBackgroundColor(Color.argb(150, 255, 0, 0));
|
ll.setBackgroundColor(Color.argb(150, 255, 0, 0));
|
||||||
iv.setVisibility(View.GONE);
|
iv.setVisibility(View.GONE);
|
||||||
}else {
|
}else{
|
||||||
bglayout.setBackgroundColor(Color.argb(0, 0, 0, 0));
|
bglayout.setBackgroundColor(Color.argb(0, 0, 0, 0));
|
||||||
IncidentReport item = new IncidentReport(data.get(position));
|
IncidentReport item = new IncidentReport(data.get(position));
|
||||||
titleText.setText(item.getIncidentCategoryName(vi.getContext()));
|
titleText.setText(item.getIncidentCategoryName(vi.getContext()));
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package org.deke.risk.riskahead.adapter;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.DataSetObserver;
|
import android.database.DataSetObserver;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ import org.deke.risk.riskahead.fragment.SubscriptionItemFragment;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SubscriptionsPagerAdapter extends FragmentStatePagerAdapter {
|
public class SubscriptionsPagerAdapter extends FragmentStatePagerAdapter {
|
||||||
int mNumOfTabs;
|
private int mNumOfTabs;
|
||||||
|
|
||||||
SubscriptionItemFragment frag1;
|
private SubscriptionItemFragment frag1;
|
||||||
SubscriptionItemFragment frag2;
|
private SubscriptionItemFragment frag2;
|
||||||
|
|
||||||
public SubscriptionsPagerAdapter(FragmentManager fm, int NumOfTabs) {
|
public SubscriptionsPagerAdapter(FragmentManager fm, int NumOfTabs) {
|
||||||
super(fm);
|
super(fm);
|
||||||
@@ -26,7 +26,7 @@ public class SubscriptionsPagerAdapter extends FragmentStatePagerAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Fragment getItem(int position) {
|
public Fragment getItem(int position) {
|
||||||
Fragment returnFragment = null;
|
Fragment returnFragment;
|
||||||
|
|
||||||
switch (position) {
|
switch (position) {
|
||||||
case 0:
|
case 0:
|
||||||
@@ -41,12 +41,9 @@ public class SubscriptionsPagerAdapter extends FragmentStatePagerAdapter {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return returnFragment;
|
return returnFragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return mNumOfTabs;
|
return mNumOfTabs;
|
||||||
|
|||||||
@@ -2,12 +2,15 @@ package org.deke.risk.riskahead.adapter;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.BaseAdapter;
|
import android.widget.BaseAdapter;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
import org.deke.risk.riskahead.R;
|
import org.deke.risk.riskahead.R;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@@ -22,9 +25,10 @@ import java.util.List;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Top10ListAdapter extends BaseAdapter {
|
public class Top10ListAdapter extends BaseAdapter {
|
||||||
|
private final static String TAG = Top10ListAdapter.class.getSimpleName();
|
||||||
|
|
||||||
Context context;
|
private Context context;
|
||||||
List<JSONObject> data;
|
private List<JSONObject> data;
|
||||||
|
|
||||||
private static LayoutInflater inflater = null;
|
private static LayoutInflater inflater = null;
|
||||||
|
|
||||||
@@ -55,11 +59,11 @@ public class Top10ListAdapter extends BaseAdapter {
|
|||||||
View vi = convertView;
|
View vi = convertView;
|
||||||
if (vi == null) vi = inflater.inflate(R.layout.fragment_top10list_row, null);
|
if (vi == null) vi = inflater.inflate(R.layout.fragment_top10list_row, null);
|
||||||
|
|
||||||
TextView rank = (TextView) vi.findViewById(R.id.txt_top10_rank);
|
TextView rank = vi.findViewById(R.id.txt_top10_rank);
|
||||||
TextView name = (TextView) vi.findViewById(R.id.txt_top10_name);
|
TextView name = vi.findViewById(R.id.txt_top10_name);
|
||||||
TextView numberOfIncidents = (TextView) vi.findViewById(R.id.txt_top10_numberOfIncidents);
|
TextView numberOfIncidents = vi.findViewById(R.id.txt_top10_numberOfIncidents);
|
||||||
TextView memberSince = (TextView) vi.findViewById(R.id.txt_top10_membersince);
|
TextView memberSince = vi.findViewById(R.id.txt_top10_membersince);
|
||||||
TextView points = (TextView) vi.findViewById(R.id.txt_top10_points);
|
TextView points = vi.findViewById(R.id.txt_top10_points);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
rank.setText("#"+data.get(position).getString("rank"));
|
rank.setText("#"+data.get(position).getString("rank"));
|
||||||
@@ -70,7 +74,8 @@ public class Top10ListAdapter extends BaseAdapter {
|
|||||||
numberOfIncidents.setText(data.get(position).getString("numberOfPosts")+" "+context.getResources().getString(R.string.txt_top10_reportedinc));
|
numberOfIncidents.setText(data.get(position).getString("numberOfPosts")+" "+context.getResources().getString(R.string.txt_top10_reportedinc));
|
||||||
memberSince.setText(context.getResources().getString(R.string.txt_top10_membersince)+" "+data.get(position).getString("created_at").split(" ")[0]);
|
memberSince.setText(context.getResources().getString(R.string.txt_top10_membersince)+" "+data.get(position).getString("created_at").split(" ")[0]);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
return vi;
|
return vi;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,15 +18,12 @@ import org.deke.risk.riskahead.helper.IncidentReport;
|
|||||||
*/
|
*/
|
||||||
public abstract class BaseReportWFFragment extends Fragment {
|
public abstract class BaseReportWFFragment extends Fragment {
|
||||||
|
|
||||||
|
|
||||||
public BaseReportWFFragment() {
|
public BaseReportWFFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
|
||||||
return new TextView(getActivity());
|
return new TextView(getActivity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
package org.deke.risk.riskahead.fragment;
|
package org.deke.risk.riskahead.fragment;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
@@ -16,12 +17,12 @@ import com.facebook.AccessToken;
|
|||||||
import com.facebook.CallbackManager;
|
import com.facebook.CallbackManager;
|
||||||
import com.facebook.FacebookCallback;
|
import com.facebook.FacebookCallback;
|
||||||
import com.facebook.FacebookException;
|
import com.facebook.FacebookException;
|
||||||
import com.facebook.FacebookSdk;
|
|
||||||
import com.facebook.GraphRequest;
|
import com.facebook.GraphRequest;
|
||||||
import com.facebook.GraphResponse;
|
import com.facebook.GraphResponse;
|
||||||
import com.facebook.login.LoginBehavior;
|
import com.facebook.login.LoginBehavior;
|
||||||
import com.facebook.login.LoginManager;
|
import com.facebook.login.LoginManager;
|
||||||
import com.facebook.login.LoginResult;
|
import com.facebook.login.LoginResult;
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
import org.deke.risk.riskahead.LoginActivity;
|
import org.deke.risk.riskahead.LoginActivity;
|
||||||
import org.deke.risk.riskahead.R;
|
import org.deke.risk.riskahead.R;
|
||||||
@@ -39,7 +40,8 @@ import java.util.Arrays;
|
|||||||
*/
|
*/
|
||||||
public class FacebookButtonFragment extends Fragment {
|
public class FacebookButtonFragment extends Fragment {
|
||||||
|
|
||||||
private BootstrapButton btnLoginFB;
|
private final static String TAG = FacebookButtonFragment.class.getSimpleName();
|
||||||
|
|
||||||
CallbackManager callbackManager;
|
CallbackManager callbackManager;
|
||||||
OnFragmentInteractionListener mListener;
|
OnFragmentInteractionListener mListener;
|
||||||
View view;
|
View view;
|
||||||
@@ -58,9 +60,8 @@ public class FacebookButtonFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
view = inflater.inflate(R.layout.fragment_facebook_button, container, false);
|
view = inflater.inflate(R.layout.fragment_facebook_button, container, false);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +74,6 @@ public class FacebookButtonFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
FacebookSdk.sdkInitialize(getContext());
|
|
||||||
callbackManager = CallbackManager.Factory.create();
|
callbackManager = CallbackManager.Factory.create();
|
||||||
initFacebookButton();
|
initFacebookButton();
|
||||||
}
|
}
|
||||||
@@ -86,17 +86,21 @@ public class FacebookButtonFragment extends Fragment {
|
|||||||
|
|
||||||
public interface OnFragmentInteractionListener {
|
public interface OnFragmentInteractionListener {
|
||||||
void onFragmentInteraction(Uri uri);
|
void onFragmentInteraction(Uri uri);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initFacebookButton() {
|
private void initFacebookButton() {
|
||||||
btnLoginFB = (BootstrapButton) view.findViewById(R.id.btn_login_fb);
|
BootstrapButton btnLoginFB = view.findViewById(R.id.btn_login_fb);
|
||||||
|
|
||||||
btnLoginFB.setOnClickListener(new OnClickListener() {
|
btnLoginFB.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
LoginManager.getInstance().setLoginBehavior(LoginBehavior.WEB_ONLY);
|
LoginManager.getInstance().setLoginBehavior(LoginBehavior.WEB_ONLY);
|
||||||
LoginManager.getInstance().logInWithReadPermissions(getActivity(), Arrays.asList("public_profile", "email"));
|
Activity activity = getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
LoginManager.getInstance().logInWithReadPermissions(activity, Arrays.asList("public_profile", "email"));
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get activity when initializing the facebook button");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -110,13 +114,23 @@ public class FacebookButtonFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onCancel() {
|
public void onCancel() {
|
||||||
Log.d("FB","OnCancel");
|
Log.d("FB","OnCancel");
|
||||||
((LoginActivity) getActivity()).showMessage("Facebook LogIn canceled. Please use E-Mail instead.");
|
LoginActivity activity = (LoginActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
activity.showMessage("Facebook LogIn canceled. Please use E-Mail instead.");
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get activity for showing onCancel message");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(FacebookException exception) {
|
public void onError(FacebookException exception) {
|
||||||
Log.d("FB","OnError: " + exception.toString());
|
Log.d("FB","OnError: " + exception.toString());
|
||||||
((LoginActivity) getActivity()).showMessage("Could not log in with Facebook. Please use E-Mail instead or try again later.");
|
LoginActivity activity = (LoginActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
activity.showMessage("Could not log in with Facebook. Please use E-Mail instead or try again later.");
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get activity for showing onError message");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -126,9 +140,15 @@ public class FacebookButtonFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onCompleted(JSONObject objects, GraphResponse response) {
|
public void onCompleted(JSONObject objects, GraphResponse response) {
|
||||||
try {
|
try {
|
||||||
((LoginActivity) getActivity()).handleSocialMediaLogin(objects.getString("id"), "facebook", objects.getString("first_name"), objects.getString("email"));
|
LoginActivity activity = (LoginActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
activity.handleSocialMediaLogin(objects.getString("id"), "facebook", objects.getString("first_name"), objects.getString("email"));
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get activity for handleSocialMediaLogin");
|
||||||
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Exception caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,31 +1,23 @@
|
|||||||
package org.deke.risk.riskahead.fragment;
|
package org.deke.risk.riskahead.fragment;
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentSender;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.ActivityCompat;
|
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.beardedhen.androidbootstrap.BootstrapButton;
|
import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||||
import com.google.android.gms.common.ConnectionResult;
|
import com.google.android.gms.auth.api.signin.GoogleSignIn;
|
||||||
import com.google.android.gms.common.GooglePlayServicesUtil;
|
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
|
||||||
import com.google.android.gms.common.SignInButton;
|
import com.google.android.gms.auth.api.signin.GoogleSignInClient;
|
||||||
import com.google.android.gms.common.api.GoogleApiClient;
|
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
|
||||||
import com.google.android.gms.plus.Plus;
|
import com.google.android.gms.common.api.ApiException;
|
||||||
import com.google.android.gms.plus.model.people.Person;
|
import com.google.android.gms.tasks.Task;
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
import org.deke.risk.riskahead.LoginActivity;
|
import org.deke.risk.riskahead.LoginActivity;
|
||||||
import org.deke.risk.riskahead.R;
|
import org.deke.risk.riskahead.R;
|
||||||
@@ -37,42 +29,32 @@ import org.deke.risk.riskahead.R;
|
|||||||
* Date of Release: 10.02.2016
|
* Date of Release: 10.02.2016
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class GooglePlusButtonFragment extends Fragment implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener{
|
public class GooglePlusButtonFragment extends Fragment{
|
||||||
|
|
||||||
public static final int RC_SIGN_IN = 0;
|
public static final int RC_SIGN_IN = 0;
|
||||||
private static final String TAG = "MainActivity";
|
private static final String TAG = GooglePlusButtonFragment.class.getSimpleName();
|
||||||
private static final int MY_PERMISSIONS_REQUEST_ACCOUNTS = 32;
|
|
||||||
|
|
||||||
private GoogleApiClient mGoogleApiClient;
|
GoogleSignInClient mGoogleSignInClient;
|
||||||
|
|
||||||
private boolean mIntentInProgress;
|
|
||||||
private boolean mSignInClicked;
|
|
||||||
|
|
||||||
private ConnectionResult mConnectionResult;
|
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private Activity mActivity;
|
private LoginActivity mActivity;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
mActivity = getActivity();
|
mActivity = (LoginActivity) getActivity();
|
||||||
mContext = getActivity().getApplicationContext();
|
if(mActivity != null){
|
||||||
|
mContext = mActivity.getApplicationContext();
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not retrieve activity for Google+ onCreate Method");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.fragment_googleplus_button,container, false);
|
View view = inflater.inflate(R.layout.fragment_googleplus_button,container, false);
|
||||||
|
|
||||||
BootstrapButton btnSignIn = (BootstrapButton) view.findViewById(R.id.btn_login_gp);
|
BootstrapButton btnSignIn = view.findViewById(R.id.btn_login_gp);
|
||||||
|
|
||||||
mGoogleApiClient = new GoogleApiClient.Builder(view.getContext())
|
|
||||||
.addConnectionCallbacks(this)
|
|
||||||
.addOnConnectionFailedListener(this).addApi(Plus.API)
|
|
||||||
.addScope(Plus.SCOPE_PLUS_LOGIN).build();
|
|
||||||
|
|
||||||
btnSignIn.setOnClickListener(new View.OnClickListener() {
|
btnSignIn.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@@ -85,206 +67,51 @@ public class GooglePlusButtonFragment extends Fragment implements GoogleApiClien
|
|||||||
|
|
||||||
private void performClickAction() {
|
private void performClickAction() {
|
||||||
Log.d(TAG,"Click on Google+ Button performed");
|
Log.d(TAG,"Click on Google+ Button performed");
|
||||||
if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.GET_ACCOUNTS) != PackageManager.PERMISSION_GRANTED) {
|
GoogleSignInAccount account = GoogleSignIn.getLastSignedInAccount(mContext);
|
||||||
Log.d(TAG,"Permission not granted yet - request now");
|
|
||||||
|
|
||||||
// Should we show an explanation?
|
|
||||||
AlertDialog alertDialog = new AlertDialog.Builder(getActivity()).create();
|
|
||||||
alertDialog.setTitle("Request Permission");
|
|
||||||
alertDialog.setMessage("Google needs permission to see your profile (Contact List) in order to enable log-in with Google+. However, if you do not grant permission, log in with Google+ will not be available.");
|
|
||||||
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "OK",
|
|
||||||
new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
dialog.dismiss();
|
|
||||||
requestPermissions(new String[]{Manifest.permission.GET_ACCOUNTS}, MY_PERMISSIONS_REQUEST_ACCOUNTS);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
alertDialog.show();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(account != null){
|
||||||
|
Log.d(TAG, "User already logged in - handle social media login");
|
||||||
|
mActivity.handleSocialMediaLogin(account.getId(),"google",account.getDisplayName(),account.getEmail());
|
||||||
}else{
|
}else{
|
||||||
Log.d(TAG,"Permission already granted");
|
Log.d(TAG, "User not logged in - log in to g+ now");
|
||||||
|
signInWithGplus();
|
||||||
if(mGoogleApiClient.isConnected()){
|
|
||||||
Person currentPerson = getProfileInformation();
|
|
||||||
((LoginActivity) getActivity()).handleSocialMediaLogin(currentPerson.getId(),"google",currentPerson.getDisplayName(),Plus.AccountApi.getAccountName(mGoogleApiClient));
|
|
||||||
}else{
|
|
||||||
signInWithGplus();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
Log.d(TAG,"RequestCode: "+requestCode);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
|
||||||
switch (requestCode) {
|
|
||||||
case MY_PERMISSIONS_REQUEST_ACCOUNTS: {
|
|
||||||
// If request is cancelled, the result arrays are empty.
|
|
||||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
|
||||||
Log.d(TAG,"Permission granted");
|
|
||||||
|
|
||||||
if(mGoogleApiClient.isConnected()){
|
|
||||||
Person currentPerson = getProfileInformation();
|
|
||||||
((LoginActivity) getActivity()).handleSocialMediaLogin(currentPerson.getId(),"google",currentPerson.getDisplayName(),Plus.AccountApi.getAccountName(mGoogleApiClient));
|
|
||||||
}else{
|
|
||||||
signInWithGplus();
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Log.d(TAG,"Permission not granted - what now?");
|
|
||||||
Toast.makeText(mContext, "Could not log in with Google+. Please use E-Mail instead or try again later.",
|
|
||||||
Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart() {
|
|
||||||
super.onStart();
|
|
||||||
mGoogleApiClient.connect();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStop() {
|
|
||||||
super.onStop();
|
|
||||||
if (mGoogleApiClient.isConnected()) {
|
|
||||||
mGoogleApiClient.disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityResult(int requestCode, int responseCode, Intent intent) {
|
|
||||||
|
|
||||||
if (requestCode == RC_SIGN_IN) {
|
if (requestCode == RC_SIGN_IN) {
|
||||||
if (responseCode != Activity.RESULT_OK) {
|
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
|
||||||
mSignInClicked = false;
|
GoogleSignInAccount account = handleSignInResult(task);
|
||||||
}
|
if(account != null){
|
||||||
|
mActivity.handleSocialMediaLogin(account.getId(),"google",account.getDisplayName(),account.getEmail());
|
||||||
mIntentInProgress = false;
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG,"Could not handle G+ SignIn Result");
|
||||||
if (!mGoogleApiClient.isConnecting()) {
|
|
||||||
mGoogleApiClient.connect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private GoogleSignInAccount handleSignInResult(Task<GoogleSignInAccount> completedTask) {
|
||||||
public void onConnectionFailed(ConnectionResult result) {
|
|
||||||
if (!result.hasResolution()) {
|
|
||||||
GooglePlayServicesUtil.getErrorDialog(result.getErrorCode(),
|
|
||||||
mActivity, 0).show();
|
|
||||||
Log.e(TAG, "" + result.getErrorCode());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mIntentInProgress) {
|
|
||||||
mConnectionResult = result;
|
|
||||||
|
|
||||||
if (mSignInClicked) {
|
|
||||||
|
|
||||||
Log.e(TAG, "" + result.getErrorCode());
|
|
||||||
resolveSignInError();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onConnected(Bundle arg0) {
|
|
||||||
Person currentPerson = getProfileInformation();
|
|
||||||
if(mSignInClicked) ((LoginActivity) getActivity()).handleSocialMediaLogin(currentPerson.getId(),"google",currentPerson.getDisplayName(),Plus.AccountApi.getAccountName(mGoogleApiClient));
|
|
||||||
|
|
||||||
mSignInClicked = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onConnectionSuspended(int arg0) {
|
|
||||||
mGoogleApiClient.connect();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sign-in into google
|
|
||||||
* */
|
|
||||||
private void signInWithGplus() {
|
|
||||||
if (!mGoogleApiClient.isConnecting()) {
|
|
||||||
mSignInClicked = true;
|
|
||||||
resolveSignInError();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to resolve any signin errors
|
|
||||||
* */
|
|
||||||
private void resolveSignInError() {
|
|
||||||
if (mConnectionResult.hasResolution()) {
|
|
||||||
try {
|
|
||||||
mIntentInProgress = true;
|
|
||||||
mConnectionResult.startResolutionForResult(mActivity,RC_SIGN_IN);
|
|
||||||
} catch (IntentSender.SendIntentException e) {
|
|
||||||
mIntentInProgress = false;
|
|
||||||
mGoogleApiClient.connect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetching user's information name, email, profile pic
|
|
||||||
* */
|
|
||||||
private Person getProfileInformation() {
|
|
||||||
Person currentPerson = null;
|
|
||||||
try {
|
try {
|
||||||
if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
|
return completedTask.getResult(ApiException.class);
|
||||||
currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
|
} catch (ApiException e) {
|
||||||
String personName = currentPerson.getDisplayName();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "signInResult:failed code=" + e.getStatusCode());
|
||||||
String personPhotoUrl = currentPerson.getImage().getUrl();
|
return null;
|
||||||
String personGooglePlusProfile = currentPerson.getUrl();
|
|
||||||
String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
|
|
||||||
|
|
||||||
Log.e(TAG, "Name: " + personName + ", plusProfile: "
|
|
||||||
+ personGooglePlusProfile + ", email: " + email
|
|
||||||
+ ", Image: " + personPhotoUrl + " user id:"
|
|
||||||
+ currentPerson.getId());
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Toast.makeText(mContext, "Person information is null",
|
|
||||||
Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return currentPerson;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sign-out from google
|
|
||||||
* */
|
|
||||||
private void signOutFromGplus() {
|
|
||||||
if (mGoogleApiClient.isConnected()) {
|
|
||||||
mGoogleApiClient.clearDefaultAccountAndReconnect();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void logoutFromGplus() {
|
private void signInWithGplus() {
|
||||||
if (mGoogleApiClient.isConnected()) {
|
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
|
||||||
Plus.AccountApi.clearDefaultAccount(mGoogleApiClient);
|
.requestEmail()
|
||||||
mGoogleApiClient.disconnect();
|
.requestId()
|
||||||
mGoogleApiClient.connect();
|
.build();
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
mGoogleSignInClient = GoogleSignIn.getClient(mContext, gso);
|
||||||
|
|
||||||
protected void setGooglePlusButtonText(SignInButton signInButton, String buttonText) {
|
Intent signInIntent = mGoogleSignInClient.getSignInIntent();
|
||||||
for (int i = 0; i < signInButton.getChildCount(); i++) {
|
startActivityForResult(signInIntent, RC_SIGN_IN);
|
||||||
View v = signInButton.getChildAt(i);
|
|
||||||
if (v instanceof TextView) {
|
|
||||||
TextView mTextView = (TextView) v;
|
|
||||||
mTextView.setAllCaps(false);
|
|
||||||
mTextView.setText(buttonText);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface OnFragmentInteractionListener {
|
public interface OnFragmentInteractionListener {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import com.android.volley.VolleyError;
|
|||||||
import com.android.volley.toolbox.StringRequest;
|
import com.android.volley.toolbox.StringRequest;
|
||||||
import com.beardedhen.androidbootstrap.BootstrapButton;
|
import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||||
import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand;
|
import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand;
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
import org.deke.risk.riskahead.ProfileActivity;
|
import org.deke.risk.riskahead.ProfileActivity;
|
||||||
import org.deke.risk.riskahead.R;
|
import org.deke.risk.riskahead.R;
|
||||||
@@ -39,15 +40,15 @@ public class ProfileStatisticsFragment extends Fragment {
|
|||||||
private final static String TAG = ProfileStatisticsFragment.class.getSimpleName();
|
private final static String TAG = ProfileStatisticsFragment.class.getSimpleName();
|
||||||
|
|
||||||
private ProfileActivity parent;
|
private ProfileActivity parent;
|
||||||
private String uid = "";
|
private String uid;
|
||||||
|
|
||||||
private TextView points ;
|
private TextView points ;
|
||||||
private TextView ranking ;
|
private TextView ranking ;
|
||||||
private TextView posts ;
|
private TextView posts ;
|
||||||
private TextView txtMemberSince ;
|
private TextView txtMemberSince ;
|
||||||
|
|
||||||
private TextView lblPoints;
|
private TextView lblPoints;
|
||||||
private TextView lblPosts;
|
private TextView lblPosts;
|
||||||
private TextView lblRanking;
|
private TextView lblRanking;
|
||||||
private TextView lblMemberSince;
|
private TextView lblMemberSince;
|
||||||
|
|
||||||
@@ -58,31 +59,40 @@ public class ProfileStatisticsFragment extends Fragment {
|
|||||||
View view = inflater.inflate(R.layout.fragment_profile_stats, container, false);
|
View view = inflater.inflate(R.layout.fragment_profile_stats, container, false);
|
||||||
parent = (ProfileActivity)getActivity();
|
parent = (ProfileActivity)getActivity();
|
||||||
|
|
||||||
points = (TextView) view.findViewById(R.id.txt_profile_points);
|
points = view.findViewById(R.id.txt_profile_points);
|
||||||
ranking = (TextView) view.findViewById(R.id.txt_profile_ranking);
|
ranking = view.findViewById(R.id.txt_profile_ranking);
|
||||||
posts = (TextView) view.findViewById(R.id.txt_profile_numberposts);
|
posts = view.findViewById(R.id.txt_profile_numberposts);
|
||||||
txtMemberSince = (TextView) view.findViewById(R.id.txt_profile_membersince);
|
txtMemberSince = view.findViewById(R.id.txt_profile_membersince);
|
||||||
|
|
||||||
lblPoints = (TextView) view.findViewById(R.id.lbl_profile_points);
|
lblPoints = view.findViewById(R.id.lbl_profile_points);
|
||||||
lblRanking = (TextView) view.findViewById(R.id.lbl_profile_ranking);
|
lblRanking = view.findViewById(R.id.lbl_profile_ranking);
|
||||||
lblPosts = (TextView) view.findViewById(R.id.lbl_profile_numberposts);
|
lblPosts = view.findViewById(R.id.lbl_profile_numberposts);
|
||||||
lblMemberSince = (TextView) view.findViewById(R.id.lbl_profile_membersince);
|
lblMemberSince = view.findViewById(R.id.lbl_profile_membersince);
|
||||||
|
|
||||||
btnMembershipType = (BootstrapButton) view.findViewById(R.id.btn_profile_membershiptype);
|
btnMembershipType = view.findViewById(R.id.btn_profile_membershiptype);
|
||||||
|
|
||||||
uid = getArguments().getString("uid",parent.user.get(SessionManager.KEY_UID));
|
Bundle arguments = getArguments();
|
||||||
|
if(arguments != null){
|
||||||
getProfileStatsForList();
|
uid = getArguments().getString("uid",parent.user.get(SessionManager.KEY_UID));
|
||||||
|
getProfileStatsForList();
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not retrieve arguments");
|
||||||
|
}
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getProfileStatsForList() {
|
private void getProfileStatsForList() {
|
||||||
((ProfileActivity)getActivity()).showDialog();
|
ProfileActivity activity = (ProfileActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
activity.showDialog();
|
||||||
|
|
||||||
StringRequest strReq = getStringRequestProfileStats();
|
StringRequest strReq = getStringRequestProfileStats();
|
||||||
String tag_string_req = "req_profilestats";
|
String tag_string_req = "req_profilestats";
|
||||||
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not retrieve activity for ProfileStats");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private StringRequest getStringRequestProfileStats() {
|
private StringRequest getStringRequestProfileStats() {
|
||||||
@@ -109,22 +119,37 @@ public class ProfileStatisticsFragment extends Fragment {
|
|||||||
btnMembershipType.setBootstrapBrand(DefaultBootstrapBrand.SUCCESS);
|
btnMembershipType.setBootstrapBrand(DefaultBootstrapBrand.SUCCESS);
|
||||||
btnMembershipType.setText(getResources().getString(R.string.lbl_membershiptype_free));
|
btnMembershipType.setText(getResources().getString(R.string.lbl_membershiptype_free));
|
||||||
}else{
|
}else{
|
||||||
|
boolean no_ads = false;
|
||||||
|
boolean premium = false;
|
||||||
|
|
||||||
for(int i = 0; i < jSubs.length();i++) {
|
for(int i = 0; i < jSubs.length();i++) {
|
||||||
if(jSubs.getJSONObject(i).getString("productId").contains("no_ads")){
|
if(jSubs.getJSONObject(i).getString("productId").contains("no_ads")){
|
||||||
|
no_ads = true;
|
||||||
|
}
|
||||||
|
if(jSubs.getJSONObject(i).getString("productId").contains("extra_functions")){
|
||||||
|
premium = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ProfileActivity activity = (ProfileActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
if(no_ads){
|
||||||
btnMembershipType.setBootstrapBrand(DefaultBootstrapBrand.PRIMARY);
|
btnMembershipType.setBootstrapBrand(DefaultBootstrapBrand.PRIMARY);
|
||||||
btnMembershipType.setText(getResources().getString(R.string.lbl_membershiptype_addfree));
|
btnMembershipType.setText(getResources().getString(R.string.lbl_membershiptype_addfree));
|
||||||
((ProfileActivity) getActivity()).session.setSubsNoAds(true);
|
activity.session.setSubsNoAds(true);
|
||||||
}else{
|
}else{
|
||||||
((ProfileActivity) getActivity()).session.setSubsNoAds(false);
|
activity.session.setSubsNoAds(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(jSubs.getJSONObject(i).getString("productId").contains("extra_functions")){
|
if(premium){
|
||||||
btnMembershipType.setBootstrapBrand(DefaultBootstrapBrand.WARNING);
|
btnMembershipType.setBootstrapBrand(DefaultBootstrapBrand.WARNING);
|
||||||
btnMembershipType.setText(getResources().getString(R.string.lbl_membershiptype_premium));
|
btnMembershipType.setText(getResources().getString(R.string.lbl_membershiptype_premium));
|
||||||
((ProfileActivity) getActivity()).session.setSubsPremium(true);
|
activity.session.setSubsPremium(true);
|
||||||
}else{
|
}else{
|
||||||
((ProfileActivity) getActivity()).session.setSubsPremium(false);
|
activity.session.setSubsPremium(false);
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not retrieve activity for ProfileStatistics. Could not set statusLevel");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,23 +161,29 @@ public class ProfileStatisticsFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error getting user stats (server returned error): " + errorMsg);
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error getting user stats (server returned error): " + errorMsg);
|
||||||
|
|
||||||
parent.showMessage(getResources().getString(R.string.txt_errormsg_retrievestats));
|
parent.showMessage(getResources().getString(R.string.txt_errormsg_retrievestats));
|
||||||
}
|
}
|
||||||
|
|
||||||
((ProfileActivity)getActivity()).hideDialog();
|
((ProfileActivity)getActivity()).hideDialog();
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, new Response.ErrorListener() {
|
}, new Response.ErrorListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "Error getting user stats: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error getting user stats: " + error.getMessage());
|
||||||
((ProfileActivity)getActivity()).hideDialog();
|
ProfileActivity activity = (ProfileActivity) getActivity();
|
||||||
((ProfileActivity)getActivity()).handleVolleyErrorResponse();
|
if(activity != null){
|
||||||
|
activity.hideDialog();
|
||||||
|
activity.handleVolleyErrorResponse();
|
||||||
|
}else {
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not retrieve activity for onErrorResponse");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import com.android.volley.Request;
|
|||||||
import com.android.volley.Response;
|
import com.android.volley.Response;
|
||||||
import com.android.volley.VolleyError;
|
import com.android.volley.VolleyError;
|
||||||
import com.android.volley.toolbox.StringRequest;
|
import com.android.volley.toolbox.StringRequest;
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
import org.deke.risk.riskahead.ProfileActivity;
|
import org.deke.risk.riskahead.ProfileActivity;
|
||||||
import org.deke.risk.riskahead.R;
|
import org.deke.risk.riskahead.R;
|
||||||
@@ -38,7 +39,6 @@ import java.util.Map;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ReportListFragment extends Fragment{
|
public class ReportListFragment extends Fragment{
|
||||||
|
|
||||||
private final static String TAG = ReportListFragment.class.getSimpleName();
|
private final static String TAG = ReportListFragment.class.getSimpleName();
|
||||||
|
|
||||||
private ProfileActivity parent;
|
private ProfileActivity parent;
|
||||||
@@ -47,16 +47,21 @@ public class ReportListFragment extends Fragment{
|
|||||||
private ListAdapter myListAdapter;
|
private ListAdapter myListAdapter;
|
||||||
private List<JSONObject> resultList;
|
private List<JSONObject> resultList;
|
||||||
|
|
||||||
private String uid = "";
|
private String uid;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.fragment_reportlist, container, false);
|
View view = inflater.inflate(R.layout.fragment_reportlist, container, false);
|
||||||
|
|
||||||
parent = (ProfileActivity)getActivity();
|
parent = (ProfileActivity)getActivity();
|
||||||
|
Bundle arguments = getArguments();
|
||||||
|
if(arguments != null && parent != null){
|
||||||
|
uid = getArguments().getString("uid",parent.user.get(SessionManager.KEY_UID));
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could either not get arguments or parent activity");
|
||||||
|
}
|
||||||
|
|
||||||
uid = getArguments().getString("uid",parent.user.get(SessionManager.KEY_UID));
|
myListView = view.findViewById(R.id.lv_reportlist_list);
|
||||||
|
|
||||||
myListView = (ListView) view.findViewById(R.id.lv_reportlist_list);
|
|
||||||
|
|
||||||
if(resultList == null || resultList.size() == 0) getIncidentsForList();
|
if(resultList == null || resultList.size() == 0) getIncidentsForList();
|
||||||
|
|
||||||
@@ -67,9 +72,9 @@ public class ReportListFragment extends Fragment{
|
|||||||
if(resultList.get(position).getInt("status") == 1){
|
if(resultList.get(position).getInt("status") == 1){
|
||||||
parent.gotoViewReportActivity(resultList.get(position).getInt("id"));
|
parent.gotoViewReportActivity(resultList.get(position).getInt("id"));
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Catched JSONException");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -78,11 +83,16 @@ public class ReportListFragment extends Fragment{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void getIncidentsForList() {
|
private void getIncidentsForList() {
|
||||||
((ProfileActivity)getActivity()).showDialog();
|
ProfileActivity activity = (ProfileActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
activity.showDialog();
|
||||||
|
|
||||||
String tag_string_req = "getincidentswithpositionfromid";
|
String tag_string_req = "getincidentswithpositionfromid";
|
||||||
StringRequest strReq = getStringRequestGetIncidentsWithPositionFromUserID();
|
StringRequest strReq = getStringRequestGetIncidentsWithPositionFromUserID();
|
||||||
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent activity");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private StringRequest getStringRequestGetIncidentsWithPositionFromUserID() {
|
private StringRequest getStringRequestGetIncidentsWithPositionFromUserID() {
|
||||||
@@ -114,20 +124,25 @@ public class ReportListFragment extends Fragment{
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error getting incident list (Server returned error): " + errorMsg);
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error getting incident list (Server returned error): " + errorMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
((ProfileActivity)getActivity()).hideDialog();
|
ProfileActivity activity = (ProfileActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
activity.hideDialog();
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent activity");
|
||||||
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Catched JSONException");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}, new Response.ErrorListener() {
|
}, new Response.ErrorListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "Error getting incident list: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error getting incident list: " + error.getMessage());
|
||||||
parent.handleVolleyErrorResponse();
|
parent.handleVolleyErrorResponse();
|
||||||
parent.hideDialog();
|
parent.hideDialog();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package org.deke.risk.riskahead.fragment;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -12,6 +13,8 @@ import android.widget.RelativeLayout;
|
|||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
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;
|
||||||
@@ -30,6 +33,8 @@ public class ReportWF_1_Fragment extends BaseReportWFFragment{
|
|||||||
private final static int VIOLANCE_LIFETHREAT = 3;
|
private final static int VIOLANCE_LIFETHREAT = 3;
|
||||||
private final static int VIOLANCE_DISASTER = 4;
|
private final static int VIOLANCE_DISASTER = 4;
|
||||||
|
|
||||||
|
private final static String TAG = ReportWF_1_Fragment.class.getSimpleName();
|
||||||
|
|
||||||
private View viewFragment;
|
private View viewFragment;
|
||||||
|
|
||||||
private Spinner crimeCategory;
|
private Spinner crimeCategory;
|
||||||
@@ -69,16 +74,23 @@ public class ReportWF_1_Fragment extends BaseReportWFFragment{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initInputElements() {
|
private void initInputElements() {
|
||||||
crimeCategory = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_1_cat_main);
|
crimeCategory = viewFragment.findViewById(R.id.dd_reportwf_1_cat_main);
|
||||||
crimeSubCategory = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_1_cat_sub);
|
crimeSubCategory = viewFragment.findViewById(R.id.dd_reportwf_1_cat_sub);
|
||||||
crimeSubOther = (EditText) viewFragment.findViewById(R.id.txt_reportwf_1_cat_etc);
|
crimeSubOther = viewFragment.findViewById(R.id.txt_reportwf_1_cat_etc);
|
||||||
timeLayout = (RelativeLayout) viewFragment.findViewById(R.id.ll_pos);
|
timeLayout = viewFragment.findViewById(R.id.ll_pos);
|
||||||
txtPositionInformation = (TextView) viewFragment.findViewById(R.id.lbl_reportwf_position_detail);
|
txtPositionInformation = viewFragment.findViewById(R.id.lbl_reportwf_position_detail);
|
||||||
|
|
||||||
crimeSubCategory.setVisibility(View.INVISIBLE);
|
crimeSubCategory.setVisibility(View.INVISIBLE);
|
||||||
crimeSubOther.setVisibility(View.INVISIBLE);
|
crimeSubOther.setVisibility(View.INVISIBLE);
|
||||||
timeLayout.setVisibility(View.INVISIBLE);
|
timeLayout.setVisibility(View.INVISIBLE);
|
||||||
((ReportWFActivity)getActivity()).setMapButtonVisibility(false);
|
|
||||||
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
activity.setMapButtonVisibility(false);
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent activity");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
crimeCategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
crimeCategory.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -144,10 +156,15 @@ public class ReportWF_1_Fragment extends BaseReportWFFragment{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setMainSpinnerValues(int stringId) {
|
private void setMainSpinnerValues(int stringId) {
|
||||||
ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(getActivity(),stringId, android.R.layout.simple_spinner_dropdown_item);
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
crimeCategory.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, getActivity()));
|
if(activity != null){
|
||||||
|
ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(activity, stringId, android.R.layout.simple_spinner_dropdown_item);
|
||||||
|
crimeCategory.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, activity));
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent activity");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSubSpinnerValues(int stringId) {
|
private void setSubSpinnerValues(int stringId) {
|
||||||
@@ -179,7 +196,12 @@ public class ReportWF_1_Fragment extends BaseReportWFFragment{
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
incident = ((ReportWFActivity)getActivity()).getIncident();
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
incident = activity.getIncident();
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent activity");
|
||||||
|
}
|
||||||
|
|
||||||
if(incident != null){
|
if(incident != null){
|
||||||
if(incident.getFidIncidentCategory() > 0){
|
if(incident.getFidIncidentCategory() > 0){
|
||||||
@@ -216,7 +238,12 @@ public class ReportWF_1_Fragment extends BaseReportWFFragment{
|
|||||||
incident.setFidIncidentSubCategory(crimeSubCategory.getSelectedItemPosition());
|
incident.setFidIncidentSubCategory(crimeSubCategory.getSelectedItemPosition());
|
||||||
incident.setEtcIncidentCategory(crimeSubOther.getText().toString());
|
incident.setEtcIncidentCategory(crimeSubOther.getText().toString());
|
||||||
|
|
||||||
((ReportWFActivity) getActivity()).setIncident(incident);
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
activity.setIncident(incident);
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent activity");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import android.support.v4.app.FragmentManager;
|
|||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.text.format.DateFormat;
|
import android.text.format.DateFormat;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -21,6 +22,8 @@ import android.widget.RelativeLayout;
|
|||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
import android.widget.TimePicker;
|
import android.widget.TimePicker;
|
||||||
|
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
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;
|
||||||
@@ -30,6 +33,7 @@ import java.text.ParseException;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -44,6 +48,8 @@ public class ReportWF_2_Fragment extends BaseReportWFFragment {
|
|||||||
private final static int DATETIME = 3;
|
private final static int DATETIME = 3;
|
||||||
private final static int DATETIMEAREA = 4;
|
private final static int DATETIMEAREA = 4;
|
||||||
|
|
||||||
|
private final static String TAG = ReportWF_2_Fragment.class.getSimpleName();
|
||||||
|
|
||||||
private View viewFragment;
|
private View viewFragment;
|
||||||
|
|
||||||
private Spinner timeCategory;
|
private Spinner timeCategory;
|
||||||
@@ -95,8 +101,8 @@ public class ReportWF_2_Fragment extends BaseReportWFFragment {
|
|||||||
initLayoutFromDateTime();
|
initLayoutFromDateTime();
|
||||||
initLayoutToDateTime();
|
initLayoutToDateTime();
|
||||||
|
|
||||||
timeCategory = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_2_time_main);
|
timeCategory = viewFragment.findViewById(R.id.dd_reportwf_2_time_main);
|
||||||
timeSubCategory = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_2_time_sub);
|
timeSubCategory = viewFragment.findViewById(R.id.dd_reportwf_2_time_sub);
|
||||||
|
|
||||||
timeSubCategory.setVisibility(View.INVISIBLE);
|
timeSubCategory.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
@@ -111,8 +117,8 @@ public class ReportWF_2_Fragment extends BaseReportWFFragment {
|
|||||||
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);
|
||||||
|
|
||||||
inputDateFrom.setText(new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime()));
|
inputDateFrom.setText(new SimpleDateFormat("yyyy-MM-dd", Locale.US).format(Calendar.getInstance().getTime()));
|
||||||
inputTimeFrom.setText(new SimpleDateFormat("HH:mm").format(Calendar.getInstance().getTime()));
|
inputTimeFrom.setText(new SimpleDateFormat("HH:mm", Locale.US).format(Calendar.getInstance().getTime()));
|
||||||
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);
|
||||||
@@ -135,8 +141,8 @@ public class ReportWF_2_Fragment extends BaseReportWFFragment {
|
|||||||
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);
|
||||||
|
|
||||||
inputDateFrom.setText(new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime()));
|
inputDateFrom.setText(new SimpleDateFormat("yyyy-MM-dd", Locale.US).format(Calendar.getInstance().getTime()));
|
||||||
inputTimeFrom.setText(new SimpleDateFormat("HH:mm").format(Calendar.getInstance().getTime()));
|
inputTimeFrom.setText(new SimpleDateFormat("HH:mm", Locale.US).format(Calendar.getInstance().getTime()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,23 +169,26 @@ public class ReportWF_2_Fragment extends BaseReportWFFragment {
|
|||||||
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) {
|
||||||
if (((SpinnerHintAdapter) timeSubCategory.getAdapter()).isInInitialState()) {
|
if (!((SpinnerHintAdapter) timeSubCategory.getAdapter()).isInInitialState()) {
|
||||||
|
|
||||||
} else {
|
|
||||||
checkIfFinished();
|
checkIfFinished();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNothingSelected(AdapterView<?> parent) {
|
public void onNothingSelected(AdapterView<?> parent) {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setMainSpinnerValues(int stringId) {
|
private void setMainSpinnerValues(int stringId) {
|
||||||
ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(getActivity(), stringId , android.R.layout.simple_spinner_dropdown_item);
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
timeCategory.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, getActivity()));
|
if(activity != null){
|
||||||
|
ArrayAdapter<CharSequence> 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()));
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent activity");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSubSpinnerValues(int stringId) {
|
private void setSubSpinnerValues(int stringId) {
|
||||||
@@ -190,11 +199,11 @@ public class ReportWF_2_Fragment extends BaseReportWFFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initLayoutFromDateTime() {
|
private void initLayoutFromDateTime() {
|
||||||
RelativeLayout rlFromTime = (RelativeLayout) viewFragment.findViewById(R.id.ll_report_from_time);
|
RelativeLayout rlFromTime = viewFragment.findViewById(R.id.ll_report_from_time);
|
||||||
rlFromTime.setVisibility(View.INVISIBLE);
|
rlFromTime.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
inputDateFrom = ((EditText) viewFragment.findViewById(R.id.input_report_from_date));
|
inputDateFrom = viewFragment.findViewById(R.id.input_report_from_date);
|
||||||
inputTimeFrom = ((EditText) viewFragment.findViewById(R.id.input_report_from_time));
|
inputTimeFrom = viewFragment.findViewById(R.id.input_report_from_time);
|
||||||
|
|
||||||
inputDateFrom.setOnClickListener(new View.OnClickListener() {
|
inputDateFrom.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -246,11 +255,11 @@ public class ReportWF_2_Fragment extends BaseReportWFFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initLayoutToDateTime() {
|
private void initLayoutToDateTime() {
|
||||||
RelativeLayout rlFromTime = (RelativeLayout) viewFragment.findViewById(R.id.ll_report_to_time);
|
RelativeLayout rlFromTime = viewFragment.findViewById(R.id.ll_report_to_time);
|
||||||
rlFromTime.setVisibility(View.INVISIBLE);
|
rlFromTime.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
inputDateTo = ((EditText) viewFragment.findViewById(R.id.input_report_to_date));
|
inputDateTo = viewFragment.findViewById(R.id.input_report_to_date);
|
||||||
inputTimeTo = ((EditText) viewFragment.findViewById(R.id.input_report_to_time));
|
inputTimeTo = viewFragment.findViewById(R.id.input_report_to_time);
|
||||||
|
|
||||||
inputDateTo.setOnClickListener(new View.OnClickListener() {
|
inputDateTo.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -283,21 +292,23 @@ public class ReportWF_2_Fragment extends BaseReportWFFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
|
||||||
tmpInput.setText(String.format("%02d:%02d",hourOfDay,minute));
|
tmpInput.setText(String.format(Locale.US, "%02d:%02d", hourOfDay, minute));
|
||||||
|
|
||||||
//checkIfFinished();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showTimePickerDialog() {
|
public void showTimePickerDialog() {
|
||||||
FragmentManager fm = getFragmentManager();
|
FragmentManager fm = getFragmentManager();
|
||||||
timePickerFragment = (TimePickerFragment) fm.findFragmentByTag("Pick Time");
|
if(fm != null){
|
||||||
|
timePickerFragment = (TimePickerFragment) fm.findFragmentByTag("Pick Time");
|
||||||
|
|
||||||
if(timePickerFragment == null){
|
if(timePickerFragment == null){
|
||||||
timePickerFragment = new TimePickerFragment();
|
timePickerFragment = new TimePickerFragment();
|
||||||
|
}
|
||||||
|
|
||||||
|
timePickerFragment.show(fm, "Pick Time");
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get FragmentManager");
|
||||||
}
|
}
|
||||||
|
|
||||||
timePickerFragment.show(fm, "Pick Time");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {
|
public static class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {
|
||||||
@@ -309,40 +320,54 @@ public class ReportWF_2_Fragment extends BaseReportWFFragment {
|
|||||||
int month = c.get(Calendar.MONTH);
|
int month = c.get(Calendar.MONTH);
|
||||||
int day = c.get(Calendar.DAY_OF_MONTH);
|
int day = c.get(Calendar.DAY_OF_MONTH);
|
||||||
|
|
||||||
|
ReportWFActivity activity = null;
|
||||||
|
|
||||||
if(tmpIsToDate && inputDateFrom.getText().length() > 0){
|
if(tmpIsToDate && inputDateFrom.getText().length() > 0){
|
||||||
try {
|
try {
|
||||||
DatePickerDialog tmpDialog = new DatePickerDialog(getActivity(), this, year, month, day);
|
activity = (ReportWFActivity) getActivity();
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
if(activity != null){
|
||||||
Date tmpFromDate = simpleDateFormat.parse(inputDateFrom.getText().toString());
|
DatePickerDialog tmpDialog = new DatePickerDialog(activity, this, year, month, day);
|
||||||
tmpDialog.getDatePicker().setMinDate(tmpFromDate.getTime());
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
|
||||||
tmpIsToDate = false;
|
Date tmpFromDate = simpleDateFormat.parse(inputDateFrom.getText().toString());
|
||||||
return tmpDialog;
|
tmpDialog.getDatePicker().setMinDate(tmpFromDate.getTime());
|
||||||
} catch (ParseException e) {
|
tmpIsToDate = false;
|
||||||
e.printStackTrace();
|
return tmpDialog;
|
||||||
}
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (ParseException e) {
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Exception caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new DatePickerDialog(getActivity(), this, year, month, day);
|
if(activity != null) {
|
||||||
|
return new DatePickerDialog(activity, this, year, month, day);
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity and therefore trying again to retrieve parent");
|
||||||
|
return new DatePickerDialog(getActivity(),this, year, month, day);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDateSet(DatePicker view, int year, int month, int day) {
|
public void onDateSet(DatePicker view, int year, int month, int day) {
|
||||||
tmpInput.setText(String.format("%04d-%02d-%02d",year,month + 1,day));
|
tmpInput.setText(String.format(Locale.US, "%04d-%02d-%02d",year, month + 1, day));
|
||||||
|
|
||||||
//checkIfFinished();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showDatePickerDialog() {
|
public void showDatePickerDialog() {
|
||||||
|
|
||||||
FragmentManager fm = getFragmentManager();
|
FragmentManager fm = getFragmentManager();
|
||||||
datePickerFragment = (DatePickerFragment) fm.findFragmentByTag("Pick Date");
|
if(fm != null){
|
||||||
|
datePickerFragment = (DatePickerFragment) fm.findFragmentByTag("Pick Date");
|
||||||
|
|
||||||
if(datePickerFragment == null){
|
if(datePickerFragment == null){
|
||||||
datePickerFragment = new DatePickerFragment();
|
datePickerFragment = new DatePickerFragment();
|
||||||
|
}
|
||||||
|
|
||||||
|
datePickerFragment.show(fm, "Pick Date");
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get FragmentManager");
|
||||||
}
|
}
|
||||||
|
|
||||||
datePickerFragment.show(fm, "Pick Date");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkIfFinished(){
|
private void checkIfFinished(){
|
||||||
@@ -384,7 +409,13 @@ public class ReportWF_2_Fragment extends BaseReportWFFragment {
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
incident = ((ReportWFActivity)getActivity()).getIncident();
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
incident = activity.getIncident();
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not retrieve parent activity");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(incident != null){
|
if(incident != null){
|
||||||
if(incident.getFidTimeCategory() != 0){
|
if(incident.getFidTimeCategory() != 0){
|
||||||
@@ -446,7 +477,13 @@ public class ReportWF_2_Fragment extends BaseReportWFFragment {
|
|||||||
incident.setToDate(inputDateTo.getText().toString());
|
incident.setToDate(inputDateTo.getText().toString());
|
||||||
incident.setToTime(inputTimeTo.getText().toString());
|
incident.setToTime(inputTimeTo.getText().toString());
|
||||||
|
|
||||||
((ReportWFActivity)getActivity()).setIncident(incident);
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
activity.setIncident(incident);
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package org.deke.risk.riskahead.fragment;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -10,6 +11,8 @@ import android.widget.ArrayAdapter;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
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;
|
||||||
@@ -32,6 +35,8 @@ public class ReportWF_3_Fragment extends BaseReportWFFragment {
|
|||||||
private final static int DONTKNOW = 7;
|
private final static int DONTKNOW = 7;
|
||||||
private final static int ETC = 8;
|
private final static int ETC = 8;
|
||||||
|
|
||||||
|
private final static String TAG = ReportWF_3_Fragment.class.getSimpleName();
|
||||||
|
|
||||||
private View viewFragment;
|
private View viewFragment;
|
||||||
|
|
||||||
private Spinner suspectCategory;
|
private Spinner suspectCategory;
|
||||||
@@ -68,9 +73,9 @@ public class ReportWF_3_Fragment extends BaseReportWFFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initInputElements() {
|
private void initInputElements() {
|
||||||
suspectCategory = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_3_suspect);
|
suspectCategory = viewFragment.findViewById(R.id.dd_reportwf_3_suspect);
|
||||||
suspectSubCategory = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_3_suspect_sub);
|
suspectSubCategory = viewFragment.findViewById(R.id.dd_reportwf_3_suspect_sub);
|
||||||
suspectEtcInput = (EditText) viewFragment.findViewById(R.id.txt_reportwf_3_suspect_etc);
|
suspectEtcInput = viewFragment.findViewById(R.id.txt_reportwf_3_suspect_etc);
|
||||||
|
|
||||||
suspectSubCategory.setVisibility(View.INVISIBLE);
|
suspectSubCategory.setVisibility(View.INVISIBLE);
|
||||||
suspectEtcInput.setVisibility(View.INVISIBLE);
|
suspectEtcInput.setVisibility(View.INVISIBLE);
|
||||||
@@ -144,8 +149,14 @@ public class ReportWF_3_Fragment extends BaseReportWFFragment {
|
|||||||
|
|
||||||
|
|
||||||
private void setMainSpinnerValues(int stringId) {
|
private void setMainSpinnerValues(int stringId) {
|
||||||
ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(getActivity(),stringId, android.R.layout.simple_spinner_dropdown_item);
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
suspectCategory.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, getActivity()));
|
if(activity != null){
|
||||||
|
ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(activity,stringId, android.R.layout.simple_spinner_dropdown_item);
|
||||||
|
suspectCategory.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, activity));
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setSubSpinnerValues(int stringId) {
|
private void setSubSpinnerValues(int stringId) {
|
||||||
@@ -173,7 +184,12 @@ public class ReportWF_3_Fragment extends BaseReportWFFragment {
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
incident = ((ReportWFActivity)getActivity()).getIncident();
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
incident = activity.getIncident();
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
|
|
||||||
if(incident != null){
|
if(incident != null){
|
||||||
if(incident.getFidSuspectCategory() != 0) suspectCategory.setSelection(incident.getFidSuspectCategory());
|
if(incident.getFidSuspectCategory() != 0) suspectCategory.setSelection(incident.getFidSuspectCategory());
|
||||||
@@ -196,7 +212,12 @@ public class ReportWF_3_Fragment extends BaseReportWFFragment {
|
|||||||
incident.setFidSuspectSubCategory(suspectSubCategory.getSelectedItemPosition());
|
incident.setFidSuspectSubCategory(suspectSubCategory.getSelectedItemPosition());
|
||||||
incident.setEtcSuspectCategory(suspectEtcInput.getText().toString());
|
incident.setEtcSuspectCategory(suspectEtcInput.getText().toString());
|
||||||
|
|
||||||
((ReportWFActivity)getActivity()).setIncident(incident);
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
activity.setIncident(incident);
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package org.deke.risk.riskahead.fragment;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -10,6 +11,8 @@ import android.widget.ArrayAdapter;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
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.adapter.SpinnerHintAdapter;
|
import org.deke.risk.riskahead.adapter.SpinnerHintAdapter;
|
||||||
@@ -30,6 +33,8 @@ public class ReportWF_4_Fragment extends BaseReportWFFragment {
|
|||||||
private final static int ETC = 6;
|
private final static int ETC = 6;
|
||||||
private final static int DONTKNOW = 5;
|
private final static int DONTKNOW = 5;
|
||||||
|
|
||||||
|
private final static String TAG = ReportWF_4_Fragment.class.getSimpleName();
|
||||||
|
|
||||||
private View viewFragment;
|
private View viewFragment;
|
||||||
|
|
||||||
private Spinner suspectWeapon;
|
private Spinner suspectWeapon;
|
||||||
@@ -66,8 +71,8 @@ public class ReportWF_4_Fragment extends BaseReportWFFragment {
|
|||||||
|
|
||||||
|
|
||||||
private void initInputElements() {
|
private void initInputElements() {
|
||||||
suspectWeapon = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_4_weapon);
|
suspectWeapon = viewFragment.findViewById(R.id.dd_reportwf_4_weapon);
|
||||||
suspectWeaponEtcInput = (EditText) viewFragment.findViewById(R.id.txt_reportwf_4_weapon_etc);
|
suspectWeaponEtcInput = viewFragment.findViewById(R.id.txt_reportwf_4_weapon_etc);
|
||||||
|
|
||||||
suspectWeaponEtcInput.setVisibility(View.INVISIBLE);
|
suspectWeaponEtcInput.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
@@ -108,8 +113,14 @@ public class ReportWF_4_Fragment extends BaseReportWFFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setMainSpinnerValues(int stringId){
|
private void setMainSpinnerValues(int stringId){
|
||||||
ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(getActivity(), stringId, android.R.layout.simple_spinner_dropdown_item);
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
suspectWeapon.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, getActivity()));
|
if(activity != null){
|
||||||
|
ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(activity, stringId, android.R.layout.simple_spinner_dropdown_item);
|
||||||
|
suspectWeapon.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, activity));
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -128,7 +139,12 @@ public class ReportWF_4_Fragment extends BaseReportWFFragment {
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
incident = ((ReportWFActivity)getActivity()).getIncident();
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
incident = activity.getIncident();
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
|
|
||||||
if(incident != null){
|
if(incident != null){
|
||||||
if(incident.getFidSuspectWeaponCategory() != 0) suspectWeapon.setSelection(incident.getFidSuspectWeaponCategory());
|
if(incident.getFidSuspectWeaponCategory() != 0) suspectWeapon.setSelection(incident.getFidSuspectWeaponCategory());
|
||||||
@@ -149,7 +165,12 @@ public class ReportWF_4_Fragment extends BaseReportWFFragment {
|
|||||||
incident.setFidSuspectWeaponCategory(suspectWeapon.getSelectedItemPosition());
|
incident.setFidSuspectWeaponCategory(suspectWeapon.getSelectedItemPosition());
|
||||||
incident.setEtcSuspectWeaponCategory(suspectWeaponEtcInput.getText().toString());
|
incident.setEtcSuspectWeaponCategory(suspectWeaponEtcInput.getText().toString());
|
||||||
|
|
||||||
((ReportWFActivity)getActivity()).setIncident(incident);
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
activity.setIncident(incident);
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package org.deke.risk.riskahead.fragment;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -10,6 +11,8 @@ import android.widget.ArrayAdapter;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
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.adapter.SpinnerHintAdapter;
|
import org.deke.risk.riskahead.adapter.SpinnerHintAdapter;
|
||||||
@@ -23,14 +26,14 @@ import org.deke.risk.riskahead.helper.IncidentReport;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ReportWF_5_Fragment extends BaseReportWFFragment {
|
public class ReportWF_5_Fragment extends BaseReportWFFragment {
|
||||||
|
|
||||||
|
|
||||||
private final static int SINGLE_PERSON = 1;
|
private final static int SINGLE_PERSON = 1;
|
||||||
private final static int SMALL_GROUP = 2;
|
private final static int SMALL_GROUP = 2;
|
||||||
private final static int BIG_GROUP = 3;
|
private final static int BIG_GROUP = 3;
|
||||||
private final static int ETC = 5;
|
private final static int ETC = 5;
|
||||||
private final static int DONTKNOW = 4;
|
private final static int DONTKNOW = 4;
|
||||||
|
|
||||||
|
private final static String TAG = ReportWF_5_Fragment.class.getSimpleName();
|
||||||
|
|
||||||
private View viewFragment;
|
private View viewFragment;
|
||||||
|
|
||||||
private Spinner suspectCount;
|
private Spinner suspectCount;
|
||||||
@@ -66,8 +69,8 @@ public class ReportWF_5_Fragment extends BaseReportWFFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initInputElements() {
|
private void initInputElements() {
|
||||||
suspectCount = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_5_count);
|
suspectCount = viewFragment.findViewById(R.id.dd_reportwf_5_count);
|
||||||
suspectCountEtcInput = (EditText) viewFragment.findViewById(R.id.txt_reportwf_5_count_etc);
|
suspectCountEtcInput = viewFragment.findViewById(R.id.txt_reportwf_5_count_etc);
|
||||||
|
|
||||||
suspectCountEtcInput.setVisibility(View.INVISIBLE);
|
suspectCountEtcInput.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
@@ -105,8 +108,13 @@ public class ReportWF_5_Fragment extends BaseReportWFFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setMainSpinnerValues(int stringId){
|
private void setMainSpinnerValues(int stringId){
|
||||||
ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(getActivity(), stringId, android.R.layout.simple_spinner_dropdown_item);
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
suspectCount.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, getActivity()));
|
if(activity != null){
|
||||||
|
ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(activity, stringId, android.R.layout.simple_spinner_dropdown_item);
|
||||||
|
suspectCount.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, activity));
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -124,7 +132,12 @@ public class ReportWF_5_Fragment extends BaseReportWFFragment {
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
incident = ((ReportWFActivity)getActivity()).getIncident();
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
incident = activity.getIncident();
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
|
|
||||||
if(incident != null){
|
if(incident != null){
|
||||||
if(incident.getFidSuspectCountCategory() != 0) suspectCount.setSelection(incident.getFidSuspectCountCategory());
|
if(incident.getFidSuspectCountCategory() != 0) suspectCount.setSelection(incident.getFidSuspectCountCategory());
|
||||||
@@ -145,7 +158,13 @@ public class ReportWF_5_Fragment extends BaseReportWFFragment {
|
|||||||
incident.setFidSuspectCountCategory(suspectCount.getSelectedItemPosition());
|
incident.setFidSuspectCountCategory(suspectCount.getSelectedItemPosition());
|
||||||
incident.setEtcSuspectCountCategory(suspectCountEtcInput.getText().toString());
|
incident.setEtcSuspectCountCategory(suspectCountEtcInput.getText().toString());
|
||||||
|
|
||||||
((ReportWFActivity)getActivity()).setIncident(incident);
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
activity.setIncident(incident);
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package org.deke.risk.riskahead.fragment;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -9,6 +10,8 @@ import android.widget.AdapterView;
|
|||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
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.adapter.SpinnerHintAdapter;
|
import org.deke.risk.riskahead.adapter.SpinnerHintAdapter;
|
||||||
@@ -22,19 +25,17 @@ import org.deke.risk.riskahead.helper.IncidentReport;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ReportWF_6_Fragment extends BaseReportWFFragment {
|
public class ReportWF_6_Fragment extends BaseReportWFFragment {
|
||||||
|
|
||||||
private final static int WOMEN = 1;
|
private final static int WOMEN = 1;
|
||||||
private final static int CHILDREN = 2;
|
private final static int CHILDREN = 2;
|
||||||
private final static int MEN = 3;
|
private final static int MEN = 3;
|
||||||
private final static int ANIMALS = 4;
|
private final static int ANIMALS = 4;
|
||||||
private final static int INFRASTRUCTURE = 5;
|
private final static int INFRASTRUCTURE = 5;
|
||||||
|
|
||||||
|
private final static String TAG = ReportWF_6_Fragment.class.getSimpleName();
|
||||||
|
|
||||||
private View viewFragment;
|
private View viewFragment;
|
||||||
|
|
||||||
private Spinner victimType;
|
private Spinner victimType;
|
||||||
|
|
||||||
private IncidentReport incident;
|
private IncidentReport incident;
|
||||||
|
|
||||||
private OnInputFinishedListener mCallback;
|
private OnInputFinishedListener mCallback;
|
||||||
|
|
||||||
public interface OnInputFinishedListener {
|
public interface OnInputFinishedListener {
|
||||||
@@ -63,7 +64,7 @@ public class ReportWF_6_Fragment extends BaseReportWFFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initInputElements() {
|
private void initInputElements() {
|
||||||
victimType = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_6_victim);
|
victimType = viewFragment.findViewById(R.id.dd_reportwf_6_victim);
|
||||||
|
|
||||||
victimType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
victimType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -93,11 +94,15 @@ public class ReportWF_6_Fragment extends BaseReportWFFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setMainSpinnerValues(int stringId){
|
private void setMainSpinnerValues(int stringId){
|
||||||
ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(getActivity(), stringId, android.R.layout.simple_spinner_dropdown_item);
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
victimType.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, getActivity()));
|
if(activity != null){
|
||||||
|
ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(activity, stringId, android.R.layout.simple_spinner_dropdown_item);
|
||||||
|
victimType.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, activity));
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void checkIfFinished(){
|
private void checkIfFinished(){
|
||||||
boolean isMainCategoryFilled = false;
|
boolean isMainCategoryFilled = false;
|
||||||
|
|
||||||
@@ -112,7 +117,12 @@ public class ReportWF_6_Fragment extends BaseReportWFFragment {
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
incident = ((ReportWFActivity)getActivity()).getIncident();
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
incident = activity.getIncident();
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
|
|
||||||
if(incident != null){
|
if(incident != null){
|
||||||
if(incident.getFidVictimCategory() != 0) victimType.setSelection(incident.getFidVictimCategory());
|
if(incident.getFidVictimCategory() != 0) victimType.setSelection(incident.getFidVictimCategory());
|
||||||
@@ -131,7 +141,12 @@ public class ReportWF_6_Fragment extends BaseReportWFFragment {
|
|||||||
private void saveInput(){
|
private void saveInput(){
|
||||||
incident.setFidVictimCategory(victimType.getSelectedItemPosition());
|
incident.setFidVictimCategory(victimType.getSelectedItemPosition());
|
||||||
|
|
||||||
((ReportWFActivity)getActivity()).setIncident(incident);
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
activity.setIncident(incident);
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package org.deke.risk.riskahead.fragment;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -10,6 +11,8 @@ import android.widget.ArrayAdapter;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
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.adapter.SpinnerHintAdapter;
|
import org.deke.risk.riskahead.adapter.SpinnerHintAdapter;
|
||||||
@@ -23,21 +26,18 @@ import org.deke.risk.riskahead.helper.IncidentReport;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ReportWF_7_Fragment extends BaseReportWFFragment {
|
public class ReportWF_7_Fragment extends BaseReportWFFragment {
|
||||||
|
|
||||||
|
|
||||||
private final static int LOCAL = 1;
|
private final static int LOCAL = 1;
|
||||||
private final static int TOURIST = 2;
|
private final static int TOURIST = 2;
|
||||||
private final static int FOREIGNER = 3;
|
private final static int FOREIGNER = 3;
|
||||||
private final static int ETC = 5;
|
private final static int ETC = 5;
|
||||||
private final static int DONTKNOW = 4;
|
private final static int DONTKNOW = 4;
|
||||||
|
|
||||||
private View viewFragment;
|
private final static String TAG = ReportWF_7_Fragment.class.getSimpleName();
|
||||||
|
|
||||||
|
private View viewFragment;
|
||||||
private Spinner victimOrigin;
|
private Spinner victimOrigin;
|
||||||
private EditText victimOriginEtcInput;
|
private EditText victimOriginEtcInput;
|
||||||
|
|
||||||
private IncidentReport incident;
|
private IncidentReport incident;
|
||||||
|
|
||||||
private OnInputFinishedListener mCallback;
|
private OnInputFinishedListener mCallback;
|
||||||
|
|
||||||
public interface OnInputFinishedListener {
|
public interface OnInputFinishedListener {
|
||||||
@@ -66,8 +66,8 @@ public class ReportWF_7_Fragment extends BaseReportWFFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initInputElements() {
|
private void initInputElements() {
|
||||||
victimOrigin = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_7_victimorigin);
|
victimOrigin = viewFragment.findViewById(R.id.dd_reportwf_7_victimorigin);
|
||||||
victimOriginEtcInput = (EditText) viewFragment.findViewById(R.id.txt_reportwf_7_victimorigin_etc);
|
victimOriginEtcInput = viewFragment.findViewById(R.id.txt_reportwf_7_victimorigin_etc);
|
||||||
|
|
||||||
victimOriginEtcInput.setVisibility(View.INVISIBLE);
|
victimOriginEtcInput.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
@@ -105,8 +105,13 @@ public class ReportWF_7_Fragment extends BaseReportWFFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setMainSpinnerValues(int stringId){
|
private void setMainSpinnerValues(int stringId){
|
||||||
ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(getActivity(), stringId, android.R.layout.simple_spinner_dropdown_item);
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
victimOrigin.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, getActivity()));
|
if(activity != null){
|
||||||
|
ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(activity, stringId, android.R.layout.simple_spinner_dropdown_item);
|
||||||
|
victimOrigin.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, activity));
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -124,7 +129,12 @@ public class ReportWF_7_Fragment extends BaseReportWFFragment {
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
incident = ((ReportWFActivity)getActivity()).getIncident();
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
incident = activity.getIncident();
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
|
|
||||||
if(incident != null){
|
if(incident != null){
|
||||||
if(incident.getFidVictimOriginCategory() != 0) victimOrigin.setSelection(incident.getFidVictimOriginCategory());
|
if(incident.getFidVictimOriginCategory() != 0) victimOrigin.setSelection(incident.getFidVictimOriginCategory());
|
||||||
@@ -145,7 +155,12 @@ public class ReportWF_7_Fragment extends BaseReportWFFragment {
|
|||||||
incident.setFidVictimOriginCategory(victimOrigin.getSelectedItemPosition());
|
incident.setFidVictimOriginCategory(victimOrigin.getSelectedItemPosition());
|
||||||
incident.setEtcVictimOriginCategory(victimOriginEtcInput.getText().toString());
|
incident.setEtcVictimOriginCategory(victimOriginEtcInput.getText().toString());
|
||||||
|
|
||||||
((ReportWFActivity)getActivity()).setIncident(incident);
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
activity.setIncident(incident);
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package org.deke.risk.riskahead.fragment;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@@ -10,6 +11,8 @@ import android.widget.ArrayAdapter;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.Spinner;
|
import android.widget.Spinner;
|
||||||
|
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
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.adapter.SpinnerHintAdapter;
|
import org.deke.risk.riskahead.adapter.SpinnerHintAdapter;
|
||||||
@@ -23,8 +26,6 @@ import org.deke.risk.riskahead.helper.IncidentReport;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ReportWF_8_Fragment extends BaseReportWFFragment {
|
public class ReportWF_8_Fragment extends BaseReportWFFragment {
|
||||||
|
|
||||||
|
|
||||||
private final static int FEET = 1;
|
private final static int FEET = 1;
|
||||||
private final static int MOTORBIKE = 2;
|
private final static int MOTORBIKE = 2;
|
||||||
private final static int CAR = 3;
|
private final static int CAR = 3;
|
||||||
@@ -47,6 +48,8 @@ public class ReportWF_8_Fragment extends BaseReportWFFragment {
|
|||||||
private final static int ANIMALS = 4;
|
private final static int ANIMALS = 4;
|
||||||
private final static int ETC_3 = 5;
|
private final static int ETC_3 = 5;
|
||||||
|
|
||||||
|
private final static String TAG = ReportWF_8_Fragment.class.getSimpleName();
|
||||||
|
|
||||||
private View viewFragment;
|
private View viewFragment;
|
||||||
|
|
||||||
private Spinner suspectVehicle;
|
private Spinner suspectVehicle;
|
||||||
@@ -86,7 +89,7 @@ public class ReportWF_8_Fragment extends BaseReportWFFragment {
|
|||||||
initSuspectRecognitionInputElements();
|
initSuspectRecognitionInputElements();
|
||||||
setSuspectRecognitionMainSpinnerValues(R.array.cat_details_suspect_recon);
|
setSuspectRecognitionMainSpinnerValues(R.array.cat_details_suspect_recon);
|
||||||
|
|
||||||
moreEtcInput = (EditText) viewFragment.findViewById(R.id.txt_reportwf_8_etc);
|
moreEtcInput = viewFragment.findViewById(R.id.txt_reportwf_8_etc);
|
||||||
|
|
||||||
return viewFragment;
|
return viewFragment;
|
||||||
}
|
}
|
||||||
@@ -98,8 +101,8 @@ public class ReportWF_8_Fragment extends BaseReportWFFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initSuspectVehicleInputElements() {
|
private void initSuspectVehicleInputElements() {
|
||||||
suspectVehicle = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_8_suspectvehicle);
|
suspectVehicle = viewFragment.findViewById(R.id.dd_reportwf_8_suspectvehicle);
|
||||||
suspectVehicleEtcInput = (EditText) viewFragment.findViewById(R.id.txt_reportwf_8_suspectvehicle);
|
suspectVehicleEtcInput = viewFragment.findViewById(R.id.txt_reportwf_8_suspectvehicle);
|
||||||
|
|
||||||
suspectVehicleEtcInput.setVisibility(View.INVISIBLE);
|
suspectVehicleEtcInput.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
@@ -143,13 +146,18 @@ public class ReportWF_8_Fragment extends BaseReportWFFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setSuspectVehicleMainSpinnerValues(int stringId){
|
private void setSuspectVehicleMainSpinnerValues(int stringId){
|
||||||
ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(getActivity(), stringId, android.R.layout.simple_spinner_dropdown_item);
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
suspectVehicle.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, getActivity()));
|
if(activity != null){
|
||||||
|
ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(activity, stringId, android.R.layout.simple_spinner_dropdown_item);
|
||||||
|
suspectVehicle.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, activity));
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initVictimAffiliationInputElements() {
|
private void initVictimAffiliationInputElements() {
|
||||||
victimAffiliation = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_8_victimaff);
|
victimAffiliation = viewFragment.findViewById(R.id.dd_reportwf_8_victimaff);
|
||||||
victimAffiliationEtcInput = (EditText) viewFragment.findViewById(R.id.txt_reportwf_8_victimaff);
|
victimAffiliationEtcInput = viewFragment.findViewById(R.id.txt_reportwf_8_victimaff);
|
||||||
|
|
||||||
victimAffiliationEtcInput.setVisibility(View.INVISIBLE);
|
victimAffiliationEtcInput.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
@@ -193,13 +201,18 @@ public class ReportWF_8_Fragment extends BaseReportWFFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setVictimAffiliationMainSpinnerValues(int stringId){
|
private void setVictimAffiliationMainSpinnerValues(int stringId){
|
||||||
ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(getActivity(), stringId, android.R.layout.simple_spinner_dropdown_item);
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
victimAffiliation.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, getActivity()));
|
if(activity != null){
|
||||||
|
ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(activity, stringId, android.R.layout.simple_spinner_dropdown_item);
|
||||||
|
victimAffiliation.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, activity));
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initSuspectRecognitionInputElements() {
|
private void initSuspectRecognitionInputElements() {
|
||||||
suspectRecongnition = (Spinner) viewFragment.findViewById(R.id.dd_reportwf_8_recon);
|
suspectRecongnition = viewFragment.findViewById(R.id.dd_reportwf_8_recon);
|
||||||
suspectRecongnitionEtcInput = (EditText) viewFragment.findViewById(R.id.txt_reportwf_8_recon);
|
suspectRecongnitionEtcInput = viewFragment.findViewById(R.id.txt_reportwf_8_recon);
|
||||||
|
|
||||||
suspectRecongnitionEtcInput.setVisibility(View.INVISIBLE);
|
suspectRecongnitionEtcInput.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
@@ -237,8 +250,13 @@ public class ReportWF_8_Fragment extends BaseReportWFFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setSuspectRecognitionMainSpinnerValues(int stringId){
|
private void setSuspectRecognitionMainSpinnerValues(int stringId){
|
||||||
ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(getActivity(), stringId, android.R.layout.simple_spinner_dropdown_item);
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
suspectRecongnition.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, getActivity()));
|
if(activity != null){
|
||||||
|
ArrayAdapter<CharSequence> adapter_main_1 = ArrayAdapter.createFromResource(activity, stringId, android.R.layout.simple_spinner_dropdown_item);
|
||||||
|
suspectRecongnition.setAdapter(new SpinnerHintAdapter(adapter_main_1, R.layout.contact_spinner_row_nothing_selected, activity));
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkIfFinished(){
|
private void checkIfFinished(){
|
||||||
@@ -259,7 +277,12 @@ public class ReportWF_8_Fragment extends BaseReportWFFragment {
|
|||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
incident = ((ReportWFActivity)getActivity()).getIncident();
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
incident = activity.getIncident();
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
|
|
||||||
if(incident != null){
|
if(incident != null){
|
||||||
if(incident.getFidSuspectTransportationCategory() != 0) suspectVehicle.setSelection(incident.getFidSuspectTransportationCategory());
|
if(incident.getFidSuspectTransportationCategory() != 0) suspectVehicle.setSelection(incident.getFidSuspectTransportationCategory());
|
||||||
@@ -296,7 +319,12 @@ public class ReportWF_8_Fragment extends BaseReportWFFragment {
|
|||||||
|
|
||||||
incident.setEtcOthersCategory(moreEtcInput.getText().toString());
|
incident.setEtcOthersCategory(moreEtcInput.getText().toString());
|
||||||
|
|
||||||
((ReportWFActivity)getActivity()).setIncident(incident);
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
activity.setIncident(incident);
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -316,6 +344,5 @@ public class ReportWF_8_Fragment extends BaseReportWFFragment {
|
|||||||
super.onDetach();
|
super.onDetach();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,14 @@ package org.deke.risk.riskahead.fragment;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
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;
|
||||||
@@ -22,13 +24,15 @@ import org.deke.risk.riskahead.helper.IncidentReport;
|
|||||||
*/
|
*/
|
||||||
public class ReportWF_Finish_Fragment extends BaseReportWFFragment {
|
public class ReportWF_Finish_Fragment extends BaseReportWFFragment {
|
||||||
|
|
||||||
|
private final static String TAG = ReportWF_Finish_Fragment.class.getSimpleName();
|
||||||
|
|
||||||
private SendReportListener mCallback;
|
private SendReportListener mCallback;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
|
||||||
View viewFragment = inflater.inflate(R.layout.fragment_reportwf_finish, container, false);
|
View viewFragment = inflater.inflate(R.layout.fragment_reportwf_finish, container, false);
|
||||||
|
|
||||||
Button btnSendReport = (Button) viewFragment.findViewById(R.id.btn_reportwf_finish_send);
|
Button btnSendReport = viewFragment.findViewById(R.id.btn_reportwf_finish_send);
|
||||||
btnSendReport.setOnClickListener(new View.OnClickListener() {
|
btnSendReport.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
@@ -41,7 +45,13 @@ public class ReportWF_Finish_Fragment extends BaseReportWFFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IncidentReport getCurrentInput() {
|
public IncidentReport getCurrentInput() {
|
||||||
return ((ReportWFActivity)getActivity()).getIncident();
|
ReportWFActivity activity = (ReportWFActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
return activity.getIncident();
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface SendReportListener {
|
public interface SendReportListener {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import com.android.volley.Request;
|
|||||||
import com.android.volley.Response;
|
import com.android.volley.Response;
|
||||||
import com.android.volley.VolleyError;
|
import com.android.volley.VolleyError;
|
||||||
import com.android.volley.toolbox.StringRequest;
|
import com.android.volley.toolbox.StringRequest;
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
import org.deke.risk.riskahead.R;
|
import org.deke.risk.riskahead.R;
|
||||||
import org.deke.risk.riskahead.SettingsActivity;
|
import org.deke.risk.riskahead.SettingsActivity;
|
||||||
@@ -36,7 +37,6 @@ import java.util.Map;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SettingsFragment extends PreferenceFragment {
|
public class SettingsFragment extends PreferenceFragment {
|
||||||
|
|
||||||
private final static String TAG = SettingsFragment.class.getSimpleName();
|
private final static String TAG = SettingsFragment.class.getSimpleName();
|
||||||
|
|
||||||
private ValidatedEditTextPreference prefUsername;
|
private ValidatedEditTextPreference prefUsername;
|
||||||
@@ -171,33 +171,35 @@ public class SettingsFragment extends PreferenceFragment {
|
|||||||
prefName.setOnPreferenceChangeListener(changeListener);
|
prefName.setOnPreferenceChangeListener(changeListener);
|
||||||
prefEmail.setOnPreferenceChangeListener(changeListener);
|
prefEmail.setOnPreferenceChangeListener(changeListener);
|
||||||
|
|
||||||
btnRequestPW.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
if(btnRequestPW != null){
|
||||||
@Override
|
btnRequestPW.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||||
public boolean onPreferenceClick(Preference preference) {
|
@Override
|
||||||
new AlertDialog.Builder(getActivity())
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
.setTitle(getResources().getString(R.string.txt_settings_resetpwtitle))
|
new AlertDialog.Builder(getActivity())
|
||||||
.setMessage(getResources().getString(R.string.txt_settings_resetpwtext))
|
.setTitle(getResources().getString(R.string.txt_settings_resetpwtitle))
|
||||||
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
.setMessage(getResources().getString(R.string.txt_settings_resetpwtext))
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
|
||||||
requestPasswordReset();
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
}
|
requestPasswordReset();
|
||||||
})
|
}
|
||||||
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
|
})
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
.setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
|
||||||
// do nothing
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
}
|
// do nothing
|
||||||
})
|
}
|
||||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
})
|
||||||
.show();
|
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||||
|
.show();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(!user.get(SessionManager.PROVIDER_TYPE).equals("local")){
|
||||||
|
btnRequestPW.setEnabled(false);
|
||||||
|
}else{
|
||||||
|
btnRequestPW.setEnabled(true);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
if(!user.get(SessionManager.PROVIDER_TYPE).equals("local")){
|
|
||||||
btnRequestPW.setEnabled(false);
|
|
||||||
}else{
|
|
||||||
btnRequestPW.setEnabled(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,11 +258,12 @@ public class SettingsFragment extends PreferenceFragment {
|
|||||||
((SettingsActivity) getActivity()).showMessage(getString(R.string.alert_passwordreset_confirmation));
|
((SettingsActivity) getActivity()).showMessage(getString(R.string.alert_passwordreset_confirmation));
|
||||||
}else{
|
}else{
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error request email reset (Server returned error): " + errorMsg);
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error request email reset (Server returned error): " + errorMsg);
|
||||||
((SettingsActivity) getActivity()).showMessage(getResources().getString(R.string.txt_errormsg_resetpw));
|
((SettingsActivity) getActivity()).showMessage(getResources().getString(R.string.txt_errormsg_resetpw));
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -268,7 +271,7 @@ public class SettingsFragment extends PreferenceFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "Error request email reset: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error request email reset: " + error.getMessage());
|
||||||
((SettingsActivity) getActivity()).showMessage(getString(R.string.errormsg_couldnotretrieve));
|
((SettingsActivity) getActivity()).showMessage(getString(R.string.errormsg_couldnotretrieve));
|
||||||
((SettingsActivity) getActivity()).hideDialog();
|
((SettingsActivity) getActivity()).hideDialog();
|
||||||
}
|
}
|
||||||
@@ -338,12 +341,13 @@ public class SettingsFragment extends PreferenceFragment {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error getting user settings (Server returned error): " + errorMsg);
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error getting user settings (Server returned error): " + errorMsg);
|
||||||
((SettingsActivity) getActivity()).showMessage(getResources().getString(R.string.txt_errormsg_changesettings));
|
((SettingsActivity) getActivity()).showMessage(getResources().getString(R.string.txt_errormsg_changesettings));
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
} finally {
|
} finally {
|
||||||
updatePrefs();
|
updatePrefs();
|
||||||
}
|
}
|
||||||
@@ -355,7 +359,7 @@ public class SettingsFragment extends PreferenceFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "Error getting user settings: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error getting user settings: " + error.getMessage());
|
||||||
((SettingsActivity) getActivity()).showMessage(getString(R.string.errormsg_couldnotretrieve));
|
((SettingsActivity) getActivity()).showMessage(getString(R.string.errormsg_couldnotretrieve));
|
||||||
((SettingsActivity) getActivity()).hideDialog();
|
((SettingsActivity) getActivity()).hideDialog();
|
||||||
updatePrefs();
|
updatePrefs();
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package org.deke.risk.riskahead.fragment;
|
package org.deke.risk.riskahead.fragment;
|
||||||
|
|
||||||
import android.media.Image;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@@ -12,8 +11,8 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import com.beardedhen.androidbootstrap.BootstrapButton;
|
import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||||
import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand;
|
import com.beardedhen.androidbootstrap.api.defaults.DefaultBootstrapBrand;
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
import org.deke.risk.riskahead.ProfileActivity;
|
|
||||||
import org.deke.risk.riskahead.R;
|
import org.deke.risk.riskahead.R;
|
||||||
import org.deke.risk.riskahead.SubscriptionsActivity;
|
import org.deke.risk.riskahead.SubscriptionsActivity;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@@ -27,7 +26,6 @@ import org.json.JSONObject;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SubscriptionItemFragment extends Fragment {
|
public class SubscriptionItemFragment extends Fragment {
|
||||||
|
|
||||||
private final static String TAG = SubscriptionItemFragment.class.getSimpleName();
|
private final static String TAG = SubscriptionItemFragment.class.getSimpleName();
|
||||||
|
|
||||||
private SubscriptionsActivity parent;
|
private SubscriptionsActivity parent;
|
||||||
@@ -43,12 +41,12 @@ public class SubscriptionItemFragment extends Fragment {
|
|||||||
View view = inflater.inflate(R.layout.fragment_subscriptionitem, container, false);
|
View view = inflater.inflate(R.layout.fragment_subscriptionitem, container, false);
|
||||||
parent = (SubscriptionsActivity)getActivity();
|
parent = (SubscriptionsActivity)getActivity();
|
||||||
|
|
||||||
txtTitle = (TextView) view.findViewById(R.id.txt_subs_title);
|
txtTitle = view.findViewById(R.id.txt_subs_title);
|
||||||
txtDescription = (TextView) view.findViewById(R.id.txt_subs_desc);
|
txtDescription = view.findViewById(R.id.txt_subs_desc);
|
||||||
btnPurchase = (BootstrapButton) view.findViewById(R.id.btn_sub_purchase);
|
btnPurchase = view.findViewById(R.id.btn_sub_purchase);
|
||||||
|
|
||||||
imgSubs = (ImageView) view.findViewById(R.id.img_subs);
|
imgSubs = view.findViewById(R.id.img_subs);
|
||||||
btnBadge = (BootstrapButton) view.findViewById(R.id.btn_subs_membershiptype);
|
btnBadge = view.findViewById(R.id.btn_subs_membershiptype);
|
||||||
|
|
||||||
txtTitle.setVisibility(View.GONE);
|
txtTitle.setVisibility(View.GONE);
|
||||||
txtDescription.setVisibility(View.GONE);
|
txtDescription.setVisibility(View.GONE);
|
||||||
@@ -79,7 +77,6 @@ public class SubscriptionItemFragment extends Fragment {
|
|||||||
btnBadge.setText(getResources().getString(R.string.lbl_membershiptype_premium));
|
btnBadge.setText(getResources().getString(R.string.lbl_membershiptype_premium));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
txtTitle.setText(title);
|
txtTitle.setText(title);
|
||||||
txtDescription.setText(description);
|
txtDescription.setText(description);
|
||||||
btnPurchase.setText(price);
|
btnPurchase.setText(price);
|
||||||
@@ -98,9 +95,8 @@ public class SubscriptionItemFragment extends Fragment {
|
|||||||
imgSubs.setVisibility(View.VISIBLE);
|
imgSubs.setVisibility(View.VISIBLE);
|
||||||
btnBadge.setVisibility(View.VISIBLE);
|
btnBadge.setVisibility(View.VISIBLE);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import com.android.volley.Request;
|
|||||||
import com.android.volley.Response;
|
import com.android.volley.Response;
|
||||||
import com.android.volley.VolleyError;
|
import com.android.volley.VolleyError;
|
||||||
import com.android.volley.toolbox.StringRequest;
|
import com.android.volley.toolbox.StringRequest;
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
import org.deke.risk.riskahead.ProfileActivity;
|
import org.deke.risk.riskahead.ProfileActivity;
|
||||||
import org.deke.risk.riskahead.R;
|
import org.deke.risk.riskahead.R;
|
||||||
@@ -38,8 +39,8 @@ import java.util.Map;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Top10Fragment extends Fragment {
|
public class Top10Fragment extends Fragment {
|
||||||
|
|
||||||
private final static String TAG = ProfileStatisticsFragment.class.getSimpleName();
|
private final static String TAG = ProfileStatisticsFragment.class.getSimpleName();
|
||||||
|
|
||||||
private ProfileActivity parent;
|
private ProfileActivity parent;
|
||||||
|
|
||||||
ListView myListView;
|
ListView myListView;
|
||||||
@@ -51,7 +52,7 @@ public class Top10Fragment extends Fragment {
|
|||||||
View view = inflater.inflate(R.layout.fragment_top10list, container, false);
|
View view = inflater.inflate(R.layout.fragment_top10list, container, false);
|
||||||
parent = (ProfileActivity)getActivity();
|
parent = (ProfileActivity)getActivity();
|
||||||
|
|
||||||
myListView = (ListView) view.findViewById(R.id.lv_top10list);
|
myListView = view.findViewById(R.id.lv_top10list);
|
||||||
|
|
||||||
myListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
myListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -59,7 +60,8 @@ public class Top10Fragment extends Fragment {
|
|||||||
try {
|
try {
|
||||||
parent.gotoProfileActivity(resultList.get(position).getString("id"));
|
parent.gotoProfileActivity(resultList.get(position).getString("id"));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -70,14 +72,18 @@ public class Top10Fragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void getTop10ForList() {
|
private void getTop10ForList() {
|
||||||
((ProfileActivity)getActivity()).showDialog();
|
ProfileActivity activity = (ProfileActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
activity.showDialog();
|
||||||
|
|
||||||
StringRequest strReq2 = getStringRequestTop10();
|
StringRequest strReq2 = getStringRequestTop10();
|
||||||
String tag_string_req2 = "req_top10";
|
String tag_string_req2 = "req_top10";
|
||||||
AppController.getInstance().addToRequestQueue(strReq2, tag_string_req2);
|
AppController.getInstance().addToRequestQueue(strReq2, tag_string_req2);
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private StringRequest getStringRequestTop10() {
|
private StringRequest getStringRequestTop10() {
|
||||||
return new StringRequest(Request.Method.POST, AppConfig.REST_GET_TOP10, new Response.Listener<String>() {
|
return new StringRequest(Request.Method.POST, AppConfig.REST_GET_TOP10, new Response.Listener<String>() {
|
||||||
|
|
||||||
@@ -105,13 +111,20 @@ public class Top10Fragment extends Fragment {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error getting top 10 stats (Server returned error): " + errorMsg);
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error getting top 10 stats (Server returned error): " + errorMsg);
|
||||||
parent.showMessage(getResources().getString(R.string.txt_errormsg_gettop10));
|
parent.showMessage(getResources().getString(R.string.txt_errormsg_gettop10));
|
||||||
}
|
}
|
||||||
|
|
||||||
((ProfileActivity)getActivity()).hideDialog();
|
ProfileActivity activity = (ProfileActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
activity.hideDialog();
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -119,10 +132,15 @@ public class Top10Fragment extends Fragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "Error getting top 10 stats: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error getting top 10 stats: " + error.getMessage());
|
||||||
((ProfileActivity)getActivity()).hideDialog();
|
|
||||||
((ProfileActivity)getActivity()).handleVolleyErrorResponse();
|
|
||||||
|
|
||||||
|
ProfileActivity activity = (ProfileActivity) getActivity();
|
||||||
|
if(activity != null){
|
||||||
|
activity.hideDialog();
|
||||||
|
activity.handleVolleyErrorResponse();
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get parent Activity");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import android.widget.Toast;
|
|||||||
import io.fabric.sdk.android.Fabric;
|
import io.fabric.sdk.android.Fabric;
|
||||||
|
|
||||||
import com.beardedhen.androidbootstrap.BootstrapButton;
|
import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
import com.twitter.sdk.android.core.Callback;
|
import com.twitter.sdk.android.core.Callback;
|
||||||
import com.twitter.sdk.android.core.Result;
|
import com.twitter.sdk.android.core.Result;
|
||||||
import com.twitter.sdk.android.core.TwitterAuthToken;
|
import com.twitter.sdk.android.core.TwitterAuthToken;
|
||||||
@@ -35,6 +36,7 @@ import org.deke.risk.riskahead.R;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class TwitterButtonFragment extends Fragment {
|
public class TwitterButtonFragment extends Fragment {
|
||||||
|
private final static String TAG = ProfileStatisticsFragment.class.getSimpleName();
|
||||||
|
|
||||||
private BootstrapButton btnLoginTW;
|
private BootstrapButton btnLoginTW;
|
||||||
private TwitterAuthClient client;
|
private TwitterAuthClient client;
|
||||||
@@ -68,7 +70,7 @@ public class TwitterButtonFragment extends Fragment {
|
|||||||
client = new TwitterAuthClient();
|
client = new TwitterAuthClient();
|
||||||
|
|
||||||
view = inflater.inflate(R.layout.fragment_twitter_button, container, false);
|
view = inflater.inflate(R.layout.fragment_twitter_button, container, false);
|
||||||
btnLoginTW = (BootstrapButton) view.findViewById(R.id.btn_login_twitter);
|
btnLoginTW = view.findViewById(R.id.btn_login_twitter);
|
||||||
|
|
||||||
btnLoginTW.setOnClickListener(new View.OnClickListener() {
|
btnLoginTW.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -87,7 +89,7 @@ public class TwitterButtonFragment extends Fragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void failure(TwitterException exception) {
|
public void failure(TwitterException exception) {
|
||||||
Log.e("Twitter", "onFailure wird ausgeführt: "+exception);
|
FirebaseCrash.logcat(Log.ERROR, TAG, "onFailure wird ausgeführt: "+exception);
|
||||||
showMessage("Could not log in with Twitter. Please use E-Mail instead or try again later.");
|
showMessage("Could not log in with Twitter. Please use E-Mail instead or try again later.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class AppRater {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
editor.commit();
|
editor.apply();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -74,7 +74,7 @@ public class AppRater {
|
|||||||
|
|
||||||
Long date_firstLaunch = System.currentTimeMillis();
|
Long date_firstLaunch = System.currentTimeMillis();
|
||||||
editor.putLong("date_firstlaunch", date_firstLaunch);
|
editor.putLong("date_firstlaunch", date_firstLaunch);
|
||||||
editor.commit();
|
editor.apply();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
alert.setNegativeButton(R.string.txt_rate_neverbtn,
|
alert.setNegativeButton(R.string.txt_rate_neverbtn,
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package org.deke.risk.riskahead.helper;
|
package org.deke.risk.riskahead.helper;
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.app.ActivityManager;
|
import android.app.ActivityManager;
|
||||||
import android.app.AlarmManager;
|
import android.app.AlarmManager;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
@@ -19,7 +18,6 @@ import android.net.ConnectivityManager;
|
|||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.ActivityCompat;
|
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
@@ -45,6 +43,7 @@ import com.android.volley.toolbox.StringRequest;
|
|||||||
import com.google.android.gms.ads.AdListener;
|
import com.google.android.gms.ads.AdListener;
|
||||||
import com.google.android.gms.ads.AdRequest;
|
import com.google.android.gms.ads.AdRequest;
|
||||||
import com.google.android.gms.ads.InterstitialAd;
|
import com.google.android.gms.ads.InterstitialAd;
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
|
import com.mikepenz.google_material_typeface_library.GoogleMaterial;
|
||||||
import com.mikepenz.materialdrawer.AccountHeader;
|
import com.mikepenz.materialdrawer.AccountHeader;
|
||||||
import com.mikepenz.materialdrawer.AccountHeaderBuilder;
|
import com.mikepenz.materialdrawer.AccountHeaderBuilder;
|
||||||
@@ -153,7 +152,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
Log.d(TAG, user.get(SessionManager.KEY_UID));
|
Log.d(TAG, user.get(SessionManager.KEY_UID));
|
||||||
|
|
||||||
mToolbar = (Toolbar) findViewById(R.id.toolbar);
|
mToolbar = findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(mToolbar);
|
setSupportActionBar(mToolbar);
|
||||||
initNavigationDrawer(savedInstanceState);
|
initNavigationDrawer(savedInstanceState);
|
||||||
|
|
||||||
@@ -169,9 +168,11 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
|
AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
|
||||||
|
|
||||||
am.setInexactRepeating(AlarmManager.RTC, firstStart, interval,
|
if (am != null){
|
||||||
wtdSServicePendingIntent);
|
am.setInexactRepeating(AlarmManager.RTC, firstStart, interval, wtdSServicePendingIntent);
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "AlarmManager in BaseActivity is null. No AlarmManager found.");
|
||||||
|
}
|
||||||
|
|
||||||
startService(new Intent(this, NotificationService.class));
|
startService(new Intent(this, NotificationService.class));
|
||||||
} else {
|
} else {
|
||||||
@@ -213,14 +214,21 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||||||
try {
|
try {
|
||||||
unregisterReceiver(myReceiver);
|
unregisterReceiver(myReceiver);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Exception caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initProgressDialog() {
|
private void initProgressDialog() {
|
||||||
pDialog = new Dialog(this);
|
pDialog = new Dialog(this);
|
||||||
pDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
pDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
pDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
|
|
||||||
|
if(pDialog.getWindow() != null){
|
||||||
|
pDialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "ProgressDialog Window is null. Could not set BackgroundDrawable.");
|
||||||
|
}
|
||||||
|
|
||||||
pDialog.setContentView(R.layout.dialog_progresscircle);
|
pDialog.setContentView(R.layout.dialog_progresscircle);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,9 +381,18 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void isNetworkAvailable() {
|
public void isNetworkAvailable() {
|
||||||
|
|
||||||
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
|
|
||||||
|
NetworkInfo activeNetworkInfo;
|
||||||
|
|
||||||
|
if(connectivityManager != null){
|
||||||
|
activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not retrieve connectivityManager. Network Status can not be checked.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// In case no activeNetworkInfo is found actually no standard network is present. Output message bos in that case
|
||||||
if (activeNetworkInfo == null) {
|
if (activeNetworkInfo == null) {
|
||||||
new AlertDialog.Builder(this)
|
new AlertDialog.Builder(this)
|
||||||
.setTitle(getString(R.string.alert_internetconnection_title))
|
.setTitle(getString(R.string.alert_internetconnection_title))
|
||||||
@@ -620,7 +637,8 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||||||
try {
|
try {
|
||||||
((TextView) dialoglayout.findViewById(R.id.lbl_about_version)).setText(String.format("Version: %s", getPackageManager().getPackageInfo(getPackageName(), 0).versionName));
|
((TextView) dialoglayout.findViewById(R.id.lbl_about_version)).setText(String.format("Version: %s", getPackageManager().getPackageInfo(getPackageName(), 0).versionName));
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Exception caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(BaseActivity.this)
|
AlertDialog.Builder builder = new AlertDialog.Builder(BaseActivity.this)
|
||||||
@@ -674,17 +692,18 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendFeedback(String feedback) {
|
private void sendFeedback(String feedback) {
|
||||||
String sysprop = "";
|
StringBuilder sysprop = new StringBuilder();
|
||||||
|
|
||||||
java.util.Properties props = System.getProperties();
|
java.util.Properties props = System.getProperties();
|
||||||
java.util.Enumeration e = props.propertyNames();
|
java.util.Enumeration e = props.propertyNames();
|
||||||
while (e.hasMoreElements()) {
|
while (e.hasMoreElements()) {
|
||||||
String k = (String) e.nextElement();
|
String k = (String) e.nextElement();
|
||||||
String v = props.getProperty(k);
|
String v = props.getProperty(k);
|
||||||
sysprop += k + ": " + v + "\n";
|
sysprop.append(k).append(": ").append(v).append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StringRequest strReq = getStringRequestSendFeedback(feedback, sysprop);
|
StringRequest strReq = getStringRequestSendFeedback(feedback, sysprop.toString());
|
||||||
String tag_string_req = "reqsendfeedback";
|
String tag_string_req = "reqsendfeedback";
|
||||||
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
|
||||||
}
|
}
|
||||||
@@ -704,10 +723,11 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||||||
showMessage(getString(R.string.txt_feedback_response));
|
showMessage(getString(R.string.txt_feedback_response));
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error sending feedback (server returned error): " + errorMsg);
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error sending feedback (server returned error): " + errorMsg);
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Exception caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -715,7 +735,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "Error sending feedback: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error sending feedback: " + error.getMessage());
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
@@ -751,11 +771,14 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private boolean isMyNotificationServiceRunning() {
|
private boolean isMyNotificationServiceRunning() {
|
||||||
ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
|
ActivityManager manager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
|
||||||
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
|
if(manager != null){
|
||||||
if (NotificationService.class.getName().equals(service.service.getClassName())) {
|
for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
|
||||||
return true;
|
if (NotificationService.class.getName().equals(service.service.getClassName())) return true;
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not retrieve Activity_Service Manager.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ package org.deke.risk.riskahead.helper;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.google.android.gms.maps.model.BitmapDescriptor;
|
import com.google.android.gms.maps.model.BitmapDescriptor;
|
||||||
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
|
||||||
import com.google.android.gms.maps.model.LatLng;
|
import com.google.android.gms.maps.model.LatLng;
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
import com.google.maps.android.clustering.ClusterItem;
|
import com.google.maps.android.clustering.ClusterItem;
|
||||||
|
|
||||||
import org.deke.risk.riskahead.R;
|
import org.deke.risk.riskahead.R;
|
||||||
@@ -15,6 +17,7 @@ import org.json.JSONObject;
|
|||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -24,6 +27,7 @@ import java.util.Date;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class IncidentReport implements ClusterItem {
|
public class IncidentReport implements ClusterItem {
|
||||||
|
private final static String TAG = IncidentReport.class.getSimpleName();
|
||||||
|
|
||||||
private int id = 0;
|
private int id = 0;
|
||||||
private LatLng incidentPosition;
|
private LatLng incidentPosition;
|
||||||
@@ -134,14 +138,13 @@ public class IncidentReport implements ClusterItem {
|
|||||||
if(mIncident.has("fid_others")) this.fidOthersCategory = mIncident.getInt("fid_others");
|
if(mIncident.has("fid_others")) this.fidOthersCategory = mIncident.getInt("fid_others");
|
||||||
if(mIncident.has("etc_others")) this.etcOthersCategory = mIncident.getString("etc_others");
|
if(mIncident.has("etc_others")) this.etcOthersCategory = mIncident.getString("etc_others");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Exception caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BitmapDescriptor getIcon() {
|
public BitmapDescriptor getIcon() {
|
||||||
BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(getIconDrawable());
|
return BitmapDescriptorFactory.fromResource(getIconDrawable());
|
||||||
|
|
||||||
return icon;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getIconDrawable() {
|
public int getIconDrawable() {
|
||||||
@@ -149,18 +152,19 @@ public class IncidentReport implements ClusterItem {
|
|||||||
|
|
||||||
Date tmpFromDate = null;
|
Date tmpFromDate = null;
|
||||||
SimpleDateFormat simpleDateFormat;
|
SimpleDateFormat simpleDateFormat;
|
||||||
Date today = new Date(System.currentTimeMillis()-1*60*60*1000);
|
Date today = new Date(System.currentTimeMillis()-60*60*1000);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(this.fromDate != null && this.fromTime != null){
|
if(this.fromDate != null && this.fromTime != null){
|
||||||
simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.US);
|
||||||
tmpFromDate = simpleDateFormat.parse(this.fromDate+" "+this.fromTime);
|
tmpFromDate = simpleDateFormat.parse(this.fromDate+" "+this.fromTime);
|
||||||
}else if(this.fromDate != null){
|
}else if(this.fromDate != null){
|
||||||
simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
|
||||||
tmpFromDate = simpleDateFormat.parse(this.fromDate);
|
tmpFromDate = simpleDateFormat.parse(this.fromDate);
|
||||||
}
|
}
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Exception caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (this.fidIncidentCategory) {
|
switch (this.fidIncidentCategory) {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import com.android.volley.Response;
|
|||||||
import com.android.volley.VolleyError;
|
import com.android.volley.VolleyError;
|
||||||
import com.android.volley.toolbox.StringRequest;
|
import com.android.volley.toolbox.StringRequest;
|
||||||
import com.google.android.gms.maps.model.LatLng;
|
import com.google.android.gms.maps.model.LatLng;
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
import org.deke.risk.riskahead.MapsActivity;
|
import org.deke.risk.riskahead.MapsActivity;
|
||||||
import org.deke.risk.riskahead.R;
|
import org.deke.risk.riskahead.R;
|
||||||
@@ -32,6 +33,7 @@ import org.json.JSONObject;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,7 +44,6 @@ import java.util.Map;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class NotificationService extends Service {
|
public class NotificationService extends Service {
|
||||||
|
|
||||||
private final static String TAG = NotificationService.class.getSimpleName();
|
private final static String TAG = NotificationService.class.getSimpleName();
|
||||||
private final static String EXTRA_MESSAGE = "org.deke.risk.riskahead.MESSAGE";
|
private final static String EXTRA_MESSAGE = "org.deke.risk.riskahead.MESSAGE";
|
||||||
|
|
||||||
@@ -223,10 +224,11 @@ public class NotificationService extends Service {
|
|||||||
sentNotification(notification);
|
sentNotification(notification);
|
||||||
} else {
|
} else {
|
||||||
String errorMsg = jObj.getString("error_msg");
|
String errorMsg = jObj.getString("error_msg");
|
||||||
Log.e(TAG, "Error getting incident notification (server returned error): " + errorMsg);
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error getting incident notification (server returned error): " + errorMsg);
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -234,7 +236,7 @@ public class NotificationService extends Service {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onErrorResponse(VolleyError error) {
|
public void onErrorResponse(VolleyError error) {
|
||||||
Log.e(TAG, "Error getting incident notification: " + error.getMessage());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Error getting incident notification: " + error.getMessage());
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
@@ -264,7 +266,7 @@ public class NotificationService extends Service {
|
|||||||
context = notification.length() + " " + getString(R.string.txt_notification_context_multi);
|
context = notification.length() + " " + getString(R.string.txt_notification_context_multi);
|
||||||
}
|
}
|
||||||
NotificationCompat.Builder mBuilder =
|
NotificationCompat.Builder mBuilder =
|
||||||
new NotificationCompat.Builder(getApplicationContext())
|
new NotificationCompat.Builder(getApplicationContext(), "MyChannelId_01")
|
||||||
.setSmallIcon(R.drawable.logo_380)
|
.setSmallIcon(R.drawable.logo_380)
|
||||||
.setAutoCancel(true)
|
.setAutoCancel(true)
|
||||||
.setContentTitle(title)
|
.setContentTitle(title)
|
||||||
@@ -276,7 +278,8 @@ public class NotificationService extends Service {
|
|||||||
try {
|
try {
|
||||||
resultIntent.putExtra(EXTRA_MESSAGE, notification.getJSONObject(notification.length()-1).getDouble("latitude")+":"+notification.getJSONObject(notification.length()-1).getDouble("longitude"));
|
resultIntent.putExtra(EXTRA_MESSAGE, notification.getJSONObject(notification.length()-1).getDouble("latitude")+":"+notification.getJSONObject(notification.length()-1).getDouble("longitude"));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
|
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
|
||||||
@@ -291,7 +294,7 @@ public class NotificationService extends Service {
|
|||||||
mBuilder.setContentIntent(resultPendingIntent);
|
mBuilder.setContentIntent(resultPendingIntent);
|
||||||
|
|
||||||
mNotificationManager.notify(1, mBuilder.build());
|
mNotificationManager.notify(1, mBuilder.build());
|
||||||
session.setLastNotification(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime()));
|
session.setLastNotification(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US).format(Calendar.getInstance().getTime()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,12 +5,14 @@ import android.util.Log;
|
|||||||
|
|
||||||
import com.google.android.gms.maps.GoogleMap;
|
import com.google.android.gms.maps.GoogleMap;
|
||||||
import com.google.android.gms.maps.model.MarkerOptions;
|
import com.google.android.gms.maps.model.MarkerOptions;
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
import com.google.maps.android.clustering.ClusterManager;
|
import com.google.maps.android.clustering.ClusterManager;
|
||||||
import com.google.maps.android.clustering.view.DefaultClusterRenderer;
|
import com.google.maps.android.clustering.view.DefaultClusterRenderer;
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -20,7 +22,7 @@ import java.util.Date;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class OwnIconRendered extends DefaultClusterRenderer<IncidentReport> {
|
public class OwnIconRendered extends DefaultClusterRenderer<IncidentReport> {
|
||||||
|
private final static String TAG = OwnIconRendered.class.getSimpleName();
|
||||||
Context context;
|
Context context;
|
||||||
|
|
||||||
public OwnIconRendered(Context context, GoogleMap map,ClusterManager<IncidentReport> clusterManager) {
|
public OwnIconRendered(Context context, GoogleMap map,ClusterManager<IncidentReport> clusterManager) {
|
||||||
@@ -32,11 +34,9 @@ public class OwnIconRendered extends DefaultClusterRenderer<IncidentReport> {
|
|||||||
protected void onBeforeClusterItemRendered(IncidentReport item, MarkerOptions markerOptions) {
|
protected void onBeforeClusterItemRendered(IncidentReport item, MarkerOptions markerOptions) {
|
||||||
markerOptions.icon(item.getIcon());
|
markerOptions.icon(item.getIcon());
|
||||||
|
|
||||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
|
||||||
Date dateToCheck = null;
|
Date dateToCheck = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(item.getToDate() != null && !item.getToDate().equals("0000-00-00")){
|
if(item.getToDate() != null && !item.getToDate().equals("0000-00-00")){
|
||||||
dateToCheck = simpleDateFormat.parse(item.getToDate());
|
dateToCheck = simpleDateFormat.parse(item.getToDate());
|
||||||
@@ -44,7 +44,8 @@ public class OwnIconRendered extends DefaultClusterRenderer<IncidentReport> {
|
|||||||
dateToCheck = simpleDateFormat.parse(item.getFromDate());
|
dateToCheck = simpleDateFormat.parse(item.getFromDate());
|
||||||
}
|
}
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "ParseException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dateToCheck != null && !dateToCheck.after(new Date(System.currentTimeMillis()-14*24*60*60*1000))){
|
if(dateToCheck != null && !dateToCheck.after(new Date(System.currentTimeMillis()-14*24*60*60*1000))){
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
package org.deke.risk.riskahead.helper;
|
package org.deke.risk.riskahead.helper;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -16,18 +20,20 @@ import org.json.JSONObject;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PlaceJSONParser {
|
public class PlaceJSONParser {
|
||||||
|
private final static String TAG = PlaceJSONParser.class.getSimpleName();
|
||||||
|
|
||||||
/** Receives a JSONObject and returns a list */
|
/** Receives a JSONObject and returns a list */
|
||||||
public List<HashMap<String,String>> parse(JSONObject jObject){
|
public List<HashMap<String,String>> parse(JSONObject jObject){
|
||||||
|
|
||||||
JSONArray jPlaces = null;
|
JSONArray jPlaces = null;
|
||||||
try {
|
try {
|
||||||
/** Retrieves all the elements in the 'places' array */
|
/* Retrieves all the elements in the 'places' array */
|
||||||
jPlaces = jObject.getJSONArray("predictions");
|
jPlaces = jObject.getJSONArray("predictions");
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
/** Invoking getPlaces with the array of json object
|
/* Invoking getPlaces with the array of json object
|
||||||
* where each json object represent a place
|
* where each json object represent a place
|
||||||
*/
|
*/
|
||||||
return getPlaces(jPlaces);
|
return getPlaces(jPlaces);
|
||||||
@@ -38,15 +44,16 @@ public class PlaceJSONParser {
|
|||||||
List<HashMap<String, String>> placesList = new ArrayList<>();
|
List<HashMap<String, String>> placesList = new ArrayList<>();
|
||||||
HashMap<String, String> place;
|
HashMap<String, String> place;
|
||||||
|
|
||||||
/** Taking each place, parses and adds to list object */
|
/* Taking each place, parses and adds to list object */
|
||||||
for(int i=0; i<placesCount;i++){
|
for(int i=0; i<placesCount;i++){
|
||||||
try {
|
try {
|
||||||
/** Call getPlace with place JSON object to parse the place */
|
/* Call getPlace with place JSON object to parse the place */
|
||||||
place = getPlace((JSONObject)jPlaces.get(i));
|
place = getPlace((JSONObject)jPlaces.get(i));
|
||||||
placesList.add(place);
|
placesList.add(place);
|
||||||
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +80,8 @@ public class PlaceJSONParser {
|
|||||||
place.put("reference",reference);
|
place.put("reference",reference);
|
||||||
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
return place;
|
return place;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
package org.deke.risk.riskahead.helper;
|
package org.deke.risk.riskahead.helper;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -15,6 +19,7 @@ import org.json.JSONObject;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PlaceJSONParserDetail {
|
public class PlaceJSONParserDetail {
|
||||||
|
private final static String TAG = PlaceJSONParserDetail.class.getSimpleName();
|
||||||
|
|
||||||
/** Receives a JSONObject and returns a list */
|
/** Receives a JSONObject and returns a list */
|
||||||
public List<HashMap<String,String>> parse(JSONObject jObject){
|
public List<HashMap<String,String>> parse(JSONObject jObject){
|
||||||
@@ -30,9 +35,9 @@ public class PlaceJSONParserDetail {
|
|||||||
lat = (Double)jObject.getJSONObject("result").getJSONObject("geometry").getJSONObject("location").get("lat");
|
lat = (Double)jObject.getJSONObject("result").getJSONObject("geometry").getJSONObject("location").get("lat");
|
||||||
lng = (Double)jObject.getJSONObject("result").getJSONObject("geometry").getJSONObject("location").get("lng");
|
lng = (Double)jObject.getJSONObject("result").getJSONObject("geometry").getJSONObject("location").get("lng");
|
||||||
formattedAddress = (String) jObject.getJSONObject("result").get("formatted_address");
|
formattedAddress = (String) jObject.getJSONObject("result").get("formatted_address");
|
||||||
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Exception caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
hm.put("lat", Double.toString(lat));
|
hm.put("lat", Double.toString(lat));
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ import android.database.MatrixCursor;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* (C) Copyright 2016 RiskAhead (http://www.riskahead.net)
|
* (C) Copyright 2016 RiskAhead (http://www.riskahead.net)
|
||||||
@@ -31,7 +33,7 @@ import android.util.Log;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PlaceProvider extends ContentProvider {
|
public class PlaceProvider extends ContentProvider {
|
||||||
|
private final static String TAG = PlaceProvider.class.getSimpleName();
|
||||||
public static final String AUTHORITY = "org.deke.risk.riskahead.helper.PlaceProvider";
|
public static final String AUTHORITY = "org.deke.risk.riskahead.helper.PlaceProvider";
|
||||||
|
|
||||||
public static final Uri SEARCH_URI = Uri.parse("content://"+AUTHORITY+"/search");
|
public static final Uri SEARCH_URI = Uri.parse("content://"+AUTHORITY+"/search");
|
||||||
@@ -71,13 +73,13 @@ public class PlaceProvider extends ContentProvider {
|
|||||||
PlaceJSONParser parser = new PlaceJSONParser();
|
PlaceJSONParser parser = new PlaceJSONParser();
|
||||||
PlaceJSONParserDetail detailsParser = new PlaceJSONParserDetail();
|
PlaceJSONParserDetail detailsParser = new PlaceJSONParserDetail();
|
||||||
|
|
||||||
String jsonString = "";
|
String jsonString;
|
||||||
String jsonPlaceDetails = "";
|
String jsonPlaceDetails;
|
||||||
|
|
||||||
List<HashMap<String, String>> list = null;
|
List<HashMap<String, String>> list;
|
||||||
List<HashMap<String, String>> detailsList = null;
|
List<HashMap<String, String>> detailsList = null;
|
||||||
|
|
||||||
MatrixCursor mCursor = null;
|
MatrixCursor mCursor;
|
||||||
|
|
||||||
switch(mUriMatcher.match(uri)){
|
switch(mUriMatcher.match(uri)){
|
||||||
case SEARCH:
|
case SEARCH:
|
||||||
@@ -118,7 +120,8 @@ public class PlaceProvider extends ContentProvider {
|
|||||||
|
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
c = mCursor;
|
c = mCursor;
|
||||||
break;
|
break;
|
||||||
@@ -146,7 +149,8 @@ public class PlaceProvider extends ContentProvider {
|
|||||||
mCursor.addRow(new String[] { Integer.toString(i), hMap.get("description"), hMap.get("reference") });
|
mCursor.addRow(new String[] { Integer.toString(i), hMap.get("description"), hMap.get("reference") });
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
c = mCursor;
|
c = mCursor;
|
||||||
break;
|
break;
|
||||||
@@ -160,13 +164,19 @@ public class PlaceProvider extends ContentProvider {
|
|||||||
try {
|
try {
|
||||||
detailsList = detailsParser.parse(new JSONObject(jsonPlaceDetails));
|
detailsList = detailsParser.parse(new JSONObject(jsonPlaceDetails));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "JSONException caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int j=0;j<detailsList.size();j++){
|
if(detailsList != null){
|
||||||
HashMap<String, String> hMapDetails = detailsList.get(j);
|
for(int j = 0; j < detailsList.size(); j++){
|
||||||
mCursor.addRow(new String[]{ hMapDetails.get("formatted_address") , hMapDetails.get("lat") , hMapDetails.get("lng") });
|
HashMap<String, String> hMapDetails = detailsList.get(j);
|
||||||
|
mCursor.addRow(new String[]{ hMapDetails.get("formatted_address") , hMapDetails.get("lat") , hMapDetails.get("lng") });
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "DetailsList is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
c = mCursor;
|
c = mCursor;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -229,10 +239,11 @@ public class PlaceProvider extends ContentProvider {
|
|||||||
br.close();
|
br.close();
|
||||||
|
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
Log.d("Exception downloading", e.toString());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "downloadURL Exception");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}finally{
|
}finally{
|
||||||
iStream.close();
|
if(iStream != null) iStream.close();
|
||||||
urlConnection.disconnect();
|
if(urlConnection != null) urlConnection.disconnect();
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@@ -291,7 +302,8 @@ public class PlaceProvider extends ContentProvider {
|
|||||||
// Fetching the data from web service in background
|
// Fetching the data from web service in background
|
||||||
data = downloadUrl(url);
|
data = downloadUrl(url);
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
Log.d("Background Task",e.toString());
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Exception caught in backgroundTask");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@@ -302,7 +314,8 @@ public class PlaceProvider extends ContentProvider {
|
|||||||
try {
|
try {
|
||||||
data = downloadUrl(url);
|
data = downloadUrl(url);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Exception caught");
|
||||||
|
FirebaseCrash.report(e);
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import android.content.Intent;
|
|||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import com.google.firebase.crash.FirebaseCrash;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* (C) Copyright 2016 RiskAhead (http://www.riskahead.net)
|
* (C) Copyright 2016 RiskAhead (http://www.riskahead.net)
|
||||||
@@ -20,7 +22,7 @@ public class RABroadcastReceiver extends BroadcastReceiver {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
|
if (intent.getAction() != null && intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
|
||||||
Log.d(TAG, "BroadcastReceiver received intent");
|
Log.d(TAG, "BroadcastReceiver received intent");
|
||||||
|
|
||||||
Intent wtdSServiceIntent = new Intent(context, NotificationService.class);
|
Intent wtdSServiceIntent = new Intent(context, NotificationService.class);
|
||||||
@@ -30,10 +32,12 @@ public class RABroadcastReceiver extends BroadcastReceiver {
|
|||||||
long interval = DateUtils.MINUTE_IN_MILLIS * 2;
|
long interval = DateUtils.MINUTE_IN_MILLIS * 2;
|
||||||
long firstStart = System.currentTimeMillis() + interval;
|
long firstStart = System.currentTimeMillis() + interval;
|
||||||
|
|
||||||
AlarmManager am = (AlarmManager) context
|
AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
|
||||||
.getSystemService(Context.ALARM_SERVICE);
|
if(am != null){
|
||||||
am.setInexactRepeating(AlarmManager.RTC, firstStart,
|
am.setInexactRepeating(AlarmManager.RTC, firstStart,interval, wtdSServicePendingIntent);
|
||||||
interval, wtdSServicePendingIntent);
|
}else{
|
||||||
|
FirebaseCrash.logcat(Log.ERROR, TAG, "Could not get AlarmManager");
|
||||||
|
}
|
||||||
|
|
||||||
Log.v(TAG, "AlarmManager gesetzt");
|
Log.v(TAG, "AlarmManager gesetzt");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ import java.util.HashMap;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SessionManager {
|
public class SessionManager {
|
||||||
|
|
||||||
|
|
||||||
private static String TAG = SessionManager.class.getSimpleName();
|
private static String TAG = SessionManager.class.getSimpleName();
|
||||||
|
|
||||||
SharedPreferences status;
|
SharedPreferences status;
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import android.util.AttributeSet;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Patterns;
|
import android.util.Patterns;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
|
|
||||||
import org.deke.risk.riskahead.R;
|
import org.deke.risk.riskahead.R;
|
||||||
|
|
||||||
@@ -24,9 +23,7 @@ import org.deke.risk.riskahead.R;
|
|||||||
* Date of Release: 10.02.2016
|
* Date of Release: 10.02.2016
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ValidatedEditTextPreference extends EditTextPreference
|
public class ValidatedEditTextPreference extends EditTextPreference {
|
||||||
{
|
|
||||||
|
|
||||||
private final static int TYPE_VARIATION_EMAIL_ADDRESS = 33;
|
private final static int TYPE_VARIATION_EMAIL_ADDRESS = 33;
|
||||||
|
|
||||||
public ValidatedEditTextPreference(Context ctx, AttributeSet attrs, int defStyle)
|
public ValidatedEditTextPreference(Context ctx, AttributeSet attrs, int defStyle)
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
android:tint="@color/white"
|
android:tint="@color/white"
|
||||||
android:src="@android:drawable/ic_input_add"
|
android:src="@android:drawable/ic_input_add"
|
||||||
app:borderWidth="0dp"
|
app:borderWidth="0dp"
|
||||||
|
|||||||
@@ -81,6 +81,7 @@
|
|||||||
android:layout_above="@+id/layoutFooter"
|
android:layout_above="@+id/layoutFooter"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
android:src="@android:drawable/ic_dialog_map" />
|
android:src="@android:drawable/ic_dialog_map" />
|
||||||
|
|
||||||
<com.beardedhen.androidbootstrap.AwesomeTextView
|
<com.beardedhen.androidbootstrap.AwesomeTextView
|
||||||
|
|||||||
@@ -299,6 +299,7 @@
|
|||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
android:src="@android:drawable/ic_dialog_map" />
|
android:src="@android:drawable/ic_dialog_map" />
|
||||||
|
|
||||||
<android.support.design.widget.FloatingActionButton
|
<android.support.design.widget.FloatingActionButton
|
||||||
@@ -308,7 +309,8 @@
|
|||||||
android:layout_margin="16dp"
|
android:layout_margin="16dp"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:clickable="true" />
|
android:clickable="true"
|
||||||
|
android:focusable="true"/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|||||||
@@ -434,5 +434,6 @@
|
|||||||
<item>30</item>
|
<item>30</item>
|
||||||
<item>60</item>
|
<item>60</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
<string name="asset_statements" translatable="false">[{\n \"relation\": [\"delegate_permission/common.handle_all_urls\"],\n \"target\": {\n \"namespace\": \"web\",\n \"site\": \"https://www.riskahead.net\",\n }\n}]</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user