From 5cdf5205dd3a4529855da251fb63ec31c7dd535a Mon Sep 17 00:00:00 2001 From: jaco <jcrucesdeveloper@gmail.com> Date: Mon, 15 Aug 2022 17:56:58 -0400 Subject: [PATCH] feat(gameActivity): WIP animations --- .idea/deploymentTargetDropDown.xml | 17 ++++++++ .idea/misc.xml | 2 + .../activities/PlayGameActivity.java | 41 ++++++++++++++++-- .../metrometro/customViews/StationView.java | 33 ++++++++++++++ .../main/res/layout/activity_play_game.xml | 43 +++++++++---------- app/src/main/res/layout/station_layout.xml | 38 ++++++++++++++++ 6 files changed, 148 insertions(+), 26 deletions(-) create mode 100644 .idea/deploymentTargetDropDown.xml create mode 100644 app/src/main/java/com/jorgecruces/metrometro/customViews/StationView.java create mode 100644 app/src/main/res/layout/station_layout.xml diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml new file mode 100644 index 0000000..4d37d12 --- /dev/null +++ b/.idea/deploymentTargetDropDown.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="deploymentTargetDropDown"> + <targetSelectedWithDropDown> + <Target> + <type value="QUICK_BOOT_TARGET" /> + <deviceKey> + <Key> + <type value="VIRTUAL_DEVICE_PATH" /> + <value value="$USER_HOME$/.android/avd/Nexus_5X_API_30_2.avd" /> + </Key> + </deviceKey> + </Target> + </targetSelectedWithDropDown> + <timeTargetWasSelectedWithDropDown value="2022-08-15T02:21:34.996636Z" /> + </component> +</project> \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 7c91822..26b7f87 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,6 +3,7 @@ <component name="DesignSurface"> <option name="filePathToZoomLevelMap"> <map> + <entry key="../../../../layout/custom_preview.xml" value="0.43498049414824447" /> <entry key="app/src/main/res/layout/activity_info.xml" value="0.2496793501496366" /> <entry key="app/src/main/res/layout/activity_main.xml" value="0.18802083333333333" /> <entry key="app/src/main/res/layout/activity_menu_metro.xml" value="0.22" /> @@ -10,6 +11,7 @@ <entry key="app/src/main/res/layout/activity_metro_play.xml" value="0.28541666666666665" /> <entry key="app/src/main/res/layout/activity_play_game.xml" value="0.22" /> <entry key="app/src/main/res/layout/menu_row.xml" value="0.28541666666666665" /> + <entry key="app/src/main/res/layout/station_layout.xml" value="0.22" /> </map> </option> </component> diff --git a/app/src/main/java/com/jorgecruces/metrometro/activities/PlayGameActivity.java b/app/src/main/java/com/jorgecruces/metrometro/activities/PlayGameActivity.java index 0544351..0fe12e3 100644 --- a/app/src/main/java/com/jorgecruces/metrometro/activities/PlayGameActivity.java +++ b/app/src/main/java/com/jorgecruces/metrometro/activities/PlayGameActivity.java @@ -1,15 +1,21 @@ package com.jorgecruces.metrometro.activities; import androidx.appcompat.app.AppCompatActivity; +import androidx.constraintlayout.widget.ConstraintLayout; +import android.animation.ObjectAnimator; import android.content.Intent; import android.os.Bundle; +import android.util.DisplayMetrics; import android.util.Log; +import android.util.TypedValue; import android.view.View; +import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; import com.jorgecruces.metrometro.R; +import com.jorgecruces.metrometro.customViews.StationView; import com.jorgecruces.metrometro.logic.MetroReaderXML; import com.jorgecruces.metrometro.logic.PickerStationsAlternative; import com.jorgecruces.metrometro.model.Line; @@ -40,8 +46,37 @@ protected void onCreate(Bundle savedInstanceState) { this.setLineName(); this.initializeLevelData(); this.initializeLevelViews(); - this.setCurrentStationQuestion(this.position); + this.testMethod(); + } + + private void testMethod() { + LinearLayout linearLayout = findViewById(R.id.gameLayout); + StationView stationView = new StationView(this); + stationView.setLayoutParams(new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.MATCH_PARENT + )); + linearLayout.addView(stationView); + + + StationView stationView2 = new StationView(this); + stationView2.setLayoutParams(new LinearLayout.LayoutParams( + LinearLayout.LayoutParams.MATCH_PARENT, + LinearLayout.LayoutParams.MATCH_PARENT + )); + linearLayout.addView(stationView2); + + DisplayMetrics displayMetrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); + int height = displayMetrics.heightPixels; + int width = displayMetrics.widthPixels; + +// ObjectAnimator animation = ObjectAnimator.ofFloat(stationView, "translationX", -(width/2)); +// animation.setDuration(3000); +// animation.start(); + + } /** @@ -165,8 +200,8 @@ private void setCurrentAlternativesViews() { private void setCurrentStationView() { - TextView currentStationView = findViewById(R.id.textViewCurrentStation); - currentStationView.setText(this.currentStationName); +// TextView currentStationView = findViewById(R.id.textViewCurrentStation); +// currentStationView.setText(this.currentStationName); } private void setCurrentStationData(int position) { diff --git a/app/src/main/java/com/jorgecruces/metrometro/customViews/StationView.java b/app/src/main/java/com/jorgecruces/metrometro/customViews/StationView.java new file mode 100644 index 0000000..8007474 --- /dev/null +++ b/app/src/main/java/com/jorgecruces/metrometro/customViews/StationView.java @@ -0,0 +1,33 @@ +package com.jorgecruces.metrometro.customViews; + +import android.content.Context; +import android.util.AttributeSet; +import android.widget.LinearLayout; + +import androidx.annotation.Nullable; + +import com.jorgecruces.metrometro.R; + +public class StationView extends LinearLayout{ + + public StationView(Context context) { + super(context); + this.init(); + } + + public StationView(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + this.init(); + } + + public StationView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + this.init(); + } + + private void init() { + inflate(getContext(), R.layout.station_layout, this); + } + + +} diff --git a/app/src/main/res/layout/activity_play_game.xml b/app/src/main/res/layout/activity_play_game.xml index 5fe000b..8ae6231 100644 --- a/app/src/main/res/layout/activity_play_game.xml +++ b/app/src/main/res/layout/activity_play_game.xml @@ -2,6 +2,7 @@ <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/mainLayout" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".activities.PlayGameActivity"> @@ -14,17 +15,18 @@ android:layout_marginStart="16dp" android:layout_marginTop="16dp" android:layout_marginEnd="331dp" - android:onClick="goBackToMenu" android:contentDescription="Button" + android:onClick="goBackToMenu" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:srcCompat="@android:drawable/ic_menu_revert" /> + <TextView android:id="@+id/textViewTitle" - android:layout_width="wrap_content" - android:layout_height="wrap_content" + android:layout_width="218dp" + android:layout_height="59dp" android:layout_marginTop="16dp" android:fontFamily="sans-serif-light" android:text="Lineas Metro" @@ -71,16 +73,19 @@ app:layout_constraintBottom_toTopOf="@+id/textViewAlternative3" app:layout_constraintStart_toStartOf="parent" /> + <LinearLayout + android:id="@+id/linearLayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="180dp" - android:layout_marginTop="24dp" + android:layout_marginTop="8dp" android:layout_marginEnd="181dp" android:orientation="horizontal" app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="1.0" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/textViewCurrentStation"> + app:layout_constraintTop_toBottomOf="@+id/gameLayout"> <TextView android:id="@+id/textViewCurrentNumberQuestion" @@ -119,28 +124,20 @@ app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toEndOf="@+id/textViewAlternative1" /> - <TextView - android:id="@+id/textViewCurrentStation" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginTop="240dp" - android:text="CURRENT LINEA" - android:textSize="24sp" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.48" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> - <LinearLayout - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginStart="180dp" - android:layout_marginTop="150dp" - android:layout_marginEnd="181dp" + android:id="@+id/gameLayout" + android:layout_width="0dp" + android:layout_height="300dp" + android:layout_marginTop="8dp" + android:background="@android:drawable/edit_text" + android:gravity="clip_horizontal|clip_vertical|center_horizontal|center_vertical" android:orientation="horizontal" app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/textViewCurrentStation"> + app:layout_constraintTop_toBottomOf="@+id/textViewTitle" + + > </LinearLayout> diff --git a/app/src/main/res/layout/station_layout.xml b/app/src/main/res/layout/station_layout.xml new file mode 100644 index 0000000..fd74483 --- /dev/null +++ b/app/src/main/res/layout/station_layout.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:gravity="center_horizontal|center_vertical" + android:orientation="vertical"> + + <RelativeLayout + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1"> + + <ImageView + android:id="@+id/imageView2" + android:layout_width="match_parent" + android:layout_height="120dp" + android:layout_centerInParent="true" + android:backgroundTint="#FF0000" + app:srcCompat="@drawable/metro_svg" /> + + <ImageView + android:id="@+id/imageView3" + android:layout_width="match_parent" + android:layout_height="80dp" + android:layout_centerInParent="true" + app:srcCompat="@drawable/ic_baseline_circle_24" /> + </RelativeLayout> + + <TextView + android:id="@+id/textViewStationName" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_weight="1" + android:text="TextView" + android:textAlignment="center" /> + +</LinearLayout> \ No newline at end of file