List of usage examples for android.content Intent ACTION_OPEN_DOCUMENT
String ACTION_OPEN_DOCUMENT
To view the source code for android.content Intent ACTION_OPEN_DOCUMENT.
Click Source Link
From source file:android_network.hetnet.vpn_service.ActivitySettings.java
private Intent getIntentOpenExport() { Intent intent;//from w w w.j a va2 s . co m if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) intent = new Intent(Intent.ACTION_GET_CONTENT); else intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("*/*"); // text/xml return intent; }
From source file:org.totschnig.myexpenses.util.Utils.java
@SuppressLint("InlinedApi") public static String getContentIntentAction() { return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT ? Intent.ACTION_OPEN_DOCUMENT : Intent.ACTION_GET_CONTENT; }
From source file:android_network.hetnet.vpn_service.ActivitySettings.java
private Intent getIntentOpenHosts() { Intent intent;/* www . ja v a2s . c om*/ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) intent = new Intent(Intent.ACTION_GET_CONTENT); else intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("*/*"); // text/plain return intent; }
From source file:com.maskyn.fileeditorpro.activity.MainActivity.java
public void OpenFile(View view) { if (Device.hasKitKatApi() && PreferenceHelper.getUseStorageAccessFramework(this)) { // ACTION_OPEN_DOCUMENT is the intent to choose a file via the system's file // browser. Intent intent = new Intent(Intent.ACTION_OPEN_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); // Filter to show only images, using the image MIME data type. // If one wanted to search for ogg vorbis files, the type would be "audio/ogg". // To search for all documents available via installed storage providers, // it would be "*/*". intent.setType("*/*");/* w w w .j av a 2 s . c o m*/ startActivityForResult(intent, READ_REQUEST_CODE); } else { Intent subActivity = new Intent(MainActivity.this, SelectFileActivity.class); subActivity.putExtra("action", SelectFileActivity.Actions.SelectFile); AnimationUtils.startActivityWithScale(this, subActivity, true, SELECT_FILE_CODE, view); } }
From source file:org.appspot.apprtc.CallActivity.java
void handleIntent(Intent intent) { if (intent == null || intent.getAction() == null) { return;//w w w . j av a 2 s .c o m } if (intent.hasExtra(WebsocketService.EXTRA_ADDRESS)) { mServer = intent.getStringExtra(WebsocketService.EXTRA_ADDRESS); } if (intent.getAction().equals(ACTION_SHARE_FILE)) { User user = (User) intent.getSerializableExtra(WebsocketService.EXTRA_USER); mFileRecipient = user.Id; Intent i; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { i = new Intent(); i.setAction(Intent.ACTION_GET_CONTENT); i.setType("*/*"); } else { i = new Intent(Intent.ACTION_OPEN_DOCUMENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.addFlags(Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION); i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); i.setType("*/*"); } startActivityForResult(i, FILE_CODE); } else if (intent.getAction().equals(ACTION_HANG_UP)) { User user = (User) intent.getSerializableExtra(WebsocketService.EXTRA_USER); if (mAdditionalPeers.containsKey(user.Id)) { mAdditionalPeers.get(user.Id).getRemoteViews().setId(""); updateRemoteViewList(mAdditionalPeers.get(user.Id).getRemoteViews()); mAdditionalPeers.get(user.Id).close(); mAdditionalPeers.remove(user.Id); } else if (mPeerId.equals(user.Id)) { onCallHangUp(); } } else if (intent.getAction().equals(ACTION_TOGGLE_VIDEO)) { User user = (User) intent.getSerializableExtra(WebsocketService.EXTRA_USER); boolean enabled = intent.getBooleanExtra(CallActivity.EXTRA_VIDEO_CALL, true); if (mAdditionalPeers.containsKey(user.Id)) { mAdditionalPeers.get(user.Id).setVideoEnabled(enabled); } else if (mPeerId.equals(user.Id)) { onToggleVideo(); } } else if (intent.getAction().equals(ACTION_TOGGLE_MIC)) { User user = (User) intent.getSerializableExtra(WebsocketService.EXTRA_USER); boolean enabled = intent.getBooleanExtra(CallActivity.EXTRA_MIC_ENABLED, true); if (mAdditionalPeers.containsKey(user.Id)) { mAdditionalPeers.get(user.Id).setAudioEnabled(enabled); } else if (mPeerId.equals(user.Id)) { onToggleMic(); } } else if (intent.getAction().equals(ACTION_SEND_MESSAGE)) { User user = (User) intent.getSerializableExtra(WebsocketService.EXTRA_USER); String messageText = intent.getStringExtra(CallActivity.EXTRA_MESSAGE); if (mService != null) { SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); fmt.setTimeZone(TimeZone.getTimeZone("GMT")); String time = fmt.format(new Date()); mService.sendChatMessage(time, mService.getAccountName(), "Self", messageText, user.Id, mService.getCurrentRoomName()); } } else if (intent.getAction().equals(ACTION_NEW_CALL)) { String signaling = intent.getStringExtra(EXTRA_SIGNALING); if (signaling != null) { mSignaling = signaling; } if (mSignaling.equals("xmpp")) { mOwnJid = intent.getStringExtra(BroadcastTypes.EXTRA_ACCOUNT_JID); mPeerId = intent.getStringExtra(BroadcastTypes.EXTRA_JID); mPeerName = mPeerId; initiator = true; signalingParameters = new SignalingParameters(WebsocketService.getIceServers(), initiator, "", "", "", null, null); } else { User user = (User) intent.getSerializableExtra(WebsocketService.EXTRA_USER); if (intent.hasExtra(WebsocketService.EXTRA_USERACTION)) { if (mConferenceId == null) { SessionIdentifierGenerator gen = new SessionIdentifierGenerator(); mConferenceId = mOwnId + "_" + gen.nextSessionId(); } } if (mPeerId.length() == 0) { callUser(user); } else if (!mPeerId.equals(user.Id)) { // don't call if already in call AdditionalPeerConnection additionalPeerConnection = new AdditionalPeerConnection(this, this, this, true, user.Id, WebsocketService.getIceServers(), peerConnectionParameters, rootEglBase, localRender, getRemoteRenderScreen(user.Id, user.displayName, getUrl(user.buddyPicture)), peerConnectionClient.getMediaStream(), "", peerConnectionClient.getPeerConnectionFactory()); mAdditionalPeers.put(user.Id, additionalPeerConnection); updateVideoView(); } } } else if (intent.getAction().equals(WebsocketService.ACTION_ADD_ALL_CONFERENCE)) { ArrayList<User> users = getUsers(); for (User user : users) { boolean added = false; if (!mPeerId.equals(user.Id) && !mAdditionalPeers.containsKey(user.Id) && (mOwnId.compareTo(user.Id) < 0)) { AdditionalPeerConnection additionalPeerConnection = new AdditionalPeerConnection(this, this, this, true, user.Id, WebsocketService.getIceServers(), peerConnectionParameters, rootEglBase, localRender, getRemoteRenderScreen(user.Id, user.displayName, getUrl(user.buddyPicture)), peerConnectionClient.getMediaStream(), mConferenceId, peerConnectionClient.getPeerConnectionFactory()); mAdditionalPeers.put(user.Id, additionalPeerConnection); updateVideoView(); added = true; } } if (mConferenceId == null) { SessionIdentifierGenerator gen = new SessionIdentifierGenerator(); mConferenceId = mOwnId + "_" + gen.nextSessionId(); } } else if (intent.getAction().equals(WebsocketService.ACTION_ADD_CONFERENCE_USER)) { User user = (User) intent.getSerializableExtra(WebsocketService.EXTRA_USER); String conferenceId = intent.getStringExtra(WebsocketService.EXTRA_CONFERENCE_ID); mOwnId = intent.getStringExtra(WebsocketService.EXTRA_OWN_ID); String userId = intent.getStringExtra(WebsocketService.EXTRA_ID); if (mConferenceId == null) { mConferenceId = conferenceId; } boolean added = false; if ((!mPeerId.equals(userId) && !mAdditionalPeers.containsKey(userId) && (mOwnId.compareTo(userId) < 0))) { if (user != null) { Log.d(TAG, "Calling conference: " + user.displayName); } if (peerConnectionClient.getMediaStream() != null) { String displayName = getString(R.string.unknown); String imgUrl = ""; if (user != null) { displayName = user.displayName; imgUrl = getUrl(user.buddyPicture); } AdditionalPeerConnection additionalPeerConnection = new AdditionalPeerConnection(this, this, this, true, userId, WebsocketService.getIceServers(), peerConnectionParameters, rootEglBase, localRender, getRemoteRenderScreen(userId, displayName, imgUrl), peerConnectionClient.getMediaStream(), mConferenceId, peerConnectionClient.getPeerConnectionFactory()); mAdditionalPeers.put(userId, additionalPeerConnection); updateVideoView(); added = true; } else if (mPeerId.length() == 0) { // show the call as incoming String displayName = getString(R.string.unknown); String imgUrl = ""; if (user != null) { displayName = user.displayName; imgUrl = getUrl(user.buddyPicture); } mPeerId = userId; mPeerName = displayName; ThumbnailsCacheManager.LoadImage(imgUrl, remoteUserImage, displayName, true, true); initiator = true; signalingParameters = new SignalingParameters(WebsocketService.getIceServers(), initiator, "", "", "", null, null); } else { mQueuedPeers.add(user); } } } else if (intent.getAction().equals(WebsocketService.ACTION_REMOTE_ICE_CANDIDATE)) { SerializableIceCandidate candidate = (SerializableIceCandidate) intent .getParcelableExtra(WebsocketService.EXTRA_CANDIDATE); String id = intent.getStringExtra(WebsocketService.EXTRA_ID); String token = intent.getStringExtra(WebsocketService.EXTRA_TOKEN); if (token != null && token.length() != 0) { if (mTokenPeers.containsKey(candidate.from)) { IceCandidate ic = new IceCandidate(candidate.sdpMid, candidate.sdpMLineIndex, candidate.sdp); mTokenPeers.get(candidate.from).addRemoteIceCandidate(ic); } } else if (mAdditionalPeers.containsKey(candidate.from)) { IceCandidate ic = new IceCandidate(candidate.sdpMid, candidate.sdpMLineIndex, candidate.sdp); mAdditionalPeers.get(candidate.from).addRemoteIceCandidate(ic); } else if (id.equals(mSdpId)) { onRemoteIceCandidate(candidate, id, candidate.from); } } else if (intent.getAction().equals(WebsocketService.ACTION_REMOTE_DESCRIPTION)) { SerializableSessionDescription sdp = (SerializableSessionDescription) intent .getSerializableExtra(WebsocketService.EXTRA_REMOTE_DESCRIPTION); String token = intent.getStringExtra(WebsocketService.EXTRA_TOKEN); String id = intent.getStringExtra(WebsocketService.EXTRA_ID); String conferenceId = intent.getStringExtra(WebsocketService.EXTRA_CONFERENCE_ID); String signaling = intent.getStringExtra(EXTRA_SIGNALING); String ownJid = intent.getStringExtra(BroadcastTypes.EXTRA_ACCOUNT_JID); mSid = intent.getStringExtra(BroadcastTypes.EXTRA_SID); User user = (User) intent.getSerializableExtra(WebsocketService.EXTRA_USER); if (mConferenceId == null && conferenceId != null && conferenceId.length() != 0) { mConferenceId = conferenceId; } /*else if (conferenceId != null && mConferenceId != null && !mConferenceId.equals(conferenceId)) { // already in a conference, reject the invite return; }*/ if (ownJid != null) { mOwnJid = ownJid; } if (signaling != null && signaling.equals("xmpp")) { mSignaling = signaling; } if (token != null && token.length() != 0) { if (mTokenPeers.containsKey(sdp.from)) { mTokenPeers.get(sdp.from) .setRemoteDescription(new SessionDescription(sdp.type, sdp.description)); } } else if (mPeerId.length() == 0 || mPeerId.equals(sdp.from)) { mSdpId = id; mPeerId = sdp.from; String imgUrl = ""; if (user != null) { mPeerName = user.displayName; imgUrl = getUrl(user.buddyPicture); } else { mPeerName = getString(R.string.unknown); } ThumbnailsCacheManager.LoadImage(imgUrl, remoteUserImage, mPeerName, true, true); if (peerConnectionClient.isConnected()) { onRemoteDescription(sdp, token, id, conferenceId, "", "", ""); } else { mRemoteSdp = sdp; mToken = token; } } else { if (mAdditionalPeers.containsKey(sdp.from)) { mAdditionalPeers.get(sdp.from) .setRemoteDescription(new SessionDescription(sdp.type, sdp.description)); } else { if (iceConnected && peerConnectionClient.getMediaStream() != null) { addToCall(sdp, user); } else { mQueuedRemoteConnections.add(new RemoteConnection(sdp, user)); } } } } }
From source file:com.apptentive.android.sdk.module.messagecenter.view.MessageCenterActivityContent.java
@Override public void onAttachImage() { try {// w ww.j av a 2s. c o m if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {//prior Api level 19 Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); Intent chooserIntent = Intent.createChooser(intent, null); viewActivity.startActivityForResult(chooserIntent, Constants.REQUEST_CODE_PHOTO_FROM_SYSTEM_PICKER); } else { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); Intent chooserIntent = Intent.createChooser(intent, null); viewActivity.startActivityForResult(chooserIntent, Constants.REQUEST_CODE_PHOTO_FROM_SYSTEM_PICKER); } imagePickerLaunched = true; } catch (Exception e) { e.printStackTrace(); imagePickerLaunched = false; Log.d("can't launch image picker"); } }
From source file:com.amaze.filemanager.activities.MainActivity.java
void initialiseViews() { appBarLayout = (AppBarLayout) findViewById(R.id.lin); if (!ImageLoader.getInstance().isInited()) { ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this)); }//from ww w . j a va 2s . c o m displayImageOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.amaze_header) .showImageForEmptyUri(R.drawable.amaze_header).showImageOnFail(R.drawable.amaze_header) .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565) .build(); buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe); buttonBarFrame.setBackgroundColor(Color.parseColor(skin)); drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null); drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent); drawerHeaderView = (View) drawerHeaderLayout.findViewById(R.id.drawer_header); drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Intent intent; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); } else { intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); } intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); startActivityForResult(intent, image_selector_request_code); return false; } }); drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic); mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name); mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email); toolbar = (Toolbar) findViewById(R.id.action_bar); setSupportActionBar(toolbar); frameLayout = (FrameLayout) findViewById(R.id.content_frame); indicator_layout = findViewById(R.id.indicator_layout); mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer); if (theme1 == 1) mDrawerLinear.setBackgroundColor(Color.parseColor("#303030")); else mDrawerLinear.setBackgroundColor(Color.WHITE); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor(skin)); mDrawerList = (ListView) findViewById(R.id.menu_drawer); drawerHeaderView.setBackgroundResource(R.drawable.amaze_header); drawerHeaderParent.setBackgroundColor(Color.parseColor(skin)); if (findViewById(R.id.tab_frame) != null) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear); mDrawerLayout.setScrimColor(Color.TRANSPARENT); isDrawerLocked = true; } mDrawerList.addHeaderView(drawerHeaderLayout); getSupportActionBar().setDisplayShowTitleEnabled(false); View v = findViewById(R.id.fab_bg); if (theme1 == 1) v.setBackgroundColor(Color.parseColor("#a6ffffff")); v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { floatingActionButton.close(true); revealShow(view, false); } }); pathbar = (LinearLayout) findViewById(R.id.pathbar); buttons = (LinearLayout) findViewById(R.id.buttons); scroll = (HorizontalScrollView) findViewById(R.id.scroll); scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1); scroll.setSmoothScrollingEnabled(true); scroll1.setSmoothScrollingEnabled(true); ImageView divider = (ImageView) findViewById(R.id.divider1); if (theme1 == 0) divider.setImageResource(R.color.divider); else divider.setImageResource(R.color.divider_dark); setDrawerHeaderBackground(); View settingsbutton = findViewById(R.id.settingsbutton); if (theme1 == 1) { settingsbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) settingsbutton.findViewById(R.id.settingicon)) .setImageResource(R.drawable.ic_settings_white_48dp); ((TextView) settingsbutton.findViewById(R.id.settingtext)) .setTextColor(getResources().getColor(android.R.color.white)); } settingsbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent in = new Intent(MainActivity.this, Preferences.class); finish(); final int enter_anim = android.R.anim.fade_in; final int exit_anim = android.R.anim.fade_out; Activity s = MainActivity.this; s.overridePendingTransition(exit_anim, enter_anim); s.finish(); s.overridePendingTransition(enter_anim, exit_anim); s.startActivity(in); } }); View appbutton = findViewById(R.id.appbutton); if (theme1 == 1) { appbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) appbutton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white); ((TextView) appbutton.findViewById(R.id.apptext)) .setTextColor(getResources().getColor(android.R.color.white)); } appbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager() .beginTransaction(); transaction2.replace(R.id.content_frame, new AppsList()); findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)) .start(); pending_fragmentTransaction = transaction2; if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); select = -2; adapter.toggleChecked(false); } }); getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin))); // status bar0 sdk = Build.VERSION.SDK_INT; if (sdk == 20 || sdk == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintColor(Color.parseColor(skin)); FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout) .getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); if (!isDrawerLocked) p.setMargins(0, config.getStatusBarHeight(), 0, 0); } else if (Build.VERSION.SDK_INT >= 21) { colourednavigation = Sp.getBoolean("colorednavigation", true); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (isDrawerLocked) { window.setStatusBarColor((skinStatusBar)); } else window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (colourednavigation) window.setNavigationBarColor(skinStatusBar); } }
From source file:com.filemanager.free.activities.MainActivity.java
@SuppressLint("InflateParams") private void initialiseViews() { mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.main_frame); appBarLayout = (AppBarLayout) findViewById(R.id.lin); if (!ImageLoader.getInstance().isInited()) { ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this)); }// ww w . j a v a 2 s . co m if (displayImageOptions != null) { displayImageOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.amaze_header) .showImageForEmptyUri(R.drawable.amaze_header).showImageOnFail(R.drawable.amaze_header) .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true) .bitmapConfig(Bitmap.Config.RGB_565).build(); } buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe); buttonBarFrame.setBackgroundColor(Color.parseColor(skin)); drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null); drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent); drawerHeaderView = (View) drawerHeaderLayout.findViewById(R.id.drawer_header); drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Intent intent; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); } else { intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); } intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); startActivityForResult(intent, image_selector_request_code); return false; } }); drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic); mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name); mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email); toolbar = (Toolbar) findViewById(R.id.action_bar); setSupportActionBar(toolbar); frameLayout = (FrameLayout) findViewById(R.id.content_frame); indicator_layout = findViewById(R.id.indicator_layout); mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer); if (theme1 == 1) mDrawerLinear.setBackgroundColor(Color.parseColor("#303030")); else { assert mDrawerLinear != null; mDrawerLinear.setBackgroundColor(Color.WHITE); } mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor(skin)); mDrawerList = (ListView) findViewById(R.id.menu_drawer); drawerHeaderView.setBackgroundResource(R.drawable.amaze_header); drawerHeaderParent.setBackgroundColor(Color.parseColor(skin)); if (findViewById(R.id.tab_frame) != null) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear); mDrawerLayout.setScrimColor(Color.TRANSPARENT); isDrawerLocked = true; } mDrawerList.addHeaderView(drawerHeaderLayout); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayShowTitleEnabled(false); } View v = findViewById(R.id.fab_bg); if (theme1 == 1) { assert v != null; v.setBackgroundColor(Color.parseColor("#a6ffffff")); } assert v != null; v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { floatingActionButton.close(true); utils.revealShow(view, false); } }); pathbar = (LinearLayout) findViewById(R.id.pathbar); buttons = (LinearLayout) findViewById(R.id.buttons); scroll = (HorizontalScrollView) findViewById(R.id.scroll); scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1); scroll.setSmoothScrollingEnabled(true); scroll1.setSmoothScrollingEnabled(true); ImageView divider = (ImageView) findViewById(R.id.divider1); if (theme1 == 0) { assert divider != null; divider.setImageResource(R.color.divider); } else { assert divider != null; divider.setImageResource(R.color.divider_dark); } setDrawerHeaderBackground(); View settingsbutton = findViewById(R.id.settingsbutton); if (theme1 == 1) { assert settingsbutton != null; settingsbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) settingsbutton.findViewById(R.id.settingicon)) .setImageResource(R.drawable.ic_settings_white_48dp); ((TextView) settingsbutton.findViewById(R.id.settingtext)) .setTextColor(ContextCompat.getColor(con, android.R.color.white)); } assert settingsbutton != null; settingsbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent in = new Intent(MainActivity.this, Preferences.class); finish(); final int enter_anim = android.R.anim.fade_in; final int exit_anim = android.R.anim.fade_out; Activity s = MainActivity.this; s.overridePendingTransition(exit_anim, enter_anim); s.finish(); s.overridePendingTransition(enter_anim, exit_anim); s.startActivity(in); } }); View appbutton = findViewById(R.id.appbutton); if (theme1 == 1) { assert appbutton != null; appbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) appbutton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white); ((TextView) appbutton.findViewById(R.id.apptext)) .setTextColor(ContextCompat.getColor(con, android.R.color.white)); } assert appbutton != null; appbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager() .beginTransaction(); transaction2.replace(R.id.content_frame, new AppsList()); findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)) .start(); pending_fragmentTransaction = transaction2; if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); select = -2; adapter.toggleChecked(false); } }); getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin))); // status bar0 sdk = Build.VERSION.SDK_INT; if (sdk == 20 || sdk == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); tintManager.setStatusBarTintColor(Color.parseColor(skin)); FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout) .getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); if (!isDrawerLocked) p.setMargins(0, config.getStatusBarHeight(), 0, 0); } else if (Build.VERSION.SDK_INT >= 21) { colourednavigation = Sp.getBoolean("colorednavigation", true); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (isDrawerLocked) { window.setStatusBarColor((skinStatusBar)); } else window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (colourednavigation) window.setNavigationBarColor(skinStatusBar); } //admob mAdView = (View) findViewById(R.id.ads); }
From source file:com.igniva.filemanager.activities.MainActivity.java
void initialiseViews() { appBarLayout = (AppBarLayout) findViewById(R.id.lin); if (!ImageLoader.getInstance().isInited()) { ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this)); }//from www .j a v a2 s . co m displayImageOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.amaze_header) .showImageForEmptyUri(R.drawable.amaze_header).showImageOnFail(R.drawable.amaze_header) .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565) .build(); mScreenLayout = (CoordinatorLayout) findViewById(R.id.main_frame); buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe); //buttonBarFrame.setBackgroundColor(Color.parseColor(currentTab==1 ? skinTwo : skin)); drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null); drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent); drawerHeaderView = (View) drawerHeaderLayout.findViewById(R.id.drawer_header); mFabBackground = findViewById(R.id.fab_bg); drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Intent intent; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); } else { intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); } intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); startActivityForResult(intent, image_selector_request_code); return false; } }); drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic); mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name); mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email); toolbar = (Toolbar) findViewById(R.id.action_bar); /* For SearchView, see onCreateOptionsMenu(Menu menu)*/ TOOLBAR_START_INSET = toolbar.getContentInsetStart(); setSupportActionBar(toolbar); frameLayout = (FrameLayout) findViewById(R.id.content_frame); indicator_layout = findViewById(R.id.indicator_layout); mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer); if (theme1 == 1) mDrawerLinear.setBackgroundColor(Color.parseColor("#303030")); else mDrawerLinear.setBackgroundColor(Color.WHITE); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); //mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor((currentTab==1 ? skinTwo : skin))); mDrawerList = (ListView) findViewById(R.id.menu_drawer); drawerHeaderView.setBackgroundResource(R.drawable.amaze_header); //drawerHeaderParent.setBackgroundColor(Color.parseColor((currentTab==1 ? skinTwo : skin))); if (findViewById(R.id.tab_frame) != null) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear); mDrawerLayout.openDrawer(mDrawerLinear); mDrawerLayout.setScrimColor(Color.TRANSPARENT); isDrawerLocked = true; } else if (findViewById(R.id.tab_frame) == null) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, mDrawerLinear); mDrawerLayout.closeDrawer(mDrawerLinear); isDrawerLocked = false; } mDrawerList.addHeaderView(drawerHeaderLayout); getSupportActionBar().setDisplayShowTitleEnabled(false); View v = findViewById(R.id.fab_bg); /*if (theme1 != 1) v.setBackgroundColor(Color.parseColor("#a6ffffff"));*/ v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { floatingActionButton.close(true); utils.revealShow(view, false); if (isSearchViewEnabled) hideSearchView(); } }); pathbar = (LinearLayout) findViewById(R.id.pathbar); buttons = (LinearLayout) findViewById(R.id.buttons); scroll = (HorizontalScrollView) findViewById(R.id.scroll); scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1); scroll.setSmoothScrollingEnabled(true); scroll1.setSmoothScrollingEnabled(true); ImageView divider = (ImageView) findViewById(R.id.divider1); if (theme1 == 0) divider.setImageResource(R.color.divider); else divider.setImageResource(R.color.divider_dark); setDrawerHeaderBackground(); View settingsbutton = findViewById(R.id.settingsbutton); if (theme1 == 1) { settingsbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) settingsbutton.findViewById(R.id.settingicon)) .setImageResource(R.drawable.ic_settings_white_48dp); ((TextView) settingsbutton.findViewById(R.id.settingtext)) .setTextColor(getResources().getColor(android.R.color.white)); } settingsbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent in = new Intent(MainActivity.this, Preferences.class); finish(); final int enter_anim = android.R.anim.fade_in; final int exit_anim = android.R.anim.fade_out; Activity s = MainActivity.this; s.overridePendingTransition(exit_anim, enter_anim); s.finish(); s.overridePendingTransition(enter_anim, exit_anim); s.startActivity(in); } }); View appbutton = findViewById(R.id.appbutton); if (theme1 == 1) { appbutton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) appbutton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white); ((TextView) appbutton.findViewById(R.id.apptext)) .setTextColor(getResources().getColor(android.R.color.white)); } appbutton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager() .beginTransaction(); transaction2.replace(R.id.content_frame, new AppsList()); findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)) .start(); pending_fragmentTransaction = transaction2; if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); select = -2; adapter.toggleChecked(false); } }); View ftpButton = findViewById(R.id.ftpbutton); if (theme1 == 1) { ftpButton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) ftpButton.findViewById(R.id.ftpicon)).setImageResource(R.drawable.ic_ftp_dark); ((TextView) ftpButton.findViewById(R.id.ftptext)) .setTextColor(getResources().getColor(android.R.color.white)); } ftpButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager() .beginTransaction(); transaction2.replace(R.id.content_frame, new FTPServerFragment()); findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)) .start(); pending_fragmentTransaction = transaction2; if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); select = -2; adapter.toggleChecked(false); } }); //getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor((currentTab==1 ? skinTwo : skin)))); // status bar0 sdk = Build.VERSION.SDK_INT; if (sdk == 20 || sdk == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); //tintManager.setStatusBarTintColor(Color.parseColor((currentTab==1 ? skinTwo : skin))); FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout) .getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); if (!isDrawerLocked) p.setMargins(0, config.getStatusBarHeight(), 0, 0); } else if (Build.VERSION.SDK_INT >= 21) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (isDrawerLocked) { window.setStatusBarColor((skinStatusBar)); } else window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (colourednavigation) window.setNavigationBarColor(skinStatusBar); } searchViewLayout = (RelativeLayout) findViewById(R.id.search_view); searchViewEditText = (AppCompatEditText) findViewById(R.id.search_edit_text); ImageView clear = (ImageView) findViewById(R.id.search_close_btn); clear.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { searchViewEditText.setText(""); } }); findViewById(R.id.img_view_back).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideSearchView(); } }); searchViewEditText.setOnKeyListener(new TextView.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN)) { // Perform action on key press mainActivityHelper.search(searchViewEditText.getText().toString()); hideSearchView(); return true; } return false; } }); // searchViewEditText.setTextColor(getResources().getColor(android.R.color.black)); // searchViewEditText.setHintTextColor(Color.parseColor(BaseActivity.accentSkin)); }
From source file:com.amaze.carbonfilemanager.activities.MainActivity.java
void initialiseViews() { appBarLayout = (AppBarLayout) findViewById(R.id.lin); mScreenLayout = (CoordinatorLayout) findViewById(R.id.main_frame); buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe); //buttonBarFrame.setBackgroundColor(Color.parseColor(currentTab==1 ? skinTwo : skin)); drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null); drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent); drawerHeaderView = drawerHeaderLayout.findViewById(R.id.drawer_header); drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() { @Override// w w w . j av a 2 s .c o m public boolean onLongClick(View v) { Intent intent; if (SDK_INT < 19) { intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); } else { intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); } intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); startActivityForResult(intent, image_selector_request_code); return false; } }); drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic); mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name); mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email); toolbar = (Toolbar) findViewById(R.id.action_bar); /* For SearchView, see onCreateOptionsMenu(Menu menu)*/ TOOLBAR_START_INSET = toolbar.getContentInsetStart(); setSupportActionBar(toolbar); frameLayout = (FrameLayout) findViewById(R.id.content_frame); indicator_layout = findViewById(R.id.indicator_layout); mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer); if (getAppTheme().equals(AppTheme.DARK)) mDrawerLinear.setBackgroundColor(Utils.getColor(this, R.color.holo_dark_background)); else mDrawerLinear.setBackgroundColor(Color.WHITE); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); //mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor((currentTab==1 ? skinTwo : skin))); mDrawerList = (ListView) findViewById(R.id.menu_drawer); drawerHeaderView.setBackgroundResource(R.drawable.amaze_header); //drawerHeaderParent.setBackgroundColor(Color.parseColor((currentTab==1 ? skinTwo : skin))); if (findViewById(R.id.tab_frame) != null) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear); mDrawerLayout.openDrawer(mDrawerLinear); mDrawerLayout.setScrimColor(Color.TRANSPARENT); isDrawerLocked = true; } else if (findViewById(R.id.tab_frame) == null) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, mDrawerLinear); mDrawerLayout.closeDrawer(mDrawerLinear); isDrawerLocked = false; } mDrawerList.addHeaderView(drawerHeaderLayout); getSupportActionBar().setDisplayShowTitleEnabled(false); fabBgView = findViewById(R.id.fab_bg); if (getAppTheme().equals(AppTheme.DARK)) { fabBgView.setBackgroundResource(R.drawable.fab_shadow_dark); } fabBgView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { floatingActionButton.close(true); if (isSearchViewEnabled) hideSearchView(); } }); pathbar = (LinearLayout) findViewById(R.id.pathbar); buttons = (LinearLayout) findViewById(R.id.buttons); scroll = (HorizontalScrollView) findViewById(R.id.scroll); scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1); scroll.setSmoothScrollingEnabled(true); scroll1.setSmoothScrollingEnabled(true); ImageView divider = (ImageView) findViewById(R.id.divider1); if (getAppTheme().equals(AppTheme.LIGHT)) divider.setImageResource(R.color.divider); else divider.setImageResource(R.color.divider_dark); setDrawerHeaderBackground(); View settingsButton = findViewById(R.id.settingsbutton); if (getAppTheme().equals(AppTheme.DARK)) { settingsButton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) settingsButton.findViewById(R.id.settingicon)) .setImageResource(R.drawable.ic_settings_white_48dp); ((TextView) settingsButton.findViewById(R.id.settingtext)) .setTextColor(Utils.getColor(this, android.R.color.white)); } settingsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent in = new Intent(MainActivity.this, PreferencesActivity.class); startActivity(in); finish(); } }); View appButton = findViewById(R.id.appbutton); if (getAppTheme().equals(AppTheme.DARK)) { appButton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) appButton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white); ((TextView) appButton.findViewById(R.id.apptext)) .setTextColor(Utils.getColor(this, android.R.color.white)); } appButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager() .beginTransaction(); transaction2.replace(R.id.content_frame, new AppsList()); findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)) .start(); pending_fragmentTransaction = transaction2; if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); selectedStorage = SELECT_MINUS_2; adapter.toggleChecked(false); } }); View ftpButton = findViewById(R.id.ftpbutton); if (getAppTheme().equals(AppTheme.DARK)) { ftpButton.setBackgroundResource(R.drawable.safr_ripple_black); ((ImageView) ftpButton.findViewById(R.id.ftpicon)).setImageResource(R.drawable.ic_ftp_dark); ((TextView) ftpButton.findViewById(R.id.ftptext)) .setTextColor(Utils.getColor(this, android.R.color.white)); } ftpButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager() .beginTransaction(); transaction2.replace(R.id.content_frame, new FTPServerFragment()); findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)) .start(); pending_fragmentTransaction = transaction2; if (!isDrawerLocked) mDrawerLayout.closeDrawer(mDrawerLinear); else onDrawerClosed(); selectedStorage = SELECT_MINUS_2; adapter.toggleChecked(false); } }); //getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor((currentTab==1 ? skinTwo : skin)))); // status bar0 if (SDK_INT == 20 || SDK_INT == 19) { SystemBarTintManager tintManager = new SystemBarTintManager(this); tintManager.setStatusBarTintEnabled(true); //tintManager.setStatusBarTintColor(Color.parseColor((currentTab==1 ? skinTwo : skin))); FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout) .getLayoutParams(); SystemBarTintManager.SystemBarConfig config = tintManager.getConfig(); if (!isDrawerLocked) p.setMargins(0, config.getStatusBarHeight(), 0, 0); } else if (SDK_INT >= 21) { Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (isDrawerLocked) { window.setStatusBarColor((skinStatusBar)); } else window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); if (colourednavigation) window.setNavigationBarColor(skinStatusBar); } searchViewLayout = (RelativeLayout) findViewById(R.id.search_view); searchViewEditText = (AppCompatEditText) findViewById(R.id.search_edit_text); ImageView clear = (ImageView) findViewById(R.id.search_close_btn); clear.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { searchViewEditText.setText(""); } }); findViewById(R.id.img_view_back).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { hideSearchView(); } }); searchViewEditText.setOnKeyListener(new TextView.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" button if ((event.getAction() == KeyEvent.ACTION_DOWN)) { // Perform action on key press mainActivityHelper.search(searchViewEditText.getText().toString()); hideSearchView(); return true; } return false; } }); // searchViewEditText.setTextColor(Utils.getColor(this, android.R.color.black)); // searchViewEditText.setHintTextColor(Color.parseColor(BaseActivity.accentSkin)); }