Initial import: Music_Server, MusicFree, catalog-sync

This commit is contained in:
2026-05-23 16:51:14 +08:00
commit 069af30dba
847 changed files with 179878 additions and 0 deletions
+191
View File
@@ -0,0 +1,191 @@
apply plugin: "com.android.application"
apply plugin: "org.jetbrains.kotlin.android"
apply plugin: "com.facebook.react"
import com.android.build.OutputFile
import groovy.json.JsonSlurper
/**
* This is the configuration block to customize your React Native Android app.
* By default you don't need to apply any configuration, just uncomment the lines you need.
*/
react {
/* Folders */
// The root of your project, i.e. where "package.json" lives. Default is '../..'
// root = file("../../")
// The folder where the react-native NPM package is. Default is ../../node_modules/react-native
// reactNativeDir = file("../../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../../node_modules/@react-native/codegen
// codegenDir = file("../../node_modules/@react-native/codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../../node_modules/react-native/cli.js
// cliFile = file("../../node_modules/react-native/cli.js")
/* Variants */
// The list of variants to that are debuggable. For those we're going to
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
// debuggableVariants = ["liteDebug", "prodDebug"]
/* Bundling */
// A list containing the node command and its flags. Default is just 'node'.
// nodeExecutableAndArgs = ["node"]
//
// The command to run when bundling. By default is 'bundle'
// bundleCommand = "ram-bundle"
//
// The path to the CLI configuration file. Default is empty.
// bundleConfig = file(../rn-cli.config.js)
//
// The name of the generated asset file containing your JS bundle
// bundleAssetName = "MyApplication.android.bundle"
//
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
// entryFile = file("../js/MyApplication.android.js")
//
// A list of extra flags to pass to the 'bundle' commands.
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
// extraPackagerArgs = []
/* Hermes Commands */
// The hermes compiler command to run. By default it is 'hermesc'
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
//
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
// hermesFlags = ["-O", "-output-source-map"]
/* Autolinking */
autolinkLibrariesWithApp()
//
// Added by install-expo-modules
entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", rootDir.getAbsoluteFile().getParentFile().getAbsolutePath(), "android", "absolute"].execute(null, rootDir).text.trim())
cliFile = new File(["node", "--print", "require.resolve('@expo/cli')"].execute(null, rootDir).text.trim())
bundleCommand = "export:embed"
//
// Added by install-expo-modules
entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", rootDir.getAbsoluteFile().getParentFile().getAbsolutePath(), "android", "absolute"].execute(null, rootDir).text.trim())
cliFile = new File(["node", "--print", "require.resolve('@expo/cli')"].execute(null, rootDir).text.trim())
bundleCommand = "export:embed"
}
/**
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
*/
def enableProguardInReleaseBuilds = false
/**
* The preferred build flavor of JavaScriptCore (JSC)
*
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
*
* The international variant includes ICU i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'
// !! Add lines
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('keystore.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
static def getVersion() {
def inputFile = new File("../package.json")
def packageJson = new JsonSlurper().parseText(inputFile.text)
return packageJson["version"]
}
// static def versionStringToCode(String version) {
// def parts = version.split('\\.')
// def versionCode = 0
// def multiplier = 1000000
//
// parts.each { part ->
// versionCode += part.toInteger() * multiplier
// multiplier /= 1000
// }
//
// return versionCode.intValue()
// }
def appVersion = getVersion()
def appVersionCode = 400012
android {
ndkVersion rootProject.ext.ndkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
compileSdk rootProject.ext.compileSdkVersion
namespace "fun.upup.musicfree"
defaultConfig {
applicationId "fun.upup.musicfree"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode appVersionCode
versionName appVersion
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
// !! Add lines
release {
storeFile file(keystoreProperties['RELEASE_STORE_FILE'])
storePassword keystoreProperties['RELEASE_STORE_PASSWORD']
keyAlias keystoreProperties['RELEASE_KEY_ALIAS']
keyPassword keystoreProperties['RELEASE_KEY_PASSWORD']
}
}
splits {
abi {
reset()
enable true
universalApk true
include "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
}
dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
implementation jscFlavor
}
// !! Add lines
implementation project(':react-native-fs')
implementation 'com.facebook.fresco:animated-gif:2.5.0'
// https://mvnrepository.com/artifact/net.jthink/jaudiotagger
implementation 'net.jthink:jaudiotagger:2.2.5'
implementation 'androidx.core:core-splashscreen:1.0.0'
}
+10
View File
@@ -0,0 +1,10 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
@@ -0,0 +1,31 @@
package `fun`.upup.musicfree
import expo.modules.ReactActivityDelegateWrapper
import expo.modules.splashscreen.SplashScreenManager
import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
import com.facebook.react.defaults.DefaultReactActivityDelegate
import android.os.Bundle
class MainActivity : ReactActivity() {
/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
override fun getMainComponentName(): String = "MusicFree"
/**
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
* which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
*/
override fun createReactActivityDelegate(): ReactActivityDelegate =
ReactActivityDelegateWrapper(this, BuildConfig.IS_NEW_ARCHITECTURE_ENABLED, DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled))
// https://reactnavigation.org/docs/getting-started/#installing-dependencies-into-a-bare-react-native-project
override fun onCreate(savedInstanceState: Bundle?) {
SplashScreenManager.registerOnActivity(this)
super.onCreate(null);
}
}
@@ -0,0 +1,59 @@
package `fun`.upup.musicfree
import android.content.res.Configuration
import expo.modules.ApplicationLifecycleDispatcher
import expo.modules.ReactNativeHostWrapper
import android.app.Application
import com.facebook.react.PackageList
import com.facebook.react.ReactApplication
import com.facebook.react.ReactHost
import com.facebook.react.ReactNativeHost
import com.facebook.react.ReactPackage
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
import com.facebook.react.defaults.DefaultReactNativeHost
import com.facebook.react.soloader.OpenSourceMergedSoMapping
import com.facebook.soloader.SoLoader
import `fun`.upup.musicfree.lyricUtil.LyricUtilPackage
import `fun`.upup.musicfree.mp3Util.Mp3UtilPackage
import `fun`.upup.musicfree.utils.UtilsPackage
class MainApplication : Application(), ReactApplication {
override val reactNativeHost: ReactNativeHost =
ReactNativeHostWrapper(this, object : DefaultReactNativeHost(this) {
override fun getPackages(): List<ReactPackage> =
PackageList(this).packages.apply {
// Packages that cannot be autolinked yet can be added manually here, for example:
// add(MyReactNativePackage())
add(UtilsPackage())
add(Mp3UtilPackage())
add(LyricUtilPackage())
}
override fun getJSMainModuleName(): String = "index"
override fun getUseDeveloperSupport(): Boolean = BuildConfig.DEBUG
override val isNewArchEnabled: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
override val isHermesEnabled: Boolean = BuildConfig.IS_HERMES_ENABLED
})
override val reactHost: ReactHost
get() = ReactNativeHostWrapper.createReactHost(applicationContext, reactNativeHost)
override fun onCreate() {
super.onCreate()
SoLoader.init(this, OpenSourceMergedSoMapping)
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
// If you opted-in for the New Architecture, we load the native entry point for this app.
load()
}
ApplicationLifecycleDispatcher.onApplicationCreate(this)
}
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig)
}
}
@@ -0,0 +1,182 @@
package `fun`.upup.musicfree.lyricUtil
import android.app.Activity
import android.content.Intent
import android.net.Uri
import android.os.Build
import android.provider.Settings
import android.util.Log
import androidx.annotation.RequiresApi
import com.facebook.react.bridge.*
import java.util.*
class LyricUtilModule(private val reactContext: ReactApplicationContext): ReactContextBaseJavaModule(reactContext) {
override fun getName() = "LyricUtil"
private var lyricView: LyricView? = null
@ReactMethod
fun checkSystemAlertPermission(promise: Promise) {
try {
promise.resolve(Settings.canDrawOverlays(reactContext))
} catch (e: Exception) {
promise.reject("Error", e.message)
}
}
@ReactMethod
fun requestSystemAlertPermission(promise: Promise) {
try {
val intent = Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION).apply {
data = Uri.parse("package:" + reactContext.packageName)
}
currentActivity?.startActivity(intent)
promise.resolve(true)
} catch (e: Exception) {
promise.reject("Error", e.message)
}
}
@ReactMethod
fun showStatusBarLyric(initLyric: String?, options: ReadableMap?, promise: Promise) {
try {
UiThreadUtil.runOnUiThread {
if (lyricView == null) {
lyricView = LyricView(reactContext)
}
val mapOptions = mutableMapOf<String, Any>().apply {
if (options == null) {
return@apply
}
if (options.hasKey("topPercent")) {
put("topPercent", options.getDouble("topPercent"))
}
if (options.hasKey("leftPercent")) {
put("leftPercent", options.getDouble("leftPercent"))
}
if (options.hasKey("align")) {
put("align", options.getInt("align"))
}
if (options.hasKey("color")) {
options.getString("color")?.let { put("color", it) }
}
if (options.hasKey("backgroundColor")) {
options.getString("backgroundColor")?.let { put("backgroundColor", it) }
}
if (options.hasKey("widthPercent")) {
put("widthPercent", options.getDouble("widthPercent"))
}
if (options.hasKey("fontSize")) {
put("fontSize", options.getDouble("fontSize"))
}
}
try {
lyricView?.showLyricWindow(initLyric, mapOptions)
promise.resolve(true)
} catch (e: Exception) {
promise.reject("Exception", e.message)
}
}
} catch (e: Exception) {
promise.reject("Exception", e.message)
}
}
@ReactMethod
fun hideStatusBarLyric(promise: Promise) {
try {
UiThreadUtil.runOnUiThread {
lyricView?.hideLyricWindow()
}
promise.resolve(true)
} catch (e: Exception) {
promise.reject("Exception", e.message)
}
}
@ReactMethod
fun setStatusBarLyricText(lyric: String, promise: Promise) {
try {
UiThreadUtil.runOnUiThread {
lyricView?.setText(lyric)
}
promise.resolve(true)
} catch (e: Exception) {
promise.reject("Exception", e.message)
}
}
@ReactMethod
fun setStatusBarLyricAlign(alignment: Int, promise: Promise) {
try {
UiThreadUtil.runOnUiThread {
lyricView?.setAlign(alignment)
}
promise.resolve(true)
} catch (e: Exception) {
promise.reject("Exception", e.message)
}
}
@ReactMethod
fun setStatusBarLyricTop(pct: Double, promise: Promise) {
try {
UiThreadUtil.runOnUiThread {
lyricView?.setTopPercent(pct)
}
promise.resolve(true)
} catch (e: Exception) {
promise.reject("Exception", e.message)
}
}
@ReactMethod
fun setStatusBarLyricLeft(pct: Double, promise: Promise) {
try {
UiThreadUtil.runOnUiThread {
lyricView?.setLeftPercent(pct)
}
promise.resolve(true)
} catch (e: Exception) {
promise.reject("Exception", e.message)
}
}
@ReactMethod
fun setStatusBarLyricWidth(pct: Double, promise: Promise) {
try {
UiThreadUtil.runOnUiThread {
lyricView?.setWidth(pct)
}
promise.resolve(true)
} catch (e: Exception) {
promise.reject("Exception", e.message)
}
}
@ReactMethod
fun setStatusBarLyricFontSize(fontSize: Float, promise: Promise) {
try {
UiThreadUtil.runOnUiThread {
lyricView?.setFontSize(fontSize)
}
promise.resolve(true)
} catch (e: Exception) {
promise.reject("Exception", e.message)
}
}
@ReactMethod
fun setStatusBarColors(textColor: String?, backgroundColor: String?, promise: Promise) {
try {
UiThreadUtil.runOnUiThread {
lyricView?.setColors(textColor, backgroundColor)
}
promise.resolve(true)
} catch (e: Exception) {
promise.reject("Exception", e.message)
}
}
}
@@ -0,0 +1,19 @@
package `fun`.upup.musicfree.lyricUtil
import android.view.View
import com.facebook.react.ReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.uimanager.ReactShadowNode
import com.facebook.react.uimanager.ViewManager
class LyricUtilPackage : ReactPackage {
override fun createViewManagers(
reactContext: ReactApplicationContext
): MutableList<ViewManager<View, ReactShadowNode<*>>> = mutableListOf()
override fun createNativeModules(
reactContext: ReactApplicationContext
): MutableList<NativeModule> = listOf(LyricUtilModule(reactContext)).toMutableList()
}
@@ -0,0 +1,222 @@
package `fun`.upup.musicfree.lyricUtil
import android.app.Activity
import android.content.Context
import android.graphics.Color
import android.graphics.PixelFormat
import android.graphics.drawable.ColorDrawable
import android.hardware.SensorManager
import android.os.Build
import android.util.DisplayMetrics
import android.util.Log
import android.view.Gravity
import android.view.MotionEvent
import android.view.OrientationEventListener
import android.view.View
import android.view.WindowManager
import android.widget.TextView
import com.facebook.react.bridge.ReactContext
class LyricView(private val reactContext: ReactContext) : Activity(), View.OnTouchListener {
private var windowManager: WindowManager? = null
private var orientationEventListener: OrientationEventListener? = null
private var layoutParams: WindowManager.LayoutParams? = null
private var tv: TextView? = null
// 窗口信息
private var windowWidth = 0.0
private var windowHeight = 0.0
private var widthPercent = 0.0
private var leftPercent = 0.0
private var topPercent = 0.0
override fun onTouch(view: View, motionEvent: MotionEvent): Boolean {
Log.d("touch", "Desktop Touch")
return false
}
// 展示歌词窗口
fun showLyricWindow(initText: String?, options: Map<String, Any>) {
try {
if (windowManager == null) {
windowManager = reactContext.getSystemService(WINDOW_SERVICE) as WindowManager
layoutParams = WindowManager.LayoutParams()
val outMetrics = DisplayMetrics()
windowManager?.defaultDisplay?.getMetrics(outMetrics)
windowWidth = outMetrics.widthPixels.toDouble()
windowHeight = outMetrics.heightPixels.toDouble()
layoutParams?.type = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT
else
WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY
/*
* topPercent: number;
* leftPercent: number;
* align: number;
* color: string;
* backgroundColor: string;
* widthPercent: number;
* fontSize: number;
*/
val topPercent = options["topPercent"]
val leftPercent = options["leftPercent"]
val align = options["align"]
val color = options["color"]
val backgroundColor = options["backgroundColor"]
val widthPercent = options["widthPercent"]
val fontSize = options["fontSize"]
this.widthPercent = widthPercent?.toString()?.toDouble() ?: 0.5
layoutParams?.width = (this.widthPercent * windowWidth).toInt()
layoutParams?.height = WindowManager.LayoutParams.WRAP_CONTENT
layoutParams?.gravity = Gravity.TOP or Gravity.START
this.leftPercent = leftPercent?.toString()?.toDouble() ?: 0.5
layoutParams?.x = (this.leftPercent * (windowWidth - layoutParams!!.width)).toInt()
layoutParams?.y = 0
layoutParams?.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL or
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN or
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS or
WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
layoutParams?.format = PixelFormat.TRANSPARENT
tv = TextView(reactContext).apply {
text = initText ?: ""
textSize = fontSize?.toString()?.toFloat() ?: 14f
setBackgroundColor(Color.parseColor(rgba2argb(backgroundColor?.toString() ?: "#84888153")))
setTextColor(Color.parseColor(rgba2argb(color?.toString() ?: "#FFE9D2")))
setPadding(12, 6, 12, 6)
gravity = align?.toString()?.toInt() ?: Gravity.CENTER
}
windowManager?.addView(tv, layoutParams)
topPercent?.toString()?.toDouble()?.let { setTopPercent(it) }
listenOrientationChange()
}
} catch (e: Exception) {
hideLyricWindow()
throw e
}
}
private fun listenOrientationChange() {
if (windowManager == null) return
if (orientationEventListener == null) {
orientationEventListener = object : OrientationEventListener(reactContext, SensorManager.SENSOR_DELAY_NORMAL) {
override fun onOrientationChanged(orientation: Int) {
if (windowManager != null) {
val outMetrics = DisplayMetrics()
windowManager?.defaultDisplay?.getMetrics(outMetrics)
windowWidth = outMetrics.widthPixels.toDouble()
windowHeight = outMetrics.heightPixels.toDouble()
layoutParams?.width = (widthPercent * windowWidth).toInt()
layoutParams?.x = (leftPercent * (windowWidth - layoutParams!!.width)).toInt()
layoutParams?.y = (topPercent * (windowHeight - tv!!.height)).toInt()
windowManager?.updateViewLayout(tv, layoutParams)
}
}
}
}
if (orientationEventListener?.canDetectOrientation() == true) {
orientationEventListener?.enable()
}
}
private fun unlistenOrientationChange() {
orientationEventListener?.disable()
}
private fun rgba2argb(color: String): String {
return if (color.length == 9) {
color[0] + color.substring(7, 9) + color.substring(1, 7)
} else {
color
}
}
// 隐藏歌词窗口
fun hideLyricWindow() {
if (windowManager != null) {
tv?.let {
try {
windowManager?.removeView(it)
} catch (e: Exception) {
// Handle exception
}
tv = null
}
windowManager = null
layoutParams = null
unlistenOrientationChange()
}
}
// 设置歌词内容
fun setText(text: String) {
tv?.text = text
}
fun setAlign(gravity: Int) {
tv?.gravity = gravity
}
fun setTopPercent(pct: Double) {
var percent = pct.coerceIn(0.0, 1.0)
tv?.let {
layoutParams?.y = (percent * (windowHeight - it.height)).toInt()
windowManager?.updateViewLayout(it, layoutParams)
}
this.topPercent = percent
}
fun setLeftPercent(pct: Double) {
var percent = pct.coerceIn(0.0, 1.0)
tv?.let {
layoutParams?.x = (percent * (windowWidth - layoutParams!!.width)).toInt()
windowManager?.updateViewLayout(it, layoutParams)
}
this.leftPercent = percent
}
fun setColors(textColor: String?, backgroundColor: String?) {
tv?.let {
textColor?.let { color -> it.setTextColor(Color.parseColor(rgba2argb(color))) }
backgroundColor?.let { color ->
it.background = ColorDrawable(Color.parseColor(rgba2argb(color)))
}
}
}
fun setWidth(pct: Double) {
var percent = pct.coerceIn(0.3, 1.0)
tv?.let {
val width = (percent * windowWidth).toInt()
val originalWidth = layoutParams?.width ?: 0
layoutParams?.x = if (width <= originalWidth) {
layoutParams!!.x + (originalWidth - width) / 2
} else {
layoutParams!!.x - (width - originalWidth) / 2
}.coerceAtLeast(0).coerceAtMost((windowWidth - width).toInt())
layoutParams?.width = width
windowManager?.updateViewLayout(it, layoutParams)
}
this.widthPercent = percent
}
fun setFontSize(fontSize: Float) {
tv?.textSize = fontSize
}
}
@@ -0,0 +1,190 @@
package `fun`.upup.musicfree.mp3Util
import android.graphics.Bitmap
import android.graphics.BitmapFactory
import android.media.MediaMetadataRetriever
import android.net.Uri
import com.facebook.react.bridge.*
import org.jaudiotagger.audio.AudioFileIO
import org.jaudiotagger.tag.FieldKey
import java.io.File
import java.io.FileOutputStream
import java.io.IOException
class Mp3UtilModule(private val reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
override fun getName() = "Mp3Util"
private fun isContentUri(uri: Uri?): Boolean {
return uri?.scheme?.equals("content", ignoreCase = true) == true
}
@ReactMethod
fun getBasicMeta(filePath: String, promise: Promise) {
try {
val uri = Uri.parse(filePath)
val mmr = MediaMetadataRetriever()
if (isContentUri(uri)) {
mmr.setDataSource(reactApplicationContext, uri)
} else {
mmr.setDataSource(filePath)
}
val properties = Arguments.createMap().apply {
putString("duration", mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION))
putString("bitrate", mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_BITRATE))
putString("artist", mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST))
putString("author", mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_AUTHOR))
putString("album", mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM))
putString("title", mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE))
putString("date", mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DATE))
putString("year", mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_YEAR))
}
promise.resolve(properties)
} catch (e: Exception) {
promise.reject("Exception", e.message)
}
}
@ReactMethod
fun getMediaMeta(filePaths: ReadableArray, promise: Promise) {
val metas = Arguments.createArray()
val mmr = MediaMetadataRetriever()
for (i in 0 until filePaths.size()) {
try {
val filePath = filePaths.getString(i)
val uri = Uri.parse(filePath)
if (isContentUri(uri)) {
mmr.setDataSource(reactApplicationContext, uri)
} else {
mmr.setDataSource(filePath)
}
val properties = Arguments.createMap().apply {
putString("duration", mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION))
putString("bitrate", mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_BITRATE))
putString("artist", mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST))
putString("author", mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_AUTHOR))
putString("album", mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ALBUM))
putString("title", mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_TITLE))
putString("date", mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DATE))
putString("year", mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_YEAR))
}
metas.pushMap(properties)
} catch (e: Exception) {
metas.pushNull()
}
}
try {
mmr.release()
} catch (ignored: Exception) {
}
promise.resolve(metas)
}
@ReactMethod
fun getMediaCoverImg(filePath: String, promise: Promise) {
try {
val file = File(filePath)
if (!file.exists()) {
promise.reject("File not exist", "File not exist")
return
}
val pathHashCode = file.hashCode()
if (pathHashCode == 0) {
promise.resolve(null)
return
}
val cacheDir = reactContext.cacheDir
val coverFile = File(cacheDir, "image_manager_disk_cache/$pathHashCode.jpg")
if (coverFile.exists()) {
promise.resolve(coverFile.toURI().toString())
return
}
val mmr = MediaMetadataRetriever()
mmr.setDataSource(filePath)
val coverImg = mmr.embeddedPicture
if (coverImg != null) {
val bitmap = BitmapFactory.decodeByteArray(coverImg, 0, coverImg.size)
FileOutputStream(coverFile).use { outputStream ->
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream)
outputStream.flush()
}
promise.resolve(coverFile.toURI().toString())
} else {
promise.resolve(null)
}
mmr.release()
} catch (ignored: Exception) {
promise.reject("Error", "Got error")
}
}
@ReactMethod
fun getLyric(filePath: String, promise: Promise) {
try {
val file = File(filePath)
if (file.exists()) {
val audioFile = AudioFileIO.read(file)
val tag = audioFile.tag
val lrc = tag.getFirst(FieldKey.LYRICS)
promise.resolve(lrc)
} else {
throw IOException("File not found")
}
} catch (e: Exception) {
promise.reject("Error", e.message)
}
}
@ReactMethod
fun setMediaTag(filePath: String, meta: ReadableMap, promise: Promise) {
try {
val file = File(filePath)
if (file.exists()) {
val audioFile = AudioFileIO.read(file)
val tag = audioFile.tag
meta.getString("title")?.let { tag.setField(FieldKey.TITLE, it) }
meta.getString("artist")?.let { tag.setField(FieldKey.ARTIST, it) }
meta.getString("album")?.let { tag.setField(FieldKey.ALBUM, it) }
meta.getString("lyric")?.let { tag.setField(FieldKey.LYRICS, it) }
meta.getString("comment")?.let { tag.setField(FieldKey.COMMENT, it) }
audioFile.commit()
promise.resolve(true)
} else {
promise.reject("Error", "File Not Exist")
}
} catch (e: Exception) {
promise.reject("Error", e.message)
}
}
@ReactMethod
fun getMediaTag(filePath: String, promise: Promise) {
try {
val file = File(filePath)
if (file.exists()) {
val audioFile = AudioFileIO.read(file)
val tag = audioFile.tag
val properties = Arguments.createMap().apply {
putString("title", tag.getFirst(FieldKey.TITLE))
putString("artist", tag.getFirst(FieldKey.ARTIST))
putString("album", tag.getFirst(FieldKey.ALBUM))
putString("lyric", tag.getFirst(FieldKey.LYRICS))
putString("comment", tag.getFirst(FieldKey.COMMENT))
}
promise.resolve(properties)
} else {
promise.reject("Error", "File Not Found")
}
} catch (e: Exception) {
promise.reject("Error", e.message)
}
}
}
@@ -0,0 +1,19 @@
package `fun`.upup.musicfree.mp3Util
import android.view.View
import com.facebook.react.ReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.uimanager.ReactShadowNode
import com.facebook.react.uimanager.ViewManager
class Mp3UtilPackage : ReactPackage {
override fun createViewManagers(
reactContext: ReactApplicationContext
): MutableList<ViewManager<View, ReactShadowNode<*>>> = mutableListOf()
override fun createNativeModules(
reactContext: ReactApplicationContext
): MutableList<NativeModule> = listOf(Mp3UtilModule(reactContext)).toMutableList()
}
@@ -0,0 +1,164 @@
package `fun`.upup.musicfree.utils; // replace your-apps-package-name with your apps package name
import android.Manifest
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Build
import android.os.Environment
import android.os.PowerManager
import android.provider.Settings
import android.util.DisplayMetrics
import android.view.WindowInsets
import android.view.WindowManager
import androidx.core.content.ContextCompat
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.Promise
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContextBaseJavaModule
import com.facebook.react.bridge.ReactMethod
import com.facebook.react.bridge.WritableMap
import kotlin.system.exitProcess
class UtilsModule(context: ReactApplicationContext) : ReactContextBaseJavaModule(context) {
private val reactContext: ReactApplicationContext = context;
override fun getName() = "NativeUtils"
@ReactMethod
fun exitApp() {
val activity = reactContext.currentActivity
activity?.finishAndRemoveTask()
android.os.Process.killProcess(android.os.Process.myPid())
exitProcess(0)
}
@ReactMethod
fun checkStoragePermission(promise: Promise) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
promise.resolve(Environment.isExternalStorageManager())
} else {
val readPermission = ContextCompat.checkSelfPermission(reactContext, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
val writePermission = ContextCompat.checkSelfPermission(reactContext, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
promise.resolve(readPermission && writePermission)
}
}
@ReactMethod
fun requestStoragePermission() {
val intent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION).apply {
data = Uri.parse("package:${reactContext.packageName}")
}
} else {
Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply {
data = Uri.parse("package:${reactContext.packageName}")
}
}
reactContext.currentActivity?.startActivity(intent)
}
@ReactMethod
fun isIgnoringBatteryOptimizations(promise: Promise) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val packageName = reactContext.packageName
val pm = reactContext.getSystemService(Context.POWER_SERVICE) as PowerManager
promise.resolve(pm.isIgnoringBatteryOptimizations(packageName))
} else {
promise.resolve(true)
}
}
@ReactMethod
fun requestIgnoreBatteryOptimizations(promise: Promise) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
try {
val packageName = reactContext.packageName
val pm = reactContext.getSystemService(Context.POWER_SERVICE) as PowerManager
if (!pm.isIgnoringBatteryOptimizations(packageName)) {
val intent = Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)
intent.data = Uri.parse("package:$packageName")
if (reactContext.currentActivity != null) {
reactContext.currentActivity?.startActivity(intent)
} else {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
reactContext.startActivity(intent)
}
}
promise.resolve(true)
} catch (e: Exception) {
promise.reject(e)
}
} else {
promise.resolve(true)
}
}
@ReactMethod(isBlockingSynchronousMethod = true)
fun getWindowDimensions(): WritableMap {
val windowManager = reactApplicationContext.getSystemService(Context.WINDOW_SERVICE) as WindowManager
val displayMetrics: DisplayMetrics = reactApplicationContext.resources.displayMetrics
val density = displayMetrics.density
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
// Android 11 (API 30) 及以上使用新 API
val windowMetrics = windowManager.currentWindowMetrics
val insets = windowMetrics.windowInsets.getInsetsIgnoringVisibility(WindowInsets.Type.systemBars())
val bounds = windowMetrics.bounds
val totalWidthPx = bounds.width()
val totalHeightPx = bounds.height()
val leftInsetPx = insets.left
val rightInsetPx = insets.right
val topInsetPx = insets.top
val bottomInsetPx = insets.bottom
val usableWidthPx = totalWidthPx - leftInsetPx - rightInsetPx
val usableHeightPx = totalHeightPx - topInsetPx - bottomInsetPx
val usableWidthDp = usableWidthPx / density
val usableHeightDp = usableHeightPx / density
Arguments.createMap().apply {
putDouble("width", usableWidthDp.toDouble())
putDouble("height", usableHeightDp.toDouble())
}
} else {
// Android 10 及以下使用旧 API
val display = windowManager.defaultDisplay
val realSize = android.graphics.Point()
display.getRealSize(realSize)
// 获取状态栏和导航栏高度
val resources = reactApplicationContext.resources
var statusBarHeight = 0
var navigationBarHeight = 0
// 状态栏高度
val statusBarResourceId = resources.getIdentifier("status_bar_height", "dimen", "android")
if (statusBarResourceId > 0) {
statusBarHeight = resources.getDimensionPixelSize(statusBarResourceId)
}
// 导航栏高度
val navigationBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android")
if (navigationBarResourceId > 0) {
navigationBarHeight = resources.getDimensionPixelSize(navigationBarResourceId)
}
val usableWidthPx = realSize.x
val usableHeightPx = realSize.y - statusBarHeight - navigationBarHeight
val usableWidthDp = usableWidthPx / density
val usableHeightDp = usableHeightPx / density
Arguments.createMap().apply {
putDouble("width", usableWidthDp.toDouble())
putDouble("height", usableHeightDp.toDouble())
}
}
}
}
@@ -0,0 +1,19 @@
package `fun`.upup.musicfree.utils
import android.view.View
import com.facebook.react.ReactPackage
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.uimanager.ReactShadowNode
import com.facebook.react.uimanager.ViewManager
class UtilsPackage : ReactPackage {
override fun createViewManagers(
reactContext: ReactApplicationContext
): MutableList<ViewManager<View, ReactShadowNode<*>>> = mutableListOf()
override fun createNativeModules(
reactContext: ReactApplicationContext
): MutableList<NativeModule> = listOf(UtilsModule(reactContext)).toMutableList()
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 944 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

+24
View File
@@ -0,0 +1,24 @@
buildscript {
ext {
buildToolsVersion = "35.0.0"
minSdkVersion = 24
compileSdkVersion = 35
targetSdkVersion = 30
ndkVersion = "26.1.10909125"
kotlinVersion = "1.9.24"
}
repositories {
maven { url 'https://maven.aliyun.com/repository/central'}
maven { url 'https://maven.aliyun.com/repository/public' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
dependencies {
classpath("com.android.tools.build:gradle")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin")
}
}
apply plugin: "com.facebook.react.rootproject"
+39
View File
@@ -0,0 +1,39 @@
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Use this property to specify which architecture you want to build.
# You can also override it from the CLI using
# ./gradlew <task> -PreactNativeArchitectures=x86_64
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
# Use this property to enable support to the new architecture.
# This will allow you to use TurboModules and the Fabric render in
# your application. You should enable this flag either if you want
# to write custom TurboModules/Fabric components OR use libraries that
# are providing them.
newArchEnabled=false
# Use this property to enable or disable the Hermes JS engine.
# If set to false, you will be using JSC instead.
hermesEnabled=true
Binary file not shown.
@@ -0,0 +1,8 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
# distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-8.10.2-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
+252
View File
@@ -0,0 +1,252 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
+94
View File
@@ -0,0 +1,94 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
+21
View File
@@ -0,0 +1,21 @@
pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
plugins { id("com.facebook.react.settings") }
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex ->
def command = [
'node',
'--no-warnings',
'--eval',
'require(require.resolve(\'expo-modules-autolinking\', { paths: [require.resolve(\'expo/package.json\')] }))(process.argv.slice(1))',
'react-native-config',
'--json',
'--platform',
'android'
].toList()
ex.autolinkLibrariesFromCommand(command)
}
rootProject.name = 'MusicFree'
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle")
useExpoModules()