Skip to content

Commit

Permalink
v0.15.3
Browse files Browse the repository at this point in the history
- Продолжил делать CreditsActivity
- Теперь цифра счёта верхнего игрока повёрнута к нему
- Поменял размер и цвет текста
  • Loading branch information
InvalidNickname committed Apr 25, 2018
1 parent 99f6355 commit ea740e0
Show file tree
Hide file tree
Showing 12 changed files with 204 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/build
/captures
.externalNativeBuild
.idea/assetWizardSettings.xml
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="hockey.airhockey"
android:versionName="0.15.2">
android:versionName="0.15.3">

<application
android:allowBackup="true"
Expand Down
42 changes: 42 additions & 0 deletions app/src/main/java/hockey/airhockey/CreditsActivity.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package hockey.airhockey;

import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.support.constraint.ConstraintLayout;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;

import static hockey.airhockey.MainActivity.gateHeight;
import static hockey.airhockey.MainActivity.width;

public class CreditsActivity extends AppCompatActivity {

Expand All @@ -13,6 +21,15 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_credits);
overridePendingTransition(0, 0);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
drawGates();
TextView versionText = findViewById(R.id.versionText);
String versionName = "0.0";
try {
versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
versionText.setText(String.format(getResources().getString(R.string.about_version), versionName));
}

@Override
Expand All @@ -21,4 +38,29 @@ public void onBackPressed() {
startActivity(intent);
finish();
}

private void drawGates() {
ImageView upperGate = findViewById(R.id.upper_gate);
ImageView lowerGate = findViewById(R.id.lower_gate);
ConstraintLayout.LayoutParams upperParams = new ConstraintLayout.LayoutParams((int) (0.48 * width), gateHeight);
upperParams.leftToLeft = R.id.main_credits;
upperParams.rightToRight = R.id.main_credits;
upperParams.topToTop = R.id.main_credits;
upperParams.bottomToBottom = R.id.main_credits;
upperParams.topMargin = -100;
upperParams.verticalBias = 0;
upperGate.setLayoutParams(upperParams);
ConstraintLayout.LayoutParams lowerParams = new ConstraintLayout.LayoutParams((int) (0.48 * width), gateHeight);
lowerParams.leftToLeft = R.id.main_credits;
lowerParams.rightToRight = R.id.main_credits;
lowerParams.topToTop = R.id.main_credits;
lowerParams.bottomToBottom = R.id.main_credits;
lowerParams.bottomMargin = -100;
lowerParams.verticalBias = 1;
lowerGate.setLayoutParams(lowerParams);
}

public void back(View view) {
onBackPressed();
}
}
8 changes: 7 additions & 1 deletion app/src/main/java/hockey/airhockey/GameField.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.Typeface;
Expand Down Expand Up @@ -160,14 +161,19 @@ private void drawOnCanvas(Canvas canvas) {
upperGate.draw(canvas);
Rect bounds = new Rect();
paint.getTextBounds(String.valueOf(count1), 0, 1, bounds);
canvas.drawText(String.valueOf(count1), (width - paint.measureText(String.valueOf(count1))) / 2f, (height / 1.9f + bounds.height()) / 2f, paint);
Path path = new Path();
path.reset();
path.moveTo((width + paint.measureText(String.valueOf(count1))) / 2f, (height / 1.9f - bounds.height()) / 2f);
path.lineTo((width - paint.measureText(String.valueOf(count1))) / 2f, (height / 1.9f - bounds.height()) / 2f);
canvas.drawTextOnPath(String.valueOf(count1), path, 0, 0, paint);
paint.getTextBounds(String.valueOf(count2), 0, 1, bounds);
canvas.drawText(String.valueOf(count2), (width - paint.measureText(String.valueOf(count2))) / 2f, (height * 1.475f + bounds.height()) / 2f, paint);
player1.draw(canvas);
player2.draw(canvas);
puck.draw(canvas);
}

// нахождение расстояния между двумя точками
private double length(double x1, double y1, double x2, double y2) {
return Math.sqrt(Math.pow(x1 - x2, 2) + Math.pow(y1 - y2, 2));
}
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/arrow_back.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"
android:fillColor="#000000" />
</vector>
132 changes: 132 additions & 0 deletions app/src/main/res/layout/activity_credits.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,141 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/main_credits"
tools:context=".CreditsActivity"
tools:layout_editor_absoluteY="25dp">

<ImageView
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="false"
android:cropToPadding="false"
android:scaleType="fitXY"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/background"
tools:ignore="ContentDescription" />

<ImageView
android:id="@+id/lower_gate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="false"
android:cropToPadding="false"
android:scaleType="fitXY"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"
app:srcCompat="@drawable/lower_gate"
tools:ignore="ContentDescription" />

<ImageView
android:id="@+id/upper_gate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="false"
android:cropToPadding="false"
android:scaleType="fitXY"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="@drawable/upper_gate"
tools:ignore="ContentDescription" />

<ImageView
android:id="@+id/backButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:onClick="back"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
app:srcCompat="@drawable/arrow_back"
tools:ignore="ContentDescription" />

<android.support.constraint.ConstraintLayout
android:id="@+id/layout"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@id/lowerSpace"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/upperSpace">

<ImageView
android:id="@+id/winBackground"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="fitXY"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@android:drawable/editbox_background"
tools:ignore="ContentDescription" />

<TextView
android:id="@+id/versionText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about_version"
android:textColor="@color/colorText"
android:textSize="@dimen/text_size"
app:layout_constraintBottom_toTopOf="@id/aboutText"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/aboutText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/about"
android:textAlignment="center"
android:textColor="@color/colorText"
android:textSize="@dimen/text_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/versionText" />

</android.support.constraint.ConstraintLayout>

<Space
android:id="@+id/upperSpace"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:visibility="invisible"
app:layout_constraintBottom_toTopOf="@+id/layout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Space
android:id="@+id/lowerSpace"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/layout" />
</android.support.constraint.ConstraintLayout>
8 changes: 2 additions & 6 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
android:id="@+id/background"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="false"
android:cropToPadding="false"
android:scaleType="fitXY"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand All @@ -25,8 +23,6 @@
android:id="@+id/lower_gate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="false"
android:cropToPadding="false"
android:scaleType="fitXY"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand All @@ -41,8 +37,6 @@
android:id="@+id/upper_gate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="false"
android:cropToPadding="false"
android:scaleType="fitXY"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand All @@ -60,6 +54,7 @@
android:layout_marginTop="8dp"
android:onClick="openCredits"
android:text="@string/settings"
android:textSize="@dimen/button_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -73,6 +68,7 @@
android:layout_marginTop="8dp"
android:onClick="startGame"
android:text="@string/start"
android:textSize="@dimen/button_size"
app:layout_constraintBottom_toTopOf="@+id/credits"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/layout/activity_win.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/win"
android:textColor="@color/colorText"
android:textSize="@dimen/win_text_size"
app:layout_constraintBottom_toTopOf="@id/menuButton"
app:layout_constraintEnd_toEndOf="parent"
Expand All @@ -88,7 +89,7 @@
android:layout_height="wrap_content"
android:onClick="goToMenu"
android:text="@string/menu"
android:textSize="@dimen/win_button_size"
android:textSize="@dimen/button_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/restartButton"
app:layout_constraintStart_toStartOf="parent"
Expand All @@ -100,7 +101,7 @@
android:layout_height="wrap_content"
android:onClick="restartGame"
android:text="@string/restart"
android:textSize="@dimen/win_button_size"
android:textSize="@dimen/button_size"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/menuButton"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-small/dimens.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="win_text_size">36sp</dimen>
<dimen name="win_button_size">14sp</dimen>
<dimen name="button_size">12sp</dimen>
<dimen name="text_size">18sp</dimen>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="transparent">#00ffffff</color>
<color name="colorText">#606060</color>
</resources>
3 changes: 2 additions & 1 deletion app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="win_text_size">45sp</dimen>
<dimen name="win_button_size">18sp</dimen>
<dimen name="button_size">14sp</dimen>
<dimen name="text_size">18sp</dimen>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
<string name="win">Game Over</string>
<string name="menu">Menu</string>
<string name="restart">Restart</string>
<string name="about">Sehr gutes Spiel. Das beste Spiel der Welt</string>
<string name="about_version">version %1$s</string>
</resources>

0 comments on commit ea740e0

Please sign in to comment.