List of usage examples for android.view Window FEATURE_ACTION_BAR
int FEATURE_ACTION_BAR
To view the source code for android.view Window FEATURE_ACTION_BAR.
Click Source Link
From source file:com.actionbarsherlock.internal.ActionBarSherlockCompat.java
@Override public void dispatchPanelClosed(int featureId, android.view.Menu menu) { if (DEBUG)/*from ww w . j a va 2 s .c om*/ Log.d(TAG, "[dispatchPanelClosed] featureId: " + featureId + ", menu: " + menu); if (featureId == Window.FEATURE_ACTION_BAR || featureId == Window.FEATURE_OPTIONS_PANEL) { if (aActionBar != null) { aActionBar.dispatchMenuVisibilityChanged(false); } } }
From source file:com.mobilinkd.tncconfig.TncConfig.java
@Override @TargetApi(Build.VERSION_CODES.HONEYCOMB) protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { getWindow().requestFeature(Window.FEATURE_ACTION_BAR); }//from ww w .ja va2 s . c o m setContentView(R.layout.activity_main); if (D) Log.e(TAG, "+++ ON CREATE +++"); // Get local Bluetooth adapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); // If the adapter is null, then Bluetooth is not supported if (mBluetoothAdapter == null) { Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show(); finish(); return; } mBluetoothDeviceView = (TextView) findViewById(R.id.bluetooth_device_text); mFirmwareVersionView = (TextView) findViewById(R.id.firmware_version_text); }
From source file:com.example.android.wifidirect.WiFiDirectActivity.java
@Override public boolean onMenuOpened(int featureId, Menu menu) { if (featureId == Window.FEATURE_ACTION_BAR && menu != null) { if (menu.getClass().getSimpleName().equals("MenuBuilder")) { try { Method m = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE); m.setAccessible(true);/*from ww w . j a v a2s.co m*/ m.invoke(menu, true); } catch (Exception e) { } } } return super.onMenuOpened(featureId, menu); }
From source file:com.polychrom.cordova.ActionBarPlugin.java
@Override public boolean execute(final String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException { if (!plugin_actions.contains(action)) { return false; }/*from w w w . j a v a 2 s . c o m*/ final Activity ctx = (Activity) cordova; if ("isAvailable".equals(action)) { JSONObject result = new JSONObject(); result.put("value", ctx.getWindow().hasFeature(Window.FEATURE_ACTION_BAR)); callbackContext.success(result); return true; } final ActionBar bar = ctx.getActionBar(); if (bar == null) { Window window = ctx.getWindow(); if (!window.hasFeature(Window.FEATURE_ACTION_BAR)) { callbackContext .error("ActionBar feature not available, Window.FEATURE_ACTION_BAR must be enabled!"); } else { callbackContext.error("Failed to get ActionBar"); } return true; } if (menu == null) { callbackContext.error("Options menu not initialised"); return true; } final StringBuffer error = new StringBuffer(); JSONObject result = new JSONObject(); if ("isShowing".equals(action)) { result.put("value", bar.isShowing()); } else if ("getHeight".equals(action)) { result.put("value", bar.getHeight()); } else if ("getDisplayOptions".equals(action)) { result.put("value", bar.getDisplayOptions()); } else if ("getNavigationMode".equals(action)) { result.put("value", bar.getNavigationMode()); } else if ("getSelectedNavigationItem".equals(action)) { result.put("value", bar.getSelectedNavigationIndex()); } else if ("getSubtitle".equals(action)) { result.put("value", bar.getSubtitle()); } else if ("getTitle".equals(action)) { result.put("value", bar.getTitle()); } else { try { JSONException exception = new Runnable() { public JSONException exception = null; public void run() { try { // This is a bit of a hack (should be specific to the request, not global) bases = new String[] { removeFilename(webView.getOriginalUrl()), removeFilename(webView.getUrl()) }; if ("show".equals(action)) { bar.show(); } else if ("hide".equals(action)) { bar.hide(); } else if ("setMenu".equals(action)) { if (args.isNull(0)) { error.append("menu can not be null"); return; } menu_definition = args.getJSONArray(0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ctx.invalidateOptionsMenu(); } } else if ("setTabs".equals(action)) { if (args.isNull(0)) { error.append("menu can not be null"); return; } bar.removeAllTabs(); tab_callbacks.clear(); if (!buildTabs(bar, args.getJSONArray(0))) { error.append("Invalid tab bar definition"); } } else if ("setDisplayHomeAsUpEnabled".equals(action)) { if (args.isNull(0)) { error.append("showHomeAsUp can not be null"); return; } bar.setDisplayHomeAsUpEnabled(args.getBoolean(0)); } else if ("setDisplayOptions".equals(action)) { if (args.isNull(0)) { error.append("options can not be null"); return; } final int options = args.getInt(0); bar.setDisplayOptions(options); } else if ("setDisplayShowHomeEnabled".equals(action)) { if (args.isNull(0)) { error.append("showHome can not be null"); return; } bar.setDisplayShowHomeEnabled(args.getBoolean(0)); } else if ("setDisplayShowTitleEnabled".equals(action)) { if (args.isNull(0)) { error.append("showTitle can not be null"); return; } bar.setDisplayShowTitleEnabled(args.getBoolean(0)); } else if ("setDisplayUseLogoEnabled".equals(action)) { if (args.isNull(0)) { error.append("useLogo can not be null"); return; } bar.setDisplayUseLogoEnabled(args.getBoolean(0)); } else if ("setHomeButtonEnabled".equals(action)) { if (args.isNull(0)) { error.append("enabled can not be null"); return; } bar.setHomeButtonEnabled(args.getBoolean(0)); } else if ("setIcon".equals(action)) { if (args.isNull(0)) { error.append("icon can not be null"); return; } Drawable drawable = getDrawableForURI(args.getString(0)); bar.setIcon(drawable); } else if ("setListNavigation".equals(action)) { JSONArray items = null; if (args.isNull(0) == false) { items = args.getJSONArray(0); } navigation_adapter.setItems(items); bar.setListNavigationCallbacks(navigation_adapter, navigation_listener); } else if ("setLogo".equals(action)) { if (args.isNull(0)) { error.append("logo can not be null"); return; } Drawable drawable = getDrawableForURI(args.getString(0)); bar.setLogo(drawable); } else if ("setNavigationMode".equals(action)) { if (args.isNull(0)) { error.append("mode can not be null"); return; } final int mode = args.getInt(0); bar.setNavigationMode(mode); } else if ("setSelectedNavigationItem".equals(action)) { if (args.isNull(0)) { error.append("position can not be null"); return; } bar.setSelectedNavigationItem(args.getInt(0)); } else if ("setSubtitle".equals(action)) { if (args.isNull(0)) { error.append("subtitle can not be null"); return; } bar.setSubtitle(args.getString(0)); } else if ("setTitle".equals(action)) { if (args.isNull(0)) { error.append("title can not be null"); return; } bar.setTitle(args.getString(0)); } } catch (JSONException e) { exception = e; } finally { synchronized (this) { this.notify(); } } } // Run task synchronously { synchronized (this) { ctx.runOnUiThread(this); this.wait(); } } }.exception; if (exception != null) { throw exception; } } catch (InterruptedException e) { error.append("Function interrupted on UI thread"); } } if (error.length() == 0) { if (result.length() > 0) { callbackContext.success(result); } else { callbackContext.success(); } } else { callbackContext.error(error.toString()); } return true; }
From source file:com.native5.plugins.ActionBarPlugin.java
@Override public boolean execute(final String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException { if (!plugin_actions.contains(action)) { return false; }/*from w w w . java2s.c o m*/ final Activity ctx = (Activity) cordova; if ("isAvailable".equals(action)) { JSONObject result = new JSONObject(); result.put("value", ctx.getWindow().hasFeature(Window.FEATURE_ACTION_BAR)); callbackContext.success(result); return true; } final ActionBar bar = ctx.getActionBar(); if (bar == null) { Window window = ctx.getWindow(); if (!window.hasFeature(Window.FEATURE_ACTION_BAR)) { callbackContext .error("ActionBar feature not available, Window.FEATURE_ACTION_BAR must be enabled!"); } else { callbackContext.error("Failed to get ActionBar"); } return true; } if (menu == null) { callbackContext.error("Options menu not initialised"); return true; } final StringBuffer error = new StringBuffer(); JSONObject result = new JSONObject(); if ("isShowing".equals(action)) { result.put("value", bar.isShowing()); } else if ("getHeight".equals(action)) { result.put("value", bar.getHeight()); } else if ("getDisplayOptions".equals(action)) { result.put("value", bar.getDisplayOptions()); } else if ("getNavigationMode".equals(action)) { result.put("value", bar.getNavigationMode()); } else if ("getSelectedNavigationItem".equals(action)) { result.put("value", bar.getSelectedNavigationIndex()); } else if ("getSubtitle".equals(action)) { result.put("value", bar.getSubtitle()); } else if ("getTitle".equals(action)) { result.put("value", bar.getTitle()); } else { try { JSONException exception = new Runnable() { public JSONException exception = null; public void run() { try { // This is a bit of a hack (should be specific to the request, not global) bases = new String[] { removeFilename(webView.getOriginalUrl()), removeFilename(webView.getUrl()) }; if ("show".equals(action)) { LOG.d("native5-action-bar", "Showing Action Bar"); bar.show(); } else if ("hide".equals(action)) { bar.hide(); } else if ("setMenu".equals(action)) { if (args.isNull(0)) { error.append("menu can not be null"); return; } menu_definition = args.getJSONArray(0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ctx.invalidateOptionsMenu(); } } else if ("setTabs".equals(action)) { if (args.isNull(0)) { error.append("menu can not be null"); return; } bar.removeAllTabs(); tab_callbacks.clear(); if (!buildTabs(bar, args.getJSONArray(0))) { error.append("Invalid tab bar definition"); } } else if ("setDisplayHomeAsUpEnabled".equals(action)) { if (args.isNull(0)) { error.append("showHomeAsUp can not be null"); return; } bar.setDisplayHomeAsUpEnabled(args.getBoolean(0)); } else if ("setDisplayOptions".equals(action)) { if (args.isNull(0)) { error.append("options can not be null"); return; } final int options = args.getInt(0); bar.setDisplayOptions(options); } else if ("setDisplayShowHomeEnabled".equals(action)) { if (args.isNull(0)) { error.append("showHome can not be null"); return; } bar.setDisplayShowHomeEnabled(args.getBoolean(0)); } else if ("setDisplayShowTitleEnabled".equals(action)) { if (args.isNull(0)) { error.append("showTitle can not be null"); return; } bar.setDisplayShowTitleEnabled(args.getBoolean(0)); } else if ("setDisplayUseLogoEnabled".equals(action)) { if (args.isNull(0)) { error.append("useLogo can not be null"); return; } bar.setDisplayUseLogoEnabled(args.getBoolean(0)); } else if ("setHomeButtonEnabled".equals(action)) { if (args.isNull(0)) { error.append("enabled can not be null"); return; } bar.setHomeButtonEnabled(args.getBoolean(0)); } else if ("setIcon".equals(action)) { if (args.isNull(0)) { error.append("icon can not be null"); return; } Drawable drawable = getDrawableForURI(args.getString(0)); bar.setIcon(drawable); } else if ("setListNavigation".equals(action)) { JSONArray items = null; if (args.isNull(0) == false) { items = args.getJSONArray(0); } navigation_adapter.setItems(items); bar.setListNavigationCallbacks(navigation_adapter, navigation_listener); } else if ("setLogo".equals(action)) { String uri = args.getString(0); if (args.isNull(0)) { error.append("logo can not be null"); return; } // try { // InputStream ims = ctx.getAssets().open(uri); Drawable drawable = getDrawableForURI(uri); // Drawable.createFromStream(ims, null); bar.setLogo(drawable); bar.setBackgroundDrawable(getDrawableForURI("images/logo-bg.png")); // } catch (IOException e) { // e.printStackTrace(); // } } else if ("setNavigationMode".equals(action)) { if (args.isNull(0)) { error.append("mode can not be null"); return; } final int mode = args.getInt(0); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); } else if ("setSelectedNavigationItem".equals(action)) { if (args.isNull(0)) { error.append("position can not be null"); return; } bar.setSelectedNavigationItem(args.getInt(0)); } else if ("setSelectedTab".equals(action)) { if (args.isNull(0)) { error.append("position can not be null"); return; } LOG.d("setSelectedTab", bar.getTabCount() + ""); bar.selectTab(bar.getTabAt(args.getInt(0))); } else if ("setSubtitle".equals(action)) { if (args.isNull(0)) { error.append("subtitle can not be null"); return; } bar.setSubtitle(args.getString(0)); } else if ("setTitle".equals(action)) { if (args.isNull(0)) { error.append("title can not be null"); return; } bar.setTitle(args.getString(0)); } } catch (JSONException e) { exception = e; } finally { synchronized (this) { this.notify(); } } } // Run task synchronously { synchronized (this) { ctx.runOnUiThread(this); this.wait(); } } }.exception; if (exception != null) { throw exception; } } catch (InterruptedException e) { error.append("Function interrupted on UI thread"); } } if (error.length() == 0) { if (result.length() > 0) { callbackContext.success(result); } else { callbackContext.success(); } } else { callbackContext.error(error.toString()); } return true; }
From source file:org.openintents.notepad.NoteEditor.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (DEBUG) {/* ww w.j ava2s . c o m*/ Log.d(TAG, "onCreate()"); } if (getIntent().getAction().equals(Intent.ACTION_CREATE_SHORTCUT)) { createShortcut(); return; } if (savedInstanceState == null) { // sDecryptedText has no use for brand new activities sDecryptedText = null; } // Usually, sDecryptedText == null. mDecryptedText = sDecryptedText; if (sDecryptedText != null) { // we use the text right now, // so don't encrypt the text anymore. EncryptActivity.cancelEncrypt(); if (EncryptActivity.getPendingEncryptActivities() == 0) { if (DEBUG) { Log.d(TAG, "sDecryptedText = null"); } // no more encrypt activies will be called sDecryptedText = null; } } mSelectionStart = 0; mSelectionStop = 0; // If an instance of this activity had previously stopped, we can // get the original text it started with. if (savedInstanceState != null) { mOriginalContent = savedInstanceState.getString(BUNDLE_ORIGINAL_CONTENT); mUndoRevert = savedInstanceState.getString(BUNDLE_UNDO_REVERT); mState = savedInstanceState.getInt(BUNDLE_STATE); String uriString = savedInstanceState.getString(BUNDLE_URI); if (uriString != null) { mUri = Uri.parse(uriString); } mSelectionStart = savedInstanceState.getInt(BUNDLE_SELECTION_START); mSelectionStop = savedInstanceState.getInt(BUNDLE_SELECTION_STOP); mFileContent = savedInstanceState.getString(BUNDLE_FILE_CONTENT); if (mApplyText == null && mApplyTextBefore == null && mApplyTextAfter == null) { // Only read values if they had not been set by // onActivityResult() yet: mApplyText = savedInstanceState.getString(BUNDLE_APPLY_TEXT); mApplyTextBefore = savedInstanceState.getString(BUNDLE_APPLY_TEXT_BEFORE); mApplyTextAfter = savedInstanceState.getString(BUNDLE_APPLY_TEXT_AFTER); } } else { // Do some setup based on the action being performed. final Intent intent = getIntent(); final String action = intent.getAction(); if (Intent.ACTION_EDIT.equals(action) || Intent.ACTION_VIEW.equals(action)) { // Requested to edit: set that state, and the data being edited. mState = STATE_EDIT; mUri = intent.getData(); if (mUri != null && mUri.getScheme().equals("file")) { mState = STATE_EDIT_NOTE_FROM_SDCARD; // Load the file into a new note. if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { mFileContent = readFile(FileUriUtils.getFile(mUri)); } else { if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.READ_EXTERNAL_STORAGE)) { } else { ActivityCompat.requestPermissions(this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, REQUEST_CODE_PERMISSION_READ_EXTERNAL_STORAGE); mFileContent = getString(R.string.request_permissions); } } } else if (mUri != null && !mUri.getAuthority().equals(NotePad.AUTHORITY)) { // Note a notepad note. Treat slightly differently. // (E.g. a note from OI Shopping List) mState = STATE_EDIT_EXTERNAL_NOTE; } } else if (Intent.ACTION_INSERT.equals(action) || Intent.ACTION_SEND.equals(action)) { // Use theme of most recently modified note: ContentValues values = new ContentValues(1); String theme = getMostRecentlyUsedTheme(); values.put(Notes.THEME, theme); String tags = intent.getStringExtra(NotepadInternalIntents.EXTRA_TAGS); values.put(Notes.TAGS, tags); if (mText != null) { values.put(Notes.SELECTION_START, mText.getSelectionStart()); values.put(Notes.SELECTION_END, mText.getSelectionEnd()); } // Requested to insert: set that state, and create a new entry // in the container. mState = STATE_INSERT; /* * intent.setAction(Intent.ACTION_EDIT); intent.setData(mUri); * setIntent(intent); */ if (Intent.ACTION_SEND.equals(action)) { values.put(Notes.NOTE, getIntent().getStringExtra(Intent.EXTRA_TEXT)); mUri = getContentResolver().insert(Notes.CONTENT_URI, values); } else { mUri = getContentResolver().insert(intent.getData(), values); } // If we were unable to create a new note, then just finish // this activity. A RESULT_CANCELED will be sent back to the // original activity if they requested a result. if (mUri == null) { Log.e(TAG, "Failed to insert new note into " + getIntent().getData()); finish(); return; } // The new entry was created, so assume all will end well and // set the result to be returned. // setResult(RESULT_OK, (new // Intent()).setAction(mUri.toString())); setResult(RESULT_OK, intent); } else { // Whoops, unknown action! Bail. Log.e(TAG, "Unknown action, exiting"); finish(); return; } } // setup actionbar if (mActionBarAvailable) { requestWindowFeature(Window.FEATURE_ACTION_BAR); WrapActionBar bar = new WrapActionBar(this); bar.setDisplayHomeAsUpEnabled(true); // force to show the actionbar on version 14+ if (Integer.valueOf(android.os.Build.VERSION.SDK) >= 14) { bar.setHomeButtonEnabled(true); } } else { requestWindowFeature(Window.FEATURE_RIGHT_ICON); } // Set the layout for this activity. You can find it in // res/layout/note_editor.xml setContentView(R.layout.note_editor); // The text view for our note, identified by its ID in the XML file. mText = (EditText) findViewById(R.id.note); if (mState == STATE_EDIT_NOTE_FROM_SDCARD) { // We add a text watcher, so that the title can be updated // to indicate a small "*" if modified. mText.addTextChangedListener(mTextWatcherSdCard); } if (mState != STATE_EDIT_NOTE_FROM_SDCARD) { // Check if we load a note from notepad or from some external module if (mState == STATE_EDIT_EXTERNAL_NOTE) { // Get all the columns as we don't know which columns are // supported. mCursor = managedQuery(mUri, null, null, null, null); // Now check which columns are available List<String> columnNames = Arrays.asList(mCursor.getColumnNames()); if (!columnNames.contains(Notes.NOTE)) { hasNoteColumn = false; } if (!columnNames.contains(Notes.TAGS)) { hasTagsColumn = false; } if (!columnNames.contains(Notes.ENCRYPTED)) { hasEncryptionColumn = false; } if (!columnNames.contains(Notes.THEME)) { hasThemeColumn = false; } if (!columnNames.contains(Notes.SELECTION_START)) { hasSelection_startColumn = false; } if (!columnNames.contains(Notes.SELECTION_END)) { hasSelection_endColumn = false; } } else { // Get the note! mCursor = managedQuery(mUri, PROJECTION, null, null, null); // It's not an external note, so all the columns are available // in the database } } else { mCursor = null; } mText.addTextChangedListener(mTextWatcherCharCount); initSearchPanel(); }
From source file:au.com.wallaceit.reddinator.SubredditSelectActivity.java
@Override public boolean onMenuOpened(int featureId, Menu menu) { if (featureId == Window.FEATURE_ACTION_BAR && menu != null) { if (menu.getClass().getSimpleName().equals("MenuBuilder")) { try { Method m = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE); m.setAccessible(true);/*from ww w . j av a2 s .com*/ m.invoke(menu, true); } catch (NoSuchMethodException e) { System.out.println("Could not display action icons in menu"); } catch (Exception e) { throw new RuntimeException(e); } } } return super.onMenuOpened(featureId, menu); }
From source file:org.brandroid.openmanager.activities.OpenExplorer.java
public void onCreate(Bundle savedInstanceState) { Thread.setDefaultUncaughtExceptionHandler(new CustomExceptionHandler()); if (getPreferences().getBoolean("global", "pref_fullscreen", false)) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); IS_FULL_SCREEN = true;//w w w . java 2s .c o m } //else getWindow().addFlags(WindowManager.LayoutParams.FLAG else { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); IS_FULL_SCREEN = false; } IS_KEYBOARD_AVAILABLE = getContext().getResources() .getConfiguration().keyboard == Configuration.KEYBOARD_QWERTY; loadPreferences(); if (getPreferences().getBoolean("global", "pref_hardware_accel", true) && !BEFORE_HONEYCOMB) getWindow().setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED); //mActionBarHelper = ActionBarHelper.createInstance(this); //mActionBarHelper.onCreate(savedInstanceState); if (BEFORE_HONEYCOMB) { requestWindowFeature(Window.FEATURE_NO_TITLE); USE_ACTION_BAR = false; //} else if(isGTV()) { // USE_ACTION_BAR = false; // mBar = (LeftNavBarService.instance()).getLeftNavBar(this); } else if (!BEFORE_HONEYCOMB) { requestWindowFeature(Window.FEATURE_ACTION_BAR); USE_ACTION_BAR = true; mBar = getActionBar(); } if (mBar != null) { if (Build.VERSION.SDK_INT >= 14) mBar.setHomeButtonEnabled(true); mBar.setDisplayUseLogoEnabled(true); try { mBar.setCustomView(R.layout.title_bar); mBar.setDisplayShowCustomEnabled(true); mBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); //ViewGroup cv = (ViewGroup)ab.getCustomView(); //if(cv.findViewById(R.id.title_paste) != null) // cv.removeView(cv.findViewById(R.id.title_paste)); //ab.getCustomView().findViewById(R.id.title_icon).setVisibility(View.GONE); } catch (InflateException e) { Logger.LogWarning("Couldn't set up ActionBar custom view", e); } } else USE_ACTION_BAR = false; OpenFile.setTempFileRoot(new OpenFile(getFilesDir()).getChild("temp")); setupLoggingDb(); handleExceptionHandler(); getMimeTypes(); setupFilesDb(); super.onCreate(savedInstanceState); setContentView(R.layout.main_fragments); getWindow().setBackgroundDrawableResource(R.drawable.background_holo_dark); try { upgradeViewSettings(); } catch (Exception e) { } //try { showWarnings(); //} catch(Exception e) { } mEvHandler.setUpdateListener(this); getClipboard().setClipboardUpdateListener(this); try { /* Signature[] sigs = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_SIGNATURES).signatures; for(Signature sig : sigs) if(sig.toCharsString().indexOf("4465627567") > -1) // check for "Debug" in signature IS_DEBUG_BUILD = true; */ if (IS_DEBUG_BUILD) IS_DEBUG_BUILD = (getPackageManager().getActivityInfo(getComponentName(), PackageManager.GET_META_DATA).applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) == ApplicationInfo.FLAG_DEBUGGABLE; if (isBlackBerry()) IS_DEBUG_BUILD = false; } catch (NameNotFoundException e1) { } handleNetworking(); refreshCursors(); checkWelcome(); checkRoot(); if (!BEFORE_HONEYCOMB) { boolean show_underline = true; if (Build.VERSION.SDK_INT < 14) show_underline = isGTV(); else if (getResources().getBoolean(R.bool.large)) // ICS+ tablets show_underline = false; if (Build.VERSION.SDK_INT > 13 && !getResources().getBoolean(R.bool.large)) show_underline = true; View tu = findViewById(R.id.title_underline); if (tu != null && !show_underline) { getActionBar().setBackgroundDrawable(getResources().getDrawable(R.drawable.actionbar_shadow)); tu.setVisibility(View.GONE); } //if(USE_ACTION_BAR) // setViewVisibility(false, false, R.id.title_bar, R.id.title_underline, R.id.title_underline_2); } if (BEFORE_HONEYCOMB || !USE_ACTION_BAR) ViewUtils.inflateView(this, R.id.title_stub); if (BEFORE_HONEYCOMB) ViewUtils.inflateView(this, R.id.base_stub); setViewVisibility(false, false, R.id.title_paste, R.id.title_ops, R.id.title_log); setOnClicks(R.id.title_ops, //R.id.menu_global_ops_icon, R.id.menu_global_ops_text, R.id.title_log, R.id.title_icon, R.id.menu_more, R.id.title_paste_icon //,R.id.title_sort, R.id.title_view, R.id.title_up ); checkTitleSeparator(); IconContextMenu.clearInstances(); if (findViewById(R.id.list_frag) == null) mSinglePane = true; else if (findViewById(R.id.list_frag).getVisibility() == View.GONE) mSinglePane = true; Logger.LogDebug("Looking for path"); OpenPath path = mLastPath; if (savedInstanceState == null || path == null) { String start = getPreferences().getString("global", "pref_start", "External"); if (savedInstanceState != null && savedInstanceState.containsKey("last") && !savedInstanceState.getString("last").equals("")) start = savedInstanceState.getString("last"); path = FileManager.getOpenCache(start, this); } if (path == null) path = OpenFile.getExternalMemoryDrive(true); if (FileManager.checkForNoMedia(path)) showToast(R.string.s_error_no_media, Toast.LENGTH_LONG); mLastPath = path; boolean bAddToStack = true; if (findViewById(R.id.content_pager_frame_stub) != null) ((ViewStub) findViewById(R.id.content_pager_frame_stub)).inflate(); Logger.LogDebug("Pager inflated"); if (fragmentManager == null) { fragmentManager = getSupportFragmentManager(); fragmentManager.addOnBackStackChangedListener(this); } mLogFragment = new LogViewerFragment(); FragmentTransaction ft = fragmentManager.beginTransaction(); Logger.LogDebug("Creating with " + path.getPath()); if (path instanceof OpenFile) new PeekAtGrandKidsTask().execute((OpenFile) path); initPager(); if (handleIntent(getIntent())) { path = mLastPath = null; bAddToStack = false; } if (mViewPager != null && mViewPagerAdapter != null && path != null) { //mViewPagerAdapter.add(mContentFragment); mLastPath = null; changePath(path, bAddToStack, true); setCurrentItem(mViewPagerAdapter.getCount() - 1, false); restoreOpenedEditors(); } else Logger.LogWarning("Nothing to show?!"); ft.commit(); invalidateOptionsMenu(); initBookmarkDropdown(); handleMediaReceiver(); if (!getPreferences().getBoolean("global", "pref_splash", false)) showSplashIntent(this, getPreferences().getString("global", "pref_start", "Internal")); }
From source file:com.polychrom.cordova.actionbar.ActionBarSherlock.java
@Override public boolean execute(final String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException { Log.d(TAG, "Execute ActionBarSherlock."); if (!plugin_actions.contains(action)) { Log.d(TAG, "ActionBarSherlock - does not contain " + action); return false; }/* ww w . j a v a 2 s . c o m*/ if ("isAvailable".equals(action)) { JSONObject result = new JSONObject(); result.put("value", ((SherlockActivity) cordova).getWindow().hasFeature(Window.FEATURE_ACTION_BAR)); callbackContext.success(result); return true; } final ActionBar bar = ((SherlockActivity) cordova).getSupportActionBar(); if (bar == null) { Log.d(TAG, "ActionBarSherlock bar is null."); Window window = ((SherlockActivity) cordova).getWindow(); if (!window.hasFeature(Window.FEATURE_ACTION_BAR)) { callbackContext .error("ActionBar feature not available, Window.FEATURE_ACTION_BAR must be enabled!"); } else { callbackContext.error("Failed to get ActionBar"); } return true; } if (menu == null) { Log.d(TAG, "ActionBarSherlock menu is null."); callbackContext.error("Options menu not initialised"); return true; } final StringBuffer error = new StringBuffer(); JSONObject result = new JSONObject(); if ("isShowing".equals(action)) { result.put("value", bar.isShowing()); } else if ("getHeight".equals(action)) { result.put("value", bar.getHeight()); } else if ("getDisplayOptions".equals(action)) { result.put("value", bar.getDisplayOptions()); } else if ("getNavigationMode".equals(action)) { result.put("value", bar.getNavigationMode()); } else if ("getSelectedNavigationItem".equals(action)) { result.put("value", bar.getSelectedNavigationIndex()); } else if ("getSubtitle".equals(action)) { result.put("value", bar.getSubtitle()); } else if ("getTitle".equals(action)) { result.put("value", bar.getTitle()); } else { ((SherlockActivity) cordova).runOnUiThread(new Runnable() { public JSONException exception = null; public void run() { try { Log.d(TAG, "ActionBarSherlock building the bar. Action: " + action); // This is a bit of a hack (should be specific to the request, not global) bases = new String[] { removeFilename(webView.getOriginalUrl()), removeFilename(webView.getUrl()) }; if ("show".equals(action)) { bar.show(); } else if ("hide".equals(action)) { bar.hide(); } else if ("setMenu".equals(action)) { if (args.isNull(0)) { error.append("menu can not be null"); return; } menu_definition = args.getJSONArray(0); ((SherlockActivity) cordova).invalidateOptionsMenu(); } else if ("setTabs".equals(action)) { if (args.isNull(0)) { error.append("menu can not be null"); return; } bar.removeAllTabs(); tab_callbacks.clear(); if (!buildTabs(bar, args.getJSONArray(0))) { error.append("Invalid tab bar definition"); } } else if ("setDisplayHomeAsUpEnabled".equals(action)) { if (args.isNull(0)) { error.append("showHomeAsUp can not be null"); return; } bar.setDisplayHomeAsUpEnabled(args.getBoolean(0)); } else if ("setDisplayOptions".equals(action)) { if (args.isNull(0)) { error.append("options can not be null"); return; } final int options = args.getInt(0); bar.setDisplayOptions(options); } else if ("setDisplayShowHomeEnabled".equals(action)) { if (args.isNull(0)) { error.append("showHome can not be null"); return; } bar.setDisplayShowHomeEnabled(args.getBoolean(0)); } else if ("setDisplayShowTitleEnabled".equals(action)) { if (args.isNull(0)) { error.append("showTitle can not be null"); return; } bar.setDisplayShowTitleEnabled(args.getBoolean(0)); } else if ("setDisplayUseLogoEnabled".equals(action)) { if (args.isNull(0)) { error.append("useLogo can not be null"); return; } bar.setDisplayUseLogoEnabled(args.getBoolean(0)); } else if ("setHomeButtonEnabled".equals(action)) { if (args.isNull(0)) { error.append("enabled can not be null"); return; } bar.setHomeButtonEnabled(args.getBoolean(0)); } else if ("setIcon".equals(action)) { if (args.isNull(0)) { error.append("icon can not be null"); return; } Drawable drawable = getDrawableForURI(args.getString(0)); bar.setIcon(drawable); } else if ("setListNavigation".equals(action)) { JSONArray items = null; if (args.isNull(0) == false) { items = args.getJSONArray(0); } navigation_adapter.setItems(items); bar.setListNavigationCallbacks(navigation_adapter, navigation_listener); } else if ("setLogo".equals(action)) { if (args.isNull(0)) { error.append("logo can not be null"); return; } Drawable drawable = getDrawableForURI(args.getString(0)); bar.setLogo(drawable); } else if ("setNavigationMode".equals(action)) { if (args.isNull(0)) { error.append("mode can not be null"); return; } final int mode = args.getInt(0); bar.setNavigationMode(mode); } else if ("setSelectedNavigationItem".equals(action)) { if (args.isNull(0)) { error.append("position can not be null"); return; } bar.setSelectedNavigationItem(args.getInt(0)); } else if ("setSubtitle".equals(action)) { if (args.isNull(0)) { error.append("subtitle can not be null"); return; } bar.setSubtitle(args.getString(0)); } else if ("setTitle".equals(action)) { if (args.isNull(0)) { error.append("title can not be null"); return; } bar.setTitle(args.getString(0)); } } catch (JSONException e) { exception = e; } finally { if (exception != null) { callbackContext.error(exception.toString()); } else { callbackContext.success(); } } }; }); } return true; }
From source file:com.ywesee.amiko.MainActivity.java
/** * Overrides onCreate method/*from ww w . j av a2 s. c o m*/ */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try { AsyncLoadDBTask loadDBTask = new AsyncLoadDBTask(this); loadDBTask.execute(); } catch (Exception e) { Log.e(TAG, "AsyncLoadDBTask exception caught!"); } // Load CSS from asset folder if (Utilities.isTablet(this)) mCSS_str = Utilities.loadFromAssetsFolder(this, "amiko_stylesheet.css", "UTF-8"); else mCSS_str = Utilities.loadFromAssetsFolder(this, "amiko_stylesheet_phone.css", "UTF-8"); // Flag for enabling the Action Bar on top getWindow().requestFeature(Window.FEATURE_ACTION_BAR); // Enable overlay mode for action bar (no good, search results disappear behind it...) // getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); // Create action bar int mode = ActionBar.NAVIGATION_MODE_TABS; if (savedInstanceState != null) { mode = savedInstanceState.getInt("mode", ActionBar.NAVIGATION_MODE_TABS); } // Sets tab bar items addTabNavigation(); // Reset action name Log.d(TAG, "OnCreate -> " + mActionName); mActionName = getString(R.string.tab_name_1); /* 'getFilesDir' returns a java.io.File object representing the root directory of the INTERNAL storage four the application from the current context. */ mFavoriteData = new DataStore(this.getFilesDir().toString()); // Load hashset containing registration numbers from persistent data store mFavoriteMedsSet = new HashSet<String>(); mFavoriteMedsSet = mFavoriteData.load(); // Initialize preferences SharedPreferences settings = getSharedPreferences(AMIKO_PREFS_FILE, 0); long timeMillisSince1970 = 0; if (Constants.appLanguage().equals("de")) { timeMillisSince1970 = settings.getLong(PREF_DB_UPDATE_DATE_DE, 0); if (timeMillisSince1970 == 0) { SharedPreferences.Editor editor = settings.edit(); editor.putLong(PREF_DB_UPDATE_DATE_DE, System.currentTimeMillis()); // Commit the edits! editor.commit(); } } else if (Constants.appLanguage().equals("fr")) { timeMillisSince1970 = settings.getLong(PREF_DB_UPDATE_DATE_FR, 0); if (timeMillisSince1970 == 0) { SharedPreferences.Editor editor = settings.edit(); editor.putLong(PREF_DB_UPDATE_DATE_DE, System.currentTimeMillis()); // Commit the edits! editor.commit(); } } checkTimeSinceLastUpdate(); // Init toast object mToastObject = new CustomToast(this); // Initialize download manager mDownloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); mBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) { long downloadId = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, 0); if (downloadId == mDatabaseId || downloadId == mReportId || downloadId == mInteractionsId) mDownloadedFileCount++; // Before proceeding make sure all files have been downloaded before proceeding if (mDownloadedFileCount == 3) { Query query = new Query(); query.setFilterById(downloadId); Cursor c = mDownloadManager.query(query); if (c.moveToFirst()) { int columnIndex = c.getColumnIndex(DownloadManager.COLUMN_STATUS); // Check if download was successful if (DownloadManager.STATUS_SUCCESSFUL == c.getInt(columnIndex)) { try { // Update database AsyncUpdateDBTask updateDBTask = new AsyncUpdateDBTask(MainActivity.this); updateDBTask.execute(); } catch (Exception e) { Log.e(TAG, "AsyncUpdateDBTask: exception caught!"); } // Toast mToastObject.show("Databases downloaded successfully. Installing...", Toast.LENGTH_SHORT); if (mProgressBar.isShowing()) mProgressBar.dismiss(); mUpdateInProgress = false; // Store time stamp SharedPreferences settings = getSharedPreferences(AMIKO_PREFS_FILE, 0); SharedPreferences.Editor editor = settings.edit(); editor.putLong(PREF_DB_UPDATE_DATE_DE, System.currentTimeMillis()); // Commit the edits! editor.commit(); } else { mToastObject.show("Error while downloading database...", Toast.LENGTH_SHORT); } } c.close(); } } } }; registerReceiver(mBroadcastReceiver, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); }