OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.chrome.browser.init; | 5 package org.chromium.chrome.browser.init; |
6 | 6 |
7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
8 import android.annotation.TargetApi; | 8 import android.annotation.TargetApi; |
9 import android.app.Activity; | 9 import android.app.Activity; |
10 import android.content.Context; | 10 import android.content.Context; |
(...skipping 21 matching lines...) Expand all Loading... | |
32 import org.chromium.chrome.browser.ChromeApplication; | 32 import org.chromium.chrome.browser.ChromeApplication; |
33 import org.chromium.chrome.browser.WarmupManager; | 33 import org.chromium.chrome.browser.WarmupManager; |
34 import org.chromium.chrome.browser.metrics.MemoryUma; | 34 import org.chromium.chrome.browser.metrics.MemoryUma; |
35 import org.chromium.chrome.browser.profiles.Profile; | 35 import org.chromium.chrome.browser.profiles.Profile; |
36 import org.chromium.chrome.browser.tabmodel.DocumentModeAssassin; | 36 import org.chromium.chrome.browser.tabmodel.DocumentModeAssassin; |
37 import org.chromium.chrome.browser.upgrade.UpgradeActivity; | 37 import org.chromium.chrome.browser.upgrade.UpgradeActivity; |
38 import org.chromium.content.browser.ChildProcessCreationParams; | 38 import org.chromium.content.browser.ChildProcessCreationParams; |
39 import org.chromium.ui.base.DeviceFormFactor; | 39 import org.chromium.ui.base.DeviceFormFactor; |
40 | 40 |
41 import java.lang.reflect.Field; | 41 import java.lang.reflect.Field; |
42 import java.util.Locale; | |
42 | 43 |
43 /** | 44 /** |
44 * An activity that talks with application and activity level delegates for asyn c initialization. | 45 * An activity that talks with application and activity level delegates for asyn c initialization. |
45 */ | 46 */ |
46 public abstract class AsyncInitializationActivity extends AppCompatActivity impl ements | 47 public abstract class AsyncInitializationActivity extends AppCompatActivity impl ements |
47 ChromeActivityNativeDelegate, BrowserParts { | 48 ChromeActivityNativeDelegate, BrowserParts { |
48 | 49 |
49 protected final Handler mHandler; | 50 protected final Handler mHandler; |
50 | 51 |
51 // Time at which onCreate is called. This is realtime, counted in ms since d evice boot. | 52 // Time at which onCreate is called. This is realtime, counted in ms since d evice boot. |
(...skipping 14 matching lines...) Expand all Loading... | |
66 } | 67 } |
67 | 68 |
68 @Override | 69 @Override |
69 protected void onDestroy() { | 70 protected void onDestroy() { |
70 mDestroyed = true; | 71 mDestroyed = true; |
71 super.onDestroy(); | 72 super.onDestroy(); |
72 } | 73 } |
73 | 74 |
74 @Override | 75 @Override |
75 // TODO(estevenson): Replace with Build.VERSION_CODES.N when available. | 76 // TODO(estevenson): Replace with Build.VERSION_CODES.N when available. |
76 @TargetApi(24) | 77 @TargetApi(24) |
Theresa
2016/08/29 20:44:23
This needs to get updated to JellyBean_MR1
Ian Wen
2016/08/29 21:03:47
Done.
| |
77 protected void attachBaseContext(Context newBase) { | 78 protected void attachBaseContext(Context newBase) { |
78 super.attachBaseContext(newBase); | 79 super.attachBaseContext(newBase); |
Theresa
2016/08/29 20:44:23
Let's add a check here to return early if the SDK
Ian Wen
2016/08/29 21:03:47
Done.
| |
79 | 80 |
81 Configuration overrideConfiguration = null; | |
82 | |
80 // On N+, Chrome should always retain the tab strip layout on tablets. N ormally in | 83 // On N+, Chrome should always retain the tab strip layout on tablets. N ormally in |
81 // multi-window, if Chrome is launched into a smaller screen Android wil l load the tab | 84 // multi-window, if Chrome is launched into a smaller screen Android wil l load the tab |
82 // switcher resources. Overriding the smallestScreenWidthDp in the Confi guration ensures | 85 // switcher resources. Overriding the smallestScreenWidthDp in the Confi guration ensures |
83 // Android will load the tab strip resources. See crbug.com/588838. | 86 // Android will load the tab strip resources. See crbug.com/588838. |
84 if (Build.VERSION.CODENAME.equals("N") || Build.VERSION.SDK_INT > Build. VERSION_CODES.M) { | 87 if (Build.VERSION.CODENAME.equals("N") || Build.VERSION.SDK_INT > Build. VERSION_CODES.M) { |
85 int smallestDeviceWidthDp = DeviceFormFactor.getSmallestDeviceWidthD p(this); | 88 int smallestDeviceWidthDp = DeviceFormFactor.getSmallestDeviceWidthD p(this); |
86 | 89 |
87 if (smallestDeviceWidthDp >= DeviceFormFactor.MINIMUM_TABLET_WIDTH_D P) { | 90 if (smallestDeviceWidthDp >= DeviceFormFactor.MINIMUM_TABLET_WIDTH_D P) { |
88 Configuration overrideConfiguration = new Configuration(); | 91 overrideConfiguration = new Configuration(); |
89 overrideConfiguration.smallestScreenWidthDp = smallestDeviceWidt hDp; | 92 overrideConfiguration.smallestScreenWidthDp = smallestDeviceWidt hDp; |
90 applyOverrideConfiguration(overrideConfiguration); | |
91 } | 93 } |
92 } | 94 } |
95 | |
96 // Before Android N, zh_HK is not well supported. Here we fall back manu ally to TW locale. | |
jungshik at Google
2016/08/29 21:19:42
The above is not an accurate statement.
zh-HK (a
Ian Wen
2016/08/29 21:34:03
Indeed. Done.
| |
97 // Since Android N, zh_HK will be automatically handled by the framework properly. | |
98 if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) { | |
99 if ("HK".equals(Locale.getDefault().getCountry())) { | |
Theresa
2016/08/29 20:44:23
Do we want to add Macau as well?
Ian Wen
2016/08/29 21:03:47
Probably not. Macau is only an option after Androi
jungshik at Google
2016/08/29 21:19:42
Android OEMs can add zh-MO, zh-SG and whatever loc
Ian Wen
2016/08/29 21:34:03
What you said is correct in theory, but I failed t
| |
100 if (overrideConfiguration == null) overrideConfiguration = new C onfiguration(); | |
101 overrideConfiguration.setLocale(Locale.TAIWAN); | |
102 } | |
103 } | |
104 | |
105 if (overrideConfiguration != null) applyOverrideConfiguration(overrideCo nfiguration); | |
93 } | 106 } |
94 | 107 |
95 @Override | 108 @Override |
96 public void preInflationStartup() { | 109 public void preInflationStartup() { |
97 mIsTablet = DeviceFormFactor.isTablet(this); | 110 mIsTablet = DeviceFormFactor.isTablet(this); |
98 } | 111 } |
99 | 112 |
100 @Override | 113 @Override |
101 public final void setContentViewAndLoadLibrary() { | 114 public final void setContentViewAndLoadLibrary() { |
102 // setContentView inflating the decorView and the basic UI hierarhcy as stubs. | 115 // setContentView inflating the decorView and the basic UI hierarhcy as stubs. |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
508 getDecorView().setVisibility(View.GONE); | 521 getDecorView().setVisibility(View.GONE); |
509 } | 522 } |
510 getViewTreeObserver().removeOnPreDrawListener(mPreDrawLi stener); | 523 getViewTreeObserver().removeOnPreDrawListener(mPreDrawLi stener); |
511 } | 524 } |
512 }); | 525 }); |
513 return true; | 526 return true; |
514 } | 527 } |
515 }; | 528 }; |
516 } | 529 } |
517 } | 530 } |
OLD | NEW |