Skip to content

Commit

Permalink
Fix all layouts (#22) [Complete]
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectroBoy404NotFound committed Mar 31, 2023
1 parent ab8bc67 commit 66c4f3b
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 53 deletions.
26 changes: 26 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 22 additions & 6 deletions app/src/main/java/me/electronicsboy/yapca/ui/chat/ChatScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
Expand Down Expand Up @@ -71,18 +74,12 @@ public void onCancelled(@NonNull DatabaseError error) {
// Failed to read value
// Toast.makeText(LoginActivity.this, "ERROR!\n" + error.toException().getMessage(), Toast.LENGTH_LONG).show();
Log.w(null,"Failed to read value.", error.toException());
// ((TextView) findViewById(R.id.status)).setText("Oh no! Connect to the internet and restart the app to continue!");
}
};
myRef.addValueEventListener(vel);
adapter.notifyDataSetChanged();
((Button) findViewById(R.id.sendtxt)).setOnClickListener((v) -> {
HashMap<String, String> data2 = new HashMap<>();
System.out.println((String) TempStorage.get("USERNAME"));
System.out.println((String) TempStorage.get("CT_CP"));
System.out.println(((EditText)findViewById(R.id.messagesend)).getText().toString());
System.out.println(Crypto.encrypt((String) TempStorage.get("USERNAME"), (String) TempStorage.get("CT_CP")));
System.out.println(Crypto.encrypt(((EditText)findViewById(R.id.messagesend)).getText().toString(), (String) TempStorage.get("CT_CP")));
data2.put("user", Crypto.encrypt((String) TempStorage.get("USERNAME"), (String) TempStorage.get("CT_CP")));
data2.put("msg", Crypto.encrypt(((EditText)findViewById(R.id.messagesend)).getText().toString(), (String) TempStorage.get("CT_CP")));
myRef.push().setValue(data2);
Expand All @@ -92,5 +89,24 @@ public void onCancelled(@NonNull DatabaseError error) {
TempStorage.clear();
startActivity(new Intent(ChatScreen.this, SplashScreen.class));
});
((Button) findViewById(R.id.logout)).setEnabled(false);
((EditText)findViewById(R.id.messagesend)).setEnabled(true);
((EditText)findViewById(R.id.messagesend)).setVisibility(View.VISIBLE);
((EditText)findViewById(R.id.messagesend)).addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// Do nothing
}

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// Do nothing
}

@Override
public void afterTextChanged(Editable s) {
((Button) findViewById(R.id.sendtxt)).setEnabled(s.toString().isEmpty());
}
});
}
}
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_chat_screen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
android:ems="10"
android:hint="Message"
android:inputType="textPersonName"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.454"
Expand Down
62 changes: 32 additions & 30 deletions app/src/main/res/layout/activity_chat_select_screen.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.chat.ChatSelectScreen"
tools:layout_editor_absoluteX="-1sp"
tools:layout_editor_absoluteX="1sp"
tools:layout_editor_absoluteY="7sp">

<Button
Expand All @@ -14,7 +14,7 @@
android:layout_height="39sp"
android:text="@string/logout"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toStartOf="@+id/textView9"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
Expand All @@ -24,28 +24,28 @@
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="116sp"
android:layout_marginTop="76sp"
android:text="Yet Another Private Chat App"
android:textSize="18sp"
app:layout_constraintBottom_toTopOf="@+id/imageView"
app:layout_constraintBottom_toTopOf="@+id/textView10"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.497"
app:layout_constraintHorizontal_bias="0.508"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.626" />
app:layout_constraintVertical_bias="0.0" />

<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="YAPCA"
android:textSize="28sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toTopOf="@+id/textView8"
app:layout_constraintEnd_toEndOf="@+id/textView8"
app:layout_constraintHorizontal_bias="0.486"
app:layout_constraintStart_toStartOf="@+id/textView8"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.106" />
app:layout_constraintVertical_bias="0.763" />

<TextView
android:id="@+id/textView10"
Expand All @@ -59,38 +59,40 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.209" />

<Button
android:id="@+id/createroom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Create Room"
app:layout_constraintBottom_toTopOf="@+id/chatsList"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.281"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView10"
app:layout_constraintVertical_bias="0.518" />

<ListView
android:id="@+id/chatsList"
android:layout_width="409sp"
android:layout_height="484sp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginStart="4sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0" >
</ListView>
app:layout_constraintVertical_bias="1.0"></ListView>

<Button
android:id="@+id/openroom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="3dp"
android:text="Open Room"
app:layout_constraintBottom_toTopOf="@+id/chatsList"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.168"
app:layout_constraintEnd_toEndOf="@+id/textView10"
app:layout_constraintHorizontal_bias="0.408"
app:layout_constraintStart_toEndOf="@+id/createroom"
app:layout_constraintTop_toBottomOf="@+id/textView10"
app:layout_constraintVertical_bias="0.518" />
app:layout_constraintVertical_bias="0.014" />

<Button
android:id="@+id/createroom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:text="Create Room"
app:layout_constraintBottom_toTopOf="@+id/chatsList"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@+id/textView10"
app:layout_constraintTop_toBottomOf="@+id/textView10"
app:layout_constraintVertical_bias="0.014" />

</androidx.constraintlayout.widget.ConstraintLayout>
23 changes: 6 additions & 17 deletions app/src/main/res/layout/item_chat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,37 @@
<LinearLayout 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:layout_width="match_parent"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:orientation="vertical">

<ImageView
android:contentDescription="image message"
android:elevation="4sp"
android:cropToPadding="true"
android:padding="4sp"
android:maxHeight="200sp"
android:id="@+id/photoImageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true" />

<androidx.cardview.widget.CardView
android:id="@+id/card"
android:layout_width="372sp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="4sp"
app:cardCornerRadius="4sp">

<LinearLayout
android:layout_width="wrap_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="8sp"
android:orientation="vertical">

<TextView

android:id="@+id/messageTextView"
android:layout_width="372sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:textAppearance="?android:attr/textAppearanceLarge"
tools:text="Message" />

<TextView
android:id="@+id/nameTextView"
android:layout_width="374sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:textAppearance="?android:attr/textAppearanceSmall"
Expand Down

0 comments on commit 66c4f3b

Please sign in to comment.