Added dialogs to sample app
Summary: This is to allow us to test dialogs from the UI debugger Reviewed By: lblasa Differential Revision: D39468653 fbshipit-source-id: 59c759a794c42b85bc288d60e1b2c6a71e32bb3d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
721b9cd4da
commit
868ae9e36a
@@ -60,7 +60,7 @@
|
||||
<data android:scheme="flipper" android:host="list_activity" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".IncrementActivity"
|
||||
<activity android:name=".ButtonsActivity"
|
||||
android:exported="true" android:hardwareAccelerated="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
@@ -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.os.Bundle;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
public class ButtonsActivity extends FragmentActivity {
|
||||
|
||||
int count = 0;
|
||||
TextView text;
|
||||
Button button;
|
||||
Button dialogOld;
|
||||
Button dialogFragment;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_buttons);
|
||||
|
||||
text = (TextView) findViewById(R.id.count);
|
||||
|
||||
button = (Button) findViewById(com.facebook.flipper.sample.R.id.btn_inc);
|
||||
dialogOld = (Button) findViewById(R.id.dialog_old_api);
|
||||
dialogFragment = (Button) findViewById(R.id.dialog_fragment);
|
||||
button.setOnClickListener(view -> ButtonsActivity.this.text.setText(String.valueOf(++count)));
|
||||
|
||||
dialogFragment.setOnClickListener(
|
||||
btn -> {
|
||||
TestDialogFragment startGameDialogFragment = new TestDialogFragment();
|
||||
startGameDialogFragment.show(getSupportFragmentManager(), "dialog");
|
||||
});
|
||||
|
||||
dialogOld.setOnClickListener(
|
||||
btn -> {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle("Old Dialog")
|
||||
.setMessage("This is an old dialog")
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.setIcon(android.R.drawable.ic_dialog_alert)
|
||||
.show();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* 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));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ public class RootComponentSpec {
|
||||
.clickHandler(RootComponent.openAnimationsActivity(c)))
|
||||
.child(
|
||||
Text.create(c)
|
||||
.text("Navigate to increment activity")
|
||||
.text("Navigate to buttons activity")
|
||||
.key("11")
|
||||
.marginDip(YogaEdge.ALL, 10)
|
||||
.textSizeSp(20)
|
||||
@@ -200,7 +200,7 @@ public class RootComponentSpec {
|
||||
|
||||
@OnEvent(ClickEvent.class)
|
||||
static void openIncrementActivity(final ComponentContext c) {
|
||||
final Intent intent = new Intent(c.getAndroidContext(), IncrementActivity.class);
|
||||
final Intent intent = new Intent(c.getAndroidContext(), ButtonsActivity.class);
|
||||
c.getAndroidContext().startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* 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.Dialog;
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
public class TestDialogFragment extends DialogFragment {
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
// Use the Builder class for convenient dialog construction
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setMessage("This is a dialog fragment").setPositiveButton("Yes", (dialog, id) -> {});
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
}
|
||||
42
android/sample/src/main/res/layout/activity_buttons.xml
Normal file
42
android/sample/src/main/res/layout/activity_buttons.xml
Normal file
@@ -0,0 +1,42 @@
|
||||
<?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=".ButtonsActivity"
|
||||
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"
|
||||
/>
|
||||
<Button
|
||||
android:id="@+id/dialog_old_api"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/darker_gray"
|
||||
android:text="Dialog Old Api"
|
||||
android:textColor="@android:color/holo_blue_dark"
|
||||
/>
|
||||
<Button
|
||||
android:id="@+id/dialog_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@android:color/darker_gray"
|
||||
android:text="Dialog Fragment"
|
||||
android:textColor="@android:color/holo_blue_dark"
|
||||
/>
|
||||
</LinearLayout>
|
||||
@@ -1,26 +0,0 @@
|
||||
<?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>
|
||||
Reference in New Issue
Block a user