From 8df3cfe6b8e6a871bcc69efdd19a632229b50384 Mon Sep 17 00:00:00 2001 From: Dan Sandler Date: Thu, 13 Aug 2015 13:30:55 -0400 Subject: [PATCH] Introducing M Land. The "M" is for Multiplayer. Bug: 21984798 Change-Id: Id752b8efe54ff0ac38854a129188027137d64dd5 --- packages/SystemUI/AndroidManifest.xml | 20 +- .../SystemUI/res/drawable-nodpi/android.xml | 37 + .../SystemUI/res/drawable-nodpi/cactus1.xml | 57 ++ .../SystemUI/res/drawable-nodpi/cactus2.xml | 57 ++ .../SystemUI/res/drawable-nodpi/cactus3.xml | 51 ++ .../SystemUI/res/drawable-nodpi/cloud.xml | 24 + .../SystemUI/res/drawable-nodpi/cloud_off.xml | 24 + packages/SystemUI/res/drawable-nodpi/icon.xml | 8 +- .../SystemUI/res/drawable-nodpi/lollipop.xml | 48 -- .../SystemUI/res/drawable-nodpi/minus.xml | 24 + .../res/drawable-nodpi/mm_antennae.xml | 27 + .../res/drawable-nodpi/mm_antennae2.xml | 27 + .../SystemUI/res/drawable-nodpi/mm_eyes.xml | 27 + .../SystemUI/res/drawable-nodpi/mm_eyes2.xml | 27 + .../SystemUI/res/drawable-nodpi/mm_head.xml | 30 + .../SystemUI/res/drawable-nodpi/mm_mouth1.xml | 24 + .../SystemUI/res/drawable-nodpi/mm_mouth2.xml | 24 + .../SystemUI/res/drawable-nodpi/mm_mouth3.xml | 24 + .../SystemUI/res/drawable-nodpi/mm_mouth4.xml | 24 + packages/SystemUI/res/drawable-nodpi/moon.xml | 24 + .../SystemUI/res/drawable-nodpi/mountain1.xml | 33 + .../SystemUI/res/drawable-nodpi/mountain2.xml | 27 + .../SystemUI/res/drawable-nodpi/mountain3.xml | 57 ++ packages/SystemUI/res/drawable-nodpi/play.xml | 27 + packages/SystemUI/res/drawable-nodpi/plus.xml | 27 + .../SystemUI/res/drawable-nodpi/ripplebg.xml | 25 + .../SystemUI/res/drawable-nodpi/scorecard.xml | 10 + .../res/drawable-nodpi/scorecard_gameover.xml | 10 + packages/SystemUI/res/drawable-nodpi/star.xml | 24 + packages/SystemUI/res/drawable-nodpi/sun.xml | 29 + packages/SystemUI/res/layout/lland.xml | 53 -- packages/SystemUI/res/layout/mland.xml | 103 +++ .../SystemUI/res/layout/mland_scorefield.xml | 32 + .../SystemUI/res/values/lland_strings.xml | 22 - .../{lland_config.xml => mland_config.xml} | 39 +- .../SystemUI/res/values/mland_strings.xml | 20 + .../android/systemui/egg/LLandActivity.java | 43 - .../systemui/egg/{LLand.java => MLand.java} | 805 ++++++++++++++---- .../android/systemui/egg/MLandActivity.java | 91 ++ .../android/systemui/egg/ShruggyActivity.java | 34 - 40 files changed, 1702 insertions(+), 417 deletions(-) create mode 100644 packages/SystemUI/res/drawable-nodpi/android.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/cactus1.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/cactus2.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/cactus3.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/cloud.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/cloud_off.xml delete mode 100644 packages/SystemUI/res/drawable-nodpi/lollipop.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/minus.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/mm_antennae.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/mm_antennae2.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/mm_eyes.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/mm_eyes2.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/mm_head.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/mm_mouth1.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/mm_mouth2.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/mm_mouth3.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/mm_mouth4.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/moon.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/mountain1.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/mountain2.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/mountain3.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/play.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/plus.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/ripplebg.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/scorecard.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/scorecard_gameover.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/star.xml create mode 100644 packages/SystemUI/res/drawable-nodpi/sun.xml delete mode 100644 packages/SystemUI/res/layout/lland.xml create mode 100644 packages/SystemUI/res/layout/mland.xml create mode 100644 packages/SystemUI/res/layout/mland_scorefield.xml delete mode 100644 packages/SystemUI/res/values/lland_strings.xml rename packages/SystemUI/res/values/{lland_config.xml => mland_config.xml} (52%) create mode 100644 packages/SystemUI/res/values/mland_strings.xml delete mode 100644 packages/SystemUI/src/com/android/systemui/egg/LLandActivity.java rename packages/SystemUI/src/com/android/systemui/egg/{LLand.java => MLand.java} (54%) create mode 100644 packages/SystemUI/src/com/android/systemui/egg/MLandActivity.java delete mode 100644 packages/SystemUI/src/com/android/systemui/egg/ShruggyActivity.java diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index bbef259511729..677ab91a012ff 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -322,28 +322,16 @@ - - - - - - - - diff --git a/packages/SystemUI/res/drawable-nodpi/android.xml b/packages/SystemUI/res/drawable-nodpi/android.xml new file mode 100644 index 0000000000000..750de057439d0 --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/android.xml @@ -0,0 +1,37 @@ + + + + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/cactus1.xml b/packages/SystemUI/res/drawable-nodpi/cactus1.xml new file mode 100644 index 0000000000000..d0c4453b9b664 --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/cactus1.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/cactus2.xml b/packages/SystemUI/res/drawable-nodpi/cactus2.xml new file mode 100644 index 0000000000000..613ee83cc57c1 --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/cactus2.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/cactus3.xml b/packages/SystemUI/res/drawable-nodpi/cactus3.xml new file mode 100644 index 0000000000000..d070e071408e4 --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/cactus3.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/cloud.xml b/packages/SystemUI/res/drawable-nodpi/cloud.xml new file mode 100644 index 0000000000000..17e4ad2ad3853 --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/cloud.xml @@ -0,0 +1,24 @@ + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/cloud_off.xml b/packages/SystemUI/res/drawable-nodpi/cloud_off.xml new file mode 100644 index 0000000000000..b15ea5fc48a83 --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/cloud_off.xml @@ -0,0 +1,24 @@ + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/icon.xml b/packages/SystemUI/res/drawable-nodpi/icon.xml index 7b8975a45427b..9c36b5a79c02e 100644 --- a/packages/SystemUI/res/drawable-nodpi/icon.xml +++ b/packages/SystemUI/res/drawable-nodpi/icon.xml @@ -1,5 +1,5 @@ - - - - - - - - - - - diff --git a/packages/SystemUI/res/drawable-nodpi/minus.xml b/packages/SystemUI/res/drawable-nodpi/minus.xml new file mode 100644 index 0000000000000..a308e0797ff71 --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/minus.xml @@ -0,0 +1,24 @@ + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/mm_antennae.xml b/packages/SystemUI/res/drawable-nodpi/mm_antennae.xml new file mode 100644 index 0000000000000..15cd450f6d932 --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/mm_antennae.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/mm_antennae2.xml b/packages/SystemUI/res/drawable-nodpi/mm_antennae2.xml new file mode 100644 index 0000000000000..c7c06c557910a --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/mm_antennae2.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/mm_eyes.xml b/packages/SystemUI/res/drawable-nodpi/mm_eyes.xml new file mode 100644 index 0000000000000..ec7eb5d29e1a7 --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/mm_eyes.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/mm_eyes2.xml b/packages/SystemUI/res/drawable-nodpi/mm_eyes2.xml new file mode 100644 index 0000000000000..73ed4532cdf27 --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/mm_eyes2.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/mm_head.xml b/packages/SystemUI/res/drawable-nodpi/mm_head.xml new file mode 100644 index 0000000000000..c6a6465a513ae --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/mm_head.xml @@ -0,0 +1,30 @@ + + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/mm_mouth1.xml b/packages/SystemUI/res/drawable-nodpi/mm_mouth1.xml new file mode 100644 index 0000000000000..2ba6c5eb5a8f0 --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/mm_mouth1.xml @@ -0,0 +1,24 @@ + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/mm_mouth2.xml b/packages/SystemUI/res/drawable-nodpi/mm_mouth2.xml new file mode 100644 index 0000000000000..50bd98b3238df --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/mm_mouth2.xml @@ -0,0 +1,24 @@ + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/mm_mouth3.xml b/packages/SystemUI/res/drawable-nodpi/mm_mouth3.xml new file mode 100644 index 0000000000000..93258eda4c909 --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/mm_mouth3.xml @@ -0,0 +1,24 @@ + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/mm_mouth4.xml b/packages/SystemUI/res/drawable-nodpi/mm_mouth4.xml new file mode 100644 index 0000000000000..c629492ca642b --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/mm_mouth4.xml @@ -0,0 +1,24 @@ + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/moon.xml b/packages/SystemUI/res/drawable-nodpi/moon.xml new file mode 100644 index 0000000000000..4ee628679d188 --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/moon.xml @@ -0,0 +1,24 @@ + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/mountain1.xml b/packages/SystemUI/res/drawable-nodpi/mountain1.xml new file mode 100644 index 0000000000000..52e22d078ab56 --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/mountain1.xml @@ -0,0 +1,33 @@ + + + + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/mountain2.xml b/packages/SystemUI/res/drawable-nodpi/mountain2.xml new file mode 100644 index 0000000000000..ad23bddcc02db --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/mountain2.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/mountain3.xml b/packages/SystemUI/res/drawable-nodpi/mountain3.xml new file mode 100644 index 0000000000000..02942d7df4bd3 --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/mountain3.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/play.xml b/packages/SystemUI/res/drawable-nodpi/play.xml new file mode 100644 index 0000000000000..747e60ba4c762 --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/play.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/plus.xml b/packages/SystemUI/res/drawable-nodpi/plus.xml new file mode 100644 index 0000000000000..2bdb0b7ea4e5a --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/plus.xml @@ -0,0 +1,27 @@ + + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/ripplebg.xml b/packages/SystemUI/res/drawable-nodpi/ripplebg.xml new file mode 100644 index 0000000000000..21c66eb2178d2 --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/ripplebg.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/packages/SystemUI/res/drawable-nodpi/scorecard.xml b/packages/SystemUI/res/drawable-nodpi/scorecard.xml new file mode 100644 index 0000000000000..f22ec7b135343 --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/scorecard.xml @@ -0,0 +1,10 @@ + + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/scorecard_gameover.xml b/packages/SystemUI/res/drawable-nodpi/scorecard_gameover.xml new file mode 100644 index 0000000000000..f663a661f3f16 --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/scorecard_gameover.xml @@ -0,0 +1,10 @@ + + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/star.xml b/packages/SystemUI/res/drawable-nodpi/star.xml new file mode 100644 index 0000000000000..73ca04a583734 --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/star.xml @@ -0,0 +1,24 @@ + + + + diff --git a/packages/SystemUI/res/drawable-nodpi/sun.xml b/packages/SystemUI/res/drawable-nodpi/sun.xml new file mode 100644 index 0000000000000..3e4a233c3281e --- /dev/null +++ b/packages/SystemUI/res/drawable-nodpi/sun.xml @@ -0,0 +1,29 @@ + + + + + + + diff --git a/packages/SystemUI/res/layout/lland.xml b/packages/SystemUI/res/layout/lland.xml deleted file mode 100644 index 71a16c9e34074..0000000000000 --- a/packages/SystemUI/res/layout/lland.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - diff --git a/packages/SystemUI/res/layout/mland.xml b/packages/SystemUI/res/layout/mland.xml new file mode 100644 index 0000000000000..d1b6d002effee --- /dev/null +++ b/packages/SystemUI/res/layout/mland.xml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + diff --git a/packages/SystemUI/res/layout/mland_scorefield.xml b/packages/SystemUI/res/layout/mland_scorefield.xml new file mode 100644 index 0000000000000..0ed72e43b40a6 --- /dev/null +++ b/packages/SystemUI/res/layout/mland_scorefield.xml @@ -0,0 +1,32 @@ + + + diff --git a/packages/SystemUI/res/values/lland_strings.xml b/packages/SystemUI/res/values/lland_strings.xml deleted file mode 100644 index ce88157d2dac3..0000000000000 --- a/packages/SystemUI/res/values/lland_strings.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - L Land - diff --git a/packages/SystemUI/res/values/lland_config.xml b/packages/SystemUI/res/values/mland_config.xml similarity index 52% rename from packages/SystemUI/res/values/lland_config.xml rename to packages/SystemUI/res/values/mland_config.xml index a9e732e32a05b..0ca88aed42ea6 100644 --- a/packages/SystemUI/res/values/lland_config.xml +++ b/packages/SystemUI/res/values/mland_config.xml @@ -1,33 +1,30 @@ + Copyright (C) 2015 The Android Open Source Project + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> 380dp 100dp 550dp 40dp 40dp - 90dp - 12dp - 170dp + 130dp + 8dp + 140dp 48dp - 20dp + 50dp 250dp 20dp 10dp @@ -42,5 +39,5 @@ 18dp 18dp 20dp - 35dp + 10dp diff --git a/packages/SystemUI/res/values/mland_strings.xml b/packages/SystemUI/res/values/mland_strings.xml new file mode 100644 index 0000000000000..fada1aeab7959 --- /dev/null +++ b/packages/SystemUI/res/values/mland_strings.xml @@ -0,0 +1,20 @@ + + + + + Marshmallow Land + diff --git a/packages/SystemUI/src/com/android/systemui/egg/LLandActivity.java b/packages/SystemUI/src/com/android/systemui/egg/LLandActivity.java deleted file mode 100644 index 50221d301d87a..0000000000000 --- a/packages/SystemUI/src/com/android/systemui/egg/LLandActivity.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.egg; - -import android.app.Activity; -import android.os.Bundle; -import android.widget.TextView; - -import com.android.systemui.R; - -public class LLandActivity extends Activity { - LLand mLand; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.lland); - mLand = (LLand) findViewById(R.id.world); - mLand.setScoreField((TextView) findViewById(R.id.score)); - mLand.setSplash(findViewById(R.id.welcome)); - //Log.v(LLand.TAG, "focus: " + mLand.requestFocus()); - } - - @Override - public void onPause() { - mLand.stop(); - super.onPause(); - } -} diff --git a/packages/SystemUI/src/com/android/systemui/egg/LLand.java b/packages/SystemUI/src/com/android/systemui/egg/MLand.java similarity index 54% rename from packages/SystemUI/src/com/android/systemui/egg/LLand.java rename to packages/SystemUI/src/com/android/systemui/egg/MLand.java index fa257b17fb432..b84777b570601 100644 --- a/packages/SystemUI/src/com/android/systemui/egg/LLand.java +++ b/packages/SystemUI/src/com/android/systemui/egg/MLand.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014 The Android Open Source Project + * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ package com.android.systemui.egg; +import android.animation.LayoutTransition; import android.animation.TimeAnimator; import android.content.Context; import android.content.res.Resources; @@ -26,6 +27,7 @@ import android.graphics.Outline; import android.graphics.Paint; import android.graphics.Path; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.graphics.drawable.GradientDrawable; @@ -35,49 +37,51 @@ import android.os.Vibrator; import android.util.AttributeSet; import android.util.Log; import android.view.Gravity; +import android.view.InputDevice; import android.view.KeyEvent; +import android.view.LayoutInflater; import android.view.MotionEvent; -import android.util.Slog; import android.view.View; +import android.view.ViewGroup; import android.view.ViewOutlineProvider; -import android.view.animation.DecelerateInterpolator; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.TextView; -import com.android.systemui.R; - import java.util.ArrayList; -public class LLand extends FrameLayout { - public static final String TAG = "LLand"; +import com.android.internal.logging.MetricsLogger; + +import com.android.systemui.R; + +// It's like LLand, but "M"ultiplayer. +public class MLand extends FrameLayout { + public static final String TAG = "MLand"; public static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); public static final boolean DEBUG_DRAW = false; // DEBUG + public static final boolean SHOW_TOUCHES = true; + public static void L(String s, Object ... objects) { if (DEBUG) { - Slog.d(TAG, objects.length == 0 ? s : String.format(s, objects)); + Log.d(TAG, objects.length == 0 ? s : String.format(s, objects)); } } + public static final float PI_2 = (float) (Math.PI/2); + public static final boolean AUTOSTART = true; public static final boolean HAVE_STARS = true; - public static final float DEBUG_SPEED_MULTIPLIER = 1f; // 0.1f; + public static final float DEBUG_SPEED_MULTIPLIER = 0.5f; // only if DEBUG public static final boolean DEBUG_IDDQD = Log.isLoggable(TAG + ".iddqd", Log.DEBUG); - final static int[] POPS = { - // resid // spinny! // alpha - R.drawable.pop_belt, 0, 255, - R.drawable.pop_droid, 0, 255, - R.drawable.pop_pizza, 1, 255, - R.drawable.pop_stripes, 0, 255, - R.drawable.pop_swirl, 1, 255, - R.drawable.pop_vortex, 1, 255, - R.drawable.pop_vortex2, 1, 255, - R.drawable.pop_ball, 0, 190, - }; + public static final int DEFAULT_PLAYERS = 1; + public static final int MIN_PLAYERS = 1; + public static final int MAX_PLAYERS = 6; + + static final float CONTROLLER_VIBRATION_MULTIPLIER = 2f; private static class Params { public float TRANSLATION_PER_SEC; @@ -125,7 +129,7 @@ public class LLand extends FrameLayout { // Sanity checking if (OBSTACLE_MIN <= OBSTACLE_WIDTH / 2) { - Slog.e(TAG, "error: obstacles might be too short, adjusting"); + L("error: obstacles might be too short, adjusting"); OBSTACLE_MIN = OBSTACLE_WIDTH / 2 + 1; } } @@ -137,21 +141,24 @@ public class LLand extends FrameLayout { private final AudioAttributes mAudioAttrs = new AudioAttributes.Builder() .setUsage(AudioAttributes.USAGE_GAME).build(); - private TextView mScoreField; private View mSplash; + private ViewGroup mScoreFields; - private Player mDroid; + private ArrayList mPlayers = new ArrayList(); private ArrayList mObstaclesInPlay = new ArrayList(); private float t, dt; - private int mScore; private float mLastPipeTime; // in sec + private int mCurrentPipeId; // basically, equivalent to the current score private int mWidth, mHeight; private boolean mAnimating, mPlaying; private boolean mFrozen; // after death, a short backoff + private int mCountdown = 0; private boolean mFlipped; + private int mTaps; + private int mTimeOfDay; private static final int DAY = 0, NIGHT = 1, TWILIGHT = 2, SUNSET = 3; private static final int[][] SKIES = { @@ -161,26 +168,62 @@ public class LLand extends FrameLayout { { 0xFFa08020, 0xFF204080 }, // SUNSET }; + private int mScene; + private static final int SCENE_CITY = 0, SCENE_TX = 1, SCENE_ZRH = 2; + private static final int SCENE_COUNT = 3; + private static Params PARAMS; - public LLand(Context context) { + private static float dp = 1f; + + private Paint mTouchPaint, mPlayerTracePaint; + + private ArrayList mGameControllers = new ArrayList<>(); + + public MLand(Context context) { this(context, null); } - public LLand(Context context, AttributeSet attrs) { + public MLand(Context context, AttributeSet attrs) { this(context, attrs, 0); } - public LLand(Context context, AttributeSet attrs, int defStyle) { + public MLand(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); + mVibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); setFocusable(true); PARAMS = new Params(getResources()); - mTimeOfDay = irand(0, SKIES.length); + mTimeOfDay = irand(0, SKIES.length - 1); + mScene = irand(0, SCENE_COUNT); + + mTouchPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mTouchPaint.setColor(0x80FFFFFF); + mTouchPaint.setStyle(Paint.Style.FILL); + + mPlayerTracePaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mPlayerTracePaint.setColor(0x80FFFFFF); + mPlayerTracePaint.setStyle(Paint.Style.STROKE); + mPlayerTracePaint.setStrokeWidth(2 * dp); // we assume everything will be laid out left|top setLayoutDirection(LAYOUT_DIRECTION_LTR); + + setupPlayers(DEFAULT_PLAYERS); + + MetricsLogger.count(getContext(), "egg_mland_create", 1); + } + + @Override + public void onAttachedToWindow() { + super.onAttachedToWindow(); + dp = getResources().getDisplayMetrics().density; + + reset(); + if (AUTOSTART) { + start(false); + } } @Override @@ -193,13 +236,18 @@ public class LLand extends FrameLayout { public float getGameTime() { return t; } public float getLastTimeStep() { return dt; } - public void setScoreField(TextView tv) { - mScoreField = tv; - if (tv != null) { - tv.setTranslationZ(PARAMS.HUD_Z); - if (!(mAnimating && mPlaying)) { - tv.setTranslationY(-500); - } + public void setScoreFieldHolder(ViewGroup vg) { + mScoreFields = vg; + if (vg != null) { + final LayoutTransition lt = new LayoutTransition(); + lt.setDuration(250); + mScoreFields.setLayoutTransition(lt); + } + for (Player p : mPlayers) { + mScoreFields.addView(p.mScoreField, + new MarginLayoutParams( + MarginLayoutParams.WRAP_CONTENT, + MarginLayoutParams.MATCH_PARENT)); } } @@ -207,23 +255,134 @@ public class LLand extends FrameLayout { mSplash = v; } + public static boolean isGamePad(InputDevice dev) { + int sources = dev.getSources(); + + // Verify that the device has gamepad buttons, control sticks, or both. + return (((sources & InputDevice.SOURCE_GAMEPAD) == InputDevice.SOURCE_GAMEPAD) + || ((sources & InputDevice.SOURCE_JOYSTICK) == InputDevice.SOURCE_JOYSTICK)); + } + + public ArrayList getGameControllers() { + mGameControllers.clear(); + int[] deviceIds = InputDevice.getDeviceIds(); + for (int deviceId : deviceIds) { + InputDevice dev = InputDevice.getDevice(deviceId); + if (isGamePad(dev)) { + if (!mGameControllers.contains(deviceId)) { + mGameControllers.add(deviceId); + } + } + } + return mGameControllers; + } + + public int getControllerPlayer(int id) { + final int player = mGameControllers.indexOf(id); + if (player < 0 || player >= mPlayers.size()) return 0; + return player; + } + @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { + dp = getResources().getDisplayMetrics().density; + stop(); + reset(); if (AUTOSTART) { start(false); } } - final float hsv[] = {0, 0, 0}; + final static float hsv[] = {0, 0, 0}; - private void thump() { + private static float luma(int bgcolor) { + return 0.2126f * (float) (bgcolor & 0xFF0000) / 0xFF0000 + + 0.7152f * (float) (bgcolor & 0xFF00) / 0xFF00 + + 0.0722f * (float) (bgcolor & 0xFF) / 0xFF; + } + + public Player getPlayer(int i) { + return i < mPlayers.size() ? mPlayers.get(i) : null; + } + + private int addPlayerInternal(Player p) { + mPlayers.add(p); + realignPlayers(); + TextView scoreField = (TextView) + LayoutInflater.from(getContext()).inflate(R.layout.mland_scorefield, null); + if (mScoreFields != null) { + mScoreFields.addView(scoreField, + new MarginLayoutParams( + MarginLayoutParams.WRAP_CONTENT, + MarginLayoutParams.MATCH_PARENT)); + } + p.setScoreField(scoreField); + return mPlayers.size()-1; + } + + private void removePlayerInternal(Player p) { + if (mPlayers.remove(p)) { + removeView(p); + mScoreFields.removeView(p.mScoreField); + realignPlayers(); + } + } + + private void realignPlayers() { + final int N = mPlayers.size(); + float x = (mWidth - (N-1) * PARAMS.PLAYER_SIZE) / 2; + for (int i=0; i 0) { + removePlayerInternal(mPlayers.get(0)); + } + } + + public void setupPlayers(int num) { + clearPlayers(); + for (int i=0; i 0.5f; setScaleX(mFlipped ? -1 : 1); - setScore(0); - int i = getChildCount(); while (i-->0) { final View v = getChildAt(i); @@ -249,6 +406,7 @@ public class LLand extends FrameLayout { } mObstaclesInPlay.clear(); + mCurrentPipeId = 0; mWidth = getWidth(); mHeight = getHeight(); @@ -297,16 +455,29 @@ public class LLand extends FrameLayout { } else if (r1 < 0.6 && !cloudless) { s = new Cloud(getContext()); } else { - s = new Building(getContext()); - - s.z = (float)i/N; - s.setTranslationZ(PARAMS.SCENERY_Z * (1+s.z)); + switch (mScene) { + case SCENE_ZRH: + s = new Mountain(getContext()); + break; + case SCENE_TX: + s = new Cactus(getContext()); + break; + case SCENE_CITY: + default: + s = new Building(getContext()); + break; + } + s.z = (float) i / N; + // no more shadows for these things + //s.setTranslationZ(PARAMS.SCENERY_Z * (1+s.z)); s.v = 0.85f * s.z; // buildings move proportional to their distance - hsv[0] = 175; - hsv[1] = 0.25f; - hsv[2] = 1 * s.z; - s.setBackgroundColor(Color.HSVToColor(hsv)); - s.h = irand(PARAMS.BUILDING_HEIGHT_MIN, mh); + if (mScene == SCENE_CITY) { + s.setBackgroundColor(Color.GRAY); + s.h = irand(PARAMS.BUILDING_HEIGHT_MIN, mh); + } + final int c = (int)(255f*s.z); + final Drawable bg = s.getBackground(); + if (bg != null) bg.setColorFilter(Color.rgb(c,c,c), PorterDuff.Mode.MULTIPLY); } final LayoutParams lp = new LayoutParams(s.w, s.h); if (s instanceof Building) { @@ -321,15 +492,21 @@ public class LLand extends FrameLayout { } } + addView(s, lp); s.setTranslationX(frand(-lp.width, mWidth + lp.width)); } - mDroid = new Player(getContext()); - mDroid.setX(mWidth / 2); - mDroid.setY(mHeight / 2); - addView(mDroid, new LayoutParams(PARAMS.PLAYER_SIZE, PARAMS.PLAYER_SIZE)); + for (Player p : mPlayers) { + addView(p); // put it back! + p.reset(); + } + realignPlayers(); + + if (mAnim != null) { + mAnim.cancel(); + } mAnim = new TimeAnimator(); mAnim.setTimeListener(new TimeAnimator.TimeListener() { @Override @@ -339,58 +516,107 @@ public class LLand extends FrameLayout { }); } - private void setScore(int score) { - mScore = score; - if (mScoreField != null) { - mScoreField.setText(DEBUG_IDDQD ? "??" : String.valueOf(score)); - } - } - - private void addScore(int incr) { - setScore(mScore + incr); - } - public void start(boolean startPlaying) { - L("start(startPlaying=%s)", startPlaying?"true":"false"); - if (startPlaying) { - mPlaying = true; + L("start(startPlaying=%s)", startPlaying ? "true" : "false"); + if (startPlaying && mCountdown <= 0) { + showSplash(); - t = 0; - // there's a sucker born every OBSTACLE_PERIOD - mLastPipeTime = getGameTime() - PARAMS.OBSTACLE_PERIOD; + mSplash.findViewById(R.id.play_button).setEnabled(false); - if (mSplash != null && mSplash.getAlpha() > 0f) { - mSplash.setTranslationZ(PARAMS.HUD_Z); - mSplash.animate().alpha(0).translationZ(0).setDuration(400); + final View playImage = mSplash.findViewById(R.id.play_button_image); + final TextView playText = (TextView) mSplash.findViewById(R.id.play_button_text); - mScoreField.animate().translationY(0) - .setInterpolator(new DecelerateInterpolator()) - .setDuration(1500); - } + playImage.animate().alpha(0f); + playText.animate().alpha(1f); - mScoreField.setTextColor(0xFFAAAAAA); - mScoreField.setBackgroundResource(R.drawable.scorecard); - mDroid.setVisibility(View.VISIBLE); - mDroid.setX(mWidth / 2); - mDroid.setY(mHeight / 2); - } else { - mDroid.setVisibility(View.GONE); + mCountdown = 3; + post(new Runnable() { + @Override + public void run() { + if (mCountdown == 0) { + startPlaying(); + } else { + postDelayed(this, 500); + } + playText.setText(String.valueOf(mCountdown)); + mCountdown--; + } + }); } + + for (Player p : mPlayers) { + p.setVisibility(View.INVISIBLE); + } + if (!mAnimating) { mAnim.start(); mAnimating = true; } } + public void hideSplash() { + if (mSplash != null && mSplash.getVisibility() == View.VISIBLE) { + mSplash.setClickable(false); + mSplash.animate().alpha(0).translationZ(0).setDuration(300).withEndAction( + new Runnable() { + @Override + public void run() { + mSplash.setVisibility(View.GONE); + } + } + ); + } + } + + public void showSplash() { + if (mSplash != null && mSplash.getVisibility() != View.VISIBLE) { + mSplash.setClickable(true); + mSplash.setAlpha(0f); + mSplash.setVisibility(View.VISIBLE); + mSplash.animate().alpha(1f).setDuration(1000); + mSplash.findViewById(R.id.play_button_image).setAlpha(1f); + mSplash.findViewById(R.id.play_button_text).setAlpha(0f); + mSplash.findViewById(R.id.play_button).setEnabled(true); + mSplash.findViewById(R.id.play_button).requestFocus(); + } + } + + public void startPlaying() { + mPlaying = true; + + t = 0; + // there's a sucker born every OBSTACLE_PERIOD + mLastPipeTime = getGameTime() - PARAMS.OBSTACLE_PERIOD; + + hideSplash(); + + realignPlayers(); + mTaps = 0; + + final int N = mPlayers.size(); + MetricsLogger.histogram(getContext(), "egg_mland_players", N); + for (int i=0; i0;) { - final Obstacle ob = mObstaclesInPlay.get(j); - if (mPlaying && ob.intersects(mDroid) && !DEBUG_IDDQD) { - L("player hit an obstacle"); - thump(); - stop(); - } else if (ob.cleared(mDroid)) { - if (ob instanceof Stem) passedBarrier = true; - mObstaclesInPlay.remove(j); - } - } + if (p.mAlive) { + // 2. Check for altitude + if (p.below(mHeight)) { + if (DEBUG_IDDQD) { + poke(i); + unpoke(i); + } else { + L("player %d hit the floor", i); + thump(i, 80); + p.die(); + } + } - if (mPlaying && passedBarrier) { - addScore(1); + // 3. Check for obstacles + int maxPassedStem = 0; + for (int j = mObstaclesInPlay.size(); j-- > 0; ) { + final Obstacle ob = mObstaclesInPlay.get(j); + if (ob.intersects(p) && !DEBUG_IDDQD) { + L("player hit an obstacle"); + thump(i, 80); + p.die(); + } else if (ob.cleared(p)) { + if (ob instanceof Stem) { + maxPassedStem = Math.max(maxPassedStem, ((Stem)ob).id); + } + } + } + + if (maxPassedStem > p.mScore) { + p.addScore(1); + } + } + + if (p.mAlive) livingPlayers++; + } + + if (livingPlayers == 0) { + stop(); + + MetricsLogger.count(getContext(), "egg_mland_taps", mTaps); + mTaps = 0; + final int playerCount = mPlayers.size(); + for (int pi=0; pi PARAMS.OBSTACLE_PERIOD) { mLastPipeTime = t; + mCurrentPipeId ++; final int obstacley = (int)(frand() * (mHeight - 2*PARAMS.OBSTACLE_MIN - PARAMS.OBSTACLE_GAP)) + PARAMS.OBSTACLE_MIN; @@ -523,11 +779,11 @@ public class LLand extends FrameLayout { p1.setTranslationY(-PARAMS.OBSTACLE_WIDTH); p1.setTranslationZ(PARAMS.OBSTACLE_Z); p1.setScaleX(0.25f); - p1.setScaleY(0.25f); + p1.setScaleY(-0.25f); p1.animate() .translationY(s1.h-inset) .scaleX(1f) - .scaleY(1f) + .scaleY(-1f) .setStartDelay(d1) .setDuration(250); mObstaclesInPlay.add(p1); @@ -568,18 +824,25 @@ public class LLand extends FrameLayout { mObstaclesInPlay.add(p2); } - if (DEBUG_DRAW) invalidate(); + if (SHOW_TOUCHES || DEBUG_DRAW) invalidate(); } - + @Override public boolean onTouchEvent(MotionEvent ev) { L("touch: %s", ev); - switch (ev.getAction()) { + final int actionIndex = ev.getActionIndex(); + final float x = ev.getX(actionIndex); + final float y = ev.getY(actionIndex); + int playerIndex = (int) (getNumPlayers() * (x / getWidth())); + if (mFlipped) playerIndex = getNumPlayers() - 1 - playerIndex; + switch (ev.getActionMasked()) { case MotionEvent.ACTION_DOWN: - poke(); + case MotionEvent.ACTION_POINTER_DOWN: + poke(playerIndex, x, y); return true; case MotionEvent.ACTION_UP: - unpoke(); + case MotionEvent.ACTION_POINTER_UP: + unpoke(playerIndex); return true; } return false; @@ -590,10 +853,10 @@ public class LLand extends FrameLayout { L("trackball: %s", ev); switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: - poke(); + poke(0); return true; case MotionEvent.ACTION_UP: - unpoke(); + unpoke(0); return true; } return false; @@ -608,7 +871,8 @@ public class LLand extends FrameLayout { case KeyEvent.KEYCODE_SPACE: case KeyEvent.KEYCODE_ENTER: case KeyEvent.KEYCODE_BUTTON_A: - poke(); + int player = getControllerPlayer(ev.getDeviceId()); + poke(player); return true; } return false; @@ -623,7 +887,8 @@ public class LLand extends FrameLayout { case KeyEvent.KEYCODE_SPACE: case KeyEvent.KEYCODE_ENTER: case KeyEvent.KEYCODE_BUTTON_A: - unpoke(); + int player = getControllerPlayer(ev.getDeviceId()); + unpoke(player); return true; } return false; @@ -635,47 +900,76 @@ public class LLand extends FrameLayout { return false; } - private void poke() { - L("poke"); + private void poke(int playerIndex) { + poke(playerIndex, -1, -1); + } + + private void poke(int playerIndex, float x, float y) { + L("poke(%d)", playerIndex); if (mFrozen) return; if (!mAnimating) { reset(); - start(true); - } else if (!mPlaying) { - start(true); } - mDroid.boost(); - if (DEBUG) { - mDroid.dv *= DEBUG_SPEED_MULTIPLIER; - mDroid.animate().setDuration((long) (200/DEBUG_SPEED_MULTIPLIER)); + if (!mPlaying) { + start(true); + } else { + final Player p = getPlayer(playerIndex); + if (p == null) return; // no player for this controller + p.boost(x, y); + mTaps++; + if (DEBUG) { + p.dv *= DEBUG_SPEED_MULTIPLIER; + p.animate().setDuration((long) (200 / DEBUG_SPEED_MULTIPLIER)); + } } } - private void unpoke() { - L("unboost"); - if (mFrozen) return; - if (!mAnimating) return; - mDroid.unboost(); + private void unpoke(int playerIndex) { + L("unboost(%d)", playerIndex); + if (mFrozen || !mAnimating || !mPlaying) return; + final Player p = getPlayer(playerIndex); + if (p == null) return; // no player for this controller + p.unboost(); } @Override public void onDraw(Canvas c) { super.onDraw(c); + if (SHOW_TOUCHES) { + for (Player p : mPlayers) { + if (p.mTouchX > 0) { + mTouchPaint.setColor(0x80FFFFFF & p.color); + mPlayerTracePaint.setColor(0x80FFFFFF & p.color); + float x1 = p.mTouchX; + float y1 = p.mTouchY; + c.drawCircle(x1, y1, 100, mTouchPaint); + float x2 = p.getX() + p.getPivotX(); + float y2 = p.getY() + p.getPivotY(); + float angle = PI_2 - (float) Math.atan2(x2-x1, y2-y1); + x1 += 100*Math.cos(angle); + y1 += 100*Math.sin(angle); + c.drawLine(x1, y1, x2, y2, mPlayerTracePaint); + } + } + } + if (!DEBUG_DRAW) return; final Paint pt = new Paint(); pt.setColor(0xFFFFFFFF); - final int L = mDroid.corners.length; - final int N = L/2; - for (int i=0; i 0.7f ? 0xFF000000 : 0xFFFFFFFF); + } + } + + public void reset() { + //setX(mLand.mWidth / 2); + setY(mLand.mHeight / 2 + + (int)(Math.random() * PARAMS.PLAYER_SIZE) + - PARAMS.PLAYER_SIZE / 2); + setScore(0); + setScoreField(mScoreField); // refresh color + mBoosting = false; + dv = 0; + } + public Player(Context context) { super(context); setBackgroundResource(R.drawable.android); getBackground().setTintMode(PorterDuff.Mode.SRC_ATOP); - getBackground().setTint(sColors[0]); + color = sColors[(sNextColor++%sColors.length)]; + getBackground().setTint(color); setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { @@ -774,7 +1126,11 @@ public class LLand extends FrameLayout { } public void step(long t_ms, long dt_ms, float t, float dt) { - if (getVisibility() != View.VISIBLE) return; // not playing yet + if (!mAlive) { + // float away with the garbage + setTranslationX(getTranslationX()-PARAMS.TRANSLATION_PER_SEC*dt); + return; + } if (mBoosting) { dv = -PARAMS.BOOST_DV; @@ -792,6 +1148,12 @@ public class LLand extends FrameLayout { prepareCheckIntersections(); } + public void boost(float x, float y) { + mTouchX = x; + mTouchY = y; + boost(); + } + public void boost() { mBoosting = true; dv = -PARAMS.BOOST_DV; @@ -808,6 +1170,7 @@ public class LLand extends FrameLayout { public void unboost() { mBoosting = false; + mTouchX = mTouchY = -1; animate().cancel(); animate() @@ -816,6 +1179,19 @@ public class LLand extends FrameLayout { .translationZ(PARAMS.PLAYER_Z) .setDuration(200); } + + public void die() { + mAlive = false; + if (mScoreField != null) { + //mScoreField.setTextColor(0xFFFFFFFF); + //mScoreField.getBackground().setColorFilter(0xFF666666, PorterDuff.Mode.SRC_ATOP); + //mScoreField.setBackgroundResource(R.drawable.scorecard_gameover); + } + } + + public void start() { + mAlive = true; + } } private class Obstacle extends View implements GameView { @@ -855,20 +1231,31 @@ public class LLand extends FrameLayout { } } + static final int[] ANTENNAE = new int[] {R.drawable.mm_antennae, R.drawable.mm_antennae2}; + static final int[] EYES = new int[] {R.drawable.mm_eyes, R.drawable.mm_eyes2}; + static final int[] MOUTHS = new int[] {R.drawable.mm_mouth1, R.drawable.mm_mouth2, + R.drawable.mm_mouth3, R.drawable.mm_mouth4}; private class Pop extends Obstacle { int mRotate; int cx, cy, r; + // The marshmallow illustration and hitbox is 2/3 the size of its container. + Drawable antenna, eyes, mouth; + + public Pop(Context context, float h) { super(context, h); - int idx = 3*irand(0, POPS.length/3); - setBackgroundResource(POPS[idx]); - setAlpha((float)(POPS[idx+2])/255); - setScaleX(frand() < 0.5f ? -1 : 1); - mRotate = POPS[idx+1] == 0 ? 0 : (frand() < 0.5f ? -1 : 1); + setBackgroundResource(R.drawable.mm_head); + antenna = context.getDrawable(pick(ANTENNAE)); + if (frand() > 0.5f) { + eyes = context.getDrawable(pick(EYES)); + if (frand() > 0.8f) { + mouth = context.getDrawable(pick(MOUTHS)); + } + } setOutlineProvider(new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { - final int pad = (int) (getWidth() * 0.02f); + final int pad = (int) (getWidth() * 1f/6); outline.setOval(pad, pad, getWidth()-pad, getHeight()-pad); } }); @@ -893,20 +1280,56 @@ public class LLand extends FrameLayout { cx = (hitRect.left + hitRect.right)/2; cy = (hitRect.top + hitRect.bottom)/2; - r = getWidth()/2; + r = getWidth() / 3; // see above re 2/3 container size + } + + @Override + public void onDraw(Canvas c) { + super.onDraw(c); + if (antenna != null) { + antenna.setBounds(0, 0, c.getWidth(), c.getHeight()); + antenna.draw(c); + } + if (eyes != null) { + eyes.setBounds(0, 0, c.getWidth(), c.getHeight()); + eyes.draw(c); + } + if (mouth != null) { + mouth.setBounds(0, 0, c.getWidth(), c.getHeight()); + mouth.draw(c); + } } } private class Stem extends Obstacle { Paint mPaint = new Paint(); Path mShadow = new Path(); + GradientDrawable mGradient = new GradientDrawable(); boolean mDrawShadow; + Path mJandystripe; + Paint mPaint2; + int id; // use this to track which pipes have been cleared public Stem(Context context, float h, boolean drawShadow) { super(context, h); + id = mCurrentPipeId; + mDrawShadow = drawShadow; - mPaint.setColor(0xFFAAAAAA); setBackground(null); + mGradient.setOrientation(GradientDrawable.Orientation.LEFT_RIGHT); + mPaint.setColor(0xFF000000); + mPaint.setColorFilter(new PorterDuffColorFilter(0x22000000, PorterDuff.Mode.MULTIPLY)); + + if (frand() < 0.01f) { + mGradient.setColors(new int[]{0xFFFFFFFF, 0xFFDDDDDD}); + mJandystripe = new Path(); + mPaint2 = new Paint(); + mPaint2.setColor(0xFFFF0000); + mPaint2.setColorFilter(new PorterDuffColorFilter(0xFFFF0000, PorterDuff.Mode.MULTIPLY)); + } else { + //mPaint.setColor(0xFFA1887F); + mGradient.setColors(new int[]{0xFFBCAAA4, 0xFFA1887F}); + } } @Override @@ -924,18 +1347,29 @@ public class LLand extends FrameLayout { public void onDraw(Canvas c) { final int w = c.getWidth(); final int h = c.getHeight(); - final GradientDrawable g = new GradientDrawable(); - g.setOrientation(GradientDrawable.Orientation.LEFT_RIGHT); - g.setGradientCenter(w * 0.75f, 0); - g.setColors(new int[] { 0xFFFFFFFF, 0xFFAAAAAA }); - g.setBounds(0, 0, w, h); - g.draw(c); + mGradient.setGradientCenter(w * 0.75f, 0); + mGradient.setBounds(0, 0, w, h); + mGradient.draw(c); + + if (mJandystripe != null) { + mJandystripe.reset(); + mJandystripe.moveTo(0, w); + mJandystripe.lineTo(w, 0); + mJandystripe.lineTo(w, 2 * w); + mJandystripe.lineTo(0, 3 * w); + mJandystripe.close(); + for (int y=0; y 0) { + mLand.setupPlayers(numControllers); + } + } + + public void updateSplashPlayers() { + final int N = mLand.getNumPlayers(); + final View minus = findViewById(R.id.player_minus_button); + final View plus = findViewById(R.id.player_plus_button); + if (N == 1) { + minus.setVisibility(View.INVISIBLE); + plus.setVisibility(View.VISIBLE); + plus.requestFocus(); + } else if (N == mLand.MAX_PLAYERS) { + minus.setVisibility(View.VISIBLE); + plus.setVisibility(View.INVISIBLE); + minus.requestFocus(); + } else { + minus.setVisibility(View.VISIBLE); + plus.setVisibility(View.VISIBLE); + } + } + + @Override + public void onPause() { + mLand.stop(); + super.onPause(); + } + + @Override + public void onResume() { + super.onResume(); + + mLand.onAttachedToWindow(); // resets and starts animation + updateSplashPlayers(); + mLand.showSplash(); + } + + public void playerMinus(View v) { + mLand.removePlayer(); + updateSplashPlayers(); + } + + public void playerPlus(View v) { + mLand.addPlayer(); + updateSplashPlayers(); + } + + public void startButtonPressed(View v) { + findViewById(R.id.player_minus_button).setVisibility(View.INVISIBLE); + findViewById(R.id.player_plus_button).setVisibility(View.INVISIBLE); + mLand.start(true); + } +} diff --git a/packages/SystemUI/src/com/android/systemui/egg/ShruggyActivity.java b/packages/SystemUI/src/com/android/systemui/egg/ShruggyActivity.java deleted file mode 100644 index 745995759be96..0000000000000 --- a/packages/SystemUI/src/com/android/systemui/egg/ShruggyActivity.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2015 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.egg; - -import android.app.Activity; -import android.os.Bundle; -import android.util.Log; -import android.widget.Toast; -import com.android.systemui.R; - -public class ShruggyActivity extends Activity { - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - Toast.makeText(this, getString(R.string.regrettable_lack_of_easter_egg), - Toast.LENGTH_SHORT).show(); - Log.v("SystemUI", "Hey, it's just a preview; what did you expect?"); - finish(); - } -}