Clean up unused code and fix profile selection

- Removed unused UserProfile.kt, ApiModels.kt
- Fixed profile checkmark showing for all profiles (using lambda)
- Increased text bubble width to 350dp
- Auto-scroll to beginning of AI messages
- Auto-select profile on creation
- Model selection persists across restarts
- Removed null-unsafe !! operators
- Added Russian language support for UI strings
This commit is contained in:
Алексей Будаев 2026-04-06 20:14:32 +08:00
parent a5fe4bc29e
commit 21505aae75
10 changed files with 1070 additions and 332 deletions

View file

@ -1,135 +1,172 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
<androidx.drawerlayout.widget.DrawerLayout
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/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".ui.MainActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingStart="16dp"
android:paddingEnd="16dp">
<ImageView
android:id="@+id/logoButton"
android:layout_width="36dp"
android:layout_height="36dp"
android:src="@drawable/ic_mistral_logo"
android:contentDescription="@string/select_model"
android:clickable="true"
android:focusable="true" />
<TextView
android:id="@+id/toolbarTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="12dp"
android:text="Le Chat"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="?attr/colorOnSurface" />
<ImageButton
android:id="@+id/menuButton"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_menu_dots"
android:contentDescription="@string/settings"
android:clickable="true"
android:focusable="true" />
</LinearLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/inputContainer"
android:layout_below="@+id/appBarLayout"
android:padding="16dp"
android:clipToPadding="false" />
<LinearLayout
android:id="@+id/inputContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:background="?attr/colorSurface"
android:padding="16dp">
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/progressIndicator"
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true"
android:visibility="gone"
android:layout_marginBottom="8dp" />
<com.google.android.material.card.MaterialCardView
android:id="@+id/inputCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="16dp"
app:cardElevation="2dp">
android:layout_alignParentTop="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_height="?attr/actionBarSize"
android:orientation="horizontal"
android:gravity="center_vertical"
android:paddingStart="4dp"
android:paddingEnd="0dp"
android:paddingTop="4dp"
android:paddingBottom="4dp">
android:paddingEnd="16dp">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/inputField"
<ImageButton
android:id="@+id/hamburgerButton"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_menu_hamburger"
android:contentDescription="@string/settings"
android:clickable="true"
android:focusable="true" />
<ImageView
android:id="@+id/logoButton"
android:layout_width="36dp"
android:layout_height="36dp"
android:src="@drawable/ic_mistral_logo"
android:contentDescription="@string/select_model"
android:clickable="true"
android:focusable="true" />
<TextView
android:id="@+id/toolbarTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@android:color/transparent"
android:hint="@string/enter_message"
android:imeOptions="actionSend"
android:inputType="textMultiLine"
android:maxLines="5"
android:minHeight="56dp"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:paddingTop="12dp"
android:paddingBottom="12dp" />
android:layout_marginStart="12dp"
android:text="Le Chat"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="?attr/colorOnSurface" />
<ImageView
android:id="@+id/sendButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="8dp"
android:src="@drawable/ic_mistral_logo"
android:background="@drawable/bg_send_button"
android:contentDescription="@string/send"
<ImageButton
android:id="@+id/menuButton"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_menu_dots"
android:contentDescription="@string/settings"
android:clickable="true"
android:focusable="true" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</com.google.android.material.appbar.AppBarLayout>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/inputContainer"
android:layout_below="@+id/appBarLayout"
android:padding="16dp"
android:clipToPadding="false" />
</RelativeLayout>
<LinearLayout
android:id="@+id/inputContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:background="?attr/colorSurface"
android:padding="16dp">
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/progressIndicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true"
android:visibility="gone"
android:layout_marginBottom="8dp" />
<com.google.android.material.card.MaterialCardView
android:id="@+id/inputCard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="16dp"
app:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="4dp"
android:paddingEnd="0dp"
android:paddingTop="4dp"
android:paddingBottom="4dp">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/inputField"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@android:color/transparent"
android:hint="@string/enter_message"
android:imeOptions="actionSend"
android:inputType="textMultiLine|textCapSentences"
android:maxLines="5"
android:minHeight="56dp"
android:paddingStart="8dp"
android:paddingEnd="8dp"
android:paddingTop="12dp"
android:paddingBottom="12dp" />
<ImageView
android:id="@+id/sendButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="8dp"
android:src="@drawable/ic_mistral_logo"
android:background="@drawable/bg_send_button"
android:contentDescription="@string/send"
android:clickable="true"
android:focusable="true" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>
</RelativeLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/navigationView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header"
app:menu="@menu/drawer_menu" />
<FrameLayout
android:id="@+id/rightPanelContainer"
android:layout_width="300dp"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="?attr/colorSurface">
<include layout="@layout/panel_right" />
</FrameLayout>
</androidx.drawerlayout.widget.DrawerLayout>

View file

@ -24,7 +24,7 @@
android:id="@+id/nameInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:inputType="textPersonName|textCapSentences"
android:maxLines="1" />
</com.google.android.material.textfield.TextInputLayout>
@ -41,7 +41,7 @@
android:id="@+id/bioInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:inputType="textMultiLine|textCapSentences"
android:minLines="3"
android:maxLines="5" />
@ -59,7 +59,7 @@
android:id="@+id/preferencesInput"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:inputType="textMultiLine|textCapSentences"
android:minLines="2"
android:maxLines="4" />

View file

@ -31,7 +31,7 @@
android:id="@+id/messageText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxWidth="280dp"
android:maxWidth="350dp"
android:padding="12dp"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="parent"

View file

@ -7,13 +7,33 @@
android:padding="8dp">
<TextView
android:id="@+id/messageText"
android:id="@+id/senderName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxWidth="280dp"
android:padding="12dp"
android:textSize="16sp"
android:layout_marginEnd="4dp"
android:textSize="12sp"
android:textColor="?attr/colorOnSurfaceVariant"
app:layout_constraintEnd_toStartOf="@id/senderIcon"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/senderIcon"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_person"
android:contentDescription="@string/profile"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/messageText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxWidth="350dp"
android:layout_marginTop="2dp"
android:padding="12dp"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/senderIcon" />
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -34,4 +34,19 @@
<string name="api_key_current">Текущий ключ: %s</string>
<string name="enter_api_key">Введите API ключ</string>
<string name="api_key_required">Требуется API ключ Mistral</string>
<string name="clear_all_history">Очистить всю историю</string>
<string name="clear_all_confirm">Удалить все сессии и сообщения?</string>
<string name="history_cleared">История очищена</string>
<string name="sessions">Сессии</string>
<string name="new_session">Новая сессия</string>
<string name="no_sessions">Нет сессий</string>
<string name="ok">OK</string>
<string name="profiles">Профили</string>
<string name="profiles_uppercase">ПРОФИЛИ</string>
<string name="new_profile">Новый профиль</string>
<string name="manage_profiles">Управление профилями</string>
<string name="edit">Редактировать</string>
<string name="selected">Выбрано</string>
<string name="clear_all_delete_profiles">Удалить все профили</string>
<string name="profile_info">Профиль: %s</string>
</resources>