Skip to content

Commit

Permalink
Cleanup sample unnecessary resources and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
hanggrian committed Jun 30, 2022
1 parent 3b09303 commit d8bc847
Show file tree
Hide file tree
Showing 21 changed files with 46 additions and 84 deletions.
16 changes: 11 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ buildscript {
}
dependencies {
classpath(plugs.android)
classpath(plugs.pages) { features("pages-minimal") }
classpath(plugs.pages) {
capability("pages-minimal")
}
}
}

Expand All @@ -37,14 +39,18 @@ allprojects {
}

subprojects {
withPlugin<LibraryPlugin> { configure<LibraryExtension>(::androidConfig) }
withPlugin<AppPlugin> { configure<BaseAppModuleExtension>(::androidConfig) }
withPlugin<LibraryPlugin> {
configure<LibraryExtension>(::androidConfig)
}
withPlugin<AppPlugin> {
configure<BaseAppModuleExtension>(::androidConfig)
}
withPluginEagerly<KotlinAndroidPluginWrapper> {
kotlinExtension.jvmToolchain {
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(sdk.versions.jdk.get()))
}
(the<BaseExtension>() as ExtensionAware).extensions
.getByType<KotlinJvmOptions>().jvmTarget = JavaVersion.toVersion(sdk.versions.androidJdk.get()).toString()
(the<BaseExtension>() as ExtensionAware).extensions.getByType<KotlinJvmOptions>()
.jvmTarget = JavaVersion.toVersion(sdk.versions.androidJdk.get()).toString()
}
}

Expand Down
4 changes: 1 addition & 3 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
repositories {
mavenCentral()
}
repositories.mavenCentral()

plugins {
`kotlin-dsl`
Expand Down
7 changes: 5 additions & 2 deletions buildSrc/src/Project.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import org.gradle.api.Project
import org.gradle.api.artifacts.ModuleDependency
import org.gradle.kotlin.dsl.withType

fun ModuleDependency.features(vararg capabilityModules: Any) =
capabilities { capabilityModules.forEach { requireCapability("$group:$it") } }
fun ModuleDependency.capability(capabilityModule: Any) =
capabilities { requireCapability("$group:$capabilityModule") }

fun ModuleDependency.capabilities(vararg capabilityModules: Any) =
capabilities { requireCapabilities(*capabilityModules.map { "$group:$it" }.toTypedArray()) }

fun Project.withPlugin(id: String, action: Plugin<*>.() -> Unit) = plugins.withId(id, action)

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/Releases.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ const val DEVELOPER_URL = "https://github.com/$DEVELOPER_ID"

const val RELEASE_GROUP = "com.hendraanggrian.material"
const val RELEASE_ARTIFACT = "collapsingtoolbarlayout-subtitle"
const val RELEASE_VERSION = "1.3.0-SNAPSHOT"
const val RELEASE_VERSION = "1.3.0"
const val RELEASE_DESCRIPTION = "Standard CollapsingToolbarLayout with subtitle support"
const val RELEASE_URL = "https://github.com/$DEVELOPER_ID/$RELEASE_ARTIFACT"
6 changes: 3 additions & 3 deletions collapsingtoolbarlayout-subtitle/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
id("com.android.library")
jacoco
alias(plugs.plugins.spotless)
alias(plugs.plugins.mvn.publish)
alias(plugs.plugins.maven.publish)
}

android {
Expand Down Expand Up @@ -77,8 +77,8 @@ tasks {
)
val debugTree = fileTree("dir" to "$buildDir/intermediates/javac/debug", "excludes" to fileFilter)
val mainSrc = "$projectDir/src/main/java"
sourceDirectories.setFrom(files(listOf(mainSrc)))
classDirectories.setFrom(files(listOf(debugTree)))
sourceDirectories.setFrom(mainSrc)
classDirectories.setFrom(debugTree)
executionData.setFrom(
fileTree(
"dir" to buildDir,
Expand Down
2 changes: 1 addition & 1 deletion collapsingtoolbarlayout-subtitle/lint.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<lint>
<issue id="RestrictedApi">
<ignore path="src/main/java/com/google/android/material/appbar/SubtitleCollapsingToolbarLayout.java" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<attr name="subtitleCollapsingToolbarLayoutStyle" format="reference" />

<declare-styleable name="SubtitleCollapsingToolbarLayout">
<!-- Inherited from material -->
<!-- Inherited from 'material-components' -->
<attr name="expandedTitleMargin" />
<attr name="expandedTitleMarginStart" />
<attr name="expandedTitleMarginTop" />
Expand All @@ -21,7 +21,7 @@
<attr name="titleEnabled" />
<attr name="maxLines" />

<!-- Inherited from appcompat -->
<!-- Inherited from 'androidx.appcompat' -->
<attr name="title" />
<attr name="subtitle" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- SubtitleCollapsingToolbarLayout styles -->
<style name="Widget.Design.SubtitleCollapsingToolbar" parent="android:Widget">
<item name="expandedTitleMargin">32dp</item>
<item name="statusBarScrim">?attr/colorPrimaryDark</item>
Expand All @@ -14,5 +13,5 @@
<item name="android:textColor">?android:attr/textColorSecondary</item>
</style>

<style name="Widget.MaterialComponents.SubtitleCollapsingToolbar" parent="Widget.Design.CollapsingToolbar"/>
<style name="Widget.MaterialComponents.SubtitleCollapsingToolbar" parent="Widget.Design.CollapsingToolbar" />
</resources>
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
package com.hendraanggrian.material.subtitlecollapsingtoolbarlayout;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import android.content.res.AssetManager;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Build.VERSION_CODES;
import android.view.Gravity;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.GravityCompat;
import com.google.android.material.internal.CollapsingTextHelper2;
import com.hendraanggrian.material.subtitlecollapsingtoolbarlayout.test.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -34,9 +31,7 @@ public class CollapsingTextHelper2Test {
@Before
public void setUpActivityAndResources() {
activity = Robolectric.buildActivity(TestActivity.class).setup().get();
textHelper2 = new CollapsingTextHelper2(activity.getLayoutInflater()
.inflate(com.hendraanggrian.material.subtitlecollapsingtoolbarlayout.test.
R.layout.test_subtitlecollapsingtoolbarlayout, null));
textHelper2 = new CollapsingTextHelper2(new View(activity));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- SubtitleCollapsingToolbarLayout styles -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge">
<item name="subtitleCollapsingToolbarLayoutStyle">@style/ToolbarLayoutTheme</item>
</style>
Expand Down
12 changes: 6 additions & 6 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ Since it uses a lot of CollapsingToolbarLayout resources and API, there are a fe
- Only safe to use with the same version of material components.
- Deceptive package name.

### Also...
#### Also...

It is detabable if we even need this library.
If the material guidelines says it's ok to have a multiline text in toolbar layout, then they surely would've already implemented such feature.
If it doesn't say anything about subtitle (which is odds because Toolbar has it), then we probably shouldn't use it out of respect to the guidelines.

## Download

This library's versioning follows [Material Components's releases](https://github.com/material-components/material-components-android/releases/).
This library's versioning follows [Material Components' releases](https://github.com/material-components/material-components-android/releases/).

```gradle
repositories {
Expand Down Expand Up @@ -72,7 +72,7 @@ Treat `SubtitleCollapsingToolbarLayout` just like a regular `CollapsingToolbarLa
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
app:layout_collapseMode="pin"/>
app:layout_collapseMode="pin" />
</android.support.design.widget.SubtitleCollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>

Expand All @@ -87,6 +87,6 @@ Treat `SubtitleCollapsingToolbarLayout` just like a regular `CollapsingToolbarLa

| Attribute | Description | Default value/behavior |
|-----------------------------------|--------------------------------------------|------------------------------------------------------|
| `subtitle` | subtitle text | disabled |
| `collapsedSubtitleTextAppearance` | text appearance of subtitle when collapsed | `TextAppearance.AppCompat.Widget.ActionBar.Subtitle` |
| `expandedSubtitleTextAppearance` | text appearance of subtitle when expanded | `TextAppearance.AppCompat.Headline` |
| `subtitle` | Subtitle text | disabled |
| `collapsedSubtitleTextAppearance` | Text appearance of subtitle when collapsed | `TextAppearance.AppCompat.Widget.ActionBar.Subtitle` |
| `expandedSubtitleTextAppearance` | Text appearance of subtitle when expanded | `TextAppearance.AppCompat.Headline` |
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 1 addition & 5 deletions sample/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,8 @@ dependencies {
implementation(project(":$RELEASE_ARTIFACT"))
implementation(libs.material)
implementation(libs.androidx.multidex)
implementation(libs.androidx.core.ktx)
implementation(libs.androidx.coordinatorlayout)
implementation(libs.androidx.preference)
implementation(libs.process.phoenix)
implementation(libs.auto.prefs.android)
kapt(libs.auto.prefs.compiler)
implementation(libs.picasso.ktx)
implementation(libs.process.phoenix)
implementation(libs.bundles.color.preference)
}
6 changes: 1 addition & 5 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@
xmlns:tools="http://schemas.android.com/tools"
package="com.example.subtitlecollapsingtoolbarlayout">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:name="androidx.multidex.MultiDexApplication"
android:allowBackup="true"
android:label="SubtitleCollapsingToolbarLayout Example"
android:supportsRtl="true"
android:theme="@style/Theme.Demo">
<activity
android:name=".MainActivity"
Expand All @@ -27,6 +23,6 @@
android:name=".MainActivity2"
android:exported="true"
android:forceDarkAllowed="true"
tools:targetApi="q"/>
tools:targetApi="q" />
</application>
</manifest>
Binary file removed sample/src/main/assets/OpenSans-Regular.ttf
Binary file not shown.
Binary file removed sample/src/main/assets/Roboto-Regular.ttf
Binary file not shown.
11 changes: 6 additions & 5 deletions sample/src/main/res/drawable/round_expand_more_24.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?attr/colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M15.88,9.29L12,13.17 8.12,9.29c-0.39,-0.39 -1.02,-0.39 -1.41,0 -0.39,0.39 -0.39,1.02 0,1.41l4.59,4.59c0.39,0.39 1.02,0.39 1.41,0l4.59,-4.59c0.39,-0.39 0.39,-1.02 0,-1.41 -0.39,-0.38 -1.03,-0.39 -1.42,0z"/>
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M15.88,9.29L12,13.17 8.12,9.29c-0.39,-0.39 -1.02,-0.39 -1.41,0 -0.39,0.39 -0.39,1.02 0,1.41l4.59,4.59c0.39,0.39 1.02,0.39 1.41,0l4.59,-4.59c0.39,-0.39 0.39,-1.02 0,-1.41 -0.39,-0.38 -1.03,-0.39 -1.42,0z" />
</vector>
22 changes: 0 additions & 22 deletions sample/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="text_appearances">
<item>Small</item>
<item>Medium</item>
<item>Large</item>
</string-array>

<string-array name="text_appearance_values">
<item>small</item>
<item>medium</item>
<item>large</item>
</string-array>

<string-array name="gravities">
<item>Left</item>
<item>Top</item>
Expand All @@ -31,14 +19,4 @@
<item>1</item>
<item>16</item>
</string-array>

<string-array name="typefaces">
<item>Roboto</item>
<item>Open Sans</item>
</string-array>

<string-array name="typeface_values">
<item>Roboto-Regular.ttf</item>
<item>OpenSans-Regular.ttf</item>
</string-array>
</resources>
4 changes: 0 additions & 4 deletions sample/src/main/res/values/colors.xml

This file was deleted.

5 changes: 1 addition & 4 deletions sample/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">

<style name="Theme.Demo" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="android:statusBarColor" tools:targetApi="l">@android:color/transparent</item>
<item name="android:windowDrawsSystemBarBackgrounds" tools:targetApi="l">true</item>
</style>

<style name="Theme.CustomToolbar" parent="Widget.Design.SubtitleCollapsingToolbar">
<item name="expandedSubtitleTextAppearance">@style/TextAppearance.AppCompat.Caption</item>
</style>
</resources>
10 changes: 4 additions & 6 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencyResolutionManagement {
plugin("kotlin-kapt", "org.jetbrains.kotlin.kapt").version(kotlinVersion)
plugin("dokka", "org.jetbrains.dokka").version(kotlinVersion)
plugin("spotless", "com.diffplug.spotless").version("6.7.2")
plugin("mvn-publish", "com.vanniktech.maven.publish.base").version("0.20.0")
plugin("maven-publish", "com.vanniktech.maven.publish.base").version("0.20.0")
plugin("git-publish", "org.ajoberstar.git-publish").version("3.0.1")
library("pages", "com.hendraanggrian:pages-gradle-plugin:0.1")
}
Expand All @@ -29,12 +29,10 @@ dependencyResolutionManagement {
library("androidx-appcompat", "androidx.appcompat:appcompat:$androidxVersion")
library("androidx-core-ktx", "androidx.core:core-ktx:$androidxVersion")
library("androidx-multidex", "androidx.multidex:multidex:2.0.1")
library("androidx-coordinatorlayout", "androidx.multidex:multidex:1.1.0")
library("androidx-preference", "androidx.multidex:multidex:1.1.0")
library("auto-prefs-android", "com.hendraanggrian.auto:prefs-android:0.1-SNAPSHOT")
library("auto-prefs-compiler", "com.hendraanggrian.auto:prefs-compiler:0.1-SNAPSHOT")
library("picasso-ktx", "com.hendraanggrian.appcompat:picasso-ktx:0.1-SNAPSHOT")
library("process-phoenix", "com.jakewharton:process-phoenix:2.1.2")
val autoPrefsVersion = "0.1-SNAPSHOT"
library("auto-prefs-android", "com.hendraanggrian.auto:prefs-android:$autoPrefsVersion")
library("auto-prefs-compiler", "com.hendraanggrian.auto:prefs-compiler:$autoPrefsVersion")
val colorPreferenceVersion = "1.1.0"
library("color-preference-core", "com.github.kizitonwose.colorpreference:core:$colorPreferenceVersion")
library(
Expand Down

0 comments on commit d8bc847

Please sign in to comment.