Switch to use small icon for most app related pages

- Renamed AppProgressPreference to AppPreference to handle most app
  related prefs
- Add ed AppSwitchPreference - the same layout as AppPreference except
  it's a SwitchPreference
- Use above 2 prefs in most app related pages.
  - Everything under special access pages
  - Recent app list in App & notifications
  - App data usage detail page
  - Default app picker pages

Bug: 65182905
Test: robotests
Change-Id: I96c980ba1db49e36dabe25b5eade1197215aad11
This commit is contained in:
Fan Zhang
2017-10-28 15:11:49 -07:00
parent 974d2fe080
commit 1c3a4de93d
25 changed files with 350 additions and 121 deletions

View File

@@ -0,0 +1,78 @@
/*
* 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.settings.widget;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import android.support.v7.preference.PreferenceViewHolder;
import android.view.View;
import com.android.settings.R;
import com.android.settings.TestConfig;
import com.android.settings.testutils.SettingsRobolectricTestRunner;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
public class AppPreferenceTest {
private Context mContext;
private View mRootView;
private AppPreference mPref;
private PreferenceViewHolder mHolder;
@Before
public void setUp() {
mContext = RuntimeEnvironment.application;
mRootView = View.inflate(mContext, R.layout.preference_app, null /* parent */);
mHolder = PreferenceViewHolder.createInstanceForTests(mRootView);
mPref = new AppPreference(mContext);
}
@Test
public void setProgress_showProgress() {
mPref.setProgress(1);
mPref.onBindViewHolder(mHolder);
assertThat(mHolder.findViewById(android.R.id.progress).getVisibility())
.isEqualTo(View.VISIBLE);
}
@Test
public void setSummary_showSummaryContainer() {
mPref.setSummary("test");
mPref.onBindViewHolder(mHolder);
assertThat(mHolder.findViewById(R.id.summary_container).getVisibility())
.isEqualTo(View.VISIBLE);
}
@Test
public void noSummary_hideSummaryContainer() {
mPref.setSummary(null);
mPref.onBindViewHolder(mHolder);
assertThat(mHolder.findViewById(R.id.summary_container).getVisibility())
.isEqualTo(View.GONE);
}
}