Example usage for android.os Bundle getBoolean

List of usage examples for android.os Bundle getBoolean

Introduction

In this page you can find the example usage for android.os Bundle getBoolean.

Prototype

public boolean getBoolean(String key, boolean defaultValue) 

Source Link

Document

Returns the value associated with the given key, or defaultValue if no mapping of the desired type exists for the given key.

Usage

From source file:com.example.snapcacheexample.SelectionFragment.java

/**
 * Resets the view to the initial defaults.
 *//*  w w  w.jav a2  s  .  com*/
private void init(Bundle savedInstanceState) {
    announceButton.setEnabled(false);

    listElements = new ArrayList<BaseListElement>();

    listElements.add(new EatListElement(0));
    listElements.add(new LocationListElement(1));
    listElements.add(new PeopleListElement(2));

    if (savedInstanceState != null) {
        for (BaseListElement listElement : listElements) {
            listElement.restoreState(savedInstanceState);
        }
        pendingAnnounce = savedInstanceState.getBoolean(PENDING_ANNOUNCE_KEY, false);
    }

    listView.setAdapter(new ActionListAdapter(getActivity(), R.id.selection_list, listElements));

    Session session = Session.getActiveSession();
    if (session != null && session.isOpened()) {
        makeMeRequest(session);
    }
}

From source file:cn.ucai.foraging.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null && savedInstanceState.getBoolean(Constant.ACCOUNT_REMOVED, false)) {
        // ??home???appcrash
        // fragment??
        DemoHXSDKHelper.getInstance().logout(true, null);
        finish();/*w  w  w. jav a 2  s  . c o m*/
        startActivity(new Intent(this, LoginActivity.class));
        return;
    } else if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) {
        // T??home???appcrash
        // fragment??
        finish();
        startActivity(new Intent(this, LoginActivity.class));
        return;
    }
    setContentView(cn.ucai.foraging.R.layout.activity_main);
    initView();

    // MobclickAgent.setDebugMode( true );
    // --?--
    MobclickAgent.updateOnlineConfig(this);

    if (getIntent().getBooleanExtra("conflict", false) && !isConflictDialogShow) {
        showConflictDialog();
    } else if (getIntent().getBooleanExtra(Constant.ACCOUNT_REMOVED, false) && !isAccountRemovedDialogShow) {
        showAccountRemovedDialog();
    }

    inviteMessgeDao = new InviteMessgeDao(this);
    userDao = new UserDao(this);
    // fragment???
    // chatHistoryFragment = new ChatHistoryFragment();
    // ?fragment
    chatHistoryFragment = new ChatAllHistoryFragment();
    contactListFragment = new ContactlistFragment();
    settingFragment = new SettingsFragment();
    mEatFragment = new EatFragment();
    fragments = new Fragment[] { mEatFragment, contactListFragment, settingFragment };
    // fragment
    getSupportFragmentManager().beginTransaction()
            .add(cn.ucai.foraging.R.id.fragment_container, settingFragment)
            .add(cn.ucai.foraging.R.id.fragment_container, chatHistoryFragment)
            .add(cn.ucai.foraging.R.id.fragment_container, mEatFragment).hide(mEatFragment).show(mEatFragment)
            .commit();

    init();
    //???
    ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getUserProfileManager().asyncGetCurrentUserInfo();
}

From source file:net.reichholf.dreamdroid.activities.ServiceListActivity.java

@SuppressWarnings("unchecked")
@Override/*from ww w.  ja v  a2  s.c  om*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String mode = getIntent().getAction();
    if (mode.equals(Intent.ACTION_PICK)) {
        mPickMode = true;
    } else {
        mPickMode = false;
    }

    String ref = DreamDroid.SP.getString(DreamDroid.PREFS_KEY_DEFAULT_BOUQUET_REF, "default");
    String name = DreamDroid.SP.getString(DreamDroid.PREFS_KEY_DEFAULT_BOUQUET_NAME,
            (String) getText(R.string.bouquet_overview));

    mReference = getDataForKey(Event.SERVICE_REFERENCE, ref);
    mName = getDataForKey(Event.SERVICE_NAME, name);

    if (savedInstanceState != null) {
        mIsBouquetList = savedInstanceState.getBoolean("isBouquetList", true);
        mHistory = (ArrayList<ExtendedHashMap>) savedInstanceState.getSerializable("history");

    } else {
        mIsBouquetList = DreamDroid.SP.getBoolean(DreamDroid.PREFS_KEY_DEFAULT_BOUQUET_IS_LIST, true);
        mHistory = new ArrayList<ExtendedHashMap>();

        ExtendedHashMap map = new ExtendedHashMap();
        map.put(Event.SERVICE_REFERENCE, mReference);
        map.put(Event.SERVICE_NAME, mName);

        mHistory.add(map);
    }

    setAdapter();
    reload();
}

From source file:cn.hbm.superwechat.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null && savedInstanceState.getBoolean(Constant.ACCOUNT_REMOVED, false)) {
        // ??home???appcrash
        // fragment??
        DemoHXSDKHelper.getInstance().logout(true, null);
        finish();//w  w  w .  j  a va 2s .  c  o m
        startActivity(new Intent(this, LoginActivity.class));
        return;
    } else if (savedInstanceState != null && savedInstanceState.getBoolean("isConflict", false)) {
        // T??home???appcrash
        // fragment??
        finish();
        startActivity(new Intent(this, LoginActivity.class));
        return;
    }
    setContentView(R.layout.activity_main);
    initView();

    // MobclickAgent.setDebugMode( true );
    // --?--
    MobclickAgent.updateOnlineConfig(this);

    if (getIntent().getBooleanExtra("conflict", false) && !isConflictDialogShow) {
        showConflictDialog();
    } else if (getIntent().getBooleanExtra(Constant.ACCOUNT_REMOVED, false) && !isAccountRemovedDialogShow) {
        showAccountRemovedDialog();
    }

    inviteMessgeDao = new InviteMessgeDao(this);
    userDao = new UserDao(this);
    // fragment???
    // chatHistoryFragment = new ChatHistoryFragment();
    // ?fragment
    chatHistoryFragment = new ChatAllHistoryFragment();
    contactListFragment = new ContactlistFragment();
    settingFragment = new SettingsFragment();
    fragments = new Fragment[] { chatHistoryFragment, contactListFragment, settingFragment };
    // fragment
    getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, chatHistoryFragment)
            .add(R.id.fragment_container, contactListFragment).hide(contactListFragment)
            .show(chatHistoryFragment).commit();

    init();
    //???
    ((DemoHXSDKHelper) HXSDKHelper.getInstance()).getUserProfileManager().asyncGetCurrentUserInfo();
}

From source file:de.ub0r.android.wifibarcode.WifiBarcodeActivity.java

/**
 * {@inheritDoc}/*from   ww  w . j ava2 s.c  o  m*/
 */
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    ChangelogHelper.showChangelog(this, getString(R.string.changelog_), getString(R.string.app_name),
            R.array.updates, -1);

    if (savedInstanceState != null) {
        gotRoot = savedInstanceState.getBoolean(EXTRA_GOT_ROOT, true);
        mFirstLoad = savedInstanceState.getBoolean("mFirstLoad", true);
    } else {
        if (!this.getCacheFile().delete()) {
            Log.e(TAG, "error deleting file: ", getCacheFile().getAbsolutePath());
        }
    }

    barcodes = new BarcodeCache(this);

    WifiAdapter adapter = new WifiAdapter(this, android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    findViewById(R.id.add).setOnClickListener(this);
    findViewById(R.id.barcode).setOnClickListener(this);
    mEtSsid = (EditText) findViewById(R.id.ssid);
    mEtPassword = (EditText) findViewById(R.id.password);
    mSpConfigs = (Spinner) findViewById(R.id.configurations);
    mSpNetType = (Spinner) findViewById(R.id.networktype);

    mSpConfigs.setAdapter(adapter);
    mSpConfigs.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(final AdapterView<?> parent, final View view, final int position,
                final long id) {
            if (position == 0) {
                WifiBarcodeActivity.this.mEtSsid.setText(null);
                WifiBarcodeActivity.this.mEtSsid.setEnabled(true);
                WifiBarcodeActivity.this.mSpNetType.setEnabled(true);
                WifiBarcodeActivity.this.mSpNetType.setSelection(0);
                WifiBarcodeActivity.this.mEtPassword.setText(null);
                WifiBarcodeActivity.this.mEtPassword.setEnabled(true);
            } else {
                WifiAdapter a = (WifiAdapter) WifiBarcodeActivity.this.mSpConfigs.getAdapter();
                WifiConfiguration wc = a.getItem(position);
                WifiBarcodeActivity.this.mEtSsid.setText(wc.SSID.replaceAll("\"", ""));
                WifiBarcodeActivity.this.mEtSsid.setEnabled(false);
                int i = 0;
                if (wc.allowedAuthAlgorithms.get(WifiConfiguration.AuthAlgorithm.SHARED)) {
                    i = 1;
                } else if (wc.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.WPA_PSK)) {
                    i = 2;
                }
                WifiBarcodeActivity.this.mSpNetType.setSelection(i);
                WifiBarcodeActivity.this.mSpNetType.setEnabled(false);
                String p = a.getPassword(position);
                WifiBarcodeActivity.this.mEtPassword.setText(p);
                WifiBarcodeActivity.this.mEtPassword.setEnabled(i != 0 && TextUtils.isEmpty(p));
            }
            WifiBarcodeActivity.this.showBarcode(true);
            WifiBarcodeActivity.this.findViewById(R.id.add).setVisibility(View.GONE);

        }

        @Override
        public void onNothingSelected(final AdapterView<?> parent) {
            // nothing to do
        }

    });

    mSpNetType.setOnItemSelectedListener(new OnItemSelectedListener() {
        @Override
        public void onItemSelected(final AdapterView<?> parent, final View view, final int position,
                final long id) {
            //noinspection ConstantConditions
            String p = WifiBarcodeActivity.this.mEtPassword.getText().toString();
            WifiBarcodeActivity.this.mEtPassword.setEnabled(
                    position != 0 && (WifiBarcodeActivity.this.mSpConfigs.getSelectedItemPosition() == 0
                            || TextUtils.isEmpty(p)));
        }

        @Override
        public void onNothingSelected(final AdapterView<?> parent) {
            // nothing to do
        }
    });

    final int c = getResources().getColor(android.R.color.background_light);
    bCBackgroundColor = Integer.toHexString(Color.red(c)) + Integer.toHexString(Color.green(c))
            + Integer.toHexString(Color.blue(c));
    bCSize = getString(R.string.barcode_size);
}

From source file:com.webcomm.plugin.CustomInAppBrowser.java

/**
 * Display a new browser with the specified URL.
 *
 * @param url           The url to load.
 * @param jsonObject/*from  w ww  .java2  s . c  o  m*/
 */
public String showWebPage(final String url, HashMap<String, Boolean> features) {
    // Determine if we should hide the location bar.
    showLocationBar = true;
    openWindowHidden = false;
    if (features != null) {
        Boolean show = features.get(LOCATION);
        if (show != null) {
            showLocationBar = show.booleanValue();
        }
        Boolean hidden = features.get(HIDDEN);
        if (hidden != null) {
            openWindowHidden = hidden.booleanValue();
        }
        Boolean cache = features.get(CLEAR_ALL_CACHE);
        if (cache != null) {
            clearAllCache = cache.booleanValue();
        } else {
            cache = features.get(CLEAR_SESSION_CACHE);
            if (cache != null) {
                clearSessionCache = cache.booleanValue();
            }
        }
    }

    final CordovaWebView thatWebView = this.webView;

    // Create dialog in new thread
    Runnable runnable = new Runnable() {
        /**
         * Convert our DIP units to Pixels
         *
         * @return int
         */
        private int dpToPixels(int dipValue) {
            int value = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) dipValue,
                    cordova.getActivity().getResources().getDisplayMetrics());

            return value;
        }

        @SuppressLint("NewApi")
        public void run() {
            // Let's create the main dialog
            dialog = new CustomInAppBrowserDialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar);
            dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog;
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCancelable(true);
            dialog.setInAppBroswer(getInAppBrowser());

            // Main container layout
            LinearLayout main = new LinearLayout(cordova.getActivity());
            main.setOrientation(LinearLayout.VERTICAL);

            // Toolbar layout
            RelativeLayout toolbar = new RelativeLayout(cordova.getActivity());
            //Please, no more black! 
            toolbar.setBackgroundColor(android.graphics.Color.LTGRAY);
            toolbar.setLayoutParams(
                    new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(44)));
            toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2));
            toolbar.setHorizontalGravity(Gravity.LEFT);
            toolbar.setVerticalGravity(Gravity.TOP);

            // Action Button Container layout
            RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity());
            actionButtonContainer.setLayoutParams(
                    new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            actionButtonContainer.setHorizontalGravity(Gravity.LEFT);
            actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL);
            actionButtonContainer.setId(1);

            // Back button
            Button back = new Button(cordova.getActivity());
            RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
            backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT);
            back.setLayoutParams(backLayoutParams);
            back.setContentDescription("Back Button");
            back.setId(2);
            Resources activityRes = cordova.getActivity().getResources();
            int backResId = activityRes.getIdentifier("ic_action_previous_item", "drawable",
                    cordova.getActivity().getPackageName());
            Drawable backIcon = activityRes.getDrawable(backResId);
            if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
                back.setBackgroundDrawable(backIcon);
            } else {
                back.setBackground(backIcon);
            }
            back.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    goBack();
                }
            });

            // Forward button
            Button forward = new Button(cordova.getActivity());
            RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
            forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2);
            forward.setLayoutParams(forwardLayoutParams);
            forward.setContentDescription("Forward Button");
            forward.setId(3);
            int fwdResId = activityRes.getIdentifier("ic_action_next_item", "drawable",
                    cordova.getActivity().getPackageName());
            Drawable fwdIcon = activityRes.getDrawable(fwdResId);
            if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
                forward.setBackgroundDrawable(fwdIcon);
            } else {
                forward.setBackground(fwdIcon);
            }
            forward.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    goForward();
                }
            });

            // Edit Text Box
            edittext = new EditText(cordova.getActivity());
            RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
            textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1);
            textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5);
            edittext.setLayoutParams(textLayoutParams);
            edittext.setId(4);
            edittext.setSingleLine(true);
            edittext.setText(url);
            edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
            edittext.setImeOptions(EditorInfo.IME_ACTION_GO);
            edittext.setInputType(InputType.TYPE_NULL); // Will not except input... Makes the text NON-EDITABLE
            edittext.setOnKeyListener(new View.OnKeyListener() {
                public boolean onKey(View v, int keyCode, KeyEvent event) {
                    // If the event is a key-down event on the "enter" button
                    if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                        navigate(edittext.getText().toString());
                        return true;
                    }
                    return false;
                }
            });

            // Close/Done button
            Button close = new Button(cordova.getActivity());
            RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
            closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
            close.setLayoutParams(closeLayoutParams);
            forward.setContentDescription("Close Button");
            close.setId(5);
            int closeResId = activityRes.getIdentifier("ic_action_remove", "drawable",
                    cordova.getActivity().getPackageName());
            Drawable closeIcon = activityRes.getDrawable(closeResId);
            if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
                close.setBackgroundDrawable(closeIcon);
            } else {
                close.setBackground(closeIcon);
            }
            close.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    closeDialog();
                }
            });

            // WebView
            inAppWebView = new WebView(cordova.getActivity());
            inAppWebView.setLayoutParams(
                    new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
            inAppWebView.setWebChromeClient(new CustomInAppChromeClient(thatWebView));
            // [Modify]
            inAppWebView.addJavascriptInterface(
                    new WebAppInterface(cordova.getActivity().getApplicationContext()), "CustomInAppBrowser");
            WebViewClient client = new InAppBrowserClient(thatWebView, edittext);
            inAppWebView.setWebViewClient(client);
            WebSettings settings = inAppWebView.getSettings();
            settings.setJavaScriptEnabled(true);
            settings.setJavaScriptCanOpenWindowsAutomatically(true);
            settings.setBuiltInZoomControls(true);
            settings.setPluginState(android.webkit.WebSettings.PluginState.ON);

            //Toggle whether this is enabled or not!
            Bundle appSettings = cordova.getActivity().getIntent().getExtras();
            boolean enableDatabase = appSettings == null ? true
                    : appSettings.getBoolean("InAppBrowserStorageEnabled", true);
            if (enableDatabase) {
                String databasePath = cordova.getActivity().getApplicationContext()
                        .getDir("inAppBrowserDB", Context.MODE_PRIVATE).getPath();
                settings.setDatabasePath(databasePath);
                settings.setDatabaseEnabled(true);
            }
            settings.setDomStorageEnabled(true);

            if (clearAllCache) {
                CookieManager.getInstance().removeAllCookie();
            } else if (clearSessionCache) {
                CookieManager.getInstance().removeSessionCookie();
            }

            inAppWebView.loadUrl(url);
            inAppWebView.setId(6);
            inAppWebView.getSettings().setLoadWithOverviewMode(true);
            inAppWebView.getSettings().setUseWideViewPort(true);
            inAppWebView.requestFocus();
            inAppWebView.requestFocusFromTouch();

            // Add the back and forward buttons to our action button container layout
            actionButtonContainer.addView(back);
            actionButtonContainer.addView(forward);

            // Add the views to our toolbar
            toolbar.addView(actionButtonContainer);
            toolbar.addView(edittext);
            toolbar.addView(close);

            // Don't add the toolbar if its been disabled
            if (getShowLocationBar()) {
                // Add our toolbar to our main view/layout
                main.addView(toolbar);
            }

            // Add our webview to our main view/layout
            main.addView(inAppWebView);

            WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
            lp.copyFrom(dialog.getWindow().getAttributes());
            lp.width = WindowManager.LayoutParams.MATCH_PARENT;
            lp.height = WindowManager.LayoutParams.MATCH_PARENT;

            dialog.setContentView(main);
            dialog.show();
            dialog.getWindow().setAttributes(lp);
            // the goal of openhidden is to load the url and not display it
            // Show() needs to be called to cause the URL to be loaded
            if (openWindowHidden) {
                dialog.hide();
            }
        }
    };
    this.cordova.getActivity().runOnUiThread(runnable);
    return "";
}

From source file:com.nextgis.maplibui.activity.ModifyAttributesActivity.java

protected void createView(final IGISApplication app, Bundle savedState) {
    //create and fill controls
    Bundle extras = getIntent().getExtras();

    if (extras != null) {
        int layerId = extras.getInt(KEY_LAYER_ID);
        MapBase map = app.getMap();/* w ww . j ava  2 s  . com*/
        mLayer = (VectorLayer) map.getLayerById(layerId);

        if (null != mLayer) {
            mSharedPreferences = mLayer.getPreferences();

            mFields = new HashMap<>();
            mFeatureId = extras.getLong(KEY_FEATURE_ID);
            mIsViewOnly = extras.getBoolean(KEY_VIEW_ONLY, false);
            mIsGeometryChanged = extras.getBoolean(KEY_GEOMETRY_CHANGED, true);
            mGeometry = (GeoGeometry) extras.getSerializable(KEY_GEOMETRY);
            LinearLayout layout = (LinearLayout) findViewById(R.id.controls_list);
            fillControls(layout, savedState);
        } else {
            Toast.makeText(this, R.string.error_layer_not_inited, Toast.LENGTH_SHORT).show();
            finish();
        }
    }
}

From source file:com.tealeaf.TeaLeaf.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PluginManager.init(this);
    instance = this;
    setFullscreenFlag();/*from  w w  w. jav  a 2  s .c  o  m*/
    configureActivity();
    String appID = findAppID();
    options = new TeaLeafOptions(this);

    PluginManager.callAll("onCreate", this, savedInstanceState);

    //check intent for test app info
    Bundle bundle = getIntent().getExtras();
    boolean isTestApp = false;
    if (bundle != null) {
        isTestApp = bundle.getBoolean("isTestApp", false);

        if (isTestApp) {
            options.setAppID(appID);
            boolean isPortrait = bundle.getBoolean("isPortrait", false);
            if (isPortrait) {
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            } else {
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            }
            options.setCodeHost(bundle.getString("hostValue"));
            options.setCodePort(bundle.getInt("portValue"));
            String simulateID = bundle.getString("simulateID");
            options.setSimulateID(simulateID);
        }
    }

    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);

    group = new FrameLayout(this);
    setContentView(group);

    // TextEditViewHandler setup
    textEditView = new TextEditViewHandler(this);

    settings = new Settings(this);
    remoteLogger = (ILogger) getLoggerInstance(this);

    checkUpdate();
    compareVersions();
    setLaunchUri();

    // defer building all of these things until we have the absolutely correct options
    logger.buildLogger(this, remoteLogger);
    resourceManager = new ResourceManager(this, options);
    contactList = new ContactList(this, resourceManager);
    soundQueue = new SoundQueue(this, resourceManager);
    localStorage = new LocalStorage(this, options);

    // start push notifications, but defer for 10 seconds to give us time to start up
    PushBroadcastReceiver.scheduleNext(this, 10);

    glView = new TeaLeafGLSurfaceView(this);
    glViewPaused = false;

    // default screen dimensions
    Display display = getWindow().getWindowManager().getDefaultDisplay();
    int width = display.getWidth();
    int height = display.getHeight();
    int orientation = getRequestedOrientation();

    // gets real screen dimensions without nav bars on recent API versions
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        Point screenSize = new Point();
        try {
            display.getRealSize(screenSize);
            width = screenSize.x;
            height = screenSize.y;
        } catch (NoSuchMethodError e) {
        }
    }

    // flip width and height based on orientation
    if ((orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE && height > width)
            || (orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT && width > height)) {
        int tempWidth = width;
        width = height;
        height = tempWidth;
    }

    final AbsoluteLayout absLayout = new AbsoluteLayout(this);
    absLayout.setLayoutParams(new android.view.ViewGroup.LayoutParams(width, height));
    absLayout.addView(glView, new android.view.ViewGroup.LayoutParams(width, height));

    group.addView(absLayout);
    editText = EditTextView.Init(this);

    if (isTestApp) {
        startGame();
    }

    soundQueue.playSound(SoundQueue.LOADING_SOUND);
    doFirstRun();
    remoteLogger.sendLaunchEvent(this);

    paused = false;
    menuButtonHandler = MenuButtonHandlerFactory.getButtonHandler(this);

    group.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
        public void onGlobalLayout() {
            // get visible area of the view
            Rect r = new Rect();
            group.getWindowVisibleDisplayFrame(r);

            int visibleHeight = r.bottom;

            // TODO
            // maybe this should be renamed
            if (visibleHeight != lastVisibleHeight) {
                lastVisibleHeight = visibleHeight;
                EventQueue.pushEvent(new KeyboardScreenResizeEvent(visibleHeight));
            }
        }
    });
}

From source file:com.likemag.cordova.inappbrowsercustom.InAppBrowser.java

/**
 * Display a new browser with the specified URL.
 *
 * @param url           The url to load.
 * @param jsonObject//  w ww.  java 2  s.  co m
 */
public String showWebPage(final String url, HashMap<String, Boolean> features) {
    // Determine if we should hide the location bar.
    showLocationBar = true;
    openWindowHidden = false;
    if (features != null) {
        Boolean show = features.get(LOCATION);
        if (show != null) {
            showLocationBar = show.booleanValue();
        }
        Boolean hidden = features.get(HIDDEN);
        if (hidden != null) {
            openWindowHidden = hidden.booleanValue();
        }
        Boolean cache = features.get(CLEAR_ALL_CACHE);
        if (cache != null) {
            clearAllCache = cache.booleanValue();
        } else {
            cache = features.get(CLEAR_SESSION_CACHE);
            if (cache != null) {
                clearSessionCache = cache.booleanValue();
            }
        }
    }

    final CordovaWebView thatWebView = this.webView;

    // Create dialog in new thread
    Runnable runnable = new Runnable() {
        /**
         * Convert our DIP units to Pixels
         *
         * @return int
         */
        private int dpToPixels(int dipValue) {
            int value = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) dipValue,
                    cordova.getActivity().getResources().getDisplayMetrics());

            return value;
        }

        @SuppressLint("NewApi")
        public void run() {
            // Let's create the main dialog
            dialog = new InAppBrowserDialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar);
            dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog;
            dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            dialog.setCancelable(true);
            dialog.setInAppBroswer(getInAppBrowser());

            // Main container layout
            LinearLayout main = new LinearLayout(cordova.getActivity());
            main.setOrientation(LinearLayout.VERTICAL);

            // Toolbar layout
            RelativeLayout toolbar = new RelativeLayout(cordova.getActivity());
            //Please, no more black! 
            toolbar.setBackgroundColor(android.graphics.Color.WHITE);
            toolbar.setLayoutParams(
                    new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(44)));
            toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2));
            toolbar.setHorizontalGravity(Gravity.LEFT);
            toolbar.setVerticalGravity(Gravity.TOP);

            // Action Button Container layout
            RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity());
            actionButtonContainer.setLayoutParams(
                    new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            actionButtonContainer.setHorizontalGravity(Gravity.LEFT);
            actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL);
            actionButtonContainer.setId(1);

            // Back button
            Button back = new Button(cordova.getActivity());
            RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
            backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT);
            back.setLayoutParams(backLayoutParams);
            back.setContentDescription("Back Button");
            back.setId(2);
            Resources activityRes = cordova.getActivity().getResources();
            int backResId = activityRes.getIdentifier("ic_action_previous_item", "drawable",
                    cordova.getActivity().getPackageName());
            Drawable backIcon = activityRes.getDrawable(backResId);
            if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
                back.setBackgroundDrawable(backIcon);
            } else {
                back.setBackground(backIcon);
            }
            back.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    goBack();
                }
            });

            // Forward button
            Button forward = new Button(cordova.getActivity());
            RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
            forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2);
            forward.setLayoutParams(forwardLayoutParams);
            forward.setContentDescription("Forward Button");
            forward.setId(3);
            int fwdResId = activityRes.getIdentifier("ic_action_next_item", "drawable",
                    cordova.getActivity().getPackageName());
            Drawable fwdIcon = activityRes.getDrawable(fwdResId);
            if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
                forward.setBackgroundDrawable(fwdIcon);
            } else {
                forward.setBackground(fwdIcon);
            }
            forward.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    goForward();
                }
            });

            // Edit Text Box
            edittext = new EditText(cordova.getActivity());
            RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
            textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1);
            textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5);
            edittext.setLayoutParams(textLayoutParams);
            edittext.setId(4);
            edittext.setSingleLine(true);
            edittext.setText(url);
            edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
            edittext.setImeOptions(EditorInfo.IME_ACTION_GO);
            edittext.setInputType(InputType.TYPE_NULL); // Will not except input... Makes the text NON-EDITABLE
            edittext.setOnKeyListener(new View.OnKeyListener() {
                public boolean onKey(View v, int keyCode, KeyEvent event) {
                    // If the event is a key-down event on the "enter" button
                    if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                        navigate(edittext.getText().toString());
                        return true;
                    }
                    return false;
                }
            });

            // Close/Done button
            Button close = new Button(cordova.getActivity());
            RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams(
                    LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
            closeLayoutParams.addRule(RelativeLayout.ALIGN_LEFT);
            close.setLayoutParams(closeLayoutParams);
            forward.setContentDescription("Close Button");
            close.setText(getPostName());
            close.setTextSize(20.0f);
            close.setTextColor(android.graphics.Color.GRAY);
            close.setId(5);
            int closeResId = activityRes.getIdentifier("ic_action_remove", "drawable",
                    cordova.getActivity().getPackageName());
            Drawable closeIcon = activityRes.getDrawable(backResId);
            closeIcon.setBounds(0, 0, 40, 40);
            close.setPadding(0, 0, 0, 0);
            close.setBackgroundDrawable(null);
            close.setCompoundDrawables(closeIcon, null, null, null);
            if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) {
                //close.setBackgroundDrawable(closeIcon);
            } else {
                //close.setBackground(closeIcon);
            }
            close.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    closeDialog();
                }
            });

            // WebView
            inAppWebView = new WebView(cordova.getActivity());
            inAppWebView.setLayoutParams(
                    new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
            inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView));
            WebViewClient client = new InAppBrowserClient(thatWebView, edittext);
            inAppWebView.setWebViewClient(client);
            WebSettings settings = inAppWebView.getSettings();
            settings.setJavaScriptEnabled(true);
            settings.setJavaScriptCanOpenWindowsAutomatically(true);
            settings.setBuiltInZoomControls(true);
            settings.setPluginState(android.webkit.WebSettings.PluginState.ON);

            //Toggle whether this is enabled or not!
            Bundle appSettings = cordova.getActivity().getIntent().getExtras();
            boolean enableDatabase = appSettings == null ? true
                    : appSettings.getBoolean("InAppBrowserStorageEnabled", true);
            if (enableDatabase) {
                String databasePath = cordova.getActivity().getApplicationContext()
                        .getDir("inAppBrowserDB", Context.MODE_PRIVATE).getPath();
                settings.setDatabasePath(databasePath);
                settings.setDatabaseEnabled(true);
            }
            settings.setDomStorageEnabled(true);

            if (clearAllCache) {
                CookieManager.getInstance().removeAllCookie();
            } else if (clearSessionCache) {
                CookieManager.getInstance().removeSessionCookie();
            }

            inAppWebView.loadUrl(url);
            inAppWebView.setId(6);
            inAppWebView.getSettings().setLoadWithOverviewMode(true);
            inAppWebView.getSettings().setUseWideViewPort(true);
            inAppWebView.requestFocus();
            inAppWebView.requestFocusFromTouch();

            // Add the back and forward buttons to our action button container layout
            actionButtonContainer.addView(back);
            actionButtonContainer.addView(forward);

            // Add the views to our toolbar
            //toolbar.addView(actionButtonContainer);
            //toolbar.addView(edittext);
            toolbar.addView(close);

            // Don't add the toolbar if its been disabled
            if (getShowLocationBar()) {
                // Add our toolbar to our main view/layout
                main.addView(toolbar);
            }

            // Add our webview to our main view/layout
            main.addView(inAppWebView);

            WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
            lp.copyFrom(dialog.getWindow().getAttributes());
            lp.width = WindowManager.LayoutParams.MATCH_PARENT;
            lp.height = WindowManager.LayoutParams.MATCH_PARENT;

            dialog.setContentView(main);
            dialog.show();
            dialog.getWindow().setAttributes(lp);
            // the goal of openhidden is to load the url and not display it
            // Show() needs to be called to cause the URL to be loaded
            if (openWindowHidden) {
                dialog.hide();
            }
        }
    };
    this.cordova.getActivity().runOnUiThread(runnable);
    return "";
}

From source file:com.borqs.browser.combo.BookmarksPageCallbacks.java

/**
 *  Create a new BrowserBookmarksPage./*w w w .j  av a2 s  .c  om*/
 */
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    /*
    SharedPreferences prefs = BrowserSettings.getInstance().getPreferences();
    try {
    mState = new JSONObject(prefs.getString(PREF_GROUP_STATE, "{}"));
    } catch (JSONException e) {
    // Parse failed, clear preference and start with empty state
    prefs.edit().remove(PREF_GROUP_STATE).apply();
    }
    */
    mState = new JSONObject();

    // Bundle args = getArguments();
    mDisableNewWindow = icicle == null ? false : icicle.getBoolean(EXTRA_DISABLE_WINDOW, false);
    /*
    // setHasOptionsMenu(true);
    if (mCallbacks == null && this instanceof CombinedBookmarksCallbacks) {
    mCallbacks = new CombinedBookmarksCallbackWrapper(
            (CombinedBookmarksCallbacks) this);
    }*/

    mRoot = LayoutInflater.from(this).inflate(R.layout.combo_bookmarks, null, false);
    mEmptyView = mRoot.findViewById(android.R.id.empty);

    mGrid = (BookmarkExpandableView) mRoot.findViewById(R.id.grid);
    mGrid.setOnChildClickListener(this);
    mGrid.setColumnWidthFromLayout(R.layout.combo_bookmark_thumbnail);
    mGrid.setBreadcrumbController(this);
    setEnableContextMenu(mEnableContextMenu);

    // Start the loaders
    LoaderManager lm = getLoaderManager();
    lm.restartLoader(LOADER_ACCOUNTS, null, this);

    this.setContentView(mRoot);
}