コード例 #1
0
  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);
  }
コード例 #2
0
 protected void refreshOldStyleRow() {
   TableViewRowProxy rp = getRowProxy();
   if (!rp.hasProperty(TiC.PROPERTY_TOUCH_ENABLED)) {
     rp.setProperty(TiC.PROPERTY_TOUCH_ENABLED, false);
   }
   if (views == null) {
     views = new ArrayList<TiUIView>();
     views.add(new TiUILabel(rp));
   }
   TiUILabel t = (TiUILabel) views.get(0);
   t.setProxy(rp);
   t.processProperties(filterProperties(rp.getProperties()));
   View v = t.getNativeView();
   if (v.getParent() == null) {
     TiCompositeLayout.LayoutParams params = (TiCompositeLayout.LayoutParams) t.getLayoutParams();
     params.optionLeft = new TiDimension(5, TiDimension.TYPE_LEFT);
     params.optionRight = new TiDimension(5, TiDimension.TYPE_RIGHT);
     params.autoFillsWidth = true;
     content.addView(v, params);
   }
 }
コード例 #3
0
 private TiCompositeLayout.LayoutParams buildFillLayoutParams() {
   TiCompositeLayout.LayoutParams params = new TiCompositeLayout.LayoutParams();
   params.autoFillsHeight = true;
   params.autoFillsWidth = true;
   return params;
 }
コード例 #4
0
  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);
  }