Additional test activities

Summary: Some activities for testing the UI debugger

Reviewed By: lblasa

Differential Revision: D39208140

fbshipit-source-id: a6fcc1f082df5dc61f72019f92a6307d0e90176e
This commit is contained in:
Luke De Feo
2022-09-07 04:37:17 -07:00
committed by Facebook GitHub Bot
parent 41068d1c90
commit 0426966b14
13 changed files with 530 additions and 81 deletions

View File

@@ -51,6 +51,24 @@
<data android:scheme="flipper" android:host="layout_test_activity" /> <data android:scheme="flipper" android:host="layout_test_activity" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".ListActivity"
android:exported="true">
<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="list_activity" />
</intent-filter>
</activity>
<activity android:name=".AnimationsActivity"
android:exported="true">
<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="animations_activity" />
</intent-filter>
</activity>
<activity android:name=".FragmentTestActivity" <activity android:name=".FragmentTestActivity"
android:exported="true"> android:exported="true">
<intent-filter> <intent-filter>

View File

@@ -0,0 +1,91 @@
/*
* Copyright (c) Meta Platforms, Inc. and 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.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.TextView;
public class AnimationsActivity extends Activity {
Button btnBlink, btnRotate, btnMove, btnBounce, btnSequential;
Animation animBlink, animRotate, animMove, animBounce, animSequential;
TextView txtBlink, txtRotate, txtMove, txtBounce, txtSeq;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_animations);
btnBlink = (Button) findViewById(R.id.btnBlink);
btnRotate = (Button) findViewById(R.id.btnRotate);
btnMove = (Button) findViewById(R.id.btnMove);
btnBounce = (Button) findViewById(R.id.btnBounce);
btnSequential = (Button) findViewById(R.id.btnSequential);
txtBlink = (TextView) findViewById(R.id.txt_blink);
txtRotate = (TextView) findViewById(R.id.txt_rotate);
txtMove = (TextView) findViewById(R.id.txt_move);
txtBounce = (TextView) findViewById(R.id.txt_bounce);
txtSeq = (TextView) findViewById(R.id.txt_seq);
animBlink = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.blink);
// blink
btnBlink.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
txtBlink.setVisibility(View.VISIBLE);
txtBlink.startAnimation(animBlink);
}
});
animRotate = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.rotate);
// Rotate
btnRotate.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
txtRotate.startAnimation(animRotate);
}
});
animMove = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.move);
// Move
btnMove.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
txtMove.startAnimation(animMove);
}
});
animBounce = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.bounce);
// Slide Down
btnBounce.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
txtBounce.startAnimation(animBounce);
}
});
animSequential = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.sequential);
// Sequential
btnSequential.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
txtSeq.startAnimation(animSequential);
}
});
}
}

View File

@@ -11,17 +11,51 @@ import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
public class FragmentTestFragment extends Fragment { public class FragmentTestFragment extends Fragment {
View mView;
int mTicker;
public FragmentTestFragment() { public FragmentTestFragment() {
// Required empty public constructor mTicker = 0;
}
private void updateTicker() {
try {
ViewGroup viewGroup = (ViewGroup) mView;
TextView textView = (TextView) viewGroup.getChildAt(1);
String text = String.valueOf(mTicker++);
textView.setText(text);
} finally {
// 100% guarantee that this always happens, even if
// your update method throws an exception
mView.postDelayed(
new Runnable() {
@Override
public void run() {
updateTicker();
}
},
10000);
}
} }
@Override @Override
public View onCreateView( public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_test, container, false); mView = inflater.inflate(R.layout.fragment_test, container, false);
mView.postDelayed(
new Runnable() {
@Override
public void run() {
updateTicker();
}
},
1000);
return mView;
} }
} }

View File

@@ -0,0 +1,52 @@
/*
* Copyright (c) Meta Platforms, Inc. and 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.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.util.ArrayList;
public class ListActivity extends Activity {
ListView listView;
ArrayList<String> list;
ArrayAdapter<String> adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list);
listView = (ListView) findViewById(R.id.list);
list = new ArrayList<>();
list.add("Apple");
list.add("Banana");
list.add("Pineapple");
list.add("Orange");
list.add("Lychee");
list.add("Guava");
list.add("Peech");
list.add("Melon");
list.add("Watermelon");
list.add("Papaya");
list.add("Grape");
list.add("Apricot");
list.add("Coconut");
list.add("Banana");
list.add("Cherry");
list.add("Pear");
list.add("Mango");
list.add("Plum");
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, list);
listView.setAdapter(adapter);
}
}

View File

@@ -24,6 +24,7 @@ import com.facebook.litho.annotations.OnUpdateState;
import com.facebook.litho.annotations.State; import com.facebook.litho.annotations.State;
import com.facebook.litho.fresco.FrescoImage; import com.facebook.litho.fresco.FrescoImage;
import com.facebook.litho.widget.Text; import com.facebook.litho.widget.Text;
import com.facebook.litho.widget.VerticalScroll;
import com.facebook.yoga.YogaEdge; import com.facebook.yoga.YogaEdge;
@LayoutSpec @LayoutSpec
@@ -33,24 +34,26 @@ public class RootComponentSpec {
static Component onCreateLayout(final ComponentContext c, @State boolean displayImage) { static Component onCreateLayout(final ComponentContext c, @State boolean displayImage) {
final DraweeController controller = final DraweeController controller =
Fresco.newDraweeControllerBuilder().setUri("https://fbflipper.com/img/icon.png").build(); Fresco.newDraweeControllerBuilder().setUri("https://fbflipper.com/img/icon.png").build();
return Column.create(c)
Column col =
Column.create(c)
.child( .child(
Text.create(c) Text.create(c)
.text("Send GET request") .text("Send HTTP/GET request")
.key("1") .key("1")
.marginDip(YogaEdge.ALL, 10) .marginDip(YogaEdge.ALL, 10)
.textSizeSp(20) .textSizeSp(20)
.clickHandler(RootComponent.hitGetRequest(c))) .clickHandler(RootComponent.hitGetRequest(c)))
.child( .child(
Text.create(c) Text.create(c)
.text("Send POST request") .text("Send HTTP/POST request")
.key("2") .key("2")
.marginDip(YogaEdge.ALL, 10) .marginDip(YogaEdge.ALL, 10)
.textSizeSp(20) .textSizeSp(20)
.clickHandler(RootComponent.hitPostRequest(c))) .clickHandler(RootComponent.hitPostRequest(c)))
.child( .child(
Text.create(c) Text.create(c)
.text("Trigger Notification") .text("Trigger notification")
.key("3") .key("3")
.marginDip(YogaEdge.ALL, 10) .marginDip(YogaEdge.ALL, 10)
.textSizeSp(20) .textSizeSp(20)
@@ -92,20 +95,34 @@ public class RootComponentSpec {
.clickHandler(RootComponent.openFragmentTestActivity(c))) .clickHandler(RootComponent.openFragmentTestActivity(c)))
.child( .child(
Text.create(c) Text.create(c)
.text("Crash this app") .text("Navigate to list activity")
.key("9") .key("9")
.marginDip(YogaEdge.ALL, 10) .marginDip(YogaEdge.ALL, 10)
.textSizeSp(20) .textSizeSp(20)
.clickHandler(RootComponent.openListActivity(c)))
.child(
Text.create(c)
.text("Navigate to animations activity")
.key("10")
.marginDip(YogaEdge.ALL, 10)
.textSizeSp(20)
.clickHandler(RootComponent.openAnimationsActivity(c)))
.child(
Text.create(c)
.text("Crash this app")
.key("11")
.marginDip(YogaEdge.ALL, 10)
.textSizeSp(20)
.clickHandler(RootComponent.triggerCrash(c))) .clickHandler(RootComponent.triggerCrash(c)))
.child( .child(
displayImage FrescoImage.create(c)
? FrescoImage.create(c)
.controller(controller) .controller(controller)
.marginDip(YogaEdge.ALL, 10) .marginDip(YogaEdge.ALL, 10)
.widthDip(150) .widthDip(150)
.heightDip(150) .heightDip(150))
: null)
.build(); .build();
return VerticalScroll.create(c).childComponent(col).build();
} }
@OnEvent(ClickEvent.class) @OnEvent(ClickEvent.class)
@@ -161,4 +178,16 @@ public class RootComponentSpec {
static void loadImage(final ComponentContext c) { static void loadImage(final ComponentContext c) {
RootComponent.updateDisplayImageAsync(c); RootComponent.updateDisplayImageAsync(c);
} }
@OnEvent(ClickEvent.class)
static void openListActivity(final ComponentContext c) {
final Intent intent = new Intent(c.getAndroidContext(), ListActivity.class);
c.getAndroidContext().startActivity(intent);
}
@OnEvent(ClickEvent.class)
static void openAnimationsActivity(final ComponentContext c) {
final Intent intent = new Intent(c.getAndroidContext(), AnimationsActivity.class);
c.getAndroidContext().startActivity(intent);
}
} }

View File

@@ -0,0 +1,8 @@
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="0.0"
android:toAlpha="1.0"
android:interpolator="@android:anim/accelerate_interpolator"
android:duration="600"
android:repeatMode="reverse"
android:repeatCount="infinite"/>
</set>

View File

@@ -0,0 +1,12 @@
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:interpolator="@android:anim/bounce_interpolator">
<scale
android:duration="500"
android:fromXScale="1.0"
android:fromYScale="0.0"
android:toXScale="1.0"
android:toYScale="1.0" />
</set>

View File

@@ -0,0 +1,10 @@
<set
xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
android:fillAfter="true">
<translate
android:fromXDelta="0%p"
android:toXDelta="75%p"
android:duration="800" />
</set>

View File

@@ -0,0 +1,11 @@
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="600"
android:repeatMode="restart"
android:repeatCount="infinite"
android:interpolator="@android:anim/cycle_interpolator"/>
</set>

View File

@@ -0,0 +1,44 @@
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:fillAfter="true"
android:interpolator="@android:anim/linear_interpolator" >
<!-- Move -->
<translate
android:duration="800"
android:fillAfter="true"
android:fromXDelta="0%p"
android:startOffset="300"
android:toXDelta="75%p" />
<translate
android:duration="800"
android:fillAfter="true"
android:fromYDelta="0%p"
android:startOffset="1100"
android:toYDelta="70%p" />
<translate
android:duration="800"
android:fillAfter="true"
android:fromXDelta="0%p"
android:startOffset="1900"
android:toXDelta="-75%p" />
<translate
android:duration="800"
android:fillAfter="true"
android:fromYDelta="0%p"
android:startOffset="2700"
android:toYDelta="-70%p" />
<!-- Rotate 360 degrees -->
<rotate
android:duration="1000"
android:fromDegrees="0"
android:interpolator="@android:anim/cycle_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="3800"
android:repeatCount="infinite"
android:repeatMode="restart"
android:toDegrees="360" />
</set>

View File

@@ -0,0 +1,111 @@
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/btnMove"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Move" android:layout_marginTop="5dp" android:layout_marginStart="5dp"
android:layout_marginEnd="5dp" android:layout_marginBottom="5dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Move"
android:id="@+id/txt_move"
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/btnSequential"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Sequential Animation"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Sequential"
android:id="@+id/txt_seq"
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/btnBounce"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bounce" android:layout_marginTop="5dp" android:layout_marginStart="5dp"
android:layout_marginEnd="5dp" android:layout_marginBottom="5dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Bounce"
android:id="@+id/txt_bounce"
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/btnBlink"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="Blink" android:layout_marginStart="5dp" android:layout_marginEnd="5dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Blink"
android:id="@+id/txt_blink"
android:layout_gravity="center_horizontal"
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/btnRotate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rotate" android:layout_marginTop="5dp" android:layout_marginStart="5dp"
android:layout_marginEnd="5dp" android:layout_marginBottom="5dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Rotate"
android:id="@+id/txt_rotate"
/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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=".ListActivity">
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>

View File

@@ -1,13 +1,29 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:orientation="vertical"
android:layout_height="match_parent" android:layout_width="match_parent">
tools:context=".FragmentTestFragment"> android:layout_height="match_parent">
<TextView <TextView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:text="@string/hello_blank_fragment" /> android:text="@string/hello_blank_fragment"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text=""/>
</FrameLayout> <Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Press me"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
/>
</LinearLayout>