Skip to content
This repository was archived by the owner on Aug 22, 2024. It is now read-only.

Commit d23e825

Browse files
committed
[ADDED] [#2] Vector icons for the grid view.
[ADDED] Guidelines for future. Fixes #2
1 parent 6b5811d commit d23e825

File tree

11 files changed

+95
-3
lines changed

11 files changed

+95
-3
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ A demo application for Android `ConstraintLayout` with various usage with sample
1818
* [ ] Horizontal Axis: left, right, start and end sides
1919
* [ ] Vertical Axis: top, bottom sides and text baseline
2020
- [ ] Margins
21-
- [ ] Centering positioning and bias
21+
- [x] Centering positioning and bias
2222
- [ ] Circular positioning _(Added in 1.1)_
2323
- [ ] Visibility behavior
2424
- [ ] Dimension constraints
@@ -45,3 +45,8 @@ These are the **my** objectives for this demo application.
4545
* Learn and use the new architecture components in the sample app
4646
* Learn and use proper architecture for the app - likely MVVM
4747
* Document everything well so that future external contribution is easier
48+
49+
## Preview
50+
Here is a snapshot of current progress _(This will be updated from time to time)_.
51+
52+
![Browse Layout Variances](https://user-images.githubusercontent.com/99822/39676220-f20ef5c6-5134-11e8-9430-08f90b5fe5fb.png) ![Show Layout Screen](https://user-images.githubusercontent.com/99822/39676265-a0bb1f28-5135-11e8-8c34-014cef844e97.png)

app/src/main/java/com/hossainkhan/android/demo/browse/LayoutBrowseAdapter.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import android.support.v7.widget.RecyclerView
2020
import android.view.LayoutInflater
2121
import android.view.View
2222
import android.view.ViewGroup
23+
import android.widget.ImageView
2324
import android.widget.TextView
2425
import com.hossainkhan.android.demo.R
2526
import com.hossainkhan.android.demo.data.LayoutInformation
@@ -35,6 +36,7 @@ class LayoutBrowseAdapter(
3536
class ViewHolder(itemViewRoot: View,
3637
private val onClickListener: (Int) -> Unit) : RecyclerView.ViewHolder(itemViewRoot) {
3738
val itemName = itemViewRoot.findViewById<TextView>(R.id.layout_preview_name)!!
39+
val itemThumb = itemViewRoot.findViewById<ImageView>(R.id.imageView)
3840

3941
init {
4042
itemViewRoot.setOnClickListener {
@@ -59,6 +61,7 @@ class LayoutBrowseAdapter(
5961
// - get element from your dataset at this position
6062
// - replace the contents of the view with that element
6163
holder.itemName.text = data[position].title
64+
holder.itemThumb.setImageResource(data[position].thumbnailResourceId)
6265
}
6366

6467
// Return the size of your dataset (invoked by the layout manager)

app/src/main/java/com/hossainkhan/android/demo/data/LayoutDataStore.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ class LayoutDataStore @Inject constructor(
2929
val supportedLayoutInfos = listOf(
3030
LayoutInformation(
3131
layoutResourceId = R.layout.preview_positioning_top_left,
32+
thumbnailResourceId = R.drawable.ic_positioning_top_left,
3233
title = "Positioning: Top Left",
3334
description = "Top left using constraints."),
3435
LayoutInformation(
3536
layoutResourceId = R.layout.preview_positioning_centered,
37+
thumbnailResourceId = R.drawable.ic_positioning_center,
3638
title = "Positioning: Centered",
3739
description = "Centered view using constraints on top-bottom and left-right.")
3840
)

app/src/main/java/com/hossainkhan/android/demo/data/LayoutInformation.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.hossainkhan.android.demo.data
1818

19+
import android.support.annotation.DrawableRes
1920
import android.support.annotation.LayoutRes
2021

2122
/**
@@ -24,6 +25,8 @@ import android.support.annotation.LayoutRes
2425
data class LayoutInformation(
2526
@LayoutRes
2627
val layoutResourceId: Int,
28+
@DrawableRes
29+
val thumbnailResourceId: Int,
2730
val title: CharSequence,
2831
val description: CharSequence
2932
)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<vector android:height="24dp" android:viewportHeight="640"
2+
android:viewportWidth="640" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
3+
<path android:fillAlpha="0" android:fillColor="#FF000000"
4+
android:pathData="M2.19,637.84L637.81,637.84L637.81,2.16L2.19,2.16L2.19,637.84Z"
5+
android:strokeAlpha="1" android:strokeColor="#000000" android:strokeWidth="2"/>
6+
<path android:fillAlpha="1" android:fillColor="#00acc1" android:pathData="M407.81,213.54C413.34,213.54 417.81,218.02 417.81,223.54C417.81,262.52 417.81,369.48 417.81,408.46C417.81,413.98 413.34,418.46 407.81,418.46C370.69,418.46 269.31,418.46 232.19,418.46C226.66,418.46 222.19,413.98 222.19,408.46C222.19,369.48 222.19,262.52 222.19,223.54C222.19,218.02 226.66,213.54 232.19,213.54C269.31,213.54 370.69,213.54 407.81,213.54Z"/>
7+
<path android:fillAlpha="0.85" android:fillColor="#006064" android:pathData="M70.13,291.64L7,320.82L70.13,350L70.13,331.03L156.51,331.03L156.51,350L219.63,320.82L156.51,291.64L156.51,310.61L70.13,310.61L70.13,291.64Z"/>
8+
<path android:fillAlpha="0" android:fillColor="#FF000000"
9+
android:pathData="M70.13,291.64L7,320.82L70.13,350L70.13,331.03L156.51,331.03L156.51,350L219.63,320.82L156.51,291.64L156.51,310.61L70.13,310.61L70.13,291.64Z"
10+
android:strokeAlpha="1" android:strokeColor="#000000" android:strokeWidth="1"/>
11+
<path android:fillAlpha="0.85" android:fillColor="#006064" android:pathData="M484.2,292.19L421.66,321.09L484.2,350L484.2,331.21L569.77,331.21L569.77,350L632.3,321.09L569.77,292.19L569.77,310.98L484.2,310.98L484.2,292.19Z"/>
12+
<path android:fillAlpha="0" android:fillColor="#FF000000"
13+
android:pathData="M484.2,292.19L421.66,321.09L484.2,350L484.2,331.21L569.77,331.21L569.77,350L632.3,321.09L569.77,292.19L569.77,310.98L484.2,310.98L484.2,292.19Z"
14+
android:strokeAlpha="1" android:strokeColor="#000000" android:strokeWidth="1"/>
15+
<path android:fillAlpha="0.85" android:fillColor="#006064" android:pathData="M292.48,149.1L320,208.26L347.52,149.1L329.63,149.1L329.63,68.15L347.52,68.15L320,9L292.48,68.15L310.37,68.15L310.37,149.1L292.48,149.1Z"/>
16+
<path android:fillAlpha="0" android:fillColor="#FF000000"
17+
android:pathData="M292.48,149.1L320,208.26L347.52,149.1L329.63,149.1L329.63,68.15L347.52,68.15L320,9L292.48,68.15L310.37,68.15L310.37,149.1L292.48,149.1Z"
18+
android:strokeAlpha="1" android:strokeColor="#000000" android:strokeWidth="1"/>
19+
<path android:fillAlpha="0.85" android:fillColor="#006064" android:pathData="M293.42,570.47L322.04,632L350.66,570.47L332.06,570.47L332.06,486.28L350.66,486.28L322.04,424.75L293.42,486.28L312.02,486.28L312.02,570.47L293.42,570.47Z"/>
20+
<path android:fillAlpha="0" android:fillColor="#FF000000"
21+
android:pathData="M293.42,570.47L322.04,632L350.66,570.47L332.06,570.47L332.06,486.28L350.66,486.28L322.04,424.75L293.42,486.28L312.02,486.28L312.02,570.47L293.42,570.47Z"
22+
android:strokeAlpha="1" android:strokeColor="#000000" android:strokeWidth="1"/>
23+
</vector>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<vector android:height="24dp" android:viewportHeight="640"
2+
android:viewportWidth="640" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
3+
<path android:fillAlpha="0" android:fillColor="#FF000000"
4+
android:pathData="M2.73,638.39L637.81,638.39L637.81,2.7L2.73,2.7L2.73,638.39Z"
5+
android:strokeAlpha="1" android:strokeColor="#000000" android:strokeWidth="2"/>
6+
<path android:fillAlpha="1" android:fillColor="#00acc1" android:pathData="M190.81,5.07C196.34,5.07 200.81,9.54 200.81,15.07C200.81,54.05 200.81,161 200.81,199.98C200.81,205.51 196.34,209.98 190.81,209.98C153.69,209.98 52.31,209.98 15.19,209.98C9.66,209.98 5.19,205.51 5.19,199.98C5.19,161 5.19,54.05 5.19,15.07C5.19,9.54 9.66,5.07 15.19,5.07C52.31,5.07 153.69,5.07 190.81,5.07Z"/>
7+
<path android:fillAlpha="0.85" android:fillColor="#006064" android:pathData="M267.28,70L206.84,100L267.28,130L267.28,110.5L582.16,110.5L582.16,130L632,100L582.16,70L582.16,89.5L267.28,89.5L267.28,70Z"/>
8+
<path android:fillAlpha="0" android:fillColor="#FF000000"
9+
android:pathData="M267.28,70L206.84,100L267.28,130L267.28,110.5L582.16,110.5L582.16,130L632,100L582.16,70L582.16,89.5L267.28,89.5L267.28,70Z"
10+
android:strokeAlpha="1" android:strokeColor="#000000" android:strokeWidth="1"/>
11+
<path android:fillAlpha="0.85" android:fillColor="#006064" android:pathData="M69.34,580.27L100,633.72L130.66,580.27L110.73,580.27L110.73,275.86L130.66,275.86L100,217L69.34,275.86L89.27,275.86L89.27,580.27L69.34,580.27Z"/>
12+
<path android:fillAlpha="0" android:fillColor="#FF000000"
13+
android:pathData="M69.34,580.27L100,633.72L130.66,580.27L110.73,580.27L110.73,275.86L130.66,275.86L100,217L69.34,275.86L89.27,275.86L89.27,580.27L69.34,580.27Z"
14+
android:strokeAlpha="1" android:strokeColor="#000000" android:strokeWidth="1"/>
15+
</vector>

app/src/main/res/layout/.README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,34 @@ All the constraint layout for preview are defined here along with activity layou
44

55
For quick navigation, all the preview/demo layout should be prefixed with `preview_`
66

7-
All layout should be documented well and minimal style should be added to element.
7+
All layout should be documented well and minimal style should be added to element.
8+
9+
Naming Conventions
10+
---------------------
11+
Each layout must also be named based on sub features. Use following convention to name each features.
12+
13+
- Prefix: **`_positioning_`** | Relative positioning
14+
* Prefix: **`_positioning_`** | Horizontal Axis: left, right, start and end sides
15+
* Prefix: **`_positioning_`** | Vertical Axis: top, bottom sides and text baseline
16+
- Prefix: **`_margins_`** | Margins
17+
- Prefix: **`_positioning_bias_`** | Centering positioning and bias
18+
- Prefix: **`_positioning_circular_`** | Circular positioning _(Added in 1.1)_
19+
- Prefix: **`_visibility_`** | Visibility behavior
20+
- Prefix: **`_dimension_`** | Dimension constraints
21+
* Prefix: **`_ratio_`** | Ratio
22+
* Prefix: **`_percent_`** | Percent dimension
23+
* Prefix: **`_sizing_`** | Min and Max
24+
* Prefix: **`_TBD_`** | `MATCH_CONSTRAINT` dimensions _(Added in 1.1)_
25+
* Prefix: **`_TBD_`** | `WRAP_CONTENT` : enforcing constraints _(Added in 1.1)_
26+
* Prefix: **`_TBD_`** | Widgets dimension constraints
27+
- Prefix: **`_TBD_`** | Chains
28+
* Prefix: **`_TBD_`** | Chain Style
29+
* Prefix: **`_TBD_`** | Weighted chains
30+
* Prefix: **`_TBD_`** | Margins and chains _(Added in 1.1)_
31+
- Prefix: **`_TBD_`** | Virtual Helpers objects
32+
* Prefix: **`_TBD_`** | Guideline
33+
* Prefix: **`_TBD_`** | Barrier
34+
* Prefix: **`_TBD_`** | Group
35+
- Prefix: **`_TBD_`** | Optimizer _(Added in 1.1)_
36+
37+
> NOTE: These feature set is taken from original readme.

app/src/main/res/layout/list_item_layout_preview.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,15 @@
4141
app:layout_constraintTop_toTopOf="parent"
4242
tools:background="@color/md_amber_300"
4343
tools:ignore="ContentDescription"
44-
tools:srcCompat="@mipmap/ic_launcher" />
44+
tools:srcCompat="@drawable/ic_position_center_preview" />
4545

4646
<TextView
4747
android:id="@+id/layout_preview_name"
4848
android:layout_width="0dp"
4949
android:layout_height="0dp"
5050
android:layout_margin="10dp"
5151
android:ellipsize="end"
52+
android:gravity="center_vertical"
5253
android:textAppearance="@style/TextAppearance.AppCompat.Large"
5354
android:textStyle="bold"
5455
app:layout_constraintBottom_toBottomOf="parent"

resources/vector/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Vector Images & Icons
2+
=========
3+
This is the container for RAW vector assets that is used in the project.
4+
Most of the assets are created by simple vector editor at [https://vectr.com](https://vectr.com).
Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)