Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 86708a8a authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Add back a SYNC_SETTINGS screen

Revive the old Accounts&Sync screen as a dialog with the auto-sync
checkbox and a list of accounts. This will be launched when Apps
request a SYNC_SETTINGS page for controlling account and master sync.

Auto-sync data checkbox will also continue to exist in Data Usage.

Minor fixes to account list and account update monitoring.

Bug: 6614013
Bug: 6622995
Bug: 6610247
Change-Id: I35c0919a29c6bc7e5edf64f2734a3ef4f5ae5e7a
parent 6a5e0252
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -1366,6 +1366,7 @@

        <activity android:name="Settings$AccountSyncSettingsActivity"
            android:label="@string/account_sync_settings_title"
            android:parentActivityName="Settings"
            android:uiOptions="none">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
@@ -1378,6 +1379,16 @@
                android:resource="@id/account_settings" />
        </activity>

        <activity android:name=".accounts.SyncSettingsActivity"
            android:label="@string/account_sync_settings_title"
            android:theme="@android:style/Theme.Holo.Dialog">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <action android:name="android.settings.SYNC_SETTINGS" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity android:name="com.android.settings.accounts.AddAccountSettings"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"
            android:configChanges="orientation|keyboardHidden|screenSize"
@@ -1441,7 +1452,6 @@
                android:parentActivityName="Settings">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <action android:name="android.settings.SYNC_SETTINGS" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="com.android.settings.SHORTCUT" />
            </intent-filter>
+1 −1
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@
    <dimen name="divider_margin_bottom">7dip</dimen>

    <!--  Size of icons in the top-level of settings  -->
    <dimen name="header_icon_width">32dp</dimen>
    <dimen name="header_icon_width">28dp</dimen>
    <dimen name="appwidget_min_width">260dip</dimen>
    <dimen name="appwidget_min_height">40dip</dimen>
</resources>
+21 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2012 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.
-->

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
    <CheckBoxPreference
        android:key="sync_switch"
        android:title="@string/sync_automatically" />
</PreferenceScreen>
+24 −10
Original line number Diff line number Diff line
@@ -39,16 +39,24 @@ public class AccountPreference extends Preference {
    private int mStatus;
    private Account mAccount;
    private ArrayList<String> mAuthorities;
    private ImageView mSyncStatusIcon;
    private boolean mShowTypeIcon;

    public AccountPreference(Context context, Account account, Drawable icon,
            ArrayList<String> authorities) {
            ArrayList<String> authorities, boolean showTypeIcon) {
        super(context);
        mAccount = account;
        mAuthorities = authorities;
        mShowTypeIcon = showTypeIcon;
        if (showTypeIcon) {
            setIcon(icon);
        } else {
            setIcon(getSyncStatusIcon(SYNC_DISABLED));
        }
        setTitle(mAccount.name);
        setSummary("");
        setPersistent(false);
        setSyncStatus(SYNC_DISABLED);
        setSyncStatus(SYNC_DISABLED, false);
    }

    public Account getAccount() {
@@ -62,17 +70,23 @@ public class AccountPreference extends Preference {
    @Override
    protected void onBindView(View view) {
        super.onBindView(view);
        setSummary(getSyncStatusMessage(mStatus));
        ImageView iconView = (ImageView) view.findViewById(android.R.id.icon);
        iconView.setImageResource(getSyncStatusIcon(mStatus));
        iconView.setContentDescription(getSyncContentDescription(mStatus));
        if (!mShowTypeIcon) {
            mSyncStatusIcon = (ImageView) view.findViewById(android.R.id.icon);
            mSyncStatusIcon.setImageResource(getSyncStatusIcon(mStatus));
            mSyncStatusIcon.setContentDescription(getSyncContentDescription(mStatus));
        }
    }

    public void setSyncStatus(int status) {
    public void setSyncStatus(int status, boolean updateSummary) {
        mStatus = status;
        setIcon(getSyncStatusIcon(status));
        if (!mShowTypeIcon && mSyncStatusIcon != null) {
            mSyncStatusIcon.setImageResource(getSyncStatusIcon(status));
            mSyncStatusIcon.setContentDescription(getSyncContentDescription(mStatus));
        }
        if (updateSummary) {
            setSummary(getSyncStatusMessage(status));
        }
    }

    private int getSyncStatusMessage(int status) {
        int res;
@@ -109,7 +123,7 @@ public class AccountPreference extends Preference {
                res = R.drawable.ic_sync_red_holo;
                break;
            case SYNC_IN_PROGRESS:
                res = R.drawable.ic_sync_grey_holo;
                res = R.drawable.ic_sync_green_holo;
                break;
            default:
                res = R.drawable.ic_sync_red_holo;
+12 −1
Original line number Diff line number Diff line
@@ -112,6 +112,7 @@ public class Settings extends PreferenceActivity

    private AuthenticatorHelper mAuthenticatorHelper;
    private Header mLastHeader;
    private boolean mListeningToAccountUpdates;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
@@ -187,7 +188,6 @@ public class Settings extends PreferenceActivity
        ListAdapter listAdapter = getListAdapter();
        if (listAdapter instanceof HeaderAdapter) {
            ((HeaderAdapter) listAdapter).resume();
            AccountManager.get(this).addOnAccountsUpdatedListener(this, null, true);
        }
    }

@@ -198,6 +198,13 @@ public class Settings extends PreferenceActivity
        ListAdapter listAdapter = getListAdapter();
        if (listAdapter instanceof HeaderAdapter) {
            ((HeaderAdapter) listAdapter).pause();
        }
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mListeningToAccountUpdates) {
            AccountManager.get(this).removeOnAccountsUpdatedListener(this);
        }
    }
@@ -462,6 +469,10 @@ public class Settings extends PreferenceActivity
        for (Header header : accountHeaders) {
            target.add(headerIndex++, header);
        }
        if (!mListeningToAccountUpdates) {
            AccountManager.get(this).addOnAccountsUpdatedListener(this, null, true);
            mListeningToAccountUpdates = true;
        }
        return headerIndex;
    }

Loading