1
0
Fork 0

Closes #378 - Creates Library Fragment UI and adds resources

master
Emily Kager 2019-02-05 13:52:04 -08:00 committed by Jeff Boek
parent 10495657c5
commit 4f3c0ee8ad
22 changed files with 504 additions and 0 deletions

View File

@ -130,6 +130,9 @@ dependencies {
implementation Deps.mozilla_feature_findinpage
implementation Deps.mozilla_support_ktx
implementation Deps.mozilla_ui_colors
implementation Deps.mozilla_ui_icons
implementation Deps.mozilla_lib_crash
testImplementation Deps.junit

View File

@ -0,0 +1,23 @@
/* 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/. */
package org.mozilla.fenix.library
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import org.mozilla.fenix.R
class LibraryFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_library, container, false)
}
}

View File

@ -0,0 +1,45 @@
/* 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/. */
package org.mozilla.fenix.library
import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import kotlinx.android.synthetic.main.library_list_item.view.*
import org.mozilla.fenix.R
class LibraryListItem @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr) {
init {
LayoutInflater.from(context).inflate(R.layout.library_list_item, this, true)
attrs.let {
context.theme.obtainStyledAttributes(
it,
R.styleable.LibraryListItem,
0, 0
).apply {
try {
val id = getResourceId(
R.styleable.LibraryListItem_listItemIcon,
R.drawable.library_icon_logins_circle_background
)
libraryIcon?.background = resources.getDrawable(id, context.theme)
libraryItemTitle?.text = resources.getString(
getResourceId(
R.styleable.LibraryListItem_listItemTitle,
R.string.browser_menu_library
)
)
} finally {
recycle()
}
}
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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/. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M12,22C6.4772,22 2,17.5228 2,12C2,6.4772 6.4772,2 12,2C17.5228,2 22,6.4772 22,12C21.9939,17.5203 17.5203,21.9939 12,22L12,22ZM12,4C7.5817,4 4,7.5817 4,12C4,16.4183 7.5817,20 12,20C16.4183,20 20,16.4183 20,12C19.995,7.5838 16.4162,4.005 12,4ZM16.5,13L11.5,13C11.2239,13 11,12.7761 11,12.5L11,7.5C11,7.2239 11.2239,7 11.5,7C11.7761,7 12,7.2239 12,7.5L12,12L16.5,12C16.7761,12 17,12.2239 17,12.5C17,12.7761 16.7761,13 16.5,13Z"
android:strokeWidth="1"
android:fillColor="#202340"
android:fillType="evenOdd"
android:strokeColor="#00000000"/>
</vector>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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/. -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<size
android:width="48dp"
android:height="48dp" />
<solid android:color="@color/library_history_icon_background" />
</shape>
</item>
<item
android:bottom="8dp"
android:left="8dp"
android:right="8dp"
android:top="8dp">
<vector
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/library_history_icon"
android:fillType="evenOdd"
android:pathData="M12,22C6.4772,22 2,17.5228 2,12C2,6.4772 6.4772,2 12,2C17.5228,2 22,6.4772 22,12C21.9939,17.5203 17.5203,21.9939 12,22L12,22ZM12,4C7.5817,4 4,7.5817 4,12C4,16.4183 7.5817,20 12,20C16.4183,20 20,16.4183 20,12C19.995,7.5838 16.4162,4.005 12,4ZM16.5,13L11.5,13C11.2239,13 11,12.7761 11,12.5L11,7.5C11,7.2239 11.2239,7 11.5,7C11.7761,7 12,7.2239 12,7.5L12,12L16.5,12C16.7761,12 17,12.2239 17,12.5C17,12.7761 16.7761,13 16.5,13Z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
</item>
</layer-list>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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/. -->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/photonGrey30"/>
</shape>

View File

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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/. -->
<LinearLayout 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"
android:orientation="vertical"
tools:context="org.mozilla.fenix.library.LibraryFragment">
<org.mozilla.fenix.library.LibraryListItem
android:id="@+id/librarySessions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/library_sessions"
app:listItemIcon="@drawable/library_icon_sessions_circle_background"
app:listItemTitle="@string/library_sessions" />
<org.mozilla.fenix.library.LibraryListItem
android:id="@+id/libraryScreenshots"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/library_screenshots"
app:listItemIcon="@drawable/library_icon_screenshots_circle_background"
app:listItemTitle="@string/library_screenshots" />
<org.mozilla.fenix.library.LibraryListItem
android:id="@+id/libraryDownloads"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/library_downloads"
app:listItemIcon="@drawable/library_icon_downloads_circle_background"
app:listItemTitle="@string/library_downloads" />
<org.mozilla.fenix.library.LibraryListItem
android:id="@+id/libraryFavorites"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/library_favorites"
app:listItemIcon="@drawable/library_icon_favorites_circle_background"
app:listItemTitle="@string/library_favorites" />
<org.mozilla.fenix.library.LibraryListItem
android:id="@+id/libraryHistory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:listItemIcon="@drawable/library_icon_history_circle_background"
app:listItemTitle="@string/library_history" />
<org.mozilla.fenix.library.LibraryListItem
android:id="@+id/libraryLogins"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/library_logins"
app:listItemIcon="@drawable/library_icon_logins_circle_background"
app:listItemTitle="@string/library_logins" />
</LinearLayout>

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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"
android:layout_width="match_parent"
android:layout_height="@dimen/library_item_height"
android:background="?android:attr/selectableItemBackground"
android:clickable="true"
android:focusable="true">
<ImageView
android:id="@+id/libraryIcon"
android:layout_width="@dimen/library_item_icon_height"
android:layout_height="@dimen/library_item_icon_height"
android:layout_margin="@dimen/library_item_icon_margin"
android:background="@drawable/library_icon_logins_circle_background"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/libraryItemTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:gravity="center_vertical"
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/libraryIcon"
app:layout_constraintTop_toTopOf="parent" />
<View
android:layout_width="0dp"
android:layout_height="1dp"
android:background="@drawable/library_separator"
app:layout_constraintStart_toStartOf="@id/libraryItemTitle"
app:layout_constraintTop_toBottomOf="@id/libraryIcon" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- 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/. -->
<resources>
<declare-styleable name="LibraryListItem">
<attr name="listItemTitle" format="reference" />
<attr name="listItemIcon" format="reference" />
</declare-styleable>
</resources>

View File

@ -22,4 +22,22 @@
<color name="searchPillBackground">#FAFAFC</color>
<color name="searchPillPrimary">#202340</color>
<color name="library_sessions_icon_background">#C0EBFF</color>
<color name="library_sessions_icon">#094490</color>
<color name="library_screenshots_icon_background">#A3FFFF</color>
<color name="library_screenshots_icon">#09616A</color>
<color name="library_downloads_icon_background">#D6CEFF</color>
<color name="library_downloads_icon">#1E1562</color>
<color name="library_favorites_icon_background">#FDD4FF</color>
<color name="library_favorites_icon">#6E006E</color>
<color name="library_history_icon_background">#FFDAEC</color>
<color name="library_history_icon">#720028</color>
<color name="library_key_icon_background">#FFF4C3</color>
<color name="library_key_icon">#C13905</color>
</resources>

View File

@ -7,4 +7,7 @@
<dimen name="glyph_button_width">48dp</dimen>
<dimen name="mozac_browser_menu_corner_radius">14dp</dimen>
<dimen name="toolbar_elevation">7dp</dimen>
<dimen name="library_item_height">56dp</dimen>
<dimen name="library_item_icon_height">40dp</dimen>
<dimen name="library_item_icon_margin">16dp</dimen>
</resources>

View File

@ -90,4 +90,22 @@
<!-- Preference for data choices -->
<string name="preferences_data_choices">Data choices</string>
<!-- Option in Library to open Sessions page -->
<string name="library_sessions">Sessions</string>
<!-- Option in Library to open Screenshots page -->
<string name="library_screenshots">Screenshots</string>
<!-- Option in Library to open Downloads page -->
<string name="library_downloads">Downloads</string>
<!-- Option in Library to open Favorites page -->
<string name="library_favorites">Favorites</string>
<!-- Option in Library to open History page -->
<string name="library_history">History</string>
<!-- Option in Library to open Logins page -->
<string name="library_logins">Logins</string>
</resources>

View File

@ -77,6 +77,9 @@ object Deps {
const val mozilla_service_fretboard = "org.mozilla.components:service-fretboard:${Versions.mozilla_android_components}"
const val mozilla_service_glean = "org.mozilla.components:service-glean:${Versions.mozilla_android_components}"
const val mozilla_ui_colors = "org.mozilla.components:ui-colors:${Versions.mozilla_android_components}"
const val mozilla_ui_icons = "org.mozilla.components:ui-icons:${Versions.mozilla_android_components}"
const val mozilla_lib_crash = "org.mozilla.components:lib-crash:${Versions.mozilla_android_components}"
const val mozilla_support_base = "org.mozilla.components:support-base:${Versions.mozilla_android_components}"