├── .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 | 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 | 12 | 13 | 14 | 26 | 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 | 69 | 70 | 71 | 72 | 73 | 74 | 79 | 80 | 81 | 82 | 83 | 84 | 1.7 85 | 86 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 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 | 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() { 86 | @Override 87 | public int compare(Object lhs, Object rhs) { 88 | if (((CompanyModel) lhs).drivers.size() > ((CompanyModel) rhs).drivers.size()) { 89 | return -1; 90 | } else if (((CompanyModel) lhs).drivers.size() < ((CompanyModel) rhs).drivers.size()) { 91 | return 1; 92 | } else { 93 | return 0; 94 | } 95 | } 96 | }); 97 | DataStorage.instance.companies = companies; 98 | mainInterface.showDrivers(companies); 99 | } 100 | } 101 | } 102 | 103 | @Override 104 | public void onFailure(Call call, Throwable t) { 105 | 106 | } 107 | }); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /app/src/main/java/io/maddevs/openfreecabs/utils/ApiClient.java: -------------------------------------------------------------------------------- 1 | package io.maddevs.openfreecabs.utils; 2 | 3 | import com.google.gson.Gson; 4 | import com.google.gson.GsonBuilder; 5 | 6 | import io.maddevs.openfreecabs.models.response.NearestResponse; 7 | import okhttp3.OkHttpClient; 8 | import okhttp3.logging.HttpLoggingInterceptor; 9 | import retrofit2.Callback; 10 | import retrofit2.Retrofit; 11 | import retrofit2.converter.gson.GsonConverterFactory; 12 | 13 | /** 14 | * Created by rustam on 22.08.16. 15 | */ 16 | public class ApiClient { 17 | private static final String baseUrl = "http://openfreecabs.org/"; 18 | public static ApiClient instance = new ApiClient(); 19 | 20 | private Retrofit retrofit; 21 | 22 | private ApiClient() { 23 | Gson gson = new GsonBuilder() 24 | .setDateFormat("yyyy-MM-dd'T'HH:mm:ssZ") 25 | .create(); 26 | 27 | HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); 28 | interceptor.setLevel(HttpLoggingInterceptor.Level.BODY); 29 | OkHttpClient client = new OkHttpClient.Builder().addInterceptor(interceptor).build(); 30 | 31 | retrofit = new Retrofit.Builder() 32 | .baseUrl(baseUrl) 33 | .client(client) 34 | .addConverterFactory(GsonConverterFactory.create(gson)) 35 | .build(); 36 | } 37 | 38 | private OpenFreeCabsAPI dieselAPI() { 39 | return retrofit.create(OpenFreeCabsAPI.class); 40 | } 41 | 42 | public void getNearest(double lat, double lng, Callback callback) { 43 | dieselAPI().getNearest(lat, lng).enqueue(callback); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/io/maddevs/openfreecabs/utils/BitmapUtils.java: -------------------------------------------------------------------------------- 1 | package io.maddevs.openfreecabs.utils; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.util.TypedValue; 6 | 7 | /** 8 | * Created by man on 02.10.16. 9 | */ 10 | public class BitmapUtils { 11 | public static final int Fill = 0; 12 | public static final int AspectFit = 1; 13 | public static final int AspectFill = 2; 14 | public static final int CenterCrop = 3; 15 | 16 | public static int dp2px(Context context, int dp) { 17 | return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, context.getResources().getDisplayMetrics()); 18 | } 19 | 20 | public static Bitmap scaleBitmap(Bitmap bitmap, int newWidth, int newHeight, int scaleType) { 21 | Bitmap scaledBitmap; 22 | double wScale = (double) newWidth / (double) bitmap.getWidth(); 23 | double hScale = (double) newHeight / (double) bitmap.getHeight(); 24 | int scaledWidth; 25 | int scaledHeight; 26 | 27 | switch (scaleType) { 28 | case Fill: 29 | scaledBitmap = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true); 30 | break; 31 | case AspectFit: 32 | scaledWidth = (int)(bitmap.getWidth() * Math.min(wScale, hScale)); 33 | scaledHeight = (int)(bitmap.getHeight() * Math.min(wScale, hScale)); 34 | scaledBitmap = Bitmap.createScaledBitmap(bitmap, scaledWidth, scaledHeight, true); 35 | break; 36 | case AspectFill: 37 | scaledWidth = (int)(bitmap.getWidth() * Math.max(wScale, hScale)); 38 | scaledHeight = (int)(bitmap.getHeight() * Math.max(wScale, hScale)); 39 | scaledBitmap = Bitmap.createScaledBitmap(bitmap, scaledWidth, scaledHeight, true); 40 | break; 41 | case CenterCrop: 42 | scaledWidth = (int)(bitmap.getWidth() * Math.max(wScale, hScale)); 43 | scaledHeight = (int)(bitmap.getHeight() * Math.max(wScale, hScale)); 44 | int xOffset = (scaledWidth - newWidth) / 2; 45 | int yOffset = (scaledHeight - newHeight) / 2; 46 | scaledBitmap = Bitmap.createBitmap( 47 | Bitmap.createScaledBitmap(bitmap, scaledWidth, scaledHeight, true), 48 | xOffset, yOffset, newWidth, newHeight); 49 | break; 50 | default: 51 | scaledBitmap = bitmap; 52 | break; 53 | } 54 | 55 | 56 | return scaledBitmap; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/java/io/maddevs/openfreecabs/utils/DataStorage.java: -------------------------------------------------------------------------------- 1 | package io.maddevs.openfreecabs.utils; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import io.maddevs.openfreecabs.models.CompanyModel; 7 | import io.maddevs.openfreecabs.models.ContactModel; 8 | 9 | /** 10 | * Created by rustam on 18.08.16. 11 | */ 12 | public class DataStorage { 13 | public static DataStorage instance = new DataStorage(); 14 | public List companies = new ArrayList<>(); 15 | public List selectedCompanyContacts = new ArrayList<>(); 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/io/maddevs/openfreecabs/utils/LocationManagerHelper.java: -------------------------------------------------------------------------------- 1 | package io.maddevs.openfreecabs.utils; 2 | 3 | import android.Manifest; 4 | import android.content.Context; 5 | import android.content.pm.PackageManager; 6 | import android.location.Location; 7 | import android.location.LocationListener; 8 | import android.location.LocationManager; 9 | import android.os.Bundle; 10 | import android.os.Looper; 11 | import android.support.v4.app.ActivityCompat; 12 | import android.util.Log; 13 | 14 | import com.google.android.gms.maps.model.LatLng; 15 | 16 | /** 17 | * Created by rustam on 19.06.16. 18 | */ 19 | public class LocationManagerHelper { 20 | private Location lastLocation; 21 | private Context context; 22 | private LocationManager locationManager; 23 | private LocationListener locationListener; 24 | 25 | public enum RequestStatus { 26 | Success, HaveLastKnownLocation, NoAvailableProviders, NoPermission 27 | } 28 | 29 | public LocationManagerHelper(Context context, final HelperLocationListener helperLocationListener) { 30 | this.context = context; 31 | locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); 32 | locationListener = new LocationListener() { 33 | @Override 34 | public void onLocationChanged(Location location) { 35 | Log.d("Location", "onLocationChanged " + location); 36 | lastLocation = location; 37 | helperLocationListener.onLocationChanged(new LatLng(location.getLatitude(), location.getLongitude())); 38 | } 39 | 40 | @Override 41 | public void onStatusChanged(String provider, int status, Bundle extras) { 42 | Log.d("Location", "onStatusChanged " + status); 43 | } 44 | 45 | @Override 46 | public void onProviderEnabled(String provider) { 47 | Log.d("Location", "onProviderEnabled " + provider); 48 | } 49 | 50 | @Override 51 | public void onProviderDisabled(String provider) { 52 | Log.d("Location", "onProviderDisabled " + provider); 53 | } 54 | }; 55 | } 56 | 57 | public RequestStatus requestUpdate() { 58 | if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && 59 | ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) { 60 | return RequestStatus.NoPermission; 61 | } 62 | 63 | boolean haveActiveProvider = false; 64 | 65 | for (String provider : locationManager.getProviders(true)) { 66 | Log.d("Location", "onLocationChanged " + provider); 67 | if (!provider.equals(LocationManager.PASSIVE_PROVIDER)) { 68 | haveActiveProvider = true; 69 | locationManager.requestSingleUpdate(provider, locationListener, Looper.getMainLooper()); 70 | Location location = locationManager.getLastKnownLocation(provider); 71 | if (location != null && lastLocation != null && location.getAccuracy() > lastLocation.getAccuracy()) { 72 | lastLocation = location; 73 | } else if (location != null && lastLocation == null) { 74 | lastLocation = location; 75 | } 76 | } 77 | } 78 | 79 | if (haveActiveProvider) { 80 | return lastLocation != null ? RequestStatus.HaveLastKnownLocation : RequestStatus.Success; 81 | } else { 82 | return RequestStatus.NoAvailableProviders; 83 | } 84 | } 85 | 86 | public LatLng getLastLocation() { 87 | return new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude()); 88 | } 89 | 90 | public interface HelperLocationListener { 91 | void onLocationChanged(LatLng location); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /app/src/main/java/io/maddevs/openfreecabs/utils/OpenFreeCabsAPI.java: -------------------------------------------------------------------------------- 1 | package io.maddevs.openfreecabs.utils; 2 | 3 | import io.maddevs.openfreecabs.models.response.NearestResponse; 4 | import retrofit2.Call; 5 | import retrofit2.http.GET; 6 | import retrofit2.http.Path; 7 | 8 | /** 9 | * Created by rustam on 23.08.16. 10 | */ 11 | public interface OpenFreeCabsAPI { 12 | @GET("nearest/{latitude}/{lng}") 13 | Call getNearest(@Path("latitude") double lat, @Path("lng") double lng); 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/java/io/maddevs/openfreecabs/utils/TouchableMapFragment.java: -------------------------------------------------------------------------------- 1 | package io.maddevs.openfreecabs.utils; 2 | 3 | import android.os.Bundle; 4 | import android.view.LayoutInflater; 5 | import android.view.View; 6 | import android.view.ViewGroup; 7 | 8 | import com.google.android.gms.maps.SupportMapFragment; 9 | 10 | public class TouchableMapFragment extends SupportMapFragment { 11 | 12 | private View mOriginalContentView; 13 | private TouchableWrapper mTouchView; 14 | 15 | public void setTouchListener(TouchableWrapper.OnTouchListener onTouchListener) { 16 | mTouchView.setTouchListener(onTouchListener); 17 | } 18 | 19 | @Override 20 | public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) { 21 | mOriginalContentView = super.onCreateView(inflater, parent, savedInstanceState); 22 | 23 | mTouchView = new TouchableWrapper(getActivity()); 24 | mTouchView.addView(mOriginalContentView); 25 | 26 | return mTouchView; 27 | } 28 | 29 | @Override 30 | public View getView() { 31 | return mOriginalContentView; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/io/maddevs/openfreecabs/utils/TouchableWrapper.java: -------------------------------------------------------------------------------- 1 | package io.maddevs.openfreecabs.utils; 2 | 3 | import android.content.Context; 4 | import android.view.MotionEvent; 5 | import android.widget.FrameLayout; 6 | 7 | public class TouchableWrapper extends FrameLayout { 8 | 9 | public TouchableWrapper(Context context) { 10 | super(context); 11 | } 12 | 13 | public void setTouchListener(OnTouchListener onTouchListener) { 14 | this.onTouchListener = onTouchListener; 15 | } 16 | 17 | private OnTouchListener onTouchListener; 18 | 19 | @Override 20 | public boolean dispatchTouchEvent(MotionEvent event) { 21 | switch (event.getAction()) { 22 | case MotionEvent.ACTION_DOWN: 23 | onTouchListener.onTouch(); 24 | break; 25 | case MotionEvent.ACTION_UP: 26 | onTouchListener.onRelease(); 27 | break; 28 | } 29 | 30 | return super.dispatchTouchEvent(event); 31 | } 32 | 33 | public interface OnTouchListener { 34 | void onTouch(); 35 | void onRelease(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/java/io/maddevs/openfreecabs/utils/views/CircleView.java: -------------------------------------------------------------------------------- 1 | package io.maddevs.openfreecabs.utils.views; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Canvas; 6 | import android.graphics.Color; 7 | import android.graphics.Paint; 8 | import android.graphics.RectF; 9 | import android.util.AttributeSet; 10 | import android.view.View; 11 | 12 | import io.maddevs.openfreecabs.R; 13 | 14 | /** 15 | * Created by man on 01.10.16. 16 | */ 17 | public class CircleView extends View { 18 | RectF rectF; 19 | Paint backgroundPaint; 20 | float aspectRatio; 21 | int color = Color.WHITE; 22 | 23 | public CircleView(Context context, AttributeSet attrs) { 24 | super(context, attrs); 25 | rectF = new RectF(); 26 | 27 | TypedArray typedArray = context.getTheme().obtainStyledAttributes( 28 | attrs, 29 | R.styleable.CircleView, 30 | 0, 0); 31 | 32 | try { 33 | aspectRatio = typedArray.getFloat(R.styleable.CircleView_aspectRatio, 1); 34 | color = typedArray.getInt(R.styleable.CircleView_fillColor, color); 35 | } finally { 36 | typedArray.recycle(); 37 | } 38 | 39 | backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG); 40 | backgroundPaint.setColor(color); 41 | backgroundPaint.setStyle(Paint.Style.FILL); 42 | } 43 | 44 | @Override 45 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 46 | int height = getDefaultSize(getSuggestedMinimumHeight(), heightMeasureSpec); 47 | int width = getDefaultSize(getSuggestedMinimumWidth(), widthMeasureSpec); 48 | float corner = Math.min(width, height) * aspectRatio; 49 | setMeasuredDimension((int) corner, (int) corner); 50 | rectF.set(0, 0, corner, corner); 51 | } 52 | 53 | @Override 54 | protected void onDraw(Canvas canvas) { 55 | super.onDraw(canvas); 56 | canvas.drawOval(rectF, backgroundPaint); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /app/src/main/java/io/maddevs/openfreecabs/utils/views/DividerItemDecoration.java: -------------------------------------------------------------------------------- 1 | package io.maddevs.openfreecabs.utils.views; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Rect; 5 | import android.graphics.drawable.Drawable; 6 | import android.support.v7.widget.LinearLayoutManager; 7 | import android.support.v7.widget.RecyclerView; 8 | import android.view.View; 9 | 10 | public class DividerItemDecoration extends RecyclerView.ItemDecoration { 11 | Drawable divider; 12 | int orientation; 13 | 14 | public DividerItemDecoration(Drawable divider) { 15 | this.divider = divider; 16 | } 17 | 18 | @Override 19 | public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { 20 | super.getItemOffsets(outRect, view, parent, state); 21 | if (parent.getChildAdapterPosition(view) > 0 || parent.getChildCount() == 1) { 22 | orientation = ((LinearLayoutManager) parent.getLayoutManager()).getOrientation(); 23 | if (orientation == LinearLayoutManager.VERTICAL) { 24 | outRect.top = divider.getIntrinsicHeight(); 25 | } else if (orientation == LinearLayoutManager.HORIZONTAL) { 26 | outRect.left = divider.getIntrinsicWidth(); 27 | } 28 | } 29 | } 30 | 31 | @Override 32 | public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { 33 | super.onDraw(c, parent, state); 34 | if (orientation == LinearLayoutManager.VERTICAL) { 35 | drawHorizontalDividers(c, parent); 36 | } else if (orientation == LinearLayoutManager.HORIZONTAL) { 37 | drawVerticalDividers(c, parent); 38 | } 39 | } 40 | 41 | private void drawHorizontalDividers(Canvas canvas, RecyclerView parent) { 42 | int parentLeft = parent.getPaddingLeft(); 43 | int parentRight = parent.getWidth() - parent.getPaddingRight(); 44 | 45 | int childCount = parent.getChildCount(); 46 | for (int i = 0; i < childCount; i++) { 47 | View child = parent.getChildAt(i); 48 | 49 | RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); 50 | 51 | int parentTop = child.getBottom() + params.bottomMargin; 52 | int parentBottom = parentTop + divider.getIntrinsicHeight(); 53 | 54 | divider.setBounds(parentLeft, parentTop, parentRight, parentBottom); 55 | divider.draw(canvas); 56 | } 57 | } 58 | 59 | private void drawVerticalDividers(Canvas canvas, RecyclerView parent) { 60 | int parentTop = parent.getPaddingTop(); 61 | int parentBottom = parent.getHeight() - parent.getPaddingBottom(); 62 | 63 | int childCount = parent.getChildCount(); 64 | for (int i = 0; i < childCount - 1; i++) { 65 | View child = parent.getChildAt(i); 66 | 67 | RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams(); 68 | 69 | int parentLeft = child.getRight() + params.rightMargin; 70 | int parentRight = parentLeft + divider.getIntrinsicWidth(); 71 | 72 | divider.setBounds(parentLeft, parentTop, parentRight, parentBottom); 73 | divider.draw(canvas); 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /app/src/main/java/io/maddevs/openfreecabs/views/ContactsActivity.java: -------------------------------------------------------------------------------- 1 | package io.maddevs.openfreecabs.views; 2 | 3 | import android.content.Intent; 4 | import android.net.Uri; 5 | import android.os.Bundle; 6 | import android.support.v4.content.ContextCompat; 7 | import android.support.v7.app.AppCompatActivity; 8 | import android.support.v7.widget.LinearLayoutManager; 9 | import android.support.v7.widget.RecyclerView; 10 | import android.view.MenuItem; 11 | 12 | import io.maddevs.openfreecabs.R; 13 | import io.maddevs.openfreecabs.adapters.ContactsAdapter; 14 | import io.maddevs.openfreecabs.models.ContactModel; 15 | import io.maddevs.openfreecabs.utils.views.DividerItemDecoration; 16 | 17 | /** 18 | * Created by man on 01.10.16. 19 | */ 20 | public class ContactsActivity extends AppCompatActivity implements ContactsAdapter.OnItemClickListener { 21 | String title; 22 | RecyclerView recyclerView; 23 | 24 | @Override 25 | protected void onCreate(Bundle savedInstanceState) { 26 | super.onCreate(savedInstanceState); 27 | setContentView(R.layout.fragment_list); 28 | 29 | if (getIntent().getExtras() != null) { 30 | title = getIntent().getExtras().getString("companyName", ""); 31 | } 32 | 33 | if (getSupportActionBar() != null) { 34 | getSupportActionBar().setDisplayShowTitleEnabled(true); 35 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 36 | getSupportActionBar().setHomeButtonEnabled(true); 37 | getSupportActionBar().setTitle(!title.isEmpty() ? title : getString(R.string.app_name)); 38 | } 39 | 40 | recyclerView = (RecyclerView) findViewById(R.id.recyclerView); 41 | recyclerView.setLayoutManager(new LinearLayoutManager(this)); 42 | recyclerView.addItemDecoration(new DividerItemDecoration(ContextCompat.getDrawable(this, R.drawable.divider))); 43 | recyclerView.setAdapter(new ContactsAdapter(this)); 44 | } 45 | 46 | @Override 47 | public void onClick(ContactModel item) { 48 | Intent intent = new Intent(Intent.ACTION_VIEW); 49 | switch (item.type) { 50 | case ContactModel.Sms: 51 | intent.setData(Uri.parse("sms:" + item.contact)); 52 | break; 53 | case ContactModel.Phone: 54 | intent.setData(Uri.parse("tel:" + item.contact)); 55 | break; 56 | case ContactModel.Website: 57 | intent.setData(Uri.parse(item.contact)); 58 | break; 59 | case ContactModel.Android: 60 | intent.setData(Uri.parse(item.contact)); 61 | break; 62 | case ContactModel.Apple: 63 | intent.setData(Uri.parse(item.contact)); 64 | break; 65 | } 66 | startActivity(intent); 67 | } 68 | 69 | @Override 70 | public boolean onOptionsItemSelected(MenuItem item) { 71 | switch (item.getItemId()) { 72 | case android.R.id.home: 73 | finish(); 74 | return true; 75 | default: 76 | return super.onOptionsItemSelected(item); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /app/src/main/java/io/maddevs/openfreecabs/views/MainActivity.java: -------------------------------------------------------------------------------- 1 | package io.maddevs.openfreecabs.views; 2 | 3 | import android.content.Intent; 4 | import android.graphics.Bitmap; 5 | import android.graphics.drawable.Drawable; 6 | import android.os.Handler; 7 | import android.os.Bundle; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.view.View; 10 | 11 | import com.google.android.gms.maps.CameraUpdateFactory; 12 | import com.google.android.gms.maps.GoogleMap; 13 | import com.google.android.gms.maps.OnMapReadyCallback; 14 | import com.google.android.gms.maps.model.BitmapDescriptor; 15 | import com.google.android.gms.maps.model.BitmapDescriptorFactory; 16 | import com.google.android.gms.maps.model.LatLng; 17 | import com.google.android.gms.maps.model.Marker; 18 | import com.google.android.gms.maps.model.MarkerOptions; 19 | import com.squareup.picasso.Picasso; 20 | import com.squareup.picasso.Target; 21 | 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | 25 | import io.maddevs.openfreecabs.R; 26 | import io.maddevs.openfreecabs.models.CompanyModel; 27 | import io.maddevs.openfreecabs.models.DriverModel; 28 | import io.maddevs.openfreecabs.presenters.MainPresenter; 29 | import io.maddevs.openfreecabs.utils.BitmapUtils; 30 | import io.maddevs.openfreecabs.utils.DataStorage; 31 | import io.maddevs.openfreecabs.utils.TouchableMapFragment; 32 | import io.maddevs.openfreecabs.utils.TouchableWrapper; 33 | import io.maddevs.openfreecabs.views.interfaces.MainInterface; 34 | 35 | public class MainActivity extends AppCompatActivity implements MainInterface, OnMapReadyCallback { 36 | GoogleMap map; 37 | List driverMarkers = new ArrayList<>(); 38 | 39 | MainPresenter presenter; 40 | TouchableMapFragment mapFragment; 41 | View mainButton; 42 | 43 | Handler mapScrollHandler = new Handler(); 44 | Runnable mapScrollRunnable = new Runnable() { 45 | LatLng lastTarget; 46 | 47 | @Override 48 | public void run() { 49 | if (map.getCameraPosition().target.equals(lastTarget)) { 50 | presenter.getNearest(lastTarget); 51 | } else { 52 | lastTarget = map.getCameraPosition().target; 53 | mapScrollHandler.postDelayed(this, 100); 54 | } 55 | } 56 | }; 57 | 58 | @Override 59 | protected void onCreate(Bundle savedInstanceState) { 60 | super.onCreate(savedInstanceState); 61 | setContentView(R.layout.activity_main); 62 | 63 | if (getSupportActionBar() != null) { 64 | getSupportActionBar().setLogo(R.drawable.logo); 65 | getSupportActionBar().setDisplayUseLogoEnabled(true); 66 | getSupportActionBar().setDisplayShowHomeEnabled(true); 67 | getSupportActionBar().setDisplayShowTitleEnabled(true); 68 | } 69 | 70 | presenter = new MainPresenter(this); 71 | 72 | mapFragment = (TouchableMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); 73 | mapFragment.getMapAsync(this); 74 | 75 | mainButton = findViewById(R.id.mainButton); 76 | mainButton.setOnClickListener(new View.OnClickListener() { 77 | @Override 78 | public void onClick(View v) { 79 | if (DataStorage.instance.companies.size() > 0) { 80 | startActivity(new Intent(MainActivity.this, NearCabListActivity.class)); 81 | } 82 | } 83 | }); 84 | } 85 | 86 | @Override 87 | public void onMapReady(GoogleMap googleMap) { 88 | map = googleMap; 89 | map.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() { 90 | Marker lastMarker; 91 | 92 | @Override 93 | public boolean onMarkerClick(Marker marker) { 94 | if (lastMarker != null) { 95 | lastMarker.hideInfoWindow(); 96 | if (lastMarker.equals(marker)) { 97 | lastMarker = null; 98 | return true; 99 | } 100 | } 101 | 102 | marker.showInfoWindow(); 103 | lastMarker = marker; 104 | 105 | return true; 106 | } 107 | }); 108 | 109 | mapFragment.setTouchListener(new TouchableWrapper.OnTouchListener() { 110 | @Override 111 | public void onTouch() { 112 | } 113 | 114 | @Override 115 | public void onRelease() { 116 | mapScrollHandler.removeCallbacks(mapScrollRunnable); 117 | mapScrollHandler.postDelayed(mapScrollRunnable, 100); 118 | } 119 | }); 120 | 121 | presenter.onMapReady(); 122 | } 123 | 124 | @Override 125 | public void toMyLocation(LatLng location) { 126 | map.animateCamera(CameraUpdateFactory.newLatLngZoom(location, 15)); 127 | } 128 | 129 | @Override 130 | public void showDrivers(List companies) { 131 | for (Marker driverMarker : driverMarkers) { 132 | driverMarker.remove(); 133 | } 134 | driverMarkers.clear(); 135 | 136 | for (final CompanyModel company : companies) { 137 | Picasso.with(this) 138 | .load(company.icon) 139 | .into(new Target() { 140 | @Override 141 | public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) { 142 | drawMarkers(company, BitmapDescriptorFactory.fromBitmap( 143 | BitmapUtils.scaleBitmap( 144 | bitmap, 145 | BitmapUtils.dp2px(MainActivity.this, 24), 146 | BitmapUtils.dp2px(MainActivity.this, 24), 147 | BitmapUtils.AspectFill 148 | ))); 149 | } 150 | 151 | @Override 152 | public void onBitmapFailed(Drawable errorDrawable) { 153 | drawMarkers(company, BitmapDescriptorFactory.fromResource(R.drawable.ic_default_marker)); 154 | } 155 | 156 | @Override 157 | public void onPrepareLoad(Drawable placeHolderDrawable) { 158 | drawMarkers(company, BitmapDescriptorFactory.fromResource(R.drawable.ic_default_marker)); 159 | } 160 | }); 161 | } 162 | } 163 | 164 | private void drawMarkers(CompanyModel company, BitmapDescriptor bitmapDescriptor) { 165 | for (Marker driverMarker : driverMarkers) { 166 | if (driverMarker.getTitle().equals(company.name)) { 167 | driverMarker.remove(); 168 | } 169 | } 170 | for (DriverModel driver : company.drivers) { 171 | driverMarkers.add(map.addMarker(new MarkerOptions() 172 | .position(new LatLng(driver.latitude, driver.longitude)) 173 | .title(company.name) 174 | .icon(bitmapDescriptor) 175 | )); 176 | } 177 | } 178 | } 179 | -------------------------------------------------------------------------------- /app/src/main/java/io/maddevs/openfreecabs/views/NearCabListActivity.java: -------------------------------------------------------------------------------- 1 | package io.maddevs.openfreecabs.views; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v4.content.ContextCompat; 6 | import android.support.v7.app.AppCompatActivity; 7 | import android.support.v7.widget.LinearLayoutManager; 8 | import android.support.v7.widget.RecyclerView; 9 | import android.view.MenuItem; 10 | import android.widget.Toast; 11 | 12 | import io.maddevs.openfreecabs.R; 13 | import io.maddevs.openfreecabs.adapters.NearCabsAdapter; 14 | import io.maddevs.openfreecabs.models.CompanyModel; 15 | import io.maddevs.openfreecabs.utils.DataStorage; 16 | import io.maddevs.openfreecabs.utils.views.DividerItemDecoration; 17 | 18 | /** 19 | * Created by rustam on 28.08.16. 20 | */ 21 | public class NearCabListActivity extends AppCompatActivity implements NearCabsAdapter.OnItemClickListener { 22 | RecyclerView recyclerView; 23 | 24 | @Override 25 | protected void onCreate(Bundle savedInstanceState) { 26 | super.onCreate(savedInstanceState); 27 | setContentView(R.layout.fragment_list); 28 | 29 | if (getSupportActionBar() != null) { 30 | getSupportActionBar().setDisplayShowTitleEnabled(true); 31 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 32 | getSupportActionBar().setHomeButtonEnabled(true); 33 | } 34 | 35 | recyclerView = (RecyclerView) findViewById(R.id.recyclerView); 36 | recyclerView.setLayoutManager(new LinearLayoutManager(this)); 37 | recyclerView.addItemDecoration(new DividerItemDecoration(ContextCompat.getDrawable(this, R.drawable.divider))); 38 | recyclerView.setAdapter(new NearCabsAdapter(this)); 39 | } 40 | 41 | @Override 42 | public void onClick(CompanyModel item) { 43 | if (item.contacts != null && item.contacts.size() > 0) { 44 | DataStorage.instance.selectedCompanyContacts = item.contacts; 45 | Intent intent = new Intent(this, ContactsActivity.class); 46 | intent.putExtra("companyName", item.name); 47 | startActivity(intent); 48 | } else { 49 | Toast.makeText(this, R.string.no_contacts, Toast.LENGTH_SHORT).show(); 50 | } 51 | } 52 | 53 | @Override 54 | public boolean onOptionsItemSelected(MenuItem item) { 55 | switch (item.getItemId()) { 56 | case android.R.id.home: 57 | finish(); 58 | return true; 59 | default: 60 | return super.onOptionsItemSelected(item); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /app/src/main/java/io/maddevs/openfreecabs/views/interfaces/MainInterface.java: -------------------------------------------------------------------------------- 1 | package io.maddevs.openfreecabs.views.interfaces; 2 | 3 | import com.google.android.gms.maps.model.LatLng; 4 | 5 | import java.util.List; 6 | 7 | import io.maddevs.openfreecabs.models.CompanyModel; 8 | 9 | /** 10 | * Created by rustam on 27.08.16. 11 | */ 12 | public interface MainInterface { 13 | void toMyLocation(LatLng location); 14 | void showDrivers(List companies); 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-ldrtl/logo.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/background_rounded.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/divider.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_android_12dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_android_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_apple_12dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_apple_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_default_marker.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 13 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_logo.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_phone_12dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_phone_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_pin.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_search.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sms_12dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sms_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_web_12dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_web_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/logo.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 27 | 28 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_list.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_contact.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 15 | 16 | 19 | 20 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_near_cabs.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 17 | 18 | 24 | 25 | 32 | 33 | 39 | 40 | 44 | 45 | 48 | 49 | 57 | 58 | 59 | 60 | 66 | 67 | 71 | 72 | 75 | 76 | 84 | 85 | 86 | 87 | 92 | 93 | 100 | 101 | 108 | 109 | 114 | 115 | 116 | 117 | 118 | 119 | 122 | 123 | 128 | 129 | 138 | 139 | 147 | 148 | 149 | 150 | 153 | 154 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/openfreecabs-android/6e8abec07403147749db0a86b1963d8b108e4df4/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/openfreecabs-android/6e8abec07403147749db0a86b1963d8b108e4df4/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/openfreecabs-android/6e8abec07403147749db0a86b1963d8b108e4df4/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/openfreecabs-android/6e8abec07403147749db0a86b1963d8b108e4df4/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/openfreecabs-android/6e8abec07403147749db0a86b1963d8b108e4df4/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #2D2C3D 4 | #1F1E2A 5 | #FFCC47 6 | 7 | #000000 8 | #FFFFFF 9 | #808080 10 | 11 | #808080 12 | 13 | #F83D45 14 | #00A844 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Open Free Cabs 3 | 4 | Your address 5 | For a taxi call? 6 | Free cabs 7 | Contacts not found 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/release/res/values/google_maps_api.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | AIzaSyC1lomQvSTp2GPabbbGkg3DmFa3UZovZ-g 21 | 22 | 23 | -------------------------------------------------------------------------------- /app/src/test/java/io/maddevs/kaisytaxi/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package io.maddevs.openfreecabs; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.1.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/maddevsio/openfreecabs-android/6e8abec07403147749db0a86b1963d8b108e4df4/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Sep 24 15:23:09 KGT 2016 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------