浏览代码

Changes from slim-launcher 2.4.20 (#53)

- Remove tests and dependencies
- Make AppModule a SingletonComponent
- Update Gradle version

Co-authored-by: sduduzog <gumedesduduzo@gmail.com>
Joshua Kuestersteffen 4 年之前
父节点
当前提交
0a14f9f3e6

+ 16 - 48
app/build.gradle.kts

@@ -17,27 +17,33 @@ android {
         testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
         vectorDrawables { useSupportLibrary = true }
 //        signingConfigs {
-//            register("release") {
-//                storeFile = file(project.extra["RELEASE_STORE_FILE"] as String)
-//                storePassword = project.extra["RELEASE_STORE_PASSWORD"] as String
-//                keyAlias = project.extra["RELEASE_KEY_ALIAS"] as String
-//                keyPassword = project.extra["RELEASE_KEY_PASSWORD"] as String
+//            if (project.extra.has("RELEASE_STORE_FILE")) {
+//                register("release") {
+//                    storeFile = file(project.extra["RELEASE_STORE_FILE"] as String)
+//                    storePassword = project.extra["RELEASE_STORE_PASSWORD"] as String
+//                    keyAlias = project.extra["RELEASE_KEY_ALIAS"] as String
+//                    keyPassword = project.extra["RELEASE_KEY_PASSWORD"] as String
+//                }
 //            }
 //        }
     }
 
-
-
     buildTypes {
         named("release").configure {
             isMinifyEnabled = true
             isShrinkResources = true
-            proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
-//            signingConfig = signingConfigs.getByName("release")
+            proguardFiles(
+                getDefaultProguardFile("proguard-android-optimize.txt"),
+                "proguard-rules.pro"
+            )
+//            signingConfig = signingConfigs.maybeCreate("release")
         }
         named("debug").configure {
             isMinifyEnabled = false
-            proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
+            proguardFiles(
+                getDefaultProguardFile("proguard-android-optimize.txt"),
+                "proguard-rules.pro"
+            )
         }
     }
     compileOptions {
@@ -47,13 +53,9 @@ android {
     kotlinOptions {
         jvmTarget = JavaVersion.VERSION_1_8.toString()
     }
-
     testOptions {
         unitTests.isIncludeAndroidResources = true
     }
-    lintOptions{
-        disable = mutableSetOf("MissingTranslation")
-    }
     applicationVariants.all{
         outputs.all {
             (this as com.android.build.gradle.internal.api.BaseVariantOutputImpl).outputFileName = "${applicationId}.apk"
@@ -88,38 +90,4 @@ dependencies {
     implementation("androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha02")
     kapt("androidx.hilt:hilt-compiler:1.0.0-alpha02")
     kapt("com.google.dagger:hilt-android-compiler:2.29-alpha")
-
-    // Test libs
-
-    testImplementation("androidx.test:core:1.3.0")
-
-    testImplementation("androidx.test:runner:1.3.0")
-    testImplementation("androidx.test:rules:1.3.0")
-
-    testImplementation("androidx.test.ext:junit:1.1.2")
-    testImplementation("androidx.test.ext:truth:1.3.0")
-    testImplementation("com.google.truth:truth:1.0")
-
-
-    testImplementation("androidx.arch.core:core-testing:2.1.0")
-    testImplementation("androidx.fragment:fragment-testing:1.2.5")
-
-    testImplementation("org.robolectric:robolectric:4.4")
-
-    testImplementation("org.mockito:mockito-core:2.24.5")
-
-    testImplementation("androidx.test.espresso:espresso-core:3.3.0")
-
-    testImplementation("com.google.dagger:hilt-android-testing:2.29-alpha")
-    kaptTest("com.google.dagger:hilt-android-compiler:2.29-alpha")
-
-    androidTestImplementation("androidx.room:room-testing:2.2.5")
-    androidTestImplementation("androidx.test:runner:1.3.0")
-    androidTestImplementation("androidx.test:rules:1.3.0")
-    androidTestImplementation("androidx.annotation:annotation:1.1.0")
-    androidTestImplementation("androidx.test:runner:1.3.0")
-    androidTestImplementation("androidx.test:rules:1.3.0")
-    androidTestImplementation("androidx.arch.core:core-testing:2.1.0")
-    androidTestImplementation("androidx.test.espresso:espresso-core:3.3.0")
-    androidTestImplementation("androidx.test.espresso:espresso-intents:3.3.0")
 }

+ 0 - 64
app/src/androidTest/java/com/sduduzog/slimlauncher/DBTest.kt

@@ -1,64 +0,0 @@
-package com.sduduzog.slimlauncher
-
-import androidx.arch.core.executor.testing.InstantTaskExecutorRule
-import androidx.lifecycle.Observer
-import androidx.room.Room
-import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
-import androidx.test.platform.app.InstrumentationRegistry
-import com.sduduzog.slimlauncher.data.BaseDao
-import com.sduduzog.slimlauncher.data.BaseDatabase
-import com.sduduzog.slimlauncher.models.HomeApp
-import org.hamcrest.CoreMatchers.equalTo
-import org.junit.After
-import org.junit.Assert.assertThat
-import org.junit.Before
-import org.junit.Rule
-import org.junit.Test
-import org.junit.runner.RunWith
-import java.util.concurrent.CountDownLatch
-import java.util.concurrent.TimeUnit
-
-@RunWith(AndroidJUnit4ClassRunner::class)
-class DBTest {
-
-    private var baseDao: BaseDao? = null
-    private var mDb: BaseDatabase? = null
-
-    @get:Rule
-    var instantTaskExecutorRule = InstantTaskExecutorRule()
-
-    @Before
-    fun createDb() {
-        val context = InstrumentationRegistry.getInstrumentation().targetContext
-        mDb = Room.inMemoryDatabaseBuilder(context, BaseDatabase::class.java).build()
-        baseDao = mDb!!.baseDao()
-    }
-
-    @After
-    fun closeDb() {
-        mDb?.close()
-    }
-
-    @Test
-    @Throws(InterruptedException::class)
-    fun testInsertLiveDataApps() {
-        val app = HomeApp("TestApp", "com.test.test.app", "TestMainActivity", 0, "Test", 0)
-        baseDao!!.add(app)
-
-        var appsInstalled: List<HomeApp> = listOf()
-
-        val latch = CountDownLatch(1)
-
-        val appsLiveData = baseDao!!.apps
-
-        val observer = Observer<List<HomeApp>> {
-            appsInstalled = it
-            latch.countDown()
-        }
-
-        appsLiveData.observeForever(observer)
-        latch.await(2, TimeUnit.SECONDS)
-        appsLiveData.removeObserver(observer)
-        assertThat(appsInstalled.size, equalTo(1))
-    }
-}

+ 0 - 18
app/src/debug/AndroidManifest.xml

@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    package="com.sduduzog.slimlauncher">
-
-    <application>
-        <activity
-            android:name=".HiltTestActivity"
-            android:exported="false">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
-
-                <category android:name="android.intent.category.LAUNCHER" />
-            </intent-filter>
-        </activity>
-    </application>
-
-</manifest>

+ 0 - 15
app/src/debug/java/com/sduduzog/slimlauncher/HiltTestActivity.kt

@@ -1,15 +0,0 @@
-package com.sduduzog.slimlauncher
-
-import androidx.appcompat.app.AppCompatActivity
-import com.sduduzog.slimlauncher.utils.IPublisher
-import com.sduduzog.slimlauncher.utils.ISubscriber
-import dagger.hilt.android.AndroidEntryPoint
-
-@AndroidEntryPoint
-class HiltTestActivity : AppCompatActivity(), IPublisher {
-    override fun attachSubscriber(s: ISubscriber) {
-    }
-
-    override fun detachSubscriber(s: ISubscriber) {
-    }
-}

+ 2 - 1
app/src/main/AndroidManifest.xml

@@ -4,7 +4,8 @@
     package="com.sduduzog.slimlauncher">
 
     <uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
-    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
+    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
+        tools:ignore="QueryAllPackagesPermission" />
 
 
     <application

+ 2 - 3
app/src/main/java/com/sduduzog/slimlauncher/di/AppModule.kt

@@ -4,15 +4,14 @@ import android.app.Application
 import androidx.room.Room
 import com.sduduzog.slimlauncher.data.BaseDao
 import com.sduduzog.slimlauncher.data.BaseDatabase
-import dagger.Binds
 import dagger.Module
 import dagger.Provides
 import dagger.hilt.InstallIn
-import dagger.hilt.android.components.ApplicationComponent
+import dagger.hilt.components.SingletonComponent
 import javax.inject.Singleton
 
 @Module
-@InstallIn(ApplicationComponent::class)
+@InstallIn(SingletonComponent::class) // TODO: wip
 class AppModule {
     @Provides
     @Singleton

+ 4 - 1
app/src/main/res/values/strings.xml

@@ -1,4 +1,7 @@
-<resources>
+<resources
+    xmlns:tools="http://schemas.android.com/tools"
+    tools:ignore="MissingTranslation" >
+
     <string name="app_name" translatable="false">Unlauncher</string>
     <string name="slim_url" translatable="false">https://github.com/jkuester/unlauncher</string>
     <string name="main_placeholder_clock" translatable="false">00:00</string>

+ 4 - 7
build.gradle.kts

@@ -1,17 +1,14 @@
-import java.net.URI
-
 // Top-level build file where you can add configuration options common to all sub-projects/modules.
 
 buildscript {
     repositories {
         google()
-        jcenter()
-//        maven { url = URI("https://oss.sonatype.org/content/repositories/snapshots/") }
+        mavenCentral()
         maven { url = java.net.URI("https://jitpack.io") }
     }
     dependencies {
-        classpath("com.android.tools.build:gradle:4.0.1")
-        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72")
+        classpath("com.android.tools.build:gradle:4.2.1")
+        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.10")
         classpath("com.google.dagger:hilt-android-gradle-plugin:2.28-alpha")
 
         // NOTE: Do not place your application dependencies here; they belong
@@ -22,7 +19,7 @@ buildscript {
 allprojects {
     repositories {
         google()
-        jcenter()
+        mavenCentral()
         maven { url = java.net.URI("https://jitpack.io") }
     }
 }

+ 1 - 1
gradle/wrapper/gradle-wrapper.properties

@@ -1,5 +1,5 @@
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists