Stage Last Version

This commit is contained in:
icewithcola 2024-06-02 12:53:54 +08:00
parent 2418dfcac2
commit 35fae8019f
10 changed files with 62 additions and 16 deletions

View file

@ -13,6 +13,9 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Android101">
<activity
android:name=".baoleme.BaolemaMainActivity"
android:exported="false" />
<activity
android:name=".SettingPage"
android:exported="false" />

View file

@ -80,17 +80,22 @@ public class Page5 extends KaBaseActivity {
TextView name = findViewById(R.id.P5AnimalNameInput);
AutoCompleteTextView type = findViewById(R.id.AnimalTypeAutoCompleteInput);
if (name.getText().toString().isEmpty()||type.getText().toString().isEmpty()){
String animal_name = name.getText().toString();
String animal_type = type.getText().toString();
if (animal_name.isEmpty()||animal_type.isEmpty()){
ToastHelper.SmartToast.ShowToast("Please input all fields",v.getContext());
return;
}
// Add to database
if (dbHelper.insertAnimalData(name.getText().toString(), type.getText().toString().replace(" ","_"))) {
if (dbHelper.insertAnimalData(animal_name, animal_type.replace(" ","_"))) {
// Insert was successful
ToastHelper.SmartToast.ShowToast( "Animal added successfully!",v.getContext());
} else {
// Name already exists
ToastHelper.SmartToast.ShowToast( "Animal with this name already exists!",v.getContext());
return;
}
try {
completeHelper.AddEntry(type.getText().toString());

View file

@ -3,24 +3,14 @@ package uk.kagurach.android101
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.ImageButton
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.core.intPreferencesKey
import androidx.datastore.preferences.preferencesDataStore
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.runBlocking
import uk.kagurach.android101.databinding.ActivitySettingPageBinding
import uk.kagurach.android101.helper.ColorHelper
val Context.datastore by preferencesDataStore(name = "settings")
val DefaultColor = intPreferencesKey("default_color")

View file

@ -0,0 +1,22 @@
package uk.kagurach.android101.baoleme
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import uk.kagurach.android101.KaBaseActivity
import uk.kagurach.android101.R
class BaolemaMainActivity : KaBaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.baolema_main)
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
}
}
}

View file

@ -42,13 +42,20 @@ fun AIAnswerService(s: String): String {
}
result = result.replace(
"",
"",""
)
result = result.replace(
"要要",""
)
result = result.replace(
"",
if (rng.nextBoolean()) {
"可以"
} else {
"不可以"
}
)
result = result.replace("什么", "很多")
result = result.replace("", "")
result = result.replace("?", "")
@ -58,7 +65,7 @@ fun AIAnswerService(s: String): String {
}
fun main() {
println(AIAnswerService("我想吃饭"))
println(AIAnswerService("我想吃饭"))
println(AIAnswerService("咱可以吃饭吗"))
println(AIAnswerService("您可以做什么?"))
println(AIAnswerService("您吃了吗?"))

View file

@ -68,6 +68,13 @@ fun Kaculate(src: String, ctx: Context): String {
numStack[intStackCurr] = a.pow(b)
numStack = dropAtIdx(numStack, intStackCurr + 1)
}
var tmpStack = charArrayOf()
for(i in opStack){
if (i!='^'){
tmpStack += i
}
}
opStack = tmpStack
}
// x and /
var intStackCurr = 0

View file

@ -92,11 +92,11 @@
android:id="@+id/SettingPageSubmit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/finish"
android:text="@string/finish_button"
android:textSize="35sp"
android:textAllCaps="false"
android:layout_marginBottom="20dp"
android:layout_marginHorizontal="55sp"
android:layout_marginHorizontal="60sp"
/>
</LinearLayout>

View file

@ -0,0 +1,10 @@
<?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=".baoleme.BaolemaMainActivity">
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -45,4 +45,5 @@
<string name="font_size">字体\n大小</string>
<string name="p2_default_setting">Color = #000000; TextSize = 70.sp</string>
<string name="set_default_theme">设置默认主题</string>
<string name="finish_button">完成</string>
</resources>

View file

@ -45,4 +45,5 @@
<string name="font_size">Font\nSize</string>
<string name="p2_default_setting">Color = #000000; TextSize = 70.sp</string>
<string name="set_default_theme">Set Default Theme</string>
<string name="finish_button">Finish</string>
</resources>