Page 7 Stage 3

This commit is contained in:
icewithcola 2024-07-27 16:07:47 +08:00
parent 4d35371e4a
commit 71c168488b
29 changed files with 906 additions and 404 deletions

View file

@ -12,8 +12,8 @@ android {
applicationId = "uk.kagurach.android101"
minSdk = 28
targetSdk = 34
versionCode = 172
versionName = "1.7.2"
versionCode = 173
versionName = "1.7.3"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
@ -44,7 +44,7 @@ android {
androidResources {
generateLocaleConfig = true
}
buildFeatures{
buildFeatures {
viewBinding = true
}
}
@ -75,6 +75,10 @@ dependencies {
implementation(libs.androidx.datastore.rxjava3)
implementation(libs.androidx.datastore.preferences)
implementation(libs.androidx.work)
implementation(libs.androidx.camera.core)
implementation(libs.androidx.camera.view)
implementation(libs.androidx.camera.lifecycle)
implementation(libs.androidx.camera.camera2)
testImplementation(libs.junit)

View file

@ -1,13 +1,11 @@
package uk.kagurach.android101
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*

View file

@ -3,27 +3,27 @@ package uk.kagurach.android101
import org.junit.Assert
import org.junit.Test
import uk.kagurach.android101.helper.ColorHelper
import org.junit.runner.RunWith
class TestColorHelper {
val colorHelper = ColorHelper()
@Test
fun Test_toColorInt(){
Assert.assertEquals(0,colorHelper.toColorInt(0, 0, 0))
Assert.assertEquals(0xfffffe,colorHelper.toColorInt(255, 0xff, 254))
fun Test_toColorInt() {
Assert.assertEquals(0, colorHelper.toColorInt(0, 0, 0))
Assert.assertEquals(0xfffffe, colorHelper.toColorInt(255, 0xff, 254))
}
@Test(expected = Exception::class)
fun Test_error(){
val wtf1 = colorHelper.toColorInt(-1,256,1)
fun Test_error() {
val wtf1 = colorHelper.toColorInt(-1, 256, 1)
}
@Test
fun Test_toString(){
Assert.assertEquals("$000000",colorHelper.toString(0,"$"))
Assert.assertEquals("#ffffff",colorHelper.toString(0xffffff))
Assert.assertEquals("#ABCD12",colorHelper.toString(0xabcd12, upperCase = true))
fun Test_toString() {
Assert.assertEquals("$000000", colorHelper.toString(0, "$"))
Assert.assertEquals("#ffffff", colorHelper.toString(0xffffff))
Assert.assertEquals("#ABCD12", colorHelper.toString(0xabcd12, upperCase = true))
}

View file

@ -1,14 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-feature
android:name="android.hardware.camera"
android:required="false" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.CAMERA" />
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
@ -18,8 +25,10 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="false"
android:theme="@style/Theme.Android101"
android:usesCleartextTraffic="true"
>
android:usesCleartextTraffic="true">
<activity
android:name=".additionalActivity.CameraXActivity"
android:exported="false" />
<activity
android:name=".Page7"
android:exported="false"

View file

@ -70,6 +70,16 @@ public class MainActivity extends KaBaseActivity {
new String[]{Manifest.permission.READ_MEDIA_AUDIO},
102);
}
if (ContextCompat
.checkSelfPermission
(MainActivity.this, Manifest.permission.CAMERA)
!= PackageManager.PERMISSION_GRANTED) {
textViewAppendString(tv, "Acquiring CAMERA");
ActivityCompat.requestPermissions
(MainActivity.this,
new String[]{Manifest.permission.CAMERA},
102);
}
textViewAppendString(tv, "Check Finished");
textViewAppendString(tv, "提示:常按有惊喜");
}

View file

@ -12,6 +12,7 @@ import android.util.Log
import android.view.View
import android.view.View.GONE
import android.view.View.OnClickListener
import android.view.View.OnLongClickListener
import android.view.View.VISIBLE
import android.widget.Button
import android.widget.EditText
@ -32,14 +33,14 @@ import kotlinx.coroutines.flow.map
import kotlinx.coroutines.runBlocking
import okhttp3.Call
import okhttp3.Callback
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.MultipartBody
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.asRequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response
import uk.kagurach.android101.additionalActivity.CameraXActivity
import uk.kagurach.android101.helper.ToastHelper
import java.io.File
import java.io.IOException
@ -77,6 +78,9 @@ class Page7 : KaBaseActivity() {
findViewById<Button>(R.id.P7ListenAudio).setOnClickListener(RecordButtonHandler())
findViewById<Button>(R.id.P7RecordAudio).setOnClickListener(RecordButtonHandler())
findViewById<Button>(R.id.P7SendAudio).setOnClickListener(ButtonHandler(this))
findViewById<Button>(R.id.P7ShotPhoto).setOnClickListener(PhotoButtonHandler(this))
findViewById<Button>(R.id.P7SendPhoto).setOnClickListener(ButtonHandler(this))
}
inner class ButtonHandler(val activity: Activity) : OnClickListener {
@ -90,6 +94,7 @@ class Page7 : KaBaseActivity() {
// Validate
if (botAPI.isBlank() || (chatID.isBlank() && v.id != R.id.P7SaveAndSetAPI)) {
ToastHelper.ShowToast(getText(R.string.require_api).toString(), baseContext)
return
}
when (v.id) {
@ -109,8 +114,22 @@ class Page7 : KaBaseActivity() {
}
R.id.P7SendMessageButton -> { // 发送文本
tgHandler.postText(
val text =
activity.findViewById<EditText>(R.id.P7SendMessageText).text.toString()
if (text.isEmpty()) {
return
}
tgHandler.postText(text) { result ->
runOnUiThread {
resultTextField.text = result
}
}
}
R.id.P7SendAudio -> { // 发送音频
tgHandler.postAudio(
audioUri,
baseContext,
) { result ->
runOnUiThread {
resultTextField.text = result
@ -118,15 +137,13 @@ class Page7 : KaBaseActivity() {
}
}
R.id.P7SendAudio ->{ // 发送音频
tgHandler.postAudio(
audioUri,
baseContext,
){result ->
R.id.P7SendPhoto -> { // 发送照片
tgHandler.postImage(photoPath) { result ->
runOnUiThread {
resultTextField.text = result
}
}
}
else -> resultTextField.text = "?"
@ -157,13 +174,13 @@ class Page7 : KaBaseActivity() {
val recordIntent = Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION)
try {
startActivityForResult(recordIntent, 0)
} catch (e : android.content.ActivityNotFoundException){
Log.e("Recorder@Android101",e.printStackTrace().toString())
} catch (e: android.content.ActivityNotFoundException) {
Log.e("Recorder@Android101", e.printStackTrace().toString())
}
}
R.id.P7ListenAudio -> {
if (audioUri!=Uri.EMPTY){
if (audioUri != Uri.EMPTY) {
val mMediaPlayer = MediaPlayer()
mMediaPlayer.reset()
mMediaPlayer.setAudioAttributes(
@ -171,13 +188,24 @@ class Page7 : KaBaseActivity() {
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
.build()
)
mMediaPlayer.setDataSource(baseContext,audioUri)
mMediaPlayer.setDataSource(baseContext, audioUri)
mMediaPlayer.prepare()
mMediaPlayer.start()
}
}
}
}
}
inner class PhotoButtonHandler(val context: Context) : OnClickListener, OnLongClickListener {
override fun onClick(v: View) {
val myIntent = Intent(context, CameraXActivity::class.java)
startActivityForResult(myIntent, 1)
}
override fun onLongClick(v: View): Boolean {
TODO("Not yet implemented")
}
}
@ -185,17 +213,26 @@ class Page7 : KaBaseActivity() {
super.onActivityResult(requestCode, resultCode, data)
when (requestCode) {
0 -> { // 录音
if (resultCode == RESULT_OK && data != null){
if (resultCode == RESULT_OK && data != null) {
audioUri = data.data
ToastHelper.ShowToast("Saved at ${audioUri}",this)
ToastHelper.ShowToast("Saved at ${audioUri}", this)
findViewById<Button>(R.id.P7ListenAudio).isEnabled = true
}
}
1 -> { // 拍照
if (resultCode == RESULT_OK && data != null) {
photoPath = data.getStringExtra("result") ?: return
ToastHelper.ShowToast("Saved at ${photoPath}", this)
findViewById<Button>(R.id.P7ViewPhoto).isEnabled = true
}
}
}
}
companion object {
var audioUri = Uri.EMPTY
var photoPath = ""
}
}
@ -245,23 +282,29 @@ class telegramHandler(val BOT_KEY: String, val CHATID: String) {
})
}
fun postAudio(audioUri: Uri,context: Context,callBack: (String) -> Unit) {
if (audioUri == Uri.EMPTY){
fun postAudio(audioUri: Uri, context: Context, callBack: (String) -> Unit) {
if (audioUri == Uri.EMPTY) {
callBack("Sorry Please Record First")
return
}
// Copy to local
val inputStream: InputStream = context.contentResolver.openInputStream(audioUri)?:return
val inputStream: InputStream = context.contentResolver.openInputStream(audioUri) ?: return
val bytes = inputStream.readBytes()
val file = File(context.cacheDir.path + "/source.m4a")
file.writeBytes(bytes)
// Convert to ogg
val session = FFmpegKit.execute("-i ${context.cacheDir.path}/source.m4a -acodec libvorbis -aq 4 -vn -ac 2 -map_metadata 0 -y -f ogg ${context.cacheDir.path}/decoded.ogg")
val session =
FFmpegKit.execute("-i ${context.cacheDir.path}/source.m4a -acodec libvorbis -aq 4 -vn -ac 2 -map_metadata 0 -y -f ogg ${context.cacheDir.path}/decoded.ogg")
if (!ReturnCode.isSuccess(session.getReturnCode())) {
// FAILURE
Log.d("FFmpeg@Android101", String.format("Command failed with state %s and rc %s.%s",
session.getState(), session.getReturnCode(), session.getFailStackTrace()))
Log.d(
"FFmpeg@Android101", String.format(
"Command failed with state %s and rc %s.%s",
session.getState(), session.getReturnCode(), session.getFailStackTrace()
)
)
return
}
@ -269,13 +312,14 @@ class telegramHandler(val BOT_KEY: String, val CHATID: String) {
val finalUri = "${basicUri}/${api}?chat_id=${CHATID}&voice=attach%3A%2F%2Fvoice"
val requestBody = MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("voice","decoded.ogg",
RequestBody.create("audio/ogg".toMediaTypeOrNull(),File("${context.cacheDir.path}/decoded.ogg"))
.addFormDataPart(
"voice", "decoded.ogg",
File("${context.cacheDir.path}/decoded.ogg").asRequestBody("audio/ogg".toMediaTypeOrNull())
)
.build()
val request = Request.Builder()
.url(finalUri)
.header("Content-Type","multipart/form-data")
.header("Content-Type", "multipart/form-data")
.post(requestBody)
.build()
val call = client.newCall(request)
@ -291,10 +335,44 @@ class telegramHandler(val BOT_KEY: String, val CHATID: String) {
callBack("${responseCode},${responseBody}")
}
})
}
}
fun postImage(photoPath: String, callBack: (String) -> Unit) {
if (!File(photoPath).exists()) {
callBack("Sorry Please Take Some Photos First")
return
}
val api = "sendPhoto"
val finalUri = "${basicUri}/${api}?chat_id=${CHATID}&photo=attach%3A%2F%2Fphoto"
val requestBody = MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart(
"photo", photoPath.split('/').last().split('.').first(),
File(photoPath).asRequestBody("image/jpeg".toMediaTypeOrNull())
)
.build()
val request = Request.Builder()
.url(finalUri)
.header("Content-Type", "multipart/form-data")
.post(requestBody)
.build()
val call = client.newCall(request)
call.enqueue(object : Callback {
override fun onFailure(call: Call, e: IOException) {
Log.e("TgHelper", e.printStackTrace().toString())
callBack("${e.printStackTrace()}")
}
override fun onResponse(call: Call, response: Response) {
val responseCode = response.code
val responseBody = response.body?.string()
callBack("${responseCode},${responseBody}")
}
})
}
}
class TGStorage(val context: Context) {

View file

@ -0,0 +1,91 @@
package uk.kagurach.android101.additionalActivity
import android.content.Intent
import android.graphics.BitmapFactory
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.util.Log
import android.view.View
import android.view.View.INVISIBLE
import android.view.View.OnClickListener
import android.view.View.VISIBLE
import android.widget.Button
import android.widget.ImageView
import androidx.activity.enableEdgeToEdge
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import uk.kagurach.android101.KaBaseActivity
import uk.kagurach.android101.R
import uk.kagurach.android101.customLayout.CameraXView
class CameraXActivity : KaBaseActivity() {
lateinit var cameraXView: CameraXView
lateinit var mHandler: Handler
var savedImage = ""
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_camera_xactivity)
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}
cameraXView = findViewById(R.id.globalCameraXView)
mHandler = Handler(Looper.getMainLooper())
findViewById<Button>(R.id.CameraXTakePhoto).setOnClickListener(ButtonHandler())
findViewById<Button>(R.id.CameraXDenyPhoto).setOnClickListener(ButtonHandler())
findViewById<Button>(R.id.CameraXUsePhoto).setOnClickListener(ButtonHandler())
initCamera()
}
fun initCamera() {
cameraXView.openCamera(this) { result ->
if (result.isBlank()) {
Log.e("initCamera@Android101", "Blank result!")
} else {
savedImage = result
val imageResult = findViewById<ImageView>(R.id.CameraXResult)
runOnUiThread {
imageResult.visibility = VISIBLE
imageResult.setImageBitmap(BitmapFactory.decodeFile(savedImage))
findViewById<Button>(R.id.CameraXUsePhoto).isEnabled = true
findViewById<Button>(R.id.CameraXDenyPhoto).isEnabled = true
}
}
}
}
inner class ButtonHandler : OnClickListener {
override fun onClick(v: View) {
when (v.id) {
R.id.CameraXTakePhoto -> {
findViewById<Button>(R.id.CameraXTakePhoto).isEnabled = false
cameraXView.takePicture()
}
R.id.CameraXDenyPhoto -> {
runOnUiThread {
findViewById<Button>(R.id.CameraXUsePhoto).isEnabled = false
findViewById<Button>(R.id.CameraXDenyPhoto).isEnabled = false
findViewById<Button>(R.id.CameraXTakePhoto).isEnabled = true
findViewById<ImageView>(R.id.CameraXResult).visibility = INVISIBLE
}
}
R.id.CameraXUsePhoto -> {
val returnIntent = Intent()
returnIntent.putExtra("result", savedImage)
setResult(RESULT_OK, returnIntent)
finish()
}
}
}
}
}

View file

@ -0,0 +1,143 @@
package uk.kagurach.android101.customLayout
import android.annotation.SuppressLint
import android.content.Context
import android.os.Handler
import android.os.Looper
import android.util.AttributeSet
import android.util.Log
import android.view.Surface.ROTATION_0
import android.view.ViewGroup
import android.widget.RelativeLayout
import androidx.camera.core.AspectRatio
import androidx.camera.core.CameraSelector
import androidx.camera.core.ImageCapture
import androidx.camera.core.ImageCaptureException
import androidx.camera.core.Preview
import androidx.camera.lifecycle.ProcessCameraProvider
import androidx.camera.view.PreviewView
import androidx.core.content.ContextCompat
import androidx.lifecycle.LifecycleOwner
import java.io.File
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
class CameraXView : RelativeLayout {
var mContext: Context
lateinit var mCameraPreview: PreviewView
lateinit var mExecutorService: ExecutorService
lateinit var mMediaDir: String
lateinit var mHandler: Handler
lateinit var mCameraType: CameraSelector
lateinit var mCameraSelector: CameraSelector
lateinit var mPreview: Preview
lateinit var mCameraProvider: ProcessCameraProvider
lateinit var mImageCapture: ImageCapture
lateinit var mOwner: LifecycleOwner
var mOnStop: (String) -> Unit = {}
private fun init() {
mCameraPreview = PreviewView(mContext)
mExecutorService = Executors.newSingleThreadExecutor()
mMediaDir = mContext.cacheDir.path
mHandler = Handler(Looper.getMainLooper()) // 声明一个处理器对象
mCameraType = CameraSelector.DEFAULT_BACK_CAMERA
mCameraPreview.layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
addView(mCameraPreview)
}
constructor(context: Context) : super(context) {
mContext = context
init()
}
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
mContext = context
init()
}
fun openCamera(owner: LifecycleOwner, onStopListener: (String) -> Unit) {
mOwner = owner
mOnStop = onStopListener
mHandler.post { initCamera() }
}
private fun initCamera() {
val future = ProcessCameraProvider.getInstance(mContext)
future.addListener(
{
try {
mCameraProvider = future.get()
resetCamera()
} catch (e: Exception) {
Log.e("Kamera@Android101", e.printStackTrace().toString())
}
},
ContextCompat.getMainExecutor(mContext)
)
}
@SuppressLint("RestrictedApi")
private fun resetCamera() {
mCameraSelector = CameraSelector.Builder()
.requireLensFacing(mCameraType.lensFacing ?: CameraSelector.LENS_FACING_BACK)
.build()
mPreview = Preview.Builder()
.setTargetAspectRatio(AspectRatio.RATIO_16_9)
.build()
mImageCapture = ImageCapture.Builder()
.setCaptureMode(ImageCapture.CAPTURE_MODE_MINIMIZE_LATENCY)
.setTargetRotation(ROTATION_0)
.setTargetAspectRatio(AspectRatio.RATIO_16_9)
.setFlashMode(ImageCapture.FLASH_MODE_OFF)
.build()
bindCamera(0)
mPreview.setSurfaceProvider(mCameraPreview.surfaceProvider)
}
fun bindCamera(mode: Int) {
when (mode) {
0 -> { // 拍照
try {
mCameraProvider.unbindAll()
mCameraProvider.bindToLifecycle(
mOwner, mCameraSelector, mPreview, mImageCapture
)
} catch (e: Exception) {
Log.e("Kamera.bindCamera@Android101", e.printStackTrace().toString())
}
}
}
}
fun takePicture() {
val metaData = ImageCapture.Metadata()
val options = ImageCapture.OutputFileOptions.Builder(
File("${mMediaDir}/${System.currentTimeMillis()}.jpg")
).setMetadata(metaData)
.build()
mImageCapture.takePicture(options, mExecutorService, object :
ImageCapture.OnImageSavedCallback {
override fun onImageSaved(outputFileResults: ImageCapture.OutputFileResults) {
mOnStop.invoke(outputFileResults.savedUri?.path.toString())
}
override fun onError(exception: ImageCaptureException) {
Log.e("takePicture@Android101", exception.printStackTrace().toString())
}
})
}
fun closeCamera() {
mCameraProvider.unbindAll()
mExecutorService.shutdown()
}
}

View file

@ -4,6 +4,6 @@
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:pathData="m256,760 l-56,-56 224,-224 -224,-224 56,-56 224,224 224,-224 56,56 -224,224 224,224 -56,56 -224,-224 -224,224Z"
android:fillColor="#5f6368"/>
android:fillColor="#5f6368"
android:pathData="m256,760 l-56,-56 224,-224 -224,-224 56,-56 224,224 224,-224 56,56 -224,224 224,224 -56,56 -224,-224 -224,224Z" />
</vector>

View file

@ -5,5 +5,5 @@
android:viewportHeight="960">
<path
android:fillColor="#FF000000"
android:pathData="M160,560v-80h280v80L160,560ZM160,400v-80h440v80L160,400ZM160,240v-80h440v80L160,240ZM520,800v-123l221,-220q9,-9 20,-13t22,-4q12,0 23,4.5t20,13.5l37,37q8,9 12.5,20t4.5,22q0,11 -4,22.5T863,580L643,800L520,800ZM820,537 L783,500 820,537ZM580,740h38l121,-122 -18,-19 -19,-18 -122,121v38ZM721,599 L702,581 739,618 721,599Z"/>
android:pathData="M160,560v-80h280v80L160,560ZM160,400v-80h440v80L160,400ZM160,240v-80h440v80L160,240ZM520,800v-123l221,-220q9,-9 20,-13t22,-4q12,0 23,4.5t20,13.5l37,37q8,9 12.5,20t4.5,22q0,11 -4,22.5T863,580L643,800L520,800ZM820,537 L783,500 820,537ZM580,740h38l121,-122 -18,-19 -19,-18 -122,121v38ZM721,599 L702,581 739,618 721,599Z" />
</vector>

View file

@ -2,9 +2,12 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#E8EAF6" />
<corners android:radius="20dp" />
<padding android:left="20dp"
android:top="20dp"
<padding
android:bottom="20dp"
android:left="20dp"
android:right="20dp"
android:bottom="20dp"/>
<stroke android:color="#6A000000" android:width="3dp"/>
android:top="20dp" />
<stroke
android:width="3dp"
android:color="#6A000000" />
</shape>

View file

@ -2,8 +2,9 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#B3E5FC" />
<corners android:radius="16dp" />
<padding android:left="16dp"
android:top="16dp"
<padding
android:bottom="16dp"
android:left="16dp"
android:right="16dp"
android:bottom="16dp"/>
android:top="16dp" />
</shape>

View file

@ -2,9 +2,12 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFDE7" />
<corners android:radius="20dp" />
<padding android:left="20dp"
android:top="20dp"
<padding
android:bottom="20dp"
android:left="20dp"
android:right="20dp"
android:bottom="20dp"/>
<stroke android:color="#FFEB3B" android:width="3dp"/>
android:top="20dp" />
<stroke
android:width="3dp"
android:color="#FFEB3B" />
</shape>

View file

@ -0,0 +1,65 @@
<?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=".additionalActivity.CameraXActivity">
<uk.kagurach.android101.customLayout.CameraXView
android:id="@+id/globalCameraXView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginHorizontal="5dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="100dp" />
<ImageView
android:id="@+id/CameraXResult"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginHorizontal="5dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="100dp"
android:rotation="90"
android:visibility="invisible" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="15dp"
android:orientation="horizontal"
app:layout_constraintTop_toBottomOf="@id/globalCameraXView">
<Button
android:id="@+id/CameraXDenyPhoto"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:backgroundTint="?colorTertiary"
android:enabled="false"
android:text="@string/retake"
android:textAllCaps="false" />
<Button
android:id="@+id/CameraXTakePhoto"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginHorizontal="15dp"
android:layout_weight="1"
android:backgroundTint="?colorPrimary"
android:text="@string/shot"
android:textAllCaps="false" />
<Button
android:id="@+id/CameraXUsePhoto"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:backgroundTint="?colorSecondary"
android:enabled="false"
android:text="@string/use"
android:textAllCaps="false" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -10,16 +10,15 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginHorizontal="15dp"
android:layout_marginVertical="10dp"
>
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="6"
>
android:layout_weight="6">
<TextView
android:id="@+id/tv_hello"
android:layout_width="match_parent"
@ -38,10 +37,9 @@
android:id="@+id/P1OpenAppSettingsLayout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginHorizontal="15dp"
android:text="@string/settings"
/>
android:layout_weight="1"
android:text="@string/settings" />
</LinearLayout>
@ -49,13 +47,12 @@
android:id="@+id/Page1NextPage"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginVertical="10dp"
android:layout_marginHorizontal="15dp"
android:layout_marginVertical="10dp"
android:layout_weight="1.5"
android:text="@string/next_page"
android:backgroundTint="?colorSecondary"
android:enabled="false"
android:backgroundTint="?colorSecondary" />
android:text="@string/next_page" />
</LinearLayout>

View file

@ -7,24 +7,25 @@
android:layout_height="match_parent"
android:windowSoftInputMode="adjustResize"
tools:context=".MainActivity2"
tools:viewBindingIgnore="true"
>
tools:viewBindingIgnore="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="300dp">
<TextView
android:id="@+id/test2strview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/test_str"
android:textColor="#000000"
android:textSize="70sp"/>
android:textSize="70sp" />
</ScrollView>
<TextView
@ -32,8 +33,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:textSize="20sp"
android:text="@string/p2_default_setting"/>
android:text="@string/p2_default_setting"
android:textSize="20sp" />
<LinearLayout
@ -41,44 +42,42 @@
android:layout_height="wrap_content"
android:minHeight="140dp"
android:orientation="horizontal">
<EditText
android:id="@+id/Page2SetTestText"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:ems="10"
android:importantForAutofill="no"
android:inputType="text"
android:text="@string/test_str"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="25dp"
android:layout_weight="1"
android:ems="10"
android:hint="@string/test_str"
/>
android:importantForAutofill="no"
android:inputType="text"
android:text="@string/test_str" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginEnd="20dp"
android:orientation="vertical"
>
android:orientation="vertical">
<Button
android:id="@+id/Page2SetTestTextButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/setText"
android:onClick="setText"
android:backgroundTint="@color/tfb"
/>
android:onClick="setText"
android:text="@string/setText" />
<Button
android:id="@+id/P2OpenSettingsButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/settings"
android:backgroundTint="@color/tfp"
/>
android:text="@string/settings" />
</LinearLayout>
@ -87,39 +86,40 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginHorizontal="20dp"
>
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAllCaps="false"
android:layout_marginTop="5dp"
android:text="@string/font_size"
android:textSize="18sp"
android:layout_marginTop="5dp"/>
android:textAllCaps="false"
android:textSize="18sp" />
<Button
android:id="@+id/Page2SetSP"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:onClick="setUnit_sp"
android:layout_marginStart="5dp"
android:layout_weight="1"
android:backgroundTint="?colorPrimary"
android:onClick="setUnit_sp"
android:text="70sp" />
<Button
android:id="@+id/Page2SetDP"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:onClick="setUnit_dp"
android:layout_marginHorizontal="10dp"
android:layout_weight="1"
android:backgroundTint="?colorSecondary"
android:onClick="setUnit_dp"
android:text="70dp" />
<Button
@ -127,20 +127,20 @@
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:backgroundTint="?colorTertiary"
android:onClick="setUnit_px"
android:text="70px"
android:backgroundTint="?colorTertiary"
tools:ignore="PxUsage" />
</LinearLayout>
<Button
android:id="@+id/next_page_nav_2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginBottom="20dp"
android:text="@string/two_way_page"
/>
android:layout_weight="1"
android:text="@string/two_way_page" />
</LinearLayout>
@ -150,28 +150,29 @@
android:id="@+id/P2SettingPage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginHorizontal="20dp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="20dp"
android:background="@drawable/p2_settings_layout"
android:visibility="invisible">
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="@string/settings"
android:layout_weight="1"
android:textSize="35sp"
android:text="@string/settings"
android:textColor="#B71C1C"
/>
android:textSize="35sp" />
<ImageButton
android:id="@+id/P2SettingsCloseButton"
@ -189,55 +190,56 @@
android:layout_marginHorizontal="8dp"
android:layout_marginVertical="5dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30sp"
android:text="@string/set_color"/>
android:text="@string/set_color"
android:textSize="30sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="20dp"
>
android:paddingTop="20dp">
<EditText
android:id="@+id/P2SetColorR"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:ems="10"
android:importantForAutofill="no"
android:inputType="number"
android:hint="@string/rgb_r_range"
/>
android:importantForAutofill="no"
android:inputType="number" />
<EditText
android:id="@+id/P2SetColorG"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginHorizontal="20dp"
android:layout_weight="1"
android:ems="10"
android:importantForAutofill="no"
android:inputType="number"
android:hint="@string/rgb_g_range"
android:layout_marginHorizontal="20dp"
/>
android:importantForAutofill="no"
android:inputType="number" />
<EditText
android:id="@+id/P2SetColorB"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:ems="10"
android:importantForAutofill="no"
android:inputType="number"
android:hint="@string/rgb_b_range"
/>
android:importantForAutofill="no"
android:inputType="number" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:layout_marginStart="10dp"
android:layout_marginTop="5dp"
android:layout_marginStart="10dp">
android:orientation="horizontal">
<ImageView
android:id="@+id/P2ColorShower"
@ -251,23 +253,23 @@
android:id="@+id/P2TestColorButton"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginStart="20dp"
android:text="@string/test_color"
android:layout_weight="1"
android:backgroundTint="?colorPrimary"
android:textAllCaps="false"/>
android:text="@string/test_color"
android:textAllCaps="false" />
<Button
android:id="@+id/Page2SetColor"
android:layout_width="0dp"
android:layout_marginStart="15dp"
android:layout_height="match_parent"
android:layout_marginStart="15dp"
android:layout_weight="1"
android:text="@string/set_color"
android:textAllCaps="false"
android:backgroundTint="?colorTertiary"
android:onClick="setColor"/>
android:onClick="setColor"
android:text="@string/set_color"
android:textAllCaps="false" />
</LinearLayout>
</LinearLayout>
@ -277,37 +279,38 @@
android:layout_marginHorizontal="8dp"
android:layout_marginTop="15dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30sp"
android:text="@string/set_per_unit_font_size"/>
android:text="@string/set_per_unit_font_size"
android:textSize="30sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="horizontal"
android:layout_marginTop="5dp"
android:layout_marginBottom="15dp"
>
android:orientation="horizontal">
<EditText
android:id="@+id/P2SetTextSize"
android:layout_width="0dp"
android:layout_height="match_parent"
android:ems="10"
android:layout_weight="1"
android:inputType="number"
android:ems="10"
android:hint="设置字体大小"
/>
android:inputType="number" />
<Button
android:id="@+id/Page2SetSize"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="30dp"
android:onClick="setSize"
android:textAllCaps="false"
android:backgroundTint="?colorTertiary"
android:text="@string/set" />
android:onClick="setSize"
android:text="@string/set"
android:textAllCaps="false" />
</LinearLayout>
</LinearLayout>
@ -316,5 +319,4 @@
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -6,185 +6,214 @@
android:layout_height="match_parent"
tools:context=".Page3"
tools:viewBindingIgnore="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/P3CalcName"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="@string/kaculate"
android:textSize="40sp"/>
android:textSize="40sp" />
<TextView
android:id="@+id/P3CalcResult"
android:layout_width="match_parent"
android:layout_height="400dp"
android:textSize="25sp"
android:text="" />
android:text=""
android:textSize="25sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<Button
android:id="@+id/P3CE"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="CE" />
<Button
android:id="@+id/P3Div"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="/" />
<Button
android:id="@+id/P3X"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="x" />
<Button
android:id="@+id/P3Nextpage"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/next_page" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<Button
android:id="@+id/P3_7"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:backgroundTint="@color/tfb"
android:text="7" />
<Button
android:id="@+id/P3_8"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:backgroundTint="@color/tfb"
android:text="8" />
<Button
android:id="@+id/P3_9"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:backgroundTint="@color/tfb"
android:text="9" />
<Button
android:id="@+id/P3Plus"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="+" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<Button
android:id="@+id/P3_4"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:backgroundTint="@color/tfb"
android:text="4" />
<Button
android:id="@+id/P3_5"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:backgroundTint="@color/tfb"
android:text="5" />
<Button
android:id="@+id/P3_6"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:backgroundTint="@color/tfb"
android:text="6" />
<Button
android:id="@+id/P3Minus"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="-" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<Button
android:id="@+id/P3_1"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:backgroundTint="@color/tfb"
android:text="1" />
<Button
android:id="@+id/P3_2"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:backgroundTint="@color/tfb"
android:text="2" />
<Button
android:id="@+id/P3_3"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:backgroundTint="@color/tfb"
android:text="3" />
<Button
android:id="@+id/P3ChengFang"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="^" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<Button
android:id="@+id/P3BK"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/Backspace" />
<Button
android:id="@+id/P3_0"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:backgroundTint="@color/tfb"
android:text="0" />
<Button
android:id="@+id/P3Dot"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="." />
<Button
android:id="@+id/P3EqualButton"
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="=" />
</LinearLayout>
</LinearLayout>

View file

@ -12,88 +12,88 @@
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="40sp"
android:text="@string/user"/>
android:text="@string/user"
android:textSize="40sp" />
<EditText
android:id="@+id/P4Ask"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="35sp"
android:layout_marginStart="10dp"
android:id="@+id/P4Ask"
android:hint="@string/AI_ASK_DEFAULT_STRING"
android:importantForAutofill="no"
android:inputType="text"
android:text="@string/AI_ASK_DEFAULT_STRING"
android:textColor="@color/tfp"
android:hint="@string/AI_ASK_DEFAULT_STRING"
android:inputType="text" />
android:textSize="35sp" />
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
android:layout_weight="1" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="40sp"
android:text="@string/ai"/>
android:text="@string/ai"
android:textSize="40sp" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="8"
android:layout_marginStart="10dp">
android:layout_marginStart="10dp"
android:layout_weight="8">
<TextView
android:layout_width="match_parent"
android:textSize="35sp"
android:layout_height="wrap_content"
android:id="@+id/P4Result"
android:textColor="@color/tfb"
/>
</ScrollView>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="25sp"
android:textColor="@color/tfb"
android:textSize="35sp" />
</ScrollView>
<TextView
android:id="@+id/P4AIRuntime"
android:text="@string/ai_ready"/>
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/ai_ready"
android:textSize="25sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:layout_marginHorizontal="5dp"
android:layout_weight="3"
android:orientation="horizontal">
<Button
android:layout_width="140dp"
android:layout_marginVertical="20dp"
android:layout_height="match_parent"
android:id="@+id/P4AskAI"
android:text="@string/ask_ai"
/>
android:layout_width="140dp"
android:layout_height="match_parent"
android:layout_marginVertical="20dp"
android:text="@string/ask_ai" />
<Button
android:layout_width="120dp"
android:layout_marginVertical="20dp"
android:layout_marginHorizontal="10dp"
android:layout_height="match_parent"
android:id="@+id/P4Vibrate"
android:layout_width="120dp"
android:layout_height="match_parent"
android:layout_marginHorizontal="10dp"
android:layout_marginVertical="20dp"
android:backgroundTint="?colorTertiary"
android:text="@string/vibrate"
/>
android:text="@string/vibrate" />
<Button
android:layout_width="match_parent"
android:layout_marginVertical="20dp"
android:layout_height="match_parent"
android:id="@+id/P4PageButton"
android:text="@string/next_page"
/>
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginVertical="20dp"
android:text="@string/next_page" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -10,8 +10,8 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -19,96 +19,106 @@
android:layout_marginTop="15dp"
android:background="#E0F7FA"
android:text="@string/animal_manage_system"
android:textSize="30sp"
/>
android:textSize="30sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="15dp"
android:layout_marginHorizontal="10dp"
android:layout_marginVertical="15dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textSize="28sp"
android:text="@string/name"/>
android:text="@string/name"
android:textSize="28sp" />
<EditText
android:layout_marginStart="10dp"
android:id="@+id/P5AnimalNameInput"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="10dp"
android:hint="@string/animal_name_default"
android:maxLines="1"
android:inputType="text"
android:id="@+id/P5AnimalNameInput"/>
android:maxLines="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="280dp"
android:orientation="vertical"
android:layout_marginHorizontal="10dp"
android:layout_marginVertical="15dp"
android:layout_marginHorizontal="10dp">
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textSize="28sp"
android:text="@string/type"/>
android:text="@string/type"
android:textSize="28sp" />
<AutoCompleteTextView
android:layout_marginStart="10dp"
android:id="@+id/AnimalTypeAutoCompleteInput"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="10dp"
android:hint="@string/cat"
android:maxLines="1"
android:inputType="text"
android:id="@+id/AnimalTypeAutoCompleteInput"/>
android:maxLines="1" />
</LinearLayout>
<ListView
android:id="@+id/P5Suggestions"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginStart="65dp"
android:layout_marginEnd="5dp"
android:layout_marginTop="10dp"
android:layout_height="200dp" />
android:layout_marginEnd="5dp" />
</LinearLayout>
<Button
android:id="@+id/P5AddAnimalButton"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_marginVertical="20dp"
android:layout_marginHorizontal="15dp"
android:text="@string/add"
android:backgroundTint="#4FC3F7"/>
android:layout_marginVertical="20dp"
android:backgroundTint="#4FC3F7"
android:text="@string/add" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_marginHorizontal="15dp"
android:orientation="horizontal">
<Button
android:id="@+id/P5CleanDataButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginEnd="15dp"
android:backgroundTint="?colorTertiary"
android:text="@string/clean_data"/>
android:text="@string/clean_data" />
<Button
android:id="@+id/P5QueryButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginEnd="15dp"
android:backgroundTint="?colorSecondary"
android:text="@string/query"/>
android:text="@string/query" />
<Button
android:id="@+id/P5NextPage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="15dp"
android:backgroundTint="#0091EA"
android:text="@string/next_page"/>
android:text="@string/next_page" />
</LinearLayout>
@ -118,38 +128,38 @@
android:id="@+id/P5Flyout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginVertical="50dp"
android:layout_marginHorizontal="20dp"
android:layout_marginVertical="50dp"
android:background="@drawable/p5_flyout_layout"
android:visibility="gone">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
>
android:layout_weight="1">
<TextView
android:id="@+id/P5QueryResult"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="monospace"
android:textSize="25sp"
/>
android:textSize="25sp" />
</ScrollView>
<Button
android:id="@+id/P5CloseQueryButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="30dp"
android:layout_marginVertical="10dp"
android:backgroundTint="#FFF59D"
android:text="@string/close"
android:layout_marginVertical="10dp"
android:layout_marginHorizontal="30dp"
android:textColor="@color/black"
/>
android:textColor="@color/black" />
</LinearLayout>
</FrameLayout>

View file

@ -1,11 +1,11 @@
<?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=".Page6">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -18,13 +18,13 @@
android:layout_marginTop="50dp"
android:minHeight="30dp"
android:text="@string/neko_no_d"
android:textSize="35sp"
/>
android:textSize="35sp" />
<androidx.viewpager.widget.ViewPager
android:id="@+id/P6_vp_content"
android:layout_width="match_parent"
android:layout_marginTop="5dp"
android:layout_height="450dp"/>
android:layout_height="450dp"
android:layout_marginTop="5dp" />
<LinearLayout
android:layout_width="match_parent"
@ -38,21 +38,23 @@
android:layout_height="match_parent"
android:layout_marginEnd="15dp"
android:backgroundTint="?colorSecondary"
android:text="@string/auto_show"/>
android:text="@string/auto_show" />
<Button
android:id="@+id/P6SetWorkButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginEnd="15dp"
android:backgroundTint="?colorTertiary"
android:text="@string/add_work"/>
android:text="@string/add_work" />
<Button
android:id="@+id/P6NextPage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="15dp"
android:backgroundTint="?colorPrimary"
android:text="@string/next_page"/>
android:text="@string/next_page" />
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -1,136 +1,169 @@
<?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=".Page7">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginVertical="20dp"
android:layout_marginHorizontal="5dp"
android:layout_marginVertical="20dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginHorizontal="15dp"
android:layout_marginVertical="5dp"
>
android:layout_marginVertical="5dp">
<EditText
android:id="@+id/P7SendMessageText"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:inputType="text"
android:text="Text Message"
android:hint="Text Message"
/>
android:layout_weight="1"
android:hint="@string/text_message"
android:inputType="text" />
<Button
android:id="@+id/P7SendMessageButton"
android:layout_width="80dp"
android:layout_height="match_parent"
android:text="@string/send_text"
android:textAllCaps="false"
/>
android:textAllCaps="false" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginHorizontal="15dp"
android:layout_marginVertical="5dp"
>
android:layout_marginVertical="5dp">
<Button
android:id="@+id/P7RecordAudio"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:text="@string/record_audio"
android:textAllCaps="false"
android:layout_weight="1"
android:backgroundTint="?colorTertiary"
/>
android:text="@string/record_audio"
android:textAllCaps="false" />
<Button
android:id="@+id/P7ListenAudio"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:text="@string/play"
android:textAllCaps="false"
android:layout_marginHorizontal="10dp"
android:layout_weight="1"
android:backgroundTint="?colorSecondary"
android:enabled="false"
/>
android:text="@string/play"
android:textAllCaps="false" />
<Button
android:id="@+id/P7SendAudio"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/send"
android:textAllCaps="false"
/>
android:textAllCaps="false" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginHorizontal="15dp"
android:layout_marginVertical="5dp"
>
android:layout_marginVertical="5dp">
<Button
android:id="@+id/P7ShotPhoto"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:backgroundTint="?colorTertiary"
android:text="@string/take_photo"
android:textAllCaps="false" />
<Button
android:id="@+id/P7ViewPhoto"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginHorizontal="10dp"
android:layout_weight="1"
android:backgroundTint="?colorSecondary"
android:enabled="false"
android:text="@string/show"
android:textAllCaps="false" />
<Button
android:id="@+id/P7SendPhoto"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/send"
android:textAllCaps="false" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_marginHorizontal="15dp"
android:layout_marginVertical="5dp">
<Button
android:id="@+id/P7SetAPI"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:text="@string/settings"
/>
android:layout_weight="1"
android:text="@string/settings" />
<Button
android:id="@+id/P7ShowResult"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_marginHorizontal="15dp"
android:layout_height="match_parent"
android:textAllCaps="false"
android:layout_marginHorizontal="15dp"
android:layout_weight="1"
android:text="@string/show_callback"
/>
android:textAllCaps="false" />
<Button
android:id="@+id/P7NextPage"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:text="@string/next_page"
/>
android:layout_weight="1"
android:text="@string/next_page" />
</LinearLayout>
</LinearLayout>
<FrameLayout
android:id="@+id/P7ResultFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/P7ResultFrame"
android:layout_marginHorizontal="10dp"
android:layout_marginVertical="25dp"
android:visibility="invisible"
android:background="@drawable/p7_result_layout"
>
android:visibility="invisible">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:textSize="40sp"
android:text="@string/result"/>
android:layout_weight="1"
android:text="@string/result"
android:textSize="40sp" />
<ImageButton
android:id="@+id/P7CloseResultButton"
@ -146,45 +179,48 @@
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginHorizontal="5dp">
android:layout_marginHorizontal="5dp"
android:layout_weight="1">
<TextView
android:id="@+id/P7Result"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="22sp"
android:fontFamily="monospace"
android:minHeight="50dp"
android:text=""/>
android:text=""
android:textSize="22sp" />
</ScrollView>
</LinearLayout>
</FrameLayout>
<FrameLayout
android:id="@+id/P7SetAPIFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/P7SetAPIFrame"
android:layout_marginHorizontal="10dp"
android:layout_marginVertical="120dp"
android:background="@drawable/p7_result_layout"
android:visibility="invisible"
>
android:visibility="invisible">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:textSize="40sp"
android:text="@string/settings"/>
android:layout_weight="1"
android:text="@string/settings"
android:textSize="40sp" />
<ImageButton
android:id="@+id/P7CloseAPIButton"
@ -200,55 +236,57 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="30sp"
android:layout_marginLeft="5dp"
android:text="@string/bot_api_key"/>
android:text="@string/bot_api_key"
android:textSize="30sp" />
<EditText
android:id="@+id/Page7BotID"
android:layout_width="match_parent"
android:layout_height="60dp"
android:ems="10"
android:importantForAutofill="no"
android:inputType="textPassword"
android:layout_marginHorizontal="20dp"
android:layout_marginBottom="15dp"
android:ems="10"
android:hint="@string/test_api_key"
/>
android:importantForAutofill="no"
android:inputType="textPassword" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:textSize="30sp"
android:text="@string/chat_id"/>
android:text="@string/chat_id"
android:textSize="30sp" />
<EditText
android:id="@+id/Page7ChatID"
android:layout_width="match_parent"
android:layout_height="60dp"
android:ems="10"
android:importantForAutofill="no"
android:inputType="numberSigned"
android:layout_marginHorizontal="20dp"
android:layout_marginBottom="15dp"
android:ems="10"
android:hint="@string/_123456"
/>
android:importantForAutofill="no"
android:inputType="numberSigned" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:orientation="horizontal">
<Button
android:id="@+id/P7SaveAndSetAPI"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/save_and_test"
android:textAllCaps="false"
/>
android:textAllCaps="false" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -1,37 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SettingPage"
>
tools:context=".SettingPage">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="serif-monospace"
android:text="@string/settings"
android:textSize="45sp"
android:fontFamily="serif-monospace"/>
android:textSize="45sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginVertical="15dp"
android:layout_marginHorizontal="20sp"
android:layout_marginVertical="15dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/set_default_theme"
android:textSize="30sp"/>
android:textSize="30sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -85,19 +85,17 @@
</LinearLayout>
</LinearLayout>
<Button
android:id="@+id/SettingPageSubmit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/finish_button"
android:textSize="35sp"
android:textAllCaps="false"
android:layout_marginBottom="20dp"
android:layout_marginHorizontal="60sp"
/>
android:layout_marginBottom="20dp"
android:text="@string/finish_button"
android:textAllCaps="false"
android:textSize="35sp" />
</LinearLayout>

View file

@ -3,7 +3,7 @@
<style name="Theme.Android101" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/tfb</item>
<item name="colorPrimaryVariant">@color/tfp </item>
<item name="colorPrimaryVariant">@color/tfp</item>
<item name="colorOnPrimary">@color/black</item>
<!-- Secondary brand color. -->
<!-- Status bar color. -->

View file

@ -63,4 +63,10 @@
<string name="record_audio">录音</string>
<string name="send">发送</string>
<string name="play">播放</string>
<string name="show">查看图片</string>
<string name="take_photo">拍照</string>
<string name="use">使用</string>
<string name="shot">拍照</string>
<string name="retake">重拍</string>
<string name="text_message">这是文本消息喵</string>
</resources>

View file

@ -65,4 +65,10 @@
<string name="record_audio">Record Audio</string>
<string name="send">Send</string>
<string name="play">Play</string>
<string name="show">Show</string>
<string name="take_photo">Take Photo</string>
<string name="use">Use</string>
<string name="shot">Shot</string>
<string name="retake">Retake</string>
<string name="text_message">Text Message</string>
</resources>

View file

@ -11,9 +11,10 @@
<item name="android:statusBarColor">#0D47A1</item>
<!-- Customize your theme here. -->
</style>
<style name="Theme.TODOList" parent="android:Theme.Material.Light.NoActionBar" />
<!-- Base application theme. -->
<style name="Base.Theme.TODOList" parent="Theme.Material3.DayNight.NoActionBar"/>
<style name="Base.Theme.TODOList" parent="Theme.Material3.DayNight.NoActionBar" />
<style name="Theme.Blue" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="colorPrimary">#039BE5</item>
@ -34,6 +35,7 @@
<item name="overlapAnchor">false</item>
<item name="android:dropDownVerticalOffset">?attr/actionBarSize</item>
</style>
<style name="Theme.Red" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="colorPrimary">#E57373</item>
<item name="colorSecondary">#e573ac</item>
@ -43,6 +45,7 @@
<item name="overlapAnchor">false</item>
<item name="android:dropDownVerticalOffset">?attr/actionBarSize</item>
</style>
<style name="Theme.Cyan" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="colorPrimary">#00ACC1</item>
<item name="colorSecondary">#00c177</item>
@ -52,6 +55,7 @@
<item name="overlapAnchor">false</item>
<item name="android:dropDownVerticalOffset">?attr/actionBarSize</item>
</style>
<style name="Theme.Pink" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="colorPrimary">#FF80AB</item>
<item name="colorSecondary">#ff80ea</item>

View file

@ -1,15 +1,15 @@
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:shortcutId="start_TODO"
android:enabled="true"
android:icon="@drawable/ic_launcher_todo"
android:shortcutShortLabel="@string/todo_app_short_label"
android:shortcutDisabledMessage="@string/todo_app"
android:shortcutId="start_TODO"
android:shortcutLongLabel="@string/todo_app"
android:shortcutDisabledMessage="@string/todo_app">
android:shortcutShortLabel="@string/todo_app_short_label">
<intent
android:action="android.intent.action.VIEW"
android:targetPackage="uk.kagurach.android101"
android:targetClass="uk.kagurach.android101.todoList.TodoListMainActivity" />
android:targetClass="uk.kagurach.android101.todoList.TodoListMainActivity"
android:targetPackage="uk.kagurach.android101" />
<categories android:name="android.shortcut.conversation" />
<capability-binding android:key="actions.intent.CREATE_MESSAGE" />
</shortcut>

View file

@ -1,9 +1,8 @@
package uk.kagurach.android101
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*

View file

@ -8,23 +8,25 @@ junitVersion = "1.2.1"
espressoCore = "3.6.1"
appcompat = "1.7.0"
material = "1.12.0"
activity = "1.9.0"
activity = "1.9.1"
constraintlayout = "2.1.4"
lifecycleRuntimeKtx = "2.8.3"
activityCompose = "1.9.0"
lifecycleRuntimeKtx = "2.8.4"
activityCompose = "1.9.1"
composeBom = "2024.06.00"
roomCommon = "2.6.1"
roomKtx = "2.6.1"
navigationFragmentKtx = "2.7.7"
navigationUiKtx = "2.7.7"
annotation = "1.8.0"
lifecycleLivedataKtx = "2.8.3"
lifecycleViewmodelKtx = "2.8.3"
annotation = "1.8.1"
lifecycleLivedataKtx = "2.8.4"
lifecycleViewmodelKtx = "2.8.4"
datastoreRxjava3 = "1.1.1"
androidxWork = "2.9.0"
okHttp3 = "4.9.3"
moshiJson = "1.15.1"
ffmpegKit = "6.0-2"
cameraX = "1.3.4"
cameraView = "1.3.4"
[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@ -55,6 +57,10 @@ androidx-lifecycle-livedata-ktx = { group = "androidx.lifecycle", name = "lifecy
androidx-lifecycle-viewmodel-ktx = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-ktx", version.ref = "lifecycleViewmodelKtx" }
androidx-datastore-rxjava3 = { group = "androidx.datastore", name = "datastore-rxjava3", version.ref = "datastoreRxjava3" }
androidx-work = { group = "androidx.work", name="work-runtime", version.ref = "androidxWork" }
androidx-camera-core = { group = "androidx.camera",name = "camera-core",version.ref="cameraX"}
androidx-camera-camera2 = { group = "androidx.camera",name = "camera-camera2",version.ref="cameraX"}
androidx-camera-lifecycle = { group = "androidx.camera",name = "camera-lifecycle",version.ref="cameraX"}
androidx-camera-view = { group = "androidx.camera",name="camera-view",version.ref="cameraView"}
okhttp3 = { group = "com.squareup.okhttp3", name="okhttp",version.ref="okHttp3"}
moshi = {group="com.squareup.moshi",name="moshi-kotlin",version.ref="moshiJson"}