Skip to content

Commit

Permalink
Merge pull request #3 from gjsk132/feature/title/lobby-start
Browse files Browse the repository at this point in the history
[Feature] Lobby Start ( 1 )
  • Loading branch information
gjsk132 authored Dec 9, 2024
2 parents a246c70 + f243f24 commit cb28377
Show file tree
Hide file tree
Showing 25 changed files with 402 additions and 121 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"
tools:targetApi="31" >
<activity
android:name=".MapCreator.CreateMap"
Expand Down
4 changes: 0 additions & 4 deletions app/src/main/java/com/gjsk/lootify/customview/BigButton.java

This file was deleted.

99 changes: 99 additions & 0 deletions app/src/main/java/com/gjsk/lootify/customview/DialogBase.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package com.gjsk.lootify.customview;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.gjsk.lootify.R;

public class DialogBase extends LinearLayout {
TextView subTitle;
TextView description;
ImageView addIcon;
FrameLayout dialogContents;
View buttonLine;
LinearLayout buttonContents;

public DialogBase(Context context){
super(context);
initView();
}

public DialogBase(Context context, AttributeSet attrs){
super(context, attrs);
initView();
getAttrs(attrs);
}

public DialogBase(Context context, AttributeSet attrs, int defStyle){
super(context, attrs);
initView();
getAttrs(attrs, defStyle);
}

private void initView(){
String infService = Context.LAYOUT_INFLATER_SERVICE;
LayoutInflater li = (LayoutInflater) getContext().getSystemService(infService);
View v = li.inflate(R.layout.dialog_base, this, false);
addView(v);

subTitle = (TextView) findViewById(R.id.sub_title);
description = (TextView) findViewById(R.id.description);
addIcon = (ImageView) findViewById(R.id.icon);
dialogContents = (FrameLayout) findViewById(R.id.dialog_contents);
buttonLine = (View) findViewById(R.id.button_line);
buttonContents = (LinearLayout) findViewById(R.id.button_contents);
}

private void getAttrs(AttributeSet attrs){
TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.DialogBase);
setTypeArray(typedArray);
}

private void getAttrs(AttributeSet attrs, int defStyle){
TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.DialogBase, defStyle, 0);
setTypeArray(typedArray);
}

private void setTypeArray(TypedArray typedArray){
String subTitleString = typedArray.getString(R.styleable.DialogBase_sub_title);
String descriptionString = typedArray.getString(R.styleable.DialogBase_description);
boolean isAddIcon = typedArray.getBoolean(R.styleable.DialogBase_add_icon_visible, false);
boolean isButtons = typedArray.getBoolean(R.styleable.DialogBase_is_buttons, false);

setTitle(subTitleString);
setDescription(descriptionString);
setIconVisibility(isAddIcon);
setButtonsVisibility(isButtons);

typedArray.recycle();
}

private void setTitle(String text){
subTitle.setText(text);
}

private void setDescription(String text){
description.setText(text);
}

private void setIconVisibility(boolean isAddIcon){
addIcon.setVisibility(isAddIcon ? View.VISIBLE : View.GONE);
}

private void setButtonsVisibility(boolean isButtons){
if(isButtons){
buttonLine.setVisibility(View.VISIBLE);
buttonContents.setVisibility(View.VISIBLE);
}else{
buttonLine.setVisibility(View.GONE);
buttonContents.setVisibility(View.GONE);
}
}
}
23 changes: 13 additions & 10 deletions app/src/main/java/com/gjsk/lootify/customview/SmallButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;

import androidx.core.content.ContextCompat;

import com.gjsk.lootify.R;

import java.util.Objects;
Expand Down Expand Up @@ -79,7 +80,9 @@ public void setEnabled(boolean enabled) {

public void setText(String textString) {
text.setText(textString);
smallButton.setBackgroundResource(setButtonColor(textString));

int color = setButtonColor(textString);
smallButton.setBackgroundTintList(ContextCompat.getColorStateList(getContext(), color));
}

private void setTextColor(int textColor) {
Expand All @@ -92,33 +95,33 @@ private int setButtonColor(String textString){
case "FIND":
case "SELECT":
case "NEXT" :
return R.drawable.light_yellow_button;
return R.color.lightYellow;

case "JOIN":
case "LOAD":
case "SAVE" :
return R.drawable.light_green_button;
return R.color.lightGreen;

case "CANCLE":
case "BEFORE":
case "BACK":
return R.drawable.gray_button;
return R.color.gray;

case "SAVE MAP":
case "CREATE MAP":
return R.drawable.light_black_button;
return R.color.lightBlack;

case "MY MAP":
return R.drawable.light_brown_button;
return R.color.lightBrown;

case "HISTORY":
return R.drawable.dark_yellow_button;
return R.color.darkYellow;

case "PREVIEW":
return R.drawable.mid_green_button;
return R.color.midGreen;

default:
return R.drawable.white_frame;
return R.drawable.white_frame_mid;
}
}
}
43 changes: 33 additions & 10 deletions app/src/main/java/com/gjsk/lootify/title/Lobby.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,52 @@
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.gjsk.lootify.R;
import com.gjsk.lootify.customview.DialogBase;
import com.gjsk.lootify.customview.SmallButton;
import com.gjsk.lootify.databinding.ActivityLobbyBinding;

public class Lobby extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

com.gjsk.lootify.databinding.ActivityLobbyBinding binding = com.gjsk.lootify.databinding.ActivityLobbyBinding.inflate(getLayoutInflater());
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

ActivityLobbyBinding binding = ActivityLobbyBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());

SmallButton button1 = binding.button1;
SmallButton button2 = binding.button2;
DialogBase dialogBase = binding.dialogBase;

button1.setOnClickListener(v->{
button1.setEnabled(false);
button2.setEnabled(true);
});
LinearLayout buttonContents = dialogBase.findViewById(R.id.button_contents);
addButtons(buttonContents);

FrameLayout dialogContents = dialogBase.findViewById(R.id.dialog_contents);
setDialogContents(dialogContents);
}

private void setDialogContents(FrameLayout dialogContents){
LinearLayout contents = (LinearLayout) getLayoutInflater().inflate(R.layout.dialog_room_select, dialogContents, false);

button2.setOnClickListener(v->{
button1.setEnabled(true);
button2.setEnabled(false);
dialogContents.addView(contents);
}

private void addButtons(LinearLayout buttonContents) {

SmallButton findButton = new SmallButton(this);
findButton.setText("FIND");
findButton.setEnabled(true);
findButton.setOnClickListener(v -> {
Toast toast = Toast.makeText(getApplicationContext(), "Finding Room...", Toast.LENGTH_SHORT);
toast.show();
});

buttonContents.addView(findButton);
}
}
Binary file added app/src/main/res/drawable/add_ic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 0 additions & 9 deletions app/src/main/res/drawable/dark_yellow_button.xml

This file was deleted.

9 changes: 0 additions & 9 deletions app/src/main/res/drawable/gray_button.xml

This file was deleted.

9 changes: 0 additions & 9 deletions app/src/main/res/drawable/light_black_button.xml

This file was deleted.

9 changes: 0 additions & 9 deletions app/src/main/res/drawable/light_brown_button.xml

This file was deleted.

9 changes: 0 additions & 9 deletions app/src/main/res/drawable/light_green_button.xml

This file was deleted.

9 changes: 0 additions & 9 deletions app/src/main/res/drawable/light_yellow_button.xml

This file was deleted.

9 changes: 0 additions & 9 deletions app/src/main/res/drawable/mid_green_button.xml

This file was deleted.

File renamed without changes.
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/white_frame_mid.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape>
<corners android:radius="10dp"/>
<stroke android:color="@color/textLightColor"
android:width="1dp"/>
<solid android:color="@color/white"/>
</shape>
</item>
</selector>
42 changes: 38 additions & 4 deletions app/src/main/res/layout/activity_create_map.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,43 @@
<?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"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/startScreen"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MapCreator.CreateMap">
android:background="@color/titleBackgroundColor"
tools:context=".title.StartTitle">

</androidx.constraintlayout.widget.ConstraintLayout>
<ImageView
android:contentDescription="@string/contents"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:scaleType="centerCrop"
android:src="@drawable/create_map_background"/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/labrada"
android:text="@string/app_name"
android:textColor="@color/textBasicColor"
android:layout_marginTop="130dp"
android:layout_marginBottom="280dp"
android:textSize="65sp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="@font/inria_sans"
android:text="Touch to Start"
android:textColor="@color/white"
android:textSize="20sp" />

</LinearLayout>

</FrameLayout>
Loading

0 comments on commit cb28377

Please sign in to comment.