├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── drawable-hdpi
│ │ │ │ ├── logo.png
│ │ │ │ ├── placeholder.png
│ │ │ │ └── profilebg.jpg
│ │ │ ├── drawable-mdpi
│ │ │ │ ├── logo.png
│ │ │ │ └── placeholder.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ ├── logo.png
│ │ │ │ └── placeholder.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ ├── logo.png
│ │ │ │ └── placeholder.png
│ │ │ ├── drawable-xxxhdpi
│ │ │ │ ├── logo.png
│ │ │ │ └── placeholder.png
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── values-v21
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── drawable
│ │ │ │ ├── side_nav_bar.xml
│ │ │ │ ├── bgrounded.xml
│ │ │ │ ├── ic_sort_black_24dp.xml
│ │ │ │ ├── ic_info_black_24dp.xml
│ │ │ │ ├── ic_playlist_add_black_24dp.xml
│ │ │ │ ├── ic_view_list_black_24dp.xml
│ │ │ │ ├── ic_person_black_24dp.xml
│ │ │ │ ├── ic_playlist_add_check_black_24dp.xml
│ │ │ │ ├── ic_add_box_black_24dp.xml
│ │ │ │ ├── ic_security_black_24dp.xml
│ │ │ │ ├── ic_edit_black_24dp.xml
│ │ │ │ ├── ic_remove_circle_outline_black_24dp.xml
│ │ │ │ ├── ic_add_circle_outline_black_24dp.xml
│ │ │ │ ├── ic_date_range_black_24dp.xml
│ │ │ │ ├── ic_flight_land_black_24dp.xml
│ │ │ │ ├── ic_account_box_black_24dp.xml
│ │ │ │ ├── ic_airplanemode_active_black_24dp.xml
│ │ │ │ ├── ic_flight_takeoff_black_24dp.xml
│ │ │ │ ├── ic_assignment_return_black_24dp.xml
│ │ │ │ ├── ic_add_a_photo_black_24dp.xml
│ │ │ │ ├── ic_airline_seat_recline_extra_black_24dp.xml
│ │ │ │ └── ic_launcher_background.xml
│ │ │ ├── drawable-v21
│ │ │ │ ├── ic_menu_send.xml
│ │ │ │ ├── ic_menu_slideshow.xml
│ │ │ │ ├── ic_menu_gallery.xml
│ │ │ │ ├── ic_menu_manage.xml
│ │ │ │ ├── ic_menu_camera.xml
│ │ │ │ └── ic_menu_share.xml
│ │ │ ├── menu
│ │ │ │ ├── main.xml
│ │ │ │ └── activity_main_drawer.xml
│ │ │ ├── values
│ │ │ │ ├── dimens.xml
│ │ │ │ ├── drawables.xml
│ │ │ │ ├── styles.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── colors.xml
│ │ │ ├── layout
│ │ │ │ ├── activity_check_out.xml
│ │ │ │ ├── activity_launch.xml
│ │ │ │ ├── activity_main.xml
│ │ │ │ ├── app_bar_main.xml
│ │ │ │ ├── activity_itinerary.xml
│ │ │ │ ├── nav_header_main.xml
│ │ │ │ ├── custom_dialog.xml
│ │ │ │ ├── activity_about.xml
│ │ │ │ ├── activity_return_flight_list.xml
│ │ │ │ ├── activity_outbound_flight_list.xml
│ │ │ │ ├── activity_one_way_flight_list.xml
│ │ │ │ ├── custom_itinerary_view.xml
│ │ │ │ ├── activity_login.xml
│ │ │ │ ├── activity_security.xml
│ │ │ │ ├── custom_list_view.xml
│ │ │ │ ├── activity_edit_profile.xml
│ │ │ │ ├── activity_profile.xml
│ │ │ │ └── activity_register.xml
│ │ │ └── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── mentesnot
│ │ │ │ └── easytravel
│ │ │ │ ├── controllers
│ │ │ │ ├── AboutActivity.java
│ │ │ │ ├── LaunchActivity.java
│ │ │ │ ├── CheckOutActivity.java
│ │ │ │ ├── ItineraryActivity.java
│ │ │ │ ├── LoginActivity.java
│ │ │ │ ├── SecurityActivity.java
│ │ │ │ ├── OneWayFlightListActivity.java
│ │ │ │ ├── FlightDetailActivity.java
│ │ │ │ ├── ReturnFlightListActivity.java
│ │ │ │ ├── EditProfileActivity.java
│ │ │ │ ├── OutboundFlightListActivity.java
│ │ │ │ ├── CheckoutOnewayFragment.java
│ │ │ │ └── RegisterActivity.java
│ │ │ │ ├── models
│ │ │ │ ├── Itinerary.java
│ │ │ │ ├── Airline.java
│ │ │ │ ├── Account.java
│ │ │ │ ├── Client.java
│ │ │ │ └── Flight.java
│ │ │ │ └── HelperUtils
│ │ │ │ └── HelperUtilities.java
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── mentesnot
│ │ │ └── easytravel
│ │ │ └── ExampleUnitTest.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── mentesnot
│ │ └── easytravel
│ │ └── ExampleInstrumentedTest.java
├── proguard-rules.pro
└── build.gradle
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .idea
├── vcs.xml
├── modules.xml
├── runConfigurations.xml
├── gradle.xml
└── misc.xml
├── .gitignore
├── gradle.properties
├── README.md
├── LICENSE
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mentesnot/Android-Flight-Reservation-App/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mentesnot/Android-Flight-Reservation-App/HEAD/app/src/main/res/drawable-hdpi/logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mentesnot/Android-Flight-Reservation-App/HEAD/app/src/main/res/drawable-mdpi/logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mentesnot/Android-Flight-Reservation-App/HEAD/app/src/main/res/drawable-xhdpi/logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mentesnot/Android-Flight-Reservation-App/HEAD/app/src/main/res/drawable-xxhdpi/logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mentesnot/Android-Flight-Reservation-App/HEAD/app/src/main/res/drawable-xxxhdpi/logo.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/placeholder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mentesnot/Android-Flight-Reservation-App/HEAD/app/src/main/res/drawable-hdpi/placeholder.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-hdpi/profilebg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mentesnot/Android-Flight-Reservation-App/HEAD/app/src/main/res/drawable-hdpi/profilebg.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable-mdpi/placeholder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mentesnot/Android-Flight-Reservation-App/HEAD/app/src/main/res/drawable-mdpi/placeholder.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mentesnot/Android-Flight-Reservation-App/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mentesnot/Android-Flight-Reservation-App/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mentesnot/Android-Flight-Reservation-App/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mentesnot/Android-Flight-Reservation-App/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xhdpi/placeholder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mentesnot/Android-Flight-Reservation-App/HEAD/app/src/main/res/drawable-xhdpi/placeholder.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxhdpi/placeholder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mentesnot/Android-Flight-Reservation-App/HEAD/app/src/main/res/drawable-xxhdpi/placeholder.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mentesnot/Android-Flight-Reservation-App/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable-xxxhdpi/placeholder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mentesnot/Android-Flight-Reservation-App/HEAD/app/src/main/res/drawable-xxxhdpi/placeholder.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mentesnot/Android-Flight-Reservation-App/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mentesnot/Android-Flight-Reservation-App/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mentesnot/Android-Flight-Reservation-App/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mentesnot/Android-Flight-Reservation-App/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mentesnot/Android-Flight-Reservation-App/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/modules.xml
6 | /.idea/misc.xml
7 | /.idea/vcs.xml
8 | /.idea/libraries
9 | .DS_Store
10 | /build
11 | /captures
12 | .externalNativeBuild
13 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Nov 24 16:42:42 EST 2017
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-4.1-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values-v21/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/side_nav_bar.xml:
--------------------------------------------------------------------------------
1 |
3 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bgrounded.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_send.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 8dp
6 | 176dp
7 | 16dp
8 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_sort_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_info_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_playlist_add_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_view_list_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_person_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_playlist_add_check_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_slideshow.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_add_box_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_gallery.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_security_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_edit_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/test/java/com/mentesnot/easytravel/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.mentesnot.easytravel;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_manage.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_remove_circle_outline_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_add_circle_outline_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_date_range_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_flight_land_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_account_box_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_airplanemode_active_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_flight_takeoff_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_assignment_return_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_check_out.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/values/drawables.xml:
--------------------------------------------------------------------------------
1 |
2 | - @android:drawable/ic_menu_camera
3 | - @android:drawable/ic_menu_gallery
4 | - @android:drawable/ic_menu_slideshow
5 | - @android:drawable/ic_menu_manage
6 | - @android:drawable/ic_menu_share
7 | - @android:drawable/ic_menu_send
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_add_a_photo_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_camera.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mentesnot/easytravel/controllers/AboutActivity.java:
--------------------------------------------------------------------------------
1 | /*************************************************************************************************
2 | * JANUARY 8, 2018
3 | * Mentesnot Aboset
4 | * ************************************************************************************************/
5 | package com.mentesnot.easytravel.controllers;
6 |
7 | import android.support.v7.app.AppCompatActivity;
8 | import android.os.Bundle;
9 |
10 | import com.mentesnot.easytravel.R;
11 |
12 | public class AboutActivity extends AppCompatActivity {
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_about);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_share.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_launch.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
18 |
19 |
--------------------------------------------------------------------------------
/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 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Introduction
2 | The "Android-Flight-Reservation-App" is a basic android project developed for Android Mobile Development Course. It implements MVC pattern and uses SQLite database to store persistent data.
3 | The project can be used by beginner android developers who want to learn the basics of android UI development, SQLite database, and MVC.
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mentesnot/easytravel/models/Itinerary.java:
--------------------------------------------------------------------------------
1 | /*************************************************************************************************
2 | * JANUARY 8, 2018
3 | * Mentesnot Aboset
4 | * ************************************************************************************************/
5 | package com.mentesnot.easytravel.models;
6 |
7 | import java.util.Date;
8 |
9 |
10 | public class Itinerary {
11 |
12 | private int itineraryID;
13 | private Date timeStamp;
14 |
15 | public int getItineraryID() {
16 | return itineraryID;
17 | }
18 |
19 | public void setItineraryID(int itineraryID) {
20 | this.itineraryID = itineraryID;
21 | }
22 |
23 | public Date getTimeStamp() {
24 | return timeStamp;
25 | }
26 |
27 | public void setTimeStamp(Date timeStamp) {
28 | this.timeStamp = timeStamp;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_airline_seat_recline_extra_black_24dp.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/mentesnot/easytravel/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.mentesnot.easytravel;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.techprax.comp3074_project13", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mentesnot/easytravel/models/Airline.java:
--------------------------------------------------------------------------------
1 | /*************************************************************************************************
2 | * JANUARY 8, 2018
3 | * Mentesnot Aboset
4 | * ************************************************************************************************/
5 | package com.mentesnot.easytravel.models;
6 |
7 |
8 |
9 | public class Airline {
10 |
11 | private int airlineID;
12 | private String airlineName;
13 |
14 | public Airline(String airlineName) {
15 | this.airlineName = airlineName;
16 | }
17 |
18 | public int getAirlineID() {
19 | return airlineID;
20 | }
21 |
22 | public void setAirlineID(int airlineID) {
23 | this.airlineID = airlineID;
24 | }
25 |
26 | public String getAirlineName() {
27 | return airlineName;
28 | }
29 |
30 | public void setAirlineName(String airlineName) {
31 | this.airlineName = airlineName;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
16 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Mentesnot Aboset
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mentesnot/easytravel/models/Account.java:
--------------------------------------------------------------------------------
1 | /*************************************************************************************************
2 | * JANUARY 8, 2018
3 | * Mentesnot Aboset
4 | * ************************************************************************************************/
5 | package com.mentesnot.easytravel.models;
6 |
7 |
8 | public class Account {
9 | private int accountID;
10 | private String email;
11 | private String password;
12 |
13 | public Account(){
14 |
15 | }
16 |
17 | public Account(String email){
18 | this.email = email;
19 | }
20 | public int getAccountID() {
21 | return accountID;
22 | }
23 |
24 | public void setAccountID(int accountID) {
25 | this.accountID = accountID;
26 | }
27 |
28 | public String getEmail() {
29 | return email;
30 | }
31 |
32 | public void setEmail(String email) {
33 | this.email = email;
34 | }
35 |
36 | public String getPassword() {
37 | return password;
38 | }
39 |
40 | public void setPassword(String password) {
41 | this.password = password;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/app_bar_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 26
5 | defaultConfig {
6 | applicationId "com.mentesnot.easytravel"
7 | minSdkVersion 16
8 | targetSdkVersion 26
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(include: ['*.jar'], dir: 'libs')
23 | implementation 'com.android.support:appcompat-v7:26.1.0'
24 | implementation 'com.android.support:design:26.1.0'
25 | implementation 'com.android.support.constraint:constraint-layout:1.0.2'
26 | implementation 'com.android.support:support-v4:26.1.0'
27 | testImplementation 'junit:junit:4.12'
28 | androidTestImplementation 'com.android.support.test:runner:1.0.1'
29 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
30 | implementation 'de.hdodenhof:circleimageview:2.2.0'
31 | }
32 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_itinerary.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
14 |
15 |
21 |
22 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/activity_main_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
11 |
12 |
13 |
14 | -
15 |
16 |
17 |
21 |
25 |
29 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/nav_header_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
20 |
21 |
27 |
28 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/custom_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
16 |
17 |
24 |
32 |
33 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mentesnot/easytravel/controllers/LaunchActivity.java:
--------------------------------------------------------------------------------
1 | /*************************************************************************************************
2 | * JANUARY 8, 2018
3 | * Mentesnot Aboset
4 | * ************************************************************************************************/
5 | package com.mentesnot.easytravel.controllers;
6 |
7 | import android.content.Intent;
8 | import android.os.Handler;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.os.Bundle;
11 | import android.view.View;
12 | import android.view.Window;
13 | import android.view.WindowManager;
14 |
15 | import com.mentesnot.easytravel.R;
16 |
17 | public class LaunchActivity extends AppCompatActivity {
18 |
19 | private static int TIME_OUT = 2000;
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 |
25 |
26 | requestWindowFeature(Window.FEATURE_NO_TITLE);
27 | this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
28 |
29 | setContentView(R.layout.activity_launch);
30 |
31 | final View myLayout = findViewById(R.id.launch);
32 | new Handler().postDelayed(new Runnable() {
33 | @Override
34 | public void run() {
35 | Intent intent = new Intent(LaunchActivity.this, LoginActivity.class);
36 | startActivity(intent);
37 | finish();
38 | }
39 | }, TIME_OUT);
40 |
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_about.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
21 |
22 |
30 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | EasyTravel
3 |
4 | Open navigation drawer
5 | Close navigation drawer
6 |
7 | Settings
8 | sign in
9 |
10 |
11 | Email
12 | Phone
13 | Credit Card
14 | Password
15 | Confirm Password
16 | Login
17 | Register
18 |
19 |
20 | Flying from
21 | Flying to
22 | Departure date
23 | Return date
24 | Select Traveller
25 | Select class
26 | First Name
27 | Last Name
28 | My Title
29 |
30 |
31 | Hello blank fragment
32 |
33 |
34 | - Fare
35 | - Travel time
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/.idea/misc.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 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_return_flight_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
14 |
15 |
21 |
27 |
28 |
32 |
33 |
34 |
35 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mentesnot/easytravel/models/Client.java:
--------------------------------------------------------------------------------
1 | /*************************************************************************************************
2 | * JANUARY 8, 2018
3 | * Mentesnot Aboset
4 | ************************************************************************************************/
5 | package com.mentesnot.easytravel.models;
6 |
7 |
8 | import android.graphics.Bitmap;
9 |
10 | public class Client {
11 |
12 | private String clientID;
13 | private String firstName;
14 | private String lastName;
15 | private String phone;
16 | private String creditCard;
17 | private Bitmap image;
18 |
19 | public Client(){
20 |
21 | }
22 |
23 | public Client(String firstName, String lastName, String phone, String creditCard) {
24 | this.firstName = firstName;
25 | this.lastName = lastName;
26 | this.phone = phone;
27 | this.creditCard = creditCard;
28 | }
29 |
30 | public String getClientID() {
31 | return clientID;
32 | }
33 |
34 | public void setClientID(String clientID) {
35 | this.clientID = clientID;
36 | }
37 |
38 | public String getFirstName() {
39 | return firstName;
40 | }
41 |
42 | public void setFirstName(String firstName) {
43 | this.firstName = firstName;
44 | }
45 |
46 | public String getLastName() {
47 | return lastName;
48 | }
49 |
50 | public void setLastName(String lastName) {
51 | this.lastName = lastName;
52 | }
53 |
54 | public String getPhone() {
55 | return phone;
56 | }
57 |
58 | public void setPhone(String phone) {
59 | this.phone = phone;
60 | }
61 |
62 | public String getCreditCard() {
63 | return creditCard;
64 | }
65 |
66 | public void setCreditCard(String creditCard) {
67 | this.creditCard = creditCard;
68 | }
69 |
70 | public Bitmap getImage() {
71 | return image;
72 | }
73 |
74 | public void setImage(Bitmap image) {
75 | this.image = image;
76 | }
77 |
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #ffffb3
7 | #FFFFFF
8 | #EEEEEE
9 | #EEEEEE
10 | #999999
11 | #777777
12 | #00b300
13 | #00C851
14 | #007E33
15 | #2196F3
16 | #f9f9f9
17 | #03A9F4
18 | #ffbb33
19 | #FF8800
20 | #F44336
21 | #ffffff
22 | #00796B
23 | #009688
24 | #FF5722
25 | #FFA000
26 | #FFC107
27 | #689F38
28 | #8BC34A
29 | #FFC107
30 | #E64A19
31 | #FF5722
32 | #F57C00
33 | #FF9800
34 | #448AFF
35 |
40 | #c87ee7
41 | #000000aa
42 | #1A237E
43 | #283593
44 |
45 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_outbound_flight_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
15 |
16 |
22 |
28 |
29 |
37 |
38 |
39 |
40 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_one_way_flight_list.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
12 |
15 |
16 |
23 |
24 |
25 |
31 |
32 |
40 |
41 |
42 |
43 |
44 |
45 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mentesnot/easytravel/controllers/CheckOutActivity.java:
--------------------------------------------------------------------------------
1 | /*************************************************************************************************
2 | * JANUARY 8, 2018
3 | * Mentesnot Aboset
4 | * ************************************************************************************************/
5 | package com.mentesnot.easytravel.controllers;
6 |
7 | import android.content.Context;
8 | import android.content.SharedPreferences;
9 | import android.os.Bundle;
10 | import android.support.v4.app.FragmentTransaction;
11 | import android.support.v7.app.AppCompatActivity;
12 |
13 | import com.mentesnot.easytravel.R;
14 |
15 | public class CheckOutActivity extends AppCompatActivity {
16 |
17 | private SharedPreferences sharedPreferences;
18 | private int currentTab;
19 |
20 |
21 | @Override
22 | protected void onCreate(Bundle savedInstanceState) {
23 | super.onCreate(savedInstanceState);
24 | setContentView(R.layout.activity_check_out);
25 |
26 | sharedPreferences = getSharedPreferences("PREFS", Context.MODE_PRIVATE);
27 | currentTab = sharedPreferences.getInt("CURRENT_TAB", 0);
28 |
29 | //Toast.makeText(getApplicationContext(), String.valueOf(currentTab), Toast.LENGTH_SHORT).show();
30 |
31 |
32 | if (currentTab == 0) {
33 | // Create new fragment and transaction
34 | CheckoutOnewayFragment newFragment = new CheckoutOnewayFragment();
35 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
36 |
37 | // Replace whatever is in the fragment_container view with this fragment,
38 | // and add the transaction to the back stack
39 | transaction.replace(R.id.fragment_container, newFragment);
40 | transaction.addToBackStack(null);
41 |
42 | // Commit the transaction
43 | transaction.commit();
44 | } else if (currentTab == 1) {
45 | // Create new fragment and transaction
46 | CheckoutRoundFragment newFragment = new CheckoutRoundFragment();
47 | FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
48 |
49 | // Replace whatever is in the fragment_container view with this fragment,
50 | // and add the transaction to the back stack
51 | transaction.replace(R.id.fragment_container, newFragment);
52 | transaction.addToBackStack(null);
53 |
54 | // Commit the transaction
55 | transaction.commit();
56 | }
57 |
58 |
59 | }
60 |
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/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/mentesnot/easytravel/models/Flight.java:
--------------------------------------------------------------------------------
1 | /*************************************************************************************************
2 | * JANUARY 8, 2018
3 | * Mentesnot Aboset
4 | * ************************************************************************************************/
5 | package com.mentesnot.easytravel.models;
6 |
7 |
8 | import java.util.Date;
9 |
10 | public class Flight {
11 |
12 | private int flightID;
13 | private int flightNumber;
14 | private String origin;
15 | private String destination;
16 | private Date departureDate;
17 | private Date arrivalDate;
18 | private Date departureTime;
19 | private Date arrivalTime;
20 | private Double fare;
21 | private Double totalCost;
22 | private int travelTime;
23 | private String flightClass;
24 |
25 |
26 | public Flight(int flightNumber, String origin, String destination, Date departureDate,
27 | Date arrivalDate, Date departureTime, Date arrivalTime, Double fare, Double totalCost, int travelTime,
28 | String flightClass) {
29 |
30 | this.flightNumber = flightNumber;
31 | this.origin = origin;
32 | this.destination = destination;
33 | this.departureDate = departureDate;
34 | this.arrivalDate = arrivalDate;
35 | this.departureTime = departureTime;
36 | this.arrivalTime = arrivalTime;
37 | this.fare = fare;
38 | this.totalCost = totalCost;
39 | this.travelTime = travelTime;
40 | this.flightClass = flightClass;
41 | }
42 |
43 | public Flight(String origin, String destination, Date departureDate) {
44 |
45 | this.origin = origin;
46 | this.destination = destination;
47 | this.departureDate = departureDate;
48 | }
49 |
50 | public int getFlightID() {
51 | return flightID;
52 | }
53 |
54 | public void setFlightID(int flightID) {
55 | this.flightID = flightID;
56 | }
57 |
58 | public int getFlightNumber() {
59 | return flightNumber;
60 | }
61 |
62 | public void setFlightNumber(int flightNumber) {
63 | this.flightNumber = flightNumber;
64 | }
65 |
66 | public String getOrigin() {
67 | return origin;
68 | }
69 |
70 | public void setOrigin(String origin) {
71 | this.origin = origin;
72 | }
73 |
74 | public String getDestination() {
75 | return destination;
76 | }
77 |
78 | public void setDestination(String destination) {
79 | this.destination = destination;
80 | }
81 |
82 | public Date getDepartureDate() {
83 | return departureDate;
84 | }
85 |
86 | public void setDepartureDate(Date departureDate) {
87 | this.departureDate = departureDate;
88 | }
89 |
90 | public Date getArrivalDate() {
91 | return arrivalDate;
92 | }
93 |
94 | public void setArrivalDate(Date arrivalDate) {
95 | this.arrivalDate = arrivalDate;
96 | }
97 |
98 | public Date getDepartureTime() {
99 | return departureTime;
100 | }
101 |
102 | public void setDepartureTime(Date departureTime) {
103 | this.departureTime = departureTime;
104 | }
105 |
106 | public Date getArrivalTime() {
107 | return arrivalTime;
108 | }
109 |
110 | public void setArrivalTime(Date arrivalTime) {
111 | this.arrivalTime = arrivalTime;
112 | }
113 |
114 | public Double getFare() {
115 | return fare;
116 | }
117 |
118 | public void setFare(Double fare) {
119 | this.fare = fare;
120 | }
121 |
122 | public Double getTotalCost() {
123 | return totalCost;
124 | }
125 |
126 | public void setTotalCost(Double totalCost) {
127 | this.totalCost = totalCost;
128 | }
129 |
130 | public int getTravelTime() {
131 | return travelTime;
132 | }
133 |
134 | public void setTravelTime(int travelTime) {
135 | this.travelTime = travelTime;
136 | }
137 |
138 | public String getFlightClass() {
139 | return flightClass;
140 | }
141 |
142 | public void setFlightClass(String flightClass) {
143 | this.flightClass = flightClass;
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mentesnot/easytravel/controllers/ItineraryActivity.java:
--------------------------------------------------------------------------------
1 | /*************************************************************************************************
2 | * JANUARY 8, 2018
3 | * Mentesnot Aboset
4 | * ************************************************************************************************/
5 | package com.mentesnot.easytravel.controllers;
6 |
7 | import android.content.Context;
8 | import android.content.Intent;
9 | import android.database.Cursor;
10 | import android.database.sqlite.SQLiteDatabase;
11 | import android.database.sqlite.SQLiteException;
12 | import android.database.sqlite.SQLiteOpenHelper;
13 | import android.support.v7.app.AppCompatActivity;
14 | import android.os.Bundle;
15 | import android.view.View;
16 | import android.widget.AdapterView;
17 | import android.widget.CursorAdapter;
18 | import android.widget.ListView;
19 | import android.widget.SimpleCursorAdapter;
20 | import android.widget.TextView;
21 | import android.widget.Toast;
22 |
23 | import com.mentesnot.easytravel.database.DatabaseHelper;
24 | import com.mentesnot.easytravel.R;
25 |
26 | public class ItineraryActivity extends AppCompatActivity {
27 |
28 | private SQLiteOpenHelper databaseHelper;
29 | private SQLiteDatabase db;
30 | private Cursor cursor;
31 | private int flightID;
32 | private int clientID;
33 | private Intent intent;
34 | private ListView flightList;
35 | private TextView itineraryMessage;
36 |
37 | @Override
38 | protected void onCreate(Bundle savedInstanceState) {
39 | super.onCreate(savedInstanceState);
40 | setContentView(R.layout.activity_itinerary);
41 |
42 | flightList = (ListView) findViewById(R.id.itinerary);
43 |
44 | itineraryMessage = (TextView)findViewById(R.id.itineraryMessage);
45 | clientID = clientID();
46 |
47 | itineraryMessage.setVisibility(View.INVISIBLE);
48 |
49 |
50 |
51 | try{
52 | databaseHelper = new DatabaseHelper(getApplicationContext());
53 | db = databaseHelper.getReadableDatabase();
54 |
55 | cursor = DatabaseHelper.selectItinerary(db, clientID);
56 |
57 | if (cursor != null && cursor.getCount() > 0) {
58 |
59 | //Toast.makeText(getApplicationContext(), String.valueOf(cursor.getCount()), Toast.LENGTH_SHORT).show();
60 |
61 | CursorAdapter listAdapter = new SimpleCursorAdapter(getApplicationContext(),
62 | R.layout.custom_itinerary_view,
63 | cursor,
64 | new String[]{"ORIGIN", "DESTINATION", "AIRLINENAME",
65 | "FLIGHTDURATION", "FLIGHTCLASSNAME", "DEPARTUREDATE"},
66 | new int[]{R.id.txtOriginList, R.id.txtDestinationList,
67 | R.id.txtAirline, R.id.txtTravelTime, R.id.txtClass, R.id.txtDepartureDateList},
68 | 0);
69 |
70 | flightList.setAdapter(listAdapter);
71 | }else{
72 |
73 | itineraryMessage.setVisibility(View.VISIBLE);
74 | }
75 |
76 | flightList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
77 | @Override
78 | public void onItemClick(AdapterView> adapterView, View view, int position, long id) {
79 |
80 | flightID = (int) id;
81 | //Toast.makeText(getApplicationContext(), String.valueOf(flightID), Toast.LENGTH_SHORT).show();
82 |
83 | intent = new Intent(getApplicationContext(), FlightDetailActivity.class);
84 | intent.putExtra("FLIGHT_ID",flightID);
85 |
86 |
87 | startActivity(intent);
88 | }
89 | });
90 |
91 |
92 | }catch (SQLiteException e){
93 | Toast.makeText(getApplicationContext(), "Database unavailable", Toast.LENGTH_SHORT).show();
94 | }
95 |
96 | }
97 |
98 | public int clientID() {
99 | LoginActivity.sharedPreferences = getSharedPreferences(LoginActivity.MY_PREFERENCES, Context.MODE_PRIVATE);
100 | clientID = LoginActivity.sharedPreferences.getInt(LoginActivity.CLIENT_ID, 0);
101 | return clientID;
102 | }
103 |
104 |
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/custom_itinerary_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
12 |
13 |
18 |
19 |
28 |
36 |
45 |
46 |
47 |
48 |
53 |
54 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
77 |
82 |
83 |
90 |
99 |
100 |
101 |
108 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
18 |
19 |
22 |
23 |
28 |
29 |
30 |
36 |
37 |
38 |
46 |
47 |
50 |
51 |
59 |
60 |
61 |
62 |
65 |
66 |
74 |
75 |
76 |
77 |
78 |
85 |
86 |
87 |
88 |
89 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_security.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
12 |
13 |
16 |
21 |
22 |
31 |
32 |
33 |
34 |
37 |
38 |
46 |
47 |
48 |
51 |
52 |
60 |
61 |
62 |
65 |
66 |
74 |
75 |
76 |
77 |
84 |
85 |
86 |
87 |
88 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/custom_list_view.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
12 |
13 |
18 |
19 |
28 |
36 |
44 |
45 |
46 |
47 |
52 |
53 |
62 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
85 |
86 |
91 |
92 |
99 |
108 |
109 |
110 |
111 |
118 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_edit_profile.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
13 |
17 |
23 |
24 |
27 |
28 |
36 |
37 |
38 |
39 |
42 |
43 |
51 |
52 |
53 |
56 |
57 |
65 |
66 |
67 |
68 |
69 |
72 |
73 |
81 |
82 |
83 |
84 |
87 |
88 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_profile.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
14 |
18 |
27 |
28 |
29 |
30 |
37 |
38 |
47 |
48 |
54 |
55 |
56 |
57 |
58 |
67 |
68 |
76 |
77 |
78 |
84 |
85 |
91 |
97 |
103 |
109 |
110 |
111 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
--------------------------------------------------------------------------------
/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 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mentesnot/easytravel/controllers/LoginActivity.java:
--------------------------------------------------------------------------------
1 | /*************************************************************************************************
2 | * JANUARY 8, 2018
3 | * Mentesnot Aboset
4 | * ************************************************************************************************/
5 | package com.mentesnot.easytravel.controllers;
6 |
7 | import android.content.Context;
8 | import android.content.Intent;
9 | import android.content.SharedPreferences;
10 | import android.database.Cursor;
11 | import android.database.sqlite.SQLiteDatabase;
12 | import android.database.sqlite.SQLiteException;
13 | import android.database.sqlite.SQLiteOpenHelper;
14 | import android.support.v7.app.AppCompatActivity;
15 | import android.os.Bundle;
16 | import android.view.View;
17 | import android.widget.Button;
18 | import android.widget.EditText;
19 | import android.widget.TextView;
20 | import android.widget.Toast;
21 |
22 | import com.mentesnot.easytravel.database.DatabaseHelper;
23 | import com.mentesnot.easytravel.HelperUtils.HelperUtilities;
24 | import com.mentesnot.easytravel.R;
25 |
26 | public class LoginActivity extends AppCompatActivity {
27 |
28 | public static final String MY_PREFERENCES = "MY_PREFS";
29 | public static final String EMAIL = "EMAIL";
30 | public static final String CLIENT_ID = "CLIENT_ID";
31 | public static final String LOGIN_STATUS = "LOGGED_IN";
32 | public static SharedPreferences sharedPreferences;
33 | private EditText inputEmail;
34 | private EditText inputPassword;
35 | private TextView txtLoginError;
36 | private boolean isValid;
37 | private SQLiteOpenHelper databaseHelper;
38 | private SQLiteDatabase db;
39 | private Cursor cursor;
40 | private int accountID;
41 | private int clientID;
42 |
43 | @Override
44 | protected void onCreate(Bundle savedInstanceState) {
45 | super.onCreate(savedInstanceState);
46 | setContentView(R.layout.activity_login);
47 |
48 |
49 | sharedPreferences = getSharedPreferences(MY_PREFERENCES, 0);
50 | Boolean loggedIn = sharedPreferences.getBoolean(LOGIN_STATUS, false);//login status
51 |
52 | //checks the login status and redirects to the main activity
53 | if (loggedIn) {
54 | Intent intent = new Intent(getApplicationContext(), MainActivity.class);
55 | startActivity(intent);
56 | finish();
57 | return;
58 | }
59 |
60 | Button btnLogin = (Button) findViewById(R.id.btnLogin);
61 | TextView linkRegister = (TextView) findViewById(R.id.linkRegister);
62 |
63 | inputEmail = (EditText) findViewById(R.id.email);
64 | inputPassword = (EditText) findViewById(R.id.password);
65 | txtLoginError = (TextView) findViewById(R.id.txtLoginError);
66 |
67 | btnLogin.setOnClickListener(new View.OnClickListener() {
68 | @Override
69 | public void onClick(View view) {
70 | attemptLogin();
71 | }
72 | });
73 | linkRegister.setOnClickListener(new View.OnClickListener() {
74 | @Override
75 | public void onClick(View view) {
76 | Intent intent = new Intent(getApplicationContext(), RegisterActivity.class);
77 | startActivity(intent);
78 | }
79 | });
80 | }
81 |
82 | //process login
83 | public void attemptLogin() {
84 |
85 | try {
86 |
87 | databaseHelper = new DatabaseHelper(getApplicationContext());
88 | db = databaseHelper.getReadableDatabase();
89 |
90 | isValid = isValidUserInput();
91 |
92 | //filters the user input
93 |
94 | String filteredEmail = HelperUtilities.filter(inputEmail.getText().toString());
95 | String filteredPassword = HelperUtilities.filter(inputPassword.getText().toString());
96 |
97 | if (isValid) {
98 |
99 | cursor = DatabaseHelper.login(db, filteredEmail, filteredPassword);
100 |
101 | if (cursor != null && cursor.getCount() == 1) {
102 | cursor.moveToFirst();
103 |
104 | String email = cursor.getString(1);
105 | clientID = cursor.getInt(3);
106 |
107 | //Toast.makeText(getApplicationContext(), "client id " + String.valueOf(clientID), Toast.LENGTH_SHORT).show();
108 |
109 | sharedPreferences = getSharedPreferences(MY_PREFERENCES, Context.MODE_PRIVATE);
110 | SharedPreferences.Editor editor = sharedPreferences.edit();
111 |
112 | editor.putInt(CLIENT_ID, clientID);
113 | editor.putString(EMAIL, email);
114 | editor.putBoolean(LOGIN_STATUS, true);
115 |
116 | editor.commit();
117 |
118 | Intent intent = new Intent(getApplicationContext(), MainActivity.class);
119 | startActivity(intent);
120 | finish();
121 |
122 | } else {
123 |
124 | txtLoginError.setText("Invalid email or password");
125 | }
126 | }
127 |
128 | } catch (SQLiteException ex) {
129 | Toast.makeText(getApplicationContext(), "Database unavailable", Toast.LENGTH_SHORT).show();
130 | }
131 | }
132 |
133 | //validate user input
134 | public boolean isValidUserInput() {
135 | if (HelperUtilities.isEmptyOrNull(inputEmail.getText().toString())) {
136 | txtLoginError.setText("Invalid email or password");
137 | return false;
138 | }
139 | if (HelperUtilities.isEmptyOrNull(inputPassword.getText().toString())) {
140 | txtLoginError.setText("Invalid email or password");
141 | return false;
142 | }
143 | return true;
144 | }
145 |
146 |
147 | @Override
148 | protected void onDestroy() {
149 | super.onDestroy();
150 |
151 | try {
152 | if (cursor != null) {
153 | cursor.close();
154 | }
155 |
156 | if (db != null) {
157 | db.close();
158 | }
159 | } catch (Exception ex) {
160 | Toast.makeText(getApplicationContext(), "Error closing database or cursor", Toast.LENGTH_SHORT).show();
161 | }
162 |
163 | }
164 |
165 |
166 | @Override
167 | protected void onSaveInstanceState(Bundle outState) {
168 | super.onSaveInstanceState(outState);
169 | }
170 |
171 | @Override
172 | protected void onRestoreInstanceState(Bundle inState) {
173 | super.onRestoreInstanceState(inState);
174 | }
175 |
176 | }
177 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mentesnot/easytravel/controllers/SecurityActivity.java:
--------------------------------------------------------------------------------
1 | /*************************************************************************************************
2 | * JANUARY 8, 2018
3 | * Mentesnot Aboset
4 | * ************************************************************************************************/
5 | package com.mentesnot.easytravel.controllers;
6 |
7 | import android.app.AlertDialog;
8 | import android.app.Dialog;
9 | import android.content.Context;
10 | import android.content.DialogInterface;
11 | import android.content.Intent;
12 | import android.database.Cursor;
13 | import android.database.sqlite.SQLiteDatabase;
14 | import android.database.sqlite.SQLiteException;
15 | import android.database.sqlite.SQLiteOpenHelper;
16 | import android.support.v7.app.AppCompatActivity;
17 | import android.os.Bundle;
18 | import android.view.View;
19 | import android.widget.Button;
20 | import android.widget.EditText;
21 | import android.widget.TextView;
22 | import android.widget.Toast;
23 |
24 | import com.mentesnot.easytravel.database.DatabaseHelper;
25 | import com.mentesnot.easytravel.HelperUtils.HelperUtilities;
26 | import com.mentesnot.easytravel.R;
27 |
28 | public class SecurityActivity extends AppCompatActivity {
29 |
30 | private EditText oldPassword;
31 | private EditText newPassword;
32 | private EditText confirmPassword;
33 | private int clientID = 1;
34 | private TextView txtMatchError;
35 | private boolean isValid;
36 | private boolean isValidUser;
37 |
38 | private SQLiteOpenHelper hospitalDatabaseHelper;
39 | private SQLiteDatabase db;
40 | private Cursor cursor;
41 |
42 | @Override
43 | protected void onCreate(Bundle savedInstanceState) {
44 | super.onCreate(savedInstanceState);
45 | setContentView(R.layout.activity_security);
46 |
47 | oldPassword = (EditText) findViewById(R.id.txtOldPassword);
48 | newPassword = (EditText) findViewById(R.id.txtNewPassword);
49 | confirmPassword = (EditText) findViewById(R.id.txtConfirmPassword);
50 | txtMatchError = (TextView) findViewById(R.id.txtMatchError);
51 |
52 | Button btnChangePassword = (Button) findViewById(R.id.btnChangePassword);
53 |
54 |
55 | clientID = clientID();
56 |
57 | btnChangePassword.setOnClickListener(new View.OnClickListener() {
58 | @Override
59 | public void onClick(View view) {
60 | changePassword();
61 | }
62 | });
63 |
64 | }
65 |
66 | public void changePassword() {
67 | try {
68 |
69 | hospitalDatabaseHelper = new DatabaseHelper(getApplicationContext());
70 | db = hospitalDatabaseHelper.getWritableDatabase();
71 |
72 | clientID = clientID();
73 | isValid = isValidInput();
74 | isValidUser = isValidUser();
75 |
76 | if (isValid && isValidUser) {
77 | DatabaseHelper.updatePassword(db,
78 | newPassword.getText().toString(),
79 | String.valueOf(clientID));
80 |
81 | changePasswordDialog().show();
82 | }
83 | } catch (SQLiteException ex) {
84 | Toast.makeText(getApplicationContext(), "Database unavailable", Toast.LENGTH_SHORT).show();
85 | }
86 |
87 | }
88 |
89 | public Dialog changePasswordDialog() {
90 |
91 | AlertDialog.Builder builder = new AlertDialog.Builder(this);
92 | builder.setMessage("The password changed successfully! ")
93 | .setCancelable(false)
94 | .setPositiveButton("OK", new DialogInterface.OnClickListener() {
95 | public void onClick(DialogInterface dialog, int id) {
96 |
97 | Intent intent = new Intent(getApplicationContext(), MainActivity.class);
98 | startActivity(intent);
99 | }
100 | });
101 |
102 | return builder.create();
103 | }
104 |
105 |
106 | public boolean isValidInput() {
107 | isValidUser = isValidUser();
108 | if (HelperUtilities.isEmptyOrNull(oldPassword.getText().toString())) {
109 | oldPassword.setError("Please enter your password");
110 | return false;
111 | } else if (!isValidUser) {
112 | oldPassword.setError("Incorrect password");
113 | return false;
114 | } else if (HelperUtilities.isEmptyOrNull(newPassword.getText().toString())) {
115 | newPassword.setError("Please enter your new password");
116 | return false;
117 | } else if (HelperUtilities.isEmptyOrNull(confirmPassword.getText().toString())) {
118 | confirmPassword.setError("Please confirm your new password");
119 | return false;
120 | } else if (HelperUtilities.isShortPassword(newPassword.getText().toString())) {
121 | newPassword.setError("Your password must have at least 6 characters.");
122 | return false;
123 | } else if (!newPassword.getText().toString().equals(confirmPassword.getText().toString())) {
124 | txtMatchError.setText("The password doesn't match");
125 | return false;
126 | }
127 | return true;
128 | }
129 |
130 | public boolean isValidUser() {
131 | try {
132 |
133 | hospitalDatabaseHelper = new DatabaseHelper(getApplicationContext());
134 | db = hospitalDatabaseHelper.getReadableDatabase();
135 |
136 | cursor = DatabaseHelper.selectClientPassword(db, clientID);
137 |
138 |
139 | if (cursor.moveToFirst()) {
140 |
141 | String password = cursor.getString(0);
142 |
143 | if (!oldPassword.getText().toString().equals(password)) {
144 | return false;
145 | } else {
146 | return true;
147 | }
148 |
149 | }
150 |
151 |
152 | } catch (SQLiteException ex) {
153 | Toast.makeText(getApplicationContext(), "Database unavailable", Toast.LENGTH_SHORT).show();
154 | return false;
155 | }
156 | return true;
157 |
158 | }
159 |
160 |
161 | public int clientID() {
162 | LoginActivity.sharedPreferences = getSharedPreferences(LoginActivity.MY_PREFERENCES, Context.MODE_PRIVATE);
163 | clientID = LoginActivity.sharedPreferences.getInt(LoginActivity.CLIENT_ID, 0);
164 | return clientID;
165 | }
166 |
167 | @Override
168 | protected void onDestroy() {
169 | super.onDestroy();
170 | try {
171 | if(cursor != null){
172 | cursor.close();
173 | }
174 | if(db != null){
175 | db.close();
176 | }
177 | } catch (Exception ex) {
178 | Toast.makeText(getApplicationContext(), "Error closing database or cursor", Toast.LENGTH_SHORT).show();
179 | }
180 | }
181 |
182 | }
183 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
29 |
33 |
34 |
35 |
38 |
39 |
44 |
45 |
46 |
49 |
50 |
54 |
55 |
56 |
59 |
60 |
64 |
65 |
66 |
69 |
70 |
74 |
78 |
82 |
83 |
84 |
87 |
88 |
92 |
93 |
94 |
97 |
98 |
102 |
103 |
104 |
107 |
108 |
112 |
113 |
114 |
117 |
118 |
122 |
123 |
124 |
127 |
128 |
132 |
133 |
134 |
137 |
138 |
139 |
140 |
141 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_register.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
17 |
18 |
21 |
26 |
32 |
33 |
36 |
37 |
45 |
46 |
47 |
48 |
51 |
52 |
60 |
61 |
62 |
65 |
66 |
74 |
75 |
76 |
79 |
80 |
88 |
89 |
90 |
91 |
94 |
95 |
103 |
104 |
105 |
106 |
107 |
110 |
111 |
119 |
120 |
121 |
122 |
125 |
126 |
134 |
135 |
136 |
137 |
138 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mentesnot/easytravel/controllers/OneWayFlightListActivity.java:
--------------------------------------------------------------------------------
1 | /*************************************************************************************************
2 | * JANUARY 8, 2018
3 | * Mentesnot Aboset
4 | * ************************************************************************************************/
5 | package com.mentesnot.easytravel.controllers;
6 |
7 | import android.app.AlertDialog;
8 | import android.app.Dialog;
9 | import android.content.Context;
10 | import android.content.DialogInterface;
11 | import android.content.Intent;
12 | import android.content.SharedPreferences;
13 | import android.database.Cursor;
14 | import android.database.sqlite.SQLiteDatabase;
15 | import android.database.sqlite.SQLiteException;
16 | import android.database.sqlite.SQLiteOpenHelper;
17 | import android.support.v7.app.AppCompatActivity;
18 | import android.os.Bundle;
19 | import android.view.View;
20 | import android.widget.AdapterView;
21 | import android.widget.Button;
22 | import android.widget.CursorAdapter;
23 | import android.widget.ListView;
24 | import android.widget.SimpleCursorAdapter;
25 | import android.widget.TextView;
26 | import android.widget.Toast;
27 |
28 | import com.mentesnot.easytravel.database.DatabaseHelper;
29 | import com.mentesnot.easytravel.HelperUtils.HelperUtilities;
30 | import com.mentesnot.easytravel.R;
31 |
32 | public class OneWayFlightListActivity extends AppCompatActivity {
33 |
34 | private SharedPreferences sharedPreferences;
35 | private SQLiteOpenHelper databaseHelper;
36 | private SQLiteDatabase db;
37 | private Cursor cursor;
38 | private String origin;
39 | private String destination;
40 | private String departureDate;
41 | private String returnDate;
42 | private String flightClass;
43 | private TextView txtMessage;
44 | private ListView oneWayFlightList;
45 | private Bundle bundle;
46 | private int currentTab;
47 | private int oneWayFightID;
48 | private int outboundFlightID;
49 | private int returnFlightID;
50 | private Intent intent;
51 | private android.support.v7.app.ActionBar actionBar;
52 | //custom dialog view
53 | private View dialogLayout;
54 | private TextView txtSortBy;
55 | private ListView sortList;
56 | private Button btnSort;
57 | private int sortByID = 100;
58 | private TextView flightNotFound;
59 |
60 | @Override
61 | protected void onCreate(Bundle savedInstanceState) {
62 | super.onCreate(savedInstanceState);
63 | setContentView(R.layout.activity_one_way_flight_list);
64 |
65 | actionBar = getSupportActionBar();
66 |
67 | sharedPreferences = getSharedPreferences("PREFS", Context.MODE_PRIVATE);
68 | currentTab = sharedPreferences.getInt("CURRENT_TAB", 0);
69 | origin = sharedPreferences.getString("ORIGIN", "");
70 | destination = sharedPreferences.getString("DESTINATION", "");
71 | departureDate = sharedPreferences.getString("DEPARTURE_DATE", "");
72 | returnDate = sharedPreferences.getString("RETURN_DATE", "");
73 | flightClass = sharedPreferences.getString("FLIGHT_CLASS", "");
74 | sortByID = sharedPreferences.getInt("ONEWAY_SORT_ID", 100);
75 |
76 | //Toast.makeText(getApplicationContext(), flightClass, Toast.LENGTH_SHORT).show();
77 |
78 | btnSort = (Button) findViewById(R.id.btnSort);
79 |
80 | flightNotFound = (TextView)findViewById(R.id.txtOneWayFlightNotFound);
81 |
82 | flightNotFound.setVisibility(View.INVISIBLE);
83 |
84 |
85 |
86 | btnSort.setOnClickListener(new View.OnClickListener() {
87 | @Override
88 | public void onClick(View view) {
89 | sortDialog().show();
90 | }
91 | });
92 |
93 | oneWayFlightList = (ListView) findViewById(R.id.onewayFlightList);
94 |
95 | searchOneWayFlight(sortByID);
96 |
97 | }
98 |
99 | public void searchOneWayFlight(int sortByID) {
100 |
101 | try {
102 | databaseHelper = new DatabaseHelper(getApplicationContext());
103 | db = databaseHelper.getReadableDatabase();
104 |
105 | if (sortByID == 0) {
106 | cursor = DatabaseHelper.selectFlight(db, origin, destination,
107 | departureDate, flightClass, "FARE");
108 | } else if (sortByID == 1) {
109 | cursor = DatabaseHelper.selectFlight(db, origin, destination,
110 | departureDate, flightClass, "FLIGHTDURATION");
111 | } else {
112 | cursor = DatabaseHelper.selectFlight(db, origin, destination,
113 | departureDate, flightClass);
114 | }
115 |
116 |
117 |
118 | if (cursor != null && cursor.getCount() > 0) {
119 |
120 | actionBar.setTitle("Select one way flight");
121 | actionBar.setSubtitle(HelperUtilities.capitalize(origin) + " -> " + HelperUtilities.capitalize(destination));
122 |
123 | CursorAdapter listAdapter = new SimpleCursorAdapter(getApplicationContext(),
124 | R.layout.custom_list_view,
125 | cursor,
126 | new String[]{"DEPARTURETIME", "ARRIVALTIME", "FARE", "AIRLINENAME",
127 | "FLIGHTDURATION", "FLIGHTCLASSNAME"},
128 | new int[]{R.id.txtDepartureTime, R.id.txtArrivalTime, R.id.txtFare,
129 | R.id.txtAirline, R.id.txtTravelTime, R.id.txtClass},
130 | 0);
131 |
132 | oneWayFlightList.setAdapter(listAdapter);
133 |
134 | } else {
135 |
136 | flightNotFound.setVisibility(View.VISIBLE);
137 | btnSort.setVisibility(View.INVISIBLE);
138 | }
139 |
140 | oneWayFlightList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
141 | @Override
142 | public void onItemClick(AdapterView> adapterView, View view, int position, long id) {
143 |
144 | oneWayFightID = (int) id;
145 | intent = new Intent(getApplicationContext(), CheckOutActivity.class);
146 |
147 | sharedPreferences = getSharedPreferences("PREFS", Context.MODE_PRIVATE);
148 | SharedPreferences.Editor editor = sharedPreferences.edit();
149 | editor.remove("ONEWAY_FLIGHT_ID");
150 | editor.putInt("ONEWAY_FLIGHT_ID", oneWayFightID);
151 |
152 | editor.commit();
153 |
154 | startActivity(intent);
155 | finish();
156 | }
157 | });
158 |
159 | } catch (SQLiteException e) {
160 | Toast.makeText(getApplicationContext(), "Database error", Toast.LENGTH_SHORT).show();
161 | }
162 | }
163 |
164 | //sort by dialog (one way)
165 | public Dialog sortDialog() {
166 |
167 | final AlertDialog.Builder builder = new AlertDialog.Builder(this);
168 | builder.setTitle("Sort by")
169 | .setItems(R.array.sort, new DialogInterface.OnClickListener() {
170 | @Override
171 | public void onClick(DialogInterface dialogInterface, int id) {
172 |
173 | sharedPreferences = getSharedPreferences("PREFS", Context.MODE_PRIVATE);
174 | SharedPreferences.Editor editor = sharedPreferences.edit();
175 | editor.remove("ONEWAY_SORT_ID");
176 | editor.putInt("ONEWAY_SORT_ID", id);
177 | editor.commit();
178 |
179 | intent = new Intent(getApplicationContext(), OneWayFlightListActivity.class);
180 | startActivity(intent);
181 |
182 |
183 | }
184 | });
185 |
186 | return builder.create();
187 | }
188 |
189 |
190 | }
191 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mentesnot/easytravel/controllers/FlightDetailActivity.java:
--------------------------------------------------------------------------------
1 | /*************************************************************************************************
2 | * JANUARY 8, 2018
3 | * Mentesnot Aboset
4 | * ************************************************************************************************/
5 | package com.mentesnot.easytravel.controllers;
6 |
7 | import android.app.AlertDialog;
8 | import android.app.Dialog;
9 | import android.content.Context;
10 | import android.content.DialogInterface;
11 | import android.content.Intent;
12 | import android.database.Cursor;
13 | import android.database.sqlite.SQLiteDatabase;
14 | import android.database.sqlite.SQLiteException;
15 | import android.database.sqlite.SQLiteOpenHelper;
16 | import android.support.v7.app.AppCompatActivity;
17 | import android.os.Bundle;
18 | import android.view.View;
19 | import android.widget.Button;
20 | import android.widget.TextView;
21 |
22 | import com.mentesnot.easytravel.database.DatabaseHelper;
23 | import com.mentesnot.easytravel.HelperUtils.HelperUtilities;
24 | import com.mentesnot.easytravel.R;
25 |
26 | public class FlightDetailActivity extends AppCompatActivity {
27 |
28 | private SQLiteOpenHelper databaseHelper;
29 | private SQLiteDatabase db;
30 | private Cursor cursor;
31 | private int flightID;
32 |
33 | private TextView flightNo;
34 | private TextView origin;
35 | private TextView destination;
36 | private TextView departureDate;
37 | private TextView arrivalDate;
38 | private TextView departureTime;
39 | private TextView arrivalTime;
40 | private TextView flightDuration;
41 | private TextView flightClass;
42 | private TextView airline;
43 | private TextView fare;
44 | private TextView totalFare;
45 | private Button btnCancelFlight;
46 | private Intent intent;
47 | private int itineraryID;
48 | private TextView traveller;
49 | private int numTraveller;
50 | private double singleFare;
51 | private double totalCost;
52 | private TextView fName;
53 | private TextView cCard;
54 | private TextView timeStamp;
55 | private int clientID;
56 |
57 | @Override
58 | protected void onCreate(Bundle savedInstanceState) {
59 | super.onCreate(savedInstanceState);
60 | setContentView(R.layout.activity_flight_detail);
61 |
62 | intent = getIntent();
63 | flightID = intent.getIntExtra("FLIGHT_ID",0);
64 | clientID =clientID();
65 |
66 | fName = (TextView)findViewById(R.id.txtFName);
67 | cCard = (TextView)findViewById(R.id.txtCCard);
68 | timeStamp = (TextView)findViewById(R.id.txtTimeStamp);
69 |
70 | airline = (TextView) findViewById(R.id.txtAirlineDetail);
71 | flightNo = (TextView) findViewById(R.id.txtFlightNumberDetail);
72 | origin = (TextView) findViewById(R.id.txtOriginDetail);
73 | destination = (TextView) findViewById(R.id.txtDestinationDetail);
74 | departureDate = (TextView) findViewById(R.id.txtDepartureDateDetail);
75 | arrivalDate = (TextView) findViewById(R.id.txtArrivalDateDetail);
76 | departureTime = (TextView) findViewById(R.id.txtDepartureTimeDetail);
77 | arrivalTime = (TextView) findViewById(R.id.txtArrivalTimeDetail);
78 | flightDuration = (TextView) findViewById(R.id.txtFlightDurationDetail);
79 | flightClass = (TextView) findViewById(R.id.txtFlightClassDetail);
80 | traveller = (TextView)findViewById(R.id.txtTravellerDetail);
81 | fare = (TextView) findViewById(R.id.txtFareDetail);
82 | totalFare = (TextView) findViewById(R.id.txtTotalFareDetail);
83 |
84 | displaySelectedFlightInfo(flightID);
85 |
86 | totalCost = HelperUtilities.calculateTotalFare(singleFare, numTraveller);
87 | traveller.setText(String.valueOf(numTraveller));
88 | fare.setText("$" + singleFare);
89 | totalFare.setText("$" + totalCost);
90 |
91 |
92 |
93 | btnCancelFlight = (Button) findViewById(R.id.btnCancelFlight) ;
94 |
95 | btnCancelFlight.setOnClickListener(new View.OnClickListener() {
96 | @Override
97 | public void onClick(View view) {
98 |
99 | cancelFlightAlert().show();
100 |
101 | }
102 | });
103 | }
104 |
105 | public void displaySelectedFlightInfo(int id) {
106 | try {
107 | databaseHelper = new DatabaseHelper(getApplicationContext());
108 | db = databaseHelper.getReadableDatabase();
109 |
110 | cursor = DatabaseHelper.getItineraryDetail(db, id);
111 |
112 | if (cursor != null && cursor.getCount() > 0) {
113 | cursor.moveToFirst();
114 | flightNo.setText(String.valueOf(cursor.getInt(1)));
115 | origin.setText(cursor.getString(2));
116 | destination.setText(cursor.getString(3));
117 | departureDate.setText(cursor.getString(4));
118 | arrivalDate.setText(cursor.getString(5));
119 | departureTime.setText(cursor.getString(6));
120 | arrivalTime.setText(cursor.getString(7));
121 | flightDuration.setText(cursor.getString(8) + "h");
122 | singleFare = cursor.getDouble(9);
123 | airline.setText(cursor.getString(10));
124 | flightClass.setText(cursor.getString(12));
125 | numTraveller = cursor.getInt(13);
126 | timeStamp.setText(cursor.getString(14));
127 | }
128 |
129 | cursor = DatabaseHelper.selectClientJoinAccount(db, clientID);
130 | if(cursor != null && cursor.getCount() == 1){
131 | cursor.moveToFirst();
132 |
133 | fName.setText(HelperUtilities.capitalize(cursor.getString(0)) + " " + HelperUtilities.capitalize(cursor.getString(1)));
134 | cCard.setText(HelperUtilities.maskCardNumber(cursor.getString(3)));
135 | }
136 |
137 | } catch (SQLiteException ex) {
138 |
139 | }
140 | }
141 |
142 | public void cancelFlight(){
143 | try{
144 |
145 | databaseHelper = new DatabaseHelper(getApplicationContext());
146 | db = databaseHelper.getWritableDatabase();
147 |
148 | clientID =clientID();
149 |
150 | cursor = DatabaseHelper.selectItinerary(db, flightID, clientID);
151 |
152 | if (cursor != null && cursor.getCount() > 0) {
153 | cursor.moveToFirst();
154 | itineraryID = cursor.getInt(0);
155 |
156 | // Toast.makeText(getApplicationContext(), String.valueOf(itineraryID), Toast.LENGTH_SHORT).show();
157 | }
158 |
159 | DatabaseHelper.deleteItinerary(db, itineraryID);
160 |
161 | }catch(SQLiteException e){
162 |
163 | }
164 | }
165 |
166 | public Dialog cancelFlightAlert() {
167 |
168 | AlertDialog.Builder builder = new AlertDialog.Builder(this);
169 | builder.setMessage("Are you sure you want to cancel your flight? ")
170 | .setCancelable(false)
171 | .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
172 | public void onClick(DialogInterface dialog, int id) {
173 | cancelFlight();
174 | Intent intent = new Intent(getApplicationContext(), ItineraryActivity.class);
175 | startActivity(intent);
176 | }
177 | })
178 | .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
179 | @Override
180 | public void onClick(DialogInterface dialogInterface, int i) {
181 |
182 |
183 |
184 | }
185 | });
186 |
187 | return builder.create();
188 | }
189 |
190 | public int clientID() {
191 | LoginActivity.sharedPreferences = getSharedPreferences(LoginActivity.MY_PREFERENCES, Context.MODE_PRIVATE);
192 | clientID = LoginActivity.sharedPreferences.getInt(LoginActivity.CLIENT_ID, 0);
193 | return clientID;
194 | }
195 |
196 |
197 |
198 |
199 | }
200 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mentesnot/easytravel/controllers/ReturnFlightListActivity.java:
--------------------------------------------------------------------------------
1 | /*************************************************************************************************
2 | * JANUARY 8, 2018
3 | * Mentesnot Aboset
4 | * ************************************************************************************************/
5 | package com.mentesnot.easytravel.controllers;
6 |
7 | import android.app.AlertDialog;
8 | import android.app.Dialog;
9 | import android.content.Context;
10 | import android.content.DialogInterface;
11 | import android.content.Intent;
12 | import android.content.SharedPreferences;
13 | import android.database.Cursor;
14 | import android.database.sqlite.SQLiteDatabase;
15 | import android.database.sqlite.SQLiteException;
16 | import android.database.sqlite.SQLiteOpenHelper;
17 | import android.support.v7.app.AppCompatActivity;
18 | import android.os.Bundle;
19 | import android.view.View;
20 | import android.widget.AdapterView;
21 | import android.widget.Button;
22 | import android.widget.CursorAdapter;
23 | import android.widget.ListView;
24 | import android.widget.SimpleCursorAdapter;
25 | import android.widget.TextView;
26 | import android.widget.Toast;
27 |
28 | import com.mentesnot.easytravel.database.DatabaseHelper;
29 | import com.mentesnot.easytravel.HelperUtils.HelperUtilities;
30 | import com.mentesnot.easytravel.R;
31 |
32 | public class ReturnFlightListActivity extends AppCompatActivity {
33 |
34 | private SharedPreferences sharedPreferences;
35 | private SQLiteOpenHelper databaseHelper;
36 | private SQLiteDatabase db;
37 | private Cursor cursor;
38 | private String origin;
39 | private String destination;
40 | private String departureDate;
41 | private String returnDate;
42 | private String flightClass;
43 | private TextView txtMessage;
44 | private ListView returnFlightList;
45 | private Bundle bundle;
46 | private int currentTab;
47 | private int oneWayFightID;
48 | private int outboundFlightID;
49 | private int returnFlightID;
50 | private Intent intent;
51 | private android.support.v7.app.ActionBar actionBar;
52 | private int sortByID;
53 | private Button btnSort;
54 |
55 | @Override
56 | protected void onCreate(Bundle savedInstanceState) {
57 | super.onCreate(savedInstanceState);
58 | setContentView(R.layout.activity_return_flight_list);
59 |
60 | actionBar = getSupportActionBar();
61 |
62 | sharedPreferences = getSharedPreferences("PREFS", Context.MODE_PRIVATE);
63 | currentTab = sharedPreferences.getInt("CURRENT_TAB", 0);
64 | origin = sharedPreferences.getString("ORIGIN", "");
65 | destination = sharedPreferences.getString("DESTINATION", "");
66 | departureDate = sharedPreferences.getString("DEPARTURE_DATE", "");
67 | returnDate = sharedPreferences.getString("RETURN_DATE", "");
68 | flightClass = sharedPreferences.getString("FLIGHT_CLASS", "");
69 | sortByID = sharedPreferences.getInt("RETURN_SORT_ID", 100);
70 |
71 | returnFlightList = (ListView) findViewById(R.id.returnFlightList);
72 |
73 | btnSort = (Button) findViewById(R.id.btnReturnSort);
74 |
75 |
76 | btnSort.setOnClickListener(new View.OnClickListener() {
77 | @Override
78 | public void onClick(View view) {
79 | sortDialog().show();
80 | }
81 | });
82 |
83 |
84 | searchReturnFlight();
85 | }
86 |
87 | public void searchReturnFlight() {
88 | try {
89 | databaseHelper = new DatabaseHelper(getApplicationContext());
90 | db = databaseHelper.getReadableDatabase();
91 |
92 | //return flight
93 | if (sortByID == 0) {
94 | cursor = DatabaseHelper.selectFlight(db, destination, origin,
95 | returnDate, flightClass, "FARE");
96 | } else if (sortByID == 1) {
97 | cursor = DatabaseHelper.selectFlight(db, destination, origin,
98 | returnDate, flightClass, "FLIGHTDURATION");
99 | } else {
100 | cursor = DatabaseHelper.selectFlight(db, destination, origin,
101 | returnDate, flightClass);
102 | }
103 |
104 | if (cursor != null && cursor.getCount() > 0) {
105 | cursor.moveToFirst();
106 |
107 | actionBar.setTitle("Select return flight");
108 | actionBar.setSubtitle(HelperUtilities.capitalize(destination) + " -> " + HelperUtilities.capitalize(origin));
109 |
110 | CursorAdapter listAdapter = new SimpleCursorAdapter(getApplicationContext(),
111 | R.layout.custom_list_view,
112 | cursor,
113 | new String[]{"DEPARTURETIME", "ARRIVALTIME", "FARE", "AIRLINENAME", "FLIGHTDURATION", "FLIGHTCLASSNAME"},
114 | new int[]{R.id.txtDepartureTime, R.id.txtArrivalTime, R.id.txtFare, R.id.txtAirline, R.id.txtTravelTime, R.id.txtClass},//map the contents of NAME col to text in ListView
115 | 0);
116 |
117 | returnFlightList.setAdapter(listAdapter);
118 |
119 |
120 | } else {
121 | flightNotFoundDialog().show();
122 | }
123 |
124 | returnFlightList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
125 | @Override
126 | public void onItemClick(AdapterView> adapterView, View view, int position, long id) {
127 |
128 | returnFlightID = (int) id;
129 |
130 | intent = new Intent(getApplicationContext(), CheckOutActivity.class);
131 |
132 | sharedPreferences = getSharedPreferences("PREFS", Context.MODE_PRIVATE);
133 | SharedPreferences.Editor editor = sharedPreferences.edit();
134 | editor.remove("RETURN_FLIGHT_ID");
135 | editor.putInt("RETURN_FLIGHT_ID", returnFlightID);
136 |
137 | editor.commit();
138 |
139 | startActivity(intent);
140 | finish();
141 | }
142 | });
143 |
144 |
145 | } catch (SQLiteException e) {
146 | Toast.makeText(getApplicationContext(), "Database error", Toast.LENGTH_SHORT).show();
147 | }
148 |
149 | }
150 |
151 | public Dialog flightNotFoundDialog() {
152 |
153 | AlertDialog.Builder builder = new AlertDialog.Builder(this);
154 | builder.setMessage("The specified return flight is not available. Please try again later.")
155 | .setCancelable(false)
156 | .setPositiveButton("OK", new DialogInterface.OnClickListener() {
157 | public void onClick(DialogInterface dialog, int id) {
158 |
159 | Intent intent = new Intent(getApplicationContext(), MainActivity.class);
160 | startActivity(intent);
161 | finish();
162 | }
163 | });
164 |
165 | return builder.create();
166 | }
167 |
168 | //sort by dialog (return)
169 | public Dialog sortDialog() {
170 |
171 | final AlertDialog.Builder builder = new AlertDialog.Builder(this);
172 | builder.setTitle("Sort by")
173 | .setItems(R.array.sort, new DialogInterface.OnClickListener() {
174 | @Override
175 | public void onClick(DialogInterface dialogInterface, int id) {
176 |
177 | sharedPreferences = getSharedPreferences("PREFS", Context.MODE_PRIVATE);
178 | SharedPreferences.Editor editor = sharedPreferences.edit();
179 | editor.remove("RETURN_SORT_ID");
180 | editor.putInt("RETURN_SORT_ID", id);
181 | editor.commit();
182 |
183 | intent = new Intent(getApplicationContext(), ReturnFlightListActivity.class);
184 | startActivity(intent);
185 | }
186 | });
187 |
188 | return builder.create();
189 | }
190 |
191 | }
192 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mentesnot/easytravel/controllers/EditProfileActivity.java:
--------------------------------------------------------------------------------
1 | /*************************************************************************************************
2 | * JANUARY 8, 2018
3 | * Mentesnot Aboset
4 | * ************************************************************************************************/
5 | package com.mentesnot.easytravel.controllers;
6 |
7 | import android.app.AlertDialog;
8 | import android.app.Dialog;
9 | import android.content.Context;
10 | import android.content.DialogInterface;
11 | import android.content.Intent;
12 | import android.database.Cursor;
13 | import android.database.sqlite.SQLiteDatabase;
14 | import android.database.sqlite.SQLiteException;
15 | import android.support.v7.app.AppCompatActivity;
16 | import android.os.Bundle;
17 | import android.view.View;
18 | import android.widget.Button;
19 | import android.widget.EditText;
20 | import android.widget.Toast;
21 |
22 | import com.mentesnot.easytravel.database.DatabaseHelper;
23 | import com.mentesnot.easytravel.HelperUtils.HelperUtilities;
24 | import com.mentesnot.easytravel.R;
25 |
26 | public class EditProfileActivity extends AppCompatActivity {
27 |
28 | private Button btnUpdateProfile;
29 | private EditText clientFirstName;
30 | private EditText clientLastName;
31 | private EditText clientEmail;
32 | private EditText clientPhone;
33 | private EditText clientCreditCard;
34 | private int clientID;
35 | private DatabaseHelper databaseHelper;
36 | private SQLiteDatabase db;
37 | private Cursor cursor;
38 | private boolean isValid;
39 |
40 | @Override
41 | protected void onCreate(Bundle savedInstanceState) {
42 | super.onCreate(savedInstanceState);
43 | setContentView(R.layout.activity_edit_profile);
44 |
45 | btnUpdateProfile = (Button) findViewById(R.id.btnSaveProfile);
46 |
47 | clientFirstName = (EditText) findViewById(R.id.txtFirstNameEdit);
48 | clientLastName = (EditText) findViewById(R.id.txtLastNameEdit);
49 | clientEmail = (EditText) findViewById(R.id.txtEmailEdit);
50 | clientPhone = (EditText) findViewById(R.id.txtPhoneEdit);
51 | clientCreditCard = (EditText) findViewById(R.id.txtCreditCardEdit);
52 |
53 |
54 | loadProfileInfo();
55 |
56 | btnUpdateProfile.setOnClickListener(new View.OnClickListener() {
57 | @Override
58 | public void onClick(View view) {
59 | updateProfile();
60 |
61 | }
62 | });
63 |
64 | }
65 |
66 | public void loadProfileInfo() {
67 |
68 | try {
69 |
70 | clientID = clientID();
71 |
72 | databaseHelper = new DatabaseHelper(getApplicationContext());
73 | db = databaseHelper.getWritableDatabase();
74 |
75 |
76 | cursor = DatabaseHelper.selectClientJoinAccount(db, clientID);
77 |
78 |
79 | if (cursor.moveToFirst()) {
80 |
81 | String firstName = cursor.getString(0);
82 | String lastName = cursor.getString(1);
83 | String phone = cursor.getString(2);
84 | String creditCard = cursor.getString(3);
85 | String email = cursor.getString(4);
86 |
87 | clientFirstName.setText(firstName);
88 | clientLastName.setText(lastName);
89 | clientEmail.setText(email);
90 | clientPhone.setText(phone);
91 | clientCreditCard.setText(creditCard);
92 |
93 |
94 | }
95 | } catch (SQLiteException ex) {
96 | Toast.makeText(getApplicationContext(), "Database unavailable", Toast.LENGTH_SHORT).show();
97 | }
98 |
99 | }
100 |
101 | public void updateProfile() {
102 | try {
103 |
104 | databaseHelper = new DatabaseHelper(getApplicationContext());
105 | db = databaseHelper.getWritableDatabase();
106 |
107 | clientID = clientID();
108 | isValid = isValidUserInput();
109 |
110 | if (isValid) {
111 | DatabaseHelper.updateClient(db,
112 | clientFirstName.getText().toString(),
113 | clientLastName.getText().toString(),
114 | clientPhone.getText().toString(),
115 | clientCreditCard.getText().toString(),
116 | clientID
117 | );
118 |
119 | DatabaseHelper.updateAccount(db,
120 | clientEmail.getText().toString(),
121 | clientID);
122 |
123 |
124 | updateProfileDialog().show();
125 | }
126 | } catch (SQLiteException ex) {
127 | Toast.makeText(getApplicationContext(), "Database unavailable", Toast.LENGTH_SHORT).show();
128 | }
129 |
130 | }
131 |
132 | public int clientID() {
133 | LoginActivity.sharedPreferences = getSharedPreferences(LoginActivity.MY_PREFERENCES, Context.MODE_PRIVATE);
134 | clientID = LoginActivity.sharedPreferences.getInt(LoginActivity.CLIENT_ID, 0);
135 | return clientID;
136 | }
137 |
138 | public Dialog updateProfileDialog() {
139 |
140 | AlertDialog.Builder builder = new AlertDialog.Builder(this);
141 | builder.setMessage("The profile updated successfully! ")
142 | .setCancelable(false)
143 | .setPositiveButton("OK", new DialogInterface.OnClickListener() {
144 | public void onClick(DialogInterface dialog, int id) {
145 |
146 | Intent intent = new Intent(getApplicationContext(), ProfileActivity.class);
147 | startActivity(intent);
148 | }
149 | });
150 |
151 | return builder.create();
152 | }
153 |
154 | public boolean isValidUserInput() {
155 | if (HelperUtilities.isEmptyOrNull(clientFirstName.getText().toString())) {
156 | clientFirstName.setError("Please enter your first name");
157 | return false;
158 | } else if (!HelperUtilities.isString(clientFirstName.getText().toString())) {
159 | clientFirstName.setError("Please enter a valid first name");
160 | return false;
161 | }
162 |
163 | if (HelperUtilities.isEmptyOrNull(clientLastName.getText().toString())) {
164 | clientLastName.setError("Please enter your last name");
165 | return false;
166 | } else if (!HelperUtilities.isString(clientLastName.getText().toString())) {
167 | clientLastName.setError("Please enter a valid last name");
168 | return false;
169 | }
170 |
171 | if (HelperUtilities.isEmptyOrNull(clientEmail.getText().toString())) {
172 | clientEmail.setError("Please enter your email");
173 | return false;
174 | } else if (!HelperUtilities.isValidEmail(clientEmail.getText().toString())) {
175 | clientEmail.setError("Please enter a valid email");
176 | return false;
177 | }
178 |
179 | if (HelperUtilities.isEmptyOrNull(clientPhone.getText().toString())) {
180 | clientPhone.setError("Please enter your phone");
181 | return false;
182 | } else if (!HelperUtilities.isValidPhone(clientPhone.getText().toString())) {
183 | clientPhone.setError("Please enter a valid phone");
184 | return false;
185 | }
186 |
187 | if (HelperUtilities.isEmptyOrNull(clientCreditCard.getText().toString())) {
188 | clientCreditCard.setError("Please enter your credit card number");
189 | return false;
190 | } else if (!HelperUtilities.isValidCreditCard(clientCreditCard.getText().toString())) {
191 | clientCreditCard.setError("Please enter a valid credit card number");
192 | return false;
193 | }
194 |
195 |
196 | return true;
197 |
198 | }
199 |
200 | @Override
201 | protected void onDestroy() {
202 | super.onDestroy();
203 | try {
204 | cursor.close();
205 | db.close();
206 | } catch (Exception ex) {
207 | Toast.makeText(getApplicationContext(), "Error closing database or cursor", Toast.LENGTH_SHORT).show();
208 | }
209 |
210 | }
211 | }
212 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mentesnot/easytravel/HelperUtils/HelperUtilities.java:
--------------------------------------------------------------------------------
1 | /*************************************************************************************************
2 | * JANUARY 8, 2018
3 | * Mentesnot Aboset
4 | * ************************************************************************************************/
5 | package com.mentesnot.easytravel.HelperUtils;
6 |
7 |
8 | import android.graphics.Bitmap;
9 | import android.graphics.BitmapFactory;
10 |
11 | import java.text.DateFormat;
12 | import java.text.SimpleDateFormat;
13 | import java.util.Calendar;
14 | import java.util.Date;
15 | import java.util.regex.Matcher;
16 | import java.util.regex.Pattern;
17 |
18 | public class HelperUtilities {
19 |
20 | public static boolean isValidPostalCode(String postalCode) {
21 | String regexPostalCode = "[A-Za-z][0-9][A-Za-z] [0-9][A-Za-z][0-9]";
22 |
23 | if (postalCode.matches(regexPostalCode)) {
24 | return true;
25 | }
26 | return false;
27 | }
28 |
29 | public static boolean isValidEmail(String email) {
30 | String regexEmail = "([_a-zA-Z0-9-]+(\\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\\.[a-zA-Z0-9-]+)*(\\.[a-zA-Z]{1,6}))?$";
31 |
32 | if (email.matches(regexEmail)) {
33 | return true;
34 | }
35 | return false;
36 | }
37 |
38 | public static boolean isValidPhone(String phone) {
39 | String regexPhone = "\\d{10}|(?:\\d{3}-){2}\\d{4}|\\(\\d{3}\\)\\d{3}-?\\d{4}";
40 |
41 | if (phone.matches(regexPhone)) {
42 | return true;
43 | }
44 | return false;
45 | }
46 |
47 | public static boolean isEmptyOrNull(String param) {
48 | if (param == null || param.trim().equals("")) {
49 | return true;
50 | }
51 | return false;
52 | }
53 |
54 | public static boolean isString(String data) {
55 |
56 | if (data.matches("\\d+(?:\\.\\d+)?")) {
57 | return false;
58 | }
59 |
60 | return true;
61 | }
62 |
63 | public static boolean isShortPassword(String password) {
64 | if (password.length() > 5) {
65 | return false;
66 | }
67 | return true;
68 | }
69 |
70 |
71 | public static boolean isValidCreditCard(String creditCardNo) {
72 |
73 | String visaRegex = "^4[0-9]{12}(?:[0-9]{3})?$";
74 | String masterRegex = "^5[1-5][0-9]{14}$";
75 | String expressRegex = "^3[47][0-9]{13}$";
76 |
77 |
78 | if (creditCardNo.matches(visaRegex)) {
79 | return true;
80 | } else if (creditCardNo.matches(masterRegex)) {
81 | return true;
82 | } else if (creditCardNo.matches(expressRegex)) {
83 | return true;
84 | }
85 |
86 | return false;
87 |
88 | }
89 |
90 | public static String getDateTime() {
91 |
92 | return DateFormat.getDateInstance().format(new Date());
93 |
94 | }
95 | public static String formatDate(int y, int m, int d){
96 |
97 | try{
98 | String date = d + "/" + (m+1) +"/" + y;
99 | Date date1= new SimpleDateFormat("dd/MM/yyyy").parse(date);
100 | DateFormat fullDf = DateFormat.getDateInstance(DateFormat.FULL);
101 |
102 | return fullDf.format(date1);
103 |
104 | }catch(Exception e){
105 |
106 | }
107 |
108 | return null;
109 | }
110 |
111 | public static int currentYear(){
112 |
113 | Calendar c = Calendar.getInstance();
114 | return c.get(Calendar.YEAR);
115 | }
116 |
117 | public static int currentMonth(){
118 | Calendar c = Calendar.getInstance();
119 | return c.get(Calendar.MONTH);
120 | }
121 |
122 | public static int currentDay(){
123 | Calendar c = Calendar.getInstance();
124 | return c.get(Calendar.DAY_OF_MONTH);
125 | }
126 |
127 | public static String maskCardNumber(String cardNumber) {
128 |
129 |
130 | int index = 0;
131 | String mask = "************####";
132 | StringBuilder maskedNumber = new StringBuilder();
133 | for (int i = 0; i < mask.length(); i++) {
134 | char c = mask.charAt(i);
135 | if (c == '#') {
136 | maskedNumber.append(cardNumber.charAt(index));
137 | index++;
138 | } else if (c == '*') {
139 | maskedNumber.append(c);
140 | index++;
141 | } else {
142 | maskedNumber.append(c);
143 | }
144 | }
145 |
146 | return maskedNumber.toString();
147 | }
148 |
149 | public static String capitalize(String str) {
150 | return str.length() == 0 ? str : str.substring(0, 1).toUpperCase() + str.substring(1);
151 | }
152 |
153 | public static String filter(String input) {
154 | if (!hasSpecialChars(input)) {
155 | return (input);
156 | }
157 | StringBuilder sb = new StringBuilder(input.length());
158 | char c;
159 |
160 | for (int i = 0; i < input.length(); i++) {
161 | c = input.charAt(i);
162 | switch (c) {
163 | case '<':
164 | sb.append("<");
165 | break;
166 | case '>':
167 | sb.append(">");
168 | break;
169 | case '"':
170 | sb.append(""");
171 | break;
172 | case '\'':
173 | sb.append("'");
174 | break;
175 | case '&':
176 | sb.append("&");
177 | break;
178 | default:
179 | sb.append(c);
180 | }
181 | }
182 | return sb.toString();
183 |
184 | }
185 |
186 | private static boolean hasSpecialChars(String input) {
187 |
188 | Pattern regexSpecialChars = Pattern.compile("[^a-z0-9 ]", Pattern.CASE_INSENSITIVE);
189 | Matcher inputStr = regexSpecialChars.matcher(input);
190 | boolean hasSpecialChars = inputStr.find();
191 |
192 | if (!hasSpecialChars) {
193 | return false;
194 | }
195 |
196 | return true;
197 | }
198 |
199 | //calculates the size of the uploaded image
200 | public static int calculateInSampleSize(
201 | BitmapFactory.Options options, int reqWidth, int reqHeight) {
202 | // Raw height and width of image
203 | final int height = options.outHeight;
204 | final int width = options.outWidth;
205 | int inSampleSize = 1;
206 |
207 | if (height > reqHeight || width > reqWidth) {
208 |
209 | final int halfHeight = height / 2;
210 | final int halfWidth = width / 2;
211 |
212 | // Calculate the largest inSampleSize value that is a power of 2 and keeps both
213 | // height and width larger than the requested height and width.
214 | while ((halfHeight / inSampleSize) >= reqHeight
215 | && (halfWidth / inSampleSize) >= reqWidth) {
216 | inSampleSize *= 2;
217 | }
218 | }
219 |
220 | return inSampleSize;
221 | }
222 |
223 | //reduces the size of the image
224 | public static Bitmap decodeSampledBitmapFromByteArray(byte[] res, int reqWidth, int reqHeight) {
225 |
226 | // First decode with inJustDecodeBounds=true to check dimensions
227 | final BitmapFactory.Options options = new BitmapFactory.Options();
228 | options.inJustDecodeBounds = true;
229 | BitmapFactory.decodeByteArray(res, 0, res.length, options);
230 |
231 | // Calculate inSampleSize
232 | options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);
233 |
234 | // Decode bitmap with inSampleSize set
235 | options.inJustDecodeBounds = false;
236 |
237 | return BitmapFactory.decodeByteArray(res, 0, res.length, options);
238 |
239 | }
240 |
241 | public static Double calculateTotalFare(double outboundFare, double returnFare, int numTraveller){
242 | return (outboundFare + returnFare) * numTraveller;
243 | }
244 |
245 | public static Double calculateTotalFare(double fare, int numTraveller){
246 | return fare * numTraveller;
247 | }
248 |
249 | public static boolean compareDate(String departureDate, String returnDate){
250 |
251 | try{
252 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
253 | Date date1 = sdf.parse(departureDate);
254 | Date date2 = sdf.parse(returnDate);
255 |
256 | if (date2.before(date1)) {
257 | return true;
258 | }
259 |
260 | }catch (Exception e){
261 | e.printStackTrace();
262 | }
263 |
264 | return false;
265 | }
266 |
267 | }
268 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mentesnot/easytravel/controllers/OutboundFlightListActivity.java:
--------------------------------------------------------------------------------
1 | /*************************************************************************************************
2 | * JANUARY 8, 2018
3 | * Mentesnot Aboset
4 | * ************************************************************************************************/
5 | package com.mentesnot.easytravel.controllers;
6 |
7 | import android.app.AlertDialog;
8 | import android.app.Dialog;
9 | import android.content.Context;
10 | import android.content.DialogInterface;
11 | import android.content.Intent;
12 | import android.content.SharedPreferences;
13 | import android.database.Cursor;
14 | import android.database.sqlite.SQLiteDatabase;
15 | import android.database.sqlite.SQLiteException;
16 | import android.database.sqlite.SQLiteOpenHelper;
17 | import android.support.v7.app.AppCompatActivity;
18 | import android.os.Bundle;
19 | import android.view.View;
20 | import android.widget.AdapterView;
21 | import android.widget.Button;
22 | import android.widget.CursorAdapter;
23 | import android.widget.ListView;
24 | import android.widget.SimpleCursorAdapter;
25 | import android.widget.TextView;
26 | import android.widget.Toast;
27 |
28 | import com.mentesnot.easytravel.database.DatabaseHelper;
29 | import com.mentesnot.easytravel.HelperUtils.HelperUtilities;
30 | import com.mentesnot.easytravel.R;
31 |
32 | public class OutboundFlightListActivity extends AppCompatActivity {
33 |
34 | private SharedPreferences sharedPreferences;
35 | private SQLiteOpenHelper databaseHelper;
36 | private SQLiteDatabase db;
37 | private Cursor cursor;
38 | private String origin;
39 | private String destination;
40 | private String departureDate;
41 | private String returnDate;
42 | private String flightClass;
43 | private TextView txtMessage;
44 | private ListView flightList;
45 | private Bundle bundle;
46 | private int currentTab;
47 | private int oneWayFightID;
48 | private int outboundFlightID;
49 | private int returnFlightID;
50 | private Intent intent;
51 | private android.support.v7.app.ActionBar actionBar;
52 | private int sortByID;
53 | private Button btnSort;
54 | private TextView flightNotFound;
55 | private boolean flightUnavailable = false;
56 |
57 |
58 | @Override
59 | protected void onCreate(Bundle savedInstanceState) {
60 | super.onCreate(savedInstanceState);
61 | setContentView(R.layout.activity_outbound_flight_list);
62 |
63 | //bundle = getIntent().getExtras();
64 | actionBar = getSupportActionBar();
65 |
66 | sharedPreferences = getSharedPreferences("PREFS", Context.MODE_PRIVATE);
67 | currentTab = sharedPreferences.getInt("CURRENT_TAB", 0);
68 | origin = sharedPreferences.getString("ORIGIN", "");
69 | destination = sharedPreferences.getString("DESTINATION", "");
70 | departureDate = sharedPreferences.getString("DEPARTURE_DATE", "");
71 | returnDate = sharedPreferences.getString("RETURN_DATE", "");
72 | flightClass = sharedPreferences.getString("FLIGHT_CLASS", "");
73 | sortByID = sharedPreferences.getInt("OUTBOUND_SORT_ID", 100);
74 |
75 | flightList = (ListView) findViewById(R.id.outboundFlightList);
76 |
77 | btnSort = (Button) findViewById(R.id.btnOutboundSort);
78 |
79 | flightNotFound = (TextView)findViewById(R.id.txtOutboundFlightNotFound);
80 |
81 | flightNotFound.setVisibility(View.INVISIBLE);
82 |
83 |
84 |
85 | btnSort.setOnClickListener(new View.OnClickListener() {
86 | @Override
87 | public void onClick(View view) {
88 | sortDialog().show();
89 | }
90 | });
91 |
92 |
93 | searchOutboundFlight();
94 |
95 | }
96 | public void searchOutboundFlight() {
97 | try {
98 | databaseHelper = new DatabaseHelper(getApplicationContext());
99 | db = databaseHelper.getReadableDatabase();
100 |
101 | //outbound flight
102 | if (sortByID == 0) {
103 | cursor = DatabaseHelper.selectFlight(db, origin, destination,
104 | departureDate, flightClass, "FARE");
105 | } else if (sortByID == 1) {
106 | cursor = DatabaseHelper.selectFlight(db, origin, destination,
107 | departureDate, flightClass, "FLIGHTDURATION");
108 | } else {
109 | cursor = DatabaseHelper.selectFlight(db, origin, destination,
110 | departureDate, flightClass);
111 | }
112 |
113 | if (cursor != null && cursor.getCount() > 0) {
114 |
115 | actionBar.setTitle("Select outbound flight");
116 | actionBar.setSubtitle(HelperUtilities.capitalize(origin) + " -> " + HelperUtilities.capitalize(destination));
117 |
118 | CursorAdapter listAdapter = new SimpleCursorAdapter(getApplicationContext(),
119 | R.layout.custom_list_view,
120 | cursor,
121 | new String[]{"DEPARTURETIME", "ARRIVALTIME", "FARE", "AIRLINENAME", "FLIGHTDURATION", "FLIGHTCLASSNAME"},
122 | new int[]{R.id.txtDepartureTime, R.id.txtArrivalTime, R.id.txtFare, R.id.txtAirline, R.id.txtTravelTime, R.id.txtClass},//map the contents of NAME col to text in ListView
123 | 0);
124 |
125 | flightList.setAdapter(listAdapter);
126 |
127 | }else{
128 | flightUnavailable = true;
129 | }
130 |
131 | cursor = DatabaseHelper.selectFlight(db, destination, origin,
132 | returnDate, flightClass);
133 |
134 | if (cursor != null && cursor.getCount() > 0){
135 | //do nothing here
136 |
137 | }else{
138 | flightUnavailable = true;
139 | }
140 |
141 | //Toast.makeText(getApplicationContext(), String.valueOf(flightUnavailable), Toast.LENGTH_SHORT).show();
142 |
143 | if(flightUnavailable == true){
144 | flightNotFound.setVisibility(View.VISIBLE);
145 | btnSort.setVisibility(View.INVISIBLE);
146 | }
147 |
148 | flightList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
149 | @Override
150 | public void onItemClick(AdapterView> adapterView, View view, int position, long id) {
151 |
152 | outboundFlightID = (int) id;
153 |
154 | intent = new Intent(getApplicationContext(), ReturnFlightListActivity.class);
155 | sharedPreferences = getSharedPreferences("PREFS", Context.MODE_PRIVATE);
156 | SharedPreferences.Editor editor = sharedPreferences.edit();
157 | editor.remove("OUTBOUND_FLIGHT_ID");
158 | editor.putInt("OUTBOUND_FLIGHT_ID", outboundFlightID);
159 |
160 | editor.commit();
161 |
162 | startActivity(intent);
163 | finish();
164 | }
165 | });
166 |
167 |
168 | } catch (SQLiteException e) {
169 | Toast.makeText(getApplicationContext(), "Database error", Toast.LENGTH_SHORT).show();
170 | }
171 |
172 | }
173 |
174 | public Dialog flightNotFoundDialog() {
175 |
176 | AlertDialog.Builder builder = new AlertDialog.Builder(this);
177 | builder.setMessage("The specified round flight is not available. Please try again later.")
178 | .setCancelable(false)
179 | .setPositiveButton("OK", new DialogInterface.OnClickListener() {
180 | public void onClick(DialogInterface dialog, int id) {
181 |
182 | Intent intent = new Intent(getApplicationContext(), MainActivity.class);
183 | startActivity(intent);
184 | finish();
185 | }
186 | });
187 |
188 | return builder.create();
189 | }
190 |
191 | //sort by dialog (outbound)
192 | public Dialog sortDialog() {
193 |
194 | final AlertDialog.Builder builder = new AlertDialog.Builder(this);
195 | builder.setTitle("Sort by")
196 | .setItems(R.array.sort, new DialogInterface.OnClickListener() {
197 | @Override
198 | public void onClick(DialogInterface dialogInterface, int id) {
199 |
200 | sharedPreferences = getSharedPreferences("PREFS", Context.MODE_PRIVATE);
201 | SharedPreferences.Editor editor = sharedPreferences.edit();
202 | editor.remove("OUTBOUND_SORT_ID");
203 | editor.putInt("OUTBOUND_SORT_ID", id);
204 | editor.commit();
205 |
206 | intent = new Intent(getApplicationContext(), OutboundFlightListActivity.class);
207 | startActivity(intent);
208 | }
209 | });
210 |
211 | return builder.create();
212 | }
213 |
214 |
215 | }
216 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mentesnot/easytravel/controllers/CheckoutOnewayFragment.java:
--------------------------------------------------------------------------------
1 | /*************************************************************************************************
2 | * JANUARY 8, 2018
3 | * Mentesnot Aboset
4 | * ************************************************************************************************/
5 | package com.mentesnot.easytravel.controllers;
6 |
7 |
8 | import android.app.AlertDialog;
9 | import android.app.Dialog;
10 | import android.content.Context;
11 | import android.content.DialogInterface;
12 | import android.content.Intent;
13 | import android.content.SharedPreferences;
14 | import android.database.Cursor;
15 | import android.database.sqlite.SQLiteDatabase;
16 | import android.database.sqlite.SQLiteException;
17 | import android.database.sqlite.SQLiteOpenHelper;
18 | import android.os.Bundle;
19 | import android.support.v4.app.Fragment;
20 | import android.view.LayoutInflater;
21 | import android.view.View;
22 | import android.view.ViewGroup;
23 | import android.widget.Button;
24 | import android.widget.ListView;
25 | import android.widget.TextView;
26 | import android.widget.Toast;
27 |
28 | import com.mentesnot.easytravel.database.DatabaseHelper;
29 | import com.mentesnot.easytravel.HelperUtils.HelperUtilities;
30 | import com.mentesnot.easytravel.R;
31 |
32 |
33 | /**
34 | * A simple {@link Fragment} subclass.
35 | */
36 | public class CheckoutOnewayFragment extends Fragment {
37 |
38 | private ListView selectedFlight;
39 | private SharedPreferences sharedPreferences;
40 | private SQLiteOpenHelper databaseHelper;
41 | private SQLiteDatabase db;
42 | private Cursor cursor;
43 | private Bundle bundle;
44 | private int flightID;
45 | private android.support.v7.app.ActionBar actionBar;
46 | private Button btnSelectFlight;
47 | private int currentTab;
48 | private Intent intent;
49 |
50 | private TextView flightNo;
51 | private TextView origin;
52 | private TextView destination;
53 | private TextView departureDate;
54 | private TextView arrivalDate;
55 | private TextView departureTime;
56 | private TextView arrivalTime;
57 | private TextView flightDuration;
58 | private TextView flightClass;
59 | private TextView airline;
60 | private TextView fare;
61 | private TextView totalFare;
62 | private Button bookFlight;
63 | private int clientID;
64 | private boolean flightExists = false;
65 | private int numTraveller;
66 | private TextView numTrav;
67 | private double onewayFare;
68 |
69 |
70 | public CheckoutOnewayFragment() {
71 | // Required empty public constructor
72 | }
73 |
74 |
75 | @Override
76 | public View onCreateView(LayoutInflater inflater, ViewGroup container,
77 | Bundle savedInstanceState) {
78 |
79 | View view = inflater.inflate(R.layout.fragment_checkout_oneway, container, false);
80 |
81 | sharedPreferences = getActivity().getSharedPreferences("PREFS", Context.MODE_PRIVATE);
82 | flightID = sharedPreferences.getInt("ONEWAY_FLIGHT_ID", 0);
83 | numTraveller = sharedPreferences.getInt("ONEWAY_NUM_TRAVELLER", 0);
84 |
85 | clientID = clientID();
86 |
87 | airline = (TextView) view.findViewById(R.id.txtCheckoutAirline);
88 | flightNo = (TextView) view.findViewById(R.id.txtCheckoutFlightNumber);
89 | origin = (TextView) view.findViewById(R.id.txtCheckoutOrigin);
90 | destination = (TextView) view.findViewById(R.id.txtCheckoutDestination);
91 | departureDate = (TextView) view.findViewById(R.id.txtCheckoutDepartureDate);
92 | arrivalDate = (TextView) view.findViewById(R.id.txtCheckoutArrivalDate);
93 | departureTime = (TextView) view.findViewById(R.id.txtCheckoutDepartureTime);
94 | arrivalTime = (TextView) view.findViewById(R.id.txtCheckoutArrivalTime);
95 | flightDuration = (TextView) view.findViewById(R.id.txtCheckoutFlightDuration);
96 | flightClass = (TextView) view.findViewById(R.id.txtCheckoutFlightClass);
97 | numTrav = (TextView) view.findViewById(R.id.txtCheckoutTraveller);
98 | fare = (TextView) view.findViewById(R.id.txtCheckoutFare);
99 | totalFare = (TextView) view.findViewById(R.id.txtCheckoutTotalFare);
100 |
101 | bookFlight = (Button)view.findViewById(R.id.btnOneWayCheckout) ;
102 |
103 | bookFlight.setOnClickListener(new View.OnClickListener() {
104 | @Override
105 | public void onClick(View view) {
106 |
107 | bookFlight(clientID);
108 | }
109 | });
110 |
111 | // Inflate the layout for this fragment
112 | return view;
113 | }
114 |
115 | @Override
116 | public void onActivityCreated(Bundle savedInstanceState){
117 | super.onActivityCreated(savedInstanceState);
118 |
119 | displaySelectedFlightInfo(flightID);
120 | fare.setText("$" + onewayFare);
121 | totalFare.setText(String.valueOf(HelperUtilities.calculateTotalFare(onewayFare,numTraveller)));
122 | }
123 |
124 | public void displaySelectedFlightInfo(int id) {
125 | try {
126 | databaseHelper = new DatabaseHelper(getActivity());
127 | db = databaseHelper.getReadableDatabase();
128 |
129 | cursor = DatabaseHelper.selectFlight(db, id);
130 |
131 | if (cursor != null && cursor.getCount() == 1) {
132 | cursor.moveToFirst();
133 |
134 | //Toast.makeText(getActivity().getApplicationContext(), String.valueOf(cursor.getCount()), Toast.LENGTH_SHORT).show();
135 | flightNo.setText(String.valueOf(cursor.getInt(1)));
136 | origin.setText(cursor.getString(2));
137 | destination.setText(cursor.getString(3));
138 | departureDate.setText(cursor.getString(4));
139 | arrivalDate.setText(cursor.getString(5));
140 | departureTime.setText(cursor.getString(6));
141 | arrivalTime.setText(cursor.getString(7));
142 | flightDuration.setText(cursor.getString(8) + "h");
143 | onewayFare = cursor.getDouble(9);
144 | airline.setText(cursor.getString(10));
145 | flightClass.setText(cursor.getString(12));
146 |
147 | numTrav.setText(String.valueOf(numTraveller));
148 | }
149 |
150 | } catch (SQLiteException ex) {
151 | Toast.makeText(getActivity().getApplicationContext(), "Database error occurred", Toast.LENGTH_SHORT).show();
152 | }
153 | }
154 |
155 | public void bookFlight(int clientID){
156 | try{
157 |
158 | databaseHelper = new DatabaseHelper(getActivity());
159 | db = databaseHelper.getWritableDatabase();
160 |
161 | cursor = DatabaseHelper.selectItinerary(db, flightID, clientID);
162 |
163 | if(cursor != null && cursor.getCount() > 0) {
164 | cursor.moveToFirst();
165 |
166 | flightExists = true;
167 |
168 | flightAlreadyBookedAlert().show();
169 |
170 | //Toast.makeText(getActivity().getApplicationContext(), "You already booked this flight.", Toast.LENGTH_SHORT).show();
171 | }else{
172 |
173 | flightExists = false;
174 |
175 |
176 | DatabaseHelper.insertItinerary(db, flightID, clientID, numTraveller);
177 |
178 | bookFlightDialog().show();
179 | //Toast.makeText(getActivity().getApplicationContext(), "Your flight booked successfully.", Toast.LENGTH_SHORT).show();
180 | }
181 |
182 |
183 |
184 | }catch(SQLiteException e){
185 |
186 | }
187 | }
188 |
189 | public Dialog bookFlightDialog() {
190 |
191 | AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
192 | builder.setMessage("Your flight booked successfully. ")
193 | .setCancelable(false)
194 | .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
195 | public void onClick(DialogInterface dialog, int id) {
196 | intent = new Intent(getActivity(), MainActivity.class);
197 | startActivity(intent);
198 | }
199 | });
200 |
201 | return builder.create();
202 | }
203 |
204 | public Dialog flightAlreadyBookedAlert() {
205 |
206 | AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
207 | builder.setMessage("You already booked this flight. ")
208 | .setCancelable(false)
209 | .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
210 | public void onClick(DialogInterface dialog, int id) {
211 | intent = new Intent(getActivity(), MainActivity.class);
212 | startActivity(intent);
213 | }
214 | });
215 |
216 | return builder.create();
217 | }
218 |
219 |
220 | public int clientID() {
221 | LoginActivity.sharedPreferences = getActivity().getSharedPreferences(LoginActivity.MY_PREFERENCES, Context.MODE_PRIVATE);
222 | clientID = LoginActivity.sharedPreferences.getInt(LoginActivity.CLIENT_ID, 0);
223 | return clientID;
224 | }
225 | }
226 |
--------------------------------------------------------------------------------
/app/src/main/java/com/mentesnot/easytravel/controllers/RegisterActivity.java:
--------------------------------------------------------------------------------
1 | /*************************************************************************************************
2 | * JANUARY 8, 2018
3 | * Mentesnot Aboset
4 | * ************************************************************************************************/
5 | package com.mentesnot.easytravel.controllers;
6 |
7 | import android.app.AlertDialog;
8 | import android.app.Dialog;
9 | import android.content.DialogInterface;
10 | import android.content.Intent;
11 | import android.database.Cursor;
12 | import android.database.sqlite.SQLiteDatabase;
13 | import android.database.sqlite.SQLiteException;
14 | import android.database.sqlite.SQLiteOpenHelper;
15 | import android.support.v7.app.AppCompatActivity;
16 | import android.os.Bundle;
17 | import android.view.View;
18 | import android.widget.Button;
19 | import android.widget.EditText;
20 | import android.widget.TextView;
21 | import android.widget.Toast;
22 |
23 | import com.mentesnot.easytravel.database.DatabaseHelper;
24 | import com.mentesnot.easytravel.HelperUtils.HelperUtilities;
25 | import com.mentesnot.easytravel.R;
26 |
27 | public class RegisterActivity extends AppCompatActivity {
28 |
29 | private int clientID;
30 | private EditText inputFirstName;
31 | private EditText inputLastName;
32 | private EditText inputEmail;
33 | private EditText inputCreditCard;
34 | private EditText inputPhone;
35 | private EditText inputConfirmPassword;
36 | private EditText inputPassword;
37 | private boolean isValid;
38 | private SQLiteOpenHelper hospitalDatabaseHelper;
39 | private SQLiteDatabase db;
40 | private Cursor cursor;
41 |
42 |
43 | @Override
44 | protected void onCreate(Bundle savedInstanceState) {
45 | super.onCreate(savedInstanceState);
46 | setContentView(R.layout.activity_register);
47 |
48 | Button register = (Button) findViewById(R.id.btnRegister);
49 | TextView linkLogin = (TextView) findViewById(R.id.linkLogin);
50 |
51 |
52 | inputFirstName = (EditText) findViewById(R.id.txtFirstName);
53 | inputLastName = (EditText) findViewById(R.id.txtLastName);
54 | inputEmail = (EditText) findViewById(R.id.txtEmail);
55 | inputPhone = (EditText) findViewById(R.id.txtPhone);
56 | inputCreditCard = (EditText) findViewById(R.id.txtCreditCard);
57 | inputPassword = (EditText) findViewById(R.id.txtPassword);
58 | inputConfirmPassword = (EditText) findViewById(R.id.txtConfirmPassword);
59 |
60 |
61 | register.setOnClickListener(new View.OnClickListener() {
62 | @Override
63 | public void onClick(View view) {
64 |
65 | registerEmployee();
66 | }
67 | });
68 |
69 | linkLogin.setOnClickListener(new View.OnClickListener() {
70 | @Override
71 | public void onClick(View view) {
72 | Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
73 | startActivity(intent);
74 |
75 | }
76 | });
77 | }
78 |
79 | //registers new employee
80 | public void registerEmployee() {
81 |
82 | try {
83 |
84 |
85 | hospitalDatabaseHelper = new DatabaseHelper(getApplicationContext());
86 | db = hospitalDatabaseHelper.getWritableDatabase();
87 |
88 | cursor = DatabaseHelper.selectAccount(db, HelperUtilities.filter(inputEmail.getText().toString()));
89 |
90 | isValid = isValidUserInput();
91 |
92 |
93 | if (isValid) {
94 |
95 | if (cursor != null && cursor.getCount() > 0) {
96 |
97 | accountExistsAlert().show();
98 |
99 | } else {
100 |
101 | DatabaseHelper.insertClient(db,
102 | inputFirstName.getText().toString(),
103 | inputLastName.getText().toString(),
104 | inputPhone.getText().toString(),
105 | inputCreditCard.getText().toString());
106 |
107 | cursor = DatabaseHelper.selectClientID(db,
108 | inputFirstName.getText().toString(),
109 | inputLastName.getText().toString(),
110 | inputPhone.getText().toString(),
111 | inputCreditCard.getText().toString());
112 |
113 | if (cursor != null && cursor.getCount() == 1) {
114 | cursor.moveToFirst();
115 |
116 | DatabaseHelper.insertAccount(db,
117 | inputEmail.getText().toString(),
118 | inputPassword.getText().toString(),
119 | cursor.getInt(0));
120 |
121 | registrationSuccessDialog().show();
122 | }
123 |
124 | }
125 |
126 | }
127 |
128 |
129 | } catch (SQLiteException ex) {
130 | Toast.makeText(getApplicationContext(), "Database unavailable", Toast.LENGTH_SHORT).show();
131 | }
132 |
133 | }
134 |
135 |
136 | public Dialog registrationSuccessDialog() {
137 |
138 | AlertDialog.Builder builder = new AlertDialog.Builder(this);
139 | builder.setMessage("Your profile created successfully! ")
140 | .setCancelable(false)
141 | .setPositiveButton("OK", new DialogInterface.OnClickListener() {
142 | public void onClick(DialogInterface dialog, int id) {
143 |
144 | Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
145 | startActivity(intent);
146 | finish();
147 | }
148 | });
149 |
150 | return builder.create();
151 | }
152 |
153 | public Dialog accountExistsAlert() {
154 |
155 | AlertDialog.Builder builder = new AlertDialog.Builder(this);
156 | builder.setMessage("An account with this email already exists. Please try again. ")
157 | .setCancelable(false)
158 | .setPositiveButton("OK", new DialogInterface.OnClickListener() {
159 | public void onClick(DialogInterface dialog, int id) {
160 |
161 | }
162 | });
163 |
164 | return builder.create();
165 | }
166 |
167 | //validates user input
168 | public boolean isValidUserInput() {
169 | if (HelperUtilities.isEmptyOrNull(inputFirstName.getText().toString())) {
170 | inputFirstName.setError("Please enter your first name");
171 | return false;
172 | } else if (!HelperUtilities.isString(inputFirstName.getText().toString())) {
173 | inputFirstName.setError("Please enter a valid first name");
174 | return false;
175 | }
176 |
177 | if (HelperUtilities.isEmptyOrNull(inputLastName.getText().toString())) {
178 | inputLastName.setError("Please enter your last name");
179 | return false;
180 | } else if (!HelperUtilities.isString(inputLastName.getText().toString())) {
181 | inputLastName.setError("Please enter a valid last name");
182 | return false;
183 | }
184 |
185 | if (HelperUtilities.isEmptyOrNull(inputEmail.getText().toString())) {
186 | inputEmail.setError("Please enter your email");
187 | return false;
188 | } else if (!HelperUtilities.isValidEmail(inputEmail.getText().toString())) {
189 | inputEmail.setError("Please enter a valid email");
190 | return false;
191 | }
192 |
193 | if (HelperUtilities.isEmptyOrNull(inputPhone.getText().toString())) {
194 | inputPhone.setError("Please enter your phone");
195 | return false;
196 | } else if (!HelperUtilities.isValidPhone(inputPhone.getText().toString())) {
197 | inputPhone.setError("Please enter a valid phone");
198 | return false;
199 | }
200 |
201 | if (HelperUtilities.isEmptyOrNull(inputCreditCard.getText().toString())) {
202 | inputCreditCard.setError("Please enter your credit card number");
203 | return false;
204 | } else if (!HelperUtilities.isValidCreditCard(inputCreditCard.getText().toString())) {
205 | inputCreditCard.setError("Please enter a valid credit card number");
206 | return false;
207 | }
208 | if (HelperUtilities.isEmptyOrNull(inputPassword.getText().toString())) {
209 | inputPassword.setError("Please enter your password");
210 | return false;
211 | } else if (HelperUtilities.isShortPassword(inputPassword.getText().toString())) {
212 | inputPassword.setError("Your password must have at least 6 characters.");
213 | return false;
214 | }
215 |
216 | if (HelperUtilities.isEmptyOrNull(inputConfirmPassword.getText().toString())) {
217 | inputConfirmPassword.setError("Please confirm password");
218 | return false;
219 | }
220 |
221 | if (!(inputConfirmPassword.getText().toString().equals(inputPassword.getText().toString()))) {
222 |
223 | inputConfirmPassword.setError("The password doesn't match.");
224 | return false;
225 | }
226 |
227 |
228 | return true;
229 |
230 | }
231 |
232 | @Override
233 | protected void onDestroy() {
234 | super.onDestroy();
235 | try {
236 | cursor.close();
237 | db.close();
238 | } catch (Exception ex) {
239 | Toast.makeText(getApplicationContext(), "Error closing database or cursor", Toast.LENGTH_SHORT).show();
240 | }
241 | }
242 | }
243 |
--------------------------------------------------------------------------------