Skip to content

Commit

Permalink
For mozilla-mobile#150 - Adds the search bar
Browse files Browse the repository at this point in the history
  • Loading branch information
boek committed Jan 10, 2019
1 parent d102f9b commit 8949739
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 8 deletions.
5 changes: 5 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ dependencies {
implementation Deps.kotlin_stdlib
implementation Deps.androidx_appcompat
implementation Deps.androidx_constraintlayout

implementation Deps.mozilla_browser_awesomebar
implementation Deps.mozilla_browser_toolbar


testImplementation Deps.junit
androidTestImplementation Deps.tools_test_runner
androidTestImplementation Deps.tools_espresso_core
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/org/mozilla/fenix/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.appcompat.app.AppCompatActivity
import org.mozilla.fenix.home.HomeFragment

class HomeActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_home)
Expand All @@ -18,6 +17,5 @@ class HomeActivity : AppCompatActivity() {
replace(R.id.container, HomeFragment.create())
commit()
}

}
}
6 changes: 6 additions & 0 deletions app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import kotlinx.android.synthetic.main.fragment_home.*

import org.mozilla.fenix.R

Expand All @@ -20,6 +21,11 @@ class HomeFragment : Fragment() {
return inflater.inflate(R.layout.fragment_home, container, false)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
toolbar_wrapper.clipToOutline = false
}


companion object {
fun create() = HomeFragment()
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/res/drawable/home_search_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF"/>

<stroke android:width="1dp"
android:color="@color/searchStroke"/>

<padding android:left="2dp"
android:top="2dp"
android:right="2dp"
android:bottom="2dp"/>

<corners android:bottomRightRadius="8dp"
android:bottomLeftRadius="8dp"
android:topLeftRadius="8dp"
android:topRightRadius="8dp"/>
</shape>
39 changes: 33 additions & 6 deletions app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<androidx.constraintlayout.widget.ConstraintLayout 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"
tools:context=".home.HomeFragment">
<androidx.constraintlayout.widget.ConstraintLayout
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"
tools:context=".home.HomeFragment"
android:clipToPadding="false">


<ImageButton
Expand All @@ -28,7 +31,7 @@
app:layout_constraintTop_toTopOf="@id/menuButton" />

<ImageView
android:id="@+id/imageView"
android:id="@+id/wordmark"
android:src="@drawable/ic_logo_wordmark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -37,4 +40,28 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@id/menuButton" />

<FrameLayout
android:id="@+id/toolbar_wrapper"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="64dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:background="@drawable/home_search_background"
app:layout_constraintTop_toBottomOf="@id/wordmark"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
android:outlineProvider="paddedBounds"
android:clipToPadding="false"
android:elevation="5dp">

<mozilla.components.browser.toolbar.BrowserToolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_margin="8dp"
android:background="@android:color/white" />

</FrameLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
2 changes: 2 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
<color name="colorPrimary">#008577</color>
<color name="colorPrimaryDark">#00574B</color>
<color name="colorAccent">#D81B60</color>

<color name="searchStroke">#331b215e</color>
</resources>
5 changes: 5 additions & 0 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ private object Versions {
const val androidx_appcompat = "1.0.2"
const val androidx_constraint_layout = "1.1.3"

const val mozilla_android_components = "0.37.0"

const val junit = "4.12"
const val test_tools = "1.0.2"
const val espresso_core = "2.2.2"
Expand All @@ -27,6 +29,9 @@ object Deps {
const val androidx_appcompat = "androidx.appcompat:appcompat:${Versions.androidx_appcompat}"
const val androidx_constraintlayout = "androidx.constraintlayout:constraintlayout:${Versions.androidx_constraint_layout}"

const val mozilla_browser_awesomebar = "org.mozilla.components:browser-awesomebar:${Versions.mozilla_android_components}"
const val mozilla_browser_toolbar = "org.mozilla.components:browser-toolbar:${Versions.mozilla_android_components}"

const val junit = "junit:junit:${Versions.junit}"
const val tools_test_runner = "com.android.support.test:runner:${Versions.test_tools}"
const val tools_espresso_core = "com.android.support.test.espresso:espresso-core:${Versions.espresso_core}"
Expand Down

0 comments on commit 8949739

Please sign in to comment.