2012-03-23 23:00:17 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
package org.mozilla.gecko;
|
|
|
|
|
2012-07-28 04:53:54 +04:00
|
|
|
import org.mozilla.gecko.gfx.LayerView;
|
|
|
|
|
2012-03-23 23:00:17 +04:00
|
|
|
import android.content.Context;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
|
2012-07-18 04:54:54 +04:00
|
|
|
public final class GeckoViewsFactory implements LayoutInflater.Factory {
|
2012-03-23 23:00:17 +04:00
|
|
|
private static final String LOGTAG = "GeckoViewsFactory";
|
|
|
|
|
|
|
|
private static final String GECKO_VIEW_IDENTIFIER = "org.mozilla.gecko.";
|
|
|
|
private static final int GECKO_VIEW_IDENTIFIER_LENGTH = GECKO_VIEW_IDENTIFIER.length();
|
|
|
|
|
|
|
|
private GeckoViewsFactory() { }
|
|
|
|
|
|
|
|
// Making this a singleton class.
|
|
|
|
private static final GeckoViewsFactory INSTANCE = new GeckoViewsFactory();
|
|
|
|
|
|
|
|
public static GeckoViewsFactory getInstance() {
|
|
|
|
return INSTANCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public View onCreateView(String name, Context context, AttributeSet attrs) {
|
|
|
|
if (!TextUtils.isEmpty(name) && name.startsWith(GECKO_VIEW_IDENTIFIER)) {
|
|
|
|
String viewName = name.substring(GECKO_VIEW_IDENTIFIER_LENGTH);
|
|
|
|
|
|
|
|
if (TextUtils.isEmpty(viewName))
|
|
|
|
return null;
|
|
|
|
|
|
|
|
Log.i(LOGTAG, "Creating custom Gecko view: " + viewName);
|
|
|
|
|
2012-08-20 08:10:00 +04:00
|
|
|
if (TextUtils.equals(viewName, "AboutHomePromoBox"))
|
|
|
|
return new AboutHomePromoBox(context, attrs);
|
2012-09-26 16:24:34 +04:00
|
|
|
else if (TextUtils.equals(viewName, "AboutHomeContent"))
|
|
|
|
return new AboutHomeContent(context, attrs);
|
|
|
|
else if (TextUtils.equals(viewName, "AboutHomeContent$TopSitesGridView"))
|
|
|
|
return new AboutHomeContent.TopSitesGridView(context, attrs);
|
2012-08-20 08:10:00 +04:00
|
|
|
else if (TextUtils.equals(viewName, "AboutHomeSection"))
|
2012-03-23 23:00:17 +04:00
|
|
|
return new AboutHomeSection(context, attrs);
|
|
|
|
else if (TextUtils.equals(viewName, "AwesomeBarTabs"))
|
|
|
|
return new AwesomeBarTabs(context, attrs);
|
2012-08-31 22:59:50 +04:00
|
|
|
else if (TextUtils.equals(viewName, "BrowserToolbarBackground"))
|
|
|
|
return new BrowserToolbarBackground(context, attrs);
|
2012-03-23 23:00:17 +04:00
|
|
|
else if (TextUtils.equals(viewName, "FormAssistPopup"))
|
|
|
|
return new FormAssistPopup(context, attrs);
|
2012-10-13 03:23:20 +04:00
|
|
|
else if (TextUtils.equals(viewName, "GeckoApp$MainLayout"))
|
|
|
|
return new GeckoApp.MainLayout(context, attrs);
|
2012-03-23 23:00:17 +04:00
|
|
|
else if (TextUtils.equals(viewName, "LinkTextView"))
|
|
|
|
return new LinkTextView(context, attrs);
|
2012-05-31 00:26:13 +04:00
|
|
|
else if (TextUtils.equals(viewName, "FindInPageBar"))
|
|
|
|
return new FindInPageBar(context, attrs);
|
2012-08-31 23:03:25 +04:00
|
|
|
else if (TextUtils.equals(viewName, "MenuButton"))
|
|
|
|
return new MenuButton(context, attrs);
|
2012-08-31 23:00:24 +04:00
|
|
|
else if (TextUtils.equals(viewName, "TabsButton"))
|
|
|
|
return new TabsButton(context, attrs);
|
2012-06-11 03:44:50 +04:00
|
|
|
else if (TextUtils.equals(viewName, "TabsPanel"))
|
|
|
|
return new TabsPanel(context, attrs);
|
2012-08-31 23:04:02 +04:00
|
|
|
else if (TextUtils.equals(viewName, "TabsPanelButton"))
|
|
|
|
return new TabsPanelButton(context, attrs);
|
2012-07-20 00:16:44 +04:00
|
|
|
else if (TextUtils.equals(viewName, "TextSelectionHandle"))
|
|
|
|
return new TextSelectionHandle(context, attrs);
|
2012-07-28 18:33:51 +04:00
|
|
|
else if (TextUtils.equals(viewName, "gfx.LayerView"))
|
|
|
|
return new LayerView(context, attrs);
|
|
|
|
else
|
2012-09-26 16:24:34 +04:00
|
|
|
Log.d(LOGTAG, "Warning: unknown custom view: " + viewName);
|
2012-03-23 23:00:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|