Example usage for android.content Intent EXTRA_TITLE

List of usage examples for android.content Intent EXTRA_TITLE

Introduction

In this page you can find the example usage for android.content Intent EXTRA_TITLE.

Prototype

String EXTRA_TITLE

To view the source code for android.content Intent EXTRA_TITLE.

Click Source Link

Document

A CharSequence dialog title to provide to the user when used with a #ACTION_CHOOSER .

Usage

From source file:ca.rmen.android.poetassistant.main.reader.ReaderFragment.java

@TargetApi(Build.VERSION_CODES.KITKAT)
private void saveAs() {
    Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType("text/plain");
    PoemFile poemFile = mPoemPrefs.getSavedPoem();
    final String fileName;
    if (poemFile != null) {
        fileName = poemFile.name;/*from   ww w  .j a v a2s . c o  m*/
    } else {
        fileName = PoemFile.generateFileName(mBinding.tvText.getText().toString());
    }
    if (!TextUtils.isEmpty(fileName))
        intent.putExtra(Intent.EXTRA_TITLE, fileName);
    startActivityForResult(intent, ACTION_FILE_SAVE_AS);
}

From source file:net.abcdroid.devfest12.ui.SessionsFragment.java

@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) {
    if (getActivity() == null) {
        return;//from   w w  w  . ja  v  a  2  s  .co  m
    }

    int token = loader.getId();
    if (token == SessionsQuery._TOKEN || token == SearchQuery._TOKEN) {
        mAdapter.changeCursor(cursor);
        Bundle arguments = getArguments();

        if (arguments != null && arguments.containsKey("_uri")) {
            String uri = arguments.get("_uri").toString();

            if (uri != null && uri.contains("blocks")) {
                String title = arguments.getString(Intent.EXTRA_TITLE);
                if (title == null) {
                    title = (String) this.getActivity().getTitle();
                }
                EasyTracker.getTracker().trackView("Session Block: " + title);
                LOGD("Tracker", "Session Block: " + title);
            }
        }
    } else {
        LOGD(TAG, "Query complete, Not Actionable: " + token);
        cursor.close();
    }
}

From source file:cn.edu.wyu.documentviewer.DocumentsActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    mRoots = DocumentsApplication.getRootsCache(this);

    virtualIntent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
    virtualIntent.addCategory(Intent.CATEGORY_OPENABLE);
    virtualIntent.setType("*/*");
    virtualIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);

    setResult(Activity.RESULT_CANCELED);
    setContentView(R.layout.activity);/*www . java 2 s. c om*/

    final Resources res = getResources();
    mShowAsDialog = res.getBoolean(R.bool.show_as_dialog);

    if (mShowAsDialog) {
        // backgroundDimAmount from theme isn't applied; do it manually
        final WindowManager.LayoutParams a = getWindow().getAttributes();
        a.dimAmount = 0.6f;
        getWindow().setAttributes(a);

        getWindow().setFlags(0, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
        getWindow().setFlags(~0, WindowManager.LayoutParams.FLAG_DIM_BEHIND);

        // Inset ourselves to look like a dialog
        final Point size = new Point();
        getWindowManager().getDefaultDisplay().getSize(size);

        final int width = (int) res.getFraction(R.dimen.dialog_width, size.x, size.x);
        final int height = (int) res.getFraction(R.dimen.dialog_height, size.y, size.y);
        final int insetX = (size.x - width) / 2;
        final int insetY = (size.y - height) / 2;

        final Drawable before = getWindow().getDecorView().getBackground();
        final Drawable after = new InsetDrawable(before, insetX, insetY, insetX, insetY);
        getWindow().getDecorView().setBackground(after);

        // Dismiss when touch down in the dimmed inset area
        getWindow().getDecorView().setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_DOWN) {
                    final float x = event.getX();
                    final float y = event.getY();
                    if (x < insetX || x > v.getWidth() - insetX || y < insetY || y > v.getHeight() - insetY) {
                        finish();
                        return true;
                    }
                }
                return false;
            }
        });

    } else {
        // Non-dialog means we have a drawer
        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);

        mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer_glyph,
                R.string.drawer_open, R.string.drawer_close);

        mDrawerLayout.setDrawerListener(mDrawerListener);
        mDrawerLayout.setDrawerShadow(R.drawable.ic_drawer_shadow, GravityCompat.START);

        mRootsContainer = findViewById(R.id.container_roots);
    }

    mDirectoryContainer = (DirectoryContainerView) findViewById(R.id.container_directory);

    if (icicle != null) {
        mState = icicle.getParcelable(EXTRA_STATE);
    } else {
        if (DEBUG) {
            Log.i(TAG, "mState");
        }
        buildDefaultState();
    }

    // Hide roots when we're managing a specific root
    if (mState.action == ACTION_MANAGE) {
        if (mShowAsDialog) {
            findViewById(R.id.dialog_roots).setVisibility(View.GONE);
        } else {
            mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
        }
    }

    if (mState.action == ACTION_CREATE) {
        final String mimeType = virtualIntent.getType();
        final String title = virtualIntent.getStringExtra(Intent.EXTRA_TITLE);
        SaveFragment.show(getFragmentManager(), mimeType, title);
    }

    if (mState.action == ACTION_GET_CONTENT) {
        final Intent moreApps = new Intent(virtualIntent);
        moreApps.setComponent(null);
        moreApps.setPackage(null);
        RootsFragment.show(getFragmentManager(), moreApps);
    } else if (mState.action == ACTION_OPEN || mState.action == ACTION_CREATE) {
        RootsFragment.show(getFragmentManager(), null);
    }

    if (!mState.restored) {
        if (mState.action == ACTION_MANAGE) {
            final Uri rootUri = virtualIntent.getData();
            new RestoreRootTask(rootUri).executeOnExecutor(getCurrentExecutor());
        } else {
            new RestoreStackTask().execute();
        }
    } else {
        onCurrentDirectoryChanged(ANIM_NONE);
    }
}

From source file:org.fedorahosted.freeotp.MainActivity.java

private void createFile(String mimeType, String fileName) {
    Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);

    // Filter to only show results that can be "opened", such as
    // a file (as opposed to a list of contacts or timezones).
    intent.addCategory(Intent.CATEGORY_OPENABLE);

    // Create a file with the requested MIME type.
    intent.setType(mimeType);/*from   www . j  av  a 2  s .  c o m*/
    intent.putExtra(Intent.EXTRA_TITLE, fileName);
    startActivityForResult(intent, WRITE_REQUEST_CODE);
}

From source file:it.rignanese.leo.slimfacebook.MainActivity.java

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

    // setup the sharedPreferences
    savedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    //setup the theme
    //int savedThemeId = Integer.parseInt(savedPreferences.getString("pref_key_theme8", "2131361965"));//get the last saved theme id
    //setTheme(savedThemeId);//this refresh the theme if necessary
    // TODO fix the change of status bar

    setContentView(R.layout.activity_main);//load the layout

    // setup the refresh layout
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
    swipeRefreshLayout.setColorSchemeResources(R.color.officialBlueFacebook, R.color.darkBlueSlimFacebookTheme);// set the colors
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override// w  w w .ja v a2  s.  co  m
        public void onRefresh() {
            refreshPage();//reload the page
            swipeRefresh = true;
        }
    });

    // setup the webView
    webViewFacebook = (WebView) findViewById(R.id.webView);
    setUpWebViewDefaults(webViewFacebook);//set the settings

    goHome();//load homepage

    //WebViewClient that is the client callback.
    webViewFacebook.setWebViewClient(new WebViewClient() {//advanced set up

        // when there isn't a connetion
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            String summary = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /></head><body><h1 "
                    + "style='text-align:center; padding-top:15%;'>" + getString(R.string.titleNoConnection)
                    + "</h1> <h3 style='text-align:center; padding-top:1%; font-style: italic;'>"
                    + getString(R.string.descriptionNoConnection)
                    + "</h3>  <h5 style='text-align:center; padding-top:80%; opacity: 0.3;'>"
                    + getString(R.string.awards) + "</h5></body></html>";
            webViewFacebook.loadData(summary, "text/html; charset=utf-8", "utf-8");//load a custom html page

            noConnectionError = true;
            swipeRefreshLayout.setRefreshing(false); //when the page is loaded, stop the refreshing
        }

        // when I click in a external link
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (url == null || url.contains("facebook.com")) {
                //url is ok
                return false;
            } else {
                if (url.contains("https://scontent")) {
                    //TODO add the possibility to download and share directly

                    Toast.makeText(getApplicationContext(), getString(R.string.downloadOrShareWithBrowser),
                            Toast.LENGTH_LONG).show();
                    //TODO get bitmap from url
                    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                    startActivity(intent);
                    return true;
                }

                //if the link doesn't contain 'facebook.com', open it using the browser
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
                return true;
            }
        }

        //START management of loading
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            //TODO when I push on messages, open messanger
            //                if(url!=null){
            //                    if (url.contains("soft=messages") || url.contains("facebook.com/messages")) {
            //                        Toast.makeText(getApplicationContext(),"Open Messanger",
            //                                Toast.LENGTH_SHORT).show();
            //                        startActivity(new Intent(getPackageManager().getLaunchIntentForPackage("com.facebook.orca")));//messanger
            //                    }
            //                }

            // show you progress image
            if (!swipeRefresh) {
                final MenuItem refreshItem = optionsMenu.findItem(R.id.refresh);
                refreshItem.setActionView(R.layout.circular_progress_bar);
            }
            swipeRefresh = false;
            super.onPageStarted(view, url, favicon);
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            // hide your progress image
            final MenuItem refreshItem = optionsMenu.findItem(R.id.refresh);
            refreshItem.setActionView(null);
            super.onPageFinished(view, url);

            swipeRefreshLayout.setRefreshing(false); //when the page is loaded, stop the refreshing
        }
        //END management of loading

    });

    //WebChromeClient for handling all chrome functions.
    webViewFacebook.setWebChromeClient(new WebChromeClient() {
        //to upload files
        //thanks to gauntface
        //https://github.com/GoogleChrome/chromium-webview-samples
        public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback,
                WebChromeClient.FileChooserParams fileChooserParams) {
            if (mFilePathCallback != null) {
                mFilePathCallback.onReceiveValue(null);
            }
            mFilePathCallback = filePathCallback;

            Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            if (takePictureIntent.resolveActivity(getBaseContext().getPackageManager()) != null) {
                // Create the File where the photo should go
                File photoFile = null;
                try {
                    photoFile = createImageFile();
                    takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath);
                } catch (IOException ex) {
                    // Error occurred while creating the File
                }

                // Continue only if the File was successfully created
                if (photoFile != null) {
                    mCameraPhotoPath = "file:" + photoFile.getAbsolutePath();
                    takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
                } else {
                    takePictureIntent = null;
                }
            }

            Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
            contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
            contentSelectionIntent.setType("image/*");

            Intent[] intentArray;
            if (takePictureIntent != null) {
                intentArray = new Intent[] { takePictureIntent };
            } else {
                intentArray = new Intent[0];
            }

            Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
            chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
            chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser");
            chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);

            startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE);

            return true;
        }
    });
}

From source file:com.schoentoon.connectbot.HostEditorActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    getSupportActionBar().setSubtitle("Host editor");
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    long hostId = this.getIntent().getLongExtra(Intent.EXTRA_TITLE, -1);

    // TODO: we could pass through a specific ContentProvider uri here
    //this.getPreferenceManager().setSharedPreferencesName(uri);

    this.hostdb = new HostDatabase(this);
    this.pubkeydb = new PubkeyDatabase(this);

    host = hostdb.findHostById(hostId);/*w  w w .ja  v a2 s .  co m*/

    connection = new ServiceConnection() {
        public void onServiceConnected(ComponentName className, IBinder service) {
            TerminalManager bound = ((TerminalManager.TerminalBinder) service).getService();

            hostBridge = bound.getConnectedBridge(host);
        }

        public void onServiceDisconnected(ComponentName name) {
            hostBridge = null;
        }
    };

    this.pref = new CursorPreferenceHack(HostDatabase.TABLE_HOSTS, hostId);
    this.pref.registerOnSharedPreferenceChangeListener(this);

    this.addPreferencesFromResource(R.xml.host_prefs);

    // add all existing pubkeys to our listpreference for user to choose from
    // TODO: may be an issue here when this activity is recycled after adding a new pubkey
    // TODO: should consider moving into onStart, but we dont have a good way of resetting the listpref after filling once
    ListPreference pubkeyPref = (ListPreference) this.findPreference(HostDatabase.FIELD_HOST_PUBKEYID);

    List<CharSequence> pubkeyNicks = new LinkedList<CharSequence>(Arrays.asList(pubkeyPref.getEntries()));
    pubkeyNicks.addAll(pubkeydb.allValues(PubkeyDatabase.FIELD_PUBKEY_NICKNAME));
    pubkeyPref.setEntries(pubkeyNicks.toArray(new CharSequence[pubkeyNicks.size()]));

    List<CharSequence> pubkeyIds = new LinkedList<CharSequence>(Arrays.asList(pubkeyPref.getEntryValues()));
    pubkeyIds.addAll(pubkeydb.allValues("_id"));
    pubkeyPref.setEntryValues(pubkeyIds.toArray(new CharSequence[pubkeyIds.size()]));

    // Populate the character set encoding list with all available
    final ListPreference charsetPref = (ListPreference) findPreference(HostDatabase.FIELD_HOST_ENCODING);

    if (CharsetHolder.isInitialized()) {
        initCharsetPref(charsetPref);
    } else {
        String[] currentCharsetPref = new String[1];
        currentCharsetPref[0] = charsetPref.getValue();
        charsetPref.setEntryValues(currentCharsetPref);
        charsetPref.setEntries(currentCharsetPref);

        new Thread(new Runnable() {
            public void run() {
                initCharsetPref(charsetPref);
            }
        }).start();
    }

    this.updateSummaries();
}

From source file:ar.com.tristeslostrestigres.diasporanativewebapp.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    progressBar = findViewById(R.id.progressBar);

    pm = new PrefManager(MainActivity.this);

    SharedPreferences config = getSharedPreferences("PodSettings", MODE_PRIVATE);
    podDomain = config.getString("podDomain", null);

    fab = findViewById(R.id.multiple_actions);
    fab.setVisibility(View.GONE);

    Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//  w w  w  . j ava  2s  .  co  m
    getSupportActionBar().setTitle(null);

    txtTitle = (TextView) findViewById(R.id.toolbar_title);
    txtTitle.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (Helpers.isOnline(MainActivity.this)) {
                txtTitle.setText(R.string.jb_stream);
                webView.loadUrl("https://" + podDomain + "/stream");
            } else {
                Snackbar.make(v, R.string.no_internet, Snackbar.LENGTH_SHORT).show();
            }
        }
    });

    webView = findViewById(R.id.webView);
    webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
    webView.addJavascriptInterface(new JavaScriptInterface(), "NotificationCounter");

    if (savedInstanceState != null) {
        webView.restoreState(savedInstanceState);
    }

    wSettings = webView.getSettings();
    wSettings.setJavaScriptEnabled(true);
    wSettings.setUseWideViewPort(true);
    wSettings.setLoadWithOverviewMode(true);
    wSettings.setDomStorageEnabled(true);
    wSettings.setMinimumFontSize(pm.getMinimumFontSize());
    wSettings.setLoadsImagesAutomatically(pm.getLoadImages());

    if (android.os.Build.VERSION.SDK_INT >= 21)
        wSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);

    /*
     * WebViewClient
     */
    webView.setWebViewClient(new WebViewClient() {
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (!url.contains(podDomain)) {
                Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                startActivity(i);
                return true;
            }
            return false;
        }

        public void onPageFinished(WebView view, String url) {
            if (url.contains("/new") || url.contains("/sign_in")) {
                fab.setVisibility(View.GONE);
            } else {
                fab.setVisibility(View.VISIBLE);
            }
        }

        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            new AlertDialog.Builder(MainActivity.this).setIcon(android.R.drawable.ic_dialog_alert)
                    .setMessage(description).setPositiveButton("CLOSE", null).show();
        }
    });

    /*
     * WebChromeClient
     */
    webView.setWebChromeClient(new WebChromeClient() {

        public void onProgressChanged(WebView wv, int progress) {
            progressBar.setProgress(progress);

            if (progress > 0 && progress <= 60) {
                Helpers.getNotificationCount(wv);
            }

            if (progress > 60) {
                Helpers.hideTopBar(wv);
                fab.setVisibility(View.VISIBLE);
            }

            if (progress == 100) {
                fab.collapse();
                progressBar.setVisibility(View.GONE);
            } else {
                progressBar.setVisibility(View.VISIBLE);
            }
        }

        @Override
        public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback,
                FileChooserParams fileChooserParams) {
            if (mFilePathCallback != null)
                mFilePathCallback.onReceiveValue(null);

            mFilePathCallback = filePathCallback;

            Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
                // Create the File where the photo should go
                File photoFile = null;
                try {
                    photoFile = createImageFile();
                    takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath);
                } catch (IOException ex) {
                    // Error occurred while creating the File
                    Snackbar.make(getWindow().findViewById(R.id.drawer), "Unable to get image",
                            Snackbar.LENGTH_SHORT).show();
                }

                // Continue only if the File was successfully created
                if (photoFile != null) {
                    mCameraPhotoPath = "file:" + photoFile.getAbsolutePath();
                    takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
                } else {
                    takePictureIntent = null;
                }
            }

            Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
            contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
            contentSelectionIntent.setType("image/*");

            Intent[] intentArray;
            if (takePictureIntent != null) {
                intentArray = new Intent[] { takePictureIntent };
            } else {
                intentArray = new Intent[0];
            }

            Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
            chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
            chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser");
            chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);

            startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE);

            return true;
        }

        public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
            return super.onJsAlert(view, url, message, result);
        }
    });

    /*
     * NavigationView
     */
    NavigationView navigationView = findViewById(R.id.navigation_view);
    navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
            if (menuItem.isChecked())
                menuItem.setChecked(false);
            else
                menuItem.setChecked(true);

            drawerLayout.closeDrawers();

            switch (menuItem.getItemId()) {
            default:
                Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet,
                        Snackbar.LENGTH_SHORT).show();
                return true;

            case R.id.jb_stream:
                if (Helpers.isOnline(MainActivity.this)) {
                    txtTitle.setText(R.string.jb_stream);
                    webView.loadUrl("https://" + podDomain + "/stream");
                    return true;
                } else {
                    Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet,
                            Snackbar.LENGTH_SHORT).show();
                    return false;
                }

            case R.id.jb_public:
                setTitle(R.string.jb_public);
                if (Helpers.isOnline(MainActivity.this)) {
                    webView.loadUrl("https://" + podDomain + "/public");
                    return true;
                } else {
                    Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet,
                            Snackbar.LENGTH_SHORT).show();
                    return false;
                }

            case R.id.jb_liked:
                txtTitle.setText(R.string.jb_liked);
                if (Helpers.isOnline(MainActivity.this)) {
                    webView.loadUrl("https://" + podDomain + "/liked");
                    return true;
                } else {
                    Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet,
                            Snackbar.LENGTH_SHORT).show();
                    return false;
                }

            case R.id.jb_commented:
                txtTitle.setText(R.string.jb_commented);
                if (Helpers.isOnline(MainActivity.this)) {
                    webView.loadUrl("https://" + podDomain + "/commented");
                    return true;
                } else {
                    Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet,
                            Snackbar.LENGTH_SHORT).show();
                    return false;
                }

            case R.id.jb_contacts:
                txtTitle.setText(R.string.jb_contacts);
                if (Helpers.isOnline(MainActivity.this)) {
                    webView.loadUrl("https://" + podDomain + "/contacts");
                    return true;
                } else {
                    Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet,
                            Snackbar.LENGTH_SHORT).show();
                    return false;
                }

            case R.id.jb_mentions:
                txtTitle.setText(R.string.jb_mentions);
                if (Helpers.isOnline(MainActivity.this)) {
                    webView.loadUrl("https://" + podDomain + "/mentions");
                    return true;
                } else {
                    Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet,
                            Snackbar.LENGTH_SHORT).show();
                    return false;
                }

            case R.id.jb_activities:
                txtTitle.setText(R.string.jb_activities);
                if (Helpers.isOnline(MainActivity.this)) {
                    webView.loadUrl("https://" + podDomain + "/activity");
                    return true;
                } else {
                    Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet,
                            Snackbar.LENGTH_SHORT).show();
                    return false;
                }

            case R.id.jb_followed_tags:
                txtTitle.setText(R.string.jb_followed_tags);
                if (Helpers.isOnline(MainActivity.this)) {
                    webView.loadUrl("https://" + podDomain + "/followed_tags");
                    return true;
                } else {
                    Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet,
                            Snackbar.LENGTH_SHORT).show();
                    return false;
                }

            case R.id.jb_manage_tags:

                txtTitle.setText(R.string.jb_manage_tags);
                if (Helpers.isOnline(MainActivity.this)) {
                    webView.loadUrl("https://" + podDomain + "/tag_followings/manage");
                    return true;
                } else {
                    Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet,
                            Snackbar.LENGTH_SHORT).show();
                    return false;
                }

            case R.id.jb_license:
                txtTitle.setText(R.string.jb_license);
                new AlertDialog.Builder(MainActivity.this).setTitle(getString(R.string.license_title))
                        .setMessage(getString(R.string.license_text))
                        .setPositiveButton(getString(R.string.license_yes),
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {
                                        Intent i = new Intent(Intent.ACTION_VIEW,
                                                Uri.parse("https://github.com/mdev88/Diaspora-Native-WebApp"));
                                        startActivity(i);
                                        dialog.cancel();
                                    }
                                })
                        .setNegativeButton(getString(R.string.license_no),
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {
                                        dialog.cancel();
                                    }
                                })
                        .show();

                return true;

            case R.id.jb_aspects:
                txtTitle.setText(R.string.jb_aspects);
                if (Helpers.isOnline(MainActivity.this)) {
                    webView.loadUrl("https://" + podDomain + "/aspects");
                    return true;
                } else {
                    Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet,
                            Snackbar.LENGTH_SHORT).show();
                    return false;
                }

            case R.id.jb_settings:
                txtTitle.setText(R.string.jb_settings);
                if (Helpers.isOnline(MainActivity.this)) {
                    webView.loadUrl("https://" + podDomain + "/user/edit");
                    return true;
                } else {
                    Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet,
                            Snackbar.LENGTH_SHORT).show();

                    return false;
                }

            case R.id.jb_pod:
                txtTitle.setText(R.string.jb_pod);
                if (Helpers.isOnline(MainActivity.this)) {
                    new AlertDialog.Builder(MainActivity.this).setTitle(getString(R.string.confirmation))
                            .setMessage(getString(R.string.change_pod_warning))
                            .setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
                                @TargetApi(11)
                                public void onClick(DialogInterface dialog, int id) {
                                    webView.clearCache(true);
                                    dialog.cancel();
                                    Intent i = new Intent(MainActivity.this, PodsActivity.class);
                                    startActivity(i);
                                    finish();
                                }
                            }).setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
                                @TargetApi(11)
                                public void onClick(DialogInterface dialog, int id) {
                                    dialog.cancel();
                                }
                            }).show();
                    return true;
                } else {
                    Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet,
                            Snackbar.LENGTH_SHORT).show();
                    return false;
                }
            }
        }
    });

    /*
     * DrawerLayout
     */
    drawerLayout = findViewById(R.id.drawer);
    ActionBarDrawerToggle actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar,
            R.string.openDrawer, R.string.closeDrawer);
    drawerLayout.setDrawerListener(actionBarDrawerToggle);
    //calling sync state is necessary or else your hamburger icon wont show up
    actionBarDrawerToggle.syncState();

    if (savedInstanceState == null) {
        if (Helpers.isOnline(MainActivity.this)) {
            webView.loadData("", "text/html", null);
            webView.loadUrl("https://" + podDomain);
        } else {
            Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet, Snackbar.LENGTH_SHORT)
                    .show();
        }
    }

}

From source file:de.schildbach.wallet.ui.backup.BackupWalletDialogFragment.java

private void backupWallet() {
    passwordView.setEnabled(false);/*from w w w.  j  a v a  2 s .  c  o m*/
    passwordAgainView.setEnabled(false);

    final DateFormat dateFormat = Iso8601Format.newDateFormat();
    dateFormat.setTimeZone(TimeZone.getDefault());

    final StringBuilder filename = new StringBuilder(Constants.Files.EXTERNAL_WALLET_BACKUP);
    filename.append('-');
    filename.append(dateFormat.format(new Date()));

    final Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType(Constants.MIMETYPE_WALLET_BACKUP);
    intent.putExtra(Intent.EXTRA_TITLE, filename.toString());
    startActivityForResult(intent, REQUEST_CODE_CREATE_DOCUMENT);
}

From source file:org.gnucash.android.test.ui.AccountsActivityTest.java

public void testIntentAccountCreation() {
    Intent intent = new Intent(Intent.ACTION_INSERT);
    intent.putExtra(Intent.EXTRA_TITLE, "Intent Account");
    intent.putExtra(Intent.EXTRA_UID, "intent-account");
    intent.putExtra(Account.EXTRA_CURRENCY_CODE, "EUR");
    intent.setType(Account.MIME_TYPE);//  ww w  . ja v  a  2 s . c  om
    getActivity().sendBroadcast(intent);

    //give time for the account to be created
    synchronized (mSolo) {
        try {
            mSolo.wait(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    AccountsDbAdapter dbAdapter = new AccountsDbAdapter(getActivity());
    Account account = dbAdapter.getAccount("intent-account");
    dbAdapter.close();
    assertNotNull(account);
    assertEquals("Intent Account", account.getName());
    assertEquals("intent-account", account.getUID());
    assertEquals("EUR", account.getCurrency().getCurrencyCode());
}

From source file:nl.endran.scrumpoker.MainActivity.java

private void shareApp() {
    tracking.logShare(new ShareEvent());
    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_TITLE, getString(R.string.app_name));
    sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name));
    sendIntent.putExtra(Intent.EXTRA_TEXT,
            "Hey check out this awesome Scrum Poker app at: https://play.google.com/store/apps/details?id=nl.endran.scrumpoker");
    sendIntent.setType("text/plain");
    startActivity(sendIntent);//from  ww w .j  a  va2  s  .  c  o  m
}