Skip to content

Commit

Permalink
Material You
Browse files Browse the repository at this point in the history
- Migrate to Groovy to Kotlin in build.gradle
  • Loading branch information
z-huang committed May 15, 2022
1 parent 77972a6 commit 2218d58
Show file tree
Hide file tree
Showing 21 changed files with 295 additions and 235 deletions.
135 changes: 0 additions & 135 deletions app/build.gradle

This file was deleted.

172 changes: 172 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
plugins {
id("com.android.application")
id("kotlin-android")
id("kotlin-parcelize")
id("kotlin-kapt")
id("androidx.navigation.safeargs")
id("kotlinx-serialization")
id("dev.rikka.tools.materialthemebuilder")
}

val newpipeVersion: String by rootProject.extra

android {
compileSdk = 31
buildToolsVersion = "30.0.3"
defaultConfig {
applicationId = "com.zionhuang.music"
minSdk = 26
targetSdk = 31
versionCode = 6
versionName = "0.2.1-beta"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
applicationVariants.all {
resValue("string", "app_version", versionName)
resValue("string", "newpipe_version", newpipeVersion)
}
buildTypes {
getByName("release") {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
getByName("debug") {
isMinifyEnabled = false
applicationIdSuffix = ".debug"
}
}
buildFeatures {
viewBinding = true
dataBinding = true
}
packagingOptions {
resources {
excludes += listOf("META-INF/proguard/androidx-annotations.pro", "META-INF/DEPENDENCIES")
}
}
compileOptions {
sourceCompatibility(JavaVersion.VERSION_1_8)
targetCompatibility(JavaVersion.VERSION_1_8)
}
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs += listOf("-Xopt-in=kotlin.RequiresOptIn")
}
configurations.all {
resolutionStrategy {
exclude(group = "org.jetbrains.kotlinx", module = "kotlinx-coroutines-debug")
}
}
testOptions {
unitTests.isIncludeAndroidResources = true
unitTests.isReturnDefaultValues = true
}
}

materialThemeBuilder {
themes {
for ((name, color) in listOf(
"Red" to "F44336",
"Pink" to "E91E63",
"Purple" to "9C27B0",
"DeepPurple" to "673AB7",
"Indigo" to "3F51B5",
"Blue" to "2196F3",
"LightBlue" to "03A9F4",
"Cyan" to "00BCD4",
"Teal" to "009688",
"Green" to "4FAF50",
"LightGreen" to "8BC3A4",
"Lime" to "CDDC39",
"Yellow" to "FFEB3B",
"Amber" to "FFC107",
"Orange" to "FF9800",
"DeepOrange" to "FF5722",
"Brown" to "795548",
"BlueGrey" to "607D8F",
"Sakura" to "FF9CA8"
)) {
create("Material$name") {
lightThemeFormat = "ThemeOverlay.Light.%s"
darkThemeFormat = "ThemeOverlay.Dark.%s"
primaryColor = "#$color"
}
}
}
}

dependencies {
implementation(fileTree("dir" to "libs", "include" to "*.jar"))
// Kotlin
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2")
// AndroidX
implementation("androidx.core:core-ktx:1.7.0")
implementation("androidx.appcompat:appcompat:1.4.1")
implementation("androidx.constraintlayout:constraintlayout:2.1.3")
implementation("androidx.fragment:fragment-ktx:1.4.1")
implementation("androidx.preference:preference-ktx:1.2.0")
implementation("androidx.vectordrawable:vectordrawable:1.1.0")
implementation("androidx.navigation:navigation-runtime-ktx:2.4.2")
implementation("androidx.navigation:navigation-fragment-ktx:2.4.2")
implementation("androidx.navigation:navigation-ui-ktx:2.4.2")
implementation("androidx.lifecycle:lifecycle-extensions:2.2.0")
implementation("androidx.lifecycle:lifecycle-common-java8:2.4.1")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.1")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.4.1")
implementation("androidx.legacy:legacy-support-v4:1.0.0")
implementation("androidx.work:work-runtime-ktx:2.7.1")
implementation("androidx.recyclerview:recyclerview-selection:1.1.0")
implementation("androidx.transition:transition-ktx:1.4.1")
implementation("com.google.android.material:material:1.6.0")
// Gson
implementation("com.google.code.gson:gson:2.9.0")
// ExoPlayer
implementation("com.google.android.exoplayer:exoplayer:2.16.1")
implementation("com.google.android.exoplayer:extension-mediasession:2.16.1")
// Paging
implementation("androidx.paging:paging-runtime-ktx:3.1.1")
testImplementation("androidx.paging:paging-common-ktx:3.1.1")
implementation("androidx.paging:paging-rxjava3:3.1.1")
// Room
implementation("androidx.room:room-runtime:2.4.2")
kapt("androidx.room:room-compiler:2.4.2")
implementation("androidx.room:room-rxjava3:2.4.2")
implementation("androidx.room:room-ktx:2.4.2")
implementation("androidx.room:room-paging:2.4.2")
testImplementation("androidx.room:room-testing:2.4.2")
// NewPipe Extractor
implementation("com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751")
implementation("com.github.TeamNewPipe:NewPipeExtractor:v$newpipeVersion")
// Apache Utils
implementation("org.apache.commons:commons-lang3:3.12.0")
implementation("org.apache.commons:commons-text:1.9")
// OkHttp
implementation("com.squareup.okhttp3:okhttp:4.9.2")
// Glide
implementation("com.github.bumptech.glide:glide:4.12.0")
implementation("com.github.bumptech.glide:annotations:4.12.0")
implementation("com.github.bumptech.glide:okhttp3-integration:4.12.0")
kapt("com.github.bumptech.glide:compiler:4.12.0")
// Jsoup
implementation("org.jsoup:jsoup:1.14.3")
// Fast Scroll
implementation("me.zhanghai.android.fastscroll:library:1.1.7")
// Markdown
implementation("org.commonmark:commonmark:0.18.2")
// Test
testImplementation("junit:junit:4.13.2")
androidTestImplementation("android.arch.core:core-testing:1.1.1")
androidTestImplementation("androidx.test.ext:junit:1.1.3")
androidTestImplementation("androidx.test:runner:1.4.0")
androidTestImplementation("androidx.test:rules:1.4.0")
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
testImplementation("org.mockito:mockito-core:4.3.1")
testImplementation("org.mockito:mockito-inline:4.3.1")
testImplementation("org.mockito:mockito-android:4.3.1")
testImplementation("com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0")
}
2 changes: 1 addition & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
# proguardFiles setting in build.gradle.kts.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/zionhuang/music/App.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.zionhuang.music

import android.app.Application
import com.google.android.material.color.DynamicColors
import com.zionhuang.music.utils.getPreferredContentCountry
import com.zionhuang.music.utils.getPreferredLocalization
import com.zionhuang.music.youtube.NewPipeDownloader
Expand All @@ -10,6 +11,7 @@ class App : Application() {
override fun onCreate() {
super.onCreate()
INSTANCE = this
DynamicColors.applyToActivitiesIfAvailable(this)
NewPipe.init(
NewPipeDownloader.init(),
getPreferredLocalization(this),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.zionhuang.music.ui.activities

import android.content.Intent
import android.content.Intent.EXTRA_TEXT
import android.content.res.Resources
import android.os.Bundle
import android.support.v4.media.session.PlaybackStateCompat.STATE_NONE
import android.util.Log
Expand Down
27 changes: 9 additions & 18 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
android:layout_height="match_parent"
tools:context=".ui.activities.MainActivity">

<com.zionhuang.music.ui.widgets.StatusBarView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?colorPrimaryVariant"
tools:layout_height="36dp" />
<!-- <com.zionhuang.music.ui.widgets.StatusBarView-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:background="?colorPrimaryVariant"-->
<!-- android:visibility="gone"-->
<!-- tools:layout_height="36dp" />-->

<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="54dp"
android:layout_marginBottom="@dimen/m3_bottom_nav_min_height"
android:fitsSystemWindows="true">

<com.google.android.material.appbar.AppBarLayout
Expand All @@ -30,21 +31,11 @@

<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar"
style="@style/Widget.MaterialComponents.Toolbar.Primary"
style="@style/Widget.Material3.Toolbar.Surface"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:contentInsetStartWithNavigation="0dp" />

<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout"
style="@style/Widget.MaterialComponents.TabLayout.Colored"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
app:tabContentStart="56dp"
app:tabIndicatorFullWidth="false"
app:tabMode="scrollable"
app:tabRippleColor="@null" />
</com.google.android.material.appbar.AppBarLayout>

<androidx.fragment.app.FragmentContainerView
Expand All @@ -70,7 +61,7 @@

<FrameLayout
android:id="@+id/bottom_controls_sheet"
style="@style/Widget.MaterialComponents.BottomSheet"
style="@style/Widget.Material3.BottomSheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:behavior_hideable="true"
Expand Down
Loading

0 comments on commit 2218d58

Please sign in to comment.