Fragment sample test (#1328)
Summary: Wanted to have a way to test fragment support in open source for https://github.com/facebook/flipper/issues/1209. Stacked on https://github.com/facebook/flipper/issues/1327. Pull Request resolved: https://github.com/facebook/flipper/pull/1328 Test Plan:  Reviewed By: jknoxville Differential Revision: D22356283 Pulled By: passy fbshipit-source-id: 2ad84df0aae85634c8245e71f18b803ce8dd6ca0
This commit is contained in:
committed by
Facebook GitHub Bot
parent
74c9f8ea33
commit
51e7ce3566
@@ -47,6 +47,14 @@
|
||||
<data android:scheme="flipper" android:host="layout_test_activity" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".FragmentTestActivity">
|
||||
<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="fragment_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"
|
||||
|
||||
@@ -50,6 +50,7 @@ dependencies {
|
||||
implementation deps.lithoWidget
|
||||
implementation deps.lithoAnnotations
|
||||
implementation deps.lithoFresco
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
annotationProcessor deps.lithoProcessor
|
||||
|
||||
// Third-party
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
public class FragmentTestActivity extends AppCompatActivity {
|
||||
@Override
|
||||
protected void onCreate(final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
NavigationFacade.sendNavigationEvent("flipper://fragment_test_activity/");
|
||||
setContentView(com.facebook.flipper.sample.R.layout.fragment_test_activity);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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 android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
public class FragmentTestFragment extends Fragment {
|
||||
|
||||
public FragmentTestFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(
|
||||
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_test, container, false);
|
||||
}
|
||||
}
|
||||
@@ -85,10 +85,17 @@ public class RootComponentSpec {
|
||||
.clickHandler(RootComponent.openAlternateLayoutTestActivity(c)))
|
||||
.child(
|
||||
Text.create(c)
|
||||
.text("Crash this app")
|
||||
.text("Navigate to fragment test page")
|
||||
.key("8")
|
||||
.marginDip(YogaEdge.ALL, 10)
|
||||
.textSizeSp(20)
|
||||
.clickHandler(RootComponent.openFragmentTestActivity(c)))
|
||||
.child(
|
||||
Text.create(c)
|
||||
.text("Crash this app")
|
||||
.key("9")
|
||||
.marginDip(YogaEdge.ALL, 10)
|
||||
.textSizeSp(20)
|
||||
.clickHandler(RootComponent.triggerCrash(c)))
|
||||
.child(
|
||||
displayImage
|
||||
@@ -134,6 +141,12 @@ public class RootComponentSpec {
|
||||
c.getAndroidContext().startActivity(intent);
|
||||
}
|
||||
|
||||
@OnEvent(ClickEvent.class)
|
||||
static void openFragmentTestActivity(final ComponentContext c) {
|
||||
final Intent intent = new Intent(c.getAndroidContext(), FragmentTestActivity.class);
|
||||
c.getAndroidContext().startActivity(intent);
|
||||
}
|
||||
|
||||
@OnEvent(ClickEvent.class)
|
||||
static void triggerCrash(final ComponentContext c) {
|
||||
throw new RuntimeException("Artificially triggered crash from Flipper sample app");
|
||||
|
||||
13
android/sample/src/main/res/layout/fragment_test.xml
Normal file
13
android/sample/src/main/res/layout/fragment_test.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout 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"
|
||||
tools:context=".FragmentTestFragment">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/hello_blank_fragment" />
|
||||
|
||||
</FrameLayout>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<fragment
|
||||
android:id="@+id/fragment_test_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:name="com.facebook.flipper.sample.FragmentTestFragment"/>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -8,5 +8,6 @@
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<string name="app_name">Flipper</string>
|
||||
<string name="app_name">Flipper</string>
|
||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user