Commit 0513eb42 authored by Mehran Mahmoudi's avatar Mehran Mahmoudi Committed by Commit Bot

[Touchless] Add splash screen for DinoActivity

Mock: https://docs.google.com/presentation/d/1X29NR8smO_P3cNJCGHpASPOOyj20IpR4ztHPNGWFtFo/edit?hl=en#slide=id.g5b4b9a286c_0_24
Implementation: https://drive.google.com/file/d/1lDS_tUembnk8qIu0VpJhLui_rO5ujFep/view?usp=sharing

Bug: 957992
Change-Id: I7764694b60ba15adcdf4f023a9c4d14f825423af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1647686Reviewed-by: default avatarPeter Kotwicz <pkotwicz@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Commit-Queue: Mehran Mahmoudi <mahmoudi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#668529}
parent e97462fe
...@@ -378,8 +378,7 @@ by a child template that "extends" this file. ...@@ -378,8 +378,7 @@ by a child template that "extends" this file.
<activity android:name="org.chromium.chrome.browser.touchless.DinoActivity" <activity android:name="org.chromium.chrome.browser.touchless.DinoActivity"
android:theme="@style/Theme.Chromium.Activity" android:theme="@style/Theme.Chromium.Activity"
android:icon="@mipmap/dino" android:icon="@mipmap/dino"
## Proposed brand name, not to be localized. android:label="@string/dino_game_title"
android:label="Dino Run"
android:exported="false" android:exported="false"
android:persistableMode="persistNever" android:persistableMode="persistNever"
android:launchMode="singleTask" android:launchMode="singleTask"
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2019 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false" android:visible="true">
<item android:drawable="@drawable/dino_stomp_1" android:duration="1000"/>
<item android:drawable="@drawable/dino_stomp_2" android:duration="500"/>
</animation-list>
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2019 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file. -->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
tools:ignore="contentDescription,UselessParent">
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical">
<ImageView android:id="@+id/dino_animation_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:src="@drawable/dino_splash_animation"/>
<TextView style="@style/TextAppearance.BlackTitle1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="35dp"
android:text="@string/dino_game_title"/>
<TextView style="@style/TextAppearance.DinoSubtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="4dp"
android:text="@string/twa_running_in_chrome"/>
</LinearLayout>
</RelativeLayout>
\ No newline at end of file
...@@ -14,6 +14,11 @@ ...@@ -14,6 +14,11 @@
<item name="android:textColor">@android:color/white</item> <item name="android:textColor">@android:color/white</item>
</style> </style>
<style name="TextAppearance.DinoSubtitle">
<item name="android:textSize">14sp</item>
<item name="android:textColor">@color/default_text_color_secondary</item>
</style>
<style name="PreferenceActionBarModern.Touchless"> <style name="PreferenceActionBarModern.Touchless">
<item name="titleTextStyle">@style/TextAppearance.BlackTitle1</item> <item name="titleTextStyle">@style/TextAppearance.BlackTitle1</item>
</style> </style>
......
...@@ -5,23 +5,51 @@ ...@@ -5,23 +5,51 @@
package org.chromium.chrome.browser.touchless; package org.chromium.chrome.browser.touchless;
import android.content.Intent; import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle; import android.os.Bundle;
import android.support.design.widget.CoordinatorLayout;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView;
import org.chromium.chrome.browser.ChromeActivity; import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.SingleTabActivity; import org.chromium.chrome.browser.SingleTabActivity;
import org.chromium.chrome.browser.compositor.layouts.LayoutManager; import org.chromium.chrome.browser.compositor.layouts.LayoutManager;
import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager; import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager;
import org.chromium.chrome.browser.tab.EmptyTabObserver;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabState; import org.chromium.chrome.browser.tab.TabState;
import org.chromium.chrome.browser.util.UrlConstants; import org.chromium.chrome.browser.util.UrlConstants;
import org.chromium.chrome.touchless.R;
import org.chromium.content_public.browser.LoadUrlParams; import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.ui.UiUtils;
import org.chromium.ui.base.PageTransition; import org.chromium.ui.base.PageTransition;
/** /**
* An Activity used to display the Dino Run game. * An Activity used to display the Dino Run game.
*/ */
public class DinoActivity extends SingleTabActivity { public class DinoActivity extends SingleTabActivity {
private View mSplashView;
@Override
protected void doLayoutInflation() {
super.doLayoutInflation();
mSplashView = LayoutInflater.from(this).inflate(R.layout.dino_splash_view, null);
mSplashView.addOnLayoutChangeListener(
(v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
ImageView dinoImage = v.findViewById(R.id.dino_animation_image);
AnimationDrawable dinoAnimation = (AnimationDrawable) dinoImage.getDrawable();
dinoAnimation.start();
});
ViewGroup coordinatorLayout = (ViewGroup) findViewById(R.id.coordinator);
CoordinatorLayout.LayoutParams layoutParams =
new CoordinatorLayout.LayoutParams(CoordinatorLayout.LayoutParams.MATCH_PARENT,
CoordinatorLayout.LayoutParams.MATCH_PARENT);
mSplashView.setLayoutParams(layoutParams);
coordinatorLayout.addView(mSplashView);
}
@Override @Override
public void finishNativeInitialization() { public void finishNativeInitialization() {
initializeCompositorContent(new LayoutManager(getCompositorViewHolder()), null /* urlBar */, initializeCompositorContent(new LayoutManager(getCompositorViewHolder()), null /* urlBar */,
...@@ -37,6 +65,12 @@ public class DinoActivity extends SingleTabActivity { ...@@ -37,6 +65,12 @@ public class DinoActivity extends SingleTabActivity {
loadUrlParams.setHasUserGesture(true); loadUrlParams.setHasUserGesture(true);
loadUrlParams.setTransitionType(PageTransition.LINK | PageTransition.FROM_API); loadUrlParams.setTransitionType(PageTransition.LINK | PageTransition.FROM_API);
tab.loadUrl(loadUrlParams); tab.loadUrl(loadUrlParams);
tab.addObserver(new EmptyTabObserver() {
@Override
public void onPageLoadFinished(Tab tab, String url) {
UiUtils.removeViewFromParent(mSplashView);
}
});
return tab; return tab;
} }
......
...@@ -135,6 +135,9 @@ ...@@ -135,6 +135,9 @@
<message name="IDS_MENU_ADD_TO_APPS" desc="Text to accompany icon that will navigate to a page showing a categorized view of different applications or sites"> <message name="IDS_MENU_ADD_TO_APPS" desc="Text to accompany icon that will navigate to a page showing a categorized view of different applications or sites">
Add to My apps Add to My apps
</message> </message>
<message name="IDS_DINO_GAME_TITLE" desc="Title for the offline dino game that will appear as an icon in the launcher">
Game
</message>
</messages> </messages>
</release> </release>
</grit> </grit>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment