Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
lsongdev committed Sep 5, 2024
1 parent d17ff20 commit 62f07e1
Show file tree
Hide file tree
Showing 18 changed files with 361 additions and 277 deletions.
46 changes: 0 additions & 46 deletions app/build.gradle

This file was deleted.

87 changes: 87 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import java.io.FileInputStream
import java.util.Properties

plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.jetbrains.kotlin.android)
alias(libs.plugins.compose.compiler)
alias(libs.plugins.kotlin.serialization)
}

val keystorePropertiesFile = rootProject.file("key.properties")
val keystoreProperties = Properties()
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
}

android {
namespace = "org.lsong.launcher"
compileSdk = 34

defaultConfig {
applicationId = "org.lsong.launcher"
minSdk = 33
targetSdk = 35
versionCode = 5
versionName = "1.2.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}

ndk {
abiFilters.addAll(listOf("armeabi-v7a", "arm64-v8a", "x86_64"))
}
}

buildTypes {
release {
isMinifyEnabled = true
isShrinkResources = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
compose = true
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}

dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.ui)
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
implementation(libs.kotlinx.collections.immutable)
implementation(libs.androidx.material.icons.extended)


testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
androidTestImplementation(platform(libs.androidx.compose.bom))
androidTestImplementation(libs.androidx.ui.test.junit4)
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
}
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
>
<activity
android:name="org.lsong.launcher.MainActivity"
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
50 changes: 0 additions & 50 deletions app/src/main/java/org/lsong/launcher/Adapter.kt

This file was deleted.

9 changes: 0 additions & 9 deletions app/src/main/java/org/lsong/launcher/AppBlock.kt

This file was deleted.

63 changes: 30 additions & 33 deletions app/src/main/java/org/lsong/launcher/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,43 @@ package org.lsong.launcher

import android.content.Intent
import android.content.pm.PackageManager
import android.content.pm.PackageManager.ResolveInfoFlags
import android.content.pm.ResolveInfo
import android.graphics.drawable.Drawable
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import org.lsong.launcher.databinding.ActivityMainBinding
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch

class MainActivity : ComponentActivity() {
private val appListManager by lazy { AppListManager(this) }

class MainActivity : AppCompatActivity() {
private lateinit var mainBinding: ActivityMainBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
mainBinding = ActivityMainBinding.inflate(layoutInflater)
setContentView(mainBinding.root)

// getInstalledApps
val appList = ArrayList<AppBlock>()

val intent = Intent(Intent.ACTION_MAIN, null)
intent.addCategory(Intent.CATEGORY_LAUNCHER)

var flags = ResolveInfoFlags.of(PackageManager.MATCH_ALL.toLong())
val activities = packageManager.queryIntentActivities(intent, flags)
for (resolveInfo in activities) {
if (resolveInfo.activityInfo.packageName == this.packageName)
continue
val app = AppBlock(
resolveInfo.loadLabel(packageManager).toString(),
resolveInfo.activityInfo.loadIcon(packageManager),
resolveInfo.activityInfo.packageName
)
appList.add(app)
setContent {
MaterialTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = Color.Black.copy(alpha = 0.1f)
) {
MainScreen(appListManager)
}
}
}
mainBinding.appList.layoutManager =
StaggeredGridLayoutManager(1, LinearLayoutManager.VERTICAL)
mainBinding.appList.adapter = Adapter(this).also {
it.passAppList(appList.sortedWith { o1, o2 ->
o1?.appName?.compareTo(o2?.appName ?: "", true) ?: 0
})
}

override fun onResume() {
super.onResume()
lifecycleScope.launch {
appListManager.refreshAppList()
}
}
}
Loading

0 comments on commit 62f07e1

Please sign in to comment.