Change account colors to what aren't used in Calendar.
Bug 2535090 Change-Id: I252e04afa402303d226a56f1d7852f50dc26e2ec
Before Width: | Height: | Size: 543 B After Width: | Height: | Size: 443 B |
Before Width: | Height: | Size: 541 B |
Before Width: | Height: | Size: 536 B |
Before Width: | Height: | Size: 549 B |
Before Width: | Height: | Size: 507 B |
Before Width: | Height: | Size: 537 B |
Before Width: | Height: | Size: 526 B |
Before Width: | Height: | Size: 496 B |
Before Width: | Height: | Size: 525 B |
Before Width: | Height: | Size: 526 B |
Before Width: | Height: | Size: 536 B |
Before Width: | Height: | Size: 548 B After Width: | Height: | Size: 503 B |
Before Width: | Height: | Size: 527 B |
Before Width: | Height: | Size: 546 B |
Before Width: | Height: | Size: 539 B After Width: | Height: | Size: 453 B |
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 470 B |
Before Width: | Height: | Size: 542 B After Width: | Height: | Size: 485 B |
Before Width: | Height: | Size: 550 B After Width: | Height: | Size: 444 B |
Before Width: | Height: | Size: 543 B After Width: | Height: | Size: 460 B |
Before Width: | Height: | Size: 531 B After Width: | Height: | Size: 458 B |
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 481 B |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 331 B |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 347 B |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 356 B |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 338 B |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 339 B |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 331 B |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 343 B |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 324 B |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 345 B |
|
@ -162,31 +162,32 @@ public class Email extends Application {
|
|||
R.drawable.appointment_indicator_leftside_7,
|
||||
R.drawable.appointment_indicator_leftside_8,
|
||||
R.drawable.appointment_indicator_leftside_9,
|
||||
R.drawable.appointment_indicator_leftside_10,
|
||||
R.drawable.appointment_indicator_leftside_11,
|
||||
R.drawable.appointment_indicator_leftside_12,
|
||||
R.drawable.appointment_indicator_leftside_13,
|
||||
R.drawable.appointment_indicator_leftside_14,
|
||||
R.drawable.appointment_indicator_leftside_15,
|
||||
R.drawable.appointment_indicator_leftside_16,
|
||||
R.drawable.appointment_indicator_leftside_17,
|
||||
R.drawable.appointment_indicator_leftside_18,
|
||||
R.drawable.appointment_indicator_leftside_19,
|
||||
R.drawable.appointment_indicator_leftside_20,
|
||||
R.drawable.appointment_indicator_leftside_21,
|
||||
};
|
||||
|
||||
private static final int[] ACCOUNT_COLOR_CHIP_RGBS = new int[] {0x6aad08, 0xe24c7f, 0xed8500,
|
||||
0x3b6dd3, 0x29ad9c, 0x6e38d1, 0x31649b, 0x309363, 0x109918, 0xcc3431, 0xacad18, 0xd4ad00,
|
||||
0x9b449b, 0xe56021, 0xa46c6a, 0x8a6a8a, 0x60738b, 0x7082ab, 0x518987, 0x813149, 0xb48d59
|
||||
private static final int[] ACCOUNT_COLOR_CHIP_RGBS = new int[] {
|
||||
0x71aea7,
|
||||
0x621919,
|
||||
0x18462f,
|
||||
0xbf8e52,
|
||||
0x001f79,
|
||||
0xa8afc2,
|
||||
0x6b64c4,
|
||||
0x738359,
|
||||
0x9d50a4,
|
||||
};
|
||||
|
||||
/* package for testing */ static int getColorIndexFromAccountId(long accountId) {
|
||||
// Account id is 1-based, so - 1.
|
||||
// Use abs so that it won't possibly return negative.
|
||||
return Math.abs((int) (accountId - 1) % ACCOUNT_COLOR_CHIP_RES_IDS.length);
|
||||
}
|
||||
|
||||
public static int getAccountColorResourceId(long accountId) {
|
||||
return ACCOUNT_COLOR_CHIP_RES_IDS[(int)accountId % ACCOUNT_COLOR_CHIP_RES_IDS.length];
|
||||
return ACCOUNT_COLOR_CHIP_RES_IDS[getColorIndexFromAccountId(accountId)];
|
||||
}
|
||||
|
||||
public static int getAccountColor(long accountId) {
|
||||
return ACCOUNT_COLOR_CHIP_RGBS[(int)accountId % ACCOUNT_COLOR_CHIP_RGBS.length];
|
||||
return ACCOUNT_COLOR_CHIP_RGBS[getColorIndexFromAccountId(accountId)];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (C) 2010 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.email;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class EmailTest extends TestCase {
|
||||
public void testGetColorIndexFromAccountId() {
|
||||
// First account (id=1) gets index 0.
|
||||
assertEquals(0, Email.getColorIndexFromAccountId(1));
|
||||
assertEquals(1, Email.getColorIndexFromAccountId(2));
|
||||
|
||||
// Never return negative.
|
||||
assertTrue(Email.getColorIndexFromAccountId(-5) >= 0);
|
||||
|
||||
// Shouldn't throw ArrayIndexOutOfRange or anything.
|
||||
for (int i = -100; i < 100; i++) {
|
||||
Email.getAccountColorResourceId(i);
|
||||
Email.getAccountColor(i);
|
||||
}
|
||||
}
|
||||
}
|