Skip to content

Commit

Permalink
design changes: scrollable EditChatActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
DevEmperor committed Feb 2, 2024
1 parent b5123c2 commit f0f4105
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@

import net.devemperor.wristassist.R;
import net.devemperor.wristassist.database.ChatHistoryDatabaseHelper;
import net.devemperor.wristassist.util.Util;

import org.json.JSONException;

import java.io.IOException;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Locale;

Expand All @@ -29,7 +27,6 @@ public class EditChatActivity extends Activity {

ChatHistoryDatabaseHelper chatHistoryDatabaseHelper;
long id;
DecimalFormat df = new DecimalFormat("#.##");

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -46,15 +43,12 @@ protected void onCreate(Bundle savedInstanceState) {
id = getIntent().getLongExtra("net.devemperor.wristassist.chatId", -1);

titleTv.setText(chatHistoryDatabaseHelper.getTitle(id));
titleTv.setTextSize(16 * Util.getFontMultiplier(this));

SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd\nHH:mm:ss", Locale.getDefault());
modifiedTv.setText(formatter.format(chatHistoryDatabaseHelper.getModified(id)));
modifiedTv.setTextSize(14 * Util.getFontMultiplier(this));
modifiedTv.setText(getString(R.string.wristassist_formatted_date, formatter.format(chatHistoryDatabaseHelper.getModified(id))));

try {
chatCostTv.setText(getString(R.string.wristassist_chat_cost, df.format(chatHistoryDatabaseHelper.getChatCost(this, id) / 1000.0)));
chatCostTv.setTextSize(14 * Util.getFontMultiplier(this));
chatCostTv.setText(getString(R.string.wristassist_chat_cost, String.format(Locale.getDefault(), "%,d", chatHistoryDatabaseHelper.getChatCost(this, id))));
} catch (IOException | JSONException e) {
throw new RuntimeException(e);
}
Expand Down
157 changes: 81 additions & 76 deletions app/src/main/res/layout/activity_edit_chat.xml
Original file line number Diff line number Diff line change
@@ -1,85 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingHorizontal="10dp"
android:fillViewport="false">

<TextView
android:id="@+id/edit_title_tv"
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="3"
android:paddingHorizontal="32dp"
android:textAlignment="center"
android:textColor="#7B1FA2"
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="@+id/modified_tv"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:orientation="vertical">

<TextView
android:id="@+id/modified_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="8dp"
android:paddingStart="24dp"
android:textAlignment="center"
app:layout_constraintBottom_toTopOf="@+id/edit_btn"
app:layout_constraintEnd_toStartOf="@+id/chat_cost_tv"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/edit_title_tv" />
<TextView
android:id="@+id/edit_title_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="32dp"
android:layout_marginHorizontal="32dp"
android:layout_marginBottom="16dp"
android:maxLines="3"
android:textAlignment="center"
android:textColor="#7B1FA2"
android:textSize="18sp"
android:textStyle="bold"/>

<ImageButton
android:id="@+id/edit_btn"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_marginStart="24dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:background="@null"
android:onClick="editTitle"
android:scaleType="fitCenter"
android:src="@drawable/twotone_edit_24"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/delete_btn"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/modified_tv" />
<TextView
android:id="@+id/modified_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginHorizontal="32dp"
android:layout_marginBottom="16dp"
android:textSize="16sp"
android:textAlignment="center" />

<ImageButton
android:id="@+id/delete_btn"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="24dp"
android:layout_marginBottom="8dp"
android:background="@null"
android:onClick="deleteChat"
android:scaleType="fitCenter"
android:src="@drawable/twotone_delete_24"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/edit_btn"
app:layout_constraintTop_toBottomOf="@id/chat_cost_tv" />
<TextView
android:id="@+id/chat_cost_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginHorizontal="32dp"
android:layout_marginBottom="16dp"
android:textSize="16sp"
android:textAlignment="center"/>

<TextView
android:id="@+id/chat_cost_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginEnd="16dp"
android:paddingEnd="24dp"
android:textAlignment="center"
app:layout_constraintBottom_toTopOf="@+id/delete_btn"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/modified_tv"
app:layout_constraintTop_toBottomOf="@+id/edit_title_tv" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="32dp">

<ImageButton
android:id="@+id/edit_btn"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="32dp"
android:layout_marginEnd="16dp"
android:background="@null"
android:onClick="editTitle"
android:src="@drawable/twotone_edit_24"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
app:layout_constraintEnd_toStartOf="@+id/delete_btn"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>
<ImageButton
android:id="@+id/delete_btn"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="16dp"
android:layout_marginEnd="32dp"
android:background="@null"
android:onClick="deleteChat"
android:src="@drawable/twotone_delete_24"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/edit_btn"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</ScrollView>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/layout_chat_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
android:textAlignment="center"
android:textColor="#7B1FA2"
android:textStyle="bold"
android:textSize="15sp"
android:textSize="18sp"
android:visibility="gone"/>
</LinearLayout>

0 comments on commit f0f4105

Please sign in to comment.