Stage Last Version
This commit is contained in:
parent
2418dfcac2
commit
35fae8019f
10 changed files with 62 additions and 16 deletions
|
@ -13,6 +13,9 @@
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.Android101">
|
android:theme="@style/Theme.Android101">
|
||||||
|
<activity
|
||||||
|
android:name=".baoleme.BaolemaMainActivity"
|
||||||
|
android:exported="false" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".SettingPage"
|
android:name=".SettingPage"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
|
|
@ -80,17 +80,22 @@ public class Page5 extends KaBaseActivity {
|
||||||
TextView name = findViewById(R.id.P5AnimalNameInput);
|
TextView name = findViewById(R.id.P5AnimalNameInput);
|
||||||
AutoCompleteTextView type = findViewById(R.id.AnimalTypeAutoCompleteInput);
|
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());
|
ToastHelper.SmartToast.ShowToast("Please input all fields",v.getContext());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add to database
|
// Add to database
|
||||||
if (dbHelper.insertAnimalData(name.getText().toString(), type.getText().toString().replace(" ","_"))) {
|
if (dbHelper.insertAnimalData(animal_name, animal_type.replace(" ","_"))) {
|
||||||
// Insert was successful
|
// Insert was successful
|
||||||
ToastHelper.SmartToast.ShowToast( "Animal added successfully!",v.getContext());
|
ToastHelper.SmartToast.ShowToast( "Animal added successfully!",v.getContext());
|
||||||
} else {
|
} else {
|
||||||
// Name already exists
|
// Name already exists
|
||||||
ToastHelper.SmartToast.ShowToast( "Animal with this name already exists!",v.getContext());
|
ToastHelper.SmartToast.ShowToast( "Animal with this name already exists!",v.getContext());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
completeHelper.AddEntry(type.getText().toString());
|
completeHelper.AddEntry(type.getText().toString());
|
||||||
|
|
|
@ -3,24 +3,14 @@ package uk.kagurach.android101
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
|
||||||
import android.view.View
|
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.ViewCompat
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import androidx.datastore.preferences.core.edit
|
|
||||||
import androidx.datastore.preferences.core.intPreferencesKey
|
import androidx.datastore.preferences.core.intPreferencesKey
|
||||||
import androidx.datastore.preferences.preferencesDataStore
|
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 kotlinx.coroutines.runBlocking
|
||||||
import uk.kagurach.android101.databinding.ActivitySettingPageBinding
|
import uk.kagurach.android101.databinding.ActivitySettingPageBinding
|
||||||
|
|
||||||
import uk.kagurach.android101.helper.ColorHelper
|
|
||||||
|
|
||||||
val Context.datastore by preferencesDataStore(name = "settings")
|
val Context.datastore by preferencesDataStore(name = "settings")
|
||||||
val DefaultColor = intPreferencesKey("default_color")
|
val DefaultColor = intPreferencesKey("default_color")
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -42,13 +42,20 @@ fun AIAnswerService(s: String): String {
|
||||||
}
|
}
|
||||||
|
|
||||||
result = result.replace(
|
result = result.replace(
|
||||||
"想",
|
"想","要"
|
||||||
|
)
|
||||||
|
result = result.replace(
|
||||||
|
"要要","要"
|
||||||
|
)
|
||||||
|
result = result.replace(
|
||||||
|
"要",
|
||||||
if (rng.nextBoolean()) {
|
if (rng.nextBoolean()) {
|
||||||
"可以"
|
"可以"
|
||||||
} else {
|
} else {
|
||||||
"不可以"
|
"不可以"
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
result = result.replace("什么", "很多")
|
result = result.replace("什么", "很多")
|
||||||
result = result.replace("吗", "")
|
result = result.replace("吗", "")
|
||||||
result = result.replace("?", "。")
|
result = result.replace("?", "。")
|
||||||
|
@ -58,7 +65,7 @@ fun AIAnswerService(s: String): String {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
println(AIAnswerService("我想吃饭"))
|
println(AIAnswerService("我想要吃饭"))
|
||||||
println(AIAnswerService("咱可以吃饭吗"))
|
println(AIAnswerService("咱可以吃饭吗"))
|
||||||
println(AIAnswerService("您可以做什么?"))
|
println(AIAnswerService("您可以做什么?"))
|
||||||
println(AIAnswerService("您吃了吗?"))
|
println(AIAnswerService("您吃了吗?"))
|
||||||
|
|
|
@ -68,6 +68,13 @@ fun Kaculate(src: String, ctx: Context): String {
|
||||||
numStack[intStackCurr] = a.pow(b)
|
numStack[intStackCurr] = a.pow(b)
|
||||||
numStack = dropAtIdx(numStack, intStackCurr + 1)
|
numStack = dropAtIdx(numStack, intStackCurr + 1)
|
||||||
}
|
}
|
||||||
|
var tmpStack = charArrayOf()
|
||||||
|
for(i in opStack){
|
||||||
|
if (i!='^'){
|
||||||
|
tmpStack += i
|
||||||
|
}
|
||||||
|
}
|
||||||
|
opStack = tmpStack
|
||||||
}
|
}
|
||||||
// x and /
|
// x and /
|
||||||
var intStackCurr = 0
|
var intStackCurr = 0
|
||||||
|
|
|
@ -92,11 +92,11 @@
|
||||||
android:id="@+id/SettingPageSubmit"
|
android:id="@+id/SettingPageSubmit"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/finish"
|
android:text="@string/finish_button"
|
||||||
android:textSize="35sp"
|
android:textSize="35sp"
|
||||||
android:textAllCaps="false"
|
android:textAllCaps="false"
|
||||||
android:layout_marginBottom="20dp"
|
android:layout_marginBottom="20dp"
|
||||||
android:layout_marginHorizontal="55sp"
|
android:layout_marginHorizontal="60sp"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
10
app/src/main/res/layout/baolema_main.xml
Normal file
10
app/src/main/res/layout/baolema_main.xml
Normal 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>
|
|
@ -45,4 +45,5 @@
|
||||||
<string name="font_size">字体\n大小</string>
|
<string name="font_size">字体\n大小</string>
|
||||||
<string name="p2_default_setting">Color = #000000; TextSize = 70.sp</string>
|
<string name="p2_default_setting">Color = #000000; TextSize = 70.sp</string>
|
||||||
<string name="set_default_theme">设置默认主题</string>
|
<string name="set_default_theme">设置默认主题</string>
|
||||||
|
<string name="finish_button">完成</string>
|
||||||
</resources>
|
</resources>
|
|
@ -45,4 +45,5 @@
|
||||||
<string name="font_size">Font\nSize</string>
|
<string name="font_size">Font\nSize</string>
|
||||||
<string name="p2_default_setting">Color = #000000; TextSize = 70.sp</string>
|
<string name="p2_default_setting">Color = #000000; TextSize = 70.sp</string>
|
||||||
<string name="set_default_theme">Set Default Theme</string>
|
<string name="set_default_theme">Set Default Theme</string>
|
||||||
|
<string name="finish_button">Finish</string>
|
||||||
</resources>
|
</resources>
|
Loading…
Reference in a new issue