summaryrefslogtreecommitdiff
path: root/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui
diff options
context:
space:
mode:
Diffstat (limited to 'espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui')
-rw-r--r--espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/ActionBarTestActivity.java100
-rw-r--r--espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/DelegatingEditText.java63
-rw-r--r--espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/DisplayActivity.java36
-rw-r--r--espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/DrawerActivity.java129
-rw-r--r--espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/FragmentStack.java127
-rw-r--r--espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/GestureActivity.java224
-rw-r--r--espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/LongListActivity.java128
-rw-r--r--espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/MainActivity.java112
-rw-r--r--espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/MenuActivity.java98
-rw-r--r--espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/ScrollActivity.java32
-rw-r--r--espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SendActivity.java219
-rw-r--r--espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SimpleActivity.java72
-rw-r--r--espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SimplePagerAdapter.java65
-rw-r--r--espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SimpleWebViewActivity.java44
-rw-r--r--espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SwipeActivity.java38
-rw-r--r--espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SyncActivity.java95
-rw-r--r--espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/ViewPagerActivity.java38
17 files changed, 0 insertions, 1620 deletions
diff --git a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/ActionBarTestActivity.java b/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/ActionBarTestActivity.java
deleted file mode 100644
index 5c1ac60..0000000
--- a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/ActionBarTestActivity.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.apps.common.testing.ui.testapp;
-
-import android.os.Bundle;
-import android.support.v7.app.ActionBarActivity;
-import android.support.v7.view.ActionMode;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.Button;
-import android.widget.TextView;
-
-/**
- * Shows ActionBar with a lot of items to get Action overflow on large displays. Click on item
- * changes text of R.id.textActionBarResult.
- */
-public class ActionBarTestActivity extends ActionBarActivity {
- private ActionMode mode;
- private MenuInflater inflater;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.actionbar_activity);
- inflater = getMenuInflater();
- mode = startSupportActionMode(new TestActionMode());
-
- ((Button) findViewById(R.id.show_contextual_action_bar)).setOnClickListener(
- new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- mode = startSupportActionMode(new TestActionMode());
- }
- });
- ((Button) findViewById(R.id.hide_contextual_action_bar)).setOnClickListener(
- new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- if (mode != null) {
- mode.finish();
- }
- }
- });
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- inflater.inflate(R.menu.actionbar_context_actions, menu);
- return super.onCreateOptionsMenu(menu);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem menu) {
- setResult(menu.getTitle());
- return true;
- }
-
- private void setResult(CharSequence result) {
- TextView text = (TextView) findViewById(R.id.text_action_bar_result);
- text.setText(result);
- }
-
- private final class TestActionMode implements ActionMode.Callback {
- @Override
- public boolean onCreateActionMode(ActionMode mode, Menu menu) {
- inflater.inflate(R.menu.actionbar_activity_actions, menu);
- return true;
- }
-
- @Override
- public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
- return false;
- }
-
- @Override
- public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
- setResult(item.getTitle());
- return true;
- }
-
- @Override
- public void onDestroyActionMode(ActionMode mode) {}
- }
-}
diff --git a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/DelegatingEditText.java b/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/DelegatingEditText.java
deleted file mode 100644
index dace49c..0000000
--- a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/DelegatingEditText.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.apps.common.testing.ui.testapp;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.KeyEvent;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.EditText;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import android.widget.TextView.OnEditorActionListener;
-
-/**
- * Custom edit text widget.
- */
-public class DelegatingEditText extends LinearLayout {
-
- private final EditText delegateEditText;
- private final TextView messageView;
- private final Context mContext;
-
- public DelegatingEditText(Context context) {
- this(context, null);
- }
-
- public DelegatingEditText(Context context, AttributeSet attrs) {
- super(context, attrs);
- setOrientation(VERTICAL);
- mContext = context;
- LayoutInflater inflater = LayoutInflater.from(context);
- inflater.inflate(R.layout.delegating_edit_text, this, /* attachToRoot */ true);
- messageView = (TextView) findViewById(R.id.edit_text_message);
- delegateEditText = (EditText) findViewById(R.id.delegate_edit_text);
- delegateEditText.setOnEditorActionListener(new OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView v, int actionCode, KeyEvent event) {
- messageView.setText("typed: " + delegateEditText.getText());
- messageView.setVisibility(View.VISIBLE);
- InputMethodManager imm =
- (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(delegateEditText.getWindowToken(), 0);
- return true;
- }
- });
- }
-}
diff --git a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/DisplayActivity.java b/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/DisplayActivity.java
deleted file mode 100644
index d05ee00..0000000
--- a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/DisplayActivity.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.apps.common.testing.ui.testapp;
-
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.widget.TextView;
-
-/**
- * Simple activity used to display data received from another activity.
- */
-public class DisplayActivity extends Activity {
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.display_activity);
- TextView textView = (TextView) findViewById(R.id.display_data);
- textView.setText(getIntent().getStringExtra(SendActivity.EXTRA_DATA));
- }
-}
diff --git a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/DrawerActivity.java b/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/DrawerActivity.java
deleted file mode 100644
index a13f688..0000000
--- a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/DrawerActivity.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.apps.common.testing.ui.testapp;
-
-import android.app.Activity;
-import android.content.res.Configuration;
-import android.os.Bundle;
-import android.support.v4.app.ActionBarDrawerToggle;
-import android.support.v4.widget.DrawerLayout;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemClickListener;
-import android.widget.ArrayAdapter;
-import android.widget.ListAdapter;
-import android.widget.ListView;
-import android.widget.TextView;
-
-/**
- * Activity to demonstrate actions on a {@link DrawerLayout}.
- */
-public class DrawerActivity extends Activity {
-
- public static final String[] DRAWER_CONTENTS =
- new String[] {"Platypus", "Wombat", "Pickle", "Badger"};
-
- private ActionBarDrawerToggle drawerToggle;
- private CharSequence title;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.drawer_activity);
-
- ListAdapter listAdapter = new ArrayAdapter<String>(
- getApplicationContext(), R.layout.drawer_row, R.id.drawer_row_name, DRAWER_CONTENTS);
- final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
- ListView drawerList = (ListView) findViewById(R.id.drawer_list);
- drawerList.setAdapter(listAdapter);
-
- final TextView textView = (TextView) findViewById(R.id.drawer_text_view);
-
- drawerList.setOnItemClickListener(new OnItemClickListener() {
- @Override
- public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
- textView.setText("You picked: " + DRAWER_CONTENTS[(int) id]);
- drawerLayout.closeDrawers();
- }
- });
-
- // enable ActionBar app icon to behave as action to toggle nav drawer
- // TODO(user): use compat lib for lower API levels
- if (android.os.Build.VERSION.SDK_INT >= 11) {
- getActionBar().setDisplayHomeAsUpEnabled(true);
- getActionBar().setHomeButtonEnabled(true);
- }
-
- title = getTitle();
-
- drawerToggle = new ActionBarDrawerToggle(
- this,
- drawerLayout,
- R.drawable.ic_drawer,
- R.string.nav_drawer_open,
- R.string.nav_drawer_close) {
-
- /** Called when a drawer has settled in a completely closed state. */
- public void onDrawerClosed(View view) {
- if (android.os.Build.VERSION.SDK_INT >= 11) {
- getActionBar().setTitle(title);
- }
- }
-
- /** Called when a drawer has settled in a completely open state. */
- public void onDrawerOpened(View drawerView) {
- if (android.os.Build.VERSION.SDK_INT >= 11) {
- getActionBar().setTitle(title);
- }
- }
- };
- drawerLayout.setDrawerListener(drawerToggle);
- }
-
- @Override
- public void setTitle(CharSequence title) {
- this.title = title;
- if (android.os.Build.VERSION.SDK_INT >= 11) {
- getActionBar().setTitle(title);
- }
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- // The action bar home/up action should open or close the drawer.
- // ActionBarDrawerToggle will take care of this.
- if (drawerToggle.onOptionsItemSelected(item)) {
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
- // Sync the toggle state after onRestoreInstanceState has occurred.
- drawerToggle.syncState();
- }
-
- @Override
- public void onConfigurationChanged(Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- // Pass any configuration change to the drawer toggls
- drawerToggle.onConfigurationChanged(newConfig);
- }
-}
diff --git a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/FragmentStack.java b/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/FragmentStack.java
deleted file mode 100644
index e89ce27..0000000
--- a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/FragmentStack.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.apps.common.testing.ui.testapp;
-
-import android.app.Activity;
-import android.app.Fragment;
-import android.app.FragmentTransaction;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.widget.Button;
-import android.widget.TextView;
-
-/**
- * Displays a counter using fragments.
- */
-public class FragmentStack extends Activity {
- int stackLevel = 1;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.fragment_stack);
-
- // Watch for button clicks.
- Button button = (Button) findViewById(R.id.new_fragment);
- button.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- addFragmentToStack();
- }
- });
-
- if (savedInstanceState == null) {
- // Do first time initialization -- add initial fragment.
- Fragment newFragment = CountingFragment.newInstance(stackLevel);
- FragmentTransaction ft = getFragmentManager().beginTransaction();
- ft.add(R.id.simple_fragment, newFragment).commit();
- } else {
- stackLevel = savedInstanceState.getInt("level");
- }
- }
-
- @Override
- public void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- outState.putInt("level", stackLevel);
- }
-
-
- void addFragmentToStack() {
- stackLevel++;
-
- // Instantiate a new fragment.
- Fragment newFragment = CountingFragment.newInstance(stackLevel);
-
- // Add the fragment to the activity, pushing this transaction
- // on to the back stack.
- FragmentTransaction ft = getFragmentManager().beginTransaction();
- ft.replace(R.id.simple_fragment, newFragment);
- ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
- ft.addToBackStack(null);
- ft.commit();
- }
-
-
-
- /**
- * A fragment that displays a number.
- */
- public static class CountingFragment extends Fragment {
- int counter;
-
- /**
- * Create a new instance of CountingFragment, providing "num"
- * as an argument.
- */
- static CountingFragment newInstance(int num) {
- CountingFragment f = new CountingFragment();
-
- // Supply num input as an argument.
- Bundle args = new Bundle();
- args.putInt("num", num);
- f.setArguments(args);
-
- return f;
- }
-
- /**
- * When creating, retrieve this instance's number from its arguments.
- */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- counter = getArguments() != null ? getArguments().getInt("num") : 1;
- }
-
- /**
- * The Fragment's UI is just a simple text view showing its
- * instance number.
- */
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- TextView text = new TextView(getActivity());
- text.setText("Fragment #" + counter);
- return text;
- }
- }
-
-}
diff --git a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/GestureActivity.java b/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/GestureActivity.java
deleted file mode 100644
index b2cbc32..0000000
--- a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/GestureActivity.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.apps.common.testing.ui.testapp;
-
-import com.google.common.collect.Lists;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.os.SystemClock;
-import android.util.Log;
-import android.view.GestureDetector;
-import android.view.MotionEvent;
-import android.view.View;
-
-import java.util.List;
-
-/**
- * Displays a large touchable area and logs the events it receives.
- */
-public class GestureActivity extends Activity {
- private static final String TAG = GestureActivity.class.getSimpleName();
-
-
- private View gestureArea;
- private List<MotionEvent> downEvents = Lists.newArrayList();
- private List<MotionEvent> scrollEvents = Lists.newArrayList();
- private List<MotionEvent> longPressEvents = Lists.newArrayList();
- private List<MotionEvent> showPresses = Lists.newArrayList();
- private List<MotionEvent> singleTaps = Lists.newArrayList();
- private List<MotionEvent> confirmedSingleTaps = Lists.newArrayList();
- private List<MotionEvent> doubleTapEvents = Lists.newArrayList();
- private List<MotionEvent> doubleTaps = Lists.newArrayList();
-
- public void clearDownEvents() {
- downEvents.clear();
- }
-
- public void clearScrollEvents() {
- scrollEvents.clear();
- }
-
- public void clearLongPressEvents() {
- longPressEvents.clear();
- }
-
- public void clearShowPresses() {
- showPresses.clear();
- }
-
- public void clearSingleTaps() {
- singleTaps.clear();
- }
-
- public void clearConfirmedSingleTaps() {
- confirmedSingleTaps.clear();
- }
-
- public void clearDoubleTapEvents() {
- doubleTapEvents.clear();
- }
-
- public void clearDoubleTaps() {
- doubleTaps.clear();
- }
-
- public List<MotionEvent> getDownEvents() {
- return Lists.newArrayList(downEvents);
- }
-
- public List<MotionEvent> getScrollEvents() {
- return Lists.newArrayList(scrollEvents);
- }
-
- public List<MotionEvent> getLongPressEvents() {
- return Lists.newArrayList(longPressEvents);
- }
-
- public List<MotionEvent> getShowPresses() {
- return Lists.newArrayList(showPresses);
- }
-
- public List<MotionEvent> getSingleTaps() {
- return Lists.newArrayList(singleTaps);
- }
-
- public List<MotionEvent> getConfirmedSingleTaps() {
- return Lists.newArrayList(confirmedSingleTaps);
- }
-
- public List<MotionEvent> getDoubleTapEvents() {
- return Lists.newArrayList(doubleTapEvents);
- }
-
- public List<MotionEvent> getDoubleTaps() {
- return Lists.newArrayList(doubleTaps);
- }
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- setContentView(R.layout.gesture_activity);
- gestureArea = findViewById(R.id.gesture_area);
- final GestureDetector simpleDetector = new GestureDetector(this, new GestureListener());
- simpleDetector.setIsLongpressEnabled(true);
- simpleDetector.setOnDoubleTapListener(new DoubleTapListener());
- gestureArea.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent m) {
- boolean res = simpleDetector.onTouchEvent(m);
- if (-1 != touchDelay) {
- Log.i(TAG, "sleeping for: " + touchDelay);
- SystemClock.sleep(touchDelay);
-
- }
- return res;
- }
- });
- }
-
- private volatile long touchDelay = -1;
-
- public void setTouchDelay(long touchDelay) {
- this.touchDelay = touchDelay;
- }
-
- public void areaClicked(@SuppressWarnings("unused") View v) {
- Log.v(TAG, "onClick called!");
- }
-
- private class DoubleTapListener implements GestureDetector.OnDoubleTapListener {
- @Override
- public boolean onDoubleTap(MotionEvent e) {
- doubleTaps.add(MotionEvent.obtain(e));
- Log.v(TAG, "onDoubleTap: " + e);
- setVisible(R.id.text_double_click);
- return false;
- }
-
- @Override
- public boolean onDoubleTapEvent(MotionEvent e) {
- doubleTapEvents.add(MotionEvent.obtain(e));
- Log.v(TAG, "onDoubleTapEvent: " + e);
- return false;
- }
-
- @Override
- public boolean onSingleTapConfirmed(MotionEvent e) {
- confirmedSingleTaps.add(MotionEvent.obtain(e));
- Log.v(TAG, "onSingleTapConfirmed: " + e);
- return false;
- }
- }
-
- private class GestureListener implements GestureDetector.OnGestureListener {
- @Override
- public boolean onDown(MotionEvent e) {
- downEvents.add(MotionEvent.obtain(e));
- Log.v(TAG, "Down: " + e);
- return false;
- }
-
- @Override
- public boolean onSingleTapUp(MotionEvent e) {
- singleTaps.add(MotionEvent.obtain(e));
- Log.v(TAG, "on single tap: " + e);
- setVisible(R.id.text_click);
- return false;
- }
-
- @Override
- public boolean onScroll(MotionEvent e1, MotionEvent e2, float distX, float distY) {
- scrollEvents.add(MotionEvent.obtain(e1));
- scrollEvents.add(MotionEvent.obtain(e2));
- Log.v(TAG, "Scroll: e1: " + e1 + " e2: " + e2 + " distX: " + distX + " distY: " + distY);
- setVisible(R.id.text_swipe);
- return false;
- }
-
- @Override
- public void onShowPress(MotionEvent e) {
- showPresses.add(MotionEvent.obtain(e));
- Log.v(TAG, "ShowPress: " + e);
- }
-
- @Override
- public void onLongPress(MotionEvent e) {
- longPressEvents.add(MotionEvent.obtain(e));
- Log.v(TAG, "LongPress: " + e);
- setVisible(R.id.text_long_click);
- }
-
- @Override
- public boolean onFling(MotionEvent e1, MotionEvent e2, float veloX, float veloY) {
- Log.v(TAG, "Fling: e1: " + e1 + " e2: " + e2 + " veloX: " + veloX + " veloY: " + veloY);
- return false;
- }
- }
-
- private void setVisible(int id) {
- hideAll();
- findViewById(id).setVisibility(View.VISIBLE);
- }
-
- private void hideAll() {
- findViewById(R.id.text_click).setVisibility(View.GONE);
- findViewById(R.id.text_long_click).setVisibility(View.GONE);
- findViewById(R.id.text_swipe).setVisibility(View.GONE);
- findViewById(R.id.text_double_click).setVisibility(View.GONE);
- }
-}
diff --git a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/LongListActivity.java b/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/LongListActivity.java
deleted file mode 100644
index 300c0ee..0000000
--- a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/LongListActivity.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.apps.common.testing.ui.testapp;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
-import android.app.Activity;
-import android.content.Context;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.ListAdapter;
-import android.widget.ListView;
-import android.widget.SimpleAdapter;
-import android.widget.TextView;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * An activity displaying a long list.
- */
-public class LongListActivity extends Activity {
-
- @VisibleForTesting
- public static final String STR = "STR";
- @VisibleForTesting
- public static final String LEN = "LEN";
- @VisibleForTesting
- public static final String FOOTER = "FOOTER";
-
- private List<Map<String, Object>> data = Lists.newArrayList();
- private LayoutInflater layoutInflater;
-
- @Override
- public void onCreate(Bundle bundle) {
- super.onCreate(bundle);
- populateData();
- setContentView(R.layout.list_activity);
- ((TextView) findViewById(R.id.selection_row_value)).setText("");
- ((TextView) findViewById(R.id.selection_column_value)).setText("");
-
- ListView listView = (ListView) findViewById(R.id.list);
- String[] from = new String[] {STR, LEN};
- int[] to = new int[] {R.id.item_content, R.id.item_size};
- layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-
- ListAdapter adapter = new SimpleAdapter(this, data, R.layout.list_item, from, to) {
- @Override
- public View getView(final int position, View convertView, ViewGroup parent) {
- if (convertView == null) {
- convertView = layoutInflater.inflate(R.layout.list_item, null);
- }
-
- TextView textViewOne = (TextView) convertView.findViewById(R.id.item_content);
- if (textViewOne != null) {
- textViewOne.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- ((TextView) findViewById(R.id.selection_row_value)).setText(String.valueOf(position));
- ((TextView) findViewById(R.id.selection_column_value)).setText("1");
- }
- });
- }
-
- TextView textViewTwo = (TextView) convertView.findViewById(R.id.item_size);
- if (textViewTwo != null) {
- textViewTwo.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- ((TextView) findViewById(R.id.selection_row_value)).setText(String.valueOf(position));
- ((TextView) findViewById(R.id.selection_column_value)).setText("2");
- }
- });
- }
- return super.getView(position, convertView, parent);
- }
- };
-
- View footerView = layoutInflater.inflate(R.layout.list_item, listView, false);
- ((TextView) footerView.findViewById(R.id.item_content)).setText("count:");
- ((TextView) footerView.findViewById(R.id.item_size)).setText(String.valueOf(data.size()));
- listView.addFooterView(footerView, FOOTER, true);
-
- listView.setAdapter(adapter);
- listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
- @Override
- public void onItemClick(
- AdapterView<?> unusedParent, View clickedView, int position, long id) {
- ((TextView) findViewById(R.id.selection_column_value)).setText("");
- ((TextView) findViewById(R.id.selection_row_value)).setText(String.valueOf(position));
- }
- });
- }
-
- public Map<String, Object> makeItem(int forRow) {
- Map<String, Object> dataRow = Maps.newHashMap();
- dataRow.put(STR, "item: " + forRow);
- dataRow.put(LEN, ((String) dataRow.get(STR)).length());
- return dataRow;
- }
-
- private void populateData() {
- for (int i = 0; i < 100; i++) {
- data.add(makeItem(i));
- }
- }
-
-}
diff --git a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/MainActivity.java b/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/MainActivity.java
deleted file mode 100644
index c5ad762..0000000
--- a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/MainActivity.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.apps.common.testing.ui.testapp;
-
-import android.app.ListActivity;
-import android.content.Intent;
-import android.content.pm.ActivityInfo;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.widget.ListView;
-import android.widget.SimpleAdapter;
-
-import java.text.Collator;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Displays a list with all available activities.
- */
-public class MainActivity extends ListActivity {
- private static final String TAG = MainActivity.class.getSimpleName();
-
- private static final Comparator<Map<String, Object>> sDisplayNameComparator =
- new Comparator<Map<String, Object>>() {
- private final Collator collator = Collator.getInstance();
-
- @Override
- public int compare(Map<String, Object> map1, Map<String, Object> map2) {
- return collator.compare(map1.get("title"), map2.get("title"));
- }
- };
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- setListAdapter(new SimpleAdapter(
- this, getData(), android.R.layout.simple_list_item_1, new String[] {"title"},
- new int[] {android.R.id.text1}));
- getListView().setTextFilterEnabled(true);
- }
-
- private List<Map<String, Object>> getData() {
- List<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
-
- PackageInfo info = null;
- try {
- info = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_ACTIVITIES);
- } catch (NameNotFoundException e) {
- Log.e(TAG, "Packageinfo not found in: " + getPackageName());
- }
-
- if (null == info) {
- return data;
- } else {
- for (ActivityInfo activityInfo : info.activities) {
-
- if (!activityInfo.name.equals(getComponentName().getClassName())) {
- String[] label = activityInfo.name.split(getPackageName() + ".");
- addItem(data, label[1],
- createActivityIntent(activityInfo.applicationInfo.packageName, activityInfo.name));
- }
- }
- }
-
- Collections.sort(data, sDisplayNameComparator);
- return data;
- }
-
- private Intent createActivityIntent(String pkg, String componentName) {
- Intent result = new Intent();
- result.setClassName(pkg, componentName);
- return result;
- }
-
- private void addItem(List<Map<String, Object>> data, String name, Intent intent) {
- Map<String, Object> temp = new HashMap<String, Object>();
- temp.put("title", name);
- temp.put("intent", intent);
- data.add(temp);
- }
-
- @Override
- protected void onListItemClick(ListView listView, View view, int position, long id) {
- Map<?, ?> map = (Map<?, ?>) listView.getItemAtPosition(position);
-
- Intent intent = (Intent) map.get("intent");
- startActivity(intent);
- }
-}
diff --git a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/MenuActivity.java b/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/MenuActivity.java
deleted file mode 100644
index e893cea..0000000
--- a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/MenuActivity.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.apps.common.testing.ui.testapp;
-
-import android.app.Activity;
-import android.os.Build;
-import android.os.Bundle;
-import android.view.ContextMenu;
-import android.view.ContextMenu.ContextMenuInfo;
-import android.view.Menu;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.widget.PopupMenu;
-import android.widget.PopupMenu.OnMenuItemClickListener;
-import android.widget.TextView;
-
-/**
- * Shows MenuActivity with Options menu, Context menu and Popup menu. Click on a menu item changes
- * text of R.id.textMenuResult.
- */
-public class MenuActivity extends Activity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.menu_activity);
- registerForContextMenu(findViewById(R.id.text_context_menu));
- }
-
- @Override
- public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
- super.onCreateContextMenu(menu, v, menuInfo);
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.contextmenu, menu);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- TextView text = (TextView) findViewById(R.id.text_menu_result);
- text.setText(item.getTitle());
- return true;
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.optionsmenu, menu);
- return true;
- }
-
- @Override
- public boolean onContextItemSelected(MenuItem item) {
- TextView text = (TextView) findViewById(R.id.text_menu_result);
- text.setText(item.getTitle());
- return true;
- }
-
- public void showPopup(View view) {
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
- TextView text = (TextView) findViewById(R.id.text_menu_result);
- text.setText("Not supported in API " + Build.VERSION.SDK_INT);
- } else {
- PopupMenu popup = new PopupMenu(this, view);
- popup.setOnMenuItemClickListener(new PopupMenuListener());
- popup.getMenuInflater().inflate(R.menu.popupmenu, popup.getMenu());
- popup.show();
- }
- }
-
- @Override
- public boolean onMenuItemSelected(int featureId, MenuItem item) {
- return super.onMenuItemSelected(featureId, item);
- }
-
- private class PopupMenuListener implements OnMenuItemClickListener {
- @Override
- public boolean onMenuItemClick(MenuItem item) {
- TextView text = (TextView) findViewById(R.id.text_menu_result);
- text.setText(item.getTitle());
- return true;
- }
- }
-}
diff --git a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/ScrollActivity.java b/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/ScrollActivity.java
deleted file mode 100644
index 864fb23..0000000
--- a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/ScrollActivity.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.apps.common.testing.ui.testapp;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-/**
- * An activity displaying various scroll views.
- */
-public class ScrollActivity extends Activity {
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.scroll_activity);
- }
-}
diff --git a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SendActivity.java b/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SendActivity.java
deleted file mode 100644
index fe472e7..0000000
--- a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SendActivity.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.apps.common.testing.ui.testapp;
-
-import android.app.Activity;
-import android.app.AlertDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Bundle;
-import android.provider.ContactsContract.CommonDataKinds.Phone;
-import android.view.Gravity;
-import android.view.KeyEvent;
-import android.view.MenuInflater;
-import android.view.View;
-import android.view.View.OnKeyListener;
-import android.view.ViewGroup.LayoutParams;
-import android.view.inputmethod.EditorInfo;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.ArrayAdapter;
-import android.widget.AutoCompleteTextView;
-import android.widget.EditText;
-import android.widget.PopupMenu;
-import android.widget.PopupWindow;
-import android.widget.TextView;
-
-/**
- * Simple activity used for validating intent sending and UI behavior.
- */
-public class SendActivity extends Activity {
-
- private static final int PICK_CONTACT_REQUEST = 1; // The request code
- static final String EXTRA_DATA = "com.google.android.apps.common.testing.ui.testapp.DATA";
- static final int PICK_CONTACT = 100;
- private PopupWindow popupWindow;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.send_activity);
-
- EditText editText = (EditText) findViewById(R.id.enter_data_edit_text);
- editText.setOnKeyListener(new OnKeyListener() {
-
- @Override
- public boolean onKey(View view, int keyCode, KeyEvent event) {
- if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
- (keyCode == KeyEvent.KEYCODE_ENTER)) {
- EditText editText = (EditText) view;
- TextView responseText = (TextView) findViewById(R.id.enter_data_response_text);
- responseText.setText(editText.getText());
- return true;
- } else {
- return false;
- }
- }
- });
-
- final EditText searchBox = (EditText) findViewById(R.id.search_box);
- searchBox.setOnEditorActionListener(new TextView.OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
- if (actionId == EditorInfo.IME_ACTION_SEARCH) {
- TextView result = (TextView) findViewById(R.id.search_result);
- result.setText(getString(R.string.searching_for_label) + " " + v.getText());
- result.setVisibility(View.VISIBLE);
- InputMethodManager imm =
- (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(searchBox.getWindowToken(), 0);
- return true;
- }
- return false;
- }
- });
- AutoCompleteTextView autoComplete = (AutoCompleteTextView) findViewById(
- R.id.auto_complete_text_view);
- String [] completions = new String[] {
- "Pacific Ocean", "Atlantic Ocean", "Indian Ocean", "Southern Ocean", "Artic Ocean",
- "Mediterranean Sea", "Caribbean Sea", "South China Sea", "Bering Sea",
- "Gulf of Mexico", "Okhotsk Sea", "East China Sea", "Hudson Bay", "Japan Sea",
- "Andaman Sea", "North Sea", "Red Sea", "Baltic Sea" };
- ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
- android.R.layout.simple_dropdown_item_1line,
- completions);
- autoComplete.setAdapter(adapter);
- }
-
- /** Called when user clicks the Send button */
- public void sendData(@SuppressWarnings("unused") View view) {
- Intent intent = new Intent(this, DisplayActivity.class);
- EditText editText = (EditText) findViewById(R.id.send_data_edit_text);
- intent.putExtra(EXTRA_DATA, editText.getText().toString());
- startActivity(intent);
- }
-
- public void sendDataToCall(@SuppressWarnings("unused") View view) {
- Intent intentToCall = new Intent(Intent.ACTION_CALL);
- EditText editText = (EditText) findViewById(R.id.send_data_to_call_edit_text);
- String number = editText.getText().toString();
- intentToCall.setData(Uri.parse("tel:" + number));
- startActivity(intentToCall);
- }
-
- public void sendDataToBrowser(@SuppressWarnings("unused") View view) {
- EditText editText = (EditText) findViewById(R.id.send_data_to_browser_edit_text);
- String url = editText.getText().toString();
- Intent intentToBrowser = new Intent(Intent.ACTION_VIEW);
- intentToBrowser.setData(Uri.parse(url));
- intentToBrowser.addCategory(Intent.CATEGORY_BROWSABLE);
- intentToBrowser.putExtra("key1", "value1");
- intentToBrowser.putExtra("key2", "value2");
- startActivity(intentToBrowser);
- }
-
- public void sendMessage(@SuppressWarnings("unused") View view) {
- Intent sendIntent = new Intent();
- EditText editText = (EditText) findViewById(R.id.send_data_to_message_edit_text);
- sendIntent.setAction(Intent.ACTION_SEND);
- sendIntent.putExtra(Intent.EXTRA_TEXT, editText.getText().toString());
- sendIntent.setType("text/plain");
- startActivity(sendIntent);
- }
-
- public void clickToMarket(@SuppressWarnings("unused") View view) {
- Intent marketIntent = new Intent(Intent.ACTION_VIEW);
- EditText editText = (EditText) findViewById(R.id.send_to_market_data);
- marketIntent.setData(Uri.parse(
- "market://details?id=" + editText.getText().toString()));
- startActivity(marketIntent);
- }
-
- public void clickToGesture(@SuppressWarnings("unused") View view) {
- startActivity(new Intent(this, GestureActivity.class));
- }
-
- public void clickToScroll(@SuppressWarnings("unused") View view) {
- startActivity(new Intent(this, ScrollActivity.class));
- }
-
- public void clickToList(@SuppressWarnings("unused") View view) {
- startActivity(new Intent(this, LongListActivity.class));
- }
-
- public boolean showDialog(@SuppressWarnings("unused") View view) {
- new AlertDialog.Builder(this)
- .setTitle(R.string.dialog_title)
- .setMessage(R.string.dialog_message)
- .setNeutralButton("Fine", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int choice) {
- dialog.dismiss();
- }
- })
- .show();
- return true;
- }
-
- public boolean showPopupView(View view) {
- View content = getLayoutInflater().inflate(R.layout.popup_window, null, false);
- popupWindow = new PopupWindow(content, LayoutParams.WRAP_CONTENT,
- LayoutParams.WRAP_CONTENT, true);
- content.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- popupWindow.dismiss();
- }
- });
-
- popupWindow.showAtLocation(view, Gravity.CENTER, 0, 0);
-
- return true;
- }
-
- public boolean showPopupMenu(View view) {
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
- return false;
- }
-
- PopupMenu popup = new PopupMenu(this, view);
- MenuInflater inflater = popup.getMenuInflater();
- inflater.inflate(R.menu.popup_menu, popup.getMenu());
- popup.show();
- return true;
- }
-
- public void pickContact(@SuppressWarnings("unused") View view) {
- Intent pickContactIntent = new Intent(Intent.ACTION_PICK, Uri.parse("content://contacts"));
- pickContactIntent.setType(Phone.CONTENT_TYPE); // Show user only contacts w/ phone numbers
- startActivityForResult(pickContactIntent, PICK_CONTACT_REQUEST);
- }
-
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (requestCode == PICK_CONTACT_REQUEST) {
- if (resultCode == RESULT_OK) {
- // TODO(user): hook this up for real as shown in this example:
- // http://developer.android.com/training/basics/intents/result.html
- TextView textView = (TextView) findViewById(R.id.phone_number);
- textView.setText(data.getExtras().getString("phone"));
- }
- }
- }
-}
diff --git a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SimpleActivity.java b/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SimpleActivity.java
deleted file mode 100644
index 8af2747..0000000
--- a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SimpleActivity.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.apps.common.testing.ui.testapp;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemSelectedListener;
-import android.widget.ArrayAdapter;
-import android.widget.EditText;
-import android.widget.Spinner;
-import android.widget.TextView;
-
-/**
- * Simple activity used to demonstrate a simple Espresso test.
- */
-public class SimpleActivity extends Activity implements OnItemSelectedListener{
-
- static final String EXTRA_DATA = "com.google.android.apps.common.testing.ui.testapp.DATA";
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.simple_activity);
-
- Spinner spinner = (Spinner) findViewById(R.id.spinner_simple);
- ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
- R.array.spinner_array, android.R.layout.simple_spinner_item);
- adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
- spinner.setAdapter(adapter);
- spinner.setOnItemSelectedListener(this);
- }
-
- public void simpleButtonClicked(View view) {
- TextView textView = (TextView) findViewById(R.id.text_simple);
- String message = "Hello Espresso!";
- textView.setText(message);
- }
-
- /** Called when user clicks the Send button */
- public void sendButtonClicked(@SuppressWarnings("unused") View view) {
- Intent intent = new Intent(this, DisplayActivity.class);
- EditText editText = (EditText) findViewById(R.id.sendtext_simple);
- intent.putExtra(EXTRA_DATA, editText.getText().toString());
- startActivity(intent);
- }
-
- public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
- TextView textView = (TextView) findViewById(R.id.spinnertext_simple);
- textView.setText(String.format("One %s a day!", parent.getItemAtPosition(pos)));
- }
-
- public void onNothingSelected(AdapterView<?> parent) {
- }
-}
-
diff --git a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SimplePagerAdapter.java b/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SimplePagerAdapter.java
deleted file mode 100644
index 42d9cf4..0000000
--- a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SimplePagerAdapter.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.apps.common.testing.ui.testapp;
-
-import android.graphics.Color;
-import android.support.v4.view.PagerAdapter;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-class SimplePagerAdapter extends PagerAdapter {
-
- private static final int[] COLORS = {
- Color.BLUE,
- Color.RED,
- Color.YELLOW,
- };
-
- private static final int NUM_PAGES = COLORS.length;
-
- @Override
- public int getCount() {
- return NUM_PAGES;
- }
-
- @Override
- public boolean isViewFromObject(View view, Object object) {
- return view == object;
- }
-
- @Override
- public int getItemPosition(Object object) {
- return ((ViewGroup) ((View) object).getParent()).indexOfChild((View) object);
- }
-
- @Override
- public Object instantiateItem(ViewGroup container, int position) {
- LayoutInflater inflater = LayoutInflater.from(container.getContext());
- View view = inflater.inflate(R.layout.pager_view, null);
- ((TextView) view.findViewById(R.id.pager_content)).setText("Position #" + position);
- view.setBackgroundColor(COLORS[position]);
- container.addView(view);
- return view;
- }
-
- @Override
- public void destroyItem(ViewGroup container, int position, Object object) {
- container.removeView((View) object);
- }
-}
diff --git a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SimpleWebViewActivity.java b/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SimpleWebViewActivity.java
deleted file mode 100644
index 9c844af..0000000
--- a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SimpleWebViewActivity.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.apps.common.testing.ui.testapp;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.webkit.WebSettings;
-import android.webkit.WebView;
-
-/**
- * One big web view to play with.
- */
-public class SimpleWebViewActivity extends Activity {
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
- WebView mainWebView = new WebView(this);
- setContentView(mainWebView);
- mainWebView.loadData(
- "<html>" +
- "<script>document.was_clicked = false</script>" +
- "<body> " +
- "<button style='height:1000px;width:1000px;' onclick='document.was_clicked = true'> " +
- "I'm a button</button>" +
- "</body> " +
- "</html>", "text/html", null);
- WebSettings settings = mainWebView.getSettings();
- settings.setJavaScriptEnabled(true);
- }
-}
diff --git a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SwipeActivity.java b/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SwipeActivity.java
deleted file mode 100644
index 93d1c18..0000000
--- a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SwipeActivity.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.apps.common.testing.ui.testapp;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.support.v4.view.ViewPager;
-
-/**
- * Activity to test swipe interactions.
- */
-public class SwipeActivity extends Activity {
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.swipe_activity);
-
- ((ViewPager) findViewById(R.id.small_pager)).setAdapter(new SimplePagerAdapter());
- ((ViewPager) findViewById(R.id.overlapped_pager)).setAdapter(new SimplePagerAdapter());
- }
-
-}
-
diff --git a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SyncActivity.java b/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SyncActivity.java
deleted file mode 100644
index 6702390..0000000
--- a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/SyncActivity.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.apps.common.testing.ui.testapp;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import com.google.common.annotations.VisibleForTesting;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.os.SystemClock;
-import android.view.View;
-import android.widget.TextView;
-
-import java.util.Random;
-
-/**
- * Displays "hello world" with a random delay of 2 to 7s after the user clicks on a button. This is
- * used to demonstrate how Espresso can synchronize with any part of your application, which may
- * cause the application state to be unstable (e.g. a network call).
- */
-public class SyncActivity extends Activity {
-
- /**
- * A server that returns a hello world string
- */
- public interface HelloWorldServer {
- String getHelloWorld();
- }
-
- private HelloWorldServer helloWorldServer;
- private TextView statusTextView;
-
- @Override
- protected void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- setContentView(R.layout.sync_activity);
-
- statusTextView = checkNotNull(((TextView) findViewById(R.id.status_text)));
-
- setHelloWorldServer(new HelloWorldServer() {
- @Override
- public String getHelloWorld() {
- Random rand = new Random();
- SystemClock.sleep(rand.nextInt(5000) + 2000);
- return getString(R.string.hello_world);
- }
- });
- }
-
- public void onRequestButtonClick(@SuppressWarnings("unused") View view) {
- Thread t = new Thread() {
- @Override
- public void run() {
- final String helloworld = helloWorldServer.getHelloWorld();
- runOnUiThread(new Runnable() {
- @Override
- public void run() {
- setStatus(helloworld);
- }
- });
- }
- };
- t.start();
- }
-
- private void setStatus(String text) {
- statusTextView.setText(text);
- }
-
- @VisibleForTesting
- public HelloWorldServer getHelloWorldServer() {
- return helloWorldServer;
- }
-
- @VisibleForTesting
- public void setHelloWorldServer(HelloWorldServer helloWorldServer) {
- this.helloWorldServer = helloWorldServer;
- }
-}
diff --git a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/ViewPagerActivity.java b/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/ViewPagerActivity.java
deleted file mode 100644
index ec92db8..0000000
--- a/espresso/espresso-sample/src/main/java/com/google/android/apps/common/testing/ui/testapp/ViewPagerActivity.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.android.apps.common.testing.ui.testapp;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.support.v4.view.ViewPager;
-
-/**
- * Activity to demonstrate actions on a {@link ViewPager}.
- */
-public class ViewPagerActivity extends Activity {
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.pager_activity);
-
- final ViewPager pager = (ViewPager) findViewById(R.id.pager_layout);
- pager.setAdapter(new SimplePagerAdapter());
- }
-
-}
-