接入tradplus
15
.gitignore
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
local.properties
|
||||
3
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
6
.idea/AndroidProjectSystem.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AndroidProjectSystem">
|
||||
<option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/compiler.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="21" />
|
||||
</component>
|
||||
</project>
|
||||
18
.idea/deploymentTargetSelector.xml
generated
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetSelector">
|
||||
<selectionStates>
|
||||
<SelectionState runConfigName="app">
|
||||
<option name="selectionMode" value="DROPDOWN" />
|
||||
<DropdownSelection timestamp="2025-12-10T03:40:22.982086600Z">
|
||||
<Target type="DEFAULT_BOOT">
|
||||
<handle>
|
||||
<DeviceId pluginId="LocalEmulator" identifier="path=C:\Users\24526\.android\avd\Pixel_9_Pro.avd" />
|
||||
</handle>
|
||||
</Target>
|
||||
</DropdownSelection>
|
||||
<DialogSelection />
|
||||
</SelectionState>
|
||||
</selectionStates>
|
||||
</component>
|
||||
</project>
|
||||
13
.idea/deviceManager.xml
generated
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DeviceTable">
|
||||
<option name="columnSorters">
|
||||
<list>
|
||||
<ColumnSorterState>
|
||||
<option name="column" value="Name" />
|
||||
<option name="order" value="ASCENDING" />
|
||||
</ColumnSorterState>
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
19
.idea/gradle.xml
generated
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="CHOOSE_PER_TEST" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
10
.idea/migrations.xml
generated
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectMigrations">
|
||||
<option name="MigrateToGradleLocalJavaHome">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
9
.idea/misc.xml
generated
Normal file
@ -0,0 +1,9 @@
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
||||
17
.idea/runConfigurations.xml
generated
Normal file
@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
|
||||
<option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
|
||||
<option value="com.intellij.execution.junit.PatternConfigurationProducer" />
|
||||
<option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
|
||||
<option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
|
||||
<option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
|
||||
<option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
|
||||
<option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
4
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings" defaultProject="true" />
|
||||
</project>
|
||||
1
app/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/build
|
||||
71
app/build.gradle.kts
Normal file
@ -0,0 +1,71 @@
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
id("kotlin-kapt")
|
||||
id("kotlin-parcelize")
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.design.mischiefgo"
|
||||
compileSdk {
|
||||
version = release(36)
|
||||
}
|
||||
val timeStamp = SimpleDateFormat("MM_dd_HH_mm").format(Date())
|
||||
defaultConfig {
|
||||
applicationId = "com.design.mischiefgo"
|
||||
minSdk = 26
|
||||
targetSdk = 36
|
||||
versionCode = 1
|
||||
versionName = "1.0"
|
||||
setProperty(
|
||||
"archivesBaseName",
|
||||
"Mischief_Go_V" + versionName + "_${versionCode}$timeStamp"
|
||||
)
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
isMinifyEnabled = false
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = "11"
|
||||
}
|
||||
buildFeatures{
|
||||
viewBinding = true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(libs.androidx.core.ktx)
|
||||
implementation(libs.androidx.appcompat)
|
||||
implementation(libs.material)
|
||||
implementation(libs.androidx.activity)
|
||||
implementation(libs.androidx.constraintlayout)
|
||||
testImplementation(libs.junit)
|
||||
androidTestImplementation(libs.androidx.junit)
|
||||
androidTestImplementation(libs.androidx.espresso.core)
|
||||
|
||||
implementation("com.github.bumptech.glide:glide:4.16.0")
|
||||
// Room components
|
||||
implementation("androidx.room:room-runtime:2.7.2")
|
||||
kapt("androidx.room:room-compiler:2.7.2")
|
||||
implementation("androidx.room:room-ktx:2.7.2")
|
||||
// 其他相关依赖
|
||||
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2")
|
||||
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.6.2")
|
||||
implementation("androidx.activity:activity-ktx:1.10.1")
|
||||
implementation("com.google.android.flexbox:flexbox:3.0.0")
|
||||
}
|
||||
21
app/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
BIN
app/release/Mischief_Go_V1.0_112_10_13_46-release.apk
Normal file
BIN
app/release/Mischief_Go_V1.0_112_10_13_59-release.aab
Normal file
37
app/release/output-metadata.json
Normal file
@ -0,0 +1,37 @@
|
||||
{
|
||||
"version": 3,
|
||||
"artifactType": {
|
||||
"type": "APK",
|
||||
"kind": "Directory"
|
||||
},
|
||||
"applicationId": "com.design.mischiefgo",
|
||||
"variantName": "release",
|
||||
"elements": [
|
||||
{
|
||||
"type": "SINGLE",
|
||||
"filters": [],
|
||||
"attributes": [],
|
||||
"versionCode": 1,
|
||||
"versionName": "1.0",
|
||||
"outputFile": "Mischief_Go_V1.0_112_10_13_46-release.apk"
|
||||
}
|
||||
],
|
||||
"elementType": "File",
|
||||
"baselineProfiles": [
|
||||
{
|
||||
"minApi": 28,
|
||||
"maxApi": 30,
|
||||
"baselineProfiles": [
|
||||
"baselineProfiles/1/Mischief_Go_V1.0_112_10_13_46-release.dm"
|
||||
]
|
||||
},
|
||||
{
|
||||
"minApi": 31,
|
||||
"maxApi": 2147483647,
|
||||
"baselineProfiles": [
|
||||
"baselineProfiles/0/Mischief_Go_V1.0_112_10_13_46-release.dm"
|
||||
]
|
||||
}
|
||||
],
|
||||
"minSdkVersionForDexing": 26
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package com.design.mischiefgo
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
import org.junit.Assert.*
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* See [testing documentation](http://d.android.com/tools/testing).
|
||||
*/
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class ExampleInstrumentedTest {
|
||||
@Test
|
||||
fun useAppContext() {
|
||||
// Context of the app under test.
|
||||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
assertEquals("com.design.mischiefgo", appContext.packageName)
|
||||
}
|
||||
}
|
||||
50
app/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission
|
||||
android:name="android.permission.READ_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="32" />
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
android:maxSdkVersion="32" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:name=".NewApp"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.MischiefGo">
|
||||
<activity
|
||||
android:name=".ui.UseSoundActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".ui.TypeInActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".ui.NavigationActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".ui.ListenSoundActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".ui.SaveToLocalActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".ui.AdShowActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
BIN
app/src/main/assets/lato_regular.ttf
Normal file
3791
app/src/main/assets/prank.json
Normal file
BIN
app/src/main/ic_launcher-playstore.png
Normal file
|
After Width: | Height: | Size: 338 KiB |
53
app/src/main/java/com/design/mischiefgo/NewApp.kt
Normal file
@ -0,0 +1,53 @@
|
||||
package com.design.mischiefgo
|
||||
|
||||
import android.app.Application
|
||||
import android.graphics.Typeface
|
||||
import android.util.Log
|
||||
import com.design.mischiefgo.entity.AppDataBase
|
||||
import com.design.mischiefgo.entity.Usual
|
||||
import com.design.mischiefgo.ut.CommonUtil
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import java.io.IOException
|
||||
import java.util.Collections;
|
||||
|
||||
class NewApp : Application() {
|
||||
companion object {
|
||||
lateinit var app: NewApp
|
||||
lateinit var typeface: Typeface
|
||||
var usuals: List<Usual>? = null
|
||||
}
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
app = this
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
initializeDatabase()
|
||||
}
|
||||
}
|
||||
private fun initializeDatabase() {
|
||||
val database = AppDataBase.getDatabase(this)
|
||||
val infoDao = database.infoDao()
|
||||
|
||||
try {
|
||||
typeface = Typeface.createFromAsset(assets, "lato_regular.ttf")
|
||||
val open = assets.open("prank.json")
|
||||
val string = CommonUtil.getString(open)
|
||||
|
||||
if (string.isNotEmpty()) {
|
||||
usuals = CommonUtil.getUsual(string)
|
||||
Collections.shuffle(usuals)
|
||||
|
||||
usuals?.forEach { category ->
|
||||
Log.d("Database", "处理分类: ${category.name}")
|
||||
// 使用Room的suspend函数或确保在IO线程
|
||||
infoDao.insertAll(category.infolist)
|
||||
}
|
||||
Log.d("Database", "数据库初始化完成")
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
Log.e("Database", "初始化失败", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,23 @@
|
||||
package com.design.mischiefgo.entity
|
||||
|
||||
import android.content.Context
|
||||
import androidx.room.Database
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
@Database(entities = [Duplicate::class], version = 1, exportSchema = false)
|
||||
abstract class AppDataBase:RoomDatabase() {
|
||||
abstract fun infoDao():DuplicateDao
|
||||
companion object{
|
||||
@Volatile
|
||||
private var INSTANCE:AppDataBase?=null
|
||||
|
||||
fun getDatabase(context:Context):AppDataBase{
|
||||
return INSTANCE?: synchronized(this){
|
||||
INSTANCE?:createDatabase(context).also { INSTANCE=it }
|
||||
}
|
||||
}
|
||||
private fun createDatabase(context: Context):AppDataBase{
|
||||
return Room.databaseBuilder(context.applicationContext,AppDataBase::class.java,"sound_database").fallbackToDestructiveMigration().build()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
package com.design.mischiefgo.entity
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Delete
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
|
||||
@Dao
|
||||
interface DuplicateDao {
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
||||
suspend fun insert(duplicate: Duplicate): Long
|
||||
@Delete
|
||||
suspend fun delete(duplicate: Duplicate): Int
|
||||
@Query("SELECT * FROM duplicate")
|
||||
suspend fun selectAll(): List<Duplicate>
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
||||
fun insertAll(infos: List<Duplicate>): List<Long>
|
||||
|
||||
//使用索引优化查询
|
||||
@Query("SELECT * FROM duplicate WHERE isLike = 1 ORDER BY id ASC")
|
||||
fun getAllLike(): List<Duplicate>
|
||||
|
||||
@Query("SELECT * FROM duplicate WHERE isCustomization = 1 ORDER BY id ASC")
|
||||
fun getAllCustomization(): List<Duplicate>
|
||||
|
||||
// 高效的随机查询(使用SQLite的随机函数)
|
||||
@Query("""
|
||||
SELECT * FROM duplicate
|
||||
WHERE isCustomization = 0
|
||||
ORDER BY RANDOM()
|
||||
LIMIT 11
|
||||
""")
|
||||
suspend fun getMoreEfficient(): List<Duplicate>
|
||||
|
||||
// 使用EXISTS进行存在性检查(更高效)
|
||||
@Query("SELECT EXISTS(SELECT 1 FROM duplicate WHERE name = :name AND isLike = 1)")
|
||||
suspend fun checkLikeExists(name: String): Boolean
|
||||
|
||||
@Query("SELECT EXISTS(SELECT 1 FROM duplicate WHERE name = :name)")
|
||||
suspend fun checkNameExists(name: String): Boolean
|
||||
|
||||
|
||||
@Query("UPDATE duplicate SET isLike = :isLike WHERE name = :name")
|
||||
suspend fun updateLikeStatus(name: String, isLike: Boolean): Int
|
||||
|
||||
|
||||
@Query("UPDATE duplicate SET isLike = 0 WHERE name = :name")
|
||||
suspend fun removeLike(name: String)
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package com.design.mischiefgo.entity
|
||||
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
class DuplicateRepository(private val infoDao: DuplicateDao){
|
||||
// 获取所有点赞项
|
||||
fun getAllLike():List<Duplicate> = infoDao.getAllLike()
|
||||
suspend fun getAll(): List<Duplicate> = infoDao.selectAll()
|
||||
|
||||
// 获取所有自定义项
|
||||
fun getAllCustomization(): List<Duplicate> = infoDao.getAllCustomization()
|
||||
|
||||
// 获取高效随机数据
|
||||
suspend fun getMoreEfficient(): List<Duplicate> = withContext(Dispatchers.IO) {
|
||||
infoDao.getMoreEfficient()
|
||||
}
|
||||
|
||||
// 检查点赞存在性
|
||||
suspend fun checkLikeExists(name: String): Boolean = withContext(Dispatchers.IO) {
|
||||
infoDao.checkLikeExists(name)
|
||||
}
|
||||
|
||||
// 检查名称存在性
|
||||
suspend fun checkNameExists(name: String): Boolean = withContext(Dispatchers.IO) {
|
||||
infoDao.checkNameExists(name)
|
||||
}
|
||||
|
||||
// 添加点赞
|
||||
suspend fun updateLikeStatus(name: String, isLike: Boolean) = withContext(Dispatchers.IO) {
|
||||
infoDao.updateLikeStatus(name, isLike)
|
||||
}
|
||||
// 移除点赞
|
||||
suspend fun removeLike(name: String) = withContext(Dispatchers.IO) {
|
||||
infoDao.removeLike(name)
|
||||
}
|
||||
|
||||
// 插入单个项目
|
||||
suspend fun insert(duplicate: Duplicate): Long = withContext(Dispatchers.IO) {
|
||||
infoDao.insert(duplicate)
|
||||
}
|
||||
|
||||
// 删除项目
|
||||
suspend fun delete(duplicate: Duplicate): Int = withContext(Dispatchers.IO) {
|
||||
infoDao.delete(duplicate)
|
||||
}
|
||||
}
|
||||
185
app/src/main/java/com/design/mischiefgo/entity/MainViewModel.kt
Normal file
@ -0,0 +1,185 @@
|
||||
package com.design.mischiefgo.entity
|
||||
|
||||
import android.app.Application
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class MainViewModel(application: Application) : AndroidViewModel(application){
|
||||
private val repository: DuplicateRepository by lazy {
|
||||
val dao = AppDataBase.getDatabase(application).infoDao()
|
||||
DuplicateRepository(dao)
|
||||
}
|
||||
// 使用LiveData暴露状态
|
||||
private val _likeItems = MutableLiveData<List<Duplicate>>()
|
||||
var likeItems: LiveData<List<Duplicate>> = _likeItems
|
||||
|
||||
private val _customItems = MutableLiveData<List<Duplicate>>()
|
||||
val customItems: LiveData<List<Duplicate>> = _customItems
|
||||
|
||||
private val _randomItems = MutableLiveData<List<Duplicate>>()
|
||||
val randomItems: LiveData<List<Duplicate>> = _randomItems
|
||||
|
||||
private val _nonCustomCount = MutableLiveData<Int>()
|
||||
val nonCustomCount: LiveData<Int> = _nonCustomCount
|
||||
|
||||
// 加载状态
|
||||
private val _isLoading = MutableLiveData<Boolean>()
|
||||
val isLoading: LiveData<Boolean> = _isLoading
|
||||
|
||||
// 错误处理
|
||||
private val _errorMessage = MutableLiveData<String>()
|
||||
val errorMessage: LiveData<String> = _errorMessage
|
||||
|
||||
init {
|
||||
loadInitialData()
|
||||
}
|
||||
|
||||
// 初始化加载数据
|
||||
private fun loadInitialData() {
|
||||
loadLikeItems()
|
||||
loadCustomItems()
|
||||
// loadRandomItems()
|
||||
}
|
||||
fun debugDatabase() {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
val duplicate = repository.getAll()
|
||||
Log.d("DB_DEBUG", "总记录数: ${duplicate.size}")
|
||||
duplicate.take(5).forEach { infoitem ->
|
||||
Log.d("DB_DEBUG", "Paper[${infoitem.id}]: " +
|
||||
"cat=${infoitem.name}, " +
|
||||
"imId=${infoitem.audioUrl}, ")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e("DB_DEBUG", "查询失败", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 加载随机项目
|
||||
fun loadRandomItems() {
|
||||
_isLoading.value = true
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
val items = repository.getMoreEfficient()
|
||||
_randomItems.postValue(items)
|
||||
} catch (e: Exception) {
|
||||
_errorMessage.postValue("Failed to load random items: ${e.message}")
|
||||
} finally {
|
||||
_isLoading.postValue(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 显式加载点赞项(可用于手动刷新)
|
||||
fun loadLikeItems() {
|
||||
_isLoading.postValue(true)
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
val likes = repository.getAllLike()
|
||||
_likeItems.postValue(likes)
|
||||
Log.d("DB_DEBUG", "点赞记录数: ${likes.size}")
|
||||
} catch (e: Exception) {
|
||||
_errorMessage.postValue("Failed to load like items: ${e.message}")
|
||||
} finally {
|
||||
_isLoading.postValue(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 显式加载上传项(可用于手动刷新)
|
||||
fun loadCustomItems() {
|
||||
_isLoading.postValue(true)
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
val customs = repository.getAllCustomization()
|
||||
_customItems.postValue(customs)
|
||||
} catch (e: Exception) {
|
||||
_errorMessage.postValue("Failed to load customs items: ${e.message}")
|
||||
} finally {
|
||||
_isLoading.postValue(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 更新点赞状态
|
||||
fun updateLikeStatus(name: String, isLike: Boolean) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
repository.updateLikeStatus(name, isLike)
|
||||
// 根据需求刷新相应的列表
|
||||
if (isLike) {
|
||||
loadLikeItems() // 如果是点赞,刷新点赞列表
|
||||
} else {
|
||||
loadLikeItems() // 如果是取消点赞,也刷新点赞列表
|
||||
// 或者如果当前在某个特定页面,也可以刷新该页面的列表
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
_errorMessage.postValue("Failed to update like status: ${e.message}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 检查是否点赞
|
||||
fun checkLikeStatus(name: String, callback: (Boolean) -> Unit) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
val isLiked = repository.checkLikeExists(name)
|
||||
callback(isLiked)
|
||||
} catch (e: Exception) {
|
||||
_errorMessage.postValue("Failed to check like status: ${e.message}")
|
||||
callback(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
// 检查是否已存在
|
||||
fun checkSaveStatus(name: String, callback: (Boolean) -> Unit) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
Log.d("DB_DEBUG", "检查是否已存在: $name")
|
||||
val isSaved = repository.checkNameExists(name)
|
||||
Log.d("DB_DEBUG", "是否已存在: $isSaved")
|
||||
callback(isSaved)
|
||||
} catch (e: Exception) {
|
||||
_errorMessage.postValue("Failed to check save status: ${e.message}")
|
||||
callback(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 插入自定义
|
||||
fun insertItem(duplicate: Duplicate) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
val itemToInsert = duplicate.copy(isCustomization = true)
|
||||
repository.insert(itemToInsert)
|
||||
loadCustomItems()
|
||||
// 依赖数据库观察者自动更新UI
|
||||
} catch (e: Exception) {
|
||||
_errorMessage.postValue("Failed to insert item: ${e.message}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 删除自定义
|
||||
fun deleteItem(duplicate: Duplicate) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
try {
|
||||
repository.delete(duplicate)
|
||||
loadCustomItems()
|
||||
loadLikeItems()
|
||||
// 依赖数据库观察者自动更新UI
|
||||
} catch (e: Exception) {
|
||||
_errorMessage.postValue("Failed to delete item: ${e.message}")
|
||||
}
|
||||
}
|
||||
}
|
||||
// 清除错误消息
|
||||
fun clearErrorMessage() {
|
||||
_errorMessage.value = ""
|
||||
}
|
||||
}
|
||||
28
app/src/main/java/com/design/mischiefgo/entity/setdata.kt
Normal file
@ -0,0 +1,28 @@
|
||||
package com.design.mischiefgo.entity
|
||||
|
||||
import android.os.Parcelable
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.Index
|
||||
import androidx.room.PrimaryKey
|
||||
import kotlinx.parcelize.Parcelize
|
||||
@Parcelize
|
||||
@Entity(tableName = "usual")
|
||||
data class Usual(
|
||||
@PrimaryKey(autoGenerate = true) var id: Int = 0,
|
||||
@ColumnInfo(name = "name") var name:String="",
|
||||
@ColumnInfo(name = "convert") var convert:String="",
|
||||
@ColumnInfo(name="infolist") var infolist:List<Duplicate> = arrayListOf()
|
||||
): Parcelable
|
||||
|
||||
@Parcelize
|
||||
@Entity(tableName = "duplicate",indices = [Index(value = ["name"], unique = true)])
|
||||
data class Duplicate(
|
||||
@PrimaryKey(autoGenerate = true) var id: Int = 0,
|
||||
@ColumnInfo(name = "name") var name: String = "",
|
||||
@ColumnInfo(name = "convert") var convert: String = "",
|
||||
@ColumnInfo(name = "audioUrl") var audioUrl: String = "",
|
||||
@ColumnInfo(name = "isLike") var isLike: Boolean = false,
|
||||
@ColumnInfo(name = "isCustomization") var isCustomization: Boolean = false,
|
||||
@ColumnInfo(name = "colorIndex") var colorIndex: Int = 0
|
||||
):Parcelable
|
||||
50
app/src/main/java/com/design/mischiefgo/ui/AdShowActivity.kt
Normal file
@ -0,0 +1,50 @@
|
||||
package com.design.mischiefgo.ui
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.CountDownTimer
|
||||
import android.os.Handler
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.design.mischiefgo.databinding.ActivityAdShowBinding
|
||||
import com.design.mischiefgo.ut.EvenTopUtils
|
||||
|
||||
class AdShowActivity : AppCompatActivity() {
|
||||
private lateinit var binding : ActivityAdShowBinding
|
||||
private var handler: Handler = Handler()
|
||||
private var countDownTimer: CountDownTimer? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
EvenTopUtils.setStatusBar(this.window)
|
||||
EvenTopUtils.setLightStatusBar(this.window, true)
|
||||
binding = ActivityAdShowBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
handler.postDelayed({
|
||||
val intent= Intent(
|
||||
this@AdShowActivity,
|
||||
NavigationActivity::class.java
|
||||
)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}, 4000)
|
||||
countDownTimer = object : CountDownTimer(4000, 100) {
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
val progress = ((4000 - millisUntilFinished) / 4000f * 100).toInt()
|
||||
binding.loadingPb.progress = progress
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
binding.loadingPb.progress = 100
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
handler.removeCallbacksAndMessages(null)
|
||||
|
||||
if (countDownTimer != null) {
|
||||
countDownTimer!!.cancel()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,84 @@
|
||||
package com.design.mischiefgo.ui
|
||||
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.SystemClock
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.design.mischiefgo.R
|
||||
import com.design.mischiefgo.databinding.ActivityListenSoundBinding
|
||||
import com.design.mischiefgo.ut.StartPlayUtil
|
||||
import com.design.mischiefgo.ut.EvenTopUtils
|
||||
|
||||
class ListenSoundActivity : AppCompatActivity() {
|
||||
private var binding: ActivityListenSoundBinding? = null
|
||||
private var startTime: Long = 0
|
||||
private var elapsedTime: Long = 0
|
||||
private val handler = Handler()
|
||||
private var runnable: Runnable? = null
|
||||
private var isCreate = false
|
||||
|
||||
private var record: StartPlayUtil? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
EvenTopUtils.setStatusBar(this.window)
|
||||
EvenTopUtils.setLightStatusBar(this.window, true)
|
||||
binding = ActivityListenSoundBinding.inflate(layoutInflater)
|
||||
setContentView(binding!!.root)
|
||||
record = StartPlayUtil(this)
|
||||
binding!!.audioTime.setText(R.string.time_init)
|
||||
|
||||
initClick()
|
||||
}
|
||||
|
||||
private fun initClick() {
|
||||
binding!!.back.setOnClickListener { finish() }
|
||||
binding!!.imMic.setOnClickListener {
|
||||
binding!!.imMic.isSelected = !binding!!.imMic.isSelected
|
||||
binding!!.audioTint.text=getString(R.string.click_to_finish)
|
||||
initDuplicate()
|
||||
}
|
||||
}
|
||||
|
||||
private fun initDuplicate() {
|
||||
if (!isCreate) {
|
||||
record?.startRecording()
|
||||
isCreate = true
|
||||
runnable = object : Runnable {
|
||||
override fun run() {
|
||||
val currentTime = SystemClock.elapsedRealtime()
|
||||
elapsedTime = currentTime - startTime
|
||||
val milliseconds = (elapsedTime % 1000).toInt() / 10
|
||||
val seconds = (elapsedTime / 1000).toInt() % 60
|
||||
val minutes = (elapsedTime / (1000 * 60)).toInt() % 60
|
||||
binding!!.audioTime.text =
|
||||
String.format("%02d : %02d : %02d", minutes, seconds, milliseconds)
|
||||
handler.postDelayed(this, 10)
|
||||
}
|
||||
}
|
||||
startTime = SystemClock.elapsedRealtime()
|
||||
handler.post(runnable as Runnable)
|
||||
} else {
|
||||
record?.stopRecording()
|
||||
|
||||
handler.removeCallbacks(runnable!!)
|
||||
val intent = Intent(
|
||||
this@ListenSoundActivity,
|
||||
SaveToLocalActivity::class.java
|
||||
)
|
||||
intent.putExtra(SaveToLocalActivity.KEY_Time, elapsedTime)
|
||||
intent.putExtra(SaveToLocalActivity.KEY_Path, record?.getTempFileName())
|
||||
intent.putExtra(SaveToLocalActivity.KEY_import, 1)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
if(runnable!=null){
|
||||
handler.removeCallbacks(runnable!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
111
app/src/main/java/com/design/mischiefgo/ui/NavigationActivity.kt
Normal file
@ -0,0 +1,111 @@
|
||||
package com.design.mischiefgo.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.design.mischiefgo.databinding.ActivityNavigationBinding
|
||||
import com.design.mischiefgo.ut.EvenTopUtils
|
||||
|
||||
class NavigationActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivityNavigationBinding
|
||||
// private val mainViewModel:MainViewModel by viewModels()
|
||||
private var isFragmentTransitionRunning=false
|
||||
private var lastClickTime=0L
|
||||
private val CLICK_THROTTLE=300L
|
||||
|
||||
private val showFragment by lazy{ YellowCenterFragment() }
|
||||
private val collFragment by lazy{ YellowEndFragment() }
|
||||
private val recordFragment by lazy{ YellowStartFragment() }
|
||||
private var currentFragment: Fragment?=null
|
||||
|
||||
private sealed class Tab {
|
||||
data object Show:Tab()
|
||||
data object Collect:Tab()
|
||||
data object Record:Tab()
|
||||
|
||||
}
|
||||
private var currentTab:Tab=Tab.Record
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
EvenTopUtils.setStatusBar(this.window)
|
||||
EvenTopUtils.setLightStatusBar(this.window, true)
|
||||
binding= ActivityNavigationBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
initViews()
|
||||
}
|
||||
|
||||
private fun initViews() {
|
||||
switchFragment(Tab.Show)
|
||||
binding.llCategory.setOnClickListener { handleTabClick(Tab.Show) }
|
||||
binding.llRecord.setOnClickListener { handleTabClick(Tab.Record) }
|
||||
binding.llCollect.setOnClickListener { handleTabClick(Tab.Collect) }
|
||||
}
|
||||
|
||||
private fun switchFragment(tab: Tab) {
|
||||
if (isFragmentTransitionRunning || currentTab == tab) return
|
||||
val targetFragment = when (tab) {
|
||||
is Tab.Show -> showFragment
|
||||
is Tab.Collect -> collFragment
|
||||
is Tab.Record -> recordFragment
|
||||
}
|
||||
Log.d("MainViewActivity", "switchFragment: $tab")
|
||||
if (binding.fragmentIn.id == View.NO_ID) return
|
||||
Log.d("MainViewActivity", "switchFragment: $tab")
|
||||
updateTabUI(tab)
|
||||
performFragmentTransaction(targetFragment, tab)
|
||||
}
|
||||
private fun updateTabUI(tab: Tab) {
|
||||
// val defaultColor = getColor(R.color.white)
|
||||
// val selectColor = getColor(R.color.text_blue)
|
||||
|
||||
binding.imgCategory.isSelected = tab is Tab.Show
|
||||
binding.llCategory.isSelected = tab is Tab.Show
|
||||
binding.ltHome.visibility= if (tab is Tab.Show) View.VISIBLE else View.GONE
|
||||
binding.imgCollect.isSelected = tab is Tab.Collect
|
||||
binding.llCollect.isSelected = tab is Tab.Collect
|
||||
binding.ltFavorite.visibility= if (tab is Tab.Collect) View.VISIBLE else View.GONE
|
||||
binding.imgRecord.isSelected = tab is Tab.Record
|
||||
binding.llRecord.isSelected = tab is Tab.Record
|
||||
binding.ltRecord.visibility= if (tab is Tab.Record) View.VISIBLE else View.GONE
|
||||
}
|
||||
|
||||
private fun performFragmentTransaction(targetFragment: Fragment, tab: Tab) {
|
||||
isFragmentTransitionRunning = true
|
||||
|
||||
supportFragmentManager.beginTransaction().apply {
|
||||
setCustomAnimations(
|
||||
android.R.anim.fade_in,
|
||||
android.R.anim.fade_out
|
||||
)
|
||||
|
||||
currentFragment?.takeIf { it.isAdded }?.let {
|
||||
hide(it)
|
||||
}
|
||||
|
||||
if (targetFragment.isAdded) {
|
||||
show(targetFragment)
|
||||
} else {
|
||||
add(binding.fragmentIn.id, targetFragment, targetFragment::class.java.simpleName)
|
||||
}
|
||||
|
||||
setReorderingAllowed(true)
|
||||
commit()
|
||||
}
|
||||
|
||||
currentFragment = targetFragment
|
||||
currentTab = tab
|
||||
isFragmentTransitionRunning = false
|
||||
}
|
||||
|
||||
private fun handleTabClick(tab: Tab) {
|
||||
val currentTime = System.currentTimeMillis()
|
||||
if (currentTime - lastClickTime > CLICK_THROTTLE) {
|
||||
switchFragment(tab)
|
||||
lastClickTime = currentTime
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,247 @@
|
||||
package com.design.mischiefgo.ui
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.media.AudioAttributes
|
||||
import android.media.MediaPlayer
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.SystemClock
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.design.mischiefgo.R
|
||||
import com.design.mischiefgo.entity.Duplicate
|
||||
import com.design.mischiefgo.entity.MainViewModel
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
import androidx.core.net.toUri
|
||||
import com.design.mischiefgo.databinding.ActivitySaveToLocalBinding
|
||||
import com.design.mischiefgo.ut.EvenTopUtils
|
||||
|
||||
class SaveToLocalActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivitySaveToLocalBinding
|
||||
private var path: String? = null
|
||||
|
||||
private var mediaPlayer: MediaPlayer? = null
|
||||
private val handler = Handler()
|
||||
private var timeUpdater: Runnable? = null
|
||||
private var startTime: Long = 0
|
||||
private var elapsedTime: Long = 0
|
||||
private lateinit var viewModel: MainViewModel
|
||||
private var audioDuration: Long = 0
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
EvenTopUtils.setStatusBar(this.window)
|
||||
EvenTopUtils.setLightStatusBar(this.window, true)
|
||||
binding = ActivitySaveToLocalBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
viewModel = ViewModelProvider(this)[MainViewModel::class.java]
|
||||
binding.audioTime.setText(R.string.time_init)
|
||||
initData()
|
||||
initEvent()
|
||||
|
||||
}
|
||||
|
||||
@Throws(IOException::class)
|
||||
private fun togglePrank() {
|
||||
if (binding.btnPlay.isSelected) {
|
||||
initMediaPlayer()
|
||||
} else {
|
||||
stopPlay()
|
||||
}
|
||||
}
|
||||
|
||||
private fun stopPlay() {
|
||||
if (timeUpdater != null) {
|
||||
handler.removeCallbacks(timeUpdater!!)
|
||||
}
|
||||
if (mediaPlayer != null) {
|
||||
mediaPlayer!!.release()
|
||||
mediaPlayer = null
|
||||
}
|
||||
}
|
||||
|
||||
private fun initMediaPlayer() {
|
||||
if (mediaPlayer == null) {
|
||||
mediaPlayer = MediaPlayer()
|
||||
mediaPlayer!!.setAudioAttributes(
|
||||
AudioAttributes.Builder()
|
||||
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
|
||||
.setUsage(AudioAttributes.USAGE_MEDIA)
|
||||
.build()
|
||||
)
|
||||
try {
|
||||
mediaPlayer!!.setDataSource(path)
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
mediaPlayer!!.setOnPreparedListener { mp: MediaPlayer? ->
|
||||
mediaPlayer!!.start()
|
||||
beginTimer()
|
||||
}
|
||||
mediaPlayer!!.setOnCompletionListener { mp: MediaPlayer? ->
|
||||
binding.btnPlay.isSelected = false
|
||||
handler.removeCallbacks(timeUpdater!!)
|
||||
}
|
||||
mediaPlayer!!.prepareAsync()
|
||||
} else {
|
||||
mediaPlayer!!.start()
|
||||
beginTimer()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun beginTimer() {
|
||||
if (timeUpdater == null) {
|
||||
timeUpdater = object : Runnable {
|
||||
@SuppressLint("DefaultLocale")
|
||||
override fun run() {
|
||||
if (mediaPlayer != null && mediaPlayer!!.isPlaying) {
|
||||
val currentTime = SystemClock.elapsedRealtime()
|
||||
elapsedTime = currentTime - startTime
|
||||
val milliseconds = (elapsedTime % 1000).toInt() / 10
|
||||
val seconds = (elapsedTime / 1000).toInt() % 60
|
||||
val minutes = (elapsedTime / (1000 * 60)).toInt() % 60
|
||||
binding.audioTime.text =
|
||||
String.format(
|
||||
"%02d : %02d : %02d",
|
||||
minutes,
|
||||
seconds,
|
||||
milliseconds
|
||||
)
|
||||
handler.postDelayed(this, 10)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
startTime = SystemClock.elapsedRealtime()
|
||||
handler.post(timeUpdater!!)
|
||||
}
|
||||
|
||||
private fun initEvent() {
|
||||
binding.back.setOnClickListener { finish() }
|
||||
binding.audioTimeLayout.setOnClickListener {
|
||||
binding.btnPlay.isSelected = !binding.btnPlay.isSelected
|
||||
try {
|
||||
togglePrank()
|
||||
} catch (e: IOException) {
|
||||
Log.e("SaveActivity", "Error toggling prank", e)
|
||||
}
|
||||
}
|
||||
|
||||
binding.save.setOnClickListener {
|
||||
val name = binding.saveEdit.text.toString().trim()
|
||||
viewModel.checkSaveStatus(name, callback = { isSave ->
|
||||
runOnUiThread {
|
||||
// 1. 先检查Activity是否即将销毁,避免在已销毁的Activity上操作
|
||||
if (isFinishing || isDestroyed) {
|
||||
return@runOnUiThread
|
||||
}
|
||||
if (TextUtils.isEmpty(name)) {
|
||||
Toast.makeText(
|
||||
this@SaveToLocalActivity,
|
||||
getString(R.string.save_tip), // 空名称提示
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
return@runOnUiThread
|
||||
}
|
||||
|
||||
if (isSave) {
|
||||
binding.saveEdit.setText("")
|
||||
Toast.makeText(
|
||||
this@SaveToLocalActivity, // 使用显式的 this@ActivityName
|
||||
getString(R.string.name_hint), // 名称已存在提示
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
} else {
|
||||
saveData(name)
|
||||
Toast.makeText(
|
||||
this@SaveToLocalActivity,
|
||||
getString(R.string.save_tips), // 保存成功提示
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
finish()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun saveData(name: String) {
|
||||
val cacheDir = cacheDir
|
||||
val sourceFile = File(path)
|
||||
val destinationFile = File(cacheDir, "$name.mp3")
|
||||
|
||||
if (sourceFile.renameTo(destinationFile)) {
|
||||
val mydata = Duplicate()
|
||||
mydata.isLike = false
|
||||
mydata.name = name
|
||||
mydata.isCustomization = true
|
||||
mydata.audioUrl = destinationFile.absolutePath
|
||||
viewModel.insertItem(mydata)
|
||||
} else {
|
||||
Log.e("SaveActivity", "Failed to rename file")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun readFileFromUri(context: Context, uri: Uri): String? {
|
||||
val contentResolver = context.contentResolver
|
||||
try {
|
||||
contentResolver.openInputStream(uri).use { inputStream ->
|
||||
FileOutputStream(
|
||||
File(
|
||||
cacheDir, "temp_audio_file.mp3"
|
||||
)
|
||||
).use { outputStream ->
|
||||
if (inputStream == null) {
|
||||
Log.e("SaveActivity", "Input stream is null")
|
||||
return null
|
||||
}
|
||||
val buffer = ByteArray(1024)
|
||||
var bytesRead: Int
|
||||
while ((inputStream.read(buffer).also { bytesRead = it }) != -1) {
|
||||
outputStream.write(buffer, 0, bytesRead)
|
||||
}
|
||||
return File(cacheDir, "temp_audio_file.mp3").absolutePath
|
||||
}
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
Log.e("SaveActivity", "Error reading file from URI", e)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
private fun initData() {
|
||||
val intent = intent
|
||||
audioDuration = intent.getLongExtra(KEY_Time, 0)
|
||||
val importFlag = intent.getIntExtra(KEY_import, 0)
|
||||
|
||||
if (importFlag == 1) {
|
||||
path = intent.getStringExtra(KEY_Path)
|
||||
Log.e("zzj", "save path is$path")
|
||||
} else {
|
||||
val uriPath = intent.getStringExtra(KEY_Path)
|
||||
val uri = uriPath!!.toUri()
|
||||
path = readFileFromUri(this, uri)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
stopPlay()
|
||||
}
|
||||
|
||||
companion object {
|
||||
var KEY_Time: String = "KEY_time"
|
||||
var KEY_Path: String = "KEY_path"
|
||||
var KEY_import: String = "flag"
|
||||
}
|
||||
}
|
||||
43
app/src/main/java/com/design/mischiefgo/ui/TypeInActivity.kt
Normal file
@ -0,0 +1,43 @@
|
||||
package com.design.mischiefgo.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.design.mischiefgo.ut.RandomAdapter
|
||||
import com.design.mischiefgo.entity.Usual
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.design.mischiefgo.databinding.ActivityTypeInBinding
|
||||
import com.design.mischiefgo.ut.EvenTopUtils
|
||||
|
||||
class TypeInActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivityTypeInBinding
|
||||
private lateinit var data: Usual
|
||||
|
||||
companion object {
|
||||
const val KEY_LIST_DATA = "list_data"
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = ActivityTypeInBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
EvenTopUtils.setStatusBar(this.window)
|
||||
EvenTopUtils.setLightStatusBar(this.window, true)
|
||||
data = intent.getParcelableExtra(KEY_LIST_DATA)!!
|
||||
initView()
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
Glide.with(this)
|
||||
.load(data.convert)
|
||||
.apply(RequestOptions.circleCropTransform())
|
||||
.into(binding.image)
|
||||
binding.title.text = data.name
|
||||
val adapter = RandomAdapter()
|
||||
binding.recyclerView.adapter = adapter
|
||||
binding.recyclerView.layoutManager = GridLayoutManager(this, 3)
|
||||
adapter.setList(data.infolist)
|
||||
binding.back.setOnClickListener { finish() }
|
||||
}
|
||||
}
|
||||
251
app/src/main/java/com/design/mischiefgo/ui/UseSoundActivity.kt
Normal file
@ -0,0 +1,251 @@
|
||||
package com.design.mischiefgo.ui
|
||||
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.media.AudioManager
|
||||
import android.media.MediaPlayer
|
||||
import android.os.Bundle
|
||||
import android.os.CountDownTimer
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.design.mischiefgo.ut.CommonUtil
|
||||
import com.design.mischiefgo.R
|
||||
import com.design.mischiefgo.ut.RandomAdapter
|
||||
import com.design.mischiefgo.entity.Duplicate
|
||||
import com.design.mischiefgo.entity.MainViewModel
|
||||
import com.design.mischiefgo.ut.OnMoreClickListener
|
||||
import com.design.mischiefgo.ut.SoundListener
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.resource.bitmap.CircleCrop
|
||||
import com.design.mischiefgo.databinding.ActivityUseSoundBinding
|
||||
import com.design.mischiefgo.ut.ChooseTimeFragment
|
||||
import com.design.mischiefgo.ut.EvenTopUtils
|
||||
import java.io.IOException
|
||||
|
||||
class UseSoundActivity : AppCompatActivity(), OnMoreClickListener,
|
||||
SoundListener {
|
||||
private lateinit var binding: ActivityUseSoundBinding
|
||||
private lateinit var data: Duplicate
|
||||
private lateinit var viewModel: MainViewModel
|
||||
private var mediaPlayer: MediaPlayer? = null
|
||||
private var countDownTimer: CountDownTimer? = null
|
||||
private lateinit var popView: ChooseTimeFragment
|
||||
private lateinit var volumeReceiver: BroadcastReceiver
|
||||
|
||||
companion object {
|
||||
const val KEY_LIST_DATA = "list_data"
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
EvenTopUtils.setStatusBar(this.window)
|
||||
EvenTopUtils.setLightStatusBar(this.window, true)
|
||||
binding = ActivityUseSoundBinding.inflate(layoutInflater)
|
||||
data = intent.getParcelableExtra(KEY_LIST_DATA)!!
|
||||
setContentView(binding.root)
|
||||
viewModel = ViewModelProvider(this)[MainViewModel::class.java]
|
||||
popView = ChooseTimeFragment(this, this)
|
||||
initView()
|
||||
initAudio()
|
||||
initClick()
|
||||
setVolumeReceiver()
|
||||
|
||||
}
|
||||
|
||||
private fun setVolumeReceiver() {
|
||||
volumeReceiver = object : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
if (intent.action == "android.media.VOLUME_CHANGED_ACTION") {
|
||||
val audioManager =
|
||||
context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
||||
val currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC)
|
||||
if (binding.seekbar.progress != currentVolume) {
|
||||
binding.seekbar.progress = currentVolume
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val filter = IntentFilter("android.media.VOLUME_CHANGED_ACTION")
|
||||
registerReceiver(volumeReceiver, filter)
|
||||
}
|
||||
|
||||
private fun initClick() {
|
||||
//播放按钮
|
||||
binding.layoutPlay.setOnClickListener {
|
||||
val playing = binding.playing.isVisible
|
||||
if (playing) {
|
||||
if (mediaPlayer?.isPlaying == true) {
|
||||
mediaPlayer?.pause()
|
||||
showLoading(1)
|
||||
}
|
||||
} else {
|
||||
if (!mediaPlayer?.isPlaying!!) {
|
||||
mediaPlayer?.start()
|
||||
showLoading(2)
|
||||
}
|
||||
}
|
||||
}
|
||||
//弹出倒计时
|
||||
binding.imTimer.setOnClickListener {
|
||||
popView.showTop(binding.imTimer)
|
||||
}
|
||||
//like
|
||||
binding.imLike.setOnClickListener {
|
||||
val isSelected = binding.imLike.isSelected
|
||||
if(isSelected){
|
||||
viewModel.updateLikeStatus(data.name,false)
|
||||
}else{
|
||||
viewModel.updateLikeStatus(data.name,true)
|
||||
}
|
||||
binding.imLike.isSelected = !isSelected
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private fun initAudio() {
|
||||
showLoading(0)
|
||||
mediaPlayer = MediaPlayer()
|
||||
try {
|
||||
mediaPlayer?.reset()
|
||||
mediaPlayer?.setDataSource(data.audioUrl)
|
||||
mediaPlayer?.prepareAsync()
|
||||
mediaPlayer?.setOnPreparedListener { showLoading(1) }
|
||||
mediaPlayer?.setOnCompletionListener { showLoading(1) }
|
||||
} catch (ioException: IOException) {
|
||||
showLoading(0)
|
||||
Toast.makeText(this, "----------prepare fail", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
//设置音量
|
||||
CommonUtil.setVolume(this, binding.seekbar)
|
||||
binding.title.text = data.name
|
||||
binding.back.setOnClickListener { finish() }
|
||||
binding.imLoop.setOnClickListener {
|
||||
binding.imLoop.setSelected(!binding.imLoop.isSelected)
|
||||
mediaPlayer!!.isLooping = binding.imLoop.isSelected
|
||||
}
|
||||
val convert = data.convert
|
||||
if (convert.isEmpty()) {
|
||||
Glide.with(this).load(R.drawable.music_default_copy).transform(CircleCrop())
|
||||
.into(binding.imgRecord)
|
||||
} else {
|
||||
Glide.with(this).load(data.convert).error(R.drawable.music_default_copy)
|
||||
.placeholder(R.drawable.music_default_copy).transform(CircleCrop())
|
||||
.into(binding.imgRecord)
|
||||
}
|
||||
|
||||
val adapter = RandomAdapter()
|
||||
adapter.setListener(this)
|
||||
binding.recyclerView.adapter = adapter
|
||||
binding.recyclerView.layoutManager =
|
||||
LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false)
|
||||
//more
|
||||
viewModel.randomItems.observe(this@UseSoundActivity) { randomItems ->
|
||||
// 更新UI
|
||||
Log.d("TAG", "initView: $randomItems")
|
||||
adapter.setList(randomItems, 1)
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
viewModel.loadRandomItems()
|
||||
|
||||
// like
|
||||
viewModel.checkLikeStatus(data.name, callback = { isLike ->
|
||||
run {
|
||||
binding.imLike.isSelected = isLike
|
||||
}
|
||||
})
|
||||
//
|
||||
}
|
||||
|
||||
private fun showLoading(type: Int) {
|
||||
when (type) {
|
||||
0 -> {//加载中
|
||||
binding.playLoading.visibility = View.VISIBLE
|
||||
binding.toPlay.visibility = View.GONE
|
||||
binding.playing.visibility = View.GONE
|
||||
}
|
||||
|
||||
1 -> {//可播放
|
||||
binding.playLoading.visibility = View.GONE
|
||||
binding.toPlay.visibility = View.VISIBLE
|
||||
binding.playing.visibility = View.GONE
|
||||
}
|
||||
|
||||
2 -> {//播放中
|
||||
binding.playLoading.visibility = View.GONE
|
||||
binding.toPlay.visibility = View.GONE
|
||||
binding.playing.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun stopCountDown() {
|
||||
countDownTimer?.cancel()
|
||||
|
||||
}
|
||||
|
||||
private fun startCountDown(time: Long) {
|
||||
stopCountDown()
|
||||
countDownTimer = object : CountDownTimer(time, 1000) {
|
||||
override fun onTick(millisUntilFinished: Long) {
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
popView.setOffSelected()
|
||||
binding.imTimer.isSelected = false
|
||||
if (!mediaPlayer?.isPlaying!!) {
|
||||
showLoading(2)
|
||||
mediaPlayer?.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
countDownTimer?.start()
|
||||
}
|
||||
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
if (mediaPlayer?.isPlaying == true) {
|
||||
mediaPlayer?.stop()
|
||||
}
|
||||
mediaPlayer?.release()
|
||||
stopCountDown()
|
||||
if (::popView.isInitialized) {
|
||||
popView.hide()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMoreClick(duplicate: Duplicate) {
|
||||
val intent = Intent(this, UseSoundActivity::class.java)
|
||||
intent.putExtra(KEY_LIST_DATA, duplicate)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
|
||||
}
|
||||
|
||||
override fun onClickTimerListener(time: Long) {
|
||||
runOnUiThread {
|
||||
popView.hide()
|
||||
if (time == -1L) {
|
||||
Log.d("TAG", "onClickTimerListener: $time")
|
||||
binding.imTimer.isSelected = false
|
||||
stopCountDown()
|
||||
} else {
|
||||
binding.imTimer.isSelected = true
|
||||
startCountDown(time)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
package com.design.mischiefgo.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
import com.design.mischiefgo.databinding.FragmentYellowCenterBinding
|
||||
import com.design.mischiefgo.NewApp
|
||||
import com.design.mischiefgo.ut.YellowCenterAdapter
|
||||
import com.design.mischiefgo.entity.MainViewModel
|
||||
|
||||
|
||||
class YellowCenterFragment : Fragment() {
|
||||
private lateinit var binding: FragmentYellowCenterBinding
|
||||
private lateinit var viewModel: MainViewModel
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = FragmentYellowCenterBinding.inflate(inflater, container, false)
|
||||
viewModel = ViewModelProvider(requireActivity())[MainViewModel::class.java]
|
||||
initView()
|
||||
return binding.root
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
val adapter = YellowCenterAdapter()
|
||||
binding.recyclerView.adapter=adapter
|
||||
val flexboxLayoutManager = StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)
|
||||
|
||||
binding.recyclerView.layoutManager=flexboxLayoutManager
|
||||
|
||||
// viewModel.randomItems.observe(viewLifecycleOwner) { randomItems ->
|
||||
// // 更新UI
|
||||
// adapter.setList(randomItems)
|
||||
// }
|
||||
// viewModel.loadRandomItems()
|
||||
viewModel.debugDatabase()
|
||||
NewApp.usuals?.let { adapter.setList(it) }
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,61 @@
|
||||
package com.design.mischiefgo.ui
|
||||
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.design.mischiefgo.databinding.FragmentYellowEndBinding
|
||||
import com.design.mischiefgo.ut.StartAndEndAdapter
|
||||
import com.design.mischiefgo.entity.Duplicate
|
||||
import com.design.mischiefgo.entity.MainViewModel
|
||||
import com.design.mischiefgo.ut.OnMoreClickListener
|
||||
|
||||
class YellowEndFragment : Fragment(),OnMoreClickListener {
|
||||
private lateinit var binding: FragmentYellowEndBinding
|
||||
private lateinit var viewModel: MainViewModel
|
||||
private lateinit var adapter: StartAndEndAdapter
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
// Inflate the layout for this fragment
|
||||
binding = FragmentYellowEndBinding.inflate(inflater, container, false)
|
||||
viewModel = ViewModelProvider(requireActivity())[MainViewModel::class.java]
|
||||
initView()
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
viewModel.loadLikeItems()
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
adapter = StartAndEndAdapter()
|
||||
adapter.setListener(this)
|
||||
viewModel.likeItems.observe(viewLifecycleOwner){likeList ->
|
||||
Log.d("CollectFragment", "initView: $likeList")
|
||||
if(likeList.isEmpty()){
|
||||
binding.emptyView.visibility=View.VISIBLE
|
||||
binding.recyclerView.visibility=View.GONE
|
||||
}else{
|
||||
binding.emptyView.visibility=View.GONE
|
||||
binding.recyclerView.visibility=View.VISIBLE
|
||||
adapter.setList(likeList,0)
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
binding.recyclerView.adapter = adapter
|
||||
binding.recyclerView.layoutManager=LinearLayoutManager(requireContext(),LinearLayoutManager.VERTICAL,false)
|
||||
}
|
||||
|
||||
override fun onMoreClick(duplicate: Duplicate) {
|
||||
viewModel.updateLikeStatus(duplicate.name,false)
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,188 @@
|
||||
package com.design.mischiefgo.ui
|
||||
|
||||
import android.Manifest
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.activity.result.ActivityResultLauncher
|
||||
import androidx.activity.result.contract.ActivityResultContracts.GetContent
|
||||
import androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions
|
||||
import androidx.activity.result.contract.ActivityResultContracts.RequestPermission
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.design.mischiefgo.databinding.FragmentYellowStartBinding
|
||||
import com.design.mischiefgo.ut.CommonUtil
|
||||
import com.design.mischiefgo.ut.StartAndEndAdapter
|
||||
import com.design.mischiefgo.entity.Duplicate
|
||||
import com.design.mischiefgo.entity.MainViewModel
|
||||
import com.design.mischiefgo.ut.OnMoreClickListener
|
||||
|
||||
class YellowStartFragment : Fragment(),OnMoreClickListener{
|
||||
private lateinit var binding: FragmentYellowStartBinding
|
||||
private lateinit var viewModel: MainViewModel
|
||||
private lateinit var adapter: StartAndEndAdapter
|
||||
private var permission_read_audio: Array<String> = arrayOf(Manifest.permission.READ_MEDIA_AUDIO)
|
||||
private var permission_record_audio: String = Manifest.permission.RECORD_AUDIO
|
||||
private var permission_store: Array<String> = arrayOf(
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
)
|
||||
private lateinit var requestStorePermissionsLauncher: ActivityResultLauncher<Array<String>>
|
||||
private lateinit var requestRecordAudioLauncher: ActivityResultLauncher<String>
|
||||
private lateinit var audioPickerLauncher: ActivityResultLauncher<String>
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater, container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
// Inflate the layout for this fragment
|
||||
binding = FragmentYellowStartBinding.inflate(inflater, container, false)
|
||||
viewModel = ViewModelProvider(requireActivity())[MainViewModel::class.java]
|
||||
initView()
|
||||
return binding.root
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
viewModel.loadCustomItems()
|
||||
}
|
||||
private fun initView() {
|
||||
adapter = StartAndEndAdapter()
|
||||
adapter.setListener(this)
|
||||
viewModel.customItems.observe(viewLifecycleOwner){customList ->
|
||||
Log.d("CustomFragment", "initView: $customList")
|
||||
if(customList.isEmpty()){
|
||||
binding.emptyView.visibility=View.VISIBLE
|
||||
binding.recyclerView.visibility=View.GONE
|
||||
}else{
|
||||
binding.emptyView.visibility=View.GONE
|
||||
binding.recyclerView.visibility=View.VISIBLE
|
||||
adapter.setList(customList,1)
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
binding.recyclerView.adapter = adapter
|
||||
binding.recyclerView.layoutManager=
|
||||
LinearLayoutManager(requireContext(), LinearLayoutManager.VERTICAL,false)
|
||||
binding.recordImg.setOnClickListener {
|
||||
selectBtnClick(1)
|
||||
}
|
||||
binding.diyImg.setOnClickListener {
|
||||
selectBtnClick(0)
|
||||
}
|
||||
requestRecordAudioLauncher = registerForActivityResult<String, Boolean>(
|
||||
RequestPermission()
|
||||
) { isGranted: Boolean ->
|
||||
if (isGranted) {
|
||||
intentRecordAudio()
|
||||
} else {
|
||||
Toast.makeText(requireContext(), "Recording permission denied", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
requestStorePermissionsLauncher =
|
||||
registerForActivityResult<Array<String>, Map<String, Boolean>>(
|
||||
RequestMultiplePermissions()
|
||||
) { result ->
|
||||
var isGranted = true
|
||||
for ((_, value) in result) {
|
||||
isGranted = value
|
||||
if (!value) {
|
||||
isGranted = false
|
||||
}
|
||||
}
|
||||
if (isGranted) {
|
||||
importFromLocal()
|
||||
} else {
|
||||
Toast.makeText(requireContext(), " permits denied", Toast.LENGTH_SHORT)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
audioPickerLauncher = registerForActivityResult<String, Uri>(
|
||||
GetContent()
|
||||
) { uri -> // Handle the returned Uri
|
||||
|
||||
if (uri != null) {
|
||||
Log.d("---------", "========uri=$uri")
|
||||
val duration: Long = CommonUtil.getAudioDuration(requireContext(), uri)
|
||||
val intent = Intent(
|
||||
requireContext(),
|
||||
SaveToLocalActivity::class.java
|
||||
)
|
||||
intent.putExtra(SaveToLocalActivity.KEY_Path, uri.toString())
|
||||
intent.putExtra(SaveToLocalActivity.KEY_Time, duration)
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onMoreClick(duplicate: Duplicate) {
|
||||
viewModel.deleteItem(duplicate)
|
||||
}
|
||||
|
||||
fun selectBtnClick(type: Int) {
|
||||
if(type == 0){
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
if (ContextCompat.checkSelfPermission(
|
||||
requireContext(),
|
||||
permission_read_audio[0]
|
||||
)
|
||||
!= PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
requestStorePermissionsLauncher.launch(permission_read_audio)
|
||||
// ActivityCompat.requestPermissions(requireActivity(), ConstValues.permission_read_audio,
|
||||
// ConstValues.REQUEST_READ_STORAGE_PERMISSION);
|
||||
} else {
|
||||
importFromLocal()
|
||||
}
|
||||
} else {
|
||||
if ((ContextCompat.checkSelfPermission(
|
||||
requireContext(),
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
)
|
||||
!= PackageManager.PERMISSION_GRANTED) ||
|
||||
(ContextCompat.checkSelfPermission(
|
||||
requireContext(),
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
)
|
||||
!= PackageManager.PERMISSION_GRANTED)
|
||||
) {
|
||||
requestStorePermissionsLauncher.launch(permission_store)
|
||||
// ActivityCompat.requestPermissions(requireActivity(), ConstValues.permission_store, ConstValues.REQUEST_READ_STORAGE_PERMISSION);
|
||||
} else {
|
||||
importFromLocal()
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
checkAndRequestAudioPermission()
|
||||
}
|
||||
}
|
||||
private fun importFromLocal() {
|
||||
val intent = Intent(Intent.ACTION_GET_CONTENT)
|
||||
intent.setType("audio/*")
|
||||
audioPickerLauncher.launch("audio/*")
|
||||
}
|
||||
private fun checkAndRequestAudioPermission() {
|
||||
if (ContextCompat.checkSelfPermission(requireContext(), permission_record_audio)
|
||||
!= PackageManager.PERMISSION_GRANTED
|
||||
) {
|
||||
requestRecordAudioLauncher.launch(permission_record_audio)
|
||||
} else {
|
||||
intentRecordAudio()
|
||||
}
|
||||
}
|
||||
private fun intentRecordAudio() {
|
||||
val intent = Intent(requireContext(), ListenSoundActivity::class.java)
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,85 @@
|
||||
package com.design.mischiefgo.ut
|
||||
|
||||
import android.app.Activity
|
||||
import android.graphics.Color
|
||||
import android.util.Log
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.PopupWindow
|
||||
import com.design.mischiefgo.databinding.FragChooseTimeBinding
|
||||
|
||||
class ChooseTimeFragment(context: Activity, private val mListener: SoundListener) : View.OnClickListener {
|
||||
|
||||
private val binding: FragChooseTimeBinding = FragChooseTimeBinding.inflate(context.layoutInflater)
|
||||
private val popupWindow: PopupWindow = PopupWindow(
|
||||
binding.root,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
|
||||
init {
|
||||
popupWindow.isOutsideTouchable = true
|
||||
popupWindow.isFocusable = true
|
||||
binding.tvOff.isSelected = true
|
||||
binding.tvOff.setOnClickListener(this)
|
||||
binding.tv15s.setOnClickListener(this)
|
||||
binding.tv30s.setOnClickListener(this)
|
||||
binding.tv1m.setOnClickListener(this)
|
||||
binding.tv5m.setOnClickListener(this)
|
||||
}
|
||||
|
||||
fun showTop(view: View) {
|
||||
val location = IntArray(2)
|
||||
view.getLocationOnScreen(location)
|
||||
|
||||
val x = location[0]
|
||||
val y = location[1]
|
||||
|
||||
val popupHeight = popupWindow.height
|
||||
val height = view.height
|
||||
val width = view.width
|
||||
Log.d("-------------", "--------x=$x---y=$y----popupHeight=$popupHeight")
|
||||
|
||||
popupWindow.showAsDropDown(view, -50, 0, Gravity.NO_GRAVITY)
|
||||
}
|
||||
|
||||
private fun setSelected(tv: DefaultTextView) {
|
||||
val childCount = binding.layoutTime.childCount
|
||||
for (i in 0 until childCount) {
|
||||
val child = binding.layoutTime.getChildAt(i)
|
||||
if (child is DefaultTextView) {
|
||||
if (child == tv) {
|
||||
child.isSelected = true
|
||||
child.setTextColor(Color.WHITE)
|
||||
} else {
|
||||
child.isSelected = false
|
||||
// child.setTextColor(Color.parseColor("#3b3664"))
|
||||
}
|
||||
println("TextView: ${child.text}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun hide() {
|
||||
popupWindow.dismiss()
|
||||
}
|
||||
|
||||
fun setOffSelected() {
|
||||
setSelected(binding.tvOff)
|
||||
}
|
||||
|
||||
override fun onClick(v: View) {
|
||||
if (v is DefaultTextView) {
|
||||
val string = v.text.toString()
|
||||
when (string) {
|
||||
"off" -> mListener.onClickTimerListener(-1)
|
||||
"15 sec" -> mListener.onClickTimerListener(15 * 1000L)
|
||||
"30 sec" -> mListener.onClickTimerListener(30 * 1000L)
|
||||
"1 min" -> mListener.onClickTimerListener(60 * 1000L)
|
||||
"5 min" -> mListener.onClickTimerListener(5 * 60 * 1000L)
|
||||
}
|
||||
setSelected(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
108
app/src/main/java/com/design/mischiefgo/ut/CommonUtil.kt
Normal file
@ -0,0 +1,108 @@
|
||||
package com.design.mischiefgo.ut
|
||||
|
||||
import android.content.Context
|
||||
import android.media.AudioManager
|
||||
import android.media.MediaMetadataRetriever
|
||||
import android.net.Uri
|
||||
import android.widget.SeekBar
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.design.mischiefgo.entity.Duplicate
|
||||
import com.design.mischiefgo.entity.Usual
|
||||
import org.json.JSONArray
|
||||
import org.json.JSONException
|
||||
import java.io.BufferedReader
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.io.InputStreamReader
|
||||
import java.io.StringWriter
|
||||
|
||||
object CommonUtil {
|
||||
fun getString(input: InputStream): String {
|
||||
try {
|
||||
val charArray = CharArray(input.available())
|
||||
var count: Int
|
||||
val stringWriter = StringWriter()
|
||||
val inputStreamReader = InputStreamReader(input)
|
||||
val bufferedReader = BufferedReader(inputStreamReader)
|
||||
while ((bufferedReader.read(charArray).also { count = it }) != -1) {
|
||||
stringWriter.write(charArray, 0, count)
|
||||
}
|
||||
return stringWriter.toString()
|
||||
} catch (exception: IOException) {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
fun getUsual(str: String?): List<Usual>? {
|
||||
try {
|
||||
val data: MutableList<Usual> = ArrayList()
|
||||
val jsonArray = JSONArray(str)
|
||||
|
||||
for (i in 0..<jsonArray.length()) {
|
||||
val it = jsonArray.getJSONObject(i)
|
||||
val listArray = it.getJSONArray("list")
|
||||
val list: MutableList<Duplicate> = ArrayList()
|
||||
for (k in 0..<listArray.length()) {
|
||||
val listBean = listArray.getJSONObject(k)
|
||||
val duplicate = Duplicate()
|
||||
duplicate.audioUrl=(listBean.getString("mp3Url"))
|
||||
duplicate.convert=(listBean.getString("preUrl"))
|
||||
duplicate.name=(listBean.getString("title"))
|
||||
list.add(duplicate)
|
||||
}
|
||||
|
||||
val newBean = Usual()
|
||||
newBean.convert=(it.getString("categoryUrl"))
|
||||
newBean.infolist=(list)
|
||||
newBean.name=(it.getString("categoryName"))
|
||||
data.add(newBean)
|
||||
}
|
||||
|
||||
return data
|
||||
} catch (jo: JSONException) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
fun setVolume(context: Context, seekBar: SeekBar) {
|
||||
val audioManager = context.getSystemService(AppCompatActivity.AUDIO_SERVICE) as AudioManager
|
||||
val maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)
|
||||
seekBar.max = maxVolume
|
||||
seekBar.progress = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC)
|
||||
seekBar.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {
|
||||
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
|
||||
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, progress, 0)
|
||||
}
|
||||
|
||||
override fun onStartTrackingTouch(seekBar: SeekBar) {
|
||||
// 可以留空或添加相应逻辑
|
||||
}
|
||||
|
||||
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
||||
// 可以留空或添加相应逻辑
|
||||
}
|
||||
})
|
||||
}
|
||||
fun getAudioDuration(context: Context, uri: Uri?): Long {
|
||||
val retriever = MediaMetadataRetriever()
|
||||
var duration: Long = 0
|
||||
|
||||
try {
|
||||
val contentResolver = context.contentResolver
|
||||
retriever.setDataSource(context, uri)
|
||||
val time = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION)
|
||||
duration = time!!.toLong()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
} finally {
|
||||
try {
|
||||
retriever.release()
|
||||
} catch (e: IOException) {
|
||||
throw RuntimeException(e)
|
||||
}
|
||||
}
|
||||
|
||||
return duration
|
||||
}
|
||||
fun dpToPx(dp: Int, context: Context): Int {
|
||||
return (dp * context.resources.displayMetrics.density).toInt()
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.design.mischiefgo.ut
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import com.design.mischiefgo.NewApp
|
||||
|
||||
class DefaultTextView(context: Context, attrs: AttributeSet?) :
|
||||
AppCompatTextView(context, attrs) {
|
||||
|
||||
init {
|
||||
initAttrs(context, attrs)
|
||||
}
|
||||
|
||||
|
||||
private fun initAttrs(context: Context, attrs: AttributeSet?) {
|
||||
this.setTypeface(NewApp.typeface)
|
||||
}
|
||||
|
||||
}
|
||||
24
app/src/main/java/com/design/mischiefgo/ut/EvenTopUtils.kt
Normal file
@ -0,0 +1,24 @@
|
||||
package com.design.mischiefgo.ut
|
||||
|
||||
import android.graphics.Color
|
||||
import android.view.View
|
||||
import android.view.Window
|
||||
object EvenTopUtils {
|
||||
// 设置状态栏透明
|
||||
fun setStatusBar(window: Window) {
|
||||
window.statusBarColor = Color.TRANSPARENT
|
||||
window.decorView.systemUiVisibility =
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
}
|
||||
|
||||
// 设置状态栏黑色字体
|
||||
fun setLightStatusBar(window: Window, isLight: Boolean) {
|
||||
var systemUiVisibility = window.decorView.systemUiVisibility
|
||||
systemUiVisibility = if (isLight) {
|
||||
systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
||||
} else {
|
||||
systemUiVisibility and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv()
|
||||
}
|
||||
window.decorView.systemUiVisibility = systemUiVisibility
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
package com.design.mischiefgo.ut
|
||||
|
||||
import com.design.mischiefgo.entity.Duplicate
|
||||
|
||||
interface OnMoreClickListener {
|
||||
fun onMoreClick(duplicate: Duplicate)
|
||||
}
|
||||
91
app/src/main/java/com/design/mischiefgo/ut/RandomAdapter.kt
Normal file
@ -0,0 +1,91 @@
|
||||
package com.design.mischiefgo.ut
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.design.mischiefgo.entity.Duplicate
|
||||
import com.design.mischiefgo.ui.UseSoundActivity
|
||||
import com.bumptech.glide.Glide
|
||||
import com.design.mischiefgo.databinding.ItemNoRandomBinding
|
||||
import com.design.mischiefgo.databinding.ItemRandomBinding
|
||||
|
||||
class RandomAdapter: RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
private lateinit var context:Context
|
||||
private var type:Int=0
|
||||
private var infoList :List<Duplicate> = arrayListOf()
|
||||
private lateinit var listener: OnMoreClickListener
|
||||
|
||||
companion object {
|
||||
private const val VIEW_TYPE_1 = 1
|
||||
private const val VIEW_TYPE_2 = 2
|
||||
}
|
||||
|
||||
// 第一个 ViewHolder
|
||||
class ViewHolder1(val binding: ItemNoRandomBinding): RecyclerView.ViewHolder(binding.root)
|
||||
|
||||
// 第二个 ViewHolder
|
||||
class ViewHolder2(val binding: ItemRandomBinding): RecyclerView.ViewHolder(binding.root)
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return if (type != 0) VIEW_TYPE_2 else VIEW_TYPE_1
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
context = parent.context
|
||||
return when (viewType) {
|
||||
VIEW_TYPE_1 -> {
|
||||
val binding = ItemNoRandomBinding.inflate(LayoutInflater.from(context), parent, false)
|
||||
ViewHolder1(binding)
|
||||
}
|
||||
VIEW_TYPE_2 -> {
|
||||
val binding = ItemRandomBinding.inflate(LayoutInflater.from(context), parent, false)
|
||||
ViewHolder2(binding)
|
||||
}
|
||||
else -> throw IllegalArgumentException("Invalid view type")
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int {
|
||||
return infoList.size
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
val duplicate = infoList[position]
|
||||
val covert: String = duplicate.convert
|
||||
Log.d("covert",covert)
|
||||
|
||||
when (holder) {
|
||||
is ViewHolder1 -> {
|
||||
// 使用 ItemShowDetail1Binding 的布局
|
||||
Glide.with(context).load(covert).into(holder.binding.image)
|
||||
holder.binding.title.text = duplicate.name
|
||||
holder.binding.imgCard.setOnClickListener {
|
||||
val intent = Intent(context, UseSoundActivity::class.java)
|
||||
intent.putExtra(UseSoundActivity.KEY_LIST_DATA, duplicate)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
is ViewHolder2 -> {
|
||||
// 使用 ItemShowDetail2Binding 的布局
|
||||
Glide.with(context).load(covert).into(holder.binding.image)
|
||||
// holder.binding.title.text = duplicate.name
|
||||
holder.binding.imgCard.setOnClickListener {
|
||||
listener.onMoreClick(duplicate)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setList(list: List<Duplicate>, setType: Int = 0) {
|
||||
this.infoList = list
|
||||
this.type = setType
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
fun setListener(listener: OnMoreClickListener) {
|
||||
this.listener = listener
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,5 @@
|
||||
package com.design.mischiefgo.ut
|
||||
|
||||
interface SoundListener {
|
||||
fun onClickTimerListener(time: Long)
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
package com.design.mischiefgo.ut
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.design.mischiefgo.R
|
||||
import com.design.mischiefgo.entity.Duplicate
|
||||
import com.design.mischiefgo.ui.UseSoundActivity
|
||||
import com.bumptech.glide.Glide
|
||||
import com.design.mischiefgo.databinding.ItemStartAndEndBinding
|
||||
|
||||
class StartAndEndAdapter: RecyclerView.Adapter<StartAndEndAdapter.SelfViewHolder>() {
|
||||
private lateinit var context:Context
|
||||
private var infoList :List<Duplicate> = arrayListOf()
|
||||
private var type:Int=0
|
||||
private lateinit var listener:OnMoreClickListener
|
||||
|
||||
class SelfViewHolder(val binding: ItemStartAndEndBinding): RecyclerView.ViewHolder(binding.root)
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SelfViewHolder {
|
||||
context=parent.context
|
||||
val binding=ItemStartAndEndBinding.inflate(LayoutInflater.from(context),parent,false)
|
||||
return SelfViewHolder(binding)
|
||||
}
|
||||
override fun getItemCount(): Int {
|
||||
return infoList.size
|
||||
}
|
||||
override fun onBindViewHolder(holder: SelfViewHolder, position: Int) {
|
||||
if (position == itemCount - 1) {
|
||||
holder.binding.vBottom.visibility = View.VISIBLE
|
||||
} else {
|
||||
holder.binding.vBottom.visibility = View.GONE
|
||||
}
|
||||
val myInfo = infoList[position]
|
||||
val covert: String = myInfo.convert
|
||||
Log.d("covert",covert+"typre$type")
|
||||
if(type==0){
|
||||
Glide.with(context).load(covert).placeholder(R.drawable.music_default_copy).error(R.drawable.music_default_copy).into(holder.binding.ivImage)
|
||||
holder.binding.imgLike.setImageDrawable(context.getDrawable(R.drawable.punctate_selector))
|
||||
holder.binding.imgLike.isSelected=true
|
||||
holder.binding.tint.visibility=View.VISIBLE
|
||||
if(myInfo.isCustomization){
|
||||
holder.binding.tint.text="resource:upload"
|
||||
}else{
|
||||
holder.binding.tint.text="resource:original"
|
||||
}
|
||||
|
||||
}else{
|
||||
Glide.with(context).load(R.drawable.music_default_copy).placeholder(R.drawable.music_default_copy).error(R.drawable.music_default_copy).into(holder.binding.ivImage)
|
||||
holder.binding.imgLike.setImageDrawable(context.getDrawable(R.drawable.remove_any_small))
|
||||
holder.binding.tint.visibility=View.GONE
|
||||
}
|
||||
holder.binding.tvTitle.text = myInfo.name
|
||||
holder.binding.imgLike.setOnClickListener {
|
||||
this.listener.onMoreClick(myInfo)
|
||||
}
|
||||
holder.binding.item.setOnClickListener {
|
||||
val intent = Intent(context, UseSoundActivity::class.java)
|
||||
intent.putExtra(UseSoundActivity.KEY_LIST_DATA, myInfo)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
fun setList(list: List<Duplicate>,type:Int){
|
||||
this.type=type
|
||||
this.infoList=list
|
||||
}
|
||||
fun setListener(listener: OnMoreClickListener){
|
||||
this.listener=listener
|
||||
}
|
||||
}
|
||||
66
app/src/main/java/com/design/mischiefgo/ut/StartPlayUtil.kt
Normal file
@ -0,0 +1,66 @@
|
||||
package com.design.mischiefgo.ut
|
||||
|
||||
import android.content.Context
|
||||
import android.media.MediaRecorder
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
|
||||
class StartPlayUtil(context: Context) {
|
||||
private var mediaRecorder: MediaRecorder? = null
|
||||
private val tempFileName: String
|
||||
private val fileName: String? = null
|
||||
private var isRecording = false
|
||||
|
||||
init {
|
||||
val dir = context.cacheDir
|
||||
val file = File(dir, "temp_audio.mp3")
|
||||
tempFileName = file.absolutePath
|
||||
}
|
||||
|
||||
|
||||
fun startRecording() {
|
||||
if (isRecording) return
|
||||
mediaRecorder = MediaRecorder()
|
||||
mediaRecorder!!.setAudioSource(MediaRecorder.AudioSource.MIC)
|
||||
mediaRecorder!!.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP)
|
||||
mediaRecorder!!.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB)
|
||||
mediaRecorder!!.setOutputFile(tempFileName)
|
||||
|
||||
try {
|
||||
mediaRecorder!!.prepare()
|
||||
mediaRecorder!!.start()
|
||||
isRecording = true
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
fun stopRecording() {
|
||||
if (!isRecording || mediaRecorder == null) return
|
||||
|
||||
try {
|
||||
// 只有在录制状态下才能调用stop
|
||||
mediaRecorder?.stop()
|
||||
} catch (e: IllegalStateException) {
|
||||
e.printStackTrace()
|
||||
} catch (e: RuntimeException) {
|
||||
e.printStackTrace()
|
||||
} finally {
|
||||
releaseMediaRecorder()
|
||||
isRecording = false
|
||||
}
|
||||
}
|
||||
private fun releaseMediaRecorder() {
|
||||
try {
|
||||
mediaRecorder?.release()
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
} finally {
|
||||
mediaRecorder = null
|
||||
}
|
||||
}
|
||||
fun getTempFileName(): String {
|
||||
return tempFileName
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
package com.design.mischiefgo.ut
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.design.mischiefgo.entity.Usual
|
||||
import com.design.mischiefgo.databinding.ItemYellowCenterBinding
|
||||
import com.design.mischiefgo.ui.TypeInActivity
|
||||
import com.bumptech.glide.Glide
|
||||
|
||||
class YellowCenterAdapter: RecyclerView.Adapter<YellowCenterAdapter.DoubleViewHolder>() {
|
||||
private lateinit var context:Context
|
||||
private var beanList :List<Usual> = arrayListOf()
|
||||
|
||||
|
||||
class DoubleViewHolder(val binding: ItemYellowCenterBinding): RecyclerView.ViewHolder(binding.root)
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): DoubleViewHolder {
|
||||
context=parent.context
|
||||
val binding=ItemYellowCenterBinding.inflate(LayoutInflater.from(context),parent,false)
|
||||
return DoubleViewHolder(binding)
|
||||
}
|
||||
override fun getItemCount(): Int {
|
||||
return beanList.size
|
||||
}
|
||||
override fun onBindViewHolder(holder: DoubleViewHolder, position: Int) {
|
||||
|
||||
val myBean = beanList[position]
|
||||
val covert: String = myBean.convert
|
||||
Log.d("covert",covert)
|
||||
Glide.with(context).load(covert).into(holder.binding.image)
|
||||
holder.binding.title.text = myBean.name
|
||||
holder.binding.imgRelay.setOnClickListener {
|
||||
val intent = Intent(context, TypeInActivity::class.java)
|
||||
intent.putExtra(TypeInActivity.KEY_LIST_DATA, myBean)
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
fun setList(list: List<Usual>){
|
||||
this.beanList=list
|
||||
}
|
||||
}
|
||||
5
app/src/main/res/drawable/all_of_main_bg.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<gradient android:startColor="@color/grad_1" android:centerColor="@color/grad_2" android:endColor="@color/grad_2" android:angle="135"/>
|
||||
|
||||
</shape>
|
||||
BIN
app/src/main/res/drawable/center_sound_0.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
app/src/main/res/drawable/center_sound_1.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
5
app/src/main/res/drawable/center_sound_selector.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/center_sound_1" android:state_selected="true"/>
|
||||
<item android:drawable="@drawable/center_sound_0"/>
|
||||
</selector>
|
||||
5
app/src/main/res/drawable/clock_selector.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/for_time_1" android:state_selected="true"/>
|
||||
<item android:drawable="@drawable/for_time"/>
|
||||
</selector>
|
||||
9
app/src/main/res/drawable/close_finishs.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="64dp"
|
||||
android:height="64dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:pathData="M395.2,513.6l323.1,-312.4c19.1,-18.4 19.1,-48.3 0,-66.7 -19.1,-18.4 -49.9,-18.4 -69,0L291.8,480.3c-19.1,18.4 -19.1,48.3 0,66.7l357.6,345.7c9.5,9.2 22,13.8 34.5,13.8 12.5,0 25,-4.6 34.5,-13.8 19.1,-18.4 19.1,-48.2 0,-66.7L395.2,513.6z"
|
||||
android:fillColor="@color/white"/>
|
||||
</vector>
|
||||
BIN
app/src/main/res/drawable/empty_list_ic.png
Normal file
|
After Width: | Height: | Size: 4.7 KiB |
15
app/src/main/res/drawable/for_like.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="200dp"
|
||||
android:height="200dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:pathData="M467.1,191.9l-19,29.7c-132.3,-70.6 -299.8,-29.7 -381.9,98.7 -86.3,134.9 -46.4,315.9 88.5,402.2l226.3,144.7 245.3,156.8 156.9,-245.3 174.6,-273.1c86.3,-134.9 46.4,-315.9 -88.5,-402.1s-315.9,-46.4 -402.1,88.5z"
|
||||
android:fillColor="@color/temp_grey"/>
|
||||
<path
|
||||
android:pathData="M193.2,140.3a58.2,30.4 37.2,1 0,36.7 -48.4,58.2 30.4,37.2 1,0 -36.7,48.4Z"
|
||||
android:fillColor="@color/temp_grey"/>
|
||||
<path
|
||||
android:pathData="M322.6,115.6a30.4,58.2 7.4,1 0,14.9 -115.4,30.4 58.2,7.4 1,0 -14.9,115.4Z"
|
||||
android:fillColor="@color/temp_grey"/>
|
||||
</vector>
|
||||
15
app/src/main/res/drawable/for_like_1.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="200dp"
|
||||
android:height="200dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:pathData="M467.1,191.9l-19,29.7c-132.3,-70.6 -299.8,-29.7 -381.9,98.7 -86.3,134.9 -46.4,315.9 88.5,402.2l226.3,144.7 245.3,156.8 156.9,-245.3 174.6,-273.1c86.3,-134.9 46.4,-315.9 -88.5,-402.1s-315.9,-46.4 -402.1,88.5z"
|
||||
android:fillColor="#E58FAC"/>
|
||||
<path
|
||||
android:pathData="M193.2,140.3a58.2,30.4 37.2,1 0,36.7 -48.4,58.2 30.4,37.2 1,0 -36.7,48.4Z"
|
||||
android:fillColor="#E58FAC"/>
|
||||
<path
|
||||
android:pathData="M322.6,115.6a30.4,58.2 7.4,1 0,14.9 -115.4,30.4 58.2,7.4 1,0 -14.9,115.4Z"
|
||||
android:fillColor="#E58FAC"/>
|
||||
</vector>
|
||||
9
app/src/main/res/drawable/for_row.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="200dp"
|
||||
android:height="200dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:pathData="M958.7,326.4l0,537.6c0,29.9 -24.2,54.2 -54.1,54.2L119.4,918.1c-29.9,0 -54.1,-24.3 -54.1,-54.2L65.3,326.4c0,-29.9 24.2,-58 54.1,-58l301,0 -73.5,-72.1c-21.1,-21.2 -21,-53.6 0.3,-74.6 21.2,-21.1 55.5,-21 76.6,0.2l165.2,166.3c21,21.1 21,55.1 0,76.3L423.7,530.7c-10.6,10.7 -24.5,15.7 -38.4,15.7 -13.8,0 -27.6,-5.7 -38.2,-16.2 -21.2,-21.1 -21.3,-56.3 -0.3,-77.5l73.6,-76L173.6,376.6l0,433.2 676.8,0L850.4,376.6 736.7,376.6c-29.9,0 -54.1,-24.2 -54.1,-54.1s24.2,-54.1 54.1,-54.1l167.9,0C934.5,268.3 958.7,296.4 958.7,326.4z"
|
||||
android:fillColor="@color/temp_grey"/>
|
||||
</vector>
|
||||
9
app/src/main/res/drawable/for_row_1.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="200dp"
|
||||
android:height="200dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:pathData="M958.7,326.4l0,537.6c0,29.9 -24.2,54.2 -54.1,54.2L119.4,918.1c-29.9,0 -54.1,-24.3 -54.1,-54.2L65.3,326.4c0,-29.9 24.2,-58 54.1,-58l301,0 -73.5,-72.1c-21.1,-21.2 -21,-53.6 0.3,-74.6 21.2,-21.1 55.5,-21 76.6,0.2l165.2,166.3c21,21.1 21,55.1 0,76.3L423.7,530.7c-10.6,10.7 -24.5,15.7 -38.4,15.7 -13.8,0 -27.6,-5.7 -38.2,-16.2 -21.2,-21.1 -21.3,-56.3 -0.3,-77.5l73.6,-76L173.6,376.6l0,433.2 676.8,0L850.4,376.6 736.7,376.6c-29.9,0 -54.1,-24.2 -54.1,-54.1s24.2,-54.1 54.1,-54.1l167.9,0C934.5,268.3 958.7,296.4 958.7,326.4z"
|
||||
android:fillColor="#ff9572"/>
|
||||
</vector>
|
||||
15
app/src/main/res/drawable/for_time.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="200dp"
|
||||
android:height="200dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:pathData="M512,924c-55.6,0 -109.6,-10.9 -160.4,-32.4 -49.1,-20.8 -93.1,-50.5 -131,-88.3 -37.8,-37.8 -67.5,-81.9 -88.3,-131C110.9,621.6 100,567.6 100,512s10.9,-109.6 32.4,-160.4c20.8,-49.1 50.5,-93.1 88.3,-131 37.8,-37.8 81.9,-67.5 131,-88.3C402.4,110.9 456.4,100 512,100c75.8,0 150,20.8 214.4,60.1 11.8,7.2 15.5,22.6 8.3,34.4 -7.2,11.8 -22.6,15.5 -34.4,8.3C643.8,168.2 578.6,150 512,150c-199.6,0 -362,162.4 -362,362s162.4,362 362,362 362,-162.4 362,-362c0,-11.6 -0.6,-23.3 -1.7,-34.8 -1.3,-13.7 8.8,-26 22.5,-27.3 13.7,-1.3 26,8.8 27.3,22.5 1.2,13.1 1.9,26.4 1.9,39.6 0,55.6 -10.9,109.6 -32.4,160.4 -20.8,49.1 -50.5,93.1 -88.3,131 -37.8,37.8 -81.9,67.5 -131,88.3C621.6,913.1 567.6,924 512,924z"
|
||||
android:fillColor="@color/temp_grey"/>
|
||||
<path
|
||||
android:pathData="M696.4,512.5H508.3c-13.8,0 -25,11.3 -25,25s11.2,25 25,25h188.1c13.8,0 25,-11.3 25,-25s-11.2,-25 -25,-25z"
|
||||
android:fillColor="@color/temp_grey"/>
|
||||
<path
|
||||
android:pathData="M508.3,313c-13.8,0 -25,11.3 -25,25v199.5c0,13.8 11.3,25 25,25s25,-11.3 25,-25V338c0,-13.7 -11.2,-25 -25,-25zM865.7,258.9l-42.4,-137.7c-7.2,-23.4 -37.9,-28.8 -52.6,-9.3L669,246.4c-14.8,19.5 -1.2,47.5 23.3,48.1l144.1,3.2c20.4,0.5 35.3,-19.2 29.3,-38.8zM510,798.3c-13.8,0 -25,11.3 -25,25v11.5c0,13.8 11.3,25 25,25s25,-11.3 25,-25v-11.5c0,-13.8 -11.2,-25 -25,-25zM509,167.3c-13.8,0 -25,11.3 -25,25v11.5c0,13.8 11.3,25 25,25s25,-11.3 25,-25v-11.5c0,-13.8 -11.2,-25 -25,-25zM205.3,515.5h-11.5c-13.8,0 -25,11.3 -25,25s11.3,25 25,25h11.5c13.8,0 25,-11.3 25,-25s-11.3,-25 -25,-25zM828.3,515.5h-12.5c-13.8,0 -25,11.3 -25,25s11.3,25 25,25h12.5c13.8,0 25,-11.3 25,-25s-11.3,-25 -25,-25z"
|
||||
android:fillColor="@color/temp_grey"/>
|
||||
</vector>
|
||||
15
app/src/main/res/drawable/for_time_1.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="200dp"
|
||||
android:height="200dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:pathData="M512,924c-55.6,0 -109.6,-10.9 -160.4,-32.4 -49.1,-20.8 -93.1,-50.5 -131,-88.3 -37.8,-37.8 -67.5,-81.9 -88.3,-131C110.9,621.6 100,567.6 100,512s10.9,-109.6 32.4,-160.4c20.8,-49.1 50.5,-93.1 88.3,-131 37.8,-37.8 81.9,-67.5 131,-88.3C402.4,110.9 456.4,100 512,100c75.8,0 150,20.8 214.4,60.1 11.8,7.2 15.5,22.6 8.3,34.4 -7.2,11.8 -22.6,15.5 -34.4,8.3C643.8,168.2 578.6,150 512,150c-199.6,0 -362,162.4 -362,362s162.4,362 362,362 362,-162.4 362,-362c0,-11.6 -0.6,-23.3 -1.7,-34.8 -1.3,-13.7 8.8,-26 22.5,-27.3 13.7,-1.3 26,8.8 27.3,22.5 1.2,13.1 1.9,26.4 1.9,39.6 0,55.6 -10.9,109.6 -32.4,160.4 -20.8,49.1 -50.5,93.1 -88.3,131 -37.8,37.8 -81.9,67.5 -131,88.3C621.6,913.1 567.6,924 512,924z"
|
||||
android:fillColor="#ff9572"/>
|
||||
<path
|
||||
android:pathData="M696.4,512.5H508.3c-13.8,0 -25,11.3 -25,25s11.2,25 25,25h188.1c13.8,0 25,-11.3 25,-25s-11.2,-25 -25,-25z"
|
||||
android:fillColor="#ff9572"/>
|
||||
<path
|
||||
android:pathData="M508.3,313c-13.8,0 -25,11.3 -25,25v199.5c0,13.8 11.3,25 25,25s25,-11.3 25,-25V338c0,-13.7 -11.2,-25 -25,-25zM865.7,258.9l-42.4,-137.7c-7.2,-23.4 -37.9,-28.8 -52.6,-9.3L669,246.4c-14.8,19.5 -1.2,47.5 23.3,48.1l144.1,3.2c20.4,0.5 35.3,-19.2 29.3,-38.8zM510,798.3c-13.8,0 -25,11.3 -25,25v11.5c0,13.8 11.3,25 25,25s25,-11.3 25,-25v-11.5c0,-13.8 -11.2,-25 -25,-25zM509,167.3c-13.8,0 -25,11.3 -25,25v11.5c0,13.8 11.3,25 25,25s25,-11.3 25,-25v-11.5c0,-13.8 -11.2,-25 -25,-25zM205.3,515.5h-11.5c-13.8,0 -25,11.3 -25,25s11.3,25 25,25h11.5c13.8,0 25,-11.3 25,-25s-11.3,-25 -25,-25zM828.3,515.5h-12.5c-13.8,0 -25,11.3 -25,25s11.3,25 25,25h12.5c13.8,0 25,-11.3 25,-25s-11.3,-25 -25,-25z"
|
||||
android:fillColor="#ff9572"/>
|
||||
</vector>
|
||||
74
app/src/main/res/drawable/ic_launcher_background.xml
Normal file
@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector
|
||||
android:height="108dp"
|
||||
android:width="108dp"
|
||||
android:viewportHeight="108"
|
||||
android:viewportWidth="108"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M9,0L9,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,0L19,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M29,0L29,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M39,0L39,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M49,0L49,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M59,0L59,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M69,0L69,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M79,0L79,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M89,0L89,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M99,0L99,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,9L108,9"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,19L108,19"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,29L108,29"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,39L108,39"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,49L108,49"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,59L108,59"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,69L108,69"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,79L108,79"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,89L108,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,99L108,99"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,29L89,29"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,39L89,39"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,49L89,49"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,59L89,59"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,69L89,69"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,79L89,79"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M29,19L29,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M39,19L39,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M49,19L49,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M59,19L59,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M69,19L69,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M79,19L79,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
</vector>
|
||||
30
app/src/main/res/drawable/ic_launcher_foreground.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
||||
BIN
app/src/main/res/drawable/listen_sound_1.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
21
app/src/main/res/drawable/listen_sound_2.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="45dp"
|
||||
android:height="45dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:pathData="M513.1,504.6m-450.8,0a450.8,450.8 0,1 0,901.6 0,450.8 450.8,0 1,0 -901.6,0Z"
|
||||
android:fillColor="@color/grad_2"/>
|
||||
<path
|
||||
android:pathData="M513.1,182c-178.2,0 -322.7,144.4 -322.7,322.7 0,178.2 144.4,322.7 322.7,322.7 178.2,0 322.7,-144.4 322.7,-322.7 0,-178.2 -144.4,-322.7 -322.7,-322.7zM419.1,397.9c0,-51.9 42,-94 94,-94 51.9,0 94,42 94,94v96.3c0,51.9 -42,94 -94,94 -51.9,0 -94,-42 -94,-94v-96.3zM684.5,492.5c0,86.5 -63.3,158.4 -145.7,171.2v46.7c0,14.1 -11.5,25.6 -25.6,25.6s-25.6,-11.5 -25.6,-25.6v-46.5C404.5,651.7 340.4,579.5 340.4,492.5v-12.8c0,-14.1 11.5,-25.6 25.6,-25.6s25.6,11.5 25.6,25.6v12.8c0,67.3 54.2,122 120.8,122 66.7,0 120.8,-54.7 120.8,-122v-12.8c0,-14.1 11.5,-25.6 25.6,-25.6s25.6,11.5 25.6,25.6v12.8z"
|
||||
android:fillColor="@color/main_title_text"/>
|
||||
<path
|
||||
android:pathData="M799.6,356.4c-53.7,-103.6 -161.8,-174.4 -286.6,-174.4 -178.2,0 -322.7,144.4 -322.7,322.7 0,117.1 62.4,219.6 155.8,276.2 1.1,0 2.3,0.1 3.4,0.1 240.1,0 436.4,-187.8 450,-424.4zM419.1,397.9c0,-51.9 42,-94 94,-94 51.9,0 94,42 94,94v96.3c0,51.9 -42,94 -94,94 -51.9,0 -94,-42 -94,-94v-96.3zM538.8,663.7v46.7c0,14.1 -11.5,25.6 -25.6,25.6s-25.6,-11.5 -25.6,-25.6v-46.5C404.5,651.7 340.4,579.5 340.4,492.5v-12.8c0,-14.1 11.5,-25.6 25.6,-25.6s25.6,11.5 25.6,25.6v12.8c0,67.3 54.2,122 120.8,122 66.7,0 120.8,-54.7 120.8,-122v-12.8c0,-14.1 11.5,-25.6 25.6,-25.6s25.6,11.5 25.6,25.6v12.8c0.1,86.5 -63.2,158.4 -145.6,171.2z"
|
||||
android:fillColor="@color/main_title_text"/>
|
||||
<path
|
||||
android:pathData="M190.4,504.6c0,40.9 7.7,79.9 21.5,115.9 4.8,0.2 9.5,0.3 14.3,0.3 51.9,0 101.8,-8.8 148.2,-24.9a172.9,172.9 0,0 1,-34.1 -103.3v-12.8c0,-14.1 11.5,-25.6 25.6,-25.6s25.6,11.5 25.6,25.6v12.8c0,31.9 12.2,61 32.2,82.8 8.4,-4.1 16.6,-8.4 24.7,-13.1 -18.1,-17.1 -29.4,-41.3 -29.4,-68.1v-96.3c0,-51.9 42,-94 94,-94 51.9,0 94,42 94,94v13.6a448.5,448.5 0,0 0,66.8 -186.6,321 321,0 0,0 -160.7,-42.9c-178.1,0 -322.6,144.5 -322.6,322.7z"
|
||||
android:fillColor="@color/main_title_text"/>
|
||||
<path
|
||||
android:pathData="M194.5,453.8c152.2,-27.8 277.7,-132 335.3,-271.5 -5.5,-0.3 -11.1,-0.4 -16.6,-0.4 -160.9,0 -294.2,117.8 -318.6,271.9z"
|
||||
android:fillColor="@color/main_title_text"/>
|
||||
</vector>
|
||||
7
app/src/main/res/drawable/listen_sound_selector.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_selected="false" android:drawable="@drawable/listen_sound_2"/>
|
||||
<item android:state_selected="true" android:drawable="@drawable/listen_sound_1"/>
|
||||
|
||||
|
||||
</selector>
|
||||
7
app/src/main/res/drawable/main_nagitive_bar.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<gradient
|
||||
android:startColor="@color/simple_white"
|
||||
android:endColor="@color/simple_white"
|
||||
android:centerColor="@color/simple_white"/>
|
||||
</shape>
|
||||
48
app/src/main/res/drawable/music_default_copy.xml
Normal file
@ -0,0 +1,48 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="200dp"
|
||||
android:height="200dp"
|
||||
android:viewportWidth="1024"
|
||||
android:viewportHeight="1024">
|
||||
<path
|
||||
android:pathData="M513.1,513.6m-508.8,0a508.8,508.8 0,1 0,1017.6 0,508.8 508.8,0 1,0 -1017.6,0Z"
|
||||
android:fillColor="@color/temp_grey"/>
|
||||
<path
|
||||
android:pathData="M513.1,513.6m-355.4,0a355.4,355.4 0,1 0,710.9 0,355.4 355.4,0 1,0 -710.9,0Z"
|
||||
android:fillColor="@color/grad_1"/>
|
||||
<path
|
||||
android:pathData="M768.5,845.3H257.7c-42.1,0 -76.3,-34.2 -76.3,-76.3v-510.8c0,-42.2 34.2,-76.3 76.3,-76.3h510.8c42.2,0 76.3,34.2 76.3,76.3v510.8c0,42.2 -34.2,76.3 -76.3,76.3z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
<path
|
||||
android:pathData="M513.1,526.3m-250.1,0a250.1,250.1 0,1 0,500.2 0,250.1 250.1,0 1,0 -500.2,0Z"
|
||||
android:fillColor="@color/main_title_text"/>
|
||||
<path
|
||||
android:pathData="M513.1,513.6m-250.1,0a250.1,250.1 0,1 0,500.2 0,250.1 250.1,0 1,0 -500.2,0Z"
|
||||
android:fillColor="@color/grad_2"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M394.4,451.9c22.3,-42.8 67.1,-72 118.7,-72M330.8,448.9c26.6,-75 98.2,-128.6 182.3,-128.6"/>
|
||||
<path
|
||||
android:pathData="M513.1,513.6m-85.7,0a85.7,85.7 0,1 0,171.4 0,85.7 85.7,0 1,0 -171.4,0Z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
<path
|
||||
android:pathData="M513.1,513.6m-75.2,0a75.2,75.2 0,1 0,150.4 0,75.2 75.2,0 1,0 -150.4,0Z"
|
||||
android:fillColor="#51E4C2"/>
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M712.3,258.9v215.6a76.3,76.3 0,0 1,-27.1 58.3l-45,38"/>
|
||||
<path
|
||||
android:pathData="M669.8,573.3l-41.9,33.8a12.7,12.7 0,0 1,-17.9 -1.9l-10.5,-13a12.7,12.7 0,0 1,1.9 -17.9l41.9,-33.8a12.7,12.7 0,0 1,17.9 1.9l10.5,13a12.7,12.7 0,0 1,-1.9 17.9z"
|
||||
android:fillColor="#F8E71C"/>
|
||||
<path
|
||||
android:pathData="M712.3,265.3m-36.3,0a36.3,36.3 0,1 0,72.6 0,36.3 36.3,0 1,0 -72.6,0Z"
|
||||
android:fillColor="@color/grad_2"/>
|
||||
<path
|
||||
android:pathData="M712.3,258.9m-36.3,0a36.3,36.3 0,1 0,72.6 0,36.3 36.3,0 1,0 -72.6,0Z"
|
||||
android:fillColor="@color/grad_2"/>
|
||||
<path
|
||||
android:pathData="M513.1,520m-19,0a19,19 0,1 0,38 0,19 19,0 1,0 -38,0Z"
|
||||
android:fillColor="#51E4C2"/>
|
||||
<path
|
||||
android:pathData="M513.1,513.6m-19,0a19,19 0,1 0,38 0,19 19,0 1,0 -38,0Z"
|
||||
android:fillColor="#FFFFFF"/>
|
||||
</vector>
|
||||
6
app/src/main/res/drawable/no_random_bg.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<corners android:radius="8dp" />
|
||||
<solid android:color="@color/white"/>
|
||||
|
||||
</shape>
|
||||
6
app/src/main/res/drawable/play_selector.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/for_row" android:state_selected="false" />
|
||||
<item android:drawable="@drawable/for_row_1" android:state_selected="true" />
|
||||
|
||||
</selector>
|
||||
5
app/src/main/res/drawable/pop_default_cor_bg.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<solid android:color="@color/white"/>
|
||||
<corners android:radius="5dp"/>
|
||||
</shape>
|
||||
5
app/src/main/res/drawable/pop_sel_selector.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<item android:state_selected="true" android:drawable="@drawable/stroke_brown_sel_choose"/>
|
||||
<item android:drawable="@drawable/trans_bg"/>
|
||||
</selector>
|
||||
6
app/src/main/res/drawable/punctate_selector.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/for_like" android:state_selected="false" />
|
||||
<item android:drawable="@drawable/for_like_1" android:state_selected="true" />
|
||||
|
||||
</selector>
|
||||
BIN
app/src/main/res/drawable/remove_any_small.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
5
app/src/main/res/drawable/save_btn_decoration.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<corners android:radius="5dp"/>
|
||||
<solid android:color="@color/temp_button"/>
|
||||
</shape>
|
||||
5
app/src/main/res/drawable/start_and_end_bg.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<corners android:radius="5dp"/>
|
||||
<solid android:color="@color/simple_white"/>
|
||||
</shape>
|
||||
23
app/src/main/res/drawable/start_joke_bg.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@android:id/background">
|
||||
<shape>
|
||||
<corners android:radius="5dp" />
|
||||
<stroke android:width="1dp" android:color="@color/main_title_text"/>
|
||||
<solid android:color="@color/simple_white" /> <!-- 背景颜色 -->
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item android:id="@android:id/progress">
|
||||
<clip>
|
||||
<shape>
|
||||
<stroke android:width="1dp" android:color="@color/main_title_text"/>
|
||||
<corners android:radius="25dp" />
|
||||
<gradient
|
||||
android:startColor="@color/grad_1"
|
||||
android:centerColor="@color/grad_1"
|
||||
android:endColor="@color/temp_button"
|
||||
android:angle="0" />
|
||||
</shape>
|
||||
</clip>
|
||||
</item>
|
||||
</layer-list>
|
||||
BIN
app/src/main/res/drawable/start_play_121.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
6
app/src/main/res/drawable/stroke_brown_sel_choose.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<stroke android:color="@color/main_title_text" android:width="1dp"/>
|
||||
<corners android:radius="10dp" />
|
||||
</shape>
|
||||
4
app/src/main/res/drawable/trans_bg.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<corners android:radius="10dp" />
|
||||
</shape>
|
||||
BIN
app/src/main/res/drawable/trumpet_ic.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
6
app/src/main/res/drawable/type_in_bg.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<!-- <corners android:topLeftRadius="25dp" android:topRightRadius="25dp"/>-->
|
||||
<solid android:color="@color/simple_white"/>
|
||||
|
||||
</shape>
|
||||
4
app/src/main/res/drawable/use_sound_oval_bg.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
|
||||
<solid android:color="@color/white"/>
|
||||
</shape>
|
||||
8
app/src/main/res/drawable/use_sound_radius.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="oval">
|
||||
<solid android:color="@color/main_title_text" />
|
||||
<size
|
||||
android:width="17dp"
|
||||
android:height="17dp" />
|
||||
</shape>
|
||||
BIN
app/src/main/res/drawable/wavy_ic.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
4
app/src/main/res/drawable/white_35_all_radius.xml
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<solid android:color="@color/simple_white" />
|
||||
</shape>
|
||||
6
app/src/main/res/drawable/yellow_center_item_bg.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<stroke android:color="@color/main_title_text" android:width="1dp" />
|
||||
<solid android:color="@color/simple_white"/>
|
||||
<corners android:radius="5dp" />
|
||||
</shape>
|
||||
BIN
app/src/main/res/drawable/yellow_end_0.png
Normal file
|
After Width: | Height: | Size: 6.4 KiB |
BIN
app/src/main/res/drawable/yellow_end_1.png
Normal file
|
After Width: | Height: | Size: 6.4 KiB |
5
app/src/main/res/drawable/yellow_end_selector.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/yellow_end_1" android:state_selected="true"/>
|
||||
<item android:drawable="@drawable/yellow_end_0"/>
|
||||
</selector>
|
||||
BIN
app/src/main/res/drawable/yellow_start_0.png
Normal file
|
After Width: | Height: | Size: 5.5 KiB |
BIN
app/src/main/res/drawable/yellow_start_1.png
Normal file
|
After Width: | Height: | Size: 5.6 KiB |
BIN
app/src/main/res/drawable/yellow_start_item1.png
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
BIN
app/src/main/res/drawable/yellow_start_item2.png
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
5
app/src/main/res/drawable/yellow_start_selector.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:drawable="@drawable/yellow_start_1" android:state_selected="true"/>
|
||||
<item android:drawable="@drawable/yellow_start_0"/>
|
||||
</selector>
|
||||
5
app/src/main/res/drawable/yellow_white.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||
<corners android:radius="5dp"/>
|
||||
<solid android:color="@color/simple_white" />
|
||||
</shape>
|
||||
44
app/src/main/res/layout/activity_ad_show.xml
Normal file
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/all_of_main_bg"
|
||||
tools:context="com.design.mischiefgo.ui.AdShowActivity">
|
||||
|
||||
<androidx.constraintlayout.utils.widget.ImageFilterView
|
||||
android:id="@+id/im"
|
||||
android:layout_width="110dp"
|
||||
android:layout_height="110dp"
|
||||
app:roundPercent="0.3"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="200dp"
|
||||
android:src="@mipmap/ic_launcher" />
|
||||
|
||||
<com.design.mischiefgo.ut.DefaultTextView
|
||||
android:id="@+id/appName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/im"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="23dp"
|
||||
android:text="@string/app_name"
|
||||
android:textColor="@color/main_title_text"
|
||||
android:textStyle="bold"
|
||||
android:textSize="24sp" />
|
||||
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/loadingPb"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginHorizontal="60dp"
|
||||
android:layout_height="7dp"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:progress="70"
|
||||
android:layout_marginBottom="100dp"
|
||||
android:progressDrawable="@drawable/start_joke_bg" />
|
||||
|
||||
</RelativeLayout>
|
||||
67
app/src/main/res/layout/activity_listen_sound.xml
Normal file
@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/simple_white"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/title_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="34dp"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="12dp"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<com.design.mischiefgo.ut.DefaultTextView
|
||||
android:id="@+id/name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="@string/recording_audio"
|
||||
android:textStyle="bold"
|
||||
android:textSize="23sp"
|
||||
android:textColor="@color/main_title_text" />
|
||||
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/back"
|
||||
android:layout_width="45dp"
|
||||
android:layout_height="45dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:padding="12dp"
|
||||
app:tint="@color/main_title_text"
|
||||
android:src="@drawable/close_finishs" />
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/im_mic"
|
||||
android:layout_width="150dp"
|
||||
android:layout_height="150dp"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginTop="120dp"
|
||||
android:src="@drawable/listen_sound_selector" />
|
||||
<com.design.mischiefgo.ut.DefaultTextView
|
||||
android:id="@+id/audioTint"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/click_to_start"
|
||||
android:textSize="17sp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:textColor="@color/temp_grey" />
|
||||
<com.design.mischiefgo.ut.DefaultTextView
|
||||
android:id="@+id/audio_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="30dp"
|
||||
android:text="00:00:00"
|
||||
android:textColor="@color/main_title_text"
|
||||
android:textSize="28sp" />
|
||||
|
||||
</LinearLayout>
|
||||
98
app/src/main/res/layout/activity_navigation.xml
Normal file
@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/main"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".ui.NavigationActivity">
|
||||
<FrameLayout
|
||||
android:id="@+id/fragmentIn"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@+id/llBottom"/>
|
||||
<LinearLayout
|
||||
android:id="@+id/llBottom"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:baselineAligned="false"
|
||||
android:background="@drawable/main_nagitive_bar"
|
||||
android:paddingBottom="10dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:orientation="horizontal">
|
||||
<LinearLayout
|
||||
android:id="@+id/llRecord"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="50dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="center"
|
||||
android:paddingVertical="8dp"
|
||||
android:layout_weight="1"
|
||||
>
|
||||
<ImageView
|
||||
android:id="@+id/imgRecord"
|
||||
android:layout_width="23dp"
|
||||
android:layout_height="23dp"
|
||||
app:tint="@color/main_title_text"
|
||||
android:src="@drawable/yellow_start_selector" />
|
||||
<com.design.mischiefgo.ut.DefaultTextView
|
||||
android:id="@+id/ltRecord"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/main_title_text"
|
||||
android:text="@string/audio"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/llCategory"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="50dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="center"
|
||||
android:paddingVertical="8dp"
|
||||
android:layout_weight="1"
|
||||
>
|
||||
<ImageView
|
||||
android:id="@+id/imgCategory"
|
||||
android:layout_width="23dp"
|
||||
android:layout_height="23dp"
|
||||
app:tint="@color/main_title_text"
|
||||
android:src="@drawable/center_sound_selector" />
|
||||
<com.design.mischiefgo.ut.DefaultTextView
|
||||
android:id="@+id/ltHome"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/main_title_text"
|
||||
android:text="@string/home"/>
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/llCollect"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="50dp"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:layout_gravity="center"
|
||||
android:paddingVertical="8dp"
|
||||
android:layout_weight="1">
|
||||
<ImageView
|
||||
android:id="@+id/imgCollect"
|
||||
android:layout_width="23dp"
|
||||
android:layout_height="23dp"
|
||||
app:tint="@color/main_title_text"
|
||||
android:src="@drawable/yellow_end_selector" />
|
||||
<com.design.mischiefgo.ut.DefaultTextView
|
||||
android:id="@+id/ltFavorite"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/main_title_text"
|
||||
android:layout_marginStart="2dp"
|
||||
android:text="@string/favorite"/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||