use of androidx.constraintlayout.widget.ConstraintLayout in project Signal-Android by WhisperSystems.
the class CreatePaymentFragment method onViewCreated.
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
Toolbar toolbar = view.findViewById(R.id.create_payment_fragment_toolbar);
toolbar.setNavigationOnClickListener(this::goBack);
CreatePaymentFragmentArgs arguments = CreatePaymentFragmentArgs.fromBundle(requireArguments());
CreatePaymentViewModel.Factory factory = new CreatePaymentViewModel.Factory(arguments.getPayee(), arguments.getNote());
CreatePaymentViewModel viewModel = new ViewModelProvider(Navigation.findNavController(view).getViewModelStoreOwner(R.id.payments_create), factory).get(CreatePaymentViewModel.class);
constraintLayout = view.findViewById(R.id.create_payment_fragment_amount_header);
request = view.findViewById(R.id.create_payment_fragment_request);
amount = view.findViewById(R.id.create_payment_fragment_amount);
exchange = view.findViewById(R.id.create_payment_fragment_exchange);
pay = view.findViewById(R.id.create_payment_fragment_pay);
balance = view.findViewById(R.id.create_payment_fragment_balance);
note = view.findViewById(R.id.create_payment_fragment_note);
addNote = view.findViewById(R.id.create_payment_fragment_add_note);
toggle = view.findViewById(R.id.create_payment_fragment_toggle);
TextView decimal = view.findViewById(R.id.create_payment_fragment_keyboard_decimal);
decimal.setText(String.valueOf(DecimalFormatSymbols.getInstance().getDecimalSeparator()));
View infoTapTarget = view.findViewById(R.id.create_payment_fragment_info_tap_region);
// noinspection CodeBlock2Expr
infoTapTarget.setOnClickListener(v -> {
new AlertDialog.Builder(requireContext()).setMessage(R.string.CreatePaymentFragment__conversions_are_just_estimates).setPositiveButton(android.R.string.ok, (dialog, which) -> dialog.dismiss()).setNegativeButton(R.string.LearnMoreTextView_learn_more, (dialog, which) -> {
dialog.dismiss();
CommunicationActions.openBrowserLink(requireContext(), getString(R.string.CreatePaymentFragment__learn_more__conversions));
}).show();
});
initializeInfoIcon();
note.setOnClickListener(v -> SafeNavigation.safeNavigate(Navigation.findNavController(v), R.id.action_createPaymentFragment_to_editPaymentNoteFragment));
addNote.setOnClickListener(v -> SafeNavigation.safeNavigate(Navigation.findNavController(v), R.id.action_createPaymentFragment_to_editPaymentNoteFragment));
pay.setOnClickListener(v -> {
NavDirections directions = CreatePaymentFragmentDirections.actionCreatePaymentFragmentToConfirmPaymentFragment(viewModel.getCreatePaymentDetails()).setFinishOnConfirm(arguments.getFinishOnConfirm());
SafeNavigation.safeNavigate(Navigation.findNavController(v), directions);
});
toggle.setOnClickListener(v -> viewModel.toggleMoneyInputTarget());
initializeConstraintSets();
initializeKeyboardButtons(view, viewModel);
viewModel.getInputState().observe(getViewLifecycleOwner(), inputState -> {
updateAmount(inputState);
updateExchange(inputState);
updateMoneyInputTarget(inputState.getInputTarget());
});
viewModel.getIsPaymentsSupportedByPayee().observe(getViewLifecycleOwner(), isSupported -> {
if (!isSupported)
RecipientHasNotEnabledPaymentsDialog.show(requireContext(), () -> goBack(requireView()));
});
viewModel.isValidAmount().observe(getViewLifecycleOwner(), this::updateRequestAmountButtons);
viewModel.getNote().observe(getViewLifecycleOwner(), this::updateNote);
viewModel.getSpendableBalance().observe(getViewLifecycleOwner(), this::updateBalance);
viewModel.getCanSendPayment().observe(getViewLifecycleOwner(), this::updatePayAmountButtons);
}
use of androidx.constraintlayout.widget.ConstraintLayout in project Gadgetbridge by Freeyourgadget.
the class SleepChartFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_sleepchart, container, false);
mActivityChart = rootView.findViewById(R.id.sleepchart);
mSleepAmountChart = rootView.findViewById(R.id.sleepchart_pie_light_deep);
mSleepchartInfo = rootView.findViewById(R.id.sleepchart_info);
heartRateIcon = rootView.findViewById(R.id.heartrate_widget_icon);
heartRateAverageLabel = rootView.findViewById(R.id.heartrate_widget_label);
intensityTotalIcon = rootView.findViewById(R.id.intensity_widget_icon);
intensityTotalLabel = rootView.findViewById(R.id.intensity_widget_label);
ConstraintLayout intensityTotalWidgetLayout = rootView.findViewById(R.id.intensity_widget_layout);
ConstraintLayout heartRateWidgetLayout = rootView.findViewById(R.id.heartrate_widget_layout);
View.OnClickListener listener = new View.OnClickListener() {
@Override
public void onClick(View v) {
DecimalFormat df = new DecimalFormat("###.#");
String detailedDuration = String.format(getString(R.string.charts_min_max_heartrate_popup), heartRateMin, heartRateMax, df.format(intensityTotal));
new ChartsActivity.ShowDurationDialog(detailedDuration, getContext()).show();
}
};
heartRateWidgetLayout.setOnClickListener(listener);
intensityTotalWidgetLayout.setOnClickListener(listener);
intensityTotalIcon.setOnClickListener(listener);
intensityTotalLabel.setOnClickListener(listener);
setupActivityChart();
setupSleepAmountChart();
// refresh immediately instead of use refreshIfVisible(), for perceived performance
refresh();
return rootView;
}
use of androidx.constraintlayout.widget.ConstraintLayout in project FirebaseUI-Android by firebase.
the class AuthMethodPickerActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FlowParameters params = getFlowParams();
customLayout = params.authMethodPickerLayout;
mHandler = new ViewModelProvider(this).get(SocialProviderResponseHandler.class);
mHandler.init(params);
mProviders = new ArrayList<>();
if (customLayout != null) {
setContentView(customLayout.getMainLayout());
// Setup using custom layout
populateIdpListCustomLayout(params.providers);
} else {
setContentView(R.layout.fui_auth_method_picker_layout);
// UI only with default layout
mProgressBar = findViewById(R.id.top_progress_bar);
mProviderHolder = findViewById(R.id.btn_holder);
populateIdpList(params.providers);
int logoId = params.logoId;
if (logoId == AuthUI.NO_LOGO) {
findViewById(R.id.logo).setVisibility(View.GONE);
ConstraintLayout layout = findViewById(R.id.root);
ConstraintSet constraints = new ConstraintSet();
constraints.clone(layout);
constraints.setHorizontalBias(R.id.container, 0.5f);
constraints.setVerticalBias(R.id.container, 0.5f);
constraints.applyTo(layout);
} else {
ImageView logo = findViewById(R.id.logo);
logo.setImageResource(logoId);
}
}
boolean tosAndPpConfigured = getFlowParams().isPrivacyPolicyUrlProvided() && getFlowParams().isTermsOfServiceUrlProvided();
int termsTextId = customLayout == null ? R.id.main_tos_and_pp : customLayout.getTosPpView();
if (termsTextId >= 0) {
TextView termsText = findViewById(termsTextId);
// No ToS or PP provided, so we should hide the view entirely
if (!tosAndPpConfigured) {
termsText.setVisibility(View.GONE);
} else {
PrivacyDisclosureUtils.setupTermsOfServiceAndPrivacyPolicyText(this, getFlowParams(), termsText);
}
}
// Handler for both
mHandler.getOperation().observe(this, new ResourceObserver<IdpResponse>(this, R.string.fui_progress_dialog_signing_in) {
@Override
protected void onSuccess(@NonNull IdpResponse response) {
startSaveCredentials(mHandler.getCurrentUser(), response, null);
}
@Override
protected void onFailure(@NonNull Exception e) {
if (e instanceof UserCancellationException) {
// User pressed back, there is no error.
return;
}
if (e instanceof FirebaseAuthAnonymousUpgradeException) {
finish(ErrorCodes.ANONYMOUS_UPGRADE_MERGE_CONFLICT, ((FirebaseAuthAnonymousUpgradeException) e).getResponse().toIntent());
} else if (e instanceof FirebaseUiException) {
FirebaseUiException fue = (FirebaseUiException) e;
finish(RESULT_CANCELED, IdpResponse.from(fue).toIntent());
} else {
String text = getString(R.string.fui_error_unknown);
Toast.makeText(AuthMethodPickerActivity.this, text, Toast.LENGTH_SHORT).show();
}
}
});
}
use of androidx.constraintlayout.widget.ConstraintLayout in project android by owncloud.
the class ReceiveExternalFilesActivity method initToolbar.
/**
* This activity is special, so we won't use the ToolbarActivity method to initialize the actionbar.
*/
private void initToolbar(String current_dir) {
Toolbar toolbar = findViewById(R.id.standard_toolbar);
ConstraintLayout rootToolbar = findViewById(R.id.root_toolbar);
toolbar.setVisibility(View.VISIBLE);
rootToolbar.setVisibility(View.GONE);
String actionBarTitle;
if (current_dir.equals("")) {
actionBarTitle = getString(R.string.uploader_top_message);
} else {
actionBarTitle = current_dir;
}
toolbar.setTitle(actionBarTitle);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
boolean notRoot = (mParents.size() > 1);
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(notRoot);
actionBar.setHomeButtonEnabled(notRoot);
}
}
use of androidx.constraintlayout.widget.ConstraintLayout in project android by owncloud.
the class FileListListAdapter method getView.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
OCFile file = null;
LayoutInflater inflator = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (mFiles != null && mFiles.size() > position) {
file = mFiles.get(position);
}
// Find out which layout should be displayed
final ViewType viewType;
if (parent instanceof GridView) {
if (file != null && file.isImage()) {
viewType = ViewType.GRID_IMAGE;
} else {
viewType = ViewType.GRID_ITEM;
}
} else {
viewType = ViewType.LIST_ITEM;
}
// create view only if differs, otherwise reuse
if (convertView == null || convertView.getTag() != viewType) {
switch(viewType) {
case GRID_IMAGE:
view = inflator.inflate(R.layout.grid_image, parent, false);
view.setTag(ViewType.GRID_IMAGE);
break;
case GRID_ITEM:
view = inflator.inflate(R.layout.grid_item, parent, false);
view.setTag(ViewType.GRID_ITEM);
break;
case LIST_ITEM:
view = inflator.inflate(R.layout.item_file_list, parent, false);
view.setTag(ViewType.LIST_ITEM);
// Allow or disallow touches with other visible windows
view.setFilterTouchesWhenObscured(PreferenceUtils.shouldDisallowTouchesWithOtherVisibleWindows(mContext));
break;
}
}
if (file != null) {
final ImageView localStateView = view.findViewById(R.id.localFileIndicator);
final ImageView fileIcon = view.findViewById(R.id.thumbnail);
fileIcon.setTag(file.getFileId());
TextView fileName;
String name = file.getFileName();
final LinearLayout linearLayout = view.findViewById(R.id.ListItemLayout);
if (linearLayout != null) {
linearLayout.setContentDescription("LinearLayout-" + name);
// Allow or disallow touches with other visible windows
linearLayout.setFilterTouchesWhenObscured(PreferenceUtils.shouldDisallowTouchesWithOtherVisibleWindows(mContext));
}
switch(viewType) {
case LIST_ITEM:
ConstraintLayout constraintLayout = view.findViewById(R.id.file_list_constraint_layout);
// Allow or disallow touches with other visible windows
constraintLayout.setFilterTouchesWhenObscured(PreferenceUtils.shouldDisallowTouchesWithOtherVisibleWindows(mContext));
TextView fileSizeTV = view.findViewById(R.id.file_list_size);
TextView lastModTV = view.findViewById(R.id.file_list_last_mod);
fileSizeTV.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength(), mContext));
lastModTV.setText(DisplayUtils.getRelativeTimestamp(mContext, file.getModificationTimestamp()));
if (mOnlyAvailableOffline || mSharedByLinkFiles) {
TextView filePath = view.findViewById(R.id.file_list_path);
filePath.setVisibility(View.VISIBLE);
filePath.setText(file.getRemotePath());
}
case GRID_ITEM:
// filename
fileName = view.findViewById(R.id.Filename);
name = file.getFileName();
fileName.setText(name);
case GRID_IMAGE:
// sharedIcon
ImageView sharedIconV = view.findViewById(R.id.sharedIcon);
if (file.isSharedViaLink()) {
sharedIconV.setImageResource(R.drawable.ic_shared_by_link);
sharedIconV.setVisibility(View.VISIBLE);
sharedIconV.bringToFront();
} else if (file.isSharedWithSharee() || file.isSharedWithMe()) {
sharedIconV.setImageResource(R.drawable.shared_via_users);
sharedIconV.setVisibility(View.VISIBLE);
sharedIconV.bringToFront();
} else {
sharedIconV.setVisibility(View.GONE);
}
break;
}
// For all Views
setIconPinAccordingToFilesLocalState(localStateView, file);
final ImageView checkBoxV = view.findViewById(R.id.custom_checkbox);
checkBoxV.setVisibility(View.GONE);
view.setBackgroundColor(Color.WHITE);
AbsListView parentList = (AbsListView) parent;
if (parentList.getChoiceMode() != AbsListView.CHOICE_MODE_NONE && parentList.getCheckedItemCount() > 0) {
if (parentList.isItemChecked(position)) {
view.setBackgroundColor(mContext.getResources().getColor(R.color.selected_item_background));
checkBoxV.setImageResource(R.drawable.ic_checkbox_marked);
} else {
view.setBackgroundColor(Color.WHITE);
checkBoxV.setImageResource(R.drawable.ic_checkbox_blank_outline);
}
checkBoxV.setVisibility(View.VISIBLE);
}
if (file.isFolder()) {
// Folder
fileIcon.setImageResource(MimetypeIconUtil.getFolderTypeIconId(file.isSharedWithMe() || file.isSharedWithSharee(), file.isSharedViaLink()));
} else {
// Set file icon depending on its mimetype. Ask for thumbnail later.
fileIcon.setImageResource(MimetypeIconUtil.getFileTypeIconId(file.getMimetype(), file.getFileName()));
if (file.getRemoteId() != null) {
// Thumbnail in Cache?
Bitmap thumbnail = ThumbnailsCacheManager.getBitmapFromDiskCache(file.getRemoteId());
if (thumbnail != null) {
fileIcon.setImageBitmap(thumbnail);
}
if (file.needsUpdateThumbnail()) {
// generate new Thumbnail
if (ThumbnailsCacheManager.cancelPotentialThumbnailWork(file, fileIcon)) {
final ThumbnailsCacheManager.ThumbnailGenerationTask task = new ThumbnailsCacheManager.ThumbnailGenerationTask(fileIcon, mStorageManager, mAccount);
final ThumbnailsCacheManager.AsyncThumbnailDrawable asyncDrawable = new ThumbnailsCacheManager.AsyncThumbnailDrawable(mContext.getResources(), thumbnail, task);
// If drawable is not visible, do not update it.
if (asyncDrawable.getMinimumHeight() > 0 && asyncDrawable.getMinimumWidth() > 0) {
fileIcon.setImageDrawable(asyncDrawable);
}
task.execute(file);
}
}
if (file.getMimetype().equalsIgnoreCase("image/png")) {
fileIcon.setBackgroundColor(mContext.getResources().getColor(R.color.background_color));
}
}
}
}
return view;
}
Aggregations