Search in sources :

Example 46 with Snackbar

use of android.support.design.widget.Snackbar in project gene-rate by Pixplicity.

the class Rate method showRatingSnackbar.

private void showRatingSnackbar() {
    // Wie is hier nou de snackbar?
    final Snackbar snackbar = Snackbar.make(mParentView, mMessage, mSnackBarSwipeToDismiss ? Snackbar.LENGTH_INDEFINITE : Snackbar.LENGTH_LONG);
    Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout) snackbar.getView();
    // Hide default text
    TextView textView = layout.findViewById(android.support.design.R.id.snackbar_text);
    textView.setVisibility(View.INVISIBLE);
    // Inflate our custom view
    final LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    assert inflater != null;
    @SuppressLint("InflateParams") View snackView = inflater.inflate(R.layout.in_snackbar, null);
    // Configure the view
    TextView tvMessage = snackView.findViewById(R.id.text);
    tvMessage.setText(mMessage);
    final CheckBox cbNever = snackView.findViewById(R.id.cb_never);
    cbNever.setText(mTextNever);
    cbNever.setChecked(DEFAULT_CHECKED);
    final Button btFeedback = snackView.findViewById(R.id.bt_negative);
    btFeedback.setPaintFlags(btFeedback.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    final Button btRate = snackView.findViewById(R.id.bt_positive);
    snackView.findViewById(R.id.tv_swipe).setVisibility(mSnackBarSwipeToDismiss ? View.VISIBLE : View.GONE);
    // Remember to not ask again if user swiped it
    snackbar.addCallback(new Snackbar.Callback() {

        @Override
        public void onDismissed(Snackbar transientBottomBar, @DismissEvent int event) {
            super.onDismissed(transientBottomBar, event);
            if (event == Snackbar.Callback.DISMISS_EVENT_SWIPE && cbNever.isChecked()) {
                saveAsked();
            }
            mFeedbackAction.onRequestDismissed(cbNever.isChecked());
        }
    });
    // Rate listener
    btRate.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            snackbar.dismiss();
            openPlayStore();
            saveAsked();
            mFeedbackAction.onRateTapped();
        }
    });
    // Feedback listener
    if (mFeedbackAction != null) {
        btFeedback.setText(mTextNegative);
        btFeedback.setVisibility(View.VISIBLE);
        btFeedback.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (cbNever.isChecked()) {
                    saveAsked();
                }
                snackbar.dismiss();
                mFeedbackAction.onFeedbackTapped();
            }
        });
    }
    // Checkbox listener
    cbNever.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton button, boolean checked) {
            mPrefs.edit().putBoolean(KEY_BOOL_ASKED, checked).apply();
        }
    });
    // Add the view to the Snackbar's layout
    layout.addView(snackView, 0);
    // Show the Snackbar
    snackbar.show();
}
Also used : OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) View(android.view.View) TextView(android.widget.TextView) SuppressLint(android.annotation.SuppressLint) Paint(android.graphics.Paint) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) CheckBox(android.widget.CheckBox) LayoutInflater(android.view.LayoutInflater) SuppressLint(android.annotation.SuppressLint) TextView(android.widget.TextView) CompoundButton(android.widget.CompoundButton) Snackbar(android.support.design.widget.Snackbar)

Example 47 with Snackbar

use of android.support.design.widget.Snackbar in project zype-android by zype.

the class UiUtils method showWarningSnackbar.

public static void showWarningSnackbar(View view, String text) {
    if (view == null) {
        return;
    }
    Snackbar snackbar = Snackbar.make(view, text, Snackbar.LENGTH_LONG);
    View snackView = snackbar.getView();
    snackView.setBackgroundColor(view.getContext().getResources().getColor(R.color.snackbar_warning));
    snackbar.show();
}
Also used : ImageView(android.widget.ImageView) View(android.view.View) Snackbar(android.support.design.widget.Snackbar)

Example 48 with Snackbar

use of android.support.design.widget.Snackbar in project zype-android by zype.

the class UiUtils method showErrorSnackbar.

public static void showErrorSnackbar(@Nullable final View view, @NonNull final String text) {
    if (view == null) {
        return;
    }
    Snackbar snackbar = Snackbar.make(view, text, Snackbar.LENGTH_LONG);
    View snackView = snackbar.getView();
    snackView.setBackgroundColor(view.getContext().getResources().getColor(R.color.snackbar_error));
    snackbar.show();
}
Also used : ImageView(android.widget.ImageView) View(android.view.View) Snackbar(android.support.design.widget.Snackbar)

Example 49 with Snackbar

use of android.support.design.widget.Snackbar in project TinyKeePass by sorz.

the class EntryFragment method copyEntry.

private void copyEntry(Entry entry, boolean copyUsername, boolean copyPassword) {
    if (copyUsername && notEmpty(entry.getUsername())) {
        clipboardManager.setPrimaryClip(ClipData.newPlainText(getString(R.string.username), entry.getUsername()));
        String message = getString(R.string.username_copied, entry.getUsername());
        if (getView() == null) {
            Toast.makeText(getContext(), message, Toast.LENGTH_SHORT).show();
        } else {
            Snackbar snackbar = Snackbar.make(getView(), message, Snackbar.LENGTH_LONG);
            if (copyPassword)
                snackbar.setAction(R.string.copy_password, v -> copyPassword(entry));
            snackbar.show();
        }
    }
    if (copyPassword && notEmpty(entry.getPassword())) {
        if (copyUsername && notEmpty(entry.getUsername())) {
            // username already copied, waiting for user's action before copy password.
            Intent intent = new Intent(getContext(), PasswordCopingService.class);
            intent.setAction(PasswordCopingService.ACTION_NEW_NOTIFICATION);
            intent.putExtra(PasswordCopingService.EXTRA_PASSWORD, entry.getPassword());
            if (entry.getUsername() != null)
                intent.putExtra(PasswordCopingService.EXTRA_USERNAME, entry.getUsername());
            if (entry.getTitle() != null)
                intent.putExtra(PasswordCopingService.EXTRA_ENTRY_TITLE, entry.getTitle());
            getContext().startService(intent);
        } else {
            // username not copied, copy password immediately.
            copyPassword(entry);
        }
    }
}
Also used : Context(android.content.Context) ActionMode(android.view.ActionMode) Bundle(android.os.Bundle) FloatingActionButton(android.support.design.widget.FloatingActionButton) LayoutInflater(android.view.LayoutInflater) IntentFilter(android.content.IntentFilter) Uri(android.net.Uri) Intent(android.content.Intent) SystemClock(android.os.SystemClock) LocalBroadcastManager(android.support.v4.content.LocalBroadcastManager) BroadcastReceiver(android.content.BroadcastReceiver) ViewGroup(android.view.ViewGroup) MenuItem(android.view.MenuItem) ClipData(android.content.ClipData) KeePassStorage(org.sorz.lab.tinykeepass.keepass.KeePassStorage) MenuInflater(android.view.MenuInflater) Toast(android.widget.Toast) Menu(android.view.Menu) ClipboardManager(android.content.ClipboardManager) View(android.view.View) Snackbar(android.support.design.widget.Snackbar) Entry(de.slackspace.openkeepass.domain.Entry) KeePassHelper.notEmpty(org.sorz.lab.tinykeepass.keepass.KeePassHelper.notEmpty) Intent(android.content.Intent) Snackbar(android.support.design.widget.Snackbar)

Example 50 with Snackbar

use of android.support.design.widget.Snackbar in project bugzy by cpunq.

the class CaseDetailsFragment method getSyncSnackbar.

public Snackbar getSyncSnackbar() {
    Snackbar bar = Snackbar.make(getView(), "Syncing case details..", Snackbar.LENGTH_INDEFINITE);
    ViewGroup contentLay = (ViewGroup) bar.getView().findViewById(android.support.design.R.id.snackbar_text).getParent();
    ProgressBar item = new ProgressBar(getContext());
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(inDp(24), inDp(24));
    params.gravity = Gravity.CENTER_VERTICAL;
    item.setLayoutParams(params);
    contentLay.addView(item, 0);
    return bar;
}
Also used : ViewGroup(android.view.ViewGroup) ProgressBar(android.widget.ProgressBar) LinearLayout(android.widget.LinearLayout) Snackbar(android.support.design.widget.Snackbar)

Aggregations

Snackbar (android.support.design.widget.Snackbar)102 View (android.view.View)56 TextView (android.widget.TextView)25 Intent (android.content.Intent)13 RecyclerView (android.support.v7.widget.RecyclerView)13 BaseTransientBottomBar (android.support.design.widget.BaseTransientBottomBar)10 ImageView (android.widget.ImageView)10 ViewGroup (android.view.ViewGroup)8 DialogInterface (android.content.DialogInterface)7 LayoutInflater (android.view.LayoutInflater)6 AdapterView (android.widget.AdapterView)6 LinearLayout (android.widget.LinearLayout)6 ListView (android.widget.ListView)6 ItemTouchHelper (android.support.v7.widget.helper.ItemTouchHelper)5 AlertDialog (android.app.AlertDialog)4 Context (android.content.Context)4 Nullable (android.support.annotation.Nullable)4 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)4 File (java.io.File)4 RemindyDAO (ve.com.abicelis.remindy.database.RemindyDAO)4