public TiUIActionBarTabGroup(TabGroupProxy proxy, TiBaseActivity activity) { super(proxy, activity); tabActivity = new WeakReference<TiBaseActivity>(activity); activity.addOnLifecycleEventListener(this); // Setup the action bar for navigation tabs. actionBar = activity.getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowTitleEnabled(true); swipeable = TiConvert.toBoolean(proxy.getProperty(TiC.PROPERTY_SWIPEABLE), true); tabGroupPagerAdapter = new TabGroupPagerAdapter(((ActionBarActivity) activity).getSupportFragmentManager()); tabGroupViewPager = (new ViewPager(proxy.getActivity()) { @Override public boolean onTouchEvent(MotionEvent event) { return swipeable ? super.onTouchEvent(event) : false; } @Override public boolean onInterceptTouchEvent(MotionEvent event) { return swipeable ? super.onInterceptTouchEvent(event) : false; } }); tabGroupViewPager.setAdapter(tabGroupPagerAdapter); tabGroupViewPager.setOnPageChangeListener( new ViewPager.OnPageChangeListener() { @Override public void onPageSelected(int position) { // on changing the page simply select the tab actionBar.setSelectedNavigationItem(position); } @Override public void onPageScrolled(int arg0, float arg1, int arg2) {} @Override public void onPageScrollStateChanged(int arg0) {} }); TiCompositeLayout.LayoutParams params = new TiCompositeLayout.LayoutParams(); params.autoFillsHeight = true; params.autoFillsWidth = true; ((ViewGroup) activity.getLayout()).addView(tabGroupViewPager, params); setNativeView(tabGroupViewPager); }
private TiCompositeLayout.LayoutParams buildFillLayoutParams() { TiCompositeLayout.LayoutParams params = new TiCompositeLayout.LayoutParams(); params.autoFillsHeight = true; params.autoFillsWidth = true; return params; }
public TiUIWebView(TiViewProxy proxy) { super(proxy); this.isFocusable = true; TiWebView webView = isHTCSenseDevice() ? new TiWebView(proxy.getActivity()) : new NonHTCWebView(proxy.getActivity()); webView.setVerticalScrollbarOverlay(true); WebSettings settings = webView.getSettings(); settings.setUseWideViewPort(true); settings.setJavaScriptEnabled(true); settings.setSupportMultipleWindows(true); settings.setJavaScriptCanOpenWindowsAutomatically(true); settings.setAllowFileAccess(true); settings.setDomStorageEnabled( true); // Required by some sites such as Twitter. This is in our iOS WebView too. File path = TiApplication.getInstance().getFilesDir(); if (path != null) { settings.setDatabasePath(path.getAbsolutePath()); settings.setDatabaseEnabled(true); } File cacheDir = TiApplication.getInstance().getCacheDir(); if (cacheDir != null) { settings.setAppCacheEnabled(true); settings.setAppCachePath(cacheDir.getAbsolutePath()); } // enable zoom controls by default boolean enableZoom = true; if (proxy.hasProperty(TiC.PROPERTY_ENABLE_ZOOM_CONTROLS)) { enableZoom = TiConvert.toBoolean(proxy.getProperty(TiC.PROPERTY_ENABLE_ZOOM_CONTROLS)); } settings.setBuiltInZoomControls(enableZoom); settings.setSupportZoom(enableZoom); if (TiC.JELLY_BEAN_OR_GREATER) { settings.setAllowUniversalAccessFromFileURLs( true); // default is "false" for JellyBean, TIMOB-13065 } // We can only support webview settings for plugin/flash in API 8 and higher. if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ECLAIR_MR1) { initializePluginAPI(webView); } boolean enableJavascriptInterface = TiConvert.toBoolean(proxy.getProperty(TiC.PROPERTY_ENABLE_JAVASCRIPT_INTERFACE), true); chromeClient = new TiWebChromeClient(this); webView.setWebChromeClient(chromeClient); client = new TiWebViewClient(this, webView); webView.setWebViewClient(client); if (Build.VERSION.SDK_INT > 16 || enableJavascriptInterface) { client.getBinding().addJavascriptInterfaces(); } webView.client = client; if (proxy instanceof WebViewProxy) { WebViewProxy webProxy = (WebViewProxy) proxy; String username = webProxy.getBasicAuthenticationUserName(); String password = webProxy.getBasicAuthenticationPassword(); if (username != null && password != null) { setBasicAuthentication(username, password); } webProxy.clearBasicAuthentication(); } TiCompositeLayout.LayoutParams params = getLayoutParams(); params.autoFillsHeight = true; params.autoFillsWidth = true; setNativeView(webView); }