use of android.support.v7.widget.CardView in project LeafPic by HoraApps.
the class MapProviderSetting method choseProvider.
public void choseProvider() {
final AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), getActivity().getDialogStyle());
View dialogLayout = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_map_provider, null);
TextView dialogTitle = (TextView) dialogLayout.findViewById(R.id.title);
((CardView) dialogLayout.findViewById(R.id.dialog_chose_provider_title)).setCardBackgroundColor(getActivity().getCardBackgroundColor());
dialogTitle.setBackgroundColor(getActivity().getPrimaryColor());
final RadioGroup mapProvider = (RadioGroup) dialogLayout.findViewById(R.id.radio_group_maps_provider);
RadioButton radioGoogleMaps = (RadioButton) dialogLayout.findViewById(R.id.radio_google_maps);
RadioButton radioMapBoxStreets = (RadioButton) dialogLayout.findViewById(R.id.radio_mapb_streets);
RadioButton radioMapBoxDark = (RadioButton) dialogLayout.findViewById(R.id.radio_mapb_dark);
RadioButton radioMapBoxLight = (RadioButton) dialogLayout.findViewById(R.id.radio_mapb_light);
RadioButton radioTyler = (RadioButton) dialogLayout.findViewById(R.id.radio_osm_tyler);
getActivity().themeRadioButton(radioGoogleMaps);
getActivity().themeRadioButton(radioMapBoxStreets);
getActivity().themeRadioButton(radioMapBoxDark);
getActivity().themeRadioButton(radioMapBoxLight);
getActivity().themeRadioButton(radioTyler);
((TextView) dialogLayout.findViewById(R.id.header_proprietary_maps)).setTextColor(getActivity().getTextColor());
((TextView) dialogLayout.findViewById(R.id.header_free_maps)).setTextColor(getActivity().getTextColor());
switch(StaticMapProvider.fromValue(Hawk.get(getActivity().getString(R.string.preference_map_provider), StaticMapProvider.GOOGLE_MAPS.getValue()))) {
case GOOGLE_MAPS:
default:
radioGoogleMaps.setChecked(true);
break;
case MAP_BOX:
radioMapBoxStreets.setChecked(true);
break;
case MAP_BOX_DARK:
radioMapBoxDark.setChecked(true);
break;
case MAP_BOX_LIGHT:
radioMapBoxLight.setChecked(true);
break;
case TYLER:
radioTyler.setChecked(true);
break;
}
dialogBuilder.setNegativeButton(getActivity().getString(R.string.cancel).toUpperCase(), null);
dialogBuilder.setPositiveButton(getActivity().getString(R.string.ok_action).toUpperCase(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch(mapProvider.getCheckedRadioButtonId()) {
case R.id.radio_google_maps:
default:
Hawk.put(getActivity().getString(R.string.preference_map_provider), StaticMapProvider.GOOGLE_MAPS.getValue());
break;
case R.id.radio_mapb_streets:
Hawk.put(getActivity().getString(R.string.preference_map_provider), StaticMapProvider.MAP_BOX.getValue());
break;
case R.id.radio_osm_tyler:
Hawk.put(getActivity().getString(R.string.preference_map_provider), StaticMapProvider.TYLER.getValue());
break;
case R.id.radio_mapb_dark:
Hawk.put(getActivity().getString(R.string.preference_map_provider), StaticMapProvider.MAP_BOX_DARK.getValue());
break;
case R.id.radio_mapb_light:
Hawk.put(getActivity().getString(R.string.preference_map_provider), StaticMapProvider.MAP_BOX_LIGHT.getValue());
break;
}
}
});
dialogBuilder.setView(dialogLayout);
dialogBuilder.show();
}
use of android.support.v7.widget.CardView in project LeafPic by HoraApps.
the class AlertDialogsHelper method getProgressDialogWithErrors.
public static AlertDialog getProgressDialogWithErrors(ThemedActivity activity, @StringRes int title, ProgressAdapter adapter, int max) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity, activity.getDialogStyle());
View dialogLayout = activity.getLayoutInflater().inflate(R.layout.dialog_list_progress, null);
final int[] progress = { 0 };
TextView dialogTitle = dialogLayout.findViewById(R.id.text_dialog_title);
TextView progressMessage = dialogLayout.findViewById(R.id.name_folder);
((ProgressBar) dialogLayout.findViewById(org.horaapps.leafpic.R.id.progress_dialog_loading)).getIndeterminateDrawable().setColorFilter(activity.getPrimaryColor(), android.graphics.PorterDuff.Mode.SRC_ATOP);
adapter.setListener(item -> {
progress[0]++;
dialogTitle.setText(activity.getString(title, progress[0], max));
progressMessage.setText(item.getName());
});
RecyclerView rv = dialogLayout.findViewById(R.id.rv_progress);
rv.setLayoutManager(new LinearLayoutManager(activity));
rv.setHasFixedSize(true);
rv.setItemAnimator(AnimationUtils.getItemAnimator(new LandingAnimator(new OvershootInterpolator(1f))));
rv.setAdapter(adapter);
((CardView) dialogLayout.findViewById(org.horaapps.leafpic.R.id.message_card)).setCardBackgroundColor(activity.getCardBackgroundColor());
dialogTitle.setBackgroundColor(activity.getPrimaryColor());
dialogTitle.setText(activity.getString(title, progress[0], max));
builder.setView(dialogLayout);
return builder.create();
}
use of android.support.v7.widget.CardView in project LeafPic by HoraApps.
the class AlertDialogsHelper method getInsertTextDialog.
public static AlertDialog getInsertTextDialog(ThemedActivity activity, EditText editText, @StringRes int title) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(activity, activity.getDialogStyle());
View dialogLayout = activity.getLayoutInflater().inflate(org.horaapps.leafpic.R.layout.dialog_insert_text, null);
TextView textViewTitle = dialogLayout.findViewById(R.id.rename_title);
((CardView) dialogLayout.findViewById(org.horaapps.leafpic.R.id.dialog_chose_provider_title)).setCardBackgroundColor(activity.getCardBackgroundColor());
textViewTitle.setBackgroundColor(activity.getPrimaryColor());
textViewTitle.setText(title);
ThemeHelper.setCursorColor(editText, activity.getTextColor());
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
editText.setLayoutParams(layoutParams);
editText.setSingleLine(true);
editText.getBackground().mutate().setColorFilter(activity.getTextColor(), PorterDuff.Mode.SRC_IN);
editText.setTextColor(activity.getTextColor());
try {
Field f = TextView.class.getDeclaredField("mCursorDrawableRes");
f.setAccessible(true);
f.set(editText, null);
} catch (Exception ignored) {
}
((RelativeLayout) dialogLayout.findViewById(org.horaapps.leafpic.R.id.container_edit_text)).addView(editText);
dialogBuilder.setView(dialogLayout);
return dialogBuilder.create();
}
use of android.support.v7.widget.CardView in project LeafPic by HoraApps.
the class AlertDialogsHelper method getTextDialog.
public static AlertDialog getTextDialog(ThemedActivity activity, @StringRes int title, @StringRes int Message) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity, activity.getDialogStyle());
View dialogLayout = activity.getLayoutInflater().inflate(R.layout.dialog_text, null);
TextView dialogTitle = dialogLayout.findViewById(R.id.text_dialog_title);
TextView dialogMessage = dialogLayout.findViewById(R.id.text_dialog_message);
((CardView) dialogLayout.findViewById(org.horaapps.leafpic.R.id.message_card)).setCardBackgroundColor(activity.getCardBackgroundColor());
dialogTitle.setBackgroundColor(activity.getPrimaryColor());
dialogTitle.setText(title);
dialogMessage.setText(Message);
dialogMessage.setTextColor(activity.getTextColor());
builder.setView(dialogLayout);
return builder.create();
}
use of android.support.v7.widget.CardView in project LeafPic by HoraApps.
the class Security method authenticateUser.
public static void authenticateUser(final ThemedActivity activity, final AuthCallBack passwordInterface) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity, activity.getDialogStyle());
CancellationSignal mCancellationSignal = new CancellationSignal();
final View view = activity.getLayoutInflater().inflate(org.horaapps.leafpic.R.layout.dialog_password, null);
final TextView passwordDialogTitle = view.findViewById(org.horaapps.leafpic.R.id.password_dialog_title);
final CardView passwordDialogCard = view.findViewById(org.horaapps.leafpic.R.id.password_dialog_card);
final EditText editTextPassword = view.findViewById(org.horaapps.leafpic.R.id.password_edittxt);
final ThemedIcon fingerprintIcon = view.findViewById(R.id.fingerprint_icon);
passwordDialogTitle.setBackgroundColor(activity.getPrimaryColor());
passwordDialogCard.setBackgroundColor(activity.getCardBackgroundColor());
ThemeHelper.setCursorColor(editTextPassword, activity.getTextColor());
editTextPassword.getBackground().mutate().setColorFilter(activity.getTextColor(), PorterDuff.Mode.SRC_ATOP);
editTextPassword.setTextColor(activity.getTextColor());
fingerprintIcon.setColor(activity.getIconColor());
builder.setView(view);
builder.setPositiveButton(activity.getString(R.string.ok_action).toUpperCase(), (dialog, which) -> {
// NOTE: set this empty, later will be overwrite to avoid the dismiss
});
builder.setNegativeButton(activity.getString(R.string.cancel).toUpperCase(), (dialog, which) -> hideKeyboard(activity, editTextPassword.getWindowToken()));
final AlertDialog dialog = builder.create();
dialog.show();
showKeyboard(activity);
editTextPassword.requestFocus();
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M && Security.isFingerprintUsed()) {
FingerprintHandler fingerprintHandler = new FingerprintHandler(activity, mCancellationSignal);
if (fingerprintHandler.isFingerprintSupported()) {
fingerprintHandler.setOnFingerprintResult(new FingerprintHandler.CallBack() {
@Override
public void onSuccess() {
hideKeyboard(activity, editTextPassword.getWindowToken());
dialog.dismiss();
passwordInterface.onAuthenticated();
}
@Override
public void onError(String s) {
// TODO: 9/9/17 siplaymessage
}
});
fingerprintHandler.startAuth();
} else {
fingerprintIcon.setVisibility(View.GONE);
}
} else {
fingerprintIcon.setVisibility(View.GONE);
}
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(v -> {
if (checkPassword(editTextPassword.getText().toString())) {
hideKeyboard(activity, editTextPassword.getWindowToken());
mCancellationSignal.cancel();
dialog.dismiss();
passwordInterface.onAuthenticated();
} else {
editTextPassword.getText().clear();
editTextPassword.requestFocus();
passwordInterface.onError();
}
});
}
Aggregations