mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 771915 - Show origin of the page if it differs from the webapps. r=mfinkle
This commit is contained in:
parent
a3f33aa6b6
commit
0975a9df28
@ -1006,6 +1006,7 @@ MOZ_ANDROID_DRAWABLES += \
|
||||
mobile/android/base/resources/drawable/tabs_shadow.xml \
|
||||
mobile/android/base/resources/drawable/shadow.png \
|
||||
mobile/android/base/resources/drawable/marketplace.png \
|
||||
mobile/android/base/resources/drawable/webapp_titlebar_bg.xml \
|
||||
$(NULL)
|
||||
|
||||
MOZ_ANDROID_DRAWABLES += $(shell if test -e $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/android-resources.mn; then cat $(topsrcdir)/$(MOZ_BRANDING_DIRECTORY)/android-resources.mn | tr '\n' ' '; fi)
|
||||
|
@ -25,7 +25,6 @@ import org.mozilla.gecko.WebAppAllocator;
|
||||
* and then launch it
|
||||
*/
|
||||
public class MarketplaceApp extends WebApp {
|
||||
protected int mWebAppIndex;
|
||||
private static final String LOGTAG = "GeckoMarketplaceApp";
|
||||
public static final String MARKETPLACE_HOST = "marketplace.mozilla.org";
|
||||
public static final String MARKETPLACE_URI = "https://marketplace.mozilla.org";
|
||||
|
@ -9,16 +9,30 @@ package @ANDROID_PACKAGE_NAME@;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.content.Context;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import org.mozilla.gecko.GeckoApp;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
import org.mozilla.gecko.WebAppAllocator;
|
||||
import org.mozilla.gecko.Tab;
|
||||
import org.mozilla.gecko.Tabs;
|
||||
import org.mozilla.gecko.R;
|
||||
|
||||
public class WebApp extends GeckoApp {
|
||||
protected int mWebAppIndex;
|
||||
private URL mOrigin;
|
||||
private TextView mTitlebarText = null;
|
||||
private View mTitlebar = null;
|
||||
private static final String LOGTAG = "WebApp";
|
||||
|
||||
protected int getIndex() { return 0; }
|
||||
|
||||
@Override
|
||||
public int getLayout() { return R.layout.web_app; }
|
||||
|
||||
@ -28,12 +42,33 @@ public class WebApp extends GeckoApp {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
Log.i("DEBUG", "xxx WebApp");
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
String action = getIntent().getAction();
|
||||
Bundle extras = getIntent().getExtras();
|
||||
String title = extras != null ? extras.getString(Intent.EXTRA_SHORTCUT_NAME) : null;
|
||||
setTitle(title != null ? title : "Web App");
|
||||
|
||||
mTitlebarText = (TextView)findViewById(R.id.webapp_title);
|
||||
mTitlebar = findViewById(R.id.webapp_titlebar);
|
||||
if (!action.startsWith(ACTION_WEBAPP_PREFIX)) {
|
||||
Log.e(LOGTAG, "WebApp launch, but intent action is " + action + "!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Try to use the origin stored in the WebAppAllocator first
|
||||
String origin = WebAppAllocator.getInstance(this).getAppForIndex(getIndex());
|
||||
try {
|
||||
mOrigin = new URL(origin);
|
||||
} catch (java.net.MalformedURLException ex) {
|
||||
// If that failed fall back to the origin stored in the shortcut
|
||||
Log.i(LOGTAG, "Webapp is not registered with allocator");
|
||||
try {
|
||||
mOrigin = new URL(getIntent().getData().toString());
|
||||
} catch (java.net.MalformedURLException ex2) {
|
||||
Log.e(LOGTAG, "Unable to parse intent url: ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getPackageName() {
|
||||
@ -88,5 +123,27 @@ public class WebApp extends GeckoApp {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@Override
|
||||
public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) {
|
||||
switch(msg) {
|
||||
case LOCATION_CHANGE:
|
||||
if (Tabs.getInstance().isSelectedTab(tab)) {
|
||||
try {
|
||||
String title = tab.getURL();
|
||||
URL page = new URL(title);
|
||||
mTitlebarText.setText(page.getProtocol() + "://" + page.getHost());
|
||||
|
||||
if (mOrigin != null && mOrigin.getHost().equals(page.getHost()))
|
||||
mTitlebar.setVisibility(View.GONE);
|
||||
else
|
||||
mTitlebar.setVisibility(View.VISIBLE);
|
||||
} catch (java.net.MalformedURLException ex) {
|
||||
Log.e(LOGTAG, "Unable to parse url: ", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.onTabChanged(tab, msg, data);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,2 +1,5 @@
|
||||
public static class WebApp@APPNUM@ extends WebApp { }
|
||||
public static class WebApp@APPNUM@ extends WebApp {
|
||||
@Override
|
||||
protected int getIndex() { return @APPNUM@; }
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- 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/. -->
|
||||
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item>
|
||||
<shape android:shape="rectangle">
|
||||
<gradient android:angle="270"
|
||||
android:startColor="#E0E6EB"
|
||||
android:centerColor="#CAD3DD"
|
||||
android:endColor="#BDC5CE"
|
||||
android:type="linear"/>
|
||||
</shape>
|
||||
</item>
|
||||
</layer-list>
|
@ -1,8 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/main_layout"
|
||||
android:orientation="vertical"
|
||||
style="@style/Screen">
|
||||
|
||||
<LinearLayout android:id="@+id/webapp_titlebar"
|
||||
android:visibility="gone"
|
||||
style="@style/WebView.Titlebar"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView android:id="@+id/webapp_title"
|
||||
style="@style/WebView.Titlebar.Title"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout android:id="@+id/gecko_layout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
@ -10,6 +26,6 @@
|
||||
|
||||
<include layout="@layout/shared_ui_components"/>
|
||||
|
||||
</RelativeLayout>
|
||||
</RelativeLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -154,4 +154,15 @@
|
||||
<item name="android:background">@android:color/transparent</item>
|
||||
</style>
|
||||
|
||||
<style name="WebView">
|
||||
</style>
|
||||
|
||||
<style name="WebView.Titlebar">
|
||||
<item name="android:background">@drawable/webapp_titlebar_bg</item>
|
||||
<item name="android:padding">2dp</item>
|
||||
</style>
|
||||
|
||||
<style name="WebView.Titlebar.Title">
|
||||
<item name="android:textColor">#ff222222</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user