diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000..f9fe3459 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/test/java=UTF-8 +encoding/=UTF-8 diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 330d9169..ed07b8ad 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,10 +1,8 @@ - + + @@ -13,96 +11,66 @@ - - - - - - + + + + + + - + - + - + - - + + - + - - + + - - - - - - - + + + + + + + - + - + - + - + - + + + + - - - - - + + + \ No newline at end of file diff --git a/assets/help_en.json b/assets/help_en.json index c8b1d95c..01cc81b8 100644 --- a/assets/help_en.json +++ b/assets/help_en.json @@ -38,7 +38,7 @@ "title" : "Managing Your Risks", "heading" : "Managing Your Risks", "section_order" : "1", - "content" : "

Managing Your Risks

How to assess your risks, the basics about mobile phone security and other risks.

", + "content" : "

How to assess your risks, the basics about mobile phone security and other risks.

", "items" : [ { "title" : "Assessing your risk", diff --git a/assets/help_es.json b/assets/help_es.json index f599fca5..04366134 100644 --- a/assets/help_es.json +++ b/assets/help_es.json @@ -38,7 +38,7 @@ "title" : "Managing Your Risks", "heading" : "Managing Your Risks", "section_order" : "1", - "content" : "

Managing Your Risks

How to assess your risks, the basics about mobile phone security and other risks.

", + "content" : "

How to assess your risks, the basics about mobile phone security and other risks.

", "items" : [ { "title" : "Assessing your risk", diff --git a/assets/help_fr.json b/assets/help_fr.json index 460e263e..8dc4dd95 100644 --- a/assets/help_fr.json +++ b/assets/help_fr.json @@ -38,7 +38,7 @@ "title" : "Managing Your Risks", "heading" : "Managing Your Risks", "section_order" : "1", - "content" : "

Managing Your Risks

How to assess your risks, the basics about mobile phone security and other risks.

", + "content" : "

How to assess your risks, the basics about mobile phone security and other risks.

", "items" : [ { "title" : "Assessing your risk", diff --git a/assets/help_ph.json b/assets/help_ph.json index 9dfd45a7..dee60623 100644 --- a/assets/help_ph.json +++ b/assets/help_ph.json @@ -38,7 +38,7 @@ "title" : "Managing Your Risks", "heading" : "Managing Your Risks", "section_order" : "1", - "content" : "

Managing Your Risks

How to assess your risks, the basics about mobile phone security and other risks.

", + "content" : "

How to assess your risks, the basics about mobile phone security and other risks.

", "items" : [ { "title" : "Assessing your risk", diff --git a/assets/help_pt.json b/assets/help_pt.json index 1a0b3207..0445e596 100644 --- a/assets/help_pt.json +++ b/assets/help_pt.json @@ -38,7 +38,7 @@ "title" : "Managing Your Risks", "heading" : "Managing Your Risks", "section_order" : "1", - "content" : "

Managing Your Risks

How to assess your risks, the basics about mobile phone security and other risks.

", + "content" : "

How to assess your risks, the basics about mobile phone security and other risks.

", "items" : [ { "title" : "Assessing your risk", diff --git a/assets/mobile_en.json b/assets/mobile_en.json index cd6374b7..5e0bc47d 100644 --- a/assets/mobile_en.json +++ b/assets/mobile_en.json @@ -333,7 +333,7 @@ "title" : "Checklist", "action" : [{"title":"Disguise Now","link":"close"},{"title":"Cancel","link":"home-ready","status":"disabled"}], "checklist" : [{"title":"Review security plan and update contacts regularly"},{"title":"Test the alert to ensure it is working"},{"title":"Ensure sufficient credit on the phone"},{"title":"Activate GPS (if you want to enable location tracking)"},{"title":"Charge phone battery to full"}], - "content" : "

More security tips...

" + "content" : "

More security tips...

" }] } } \ No newline at end of file diff --git a/assets/mobile_es.json b/assets/mobile_es.json index fca2da2d..402028cd 100644 --- a/assets/mobile_es.json +++ b/assets/mobile_es.json @@ -332,7 +332,7 @@ "title" : "Lista de verificación", "action" : [{"title":"Aceptar","link":"close"},{"title":"Cancelar","link":"home-ready","status":"disabled"}], "checklist" : [{"title":"Revisar plan de seguridad y actualizar contactos regularmente"},{"title":"Prueba la alerta para asegurarte que funcione"},{"title":"Asegurate de tener suficiente crédito en tu teléfono móvil"},{"title":"Activa el GPS (si deseas que tu ubicación se incluya en el mensaje)"},{"title":"Carga la batería de tu teléfono completamente"}], - "content" : "

Consejos sobre seguridad...

" + "content" : "

Consejos sobre seguridad...

" }] } } \ No newline at end of file diff --git a/assets/mobile_fr.json b/assets/mobile_fr.json index bceb3ee0..e29997c7 100644 --- a/assets/mobile_fr.json +++ b/assets/mobile_fr.json @@ -332,7 +332,7 @@ "title" : "Check-list", "action" : [{"title":"OK","link":"close"},{"title":"Annuler ","link":"home-ready","status":"disabled"}], "checklist" : [{"title":"Revoir la stratégie de sécurité et mettre à jour les contacts régulièrement"},{"title":"Tester l'alerte pour vérifier qu'elle fonctionne"},{"title":"Vérifier qu'il y a assez de crédit sur le téléphone"},{"title":"Activer le GPS (si vous souhaitez signaler votre position géographique"},{"title":"Recharger complètement la batterie"}], - "content" : "

More conseils de sécurité...

" + "content" : "

More conseils de sécurité...

" }] } } diff --git a/assets/mobile_ph.json b/assets/mobile_ph.json index cc933404..08657bde 100644 --- a/assets/mobile_ph.json +++ b/assets/mobile_ph.json @@ -316,7 +316,7 @@ "title" : "Checklist", "action" : [{"title":"OK","link":"close"},{"title":"Cancel","link":"home-ready","status":"disabled"}], "checklist" : [{"title":"The application will be disguised"},{"title":"Review security plan and update trusted contacts regularly"},{"title":"Test setting off the alarm to ensure it is working"},{"title":"Ensure sufficient credit on the phone"},{"title":"Activate GPS (if you want to enable location tracking)"},{"title":"Charge phone battery to full"}], - "content" : "

More security tips...

" + "content" : "

More security tips...

" },] } } \ No newline at end of file diff --git a/assets/mobile_pt.json b/assets/mobile_pt.json index 9928ae32..426f0b92 100644 --- a/assets/mobile_pt.json +++ b/assets/mobile_pt.json @@ -325,7 +325,7 @@ "title" : "Lista de Controle", "action" : [{"title":"Disfarce agora","link":"close"},{"title":"Cancelar","link":"home-ready","status":"disabled"}], "checklist" : [{"title":"Revisar plano de segurança e atualizar os contatos regularmente"},{"title":"Testar o alerta para garantir que está funcionando"},{"title":"Verificar se tem crédito suficiente no telefone"},{"title":"Ativar GPS (se quiser habilitar o rastreamento de localização)"},{"title":"Carregar completamente a bateria do telefone"}], - "content" : "

Mais dicas de segurança...

" + "content" : "

Mais dicas de segurança...

" }] } } \ No newline at end of file diff --git a/features/3_wizard_message.feature b/features/3_wizard_message.feature index 10965f45..7398561f 100644 --- a/features/3_wizard_message.feature +++ b/features/3_wizard_message.feature @@ -18,7 +18,7 @@ Feature: Message setup in the Wizard Then I see the text "Next" Then I verify "Next" button is "enabled" Then I see the text "Help me, I'm in danger" - Then I see the text "I'm at http://maps.google.com/GPS-location" + Then I see the text "I'm at https://maps.google.com/GPS-location" Scenario: Navigating back to start screen When I go back diff --git a/features/README.md b/features/README.md index da5d687f..2b5cdcd2 100644 --- a/features/README.md +++ b/features/README.md @@ -11,7 +11,7 @@ To run your test: For example: - calabash-android run target/panic-button-dev.apk MAIN_ACTIVITY=com.apb.beacon.HomeActivity + calabash-android run target/panic-button-dev.apk MAIN_ACTIVITY=org.iilab.pb.HomeActivity Calabash-android will install an instrumentation along with your app when executing the app. We call this instrumentation for "test server". The "test server" has special permission that allows it to interact very closely with your app during test. Everytime you test a new binary or use an upgraded version of calabash a new test server will be build. diff --git a/features/step_definitions/custom_steps.rb b/features/step_definitions/custom_steps.rb index 4b023e1f..14ff6237 100644 --- a/features/step_definitions/custom_steps.rb +++ b/features/step_definitions/custom_steps.rb @@ -23,7 +23,7 @@ end And(/^I start application$/) do - Device.adb_command("shell am start -n com.apb.beacon/.HomeActivity") + Device.adb_command("shell am start -n org.iilab.pb/.HomeActivity") end And(/^I clear log$/) do @@ -32,7 +32,7 @@ And(/^I check sms text contains "(.*?)"$/) do |sms_text| # Get sms text - log_input = "adb logcat -d -n5 -s \"com.apb.beacon.alert.SMSAdapter\"" + log_input = "adb logcat -d -n5 -s \"org.iilab.pb.alert.SMSAdapter\"" log_output = `#{log_input}` print log_output diff --git a/pom.xml b/pom.xml index 79211444..93b725cc 100644 --- a/pom.xml +++ b/pom.xml @@ -3,9 +3,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 - com.apb.beacon + org.iilab.pb panic-button - 1.2.6b + 1.2.7 apk Panic Button @@ -19,6 +19,7 @@ 4.1.1.4 + UTF-8 master ${project.version} @@ -28,13 +29,6 @@ true - - - - my-release-key.keystore - testAlias - 123456 - 123456 @@ -172,20 +166,20 @@ ${skipCoverage} - com/apb/beacon/R*.class - com/apb/beacon/Manifest.class - com/apb/beacon/BuildConfig.class + org/iilab/pb/R*.class + org/iilab/pb/Manifest.class + org/iilab/pb/BuildConfig.class - com/apb/beacon/location/LocationListenerAdapter.class - com/apb/beacon/common/Intents.class - com/apb/beacon/common/AppUtil.class - com/apb/beacon/AppConstants.class - com/apb/beacon/twitter/OnItemSelectedListenerAdapter.class + org/iilab/pb/location/LocationListenerAdapter.class + org/iilab/pb/common/Intents.class + org/iilab/pb/common/AppUtil.class + org/iilab/pb/AppConstants.class + org/iilab/pb/twitter/OnItemSelectedListenerAdapter.class - com/apb/beacon/twitter/HintSpinnerAdapter.class + org/iilab/pb/twitter/HintSpinnerAdapter.class - com/apb/beacon/HomeActivity*.class - com/apb/beacon/ApplicationSettings.class + org/iilab/pb/HomeActivity*.class + org/iilab/pb/ApplicationSettings.class @@ -248,7 +242,7 @@ - release + presign @@ -259,37 +253,6 @@ - - org.apache.maven.plugins - maven-jarsigner-plugin - - - signing - - sign - verify - - package - true - - true - - - ${project.build.directory}/${project.artifactId}.apk - - ${sign.keystore} - ${sign.alias} - ${sign.storepass} - ${sign.keypass} - false - - -sigalgMD5withRSA - -digestalgSHA1 - - - - - com.jayway.maven.plugins.android.generation2 android-maven-plugin @@ -299,20 +262,14 @@ false - - false - true - ${project.build.directory}/${project.artifactId}-${project.version}.apk - ${project.build.directory}/${project.artifactId}-signed-aligned.apk - false - + true - true - proguard.conf + false + proguard-project.txt @@ -322,6 +279,12 @@ manifest-update + + + + false + + alignApk @@ -332,33 +295,6 @@ - - org.codehaus.mojo - build-helper-maven-plugin - - - - ${project.build.directory}/${project.artifactId}-signed-aligned.apk - apk - signed-aligned - - - - - - - - - - - attach-signed-aligned - package - - attach-artifact - - - - diff --git a/proguard-project.txt b/proguard-project.txt index f2fe1559..8dc56564 100644 --- a/proguard-project.txt +++ b/proguard-project.txt @@ -18,3 +18,15 @@ #-keepclassmembers class fqcn.of.javascript.interface.for.webview { # public *; #} +-dontskipnonpubliclibraryclasses +-dontobfuscate +-forceprocessing +-optimizationpasses 5 +-dontwarn android.support.v4.view.** +-keep class android.support.v4.** { *; } +-keep class * extends android.app.Activity +-assumenosideeffects class android.util.Log { + public static *** d(...); + public static *** v(...); + public static *** e(...); +} \ No newline at end of file diff --git a/project.properties b/project.properties index 4ab12569..ce39f2d0 100644 --- a/project.properties +++ b/project.properties @@ -11,4 +11,4 @@ #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt # Project target. -target=android-19 +target=android-18 diff --git a/res/layout/fragment_type_interactive_contacts.xml b/res/layout/fragment_type_interactive_contacts.xml index 8a708138..defd67d3 100644 --- a/res/layout/fragment_type_interactive_contacts.xml +++ b/res/layout/fragment_type_interactive_contacts.xml @@ -64,7 +64,7 @@ style="@style/contact_number" /> @@ -84,7 +84,7 @@ style="@style/contact_number" /> @@ -104,7 +104,7 @@ style="@style/contact_number" /> diff --git a/res/layout/fragment_type_interactive_message.xml b/res/layout/fragment_type_interactive_message.xml index 88a5a11e..6f47114c 100644 --- a/res/layout/fragment_type_interactive_message.xml +++ b/res/layout/fragment_type_interactive_message.xml @@ -6,7 +6,7 @@ android:descendantFocusability="beforeDescendants" android:focusableInTouchMode="true"> - @@ -59,7 +59,7 @@ - - - @@ -47,7 +47,7 @@ android:layout_width="wrap_content" android:text="@string/second_contact" style="@style/contact_number" /> - @@ -61,7 +61,7 @@ android:layout_width="wrap_content" android:text="@string/third_contact" style="@style/contact_number" /> - @@ -71,7 +71,7 @@ android:layout_height="0dip" android:layout_weight="1"> Enter Message I\'m at - I\'m at http://maps.google.com/GPS-location + I\'m at https://maps.google.com/GPS-location Panic\nButton Title diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index a3d362cc..87831ece 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -9,7 +9,7 @@ Ingresa tu mensaje Estoy en - Estoy en : http://maps.google.com/GPS-ubicación + Estoy en : https://maps.google.com/GPS-ubicación Boton de Panico Titulo diff --git a/res/values-ph/strings.xml b/res/values-ph/strings.xml index 2a2d69d3..a3d895c2 100644 --- a/res/values-ph/strings.xml +++ b/res/values-ph/strings.xml @@ -9,7 +9,7 @@ Enter Message I\'m at - I\'m at http://maps.google.com/GPS-location + I\'m at https://maps.google.com/GPS-location Panic\nButton Title diff --git a/res/values-pt/strings.xml b/res/values-pt/strings.xml index 14d44cab..4a80398b 100644 --- a/res/values-pt/strings.xml +++ b/res/values-pt/strings.xml @@ -9,7 +9,7 @@ Inserir mensagem Estou em - Estou em http://maps.google.com/GPS-location + Estou em https://maps.google.com/GPS-location Botão\nPânico Title diff --git a/res/values/roboguice.xml b/res/values/roboguice.xml index fd187466..a7a81322 100644 --- a/res/values/roboguice.xml +++ b/res/values/roboguice.xml @@ -1,6 +1,6 @@ - com.apb.beacon.calculator.CalculatorModule + org.iilab.pb.calculator.CalculatorModule \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 5246cce3..7dcc50c9 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -9,7 +9,7 @@ Enter Message I\'m at - I\'m at http://maps.google.com/GPS-location + I\'m at https://maps.google.com/GPS-location Panic\nButton Title diff --git a/src/main/java/com/apb/beacon/alert/AlarmReceiver.java b/src/main/java/com/apb/beacon/alert/AlarmReceiver.java deleted file mode 100644 index 6202528c..00000000 --- a/src/main/java/com/apb/beacon/alert/AlarmReceiver.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.apb.beacon.alert; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.location.Location; - -import com.apb.beacon.common.ApplicationSettings; -import com.apb.beacon.common.Intents; - -public class AlarmReceiver extends BroadcastReceiver { - @Override - public void onReceive(Context context, Intent intent) { - Context _context = context.getApplicationContext(); - if(intent.getAction().equals(Intents.SEND_ALERT_ACTION)) { - Location currentBestLocation = ApplicationSettings.getCurrentBestLocation(_context); - getPanicMessage(_context).send(currentBestLocation); - } - } - - PanicMessage getPanicMessage(Context context) { - Context _context = context.getApplicationContext(); - return new PanicMessage(_context); - } -} diff --git a/src/main/java/com/apb/beacon/alert/PanicAlert.java b/src/main/java/com/apb/beacon/alert/PanicAlert.java deleted file mode 100644 index 3cbeb89c..00000000 --- a/src/main/java/com/apb/beacon/alert/PanicAlert.java +++ /dev/null @@ -1,136 +0,0 @@ -package com.apb.beacon.alert; - -import android.app.AlarmManager; -import android.app.PendingIntent; -import android.content.Context; -import android.location.Location; -import android.location.LocationManager; -import android.os.SystemClock; -import android.os.Vibrator; -import android.util.Log; - -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.common.ApplicationSettings; -import com.apb.beacon.common.AppUtil; -import com.apb.beacon.location.CurrentLocationProvider; - -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import static android.location.LocationManager.GPS_PROVIDER; -import static android.location.LocationManager.NETWORK_PROVIDER; -import static com.apb.beacon.common.Intents.alarmPendingIntent; -import static com.apb.beacon.common.Intents.locationPendingIntent; - -public class PanicAlert { - private static final String TAG = PanicAlert.class.getName(); - private LocationManager locationManager; - private Context context; - private AlarmManager alarmManager; - - public PanicAlert(Context context) { - this.context = context; - locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); - alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); - } - - public void activate() { - AppUtil.close(context); - vibrate(); - if (isActive() -// || ApplicationSettings.isRestartedSetup(context) - ) { - return; - } - ApplicationSettings.setAlertActive(context, true); - getExecutorService().execute( - new Runnable() { - @Override - public void run() { - activateAlert(); - } - } - ); - } - - private void activateAlert() { - ApplicationSettings.setAlertActive(context, true); - sendFirstAlert(); - registerLocationUpdate(); - scheduleFutureAlert(); - } - - public void deActivate() { - ApplicationSettings.setAlertActive(context, false); - locationManager.removeUpdates(locationPendingIntent(context)); - alarmManager.cancel(alarmPendingIntent(context)); - } - - private void sendFirstAlert() { - CurrentLocationProvider currentLocationProvider = getCurrentLocationProvider(); - Location loc = getLocation(currentLocationProvider); - createPanicMessage().send(loc); - } - - PanicMessage createPanicMessage() { - return new PanicMessage(context); - } - - CurrentLocationProvider getCurrentLocationProvider() { - return new CurrentLocationProvider(context); - } - - private void scheduleFutureAlert() { - PendingIntent alarmPendingIntent = alarmPendingIntent(context); - long timeFromNow = SystemClock.elapsedRealtime() + AppConstants.ONE_MINUTE * ApplicationSettings.getAlertDelay(context); - alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, timeFromNow, AppConstants.ONE_MINUTE * ApplicationSettings.getAlertDelay(context), alarmPendingIntent); - } - - private void registerLocationUpdate() { - if (locationManager.getAllProviders().contains(LocationManager.GPS_PROVIDER)) - locationManager.requestLocationUpdates(GPS_PROVIDER, AppConstants.GPS_MIN_TIME, AppConstants.GPS_MIN_DISTANCE, locationPendingIntent(context)); - if (locationManager.getAllProviders().contains(LocationManager.NETWORK_PROVIDER)) - locationManager.requestLocationUpdates(NETWORK_PROVIDER, AppConstants.NETWORK_MIN_TIME, AppConstants.NETWORK_MIN_DISTANCE, locationPendingIntent(context)); - } - - public boolean isActive() { - return ApplicationSettings.isAlertActive(context); - } - - private void vibrate() { - Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); - vibrator.vibrate(AppConstants.HAPTIC_FEEDBACK_DURATION); - } - - private Location getLocation(CurrentLocationProvider currentLocationProvider) { - Location location = null; - int retryCount = 0; - - while (retryCount < MAX_RETRIES && location == null) { - location = currentLocationProvider.getLocation(); - if (location == null) { - try { - retryCount++; - Thread.sleep(LOCATION_WAIT_TIME); - } catch (InterruptedException e) { - Log.e(TAG, "Location wait InterruptedException", e); - } - } - } - return location; - } - -// public AlertStatus getAlertStatus() { -// if (isActive()) { -// return AlertStatus.ACTIVE; -// } -// return AlertStatus.STANDBY; -// } - - ExecutorService getExecutorService() { - return Executors.newSingleThreadExecutor(); - } - - public static final int MAX_RETRIES = 10; - public static final int LOCATION_WAIT_TIME = 1000; -} \ No newline at end of file diff --git a/src/main/java/com/apb/beacon/BaseFragmentActivity.java b/src/main/java/org/iilab/pb/BaseFragmentActivity.java similarity index 84% rename from src/main/java/com/apb/beacon/BaseFragmentActivity.java rename to src/main/java/org/iilab/pb/BaseFragmentActivity.java index 79d8f875..7fe15860 100644 --- a/src/main/java/com/apb/beacon/BaseFragmentActivity.java +++ b/src/main/java/org/iilab/pb/BaseFragmentActivity.java @@ -1,4 +1,4 @@ -package com.apb.beacon; +package org.iilab.pb; import android.content.BroadcastReceiver; import android.content.Context; @@ -19,13 +19,13 @@ protected void onCreate(Bundle savedInstanceState) { public void registerFinishActivityReceiver() { IntentFilter intentFilter = new IntentFilter(); - intentFilter.addAction("com.apb.beacon.ACTION_LOGOUT"); + intentFilter.addAction("org.iilab.pb.ACTION_LOGOUT"); registerReceiver(activityFinishReceiver, intentFilter); } public void callFinishActivityReceiver() { Intent broadcastIntent = new Intent(); - broadcastIntent.setAction("com.apb.beacon.ACTION_LOGOUT"); + broadcastIntent.setAction("org.iilab.pb.ACTION_LOGOUT"); sendBroadcast(broadcastIntent); } @@ -43,7 +43,7 @@ protected void onDestroy() { @Override public void onReceive(Context context, Intent intent) { - if (intent.getAction().equals("com.apb.beacon.ACTION_LOGOUT")) { + if (intent.getAction().equals("org.iilab.pb.ACTION_LOGOUT")) { finish(); } } diff --git a/src/main/java/com/apb/beacon/CalculatorActivity.java b/src/main/java/org/iilab/pb/CalculatorActivity.java similarity index 95% rename from src/main/java/com/apb/beacon/CalculatorActivity.java rename to src/main/java/org/iilab/pb/CalculatorActivity.java index 077ac879..1fe80d47 100644 --- a/src/main/java/com/apb/beacon/CalculatorActivity.java +++ b/src/main/java/org/iilab/pb/CalculatorActivity.java @@ -1,4 +1,12 @@ -package com.apb.beacon; +package org.iilab.pb; + +import org.iilab.pb.alert.PanicAlert; +import org.iilab.pb.calculator.CalculatorImpl; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.common.AppUtil; +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.trigger.HardwareTriggerService; +import org.iilab.pb.trigger.MultiClickEvent; import android.content.Intent; import android.os.Bundle; @@ -9,13 +17,6 @@ import android.widget.Button; import android.widget.TextView; -import com.apb.beacon.alert.PanicAlert; -import com.apb.beacon.calculator.CalculatorImpl; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.common.AppUtil; -import com.apb.beacon.common.ApplicationSettings; -import com.apb.beacon.trigger.HardwareTriggerService; -import com.apb.beacon.trigger.MultiClickEvent; public class CalculatorActivity extends PanicButtonActivity { private static final int[] buttons = {R.id.one, R.id.two, R.id.three, diff --git a/src/main/java/com/apb/beacon/HomeActivity.java b/src/main/java/org/iilab/pb/HomeActivity.java similarity index 93% rename from src/main/java/com/apb/beacon/HomeActivity.java rename to src/main/java/org/iilab/pb/HomeActivity.java index b20ac0b2..eb0a84b7 100644 --- a/src/main/java/com/apb/beacon/HomeActivity.java +++ b/src/main/java/org/iilab/pb/HomeActivity.java @@ -1,4 +1,4 @@ -package com.apb.beacon; +package org.iilab.pb; import android.app.Activity; import android.app.ProgressDialog; @@ -7,16 +7,16 @@ import android.os.Bundle; import android.util.Log; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.common.AppUtil; -import com.apb.beacon.common.ApplicationSettings; -import com.apb.beacon.common.JsonParser; -import com.apb.beacon.data.PBDatabase; -import com.apb.beacon.model.HelpPage; -import com.apb.beacon.model.Page; -import com.apb.beacon.model.ServerResponse; -import com.apb.beacon.trigger.HardwareTriggerService; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.common.AppUtil; +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.common.JsonParser; +import org.iilab.pb.data.PBDatabase; +import org.iilab.pb.model.HelpPage; +import org.iilab.pb.model.Page; +import org.iilab.pb.model.ServerResponse; +import org.iilab.pb.trigger.HardwareTriggerService; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -25,6 +25,8 @@ import java.io.InputStream; import java.util.List; +import org.iilab.pb.R; + public class HomeActivity extends Activity { ProgressDialog pDialog; @@ -103,6 +105,19 @@ private void startNextActivity(){ if (wizardState != AppConstants.WIZARD_FLAG_HOME_READY) { Log.e(">>>>>>", "first run TRUE, running WizardActivity with pageId = " + pageId); Intent i = new Intent(HomeActivity.this, WizardActivity.class); + // Removing default homescreen shortcut when installed via Google Play. + Intent shortcutIntent = new Intent(getApplicationContext(), + MainActivity.class); + shortcutIntent.setAction(Intent.ACTION_MAIN); + + Intent addIntent = new Intent(); + addIntent + .putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); + addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "HelloWorldShortcut"); + + addIntent + .setAction("com.android.launcher.action.UNINSTALL_SHORTCUT"); + getApplicationContext().sendBroadcast(addIntent); i.putExtra("page_id", pageId); startActivity(i); } else { diff --git a/src/main/java/com/apb/beacon/LoginActivity.java b/src/main/java/org/iilab/pb/LoginActivity.java similarity index 51% rename from src/main/java/com/apb/beacon/LoginActivity.java rename to src/main/java/org/iilab/pb/LoginActivity.java index eb503fda..0246fc9d 100644 --- a/src/main/java/com/apb/beacon/LoginActivity.java +++ b/src/main/java/org/iilab/pb/LoginActivity.java @@ -1,15 +1,16 @@ -package com.apb.beacon; +package org.iilab.pb; + +import org.iilab.pb.common.AppUtil; +import org.iilab.pb.common.ApplicationSettings; import android.content.Intent; import android.os.Bundle; +import android.view.KeyEvent; import android.view.View; +import android.view.View.OnKeyListener; import android.widget.Button; import android.widget.EditText; -import com.apb.beacon.common.AppUtil; -import com.apb.beacon.common.ApplicationSettings; - - public class LoginActivity extends PanicButtonActivity { private EditText passwordEditText; @@ -20,9 +21,34 @@ public class LoginActivity extends PanicButtonActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login_screen_layout); - passwordEditText = (EditText) findViewById(R.id.create_pin_edittext); + passwordEditText.setOnKeyListener(new OnKeyListener() { + public boolean onKey(View v, int keyCode, KeyEvent event) { + // If the event is a key-down event on the "enter" button + if ((event.getAction() == KeyEvent.ACTION_DOWN) && + (keyCode == KeyEvent.KEYCODE_ENTER)) { + // Perform action on key press + String password = passwordEditText.getText().toString(); + if (ApplicationSettings.passwordMatches(getApplicationContext(), password)) { + + Intent i = new Intent(LoginActivity.this, MainActivity.class); +// i = AppUtil.clearBackStack(i); + if (ApplicationSettings.isAlertActive(LoginActivity.this)) { + i.putExtra("page_id", "home-alerting"); + } else { + i.putExtra("page_id", "home-ready"); + } + startActivity(i); + finish(); + return true; + } + AppUtil.setError(LoginActivity.this, passwordEditText, ((tryCount < 2) ? R.string.incorrect_pin : R.string.incorrect_pin_3_times)); + tryCount++; + } + return false; + } + }); bAction = (Button) findViewById(R.id.b_action); bAction.setText(getResources().getString(R.string.code_ok)); bAction.setOnClickListener(new View.OnClickListener() { @@ -47,6 +73,8 @@ public void onClick(View v) { tryCount++; } }); + + } } \ No newline at end of file diff --git a/src/main/java/com/apb/beacon/MainActivity.java b/src/main/java/org/iilab/pb/MainActivity.java similarity index 89% rename from src/main/java/com/apb/beacon/MainActivity.java rename to src/main/java/org/iilab/pb/MainActivity.java index 4d052cbc..c021d8c1 100644 --- a/src/main/java/com/apb/beacon/MainActivity.java +++ b/src/main/java/org/iilab/pb/MainActivity.java @@ -1,4 +1,19 @@ -package com.apb.beacon; +package org.iilab.pb; + +import org.iilab.pb.alert.PanicAlert; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.common.AppUtil; +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.data.PBDatabase; +import org.iilab.pb.fragment.LanguageSettingsFragment; +import org.iilab.pb.fragment.MainSetupAlertFragment; +import org.iilab.pb.fragment.SetupCodeFragment; +import org.iilab.pb.fragment.SetupContactsFragment; +import org.iilab.pb.fragment.SetupMessageFragment; +import org.iilab.pb.fragment.SimpleFragment; +import org.iilab.pb.fragment.WarningFragment; +import org.iilab.pb.model.Page; +import org.iilab.pb.trigger.HardwareTriggerService; import android.content.ComponentName; import android.content.Intent; @@ -12,20 +27,6 @@ import android.widget.TextView; import android.widget.Toast; -import com.apb.beacon.alert.PanicAlert; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.common.AppUtil; -import com.apb.beacon.common.ApplicationSettings; -import com.apb.beacon.data.PBDatabase; -import com.apb.beacon.model.Page; -import com.apb.beacon.fragment.SetupContactsFragment; -import com.apb.beacon.fragment.SetupMessageFragment; -import com.apb.beacon.fragment.LanguageSettingsFragment; -import com.apb.beacon.fragment.SimpleFragment; -import com.apb.beacon.fragment.MainSetupAlertFragment; -import com.apb.beacon.fragment.SetupCodeFragment; -import com.apb.beacon.fragment.WarningFragment; -import com.apb.beacon.trigger.HardwareTriggerService; /** * Created by aoe on 2/15/14. @@ -78,7 +79,7 @@ public void onCreate(Bundle savedInstanceState) { callFinishActivityReceiver(); Intent broadcastIntent = new Intent(); - broadcastIntent.setAction("com.apb.beacon.RESTART_INSTALL"); + broadcastIntent.setAction("org.iilab.pb.RESTART_INSTALL"); sendBroadcast(broadcastIntent); finish(); @@ -139,11 +140,11 @@ else if (currentPage.getComponent().equals("language")) private void changeAppIcontoPB() { getPackageManager().setComponentEnabledSetting( - new ComponentName("com.apb.beacon", "com.apb.beacon.HomeActivity-setup"), + new ComponentName("org.iilab.pb", "org.iilab.pb.HomeActivity-setup"), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); getPackageManager().setComponentEnabledSetting( - new ComponentName("com.apb.beacon", "com.apb.beacon.HomeActivity-calculator"), + new ComponentName("org.iilab.pb", "org.iilab.pb.HomeActivity-calculator"), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } diff --git a/src/main/java/com/apb/beacon/MainModalActivity.java b/src/main/java/org/iilab/pb/MainModalActivity.java similarity index 89% rename from src/main/java/com/apb/beacon/MainModalActivity.java rename to src/main/java/org/iilab/pb/MainModalActivity.java index 63e6b114..512be413 100644 --- a/src/main/java/com/apb/beacon/MainModalActivity.java +++ b/src/main/java/org/iilab/pb/MainModalActivity.java @@ -1,10 +1,9 @@ -package com.apb.beacon; +package org.iilab.pb; import android.content.Intent; import android.graphics.Color; import android.os.Bundle; import android.text.Html; -import android.text.method.LinkMovementMethod; import android.util.DisplayMetrics; import android.util.Log; import android.view.View; @@ -13,13 +12,13 @@ import android.widget.ListView; import android.widget.TextView; -import com.apb.beacon.adapter.PageCheckListAdapter; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.common.AppUtil; -import com.apb.beacon.common.ApplicationSettings; -import com.apb.beacon.common.MyTagHandler; -import com.apb.beacon.data.PBDatabase; -import com.apb.beacon.model.Page; +import org.iilab.pb.adapter.PageCheckListAdapter; +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.common.CustomLinkMovementMethod; +import org.iilab.pb.common.MyTagHandler; +import org.iilab.pb.data.PBDatabase; +import org.iilab.pb.model.Page; + /** @@ -97,7 +96,7 @@ protected void onCreate(Bundle savedInstanceState) { tvContent.setVisibility(View.GONE); else{ tvContent.setText(Html.fromHtml(currentPage.getContent(), null, new MyTagHandler())); - tvContent.setMovementMethod(LinkMovementMethod.getInstance()); + tvContent.setMovementMethod(CustomLinkMovementMethod.getInstance(MainModalActivity.this)); } if (currentPage.getAction().size() > 1) { @@ -145,11 +144,11 @@ public void onClick(View v) { // ApplicationSettings.setFirstRun(MainModalActivity.this, false); // // getPackageManager().setComponentEnabledSetting( -// new ComponentName("com.apb.beacon", "com.apb.beacon.HomeActivity-calculator"), +// new ComponentName("org.iilab.pb", "org.iilab.pb.HomeActivity-calculator"), // PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); // // getPackageManager().setComponentEnabledSetting( -// new ComponentName("com.apb.beacon", "com.apb.beacon.HomeActivity-setup"), +// new ComponentName("org.iilab.pb", "org.iilab.pb.HomeActivity-setup"), // PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); // } @@ -178,7 +177,7 @@ public void onClick(View v) { checkList.setAdapter(pageCheckListAdapter); pageCheckListAdapter.setData(currentPage.getChecklist()); - AppUtil.updateImages(true, currentPage.getContent(), MainModalActivity.this, metrics, tvContent, AppConstants.IMAGE_INLINE); +// AppUtil.updateImages(true, currentPage.getContent(), MainModalActivity.this, metrics, tvContent, AppConstants.IMAGE_INLINE); } diff --git a/src/main/java/com/apb/beacon/PanicButtonActivity.java b/src/main/java/org/iilab/pb/PanicButtonActivity.java similarity index 89% rename from src/main/java/com/apb/beacon/PanicButtonActivity.java rename to src/main/java/org/iilab/pb/PanicButtonActivity.java index 3b8fc64c..ace0ba65 100644 --- a/src/main/java/com/apb/beacon/PanicButtonActivity.java +++ b/src/main/java/org/iilab/pb/PanicButtonActivity.java @@ -1,4 +1,7 @@ -package com.apb.beacon; +package org.iilab.pb; + +import org.iilab.pb.alert.PanicAlert; +import org.iilab.pb.common.ApplicationSettings; import android.app.Activity; import android.content.BroadcastReceiver; @@ -11,8 +14,6 @@ import android.view.View; import android.view.ViewGroup; -import com.apb.beacon.alert.PanicAlert; -import com.apb.beacon.common.ApplicationSettings; public abstract class PanicButtonActivity extends Activity { public static final int ADD_TO_TOP = 0; @@ -68,7 +69,7 @@ PanicAlert getPanicAlert() { public void registerRestartInstallReceiver() { IntentFilter intentFilter = new IntentFilter(); - intentFilter.addAction("com.apb.beacon.RESTART_INSTALL"); + intentFilter.addAction("org.iilab.pb.RESTART_INSTALL"); registerReceiver(activityFinishReceiver, intentFilter); } @@ -76,7 +77,7 @@ public void registerRestartInstallReceiver() { @Override public void onReceive(Context context, Intent intent) { - if (intent.getAction().equals("com.apb.beacon.RESTART_INSTALL")) { + if (intent.getAction().equals("org.iilab.pb.RESTART_INSTALL")) { finish(); } } diff --git a/src/main/java/com/apb/beacon/WizardActivity.java b/src/main/java/org/iilab/pb/WizardActivity.java similarity index 92% rename from src/main/java/com/apb/beacon/WizardActivity.java rename to src/main/java/org/iilab/pb/WizardActivity.java index 73c65bbd..14e5dc9a 100644 --- a/src/main/java/com/apb/beacon/WizardActivity.java +++ b/src/main/java/org/iilab/pb/WizardActivity.java @@ -1,5 +1,23 @@ -package com.apb.beacon; - +package org.iilab.pb; + + +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.common.MyTagHandler; +import org.iilab.pb.data.PBDatabase; +import org.iilab.pb.fragment.LanguageSettingsFragment; +import org.iilab.pb.fragment.SetupCodeFragment; +import org.iilab.pb.fragment.SetupContactsFragment; +import org.iilab.pb.fragment.SetupMessageFragment; +import org.iilab.pb.fragment.SimpleFragment; +import org.iilab.pb.fragment.WarningFragment; +import org.iilab.pb.fragment.WizardAlarmTestDisguiseFragment; +import org.iilab.pb.fragment.WizardAlarmTestHardwareFragment; +import org.iilab.pb.fragment.WizardTestDisguiseCodeFragment; +import org.iilab.pb.fragment.WizardTestDisguiseOpenFragment; +import org.iilab.pb.fragment.WizardTestDisguiseUnlockFragment; +import org.iilab.pb.model.Page; +import org.iilab.pb.trigger.HardwareTriggerService; import android.content.ComponentName; import android.content.Intent; @@ -16,23 +34,6 @@ import android.widget.TextView; import android.widget.Toast; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.common.ApplicationSettings; -import com.apb.beacon.common.MyTagHandler; -import com.apb.beacon.data.PBDatabase; -import com.apb.beacon.fragment.LanguageSettingsFragment; -import com.apb.beacon.fragment.SetupCodeFragment; -import com.apb.beacon.fragment.SetupContactsFragment; -import com.apb.beacon.fragment.SetupMessageFragment; -import com.apb.beacon.fragment.SimpleFragment; -import com.apb.beacon.fragment.WarningFragment; -import com.apb.beacon.fragment.WizardAlarmTestDisguiseFragment; -import com.apb.beacon.fragment.WizardAlarmTestHardwareFragment; -import com.apb.beacon.fragment.WizardTestDisguiseCodeFragment; -import com.apb.beacon.fragment.WizardTestDisguiseOpenFragment; -import com.apb.beacon.fragment.WizardTestDisguiseUnlockFragment; -import com.apb.beacon.model.Page; -import com.apb.beacon.trigger.HardwareTriggerService; public class WizardActivity extends BaseFragmentActivity { @@ -164,11 +165,11 @@ else if (currentPage.getComponent().equals("alarm-test-hardware")) { private void changeAppIcontoCalculator() { getPackageManager().setComponentEnabledSetting( - new ComponentName("com.apb.beacon", "com.apb.beacon.HomeActivity-calculator"), + new ComponentName("org.iilab.pb", "org.iilab.pb.HomeActivity-calculator"), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); getPackageManager().setComponentEnabledSetting( - new ComponentName("com.apb.beacon", "com.apb.beacon.HomeActivity-setup"), + new ComponentName("org.iilab.pb", "org.iilab.pb.HomeActivity-setup"), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } diff --git a/src/main/java/com/apb/beacon/WizardModalActivity.java b/src/main/java/org/iilab/pb/WizardModalActivity.java similarity index 90% rename from src/main/java/com/apb/beacon/WizardModalActivity.java rename to src/main/java/org/iilab/pb/WizardModalActivity.java index 86fd3e8f..b7fe08cd 100644 --- a/src/main/java/com/apb/beacon/WizardModalActivity.java +++ b/src/main/java/org/iilab/pb/WizardModalActivity.java @@ -1,4 +1,12 @@ -package com.apb.beacon; +package org.iilab.pb; + +import org.iilab.pb.adapter.PageCheckListAdapter; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.common.AppUtil; +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.common.MyTagHandler; +import org.iilab.pb.data.PBDatabase; +import org.iilab.pb.model.Page; import android.content.ComponentName; import android.content.Intent; @@ -13,13 +21,6 @@ import android.widget.ListView; import android.widget.TextView; -import com.apb.beacon.adapter.PageCheckListAdapter; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.common.AppUtil; -import com.apb.beacon.common.ApplicationSettings; -import com.apb.beacon.common.MyTagHandler; -import com.apb.beacon.data.PBDatabase; -import com.apb.beacon.model.Page; /** @@ -113,11 +114,11 @@ public void onClick(View v) { // ApplicationSettings.setFirstRun(WizardModalActivity.this, false); getPackageManager().setComponentEnabledSetting( - new ComponentName("com.apb.beacon", "com.apb.beacon.HomeActivity-calculator"), + new ComponentName("org.iilab.pb", "org.iilab.pb.HomeActivity-calculator"), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); getPackageManager().setComponentEnabledSetting( - new ComponentName("com.apb.beacon", "com.apb.beacon.HomeActivity-setup"), + new ComponentName("org.iilab.pb", "org.iilab.pb.HomeActivity-setup"), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } @@ -156,11 +157,11 @@ public void onClick(View v) { // ApplicationSettings.setFirstRun(WizardModalActivity.this, false); getPackageManager().setComponentEnabledSetting( - new ComponentName("com.apb.beacon", "com.apb.beacon.HomeActivity-calculator"), + new ComponentName("org.iilab.pb", "org.iilab.pb.HomeActivity-calculator"), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); getPackageManager().setComponentEnabledSetting( - new ComponentName("com.apb.beacon", "com.apb.beacon.HomeActivity-setup"), + new ComponentName("org.iilab.pb", "org.iilab.pb.HomeActivity-setup"), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); } diff --git a/src/main/java/com/apb/beacon/adapter/AppInfoAdapter.java b/src/main/java/org/iilab/pb/adapter/AppInfoAdapter.java similarity index 96% rename from src/main/java/com/apb/beacon/adapter/AppInfoAdapter.java rename to src/main/java/org/iilab/pb/adapter/AppInfoAdapter.java index d0d95916..f8143f63 100644 --- a/src/main/java/com/apb/beacon/adapter/AppInfoAdapter.java +++ b/src/main/java/org/iilab/pb/adapter/AppInfoAdapter.java @@ -1,4 +1,4 @@ -package com.apb.beacon.adapter; +package org.iilab.pb.adapter; import android.content.Context; import android.content.pm.ApplicationInfo; @@ -14,11 +14,12 @@ import android.widget.TextView; import android.widget.Toast; -import com.apb.beacon.R; -import com.apb.beacon.model.AppInfo; import java.util.List; +import org.iilab.pb.R; +import org.iilab.pb.model.AppInfo; + /** * Created by aoe on 1/24/14. */ diff --git a/src/main/java/com/apb/beacon/adapter/PageActionAdapter.java b/src/main/java/org/iilab/pb/adapter/PageActionAdapter.java similarity index 96% rename from src/main/java/com/apb/beacon/adapter/PageActionAdapter.java rename to src/main/java/org/iilab/pb/adapter/PageActionAdapter.java index 576d6514..b88cd555 100644 --- a/src/main/java/com/apb/beacon/adapter/PageActionAdapter.java +++ b/src/main/java/org/iilab/pb/adapter/PageActionAdapter.java @@ -1,4 +1,4 @@ -package com.apb.beacon.adapter; +package org.iilab.pb.adapter; import android.app.Activity; import android.content.Context; @@ -10,15 +10,16 @@ import android.widget.Button; import android.widget.ImageView; -import com.apb.beacon.CalculatorActivity; -import com.apb.beacon.MainActivity; -import com.apb.beacon.R; -import com.apb.beacon.WizardActivity; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.model.PageAction; import java.util.List; +import org.iilab.pb.CalculatorActivity; +import org.iilab.pb.MainActivity; +import org.iilab.pb.R; +import org.iilab.pb.WizardActivity; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.model.PageAction; + /** * Created by aoe on 1/5/14. diff --git a/src/main/java/com/apb/beacon/adapter/PageActionFakeAdapter.java b/src/main/java/org/iilab/pb/adapter/PageActionFakeAdapter.java similarity index 97% rename from src/main/java/com/apb/beacon/adapter/PageActionFakeAdapter.java rename to src/main/java/org/iilab/pb/adapter/PageActionFakeAdapter.java index c068a90a..f335c295 100644 --- a/src/main/java/com/apb/beacon/adapter/PageActionFakeAdapter.java +++ b/src/main/java/org/iilab/pb/adapter/PageActionFakeAdapter.java @@ -1,4 +1,4 @@ -package com.apb.beacon.adapter; +package org.iilab.pb.adapter; import android.content.Context; import android.view.LayoutInflater; @@ -8,11 +8,12 @@ import android.widget.Button; import android.widget.ImageView; -import com.apb.beacon.R; -import com.apb.beacon.model.PageAction; import java.util.List; +import org.iilab.pb.R; +import org.iilab.pb.model.PageAction; + /** * Created by aoe on 2/10/14. */ diff --git a/src/main/java/com/apb/beacon/adapter/PageCheckListAdapter.java b/src/main/java/org/iilab/pb/adapter/PageCheckListAdapter.java similarity index 94% rename from src/main/java/com/apb/beacon/adapter/PageCheckListAdapter.java rename to src/main/java/org/iilab/pb/adapter/PageCheckListAdapter.java index cf6d15fb..cc9719a4 100644 --- a/src/main/java/com/apb/beacon/adapter/PageCheckListAdapter.java +++ b/src/main/java/org/iilab/pb/adapter/PageCheckListAdapter.java @@ -1,4 +1,4 @@ -package com.apb.beacon.adapter; +package org.iilab.pb.adapter; import android.content.Context; import android.view.LayoutInflater; @@ -7,11 +7,12 @@ import android.widget.ArrayAdapter; import android.widget.TextView; -import com.apb.beacon.R; -import com.apb.beacon.model.PageChecklist; import java.util.List; +import org.iilab.pb.R; +import org.iilab.pb.model.PageChecklist; + /** * Created by aoe on 1/16/14. */ diff --git a/src/main/java/com/apb/beacon/adapter/PageItemAdapter.java b/src/main/java/org/iilab/pb/adapter/PageItemAdapter.java similarity index 94% rename from src/main/java/com/apb/beacon/adapter/PageItemAdapter.java rename to src/main/java/org/iilab/pb/adapter/PageItemAdapter.java index fceb5960..8198e545 100644 --- a/src/main/java/com/apb/beacon/adapter/PageItemAdapter.java +++ b/src/main/java/org/iilab/pb/adapter/PageItemAdapter.java @@ -1,4 +1,4 @@ -package com.apb.beacon.adapter; +package org.iilab.pb.adapter; import android.content.Context; import android.view.LayoutInflater; @@ -8,11 +8,12 @@ import android.widget.ImageView; import android.widget.TextView; -import com.apb.beacon.R; -import com.apb.beacon.model.PageItem; import java.util.List; +import org.iilab.pb.R; +import org.iilab.pb.model.PageItem; + /** * Created by aoe on 1/6/14. */ diff --git a/src/main/java/com/apb/beacon/adapter/PageLanguageSettingsAdapter.java b/src/main/java/org/iilab/pb/adapter/PageLanguageSettingsAdapter.java similarity index 95% rename from src/main/java/com/apb/beacon/adapter/PageLanguageSettingsAdapter.java rename to src/main/java/org/iilab/pb/adapter/PageLanguageSettingsAdapter.java index 946a25ed..8142bc54 100644 --- a/src/main/java/com/apb/beacon/adapter/PageLanguageSettingsAdapter.java +++ b/src/main/java/org/iilab/pb/adapter/PageLanguageSettingsAdapter.java @@ -1,4 +1,4 @@ -package com.apb.beacon.adapter; +package org.iilab.pb.adapter; import android.app.Activity; import android.app.ProgressDialog; @@ -15,18 +15,18 @@ import android.widget.Button; import android.widget.Toast; -import com.apb.beacon.MainActivity; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.common.ApplicationSettings; -import com.apb.beacon.R; -import com.apb.beacon.common.AppUtil; -import com.apb.beacon.data.PBDatabase; -import com.apb.beacon.model.Page; -import com.apb.beacon.model.PageAction; -import com.apb.beacon.model.ServerResponse; -import com.apb.beacon.common.JsonParser; -import com.apb.beacon.WizardActivity; +import org.iilab.pb.MainActivity; +import org.iilab.pb.R; +import org.iilab.pb.WizardActivity; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.common.AppUtil; +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.common.JsonParser; +import org.iilab.pb.data.PBDatabase; +import org.iilab.pb.model.Page; +import org.iilab.pb.model.PageAction; +import org.iilab.pb.model.ServerResponse; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; diff --git a/src/main/java/org/iilab/pb/alert/AlarmReceiver.java b/src/main/java/org/iilab/pb/alert/AlarmReceiver.java new file mode 100644 index 00000000..3ab1434e --- /dev/null +++ b/src/main/java/org/iilab/pb/alert/AlarmReceiver.java @@ -0,0 +1,45 @@ +package org.iilab.pb.alert; + +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.Intent; +import android.location.Location; +import android.util.Log; + +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.common.Intents; + + +public class AlarmReceiver extends BroadcastReceiver { + + private Context mContext; + + @Override + public void onReceive(Context context, Intent intent) { + Log.e(">>>>>>>>", "onReceive - AlarmReceiver"); + mContext = context.getApplicationContext(); + if(intent.getAction().equals(Intents.SEND_ALERT_ACTION)) { + Log.e(">>>>>>>>", "alert update received in AlarmReceiver at current time in millis = " + System.currentTimeMillis() % 100000); + getPanicMessage(mContext).send(getCurrentBestLocation()); + + if (!ApplicationSettings.getFirstMsgWithLocationTriggered(context)) { + ApplicationSettings.setFirstMsgWithLocationTriggered(context, true); + } + } else if(intent.getAction().equals(Intents.SEND_ALERT_ACTION_SINGLE)) { + Log.e(">>>>>>>>", "alert update(single) received in AlarmReceiver at current time in millis = " + System.currentTimeMillis() % 100000); + + if (!ApplicationSettings.getFirstMsgWithLocationTriggered(context)) { + getPanicMessage(mContext).send(getCurrentBestLocation()); + ApplicationSettings.setFirstMsgWithLocationTriggered(context, true); + } + } + } + + PanicMessage getPanicMessage(Context context) { + return new PanicMessage(mContext); + } + + Location getCurrentBestLocation() { + return ApplicationSettings.getCurrentBestLocation(mContext); + } +} diff --git a/src/main/java/com/apb/beacon/alert/AlertStatus.java b/src/main/java/org/iilab/pb/alert/AlertStatus.java similarity index 94% rename from src/main/java/com/apb/beacon/alert/AlertStatus.java rename to src/main/java/org/iilab/pb/alert/AlertStatus.java index fd530e57..9cccb1b4 100644 --- a/src/main/java/com/apb/beacon/alert/AlertStatus.java +++ b/src/main/java/org/iilab/pb/alert/AlertStatus.java @@ -1,6 +1,6 @@ -package com.apb.beacon.alert; +package org.iilab.pb.alert; -import com.apb.beacon.R; +import org.iilab.pb.R; public enum AlertStatus { STANDBY(R.string.send_emergency_alert, R.string.alert_status_standby, R.drawable.send_alert_button, true), diff --git a/src/main/java/org/iilab/pb/alert/PanicAlert.java b/src/main/java/org/iilab/pb/alert/PanicAlert.java new file mode 100644 index 00000000..cc68b73f --- /dev/null +++ b/src/main/java/org/iilab/pb/alert/PanicAlert.java @@ -0,0 +1,176 @@ +package org.iilab.pb.alert; + +import android.app.Activity; +import android.app.AlarmManager; +import android.app.PendingIntent; +import android.content.Context; +import android.location.Location; +import android.location.LocationManager; +import android.os.Handler; +import android.os.SystemClock; +import android.os.Vibrator; +import android.util.Log; + +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.common.AppUtil; +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.common.Intents; +import org.iilab.pb.location.CurrentLocationProvider; + +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import static android.location.LocationManager.GPS_PROVIDER; +import static android.location.LocationManager.NETWORK_PROVIDER; +import static org.iilab.pb.common.Intents.locationPendingIntent; + +public class PanicAlert { + private static final String TAG = PanicAlert.class.getName(); + private LocationManager locationManager; + private Context context; + private AlarmManager alarmManager1, alarmManager2; + + public PanicAlert(Context context) { + this.context = context; + locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); + alarmManager1 = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); + alarmManager2 = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); + } + + public void activate() { + AppUtil.close(context); + vibrate(); + if (isActive() +// || ApplicationSettings.isRestartedSetup(context) + ) { + return; + } + ApplicationSettings.setAlertActive(context, true); + getExecutorService().execute( + new Runnable() { + @Override + public void run() { + activateAlert(); + } + } + ); + } + + private void activateAlert() { + ApplicationSettings.setAlertActive(context, true); + sendFirstAlert(); + registerLocationUpdate(); + scheduleFutureAlert(); + } + + public void deActivate() { + Log.e("", "Deactivating???"); + ApplicationSettings.setAlertActive(context, false); + locationManager.removeUpdates(locationPendingIntent(context)); + alarmManager2.cancel(Intents.alarmPendingIntent(context)); + ApplicationSettings.setFirstMsgWithLocationTriggered(context, false); + } + + private void sendFirstAlert() { + CurrentLocationProvider currentLocationProvider = getCurrentLocationProvider(); + Location loc = getLocation(currentLocationProvider); + if(loc != null) { + ApplicationSettings.setFirstMsgWithLocationTriggered(context, true); + } else { + scheduleFirstLocationAlert(); + } + createPanicMessage().send(loc); + } + + PanicMessage createPanicMessage() { + return new PanicMessage(context); + } + + CurrentLocationProvider getCurrentLocationProvider() { + return new CurrentLocationProvider(context); + } + + private void scheduleFirstLocationAlert() { + PendingIntent alarmPendingIntent = Intents.singleAlarmPendingIntent(context); + long firstTimeTriggerAt = SystemClock.elapsedRealtime() + AppConstants.ONE_MINUTE * 1; // we schedule this alarm after 1 minute + alarmManager1.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTimeTriggerAt, alarmPendingIntent); +// alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTimeTriggerAt, interval, alarmPendingIntent); + } + + private void scheduleFutureAlert() { + PendingIntent alarmPendingIntent = Intents.alarmPendingIntent(context); + long firstTimeTriggerAt = SystemClock.elapsedRealtime() + AppConstants.ONE_MINUTE * ApplicationSettings.getAlertDelay(context); + long interval = AppConstants.ONE_MINUTE * ApplicationSettings.getAlertDelay(context); + alarmManager2.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTimeTriggerAt, interval, alarmPendingIntent); + } + + private void registerLocationUpdate() { + + if (locationManager.getAllProviders().contains(LocationManager.GPS_PROVIDER)) + locationManager.requestLocationUpdates(GPS_PROVIDER, AppConstants.GPS_MIN_TIME_IN_FIRST_ONE_MINUTE, AppConstants.GPS_MIN_DISTANCE, locationPendingIntent(context)); + if (locationManager.getAllProviders().contains(LocationManager.NETWORK_PROVIDER)) + locationManager.requestLocationUpdates(NETWORK_PROVIDER, AppConstants.NETWORK_MIN_TIME_IN_FIRST_ONE_MINUTE, AppConstants.NETWORK_MIN_DISTANCE, locationPendingIntent(context)); + + + ((Activity)context).runOnUiThread(new Runnable() { + @Override + public void run() { + Handler locationRefreshIntervalHandler = new Handler(); + locationRefreshIntervalHandler.postDelayed(new Runnable() { + @Override + public void run() { + if (locationManager != null && locationPendingIntent(context) != null) { + locationManager.removeUpdates(locationPendingIntent(context)); + } + if (locationManager.getAllProviders().contains(LocationManager.GPS_PROVIDER)) + locationManager.requestLocationUpdates(GPS_PROVIDER, AppConstants.GPS_MIN_TIME, AppConstants.GPS_MIN_DISTANCE, locationPendingIntent(context)); + if (locationManager.getAllProviders().contains(LocationManager.NETWORK_PROVIDER)) + locationManager.requestLocationUpdates(NETWORK_PROVIDER, AppConstants.NETWORK_MIN_TIME, AppConstants.NETWORK_MIN_DISTANCE, locationPendingIntent(context)); + } + }, 60 * 1000); // after 1 minute + } + }); + + } + + public boolean isActive() { + return ApplicationSettings.isAlertActive(context); + } + + private void vibrate() { + Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); + vibrator.vibrate(AppConstants.HAPTIC_FEEDBACK_DURATION); + } + + private Location getLocation(CurrentLocationProvider currentLocationProvider) { + Location location = null; + int retryCount = 0; + + while (retryCount < MAX_RETRIES && location == null) { + location = currentLocationProvider.getLocation(); + if (location == null) { + try { + retryCount++; + Thread.sleep(LOCATION_WAIT_TIME); + } catch (InterruptedException e) { + Log.e(TAG, "Location wait InterruptedException", e); + } + } + } + return location; + } + +// public AlertStatus getAlertStatus() { +// if (isActive()) { +// return AlertStatus.ACTIVE; +// } +// return AlertStatus.STANDBY; +// } + + ExecutorService getExecutorService() { + return Executors.newSingleThreadExecutor(); + } + + public static final int MAX_RETRIES = 10; + public static final int LOCATION_WAIT_TIME = 1000; +} \ No newline at end of file diff --git a/src/main/java/com/apb/beacon/alert/PanicMessage.java b/src/main/java/org/iilab/pb/alert/PanicMessage.java similarity index 92% rename from src/main/java/com/apb/beacon/alert/PanicMessage.java rename to src/main/java/org/iilab/pb/alert/PanicMessage.java index 9cc7b4a3..dbeb60e3 100644 --- a/src/main/java/com/apb/beacon/alert/PanicMessage.java +++ b/src/main/java/org/iilab/pb/alert/PanicMessage.java @@ -1,10 +1,11 @@ -package com.apb.beacon.alert; +package org.iilab.pb.alert; + +import org.iilab.pb.location.LocationFormatter; +import org.iilab.pb.model.SMSSettings; import android.content.Context; import android.location.Location; -import com.apb.beacon.location.LocationFormatter; -import com.apb.beacon.model.SMSSettings; import static android.telephony.SmsMessage.MAX_USER_DATA_SEPTETS; diff --git a/src/main/java/com/apb/beacon/alert/SMSAdapter.java b/src/main/java/org/iilab/pb/alert/SMSAdapter.java similarity index 95% rename from src/main/java/com/apb/beacon/alert/SMSAdapter.java rename to src/main/java/org/iilab/pb/alert/SMSAdapter.java index 0bb84292..d48c7825 100644 --- a/src/main/java/com/apb/beacon/alert/SMSAdapter.java +++ b/src/main/java/org/iilab/pb/alert/SMSAdapter.java @@ -1,4 +1,4 @@ -package com.apb.beacon.alert; +package org.iilab.pb.alert; import android.telephony.SmsManager; import android.util.Log; diff --git a/src/main/java/com/apb/beacon/calculator/Calculator.java b/src/main/java/org/iilab/pb/calculator/Calculator.java similarity index 88% rename from src/main/java/com/apb/beacon/calculator/Calculator.java rename to src/main/java/org/iilab/pb/calculator/Calculator.java index 4a9a0686..f5a492b1 100644 --- a/src/main/java/com/apb/beacon/calculator/Calculator.java +++ b/src/main/java/org/iilab/pb/calculator/Calculator.java @@ -1,4 +1,4 @@ -package com.apb.beacon.calculator; +package org.iilab.pb.calculator; public interface Calculator { diff --git a/src/main/java/com/apb/beacon/calculator/CalculatorImpl.java b/src/main/java/org/iilab/pb/calculator/CalculatorImpl.java similarity index 99% rename from src/main/java/com/apb/beacon/calculator/CalculatorImpl.java rename to src/main/java/org/iilab/pb/calculator/CalculatorImpl.java index 9a88d490..a6739f9d 100644 --- a/src/main/java/com/apb/beacon/calculator/CalculatorImpl.java +++ b/src/main/java/org/iilab/pb/calculator/CalculatorImpl.java @@ -1,4 +1,4 @@ -package com.apb.beacon.calculator; +package org.iilab.pb.calculator; import java.math.BigDecimal; diff --git a/src/main/java/com/apb/beacon/common/AppConstants.java b/src/main/java/org/iilab/pb/common/AppConstants.java similarity index 88% rename from src/main/java/com/apb/beacon/common/AppConstants.java rename to src/main/java/org/iilab/pb/common/AppConstants.java index 51abc9ec..63100036 100644 --- a/src/main/java/com/apb/beacon/common/AppConstants.java +++ b/src/main/java/org/iilab/pb/common/AppConstants.java @@ -1,4 +1,4 @@ -package com.apb.beacon.common; +package org.iilab.pb.common; public class AppConstants { //Test values @@ -13,11 +13,14 @@ public class AppConstants { public static final int HAPTIC_FEEDBACK_DURATION = 3000; public static final float GPS_MIN_DISTANCE = 0; + public static final long GPS_MIN_TIME_IN_FIRST_ONE_MINUTE = 1000 * 20; public static final long GPS_MIN_TIME = 1000 * 60 * 2; public static final float NETWORK_MIN_DISTANCE = 0; + public static final long NETWORK_MIN_TIME_IN_FIRST_ONE_MINUTE = 1000 * 20; public static final long NETWORK_MIN_TIME = 1000 * 60 * 2; + public static final String CUSTOM_ALERT_MSG_WHEN_LOCATION_NOT_FOUND = " - trying to identify location"; public static final int WARNING_TRAINING_MESSAGE_MINIMUM_CHARACTER = 30; diff --git a/src/main/java/com/apb/beacon/common/AppUtil.java b/src/main/java/org/iilab/pb/common/AppUtil.java similarity index 99% rename from src/main/java/com/apb/beacon/common/AppUtil.java rename to src/main/java/org/iilab/pb/common/AppUtil.java index 322c40f4..d9ad09aa 100644 --- a/src/main/java/com/apb/beacon/common/AppUtil.java +++ b/src/main/java/org/iilab/pb/common/AppUtil.java @@ -1,4 +1,4 @@ -package com.apb.beacon.common; +package org.iilab.pb.common; import android.content.Context; import android.content.Intent; diff --git a/src/main/java/com/apb/beacon/common/ApplicationSettings.java b/src/main/java/org/iilab/pb/common/ApplicationSettings.java similarity index 85% rename from src/main/java/com/apb/beacon/common/ApplicationSettings.java rename to src/main/java/org/iilab/pb/common/ApplicationSettings.java index 675be2b7..3693e711 100644 --- a/src/main/java/com/apb/beacon/common/ApplicationSettings.java +++ b/src/main/java/org/iilab/pb/common/ApplicationSettings.java @@ -1,5 +1,6 @@ -package com.apb.beacon.common; +package org.iilab.pb.common; +import android.app.Application; import android.content.Context; import android.content.SharedPreferences; import android.location.Location; @@ -7,7 +8,10 @@ import com.google.gson.Gson; -public class ApplicationSettings { +public class ApplicationSettings extends Application{ + + private static final int ALERT_FREQUENCY = 10 * 60000; // 10 minute + public static final String FIRST_RUN = "FIRST_RUN"; // public static final String RESTARTED_SETUP = "RESTARTED_SETUP"; public static final String HARDCODE_INSERT = "HARDCODE_INSERT"; @@ -20,7 +24,11 @@ public class ApplicationSettings { public static final String LAST_UPDATED_VERSION = "LAST_UPDATED_VERSION"; public static final String LAST_UPDATED_DB_VERSION = "LAST_UPDATED_DB_VERSION"; public static final String ALERT_DELAY = "ALERT_DELAY"; - + public static final String IS_FIRST_MSG_WITH_LOCATION_TRIGGERED = "is_first_msg_with_location_triggered"; + + public static Context getAppContext(){ + return getAppContext(); + } // these 2 methods with first time run won't be needed any more. I'll get rid of it after further analysis. public static void setFirstRun(Context context, boolean isFirstRun) { @@ -89,9 +97,8 @@ public static Location getCurrentBestLocation(Context context) { private static Location constructLocation(String locationJson) { Location location = new Gson().fromJson(locationJson, Location.class); -// long timeDelta = System.currentTimeMillis() - location.getTime(); -// return (timeDelta <= ALERT_FREQUENCY) ? location : null; - return location; + long timeDelta = System.currentTimeMillis() - location.getTime(); + return (timeDelta <= ALERT_FREQUENCY) ? location : null; } public static void setCurrentBestLocation(Context context, Location location) { @@ -157,7 +164,16 @@ public static void setAlertDelay(Context context, int alertDelay) { } public static int getAlertDelay(Context context) { - return sharedPreferences(context).getInt(ALERT_DELAY, 5); + return sharedPreferences(context).getInt(ALERT_DELAY, 2); // need to change it to default value = 5 + } + + + public static void setFirstMsgWithLocationTriggered(Context context, Boolean flag) { + saveBoolean(context, IS_FIRST_MSG_WITH_LOCATION_TRIGGERED , flag); + } + + public static Boolean getFirstMsgWithLocationTriggered(Context context) { + return sharedPreferences(context).getBoolean(IS_FIRST_MSG_WITH_LOCATION_TRIGGERED, false); } diff --git a/src/main/java/com/apb/beacon/common/ContactEditTexts.java b/src/main/java/org/iilab/pb/common/ContactEditTexts.java similarity index 92% rename from src/main/java/com/apb/beacon/common/ContactEditTexts.java rename to src/main/java/org/iilab/pb/common/ContactEditTexts.java index 5a875b16..79e82122 100644 --- a/src/main/java/com/apb/beacon/common/ContactEditTexts.java +++ b/src/main/java/org/iilab/pb/common/ContactEditTexts.java @@ -1,4 +1,4 @@ -package com.apb.beacon.common; +package org.iilab.pb.common; import android.content.Context; import android.support.v4.app.Fragment; @@ -9,18 +9,19 @@ import android.widget.Button; import android.widget.EditText; -import com.apb.beacon.R; -import com.apb.beacon.model.SMSSettings; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import static com.apb.beacon.R.id.first_contact; -import static com.apb.beacon.R.id.second_contact; -import static com.apb.beacon.R.id.third_contact; +import org.iilab.pb.R; +import org.iilab.pb.model.SMSSettings; -import static com.apb.beacon.common.AppConstants.PHONE_NUMBER_LIMIT; + +import static org.iilab.pb.R.id.first_contact; +import static org.iilab.pb.R.id.second_contact; +import static org.iilab.pb.R.id.third_contact; +import static org.iilab.pb.common.AppConstants.PHONE_NUMBER_LIMIT; public class ContactEditTexts { private List contacts = new ArrayList(); diff --git a/src/main/java/com/apb/beacon/common/ContactPickerFragment.java b/src/main/java/org/iilab/pb/common/ContactPickerFragment.java similarity index 98% rename from src/main/java/com/apb/beacon/common/ContactPickerFragment.java rename to src/main/java/org/iilab/pb/common/ContactPickerFragment.java index f1c3c46a..754ac9de 100644 --- a/src/main/java/com/apb/beacon/common/ContactPickerFragment.java +++ b/src/main/java/org/iilab/pb/common/ContactPickerFragment.java @@ -1,4 +1,6 @@ -package com.apb.beacon.common; +package org.iilab.pb.common; + +import org.iilab.pb.R; import android.content.Intent; import android.database.Cursor; @@ -12,7 +14,6 @@ import android.widget.EditText; import android.widget.ImageButton; -import com.apb.beacon.R; import static android.app.Activity.RESULT_OK; import static android.content.Intent.ACTION_GET_CONTENT; diff --git a/src/main/java/org/iilab/pb/common/CustomLinkMovementMethod.java b/src/main/java/org/iilab/pb/common/CustomLinkMovementMethod.java new file mode 100644 index 00000000..56317851 --- /dev/null +++ b/src/main/java/org/iilab/pb/common/CustomLinkMovementMethod.java @@ -0,0 +1,69 @@ +package org.iilab.pb.common; + +import android.content.Context; +import android.content.Intent; +import android.graphics.Color; +import android.net.Uri; +import android.text.Layout; +import android.text.Spannable; +import android.text.method.LinkMovementMethod; +import android.text.method.MovementMethod; +import android.text.style.URLSpan; +import android.util.Log; +import android.view.MotionEvent; +import android.widget.TextView; +import android.widget.Toast; + + +/** + * Created by aoe on 6/13/2014. + */ +public class CustomLinkMovementMethod extends LinkMovementMethod { + + private static Context movementContext; + + private static CustomLinkMovementMethod linkMovementMethod = new CustomLinkMovementMethod(); + + public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) { + int action = event.getAction(); + + if (action == MotionEvent.ACTION_UP) { + int x = (int) event.getX(); + int y = (int) event.getY(); + + x -= widget.getTotalPaddingLeft(); + y -= widget.getTotalPaddingTop(); + + x += widget.getScrollX(); + y += widget.getScrollY(); + + Layout layout = widget.getLayout(); + int line = layout.getLineForVertical(y); + int off = layout.getOffsetForHorizontal(line, x); + + URLSpan[] link = buffer.getSpans(off, off, URLSpan.class); + if (link.length != 0) { + String url = link[0].getURL(); + if (url.contains("https") || url.contains("http")) { + Log.d("Link", url); + Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); + movementContext.startActivity(browserIntent); + return true; + } else { + Log.d("Link", url); + widget.setHighlightColor(Color.WHITE); + Toast.makeText(movementContext, "Invalid link.", Toast.LENGTH_LONG).show(); + return false; + } + + } + } + + return super.onTouchEvent(widget, buffer, event); + } + + public static MovementMethod getInstance(Context c) { + movementContext = c; + return linkMovementMethod; + } +} diff --git a/src/main/java/com/apb/beacon/common/ImageDownloader.java b/src/main/java/org/iilab/pb/common/ImageDownloader.java similarity index 97% rename from src/main/java/com/apb/beacon/common/ImageDownloader.java rename to src/main/java/org/iilab/pb/common/ImageDownloader.java index 2001a38c..38a9f9e0 100644 --- a/src/main/java/com/apb/beacon/common/ImageDownloader.java +++ b/src/main/java/org/iilab/pb/common/ImageDownloader.java @@ -1,9 +1,8 @@ -package com.apb.beacon.common; +package org.iilab.pb.common; import android.os.AsyncTask; import android.util.Log; -import com.apb.beacon.model.AsyncTaskResult; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -11,6 +10,8 @@ import java.net.URL; import java.net.URLConnection; +import org.iilab.pb.model.AsyncTaskResult; + /** * Created by aoe on 1/3/14. */ diff --git a/src/main/java/com/apb/beacon/common/Intents.java b/src/main/java/org/iilab/pb/common/Intents.java similarity index 66% rename from src/main/java/com/apb/beacon/common/Intents.java rename to src/main/java/org/iilab/pb/common/Intents.java index 5d08045c..30b7825b 100644 --- a/src/main/java/com/apb/beacon/common/Intents.java +++ b/src/main/java/org/iilab/pb/common/Intents.java @@ -1,4 +1,4 @@ -package com.apb.beacon.common; +package org.iilab.pb.common; import android.app.PendingIntent; import android.content.Context; @@ -7,14 +7,19 @@ import static android.app.PendingIntent.FLAG_UPDATE_CURRENT; public class Intents { - private static final String PREFIX = "com.apb.beacon"; + private static final String PREFIX = "org.iilab.pb"; public static final String LOCATION_UPDATE_ACTION = PREFIX + ".LOCATION_UPDATE_ACTION"; public static final String SEND_ALERT_ACTION = PREFIX + ".SEND_ALERT_ACTION"; + public static final String SEND_ALERT_ACTION_SINGLE = PREFIX + ".SEND_ALERT_ACTION_SINGLE"; public static PendingIntent alarmPendingIntent(Context context) { return PendingIntent.getBroadcast(context, 0, new Intent(SEND_ALERT_ACTION), FLAG_UPDATE_CURRENT); } + public static PendingIntent singleAlarmPendingIntent(Context context) { + return PendingIntent.getBroadcast(context, 0, new Intent(SEND_ALERT_ACTION_SINGLE), FLAG_UPDATE_CURRENT); + } + public static PendingIntent locationPendingIntent(Context context) { return PendingIntent.getBroadcast(context, 0, new Intent(LOCATION_UPDATE_ACTION), FLAG_UPDATE_CURRENT); } diff --git a/src/main/java/com/apb/beacon/common/JsonParser.java b/src/main/java/org/iilab/pb/common/JsonParser.java similarity index 98% rename from src/main/java/com/apb/beacon/common/JsonParser.java rename to src/main/java/org/iilab/pb/common/JsonParser.java index c55a0429..6a8f3a95 100644 --- a/src/main/java/com/apb/beacon/common/JsonParser.java +++ b/src/main/java/org/iilab/pb/common/JsonParser.java @@ -1,8 +1,7 @@ -package com.apb.beacon.common; +package org.iilab.pb.common; import android.util.Log; -import com.apb.beacon.model.ServerResponse; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; @@ -17,6 +16,7 @@ import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.message.BasicHeader; import org.apache.http.protocol.HTTP; +import org.iilab.pb.model.ServerResponse; import org.json.JSONException; import org.json.JSONObject; diff --git a/src/main/java/com/apb/beacon/common/MessageLimitWatcher.java b/src/main/java/org/iilab/pb/common/MessageLimitWatcher.java similarity index 98% rename from src/main/java/com/apb/beacon/common/MessageLimitWatcher.java rename to src/main/java/org/iilab/pb/common/MessageLimitWatcher.java index 936ca658..685dd756 100644 --- a/src/main/java/com/apb/beacon/common/MessageLimitWatcher.java +++ b/src/main/java/org/iilab/pb/common/MessageLimitWatcher.java @@ -1,4 +1,4 @@ -package com.apb.beacon.common; +package org.iilab.pb.common; import android.graphics.Color; import android.text.Editable; diff --git a/src/main/java/com/apb/beacon/common/MyTagHandler.java b/src/main/java/org/iilab/pb/common/MyTagHandler.java similarity index 99% rename from src/main/java/com/apb/beacon/common/MyTagHandler.java rename to src/main/java/org/iilab/pb/common/MyTagHandler.java index 3e11c072..7b5b7b80 100644 --- a/src/main/java/com/apb/beacon/common/MyTagHandler.java +++ b/src/main/java/org/iilab/pb/common/MyTagHandler.java @@ -1,4 +1,4 @@ -package com.apb.beacon.common; +package org.iilab.pb.common; import android.text.Editable; import android.text.Html; diff --git a/src/main/java/com/apb/beacon/common/NestedListView.java b/src/main/java/org/iilab/pb/common/NestedListView.java similarity index 99% rename from src/main/java/com/apb/beacon/common/NestedListView.java rename to src/main/java/org/iilab/pb/common/NestedListView.java index 8de65de5..f92762f3 100644 --- a/src/main/java/com/apb/beacon/common/NestedListView.java +++ b/src/main/java/org/iilab/pb/common/NestedListView.java @@ -1,4 +1,4 @@ -package com.apb.beacon.common; +package org.iilab.pb.common; import android.content.Context; import android.util.AttributeSet; diff --git a/src/main/java/com/apb/beacon/common/SoftKeyboard.java b/src/main/java/org/iilab/pb/common/SoftKeyboard.java similarity index 93% rename from src/main/java/com/apb/beacon/common/SoftKeyboard.java rename to src/main/java/org/iilab/pb/common/SoftKeyboard.java index cde7b7aa..72d4e67b 100644 --- a/src/main/java/com/apb/beacon/common/SoftKeyboard.java +++ b/src/main/java/org/iilab/pb/common/SoftKeyboard.java @@ -1,4 +1,4 @@ -package com.apb.beacon.common; +package org.iilab.pb.common; import android.app.Activity; import android.content.Context; diff --git a/src/main/java/com/apb/beacon/data/HelpPageDbManager.java b/src/main/java/org/iilab/pb/data/HelpPageDbManager.java similarity index 97% rename from src/main/java/com/apb/beacon/data/HelpPageDbManager.java rename to src/main/java/org/iilab/pb/data/HelpPageDbManager.java index 9d74ac30..1d8d2619 100644 --- a/src/main/java/com/apb/beacon/data/HelpPageDbManager.java +++ b/src/main/java/org/iilab/pb/data/HelpPageDbManager.java @@ -1,4 +1,4 @@ -package com.apb.beacon.data; +package org.iilab.pb.data; import android.content.ContentValues; import android.database.Cursor; @@ -6,13 +6,14 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteStatement; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.model.HelpPage; -import com.apb.beacon.model.PageItem; import java.util.ArrayList; import java.util.List; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.model.HelpPage; +import org.iilab.pb.model.PageItem; + /** * Created by aoe on 2/28/14. */ diff --git a/src/main/java/com/apb/beacon/data/PBDatabase.java b/src/main/java/org/iilab/pb/data/PBDatabase.java similarity index 94% rename from src/main/java/com/apb/beacon/data/PBDatabase.java rename to src/main/java/org/iilab/pb/data/PBDatabase.java index cf1be0b5..94fa488d 100644 --- a/src/main/java/com/apb/beacon/data/PBDatabase.java +++ b/src/main/java/org/iilab/pb/data/PBDatabase.java @@ -1,21 +1,22 @@ -package com.apb.beacon.data; +package org.iilab.pb.data; import android.content.Context; import android.database.SQLException; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.model.HelpPage; -import com.apb.beacon.model.Page; -import com.apb.beacon.model.PageAction; -import com.apb.beacon.model.PageChecklist; -import com.apb.beacon.model.PageItem; -import com.apb.beacon.model.PageStatus; -import com.apb.beacon.model.PageTimer; import java.util.List; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.model.HelpPage; +import org.iilab.pb.model.Page; +import org.iilab.pb.model.PageAction; +import org.iilab.pb.model.PageChecklist; +import org.iilab.pb.model.PageItem; +import org.iilab.pb.model.PageStatus; +import org.iilab.pb.model.PageTimer; + /** * Created by aoe on 12/12/13. */ diff --git a/src/main/java/com/apb/beacon/data/PageActionDbManager.java b/src/main/java/org/iilab/pb/data/PageActionDbManager.java similarity index 98% rename from src/main/java/com/apb/beacon/data/PageActionDbManager.java rename to src/main/java/org/iilab/pb/data/PageActionDbManager.java index 52a26b44..1ae53666 100644 --- a/src/main/java/com/apb/beacon/data/PageActionDbManager.java +++ b/src/main/java/org/iilab/pb/data/PageActionDbManager.java @@ -1,4 +1,4 @@ -package com.apb.beacon.data; +package org.iilab.pb.data; import android.content.ContentValues; import android.database.Cursor; @@ -6,12 +6,13 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteStatement; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.model.PageAction; import java.util.ArrayList; import java.util.List; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.model.PageAction; + /** * Created by aoe on 1/5/14. */ diff --git a/src/main/java/com/apb/beacon/data/PageChecklistDbManager.java b/src/main/java/org/iilab/pb/data/PageChecklistDbManager.java similarity index 97% rename from src/main/java/com/apb/beacon/data/PageChecklistDbManager.java rename to src/main/java/org/iilab/pb/data/PageChecklistDbManager.java index 90856e6a..22b10812 100644 --- a/src/main/java/com/apb/beacon/data/PageChecklistDbManager.java +++ b/src/main/java/org/iilab/pb/data/PageChecklistDbManager.java @@ -1,4 +1,4 @@ -package com.apb.beacon.data; +package org.iilab.pb.data; import android.content.ContentValues; import android.database.Cursor; @@ -6,12 +6,13 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteStatement; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.model.PageChecklist; import java.util.ArrayList; import java.util.List; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.model.PageChecklist; + /** * Created by aoe on 1/16/14. */ diff --git a/src/main/java/com/apb/beacon/data/PageDbManager.java b/src/main/java/org/iilab/pb/data/PageDbManager.java similarity index 96% rename from src/main/java/com/apb/beacon/data/PageDbManager.java rename to src/main/java/org/iilab/pb/data/PageDbManager.java index 9a621534..87112aad 100644 --- a/src/main/java/com/apb/beacon/data/PageDbManager.java +++ b/src/main/java/org/iilab/pb/data/PageDbManager.java @@ -1,4 +1,4 @@ -package com.apb.beacon.data; +package org.iilab.pb.data; import android.content.ContentValues; import android.database.Cursor; @@ -6,17 +6,18 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteStatement; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.model.Page; -import com.apb.beacon.model.PageAction; -import com.apb.beacon.model.PageChecklist; -import com.apb.beacon.model.PageItem; -import com.apb.beacon.model.PageStatus; -import com.apb.beacon.model.PageTimer; import java.util.ArrayList; import java.util.List; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.model.Page; +import org.iilab.pb.model.PageAction; +import org.iilab.pb.model.PageChecklist; +import org.iilab.pb.model.PageItem; +import org.iilab.pb.model.PageStatus; +import org.iilab.pb.model.PageTimer; + /** * Created by aoe on 1/5/14. */ diff --git a/src/main/java/com/apb/beacon/data/PageItemDbManager.java b/src/main/java/org/iilab/pb/data/PageItemDbManager.java similarity index 97% rename from src/main/java/com/apb/beacon/data/PageItemDbManager.java rename to src/main/java/org/iilab/pb/data/PageItemDbManager.java index 3e556541..37681c54 100644 --- a/src/main/java/com/apb/beacon/data/PageItemDbManager.java +++ b/src/main/java/org/iilab/pb/data/PageItemDbManager.java @@ -1,4 +1,4 @@ -package com.apb.beacon.data; +package org.iilab.pb.data; import android.content.ContentValues; import android.database.Cursor; @@ -6,12 +6,13 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteStatement; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.model.PageItem; import java.util.ArrayList; import java.util.List; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.model.PageItem; + /** * Created by aoe on 1/5/14. */ diff --git a/src/main/java/com/apb/beacon/data/PageStatusDbManager.java b/src/main/java/org/iilab/pb/data/PageStatusDbManager.java similarity index 97% rename from src/main/java/com/apb/beacon/data/PageStatusDbManager.java rename to src/main/java/org/iilab/pb/data/PageStatusDbManager.java index 89c86d34..03db8878 100644 --- a/src/main/java/com/apb/beacon/data/PageStatusDbManager.java +++ b/src/main/java/org/iilab/pb/data/PageStatusDbManager.java @@ -1,4 +1,4 @@ -package com.apb.beacon.data; +package org.iilab.pb.data; import android.content.ContentValues; import android.database.Cursor; @@ -6,12 +6,13 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteStatement; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.model.PageStatus; import java.util.ArrayList; import java.util.List; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.model.PageStatus; + /** * Created by aoe on 1/5/14. */ diff --git a/src/main/java/com/apb/beacon/data/PageTimerDbManager.java b/src/main/java/org/iilab/pb/data/PageTimerDbManager.java similarity index 97% rename from src/main/java/com/apb/beacon/data/PageTimerDbManager.java rename to src/main/java/org/iilab/pb/data/PageTimerDbManager.java index 83a9b5cd..2bd4b134 100644 --- a/src/main/java/com/apb/beacon/data/PageTimerDbManager.java +++ b/src/main/java/org/iilab/pb/data/PageTimerDbManager.java @@ -1,4 +1,7 @@ -package com.apb.beacon.data; +package org.iilab.pb.data; + +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.model.PageTimer; import android.content.ContentValues; import android.database.Cursor; @@ -6,8 +9,6 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteStatement; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.model.PageTimer; /** * Created by aoe on 1/16/14. diff --git a/src/main/java/com/apb/beacon/fragment/LanguageSettingsFragment.java b/src/main/java/org/iilab/pb/fragment/LanguageSettingsFragment.java similarity index 92% rename from src/main/java/com/apb/beacon/fragment/LanguageSettingsFragment.java rename to src/main/java/org/iilab/pb/fragment/LanguageSettingsFragment.java index 6e990cc5..187baa09 100644 --- a/src/main/java/com/apb/beacon/fragment/LanguageSettingsFragment.java +++ b/src/main/java/org/iilab/pb/fragment/LanguageSettingsFragment.java @@ -1,4 +1,11 @@ -package com.apb.beacon.fragment; +package org.iilab.pb.fragment; + +import org.iilab.pb.R; +import org.iilab.pb.adapter.PageLanguageSettingsAdapter; +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.common.MyTagHandler; +import org.iilab.pb.data.PBDatabase; +import org.iilab.pb.model.Page; import android.app.Activity; import android.os.Bundle; @@ -11,12 +18,6 @@ import android.widget.ListView; import android.widget.TextView; -import com.apb.beacon.common.ApplicationSettings; -import com.apb.beacon.R; -import com.apb.beacon.adapter.PageLanguageSettingsAdapter; -import com.apb.beacon.common.MyTagHandler; -import com.apb.beacon.data.PBDatabase; -import com.apb.beacon.model.Page; /** * Created by aoe on 2/25/14. diff --git a/src/main/java/com/apb/beacon/fragment/MainSetupAlertFragment.java b/src/main/java/org/iilab/pb/fragment/MainSetupAlertFragment.java similarity index 94% rename from src/main/java/com/apb/beacon/fragment/MainSetupAlertFragment.java rename to src/main/java/org/iilab/pb/fragment/MainSetupAlertFragment.java index 5297bae3..df24e92a 100644 --- a/src/main/java/com/apb/beacon/fragment/MainSetupAlertFragment.java +++ b/src/main/java/org/iilab/pb/fragment/MainSetupAlertFragment.java @@ -1,4 +1,15 @@ -package com.apb.beacon.fragment; +package org.iilab.pb.fragment; + +import org.iilab.pb.MainActivity; +import org.iilab.pb.R; +import org.iilab.pb.WizardActivity; +import org.iilab.pb.adapter.PageItemAdapter; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.common.MyTagHandler; +import org.iilab.pb.data.PBDatabase; +import org.iilab.pb.model.Page; +import org.iilab.pb.model.PageItem; import android.app.Activity; import android.app.AlertDialog; @@ -19,16 +30,6 @@ import android.widget.TextView; import android.widget.Toast; -import com.apb.beacon.MainActivity; -import com.apb.beacon.R; -import com.apb.beacon.WizardActivity; -import com.apb.beacon.adapter.PageItemAdapter; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.common.ApplicationSettings; -import com.apb.beacon.common.MyTagHandler; -import com.apb.beacon.data.PBDatabase; -import com.apb.beacon.model.Page; -import com.apb.beacon.model.PageItem; public class MainSetupAlertFragment extends Fragment implements OnClickListener{ diff --git a/src/main/java/com/apb/beacon/fragment/MessageTextFragment.java b/src/main/java/org/iilab/pb/fragment/MessageTextFragment.java similarity index 96% rename from src/main/java/com/apb/beacon/fragment/MessageTextFragment.java rename to src/main/java/org/iilab/pb/fragment/MessageTextFragment.java index abb1064c..69fd7ca8 100644 --- a/src/main/java/com/apb/beacon/fragment/MessageTextFragment.java +++ b/src/main/java/org/iilab/pb/fragment/MessageTextFragment.java @@ -1,4 +1,7 @@ -package com.apb.beacon.fragment; +package org.iilab.pb.fragment; + +import org.iilab.pb.R; +import org.iilab.pb.common.MessageLimitWatcher; import android.app.Activity; import android.content.res.TypedArray; @@ -13,8 +16,6 @@ import android.widget.EditText; import android.widget.TextView; -import com.apb.beacon.R; -import com.apb.beacon.common.MessageLimitWatcher; import static java.lang.String.valueOf; diff --git a/src/main/java/com/apb/beacon/fragment/SetupCodeFragment.java b/src/main/java/org/iilab/pb/fragment/SetupCodeFragment.java similarity index 74% rename from src/main/java/com/apb/beacon/fragment/SetupCodeFragment.java rename to src/main/java/org/iilab/pb/fragment/SetupCodeFragment.java index aa17551f..ee968f4e 100644 --- a/src/main/java/com/apb/beacon/fragment/SetupCodeFragment.java +++ b/src/main/java/org/iilab/pb/fragment/SetupCodeFragment.java @@ -1,4 +1,17 @@ -package com.apb.beacon.fragment; +package org.iilab.pb.fragment; + +import org.iilab.pb.LoginActivity; +import org.iilab.pb.MainActivity; +import org.iilab.pb.R; +import org.iilab.pb.WizardActivity; +import org.iilab.pb.adapter.PageItemAdapter; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.common.AppUtil; +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.common.MyTagHandler; +import org.iilab.pb.data.PBDatabase; +import org.iilab.pb.model.Page; +import org.iilab.pb.model.PageItem; import android.app.Activity; import android.content.Intent; @@ -9,9 +22,11 @@ import android.text.TextWatcher; import android.util.DisplayMetrics; import android.util.Log; +import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.View.OnKeyListener; import android.widget.AdapterView; import android.widget.Button; import android.widget.EditText; @@ -20,17 +35,6 @@ import android.widget.TextView; import android.widget.Toast; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.common.ApplicationSettings; -import com.apb.beacon.MainActivity; -import com.apb.beacon.R; -import com.apb.beacon.WizardActivity; -import com.apb.beacon.adapter.PageItemAdapter; -import com.apb.beacon.common.AppUtil; -import com.apb.beacon.common.MyTagHandler; -import com.apb.beacon.data.PBDatabase; -import com.apb.beacon.model.Page; -import com.apb.beacon.model.PageItem; public class SetupCodeFragment extends Fragment { @@ -67,6 +71,40 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa View view = inflater.inflate(R.layout.fragment_type_interactive_code, container, false); passwordEditText = (EditText) view.findViewById(R.id.create_pin_edittext); passwordEditText.addTextChangedListener(passwordTextChangeListener); + passwordEditText.setOnKeyListener(new OnKeyListener() { + public boolean onKey(View v, int keyCode, KeyEvent event) { + // If the event is a key-down event on the "enter" button + if ((event.getAction() == KeyEvent.ACTION_DOWN) && + (keyCode == KeyEvent.KEYCODE_ENTER)) { + // Perform action on key press + Log.e(">>>>", "action button pressed"); + ApplicationSettings.savePassword(getActivity(), passwordEditText.getText().toString()); + + String pageId = currentPage.getAction().get(0).getLink(); + int parentActivity = getArguments().getInt(PARENT_ACTIVITY); + Intent i; + + if(parentActivity == AppConstants.FROM_WIZARD_ACTIVITY){ + i = new Intent(activity, WizardActivity.class); + } else{ +// AppUtil.showToast("New pincode saved.", 1000, activity); + String confirmation = (currentPage.getAction().get(0).getConfirmation() == null) + ? AppConstants.DEFAULT_CONFIRMATION_MESSAGE + : currentPage.getAction().get(0).getConfirmation(); + Toast.makeText(activity, confirmation, Toast.LENGTH_SHORT).show(); + + i = new Intent(activity, MainActivity.class); + } + i.putExtra("page_id", pageId); + startActivity(i); + + if(parentActivity == AppConstants.FROM_MAIN_ACTIVITY){ + activity.finish(); + } + } + return false; + } + }); tvTitle = (TextView) view.findViewById(R.id.fragment_title); tvIntro = (TextView) view.findViewById(R.id.fragment_intro); diff --git a/src/main/java/com/apb/beacon/fragment/SetupContactsFragment.java b/src/main/java/org/iilab/pb/fragment/SetupContactsFragment.java similarity index 92% rename from src/main/java/com/apb/beacon/fragment/SetupContactsFragment.java rename to src/main/java/org/iilab/pb/fragment/SetupContactsFragment.java index 7a83c267..69f0f42f 100644 --- a/src/main/java/com/apb/beacon/fragment/SetupContactsFragment.java +++ b/src/main/java/org/iilab/pb/fragment/SetupContactsFragment.java @@ -1,4 +1,4 @@ -package com.apb.beacon.fragment; +package org.iilab.pb.fragment; import android.app.Activity; import android.content.Intent; @@ -17,22 +17,23 @@ import android.widget.TextView; import android.widget.Toast; -import com.apb.beacon.MainActivity; -import com.apb.beacon.R; -import com.apb.beacon.WizardActivity; -import com.apb.beacon.adapter.PageItemAdapter; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.common.AppUtil; -import com.apb.beacon.common.ApplicationSettings; -import com.apb.beacon.common.ContactEditTexts; -import com.apb.beacon.common.MyTagHandler; -import com.apb.beacon.data.PBDatabase; -import com.apb.beacon.model.Page; -import com.apb.beacon.model.PageItem; -import com.apb.beacon.model.SMSSettings; import java.util.List; +import org.iilab.pb.MainActivity; +import org.iilab.pb.R; +import org.iilab.pb.WizardActivity; +import org.iilab.pb.adapter.PageItemAdapter; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.common.AppUtil; +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.common.ContactEditTexts; +import org.iilab.pb.common.MyTagHandler; +import org.iilab.pb.data.PBDatabase; +import org.iilab.pb.model.Page; +import org.iilab.pb.model.PageItem; +import org.iilab.pb.model.SMSSettings; + /** * Created by aoe on 12/11/13. */ diff --git a/src/main/java/com/apb/beacon/fragment/SetupMessageFragment.java b/src/main/java/org/iilab/pb/fragment/SetupMessageFragment.java similarity index 93% rename from src/main/java/com/apb/beacon/fragment/SetupMessageFragment.java rename to src/main/java/org/iilab/pb/fragment/SetupMessageFragment.java index dfce47b8..71faf57a 100644 --- a/src/main/java/com/apb/beacon/fragment/SetupMessageFragment.java +++ b/src/main/java/org/iilab/pb/fragment/SetupMessageFragment.java @@ -1,4 +1,17 @@ -package com.apb.beacon.fragment; +package org.iilab.pb.fragment; + +import org.iilab.pb.MainActivity; +import org.iilab.pb.R; +import org.iilab.pb.WizardActivity; +import org.iilab.pb.adapter.PageItemAdapter; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.common.AppUtil; +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.common.MyTagHandler; +import org.iilab.pb.data.PBDatabase; +import org.iilab.pb.model.Page; +import org.iilab.pb.model.PageItem; +import org.iilab.pb.model.SMSSettings; import android.app.Activity; import android.content.Intent; @@ -18,18 +31,6 @@ import android.widget.TextView; import android.widget.Toast; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.common.ApplicationSettings; -import com.apb.beacon.MainActivity; -import com.apb.beacon.R; -import com.apb.beacon.adapter.PageItemAdapter; -import com.apb.beacon.common.AppUtil; -import com.apb.beacon.common.MyTagHandler; -import com.apb.beacon.data.PBDatabase; -import com.apb.beacon.model.Page; -import com.apb.beacon.model.PageItem; -import com.apb.beacon.model.SMSSettings; -import com.apb.beacon.WizardActivity; /** * Created by aoe on 12/12/13. diff --git a/src/main/java/com/apb/beacon/fragment/SimpleFragment.java b/src/main/java/org/iilab/pb/fragment/SimpleFragment.java similarity index 94% rename from src/main/java/com/apb/beacon/fragment/SimpleFragment.java rename to src/main/java/org/iilab/pb/fragment/SimpleFragment.java index db800d4d..21790af4 100644 --- a/src/main/java/com/apb/beacon/fragment/SimpleFragment.java +++ b/src/main/java/org/iilab/pb/fragment/SimpleFragment.java @@ -1,4 +1,4 @@ -package com.apb.beacon.fragment; +package org.iilab.pb.fragment; import android.app.Activity; import android.content.Intent; @@ -19,24 +19,25 @@ import android.widget.LinearLayout; import android.widget.TextView; -import com.apb.beacon.MainActivity; -import com.apb.beacon.R; -import com.apb.beacon.WizardActivity; -import com.apb.beacon.adapter.PageActionAdapter; -import com.apb.beacon.adapter.PageActionFakeAdapter; -import com.apb.beacon.adapter.PageItemAdapter; -import com.apb.beacon.alert.PanicAlert; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.common.AppUtil; -import com.apb.beacon.common.ApplicationSettings; -import com.apb.beacon.common.MyTagHandler; -import com.apb.beacon.common.NestedListView; -import com.apb.beacon.data.PBDatabase; -import com.apb.beacon.model.Page; -import com.apb.beacon.model.PageItem; import java.util.HashMap; +import org.iilab.pb.MainActivity; +import org.iilab.pb.R; +import org.iilab.pb.WizardActivity; +import org.iilab.pb.adapter.PageActionAdapter; +import org.iilab.pb.adapter.PageActionFakeAdapter; +import org.iilab.pb.adapter.PageItemAdapter; +import org.iilab.pb.alert.PanicAlert; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.common.AppUtil; +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.common.MyTagHandler; +import org.iilab.pb.common.NestedListView; +import org.iilab.pb.data.PBDatabase; +import org.iilab.pb.model.Page; +import org.iilab.pb.model.PageItem; + /** * Created by aoe on 1/3/14. diff --git a/src/main/java/com/apb/beacon/fragment/WarningFragment.java b/src/main/java/org/iilab/pb/fragment/WarningFragment.java similarity index 93% rename from src/main/java/com/apb/beacon/fragment/WarningFragment.java rename to src/main/java/org/iilab/pb/fragment/WarningFragment.java index ddbc6e13..102c779e 100644 --- a/src/main/java/com/apb/beacon/fragment/WarningFragment.java +++ b/src/main/java/org/iilab/pb/fragment/WarningFragment.java @@ -1,4 +1,4 @@ -package com.apb.beacon.fragment; +package org.iilab.pb.fragment; import android.app.Activity; import android.content.Intent; @@ -17,20 +17,21 @@ import android.widget.ListView; import android.widget.TextView; -import com.apb.beacon.R; -import com.apb.beacon.WizardActivity; -import com.apb.beacon.adapter.PageActionAdapter; -import com.apb.beacon.adapter.PageItemAdapter; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.common.AppUtil; -import com.apb.beacon.common.ApplicationSettings; -import com.apb.beacon.common.MyTagHandler; -import com.apb.beacon.data.PBDatabase; -import com.apb.beacon.model.Page; -import com.apb.beacon.model.PageItem; import java.util.HashMap; +import org.iilab.pb.R; +import org.iilab.pb.WizardActivity; +import org.iilab.pb.adapter.PageActionAdapter; +import org.iilab.pb.adapter.PageItemAdapter; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.common.AppUtil; +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.common.MyTagHandler; +import org.iilab.pb.data.PBDatabase; +import org.iilab.pb.model.Page; +import org.iilab.pb.model.PageItem; + /** * Created by aoe on 1/31/14. */ diff --git a/src/main/java/com/apb/beacon/fragment/WizardAlarmTestDisguiseFragment.java b/src/main/java/org/iilab/pb/fragment/WizardAlarmTestDisguiseFragment.java similarity index 92% rename from src/main/java/com/apb/beacon/fragment/WizardAlarmTestDisguiseFragment.java rename to src/main/java/org/iilab/pb/fragment/WizardAlarmTestDisguiseFragment.java index 92ed3706..c34ec648 100644 --- a/src/main/java/com/apb/beacon/fragment/WizardAlarmTestDisguiseFragment.java +++ b/src/main/java/org/iilab/pb/fragment/WizardAlarmTestDisguiseFragment.java @@ -1,4 +1,12 @@ -package com.apb.beacon.fragment; +package org.iilab.pb.fragment; + +import org.iilab.pb.R; +import org.iilab.pb.WizardActivity; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.data.PBDatabase; +import org.iilab.pb.model.Page; +import org.iilab.pb.trigger.MultiClickEvent; import android.app.Activity; import android.content.Context; @@ -12,13 +20,6 @@ import android.view.ViewGroup; import android.widget.Button; -import com.apb.beacon.R; -import com.apb.beacon.WizardActivity; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.common.ApplicationSettings; -import com.apb.beacon.data.PBDatabase; -import com.apb.beacon.model.Page; -import com.apb.beacon.trigger.MultiClickEvent; /** * Created by aoe on 1/16/14. diff --git a/src/main/java/com/apb/beacon/fragment/WizardAlarmTestHardwareFragment.java b/src/main/java/org/iilab/pb/fragment/WizardAlarmTestHardwareFragment.java similarity index 92% rename from src/main/java/com/apb/beacon/fragment/WizardAlarmTestHardwareFragment.java rename to src/main/java/org/iilab/pb/fragment/WizardAlarmTestHardwareFragment.java index aa88f59f..7d1592d3 100644 --- a/src/main/java/com/apb/beacon/fragment/WizardAlarmTestHardwareFragment.java +++ b/src/main/java/org/iilab/pb/fragment/WizardAlarmTestHardwareFragment.java @@ -1,4 +1,4 @@ -package com.apb.beacon.fragment; +package org.iilab.pb.fragment; import android.app.Activity; import android.content.BroadcastReceiver; @@ -18,18 +18,19 @@ import android.view.ViewGroup; import android.widget.TextView; -import com.apb.beacon.R; -import com.apb.beacon.WizardActivity; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.common.AppUtil; -import com.apb.beacon.common.ApplicationSettings; -import com.apb.beacon.common.MyTagHandler; -import com.apb.beacon.data.PBDatabase; -import com.apb.beacon.model.Page; -import com.apb.beacon.trigger.HardwareTriggerReceiver; import java.util.HashMap; +import org.iilab.pb.R; +import org.iilab.pb.WizardActivity; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.common.AppUtil; +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.common.MyTagHandler; +import org.iilab.pb.data.PBDatabase; +import org.iilab.pb.model.Page; +import org.iilab.pb.trigger.HardwareTriggerReceiver; + /** * Created by aoe on 1/9/14. */ diff --git a/src/main/java/com/apb/beacon/fragment/WizardTestDisguiseCodeFragment.java b/src/main/java/org/iilab/pb/fragment/WizardTestDisguiseCodeFragment.java similarity index 70% rename from src/main/java/com/apb/beacon/fragment/WizardTestDisguiseCodeFragment.java rename to src/main/java/org/iilab/pb/fragment/WizardTestDisguiseCodeFragment.java index 2d1da50b..46c9cecf 100644 --- a/src/main/java/com/apb/beacon/fragment/WizardTestDisguiseCodeFragment.java +++ b/src/main/java/org/iilab/pb/fragment/WizardTestDisguiseCodeFragment.java @@ -1,4 +1,4 @@ -package com.apb.beacon.fragment; +package org.iilab.pb.fragment; import android.app.Activity; import android.content.Intent; @@ -8,24 +8,27 @@ import android.text.Html; import android.util.DisplayMetrics; import android.util.Log; +import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.View.OnKeyListener; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; -import com.apb.beacon.R; -import com.apb.beacon.WizardActivity; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.common.AppUtil; -import com.apb.beacon.common.ApplicationSettings; -import com.apb.beacon.common.MyTagHandler; -import com.apb.beacon.data.PBDatabase; -import com.apb.beacon.model.Page; import java.util.HashMap; +import org.iilab.pb.R; +import org.iilab.pb.WizardActivity; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.common.AppUtil; +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.common.MyTagHandler; +import org.iilab.pb.data.PBDatabase; +import org.iilab.pb.model.Page; + /** * Created by aoe on 1/18/14. */ @@ -56,6 +59,34 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa View view = inflater.inflate(R.layout.fragment_type_interactive_disguise_test_code, container, false); passwordEditText = (EditText) view.findViewById(R.id.create_pin_edittext); + passwordEditText.setOnKeyListener(new OnKeyListener() { + public boolean onKey(View v, int keyCode, KeyEvent event) { + // If the event is a key-down event on the "enter" button + if ((event.getAction() == KeyEvent.ACTION_DOWN) && + (keyCode == KeyEvent.KEYCODE_ENTER)) { + // Perform action on key press + + String password = passwordEditText.getText().toString(); + if (ApplicationSettings.passwordMatches(activity, password)) { + + String pageId = null; + if (currentPage.getAction().size() > 0) + pageId = currentPage.getAction().get(0).getLink(); + else + pageId = currentPage.getSuccessId(); + + Intent i = new Intent(activity, WizardActivity.class); + i.putExtra("page_id", pageId); + activity.startActivity(i); + activity.finish(); + return true; + } + AppUtil.setError(activity, passwordEditText, R.string.incorrect_pin); + } + return false; + } + }); + tvContent = (TextView) view.findViewById(R.id.fragment_contents); bAction = (Button) view.findViewById(R.id.b_action); diff --git a/src/main/java/com/apb/beacon/fragment/WizardTestDisguiseOpenFragment.java b/src/main/java/org/iilab/pb/fragment/WizardTestDisguiseOpenFragment.java similarity index 94% rename from src/main/java/com/apb/beacon/fragment/WizardTestDisguiseOpenFragment.java rename to src/main/java/org/iilab/pb/fragment/WizardTestDisguiseOpenFragment.java index d64cdac3..df1dad92 100644 --- a/src/main/java/com/apb/beacon/fragment/WizardTestDisguiseOpenFragment.java +++ b/src/main/java/org/iilab/pb/fragment/WizardTestDisguiseOpenFragment.java @@ -1,4 +1,4 @@ -package com.apb.beacon.fragment; +package org.iilab.pb.fragment; import android.app.Activity; import android.content.Intent; @@ -16,18 +16,19 @@ import android.widget.GridView; import android.widget.Toast; -import com.apb.beacon.R; -import com.apb.beacon.WizardActivity; -import com.apb.beacon.adapter.AppInfoAdapter; -import com.apb.beacon.common.ApplicationSettings; -import com.apb.beacon.data.PBDatabase; -import com.apb.beacon.model.AppInfo; -import com.apb.beacon.model.Page; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import org.iilab.pb.R; +import org.iilab.pb.WizardActivity; +import org.iilab.pb.adapter.AppInfoAdapter; +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.data.PBDatabase; +import org.iilab.pb.model.AppInfo; +import org.iilab.pb.model.Page; + /** * Created by aoe on 1/16/14. */ diff --git a/src/main/java/com/apb/beacon/fragment/WizardTestDisguiseUnlockFragment.java b/src/main/java/org/iilab/pb/fragment/WizardTestDisguiseUnlockFragment.java similarity index 95% rename from src/main/java/com/apb/beacon/fragment/WizardTestDisguiseUnlockFragment.java rename to src/main/java/org/iilab/pb/fragment/WizardTestDisguiseUnlockFragment.java index 99e81781..0e83d2c0 100644 --- a/src/main/java/com/apb/beacon/fragment/WizardTestDisguiseUnlockFragment.java +++ b/src/main/java/org/iilab/pb/fragment/WizardTestDisguiseUnlockFragment.java @@ -1,4 +1,10 @@ -package com.apb.beacon.fragment; +package org.iilab.pb.fragment; + +import org.iilab.pb.R; +import org.iilab.pb.WizardActivity; +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.data.PBDatabase; +import org.iilab.pb.model.Page; import android.app.Activity; import android.content.Intent; @@ -12,11 +18,6 @@ import android.view.ViewGroup; import android.widget.Button; -import com.apb.beacon.R; -import com.apb.beacon.WizardActivity; -import com.apb.beacon.common.ApplicationSettings; -import com.apb.beacon.data.PBDatabase; -import com.apb.beacon.model.Page; /** * Created by aoe on 1/17/14. diff --git a/src/main/java/com/apb/beacon/location/CurrentLocationProvider.java b/src/main/java/org/iilab/pb/location/CurrentLocationProvider.java similarity index 70% rename from src/main/java/com/apb/beacon/location/CurrentLocationProvider.java rename to src/main/java/org/iilab/pb/location/CurrentLocationProvider.java index 6dd443ac..b43d68cc 100644 --- a/src/main/java/com/apb/beacon/location/CurrentLocationProvider.java +++ b/src/main/java/org/iilab/pb/location/CurrentLocationProvider.java @@ -1,21 +1,22 @@ -package com.apb.beacon.location; - -import com.apb.beacon.common.ApplicationSettings; +package org.iilab.pb.location; import android.content.Context; +import android.location.Criteria; import android.location.Location; import android.location.LocationManager; -import android.location.Criteria; +import android.util.Log; + +import org.iilab.pb.common.ApplicationSettings; import static android.location.Criteria.ACCURACY_FINE; -import static android.location.LocationManager.NETWORK_PROVIDER; import static android.location.LocationManager.GPS_PROVIDER; -import static android.location.LocationManager.PASSIVE_PROVIDER; +import static android.location.LocationManager.NETWORK_PROVIDER; public class CurrentLocationProvider extends LocationListenerAdapter { private Location currentLocation; public CurrentLocationProvider(Context context) { + Log.e(">>>>>>", "in CurrentLocationProvider CONSTRUCTOR - trying to retrieve location from getLastKnownLocation()"); LocationManager manager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy(ACCURACY_FINE); @@ -25,20 +26,17 @@ public CurrentLocationProvider(Context context) { bestLocation = manager.getLastKnownLocation(provider); else bestLocation = null; - Location latestLocation = getLatest(bestLocation, - manager.getLastKnownLocation(GPS_PROVIDER)); - latestLocation = getLatest(latestLocation, - manager.getLastKnownLocation(NETWORK_PROVIDER)); - latestLocation = getLatest(latestLocation, - manager.getLastKnownLocation(PASSIVE_PROVIDER)); + + Location latestLocation = getLatest(bestLocation, manager.getLastKnownLocation(GPS_PROVIDER)); + latestLocation = getLatest(latestLocation, manager.getLastKnownLocation(NETWORK_PROVIDER)); +// latestLocation = getLatest(latestLocation, manager.getLastKnownLocation(PASSIVE_PROVIDER)); currentLocation = latestLocation; if (currentLocation != null) ApplicationSettings.setCurrentBestLocation(context, currentLocation); return; } - private static Location getLatest(final Location location1, - final Location location2) { + private static Location getLatest(final Location location1, final Location location2) { if (location1 == null) return location2; diff --git a/src/main/java/com/apb/beacon/location/LocationFormatter.java b/src/main/java/org/iilab/pb/location/LocationFormatter.java similarity index 82% rename from src/main/java/com/apb/beacon/location/LocationFormatter.java rename to src/main/java/org/iilab/pb/location/LocationFormatter.java index 85779a75..2430d712 100644 --- a/src/main/java/com/apb/beacon/location/LocationFormatter.java +++ b/src/main/java/org/iilab/pb/location/LocationFormatter.java @@ -1,13 +1,13 @@ -package com.apb.beacon.location; +package org.iilab.pb.location; -import com.apb.beacon.R; -import android.content.res.TypedArray; - -import android.location.Location; import android.content.Context; +import android.location.Location; + +import org.iilab.pb.R; +import org.iilab.pb.common.AppConstants; public class LocationFormatter { - public static final String GOOGLE_MAP_URL = "http://maps.google.com/maps?q="; + public static final String GOOGLE_MAP_URL = "https://maps.google.com/maps?q="; // public static final String GOOGLE_MAP_URL = "https://maps.google.com/maps?q=https:%2F%2Floc_panicbutton.iilab.org%2F%3Flat%3D33.66121%26long%3D-95.563889%26rad%3D100000" // public static final String IAMAT = "I'm at"; public static final String VIA = " via "; @@ -28,6 +28,6 @@ public String format(Context context) { // return ". " + getString(R.string.i_am_at) + " " + GOOGLE_MAP_URL + "%2F%3Flat%3D33.66121" + latitude + "%26long%3D-95.563889" + longitude + "%26rad%3D" + radius + " " VIA + provider; } - return ""; + return AppConstants.CUSTOM_ALERT_MSG_WHEN_LOCATION_NOT_FOUND; } } diff --git a/src/main/java/com/apb/beacon/location/LocationListenerAdapter.java b/src/main/java/org/iilab/pb/location/LocationListenerAdapter.java similarity index 93% rename from src/main/java/com/apb/beacon/location/LocationListenerAdapter.java rename to src/main/java/org/iilab/pb/location/LocationListenerAdapter.java index 28e02922..7c4cbd64 100644 --- a/src/main/java/com/apb/beacon/location/LocationListenerAdapter.java +++ b/src/main/java/org/iilab/pb/location/LocationListenerAdapter.java @@ -1,4 +1,4 @@ -package com.apb.beacon.location; +package org.iilab.pb.location; import android.location.Location; import android.location.LocationListener; diff --git a/src/main/java/com/apb/beacon/location/LocationUpdateReceiver.java b/src/main/java/org/iilab/pb/location/LocationUpdateReceiver.java similarity index 56% rename from src/main/java/com/apb/beacon/location/LocationUpdateReceiver.java rename to src/main/java/org/iilab/pb/location/LocationUpdateReceiver.java index c835cf70..d2d0a036 100644 --- a/src/main/java/com/apb/beacon/location/LocationUpdateReceiver.java +++ b/src/main/java/org/iilab/pb/location/LocationUpdateReceiver.java @@ -1,4 +1,4 @@ -package com.apb.beacon.location; +package org.iilab.pb.location; import android.content.BroadcastReceiver; import android.content.Context; @@ -7,8 +7,9 @@ import android.location.LocationManager; import android.util.Log; -import com.apb.beacon.common.ApplicationSettings; -import com.apb.beacon.common.Intents; +import org.iilab.pb.alert.PanicMessage; +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.common.Intents; public class LocationUpdateReceiver extends BroadcastReceiver { private static final String TAG = LocationUpdateReceiver.class.getName(); @@ -18,9 +19,20 @@ public class LocationUpdateReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { + Log.e(">>>>>>>>", "onReceive - LocationUpdateReceiver"); if(intent.getAction().equals(Intents.LOCATION_UPDATE_ACTION)) { + Log.e(">>>>>>>>", "location update received in LocationUpdateReceiver at current time in millis = " + System.currentTimeMillis() % 100000); this.context = context; processNewLocation(intent); + + if (!ApplicationSettings.getFirstMsgWithLocationTriggered(context)) { + Location location = getCurrentBestLocation(); + if(location != null) { + new PanicMessage(context).send(getCurrentBestLocation()); + ApplicationSettings.setFirstMsgWithLocationTriggered(context, true); + } + } + } } @@ -38,36 +50,51 @@ private boolean isBetterLocation(Location location) { if (currentBestLocation == null) { return true; } + + // Check whether the new location fix is newer or older long timeDelta = location.getTime() - currentBestLocation.getTime(); + boolean isSignificantlyNewer = timeDelta > MIN_UPDATE_INTERVAL; + boolean isSignificantlyOlder = timeDelta < -MIN_UPDATE_INTERVAL; boolean isNewer = timeDelta > 0; - - if (timeDelta > MIN_UPDATE_INTERVAL) { + + // If it's been more than two minutes since the current location, use the new location + // because the user has likely moved + if (isSignificantlyNewer) { return true; - } /*else if (timeDelta < -MIN_UPDATE_INTERVAL) { + // If the new location is more than two minutes older, it must be worse + } else if (isSignificantlyOlder) { return false; - }*/ + } + // Check whether the new location fix is more or less accurate int accuracyDelta = (int) (location.getAccuracy() - currentBestLocation.getAccuracy()); + boolean isLessAccurate = accuracyDelta > 0; boolean isMoreAccurate = accuracyDelta < 0; - boolean isAlmostSame = accuracyDelta == 0; boolean isSignificantlyLessAccurate = accuracyDelta > ACCURACY_THRESHOLD; + + // Check if the old and new location are from the same provider boolean isFromSameProvider = isSameProvider(location.getProvider(), currentBestLocation.getProvider()); + // Determine location quality using a combination of timeliness and accuracy if (isMoreAccurate) { return true; - } else if (isFromSameProvider && isNewer) { + } else if (isNewer && !isLessAccurate) { return true; - } else if (isNewer && !isSignificantlyLessAccurate) { + } else if (isNewer && !isSignificantlyLessAccurate && isFromSameProvider) { return true; } - return false; } + /** Checks whether two providers are the same */ private boolean isSameProvider(String provider1, String provider2) { + if (provider1 == null) { + return provider2 == null; + } return provider1.equals(provider2); } + Location getCurrentBestLocation() { return ApplicationSettings.getCurrentBestLocation(context); } diff --git a/src/main/java/com/apb/beacon/model/AppInfo.java b/src/main/java/org/iilab/pb/model/AppInfo.java similarity index 95% rename from src/main/java/com/apb/beacon/model/AppInfo.java rename to src/main/java/org/iilab/pb/model/AppInfo.java index 06d8947c..75a1cd24 100644 --- a/src/main/java/com/apb/beacon/model/AppInfo.java +++ b/src/main/java/org/iilab/pb/model/AppInfo.java @@ -1,4 +1,4 @@ -package com.apb.beacon.model; +package org.iilab.pb.model; /** * Created by aoe on 1/24/14. diff --git a/src/main/java/com/apb/beacon/model/AsyncTaskResult.java b/src/main/java/org/iilab/pb/model/AsyncTaskResult.java similarity index 93% rename from src/main/java/com/apb/beacon/model/AsyncTaskResult.java rename to src/main/java/org/iilab/pb/model/AsyncTaskResult.java index c1991897..81b6532f 100644 --- a/src/main/java/com/apb/beacon/model/AsyncTaskResult.java +++ b/src/main/java/org/iilab/pb/model/AsyncTaskResult.java @@ -1,4 +1,4 @@ -package com.apb.beacon.model; +package org.iilab.pb.model; /** * Created by aoe on 1/3/14. diff --git a/src/main/java/org/iilab/pb/model/Coordinates.java b/src/main/java/org/iilab/pb/model/Coordinates.java new file mode 100644 index 00000000..cb789e24 --- /dev/null +++ b/src/main/java/org/iilab/pb/model/Coordinates.java @@ -0,0 +1,32 @@ +package org.iilab.pb.model; + +/** + * Created by aoe on 5/29/14. + */ +public class Coordinates { + + public static final Coordinates UNDEFINED = new Coordinates(0.000, 0.000); + private double latitude; + private double longitude; + + public Coordinates(double latitude, double longitude) { + this.latitude = latitude; + this.longitude = longitude; + } + + public double getLatitude() { + return latitude; + } + + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + public double getLongitude() { + return longitude; + } + + public void setLongitude(double longitude) { + this.longitude = longitude; + } +} diff --git a/src/main/java/com/apb/beacon/model/HelpImage.java b/src/main/java/org/iilab/pb/model/HelpImage.java similarity index 97% rename from src/main/java/com/apb/beacon/model/HelpImage.java rename to src/main/java/org/iilab/pb/model/HelpImage.java index 13e57a7f..08f86cd0 100644 --- a/src/main/java/com/apb/beacon/model/HelpImage.java +++ b/src/main/java/org/iilab/pb/model/HelpImage.java @@ -1,4 +1,4 @@ -package com.apb.beacon.model; +package org.iilab.pb.model; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/src/main/java/com/apb/beacon/model/HelpPage.java b/src/main/java/org/iilab/pb/model/HelpPage.java similarity index 98% rename from src/main/java/com/apb/beacon/model/HelpPage.java rename to src/main/java/org/iilab/pb/model/HelpPage.java index 132d772e..abe4e96c 100644 --- a/src/main/java/com/apb/beacon/model/HelpPage.java +++ b/src/main/java/org/iilab/pb/model/HelpPage.java @@ -1,4 +1,4 @@ -package com.apb.beacon.model; +package org.iilab.pb.model; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/src/main/java/com/apb/beacon/model/MarkDownResponse.java b/src/main/java/org/iilab/pb/model/MarkDownResponse.java similarity index 94% rename from src/main/java/com/apb/beacon/model/MarkDownResponse.java rename to src/main/java/org/iilab/pb/model/MarkDownResponse.java index 359e5aed..2f7910b5 100644 --- a/src/main/java/com/apb/beacon/model/MarkDownResponse.java +++ b/src/main/java/org/iilab/pb/model/MarkDownResponse.java @@ -1,4 +1,4 @@ -package com.apb.beacon.model; +package org.iilab.pb.model; /** * Created by aoe on 12/14/13. diff --git a/src/main/java/com/apb/beacon/model/Page.java b/src/main/java/org/iilab/pb/model/Page.java similarity index 99% rename from src/main/java/com/apb/beacon/model/Page.java rename to src/main/java/org/iilab/pb/model/Page.java index 9ee16b5a..6cdb78a0 100644 --- a/src/main/java/com/apb/beacon/model/Page.java +++ b/src/main/java/org/iilab/pb/model/Page.java @@ -1,4 +1,4 @@ -package com.apb.beacon.model; +package org.iilab.pb.model; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/src/main/java/com/apb/beacon/model/PageAction.java b/src/main/java/org/iilab/pb/model/PageAction.java similarity index 98% rename from src/main/java/com/apb/beacon/model/PageAction.java rename to src/main/java/org/iilab/pb/model/PageAction.java index debcda4f..e96cfd2c 100644 --- a/src/main/java/com/apb/beacon/model/PageAction.java +++ b/src/main/java/org/iilab/pb/model/PageAction.java @@ -1,4 +1,4 @@ -package com.apb.beacon.model; +package org.iilab.pb.model; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/src/main/java/com/apb/beacon/model/PageChecklist.java b/src/main/java/org/iilab/pb/model/PageChecklist.java similarity index 98% rename from src/main/java/com/apb/beacon/model/PageChecklist.java rename to src/main/java/org/iilab/pb/model/PageChecklist.java index 84a3eb9f..1dbe5115 100644 --- a/src/main/java/com/apb/beacon/model/PageChecklist.java +++ b/src/main/java/org/iilab/pb/model/PageChecklist.java @@ -1,4 +1,4 @@ -package com.apb.beacon.model; +package org.iilab.pb.model; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/src/main/java/com/apb/beacon/model/PageItem.java b/src/main/java/org/iilab/pb/model/PageItem.java similarity index 97% rename from src/main/java/com/apb/beacon/model/PageItem.java rename to src/main/java/org/iilab/pb/model/PageItem.java index f4695299..df58f777 100644 --- a/src/main/java/com/apb/beacon/model/PageItem.java +++ b/src/main/java/org/iilab/pb/model/PageItem.java @@ -1,4 +1,4 @@ -package com.apb.beacon.model; +package org.iilab.pb.model; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/src/main/java/com/apb/beacon/model/PageStatus.java b/src/main/java/org/iilab/pb/model/PageStatus.java similarity index 98% rename from src/main/java/com/apb/beacon/model/PageStatus.java rename to src/main/java/org/iilab/pb/model/PageStatus.java index be2a8b3c..f8f3e21e 100644 --- a/src/main/java/com/apb/beacon/model/PageStatus.java +++ b/src/main/java/org/iilab/pb/model/PageStatus.java @@ -1,4 +1,4 @@ -package com.apb.beacon.model; +package org.iilab.pb.model; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/src/main/java/com/apb/beacon/model/PageTimer.java b/src/main/java/org/iilab/pb/model/PageTimer.java similarity index 97% rename from src/main/java/com/apb/beacon/model/PageTimer.java rename to src/main/java/org/iilab/pb/model/PageTimer.java index 368c166d..d323abf2 100644 --- a/src/main/java/com/apb/beacon/model/PageTimer.java +++ b/src/main/java/org/iilab/pb/model/PageTimer.java @@ -1,4 +1,4 @@ -package com.apb.beacon.model; +package org.iilab.pb.model; import com.google.gson.Gson; import com.google.gson.GsonBuilder; diff --git a/src/main/java/com/apb/beacon/model/SMSSettings.java b/src/main/java/org/iilab/pb/model/SMSSettings.java similarity index 99% rename from src/main/java/com/apb/beacon/model/SMSSettings.java rename to src/main/java/org/iilab/pb/model/SMSSettings.java index 884bdb51..2030e625 100644 --- a/src/main/java/com/apb/beacon/model/SMSSettings.java +++ b/src/main/java/org/iilab/pb/model/SMSSettings.java @@ -1,4 +1,4 @@ -package com.apb.beacon.model; +package org.iilab.pb.model; import android.content.Context; import android.content.SharedPreferences; diff --git a/src/main/java/com/apb/beacon/model/ServerResponse.java b/src/main/java/org/iilab/pb/model/ServerResponse.java similarity index 95% rename from src/main/java/com/apb/beacon/model/ServerResponse.java rename to src/main/java/org/iilab/pb/model/ServerResponse.java index 736f548f..02ba084a 100644 --- a/src/main/java/com/apb/beacon/model/ServerResponse.java +++ b/src/main/java/org/iilab/pb/model/ServerResponse.java @@ -1,4 +1,4 @@ -package com.apb.beacon.model; +package org.iilab.pb.model; import org.json.JSONObject; diff --git a/src/main/java/com/apb/beacon/trigger/BootReceiver.java b/src/main/java/org/iilab/pb/trigger/BootReceiver.java similarity index 86% rename from src/main/java/com/apb/beacon/trigger/BootReceiver.java rename to src/main/java/org/iilab/pb/trigger/BootReceiver.java index be30a61c..1ba8b195 100644 --- a/src/main/java/com/apb/beacon/trigger/BootReceiver.java +++ b/src/main/java/org/iilab/pb/trigger/BootReceiver.java @@ -1,13 +1,14 @@ -package com.apb.beacon.trigger; +package org.iilab.pb.trigger; + +import org.iilab.pb.alert.PanicAlert; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.common.ApplicationSettings; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.util.Log; -import com.apb.beacon.alert.PanicAlert; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.common.ApplicationSettings; import static android.content.Intent.ACTION_BOOT_COMPLETED; diff --git a/src/main/java/com/apb/beacon/trigger/HardwareTriggerReceiver.java b/src/main/java/org/iilab/pb/trigger/HardwareTriggerReceiver.java similarity index 95% rename from src/main/java/com/apb/beacon/trigger/HardwareTriggerReceiver.java rename to src/main/java/org/iilab/pb/trigger/HardwareTriggerReceiver.java index 62085da5..8099d7c4 100644 --- a/src/main/java/com/apb/beacon/trigger/HardwareTriggerReceiver.java +++ b/src/main/java/org/iilab/pb/trigger/HardwareTriggerReceiver.java @@ -1,4 +1,6 @@ -package com.apb.beacon.trigger; +package org.iilab.pb.trigger; + +import org.iilab.pb.alert.PanicAlert; import android.app.KeyguardManager; import android.content.BroadcastReceiver; @@ -6,7 +8,6 @@ import android.content.Intent; import android.util.Log; -import com.apb.beacon.alert.PanicAlert; import static android.content.Intent.ACTION_SCREEN_OFF; import static android.content.Intent.ACTION_SCREEN_ON; diff --git a/src/main/java/com/apb/beacon/trigger/HardwareTriggerService.java b/src/main/java/org/iilab/pb/trigger/HardwareTriggerService.java similarity index 97% rename from src/main/java/com/apb/beacon/trigger/HardwareTriggerService.java rename to src/main/java/org/iilab/pb/trigger/HardwareTriggerService.java index 471444e6..9b8c25e7 100644 --- a/src/main/java/com/apb/beacon/trigger/HardwareTriggerService.java +++ b/src/main/java/org/iilab/pb/trigger/HardwareTriggerService.java @@ -1,4 +1,4 @@ -package com.apb.beacon.trigger; +package org.iilab.pb.trigger; import android.app.Service; import android.content.Intent; diff --git a/src/main/java/com/apb/beacon/trigger/MultiClickEvent.java b/src/main/java/org/iilab/pb/trigger/MultiClickEvent.java similarity index 96% rename from src/main/java/com/apb/beacon/trigger/MultiClickEvent.java rename to src/main/java/org/iilab/pb/trigger/MultiClickEvent.java index 97767d76..4147d999 100644 --- a/src/main/java/com/apb/beacon/trigger/MultiClickEvent.java +++ b/src/main/java/org/iilab/pb/trigger/MultiClickEvent.java @@ -1,4 +1,4 @@ -package com.apb.beacon.trigger; +package org.iilab.pb.trigger; import android.util.Log; diff --git a/src/test/java/com/apb/beacon/ApplicationSettingsTest.java b/src/test/java/org/iilab/pb/ApplicationSettingsTest.java similarity index 87% rename from src/test/java/com/apb/beacon/ApplicationSettingsTest.java rename to src/test/java/org/iilab/pb/ApplicationSettingsTest.java index 7a606250..c2c278b6 100644 --- a/src/test/java/com/apb/beacon/ApplicationSettingsTest.java +++ b/src/test/java/org/iilab/pb/ApplicationSettingsTest.java @@ -1,10 +1,10 @@ -package com.apb.beacon; +package org.iilab.pb; import android.app.Application; import android.content.SharedPreferences; -import com.apb.beacon.common.ApplicationSettings; +import org.iilab.pb.common.ApplicationSettings; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -12,9 +12,9 @@ import org.robolectric.RobolectricTestRunner; import org.robolectric.shadows.ShadowPreferenceManager; -import static com.apb.beacon.common.ApplicationSettings.setFirstRun; -import static com.apb.beacon.common.ApplicationSettings.isFirstRun; import static junit.framework.Assert.assertNull; +import static org.iilab.pb.common.ApplicationSettings.isFirstRun; +import static org.iilab.pb.common.ApplicationSettings.setFirstRun; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; diff --git a/src/test/java/com/apb/beacon/CalculatorActivityTest.java b/src/test/java/org/iilab/pb/CalculatorActivityTest.java similarity index 96% rename from src/test/java/com/apb/beacon/CalculatorActivityTest.java rename to src/test/java/org/iilab/pb/CalculatorActivityTest.java index c4f0ae88..4fe03aa1 100644 --- a/src/test/java/com/apb/beacon/CalculatorActivityTest.java +++ b/src/test/java/org/iilab/pb/CalculatorActivityTest.java @@ -1,12 +1,13 @@ -package com.apb.beacon; +package org.iilab.pb; import android.content.Intent; import android.widget.Button; import android.widget.TextView; -import com.apb.beacon.alert.PanicAlert; -import com.apb.beacon.trigger.HardwareTriggerService; +import org.iilab.pb.CalculatorActivity; +import org.iilab.pb.alert.PanicAlert; +import org.iilab.pb.trigger.HardwareTriggerService; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/com/apb/beacon/HomeActivityTest.java b/src/test/java/org/iilab/pb/HomeActivityTest.java similarity index 94% rename from src/test/java/com/apb/beacon/HomeActivityTest.java rename to src/test/java/org/iilab/pb/HomeActivityTest.java index eb973fdb..32a319cc 100644 --- a/src/test/java/com/apb/beacon/HomeActivityTest.java +++ b/src/test/java/org/iilab/pb/HomeActivityTest.java @@ -1,10 +1,11 @@ -package com.apb.beacon; +package org.iilab.pb; import android.content.Intent; import android.content.SharedPreferences; -import com.apb.beacon.common.ApplicationSettings; +import org.iilab.pb.HomeActivity; +import org.iilab.pb.common.ApplicationSettings; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -16,7 +17,7 @@ import static org.junit.Assert.assertNotNull; import static org.robolectric.Robolectric.shadowOf; -//import com.apb.beacon.HomeActivity; +//import org.iilab.pb.HomeActivity; @RunWith(RobolectricTestRunner.class) public class HomeActivityTest { diff --git a/src/test/java/com/apb/beacon/LoginActivityTest.java b/src/test/java/org/iilab/pb/LoginActivityTest.java similarity index 90% rename from src/test/java/com/apb/beacon/LoginActivityTest.java rename to src/test/java/org/iilab/pb/LoginActivityTest.java index 4e1b5e32..4f16b633 100644 --- a/src/test/java/com/apb/beacon/LoginActivityTest.java +++ b/src/test/java/org/iilab/pb/LoginActivityTest.java @@ -1,10 +1,11 @@ -package com.apb.beacon; +package org.iilab.pb; import android.widget.Button; import android.widget.EditText; -import com.apb.beacon.common.ApplicationSettings; +import org.iilab.pb.LoginActivity; +import org.iilab.pb.common.ApplicationSettings; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/com/apb/beacon/PanicButtonActivityTest.java b/src/test/java/org/iilab/pb/PanicButtonActivityTest.java similarity index 91% rename from src/test/java/com/apb/beacon/PanicButtonActivityTest.java rename to src/test/java/org/iilab/pb/PanicButtonActivityTest.java index ae4f4935..6dbef28f 100644 --- a/src/test/java/com/apb/beacon/PanicButtonActivityTest.java +++ b/src/test/java/org/iilab/pb/PanicButtonActivityTest.java @@ -1,11 +1,12 @@ -package com.apb.beacon; +package org.iilab.pb; import android.view.ViewGroup; -import com.apb.beacon.alert.PanicAlert; -import com.apb.beacon.test.support.PanicButtonRobolectricTestRunner; import org.hamcrest.core.Is; +import org.iilab.pb.CalculatorActivity; +import org.iilab.pb.alert.PanicAlert; +import org.iilab.pb.test.support.PanicButtonRobolectricTestRunner; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/com/apb/beacon/SoftKeyboardTest.java b/src/test/java/org/iilab/pb/SoftKeyboardTest.java similarity index 75% rename from src/test/java/com/apb/beacon/SoftKeyboardTest.java rename to src/test/java/org/iilab/pb/SoftKeyboardTest.java index 7e4490c5..4af2aa4f 100644 --- a/src/test/java/com/apb/beacon/SoftKeyboardTest.java +++ b/src/test/java/org/iilab/pb/SoftKeyboardTest.java @@ -1,7 +1,7 @@ -package com.apb.beacon; +package org.iilab.pb; -import com.apb.beacon.common.SoftKeyboard; +import org.iilab.pb.common.SoftKeyboard; import org.junit.Test; import static org.junit.Assert.assertNotNull; diff --git a/src/test/java/com/apb/beacon/alert/AlarmReceiverTest.java b/src/test/java/org/iilab/pb/alert/AlarmReceiverTest.java similarity index 92% rename from src/test/java/com/apb/beacon/alert/AlarmReceiverTest.java rename to src/test/java/org/iilab/pb/alert/AlarmReceiverTest.java index 954d18a2..24aab2b4 100644 --- a/src/test/java/com/apb/beacon/alert/AlarmReceiverTest.java +++ b/src/test/java/org/iilab/pb/alert/AlarmReceiverTest.java @@ -1,11 +1,13 @@ -package com.apb.beacon.alert; +package org.iilab.pb.alert; import android.content.Context; import android.content.Intent; import android.location.Location; -import com.apb.beacon.common.Intents; +import org.iilab.pb.alert.AlarmReceiver; +import org.iilab.pb.alert.PanicMessage; +import org.iilab.pb.common.Intents; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/com/apb/beacon/alert/PanicAlertTest.java b/src/test/java/org/iilab/pb/alert/PanicAlertTest.java similarity index 97% rename from src/test/java/com/apb/beacon/alert/PanicAlertTest.java rename to src/test/java/org/iilab/pb/alert/PanicAlertTest.java index 92547298..01a8f6d2 100644 --- a/src/test/java/com/apb/beacon/alert/PanicAlertTest.java +++ b/src/test/java/org/iilab/pb/alert/PanicAlertTest.java @@ -1,4 +1,4 @@ -package com.apb.beacon.alert; +package org.iilab.pb.alert; import android.app.AlarmManager; import android.app.Application; @@ -12,9 +12,11 @@ import android.location.LocationManager; import android.os.Vibrator; -import com.apb.beacon.common.ApplicationSettings; -import com.apb.beacon.location.CurrentLocationProvider; +import org.iilab.pb.alert.PanicAlert; +import org.iilab.pb.alert.PanicMessage; +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.location.CurrentLocationProvider; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/com/apb/beacon/alert/PanicMessageTest.java b/src/test/java/org/iilab/pb/alert/PanicMessageTest.java similarity index 82% rename from src/test/java/com/apb/beacon/alert/PanicMessageTest.java rename to src/test/java/org/iilab/pb/alert/PanicMessageTest.java index 1216a127..de650dd0 100644 --- a/src/test/java/com/apb/beacon/alert/PanicMessageTest.java +++ b/src/test/java/org/iilab/pb/alert/PanicMessageTest.java @@ -1,12 +1,12 @@ -package com.apb.beacon.alert; +package org.iilab.pb.alert; import android.content.Context; import android.location.Location; import android.location.LocationManager; -import com.apb.beacon.location.LocationTestUtil; -import com.apb.beacon.model.SMSSettings; - +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.location.LocationTestUtil; +import org.iilab.pb.model.SMSSettings; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -47,8 +47,8 @@ public void setUp() { double finerLongitude = 80.246778812345; message = "Normal test message.Normal test message.Normal test message.Normal test message.12345"; - normalLocationText = ". I\\'m at http://maps.google.com/maps?q=12.9839562,80.2467788 via network"; - finerLocationText = ". I\\'m at http://maps.google.com/maps?q=12.983956212345,80.246778812345 via network"; + normalLocationText = ". I\\'m at https://maps.google.com/maps?q=12.9839562,80.2467788 via network"; + finerLocationText = ". I\\'m at https://maps.google.com/maps?q=12.983956212345,80.246778812345 via network"; location = LocationTestUtil.location(LocationManager.NETWORK_PROVIDER, latitude, longitude, currentTimeMillis(), 10.0f); finerLocation = LocationTestUtil.location(LocationManager.NETWORK_PROVIDER, finerLatitude, finerLongitude, currentTimeMillis(), 10.0f); @@ -74,15 +74,15 @@ public void shouldSendSMSWithOutLocationToAllConfiguredPhoneNumbersIfTheLocation PanicMessage panicMessage = createPanicMessage(); panicMessage.send(null); - verify(mockSMSAdapter).sendSMS(mobile1, message); - verify(mockSMSAdapter).sendSMS(mobile3, message); + verify(mockSMSAdapter).sendSMS(mobile1, message + AppConstants.CUSTOM_ALERT_MSG_WHEN_LOCATION_NOT_FOUND); + verify(mockSMSAdapter).sendSMS(mobile3, message + AppConstants.CUSTOM_ALERT_MSG_WHEN_LOCATION_NOT_FOUND); verifyNoMoreInteractions(mockSMSAdapter); } @Test public void shouldTruncateTheMessagePartIfItExceeds() { - String expectedMessage = "Normal test message.Normal test message.Normal test message.Normal test messa" + finerLocationText; + String expectedMessage = "Normal test message.Normal test message.Normal test message.Normal test mess" + finerLocationText; PanicMessage panicMessage = createPanicMessage(); panicMessage.send(finerLocation); diff --git a/src/test/java/com/apb/beacon/alert/SMSAdapterTest.java b/src/test/java/org/iilab/pb/alert/SMSAdapterTest.java similarity index 96% rename from src/test/java/com/apb/beacon/alert/SMSAdapterTest.java rename to src/test/java/org/iilab/pb/alert/SMSAdapterTest.java index 718ec892..b4a37571 100644 --- a/src/test/java/com/apb/beacon/alert/SMSAdapterTest.java +++ b/src/test/java/org/iilab/pb/alert/SMSAdapterTest.java @@ -1,9 +1,9 @@ -package com.apb.beacon.alert; +package org.iilab.pb.alert; import android.telephony.SmsManager; -import com.apb.beacon.alert.SMSAdapter; +import org.iilab.pb.alert.SMSAdapter; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/com/apb/beacon/calculator/CalculatorImplTest.java b/src/test/java/org/iilab/pb/calculator/CalculatorImplTest.java similarity index 82% rename from src/test/java/com/apb/beacon/calculator/CalculatorImplTest.java rename to src/test/java/org/iilab/pb/calculator/CalculatorImplTest.java index 8e2cee3c..0d5f6003 100644 --- a/src/test/java/com/apb/beacon/calculator/CalculatorImplTest.java +++ b/src/test/java/org/iilab/pb/calculator/CalculatorImplTest.java @@ -1,26 +1,27 @@ -package com.apb.beacon.calculator; +package org.iilab.pb.calculator; -import com.apb.beacon.calculator.CalculatorImpl.Button; import junit.framework.TestCase; +import org.iilab.pb.calculator.CalculatorImpl; +import org.iilab.pb.calculator.CalculatorImpl.Button; import org.junit.Test; -import static com.apb.beacon.calculator.CalculatorImpl.Button.DIVIDE; -import static com.apb.beacon.calculator.CalculatorImpl.Button.EIGHT; -import static com.apb.beacon.calculator.CalculatorImpl.Button.EQUALS; -import static com.apb.beacon.calculator.CalculatorImpl.Button.FIVE; -import static com.apb.beacon.calculator.CalculatorImpl.Button.FOUR; -import static com.apb.beacon.calculator.CalculatorImpl.Button.MINUS; -import static com.apb.beacon.calculator.CalculatorImpl.Button.MULTIPLY; -import static com.apb.beacon.calculator.CalculatorImpl.Button.NINE; -import static com.apb.beacon.calculator.CalculatorImpl.Button.ONE; -import static com.apb.beacon.calculator.CalculatorImpl.Button.PLUS; -import static com.apb.beacon.calculator.CalculatorImpl.Button.SEVEN; -import static com.apb.beacon.calculator.CalculatorImpl.Button.SIX; -import static com.apb.beacon.calculator.CalculatorImpl.Button.THREE; -import static com.apb.beacon.calculator.CalculatorImpl.Button.TWO; -import static com.apb.beacon.calculator.CalculatorImpl.Button.ZERO; +import static org.iilab.pb.calculator.CalculatorImpl.Button.DIVIDE; +import static org.iilab.pb.calculator.CalculatorImpl.Button.EIGHT; +import static org.iilab.pb.calculator.CalculatorImpl.Button.EQUALS; +import static org.iilab.pb.calculator.CalculatorImpl.Button.FIVE; +import static org.iilab.pb.calculator.CalculatorImpl.Button.FOUR; +import static org.iilab.pb.calculator.CalculatorImpl.Button.MINUS; +import static org.iilab.pb.calculator.CalculatorImpl.Button.MULTIPLY; +import static org.iilab.pb.calculator.CalculatorImpl.Button.NINE; +import static org.iilab.pb.calculator.CalculatorImpl.Button.ONE; +import static org.iilab.pb.calculator.CalculatorImpl.Button.PLUS; +import static org.iilab.pb.calculator.CalculatorImpl.Button.SEVEN; +import static org.iilab.pb.calculator.CalculatorImpl.Button.SIX; +import static org.iilab.pb.calculator.CalculatorImpl.Button.THREE; +import static org.iilab.pb.calculator.CalculatorImpl.Button.TWO; +import static org.iilab.pb.calculator.CalculatorImpl.Button.ZERO; public class CalculatorImplTest extends TestCase { diff --git a/src/test/java/com/apb/beacon/common/ContactPickerFragmentTest.java b/src/test/java/org/iilab/pb/common/ContactPickerFragmentTest.java similarity index 95% rename from src/test/java/com/apb/beacon/common/ContactPickerFragmentTest.java rename to src/test/java/org/iilab/pb/common/ContactPickerFragmentTest.java index 2ba9e914..16cc5719 100644 --- a/src/test/java/com/apb/beacon/common/ContactPickerFragmentTest.java +++ b/src/test/java/org/iilab/pb/common/ContactPickerFragmentTest.java @@ -1,4 +1,4 @@ -package com.apb.beacon.common; +package org.iilab.pb.common; import android.content.Intent; import android.database.Cursor; @@ -9,8 +9,9 @@ import android.widget.EditText; import android.widget.ImageButton; -import com.apb.beacon.R; +import org.iilab.pb.R; +import org.iilab.pb.common.ContactPickerFragment; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -22,8 +23,8 @@ import static android.app.Activity.RESULT_OK; import static android.content.Intent.ACTION_GET_CONTENT; import static android.provider.ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE; -import static com.apb.beacon.R.id.contact_picker_button; import static org.hamcrest.CoreMatchers.equalTo; +import static org.iilab.pb.R.id.contact_picker_button; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import static org.robolectric.Robolectric.shadowOf; diff --git a/src/test/java/com/apb/beacon/common/MessageFragmentTest.java b/src/test/java/org/iilab/pb/common/MessageFragmentTest.java similarity index 96% rename from src/test/java/com/apb/beacon/common/MessageFragmentTest.java rename to src/test/java/org/iilab/pb/common/MessageFragmentTest.java index c919c86f..fae3dca3 100644 --- a/src/test/java/com/apb/beacon/common/MessageFragmentTest.java +++ b/src/test/java/org/iilab/pb/common/MessageFragmentTest.java @@ -1,4 +1,4 @@ -package com.apb.beacon.common; +package org.iilab.pb.common; import android.content.res.TypedArray; import android.support.v4.app.FragmentActivity; @@ -10,9 +10,10 @@ import android.widget.EditText; import android.widget.TextView; -import com.apb.beacon.R; -import com.apb.beacon.fragment.MessageTextFragment; +import org.iilab.pb.R; +import org.iilab.pb.common.MessageLimitWatcher; +import org.iilab.pb.fragment.MessageTextFragment; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/com/apb/beacon/common/MessageLimitWatcherTest.java b/src/test/java/org/iilab/pb/common/MessageLimitWatcherTest.java similarity index 91% rename from src/test/java/com/apb/beacon/common/MessageLimitWatcherTest.java rename to src/test/java/org/iilab/pb/common/MessageLimitWatcherTest.java index 1a8ed7a5..350ea956 100644 --- a/src/test/java/com/apb/beacon/common/MessageLimitWatcherTest.java +++ b/src/test/java/org/iilab/pb/common/MessageLimitWatcherTest.java @@ -1,8 +1,9 @@ -package com.apb.beacon.common; +package org.iilab.pb.common; import android.app.Activity; import android.widget.TextView; +import org.iilab.pb.common.MessageLimitWatcher; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.Robolectric; diff --git a/src/test/java/com/apb/beacon/common/TestFragmentActivity.java b/src/test/java/org/iilab/pb/common/TestFragmentActivity.java similarity index 92% rename from src/test/java/com/apb/beacon/common/TestFragmentActivity.java rename to src/test/java/org/iilab/pb/common/TestFragmentActivity.java index 3de961be..47c76707 100644 --- a/src/test/java/com/apb/beacon/common/TestFragmentActivity.java +++ b/src/test/java/org/iilab/pb/common/TestFragmentActivity.java @@ -1,4 +1,4 @@ -package com.apb.beacon.common; +package org.iilab.pb.common; import android.support.v4.app.FragmentActivity; diff --git a/src/test/java/com/apb/beacon/location/CurrentLocationProviderTest.java b/src/test/java/org/iilab/pb/location/CurrentLocationProviderTest.java similarity index 90% rename from src/test/java/com/apb/beacon/location/CurrentLocationProviderTest.java rename to src/test/java/org/iilab/pb/location/CurrentLocationProviderTest.java index c738bf06..ac1fd998 100644 --- a/src/test/java/com/apb/beacon/location/CurrentLocationProviderTest.java +++ b/src/test/java/org/iilab/pb/location/CurrentLocationProviderTest.java @@ -1,7 +1,8 @@ -package com.apb.beacon.location; +package org.iilab.pb.location; import android.location.Location; +import org.iilab.pb.location.CurrentLocationProvider; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/com/apb/beacon/location/LocationFormatterTest.java b/src/test/java/org/iilab/pb/location/LocationFormatterTest.java similarity index 77% rename from src/test/java/com/apb/beacon/location/LocationFormatterTest.java rename to src/test/java/org/iilab/pb/location/LocationFormatterTest.java index 688c9233..cca57406 100644 --- a/src/test/java/com/apb/beacon/location/LocationFormatterTest.java +++ b/src/test/java/org/iilab/pb/location/LocationFormatterTest.java @@ -1,8 +1,9 @@ -package com.apb.beacon.location; +package org.iilab.pb.location; import android.content.Context; import android.location.Location; +import org.iilab.pb.common.AppConstants; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.Robolectric; @@ -21,7 +22,7 @@ public void shouldReturnGoogleMapUrlForTheGivenLocation() { double latitude = -183.123456; double longitude = 78.654321; Location location = LocationTestUtil.location(NETWORK_PROVIDER, latitude, longitude, currentTimeMillis(), 10.0f); - String expectedMessage = ". I\\'m at http://maps.google.com/maps?q=" + latitude + "," + longitude +" via network"; + String expectedMessage = ". I\\'m at https://maps.google.com/maps?q=" + latitude + "," + longitude +" via network"; LocationFormatter locationFormatter = new LocationFormatter(location); assertEquals(expectedMessage, locationFormatter.format(context)); @@ -30,6 +31,6 @@ public void shouldReturnGoogleMapUrlForTheGivenLocation() { @Test public void shouldReturnEmptyStringIfTheGivenLocationIsNull() { LocationFormatter locationFormatter = new LocationFormatter(null); - assertEquals("", locationFormatter.format(context)); + assertEquals(AppConstants.CUSTOM_ALERT_MSG_WHEN_LOCATION_NOT_FOUND, locationFormatter.format(context)); } } diff --git a/src/test/java/com/apb/beacon/location/LocationTestUtil.java b/src/test/java/org/iilab/pb/location/LocationTestUtil.java similarity index 92% rename from src/test/java/com/apb/beacon/location/LocationTestUtil.java rename to src/test/java/org/iilab/pb/location/LocationTestUtil.java index 2c75f960..56f92ea2 100644 --- a/src/test/java/com/apb/beacon/location/LocationTestUtil.java +++ b/src/test/java/org/iilab/pb/location/LocationTestUtil.java @@ -1,4 +1,4 @@ -package com.apb.beacon.location; +package org.iilab.pb.location; import android.location.Location; diff --git a/src/test/java/com/apb/beacon/location/LocationUpdateReceiverTest.java b/src/test/java/org/iilab/pb/location/LocationUpdateReceiverTest.java similarity index 96% rename from src/test/java/com/apb/beacon/location/LocationUpdateReceiverTest.java rename to src/test/java/org/iilab/pb/location/LocationUpdateReceiverTest.java index a66a030d..87c664e3 100644 --- a/src/test/java/com/apb/beacon/location/LocationUpdateReceiverTest.java +++ b/src/test/java/org/iilab/pb/location/LocationUpdateReceiverTest.java @@ -1,4 +1,4 @@ -package com.apb.beacon.location; +package org.iilab.pb.location; import android.content.Context; import android.content.Intent; @@ -13,9 +13,9 @@ import static android.location.LocationManager.GPS_PROVIDER; import static android.location.LocationManager.NETWORK_PROVIDER; -import static com.apb.beacon.common.Intents.LOCATION_UPDATE_ACTION; -import static com.apb.beacon.location.LocationTestUtil.location; import static java.lang.System.currentTimeMillis; +import static org.iilab.pb.common.Intents.LOCATION_UPDATE_ACTION; +import static org.iilab.pb.location.LocationTestUtil.location; import static org.junit.Assert.assertEquals; @RunWith(RobolectricTestRunner.class) @@ -98,7 +98,7 @@ public void shouldReturnLocationWhichHasAlmostSameAccuracyAndRelativelyNew() { public void shouldReturnLocationFromSameProviderAndNotSignificantlyAccurateButRelativelyNew() { Location oldLocation = location(NETWORK_PROVIDER, 12.0, 20.0, currentTimeMillis(), LESS_ACCURATE); Location lessAccurateButNewLocation = location(NETWORK_PROVIDER, 12.0, 20.0, offsetCurrentTimeBy(10), VERY_LESS_ACCURATE); - Location diffMoreAccurateProviderLocation = location(GPS_PROVIDER, 12.0, 20.0, offsetCurrentTimeBy(20), VERY_LESS_ACCURATE + 10.0f); + Location diffMoreAccurateProviderLocation = location(GPS_PROVIDER, 12.0, 20.0, offsetCurrentTimeBy(20), VERY_LESS_ACCURATE - 10.0f); Location significantlyLessAccurateLocation = location(NETWORK_PROVIDER, 13.0, 20.0, offsetCurrentTimeBy(10), SIGNIFICANTLY_LESS_ACCURATE); locationUpdateReceiver.onReceive(context, getIntent(oldLocation)); diff --git a/src/test/java/com/apb/beacon/model/SMSSettingsTest.java b/src/test/java/org/iilab/pb/model/SMSSettingsTest.java similarity index 98% rename from src/test/java/com/apb/beacon/model/SMSSettingsTest.java rename to src/test/java/org/iilab/pb/model/SMSSettingsTest.java index df7e39bd..28589f0f 100644 --- a/src/test/java/com/apb/beacon/model/SMSSettingsTest.java +++ b/src/test/java/org/iilab/pb/model/SMSSettingsTest.java @@ -1,7 +1,8 @@ -package com.apb.beacon.model; +package org.iilab.pb.model; import android.content.Context; +import org.iilab.pb.model.SMSSettings; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.Robolectric; diff --git a/src/test/java/com/apb/beacon/test/support/CustomShadowRelativeLayout.java b/src/test/java/org/iilab/pb/test/support/CustomShadowRelativeLayout.java similarity index 93% rename from src/test/java/com/apb/beacon/test/support/CustomShadowRelativeLayout.java rename to src/test/java/org/iilab/pb/test/support/CustomShadowRelativeLayout.java index 67ee8ca1..66e84901 100644 --- a/src/test/java/com/apb/beacon/test/support/CustomShadowRelativeLayout.java +++ b/src/test/java/org/iilab/pb/test/support/CustomShadowRelativeLayout.java @@ -1,4 +1,4 @@ -package com.apb.beacon.test.support; +package org.iilab.pb.test.support; import android.widget.RelativeLayout; diff --git a/src/test/java/com/apb/beacon/test/support/PanicButtonRobolectricTestRunner.java b/src/test/java/org/iilab/pb/test/support/PanicButtonRobolectricTestRunner.java similarity index 92% rename from src/test/java/com/apb/beacon/test/support/PanicButtonRobolectricTestRunner.java rename to src/test/java/org/iilab/pb/test/support/PanicButtonRobolectricTestRunner.java index 478ed7f2..76d2428c 100644 --- a/src/test/java/com/apb/beacon/test/support/PanicButtonRobolectricTestRunner.java +++ b/src/test/java/org/iilab/pb/test/support/PanicButtonRobolectricTestRunner.java @@ -1,4 +1,4 @@ -package com.apb.beacon.test.support; +package org.iilab.pb.test.support; import org.junit.runners.model.InitializationError; import org.robolectric.Robolectric; diff --git a/src/test/java/com/apb/beacon/trigger/BootReceiverTest.java b/src/test/java/org/iilab/pb/trigger/BootReceiverTest.java similarity index 88% rename from src/test/java/com/apb/beacon/trigger/BootReceiverTest.java rename to src/test/java/org/iilab/pb/trigger/BootReceiverTest.java index 5ad935f2..cf6329af 100644 --- a/src/test/java/com/apb/beacon/trigger/BootReceiverTest.java +++ b/src/test/java/org/iilab/pb/trigger/BootReceiverTest.java @@ -1,10 +1,12 @@ -package com.apb.beacon.trigger; +package org.iilab.pb.trigger; import android.content.Intent; -import com.apb.beacon.common.AppConstants; -import com.apb.beacon.common.ApplicationSettings; +import org.iilab.pb.common.AppConstants; +import org.iilab.pb.common.ApplicationSettings; +import org.iilab.pb.trigger.BootReceiver; +import org.iilab.pb.trigger.HardwareTriggerService; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/src/test/java/com/apb/beacon/trigger/HardwareTriggerReceiverTest.java b/src/test/java/org/iilab/pb/trigger/HardwareTriggerReceiverTest.java similarity index 95% rename from src/test/java/com/apb/beacon/trigger/HardwareTriggerReceiverTest.java rename to src/test/java/org/iilab/pb/trigger/HardwareTriggerReceiverTest.java index d5fd7272..b21806b2 100644 --- a/src/test/java/com/apb/beacon/trigger/HardwareTriggerReceiverTest.java +++ b/src/test/java/org/iilab/pb/trigger/HardwareTriggerReceiverTest.java @@ -1,13 +1,15 @@ -package com.apb.beacon.trigger; +package org.iilab.pb.trigger; import android.app.Application; import android.app.KeyguardManager; import android.content.Context; import android.content.Intent; -import com.apb.beacon.alert.PanicAlert; import org.codehaus.plexus.util.ReflectionUtils; +import org.iilab.pb.alert.PanicAlert; +import org.iilab.pb.trigger.HardwareTriggerReceiver; +import org.iilab.pb.trigger.MultiClickEvent; import org.junit.Assert; import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/com/apb/beacon/trigger/HardwareTriggerServiceTest.java b/src/test/java/org/iilab/pb/trigger/HardwareTriggerServiceTest.java similarity index 92% rename from src/test/java/com/apb/beacon/trigger/HardwareTriggerServiceTest.java rename to src/test/java/org/iilab/pb/trigger/HardwareTriggerServiceTest.java index 3ecd8088..6b3c60d9 100644 --- a/src/test/java/com/apb/beacon/trigger/HardwareTriggerServiceTest.java +++ b/src/test/java/org/iilab/pb/trigger/HardwareTriggerServiceTest.java @@ -1,8 +1,10 @@ -package com.apb.beacon.trigger; +package org.iilab.pb.trigger; import android.content.Intent; import android.content.IntentFilter; +import org.iilab.pb.trigger.HardwareTriggerReceiver; +import org.iilab.pb.trigger.HardwareTriggerService; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.Robolectric; diff --git a/src/test/java/com/apb/beacon/trigger/MultiClickEventTest.java b/src/test/java/org/iilab/pb/trigger/MultiClickEventTest.java similarity index 94% rename from src/test/java/com/apb/beacon/trigger/MultiClickEventTest.java rename to src/test/java/org/iilab/pb/trigger/MultiClickEventTest.java index 830be926..cb4831dc 100644 --- a/src/test/java/com/apb/beacon/trigger/MultiClickEventTest.java +++ b/src/test/java/org/iilab/pb/trigger/MultiClickEventTest.java @@ -1,5 +1,6 @@ -package com.apb.beacon.trigger; +package org.iilab.pb.trigger; +import org.iilab.pb.trigger.MultiClickEvent; import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/com/apb/beacon/wizard/WizardActivityTest.java b/src/test/java/org/iilab/pb/wizard/WizardActivityTest.java similarity index 96% rename from src/test/java/com/apb/beacon/wizard/WizardActivityTest.java rename to src/test/java/org/iilab/pb/wizard/WizardActivityTest.java index 4dec74c8..3eca88ef 100644 --- a/src/test/java/com/apb/beacon/wizard/WizardActivityTest.java +++ b/src/test/java/org/iilab/pb/wizard/WizardActivityTest.java @@ -1,10 +1,10 @@ -package com.apb.beacon.wizard; +package org.iilab.pb.wizard; import android.app.Application; import android.support.v4.app.FragmentStatePagerAdapter; -import com.apb.beacon.WizardActivity; +import org.iilab.pb.WizardActivity; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith;