Use entity header to show account name in sync detail page

Also removed a bunch of outdated layout and drawables.

Change-Id: I38094d72b84fab1309163f641c4019349f5d6ee7
Fixes: 77657624
Test: visual
This commit is contained in:
Fan Zhang
2018-04-05 17:47:40 -07:00
parent 02aaca9529
commit 11e8d2f293
23 changed files with 53 additions and 239 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1016 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 779 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 757 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 790 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

View File

@@ -19,6 +19,6 @@
-->
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_sync_anim_holo"
android:drawable="@drawable/ic_sync"
android:pivotX="50%"
android:pivotY="50%" />

View File

@@ -0,0 +1,26 @@
<!--
Copyright (C) 2018 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.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?android:attr/colorControlNormal">
<path
android:fillColor="#FF000000"
android:pathData="M3,12c0,2.21 0.91,4.2 2.36,5.64L3,20h6v-6l-2.24,2.24C5.68,15.15 5,13.66 5,12c0,-2.61 1.67,-4.83 4,-5.65L9,4.26C5.55,5.15 3,8.27 3,12zM11,17h2v-2h-2v2zM21,4h-6v6l2.24,-2.24C18.32,8.85 19,10.34 19,12c0,2.61 -1.67,4.83 -4,5.65v2.09c3.45,-0.89 6,-4.01 6,-7.74 0,-2.21 -0.91,-4.2 -2.36,-5.64L21,4zM11,13h2L13,7h-2v6z"/>
</vector>

View File

@@ -1,69 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2006, 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.
*/
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/title" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/settings_side_margin"
android:layout_marginEnd="@dimen/settings_side_margin"
android:scaleType="fitXY"
android:src="?android:attr/listDivider" />
<FrameLayout
android:id="@+id/prefs_container"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:clipToPadding="false"
android:scrollbarStyle="outsideOverlay" />
<TextView android:id="@+id/sync_settings_error_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dip"
android:text="@string/sync_is_failing"
android:drawablePadding="8dip"
android:drawableLeft="@drawable/ic_sync_error_holo" />
<RelativeLayout android:id="@+id/finish_button_area"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="@android:drawable/bottom_bar"
android:visibility="gone">
<Button android:id="@+id/finish_button"
android:layout_width="150dip"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:layout_alignParentEnd="true"
android:drawableEnd="@drawable/ic_btn_next"
android:drawablePadding="3dip"
android:text="@string/finish_button_label"
/>
</RelativeLayout>
</LinearLayout>

View File

@@ -1,41 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/* //device/apps/common/assets/res/layout/list_content.xml
**
** Copyright 2006, 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.
*/
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/prefs_container"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:clipToPadding="false"
android:scrollbarStyle="@integer/preference_scrollbar_style" />
<TextView android:id="@+id/sync_settings_error_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dip"
android:text="@string/sync_is_failing"
android:drawablePadding="8dip"
android:drawableLeft="@drawable/ic_sync_error_holo" />
</LinearLayout>

View File

@@ -24,7 +24,7 @@
<ImageView
android:id="@+id/sync_failed"
android:src="@drawable/ic_sync_error_holo"
android:src="@drawable/ic_sync_problem_24dp"
android:layout_width="wrap_content"
android:layout_marginEnd="8dip"
android:layout_height="wrap_content"

View File

@@ -1,63 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/**
* Copyright (C) 2009 Google Inc.
*
* 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.
*/
-->
<!-- The title area at the top of the settings pane -->
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/title_area"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/settings_side_margin"
android:layout_marginEnd="@dimen/settings_side_margin"
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:paddingTop="8dip"
android:paddingBottom="8dip"
android:columnCount="2">
<ImageView
android:id="@+id/provider_icon"
android:layout_width="@android:dimen/app_icon_size"
android:layout_height="@android:dimen/app_icon_size"
android:layout_rowSpan="2"
android:layout_marginEnd="8dip"
android:scaleType="centerInside"
android:contentDescription="@null" />
<TextView
android:id="@+id/user_id"
android:layout_width="0dip"
android:layout_gravity="fill_horizontal"
android:layout_marginTop="2dip"
android:singleLine="true"
android:ellipsize="marquee"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textAlignment="viewStart" />
<TextView
android:id="@+id/provider_id"
android:layout_width="0dip"
android:layout_gravity="fill_horizontal|top"
android:singleLine="true"
android:ellipsize="marquee"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textAlignment="viewStart" />
</GridLayout>

View File

@@ -5908,8 +5908,6 @@
<string name="remove_account_label">Remove account</string>
<!-- Title shown in AddAccount -->
<string name="header_add_an_account">Add an account</string>
<!-- Button shown when this activity is run from SetupWizard -->
<string name="finish_button_label">Finish</string>
<!-- Title of remove message for remove account dialog -->
<string name="really_remove_account_title">Remove account?</string>
<!-- Remove account message in dialog [CHAR LIMIT=NONE] -->

View File

@@ -14,11 +14,9 @@
limitations under the License.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Needed so PreferenceGroupAdapter allows SyncStateSwitchPreference to be
recycled. Removed in onResume -->
<com.android.settings.accounts.SyncStateSwitchPreference
android:key="dummy" />
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:key="account_sync_details_screen"
android:title="@string/account_sync_title">
</PreferenceScreen>

View File

@@ -35,22 +35,17 @@ import android.os.Binder;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.UserManager;
import androidx.preference.Preference;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
import com.android.settings.R;
import com.android.settings.Utils;
import com.android.settings.widget.EntityHeaderController;
import com.google.android.collect.Lists;
@@ -58,6 +53,8 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import androidx.preference.Preference;
public class AccountSyncSettings extends AccountPreferenceBase {
public static final String ACCOUNT_KEY = "account";
@@ -65,10 +62,6 @@ public class AccountSyncSettings extends AccountPreferenceBase {
private static final int MENU_SYNC_CANCEL_ID = Menu.FIRST + 1;
private static final int CANT_DO_ONETIME_SYNC_DIALOG = 102;
private TextView mUserId;
private TextView mProviderId;
private ImageView mProviderIcon;
private TextView mErrorInfoView;
private Account mAccount;
private ArrayList<SyncAdapterType> mInvisibleAdapters = Lists.newArrayList();
@@ -103,36 +96,8 @@ public class AccountSyncSettings extends AccountPreferenceBase {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setPreferenceScreen(null);
addPreferencesFromResource(R.xml.account_sync_settings);
getPreferenceScreen().setOrderingAsAdded(false);
setAccessibilityTitle();
setHasOptionsMenu(true);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.account_sync_screen, container, false);
final ViewGroup prefs_container = view.findViewById(R.id.prefs_container);
Utils.prepareCustomPreferencesList(container, view, prefs_container, false);
View prefs = super.onCreateView(inflater, prefs_container, savedInstanceState);
prefs_container.addView(prefs);
initializeUi(view);
return view;
}
protected void initializeUi(final View rootView) {
mErrorInfoView = (TextView) rootView.findViewById(R.id.sync_settings_error_info);
mErrorInfoView.setVisibility(View.GONE);
mUserId = (TextView) rootView.findViewById(R.id.user_id);
mProviderId = (TextView) rootView.findViewById(R.id.provider_id);
mProviderIcon = (ImageView) rootView.findViewById(R.id.provider_icon);
}
@Override
@@ -145,7 +110,7 @@ public class AccountSyncSettings extends AccountPreferenceBase {
finish();
return;
}
mAccount = (Account) arguments.getParcelable(ACCOUNT_KEY);
mAccount = arguments.getParcelable(ACCOUNT_KEY);
if (!accountExists(mAccount)) {
Log.e(TAG, "Account provided does not exist: " + mAccount);
finish();
@@ -154,8 +119,15 @@ public class AccountSyncSettings extends AccountPreferenceBase {
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "Got account: " + mAccount);
}
mUserId.setText(mAccount.name);
mProviderId.setText(mAccount.type);
final Activity activity = getActivity();
final Preference pref = EntityHeaderController
.newInstance(activity, this, null /* header */)
.setRecyclerView(getListView(), getLifecycle())
.setIcon(getDrawableForType(mAccount.type))
.setLabel(mAccount.name)
.setSummary(getLabelForType(mAccount.type))
.done(activity, getPrefContext());
getPreferenceScreen().addPreference(pref);
}
private void setAccessibilityTitle() {
@@ -172,7 +144,6 @@ public class AccountSyncSettings extends AccountPreferenceBase {
@Override
public void onResume() {
removePreference("dummy");
mAuthenticatorHelper.listenToAccountUpdates();
updateAuthDescriptions();
onAccountsUpdate(Binder.getCallingUserHandle());
@@ -481,7 +452,10 @@ public class AccountSyncSettings extends AccountPreferenceBase {
syncPref.setOneTimeSyncMode(oneTimeSyncMode);
syncPref.setChecked(oneTimeSyncMode || syncEnabled);
}
mErrorInfoView.setVisibility(syncIsFailing ? View.VISIBLE : View.GONE);
if (syncIsFailing) {
mFooterPreferenceMixin.createFooterPreference()
.setTitle(R.string.sync_is_failing);
}
}
@Override
@@ -536,7 +510,9 @@ public class AccountSyncSettings extends AccountPreferenceBase {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "looking for sync adapters that match account " + mAccount);
}
cacheRemoveAllPrefs(getPreferenceScreen());
getCachedPreference(EntityHeaderController.PREF_KEY_APP_HEADER);
for (int j = 0, m = authorities.size(); j < m; j++) {
final SyncAdapterType syncAdapter = authorities.get(j);
// We could check services here....
@@ -560,18 +536,6 @@ public class AccountSyncSettings extends AccountPreferenceBase {
removeCachedPrefs(getPreferenceScreen());
}
/**
* Updates the titlebar with an icon for the provider type.
*/
@Override
protected void onAuthDescriptionsUpdated() {
super.onAuthDescriptionsUpdated();
if (mAccount != null) {
mProviderIcon.setImageDrawable(getDrawableForType(mAccount.type));
mProviderId.setText(getLabelForType(mAccount.type));
}
}
@Override
public int getHelpResource() {
return R.string.help_url_accounts;

View File

@@ -24,7 +24,6 @@ import static org.mockito.Mockito.when;
import android.content.Context;
import android.hardware.input.InputManager;
import androidx.preference.Preference;
import android.view.InputDevice;
import com.android.settings.R;
@@ -40,6 +39,8 @@ import org.mockito.MockitoAnnotations;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import androidx.preference.Preference;
@RunWith(SettingsRobolectricTestRunner.class)
public class PhysicalKeyboardPreferenceControllerTest {