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

Final beta update #36

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Updates for demo on feb 21
* Rename 'Pantries' tab to 'List'
* Replace phone button with hyperlinked text field
* Create directions button on map with white icon
* Fixed typos in image assets
* Added icon to RecyclerView ListItem's
  • Loading branch information
robert-w-gries committed Feb 19, 2020
commit c70c2f14e3e0234a26f95e47aac9763a9b8931c5
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const val LIST_PAGE = 1
const val PAGE_COUNT = 2

class MyFragmentPagerAdapter(fm: FragmentManager, context: Context) : androidx.fragment.app.FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
private val tabTitles = mapOf(MAP_PAGE to context.getString(R.string.map), LIST_PAGE to context.getString(R.string.pantries))
private val tabTitles = mapOf(MAP_PAGE to context.getString(R.string.map), LIST_PAGE to context.getString(R.string.list))

override fun getCount(): Int {
return PAGE_COUNT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.endhungerdurham.pantries.ui.fragment

import android.content.Intent
import android.graphics.Paint
import android.net.Uri
import android.os.Bundle
import android.view.*
Expand Down Expand Up @@ -106,16 +107,11 @@ class DetailsFragment : androidx.fragment.app.Fragment(), OnMapReadyCallback {
}.joinToString(separator)
}

val phoneButton = view?.findViewById<Button>(R.id.phone)
if (mPantry.phone.isNullOrBlank()) {
phoneButton?.visibility = View.GONE
} else {
// change phone icon to white
val icon = ContextCompat.getDrawable(requireContext(), R.drawable.ic_baseline_local_phone_24px)
setColorFilter(icon, ContextCompat.getColor(requireContext(), R.color.details_phone_icon))
phoneButton?.setCompoundDrawablesRelativeWithIntrinsicBounds(null, icon, null, null)
view?.findViewById<TextView>(R.id.phone_number_field)?.let { textView ->
textView.text = mPantry.phone
textView.paintFlags = textView.paintFlags or Paint.UNDERLINE_TEXT_FLAG

phoneButton?.setOnClickListener{
textView.setOnClickListener{
startActivity(Intent(Intent.ACTION_DIAL, Uri.fromParts("tel", mPantry.phone, null)))
}
}
Expand All @@ -125,6 +121,10 @@ class DetailsFragment : androidx.fragment.app.Fragment(), OnMapReadyCallback {
val icon = ContextCompat.getDrawable(requireContext(), R.drawable.ic_directions_24px)
setColorFilter(icon, ContextCompat.getColor(requireContext(), R.color.details_directions_icon))
button.setCompoundDrawablesRelativeWithIntrinsicBounds(icon, null, null, null)

button.setOnClickListener {
startGoogleMapsIntent(mPantry, requireContext())
}
}

val addressText = view?.findViewById<TextView>(R.id.address_field)
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_chevron_right_24px.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#FF000000"
android:pathData="M10,6L8.59,7.41 13.17,12l-4.58,4.59L10,18l6,-6z"/>
</vector>
94 changes: 53 additions & 41 deletions app/src/main/res/layout-land/fragment_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
android:layout_height="match_parent"
tools:context=".ui.fragment.DetailsFragment">

<RelativeLayout
<FrameLayout
android:id="@+id/fragment_details_map_wrapper"
android:layout_width="0dp"
android:layout_height="0dp"
Expand All @@ -30,7 +30,19 @@
android:layout_height="match_parent"
map:liteMode="true"
map:mapType="normal" />
</RelativeLayout>

<Button
android:id="@+id/directions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:drawableStart="@drawable/ic_directions_24px"
android:drawablePadding="4dp"
android:text="@string/directions"
android:textAllCaps="false"
android:textColor="@android:color/white"
android:textSize="16sp" />
</FrameLayout>

<TextView
android:id="@+id/address"
Expand All @@ -44,7 +56,7 @@
app:layout_constraintBottom_toTopOf="@+id/address_field"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/fragment_details_map_wrapper"
app:layout_constraintTop_toBottomOf="@+id/phone" />
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/address_field"
Expand Down Expand Up @@ -88,11 +100,47 @@
app:autoSizeMaxTextSize="18sp"
app:autoSizeStepGranularity="2sp"
app:autoSizeTextType="uniform"
app:layout_constraintBottom_toTopOf="@+id/qualifications"
app:layout_constraintBottom_toTopOf="@+id/phone_number"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/fragment_details_map_wrapper"
app:layout_constraintTop_toBottomOf="@+id/availability" />

<TextView
android:id="@+id/phone_number"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:text="@string/phone_number"
android:textSize="14sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/phone_number_field_wrapper"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/fragment_details_map_wrapper"
app:layout_constraintTop_toBottomOf="@+id/availability_field" />

<FrameLayout
android:id="@+id/phone_number_field_wrapper"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/qualifications"
app:layout_constraintStart_toEndOf="@+id/fragment_details_map_wrapper"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/phone_number">
<TextView
android:id="@+id/phone_number_field"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:textIsSelectable="true"
android:textSize="18sp"
android:textColor="@android:color/holo_blue_dark"
app:autoSizeMaxTextSize="18sp"
app:autoSizeStepGranularity="2sp"
app:autoSizeTextType="uniform" />
</FrameLayout>

<TextView
android:id="@+id/qualifications"
android:layout_width="0dp"
Expand All @@ -105,7 +153,7 @@
app:layout_constraintBottom_toTopOf="@+id/qualifications_field"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/fragment_details_map_wrapper"
app:layout_constraintTop_toBottomOf="@+id/availability_field" />
app:layout_constraintTop_toBottomOf="@+id/phone_number_field_wrapper" />

<TextView
android:id="@+id/qualifications_field"
Expand Down Expand Up @@ -152,40 +200,4 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/fragment_details_map_wrapper"
app:layout_constraintTop_toBottomOf="@+id/info" />

<com.google.android.material.button.MaterialButton
android:id="@+id/phone"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:drawableTop="@drawable/ic_baseline_local_phone_24px"
android:padding="8dp"
android:text="@string/call"
android:textAlignment="center"
android:textAllCaps="false"
android:textSize="18sp"
app:backgroundTint="@color/colorPrimary"
app:layout_constraintBottom_toTopOf="@+id/address"
app:layout_constraintEnd_toStartOf="@+id/directions"
app:layout_constraintStart_toEndOf="@+id/fragment_details_map_wrapper"
app:layout_constraintTop_toTopOf="parent" />

<com.google.android.material.button.MaterialButton
android:id="@+id/directions"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground"
android:drawableTop="@drawable/ic_directions_24px"
android:padding="8dp"
android:text="@string/directions"
android:textAlignment="center"
android:textAllCaps="false"
android:textSize="18sp"
app:backgroundTint="@color/colorPrimary"
app:layout_constraintBottom_toTopOf="@+id/address"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toEndOf="@+id/phone"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
</androidx.constraintlayout.widget.ConstraintLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<com.google.android.material.tabs.TabItem
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@string/pantries" />
android:text="@string/list" />

<com.google.android.material.tabs.TabItem
android:layout_width="match_parent"
Expand Down
105 changes: 55 additions & 50 deletions app/src/main/res/layout/fragment_details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
android:layout_height="match_parent"
tools:context=".ui.fragment.DetailsFragment">

<RelativeLayout
<FrameLayout
android:id="@+id/fragment_details_map_wrapper"
android:layout_width="0dp"
android:layout_height="175dp"
app:layout_constraintBottom_toTopOf="@+id/directions_wrapper"
app:layout_constraintBottom_toTopOf="@+id/address"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
Expand All @@ -30,21 +30,34 @@
android:layout_height="match_parent"
map:liteMode="true"
map:mapType="normal" />
</RelativeLayout>

<Button
android:id="@+id/directions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:drawableStart="@drawable/ic_directions_24px"
android:drawablePadding="4dp"
android:text="@string/directions"
android:textAllCaps="false"
android:textColor="@android:color/white"
android:textSize="16sp" />
</FrameLayout>

<TextView
android:id="@+id/address"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingStart="8dp"
android:paddingTop="4dp"
android:paddingEnd="8dp"
android:text="@string/address"
android:textSize="14sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/address_field"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/directions_wrapper" />
app:layout_constraintTop_toBottomOf="@+id/fragment_details_map_wrapper" />

<TextView
android:id="@+id/address_field"
Expand Down Expand Up @@ -87,11 +100,47 @@
app:autoSizeMaxTextSize="18sp"
app:autoSizeStepGranularity="2sp"
app:autoSizeTextType="uniform"
app:layout_constraintBottom_toTopOf="@+id/qualifications"
app:layout_constraintBottom_toTopOf="@+id/phone_number"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/availability" />

<TextView
android:id="@+id/phone_number"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:text="@string/phone_number"
android:textSize="14sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/phone_number_field_wrapper"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/availability_field" />

<FrameLayout
android:id="@+id/phone_number_field_wrapper"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/qualifications"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/phone_number">
<TextView
android:id="@+id/phone_number_field"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:textIsSelectable="true"
android:textSize="18sp"
android:textColor="@android:color/holo_blue_dark"
app:autoSizeMaxTextSize="18sp"
app:autoSizeStepGranularity="2sp"
app:autoSizeTextType="uniform" />
</FrameLayout>

<TextView
android:id="@+id/qualifications"
android:layout_width="0dp"
Expand All @@ -104,7 +153,7 @@
app:layout_constraintBottom_toTopOf="@+id/qualifications_field"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/availability_field" />
app:layout_constraintTop_toBottomOf="@+id/phone_number_field_wrapper" />

<TextView
android:id="@+id/qualifications_field"
Expand Down Expand Up @@ -151,48 +200,4 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/info" />

<FrameLayout
android:id="@+id/directions_wrapper"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/address"
app:layout_constraintEnd_toStartOf="@id/phone_wrapper"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/fragment_details_map_wrapper">

<Button
android:id="@+id/directions"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:drawableStart="@drawable/ic_directions_24px"
android:drawablePadding="8dp"
android:text="@string/directions"
android:textAllCaps="false"
android:textColor="@android:color/white"
android:textSize="18sp" />
</FrameLayout>

<FrameLayout
android:id="@+id/phone_wrapper"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/address"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/directions_wrapper"
app:layout_constraintTop_toBottomOf="@+id/fragment_details_map_wrapper">

<Button
android:id="@+id/phone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:drawableTop="@drawable/ic_baseline_local_phone_24px"
android:padding="8dp"
android:text="@string/call"
android:textAllCaps="false"
android:textColor="@android:color/white"
android:textSize="18sp" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Loading