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

Commit 5fa7b17

Browse files
committed
[ADDED] [#27] Icon and layout info for the biased example.
Fixes #27
1 parent acf6878 commit 5fa7b17

File tree

4 files changed

+105
-3
lines changed

4 files changed

+105
-3
lines changed

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ import com.hossainkhan.android.demo.base.AppConfig
2323
import javax.inject.Inject
2424
import javax.inject.Singleton
2525

26+
/**
27+
* Provides layout data, which is currently static based on what is available.
28+
*
29+
* In future, we may store the title and description based on layout ID.
30+
*/
2631
@Singleton
2732
class LayoutDataStore @Inject constructor(
2833
private val resources: Resources) {
@@ -44,6 +49,14 @@ class LayoutDataStore @Inject constructor(
4449
thumbnailResourceId = R.drawable.thumb_positioning_center,
4550
title = "Positioning: Centered",
4651
description = "Centered view using constraints on top-bottom and left-right."),
52+
LayoutInformation(
53+
layoutResourceId = R.layout.preview_positioning_bias,
54+
thumbnailResourceId = R.drawable.thumb_positioning_bias,
55+
title = "Positioning: Horizontal and Vertical Bias",
56+
description = "The default when encountering such opposite constraints is to center the widget; but you can tweak the positioning to favor one side over another using the bias attributes:" +
57+
"\n\n" +
58+
" * layout_constraintHorizontal_bias\n" +
59+
" * layout_constraintVertical_bias"),
4760
LayoutInformation(
4861
layoutResourceId = R.layout.preview_positioning_circular,
4962
thumbnailResourceId = R.drawable.thumb_positioning_circular,
@@ -78,8 +91,8 @@ class LayoutDataStore @Inject constructor(
7891
* @return The URL to load the layout blob file.
7992
*/
8093
fun getLayoutUrl(@LayoutRes layoutResourceId: Int): String {
81-
// Containes package name and layout name
82-
// com.hossainkhan.android.demo:layout/preview_positioning_top_left
94+
// Contains package name and layout name
95+
// For example: com.hossainkhan.android.demo:layout/preview_positioning_top_left
8396
val resourceName = resources.getResourceName(layoutResourceId)
8497

8598
if (!resourceName.contains("layout")) {
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<!--
2+
~ Copyright (c) 2018 Hossain Khan
3+
~
4+
~ Licensed under the Apache License, Version 2.0 (the "License");
5+
~ you may not use this file except in compliance with the License.
6+
~ You may obtain a copy of the License at
7+
~
8+
~ http://www.apache.org/licenses/LICENSE-2.0
9+
~
10+
~ Unless required by applicable law or agreed to in writing, software
11+
~ distributed under the License is distributed on an "AS IS" BASIS,
12+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
~ See the License for the specific language governing permissions and
14+
~ limitations under the License.
15+
-->
16+
17+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:width="24dp"
19+
android:height="24dp"
20+
android:viewportWidth="640"
21+
android:viewportHeight="640">
22+
<path
23+
android:fillAlpha="0"
24+
android:fillColor="#FF000000"
25+
android:pathData="M2.73,638.39L637.81,638.39L637.81,2.7L2.73,2.7L2.73,638.39Z"
26+
android:strokeWidth="2"
27+
android:strokeAlpha="1"
28+
android:strokeColor="#000000" />
29+
<path
30+
android:fillAlpha="1"
31+
android:fillColor="#00acc1"
32+
android:pathData="M537.81,317.54C543.34,317.54 547.81,322.02 547.81,327.54C547.81,366.52 547.81,473.48 547.81,512.46C547.81,517.98 543.34,522.46 537.81,522.46C500.69,522.46 399.31,522.46 362.19,522.46C356.66,522.46 352.19,517.98 352.19,512.46C352.19,473.48 352.19,366.52 352.19,327.54C352.19,322.02 356.66,317.54 362.19,317.54C399.31,317.54 500.69,317.54 537.81,317.54Z" />
33+
<path
34+
android:fillAlpha="0.85"
35+
android:fillColor="#006064"
36+
android:pathData="M492.22,265.09L513.75,302.62L535.28,265.09L521.28,265.09L521.28,51.33L535.28,51.33L513.75,10L492.22,51.33L506.21,51.33L506.21,265.09L492.22,265.09Z" />
37+
<path
38+
android:fillAlpha="0"
39+
android:fillColor="#FF000000"
40+
android:pathData="M492.22,265.09L513.75,302.62L535.28,265.09L521.28,265.09L521.28,51.33L535.28,51.33L513.75,10L492.22,51.33L506.21,51.33L506.21,265.09L492.22,265.09Z"
41+
android:strokeWidth="1"
42+
android:strokeAlpha="1"
43+
android:strokeColor="#000000" />
44+
<path
45+
android:fillAlpha="0"
46+
android:fillColor="#FF000000"
47+
android:pathData="M367.69,133.71C367.69,148.28 358.39,160.12 346.92,160.12C335.46,160.12 326.15,148.28 326.15,133.71C326.15,119.13 335.46,107.29 346.92,107.29C358.39,107.29 367.69,119.13 367.69,133.71Z"
48+
android:strokeWidth="8"
49+
android:strokeAlpha="1"
50+
android:strokeColor="#000000" />
51+
<path
52+
android:fillAlpha="0"
53+
android:fillColor="#FF000000"
54+
android:pathData="M420,159.09C420,186.69 411.27,209.09 400.51,209.09C389.76,209.09 381.03,186.69 381.03,159.09C381.03,131.49 389.76,109.09 400.51,109.09C411.27,109.09 420,131.49 420,159.09Z"
55+
android:strokeWidth="8"
56+
android:strokeAlpha="1"
57+
android:strokeColor="#000000" />
58+
<path
59+
android:fillAlpha="0"
60+
android:fillColor="#FF000000"
61+
android:pathData="M367.95,186.29C367.95,200.87 358.64,212.71 347.18,212.71C335.72,212.71 326.41,200.87 326.41,186.29C326.41,171.72 335.72,159.88 347.18,159.88C358.64,159.88 367.95,171.72 367.95,186.29Z"
62+
android:strokeWidth="8"
63+
android:strokeAlpha="1"
64+
android:strokeColor="#000000" />
65+
<path
66+
android:fillAlpha="0"
67+
android:fillColor="#FF000000"
68+
android:pathData="M437.44,211.4L480,109.09"
69+
android:strokeWidth="6"
70+
android:strokeAlpha="1"
71+
android:strokeColor="#303030" />
72+
<path
73+
android:fillAlpha="0"
74+
android:fillColor="#FF000000"
75+
android:pathData="M454.36,129.09C454.36,137.58 451.72,144.47 448.46,144.47C445.21,144.47 442.56,137.58 442.56,129.09C442.56,120.6 445.21,113.71 448.46,113.71C451.72,113.71 454.36,120.6 454.36,129.09Z"
76+
android:strokeWidth="6"
77+
android:strokeAlpha="1"
78+
android:strokeColor="#303030" />
79+
<path
80+
android:fillAlpha="0"
81+
android:fillColor="#FF000000"
82+
android:pathData="M477.18,190.37C477.18,198.86 474.54,205.76 471.28,205.76C468.03,205.76 465.38,198.86 465.38,190.37C465.38,181.88 468.03,174.99 471.28,174.99C474.54,174.99 477.18,181.88 477.18,190.37Z"
83+
android:strokeWidth="6"
84+
android:strokeAlpha="1"
85+
android:strokeColor="#303030" />
86+
</vector>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ Each layout must also be named based on sub features. Use following convention t
3434
* Prefix: **`_TBD_`** | Group
3535
- Prefix: **`_TBD_`** | Optimizer _(Added in 1.1)_
3636

37-
> NOTE: These feature set is taken from original readme.
37+
> NOTE: The list of feature set is taken from original [readme](https://github.com/amardeshbd/android-constraint-layout-cheatsheet/blob/master/README.md).
Lines changed: 3 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)