use of rocks.tbog.tblauncher.ui.ListPopup in project TBLauncher by TBog.
the class LiveWallpaper method onLongClick.
private void onLongClick(View view) {
if (!view.isAttachedToWindow()) {
return;
}
view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
Context ctx = view.getContext();
ListPopup menu = TBApplication.widgetManager(ctx).getConfigPopup(mTBLauncherActivity);
TBApplication.getApplication(getContext()).registerPopup(menu);
int x = (int) (mLastTouchPos.x + .5f);
int y = (int) (mLastTouchPos.y + .5f);
menu.showAtLocation(view, Gravity.START | Gravity.TOP, x, y);
}
use of rocks.tbog.tblauncher.ui.ListPopup in project TBLauncher by TBog.
the class TBLauncherActivity method dispatchTouchEvent.
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
boolean shouldDismissPopup = false;
ListPopup listPopup = TBApplication.getApplication(this).getPopup();
if (listPopup != null) {
int action = event.getActionMasked();
if (action == MotionEvent.ACTION_DOWN) {
// this check is not needed
// we'll not receive the event if it happened inside the popup
int x = (int) (event.getRawX() + .5f);
int y = (int) (event.getRawY() + .5f);
if (!listPopup.isInsideViewBounds(x, y))
shouldDismissPopup = true;
}
}
if (shouldDismissPopup && TBApplication.getApplication(this).dismissPopup())
return true;
return super.dispatchTouchEvent(event);
}
use of rocks.tbog.tblauncher.ui.ListPopup in project TBLauncher by TBog.
the class Behaviour method onCreateActivity.
public void onCreateActivity(TBLauncherActivity tbLauncherActivity) {
mTBLauncherActivity = tbLauncherActivity;
mPref = PreferenceManager.getDefaultSharedPreferences(mTBLauncherActivity);
Window window = mTBLauncherActivity.getWindow();
mDecorView = window.getDecorView();
KeyboardTriggerBehaviour keyboardListener = new KeyboardTriggerBehaviour(mTBLauncherActivity);
keyboardListener.observe(mTBLauncherActivity, status -> {
LauncherState state = TBApplication.state();
if (status == KeyboardTriggerBehaviour.Status.CLOSED) {
boolean keyboardClosedByUser = true;
if (state.getSearchBarVisibility() == LauncherState.AnimatedVisibility.ANIM_TO_VISIBLE) {
Log.i(TAG, "keyboard closed - app start");
// don't call onKeyboardClosed() when we start the app
keyboardClosedByUser = false;
} else if (mRecycleScrollListener.isClosedOnScroll()) {
Log.i(TAG, "keyboard closed - scrolling results");
// keyboard closed because the result list was scrolled
keyboardClosedByUser = false;
} else if (isFragmentDialogVisible()) {
Log.i(TAG, "keyboard closed - fragment dialog");
// don't send keyboard close event while we have a dialog open
keyboardClosedByUser = false;
}
if (keyboardClosedByUser) {
Log.i(TAG, "keyboard closed - user");
onKeyboardClosed();
}
if (state.isSearchBarVisible()) {
int duration = 0;
if (mPref.getBoolean("search-bar-animation", true))
duration = UI_ANIMATION_DURATION;
mTBLauncherActivity.customizeUI.collapseSearchPill(duration);
}
} else {
if (state.isSearchBarVisible()) {
int duration = 0;
if (mPref.getBoolean("search-bar-animation", true))
duration = UI_ANIMATION_DURATION;
mTBLauncherActivity.customizeUI.expandSearchPill(duration);
mSearchEditText.requestFocus();
}
}
});
initKeyboardScrollHider();
initResultLayout();
initSearchBarContainer();
mNotificationBackground = findViewById(R.id.notificationBackground);
mWidgetContainer = findViewById(R.id.widgetContainer);
// mSearchBarContainer = findViewById(R.id.searchBarContainer);
// mLauncherButton = mSearchBarContainer.findViewById(R.id.launcherButton);
// mSearchEditText = mSearchBarContainer.findViewById(R.id.launcherSearch);
// mClearButton = mSearchBarContainer.findViewById(R.id.clearButton);
// mMenuButton = mSearchBarContainer.findViewById(R.id.menuButton);
// WindowCompat.setDecorFitsSystemWindows(window, false);
// ViewCompat.setOnApplyWindowInsetsListener(window.getDecorView(), (v, insets) -> {
// int left = v.getPaddingLeft();
// int top = v.getPaddingTop();
// int right = v.getPaddingRight();
// int bottom = v.getPaddingBottom();
// @WindowInsetsCompat.Type.InsetsType
// int type = WindowInsetsCompat.Type.systemBars() | WindowInsetsCompat.Type.ime();
// v.setPadding(left, top, right, insets.getInsets(type).bottom);
// return insets;
// });
initLauncherButton();
initLauncherSearchEditText();
// menu button / 3 dot button actions
mMenuButton.setOnClickListener(v -> {
Context ctx = v.getContext();
ListPopup menu = getMenuPopup(ctx);
registerPopup(menu);
menu.showCenter(v);
});
mMenuButton.setOnLongClickListener(v -> {
Context ctx = v.getContext();
ListPopup menu = getMenuPopup(ctx);
// check if menu contains elements and if yes show it
if (!menu.getAdapter().isEmpty()) {
registerPopup(menu);
menu.show(v, 0f);
return true;
}
return false;
});
// clear button actions
mClearButton.setOnClickListener(v -> clearSearch());
mClearButton.setOnLongClickListener(v -> {
clearSearch();
Context ctx = v.getContext();
ListPopup menu = getMenuPopup(ctx);
// check if menu contains elements and if yes show it
if (!menu.getAdapter().isEmpty()) {
registerPopup(menu);
menu.show(v);
return true;
}
return false;
});
}
use of rocks.tbog.tblauncher.ui.ListPopup in project TBLauncher by TBog.
the class AppEntry method popupMenuClickHandler.
@Override
protected boolean popupMenuClickHandler(@NonNull final View view, @NonNull LinearAdapter.MenuItem item, int stringId, View parentView) {
Context ctx = view.getContext();
if (item instanceof ShortcutItem) {
TBApplication.behaviour(ctx).beforeLaunchOccurred();
final ShortcutInfo shortcutInfo = ((ShortcutItem) item).shortcutInfo;
parentView.postDelayed(() -> {
Activity activity = Utilities.getActivity(parentView);
if (activity == null)
return;
ShortcutEntry.doOreoLaunch(activity, parentView, shortcutInfo);
TBApplication.behaviour(activity).afterLaunchOccurred();
}, Behaviour.LAUNCH_DELAY);
return true;
}
switch(stringId) {
// return true;
case R.string.menu_app_details:
launchAppDetails(ctx, parentView);
return true;
case R.string.menu_app_store:
launchAppStore(ctx, parentView);
return true;
case R.string.menu_app_uninstall:
launchUninstall(ctx);
return true;
case R.string.menu_app_hibernate:
hibernate(ctx);
return true;
// return true;
case R.string.menu_exclude:
{
LinearAdapter adapter = new LinearAdapter();
ListPopup menu = ListPopup.create(ctx, adapter);
adapter.add(new LinearAdapter.Item(ctx, R.string.menu_exclude_history));
adapter.add(new LinearAdapter.Item(ctx, R.string.menu_exclude_kiss));
menu.setOnItemClickListener((a, v, pos) -> {
LinearAdapter.MenuItem menuItem = ((LinearAdapter) a).getItem(pos);
@StringRes int id = 0;
if (menuItem instanceof LinearAdapter.Item) {
id = ((LinearAdapter.Item) a.getItem(pos)).stringId;
}
switch(id) {
case R.string.menu_exclude_history:
// excludeFromHistory(v.getContext(), appPojo());
Toast.makeText(ctx, "Not Implemented", Toast.LENGTH_LONG).show();
break;
case R.string.menu_exclude_kiss:
// excludeFromKiss(v.getContext(), appPojo(), parent);
Toast.makeText(ctx, "Work in progress", Toast.LENGTH_LONG).show();
break;
}
});
menu.show(parentView);
TBApplication.getApplication(ctx).registerPopup(menu);
return true;
}
case R.string.menu_hide:
if (TBApplication.dataHandler(ctx).addToHidden(this)) {
setHiddenByUser(true);
TBApplication.behaviour(ctx).refreshSearchRecord(this);
// Toast.makeText(ctx, "App "+getName()+" hidden from search", Toast.LENGTH_LONG).show();
}
break;
case R.string.menu_show:
if (TBApplication.dataHandler(ctx).removeFromHidden(this)) {
setHiddenByUser(false);
TBApplication.behaviour(ctx).refreshSearchRecord(this);
// Toast.makeText(ctx, "App "+getName()+" shown in searches", Toast.LENGTH_LONG).show();
}
break;
case R.string.menu_tags_add:
case R.string.menu_tags_edit:
TBApplication.behaviour(ctx).launchEditTagsDialog(this);
return true;
case R.string.menu_app_rename:
launchRenameDialog(ctx);
return true;
case R.string.menu_custom_icon:
TBApplication.behaviour(ctx).launchCustomIconDialog(this);
return true;
}
return super.popupMenuClickHandler(view, item, stringId, parentView);
}
use of rocks.tbog.tblauncher.ui.ListPopup in project TBLauncher by TBog.
the class WidgetManager method getConfigPopup.
/**
* Popup with options for all widgets
*
* @param activity used to start the widget select popup
* @return the popup menu
*/
public ListPopup getConfigPopup(Activity activity) {
LinearAdapter adapter = new LinearAdapter();
adapter.add(new LinearAdapter.ItemTitle(activity, R.string.menu_widget_title));
adapter.add(new LinearAdapter.Item(activity, R.string.menu_widget_add));
if (widgetCount() > 0) {
adapter.add(new LinearAdapter.Item(activity, R.string.menu_widget_configure));
adapter.add(new LinearAdapter.Item(activity, R.string.menu_widget_remove));
}
adapter.add(new LinearAdapter.Item(activity, R.string.menu_popup_launcher_settings));
ListPopup menu = ListPopup.create(activity, adapter);
menu.setOnItemClickListener((a, v, pos) -> {
LinearAdapter.MenuItem item = ((LinearAdapter) a).getItem(pos);
@StringRes int stringId = 0;
if (item instanceof LinearAdapter.Item) {
stringId = ((LinearAdapter.Item) a.getItem(pos)).stringId;
}
switch(stringId) {
case R.string.menu_widget_add:
TBApplication.widgetManager(activity).showSelectWidget(activity);
break;
case R.string.menu_widget_configure:
{
ListPopup configWidgetPopup = TBApplication.widgetManager(activity).getWidgetListPopup(R.string.menu_widget_configure);
configWidgetPopup.setOnItemClickListener((a1, v1, pos1) -> {
Object item1 = a1.getItem(pos1);
if (item1 instanceof WidgetPopupItem) {
AppWidgetHostView widgetView = mLayout.getWidget(((WidgetPopupItem) item1).appWidgetId);
if (widgetView == null)
return;
ListPopup popup = getConfigPopup((WidgetView) widgetView);
TBApplication.getApplication(mLayout.getContext()).registerPopup(popup);
popup.show(widgetView, 0.f);
} else if (item1 instanceof PlaceholderPopupItem) {
PlaceholderWidgetRecord placeholder = ((PlaceholderPopupItem) item1).placeholder;
View placeholderView = mLayout.getPlaceholder(placeholder.provider);
if (placeholderView != null)
placeholderView.performClick();
}
});
TBApplication.getApplication(activity).registerPopup(configWidgetPopup);
configWidgetPopup.showCenter(activity.getWindow().getDecorView());
break;
}
case R.string.menu_widget_remove:
showRemoveWidgetPopup();
break;
case R.string.menu_popup_launcher_settings:
// TBApplication.behaviour(v.getContext()).beforeLaunchOccurred();
mLayout.postDelayed(() -> {
Context c = mLayout.getContext();
c.startActivity(new Intent(c, SettingsActivity.class));
// TBApplication.behaviour(c).afterLaunchOccurred();
}, Behaviour.LAUNCH_DELAY);
break;
}
});
return menu;
}
Aggregations