Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
Added increment activity
Browse files Browse the repository at this point in the history
Summary: Added simple activity to test how flipper reacts to changes in native UI

Reviewed By: passy

Differential Revision: D38704012

fbshipit-source-id: 8a593577322922c6f6f0f96dd5cb0761c3035389
  • Loading branch information
LukeDefeo authored and facebook-github-bot committed Sep 7, 2022
1 parent 0426966 commit 2fc1ff9
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 1 deletion.
9 changes: 9 additions & 0 deletions android/sample/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@
<data android:scheme="flipper" android:host="list_activity" />
</intent-filter>
</activity>
<activity android:name=".IncrementActivity"
android:exported="true" android:hardwareAccelerated="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="increment_activity" />
</intent-filter>
</activity>
<activity android:name=".AnimationsActivity"
android:exported="true">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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.widget.Button;
import android.widget.TextView;

public class IncrementActivity extends Activity {

int count = 0;
TextView text;
Button button;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_increment);

text = (TextView) findViewById(R.id.count);

button = (Button) findViewById(com.facebook.flipper.sample.R.id.btn_inc);
button.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
IncrementActivity.this.text.setText(String.valueOf(++count));
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,17 @@ static Component onCreateLayout(final ComponentContext c, @State boolean display
.clickHandler(RootComponent.openAnimationsActivity(c)))
.child(
Text.create(c)
.text("Crash this app")
.text("Navigate to increment activity")
.key("11")
.marginDip(YogaEdge.ALL, 10)
.textSizeSp(20)
.clickHandler(RootComponent.openIncrementActivity(c)))
.child(
Text.create(c)
.text("Crash this app")
.key("12")
.marginDip(YogaEdge.ALL, 10)
.textSizeSp(20)
.clickHandler(RootComponent.triggerCrash(c)))
.child(
FrescoImage.create(c)
Expand Down Expand Up @@ -190,4 +197,10 @@ static void openAnimationsActivity(final ComponentContext c) {
final Intent intent = new Intent(c.getAndroidContext(), AnimationsActivity.class);
c.getAndroidContext().startActivity(intent);
}

@OnEvent(ClickEvent.class)
static void openIncrementActivity(final ComponentContext c) {
final Intent intent = new Intent(c.getAndroidContext(), IncrementActivity.class);
c.getAndroidContext().startActivity(intent);
}
}
26 changes: 26 additions & 0 deletions android/sample/src/main/res/layout/activity_increment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?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=".IncrementActivity"
android:orientation="vertical"
>


<TextView
android:id="@+id/count"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="0" />

<Button
android:id="@+id/btn_inc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/darker_gray"
android:text="Inc"
android:textColor="@android:color/holo_blue_dark"
/>
</LinearLayout>

0 comments on commit 2fc1ff9

Please sign in to comment.