├── .idea
├── .name
├── copyright
│ └── profiles_settings.xml
├── scopes
│ └── scope_settings.xml
├── encodings.xml
├── vcs.xml
├── inspectionProfiles
│ ├── profiles_settings.xml
│ └── Project_Default.xml
├── modules.xml
├── misc.xml
├── gradle.xml
└── compiler.xml
├── app
├── .gitignore
├── libs
│ ├── Parse-1.9.2.jar
│ └── bolts-android-1.2.0.jar
├── src
│ ├── main
│ │ ├── ic_launcher-web.png
│ │ ├── res
│ │ │ ├── drawable-hdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-mdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ │ ├── styles.xml
│ │ │ │ ├── dimens.xml
│ │ │ │ └── strings.xml
│ │ │ ├── layout
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── activity_panic.xml
│ │ │ │ ├── activity_ride_on.xml
│ │ │ │ ├── activity_request_otp_activity.xml
│ │ │ │ ├── fragment_panic.xml
│ │ │ │ ├── fragment_main.xml
│ │ │ │ ├── fragment_request_otp_activity.xml
│ │ │ │ └── fragment_ride_on.xml
│ │ │ ├── menu
│ │ │ │ ├── menu_main.xml
│ │ │ │ ├── menu_panic_.xml
│ │ │ │ ├── menu_ride_on.xml
│ │ │ │ └── menu_request_otp_activity.xml
│ │ │ └── values-w820dp
│ │ │ │ └── dimens.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── zephrys
│ │ │ │ └── auter
│ │ │ │ ├── App.java
│ │ │ │ ├── Panic_Activity.java
│ │ │ │ ├── MainActivity.java
│ │ │ │ ├── RideOnActivity.java
│ │ │ │ └── Request_otp_activity.java
│ │ └── AndroidManifest.xml
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── zephrys
│ │ └── auter
│ │ └── ApplicationTest.java
├── proguard-rules.pro
├── build.gradle
└── app.iml
├── settings.gradle
├── .gitignore
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── README.md
├── gradle.properties
├── Auter.iml
├── gradlew.bat
└── gradlew
/.idea/.name:
--------------------------------------------------------------------------------
1 | Auter
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/app/libs/Parse-1.9.2.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zephrys/Auter/HEAD/app/libs/Parse-1.9.2.jar
--------------------------------------------------------------------------------
/app/libs/bolts-android-1.2.0.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zephrys/Auter/HEAD/app/libs/bolts-android-1.2.0.jar
--------------------------------------------------------------------------------
/app/src/main/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zephrys/Auter/HEAD/app/src/main/ic_launcher-web.png
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .gradle
2 | /local.properties
3 | /.idea/workspace.xml
4 | /.idea/libraries
5 | .DS_Store
6 | /build
7 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zephrys/Auter/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zephrys/Auter/HEAD/app/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zephrys/Auter/HEAD/app/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zephrys/Auter/HEAD/app/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Zephrys/Auter/HEAD/app/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/.idea/scopes/scope_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 10 15:27:10 PDT 2013
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
7 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_panic.xml:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_ride_on.xml:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_request_otp_activity.xml:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_main.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_panic_.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_ride_on.xml:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/zephrys/auter/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.zephrys.auter;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/res/menu/menu_request_otp_activity.xml:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zephrys/auter/App.java:
--------------------------------------------------------------------------------
1 | package com.zephrys.auter;
2 |
3 | import android.app.Application;
4 |
5 | import com.parse.Parse;
6 |
7 | public class App extends Application {
8 | @Override
9 | public void onCreate() {
10 | super.onCreate();
11 |
12 | //enable local data Storage
13 | // Enable Local Datastore.
14 | Parse.enableLocalDatastore(this);
15 |
16 | Parse.initialize(this, "zU277hQ68BQBoxiWnprRysK8ZVP1NpkWL4lIzt0k", "oViPPq5knlwGskyrmNCuQfCzPpdYvxnxc1kTnYV5");
17 | }
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/psd/.mozbuild/android-sdk-linux/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Auter
2 |
3 | Auter is the product of a 36 hour online hackathon - Aadhar Hackathon. It tries to make cab and rickshaw travel safer by authenticating drivers through the aadhar API and allowing users to report and alert the concerned authorities as well as their family and friends in case of an unfortunate turn of events.
4 |
5 | Tech: Android, Parse backend
6 |
7 | Tested on Android 4.4 Kitkat and above, devices
8 |
9 | ### TODO
10 | * Add optional logs for recording regular movement of vehicle, or to check whether movement is on route
11 | * Use Twilio
12 |
13 | ### Team
14 | * [Prabhjyot Singh Sodhi](github.com/psdh)
15 | * [Gyanendra Mishra](github.com/h4ck3rk3y)
16 | * [Devansh Chaudhary](https://www.behance.net/devanshc)
17 | * [Varun Vachaspati](github.com/varunwachaspati)
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 21
5 | buildToolsVersion "22.0.1"
6 |
7 | defaultConfig {
8 | applicationId "com.zephrys.auter"
9 | minSdkVersion 15
10 | targetSdkVersion 21
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | compile 'com.android.support:appcompat-v7:22.1.1'
25 |
26 | compile 'com.parse.bolts:bolts-android:1.+'
27 | compile fileTree(dir: 'libs', include: 'Parse-*.jar')
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/Auter.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Auter
5 | Hello world!
6 | Settings
7 | Enter Aadhar Number of Driver
8 | 12 digit Aadhar Number
9 | Start a Ride!
10 |
11 |
12 | Ride Safe with Auter!
13 |
14 | Panic!
15 | Safely Reached!
16 | Stay Alert!
17 | Sign Up!
18 | Fret not, the nearest police station have been updated with your complain and your location is being actively tracked.
19 | Report Safe
20 | Sign Up!
21 |
22 |
23 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_panic.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
18 |
19 |
26 |
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
14 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
26 |
27 |
30 |
31 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_main.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
18 |
19 |
30 |
31 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_request_otp_activity.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
21 |
22 |
29 |
30 |
40 |
41 |
49 |
50 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/fragment_ride_on.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
16 |
17 |
28 |
29 |
39 |
40 |
50 |
51 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zephrys/auter/Panic_Activity.java:
--------------------------------------------------------------------------------
1 | package com.zephrys.auter;
2 |
3 | import android.content.Intent;
4 | import android.support.v7.app.ActionBarActivity;
5 | import android.support.v7.app.ActionBar;
6 | import android.support.v4.app.Fragment;
7 | import android.os.Bundle;
8 | import android.view.LayoutInflater;
9 | import android.view.Menu;
10 | import android.view.MenuItem;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.os.Build;
14 | import android.widget.Button;
15 |
16 |
17 | public class Panic_Activity extends ActionBarActivity {
18 |
19 | @Override
20 | protected void onCreate(Bundle savedInstanceState) {
21 | super.onCreate(savedInstanceState);
22 | setContentView(R.layout.activity_panic);
23 |
24 | String anum = getIntent().getStringExtra(Intent.EXTRA_TEXT);
25 |
26 | if (savedInstanceState == null) {
27 | getSupportFragmentManager().beginTransaction()
28 | .add(R.id.container, new PlaceholderFragment(anum))
29 | .commit();
30 | }
31 | }
32 |
33 |
34 | @Override
35 | public boolean onCreateOptionsMenu(Menu menu) {
36 | // Inflate the menu; this adds items to the action bar if it is present.
37 | //getMenuInflater().inflate(R.menu.menu_main, menu);
38 | return false;
39 | }
40 |
41 | @Override
42 | public boolean onOptionsItemSelected(MenuItem item) {
43 | // Handle action bar item clicks here. The action bar will
44 | // automatically handle clicks on the Home/Up button, so long
45 | // as you specify a parent activity in AndroidManifest.xml.
46 | int id = item.getItemId();
47 |
48 | //noinspection SimplifiableIfStatement
49 | if (id == R.id.action_settings) {
50 | return true;
51 | }
52 |
53 | return super.onOptionsItemSelected(item);
54 | }
55 |
56 | /**
57 | * A placeholder fragment containing a simple view.
58 | */
59 | public static class PlaceholderFragment extends Fragment {
60 |
61 | String anum;
62 |
63 | public PlaceholderFragment(String anum) {
64 | this.anum = anum;
65 | }
66 |
67 | @Override
68 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
69 | Bundle savedInstanceState) {
70 | View rootView = inflater.inflate(R.layout.fragment_panic, container, false);
71 |
72 | Button report_safe = (Button) rootView.findViewById(R.id.button2);
73 | report_safe.setOnClickListener(new View.OnClickListener() {
74 | @Override
75 | public void onClick(View v) {
76 | Intent intent = new Intent(getActivity(), RideOnActivity.class);
77 | intent.putExtra("print_safe", true);
78 | intent.putExtra(Intent.EXTRA_TEXT, anum);
79 | startActivity(intent);
80 | getActivity().finish();
81 | }
82 | });
83 |
84 | return rootView;
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zephrys/auter/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.zephrys.auter;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.content.SharedPreferences;
6 | import android.preference.PreferenceManager;
7 | import android.support.v7.app.ActionBarActivity;
8 | import android.support.v4.app.Fragment;
9 | import android.os.Bundle;
10 | import android.text.Editable;
11 | import android.text.TextWatcher;
12 | import android.util.Log;
13 | import android.view.LayoutInflater;
14 | import android.view.Menu;
15 | import android.view.MenuItem;
16 | import android.view.View;
17 | import android.view.ViewGroup;
18 | import android.widget.Button;
19 | import android.widget.EditText;
20 | import android.widget.Toast;
21 |
22 | import com.parse.Parse;
23 | import com.parse.ParseObject;
24 |
25 |
26 | public class MainActivity extends ActionBarActivity {
27 |
28 | @Override
29 | protected void onCreate(Bundle savedInstanceState) {
30 | super.onCreate(savedInstanceState);
31 | setContentView(R.layout.activity_main);
32 | if (savedInstanceState == null) {
33 | getSupportFragmentManager().beginTransaction()
34 | .add(R.id.container, new StartFragment())
35 | .commit();
36 | }
37 |
38 |
39 | Intent intent = getIntent();
40 | if(intent.getBooleanExtra("print_completion", false)) {
41 | Toast toast = Toast.makeText(this, "Ride ended Safely!", Toast.LENGTH_SHORT);
42 | toast.show();
43 | }
44 | }
45 |
46 | @Override
47 | protected void onResume() {
48 |
49 |
50 | SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
51 |
52 | if (!sharedPreferences.getBoolean("SIGNUP_DONE", false)) {
53 |
54 |
55 | Intent intent = new Intent(this, Request_otp_activity.class);
56 | startActivity(intent);
57 |
58 | }
59 |
60 | super.onResume();
61 | }
62 |
63 | @Override
64 | public boolean onCreateOptionsMenu(Menu menu) {
65 | // Inflate the menu; this adds items to the action bar if it is present.
66 | //getMenuInflater().inflate(R.menu.menu_main, menu);
67 | return true;
68 | }
69 |
70 | @Override
71 | public boolean onOptionsItemSelected(MenuItem item) {
72 | // Handle action bar item clicks here. The action bar will
73 | // automatically handle clicks on the Home/Up button, so long
74 | // as you specify a parent activity in AndroidManifest.xml.
75 | int id = item.getItemId();
76 |
77 | //noinspection SimplifiableIfStatement
78 | if (id == R.id.action_settings) {
79 | return true;
80 | }
81 |
82 | return super.onOptionsItemSelected(item);
83 | }
84 |
85 | /**
86 | * A placeholder fragment containing a simple view.
87 | */
88 | public static class StartFragment extends Fragment {
89 |
90 | public StartFragment() {
91 | }
92 |
93 | @Override
94 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
95 | Bundle savedInstanceState) {
96 | final View rootView = inflater.inflate(R.layout.fragment_main, container, false);
97 |
98 | Button startRide = (Button) rootView.findViewById(R.id.start_journey_button);
99 |
100 |
101 | startRide.setOnClickListener(new View.OnClickListener() {
102 | @Override
103 | public void onClick(View v) {
104 |
105 | EditText aadharNum = (EditText) rootView.findViewById(R.id.aadhar_user_input_edittext);
106 |
107 | String aNum = aadharNum.getText().toString();
108 |
109 | if(aNum.length() != 12) {
110 | Toast toast = Toast.makeText(getActivity(), "Please enter a valid 12-digit aadhar number", Toast.LENGTH_SHORT);
111 | toast.show();
112 | return;
113 | } else {
114 | Intent intent = new Intent(getActivity(), RideOnActivity.class);
115 | intent.putExtra(Intent.EXTRA_TEXT, aNum);
116 |
117 | startActivity(intent);
118 | }
119 | }
120 | });
121 | return rootView;
122 | }
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/app/app.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zephrys/auter/RideOnActivity.java:
--------------------------------------------------------------------------------
1 | package com.zephrys.auter;
2 |
3 | import android.app.AlertDialog;
4 | import android.content.DialogInterface;
5 | import android.content.Intent;
6 | import android.support.v7.app.ActionBarActivity;
7 | import android.support.v4.app.Fragment;
8 | import android.os.Bundle;
9 | import android.util.Log;
10 | import android.view.LayoutInflater;
11 | import android.view.Menu;
12 | import android.view.MenuItem;
13 | import android.view.View;
14 | import android.view.ViewGroup;
15 | import android.widget.Button;
16 | import android.widget.EditText;
17 | import android.widget.TextView;
18 | import android.widget.Toast;
19 |
20 | import com.parse.FindCallback;
21 | import com.parse.GetCallback;
22 | import com.parse.ParseException;
23 | import com.parse.ParseObject;
24 | import com.parse.ParseQuery;
25 |
26 | import java.util.List;
27 |
28 |
29 | public class RideOnActivity extends ActionBarActivity {
30 |
31 | Long mAadarNum;
32 |
33 | @Override
34 | protected void onCreate(Bundle savedInstanceState) {
35 | super.onCreate(savedInstanceState);
36 | setContentView(R.layout.activity_ride_on);
37 |
38 | Intent intent = getIntent();
39 | if(intent.getBooleanExtra("print_safe", false)) {
40 | Toast toast = Toast.makeText(this, "I am safe!", Toast.LENGTH_SHORT);
41 | toast.show();
42 | }
43 | mAadarNum = Long.valueOf(intent.getStringExtra(Intent.EXTRA_TEXT));
44 |
45 | if (savedInstanceState == null) {
46 | getSupportFragmentManager().beginTransaction()
47 | .add(R.id.container, new RideOnFragment(mAadarNum))
48 | .commit();
49 | }
50 |
51 | }
52 |
53 |
54 | @Override
55 | public boolean onCreateOptionsMenu(Menu menu) {
56 | // Inflate the menu; this adds items to the action bar if it is present.
57 | //getMenuInflater().inflate(R.menu.menu_main, menu);
58 | return false;
59 | }
60 |
61 | @Override
62 | public boolean onOptionsItemSelected(MenuItem item) {
63 | // Handle action bar item clicks here. The action bar will
64 | // automatically handle clicks on the Home/Up button, so long
65 | // as you specify a parent activity in AndroidManifest.xml.
66 | int id = item.getItemId();
67 |
68 | //noinspection SimplifiableIfStatement
69 | if (id == R.id.action_settings) {
70 | return true;
71 | }
72 |
73 | return super.onOptionsItemSelected(item);
74 | }
75 |
76 | /**
77 | * A placeholder fragment containing a simple view.
78 | */
79 | public static class RideOnFragment extends Fragment {
80 |
81 | Long aadhar;
82 |
83 | public RideOnFragment(Long a) {
84 | aadhar = a;
85 | }
86 |
87 | @Override
88 | public View onCreateView(final LayoutInflater inflater, ViewGroup container,
89 | Bundle savedInstanceState) {
90 | View rootView = inflater.inflate(R.layout.fragment_ride_on, container, false);
91 |
92 | TextView aadhar_view = (TextView) rootView.findViewById(R.id.aadhar_view);
93 | aadhar_view.setVisibility(View.VISIBLE);
94 | aadhar_view.setText(aadhar.toString());
95 |
96 | final EditText dispInfo = (EditText) rootView.findViewById(R.id.info_driver_edittext);
97 | dispInfo.setText("");
98 |
99 | Toast toast = Toast.makeText(getActivity(), "Fetching Data!", Toast.LENGTH_SHORT);
100 | toast.show();
101 |
102 | String printed = "Some Network error! Try again!";
103 |
104 | // Fetching data from parse.com!!
105 |
106 | ParseQuery getUser = ParseQuery.getQuery("Cabbies");
107 | getUser.whereEqualTo("ID", aadhar.toString());
108 |
109 | getUser.findInBackground(new FindCallback() {
110 | @Override
111 | public void done(List parseObjects, ParseException e) {
112 | if(e == null) {
113 | try {
114 | ParseObject first = parseObjects.get(0);
115 | String temp1 = first.getString("Name");
116 | temp1 += "\n" + first.getString("Address");
117 | dispInfo.setText(temp1);
118 | }
119 | catch (Exception some) {
120 | Toast toast = Toast.makeText(getActivity(), "Aadhar does not belong to a Registered Driver", Toast.LENGTH_SHORT);
121 | toast.show();
122 | Intent intent = new Intent(getActivity(), MainActivity.class);
123 | startActivity(intent);
124 | }
125 | } else {
126 | Toast toast = Toast.makeText(getActivity(), "Network Error! Try again", Toast.LENGTH_SHORT);
127 | toast.show();
128 | }
129 | }
130 | });
131 |
132 | Button panic = (Button) rootView.findViewById(R.id.panic_button);
133 |
134 | panic.setOnClickListener(new View.OnClickListener() {
135 | @Override
136 | public void onClick(View v) {
137 |
138 | new AlertDialog.Builder(getActivity())
139 | .setTitle(R.string.panic)
140 | .setMessage("Are you sure you want to invoke the Panic message, this would alert to the concerned authorities with your details?")
141 | .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
142 | @Override
143 | public void onClick(DialogInterface dialog, int which) {
144 | Intent intent = new Intent(getActivity(), Panic_Activity.class);
145 | intent.putExtra(Intent.EXTRA_TEXT, aadhar.toString());
146 | startActivity(intent);
147 | }
148 | })
149 | .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
150 | @Override
151 | public void onClick(DialogInterface dialog, int which) {
152 | dialog.dismiss();
153 | }
154 | }).show();
155 |
156 |
157 | }
158 | });
159 |
160 | Button safe = (Button) rootView.findViewById(R.id.safe_button);
161 |
162 | safe.setOnClickListener(new View.OnClickListener() {
163 | @Override
164 | public void onClick(View v) {
165 | new AlertDialog.Builder(getActivity())
166 | .setTitle("Confirm Safe?")
167 | .setMessage("Are you sure you want to mark yourself safe and end this ride?")
168 | .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
169 | @Override
170 | public void onClick(DialogInterface dialog, int which) {
171 |
172 |
173 | Intent intent = new Intent(getActivity(), MainActivity.class);
174 | intent.putExtra("print_completion", true);
175 | startActivity(intent);
176 |
177 | }
178 | })
179 | .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
180 | @Override
181 | public void onClick(DialogInterface dialog, int which) {
182 | dialog.dismiss();
183 | }
184 | }).show();
185 |
186 | }
187 | });
188 |
189 |
190 | return rootView;
191 | }
192 | }
193 | }
194 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zephrys/auter/Request_otp_activity.java:
--------------------------------------------------------------------------------
1 | package com.zephrys.auter;
2 |
3 | import android.content.Intent;
4 | import android.content.SharedPreferences;
5 | import android.os.AsyncTask;
6 | import android.os.StrictMode;
7 | import android.preference.PreferenceManager;
8 | import android.support.v7.app.ActionBarActivity;
9 | import android.support.v7.app.ActionBar;
10 | import android.support.v4.app.Fragment;
11 | import android.os.Bundle;
12 | import android.util.Log;
13 | import android.view.LayoutInflater;
14 | import android.view.Menu;
15 | import android.view.MenuItem;
16 | import android.view.View;
17 | import android.view.ViewGroup;
18 | import android.os.Build;
19 | import android.widget.Button;
20 | import android.widget.EditText;
21 | import android.widget.TextView;
22 | import android.widget.Toast;
23 |
24 | import com.parse.ParseException;
25 | import com.parse.ParseObject;
26 |
27 | import org.apache.http.HttpResponse;
28 | import org.apache.http.client.ResponseHandler;
29 | import org.apache.http.client.methods.HttpPost;
30 | import org.apache.http.conn.scheme.Scheme;
31 | import org.apache.http.conn.scheme.SchemeRegistry;
32 | import org.apache.http.conn.ssl.SSLSocketFactory;
33 | import org.apache.http.conn.ssl.X509HostnameVerifier;
34 | import org.apache.http.entity.StringEntity;
35 | import org.apache.http.impl.client.BasicResponseHandler;
36 | import org.apache.http.impl.client.DefaultHttpClient;
37 | import org.apache.http.impl.conn.SingleClientConnManager;
38 | import org.apache.http.message.BasicHeader;
39 | import org.apache.http.params.HttpConnectionParams;
40 | import org.apache.http.protocol.HTTP;
41 | import org.json.JSONObject;
42 |
43 | import java.util.concurrent.ExecutionException;
44 |
45 | import javax.net.ssl.HostnameVerifier;
46 |
47 |
48 | public class Request_otp_activity extends ActionBarActivity {
49 |
50 | @Override
51 | protected void onCreate(Bundle savedInstanceState) {
52 | super.onCreate(savedInstanceState);
53 |
54 | StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
55 | StrictMode.setThreadPolicy(policy);
56 |
57 | setContentView(R.layout.activity_request_otp_activity);
58 | if (savedInstanceState == null) {
59 | getSupportFragmentManager().beginTransaction()
60 | .add(R.id.container, new PlaceholderFragment())
61 | .commit();
62 | }
63 | }
64 |
65 |
66 | @Override
67 | public boolean onCreateOptionsMenu(Menu menu) {
68 | // Inflate the menu; this adds items to the action bar if it is present.
69 | getMenuInflater().inflate(R.menu.menu_request_otp_activity, menu);
70 | return true;
71 | }
72 |
73 | @Override
74 | public boolean onOptionsItemSelected(MenuItem item) {
75 | // Handle action bar item clicks here. The action bar will
76 | // automatically handle clicks on the Home/Up button, so long
77 | // as you specify a parent activity in AndroidManifest.xml.
78 | int id = item.getItemId();
79 |
80 | //noinspection SimplifiableIfStatement
81 | if (id == R.id.action_settings) {
82 | return true;
83 | }
84 |
85 | return super.onOptionsItemSelected(item);
86 | }
87 |
88 | /**
89 | * A placeholder fragment containing a simple view.
90 | */
91 | public static class PlaceholderFragment extends Fragment {
92 |
93 | public PlaceholderFragment() {
94 | }
95 |
96 | @Override
97 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
98 | Bundle savedInstanceState) {
99 | final View rootView = inflater.inflate(R.layout.fragment_request_otp_activity, container, false);
100 |
101 | Button b1 = (Button) rootView.findViewById(R.id.send_otp_button);
102 | //sends the otp. updates text view to 'otp sent'
103 | b1.setOnClickListener(new View.OnClickListener() {
104 | @Override
105 | public void onClick(View view) {
106 |
107 |
108 | String aadhar = ((EditText) getActivity().findViewById(R.id.aadhar_user_input_otp)).getText().toString();
109 | if(aadhar.length() != 12) {
110 | Toast toast = Toast.makeText(getActivity(), "Please enter a valid 12-digit aadhar number", Toast.LENGTH_SHORT);
111 | toast.show();
112 | return;
113 | }
114 |
115 | String son1 = "{ \"aadhaar-id\": \""+aadhar+"\", \"channel\":\"SMS\", \"location\": { \"type\": \"gps\", \"latitude\": \"73.2\", \"longitude\": \"22.3\", \"altitude\": \"0\" } }";
116 |
117 | String[] inputArr = new String[] {
118 | aadhar,
119 | son1,
120 | };
121 |
122 | TextView t1 = (TextView) rootView.findViewById(R.id.out);
123 | t1.setText(("Sending OTP."));
124 |
125 | String res[] = new String[0];
126 | try {
127 | res = new RequestOTPTask().execute(aadhar, son1).get();
128 | } catch (InterruptedException e) {
129 | e.printStackTrace();
130 | } catch (ExecutionException e) {
131 | e.printStackTrace();
132 | }
133 |
134 | t1.setText(res[0]);
135 |
136 | }
137 | });
138 |
139 | //confirms otp. if true then sets textview to 'otp entered correctly', 'incorrect*' otherwise.
140 | //to do parse json output.
141 | Button b2 = (Button) rootView.findViewById(R.id.check_otp_button);
142 | b2.setOnClickListener(new View.OnClickListener() {
143 | @Override
144 | public void onClick(View view) {
145 | Log.d("I am here", "YE");
146 | //get the various required fields
147 | String otp = ((EditText) rootView.findViewById(R.id.enter_otp)).getText().toString();
148 |
149 | if(otp.length() != 6) {
150 | Toast toast = Toast.makeText(getActivity(), "Please enter a valid 6-digit OTP", Toast.LENGTH_SHORT);
151 | toast.show();
152 | ((EditText) rootView.findViewById(R.id.enter_otp)).setText("");
153 | return;
154 | }
155 | String aadhar = ((EditText) rootView.findViewById(R.id.aadhar_user_input_otp)).getText().toString();
156 | String son1 = "{\"consent\":\"Y\", \"auth-capture-request\":{\"aadhaar-id\": \""+aadhar+"\", \"modality\":\"otp\", \"otp\":\""+otp+"\", \"device-id\":\"MAC\", \"certificate-type\":\"preprod\", \"location\": { \"type\": \"gps\", \"latitude\": \"73.2\", \"longitude\": \"22.3\", \"altitude\": \"0\" } } }";
157 | TextView t1 = (TextView) rootView.findViewById(R.id.out);
158 |
159 |
160 | String[] inputArr = new String[] {
161 | aadhar,
162 | son1,
163 | };
164 |
165 | t1.setText(("Checking Password"));
166 |
167 | String res[] = new String[7];
168 | try {
169 | res = new CheckOTPTask().execute(aadhar, son1).get();
170 | } catch (InterruptedException e) {
171 | e.printStackTrace();
172 | } catch (ExecutionException e) {
173 | e.printStackTrace();
174 | }
175 |
176 | // TODO change to ==.. for dev purposes!!!! :DDDD:
177 | if (res[6] == "true" || res[6] != "true"){
178 | t1.setText("Logged IN!");
179 |
180 | try {
181 | // TODO add parse user: db here!
182 | ParseObject newUser = new ParseObject("Users");
183 | //newUser.put("objectId", "bar"/*res[0]*/);
184 | newUser.put("ID", res[0]);
185 | newUser.put("Name", res[4]);
186 | newUser.put("Address", res[5]);
187 | newUser.put("Photo", res[1]);
188 | //TODO add more fields
189 | newUser.saveInBackground();
190 | }
191 | catch (Exception e)
192 | {
193 | Log.e("Exception", "Data Invalid");
194 | }
195 |
196 | Log.d("VAL", "value in users stored");
197 |
198 |
199 | // Welcome new user!
200 | Toast toast = Toast.makeText(getActivity(), "Welcome " + res[4], Toast.LENGTH_SHORT);
201 | toast.show();
202 |
203 |
204 | SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());
205 | SharedPreferences.Editor editor = sharedPreferences.edit();
206 | editor.putBoolean("SIGNUP_DONE", true);
207 | editor.commit();
208 |
209 | // Activity calling!!
210 |
211 | Intent intent = new Intent(getActivity(), MainActivity.class);
212 | intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
213 | startActivity(intent);
214 |
215 | getActivity().finish();
216 | }
217 | else{
218 | t1.setText("Try Again!");
219 | }
220 | }
221 | });
222 |
223 | return rootView;
224 | }
225 |
226 | public static class RequestOTPTask extends AsyncTask {
227 |
228 | @Override
229 | protected String[] doInBackground(String... params) {
230 | Log.d("I am here", "YE");
231 | //get the various required fields
232 |
233 | String son1 = params[1];
234 |
235 | Boolean otp_sent = false;
236 | DefaultHttpClient client = new DefaultHttpClient();
237 | HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
238 | String result[] = new String[1];
239 | //adding ssl capabilities
240 | SchemeRegistry registry = new SchemeRegistry();
241 | SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
242 | socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
243 | registry.register(new Scheme("https", socketFactory, 443));
244 | SingleClientConnManager mgr = new SingleClientConnManager(client.getParams(), registry);
245 |
246 | DefaultHttpClient httpClient = new DefaultHttpClient(mgr, client.getParams());
247 |
248 |
249 | HttpConnectionParams.setConnectionTimeout(httpClient.getParams(), 10000); //Timeout Limit
250 |
251 |
252 |
253 | HttpResponse response;
254 |
255 | try {
256 | HttpPost post = new HttpPost("https://ac.khoslalabs.com/hackgate/hackathon/otp");
257 | StringEntity se = new StringEntity(son1);
258 | se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
259 | post.setEntity(se);
260 | response = httpClient.execute(post);
261 |
262 | /*Checking response */
263 | if(response!=null){
264 | Log.d("RESPONSE", "FOUND");
265 | ResponseHandler handler = new BasicResponseHandler();
266 | String body = handler.handleResponse(response);
267 | Log.d("stream", body);
268 | if(body.indexOf("success\":true") > 0) {
269 | otp_sent= true;
270 | result[0] = "Sent!";
271 | }
272 | if(body.indexOf("success\":false") > 0) {
273 | otp_sent= true;
274 | result[0] = "Invalid Aadhar Number!";
275 | }
276 |
277 | Log.d("AsyncTask", "done done Details Correct");
278 | }
279 |
280 | } catch(Exception e) {
281 | e.printStackTrace();
282 | }
283 | if(otp_sent==true) {Log.d("AsyncTask", "OTP succesfully sent");return result; }
284 |
285 |
286 | result[0] = "Check Connectivity.";
287 | return result;
288 |
289 | }
290 |
291 | }
292 |
293 | public static class CheckOTPTask extends AsyncTask {
294 | @Override
295 | protected String[] doInBackground(String... params) {
296 |
297 | String son1 = params[1];
298 | Boolean otp_sent = false;
299 |
300 |
301 | DefaultHttpClient client = new DefaultHttpClient();
302 | HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
303 |
304 | //adding ssl capabilities
305 | SchemeRegistry registry = new SchemeRegistry();
306 | SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
307 | socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
308 | registry.register(new Scheme("https", socketFactory, 443));
309 | SingleClientConnManager mgr = new SingleClientConnManager(client.getParams(), registry);
310 |
311 | DefaultHttpClient httpClient = new DefaultHttpClient(mgr, client.getParams());
312 |
313 |
314 | HttpConnectionParams.setConnectionTimeout(httpClient.getParams(), 10000); //Timeout Limit
315 |
316 |
317 | String[] output = new String[7];
318 | HttpResponse response;
319 |
320 | try {
321 | HttpPost post = new HttpPost("https://ac.khoslalabs.com/hackgate/hackathon/kyc/raw");
322 | StringEntity se = new StringEntity(son1);
323 | se.setContentType(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
324 | post.setEntity(se);
325 | response = httpClient.execute(post);
326 |
327 | /*Checking response */
328 | if(response!=null){
329 | Log.d("RESPONSE", "FOUND");
330 | ResponseHandler handler = new BasicResponseHandler();
331 | String body = handler.handleResponse(response);
332 | Log.d("stream", body); //this contains the fat json response
333 |
334 |
335 | if(body.indexOf("photo") > 0) {
336 | otp_sent= true;
337 | String goon = "aadhaar";
338 |
339 |
340 | JSONObject object = new JSONObject(body);
341 | String syncresponse = object.getString("kyc");
342 | JSONObject object2 = new JSONObject(syncresponse);
343 | output[0]= object2.getString("aadhaar-id");
344 | output[1]= object2.getString("photo");
345 | String poi= object2.getString("poi");
346 | JSONObject object21 = new JSONObject(poi);
347 | output[2] = object21.getString("gender");
348 | output[4] = object21.getString("name");
349 | output[3] = object21.getString("dob");
350 | String poa = object2.getString("poa");
351 | object21 = new JSONObject(poa);
352 | output[5] = "";
353 | if(object21.has("house")) {
354 | if(output[5].length()>0){output[5]= output[5] + ", ";}
355 | output[5] = output[5] + object21.getString("house");
356 | }
357 | if(object21.has("street")) {
358 | if(output[5].length()>0) {
359 | output[5]= output[5] + ", ";}
360 | output[5] = output[5] + object21.getString("street");
361 | }
362 | if(object21.has("lm")) {
363 | if(output[5].length()>0){output[5] =output[5] + ", ";}
364 | output[5] = output[5] + object21.getString("lm");
365 | }
366 | if(object21.has("loc")) {
367 | if(output[5].length()>0){output[5]= output[5] + ", ";}
368 | output[5] = output[5] + object21.getString("loc");
369 | }
370 | if(object21.has("vtc")) {
371 | if(output[5].length()>0){output[5]= output[5] + ", ";}
372 | output[5] = output[5] + object21.getString("vtc");
373 | }
374 | if(object21.has("subdist")) {
375 | if(output[5].length()>0){output[5] = output[5] + ", ";}
376 | output[5] = output[5] + object21.getString("subdist");
377 | }
378 |
379 | if(object21.has("state")) {
380 | if(output[5].length()>0){output[5]= output[5] + ", ";}
381 | output[5] = output[5] + object21.getString("state");
382 | }
383 | if(object21.has("pc")) {
384 | if(output[5].length()>0){output[5]= output[5] + ", ";}
385 | output[5] = output[5] + object21.getString("pc");
386 | }
387 |
388 | for(int i = 0 ; i<=4 ; i++){
389 | Log.d("JSON", output[i]);
390 | }
391 |
392 | }
393 | }
394 | } catch(Exception e) {
395 | e.printStackTrace();
396 | }
397 | if(otp_sent==true) {
398 | // t1.setText("OTP entered correctly.");
399 | Log.d("AsyncTask", "Otp Entered correctly");
400 | output[6] = "true";
401 | }
402 | else{
403 | // t1.setText("Incorrect OTP entered.");
404 | Log.d("AsyncTask", "Otp Entered was wrong");
405 | output[6] = "false" ;
406 | }
407 |
408 | return output;
409 | }
410 | }
411 | }
412 | }
--------------------------------------------------------------------------------