Skip to content

Commit 85d88c1

Browse files
authored
Merge pull request #4 from CraveFood/3-implement-buttons
Implemented all button styles
2 parents fb6749e + e8f58b3 commit 85d88c1

32 files changed

+417
-87
lines changed

.idea/codeStyles/Project.xml

+4-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle

+25-25
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,32 @@ apply plugin: 'kotlin-android'
55
apply plugin: 'kotlin-android-extensions'
66

77
android {
8-
compileSdkVersion 29
9-
defaultConfig {
10-
applicationId "br.com.farmblocks_android"
11-
minSdkVersion 21
12-
targetSdkVersion 29
13-
versionCode 1
14-
versionName "1.0"
15-
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16-
}
17-
buildTypes {
18-
release {
19-
minifyEnabled false
20-
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21-
}
22-
}
8+
compileSdkVersion 29
9+
defaultConfig {
10+
applicationId "br.com.farmblocks_android"
11+
minSdkVersion 21
12+
targetSdkVersion 29
13+
versionCode 1
14+
versionName "1.0"
15+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16+
}
17+
buildTypes {
18+
release {
19+
minifyEnabled false
20+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
21+
}
22+
}
2323
}
2424

2525
dependencies {
26-
implementation project(path: ':components')
27-
implementation fileTree(dir: 'libs', include: ['*.jar'])
28-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
29-
implementation 'androidx.appcompat:appcompat:1.0.2'
30-
implementation 'androidx.core:core-ktx:1.0.2'
31-
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
32-
implementation 'com.google.android.material:material:1.0.0'
33-
testImplementation 'junit:junit:4.12'
34-
androidTestImplementation 'androidx.test:runner:1.2.0'
35-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
26+
implementation project(path: ':components')
27+
implementation fileTree(dir: 'libs', include: ['*.jar'])
28+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
29+
implementation 'androidx.appcompat:appcompat:1.0.2'
30+
implementation 'androidx.core:core-ktx:1.0.2'
31+
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
32+
implementation 'com.google.android.material:material:1.0.0'
33+
testImplementation 'junit:junit:4.12'
34+
androidTestImplementation 'androidx.test:runner:1.2.0'
35+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
3636
}

app/src/main/AndroidManifest.xml

+25-22
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:dist="http://schemas.android.com/apk/distribution"
4-
package="br.com.farmblocks_android">
2+
<manifest
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:dist="http://schemas.android.com/apk/distribution"
5+
package="br.com.farmblocks_android">
56

6-
<dist:module dist:instant="true"/>
7+
<dist:module dist:instant="true" />
78

8-
<application
9-
android:allowBackup="true"
10-
android:icon="@mipmap/ic_launcher"
11-
android:label="@string/app_name"
12-
android:roundIcon="@mipmap/ic_launcher_round"
13-
android:supportsRtl="true"
14-
android:theme="@style/AppTheme">
15-
<activity
16-
android:name=".TextStylesActivity"
17-
android:label="@string/text_styles">
18-
</activity>
19-
<activity android:name=".MainActivity">
20-
<intent-filter>
21-
<action android:name="android.intent.action.MAIN"/>
9+
<application
10+
android:allowBackup="true"
11+
android:icon="@mipmap/ic_launcher"
12+
android:label="@string/app_name"
13+
android:roundIcon="@mipmap/ic_launcher_round"
14+
android:supportsRtl="true"
15+
android:theme="@style/AppTheme">
16+
<activity android:name=".MainActivity">
17+
<intent-filter>
18+
<action android:name="android.intent.action.MAIN" />
2219

23-
<category android:name="android.intent.category.LAUNCHER"/>
24-
</intent-filter>
25-
</activity>
26-
</application>
20+
<category android:name="android.intent.category.LAUNCHER" />
21+
</intent-filter>
22+
</activity>
23+
<activity
24+
android:name=".TextStylesActivity"
25+
android:label="@string/text_styles"></activity>
26+
<activity
27+
android:name=".ButtonsActivity"
28+
android:label="@string/buttons"></activity>
29+
</application>
2730

2831
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package br.com.farmblocks_android
2+
3+
import android.os.Bundle
4+
import android.view.MenuItem
5+
import androidx.appcompat.app.AppCompatActivity
6+
7+
class ButtonsActivity : AppCompatActivity() {
8+
9+
override fun onCreate(savedInstanceState: Bundle?) {
10+
super.onCreate(savedInstanceState)
11+
setContentView(R.layout.activity_buttons)
12+
13+
supportActionBar?.setDisplayHomeAsUpEnabled(true)
14+
}
15+
16+
override fun onOptionsItemSelected(item: MenuItem): Boolean {
17+
if (item.itemId == android.R.id.home) onBackPressed()
18+
return super.onOptionsItemSelected(item)
19+
}
20+
21+
}

app/src/main/java/br/com/farmblocks_android/MainActivity.kt

+11-7
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@ import kotlinx.android.synthetic.main.activity_main.*
77

88
class MainActivity : AppCompatActivity() {
99

10-
override fun onCreate(savedInstanceState: Bundle?) {
11-
super.onCreate(savedInstanceState)
12-
setContentView(R.layout.activity_main)
10+
override fun onCreate(savedInstanceState: Bundle?) {
11+
super.onCreate(savedInstanceState)
12+
setContentView(R.layout.activity_main)
1313

14-
textViewTextStyles.setOnClickListener {
15-
startActivity(Intent(this, TextStylesActivity::class.java))
16-
}
17-
}
14+
textViewTextStyles.setOnClickListener {
15+
startActivity(Intent(this, TextStylesActivity::class.java))
16+
}
17+
18+
textViewButton.setOnClickListener {
19+
startActivity(Intent(this, ButtonsActivity::class.java))
20+
}
21+
}
1822
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<ScrollView
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
tools:context=".ButtonsActivity">
8+
9+
<LinearLayout
10+
android:layout_width="match_parent"
11+
android:layout_height="wrap_content"
12+
android:gravity="center"
13+
android:orientation="vertical"
14+
android:padding="16dp">
15+
16+
<Button
17+
style="@style/FarmBlocks.Button.Primary"
18+
android:layout_margin="8dp"
19+
android:text="Primary Button"
20+
tools:ignore="HardcodedText" />
21+
22+
<Button
23+
style="@style/FarmBlocks.Button.Secondary"
24+
android:layout_margin="8dp"
25+
android:text="Secondary Button"
26+
tools:ignore="HardcodedText" />
27+
28+
<Button
29+
style="@style/FarmBlocks.Button.Neutral"
30+
android:layout_margin="8dp"
31+
android:text="Neutral Button"
32+
tools:ignore="HardcodedText" />
33+
34+
<Button
35+
style="@style/FarmBlocks.Button.White"
36+
android:layout_margin="8dp"
37+
android:text="White Button"
38+
tools:ignore="HardcodedText" />
39+
40+
<Button
41+
style="@style/FarmBlocks.Button.Accept"
42+
android:layout_margin="8dp"
43+
android:text="Accept Button"
44+
tools:ignore="HardcodedText" />
45+
46+
<Button
47+
style="@style/FarmBlocks.Button.Primary"
48+
android:layout_margin="8dp"
49+
android:enabled="false"
50+
android:text="Primary Button Disabled"
51+
tools:ignore="HardcodedText" />
52+
53+
<Button
54+
style="@style/FarmBlocks.ButtonFlat.Primary"
55+
android:layout_margin="8dp"
56+
android:text="Primary Flat Button"
57+
tools:ignore="HardcodedText" />
58+
59+
<Button
60+
style="@style/FarmBlocks.ButtonFlat.Secondary"
61+
android:layout_margin="8dp"
62+
android:text="Secondary Flat Button"
63+
tools:ignore="HardcodedText" />
64+
65+
<Button
66+
style="@style/FarmBlocks.ButtonFlat.Neutral"
67+
android:layout_margin="8dp"
68+
android:text="Neutral Flat Button"
69+
tools:ignore="HardcodedText" />
70+
71+
<Button
72+
style="@style/FarmBlocks.ButtonFlat.White"
73+
android:layout_margin="8dp"
74+
android:text="White Flat Button"
75+
tools:ignore="HardcodedText" />
76+
77+
<Button
78+
style="@style/FarmBlocks.ButtonFlat.Primary"
79+
android:layout_margin="8dp"
80+
android:enabled="false"
81+
android:text="Primary Flat Button"
82+
tools:ignore="HardcodedText" />
83+
84+
<com.google.android.material.floatingactionbutton.FloatingActionButton
85+
style="@style/FarmBlocks.FloatingActionButton"
86+
android:layout_margin="8dp"
87+
android:src="@drawable/ic_edit" />
88+
89+
<com.google.android.material.floatingactionbutton.FloatingActionButton
90+
style="@style/FarmBlocks.FloatingActionButton.Small"
91+
android:layout_margin="8dp"
92+
android:src="@drawable/ic_edit" />
93+
94+
</LinearLayout>
95+
96+
</ScrollView>
+23-16
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<ScrollView
3-
xmlns:android="http://schemas.android.com/apk/res/android"
4-
xmlns:tools="http://schemas.android.com/tools"
5-
android:layout_width="match_parent"
6-
android:layout_height="match_parent"
7-
tools:context=".MainActivity">
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
xmlns:tools="http://schemas.android.com/tools"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
tools:context=".MainActivity">
88

9-
<LinearLayout
10-
android:layout_width="match_parent"
11-
android:layout_gravity="center"
12-
android:layout_height="wrap_content"
13-
android:padding="16dp"
14-
android:orientation="vertical">
9+
<LinearLayout
10+
android:layout_width="match_parent"
11+
android:layout_height="wrap_content"
12+
android:layout_gravity="center"
13+
android:orientation="vertical"
14+
android:padding="16dp">
1515

16-
<Button android:layout_width="match_parent"
17-
android:text="@string/text_styles"
18-
android:id="@+id/textViewTextStyles"
19-
android:layout_height="wrap_content"/>
16+
<Button
17+
android:id="@+id/textViewTextStyles"
18+
android:layout_width="match_parent"
19+
android:layout_height="wrap_content"
20+
android:text="@string/text_styles" />
2021

21-
</LinearLayout>
22+
<Button
23+
android:id="@+id/textViewButton"
24+
android:layout_width="match_parent"
25+
android:layout_height="wrap_content"
26+
android:text="@string/buttons" />
27+
28+
</LinearLayout>
2229

2330
</ScrollView>

app/src/main/res/values/strings.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<resources>
2-
<string name="app_name">farmblocks-android</string>
3-
<string name="text_styles">Text Styles</string>
2+
<string name="app_name">farmblocks-android</string>
3+
<string name="text_styles">Text Styles</string>
4+
<string name="buttons">Buttons</string>
45
</resources>

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88

99
}
1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:3.4.2'
11+
classpath 'com.android.tools.build:gradle:3.5.0'
1212
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1313
// NOTE: Do not place your application dependencies here; they belong
1414
// in the individual module build.gradle files

components/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ dependencies {
3030
testImplementation 'junit:junit:4.12'
3131
androidTestImplementation 'androidx.test:runner:1.2.0'
3232
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
33+
implementation 'com.google.android.material:material:1.0.0'
3334
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<selector xmlns:android="http://schemas.android.com/apk/res/android">
3+
<item android:color="@color/colorBackgroundButtonDisabled" android:state_enabled="false" />
4+
<item android:color="@color/colorTextGreen" />
5+
</selector>

0 commit comments

Comments
 (0)