(client) Add Another Activity to Sample App to Test The Functionality

Summary: - add another activity where there are two component overlapping each other

Reviewed By: mweststrate

Differential Revision: D21040425

fbshipit-source-id: 5514b59140bbf6b726e6777191e1808be5ac5b6f
This commit is contained in:
Chaiwat Ekkaewnumchai
2020-05-07 03:37:49 -07:00
committed by Facebook GitHub Bot
parent f06dc46c06
commit d7172df082
3 changed files with 63 additions and 1 deletions

View File

@@ -39,6 +39,14 @@
<data android:scheme="flipper" android:host="deep_link_activity" />
</intent-filter>
</activity>
<activity android:name=".LayoutTestActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="flipper" android:host="layout_test_activity" />
</intent-filter>
</activity>
<activity android:name="com.facebook.flipper.android.diagnostics.FlipperDiagnosticActivity"
android:exported="true"/>
<activity android:name="com.facebook.flipper.connectivitytest.ConnectionTestActivity"

View File

@@ -0,0 +1,41 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.flipper.sample;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import com.facebook.litho.Column;
import com.facebook.litho.Component;
import com.facebook.litho.ComponentContext;
import com.facebook.litho.LithoView;
import com.facebook.litho.widget.Text;
import com.facebook.yoga.YogaEdge;
import com.facebook.yoga.YogaPositionType;
public class LayoutTestActivity extends AppCompatActivity {
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
NavigationFacade.sendNavigationEvent("flipper://layout_test_activity/");
final ComponentContext context = new ComponentContext(this);
final Component component =
Column.create(context)
.child(Text.create(context).text("This is a page to test layout").textSizeDip(20))
.child(
Text.create(context)
.text("This is another welcome text")
.textSizeDip(20)
.positionDip(YogaEdge.TOP, 10)
.positionType(YogaPositionType.ABSOLUTE))
.build();
setContentView(LithoView.create(context, component));
}
}

View File

@@ -78,10 +78,17 @@ public class RootComponentSpec {
.clickHandler(RootComponent.openAlternateActivityOne(c)))
.child(
Text.create(c)
.text("Crash this app")
.text("Navigate to layout test page")
.key("7")
.marginDip(YogaEdge.ALL, 10)
.textSizeSp(20)
.clickHandler(RootComponent.openAlternateLayoutTestActivity(c)))
.child(
Text.create(c)
.text("Crash this app")
.key("8")
.marginDip(YogaEdge.ALL, 10)
.textSizeSp(20)
.clickHandler(RootComponent.triggerCrash(c)))
.child(
displayImage
@@ -121,6 +128,12 @@ public class RootComponentSpec {
c.getAndroidContext().startActivity(intent);
}
@OnEvent(ClickEvent.class)
static void openAlternateLayoutTestActivity(final ComponentContext c) {
final Intent intent = new Intent(c.getAndroidContext(), LayoutTestActivity.class);
c.getAndroidContext().startActivity(intent);
}
@OnEvent(ClickEvent.class)
static void triggerCrash(final ComponentContext c) {
throw new RuntimeException("Artificially triggered crash from Flipper sample app");