1.5.7 New UI

This commit is contained in:
icewithcola 2024-06-01 10:55:56 +08:00
parent 90478c881d
commit 001975aab1
24 changed files with 656 additions and 173 deletions

View file

@ -11,8 +11,8 @@ android {
applicationId = "uk.kagurach.android101"
minSdk = 31
targetSdk = 34
versionCode = 155
versionName = "1.5.4"
versionCode = 157
versionName = "1.5.7"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
@ -68,7 +68,6 @@ dependencies {
implementation(libs.androidx.annotation)
implementation(libs.androidx.lifecycle.livedata.ktx)
implementation(libs.androidx.lifecycle.viewmodel.ktx)
implementation(libs.androidx.datastore.rxjava3)
testImplementation(libs.junit)

View file

@ -0,0 +1,93 @@
package chatgpt;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class AnimalDatabaseHelper extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "AnimalDatabase.db";
private static final int DATABASE_VERSION = 1;
private static final String TABLE_NAME = "AnimalData";
// Columns
private static final String COLUMN_ID = "_id";
private static final String COLUMN_NAME = "name";
private static final String COLUMN_TYPE = "type";
public AnimalDatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
String createTable = "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" +
COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, " +
COLUMN_NAME + " VARCHAR NOT NULL, " +
COLUMN_TYPE + " VARCHAR NOT NULL);";
db.execSQL(createTable);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
// Handle database upgrade as needed
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(db);
}
// Method to check if the name already exists
public boolean isNameExists(String name) {
SQLiteDatabase db = this.getReadableDatabase();
String query = "SELECT * FROM " + TABLE_NAME + " WHERE " + COLUMN_NAME + " = ?";
Cursor cursor = db.rawQuery(query, new String[]{name});
boolean exists = cursor.getCount() > 0;
cursor.close();
return exists;
}
// Method to insert new animal data if the name does not exist
public boolean insertAnimalData(String name, String type) {
if (!isNameExists(name)) {
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(COLUMN_NAME, name);
values.put(COLUMN_TYPE, type);
long result = db.insert(TABLE_NAME, null, values);
return result != -1; // Return true if insert is successful
} else {
return false; // Name already exists
}
}
// Method to clear the table
public void clearTable() {
SQLiteDatabase db = this.getWritableDatabase();
db.execSQL("DELETE FROM " + TABLE_NAME);
db.execSQL("VACUUM"); // Optional: Reclaims database space after delete
}
// Method to get all data as a formatted string
public String getAllDataAsString() {
SQLiteDatabase db = this.getReadableDatabase();
StringBuilder result = new StringBuilder();
String query = "SELECT " + COLUMN_NAME + ", " + COLUMN_TYPE + " FROM " + TABLE_NAME;
Cursor cursor = db.rawQuery(query, null);
int id = 1;
if (cursor.moveToFirst()) {
do {
String name = cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_NAME));
String type = cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_TYPE));
result.append(id++).append(": name:'").append(name).append("'@'").append(type).append("'\n");
} while (cursor.moveToNext());
}
cursor.close();
return result.toString();
}
}

View file

@ -107,7 +107,7 @@ public class MainActivity extends AppCompatActivity {
}
private final class LongClickHandler implements View.OnLongClickListener {
Context context;
final Context context;
LongClickHandler(Context ctx) {
context = ctx;

View file

@ -10,6 +10,9 @@ import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.activity.EdgeToEdge;
@ -23,6 +26,8 @@ public class MainActivity2 extends AppCompatActivity {
PageHelper pageHelper;
int _text_size = 70;
int _text_color = Color.rgb(0,0,0);
String _text_unit = "sp";
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -40,32 +45,49 @@ public class MainActivity2 extends AppCompatActivity {
@Override
protected void onResume() {
super.onResume();
Button button = findViewById(R.id.next_page_nav_2);
button.setOnClickListener(pageHelper.pageButtonHandler);
button.setOnLongClickListener(pageHelper.longClickHandler);
Button SettingButton = findViewById(R.id.P2OpenSettingsButton);
SettingButton.setOnClickListener(new SettingButtonHandler());
ImageButton CloseSettingButton = findViewById(R.id.P2SettingsCloseButton);
CloseSettingButton.setOnClickListener(new CloseSettingButtonHandler());
Button TestColorButton = findViewById(R.id.P2TestColorButton);
TestColorButton.setOnClickListener(new TestColorButtonHandler());
}
public void set70sp(View view) {
public void setUnit_sp(View view) {
TextView t = findViewById(R.id.test2strview);
t.setTextSize(TypedValue.COMPLEX_UNIT_SP, _text_size);
_text_unit = "sp";
updateCurrentSettingShower();
}
public void set70dp(View view) {
public void setUnit_dp(View view) {
TextView t = findViewById(R.id.test2strview);
t.setTextSize(TypedValue.COMPLEX_UNIT_DIP, _text_size);
_text_unit = "dp";
updateCurrentSettingShower();
}
public void set70px(View view) {
public void setUnit_px(View view) {
TextView t = findViewById(R.id.test2strview);
t.setTextSize(TypedValue.COMPLEX_UNIT_PX, _text_size);
_text_unit = "px";
updateCurrentSettingShower();
}
public void setColor(View view) {
TextView t = findViewById(R.id.test2strview);
EditText r_edit = findViewById(R.id.EditText_R);
EditText g_edit = findViewById(R.id.G);
EditText b_edit = findViewById(R.id.B);
EditText r_edit = findViewById(R.id.P2SetColorR);
EditText g_edit = findViewById(R.id.P2SetColorG);
EditText b_edit = findViewById(R.id.P2SetColorB);
int _r, _g, _b;
// Here we are testing toast
@ -87,12 +109,14 @@ public class MainActivity2 extends AppCompatActivity {
return;
}
if (_r >= 0 && _g >= 0 && _b >= 0 && _r <= 255 && _g <= 255 && _b <= 255) {
t.setTextColor(Color.rgb(_r, _g, _b));
_text_color = Color.rgb(_r, _g, _b);
t.setTextColor(_text_color);
} else {
ToastHelper.SmartToast.ShowToast(
"The color: R=" + _r + " G=" + _g + " B=" + _b + " is invalid!", this);
}
updateCurrentSettingShower();
}
public void setText(View view) {
@ -126,9 +150,75 @@ public class MainActivity2 extends AppCompatActivity {
sp.setText(size + "SP");
dp.setText(size + "DP");
px.setText(size + "PX");
updateCurrentSettingShower();
}
private void updateCurrentSettingShower(){
TextView tv = findViewById(R.id.P2SettingResult);
String sb = "Color = #" + Integer.toString(_text_color&0xffffff, 16) +
"; TextSize = " +
_text_size +
"." +
_text_unit;
tv.setText(sb);
}
class SettingButtonHandler implements View.OnClickListener{
@Override
public void onClick(View v) {
FrameLayout fl = findViewById(R.id.P2SettingPage);
fl.setVisibility(View.VISIBLE);
}
}
class CloseSettingButtonHandler implements View.OnClickListener{
@Override
public void onClick(View v) {
FrameLayout fl = findViewById(R.id.P2SettingPage);
fl.setVisibility(View.GONE);
}
}
class TestColorButtonHandler implements View.OnClickListener{
@Override
public void onClick(View v) {
ImageView imageView = findViewById(R.id.P2ColorShower);
int _test_color = 0;
EditText r_edit = findViewById(R.id.P2SetColorR);
EditText g_edit = findViewById(R.id.P2SetColorG);
EditText b_edit = findViewById(R.id.P2SetColorB);
int _r, _g, _b;
// Here we are testing toast
if (r_edit.getText().toString().isEmpty() ||
g_edit.getText().toString().isEmpty() ||
b_edit.getText().toString().isEmpty()) {
ToastHelper.SmartToast.ShowToast("""
Please input R,G,B within 0-255
请在大小选择下方输入0-255的RGB""",
v.getContext());
}
try {
_r = Integer.parseInt(r_edit.getText().toString());
_g = Integer.parseInt(g_edit.getText().toString());
_b = Integer.parseInt(b_edit.getText().toString());
} catch (NumberFormatException e) {
ToastHelper.SmartToast.ShowToast(e.toString(), v.getContext());
return;
}
if (_r >= 0 && _g >= 0 && _b >= 0 && _r <= 255 && _g <= 255 && _b <= 255) {
_test_color = Color.rgb(_r, _g, _b);
imageView.setBackgroundColor(_test_color);
} else {
ToastHelper.SmartToast.ShowToast(
"The color: R=" + _r + " G=" + _g + " B=" + _b + " is invalid!", v.getContext());
}
}
}
// Fix: hide keyboard
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {

View file

@ -24,7 +24,7 @@ import uk.kagurach.android101.vibrationBroadcastReceiver.vibrationBroadcastRecei
public class Page4 extends AppCompatActivity {
PageHelper pageHelper;
ActivityResultLauncher mLauncher;
ActivityResultLauncher<Intent> mLauncher;
long startTime = 0;
long endTime = 0;

View file

@ -1,6 +1,6 @@
package uk.kagurach.android101;
import static uk.kagurach.misc.AIAnswerServiceKt.AIAnswerService;
import static uk.kagurach.android101.misc.AIAnswerServiceKt.AIAnswerService;
import android.content.Intent;
import android.os.Bundle;

View file

@ -2,13 +2,13 @@ package uk.kagurach.android101;
import android.content.Context;
import android.os.Bundle;
import android.preference.Preference;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.activity.EdgeToEdge;
@ -16,17 +16,18 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.datastore.rxjava3.RxDataStore;
import java.io.IOException;
import java.util.Objects;
import chatgpt.AnimalDatabaseHelper;
import uk.kagurach.android101.misc.AutoCompleHelper.AnimalTypeAutoCompleteHelper;
public class Page5 extends AppCompatActivity {
AnimalTypeAutoCompleteHelper completeHelper = null;
RxDataStore<String> mDataStore = null;
final AnimalDatabaseHelper dbHelper = new AnimalDatabaseHelper(this);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -38,7 +39,6 @@ public class Page5 extends AppCompatActivity {
return insets;
});
// Set auto-suggestions for animals
AutoCompleteTextView autoCompleteTextView = findViewById(R.id.AnimalTypeAutoCompleteInput);
try {
@ -54,12 +54,19 @@ public class Page5 extends AppCompatActivity {
// Set Button Handler
Button P5AddAnimalButton = findViewById(R.id.P5AddAnimalButton);
P5AddAnimalButton.setOnClickListener(new AddAminalButtonHander());
P5AddAnimalButton.setOnClickListener(new AddAnimalButtonHandler());
Button P5CleanDataButton = findViewById(R.id.P5CleanDataButton);
P5CleanDataButton.setOnLongClickListener(new CleanButtonHandler());
Button P5CloseQueryButton = findViewById(R.id.P5CloseQueryButton);
P5CloseQueryButton.setOnClickListener(new P5CloseQueryButtonHandler());
Button P5QueryButton = findViewById(R.id.P5QueryButton);
P5QueryButton.setOnClickListener(new QueryButtonHandler());
}
class AddAminalButtonHander implements View.OnClickListener {
class AddAnimalButtonHandler implements View.OnClickListener {
@Override
public void onClick(View v) {
TextView name = findViewById(R.id.P5AnimalNameInput);
@ -69,6 +76,14 @@ public class Page5 extends AppCompatActivity {
ToastHelper.SmartToast.ShowToast("Please input all fields",v.getContext());
}
// Add to database
if (dbHelper.insertAnimalData(name.getText().toString(), type.getText().toString().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());
}
try {
completeHelper.AddEntry(type.getText().toString());
} catch (IOException e) {
@ -87,6 +102,51 @@ public class Page5 extends AppCompatActivity {
}
}
class CleanButtonHandler implements View.OnLongClickListener {
@Override
public boolean onLongClick(View v) {
AutoCompleteTextView _a = findViewById(R.id.AnimalTypeAutoCompleteInput);
try {
completeHelper.Clean();
} catch (IOException e) {
throw new RuntimeException(e);
}
_a.setAdapter(
completeHelper.GetArrayAdapter(
v.getContext(),android.R.layout.simple_list_item_1
));
ToastHelper.SmartToast.ShowToast("Cleaned Data",v.getContext());
// Clean DataBase
dbHelper.clearTable();
ToastHelper.SmartToast.ShowToast("Cleaned Database",v.getContext());
return true;
}
}
class P5CloseQueryButtonHandler implements View.OnClickListener{
@Override
public void onClick(View v) {
FrameLayout fl = findViewById(R.id.P5Flyout);
fl.setVisibility(View.GONE);
}
}
class QueryButtonHandler implements View.OnClickListener{
@Override
public void onClick(View v) {
String res = dbHelper.getAllDataAsString();
if (res.isEmpty()){
res = "No animals qwq";
}
TextView tv = findViewById(R.id.P5QueryResult);
tv.setText(res);
FrameLayout fl = findViewById(R.id.P5Flyout);
fl.setVisibility(View.VISIBLE);
}
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {

View file

@ -29,19 +29,32 @@ public class PageHelper {
_activity = activity;
}
void goPrev() {
void goPrev(){// Keep no parameter signature
goPrev(true);
}
void goPrev(boolean keepOneInstance) {
if (_prev == null) {
return;
}
Intent myIntent = new Intent(_curr, _prev);
if (keepOneInstance) {
myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // 仅保留一个实例
}
startActivity(_curr, myIntent, null);
}
void goNext() {
goNext(true);
}
void goNext(boolean keepOneInstance) {
if (_next == null) {
return;
}
Intent myIntent = new Intent(_curr, _next);
if (keepOneInstance) {
myIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
}
startActivity(_curr, myIntent, null);
}

View file

@ -1,4 +1,4 @@
package uk.kagurach.misc
package uk.kagurach.android101.misc
import java.time.Instant
import java.util.Date

View file

@ -38,14 +38,13 @@ public abstract class AbstractAutoCompleteHelper {
if (data == null) {
data = new ArrayList<>();
}else {
while (scanner.hasNextLine()){
data.add(scanner.nextLine());
}
// 去重
Set<String> set = new LinkedHashSet<>(data);
data = new ArrayList<>(set);
}
while (scanner.hasNextLine()){
data.add(scanner.nextLine());
}
}
public void Sync() throws IOException {
if (dataFile==null){
@ -74,4 +73,21 @@ public abstract class AbstractAutoCompleteHelper {
public abstract ArrayAdapter<String> GetArrayAdapter(
Context ctx, @LayoutRes int resource);
public void Clean() throws IOException {
if (dataFile!=null){
File _data = new File(dataFile);
if (!_data.isFile()){
_data.createNewFile();
}
if (!_data.canRead() || !_data.canWrite()){
throw new RuntimeException("File permission denied");
}
try (FileWriter fileWriter = new FileWriter(_data,false)) {
fileWriter.write("");
}catch (IOException e){
throw new IOException(e);
}
}
}
}

View file

@ -3,12 +3,10 @@ package uk.kagurach.android101.misc.AutoCompleHelper;
import android.content.Context;
import android.widget.ArrayAdapter;
import androidx.annotation.DrawableRes;
import androidx.annotation.LayoutRes;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
public class AnimalTypeAutoCompleteHelper extends AbstractAutoCompleteHelper {
public AnimalTypeAutoCompleteHelper(Context ctx) throws IOException {
@ -22,6 +20,7 @@ public class AnimalTypeAutoCompleteHelper extends AbstractAutoCompleteHelper {
if (!loaded){
throw new RuntimeException("Haven't loaded");
}
name = name.replace(" ","_");
if (data.contains(name)){
return;
}

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
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"/>
</vector>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<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"
android:right="20dp"
android:bottom="20dp"/>
</shape>

View file

@ -0,0 +1,9 @@
<!-- res/drawable/rounded_corner.xml -->
<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"
android:right="16dp"
android:bottom="16dp"/>
</shape>

View file

@ -1,6 +1,5 @@
<?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"
@ -12,11 +11,6 @@
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="35dp" />
<TextView
android:id="@+id/tv_hello"
android:layout_width="match_parent"
@ -32,8 +26,7 @@
android:layout_weight="1"
android:text="@string/next_page"
android:enabled="false"
android:backgroundTint="#81D4FA"
/>
android:backgroundTint="#4DB6AC" />

View file

@ -5,6 +5,7 @@
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:windowSoftInputMode="adjustResize"
tools:context=".MainActivity2">
@ -12,158 +13,299 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="35dp" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="350dp">
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:textSize="60sp"/>
android:textColor="#000000"
android:textSize="70sp"/>
</ScrollView>
<LinearLayout
<TextView
android:id="@+id/P2SettingResult"
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal">
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:textSize="20sp"
android:text="@string/p2_default_setting"/>
<LinearLayout
android:layout_width="80dp"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:id="@+id/P2SetTextSize"
android:layout_width="80dp"
android:layout_height="0dp"
android:layout_weight="1"
android:ems="10"
android:inputType="number"
android:hint="字体大小"
/>
<Button
android:id="@+id/Page2SetSize"
android:layout_width="80dp"
android:layout_height="5dp"
android:layout_weight="1"
android:onClick="setSize"
android:text="设置" />
</LinearLayout>
<Button
android:id="@+id/Page2SetSP"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:onClick="set70sp"
android:text="70sp" />
<Button
android:id="@+id/Page2SetDP"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:onClick="set70dp"
android:text="70dp" />
<Button
android:id="@+id/Page2SetPX"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:onClick="set70px"
android:text="70px" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="horizontal">
<EditText
android:id="@+id/EditText_R"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:ems="10"
android:inputType="number"
android:hint="R:0-255"
/>
<EditText
android:id="@+id/G"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:ems="10"
android:inputType="number"
android:hint="G:0-255"
/>
<EditText
android:id="@+id/B"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:ems="10"
android:inputType="number"
android:hint="B:0-255"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_height="wrap_content"
android:minHeight="140dp"
android:orientation="horizontal">
<EditText
android:id="@+id/Page2SetTestText"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:ems="10"
android:importantForAutofill="no"
android:inputType="text"
android:text="测试文本"
android:text="@string/test_str"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="25dp"
android:hint="@string/test_str"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginEnd="20dp"
android:orientation="vertical"
>
<Button
android:id="@+id/Page2SetTestTextButton"
android:layout_width="wrap_content"
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"
/>
<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"
/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
android:orientation="vertical"
android:layout_marginHorizontal="20dp"
>
<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:text="@string/font_size"
android:textSize="18sp"
android:layout_marginTop="18dp"/>
<Button
android:id="@+id/Page2SetColor"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@string/set_color"
android:onClick="setColor"/>
<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: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:text="70dp" />
<Button
android:id="@+id/Page2SetPX"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:onClick="setUnit_px"
android:text="70px"
tools:ignore="PxUsage" />
</LinearLayout>
<Button
android:id="@+id/next_page_nav_2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginBottom="20dp"
android:text="@string/two_way_page"
/>
</LinearLayout>
</LinearLayout>
<FrameLayout
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:background="@drawable/p2_settings_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_height="match_parent"
android:text="@string/settings"
android:layout_weight="1"
android:textSize="35sp"
android:textColor="#B71C1C"
/>
<ImageButton
android:id="@+id/P2SettingsCloseButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="2dp"
android:layout_marginEnd="2dp"
android:background="@drawable/close_24"
android:contentDescription="@string/close" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
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"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
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"
/>
<EditText
android:id="@+id/P2SetColorG"
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_g_range"
android:layout_marginHorizontal="20dp"
/>
<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"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:layout_marginTop="5dp"
android:layout_marginStart="10dp">
<ImageView
android:id="@+id/P2ColorShower"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginVertical="15dp"
android:background="@color/black"
android:contentDescription="@string/add" />
<Button
android:id="@+id/P2TestColorButton"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginStart="45dp"
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_weight="1"
android:text="@string/set_color"
android:textAllCaps="false"
android:onClick="setColor"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
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"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="horizontal"
android:layout_marginTop="5dp"
>
<EditText
android:id="@+id/P2SetTextSize"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:ems="10"
android:inputType="number"
android:hint="设置字体大小"
/>
<Button
android:id="@+id/Page2SetSize"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="30dp"
android:layout_weight="1"
android:onClick="setSize"
android:textAllCaps="false"
android:text="@string/set" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -1,6 +1,5 @@
<?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"
@ -9,12 +8,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="35dp" />
android:orientation="vertical">
<TextView
android:id="@+id/P3CalcName"
android:layout_width="match_parent"

View file

@ -1,6 +1,5 @@
<?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"
@ -10,11 +9,8 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<View
android:layout_width="match_parent"
android:layout_height="50dp" />
android:layout_marginTop="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -25,6 +21,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="35sp"
android:layout_marginStart="10dp"
android:id="@+id/P4Ask"
android:importantForAutofill="no"
android:text="@string/AI_ASK_DEFAULT_STRING"
@ -43,7 +40,8 @@
<ScrollView
android:layout_width="match_parent"
android:layout_height="300dp">
android:layout_height="350dp"
android:layout_marginStart="10dp">
<TextView
android:layout_width="match_parent"
android:textSize="35sp"
@ -60,25 +58,31 @@
android:text="@string/ai_ready"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="130dp"
android:layout_marginHorizontal="5dp"
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"
/>
<Button
android:layout_width="140dp"
android:layout_width="120dp"
android:layout_marginVertical="20dp"
android:layout_marginHorizontal="10dp"
android:layout_height="match_parent"
android:id="@+id/P4Vibrate"
android:backgroundTint="#7E57C2"
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"

View file

@ -1,6 +1,5 @@
<?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"
@ -12,15 +11,13 @@
android:layout_height="match_parent"
android:orientation="vertical"
>
<View
android:layout_width="match_parent"
android:layout_height="50dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="10dp"
android:layout_marginTop="15dp"
android:background="#E0F7FA"
android:text="@string/animal_manage_system_n_kv_backend"
android:text="@string/animal_manage_system"
android:textSize="30sp"
/>
@ -41,6 +38,7 @@
android:layout_height="match_parent"
android:hint="@string/animal_name_default"
android:maxLines="1"
android:inputType="text"
android:id="@+id/P5AnimalNameInput"/>
</LinearLayout>
<LinearLayout
@ -64,6 +62,7 @@
android:layout_height="match_parent"
android:hint="@string/cat"
android:maxLines="1"
android:inputType="text"
android:id="@+id/AnimalTypeAutoCompleteInput"/>
</LinearLayout>
@ -86,7 +85,6 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_marginVertical="20dp"
android:layout_marginHorizontal="15dp"
android:orientation="horizontal">
<Button
@ -115,6 +113,45 @@
</LinearLayout>
<FrameLayout
android:id="@+id/P5Flyout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginVertical="50dp"
android:layout_marginHorizontal="20dp"
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"
>
<TextView
android:id="@+id/P5QueryResult"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="monospace"
android:textSize="25sp"
/>
</ScrollView>
<Button
android:id="@+id/P5CloseQueryButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#FFF59D"
android:text="@string/close"
android:layout_marginVertical="10dp"
android:layout_marginHorizontal="30dp"
android:textColor="@color/black"
/>
</LinearLayout>
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -1,4 +1,4 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<resources>
<!-- Base application theme. -->
<style name="Theme.Android101" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->

View file

@ -17,7 +17,7 @@
<string name="ai_ready">AI 准备好了</string>
<string name="AI_ASK_DEFAULT_STRING">你吃了吗?</string>
<string name="vibrate">振动手机</string>
<string name="animal_manage_system_n_kv_backend">动物管理系统\n当前后端: KV对</string>
<string name="animal_manage_system">动物管理系统\n当前后端: SQLite</string>
<string name="name">姓名</string>
<string name="animal_name_default">可爱喵</string>
<string name="type">类型</string>
@ -35,4 +35,13 @@
<string name="kaculate">弱智计算器</string>
<string name="Backspace">退格</string>
<string name="query">查询</string>
<string name="close">关闭</string>
<string name="settings">设置</string>
<string name="test_color">测试颜色</string>
<string name="rgb_r_range">R:0-255</string>
<string name="rgb_g_range">G:0-255</string>
<string name="rgb_b_range">B:0-255</string>
<string name="set_per_unit_font_size">设置每个单位的字体大小</string>
<string name="font_size">字体大小</string>
<string name="p2_default_setting">Color = #ffffff; TextSize = 70.sp</string>
</resources>

View file

@ -19,7 +19,7 @@
<string name="ai_ready">AI Ready</string>
<string name="AI_ASK_DEFAULT_STRING">你吃了吗?</string>
<string name="vibrate">Vibrate</string>
<string name="animal_manage_system_n_kv_backend">Animal Manage System\nCurrent Backend: KV Pair</string>
<string name="animal_manage_system">Animal Manage System\nCurrent Backend: SQLite</string>
<string name="name">Name</string>
<string name="animal_name_default">NachoNeko</string>
<string name="type">Type</string>
@ -35,4 +35,13 @@
<string name="set_color">Set Color</string>
<string name="set">Set</string>
<string name="setText">Set Text</string>
<string name="close">close</string>
<string name="settings">Settings</string>
<string name="test_color">Test color</string>
<string name="rgb_r_range">R:0-255</string>
<string name="rgb_g_range">G:0-255</string>
<string name="rgb_b_range">B:0-255</string>
<string name="set_per_unit_font_size">Set per unit font size</string>
<string name="font_size">Font Size:</string>
<string name="p2_default_setting">Color = #ffffff; TextSize = 70.sp</string>
</resources>

View file

@ -1,8 +1,8 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<resources>
<!-- Base application theme. -->
<style name="Theme.Android101" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">#3D5AFE</item>
<item name="colorPrimary">#039BE5</item>
<item name="colorPrimaryVariant">#D500F9</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->

View file

@ -19,7 +19,6 @@ navigationUiKtx = "2.7.7"
annotation = "1.8.0"
lifecycleLivedataKtx = "2.8.1"
lifecycleViewmodelKtx = "2.8.1"
datastoreRxjava3 = "1.1.1"
[libraries]
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@ -47,7 +46,6 @@ androidx-navigation-ui-ktx = { group = "androidx.navigation", name = "navigation
androidx-annotation = { group = "androidx.annotation", name = "annotation", version.ref = "annotation" }
androidx-lifecycle-livedata-ktx = { group = "androidx.lifecycle", name = "lifecycle-livedata-ktx", version.ref = "lifecycleLivedataKtx" }
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" }
[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }