OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.ui.resources.system; | 5 package org.chromium.ui.resources.system; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.content.res.Resources; | 8 import android.content.res.Resources; |
9 import android.graphics.Bitmap; | 9 import android.graphics.Bitmap; |
10 import android.graphics.Canvas; | 10 import android.graphics.Canvas; |
11 import android.graphics.Paint; | 11 import android.graphics.Paint; |
12 import android.graphics.Paint.Style; | 12 import android.graphics.Paint.Style; |
13 import android.graphics.RectF; | 13 import android.graphics.RectF; |
14 | 14 |
| 15 import org.chromium.ui.R; |
15 import org.chromium.ui.base.SystemUIResourceType; | 16 import org.chromium.ui.base.SystemUIResourceType; |
16 import org.chromium.ui.gfx.DeviceDisplayInfo; | 17 import org.chromium.ui.gfx.DeviceDisplayInfo; |
17 import org.chromium.ui.resources.Resource; | 18 import org.chromium.ui.resources.Resource; |
18 import org.chromium.ui.resources.async.AsyncPreloadResourceLoader; | 19 import org.chromium.ui.resources.async.AsyncPreloadResourceLoader; |
19 import org.chromium.ui.resources.statics.StaticResource; | 20 import org.chromium.ui.resources.statics.StaticResource; |
20 | 21 |
21 /** | 22 /** |
22 * Handles loading system specific resources like overscroll and edge glows. | 23 * Handles loading system specific resources like overscroll and edge glows. |
23 */ | 24 */ |
24 public class SystemResourceLoader extends AsyncPreloadResourceLoader { | 25 public class SystemResourceLoader extends AsyncPreloadResourceLoader { |
(...skipping 20 matching lines...) Expand all Loading... |
45 private static Resource createResource(Context context, int resId) { | 46 private static Resource createResource(Context context, int resId) { |
46 switch (resId) { | 47 switch (resId) { |
47 case SystemUIResourceType.OVERSCROLL_EDGE: | 48 case SystemUIResourceType.OVERSCROLL_EDGE: |
48 return StaticResource.create(Resources.getSystem(), | 49 return StaticResource.create(Resources.getSystem(), |
49 getResourceId("android:drawable/overscroll_edge"), 128,
12); | 50 getResourceId("android:drawable/overscroll_edge"), 128,
12); |
50 case SystemUIResourceType.OVERSCROLL_GLOW: | 51 case SystemUIResourceType.OVERSCROLL_GLOW: |
51 return StaticResource.create(Resources.getSystem(), | 52 return StaticResource.create(Resources.getSystem(), |
52 getResourceId("android:drawable/overscroll_glow"), 128,
64); | 53 getResourceId("android:drawable/overscroll_glow"), 128,
64); |
53 case SystemUIResourceType.OVERSCROLL_GLOW_L: | 54 case SystemUIResourceType.OVERSCROLL_GLOW_L: |
54 return createOverscrollGlowLBitmap(context); | 55 return createOverscrollGlowLBitmap(context); |
| 56 case SystemUIResourceType.OVERSCROLL_REFRESH_IDLE: |
| 57 return StaticResource.create(context.getResources(), R.drawable.
refresh_gray, 0, 0); |
| 58 case SystemUIResourceType.OVERSCROLL_REFRESH_ACTIVE: |
| 59 return StaticResource.create(context.getResources(), R.drawable.
refresh_blue, 0, 0); |
| 60 default: |
| 61 assert false; |
55 } | 62 } |
56 return null; | 63 return null; |
57 } | 64 } |
58 | 65 |
59 private static Resource createOverscrollGlowLBitmap(Context context) { | 66 private static Resource createOverscrollGlowLBitmap(Context context) { |
60 DeviceDisplayInfo displayInfo = DeviceDisplayInfo.create(context); | 67 DeviceDisplayInfo displayInfo = DeviceDisplayInfo.create(context); |
61 int screenWidth = displayInfo.getPhysicalDisplayWidth() != 0 | 68 int screenWidth = displayInfo.getPhysicalDisplayWidth() != 0 |
62 ? displayInfo.getPhysicalDisplayWidth() : displayInfo.getDisplay
Width(); | 69 ? displayInfo.getPhysicalDisplayWidth() : displayInfo.getDisplay
Width(); |
63 int screenHeight = displayInfo.getPhysicalDisplayHeight() != 0 | 70 int screenHeight = displayInfo.getPhysicalDisplayHeight() != 0 |
64 ? displayInfo.getPhysicalDisplayHeight() : displayInfo.getDispla
yHeight(); | 71 ? displayInfo.getPhysicalDisplayHeight() : displayInfo.getDispla
yHeight(); |
(...skipping 19 matching lines...) Expand all Loading... |
84 canvas.drawArc(arcRect, 45, 90, true, arcPaint); | 91 canvas.drawArc(arcRect, 45, 90, true, arcPaint); |
85 | 92 |
86 return new StaticResource(bitmap); | 93 return new StaticResource(bitmap); |
87 } | 94 } |
88 | 95 |
89 private static int getResourceId(String name) { | 96 private static int getResourceId(String name) { |
90 Resources systemResources = Resources.getSystem(); | 97 Resources systemResources = Resources.getSystem(); |
91 return systemResources.getIdentifier(name, null, null); | 98 return systemResources.getIdentifier(name, null, null); |
92 } | 99 } |
93 } | 100 } |
OLD | NEW |