Search in sources :

Example 1 with MaterialCardView

use of com.google.android.material.card.MaterialCardView in project AppManager by MuntashirAkon.

the class ScannerActivity method setLibraryInfo.

private void setLibraryInfo() {
    ArrayList<String> missingLibs = new ArrayList<>();
    String[] libNames = getResources().getStringArray(R.array.lib_names);
    String[] libSignatures = getResources().getStringArray(R.array.lib_signatures);
    String[] libTypes = getResources().getStringArray(R.array.lib_types);
    // The following array is directly mapped to the arrays above
    int[] signatureCount = new int[libSignatures.length];
    // Iterate over all classes
    for (String className : model.getClassListAll()) {
        if (className.length() > 8 && className.contains(".")) {
            boolean matched = false;
            // This is a greedy algorithm, only matches the first item
            for (int i = 0; i < libSignatures.length; i++) {
                if (className.contains(libSignatures[i])) {
                    matched = true;
                    // Add to found classes
                    libClassList.add(className);
                    // Increment this signature match count
                    signatureCount[i]++;
                    break;
                }
            }
            // Add the class to the missing libs list if it doesn't match the filters
            if (!matched && (mPackageName != null && !className.startsWith(mPackageName)) && !className.matches(SIG_TO_IGNORE)) {
                missingLibs.add(className);
            }
        }
    }
    Map<String, SpannableStringBuilder> foundLibInfoMap = new ArrayMap<>();
    foundLibInfoMap.putAll(getNativeLibraryInfo(false));
    // Iterate over signatures again but this time list only the found ones.
    for (int i = 0; i < libSignatures.length; i++) {
        if (signatureCount[i] == 0)
            continue;
        if (foundLibInfoMap.get(libNames[i]) == null) {
            // Add the lib info since it isn't added already
            foundLibInfoMap.put(libNames[i], new SpannableStringBuilder().append(getPrimaryText(this, libNames[i])).append(getSmallerText(" (" + libTypes[i] + ")")));
        }
        // noinspection ConstantConditions Never null here
        foundLibInfoMap.get(libNames[i]).append("\n").append(getMonospacedText(libSignatures[i])).append(getSmallerText(" (" + signatureCount[i] + ")"));
    }
    Set<String> foundLibNames = foundLibInfoMap.keySet();
    List<Spannable> foundLibInfoList = new ArrayList<>(foundLibInfoMap.values());
    int totalLibsFound = foundLibInfoList.size();
    Collections.sort(foundLibInfoList, (o1, o2) -> o1.toString().compareToIgnoreCase(o2.toString()));
    Spanned foundLibsInfo = getOrderedList(foundLibInfoList);
    String summary;
    if (totalLibsFound == 0) {
        summary = getString(R.string.no_libs);
    } else {
        summary = getResources().getQuantityString(R.plurals.libraries, totalLibsFound, totalLibsFound);
    }
    runOnUiThread(() -> {
        ((TextView) findViewById(R.id.libs_title)).setText(summary);
        ((TextView) findViewById(R.id.libs_description)).setText(TextUtils.join(", ", foundLibNames));
        if (totalLibsFound == 0)
            return;
        MaterialCardView libsView = findViewById(R.id.libs);
        libsView.setOnClickListener(v -> new ScrollableDialogBuilder(this, foundLibsInfo).setTitle(new DialogTitleBuilder(this).setTitle(R.string.lib_details).setSubtitle(summary).build()).setNegativeButton(R.string.ok, null).setNeutralButton(R.string.copy, (dialog, which, isChecked) -> {
            ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
            ClipData clip = ClipData.newPlainText(getString(R.string.signatures), foundLibsInfo);
            clipboard.setPrimaryClip(clip);
            Snackbar.make(libsView, R.string.copied_to_clipboard, Snackbar.LENGTH_SHORT).show();
        }).show());
        // Missing libs
        if (missingLibs.size() > 0) {
            ((TextView) findViewById(R.id.missing_libs_title)).setText(getResources().getQuantityString(R.plurals.missing_signatures, missingLibs.size(), missingLibs.size()));
            View view = findViewById(R.id.missing_libs);
            view.setVisibility(View.VISIBLE);
            view.setOnClickListener(v -> new SearchableMultiChoiceDialogBuilder<>(this, missingLibs, ArrayUtils.toCharSequence(missingLibs)).setTitle(R.string.signatures).showSelectAll(false).setNegativeButton(R.string.ok, null).setNeutralButton(R.string.send_selected, (dialog, which, selectedItems) -> {
                Intent i = new Intent(Intent.ACTION_SEND);
                i.setType("message/rfc822");
                i.putExtra(Intent.EXTRA_EMAIL, new String[] { "muntashirakon@riseup.net" });
                i.putExtra(Intent.EXTRA_SUBJECT, "App Manager: Missing signatures");
                i.putExtra(Intent.EXTRA_TEXT, selectedItems.toString());
                startActivity(Intent.createChooser(i, getText(R.string.signatures)));
            }).show());
        }
    });
}
Also used : ClipboardManager(android.content.ClipboardManager) ArrayList(java.util.ArrayList) ArrayMap(androidx.collection.ArrayMap) Intent(android.content.Intent) SpannableString(android.text.SpannableString) Spanned(android.text.Spanned) View(android.view.View) TextView(android.widget.TextView) MaterialCardView(com.google.android.material.card.MaterialCardView) MaterialCardView(com.google.android.material.card.MaterialCardView) SearchableMultiChoiceDialogBuilder(io.github.muntashirakon.AppManager.types.SearchableMultiChoiceDialogBuilder) TextView(android.widget.TextView) ScrollableDialogBuilder(io.github.muntashirakon.dialog.ScrollableDialogBuilder) ClipData(android.content.ClipData) SpannableStringBuilder(android.text.SpannableStringBuilder) Spannable(android.text.Spannable) DialogTitleBuilder(io.github.muntashirakon.dialog.DialogTitleBuilder)

Example 2 with MaterialCardView

use of com.google.android.material.card.MaterialCardView in project luckyzyxtools by luckyzyx.

the class UserFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    MaterialCardView user = requireActivity().findViewById(R.id.user);
    user.setOnClickListener(v -> Snackbar.make(v, "不认识字? 还点?", Snackbar.LENGTH_SHORT).show());
    MaterialCardView checkupdate_card = requireActivity().findViewById(R.id.checkupdate_card);
    checkupdate_card.setOnClickListener(v -> new HttpUtils(requireActivity()).CheckUpdate(true));
    MaterialCardView settings = requireActivity().findViewById(R.id.settings_card);
    settings.setOnClickListener(v -> startActivity(new Intent(getActivity(), SettingsActivity.class)));
    MaterialCardView about = requireActivity().findViewById(R.id.about_card);
    about.setOnClickListener(v -> startActivity(new Intent(getActivity(), AboutActivity.class)));
}
Also used : MaterialCardView(com.google.android.material.card.MaterialCardView) HttpUtils(com.luckyzyx.tools.utils.HttpUtils) Intent(android.content.Intent)

Example 3 with MaterialCardView

use of com.google.android.material.card.MaterialCardView in project android-java-chat-push-notification-app by cometchat-pro.

the class CometChatMessageList method createPollDialog.

private void createPollDialog() {
    AlertDialog.Builder alertDialog = new AlertDialog.Builder(context, R.style.MyDialogTheme);
    View view = LayoutInflater.from(context).inflate(R.layout.add_polls_layout, null);
    alertDialog.setView(view);
    Dialog dialog = alertDialog.create();
    optionsArrayList.clear();
    EditText questionEdt = view.findViewById(R.id.question_edt);
    View option1 = view.findViewById(R.id.option_1);
    View option2 = view.findViewById(R.id.option_2);
    option1.findViewById(R.id.delete_option).setVisibility(GONE);
    option2.findViewById(R.id.delete_option).setVisibility(GONE);
    MaterialCardView addOption = view.findViewById(R.id.add_options);
    LinearLayout optionLayout = view.findViewById(R.id.options_layout);
    MaterialButton addPoll = view.findViewById(R.id.add_poll);
    addPoll.setBackgroundColor(Color.parseColor(UIKitSettings.getColor()));
    ImageView cancelPoll = view.findViewById(R.id.close_poll);
    addOption.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            View optionView = LayoutInflater.from(context).inflate(R.layout.polls_option, null);
            optionsArrayList.add(optionView);
            optionLayout.addView(optionView);
            optionView.findViewById(R.id.delete_option).setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    optionsArrayList.remove(optionView);
                    optionLayout.removeView(optionView);
                }
            });
        }
    });
    addPoll.setEnabled(true);
    addPoll.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            questionEdt.requestFocus();
            EditText option1Text = option1.findViewById(R.id.option_txt);
            EditText option2Text = option2.findViewById(R.id.option_txt);
            if (questionEdt.getText().toString().trim().isEmpty())
                questionEdt.setError(getString(R.string.fill_this_field));
            else if (option1Text.getText().toString().trim().isEmpty())
                option1Text.setError(getString(R.string.fill_this_field));
            else if (option2Text.getText().toString().trim().isEmpty())
                option2Text.setError(getString(R.string.fill_this_field));
            else {
                ProgressDialog progressDialog;
                progressDialog = ProgressDialog.show(context, "", getResources().getString(R.string.create_a_poll));
                addPoll.setEnabled(false);
                try {
                    JSONArray optionJson = new JSONArray();
                    optionJson.put(option1Text.getText().toString());
                    optionJson.put(option2Text.getText().toString());
                    for (View views : optionsArrayList) {
                        EditText optionsText = views.findViewById(R.id.option_txt);
                        if (!optionsText.getText().toString().trim().isEmpty())
                            optionJson.put(optionsText.getText().toString());
                    }
                    JSONObject jsonObject = new JSONObject();
                    jsonObject.put("question", questionEdt.getText().toString());
                    jsonObject.put("options", optionJson);
                    jsonObject.put("receiver", Id);
                    jsonObject.put("receiverType", type);
                    CometChat.callExtension("polls", "POST", "/v2/create", jsonObject, new CometChat.CallbackListener<JSONObject>() {

                        @Override
                        public void onSuccess(JSONObject jsonObject) {
                            progressDialog.dismiss();
                            dialog.dismiss();
                        }

                        @Override
                        public void onError(CometChatException e) {
                            progressDialog.dismiss();
                            addPoll.setEnabled(true);
                            Log.e(TAG, "onErrorCallExtension: " + e.getMessage());
                            if (view != null)
                                CometChatSnackBar.show(context, view, CometChatError.Extension.localized(e, "polls"), CometChatSnackBar.ERROR);
                        }
                    });
                } catch (Exception e) {
                    addPoll.setEnabled(true);
                    Log.e(TAG, "onErrorJSON: " + e.getMessage());
                    Toast.makeText(context, e.getMessage(), Toast.LENGTH_LONG).show();
                }
            }
        }
    });
    cancelPoll.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();
        }
    });
    dialog.show();
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) EditText(android.widget.EditText) CometChatException(com.cometchat.pro.exceptions.CometChatException) JSONArray(org.json.JSONArray) ProgressDialog(android.app.ProgressDialog) ImageView(android.widget.ImageView) MaterialCardView(com.google.android.material.card.MaterialCardView) StickerView(com.cometchat.pro.uikit.ui_components.shared.cometchatStickers.StickerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) MaterialButton(com.google.android.material.button.MaterialButton) CometChatException(com.cometchat.pro.exceptions.CometChatException) JSONException(org.json.JSONException) MaterialCardView(com.google.android.material.card.MaterialCardView) JSONObject(org.json.JSONObject) Dialog(android.app.Dialog) ProgressDialog(android.app.ProgressDialog) CometChatReactionDialog(com.cometchat.pro.uikit.ui_components.shared.cometchatReaction.CometChatReactionDialog) AlertDialog(androidx.appcompat.app.AlertDialog) ImageView(android.widget.ImageView) LinearLayout(android.widget.LinearLayout)

Example 4 with MaterialCardView

use of com.google.android.material.card.MaterialCardView in project ods-android by Orange-OpenSource.

the class ElevationMainDemoFragment method updateCardsElevationLevel.

// It's safe to use restricted MDC code in MDC Catalog.
@SuppressWarnings("RestrictTo")
private void updateCardsElevationLevel(View view, int newElevationLevel) {
    List<MaterialCardView> elevationCards = DemoUtils.findViewsWithType(view, MaterialCardView.class);
    if (newElevationLevel >= 0 && newElevationLevel <= getMaxElevationValue()) {
        setElevationLevel(newElevationLevel);
        for (MaterialCardView elevationCard : elevationCards) {
            elevationCard.setCardElevation(ViewUtils.dpToPx(view.getContext(), elevationInDp));
        }
        setElevationLevelTextView(view, getElevationLevelText());
    }
}
Also used : MaterialCardView(com.google.android.material.card.MaterialCardView)

Example 5 with MaterialCardView

use of com.google.android.material.card.MaterialCardView in project android-frontend-java by Dezenix.

the class aboutYou method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about_you);
    Objects.requireNonNull(getSupportActionBar()).hide();
    MaterialCardView male, female;
    CardView next;
    next = findViewById(R.id.next);
    birth = findViewById(R.id.birth);
    EditText name = findViewById(R.id.name);
    next.setCardBackgroundColor(getResources().getColor(R.color.pink));
    AtomicReference<String> gender = new AtomicReference<>("");
    male = findViewById(R.id.male);
    female = findViewById(R.id.female);
    male.setOnClickListener(v -> {
        male.setStrokeWidth(5);
        female.setStrokeWidth(0);
        gender.set("male");
    });
    female.setOnClickListener(v -> {
        male.setStrokeWidth(0);
        female.setStrokeWidth(5);
        gender.set("female");
    });
    birth.setOnClickListener(v -> {
        show();
    });
    next.setOnClickListener(v -> {
        if (gender.toString().length() > 0 && name.length() > 0 && birth.getText().length() == 4) {
            Intent intent = new Intent(this, picks.class);
            startActivity(intent);
        } else {
            Toast.makeText(this, "Provide all the details", Toast.LENGTH_SHORT).show();
        }
    });
}
Also used : EditText(android.widget.EditText) MaterialCardView(com.google.android.material.card.MaterialCardView) MaterialCardView(com.google.android.material.card.MaterialCardView) CardView(androidx.cardview.widget.CardView) AtomicReference(java.util.concurrent.atomic.AtomicReference) Intent(android.content.Intent)

Aggregations

MaterialCardView (com.google.android.material.card.MaterialCardView)14 View (android.view.View)8 Intent (android.content.Intent)6 TextView (android.widget.TextView)6 SuppressLint (android.annotation.SuppressLint)4 EditText (android.widget.EditText)4 AlertDialog (androidx.appcompat.app.AlertDialog)4 CardView (androidx.cardview.widget.CardView)4 MaterialAlertDialogBuilder (com.google.android.material.dialog.MaterialAlertDialogBuilder)4 Uri (android.net.Uri)3 Button (android.widget.Button)3 ImageView (android.widget.ImageView)3 ListView (android.widget.ListView)3 ClipData (android.content.ClipData)2 ClipboardManager (android.content.ClipboardManager)2 Bundle (android.os.Bundle)2 Spannable (android.text.Spannable)2 SpannableString (android.text.SpannableString)2 SpannableStringBuilder (android.text.SpannableStringBuilder)2 Spanned (android.text.Spanned)2