gecko/mobile/android/base/WebApp.java.in

97 lines
2.9 KiB
Java
Raw Normal View History

/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* 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/. */
#filter substitution
package @ANDROID_PACKAGE_NAME@;
import org.mozilla.gecko.GeckoApp;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.GeckoEvent;
import org.mozilla.gecko.R;
import android.view.MenuItem;
Bug 772684: Extending support for HDPI + ICS that don't have a tabs tail. [r=mfinkle] --HG-- rename : mobile/android/base/resources/drawable-hdpi/tabs_normal.png => mobile/android/base/resources/drawable-hdpi/tabs_crop_normal.png rename : mobile/android/base/resources/drawable-hdpi/tabs_pressed.png => mobile/android/base/resources/drawable-hdpi/tabs_crop_pressed.png rename : mobile/android/base/resources/drawable-land-hdpi-v14/tabs_normal.png => mobile/android/base/resources/drawable-land-hdpi-v14/tabs_crop_normal.png rename : mobile/android/base/resources/drawable-land-hdpi-v14/tabs_pressed.png => mobile/android/base/resources/drawable-land-hdpi-v14/tabs_crop_pressed.png rename : mobile/android/base/resources/drawable-land-mdpi-v14/tabs_normal.png => mobile/android/base/resources/drawable-land-mdpi-v14/tabs_crop_normal.png rename : mobile/android/base/resources/drawable-land-mdpi-v14/tabs_pressed.png => mobile/android/base/resources/drawable-land-mdpi-v14/tabs_crop_pressed.png rename : mobile/android/base/resources/drawable-land-xhdpi-v14/tabs_normal.png => mobile/android/base/resources/drawable-land-xhdpi-v14/tabs_full_normal.png rename : mobile/android/base/resources/drawable-land-xhdpi-v14/tabs_pressed.png => mobile/android/base/resources/drawable-land-xhdpi-v14/tabs_full_pressed.png rename : mobile/android/base/resources/drawable-large-hdpi/tabs_expanded_normal.png => mobile/android/base/resources/drawable-large-hdpi/tabs_crop_expanded_normal.png rename : mobile/android/base/resources/drawable-large-hdpi/tabs_expanded_pressed.png => mobile/android/base/resources/drawable-large-hdpi/tabs_crop_expanded_pressed.png rename : mobile/android/base/resources/drawable-large-hdpi/tabs_normal.png => mobile/android/base/resources/drawable-large-hdpi/tabs_crop_normal.png rename : mobile/android/base/resources/drawable-large-hdpi/tabs_pressed.png => mobile/android/base/resources/drawable-large-hdpi/tabs_crop_pressed.png rename : mobile/android/base/resources/drawable-large-mdpi/tabs_button.xml => mobile/android/base/resources/drawable-large-mdpi/tabs_crop_button.xml rename : mobile/android/base/resources/drawable-large-mdpi/tabs_expanded_normal.png => mobile/android/base/resources/drawable-large-mdpi/tabs_crop_expanded_normal.png rename : mobile/android/base/resources/drawable-large-mdpi/tabs_expanded_pressed.png => mobile/android/base/resources/drawable-large-mdpi/tabs_crop_expanded_pressed.png rename : mobile/android/base/resources/drawable-large-mdpi/tabs_normal.png => mobile/android/base/resources/drawable-large-mdpi/tabs_crop_normal.png rename : mobile/android/base/resources/drawable-large-mdpi/tabs_pressed.png => mobile/android/base/resources/drawable-large-mdpi/tabs_crop_pressed.png rename : mobile/android/base/resources/drawable-large-xhdpi/tabs_expanded_normal.png => mobile/android/base/resources/drawable-large-xhdpi/tabs_crop_expanded_normal.png rename : mobile/android/base/resources/drawable-large-xhdpi/tabs_expanded_pressed.png => mobile/android/base/resources/drawable-large-xhdpi/tabs_crop_expanded_pressed.png rename : mobile/android/base/resources/drawable-large-xhdpi/tabs_normal.png => mobile/android/base/resources/drawable-large-xhdpi/tabs_crop_normal.png rename : mobile/android/base/resources/drawable-large-xhdpi/tabs_pressed.png => mobile/android/base/resources/drawable-large-xhdpi/tabs_crop_pressed.png rename : mobile/android/base/resources/drawable-xhdpi-v14/menu.png => mobile/android/base/resources/drawable-xhdpi-v11/menu.png rename : mobile/android/base/resources/drawable-xhdpi-v11/tabs_normal.png => mobile/android/base/resources/drawable-xhdpi-v11/tabs_crop_normal.png rename : mobile/android/base/resources/drawable-xhdpi-v11/tabs_pressed.png => mobile/android/base/resources/drawable-xhdpi-v11/tabs_crop_pressed.png rename : mobile/android/base/resources/drawable-xhdpi-v14/tabs_normal.png => mobile/android/base/resources/drawable-xhdpi-v11/tabs_full_normal.png rename : mobile/android/base/resources/drawable-xhdpi-v14/tabs_pressed.png => mobile/android/base/resources/drawable-xhdpi-v11/tabs_full_pressed.png rename : mobile/android/base/resources/drawable/tabs_button.xml => mobile/android/base/resources/drawable/tabs_crop_button.xml rename : mobile/android/base/resources/drawable/tabs_button_contracted.xml => mobile/android/base/resources/drawable/tabs_crop_button_contracted.xml rename : mobile/android/base/resources/drawable-large-mdpi/tabs_button_expanded.xml => mobile/android/base/resources/drawable/tabs_crop_button_expanded.xml rename : mobile/android/base/resources/drawable/tabs_normal.png => mobile/android/base/resources/drawable/tabs_crop_normal.png rename : mobile/android/base/resources/drawable/tabs_pressed.png => mobile/android/base/resources/drawable/tabs_crop_pressed.png rename : mobile/android/base/resources/layout-land-v14/tabs_panel_toolbar.xml => mobile/android/base/resources/layout-land-v14/tabs_panel_toolbar_menu.xml rename : mobile/android/base/resources/layout-v14/browser_toolbar.xml => mobile/android/base/resources/layout/browser_toolbar_menu.xml rename : mobile/android/base/resources/layout-v14/tabs_panel_toolbar.xml => mobile/android/base/resources/layout/tabs_panel_toolbar_menu.xml
2012-07-12 15:03:09 -07:00
import android.view.View;
import android.util.Log;
import android.os.Bundle;
import android.content.Intent;
public class WebApp extends GeckoApp {
protected int mWebAppIndex;
private static final String LOGTAG = "WebApp";
@Override
public int getLayout() { return R.layout.web_app; }
Bug 772684: Extending support for HDPI + ICS that don't have a tabs tail. [r=mfinkle] --HG-- rename : mobile/android/base/resources/drawable-hdpi/tabs_normal.png => mobile/android/base/resources/drawable-hdpi/tabs_crop_normal.png rename : mobile/android/base/resources/drawable-hdpi/tabs_pressed.png => mobile/android/base/resources/drawable-hdpi/tabs_crop_pressed.png rename : mobile/android/base/resources/drawable-land-hdpi-v14/tabs_normal.png => mobile/android/base/resources/drawable-land-hdpi-v14/tabs_crop_normal.png rename : mobile/android/base/resources/drawable-land-hdpi-v14/tabs_pressed.png => mobile/android/base/resources/drawable-land-hdpi-v14/tabs_crop_pressed.png rename : mobile/android/base/resources/drawable-land-mdpi-v14/tabs_normal.png => mobile/android/base/resources/drawable-land-mdpi-v14/tabs_crop_normal.png rename : mobile/android/base/resources/drawable-land-mdpi-v14/tabs_pressed.png => mobile/android/base/resources/drawable-land-mdpi-v14/tabs_crop_pressed.png rename : mobile/android/base/resources/drawable-land-xhdpi-v14/tabs_normal.png => mobile/android/base/resources/drawable-land-xhdpi-v14/tabs_full_normal.png rename : mobile/android/base/resources/drawable-land-xhdpi-v14/tabs_pressed.png => mobile/android/base/resources/drawable-land-xhdpi-v14/tabs_full_pressed.png rename : mobile/android/base/resources/drawable-large-hdpi/tabs_expanded_normal.png => mobile/android/base/resources/drawable-large-hdpi/tabs_crop_expanded_normal.png rename : mobile/android/base/resources/drawable-large-hdpi/tabs_expanded_pressed.png => mobile/android/base/resources/drawable-large-hdpi/tabs_crop_expanded_pressed.png rename : mobile/android/base/resources/drawable-large-hdpi/tabs_normal.png => mobile/android/base/resources/drawable-large-hdpi/tabs_crop_normal.png rename : mobile/android/base/resources/drawable-large-hdpi/tabs_pressed.png => mobile/android/base/resources/drawable-large-hdpi/tabs_crop_pressed.png rename : mobile/android/base/resources/drawable-large-mdpi/tabs_button.xml => mobile/android/base/resources/drawable-large-mdpi/tabs_crop_button.xml rename : mobile/android/base/resources/drawable-large-mdpi/tabs_expanded_normal.png => mobile/android/base/resources/drawable-large-mdpi/tabs_crop_expanded_normal.png rename : mobile/android/base/resources/drawable-large-mdpi/tabs_expanded_pressed.png => mobile/android/base/resources/drawable-large-mdpi/tabs_crop_expanded_pressed.png rename : mobile/android/base/resources/drawable-large-mdpi/tabs_normal.png => mobile/android/base/resources/drawable-large-mdpi/tabs_crop_normal.png rename : mobile/android/base/resources/drawable-large-mdpi/tabs_pressed.png => mobile/android/base/resources/drawable-large-mdpi/tabs_crop_pressed.png rename : mobile/android/base/resources/drawable-large-xhdpi/tabs_expanded_normal.png => mobile/android/base/resources/drawable-large-xhdpi/tabs_crop_expanded_normal.png rename : mobile/android/base/resources/drawable-large-xhdpi/tabs_expanded_pressed.png => mobile/android/base/resources/drawable-large-xhdpi/tabs_crop_expanded_pressed.png rename : mobile/android/base/resources/drawable-large-xhdpi/tabs_normal.png => mobile/android/base/resources/drawable-large-xhdpi/tabs_crop_normal.png rename : mobile/android/base/resources/drawable-large-xhdpi/tabs_pressed.png => mobile/android/base/resources/drawable-large-xhdpi/tabs_crop_pressed.png rename : mobile/android/base/resources/drawable-xhdpi-v14/menu.png => mobile/android/base/resources/drawable-xhdpi-v11/menu.png rename : mobile/android/base/resources/drawable-xhdpi-v11/tabs_normal.png => mobile/android/base/resources/drawable-xhdpi-v11/tabs_crop_normal.png rename : mobile/android/base/resources/drawable-xhdpi-v11/tabs_pressed.png => mobile/android/base/resources/drawable-xhdpi-v11/tabs_crop_pressed.png rename : mobile/android/base/resources/drawable-xhdpi-v14/tabs_normal.png => mobile/android/base/resources/drawable-xhdpi-v11/tabs_full_normal.png rename : mobile/android/base/resources/drawable-xhdpi-v14/tabs_pressed.png => mobile/android/base/resources/drawable-xhdpi-v11/tabs_full_pressed.png rename : mobile/android/base/resources/drawable/tabs_button.xml => mobile/android/base/resources/drawable/tabs_crop_button.xml rename : mobile/android/base/resources/drawable/tabs_button_contracted.xml => mobile/android/base/resources/drawable/tabs_crop_button_contracted.xml rename : mobile/android/base/resources/drawable-large-mdpi/tabs_button_expanded.xml => mobile/android/base/resources/drawable/tabs_crop_button_expanded.xml rename : mobile/android/base/resources/drawable/tabs_normal.png => mobile/android/base/resources/drawable/tabs_crop_normal.png rename : mobile/android/base/resources/drawable/tabs_pressed.png => mobile/android/base/resources/drawable/tabs_crop_pressed.png rename : mobile/android/base/resources/layout-land-v14/tabs_panel_toolbar.xml => mobile/android/base/resources/layout-land-v14/tabs_panel_toolbar_menu.xml rename : mobile/android/base/resources/layout-v14/browser_toolbar.xml => mobile/android/base/resources/layout/browser_toolbar_menu.xml rename : mobile/android/base/resources/layout-v14/tabs_panel_toolbar.xml => mobile/android/base/resources/layout/tabs_panel_toolbar_menu.xml
2012-07-12 15:03:09 -07:00
@Override
public boolean isBrowserToolbarSupported() { return false; }
@Override
public View getBrowserToolbar() { return null; }
@Override
public void onCreate(Bundle savedInstanceState)
{
Log.i("DEBUG", "xxx WebApp");
super.onCreate(savedInstanceState);
Bundle extras = getIntent().getExtras();
String title = extras != null ? extras.getString(Intent.EXTRA_SHORTCUT_NAME) : null;
setTitle(title != null ? title : "Web App");
}
public String getPackageName() {
return "@ANDROID_PACKAGE_NAME@";
}
public String getContentProcessName() {
return "@MOZ_CHILD_PROCESS_NAME@";
}
public String getDefaultUAString() {
String deviceType = "Mobile";
if (GeckoAppShell.isTablet())
deviceType = "Tablet";
return "Mozilla/5.0 (Android; " + deviceType + "; rv:@MOZ_APP_VERSION@) Gecko/@MOZ_APP_VERSION@ Firefox/@MOZ_APP_VERSION@";
}
public String getUAStringForHost(String host) {
// With our standard UA String, we get a 200 response code and
// client-side redirect from t.co. This bot-like UA gives us a
// 301 response code
if ("t.co".equals(host))
return "Redirector/@MOZ_APP_VERSION@ (Android; rv:@MOZ_APP_VERSION@)";
return getDefaultUAString();
}
@Override
protected String getDefaultProfileName() {
String action = getIntent().getAction();
if (!action.startsWith(ACTION_WEBAPP_PREFIX)) {
Log.e(LOGTAG, "WebApp launch, but intent action is " + action + "!");
return null;
}
return "webapp" + action.substring(ACTION_WEBAPP_PREFIX.length());
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
#ifdef MOZ_PROFILING
if (item.getItemId() == R.id.toggle_profiling) {
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("ToggleProfiling", null));
return true;
}
#endif
return super.onOptionsItemSelected(item);
}
#ifdef MOZ_LINKER_EXTRACT
@Override
public boolean linkerExtract() {
return true;
}
#endif
};