├── .gitignore
├── .idea
├── .name
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── dictionaries
│ └── rustam.xml
├── gradle.xml
├── misc.xml
├── modules.xml
├── runConfigurations.xml
└── vcs.xml
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── io
│ │ └── maddevs
│ │ └── openfreecabs
│ │ └── ApplicationTest.java
│ ├── debug
│ └── res
│ │ └── values
│ │ └── google_maps_api.xml
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── io
│ │ │ └── maddevs
│ │ │ └── openfreecabs
│ │ │ ├── adapters
│ │ │ ├── ContactsAdapter.java
│ │ │ └── NearCabsAdapter.java
│ │ │ ├── models
│ │ │ ├── CompanyModel.java
│ │ │ ├── ContactModel.java
│ │ │ ├── DriverModel.java
│ │ │ └── response
│ │ │ │ └── NearestResponse.java
│ │ │ ├── presenters
│ │ │ └── MainPresenter.java
│ │ │ ├── utils
│ │ │ ├── ApiClient.java
│ │ │ ├── BitmapUtils.java
│ │ │ ├── DataStorage.java
│ │ │ ├── LocationManagerHelper.java
│ │ │ ├── OpenFreeCabsAPI.java
│ │ │ ├── TouchableMapFragment.java
│ │ │ ├── TouchableWrapper.java
│ │ │ └── views
│ │ │ │ ├── CircleView.java
│ │ │ │ └── DividerItemDecoration.java
│ │ │ └── views
│ │ │ ├── ContactsActivity.java
│ │ │ ├── MainActivity.java
│ │ │ ├── NearCabListActivity.java
│ │ │ └── interfaces
│ │ │ └── MainInterface.java
│ └── res
│ │ ├── drawable-ldrtl
│ │ └── logo.xml
│ │ ├── drawable
│ │ ├── background_rounded.xml
│ │ ├── divider.xml
│ │ ├── ic_android_12dp.xml
│ │ ├── ic_android_24dp.xml
│ │ ├── ic_apple_12dp.xml
│ │ ├── ic_apple_24dp.xml
│ │ ├── ic_default_marker.xml
│ │ ├── ic_logo.xml
│ │ ├── ic_phone_12dp.xml
│ │ ├── ic_phone_24dp.xml
│ │ ├── ic_pin.xml
│ │ ├── ic_search.xml
│ │ ├── ic_sms_12dp.xml
│ │ ├── ic_sms_24dp.xml
│ │ ├── ic_web_12dp.xml
│ │ ├── ic_web_24dp.xml
│ │ └── logo.xml
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── fragment_list.xml
│ │ ├── item_contact.xml
│ │ └── item_near_cabs.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ └── values
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ ├── release
│ └── res
│ │ └── values
│ │ └── google_maps_api.xml
│ └── test
│ └── java
│ └── io
│ └── maddevs
│ └── kaisytaxi
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | OpenFreeCabs
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/dictionaries/rustam.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
19 |
--------------------------------------------------------------------------------
/.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 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | Android
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | 1.7
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.3"
6 |
7 | defaultConfig {
8 | applicationId "io.maddevs.openfreecabs"
9 | minSdkVersion 14
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 |
26 | compile 'com.squareup.retrofit2:retrofit:2.1.0'
27 | compile 'com.squareup.retrofit2:converter-gson:2.1.0'
28 | compile 'com.squareup.okhttp3:logging-interceptor:3.4.1'
29 |
30 | compile 'com.android.support:appcompat-v7:23.3.0'
31 | compile 'com.android.support:cardview-v7:23.3.0'
32 | compile 'com.android.support:design:23.3.0'
33 |
34 | compile 'com.squareup.picasso:picasso:2.5.2'
35 |
36 | compile 'com.google.android.gms:play-services-maps:9.2.0'
37 | }
38 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/rustam/.bin/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/io/maddevs/openfreecabs/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package io.maddevs.openfreecabs;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/debug/res/values/google_maps_api.xml:
--------------------------------------------------------------------------------
1 |
2 |
18 |
19 | AIzaSyC1lomQvSTp2GPabbbGkg3DmFa3UZovZ-g
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
14 |
15 |
18 |
19 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/src/main/java/io/maddevs/openfreecabs/adapters/ContactsAdapter.java:
--------------------------------------------------------------------------------
1 | package io.maddevs.openfreecabs.adapters;
2 |
3 | import android.support.v7.widget.RecyclerView;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.ImageView;
8 | import android.widget.TextView;
9 |
10 | import io.maddevs.openfreecabs.R;
11 | import io.maddevs.openfreecabs.models.ContactModel;
12 | import io.maddevs.openfreecabs.utils.DataStorage;
13 |
14 | /**
15 | * Created by man on 01.10.16.
16 | */
17 | public class ContactsAdapter extends RecyclerView.Adapter {
18 | OnItemClickListener clickListener;
19 |
20 | public ContactsAdapter(OnItemClickListener clickListener) {
21 | this.clickListener = clickListener;
22 | }
23 |
24 | @Override
25 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
26 | return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_contact, parent, false));
27 | }
28 |
29 | @Override
30 | public void onBindViewHolder(ViewHolder holder, int position) {
31 | final ContactModel contact = DataStorage.instance.selectedCompanyContacts.get(position);
32 | holder.contact.setText(contact.contact);
33 |
34 | switch (contact.type) {
35 | case ContactModel.Sms:
36 | holder.icon.setImageResource(R.drawable.ic_sms_24dp);
37 | break;
38 | case ContactModel.Phone:
39 | holder.icon.setImageResource(R.drawable.ic_phone_24dp);
40 | break;
41 | case ContactModel.Website:
42 | holder.icon.setImageResource(R.drawable.ic_web_24dp);
43 | break;
44 | case ContactModel.Android:
45 | holder.icon.setImageResource(R.drawable.ic_android_24dp);
46 | break;
47 | case ContactModel.Apple:
48 | holder.icon.setImageResource(R.drawable.ic_apple_24dp);
49 | break;
50 | }
51 |
52 | holder.itemView.setOnClickListener(new View.OnClickListener() {
53 | @Override
54 | public void onClick(View v) {
55 | clickListener.onClick(contact);
56 | }
57 | });
58 | }
59 |
60 | @Override
61 | public int getItemCount() {
62 | return DataStorage.instance.selectedCompanyContacts.size();
63 | }
64 |
65 | public class ViewHolder extends RecyclerView.ViewHolder {
66 | ImageView icon;
67 | TextView contact;
68 |
69 | public ViewHolder(View itemView) {
70 | super(itemView);
71 | icon = (ImageView) itemView.findViewById(R.id.icon);
72 | contact = (TextView) itemView.findViewById(R.id.contact);
73 | }
74 | }
75 |
76 | public interface OnItemClickListener {
77 | void onClick(ContactModel item);
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/app/src/main/java/io/maddevs/openfreecabs/adapters/NearCabsAdapter.java:
--------------------------------------------------------------------------------
1 | package io.maddevs.openfreecabs.adapters;
2 |
3 | import android.support.v4.content.ContextCompat;
4 | import android.support.v7.widget.RecyclerView;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.view.ViewGroup;
8 | import android.widget.ImageView;
9 | import android.widget.TextView;
10 |
11 | import com.squareup.picasso.Picasso;
12 |
13 | import io.maddevs.openfreecabs.R;
14 | import io.maddevs.openfreecabs.models.CompanyModel;
15 | import io.maddevs.openfreecabs.models.ContactModel;
16 | import io.maddevs.openfreecabs.utils.DataStorage;
17 |
18 | /**
19 | * Created by rustam on 28.08.16.
20 | */
21 | public class NearCabsAdapter extends RecyclerView.Adapter {
22 | OnItemClickListener clickListener;
23 |
24 | public NearCabsAdapter(OnItemClickListener clickListener) {
25 | this.clickListener = clickListener;
26 | }
27 |
28 | @Override
29 | public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
30 | return new ViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_near_cabs, parent, false));
31 | }
32 |
33 | @Override
34 | public void onBindViewHolder(ViewHolder holder, int position) {
35 | final CompanyModel company = DataStorage.instance.companies.get(position);
36 | Picasso.with(holder.itemView.getContext()).load(company.icon).into(holder.icon);
37 | holder.name.setText(company.name);
38 | holder.count.setText(String.valueOf(company.drivers.size()));
39 |
40 | holder.count.setTextColor(ContextCompat.getColor(
41 | holder.itemView.getContext(),
42 | position == 0 ? R.color.green : R.color.textColorSecondary));
43 | holder.freeCabs.setTextColor(ContextCompat.getColor(
44 | holder.itemView.getContext(),
45 | position == 0 ? R.color.green : R.color.textColorSecondary));
46 |
47 | String phoneContacts = "";
48 | String smsContacts = "";
49 | if (company.contacts != null) {
50 | for (ContactModel contact : company.contacts) {
51 | if (contact.type.equals(ContactModel.Phone)) {
52 | if (!phoneContacts.isEmpty()) {
53 | phoneContacts += ", ";
54 | }
55 | phoneContacts += contact.contact;
56 | } else if (contact.type.equals(ContactModel.Sms)) {
57 | if (!smsContacts.isEmpty()) {
58 | smsContacts += ", ";
59 | }
60 | smsContacts += contact.contact;
61 | }
62 | }
63 | }
64 |
65 | if (!phoneContacts.isEmpty()) {
66 | holder.phone.setText(phoneContacts);
67 | } else {
68 | holder.phoneContacts.setVisibility(View.GONE);
69 | }
70 |
71 | if (!smsContacts.isEmpty()) {
72 | holder.sms.setText(smsContacts);
73 | } else {
74 | holder.smsContacts.setVisibility(View.GONE);
75 | }
76 |
77 | holder.itemView.setOnClickListener(new View.OnClickListener() {
78 | @Override
79 | public void onClick(View v) {
80 | clickListener.onClick(company);
81 | }
82 | });
83 | }
84 |
85 | @Override
86 | public int getItemCount() {
87 | return DataStorage.instance.companies.size();
88 | }
89 |
90 | public class ViewHolder extends RecyclerView.ViewHolder {
91 | ImageView icon;
92 | TextView name, count, freeCabs, phone, sms;
93 | View phoneContacts, smsContacts;
94 |
95 | public ViewHolder(View itemView) {
96 | super(itemView);
97 | icon = (ImageView) itemView.findViewById(R.id.icon);
98 | name = (TextView) itemView.findViewById(R.id.name);
99 | count = (TextView) itemView.findViewById(R.id.count);
100 | freeCabs = (TextView) itemView.findViewById(R.id.freeCabs);
101 | phone = (TextView) itemView.findViewById(R.id.phone);
102 | sms = (TextView) itemView.findViewById(R.id.sms);
103 | phoneContacts = itemView.findViewById(R.id.phoneContacts);
104 | smsContacts = itemView.findViewById(R.id.smsContacts);
105 | }
106 | }
107 |
108 | public interface OnItemClickListener {
109 | void onClick(CompanyModel item);
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/app/src/main/java/io/maddevs/openfreecabs/models/CompanyModel.java:
--------------------------------------------------------------------------------
1 | package io.maddevs.openfreecabs.models;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * Created by rustam on 27.08.16.
7 | */
8 | public class CompanyModel {
9 | public String name;
10 | public String icon;
11 | public List contacts;
12 | public List drivers;
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/io/maddevs/openfreecabs/models/ContactModel.java:
--------------------------------------------------------------------------------
1 | package io.maddevs.openfreecabs.models;
2 |
3 | /**
4 | * Created by rustam on 03.09.16.
5 | */
6 | public class ContactModel {
7 | public static final String Sms = "sms";
8 | public static final String Phone = "phone";
9 | public static final String Website = "website";
10 | public static final String Android = "android";
11 | public static final String Apple = "ios";
12 |
13 | public String type;
14 | public String contact;
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/java/io/maddevs/openfreecabs/models/DriverModel.java:
--------------------------------------------------------------------------------
1 | package io.maddevs.openfreecabs.models;
2 |
3 | import com.google.gson.annotations.SerializedName;
4 |
5 | /**
6 | * Created by rustam on 27.08.16.
7 | */
8 | public class DriverModel {
9 | @SerializedName("lat")
10 | public double latitude;
11 |
12 | @SerializedName("lon")
13 | public double longitude;
14 | }
15 |
--------------------------------------------------------------------------------
/app/src/main/java/io/maddevs/openfreecabs/models/response/NearestResponse.java:
--------------------------------------------------------------------------------
1 | package io.maddevs.openfreecabs.models.response;
2 |
3 | import java.util.List;
4 |
5 | import io.maddevs.openfreecabs.models.CompanyModel;
6 |
7 | /**
8 | * Created by rustam on 27.08.16.
9 | */
10 | public class NearestResponse {
11 | public boolean success;
12 | public List companies;
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/main/java/io/maddevs/openfreecabs/presenters/MainPresenter.java:
--------------------------------------------------------------------------------
1 | package io.maddevs.openfreecabs.presenters;
2 |
3 | import com.google.android.gms.maps.model.LatLng;
4 |
5 | import java.util.Collections;
6 | import java.util.Comparator;
7 | import java.util.List;
8 |
9 | import io.maddevs.openfreecabs.models.CompanyModel;
10 | import io.maddevs.openfreecabs.models.response.NearestResponse;
11 | import io.maddevs.openfreecabs.utils.ApiClient;
12 | import io.maddevs.openfreecabs.utils.DataStorage;
13 | import io.maddevs.openfreecabs.utils.LocationManagerHelper;
14 | import io.maddevs.openfreecabs.views.MainActivity;
15 | import io.maddevs.openfreecabs.views.interfaces.MainInterface;
16 | import retrofit2.Call;
17 | import retrofit2.Callback;
18 | import retrofit2.Response;
19 |
20 | /**
21 | * Created by rustam on 27.08.16.
22 | */
23 | public class MainPresenter implements LocationManagerHelper.HelperLocationListener {
24 | MainInterface mainInterface;
25 | LocationManagerHelper locationManagerHelper;
26 | public List companies;
27 |
28 | public MainPresenter(MainActivity mainActivity) {
29 | mainInterface = mainActivity;
30 | locationManagerHelper = new LocationManagerHelper(mainActivity, this);
31 | companies = DataStorage.instance.companies;
32 | }
33 |
34 | public void onMapReady() {
35 | if (companies != null && companies.size() > 0) {
36 | DataStorage.instance.companies = companies;
37 | mainInterface.showDrivers(companies);
38 | }
39 |
40 | locationManagerHelper.requestUpdate();
41 | switch (locationManagerHelper.requestUpdate()) {
42 | case NoAvailableProviders:
43 | // new MaterialDialog.Builder(this)
44 | // .title(R.string.attention)
45 | // .content(R.string.no_available_providers)
46 | // .positiveText(R.string.settings)
47 | // .onPositive(new MaterialDialog.SingleButtonCallback() {
48 | // @Override
49 | // public void onClick(MaterialDialog dialog, DialogAction which) {
50 | // Intent callGPSSettingIntent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
51 | // startActivity(callGPSSettingIntent);
52 | // }
53 | // })
54 | // .negativeText(R.string.close).show();
55 | // break;
56 | case NoPermission:
57 | // ActivityCompat.requestPermissions(this, new String[]{
58 | // Manifest.permission.ACCESS_FINE_LOCATION,
59 | // Manifest.permission.ACCESS_COARSE_LOCATION
60 | // }, requestPermissionCode);
61 | // break;
62 | case HaveLastKnownLocation:
63 | // animateToMyLocation = 2;
64 | // mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(locationManagerHelper.getLastLocation(), 17));
65 | // break;
66 | case Success:
67 | // animateToMyLocation = 1;
68 | break;
69 | }
70 | }
71 |
72 | @Override
73 | public void onLocationChanged(LatLng location) {
74 | getNearest(location);
75 | mainInterface.toMyLocation(location);
76 | }
77 |
78 | public void getNearest(LatLng location) {
79 | ApiClient.instance.getNearest(location.latitude, location.longitude, new Callback() {
80 | @Override
81 | public void onResponse(Call call, Response response) {
82 | if (response.isSuccessful()) {
83 | if (response.body().success && response.body().companies != null) {
84 | companies = response.body().companies;
85 | Collections.sort(companies, new Comparator