Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre release/0.1.5 #49

Merged
merged 13 commits into from
Mar 25, 2024
10 changes: 0 additions & 10 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
@Suppress("DSL_SCOPE_VIOLATION")
// https://github.com/gradle/gradle/issues/22797
plugins {
alias(sharedLibs.plugins.android.application) apply false
alias(sharedLibs.plugins.android.library) apply false
alias(sharedLibs.plugins.kotlin.android) apply false
alias(sharedLibs.plugins.sqldelight) apply false
}

tasks.register<Delete>("clean") {
delete(rootProject.buildDir)
}
64 changes: 29 additions & 35 deletions devtools/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,47 +1,39 @@
@Suppress("DSL_SCOPE_VIOLATION")
// https://github.com/gradle/gradle/issues/22797
import com.android.build.api.dsl.LibraryDefaultConfig

plugins {
alias(sharedLibs.plugins.android.library)
alias(sharedLibs.plugins.kotlin.android)
// debug only
val launchAsApplication = false

if (launchAsApplication) {
id("foodiestudio.android.application.compose")
} else {
id("foodiestudio.android.library.compose")
}
id("maven-publish")
}

val launchAsApplication = project.plugins.findPlugin("foodiestudio.android.library.compose") == null

android {
namespace = "com.github.foodiestudio.devtools"
compileSdk = 33

defaultConfig {
minSdk = 21
targetSdk = 33

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")

if (!launchAsApplication) {
(this as LibraryDefaultConfig).consumerProguardFiles("consumer-rules.pro")
}
}

buildTypes {
getByName("release") {
release {
isMinifyEnabled = false
setProguardFiles(listOf(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"))
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
}
buildFeatures {
buildConfig = false
aidl = false
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = sharedLibs.versions.compose.compiler.get()
}
packagingOptions {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
setProguardFiles(
listOf(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
)
}
}
publishing {
Expand All @@ -52,19 +44,21 @@ android {
}

dependencies {
val composeBom = platform(sharedLibs.compose.bom)
implementation(composeBom)
implementation(sharedLibs.bundles.compose.core)
implementation(sharedLibs.accompanist.systemuicontroller)
implementation(sharedLibs.accompanist.navigation.material)
implementation(sharedLibs.okio)
implementation("com.iqiyi.xcrash:xcrash-android-lib:3.0.0")
api(sharedLibs.startup)

testImplementation(sharedLibs.junit)
// debugOnly
debugImplementation(sharedLibs.activity.compose)
debugImplementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1")
debugImplementation(sharedLibs.compose.material)
}

group = "com.github.foodiestudio"
version = "0.1.1"
version = "0.1.5"

publishing {
publications {
Expand Down
14 changes: 14 additions & 0 deletions devtools/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:label="Devtools Sample"
android:theme="@android:style/Theme.Material.Light.NoActionBar">
<activity
android:name=".SampleActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.github.foodiestudio.devtools

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material.Button
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier

class SampleActivity : ComponentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
Content()
}
}
}

@Composable
private fun Content(modifier: Modifier = Modifier) {
Button(onClick = { TODO("test") }) {
Text(text = "throw Error")
}
}
8 changes: 6 additions & 2 deletions devtools/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@
android:exported="true" />

<provider
android:name=".internal.DevToolsFileProvider"
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true" />
android:grantUriPermissions="true" >
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ object DevToolsManager {
if (initialized) {
return
}
xcrash.XCrash.init(context)
this.widgets = widgets
val shortcut = ShortcutInfoCompat.Builder(context, "id-dev-tools")
.setShortLabel("Dev Tools")
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import androidx.compose.material.icons.filled.ArrowRight
import androidx.compose.material.icons.filled.Folder
import androidx.compose.material.icons.filled.FolderOpen
import androidx.compose.material.icons.filled.InsertDriveFile
import androidx.compose.material.icons.filled.Share
import androidx.compose.material.rememberScaffoldState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.derivedStateOf
Expand Down Expand Up @@ -108,6 +109,30 @@ internal fun AppFilesScreen() {
.navigationBarsPadding()
.padding(paddingValues),
fileList,
onShare = {
val uri =
FileProvider.getUriForFile(
context,
context.packageName + ".fileprovider",
it
)
val mime: String =
context.contentResolver.getType(uri) ?: MimeTypeMap.getSingleton()
.getMimeTypeFromExtension(it.extension) ?: "*/*"

runCatching {
Intent().apply {
action = Intent.ACTION_SEND
type = mime
putExtra(Intent.EXTRA_STREAM, uri)
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
context.startActivity(this)
}
}.onFailure { err ->
Toast.makeText(context, err.message, Toast.LENGTH_SHORT).show()
err.printStackTrace()
}
},
onItemClick = {
if (it.isDirectory) {
navStack = navStack.toMutableList().apply {
Expand Down Expand Up @@ -194,6 +219,7 @@ private fun FileList(
modifier: Modifier,
fileList: List<File>,
onItemClick: (File) -> Unit,
onShare: (File) -> Unit
) {
if (fileList.isEmpty()) {
NoFiles(modifier)
Expand Down Expand Up @@ -223,6 +249,13 @@ private fun FileList(
Text(text = Timestamp(it.lastModified()).toString())
}
} else null,
trailing = if (!it.isDirectory) {
@Composable {
IconButton(onClick = { onShare(it) }) {
Icon(Icons.Filled.Share, "share")
}
}
} else null
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import com.github.foodiestudio.devtools.kibana.kibanaQuery

@OptIn(ExperimentalComposeUiApi::class)
@Composable
fun KibanaQuerySheet(
internal fun KibanaQuerySheet(
modifier: Modifier,
kibanaBaseUrl: String = "",
kibanaIndex: String = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ package com.github.foodiestudio.devtools.internal.ui

import android.content.Context
import android.content.Intent
import android.net.Uri
import android.content.pm.PackageManager
import android.os.Build
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.basicMarquee
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
Expand All @@ -25,12 +28,16 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.core.content.pm.PackageInfoCompat
import androidx.core.net.toUri
import androidx.navigation.NavHostController
import com.github.foodiestudio.devtools.DevToolsManager
import com.github.foodiestudio.devtools.R


@OptIn(ExperimentalFoundationApi::class)
@Composable
fun MainScreen(navigator: NavHostController) {
internal fun MainScreen(navigator: NavHostController) {
val context = LocalContext.current

val map: Map<String, String> = remember {
Expand All @@ -42,8 +49,26 @@ fun MainScreen(navigator: NavHostController) {
TopAppBar(
title = {
Column {
val versionCode = PackageInfoCompat.getLongVersionCode(
context.packageManager.getPackageInfo(
context.packageName,
0
)
)
val versionName = context.packageManager.getPackageInfo(
context.packageName,
0
).versionName
val targetSdkVersion = context.packageManager.getApplicationInfo(
context.packageName,
0
).targetSdkVersion
Text(text = context.getAppName())
Text("DevTools", style = MaterialTheme.typography.caption)
Text(
modifier = Modifier.basicMarquee(),
text = "Version: $versionName($versionCode) Target SDK: $targetSdkVersion",
style = MaterialTheme.typography.caption
)
}
},
modifier = Modifier.statusBarsPadding(),
Expand All @@ -52,7 +77,7 @@ fun MainScreen(navigator: NavHostController) {
context.startActivity(
Intent(
Intent.ACTION_VIEW,
Uri.parse("https://github.com/foodiestudio/dev-tools/issues")
"https://github.com/foodiestudio/devtools/issues".toUri()
)
)
}) {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ android.useAndroidX=true
#android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
android.disableAutomaticComponentCreation=true
android.suppressUnsupportedCompileSdk=34
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jan 21 23:40:41 CST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
2 changes: 2 additions & 0 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jdk:
- openjdk17
16 changes: 10 additions & 6 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ pluginManagement {
google()
mavenCentral()
gradlePluginPortal()
maven("https://jitpack.io")
}
resolutionStrategy {
eachPlugin {
if (requested.id.id.startsWith("foodiestudio")) {
// convention-plugins:0.4.0 依赖 libs-versions:2023.08.01,
useModule("com.github.foodiestudio:convention-plugins:0.4.0")
}
}
}
}

Expand All @@ -15,12 +24,7 @@ dependencyResolutionManagement {
}
versionCatalogs {
create("sharedLibs") {
from("io.github.foodiestudio:libs-versions:2023.04.00")
library("startup", "androidx.startup:startup-runtime:1.1.1")
val accompanistVersion = "0.30.1"
library("accompanist-systemuicontroller", "com.google.accompanist:accompanist-systemuicontroller:$accompanistVersion")
library("accompanist-navigation-material", "com.google.accompanist:accompanist-navigation-material:$accompanistVersion")
library("okio", "com.squareup.okio:okio:3.3.0")
from("io.github.foodiestudio:libs-versions:2023.08.01")
}
}
}
Expand Down