boolean checkInternetPermission() { if (checkedInternetPermission) { return true; } int permissionCheck = checkPermission(Manifest.permission.INTERNET); if (permissionCheck != PackageManager.PERMISSION_GRANTED) { String errorType = context.getString(R.string.com_facebook_internet_permission_error_title); String errorDescription = context.getString(R.string.com_facebook_internet_permission_error_message); complete(Result.createErrorResult(pendingRequest, errorType, errorDescription)); return false; } checkedInternetPermission = true; return true; }
private int getPresetSizeInPixels(boolean forcePreset) { int dimensionId; switch (presetSizeType) { case SMALL: dimensionId = R.dimen.com_facebook_profilepictureview_preset_size_small; break; case NORMAL: dimensionId = R.dimen.com_facebook_profilepictureview_preset_size_normal; break; case LARGE: dimensionId = R.dimen.com_facebook_profilepictureview_preset_size_large; break; case CUSTOM: if (!forcePreset) { return ImageRequest.UNSPECIFIED_DIMENSION; } else { dimensionId = R.dimen.com_facebook_profilepictureview_preset_size_normal; break; } default: return ImageRequest.UNSPECIFIED_DIMENSION; } return getResources().getDimensionPixelSize(dimensionId); }
private void checkNuxSettings() { if (nuxMode == ToolTipMode.DISPLAY_ALWAYS) { String nuxString = getResources().getString(R.string.com_facebook_tooltip_default); displayNux(nuxString); } else { // kick off an async request final String appId = Utility.getMetadataApplicationId(getContext()); AsyncTask<Void, Void, FetchedAppSettings> task = new AsyncTask<Void, Void, Utility.FetchedAppSettings>() { @Override protected FetchedAppSettings doInBackground(Void... params) { FetchedAppSettings settings = Utility.queryAppSettings(appId, false); return settings; } @Override protected void onPostExecute(FetchedAppSettings result) { showNuxPerSettings(result); } }; task.execute((Void[])null); } }
protected View createGraphObjectView(T graphObject) { View result = inflater.inflate(getGraphObjectRowLayoutId(graphObject), null); ViewStub checkboxStub = (ViewStub) result.findViewById(R.id.com_facebook_picker_checkbox_stub); if (checkboxStub != null) { if (!getShowCheckbox()) { checkboxStub.setVisibility(View.GONE); } else { CheckBox checkBox = (CheckBox) checkboxStub.inflate(); updateCheckboxState(checkBox, false); } } ViewStub profilePicStub = (ViewStub) result.findViewById(R.id.com_facebook_picker_profile_pic_stub); if (!getShowPicture()) { profilePicStub.setVisibility(View.GONE); } else { ImageView imageView = (ImageView) profilePicStub.inflate(); imageView.setVisibility(View.VISIBLE); } return result; }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.com_facebook_usersettingsfragment, container, false); loginButton = (LoginButton) view.findViewById(R.id.com_facebook_usersettingsfragment_login_button); loginButton.setProperties(loginButtonProperties); loginButton.setFragment(this); loginButton.setLoginLogoutEventName(AnalyticsEvents.EVENT_USER_SETTINGS_USAGE); Session session = getSession(); if (session != null && !session.equals(Session.getActiveSession())) { loginButton.setSession(session); } connectedStateLabel = (TextView) view.findViewById(R.id.com_facebook_usersettingsfragment_profile_name); // if no background is set for some reason, then default to Facebook blue if (view.getBackground() == null) { view.setBackgroundColor(getResources().getColor(R.color.com_facebook_blue)); } else { view.getBackground().setDither(true); } return view; }
private ImageRequest getImageRequest() { ImageRequest request = null; try { ImageRequest.Builder requestBuilder = new ImageRequest.Builder( getActivity(), ImageRequest.getProfilePictureUrl( user.getId(), getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_width), getResources().getDimensionPixelSize(R.dimen.com_facebook_usersettingsfragment_profile_picture_height))); request = requestBuilder.setCallerTag(this) .setCallback( new ImageRequest.Callback() { @Override public void onCompleted(ImageResponse response) { processImageResponse(user.getId(), response); } }) .build(); } catch (URISyntaxException e) { } return request; }
@Override void setupViews(ViewGroup view) { if (showSearchBox) { ListView listView = (ListView) view.findViewById(R.id.com_facebook_picker_list_view); View searchHeaderView = getActivity().getLayoutInflater().inflate( R.layout.com_facebook_picker_search_box, listView, false); listView.addHeaderView(searchHeaderView, null, false); searchBox = (EditText) view.findViewById(R.id.com_facebook_picker_search_text); searchBox.addTextChangedListener(new SearchTextWatcher()); if (!TextUtils.isEmpty(searchText)) { searchBox.setText(searchText); } } }
@Override public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) { super.onInflate(activity, attrs, savedInstanceState); TypedArray a = activity.obtainStyledAttributes(attrs, R.styleable.com_facebook_picker_fragment); setShowPictures(a.getBoolean(R.styleable.com_facebook_picker_fragment_show_pictures, showPictures)); String extraFieldsString = a.getString(R.styleable.com_facebook_picker_fragment_extra_fields); if (extraFieldsString != null) { String[] strings = extraFieldsString.split(","); setExtraFields(Arrays.asList(strings)); } showTitleBar = a.getBoolean(R.styleable.com_facebook_picker_fragment_show_title_bar, showTitleBar); titleText = a.getString(R.styleable.com_facebook_picker_fragment_title_text); doneButtonText = a.getString(R.styleable.com_facebook_picker_fragment_done_button_text); titleBarBackground = a.getDrawable(R.styleable.com_facebook_picker_fragment_title_bar_background); doneButtonBackground = a.getDrawable(R.styleable.com_facebook_picker_fragment_done_button_background); a.recycle(); }
@Override PickerFragmentAdapter<GraphUser> createAdapter() { PickerFragmentAdapter<GraphUser> adapter = new PickerFragmentAdapter<GraphUser>( this.getActivity()) { @Override protected int getGraphObjectRowLayoutId(GraphUser graphObject) { return R.layout.com_facebook_picker_list_row; } @Override protected int getDefaultPicture() { return R.drawable.com_facebook_profile_default_icon; } }; adapter.setShowCheckbox(true); adapter.setShowPicture(getShowPictures()); adapter.setSortFields(Arrays.asList(new String[]{NAME})); adapter.setGroupByField(NAME); return adapter; }
private void createCrossImage() { crossImageView = new ImageView(getContext()); // Dismiss the dialog when user click on the 'x' crossImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { sendCancelToListener(); WebDialog.this.dismiss(); } }); Drawable crossDrawable = getContext().getResources().getDrawable(R.drawable.com_facebook_close); crossImageView.setImageDrawable(crossDrawable); /* 'x' should not be visible while webview is loading * make it visible only after webview has fully loaded */ crossImageView.setVisibility(View.INVISIBLE); }
private void initialize() { // apparently there's no method of setting a default style in xml, // so in case the users do not explicitly specify a style, we need // to use sensible defaults. this.setGravity(Gravity.CENTER_VERTICAL); this.setTextColor(getResources().getColor(R.color.com_facebook_likebutton_text_color)); this.setTextSize(TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.com_facebook_likebutton_text_size)); this.setTypeface(Typeface.DEFAULT_BOLD); this.setCompoundDrawablePadding( getResources().getDimensionPixelSize(R.dimen.com_facebook_likebutton_compound_drawable_padding)); this.setPadding( getResources().getDimensionPixelSize(R.dimen.com_facebook_likebutton_padding_left), getResources().getDimensionPixelSize(R.dimen.com_facebook_likebutton_padding_top), getResources().getDimensionPixelSize(R.dimen.com_facebook_likebutton_padding_right), getResources().getDimensionPixelSize(R.dimen.com_facebook_likebutton_padding_bottom)); updateForLikeStatus(); }
private void initializeLikeCountLabel(Context context) { likeCountLabel = new TextView(context); LayoutParams likeCountLabelLayoutParams = new LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); likeCountLabel.setLayoutParams(likeCountLabelLayoutParams); likeCountLabel.setGravity(Gravity.CENTER); likeCountLabel.setTextSize( TypedValue.COMPLEX_UNIT_PX, getResources().getDimension(R.dimen.com_facebook_likeboxcountview_text_size)); likeCountLabel.setTextColor(getResources().getColor(R.color.com_facebook_likeboxcountview_text_color)); textPadding = getResources().getDimensionPixelSize(R.dimen.com_facebook_likeboxcountview_text_padding); // Calculate the additional text padding that will be applied in the direction of the caret. additionalTextPadding = getResources().getDimensionPixelSize(R.dimen.com_facebook_likeboxcountview_caret_height); }
private void createCrossImage() { crossImageView = new ImageView(getContext()); // Dismiss the dialog when user click on the 'x' crossImageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); Drawable crossDrawable = getContext().getResources().getDrawable(R.drawable.com_facebook_close); crossImageView.setImageDrawable(crossDrawable); /* 'x' should not be visible while webview is loading * make it visible only after webview has fully loaded */ crossImageView.setVisibility(View.INVISIBLE); }