Example usage for android.content Intent EXTRA_LOCAL_ONLY

List of usage examples for android.content Intent EXTRA_LOCAL_ONLY

Introduction

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

Prototype

String EXTRA_LOCAL_ONLY

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

Click Source Link

Document

Extra used to indicate that an intent should only return data that is on the local device.

Usage

From source file:com.frostwire.android.gui.StoragePicker.java

public static void show(Activity activity) {
    Intent intent = new Intent(ACTION_OPEN_DOCUMENT_TREE);
    intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
    intent.putExtra(EXTRA_SHOW_ADVANCED, true);
    activity.startActivityForResult(intent, SELECT_FOLDER_REQUEST_CODE);
}

From source file:com.github.chenxiaolong.dualbootpatcher.FileUtils.java

private static void setCommonNativeSafOptions(Intent intent) {
    // Avoid cloud providers since we need the C file descriptor for the file
    intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
    // Hack to show internal/external storage by default
    intent.putExtra("android.content.extra.SHOW_ADVANCED", true);
}

From source file:ca.ggolda.lendit.fragments.FragChat.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View v = inflater.inflate(R.layout.activity_chat, container, false);

    // Get UserID
    mFirebaseAuth = FirebaseAuth.getInstance();
    FirebaseUser user = mFirebaseAuth.getCurrentUser();
    UserID = user.getUid();//  w  w  w . java 2s .c o m
    mUsername = user.getDisplayName();

    mUsername = ANONYMOUS;

    mFirebaseDatabase = FirebaseDatabase.getInstance();

    mUsername = user.getDisplayName();

    mFirebaseStorage = FirebaseStorage.getInstance();

    mMessagesDatabaseReference = mFirebaseDatabase.getReference().child("messages");
    mChatPhotosStorageReference = mFirebaseStorage.getReference().child("chat_photos");

    // Initialize references to views
    mProgressBar = (ProgressBar) v.findViewById(R.id.progressBar);
    mMessageListView = (ListView) v.findViewById(R.id.messageListView);
    mPhotoPickerButton = (ImageButton) v.findViewById(R.id.photoPickerButton);
    mMessageEditText = (EditText) v.findViewById(R.id.messageEditText);
    mSendButton = (Button) v.findViewById(R.id.sendButton);

    // Initialize message ListView and its adapter
    List<InstanceMessage> friendlyMessages = new ArrayList<>();
    mMessageAdapter = new AdapterMessages(getContext(), R.layout.message_slide, friendlyMessages);
    mMessageListView.setAdapter(mMessageAdapter);

    // Initialize progress bar
    mProgressBar.setVisibility(ProgressBar.INVISIBLE);

    // ImagePickerButton shows an image picker to upload a image for a message
    mPhotoPickerButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
            intent.setType("image/jpeg");
            intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
            startActivityForResult(Intent.createChooser(intent, "Complete action using"), RC_PHOTO_PICKER);
        }
    });

    // Enable Send button when there's text to send
    mMessageEditText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            if (charSequence.toString().trim().length() > 0) {
                mSendButton.setEnabled(true);
            } else {
                mSendButton.setEnabled(false);
            }
        }

        @Override
        public void afterTextChanged(Editable editable) {
        }
    });
    mMessageEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(DEFAULT_MSG_LENGTH_LIMIT) });

    // Send button sends a message and clears the EditText
    mSendButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            // TODO: Send messages on click

            InstanceMessage friendlyMessage = new InstanceMessage(mMessageEditText.getText().toString(),
                    mUsername, null);

            mMessagesDatabaseReference.push().setValue(friendlyMessage);

            // Clear input box
            mMessageEditText.setText("");
        }
    });

    mChildEventListener = new ChildEventListener() {
        @Override
        public void onChildAdded(DataSnapshot dataSnapshot, String s) {
            InstanceMessage friendlyMessage = dataSnapshot.getValue(InstanceMessage.class);
            mMessageAdapter.add(friendlyMessage);
        }

        @Override
        public void onChildChanged(DataSnapshot dataSnapshot, String s) {
        }

        @Override
        public void onChildRemoved(DataSnapshot dataSnapshot) {
        }

        @Override
        public void onChildMoved(DataSnapshot dataSnapshot, String s) {
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
        }
    };
    mMessagesDatabaseReference.addChildEventListener(mChildEventListener);

    mAuthStateListener = new FirebaseAuth.AuthStateListener() {
        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {

            FirebaseUser user = firebaseAuth.getCurrentUser();
            if (user != null) {
                //user signed in
                OnSignedInInitialise(user.getDisplayName());
            } else {
                //user signed out
                OnSignedOutCleanUp();
                startActivityForResult(
                        AuthUI.getInstance().createSignInIntentBuilder()
                                .setProviders(AuthUI.EMAIL_PROVIDER, AuthUI.GOOGLE_PROVIDER).build(),
                        RC_SIGN_IN);
            }

        }
    };

    return v;
}

From source file:com.chess.genesis.activity.GameListLocalFrag.java

@Override
public boolean onOptionsItemSelected(final MenuItem item) {
    switch (item.getItemId()) {
    case R.id.new_game:
        new NewLocalGameDialog(act, handle).show();
        break;/*w ww .ja v a  2  s . c  om*/
    case R.id.import_game:
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent = intent.addCategory(Intent.CATEGORY_OPENABLE).setType("text/*");
        intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
        try {
            startActivityForResult(intent, Enums.IMPORT_GAME);
        } catch (final ActivityNotFoundException e) {
            Toast.makeText(act, "No File Manager Installed", Toast.LENGTH_LONG).show();
        }
        break;
    default:
        return super.onOptionsItemSelected(item);
    }
    return true;
}

From source file:com.dropbox.android.sample.DBRoulette.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    /*//api 23 target sdk versionapi 23?? ?
            int permission = ActivityCompat.checkSelfPermission(this, WRITE_EXTERNAL_STORAGE);
            if (permission != PackageManager.PERMISSION_GRANTED) {
    // ??//w w  w  . j  a  va2s  .co m
    ActivityCompat.requestPermissions(
            this,
            new String[] {WRITE_EXTERNAL_STORAGE, READ_EXTERNAL_STORAGE},
            REQUEST_EXTERNAL_STORAGE
    );
            }else{
    //??
            
            }
    */
    //============= ?==================================
    // We create a new AuthSession so that we can use the Dropbox API.
    AndroidAuthSession session = buildSession();
    mApi = new DropboxAPI<AndroidAuthSession>(session);
    checkAppKeySetup();
    operations = new DropboxAccess(this, mApi);
    //======================================================

    // Basic Android widgets
    setContentView(R.layout.main);

    mSubmit = (Button) findViewById(R.id.auth_button);

    mSubmit.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            // This logs you out if you're logged in, or vice versa
            if (mLoggedIn) {
                logOut();
            } else {
                // Start the remote authentication
                if (USE_OAUTH1) {
                    mApi.getSession().startAuthentication(DBRoulette.this);
                } else {
                    mApi.getSession().startOAuth2Authentication(DBRoulette.this);
                }
            }
        }
    });

    mDisplay = (LinearLayout) findViewById(R.id.logged_in_display);

    // This is the button to upload file
    Button mUpload = (Button) findViewById(R.id.photo_button);

    mUpload.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            final String mimeType = "application/x-sqlite3";
            final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
            intent.setType(mimeType);
            intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
            startActivityForResult(intent, CHOOSE_FILE);
        }
    });

    Button mShowDropboxFile = (Button) findViewById(R.id.list_button);
    mList = (ListView) findViewById(R.id.listView_dropbox);
    mShowDropboxFile.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            operations.ListRemoteFile(MyDropbox_DIR, mList);
        }
    });

    downloadList = (ListView) findViewById(R.id.listView_download);
    mList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
            String select = ((TextView) view).getText().toString();
            operations.DownloadFile(MyDropbox_DIR, downloadDir.getAbsolutePath(), select, downloadList);
        }
    });
    // Display the proper UI state if logged in or not
    setLoggedIn(mApi.getSession().isLinked());//,<<<==============================================

}

From source file:com.activiti.android.platform.provider.transfer.ContentTransferManager.java

public static final void requestCreateLocalContent(Fragment fr, String filename, String mimetype, File file) {

    if (AndroidVersion.isKitKatOrAbove()) {
        Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
        intent.addCategory(Intent.CATEGORY_OPENABLE);
        intent.setType(mimetype);/*w  w w .  ja  v a2 s . co m*/
        intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
        intent.putExtra(Intent.EXTRA_TITLE, filename);
        fr.startActivityForResult(intent, CREATE_REQUEST_CODE);
    } else {
        // Good question ? Send Intent ? File Picker ?
    }
}

From source file:com.brandroidtools.filemanager.activities.PickerActivity.java

/**
 * Method that displays a dialog with a {@link NavigationFragment} to select the
 * proposed file//w ww  .j  a va2s.c om
 */
private void init() {
    final boolean pickingDirectory;
    final Intent intent = getIntent();

    if (isFilePickIntent(intent)) {
        // ok
        Log.d(TAG, "PickerActivity: got file pick intent: " + String.valueOf(intent)); //$NON-NLS-1$
        pickingDirectory = false;
    } else if (isDirectoryPickIntent(getIntent())) {
        // ok
        Log.d(TAG, "PickerActivity: got folder pick intent: " + String.valueOf(intent)); //$NON-NLS-1$
        pickingDirectory = true;
    } else {
        Log.d(TAG, "PickerActivity got unrecognized intent: " + String.valueOf(intent)); //$NON-NLS-1$
        setResult(Activity.RESULT_CANCELED);
        finish();
        return;
    }

    // Display restrictions
    Map<DisplayRestrictions, Object> restrictions = new HashMap<DisplayRestrictions, Object>();
    //- Mime/Type restriction
    String mimeType = getIntent().getType();
    if (mimeType != null) {
        if (!MimeTypeHelper.isMimeTypeKnown(this, mimeType)) {
            Log.i(TAG, String.format("Mime type %s unknown, falling back to wildcard.", //$NON-NLS-1$
                    mimeType));
            mimeType = MimeTypeHelper.ALL_MIME_TYPES;
        }
        restrictions.put(DisplayRestrictions.MIME_TYPE_RESTRICTION, mimeType);
    }
    // Other restrictions
    Bundle extras = getIntent().getExtras();
    Log.d(TAG, "PickerActivity. extras: " + String.valueOf(extras)); //$NON-NLS-1$
    if (extras != null) {
        //-- File size
        if (extras.containsKey(android.provider.MediaStore.Audio.Media.EXTRA_MAX_BYTES)) {
            long size = extras.getLong(android.provider.MediaStore.Audio.Media.EXTRA_MAX_BYTES);
            restrictions.put(DisplayRestrictions.SIZE_RESTRICTION, Long.valueOf(size));
        }
        //-- Local filesystems only
        if (extras.containsKey(Intent.EXTRA_LOCAL_ONLY)) {
            boolean localOnly = extras.getBoolean(Intent.EXTRA_LOCAL_ONLY);
            restrictions.put(DisplayRestrictions.LOCAL_FILESYSTEM_ONLY_RESTRICTION, Boolean.valueOf(localOnly));
        }
    }
    if (pickingDirectory) {
        restrictions.put(DisplayRestrictions.DIRECTORY_ONLY_RESTRICTION, Boolean.TRUE);
    }

    // Create or use the console
    if (!initializeConsole()) {
        // Something when wrong. Display a message and exit
        DialogHelper.showToast(this, R.string.msgs_cant_create_console, Toast.LENGTH_SHORT);
        cancel();
        return;
    }

    // Create the root file
    this.mRootView = getLayoutInflater().inflate(R.layout.picker, null, false);
    this.mRootView.post(new Runnable() {
        @Override
        public void run() {
            measureHeight();
        }
    });

    // Breadcrumb
    Breadcrumb breadcrumb = (Breadcrumb) this.mRootView.findViewById(R.id.breadcrumb_view);
    // Set the free disk space warning level of the breadcrumb widget
    String fds = Preferences.getSharedPreferences().getString(
            FileManagerSettings.SETTINGS_DISK_USAGE_WARNING_LEVEL.getId(),
            (String) FileManagerSettings.SETTINGS_DISK_USAGE_WARNING_LEVEL.getDefaultValue());
    breadcrumb.setFreeDiskSpaceWarningLevel(Integer.parseInt(fds));

    // Navigation view
    this.mNavigationFragment = (NavigationFragment) getSupportFragmentManager()
            .findFragmentById(R.id.navigation_fragment);
    this.mNavigationFragment.setRestrictions(restrictions);
    this.mNavigationFragment.setOnFilePickedListener(this);
    this.mNavigationFragment.setOnDirectoryChangedListener(this);
    this.mNavigationFragment.setBreadcrumb(breadcrumb);

    // Apply the current theme
    applyTheme();

    // Create the dialog
    this.mDialog = DialogHelper.createDialog(this, R.drawable.ic_launcher,
            pickingDirectory ? R.string.directory_picker_title : R.string.picker_title, this.mRootView);

    this.mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dlg, int which) {
                    dlg.cancel();
                }
            });
    if (pickingDirectory) {
        this.mDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.select),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dlg, int which) {
                        PickerActivity.this.mFso = PickerActivity.this.mCurrentDirectory;
                        dlg.dismiss();
                    }
                });
    }
    this.mDialog.setCancelable(true);
    this.mDialog.setOnCancelListener(this);
    this.mDialog.setOnDismissListener(this);
    DialogHelper.delegateDialogShow(this, this.mDialog);

    // Set content description of storage volume button
    ButtonItem fs = (ButtonItem) this.mRootView.findViewById(R.id.ab_filesystem_info);
    fs.setContentDescription(getString(R.string.actionbar_button_storage_cd));

    final File initialDir = getInitialDirectoryFromIntent(getIntent());
    final String rootDirectory;

    if (initialDir != null) {
        rootDirectory = initialDir.getAbsolutePath();
    } else {
        rootDirectory = FileHelper.ROOT_DIRECTORY;
    }

    this.mHandler = new Handler();
    this.mHandler.post(new Runnable() {
        @Override
        public void run() {
            // Navigate to. The navigation view will redirect to the appropriate directory
            PickerActivity.this.mNavigationFragment.changeCurrentDir(rootDirectory);
        }
    });

}

From source file:org.lytsing.android.weibo.ui.ComposeActivity.java

@Override
public void onClick(View view) {
    int viewId = view.getId();

    if (viewId == android.R.id.home) {
        NavUtils.navigateUpFromSameTask(this);
        return;//w w  w  .  j  a v  a2 s.c  o  m
    }

    if (viewId == R.id.ll_text_limit_unit) {
        mContent = mEdit.getText().toString();
        if (TextUtils.isEmpty(mContent))
            return;

        DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                mEdit.setText("");
            }
        };

        AlertUtil.showAlert(this, R.string.attention, R.string.delete_all, getString(R.string.ok), listener,
                getString(R.string.cancel), null);
    } else if (viewId == R.id.ib_insert_pic) {
        PopupMenu popup = new PopupMenu(this, view);
        popup.getMenuInflater().inflate(R.menu.pic, popup.getMenu());

        popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
            public boolean onMenuItemClick(android.view.MenuItem item) {

                Intent galleryIntent = new Intent();
                galleryIntent.setType("image/*");
                galleryIntent.setAction(Intent.ACTION_GET_CONTENT);
                galleryIntent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
                startActivityForResult(galleryIntent, 2);

                return true;
            }
        });

        popup.show();
    } else if (viewId == R.id.ib_face_keyboard) {
        showOrHideIMM();
    } else if (viewId == R.id.ib_insert_location) {
        if (mIsLocation) {
            aq.id(R.id.tv_location).gone();
            aq.id(R.id.ib_insert_location).image(R.drawable.btn_insert_location_nor);
            mIsLocation = false;
            mLatitude = "";
            mLongitude = "";
        } else {
            aq.id(R.id.ly_loadlocation).visible();
            location_ajax();
        }
    }
}

From source file:com.android.documentsui.DocumentsActivity.java

private void buildDefaultState() {
    mState = new State();

    final Intent intent = getIntent();
    final String action = intent.getAction();
    if (Intent.ACTION_OPEN_DOCUMENT.equals(action)) {
        mState.action = ACTION_OPEN;/* w  w  w .  jav a 2  s .  c om*/
    } else if (Intent.ACTION_CREATE_DOCUMENT.equals(action)) {
        mState.action = ACTION_CREATE;
    } else if (Intent.ACTION_GET_CONTENT.equals(action)) {
        mState.action = ACTION_GET_CONTENT;
    } else if (DocumentsContract.ACTION_MANAGE_ROOT.equals(action)) {
        mState.action = ACTION_MANAGE;
    }

    if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT) {
        mState.allowMultiple = intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false);
    }

    if (mState.action == ACTION_MANAGE) {
        mState.acceptMimes = new String[] { "*/*" };
        mState.allowMultiple = true;
    } else if (intent.hasExtra(Intent.EXTRA_MIME_TYPES)) {
        mState.acceptMimes = intent.getStringArrayExtra(Intent.EXTRA_MIME_TYPES);
    } else {
        mState.acceptMimes = new String[] { intent.getType() };
    }

    mState.localOnly = intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, false);
    mState.forceAdvanced = intent.getBooleanExtra(DocumentsContract.EXTRA_SHOW_ADVANCED, false);
    mState.showAdvanced = mState.forceAdvanced | SettingsActivity.getDisplayAdvancedDevices(this);
}

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

private void buildDefaultState() {
    mState = new State();

    final Intent intent = virtualIntent;
    final String action = intent.getAction();
    if (Intent.ACTION_OPEN_DOCUMENT.equals(action)) {
        mState.action = ACTION_OPEN;//from   w  w  w  . j a va 2 s  .com
    } else if (Intent.ACTION_CREATE_DOCUMENT.equals(action)) {
        mState.action = ACTION_CREATE;
    } else if (Intent.ACTION_GET_CONTENT.equals(action)) {
        mState.action = ACTION_GET_CONTENT;
    } else if (DocumentsContract.ACTION_MANAGE_ROOT.equals(action)) {
        mState.action = ACTION_MANAGE;
    }

    if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT) {
        mState.allowMultiple = intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false);
    }

    if (mState.action == ACTION_MANAGE) {
        mState.acceptMimes = new String[] { "*/*" };
        mState.allowMultiple = true;
    } else if (intent.hasExtra(Intent.EXTRA_MIME_TYPES)) {
        mState.acceptMimes = intent.getStringArrayExtra(Intent.EXTRA_MIME_TYPES);
    } else {
        mState.acceptMimes = new String[] { intent.getType() };
    }

    mState.localOnly = intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, false);
    mState.forceAdvanced = intent.getBooleanExtra(DocumentsContract.EXTRA_SHOW_ADVANCED, false);
    mState.showAdvanced = mState.forceAdvanced | SettingsActivity.getDisplayAdvancedDevices(this);
}