Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add resources module with themes/styles #27

Merged
merged 9 commits into from
Aug 12, 2019
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ android {
dependencies {
implementation project(':core')
implementation project(':feed')
implementation project(':navigation')
api project(':resources')

implementation libraries.androidxAppCompat
implementation libraries.androidxLifecycleViewmodelKtx
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:theme="@style/Theme.Muvi"
tools:ignore="GoogleAppIndexingWarning">

<activity android:name=".MainActivity" />
Expand Down
22 changes: 17 additions & 5 deletions app/src/main/java/com/muvi/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
package com.muvi

import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import com.muvi.navigation.themePlaygroundIntent

class MainActivity : AppCompatActivity() {
class MainActivity : AppCompatActivity(R.layout.activity_main) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool cool cool


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.menu_main, menu)
return true
}

override fun onOptionsItemSelected(item: MenuItem?): Boolean {
return when (item?.itemId) {
R.id.action_theme_playground -> {
startActivity(themePlaygroundIntent())
true
}
else -> super.onOptionsItemSelected(item)
}
}
}
12 changes: 12 additions & 0 deletions app/src/main/res/menu/menu_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<item
android:id="@+id/action_theme_playground"
android:title="@string/action_theme_playground"
android:icon="@drawable/ic_android_24dp"
app:showAsAction="ifRoom" />

</menu>
4 changes: 4 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="app_name">MuVi</string>

<string name="action_theme_playground">Show theme playground</string>

</resources>
10 changes: 0 additions & 10 deletions app/src/main/res/values/styles.xml

This file was deleted.

1 change: 1 addition & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ ext {
koinViewModel : "org.koin:koin-androidx-viewmodel:${versions.koin}",
kotlinStdLib : "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}",
kotlinCoroutinesCore : "org.jetbrains.kotlinx:kotlinx-coroutines-core:${versions.kotlinCoroutines}",
materialComponents : 'com.google.android.material:material:1.1.0-alpha09',
moshi : "com.squareup.moshi:moshi:${versions.moshi}",
moshiKotlinCodegen : "com.squareup.moshi:moshi-kotlin-codegen:${versions.moshi}",
okhttp : "com.squareup.okhttp3:okhttp:${versions.okhttp}",
Expand Down
2 changes: 1 addition & 1 deletion film_detail/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<application>
<activity
android:name=".FilmDetailActivity"
android:theme="@style/AppTheme.NoActionBar" />
android:theme="@style/Theme.Muvi.NoActionBar" />
</application>

<dist:module
Expand Down
5 changes: 5 additions & 0 deletions navigation/src/main/java/com/muvi/navigation/Navigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ fun actorDetailIntent(actorId: String): Intent {
}

fun Intent.extractActorId(): String = getStringExtra(EXTRA_ACTOR_ID)

fun themePlaygroundIntent(): Intent {
return Intent(Intent.ACTION_VIEW)
.setClassName(PACKAGE_NAME, "$PACKAGE_NAME.resources.ThemePlaygroundActivity")
}
9 changes: 9 additions & 0 deletions resources/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

dependencies {
implementation libraries.androidxAppCompat
implementation libraries.androidxConstraintLayout
implementation libraries.kotlinStdLib
implementation libraries.materialComponents
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this guy alphabetizes

}
15 changes: 15 additions & 0 deletions resources/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.muvi.resources">

<application>

<activity android:name=".ThemePlaygroundActivity" />
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a real life app, I guess this Manifest would exist in both the main and debug sourcesets so we only had ThemePlaygroundActivity in debug, but the meta-data block would be alright here since the theme needs it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea I think we could get away with it in debug, theoretically, unless I'm missing something!


<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.muvi.resources

import androidx.appcompat.app.AppCompatActivity

class ThemePlaygroundActivity : AppCompatActivity(R.layout.activity_theme_playground)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very pleased

10 changes: 10 additions & 0 deletions resources/src/main/res/drawable/ic_android_24dp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorOnPrimarySurface">
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<path
android:fillColor="#FF000000"
android:pathData="M6,18c0,0.55 0.45,1 1,1h1v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L11,19h2v3.5c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5L16,19h1c0.55,0 1,-0.45 1,-1L18,8L6,8v10zM3.5,8C2.67,8 2,8.67 2,9.5v7c0,0.83 0.67,1.5 1.5,1.5S5,17.33 5,16.5v-7C5,8.67 4.33,8 3.5,8zM20.5,8c-0.83,0 -1.5,0.67 -1.5,1.5v7c0,0.83 0.67,1.5 1.5,1.5s1.5,-0.67 1.5,-1.5v-7c0,-0.83 -0.67,-1.5 -1.5,-1.5zM15.53,2.16l1.3,-1.3c0.2,-0.2 0.2,-0.51 0,-0.71 -0.2,-0.2 -0.51,-0.2 -0.71,0l-1.48,1.48C13.85,1.23 12.95,1 12,1c-0.96,0 -1.86,0.23 -2.66,0.63L7.85,0.15c-0.2,-0.2 -0.51,-0.2 -0.71,0 -0.2,0.2 -0.2,0.51 0,0.71l1.31,1.31C6.97,3.26 6,5.01 6,7h12c0,-1.99 -0.97,-3.75 -2.47,-4.84zM10,5L9,5L9,4h1v1zM15,5h-1L14,4h1v1z"/>
</vector>
7 changes: 7 additions & 0 deletions resources/src/main/res/font/poppins.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:app="http://schemas.android.com/apk/res-auto"
app:fontProviderAuthority="com.google.android.gms.fonts"
app:fontProviderPackage="com.google.android.gms"
app:fontProviderQuery="Poppins:500,600,700"
app:fontProviderCerts="@array/com_google_android_gms_fonts_certs">
</font-family>
241 changes: 241 additions & 0 deletions resources/src/main/res/layout-land/activity_theme_playground.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ThemePlaygroundActivity">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="16dp"
android:clipToPadding="false">

<com.google.android.material.button.MaterialButton
android:id="@+id/raisedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:text="Raised Button" />

<com.google.android.material.button.MaterialButton
android:id="@+id/unelevatedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toEndOf="@id/raisedButton"
android:text="Unelevated Button" />

<com.google.android.material.button.MaterialButton
android:id="@+id/outlinedButtonButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toEndOf="@id/unelevatedButton"
android:text="Outlined Button" />

<com.google.android.material.button.MaterialButton
android:id="@+id/textButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
style="@style/Widget.MaterialComponents.Button.TextButton"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toEndOf="@id/outlinedButtonButton"
android:text="Text Button" />

<com.google.android.material.chip.Chip
android:id="@+id/inputChip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
style="?attr/chipStandaloneStyle"
app:layout_constraintTop_toBottomOf="@id/raisedButton"
app:layout_constraintStart_toStartOf="parent"
android:text="Input Chip" />

<com.google.android.material.chip.Chip
android:id="@+id/choiceChip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
style="@style/Widget.MaterialComponents.Chip.Choice"
app:layout_constraintTop_toBottomOf="@id/raisedButton"
app:layout_constraintStart_toEndOf="@id/inputChip"
android:text="Choice Chip" />

<com.google.android.material.chip.Chip
android:id="@+id/filterChip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
style="@style/Widget.MaterialComponents.Chip.Filter"
app:layout_constraintTop_toBottomOf="@id/raisedButton"
app:layout_constraintStart_toEndOf="@id/choiceChip"
android:text="Filter Chip" />

<com.google.android.material.chip.Chip
android:id="@+id/actionChip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
app:chipIcon="@drawable/ic_android_24dp"
style="?attr/chipStyle"
app:layout_constraintTop_toBottomOf="@id/raisedButton"
app:layout_constraintStart_toEndOf="@id/filterChip"
android:text="Action Chip" />

<com.google.android.material.checkbox.MaterialCheckBox
android:id="@+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
app:layout_constraintTop_toBottomOf="@id/inputChip"
app:layout_constraintStart_toStartOf="parent"
android:text="Checkbox" />

<com.google.android.material.radiobutton.MaterialRadioButton
android:id="@+id/radioButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
app:layout_constraintTop_toBottomOf="@id/inputChip"
app:layout_constraintStart_toEndOf="@id/checkBox"
android:text="Radio Button" />

<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/switchMaterial"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
app:layout_constraintTop_toBottomOf="@id/inputChip"
app:layout_constraintStart_toEndOf="@id/radioButton"
android:text="Switch" />

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/filledBoxTextField"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
app:layout_constraintTop_toBottomOf="@id/checkBox"
app:layout_constraintStart_toStartOf="parent"
android:hint="Filled Box Text Field">

<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Text" />

</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.textfield.TextInputLayout
android:id="@+id/outlinedBoxTextField"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
app:layout_constraintTop_toBottomOf="@id/checkBox"
app:layout_constraintStart_toEndOf="@id/filledBoxTextField"
android:hint="Outlined Box Text Field">

<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Text" />

</com.google.android.material.textfield.TextInputLayout>

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/floatingActionButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
app:srcCompat="@drawable/ic_android_24dp"
app:layout_constraintTop_toBottomOf="@id/checkBox"
app:layout_constraintStart_toEndOf="@id/outlinedBoxTextField" />

<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
app:layout_constraintTop_toBottomOf="@id/filledBoxTextField"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/card">

<com.google.android.material.tabs.TabItem
android:id="@+id/tab1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tab 1" />

<com.google.android.material.tabs.TabItem
android:id="@+id/tab2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tab 2" />

<com.google.android.material.tabs.TabItem
android:id="@+id/tab3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tab 3" />

</com.google.android.material.tabs.TabLayout>

<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottomNavigation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
app:menu="@menu/menu_bottom_navigation"
app:layout_constraintTop_toBottomOf="@id/tabs"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/card" />

<com.google.android.material.card.MaterialCardView
android:id="@+id/card"
android:layout_width="360dp"
android:layout_height="160dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
app:layout_constraintTop_toBottomOf="@id/filledBoxTextField"
app:layout_constraintEnd_toEndOf="parent">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Card" />

</com.google.android.material.card.MaterialCardView>

</androidx.constraintlayout.widget.ConstraintLayout>

</ScrollView>
Loading