Add test Theme Activity

This commit is contained in:
Benoit Marty 2019-06-06 13:39:08 +02:00
parent 917282303d
commit 311d8484a2
9 changed files with 366 additions and 4 deletions

View File

@ -3,6 +3,12 @@
<application>
<activity android:name="im.vector.riotredesign.features.debug.TestLinkifyActivity" />
<activity
android:name="im.vector.riotredesign.features.debug.DebugMaterialThemeLightActivity"
android:theme="@style/VectorMaterialThemeDebugLight" />
<activity
android:name="im.vector.riotredesign.features.debug.DebugMaterialThemeDarkActivity"
android:theme="@style/VectorMaterialThemeDebugDark" />
</application>
</manifest>

View File

@ -0,0 +1,65 @@
/*
* Copyright 2019 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.riotredesign.features.debug
import android.os.Bundle
import android.view.Menu
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.google.android.material.snackbar.Snackbar
import im.vector.riotredesign.R
import im.vector.riotredesign.core.utils.toast
import kotlinx.android.synthetic.debug.activity_test_material_theme.*
// Rendering is not the same with VectorBaseActivity
abstract class DebugMaterialThemeActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_test_material_theme)
debugShowSnackbar.setOnClickListener {
Snackbar.make(debugMaterialCoordinator, "Snackbar!", Snackbar.LENGTH_SHORT)
.setAction("Action") { }
.show()
}
debugShowToast.setOnClickListener {
toast("Toast")
}
debugShowDialog.setOnClickListener {
AlertDialog.Builder(this)
.setMessage("Dialog content")
.setIcon(R.drawable.ic_settings_x)
.setPositiveButton("Positive", null)
.setNegativeButton("Negative", null)
.setNeutralButton("Neutral", null)
.show()
}
debugShowBottomSheet.setOnClickListener {
BottomSheetDialogFragment().show(supportFragmentManager, "TAG")
}
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.vector_home, menu)
return true
}
}

View File

@ -0,0 +1,19 @@
/*
* Copyright 2019 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.riotredesign.features.debug
class DebugMaterialThemeDarkActivity : DebugMaterialThemeActivity()

View File

@ -0,0 +1,19 @@
/*
* Copyright 2019 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package im.vector.riotredesign.features.debug
class DebugMaterialThemeLightActivity : DebugMaterialThemeActivity()

View File

@ -122,5 +122,16 @@ class DebugMenuActivity : VectorBaseActivity() {
.build()
)
}
@OnClick(R.id.debug_test_material_theme_light)
fun testMaterialThemeLight() {
startActivity(Intent(this, DebugMaterialThemeLightActivity::class.java))
}
@OnClick(R.id.debug_test_material_theme_dark)
fun testMaterialThemeDark() {
startActivity(Intent(this, DebugMaterialThemeDarkActivity::class.java))
}
}

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<size
android:width="8dp"
android:height="8dp" />
</shape>

View File

@ -13,25 +13,40 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@drawable/linear_divider"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="@dimen/layout_horizontal_margin">
android:padding="@dimen/layout_horizontal_margin"
android:showDividers="middle">
<Button
<com.google.android.material.button.MaterialButton
android:id="@+id/debug_test_text_view_link"
style="@style/VectorButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test linkification" />
<Button
<com.google.android.material.button.MaterialButton
android:id="@+id/debug_test_notification"
style="@style/VectorButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/layout_vertical_margin"
android:text="Test Notification" />
<com.google.android.material.button.MaterialButton
android:id="@+id/debug_test_material_theme_light"
style="@style/VectorButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test Material theme Light" />
<com.google.android.material.button.MaterialButton
android:id="@+id/debug_test_material_theme_dark"
style="@style/VectorButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test Material theme Dark" />
</LinearLayout>
</ScrollView>

View File

@ -0,0 +1,168 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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:id="@+id/debugMaterialCoordinator"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".features.debug.DebugMaterialThemeActivity"
tools:ignore="HardcodedText">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="@drawable/linear_divider"
android:orientation="vertical"
android:padding="16dp"
android:showDividers="middle">
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
app:subtitle="Toolbar Subtitle"
app:title="Toolbar Title" />
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="OutlinedBox.Dense">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="FilledBox">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.Dense"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="FilledBox.Dense">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Material Button Classic"
app:icon="@drawable/ic_settings_x" />
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Material Button OutlinedButton"
app:icon="@drawable/ic_settings_x" />
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Material Button TextButton"
app:icon="@drawable/ic_settings_x" />
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Material Button UnelevatedButton"
app:icon="@drawable/ic_settings_x" />
<com.google.android.material.button.MaterialButton
android:id="@+id/debugShowSnackbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Snackbar" />
<com.google.android.material.button.MaterialButton
android:id="@+id/debugShowToast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Toast" />
<com.google.android.material.button.MaterialButton
android:id="@+id/debugShowDialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Dialog" />
<com.google.android.material.button.MaterialButton
android:id="@+id/debugShowBottomSheet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Bottom Sheet" />
<com.google.android.material.checkbox.MaterialCheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Material CheckBox" />
<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Material Switch" />
<com.google.android.material.card.MaterialCardView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="48dp"
android:text="TextView in MaterialCardView" />
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_settings_x" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -5,4 +5,55 @@
<item name="android:visibility">visible</item>
</style>
<style name="VectorMaterialThemeDebugLight" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="colorPrimary">#7F7F00</item>
<item name="colorPrimaryVariant">#00FF00</item>
<item name="colorOnPrimary">#0000FF</item>
<item name="colorSecondary">#FF00FF</item>
<item name="colorSecondaryVariant">#00FFFF</item>
<item name="colorOnSecondary">#FFF000</item>
<item name="colorError">#FF0000</item>
<item name="colorOnError">#330033</item>
<item name="colorSurface">#003333</item>
<item name="colorOnSurface">#777777</item>
<item name="android:colorBackground">#FF7777</item>
<item name="colorOnBackground">#077700</item>
<!-- TODO is it still required? -->
<item name="colorAccent">#03b381</item>
<item name="android:statusBarColor">#1188FF</item>
<item name="android:navigationBarColor">#FF8811</item>
</style>
<style name="VectorMaterialThemeDebugDark" parent="Theme.MaterialComponents.NoActionBar">
<item name="colorPrimary">#7F7F00</item>
<item name="colorPrimaryVariant">#00FF00</item>
<item name="colorOnPrimary">#0000FF</item>
<item name="colorSecondary">#FF00FF</item>
<item name="colorSecondaryVariant">#00FFFF</item>
<item name="colorOnSecondary">#FFF000</item>
<item name="colorError">#FF0000</item>
<item name="colorOnError">#330033</item>
<item name="colorSurface">#003333</item>
<item name="colorOnSurface">#777777</item>
<item name="android:colorBackground">#FF7777</item>
<item name="colorOnBackground">#077700</item>
<!-- TODO is it still required? -->
<item name="colorAccent">#03b381</item>
<item name="android:statusBarColor">#1188FF</item>
<item name="android:navigationBarColor">#FF8811</item>
</style>
</resources>