зеркало из https://github.com/mozilla/gecko-dev.git
Bug 806937: Shadowed android ui for gecko to support "state_private". [r=mfinkle]
This commit is contained in:
Родитель
47ffbd611d
Коммит
8ba601b57f
|
@ -0,0 +1,36 @@
|
|||
/* 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;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.@VIEWTYPE@;
|
||||
|
||||
public class Gecko@VIEWTYPE@ extends @VIEWTYPE@ {
|
||||
private static final int[] STATE_PRIVATE_MODE = { R.attr.state_private };
|
||||
|
||||
private boolean mIsPrivate = false;
|
||||
|
||||
public Gecko@VIEWTYPE@(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] onCreateDrawableState(int extraSpace) {
|
||||
final int[] drawableState = super.onCreateDrawableState(extraSpace + 1);
|
||||
|
||||
if (mIsPrivate)
|
||||
mergeDrawableStates(drawableState, STATE_PRIVATE_MODE);
|
||||
|
||||
return drawableState;
|
||||
}
|
||||
|
||||
public void setPrivateMode(boolean isPrivate) {
|
||||
if (mIsPrivate != isPrivate) {
|
||||
mIsPrivate = isPrivate;
|
||||
refreshDrawableState();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,6 +19,9 @@ public final class GeckoViewsFactory implements LayoutInflater.Factory {
|
|||
private static final String GECKO_VIEW_IDENTIFIER = "org.mozilla.gecko.";
|
||||
private static final int GECKO_VIEW_IDENTIFIER_LENGTH = GECKO_VIEW_IDENTIFIER.length();
|
||||
|
||||
private static final String GECKO_IDENTIFIER = "Gecko.";
|
||||
private static final int GECKO_IDENTIFIER_LENGTH = GECKO_IDENTIFIER.length();
|
||||
|
||||
private GeckoViewsFactory() { }
|
||||
|
||||
// Making this a singleton class.
|
||||
|
@ -30,8 +33,15 @@ public final class GeckoViewsFactory implements LayoutInflater.Factory {
|
|||
|
||||
@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(name)) {
|
||||
String viewName = null;
|
||||
|
||||
if (name.startsWith(GECKO_VIEW_IDENTIFIER))
|
||||
viewName = name.substring(GECKO_VIEW_IDENTIFIER_LENGTH);
|
||||
else if (name.startsWith(GECKO_IDENTIFIER))
|
||||
viewName = name.substring(GECKO_IDENTIFIER_LENGTH);
|
||||
else
|
||||
return null;
|
||||
|
||||
if (TextUtils.isEmpty(viewName))
|
||||
return null;
|
||||
|
@ -74,6 +84,18 @@ public final class GeckoViewsFactory implements LayoutInflater.Factory {
|
|||
return new TextSelectionHandle(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "gfx.LayerView"))
|
||||
return new LayerView(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "Button"))
|
||||
return new GeckoButton(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "FrameLayout"))
|
||||
return new GeckoFrameLayout(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "ImageButton"))
|
||||
return new GeckoImageButton(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "ImageView"))
|
||||
return new GeckoImageView(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "LinearLayout"))
|
||||
return new GeckoLinearLayout(context, attrs);
|
||||
else if (TextUtils.equals(viewName, "TextView"))
|
||||
return new GeckoTextView(context, attrs);
|
||||
else
|
||||
Log.d(LOGTAG, "Warning: unknown custom view: " + viewName);
|
||||
}
|
||||
|
|
|
@ -189,6 +189,15 @@ ifdef MOZ_WEBSMS_BACKEND
|
|||
FENNEC_JAVA_FILES += GeckoSmsManager.java
|
||||
endif
|
||||
|
||||
FENNEC_PP_JAVA_VIEW_FILES = \
|
||||
GeckoButton.java \
|
||||
GeckoImageButton.java \
|
||||
GeckoImageView.java \
|
||||
GeckoFrameLayout.java \
|
||||
GeckoLinearLayout.java \
|
||||
GeckoTextView.java \
|
||||
$(NULL)
|
||||
|
||||
FENNEC_PP_JAVA_FILES = \
|
||||
App.java \
|
||||
MarketplaceApp.java \
|
||||
|
@ -286,6 +295,7 @@ GARBAGE += \
|
|||
AndroidManifest.xml \
|
||||
classes.dex \
|
||||
$(FENNEC_PP_JAVA_FILES) \
|
||||
$(FENNEC_PP_JAVA_VIEW_FILES) \
|
||||
$(SYNC_PP_JAVA_FILES) \
|
||||
gecko.ap_ \
|
||||
res/values/strings.xml \
|
||||
|
@ -1061,10 +1071,10 @@ classes.dex: jars/gecko-browser.jar
|
|||
@echo "DX classes.dex"
|
||||
$(DX) --dex --output=classes.dex jars $(ANDROID_COMPAT_LIB)
|
||||
|
||||
jars/gecko-browser.jar: jars/gecko-mozglue.jar jars/gecko-util.jar jars/sync-thirdparty.jar $(addprefix $(srcdir)/,$(FENNEC_JAVA_FILES)) $(FENNEC_PP_JAVA_FILES) $(addprefix $(srcdir)/,$(SYNC_JAVA_FILES)) $(SYNC_PP_JAVA_FILES) R.java
|
||||
jars/gecko-browser.jar: jars/gecko-mozglue.jar jars/gecko-util.jar jars/sync-thirdparty.jar $(addprefix $(srcdir)/,$(FENNEC_JAVA_FILES)) $(FENNEC_PP_JAVA_FILES) $(FENNEC_PP_JAVA_VIEW_FILES) $(addprefix $(srcdir)/,$(SYNC_JAVA_FILES)) $(SYNC_PP_JAVA_FILES) R.java
|
||||
@echo "JAR gecko-browser.jar"
|
||||
$(NSINSTALL) -D classes/gecko-browser
|
||||
$(JAVAC) $(JAVAC_FLAGS) -Xlint:all,-deprecation,-fallthrough -d classes/gecko-browser -classpath "jars/gecko-mozglue.jar:jars/gecko-util.jar:jars/sync-thirdparty.jar" $(addprefix $(srcdir)/,$(FENNEC_JAVA_FILES)) $(FENNEC_PP_JAVA_FILES) $(addprefix $(srcdir)/,$(SYNC_JAVA_FILES)) $(SYNC_PP_JAVA_FILES) R.java
|
||||
$(JAVAC) $(JAVAC_FLAGS) -Xlint:all,-deprecation,-fallthrough -d classes/gecko-browser -classpath "jars/gecko-mozglue.jar:jars/gecko-util.jar:jars/sync-thirdparty.jar" $(addprefix $(srcdir)/,$(FENNEC_JAVA_FILES)) $(FENNEC_PP_JAVA_FILES) $(FENNEC_PP_JAVA_VIEW_FILES) $(addprefix $(srcdir)/,$(SYNC_JAVA_FILES)) $(SYNC_PP_JAVA_FILES) R.java
|
||||
$(JAR) cMf jars/gecko-browser.jar -C classes/gecko-browser .
|
||||
|
||||
jars/gecko-mozglue.jar: $(addprefix $(srcdir)/,$(MOZGLUE_JAVA_FILES)) jars
|
||||
|
@ -1137,6 +1147,11 @@ WebAppsFragments.java: WebAppsFragment.java.frag
|
|||
cat $< | sed s,@APPNUM@,$$n,g >> $@ ; \
|
||||
done
|
||||
|
||||
# Replace @VIEWTYPE@ with different View names.
|
||||
$(FENNEC_PP_JAVA_VIEW_FILES): GeckoView.java.frag
|
||||
@rm -f $@
|
||||
cat $< | sed s,@VIEWTYPE@,$(patsubst Gecko%.java,%,$@),g >> $@ ; \
|
||||
|
||||
res/drawable/icon.png: $(MOZ_APP_ICON)
|
||||
$(NSINSTALL) -D res/drawable
|
||||
cp $(ICON_PATH) $@
|
||||
|
|
|
@ -57,5 +57,9 @@
|
|||
</attr>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="PrivateBrowsing">
|
||||
<attr name="state_private" format="boolean"/>
|
||||
</declare-styleable>
|
||||
|
||||
</resources>
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче