diff --git a/MaterialThemeBuilder/README.md b/MaterialThemeBuilder/README.md deleted file mode 100644 index 7d172a0a..00000000 --- a/MaterialThemeBuilder/README.md +++ /dev/null @@ -1,34 +0,0 @@ -## Build a Material Theme -Build a Material Theme lets you create your own Material theme by customizing values for color, typography, and shape. See how these values appear when applied to Material Components and discover how to implement your custom theme in your own projects. Build a Material Theme is also available for the web as a remixable project on [Glitch](https://glitch.com/~material-theme-builder). - -## Overview -Material Components for Android supports Material Theming by exposing top level theme attributes for color, typography and shape. Customizing these attributes will apply your custom theme throughout your entire app. - -This project shows how you can organize and use your theme and style resources to take advantage of the robust support for theming in Material Components for Android. - -## Change values for typography, shape, and color -By default, apps built with Material Components inherit our baseline theme values. To begin customizing, override properties in `color.xml`, `type.xml` and `shape.xml`. Each file includes detailed comments that illustrate how each subsystem can be customized. - -### type.xml -To change your theme’s typography, we recommend using [Google Fonts](https://fonts.google.com/) and choosing a font family that best reflects your style. Set TextApperances to use your custom font and additional type properties to apply a custom type scale globally. [Learn how to add fonts in Android Studio](https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts) - -### shape.xml -To systematically apply shape throughout your app, it helps to understand that components are grouped by size into categories of small, medium and large. The shape of each component size group can be themed by customizing its ShapeApperance style. We recommend using our [shape customization tool](https://material.io/design/shape/about-shape.html#shape-customization-tool) to help you pick your corner family and size values. - -### color.xml -To change your theme's color scheme, replace the existing HEX color values with your custom HEX values. This project has both light and dark themes, toggle between them within the app to see your changes. Use our [color palette generator](https://material.io/design/color/the-color-system.html#tools-for-picking-colors) to help come up with pairings and check your color contrast. - -## Get Started -Clone the material-components-android-examples repository - -``` -git clone https://github.com/material-components/material-components-android-examples.git -``` - -In Android Studio - Choose ‘Open an existing Android Studio Project’ and select ‘material-components-android-examples/MaterialThemeBuilder’ - -Sync, build and run the project. The project, by default, will be configured with the baseline Material theme. - -Under the ‘res’ folder, open `color.xml`, `type.xml` and `shape.xml`. Each file has detailed comments describing the Material subsystem it controls. Try modifying each subsystem, re-running the app and seeing how changes are propagated throughout the app. - -Once you build your Material theme, move the theme resources (`color.xml`, `type.xml`, `shape.xml`, `styles.xml`, `themes.xml` and `night/themes.xml`) over to your app to start using your Material theme in your own projects. diff --git a/MaterialThemeBuilder/app/build.gradle b/MaterialThemeBuilder/app/build.gradle deleted file mode 100644 index 4387a014..00000000 --- a/MaterialThemeBuilder/app/build.gradle +++ /dev/null @@ -1,44 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' - -android { - compileSdkVersion 29 - defaultConfig { - applicationId "io.material.materialthemebuilder" - minSdkVersion 23 - targetSdkVersion 29 - versionCode 1 - versionName "1.0" - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - } - buildTypes { - release { - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - compileOptions { - sourceCompatibility = 1.8 - targetCompatibility = 1.8 - } - kotlinOptions { - jvmTarget = "1.8" - } -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - - // Kotlin - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - - // AndroidX - implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4' - implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha01' - implementation 'androidx.core:core-ktx:1.1.0' - - //MDC - implementation 'com.google.android.material:material:1.2.0-alpha03' -} diff --git a/MaterialThemeBuilder/app/proguard-rules.pro b/MaterialThemeBuilder/app/proguard-rules.pro deleted file mode 100644 index f1b42451..00000000 --- a/MaterialThemeBuilder/app/proguard-rules.pro +++ /dev/null @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile diff --git a/MaterialThemeBuilder/app/src/main/AndroidManifest.xml b/MaterialThemeBuilder/app/src/main/AndroidManifest.xml deleted file mode 100644 index 5d1010f9..00000000 --- a/MaterialThemeBuilder/app/src/main/AndroidManifest.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/MaterialThemeBuilder/app/src/main/ic_launcher-web.png b/MaterialThemeBuilder/app/src/main/ic_launcher-web.png deleted file mode 100644 index ab7a270e..00000000 Binary files a/MaterialThemeBuilder/app/src/main/ic_launcher-web.png and /dev/null differ diff --git a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/App.kt b/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/App.kt deleted file mode 100644 index c65effd2..00000000 --- a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/App.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2019 The Android Open Source Project - * - * 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 io.material.materialthemebuilder - -import android.app.Application -import android.content.Context -import io.material.materialthemebuilder.data.PreferenceRepository - -class App : Application() { - - lateinit var preferenceRepository: PreferenceRepository - - override fun onCreate() { - super.onCreate() - preferenceRepository = PreferenceRepository( - getSharedPreferences(DEFAULT_PREFERENCES, Context.MODE_PRIVATE) - ) - } - - companion object { - const val DEFAULT_PREFERENCES = "default_preferences" - } -} diff --git a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/data/PreferenceRepository.kt b/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/data/PreferenceRepository.kt deleted file mode 100644 index f12c0eaa..00000000 --- a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/data/PreferenceRepository.kt +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2019 The Android Open Source Project - * - * 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 io.material.materialthemebuilder.data - -import android.content.SharedPreferences -import androidx.appcompat.app.AppCompatDelegate -import androidx.lifecycle.LiveData -import androidx.lifecycle.MutableLiveData - -/** - * A simple data repository for in-app settings. - */ -class PreferenceRepository(private val sharedPreferences: SharedPreferences) { - - val nightMode: Int - get() = sharedPreferences.getInt(PREFERENCE_NIGHT_MODE, PREFERENCE_NIGHT_MODE_DEF_VAL) - - private val _nightModeLive: MutableLiveData = MutableLiveData() - val nightModeLive: LiveData - get() = _nightModeLive - - var isDarkTheme: Boolean = false - get() = nightMode == AppCompatDelegate.MODE_NIGHT_YES - set(value) { - sharedPreferences.edit().putInt(PREFERENCE_NIGHT_MODE, if (value) { - AppCompatDelegate.MODE_NIGHT_YES - } else { - AppCompatDelegate.MODE_NIGHT_NO - }).apply() - field = value - } - - private val _isDarkThemeLive: MutableLiveData = MutableLiveData() - val isDarkThemeLive: LiveData - get() = _isDarkThemeLive - - private val preferenceChangedListener = - SharedPreferences.OnSharedPreferenceChangeListener { _, key -> - when (key) { - PREFERENCE_NIGHT_MODE -> { - _nightModeLive.value = nightMode - _isDarkThemeLive.value = isDarkTheme - } - } - } - - init { - // Init preference LiveData objects. - _nightModeLive.value = nightMode - _isDarkThemeLive.value = isDarkTheme - - sharedPreferences.registerOnSharedPreferenceChangeListener(preferenceChangedListener) - } - - companion object { - private const val PREFERENCE_NIGHT_MODE = "preference_night_mode" - private const val PREFERENCE_NIGHT_MODE_DEF_VAL = AppCompatDelegate.MODE_NIGHT_NO - } -} diff --git a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/MainActivity.kt b/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/MainActivity.kt deleted file mode 100644 index 7482621f..00000000 --- a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/MainActivity.kt +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2019 The Android Open Source Project - * - * 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 io.material.materialthemebuilder.ui - -import androidx.appcompat.app.AppCompatActivity -import android.os.Bundle -import androidx.lifecycle.Observer -import com.google.android.material.tabs.TabLayout -import androidx.viewpager.widget.ViewPager -import io.material.materialthemebuilder.R -import io.material.materialthemebuilder.App -import io.material.materialthemebuilder.ui.instruction.InstructionsFragment -import io.material.materialthemebuilder.ui.themesummary.ThemeSummaryFragment -import io.material.materialthemebuilder.ui.component.ComponentFragment - -/** - * Single activity which contains the [MainViewPagerAdapter] that shows the [InstructionsFragment], - * [ThemeSummaryFragment] and [ComponentFragment]. - */ -class MainActivity : AppCompatActivity() { - - private lateinit var viewPager: ViewPager - private lateinit var tabLayout: TabLayout - - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContentView(R.layout.activity_main) - viewPager = findViewById(R.id.view_pager) - tabLayout = findViewById(R.id.tab_layout) - - tabLayout.setupWithViewPager(viewPager) - val adapter = MainViewPagerAdapter(this, supportFragmentManager) - viewPager.adapter = adapter - - (application as App).preferenceRepository - .nightModeLive.observe(this, Observer { nightMode -> - nightMode?.let { delegate.localNightMode = it } - } - ) - } -} diff --git a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/MainViewPagerAdapter.kt b/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/MainViewPagerAdapter.kt deleted file mode 100644 index 20f6a2b9..00000000 --- a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/MainViewPagerAdapter.kt +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2019 The Android Open Source Project - * - * 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 io.material.materialthemebuilder.ui - -import android.content.Context -import androidx.fragment.app.Fragment -import androidx.fragment.app.FragmentManager -import androidx.fragment.app.FragmentStatePagerAdapter -import io.material.materialthemebuilder.R -import io.material.materialthemebuilder.ui.component.ComponentFragment -import io.material.materialthemebuilder.ui.instruction.InstructionsFragment -import io.material.materialthemebuilder.ui.themesummary.ThemeSummaryFragment - -/** - * View pager to show all tabbed destinations - Instructions, Theme Summary and Components. - */ -class MainViewPagerAdapter( - private val context: Context, - fragmentManager: FragmentManager -) : FragmentStatePagerAdapter(fragmentManager) { - - enum class MainFragments(val titleRes: Int) { - INSTRUCTIONS(R.string.tab_title_instructions), - THEME_SUMMARY(R.string.tab_title_theme_summary), - COMPONENTS(R.string.tab_title_components) - } - - override fun getCount(): Int = MainFragments.values().size - - private fun getItemType(position: Int): MainFragments { - return MainFragments.values()[position] - } - - override fun getPageTitle(position: Int): CharSequence? { - return context.getString(getItemType(position).titleRes) - } - - override fun getItem(position: Int): Fragment { - return when (getItemType(position)) { - MainFragments.INSTRUCTIONS -> InstructionsFragment() - MainFragments.THEME_SUMMARY -> ThemeSummaryFragment() - MainFragments.COMPONENTS -> ComponentFragment() - } - } -} diff --git a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/component/BottomSheetFragment.kt b/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/component/BottomSheetFragment.kt deleted file mode 100644 index 81d46fad..00000000 --- a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/component/BottomSheetFragment.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2019 The Android Open Source Project - * - * 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 io.material.materialthemebuilder.ui.component - -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import com.google.android.material.bottomsheet.BottomSheetDialogFragment -import io.material.materialthemebuilder.R - -/** - * A simple Modal Bottom Sheet. - */ -class BottomSheetFragment : BottomSheetDialogFragment() { - - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - return inflater.inflate(R.layout.fragment_bottom_sheet, container, false) - } - - companion object { - const val FRAGMENT_TAG = "bottom_sheet_fragment_tag" - } -} diff --git a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/component/Component.kt b/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/component/Component.kt deleted file mode 100644 index a162d535..00000000 --- a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/component/Component.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2019 The Android Open Source Project - * - * 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 io.material.materialthemebuilder.ui.component - -/** - * Enumeration of all components to be displayed by [ComponentAdapter]. - * - * All components in this enum will be shown by [ComponentAdapter]. The order of the components - * here will be the order they are displayed in by [ComponentAdapter]. - */ -enum class Component { - BUTTON, - FAB, - CARD, - TOP_APP_BAR, - CHIP, - DRAWER, - TEXT_FIELD, - BOTTOM_NAVIGATION, - SWITCH, - RADIO_BUTTON, - CHECKBOX, - BOTTOM_APP_BAR, - TABS, - SNACKBAR, - DIALOG, - BOTTOM_SHEET -} diff --git a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/component/ComponentAdapter.kt b/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/component/ComponentAdapter.kt deleted file mode 100644 index d8a88530..00000000 --- a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/component/ComponentAdapter.kt +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2019 The Android Open Source Project - * - * 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 io.material.materialthemebuilder.ui.component - -import android.view.ViewGroup -import androidx.recyclerview.widget.DiffUtil -import androidx.recyclerview.widget.ListAdapter - -/** - * An adapter to display all [Component]s using their corresponding [ComponentViewHolder]. - */ -class ComponentAdapter( - private val listener: ComponentAdapterListener -) : ListAdapter(DIFF_CALLBACK) { - - interface ComponentAdapterListener { - fun onShowBottomSheetClicked() - } - - override fun getItemViewType(position: Int): Int = getItem(position).ordinal - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ComponentViewHolder { - return ComponentViewHolder.create(parent, viewType, listener) - } - - override fun onBindViewHolder(holder: ComponentViewHolder, position: Int) { - holder.bind(getItem(position)) - } - - companion object { - private val DIFF_CALLBACK = object : DiffUtil.ItemCallback() { - override fun areItemsTheSame(oldItem: Component, newItem: Component): Boolean { - return oldItem == newItem - } - override fun areContentsTheSame(oldItem: Component, newItem: Component): Boolean { - return oldItem == newItem - } - } - } -} diff --git a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/component/ComponentFragment.kt b/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/component/ComponentFragment.kt deleted file mode 100644 index 6db56fdf..00000000 --- a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/component/ComponentFragment.kt +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2019 The Android Open Source Project - * - * 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 io.material.materialthemebuilder.ui.component - -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.fragment.app.Fragment -import androidx.recyclerview.widget.RecyclerView -import androidx.recyclerview.widget.LinearLayoutManager -import io.material.materialthemebuilder.R - -/** - * Fragment to hold a list of all [Component]s. - */ -class ComponentFragment : Fragment(), ComponentAdapter.ComponentAdapterListener { - - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - return inflater.inflate(R.layout.fragment_component, container, false) - } - - override fun onViewCreated(view: View, savedInstanceBundle: Bundle?) { - super.onViewCreated(view, savedInstanceBundle) - - val recyclerView: RecyclerView = view.findViewById(R.id.recycler_view) - val adapter = ComponentAdapter(this) - recyclerView.layoutManager = LinearLayoutManager(requireContext()) - recyclerView.adapter = adapter - adapter.submitList(Component.values().toList()) - } - - override fun onShowBottomSheetClicked() { - BottomSheetFragment().show(requireFragmentManager(), BottomSheetFragment.FRAGMENT_TAG) - } -} diff --git a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/component/ComponentViewHolder.kt b/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/component/ComponentViewHolder.kt deleted file mode 100644 index f340f966..00000000 --- a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/component/ComponentViewHolder.kt +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright 2019 The Android Open Source Project - * - * 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 io.material.materialthemebuilder.ui.component - -import android.view.Gravity -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import android.widget.FrameLayout -import androidx.core.content.ContextCompat -import androidx.drawerlayout.widget.DrawerLayout -import androidx.recyclerview.widget.RecyclerView -import com.google.android.material.bottomappbar.BottomAppBar -import com.google.android.material.button.MaterialButton -import com.google.android.material.dialog.MaterialAlertDialogBuilder -import com.google.android.material.navigation.NavigationView -import com.google.android.material.snackbar.Snackbar -import io.material.materialthemebuilder.R -import io.material.materialthemebuilder.ui.component.Component.BUTTON -import io.material.materialthemebuilder.ui.component.Component.FAB -import io.material.materialthemebuilder.ui.component.Component.CARD -import io.material.materialthemebuilder.ui.component.Component.TOP_APP_BAR -import io.material.materialthemebuilder.ui.component.Component.CHIP -import io.material.materialthemebuilder.ui.component.Component.DRAWER -import io.material.materialthemebuilder.ui.component.Component.TEXT_FIELD -import io.material.materialthemebuilder.ui.component.Component.BOTTOM_NAVIGATION -import io.material.materialthemebuilder.ui.component.Component.SWITCH -import io.material.materialthemebuilder.ui.component.Component.RADIO_BUTTON -import io.material.materialthemebuilder.ui.component.Component.CHECKBOX -import io.material.materialthemebuilder.ui.component.Component.BOTTOM_APP_BAR -import io.material.materialthemebuilder.ui.component.Component.TABS -import io.material.materialthemebuilder.ui.component.Component.SNACKBAR -import io.material.materialthemebuilder.ui.component.Component.DIALOG -import io.material.materialthemebuilder.ui.component.Component.BOTTOM_SHEET - -/** - * Sealed class to define all [RecyclerView.ViewHolder]s used to display [Component]s. - */ -sealed class ComponentViewHolder(val view: View) : RecyclerView.ViewHolder(view) { - - open fun bind(component: Component) { - // Override in subclass if needed. - } - - class ButtonComponentViewHolder( - parent: ViewGroup - ) : ComponentViewHolder(inflate(parent, R.layout.component_buttons)) - - class FabComponentViewHolder( - parent: ViewGroup - ) : ComponentViewHolder(inflate(parent, R.layout.component_fabs)) - - class CardComponentViewHolder( - parent: ViewGroup - ) : ComponentViewHolder(inflate(parent, R.layout.component_cards)) - - class TopAppBarComponentViewHolder( - parent: ViewGroup - ) : ComponentViewHolder(inflate(parent, R.layout.component_top_app_bar)) - - class ChipComponentViewHolder( - parent: ViewGroup - ) : ComponentViewHolder(inflate(parent, R.layout.component_chips)) - - class DrawerComponentViewHolder( - parent: ViewGroup - ) : ComponentViewHolder(inflate(parent, R.layout.component_drawer)) { - private val drawerLayout: DrawerLayout = view.findViewById(R.id.drawer_layout) - private val navigationView: NavigationView = view.findViewById(R.id.nav_view) - - override fun bind(component: Component) { - drawerLayout.openDrawer(Gravity.LEFT) - navigationView.setNavigationItemSelectedListener { true } - navigationView.setCheckedItem(R.id.nav_item_one) - } - } - - class TextFieldComponentViewHolder( - parent: ViewGroup - ) : ComponentViewHolder(inflate(parent, R.layout.component_text_field)) - - class BottomNavigationComponentViewHolder( - parent: ViewGroup - ) : ComponentViewHolder(inflate(parent, R.layout.component_bottom_navigation)) - - class SwitchComponentViewHolder( - parent: ViewGroup - ) : ComponentViewHolder(inflate(parent, R.layout.component_switch)) - - class RadioButtonComponentViewHolder( - parent: ViewGroup - ) : ComponentViewHolder(inflate(parent, R.layout.component_radio_button)) - - class CheckboxComponentViewHolder( - parent: ViewGroup - ) : ComponentViewHolder(inflate(parent, R.layout.component_checkbox)) - - class BottomAppBarComponentViewHolder( - parent: ViewGroup - ) : ComponentViewHolder(inflate(parent, R.layout.component_bottom_app_bar)) { - private val bottomAppBar: BottomAppBar = view.findViewById(R.id.bottom_app_bar) - - override fun bind(component: Component) { - bottomAppBar.overflowIcon = ContextCompat.getDrawable( - bottomAppBar.context, - R.drawable.ic_more_vert_on_surface_24dp - ) - } - } - - class TabsComponentViewHolder( - parent: ViewGroup - ) : ComponentViewHolder(inflate(parent, R.layout.component_tabs)) - - class SnackbarComponentViewHolder( - parent: ViewGroup - ) : ComponentViewHolder(inflate(parent, R.layout.component_snackbar)) { - - init { - val container: FrameLayout = view.findViewById(R.id.snackbar_container) - val snackbarView = Snackbar.make( - container, - R.string.snackbar_message_text, - Snackbar.LENGTH_INDEFINITE - ) - .setAction(R.string.snackbar_action_text) { } - .view - (snackbarView.layoutParams as FrameLayout.LayoutParams).gravity = Gravity.CENTER - - container.addView(snackbarView) - } - } - - class DialogComponentViewHolder( - parent: ViewGroup - ) : ComponentViewHolder(inflate(parent, R.layout.component_dialog)) { - init { - val button = view.findViewById(R.id.button) - button.setOnClickListener { - showDialog() - } - } - - private fun showDialog() { - MaterialAlertDialogBuilder(view.context) - .setTitle(R.string.text_headline_6) - .setMessage(R.string.lorem_ipsum) - .setPositiveButton(R.string.text_button, null) - .setNegativeButton(R.string.text_button, null) - .show() - } - } - - class BottomSheetComponentViewHolder( - parent: ViewGroup, - listener: ComponentAdapter.ComponentAdapterListener - ) : ComponentViewHolder(inflate(parent, R.layout.component_bottom_sheet)) { - init { - view.findViewById(R.id.button).setOnClickListener { - listener.onShowBottomSheetClicked() - } - } - } - - companion object { - fun create( - parent: ViewGroup, - viewType: Int, - listener: ComponentAdapter.ComponentAdapterListener - ): ComponentViewHolder { - return when (Component.values()[viewType]) { - BUTTON -> ComponentViewHolder.ButtonComponentViewHolder(parent) - FAB -> ComponentViewHolder.FabComponentViewHolder(parent) - CARD -> ComponentViewHolder.CardComponentViewHolder(parent) - TOP_APP_BAR -> ComponentViewHolder.TopAppBarComponentViewHolder(parent) - CHIP -> ComponentViewHolder.ChipComponentViewHolder(parent) - DRAWER -> ComponentViewHolder.DrawerComponentViewHolder(parent) - TEXT_FIELD -> ComponentViewHolder.TextFieldComponentViewHolder(parent) - BOTTOM_NAVIGATION -> ComponentViewHolder.BottomNavigationComponentViewHolder(parent) - SWITCH -> ComponentViewHolder.SwitchComponentViewHolder(parent) - RADIO_BUTTON -> ComponentViewHolder.RadioButtonComponentViewHolder(parent) - CHECKBOX -> ComponentViewHolder.CheckboxComponentViewHolder(parent) - BOTTOM_APP_BAR -> ComponentViewHolder.BottomAppBarComponentViewHolder(parent) - TABS -> ComponentViewHolder.TabsComponentViewHolder(parent) - SNACKBAR -> ComponentViewHolder.SnackbarComponentViewHolder(parent) - DIALOG -> ComponentViewHolder.DialogComponentViewHolder(parent) - BOTTOM_SHEET -> ComponentViewHolder.BottomSheetComponentViewHolder(parent, listener) - } - } - - private fun inflate(parent: ViewGroup, layout: Int): View { - return LayoutInflater.from(parent.context).inflate(layout, parent, false) - } - } -} diff --git a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/instruction/InstructionsFragment.kt b/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/instruction/InstructionsFragment.kt deleted file mode 100644 index ec204ae6..00000000 --- a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/instruction/InstructionsFragment.kt +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2019 The Android Open Source Project - * - * 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 io.material.materialthemebuilder.ui.instruction - -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.fragment.app.Fragment -import androidx.lifecycle.Observer -import com.google.android.material.switchmaterial.SwitchMaterial -import io.material.materialthemebuilder.App -import io.material.materialthemebuilder.R - -/** - * Fragment to display static instructions text and in-app theming options. - */ -class InstructionsFragment : Fragment() { - - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - return inflater.inflate(R.layout.fragment_instructions, container, false) - } - - override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - super.onViewCreated(view, savedInstanceState) - val darkThemeSwitch: SwitchMaterial = view.findViewById(R.id.dark_theme_switch) - val preferenceRepository = (requireActivity().application as App).preferenceRepository - - preferenceRepository.isDarkThemeLive.observe(this, Observer { isDarkTheme -> - isDarkTheme?.let { darkThemeSwitch.isChecked = it } - }) - - darkThemeSwitch.setOnCheckedChangeListener { _, checked -> - preferenceRepository.isDarkTheme = checked - } - } -} diff --git a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/themesummary/SubsystemAdapter.kt b/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/themesummary/SubsystemAdapter.kt deleted file mode 100644 index 518e0af5..00000000 --- a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/themesummary/SubsystemAdapter.kt +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2019 The Android Open Source Project - * - * 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 io.material.materialthemebuilder.ui.themesummary - -import android.view.ViewGroup -import androidx.recyclerview.widget.DiffUtil -import androidx.recyclerview.widget.ListAdapter - -/** - * Adapter to display [Subsystem]s using their corresponding [SubsystemViewHolder]. - */ -class SubsystemAdapter : ListAdapter(DIFF_CALLBACK) { - - override fun getItemViewType(position: Int): Int = getItem(position).ordinal - - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SubsystemViewHolder { - return SubsystemViewHolder.create(parent, viewType) - } - - override fun onBindViewHolder(holder: SubsystemViewHolder, position: Int) { - holder.bind(getItem(position)) - } - - companion object { - private val DIFF_CALLBACK = object : DiffUtil.ItemCallback() { - override fun areItemsTheSame(oldItem: Subsystem, newItem: Subsystem): Boolean { - return oldItem == newItem - } - override fun areContentsTheSame(oldItem: Subsystem, newItem: Subsystem): Boolean { - return oldItem == newItem - } - } - } -} diff --git a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/themesummary/SubsystemViewHolder.kt b/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/themesummary/SubsystemViewHolder.kt deleted file mode 100644 index 919cad14..00000000 --- a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/themesummary/SubsystemViewHolder.kt +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2019 The Android Open Source Project - * - * 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 io.material.materialthemebuilder.ui.themesummary - -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.recyclerview.widget.RecyclerView -import io.material.materialthemebuilder.R -import io.material.materialthemebuilder.ui.themesummary.Subsystem.COLOR -import io.material.materialthemebuilder.ui.themesummary.Subsystem.TYPE -import io.material.materialthemebuilder.ui.themesummary.Subsystem.SHAPE - -/** - * Sealed class to define all [RecyclerView.ViewHolder]s used to display [Subsystem]s. - */ -sealed class SubsystemViewHolder(val view: View) : RecyclerView.ViewHolder(view) { - - open fun bind(subsystem: Subsystem) { - // Override in subclass if needed. - } - - class ColorSubsystemViewHolder( - parent: ViewGroup - ) : SubsystemViewHolder(inflate(parent, R.layout.subsystem_color)) - - class TypeSubsystemViewHolder( - parent: ViewGroup - ) : SubsystemViewHolder(inflate(parent, R.layout.subsystem_type)) - - class ShapeSubsystemViewHolder( - parent: ViewGroup - ) : SubsystemViewHolder(inflate(parent, R.layout.subsystem_shape)) - - companion object { - fun create(parent: ViewGroup, viewType: Int): SubsystemViewHolder { - return when (Subsystem.values()[viewType]) { - COLOR -> SubsystemViewHolder.ColorSubsystemViewHolder(parent) - TYPE -> SubsystemViewHolder.TypeSubsystemViewHolder(parent) - SHAPE -> SubsystemViewHolder.ShapeSubsystemViewHolder(parent) - } - } - - private fun inflate(parent: ViewGroup, layout: Int): View { - return LayoutInflater.from(parent.context).inflate(layout, parent, false) - } - } -} diff --git a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/themesummary/ThemeSummaryFragment.kt b/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/themesummary/ThemeSummaryFragment.kt deleted file mode 100644 index a709a2ec..00000000 --- a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/ui/themesummary/ThemeSummaryFragment.kt +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2019 The Android Open Source Project - * - * 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 io.material.materialthemebuilder.ui.themesummary - -import android.os.Bundle -import android.view.LayoutInflater -import android.view.View -import android.view.ViewGroup -import androidx.fragment.app.Fragment -import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView -import io.material.materialthemebuilder.R - -/** - * Fragment to display a list of subsystems that show the values of this app's theme. - */ -class ThemeSummaryFragment : Fragment() { - - override fun onCreateView( - inflater: LayoutInflater, - container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - return inflater.inflate(R.layout.fragment_theme_summary, container, false) - } - - override fun onViewCreated(view: View, savedInstanceBundle: Bundle?) { - super.onViewCreated(view, savedInstanceBundle) - - val adapter = SubsystemAdapter() - val recyclerView: RecyclerView = view.findViewById(R.id.recycler_view) - recyclerView.layoutManager = LinearLayoutManager(requireContext()) - recyclerView.adapter = adapter - adapter.submitList(Subsystem.values().toList()) - } -} diff --git a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/widget/ColorAttributeView.kt b/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/widget/ColorAttributeView.kt deleted file mode 100644 index 88a273b6..00000000 --- a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/widget/ColorAttributeView.kt +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2019 The Android Open Source Project - * - * 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 io.material.materialthemebuilder.widget - -import android.content.Context -import android.graphics.Color -import android.util.AttributeSet -import android.view.View -import android.widget.FrameLayout -import androidx.appcompat.widget.AppCompatTextView -import io.material.materialthemebuilder.R - -/** - * Composite view to show an item containing a text label and a [ColorDotView]. - */ -class ColorAttributeView @JvmOverloads constructor( - context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = 0, - defStyleRes: Int = 0 -) : FrameLayout(context, attrs, defStyleAttr, defStyleRes) { - - private val colorAttributeTextView: AppCompatTextView - private val colorDotView: ColorDotView - - private var attributeText: String = "" - set(value) { - colorAttributeTextView.text = value - field = value - } - - private var dotFillColor: Int = Color.LTGRAY - set(value) { - colorDotView.fillColor = value - field = value - } - - private var dotStrokeColor: Int = Color.DKGRAY - set(value) { - colorDotView.strokeColor = value - field = value - } - - init { - val view = View.inflate(context, R.layout.color_attribute_view_layout, this) - colorAttributeTextView = view.findViewById(R.id.color_attribute) - colorDotView = view.findViewById(R.id.color_dot) - - val a = context.theme.obtainStyledAttributes( - attrs, - R.styleable.ColorAttributeView, - defStyleAttr, - defStyleRes - ) - attributeText = a.getString( - R.styleable.ColorAttributeView_android_text - ) ?: attributeText - dotFillColor = a.getColor(R.styleable.ColorAttributeView_colorFillColor, dotFillColor) - dotStrokeColor = a.getColor( - R.styleable.ColorAttributeView_colorStrokeColor, - dotStrokeColor - ) - a.recycle() - } -} diff --git a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/widget/ColorDotView.kt b/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/widget/ColorDotView.kt deleted file mode 100644 index 02941a9e..00000000 --- a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/widget/ColorDotView.kt +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2019 The Android Open Source Project - * - * 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 io.material.materialthemebuilder.widget - -import android.content.Context -import android.graphics.Canvas -import android.graphics.Color -import android.graphics.Paint -import android.util.AttributeSet -import android.view.View -import io.material.materialthemebuilder.R - -/** - * Simple view that draws a filled circle with a stroke. - */ -class ColorDotView @JvmOverloads constructor( - context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = 0 -) : View(context, attrs, defStyleAttr) { - - var fillColor: Int = Color.LTGRAY - set(value) { - paintFill.color = value - field = value - } - - var strokeColor: Int = Color.DKGRAY - set(value) { - paintStroke.color = value - field = value - } - - private val paintFill = Paint(Paint.ANTI_ALIAS_FLAG).apply { - style = Paint.Style.FILL - color = Color.RED - } - - private val paintStroke = Paint(Paint.ANTI_ALIAS_FLAG).apply { - style = Paint.Style.STROKE - color = Color.BLACK - } - - private var cx: Float = 0F - private var cy: Float = 0F - private var radius: Float = 0F - - init { - val a = context.theme.obtainStyledAttributes( - attrs, - R.styleable.ColorDotView, - defStyleAttr, - 0 - ) - fillColor = a.getColor(R.styleable.ColorDotView_colorFillColor, fillColor) - strokeColor = a.getColor(R.styleable.ColorDotView_colorStrokeColor, strokeColor) - a.recycle() - } - - override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { - super.onSizeChanged(w, h, oldw, oldh) - cx = w / 2F - cy = h / 2F - // Decreases our circle's radius slightly so our stroke doesn't get clipped. - radius = (w / 2F) - 1F - } - - override fun onDraw(canvas: Canvas) { - canvas.drawCircle(cx, cy, radius, paintFill) - canvas.drawCircle(cx, cy, radius, paintStroke) - } -} diff --git a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/widget/LabelLinkView.kt b/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/widget/LabelLinkView.kt deleted file mode 100644 index ddf8a81a..00000000 --- a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/widget/LabelLinkView.kt +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2019 The Android Open Source Project - * - * 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 io.material.materialthemebuilder.widget - -import android.content.Context -import android.content.Intent -import android.graphics.drawable.Drawable -import android.net.Uri -import android.util.AttributeSet -import android.view.View -import android.widget.LinearLayout -import androidx.appcompat.widget.AppCompatTextView -import androidx.appcompat.widget.AppCompatImageView -import io.material.materialthemebuilder.R - -/** - * Composite view to show an (optional) leading icon, followed by a text label, followed by - * a trailing icon. - * - * Clicking on this view's trailing icon will launch [linkUrl]. - */ -class LabelLinkView @JvmOverloads constructor( - context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = 0, - defStyleRes: Int = 0 -) : LinearLayout(context, attrs, defStyleAttr, defStyleRes) { - - private val leadingImageView: AppCompatImageView - private val labelTextView: AppCompatTextView - private val trailingImageView: AppCompatImageView - - private var leadingIcon: Drawable? = null - set(value) { - if (value == null) { - leadingImageView.visibility = View.GONE - } else { - leadingImageView.setImageDrawable(value) - leadingImageView.visibility = View.VISIBLE - } - field = value - } - - private var label: String = "" - set(value) { - labelTextView.text = value - field = value - } - - private var linkUrl: String = "" - - private val onLinkClickedListener = OnClickListener { - if (linkUrl.isBlank()) return@OnClickListener - - launchUrl(linkUrl) - } - - init { - clipToPadding = false - orientation = LinearLayout.HORIZONTAL - - val view = View.inflate(context, R.layout.label_view_layout, this) - leadingImageView = view.findViewById(R.id.label_leading_image_view) - labelTextView = view.findViewById(R.id.label_text_view) - trailingImageView = view.findViewById(R.id.label_trailing_image_view) - trailingImageView.setOnClickListener(onLinkClickedListener) - - val a = context.theme.obtainStyledAttributes( - attrs, - R.styleable.LabelLinkView, - defStyleAttr, - defStyleRes - ) - leadingIcon = a.getDrawable(R.styleable.LabelLinkView_leadingIcon) - label = a.getString(R.styleable.LabelLinkView_android_text) ?: label - linkUrl = a.getString(R.styleable.LabelLinkView_linkUrl) ?: linkUrl - a.recycle() - } - - private fun launchUrl(urlString: String) { - context.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(urlString))) - } -} diff --git a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/widget/ShapeAttributeView.kt b/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/widget/ShapeAttributeView.kt deleted file mode 100644 index 84144b82..00000000 --- a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/widget/ShapeAttributeView.kt +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright 2019 The Android Open Source Project - * - * 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 io.material.materialthemebuilder.widget - -import android.content.Context -import android.content.res.ColorStateList -import android.graphics.Color -import com.google.android.material.shape.MaterialShapeDrawable -import com.google.android.material.shape.ShapeAppearanceModel -import androidx.core.view.ViewCompat -import androidx.appcompat.widget.AppCompatTextView -import android.util.AttributeSet -import android.view.View -import android.widget.FrameLayout -import io.material.materialthemebuilder.R - -/** - * A composite view to display a text label and a shape preview view. - * - * The shape preview view is used to visualize the properties of shapeAppearance theme attributes. - * The shape preview view is a TextView with it's background set to a MaterialShapeDrawable, - * inflated according to this view's app:shapeAppearanceAttr property. - */ -class ShapeAttributeView @JvmOverloads constructor( - context: Context, - private val attrs: AttributeSet? = null, - private val defStyleAttr: Int = 0, - defStyleRes: Int = 0 -) : FrameLayout(context, attrs, defStyleAttr, defStyleRes) { - - private val shapeAttributeTextView: AppCompatTextView - private val shapePreviewView: AppCompatTextView - - var shapeAttrText: String = "?shapeAppearanceSmallComponent" - set(value) { - shapeAttributeTextView.text = value - field = value - } - - private var shape = MaterialShapeDrawable().apply { - strokeWidth = DEFAULT_SHAPE_STROKE_WIDTH - } - - var shapeAppearanceRes: Int = R.attr.shapeAppearanceSmallComponent - set(value) { - shape.shapeAppearanceModel = ShapeAppearanceModel.builder( - context, - attrs, - defStyleAttr, - getShapeAppearanceDefaultRes(value) - ).build() - - ViewCompat.setBackground(shapePreviewView, shape) - - field = value - } - - var shapeFillColor: Int = Color.LTGRAY - set(value) { - shape.fillColor = ColorStateList.valueOf(value) - field = value - } - - var shapeStrokeColor: Int = Color.DKGRAY - set(value) { - shape.strokeColor = ColorStateList.valueOf(value) - field = value - } - - var shapeLetter: String = context.getString(R.string.shape_appearance_small_label) - set(value) { - shapePreviewView.text = value - field = value - } - - init { - val view = View.inflate(context, R.layout.shape_attribute_view_layout, this) - shapeAttributeTextView = view.findViewById(R.id.shape_attribute) - shapePreviewView = view.findViewById(R.id.shape_preview) - - val a = context.theme.obtainStyledAttributes( - attrs, - R.styleable.ShapeAttributeView, - defStyleAttr, - defStyleRes - ) - shapeAttrText = a.getString( - R.styleable.ShapeAttributeView_android_text - ) ?: shapeAttrText - - shapeFillColor = a.getColor( - R.styleable.ShapeAttributeView_shapeFillColor, - Color.LTGRAY - ) - shapeStrokeColor = a.getColor( - R.styleable.ShapeAttributeView_shapeStrokeColor, - Color.DKGRAY - ) - shapeAppearanceRes = a.getInt( - R.styleable.ShapeAttributeView_shapeAppearanceAttr, - R.attr.shapeAppearanceSmallComponent - ) - - shapeLetter = a.getString( - R.styleable.ShapeAttributeView_shapeSizeLetter - ) ?: shapeLetter - - a.recycle() - } - - private fun getShapeAppearanceDefaultRes(shapeAppearanceRes: Int) = when (shapeAppearanceRes) { - R.attr.shapeAppearanceMediumComponent -> R.style.Widget_MaterialComponents_CardView - R.attr.shapeAppearanceLargeComponent -> R.style.Widget_MaterialComponents_NavigationView - else -> R.style.Widget_MaterialComponents_Button - } - - companion object { - private const val DEFAULT_SHAPE_STROKE_WIDTH = 2F - } -} diff --git a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/widget/TypeAttributeView.kt b/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/widget/TypeAttributeView.kt deleted file mode 100644 index 9030f2f2..00000000 --- a/MaterialThemeBuilder/app/src/main/java/io/material/materialthemebuilder/widget/TypeAttributeView.kt +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2019 The Android Open Source Project - * - * 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 io.material.materialthemebuilder.widget - -import android.content.Context -import android.util.AttributeSet -import android.view.View -import androidx.appcompat.widget.AppCompatTextView -import android.widget.LinearLayout -import androidx.appcompat.content.res.AppCompatResources -import io.material.materialthemebuilder.R - -/** - * A composite view to display a text label and a preview of a TextAppearance theme attribute. - */ -class TypeAttributeView @JvmOverloads constructor( - context: Context, - attrs: AttributeSet? = null, - defStyleAttr: Int = 0, - defStyleRes: Int = 0 -) : LinearLayout(context, attrs, defStyleAttr, defStyleRes) { - - private val typeAttributeTextView: AppCompatTextView - private val typeAttributePreviewTextView: AppCompatTextView - - var typeAttrText: String = "?textAppearanceHeadline1" - set(value) { - typeAttributeTextView.text = value - field = value - } - - var typeAttrPreviewText: String = context.getString(R.string.text_appearance_h1_label) - set(value) { - typeAttributePreviewTextView.text = value - field = value - } - - var typeAttrPreviewTextAppearance: Int = R.attr.textAppearanceHeadline1 - set(value) { - typeAttributePreviewTextView.setTextAppearance(value) - field = value - } - - var typeAttrPreviewTextColor = AppCompatResources.getColorStateList( - context, - R.color.material_on_background_emphasis_high_type - ) - set(value) { - typeAttributePreviewTextView.setTextColor(value) - field = value - } - - init { - orientation = LinearLayout.HORIZONTAL - val view = View.inflate(context, R.layout.type_attribute_view_layout, this) - typeAttributeTextView = view.findViewById(R.id.type_attribute) - typeAttributePreviewTextView = view.findViewById(R.id.type_attribute_preview) - - val a = context.theme.obtainStyledAttributes( - attrs, - R.styleable.TypeAttributeView, - defStyleAttr, - defStyleRes - ) - typeAttrText = a.getString(R.styleable.TypeAttributeView_android_text) ?: typeAttrText - typeAttrPreviewText = a.getString( - R.styleable.TypeAttributeView_previewText - ) ?: typeAttrPreviewText - typeAttrPreviewTextAppearance = a.getResourceId( - R.styleable.TypeAttributeView_previewTextAppearance, - typeAttrPreviewTextAppearance - ) - typeAttrPreviewTextColor = a.getColorStateList( - R.styleable.TypeAttributeView_previewTextColor - ) ?: typeAttrPreviewTextColor - a.recycle() - } -} diff --git a/MaterialThemeBuilder/app/src/main/res/anim/bottom_sheet_slide_in.xml b/MaterialThemeBuilder/app/src/main/res/anim/bottom_sheet_slide_in.xml deleted file mode 100644 index 75b48919..00000000 --- a/MaterialThemeBuilder/app/src/main/res/anim/bottom_sheet_slide_in.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/anim/bottom_sheet_slide_out.xml b/MaterialThemeBuilder/app/src/main/res/anim/bottom_sheet_slide_out.xml deleted file mode 100644 index 465f9730..00000000 --- a/MaterialThemeBuilder/app/src/main/res/anim/bottom_sheet_slide_out.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/MaterialThemeBuilder/app/src/main/res/drawable-v24/ic_launcher_foreground.xml deleted file mode 100644 index 5b233b28..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_add_on_secondary_24dp.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_add_on_secondary_24dp.xml deleted file mode 100644 index c8be1fea..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_add_on_secondary_24dp.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_bookmark_24dp.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_bookmark_24dp.xml deleted file mode 100644 index 6f6aa581..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_bookmark_24dp.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_bookmark_control_normal_24dp.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_bookmark_control_normal_24dp.xml deleted file mode 100644 index 12f086cc..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_bookmark_control_normal_24dp.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_bookmark_on_surface_24dp.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_bookmark_on_surface_24dp.xml deleted file mode 100644 index 3bd1535d..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_bookmark_on_surface_24dp.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_colorize_24dp.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_colorize_24dp.xml deleted file mode 100644 index f53a0e24..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_colorize_24dp.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_favorite_on_surface_24dp.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_favorite_on_surface_24dp.xml deleted file mode 100644 index a1b80340..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_favorite_on_surface_24dp.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_format_size_24dp.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_format_size_24dp.xml deleted file mode 100644 index 44595ade..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_format_size_24dp.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_inbox_24dp.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_inbox_24dp.xml deleted file mode 100644 index 111e2414..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_inbox_24dp.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_launcher_background.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index c0ec19f5..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_material_icon_24dp.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_material_icon_24dp.xml deleted file mode 100644 index cfe21c59..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_material_icon_24dp.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_menu_control_normal_24dp.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_menu_control_normal_24dp.xml deleted file mode 100644 index 3ba200ee..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_menu_control_normal_24dp.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_menu_on_surface_24dp.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_menu_on_surface_24dp.xml deleted file mode 100644 index ad77a374..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_menu_on_surface_24dp.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_more_vert_on_surface_24dp.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_more_vert_on_surface_24dp.xml deleted file mode 100644 index c7c6b366..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_more_vert_on_surface_24dp.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_music_note_on_surface_24dp.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_music_note_on_surface_24dp.xml deleted file mode 100644 index 444f58f2..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_music_note_on_surface_24dp.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_news_on_surface_24dp.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_news_on_surface_24dp.xml deleted file mode 100644 index 52d8ad34..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_news_on_surface_24dp.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_open_in_new_24dp.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_open_in_new_24dp.xml deleted file mode 100644 index 3d043075..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_open_in_new_24dp.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_place_on_surface_24dp.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_place_on_surface_24dp.xml deleted file mode 100644 index 246e74dd..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_place_on_surface_24dp.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_rounded_corner_24dp.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_rounded_corner_24dp.xml deleted file mode 100644 index e1966d42..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_rounded_corner_24dp.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_search_control_normal_24dp.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_search_control_normal_24dp.xml deleted file mode 100644 index 56a6e274..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_search_control_normal_24dp.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_search_on_surface_24dp.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_search_on_surface_24dp.xml deleted file mode 100644 index a73e0e9d..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_search_on_surface_24dp.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_send_24dp.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_send_24dp.xml deleted file mode 100644 index 328f1cc9..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_send_24dp.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_share_control_normal_24dp.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_share_control_normal_24dp.xml deleted file mode 100644 index f883971e..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_share_control_normal_24dp.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_share_on_surface_24dp.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_share_on_surface_24dp.xml deleted file mode 100644 index 1f637976..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_share_on_surface_24dp.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/ic_star_24dp.xml b/MaterialThemeBuilder/app/src/main/res/drawable/ic_star_24dp.xml deleted file mode 100644 index dd0ec02a..00000000 --- a/MaterialThemeBuilder/app/src/main/res/drawable/ic_star_24dp.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/drawable/sample_image.png b/MaterialThemeBuilder/app/src/main/res/drawable/sample_image.png deleted file mode 100644 index 8648f274..00000000 Binary files a/MaterialThemeBuilder/app/src/main/res/drawable/sample_image.png and /dev/null differ diff --git a/MaterialThemeBuilder/app/src/main/res/font/roboto_black_italic.xml b/MaterialThemeBuilder/app/src/main/res/font/roboto_black_italic.xml deleted file mode 100644 index afaa1a9e..00000000 --- a/MaterialThemeBuilder/app/src/main/res/font/roboto_black_italic.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/layout/activity_main.xml b/MaterialThemeBuilder/app/src/main/res/layout/activity_main.xml deleted file mode 100644 index 064976fa..00000000 --- a/MaterialThemeBuilder/app/src/main/res/layout/activity_main.xml +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/layout/color_attribute_view_layout.xml b/MaterialThemeBuilder/app/src/main/res/layout/color_attribute_view_layout.xml deleted file mode 100644 index b1a39712..00000000 --- a/MaterialThemeBuilder/app/src/main/res/layout/color_attribute_view_layout.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/layout/component_bottom_app_bar.xml b/MaterialThemeBuilder/app/src/main/res/layout/component_bottom_app_bar.xml deleted file mode 100644 index 034ad197..00000000 --- a/MaterialThemeBuilder/app/src/main/res/layout/component_bottom_app_bar.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/layout/component_bottom_navigation.xml b/MaterialThemeBuilder/app/src/main/res/layout/component_bottom_navigation.xml deleted file mode 100644 index 2fc9f475..00000000 --- a/MaterialThemeBuilder/app/src/main/res/layout/component_bottom_navigation.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - diff --git a/MaterialThemeBuilder/app/src/main/res/layout/component_bottom_sheet.xml b/MaterialThemeBuilder/app/src/main/res/layout/component_bottom_sheet.xml deleted file mode 100644 index 680ceb80..00000000 --- a/MaterialThemeBuilder/app/src/main/res/layout/component_bottom_sheet.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - -