diff options
4 files changed, 81 insertions, 1 deletions
diff --git a/tests/UiBench/AndroidManifest.xml b/tests/UiBench/AndroidManifest.xml index 0681b61fc02f..07f7617828e5 100644 --- a/tests/UiBench/AndroidManifest.xml +++ b/tests/UiBench/AndroidManifest.xml @@ -100,6 +100,15 @@              </intent-filter>          </activity>          <activity +            android:name=".ClippedListActivity" +            android:label="General/Clipped ListView" +            android:theme="@style/NoActionBar"> +            <intent-filter> +                <action android:name="android.intent.action.MAIN" /> +                <category android:name="com.android.test.uibench.TEST" /> +            </intent-filter> +        </activity> +        <activity              android:name=".TrivialRecyclerViewActivity"              android:label="General/Trivial RecyclerView" >              <intent-filter> diff --git a/tests/UiBench/res/layout/app_bar_navigation_drawer.xml b/tests/UiBench/res/layout/app_bar_navigation_drawer.xml index ede2a566987b..5657587f7772 100644 --- a/tests/UiBench/res/layout/app_bar_navigation_drawer.xml +++ b/tests/UiBench/res/layout/app_bar_navigation_drawer.xml @@ -16,6 +16,7 @@    -->  <android.support.design.widget.CoordinatorLayout      xmlns:android="http://schemas.android.com/apk/res/android" +    android:id="@+id/app_bar_layout"      android:layout_width="match_parent"      android:layout_height="match_parent"      android:fitsSystemWindows="true"> diff --git a/tests/UiBench/src/com/android/test/uibench/ClippedListActivity.java b/tests/UiBench/src/com/android/test/uibench/ClippedListActivity.java new file mode 100644 index 000000000000..7454124b5ed0 --- /dev/null +++ b/tests/UiBench/src/com/android/test/uibench/ClippedListActivity.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2017 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.android.test.uibench; + +import android.os.Bundle; +import android.support.design.widget.NavigationView; +import android.support.v4.app.FragmentManager; +import android.support.v4.app.ListFragment; +import android.support.v4.view.GravityCompat; +import android.support.v4.widget.DrawerLayout; +import android.support.v7.app.ActionBarDrawerToggle; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.view.MenuItem; +import android.widget.ArrayAdapter; +import android.widget.ListAdapter; + +public class ClippedListActivity extends AppCompatActivity +        implements NavigationView.OnNavigationItemSelectedListener { + +    @Override +    protected void onCreate(Bundle savedInstanceState) { +        super.onCreate(savedInstanceState); +        setContentView(R.layout.activity_navigation_drawer); +        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); +        setSupportActionBar(toolbar); +        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); +        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( +                this, drawer, toolbar, R.string.navigation_drawer_open, +                R.string.navigation_drawer_close); +        drawer.setDrawerListener(toggle); +        toggle.syncState(); + +        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); +        navigationView.setNavigationItemSelectedListener(this); + +        FragmentManager fm = getSupportFragmentManager(); +        if (fm.findFragmentById(android.R.id.content) == null) { +            ListFragment listFragment = new ListFragment(); +            ListAdapter adapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, +                    TextUtils.buildSimpleStringList(40)); +            listFragment.setListAdapter(adapter); +            fm.beginTransaction().add(R.id.app_bar_layout, listFragment).commit(); +        } +    } + +    @Override +    public boolean onNavigationItemSelected(MenuItem item) { +        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); +        drawer.closeDrawer(GravityCompat.START); +        return true; +    } +} diff --git a/tests/UiBench/src/com/android/test/uibench/TextUtils.java b/tests/UiBench/src/com/android/test/uibench/TextUtils.java index d88ca1e1a889..32a59868e6c0 100644 --- a/tests/UiBench/src/com/android/test/uibench/TextUtils.java +++ b/tests/UiBench/src/com/android/test/uibench/TextUtils.java @@ -35,10 +35,14 @@ public class TextUtils {      }      public static String[] buildSimpleStringList() { +        return buildSimpleStringList(SIMPLE_STRING_LENGTH); +    } + +    public static String[] buildSimpleStringList(int stringLength) {          String[] strings = new String[STRING_COUNT];          Random random = new Random(0);          for (int i = 0; i < strings.length; i++) { -            strings[i] = randomWord(random, SIMPLE_STRING_LENGTH); +            strings[i] = randomWord(random, stringLength);          }          return strings;      }  |