use of com.eveningoutpost.dexdrip.UtilityModels.JamorhamShowcaseDrawer in project xDrip-plus by jamorham.
the class Reminders method showcase.
private static void showcase(final Activity activity, final int which) {
final ViewTarget target;
final String title;
final String message;
int size1 = 200;
int size2 = 70;
long delay = 1000;
final boolean oneshot = true;
final int option = which;
if ((oneshot) && (ShotStateStore.hasShot(option)))
return;
switch(which) {
case Home.SHOWCASE_REMINDER1:
target = new ViewTarget(R.id.fab, activity);
title = xdrip.getAppContext().getString(R.string.title_You_have_no_reminders_yet);
message = xdrip.getAppContext().getString(R.string.message_reminders_explanation);
delay = 200;
break;
case Home.SHOWCASE_REMINDER2:
target = null;
title = xdrip.getAppContext().getString(R.string.title_swipe_reminder);
message = xdrip.getAppContext().getString(R.string.message_swipe_explanation);
break;
case Home.SHOWCASE_REMINDER3:
target = new ViewTarget(R.id.imageButton5, activity);
title = xdrip.getAppContext().getString(R.string.title_reminder_snooze_undo);
message = xdrip.getAppContext().getString(R.string.message_snooze_explanaition_undo);
break;
case Home.SHOWCASE_REMINDER4:
target = new ViewTarget(R.id.reminderTrashButton, activity);
title = xdrip.getAppContext().getString(R.string.title_snooze_trash);
message = xdrip.getAppContext().getString(R.string.message_snooze_trash);
delay = 10;
break;
case Home.SHOWCASE_REMINDER5:
target = new ViewTarget(R.id.imageButton7, activity);
title = xdrip.getAppContext().getString(R.string.title_snooze_hide);
message = xdrip.getAppContext().getString(R.string.message_snooze_hide);
delay = 10;
break;
case Home.SHOWCASE_REMINDER6:
target = new ViewTarget(R.id.button5, activity);
title = xdrip.getAppContext().getString(R.string.title_snooze_times);
message = xdrip.getAppContext().getString(R.string.message_snooze_times);
delay = 10;
break;
default:
return;
}
final int f_size1 = size1;
final int f_size2 = size2;
JoH.runOnUiThreadDelayed(new Runnable() {
@Override
public void run() {
final ShowcaseView myShowcase;
if (target != null) {
myShowcase = new ShowcaseView.Builder(activity).setStyle(R.style.CustomShowcaseTheme2).setContentTitle(title).setTarget(target).blockAllTouches().setContentText("\n" + message).setShowcaseDrawer(new JamorhamShowcaseDrawer(activity.getResources(), activity.getTheme(), f_size1, f_size2, 255)).singleShot(oneshot ? option : -1).build();
} else {
myShowcase = new ShowcaseView.Builder(activity).setStyle(R.style.CustomShowcaseTheme2).setContentTitle(title).blockAllTouches().setContentText("\n" + message).setShowcaseDrawer(new JamorhamShowcaseDrawer(activity.getResources(), activity.getTheme(), f_size1, f_size2, 255)).singleShot(oneshot ? option : -1).build();
}
myShowcase.setTag(which);
myShowcase.setBackgroundColor(Color.TRANSPARENT);
myShowcase.setShouldCentreText(false);
myShowcase.setOnShowcaseEventListener(new OnShowcaseEventListener() {
@Override
public void onShowcaseViewHide(ShowcaseView showcaseView) {
}
@Override
public void onShowcaseViewDidHide(ShowcaseView showcaseView) {
switch((int) showcaseView.getTag()) {
case Home.SHOWCASE_REMINDER3:
showcase(activity, Home.SHOWCASE_REMINDER4);
break;
case Home.SHOWCASE_REMINDER4:
showcase(activity, Home.SHOWCASE_REMINDER5);
break;
case Home.SHOWCASE_REMINDER5:
showcase(activity, Home.SHOWCASE_REMINDER6);
break;
}
}
@Override
public void onShowcaseViewShow(ShowcaseView showcaseView) {
}
@Override
public void onShowcaseViewTouchBlocked(MotionEvent motionEvent) {
}
});
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
int margin = (int) activity.getResources().getDimension(R.dimen.button_margin);
params.setMargins(margin, margin, margin, margin);
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
myShowcase.setButtonPosition(params);
myShowcase.show();
}
}, delay);
}
use of com.eveningoutpost.dexdrip.UtilityModels.JamorhamShowcaseDrawer in project xDrip-plus by jamorham.
the class Home method showcasemenu.
private synchronized void showcasemenu(int option) {
if ((myShowcase != null) && (myShowcase.isShowing()))
return;
if (ShotStateStore.hasShot(option))
return;
// if (showcaseblocked) return;
try {
ViewTarget target = null;
String title = "";
String message = "";
int size1 = 90;
int size2 = 14;
switch(option) {
case SHOWCASE_MOTION_DETECTION:
// dummy
target = new ViewTarget(R.id.btnNote, this);
size1 = 0;
size2 = 0;
title = getString(R.string.title_motion_detection_warning);
message = getString(R.string.message_motion_detection_warning);
break;
case SHOWCASE_VARIANT:
// dummy
target = new ViewTarget(R.id.btnNote, this);
size1 = 0;
size2 = 0;
title = getString(R.string.title_variant);
message = getString(R.string.message_variant);
break;
case SHOWCASE_NOTE_LONG:
target = new ViewTarget(R.id.btnNote, this);
title = getString(R.string.note_button);
message = getString(R.string.showcase_note_long);
break;
case SHOWCASE_REDO:
target = new ViewTarget(R.id.btnRedo, this);
title = getString(R.string.redo_button);
message = getString(R.string.showcase_redo);
break;
case SHOWCASE_UNDO:
target = new ViewTarget(R.id.btnUndo, this);
title = getString(R.string.undo_button);
message = getString(R.string.showcase_undo);
break;
case 3:
target = new ViewTarget(R.id.btnTreatment, this);
break;
case 1:
Toolbar toolbar = (Toolbar) findViewById(R.id.my_toolbar);
List<View> views = toolbar.getTouchables();
// Log.d("xxy", Integer.toString(views.size()));
for (View view : views) {
Log.d("jamhorham showcase", view.getClass().getSimpleName());
if (view.getClass().getSimpleName().equals("OverflowMenuButton")) {
target = new ViewTarget(view);
break;
}
}
break;
}
if (target != null) {
// showcaseblocked = true;
myShowcase = new ShowcaseView.Builder(this).setTarget(target).setStyle(R.style.CustomShowcaseTheme2).setContentTitle(title).setContentText("\n" + message).setShowcaseDrawer(new JamorhamShowcaseDrawer(getResources(), getTheme(), size1, size2)).singleShot(oneshot ? option : -1).build();
myShowcase.setBackgroundColor(Color.TRANSPARENT);
myShowcase.show();
}
} catch (Exception e) {
Log.e(TAG, "Exception in showcase: " + e.toString());
}
}
use of com.eveningoutpost.dexdrip.UtilityModels.JamorhamShowcaseDrawer in project xDrip-plus by jamorham.
the class Mdns method startupInfo.
// showcase info
private static void startupInfo(Context context) {
if (MegaStatus.runnableView == null)
return;
if (JoH.quietratelimit("mdns-showcase", 60)) {
final boolean oneshot = true;
final int option = Home.SHOWCASE_MDNS;
if ((oneshot) && (ShotStateStore.hasShot(option)))
return;
// This could do with being in a utility static method also used in Home
final int size1 = 200;
final int size2 = 70;
final String title = "Tap to add or remove";
final String message = "Devices discovered on the local network can be added or removed as collectors by tapping on them.";
final ViewTarget target = new ViewTarget(MegaStatus.runnableView);
final Activity activity = (Activity) context;
JoH.runOnUiThreadDelayed(new Runnable() {
@Override
public void run() {
final ShowcaseView myShowcase = new ShowcaseView.Builder(activity).setTarget(target).setStyle(R.style.CustomShowcaseTheme2).setContentTitle(title).setContentText("\n" + message).setShowcaseDrawer(new JamorhamShowcaseDrawer(activity.getResources(), activity.getTheme(), size1, size2, 255)).singleShot(oneshot ? option : -1).build();
myShowcase.setBackgroundColor(Color.TRANSPARENT);
myShowcase.setShouldCentreText(false);
myShowcase.setBlocksTouches(true);
myShowcase.show();
}
}, 10);
}
}
use of com.eveningoutpost.dexdrip.UtilityModels.JamorhamShowcaseDrawer in project xDrip-plus by jamorham.
the class LanguageAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(final MyViewHolder holder, int position) {
final LanguageItem languageItem = languageList.get(position);
holder.position = position;
holder.english_text.setText(languageItem.english_text);
holder.local_text.setText(languageItem.local_text.replace("\n", " ^ "));
holder.id_text.setText(languageItem.item_name);
if (languageItem.customized) {
holder.local_text.setTextColor(Color.parseColor("#d6a5a7"));
holder.elementUndo.setVisibility(View.VISIBLE);
// optimize with flag
if (!showcased_undo) {
if (JoH.ratelimit("language-showcase", 2)) {
if (!ShotStateStore.hasShot(LanguageEditor.SHOWCASE_LANGUAGE_ELEMENT_UNDO)) {
ShowcaseView myShowcase = new ShowcaseView.Builder((Activity) context).setTarget(new ViewTarget(holder.elementUndo)).setStyle(R.style.CustomShowcaseTheme2).setContentTitle(// always in english
"Item Undo Button").setContentText(// always in english
"\n" + "You can Undo a single change by Long-pressing the Undo button.").setShowcaseDrawer(new JamorhamShowcaseDrawer(context.getResources(), context.getTheme(), 90, 14)).singleShot(LanguageEditor.oneshot ? LanguageEditor.SHOWCASE_LANGUAGE_ELEMENT_UNDO : -1).build();
myShowcase.setBackgroundColor(Color.TRANSPARENT);
myShowcase.show();
showcased_undo = true;
} else {
showcased_undo = true;
}
}
}
} else {
holder.local_text.setTextColor(Color.parseColor("#a5d6a7"));
holder.elementUndo.setVisibility(View.INVISIBLE);
}
if (languageItem.english_text.equals(languageItem.local_text)) {
holder.id_text.setText(holder.id_text.getText() + " NEW");
}
if (!showcased_newline) {
if (LanguageEditor.last_filter.length() == 0) {
if (holder.local_text.getText().toString().contains(" ^ ")) {
if (JoH.ratelimit("language-showcase", 2)) {
if (!ShotStateStore.hasShot(LanguageEditor.SHOWCASE_LANGUAGE_ELEMENT_NEWLINE)) {
ShowcaseView myShowcase = new ShowcaseView.Builder((Activity) context).setTarget(new ViewTarget(holder.local_text)).setStyle(R.style.CustomShowcaseTheme2).setContentTitle(// always in english
"Line break and other Symbols").setContentText(// always in english
"\n" + "Symbols like ^ are used internally for advancing to a new line.\n\nPlease be careful to preserve these exactly and also respect other symbols you find like : which may affect the user interface if removed.").setShowcaseDrawer(new JamorhamShowcaseDrawer(context.getResources(), context.getTheme(), 90, 50)).singleShot(LanguageEditor.oneshot ? LanguageEditor.SHOWCASE_LANGUAGE_ELEMENT_NEWLINE : -1).build();
myShowcase.setBackgroundColor(Color.TRANSPARENT);
myShowcase.show();
showcased_newline = true;
} else {
showcased_newline = true;
}
}
}
}
}
}
Aggregations