Search in sources :

Example 1 with WidgetLayout

use of rocks.tbog.tblauncher.ui.WidgetLayout in project TBLauncher by TBog.

the class WidgetManager method addConfigPopupItems.

private static void addConfigPopupItems(WidgetLayout widgetLayout, LinearAdapter adapter, WidgetView view, WidgetRecord widget) {
    Context ctx = widgetLayout.getContext();
    adapter.add(new LinearAdapter.ItemTitle(getWidgetName(ctx, view.getAppWidgetInfo())));
    final WidgetLayout.Handle handleType = widgetLayout.getHandleType(view);
    if (handleType.isMove()) {
        adapter.add(new WidgetOptionItem(ctx, R.string.cfg_widget_move_switch, WidgetOptionItem.Action.MOVE_SWITCH));
        adapter.add(new WidgetOptionItem(ctx, R.string.cfg_widget_move_exit, WidgetOptionItem.Action.RESET));
    } else {
        adapter.add(new WidgetOptionItem(ctx, R.string.cfg_widget_move, WidgetOptionItem.Action.MOVE));
    }
    if (handleType.isResize()) {
        adapter.add(new WidgetOptionItem(ctx, R.string.cfg_widget_resize_switch, WidgetOptionItem.Action.RESIZE_SWITCH));
        adapter.add(new WidgetOptionItem(ctx, R.string.cfg_widget_resize_exit, WidgetOptionItem.Action.RESET));
    } else {
        adapter.add(new WidgetOptionItem(ctx, R.string.cfg_widget_resize, WidgetOptionItem.Action.RESIZE));
    }
    if (handleType.isMoveResize()) {
        adapter.add(new WidgetOptionItem(ctx, R.string.cfg_widget_move_resize, WidgetOptionItem.Action.MOVE_RESIZE_SWITCH));
        adapter.add(new WidgetOptionItem(ctx, R.string.cfg_widget_move_resize_exit, WidgetOptionItem.Action.RESET));
    } else {
        adapter.add(new WidgetOptionItem(ctx, R.string.cfg_widget_move_resize, WidgetOptionItem.Action.MOVE_RESIZE));
    }
    adapter.add(new LinearAdapter.ItemDivider());
    final ViewGroup.LayoutParams lp = view.getLayoutParams();
    if (lp instanceof WidgetLayout.LayoutParams) {
        final int screenPage = ((WidgetLayout.LayoutParams) lp).screenPage;
        if (canMoveToPage(widgetLayout, screenPage, WidgetLayout.LayoutParams.PAGE_LEFT))
            adapter.add(new WidgetOptionItem(ctx, R.string.cfg_widget_screen_left, WidgetOptionItem.Action.MOVE2SCREEN_LEFT));
        if (canMoveToPage(widgetLayout, screenPage, WidgetLayout.LayoutParams.PAGE_UP))
            adapter.add(new WidgetOptionItem(ctx, R.string.cfg_widget_screen_up, WidgetOptionItem.Action.MOVE2SCREEN_UP));
        if (canMoveToPage(widgetLayout, screenPage, WidgetLayout.LayoutParams.PAGE_MIDDLE))
            adapter.add(new WidgetOptionItem(ctx, R.string.cfg_widget_screen_middle, WidgetOptionItem.Action.MOVE2SCREEN_MIDDLE));
        if (canMoveToPage(widgetLayout, screenPage, WidgetLayout.LayoutParams.PAGE_RIGHT))
            adapter.add(new WidgetOptionItem(ctx, R.string.cfg_widget_screen_right, WidgetOptionItem.Action.MOVE2SCREEN_RIGHT));
        if (canMoveToPage(widgetLayout, screenPage, WidgetLayout.LayoutParams.PAGE_DOWN))
            adapter.add(new WidgetOptionItem(ctx, R.string.cfg_widget_screen_down, WidgetOptionItem.Action.MOVE2SCREEN_DOWN));
        adapter.add(new WidgetOptionItem(ctx, R.string.cfg_widget_back, WidgetOptionItem.Action.MOVE_BELOW));
        adapter.add(new WidgetOptionItem(ctx, R.string.cfg_widget_front, WidgetOptionItem.Action.MOVE_ABOVE));
    }
    adapter.add(new WidgetOptionItem(ctx, R.string.cfg_widget_remove, WidgetOptionItem.Action.REMOVE));
    if (DebugInfo.widgetInfo(ctx)) {
        adapter.add(new LinearAdapter.ItemTitle("Debug info"));
        adapter.add(new LinearAdapter.ItemString("Name: " + getWidgetName(ctx, view.getAppWidgetInfo())));
        adapter.add(new LinearAdapter.ItemText(widget.packedProperties()));
        adapter.add(new LinearAdapter.ItemString("ID: " + widget.appWidgetId));
    }
}
Also used : Context(android.content.Context) WidgetLayout(rocks.tbog.tblauncher.ui.WidgetLayout) ViewGroup(android.view.ViewGroup) LinearAdapter(rocks.tbog.tblauncher.ui.LinearAdapter)

Aggregations

Context (android.content.Context)1 ViewGroup (android.view.ViewGroup)1 LinearAdapter (rocks.tbog.tblauncher.ui.LinearAdapter)1 WidgetLayout (rocks.tbog.tblauncher.ui.WidgetLayout)1