Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: reduce app size by removing mapbox #1516

Merged
merged 3 commits into from
Apr 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ android {
}
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "String", "DEFAULT_BASE_URL", '"https://api.eventyay.com/v1/"'
Expand Down Expand Up @@ -72,6 +73,9 @@ android {
androidExtensions {
experimental = true
}
aaptOptions {
cruncherEnabled = false
}
}

spotless {
Expand Down Expand Up @@ -172,9 +176,6 @@ dependencies {
releaseImplementation 'com.github.iamareebjamal:stetho-noop:1.2.1'
testImplementation 'com.github.iamareebjamal:stetho-noop:1.2.1'

//Mapbox SDK plugins
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-places-v7:0.7.0'

testImplementation 'junit:junit:4.12'
testImplementation "io.mockk:mockk:1.9.3"
testImplementation 'org.threeten:threetenbp:1.3.8'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class EditProfileViewModel(
.subscribe({
updateUser(it.url, firstName, lastName)
mutableMessage.value = "Image uploaded successfully!"
Timber.d("Image uploaded " + it.url)
Timber.d("Image uploaded ${it.url}")
}) {
mutableMessage.value = "Error uploading image!"
Timber.e(it, "Error uploading user!")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class LoginViewModel(
mutableProgress.value = true
}.doFinally {
mutableProgress.value = false
}.subscribe({ it ->
}.subscribe({
Timber.d("User Fetched")
mutableUser.value = it
}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class EventDetailsFragment : Fragment() {

// Event Description Section
if (!event.description.isNullOrEmpty()) {
setTextField(rootView.eventDescription, event.description?.stripHtml())
setTextField(rootView.eventDescription, event.description.stripHtml())

rootView.eventDescription.post {
if (rootView.eventDescription.lineCount > LINE_COUNT) {
Expand Down Expand Up @@ -246,6 +246,7 @@ class EventDetailsFragment : Fragment() {
Picasso.get()
.load(eventViewModel.loadMap(event))
.placeholder(R.drawable.ic_map_black)
.error(R.drawable.ic_map_black)
.into(rootView.imageMap)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class EventService(
private fun getEventTopicList(eventsList: List<Event>): List<EventTopic?> {
return eventsList
.filter { it.eventTopic != null }
.map { it -> it.eventTopic }
.map { it.eventTopic }
.toList()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,25 @@ import android.Manifest
import android.content.pm.PackageManager
import android.os.Bundle
import android.view.LayoutInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.SearchView
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.navigation.Navigation
import androidx.navigation.fragment.navArgs
import com.google.android.material.snackbar.Snackbar
import com.mapbox.api.geocoding.v5.models.CarmenFeature
import com.mapbox.mapboxsdk.plugins.places.autocomplete.model.PlaceOptions
import com.mapbox.mapboxsdk.plugins.places.autocomplete.ui.PlaceAutocompleteFragment
import com.mapbox.mapboxsdk.plugins.places.autocomplete.ui.PlaceSelectionListener
import kotlinx.android.synthetic.main.fragment_search_location.view.currentLocationLinearLayout
import kotlinx.android.synthetic.main.fragment_search_location.view.locationProgressBar
import org.fossasia.openevent.general.BuildConfig
import kotlinx.android.synthetic.main.fragment_search_location.view.locationSearchView
import org.fossasia.openevent.general.R
import org.fossasia.openevent.general.utils.Utils
import org.koin.androidx.viewmodel.ext.android.viewModel

const val LOCATION_PERMISSION_REQUEST = 1000
const val AUTOCOMPLETE_FRAG_TAG = "AutoComplete_Frag"

class SearchLocationFragment : Fragment() {
private lateinit var rootView: View
Expand All @@ -37,7 +35,8 @@ class SearchLocationFragment : Fragment() {

val thisActivity = activity
if (thisActivity is AppCompatActivity) {
thisActivity.supportActionBar?.hide()
thisActivity.supportActionBar?.show()
thisActivity.supportActionBar?.setDisplayHomeAsUpEnabled(true)
}
setHasOptionsMenu(true)

Expand All @@ -56,11 +55,37 @@ class SearchLocationFragment : Fragment() {
redirectToMain()
})

setupPlaceAutoCompleteFrag(savedInstanceState)
rootView.locationSearchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What'll happen here?

Copy link
Contributor Author

@anhanh11001 anhanh11001 Apr 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In short, I reverted it back to old SearchLocationFragment where there is only a searchview for user to type in the name of the the place, there isn't location suggestion anymore (I will improve this fragment with retaining old search and hopefully a better autosuggestion solution if this PR is accepted). Here is the view:

override fun onQueryTextSubmit(query: String): Boolean {
searchLocationViewModel.saveSearch(query)
redirectToMain()
return false
}

override fun onQueryTextChange(newText: String): Boolean {
return false
}
})

return rootView
}

override fun onResume() {
super.onResume()
Utils.showSoftKeyboard(context, rootView.locationSearchView)
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) {
android.R.id.home -> {
Utils.hideSoftKeyboard(context, rootView)
activity?.onBackPressed()
true
}
else -> super.onOptionsItemSelected(item)
}
}

private fun checkLocationPermission() {
val permission =
ContextCompat.checkSelfPermission(requireContext(), Manifest.permission.ACCESS_COARSE_LOCATION)
Expand All @@ -75,37 +100,6 @@ class SearchLocationFragment : Fragment() {
Navigation.findNavController(rootView).popBackStack(fragmentId, false)
}

private fun setupPlaceAutoCompleteFrag(savedInstanceState: Bundle?) {

val autocompleteFragment: PlaceAutocompleteFragment?
if (savedInstanceState == null) {
val placeOptions = PlaceOptions.builder().build(PlaceOptions.MODE_CARDS)
autocompleteFragment = PlaceAutocompleteFragment.newInstance(
BuildConfig.MAPBOX_KEY, placeOptions)
val transaction = fragmentManager?.beginTransaction()
transaction?.add(R.id.autocomplete_frag_container, autocompleteFragment,
AUTOCOMPLETE_FRAG_TAG)
transaction?.commit()
} else {
autocompleteFragment = fragmentManager?.findFragmentByTag(
AUTOCOMPLETE_FRAG_TAG) as? PlaceAutocompleteFragment
}

autocompleteFragment?.setOnPlaceSelectedListener(object : PlaceSelectionListener {
override fun onPlaceSelected(carmenFeature: CarmenFeature) {
val location = carmenFeature.placeName()?.split(",")?.first()
location?.let {
searchLocationViewModel.saveSearch(it)
redirectToMain()
}
}

override fun onCancel() {
activity?.onBackPressed()
}
})
}

override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray) {
when (requestCode) {
LOCATION_PERMISSION_REQUEST -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ class TicketDetailsViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView
}

if (ticket.price != null) {
itemView.price.text = "${eventCurrency}${ticket.price}"
itemView.price.text = "$eventCurrency${ticket.price}"
}

if (ticket.price == 0.toFloat()) {
itemView.price.text = "Free"
}

val subTotal: Float? = ticket.price?.toFloat()?.times(qty[adapterPosition])
val subTotal: Float? = ticket.price?.times(qty[adapterPosition])
itemView.qty.text = qty[adapterPosition].toString()
itemView.subTotal.text = "$$subTotal"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class TicketViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
}

if (ticket.price != null) {
itemView.price.text = "${eventCurrency}${ticket.price}"
itemView.price.text = "$eventCurrency${ticket.price}"
}

if (ticket.price == 0.toFloat()) {
Expand Down
Binary file modified app/src/main/res/drawable/header.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable/ic_open_event.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/src/main/res/layout/content_event.xml
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@
android:layout_width="match_parent"
android:layout_height="@dimen/home_logo_width"
android:layout_marginBottom="@dimen/divider_margin_bottom"
android:scaleType="centerCrop"
android:src="@drawable/header"
android:visibility="gone" />
</LinearLayout>
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/fragment_attendee.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/attendeeScrollView"
android:layout_width="match_parent"
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/fragment_order_details.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down
16 changes: 8 additions & 8 deletions app/src/main/res/layout/fragment_search_location.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
android:layout_height="match_parent"
android:orientation="vertical">

<FrameLayout
android:id="@+id/autocomplete_frag_container"
<androidx.appcompat.widget.SearchView
android:id="@+id/locationSearchView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/layout_margin_medium"
android:layout_marginLeft="@dimen/layout_margin_medium"
android:layout_marginTop="@dimen/layout_margin_medium"
android:layout_marginEnd="@dimen/layout_margin_medium"
android:layout_marginRight="@dimen/layout_margin_medium"
android:layout_marginBottom="@dimen/layout_margin_large"
app:layout_constraintBottom_toTopOf="@+id/currentLocationLinearLayout"
android:inputType="textCapWords"
app:iconifiedByDefault="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

</FrameLayout>
app:layout_constraintTop_toTopOf="parent"
app:queryHint="@string/location_hint"
app:searchIcon="@null" />

<LinearLayout
android:id="@+id/currentLocationLinearLayout"
Expand Down