зеркало из https://github.com/mozilla/gecko-dev.git
Bug 725932: Use handler messages. [r=mfinkle,blassey]
This commit is contained in:
Родитель
92f302e38f
Коммит
5e22b7de58
|
@ -125,6 +125,14 @@ public class AboutHomeContent extends ScrollView {
|
||||||
|
|
||||||
public AboutHomeContent(Context context) {
|
public AboutHomeContent(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AboutHomeContent(Context context, AttributeSet attrs) {
|
||||||
|
super(context, attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
Context context = getContext();
|
||||||
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
mInflater.inflate(R.layout.abouthome_content, this);
|
mInflater.inflate(R.layout.abouthome_content, this);
|
||||||
|
|
||||||
|
@ -148,9 +156,6 @@ public class AboutHomeContent extends ScrollView {
|
||||||
}
|
}
|
||||||
}, GeckoAppShell.getHandler(), true);
|
}, GeckoAppShell.getHandler(), true);
|
||||||
|
|
||||||
setScrollContainer(true);
|
|
||||||
setBackgroundResource(R.drawable.abouthome_bg_repeat);
|
|
||||||
|
|
||||||
mTopSitesGrid = (GridView)findViewById(R.id.top_sites_grid);
|
mTopSitesGrid = (GridView)findViewById(R.id.top_sites_grid);
|
||||||
mTopSitesGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
mTopSitesGrid.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
|
||||||
|
|
|
@ -77,7 +77,6 @@ public class BrowserToolbar extends LinearLayout {
|
||||||
|
|
||||||
final private Context mContext;
|
final private Context mContext;
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
private boolean mInflated;
|
|
||||||
private int mColor;
|
private int mColor;
|
||||||
private int mCounterColor;
|
private int mCounterColor;
|
||||||
private int[] mPadding;
|
private int[] mPadding;
|
||||||
|
@ -94,7 +93,6 @@ public class BrowserToolbar extends LinearLayout {
|
||||||
public BrowserToolbar(Context context, AttributeSet attrs) {
|
public BrowserToolbar(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mInflated = false;
|
|
||||||
mTitleCanExpand = true;
|
mTitleCanExpand = true;
|
||||||
|
|
||||||
// Get the device's highlight color
|
// Get the device's highlight color
|
||||||
|
@ -111,18 +109,7 @@ public class BrowserToolbar extends LinearLayout {
|
||||||
typedArray.recycle();
|
typedArray.recycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void init() {
|
||||||
protected void onFinishInflate () {
|
|
||||||
super.onFinishInflate();
|
|
||||||
|
|
||||||
// HACK: Without this, the onFinishInflate is called twice
|
|
||||||
// This issue is due to a bug when Android inflates a layout with a
|
|
||||||
// parent. Fixed in Honeycomb
|
|
||||||
if (mInflated)
|
|
||||||
return;
|
|
||||||
|
|
||||||
mInflated = true;
|
|
||||||
|
|
||||||
mAwesomeBar = (Button) findViewById(R.id.awesome_bar);
|
mAwesomeBar = (Button) findViewById(R.id.awesome_bar);
|
||||||
mAwesomeBar.setOnClickListener(new Button.OnClickListener() {
|
mAwesomeBar.setOnClickListener(new Button.OnClickListener() {
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
|
|
@ -124,7 +124,7 @@ abstract public class GeckoApp
|
||||||
public static File sGREDir = null;
|
public static File sGREDir = null;
|
||||||
public static Menu sMenu;
|
public static Menu sMenu;
|
||||||
private static GeckoThread sGeckoThread = null;
|
private static GeckoThread sGeckoThread = null;
|
||||||
public Handler mMainHandler;
|
public GeckoAppHandler mMainHandler;
|
||||||
private File mProfileDir;
|
private File mProfileDir;
|
||||||
public static boolean sIsGeckoReady = false;
|
public static boolean sIsGeckoReady = false;
|
||||||
public static int mOrientation;
|
public static int mOrientation;
|
||||||
|
@ -152,6 +152,10 @@ abstract public class GeckoApp
|
||||||
public byte[] mLastScreen;
|
public byte[] mLastScreen;
|
||||||
public int mOwnActivityDepth = 0;
|
public int mOwnActivityDepth = 0;
|
||||||
private boolean mRestoreSession = false;
|
private boolean mRestoreSession = false;
|
||||||
|
private boolean mInitialized = false;
|
||||||
|
|
||||||
|
private static final String HANDLER_MSG_TYPE = "type";
|
||||||
|
private static final int HANDLER_MSG_TYPE_INITIALIZE = 1;
|
||||||
|
|
||||||
public interface OnTabsChangedListener {
|
public interface OnTabsChangedListener {
|
||||||
public void onTabsChanged(Tab tab);
|
public void onTabsChanged(Tab tab);
|
||||||
|
@ -1145,8 +1149,10 @@ abstract public class GeckoApp
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
mAutoCompletePopup.hide();
|
mAutoCompletePopup.hide();
|
||||||
if (mAboutHomeContent == null && mShow) {
|
if (mShow) {
|
||||||
mAboutHomeContent = new AboutHomeContent(GeckoApp.mAppContext);
|
if (mAboutHomeContent == null) {
|
||||||
|
mAboutHomeContent = (AboutHomeContent) findViewById(R.id.abouthome_content);
|
||||||
|
mAboutHomeContent.init();
|
||||||
mAboutHomeContent.update(GeckoApp.mAppContext, AboutHomeContent.UpdateFlags.ALL);
|
mAboutHomeContent.update(GeckoApp.mAppContext, AboutHomeContent.UpdateFlags.ALL);
|
||||||
mAboutHomeContent.setUriLoadCallback(new AboutHomeContent.UriLoadCallback() {
|
mAboutHomeContent.setUriLoadCallback(new AboutHomeContent.UriLoadCallback() {
|
||||||
public void callback(String url) {
|
public void callback(String url) {
|
||||||
|
@ -1154,17 +1160,15 @@ abstract public class GeckoApp
|
||||||
loadUrl(url, AwesomeBar.Type.EDIT);
|
loadUrl(url, AwesomeBar.Type.EDIT);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
RelativeLayout.LayoutParams lp =
|
} else {
|
||||||
new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
|
|
||||||
LayoutParams.FILL_PARENT);
|
|
||||||
mGeckoLayout.addView(mAboutHomeContent, lp);
|
|
||||||
} else if (mAboutHomeContent != null && mShow) {
|
|
||||||
mAboutHomeContent.update(GeckoApp.mAppContext,
|
mAboutHomeContent.update(GeckoApp.mAppContext,
|
||||||
EnumSet.of(AboutHomeContent.UpdateFlags.TOP_SITES));
|
EnumSet.of(AboutHomeContent.UpdateFlags.TOP_SITES));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mAboutHomeContent != null)
|
mAboutHomeContent.setVisibility(View.VISIBLE);
|
||||||
mAboutHomeContent.setVisibility(mShow ? View.VISIBLE : View.GONE);
|
} else {
|
||||||
|
findViewById(R.id.abouthome_content).setVisibility(View.GONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1637,6 +1641,7 @@ abstract public class GeckoApp
|
||||||
public void refreshActionBar() {
|
public void refreshActionBar() {
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
if (Build.VERSION.SDK_INT >= 11) {
|
||||||
mBrowserToolbar = (BrowserToolbar) getLayoutInflater().inflate(R.layout.browser_toolbar, null);
|
mBrowserToolbar = (BrowserToolbar) getLayoutInflater().inflate(R.layout.browser_toolbar, null);
|
||||||
|
mBrowserToolbar.init();
|
||||||
mBrowserToolbar.refresh();
|
mBrowserToolbar.refresh();
|
||||||
GeckoActionBar.setBackgroundDrawable(this, getResources().getDrawable(R.drawable.gecko_actionbar_bg));
|
GeckoActionBar.setBackgroundDrawable(this, getResources().getDrawable(R.drawable.gecko_actionbar_bg));
|
||||||
GeckoActionBar.setDisplayOptions(this, ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM |
|
GeckoActionBar.setDisplayOptions(this, ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM |
|
||||||
|
@ -1659,7 +1664,7 @@ abstract public class GeckoApp
|
||||||
}
|
}
|
||||||
|
|
||||||
System.loadLibrary("mozglue");
|
System.loadLibrary("mozglue");
|
||||||
mMainHandler = new Handler();
|
mMainHandler = new GeckoAppHandler();
|
||||||
Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - onCreate");
|
Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - onCreate");
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
mLastTitle = savedInstanceState.getString(SAVED_STATE_TITLE);
|
mLastTitle = savedInstanceState.getString(SAVED_STATE_TITLE);
|
||||||
|
@ -1668,6 +1673,30 @@ abstract public class GeckoApp
|
||||||
mRestoreSession = savedInstanceState.getBoolean(SAVED_STATE_SESSION);
|
mRestoreSession = savedInstanceState.getBoolean(SAVED_STATE_SESSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
mOrientation = getResources().getConfiguration().orientation;
|
||||||
|
|
||||||
|
setContentView(R.layout.gecko_app);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= 11) {
|
||||||
|
mBrowserToolbar = (BrowserToolbar) GeckoActionBar.getCustomView(this);
|
||||||
|
} else {
|
||||||
|
mBrowserToolbar = (BrowserToolbar) findViewById(R.id.browser_toolbar);
|
||||||
|
}
|
||||||
|
|
||||||
|
// setup gecko layout
|
||||||
|
mGeckoLayout = (RelativeLayout) findViewById(R.id.gecko_layout);
|
||||||
|
mMainLayout = (LinearLayout) findViewById(R.id.main_layout);
|
||||||
|
|
||||||
|
mConnectivityFilter = new IntentFilter();
|
||||||
|
mConnectivityFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
|
||||||
|
mConnectivityReceiver = new GeckoConnectivityReceiver();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialize() {
|
||||||
|
mInitialized = true;
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
String args = intent.getStringExtra("args");
|
String args = intent.getStringExtra("args");
|
||||||
if (args != null && args.contains("-profile")) {
|
if (args != null && args.contains("-profile")) {
|
||||||
|
@ -1686,18 +1715,7 @@ abstract public class GeckoApp
|
||||||
checkAndLaunchUpdate();
|
checkAndLaunchUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
mBrowserToolbar.init();
|
||||||
|
|
||||||
mOrientation = getResources().getConfiguration().orientation;
|
|
||||||
|
|
||||||
setContentView(R.layout.gecko_app);
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 11) {
|
|
||||||
mBrowserToolbar = (BrowserToolbar) GeckoActionBar.getCustomView(this);
|
|
||||||
} else {
|
|
||||||
mBrowserToolbar = (BrowserToolbar) findViewById(R.id.browser_toolbar);
|
|
||||||
}
|
|
||||||
|
|
||||||
mBrowserToolbar.setTitle(mLastTitle);
|
mBrowserToolbar.setTitle(mLastTitle);
|
||||||
|
|
||||||
String passedUri = null;
|
String passedUri = null;
|
||||||
|
@ -1745,23 +1763,7 @@ abstract public class GeckoApp
|
||||||
|
|
||||||
mFavicons = new Favicons(this);
|
mFavicons = new Favicons(this);
|
||||||
|
|
||||||
// setup gecko layout
|
Tabs.getInstance().setContentResolver(getContentResolver());
|
||||||
mGeckoLayout = (RelativeLayout) findViewById(R.id.gecko_layout);
|
|
||||||
mMainLayout = (LinearLayout) findViewById(R.id.main_layout);
|
|
||||||
|
|
||||||
mDoorHangerPopup = new DoorHangerPopup(this);
|
|
||||||
mAutoCompletePopup = (AutoCompletePopup) findViewById(R.id.autocomplete_popup);
|
|
||||||
|
|
||||||
Tabs tabs = Tabs.getInstance();
|
|
||||||
Tab tab = tabs.getSelectedTab();
|
|
||||||
if (tab != null) {
|
|
||||||
mBrowserToolbar.setTitle(tab.getDisplayTitle());
|
|
||||||
mBrowserToolbar.setFavicon(tab.getFavicon());
|
|
||||||
mBrowserToolbar.setProgressVisibility(tab.isLoading());
|
|
||||||
mBrowserToolbar.updateTabCountAndAnimate(Tabs.getInstance().getCount());
|
|
||||||
}
|
|
||||||
|
|
||||||
tabs.setContentResolver(getContentResolver());
|
|
||||||
|
|
||||||
if (cameraView == null) {
|
if (cameraView == null) {
|
||||||
cameraView = new SurfaceView(this);
|
cameraView = new SurfaceView(this);
|
||||||
|
@ -1793,6 +1795,9 @@ abstract public class GeckoApp
|
||||||
|
|
||||||
mPluginContainer = (AbsoluteLayout) findViewById(R.id.plugin_container);
|
mPluginContainer = (AbsoluteLayout) findViewById(R.id.plugin_container);
|
||||||
|
|
||||||
|
mDoorHangerPopup = new DoorHangerPopup(this);
|
||||||
|
mAutoCompletePopup = (AutoCompletePopup) findViewById(R.id.autocomplete_popup);
|
||||||
|
|
||||||
Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - UI almost up");
|
Log.w(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - UI almost up");
|
||||||
|
|
||||||
if (!sTryCatchAttached) {
|
if (!sTryCatchAttached) {
|
||||||
|
@ -1840,10 +1845,6 @@ abstract public class GeckoApp
|
||||||
GeckoAppShell.registerGeckoEventListener("Tab:HasTouchListener", GeckoApp.mAppContext);
|
GeckoAppShell.registerGeckoEventListener("Tab:HasTouchListener", GeckoApp.mAppContext);
|
||||||
GeckoAppShell.registerGeckoEventListener("Session:StatePurged", GeckoApp.mAppContext);
|
GeckoAppShell.registerGeckoEventListener("Session:StatePurged", GeckoApp.mAppContext);
|
||||||
|
|
||||||
mConnectivityFilter = new IntentFilter();
|
|
||||||
mConnectivityFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
|
|
||||||
mConnectivityReceiver = new GeckoConnectivityReceiver();
|
|
||||||
|
|
||||||
IntentFilter batteryFilter = new IntentFilter();
|
IntentFilter batteryFilter = new IntentFilter();
|
||||||
batteryFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
batteryFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
|
||||||
mBatteryReceiver = new GeckoBatteryManager();
|
mBatteryReceiver = new GeckoBatteryManager();
|
||||||
|
@ -2099,6 +2100,17 @@ abstract public class GeckoApp
|
||||||
// Undo whatever we did in onPause.
|
// Undo whatever we did in onPause.
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
|
/* We load the initial UI and wait until it is shown to the user
|
||||||
|
to continue other initializations and loading about:home (if needed) */
|
||||||
|
if (!mInitialized) {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putInt(HANDLER_MSG_TYPE, HANDLER_MSG_TYPE_INITIALIZE);
|
||||||
|
|
||||||
|
Message message = mMainHandler.obtainMessage();
|
||||||
|
message.setData(bundle);
|
||||||
|
mMainHandler.sendMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
int newOrientation = getResources().getConfiguration().orientation;
|
int newOrientation = getResources().getConfiguration().orientation;
|
||||||
|
|
||||||
if (mOrientation != newOrientation) {
|
if (mOrientation != newOrientation) {
|
||||||
|
@ -2712,6 +2724,23 @@ abstract public class GeckoApp
|
||||||
layerController.setLayerClient(mSoftwareLayerClient);
|
layerController.setLayerClient(mSoftwareLayerClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class GeckoAppHandler extends Handler {
|
||||||
|
@Override
|
||||||
|
public void handleMessage(Message message) {
|
||||||
|
Bundle bundle = message.getData();
|
||||||
|
if (bundle == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int type = bundle.getInt(HANDLER_MSG_TYPE);
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case HANDLER_MSG_TYPE_INITIALIZE:
|
||||||
|
initialize();
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PluginLayoutParams extends AbsoluteLayout.LayoutParams
|
class PluginLayoutParams extends AbsoluteLayout.LayoutParams
|
||||||
|
|
|
@ -21,6 +21,11 @@
|
||||||
android:cacheColorHint="#ffffff"
|
android:cacheColorHint="#ffffff"
|
||||||
android:visibility="gone"/>
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
<org.mozilla.gecko.AboutHomeContent android:id="@+id/abouthome_content"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:background="@drawable/abouthome_bg_repeat"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
|
|
||||||
<LinearLayout android:layout_width="fill_parent"
|
<LinearLayout android:layout_width="fill_parent"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent">
|
||||||
android:background="@drawable/abouthome_bg_repeat">
|
|
||||||
|
|
||||||
<RelativeLayout android:id="@+id/top_sites"
|
<RelativeLayout android:id="@+id/top_sites"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
|
android:background="@drawable/address_bar_url_default"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:gravity="center_vertical|left"
|
android:gravity="center_vertical|left"
|
||||||
android:hint="@string/awesomebar_default_text"
|
android:hint="@string/awesomebar_default_text"
|
||||||
|
|
|
@ -23,6 +23,11 @@
|
||||||
android:cacheColorHint="#ffffff"
|
android:cacheColorHint="#ffffff"
|
||||||
android:visibility="gone"/>
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
<org.mozilla.gecko.AboutHomeContent android:id="@+id/abouthome_content"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:background="@drawable/abouthome_bg_repeat"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
Загрузка…
Ссылка в новой задаче