diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..39fb081
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,9 @@
+*.iml
+.gradle
+/local.properties
+/.idea/workspace.xml
+/.idea/libraries
+.DS_Store
+/build
+/captures
+.externalNativeBuild
diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser
new file mode 100644
index 0000000..704a5ef
Binary files /dev/null and b/.idea/caches/build_file_checksums.ser differ
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 0000000..30aa626
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 0000000..2c7f2f9
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..c0f68ed
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..dc52ff4
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
new file mode 100644
index 0000000..7f68460
--- /dev/null
+++ b/.idea/runConfigurations.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/.gitignore b/app/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/app/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/app/build.gradle b/app/build.gradle
new file mode 100644
index 0000000..2f57171
--- /dev/null
+++ b/app/build.gradle
@@ -0,0 +1,48 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 26
+ defaultConfig {
+ applicationId "com.womensafety.shajt3ch"
+ minSdkVersion 16
+ targetSdkVersion 26
+ versionCode 1
+ versionName "1.0"
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+}
+
+dependencies {
+ implementation fileTree(include: ['*.jar'], dir: 'libs')
+ //noinspection GradleCompatible
+ implementation 'com.android.support:appcompat-v7:26.1.0'
+ implementation 'com.codemybrainsout.rating:ratingdialog:1.0.8'
+ implementation 'com.android.support:design:26.1.0'
+ implementation 'com.google.android.gms:play-services-location:11.8.0'
+ implementation 'com.android.support.constraint:constraint-layout:1.0.2'
+ implementation 'com.google.android.gms:play-services-maps:11.8.0'
+ implementation 'cn.hugeterry.coordinatortablayout:coordinatortablayout:1.2.2'
+ implementation 'com.android.support:cardview-v7:26.1.0'
+ implementation fileTree(include: ['*.jar'], dir: 'libs')
+ implementation 'com.tbruyelle.rxpermissions:rxpermissions:0.7.0@aar'
+ implementation 'io.reactivex:rxandroid:1.2.1'
+ implementation 'com.afollestad.material-dialogs:core:0.9.4.2'
+ implementation project(':speech')
+ implementation 'io.reactivex:rxjava:1.1.6'
+ testImplementation 'junit:junit:4.12'
+ /* testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'com.android.support.test:runner:1.0.1'
+ androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
+ */
+}
+
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
new file mode 100644
index 0000000..f1b4245
--- /dev/null
+++ b/app/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/app/src/androidTest/java/com/womensafety/shajt3ch/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/womensafety/shajt3ch/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..94d6402
--- /dev/null
+++ b/app/src/androidTest/java/com/womensafety/shajt3ch/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package com.womensafety.shajt3ch;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() throws Exception {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getTargetContext();
+
+ assertEquals("com.apkglobal.suraksha", appContext.getPackageName());
+ }
+}
diff --git a/app/src/debug/res/values/google_maps_api.xml b/app/src/debug/res/values/google_maps_api.xml
new file mode 100644
index 0000000..6ff3c6d
--- /dev/null
+++ b/app/src/debug/res/values/google_maps_api.xml
@@ -0,0 +1,24 @@
+
+
+ AIzaSyDxRfxqFdgUlccCFu65mDq2C9Ao33G9q4A
+
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..9fea3e3
--- /dev/null
+++ b/app/src/main/AndroidManifest.xml
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/ic_launcher-web.png b/app/src/main/ic_launcher-web.png
new file mode 100644
index 0000000..bf1cde6
Binary files /dev/null and b/app/src/main/ic_launcher-web.png differ
diff --git a/app/src/main/java/com/womensafety/shajt3ch/AccelerometerListener.java b/app/src/main/java/com/womensafety/shajt3ch/AccelerometerListener.java
new file mode 100644
index 0000000..87ca3e9
--- /dev/null
+++ b/app/src/main/java/com/womensafety/shajt3ch/AccelerometerListener.java
@@ -0,0 +1,11 @@
+package com.womensafety.shajt3ch;
+
+
+
+interface AccelerometerListener {
+
+ public void onAccelerationChanged(float x, float y, float z);
+
+ public void onShake(float force);
+
+}
diff --git a/app/src/main/java/com/womensafety/shajt3ch/AccelerometerManager.java b/app/src/main/java/com/womensafety/shajt3ch/AccelerometerManager.java
new file mode 100644
index 0000000..d317d6d
--- /dev/null
+++ b/app/src/main/java/com/womensafety/shajt3ch/AccelerometerManager.java
@@ -0,0 +1,229 @@
+package com.womensafety.shajt3ch;
+
+import android.content.Context;
+import android.hardware.Sensor;
+import android.hardware.SensorEvent;
+import android.hardware.SensorEventListener;
+import android.hardware.SensorManager;
+import android.widget.Toast;
+
+import java.util.List;
+
+
+
+class AccelerometerManager{
+
+ private static Context aContext=null;
+
+
+ /** Accuracy configuration */
+ private static float threshold = 15.0f;
+ private static int interval = 200;
+
+ private static Sensor sensor;
+ private static SensorManager sensorManager;
+ // you could use an OrientationListener array instead
+ // if you plans to use more than one listener
+ private static AccelerometerListener listener;
+
+ /** indicates whether or not Accelerometer Sensor is supported */
+ private static Boolean supported;
+ /** indicates whether or not Accelerometer Sensor is running */
+ private static boolean running = false;
+
+ /**
+ * Returns true if the manager is listening to orientation changes
+ */
+ public static boolean isListening() {
+ return running;
+ }
+
+ /**
+ * Unregisters listeners
+ */
+ public static void stopListening() {
+ running = false;
+ try {
+ if (sensorManager != null && sensorEventListener != null) {
+ sensorManager.unregisterListener(sensorEventListener);
+ }
+ } catch (Exception e) {}
+ }
+
+ /**
+ * Returns true if at least one Accelerometer sensor is available
+ * @param context
+ */
+ public static boolean isSupported(Context context) {
+ aContext = context;
+ if (supported == null) {
+ if (aContext != null) {
+
+
+ sensorManager = (SensorManager) aContext.
+ getSystemService(Context.SENSOR_SERVICE);
+
+ // Get all sensors in device
+ List sensors = sensorManager.getSensorList(
+ Sensor.TYPE_ACCELEROMETER);
+
+ supported = new Boolean(sensors.size() > 0);
+
+
+
+ } else {
+ supported = Boolean.FALSE;
+ }
+ }
+ return supported;
+ }
+
+ /**
+ * Configure the listener for shaking
+ * @param threshold
+ * minimum acceleration variation for considering shaking
+ * @param interval
+ * minimum interval between to shake events
+ */
+ public static void configure(int threshold, int interval) {
+ AccelerometerManager.threshold = threshold;
+ AccelerometerManager.interval = interval;
+ }
+
+ /**
+ * Registers a listener and start listening
+ * @param accelerometerListener
+ * callback for accelerometer events
+ */
+ public static void startListening( AccelerometerListener accelerometerListener )
+ {
+
+ sensorManager = (SensorManager) aContext.
+ getSystemService(Context.SENSOR_SERVICE);
+
+ // Take all sensors in device
+ List sensors = sensorManager.getSensorList(
+ Sensor.TYPE_ACCELEROMETER);
+
+ if (sensors.size() > 0) {
+
+ sensor = sensors.get(0);
+
+ // Register Accelerometer Listener
+ running = sensorManager.registerListener(
+ sensorEventListener, sensor,
+ SensorManager.SENSOR_DELAY_GAME);
+
+ listener = accelerometerListener;
+ }
+
+
+ }
+
+ /**
+ * Configures threshold and interval
+ * And registers a listener and start listening
+ * @param accelerometerListener
+ * callback for accelerometer events
+ * @param threshold
+ * minimum acceleration variation for considering shaking
+ * @param interval
+ * minimum interval between to shake events
+ */
+ public static void startListening(
+ AccelerometerListener accelerometerListener,
+ int threshold, int interval) {
+ configure(threshold, interval);
+ startListening(accelerometerListener);
+ }
+
+ /**
+ * The listener that listen to events from the accelerometer listener
+ */
+ private static SensorEventListener sensorEventListener =
+ new SensorEventListener() {
+
+ private long now = 0;
+ private long timeDiff = 0;
+ private long lastUpdate = 0;
+ private long lastShake = 0;
+
+ private float x = 0;
+ private float y = 0;
+ private float z = 0;
+ private float lastX = 0;
+ private float lastY = 0;
+ private float lastZ = 0;
+ private float force = 0;
+
+
+
+
+ public void onAccuracyChanged(Sensor sensor, int accuracy) {}
+
+ public void onSensorChanged(SensorEvent event) {
+ // use the event timestamp as reference
+ // so the manager precision won't depends
+ // on the AccelerometerListener implementation
+ // processing time
+ now = event.timestamp;
+
+ x = event.values[0];
+ y = event.values[1];
+ z = event.values[2];
+
+ // if not interesting in shake events
+ // just remove the whole if then else block
+ if (lastUpdate == 0) {
+ lastUpdate = now;
+ lastShake = now;
+ lastX = x;
+ lastY = y;
+ lastZ = z;
+ Toast.makeText(aContext,"No Motion detected",
+ Toast.LENGTH_SHORT).show();
+
+ } else {
+ timeDiff = now - lastUpdate;
+
+ if (timeDiff > 0) {
+
+ /*force = Math.abs(x + y + z - lastX - lastY - lastZ)
+ / timeDiff;*/
+ force = Math.abs(x + y + z - lastX - lastY - lastZ);
+
+ if (Float.compare(force, threshold) >0 ) {
+ //Toast.makeText(Accelerometer.getContext(),
+ //(now-lastShake)+" >= "+interval, 1000).show();
+
+ if (now - lastShake >= interval) {
+
+ // trigger shake event
+ listener.onShake(force);
+ }
+ else
+ {
+ Toast.makeText(aContext,"No Motion detected",
+ Toast.LENGTH_SHORT).show();
+
+ }
+ lastShake = now;
+ }
+ lastX = x;
+ lastY = y;
+ lastZ = z;
+ lastUpdate = now;
+ }
+ else
+ {
+ Toast.makeText(aContext,"No Motion detected", Toast.LENGTH_SHORT).show();
+
+ }
+ }
+ // trigger change event
+ listener.onAccelerationChanged(x, y, z);
+ }
+
+ };
+
+}
diff --git a/app/src/main/java/com/womensafety/shajt3ch/BackgrndServices.java b/app/src/main/java/com/womensafety/shajt3ch/BackgrndServices.java
new file mode 100644
index 0000000..c832efd
--- /dev/null
+++ b/app/src/main/java/com/womensafety/shajt3ch/BackgrndServices.java
@@ -0,0 +1,192 @@
+package com.womensafety.shajt3ch;
+
+import android.app.Service;
+import android.content.Context;
+import android.content.Intent;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.os.IBinder;
+import android.os.Looper;
+import android.os.Message;
+import android.support.annotation.Nullable;
+import android.telephony.SmsManager;
+import android.util.Log;
+import android.widget.Toast;
+
+
+
+public class BackgrndServices extends Service implements AccelerometerListener {
+ String str_address;
+
+
+ private Looper mServiceLooper;
+ private ServiceHandler mServiceHandler;
+ // Handler that receives messages from the thread.
+ private final class ServiceHandler extends Handler {
+
+ public ServiceHandler(Looper looper) {
+
+ super(looper);
+ }
+ @Override
+ public void handleMessage(Message msg) {
+
+ // REPLACE THIS CODE WITH YOUR APP CODE
+ // Wait before Toasting Service Message
+ // to give the Service Started message time to display.
+
+ // Toast Service Message.
+ /* Context context = getApplicationContext();
+ CharSequence text = "Service Message";
+ int duration = Toast.LENGTH_LONG;
+ Toast toast = Toast.makeText(context, text, duration);
+ toast.show();
+ */
+
+ // Service can stop itself using the stopSelf() method.
+ // Not using in this app. Example statement shown below.
+ //stopSelf(msg.arg1);
+ }
+ }
+
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+
+
+ if (AccelerometerManager.isSupported(this)) {
+
+ AccelerometerManager.startListening(this);
+ }
+ HandlerThread thread = new HandlerThread("ServiceStartArguments",android.os.Process.THREAD_PRIORITY_BACKGROUND);
+ thread.start();
+
+ mServiceLooper = thread.getLooper();
+
+ mServiceHandler = new ServiceHandler(mServiceLooper);
+ }
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+
+ // Get message from message pool using handler.
+ Message msg = mServiceHandler.obtainMessage();
+
+ // Set start ID (unique to the specific start) in message.
+ msg.arg1 = startId;
+
+ // Send message to start job.
+ mServiceHandler.sendMessage(msg);
+
+ // Toast Service Started message.
+ // Context context = getApplicationContext();
+
+
+
+
+ /* CharSequence text = "Service Started";
+ int duration = Toast.LENGTH_SHORT;
+ Toast toast = Toast.makeText(context, text, duration);
+ toast.show();
+ */
+
+ // Start a sticky.
+ return START_STICKY;
+ }
+ public class GeocoderHandler extends Handler {
+ @Override
+ public void handleMessage(Message message) {
+
+ Toast.makeText(getApplicationContext(), "geocoderhandler started", Toast.LENGTH_SHORT).show();
+
+
+ switch (message.what) {
+ case 1:
+ Bundle bundle = message.getData();
+ str_address = bundle.getString("address");
+ // TelephonyManager tmgr=(TelephonyManager)BgService.this.getSystemService(Context.TELEPHONY_SERVICE);
+ // String ph_number=tmgr.getLine1Number();
+ SQLiteDatabase db;
+ db=openOrCreateDatabase("NumDB", Context.MODE_PRIVATE, null);
+ Cursor c=db.rawQuery("SELECT * FROM details", null);
+ Cursor c1=db.rawQuery("SELECT * FROM SOURCE", null);
+
+ String source_ph_number=c1.getString(0);
+ while(c.moveToNext())
+ {
+ String target_ph_number=c.getString(1);
+ SmsManager smsManager=SmsManager.getDefault();
+ smsManager.sendTextMessage(target_ph_number, source_ph_number, "Please help me. I need help immediately. This is where i am now:"+str_address, null, null);
+
+ Toast.makeText(getApplicationContext(), "Source:"+source_ph_number+"Target:"+target_ph_number, Toast.LENGTH_SHORT).show();
+
+ }
+ db.close();
+
+ break;
+ default:
+ str_address = null;
+ }
+ Toast.makeText(getApplicationContext(), str_address, Toast.LENGTH_SHORT).show();
+
+ }
+ }
+
+ @Nullable
+ @Override
+ public IBinder onBind(Intent intent) {
+ return null;
+ }
+
+ @Override
+ public void onAccelerationChanged(float x, float y, float z) {
+
+ }
+
+ @Override
+ public void onShake(float force) {
+ GPSTracker gps;
+ gps = new GPSTracker(BackgrndServices.this);
+ if(gps.canGetLocation()){
+
+ double latitude = gps.getLatitude();
+ double longitude = gps.getLongitude();
+
+ RGeocoder RGeocoder = new RGeocoder();
+ RGeocoder.getAddressFromLocation(latitude, longitude,getApplicationContext(), new GeocoderHandler());
+ Toast.makeText(getApplicationContext(), "onShake", Toast.LENGTH_SHORT).show();
+
+ }
+ else{
+ gps.showSettingsAlert();
+ }
+ }
+
+
+ // onDestroy method. Display toast that service has stopped.
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+
+ // Toast Service Stopped.
+ Context context = getApplicationContext();
+
+ Log.i("Sensor", "Service distroy");
+
+ if (AccelerometerManager.isListening()) {
+
+ AccelerometerManager.stopListening();
+
+ }
+
+ CharSequence text = "App Service Stopped";
+ int duration = Toast.LENGTH_SHORT;
+ Toast toast = Toast.makeText(context, text, duration);
+ toast.show();
+
+
+ }
+}
diff --git a/app/src/main/java/com/womensafety/shajt3ch/Constants.java b/app/src/main/java/com/womensafety/shajt3ch/Constants.java
new file mode 100644
index 0000000..09d6032
--- /dev/null
+++ b/app/src/main/java/com/womensafety/shajt3ch/Constants.java
@@ -0,0 +1,35 @@
+package com.womensafety.shajt3ch;
+
+import android.content.ComponentName;
+import android.content.Intent;
+import android.net.Uri;
+
+public class Constants {
+
+ public static final Intent[] AUTO_START_INTENTS = {
+ new Intent().setComponent(new ComponentName("com.samsung.android.lool",
+ "com.samsung.android.sm.ui.battery.BatteryActivity")),
+ new Intent("miui.intent.action.OP_AUTO_START").addCategory(Intent.CATEGORY_DEFAULT),
+ new Intent().setComponent(new ComponentName("com.miui.securitycenter",
+ "com.miui.permcenter.autostart.AutoStartManagementActivity")), new Intent().setComponent(
+ new ComponentName("com.letv.android.letvsafe",
+ "com.letv.android.letvsafe.AutobootManageActivity")), new Intent().setComponent(
+ new ComponentName("com.huawei.systemmanager",
+ "com.huawei.systemmanager.optimize.process.ProtectActivity")), new Intent().setComponent(
+ new ComponentName("com.coloros.safecenter",
+ "com.coloros.safecenter.permission.startup.StartupAppListActivity")),
+ new Intent().setComponent(new ComponentName("com.coloros.safecenter",
+ "com.coloros.safecenter.startupapp.StartupAppListActivity")), new Intent().setComponent(
+ new ComponentName("com.oppo.safe", "com.oppo.safe.permission.startup.StartupAppListActivity")),
+ new Intent().setComponent(new ComponentName("com.iqoo.secure",
+ "com.iqoo.secure.ui.phoneoptimize.AddWhiteListActivity")), new Intent().setComponent(
+ new ComponentName("com.iqoo.secure", "com.iqoo.secure.ui.phoneoptimize.BgStartUpManager")),
+ new Intent().setComponent(new ComponentName("com.vivo.permissionmanager",
+ "com.vivo.permissionmanager.activity.BgStartUpManagerActivity")), new Intent().setComponent(
+ new ComponentName("com.asus.mobilemanager",
+ "com.asus.mobilemanager.entry.FunctionActivity")).setData(
+ Uri.parse("mobilemanager://function/entry/AutoStart"))
+ };
+
+
+}
diff --git a/app/src/main/java/com/womensafety/shajt3ch/DataHolder.java b/app/src/main/java/com/womensafety/shajt3ch/DataHolder.java
new file mode 100644
index 0000000..1d304c0
--- /dev/null
+++ b/app/src/main/java/com/womensafety/shajt3ch/DataHolder.java
@@ -0,0 +1,77 @@
+package com.womensafety.shajt3ch;
+
+import android.os.Bundle;
+import android.support.v4.app.Fragment;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import java.util.ArrayList;
+
+
+
+public class DataHolder extends Fragment {
+ private RecyclerView mRecyclerView;
+
+ private ArrayList mDatas;
+ private static final String ARG_TITLE = "title";
+ private String mTitle;
+ /* Configure configure=new Configure();*/
+ private final String[] First_Aid={"choking", "bleeding heavily" ,"burns" ,"a broken bone" ,"heart attack" ,"stroke" ,"seizures (epilepsy)"
+ ,"diabetic emergency" ,"asthma attack"};
+ private final String[] Self_Defence={"1","2","3"};
+
+ public static DataHolder getInstance(String title) {
+ DataHolder fra = new DataHolder();
+ Bundle bundle = new Bundle();
+ bundle.putString(ARG_TITLE, title);
+ fra.setArguments(bundle);
+ return fra;
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Bundle bundle = getArguments();
+ mTitle = bundle.getString(ARG_TITLE);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ View v = inflater.inflate(R.layout.main_fragment, container, false);
+
+ initData();
+ mRecyclerView = (RecyclerView) v.findViewById(R.id.recyclerview);
+ mRecyclerView.setLayoutManager(new LinearLayoutManager(mRecyclerView.getContext()));
+ mRecyclerView.setAdapter(new RecyclerAdapter(mRecyclerView.getContext(), mDatas));
+
+ return v;
+ }
+
+ /* private void initData() {
+ mDatas = new ArrayList<>();
+ for (int i = 'A'; i < 'z'; i++) {
+ mDatas.add(mTitle + (char) i);
+ }
+ }*/
+ private void initData() {
+ mDatas = new ArrayList<>();
+ if (mTitle.equals("First_Aid")) {
+ for (int i = 0; i < First_Aid.length; i++) {
+
+ mDatas.add(new Model(First_Aid[i]));
+ }
+ }
+
+ else if (mTitle.equals("Self_defence")) {
+ for (int i = 0; i < Self_Defence.length; i++) {
+
+ mDatas.add(new Model(Self_Defence[i]));
+ }
+ }
+
+ }
+}
+
diff --git a/app/src/main/java/com/womensafety/shajt3ch/DataParser.java b/app/src/main/java/com/womensafety/shajt3ch/DataParser.java
new file mode 100644
index 0000000..2c4ff7a
--- /dev/null
+++ b/app/src/main/java/com/womensafety/shajt3ch/DataParser.java
@@ -0,0 +1,82 @@
+package com.womensafety.shajt3ch;
+
+import android.util.Log;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+
+public class DataParser {
+ public List> parse(String jsonData) {
+ JSONArray jsonArray = null;
+ JSONObject jsonObject;
+
+ try {
+ Log.d("Places", "parse");
+ jsonObject = new JSONObject((String) jsonData);
+ jsonArray = jsonObject.getJSONArray("results");
+ } catch (JSONException e) {
+ Log.d("Places", "parse error");
+ e.printStackTrace();
+ }
+ return getPlaces(jsonArray);
+ }
+
+ private List> getPlaces(JSONArray jsonArray) {
+ int placesCount = jsonArray.length();
+ List> placesList = new ArrayList<>();
+ HashMap placeMap = null;
+ Log.d("Places", "getPlaces");
+
+ for (int i = 0; i < placesCount; i++) {
+ try {
+ placeMap = getPlace((JSONObject) jsonArray.get(i));
+ placesList.add(placeMap);
+ Log.d("Places", "Adding places");
+
+ } catch (JSONException e) {
+ Log.d("Places", "Error in Adding places");
+ e.printStackTrace();
+ }
+ }
+ return placesList;
+ }
+
+ private HashMap getPlace(JSONObject googlePlaceJson) {
+ HashMap googlePlaceMap = new HashMap();
+ String placeName = "-NA-";
+ String vicinity = "-NA-";
+ String latitude = "";
+ String longitude = "";
+ String reference = "";
+
+ Log.d("getPlace", "Entered");
+
+ try {
+ if (!googlePlaceJson.isNull("name")) {
+ placeName = googlePlaceJson.getString("name");
+ }
+ if (!googlePlaceJson.isNull("vicinity")) {
+ vicinity = googlePlaceJson.getString("vicinity");
+ }
+ latitude = googlePlaceJson.getJSONObject("geometry").getJSONObject("location").getString("lat");
+ longitude = googlePlaceJson.getJSONObject("geometry").getJSONObject("location").getString("lng");
+ reference = googlePlaceJson.getString("reference");
+ googlePlaceMap.put("place_name", placeName);
+ googlePlaceMap.put("vicinity", vicinity);
+ googlePlaceMap.put("lat", latitude);
+ googlePlaceMap.put("lng", longitude);
+ googlePlaceMap.put("reference", reference);
+ Log.d("getPlace", "Putting Places");
+ } catch (JSONException e) {
+ Log.d("getPlace", "Error");
+ e.printStackTrace();
+ }
+ return googlePlaceMap;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/womensafety/shajt3ch/Display.java b/app/src/main/java/com/womensafety/shajt3ch/Display.java
new file mode 100644
index 0000000..cd03048
--- /dev/null
+++ b/app/src/main/java/com/womensafety/shajt3ch/Display.java
@@ -0,0 +1,68 @@
+package com.womensafety.shajt3ch;
+
+import android.app.AlertDialog;
+import android.support.v4.app.Fragment;
+import android.content.Context;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+
+
+public class Display extends Fragment {
+ Cursor c;
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ //returning our layout file
+ //change R.layout.yourlayoutfilename for each of your fragments
+ /*return inflater.inflate(R.layout.display, container, false);*/
+ View view = inflater.inflate(R.layout.display, container, false);
+
+ SQLiteDatabase db;
+ db = getActivity().openOrCreateDatabase("NumberDB",Context.MODE_PRIVATE, null);
+
+ c = db.rawQuery("SELECT * FROM details", null);
+ if (c.getCount() == 0) {
+ showMessage("Error", "No records found.");
+ return inflater.inflate(R.layout.display, container, false);
+ }
+ StringBuffer buffer = new StringBuffer();
+ while (c.moveToNext()) {
+ buffer.append("Name: " + c.getString(0) + "\n");
+ buffer.append("Number: " + c.getString(1) + "\n");
+ }
+ showMessage("Details", buffer.toString());
+ /*Intent i_startservice=new Intent(Display.this,BgService.class);
+ startService(i_startservice);
+*/ return view;
+
+ }
+
+
+
+ public void showMessage(String title,String message)
+ {
+ AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
+ builder.setCancelable(true);
+ builder.setTitle(title);
+ builder.setMessage(message);
+ builder.show();
+ }
+
+
+
+
+ /*public void back(View v) {
+ Intent i_back=new Intent(Display.this,MainActivity.class);
+ startActivity(i_back);
+
+ }
+*/
+
+
+}
diff --git a/app/src/main/java/com/womensafety/shajt3ch/DownloadUrl.java b/app/src/main/java/com/womensafety/shajt3ch/DownloadUrl.java
new file mode 100644
index 0000000..0287b6b
--- /dev/null
+++ b/app/src/main/java/com/womensafety/shajt3ch/DownloadUrl.java
@@ -0,0 +1,53 @@
+package com.womensafety.shajt3ch;
+
+import android.util.Log;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+
+
+public class DownloadUrl {
+
+ public String readUrl(String strUrl) throws IOException {
+ String data = "";
+ InputStream iStream = null;
+ HttpURLConnection urlConnection = null;
+ try {
+ URL url = new URL(strUrl);
+
+ // Creating an http connection to communicate with url
+ urlConnection = (HttpURLConnection) url.openConnection();
+
+ // Connecting to url
+ urlConnection.connect();
+
+ // Reading data from url
+ iStream = urlConnection.getInputStream();
+
+ BufferedReader br = new BufferedReader(new InputStreamReader(iStream));
+
+ StringBuffer sb = new StringBuffer();
+
+ String line = "";
+ while ((line = br.readLine()) != null) {
+ sb.append(line);
+ }
+
+ data = sb.toString();
+ Log.d("downloadUrl", data.toString());
+ br.close();
+
+ } catch (Exception e) {
+ Log.d("Exception", e.toString());
+ } finally {
+ iStream.close();
+ urlConnection.disconnect();
+ }
+ return data;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/womensafety/shajt3ch/GPSTracker.java b/app/src/main/java/com/womensafety/shajt3ch/GPSTracker.java
new file mode 100644
index 0000000..0a7cbb9
--- /dev/null
+++ b/app/src/main/java/com/womensafety/shajt3ch/GPSTracker.java
@@ -0,0 +1,206 @@
+package com.womensafety.shajt3ch;
+
+import android.annotation.SuppressLint;
+import android.app.AlertDialog;
+import android.app.Service;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.location.Location;
+import android.location.LocationListener;
+import android.location.LocationManager;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.provider.Settings;
+import android.util.Log;
+
+
+
+public class GPSTracker extends Service implements LocationListener {
+
+ private final Context mContext;
+
+ // flag for GPS status
+ boolean isGPSEnabled = false;
+
+ // flag for network status
+ boolean isNetworkEnabled = false;
+
+ // flag for GPS status
+ boolean canGetLocation = false;
+
+ Location location; // location
+ double latitude; // latitude
+ double longitude; // longitude
+
+ // The minimum distance to change Updates in meters
+ private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
+
+ // The minimum time between updates in milliseconds
+ private static final long MIN_TIME_BW_UPDATES = 1000 * 60 * 1; // 1 minute
+
+ // Declaring a Location Manager
+ protected LocationManager locationManager;
+
+ public GPSTracker(Context context) {
+ this.mContext = context;
+ getLocation();
+ }
+
+ @SuppressLint("MissingPermission")
+ public Location getLocation() {
+ try {
+ locationManager = (LocationManager) mContext
+ .getSystemService(LOCATION_SERVICE);
+
+ // getting GPS status
+ isGPSEnabled = locationManager
+ .isProviderEnabled(LocationManager.GPS_PROVIDER);
+
+ // getting network status
+ isNetworkEnabled = locationManager
+ .isProviderEnabled(LocationManager.NETWORK_PROVIDER);
+
+ if (!isGPSEnabled && !isNetworkEnabled) {
+ // no network provider is enabled
+ } else {
+ this.canGetLocation = true;
+ if (isNetworkEnabled) {
+ locationManager.requestLocationUpdates(
+ LocationManager.NETWORK_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+ Log.d("Network", "Network");
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+ }
+ }
+ }
+ // if GPS Enabled get lat/long using GPS Services
+ if (isGPSEnabled) {
+ if (location == null) {
+ locationManager.requestLocationUpdates(
+ LocationManager.GPS_PROVIDER,
+ MIN_TIME_BW_UPDATES,
+ MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
+ Log.d("GPS Enabled", "GPS Enabled");
+ if (locationManager != null) {
+ location = locationManager
+ .getLastKnownLocation(LocationManager.GPS_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+ }
+ }
+ }
+ }
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ return location;
+ }
+
+ /**
+ * Stop using GPS listener
+ * Calling this function will stop using GPS in your app
+ * */
+ public void stopUsingGPS(){
+ if(locationManager != null){
+ locationManager.removeUpdates(GPSTracker.this);
+ }
+ }
+
+ /**
+ * Function to get latitude
+ * */
+ public double getLatitude(){
+ if(location != null){
+ latitude = location.getLatitude();
+ }
+
+ // return latitude
+ return latitude;
+ }
+
+ /**
+ * Function to get longitude
+ * */
+ public double getLongitude(){
+ if(location != null){
+ longitude = location.getLongitude();
+ }
+
+ // return longitude
+ return longitude;
+ }
+
+ /**
+ * Function to check GPS/wifi enabled
+ * @return boolean
+ * */
+ public boolean canGetLocation() {
+ return this.canGetLocation;
+ }
+
+ /**
+ * Function to show settings alert dialog
+ * On pressing Settings button will lauch Settings Options
+ * */
+ public void showSettingsAlert(){
+ AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
+
+ // Setting Dialog Title
+ alertDialog.setTitle("GPS is settings");
+
+ // Setting Dialog Message
+ alertDialog.setMessage("GPS is not enabled. Do you want to go to settings menu?");
+
+ // On pressing Settings button
+ alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog,int which) {
+ Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+ mContext.startActivity(intent);
+ }
+ });
+
+ // on pressing cancel button
+ alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ }
+ });
+
+ // Showing Alert Message
+ alertDialog.show();
+ }
+
+ @Override
+ public void onLocationChanged(Location location) {
+ }
+
+ @Override
+ public void onProviderDisabled(String provider) {
+ }
+
+ @Override
+ public void onProviderEnabled(String provider) {
+ }
+
+ @Override
+ public void onStatusChanged(String provider, int status, Bundle extras) {
+ }
+
+ @Override
+ public IBinder onBind(Intent arg0) {
+ return null;
+ }
+
+}
+
diff --git a/app/src/main/java/com/womensafety/shajt3ch/GetNearbyPlacesData.java b/app/src/main/java/com/womensafety/shajt3ch/GetNearbyPlacesData.java
new file mode 100644
index 0000000..93c6461
--- /dev/null
+++ b/app/src/main/java/com/womensafety/shajt3ch/GetNearbyPlacesData.java
@@ -0,0 +1,67 @@
+package com.womensafety.shajt3ch;
+
+import android.os.AsyncTask;
+import android.util.Log;
+
+import com.google.android.gms.maps.CameraUpdateFactory;
+import com.google.android.gms.maps.GoogleMap;
+import com.google.android.gms.maps.model.BitmapDescriptorFactory;
+import com.google.android.gms.maps.model.LatLng;
+import com.google.android.gms.maps.model.MarkerOptions;
+
+import java.util.HashMap;
+import java.util.List;
+
+
+
+public class GetNearbyPlacesData extends AsyncTask