Java Code Examples for android.widget.LinearLayout#getContext()

The following examples show how to use android.widget.LinearLayout#getContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JDIndicatorAdapter.java    From LoopBanner with Apache License 2.0 6 votes vote down vote up
@Override
public void addIndicator(LinearLayout container, Drawable drawable, int size, int margin) {
    drawable = ContextCompat.getDrawable(container.getContext(), drawableId);
    if (drawable == null) {
        throw new IllegalArgumentException("please provide valid drawableId");
    }
    ImageView image = new ImageView(container.getContext());
    ViewCompat.setBackground(image, drawable);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
            LinearLayout.LayoutParams.WRAP_CONTENT);
    params.leftMargin = margin;
    container.addView(image, params);

    computeScale(drawable.getMinimumWidth(), margin);

}
 
Example 2
Source File: PaymentRequestSection.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
protected void createMainSectionContent(LinearLayout mainSectionLayout) {
    Context context = mainSectionLayout.getContext();

    // Add a label that will be used to indicate that the total cart price has been updated.
    addUpdateText(mainSectionLayout);

    // The breakdown is represented by an end-aligned GridLayout that takes up only as much
    // space as it needs.  The GridLayout ensures a consistent margin between the columns.
    mBreakdownLayout = new GridLayout(context);
    mBreakdownLayout.setColumnCount(2);
    LayoutParams breakdownParams =
            new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    breakdownParams.gravity = Gravity.END;
    mainSectionLayout.addView(mBreakdownLayout, breakdownParams);
}
 
Example 3
Source File: NavigationLayoutFactory.java    From navigation-widgets with MIT License 6 votes vote down vote up
@Override
public View produceLayout(LayoutInflater inflater, @Nullable ViewGroup container) {
    LinearLayout parent = new LinearLayout(inflater.getContext());
    parent.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
    parent.setOrientation(VERTICAL);

    View child = origin.produceLayout(inflater, parent);
    LinearLayout.LayoutParams childParams = new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT);
    if (includeBottomBar) {
        childParams.weight = 1;
    }

    if (includeToolbar) {
        inflater.inflate(R.layout.toolbar, parent);
    }
    parent.addView(child, childParams);
    if (includeBottomBar) {
        AHBottomNavigation bottomNavigation = new AHBottomNavigation(parent.getContext());
        bottomNavigation.setId(R.id.bottomNavigation);
        parent.addView(
                bottomNavigation,
                new LinearLayout.LayoutParams(MATCH_PARENT, (int) dp(parent.getContext(), 56)));
    }

    return parent;
}
 
Example 4
Source File: SWHtmlLink.java    From AndroidAPS with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void generateDialog(LinearLayout layout) {
    Context context = layout.getContext();

    l = new TextView(context);
    l.setId(View.generateViewId());
    l.setAutoLinkMask(Linkify.ALL);
    if(textLabel != null)
        l.setText(textLabel);
    else
        l.setText(label);
    layout.addView(l);

}
 
Example 5
Source File: SWButton.java    From AndroidAPS with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void generateDialog(LinearLayout layout) {
    Context context = layout.getContext();

    button = new Button(context);
    button.setText(buttonText);
    button.setOnClickListener((v) -> {
        if (buttonRunnable != null)
            buttonRunnable.run();
    });
    processVisibility();
    layout.addView(button);
    super.generateDialog(layout);
}
 
Example 6
Source File: InputInsulin.java    From AndroidAPS with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void addToLayout(LinearLayout root) {
    NumberPicker numberPicker = new NumberPicker(root.getContext(), null);
    numberPicker.setParams(0d, -20d, 20d, 0.1, new DecimalFormat("0.0"), true, null, textWatcher);
    numberPicker.setValue(value);
    numberPicker.setOnValueChangedListener(value -> this.value = value);
    root.addView(numberPicker);
}
 
Example 7
Source File: StaticLabel.java    From AndroidAPS with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
    public void addToLayout(LinearLayout root) {
        // text view pre element
        int px = MainApp.dpToPx(10);
        TextView textView = new TextView(root.getContext());
        textView.setText(label);
//       textViewPre.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,                ViewGroup.LayoutParams.WRAP_CONTENT));
        textView.setPadding(px, px, px, px);
        textView.setTypeface(textView.getTypeface(), Typeface.BOLD);
        textView.setBackgroundColor(MainApp.gc(R.color.mdtp_line_dark));
        // add element to layout
        root.addView(textView);
    }
 
Example 8
Source File: NoEditableLayerToolGroup.java    From geopaparazzi with GNU General Public License v3.0 5 votes vote down vote up
public void initUI() {

        LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
        Context context = parent.getContext();
//        IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer();
        int padding = 2;

        selectAllButton = new ImageButton(context);
        selectAllButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        selectAllButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_all_24dp));
        selectAllButton.setPadding(0, padding, 0, padding);
        selectAllButton.setOnClickListener(this);
        selectAllButton.setOnTouchListener(this);
        parent.addView(selectAllButton);
    }
 
Example 9
Source File: PaymentRequestSection.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
protected void createMainSectionContent(LinearLayout mainSectionLayout) {
    Context context = mainSectionLayout.getContext();

    mExtraTextViews = new TextView[3];
    for (int i = 0; i < mExtraTextViews.length; i++) {
        mExtraTextViews[i] = new TextView(context);
        ApiCompatibilityUtils.setTextAppearance(
                mExtraTextViews[i], R.style.PaymentsUiSectionDefaultText);
        mainSectionLayout.addView(
                mExtraTextViews[i], new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
                                            LayoutParams.WRAP_CONTENT));
    }
}
 
Example 10
Source File: TriggerConnector.java    From AndroidAPS with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void generateDialog(LinearLayout root, FragmentManager fragmentManager) {
    final int padding = MainApp.dpToPx(5);

    root.setPadding(padding, padding, padding, padding);
    root.setBackgroundResource(R.drawable.border_automation_unit);

    LinearLayout triggerListLayout = new LinearLayout(root.getContext());
    triggerListLayout.setOrientation(LinearLayout.VERTICAL);
    triggerListLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    root.addView(triggerListLayout);

    adapter = new TriggerListAdapter(fragmentManager, root.getContext(), triggerListLayout, this);
}
 
Example 11
Source File: SWEventListener.java    From AndroidAPS with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void generateDialog(LinearLayout layout) {
    Context context = layout.getContext();

    textView = new TextView(context);
    textView.setId(layout.generateViewId());
    textView.setText((textLabel != 0 ? MainApp.gs(textLabel) : "") + " " + status);
    layout.addView(textView);
}
 
Example 12
Source File: NoEditableLayerToolGroup.java    From geopaparazzi with GNU General Public License v3.0 5 votes vote down vote up
public void onClick(View v) {
    if (v == selectAllButton) {
        Tool currentTool = EditManager.INSTANCE.getActiveTool();
        if (currentTool instanceof InfoTool) {
            // if the same tool is re-selected, it is disabled
            EditManager.INSTANCE.setActiveTool(null);
        } else {
            // check maps enablement
            try {
                List<IVectorDbLayer> enabledVectorLayers = LayerManager.INSTANCE.getEnabledVectorLayers(mapView);
                if (enabledVectorLayers.size() == 0) {
                    LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
                    if (parent != null) {
                        Context context = parent.getContext();
                        GPDialogs.warningDialog(context, context.getString(R.string.no_queriable_layer_is_visible), null);
                    }
                    return;
                }
            } catch (Exception e) {
                GPLog.error(this, null, e);
            }

            Tool activeTool = new InfoTool(this, mapView);
            EditManager.INSTANCE.setActiveTool(activeTool);
        }
    }

    handleToolIcons(v);
}
 
Example 13
Source File: LabelWithElement.java    From AndroidAPS with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void addToLayout(LinearLayout root) {
    // container layout
    LinearLayout layout = new LinearLayout(root.getContext());
    layout.setOrientation(LinearLayout.HORIZONTAL);
    layout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));

    // text view pre element
    int px = MainApp.dpToPx(10);
    TextView textViewPre = new TextView(root.getContext());
    textViewPre.setText(textPre);
    textViewPre.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    //textViewPre.setWidth(MainApp.dpToPx(120));
    textViewPre.setPadding(px, px, px, px);
    textViewPre.setTypeface(textViewPre.getTypeface(), Typeface.BOLD);
    layout.addView(textViewPre);

    TextView spacer = new TextView(root.getContext());
    spacer.setLayoutParams(new TableLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
    layout.addView(spacer);

    // add element to layout
    element.addToLayout(layout);

    // text view post element
    if (textPost != null) {
        px = MainApp.dpToPx(5);
        TextView textViewPost = new TextView(root.getContext());
        textViewPost.setText(textPost);
        textViewPost.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        //textViewPost.setWidth(MainApp.dpToPx(45));
        textViewPost.setPadding(px, px, px, px);
        textViewPost.setTypeface(textViewPost.getTypeface(), Typeface.BOLD);
        layout.addView(textViewPost);
    }

    // add layout to root layout
    root.addView(layout);
}
 
Example 14
Source File: Main.java    From Simple-Brick-Games with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    createSoundPool();

    mLinearLayoutBackground = (LinearLayout) findViewById(R.id.linearLayoutBackground); //the whole display
    l1 = (LinearLayout) findViewById(R.id.LinearLayout1);
    linearLayoutMenuButtons = (LinearLayout) findViewById(R.id.linearLayoutMenuButtons);
    linearLayoutGameField = (LinearLayout) findViewById(R.id.linearLayoutGameField);
    linearLayoutTexts = (LinearLayout) findViewById(R.id.linearLayoutTexts);
    linearLayoutGameExtra = (LinearLayout) findViewById(R.id.linearLayoutGameExtra);
    layoutButtons1 = (LinearLayout) findViewById(R.id.layoutButtons1);
    layoutButtons2 = (FrameLayout) findViewById(R.id.layoutButtons2);
    vibration = (Vibrator) getSystemService(VIBRATOR_SERVICE);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);

    gameView1 = new GameView1(linearLayoutGameField.getContext());
    gameView2 = new GameView2(linearLayoutGameExtra.getContext());

    mButton[0] = (ImageView) findViewById(R.id.button_up);
    mButton[1] = (ImageView) findViewById(R.id.button_down);
    mButton[2] = (ImageView) findViewById(R.id.button_left);
    mButton[3] = (ImageView) findViewById(R.id.button_right);
    mButton[4] = (ImageView) findViewById(R.id.button_action);
    mButton[5] = (ImageView) findViewById(R.id.button_reset);
    mButton[6] = (ImageView) findViewById(R.id.button_pause);
    mButton[7] = (ImageView) findViewById(R.id.button_close);

    mText[0] = (TextView) findViewById(R.id.text_highscore);
    mText[1] = (TextView) findViewById(R.id.text_score);
    mText[2] = (TextView) findViewById(R.id.text_level);
    mText[3] = (TextView) findViewById(R.id.text_speed);
    mText[4] = (TextView) findViewById(R.id.text_pause);

    soundList[0] = sp.load(this, R.raw.beep, 1);
    soundList[1] = sp.load(this, R.raw.boing, 1);
    soundList[2] = sp.load(this, R.raw.explosion, 1);
    soundList[3] = sp.load(this, R.raw.boop, 1);
    soundList[4] = sp.load(this, R.raw.crunch, 1);
    soundList[5] = sp.load(this, R.raw.next, 1);
    soundList[6] = sp.load(this, R.raw.gameover, 1);
    soundList[7] = sp.load(this, R.raw.shoot, 1);

    mainActivity = this;
    setSupportActionBar(mToolbar);

    /* Load saved SharedData */
    savedData = PreferenceManager.getDefaultSharedPreferences(this);
    edit = savedData.edit();
    for (int i = 1; i <= NUMBER_OF_GAMES; i++)
        highScores[i] = savedData.getInt("HighScore" + Integer.toString(i), 0);
    look = savedData.getInt(getString(R.string.prefKeyTextures), 2);
    menu.load();

    Game.reset();

    for (int i=0;i<5;i++) {
        mButton[i].setOnTouchListener(this);
    }

    setBackgroundColor();
    changeButtonColor();

    linearLayoutGameField.addView(gameView1);
    linearLayoutGameExtra.addView(gameView2);

    /* set up the layouts (the layouts will be rearranged to fit the calculated field dimensions)*/
    mLinearLayoutBackground.post(new Runnable() {
        @Override
        public void run() {
            if (getResources().getConfiguration().orientation==Configuration.ORIENTATION_PORTRAIT) {
                setUpDimensions();
            } else {
                setUpDimensionsLandscape();
            }
        }
    });

    buttonKeyCodes[0] = savedData.getInt("buttonUp",KeyEvent.KEYCODE_W);
    buttonKeyCodes[1] = savedData.getInt("buttonDown",KeyEvent.KEYCODE_S);
    buttonKeyCodes[2] = savedData.getInt("buttonLeft",KeyEvent.KEYCODE_A);
    buttonKeyCodes[3] = savedData.getInt("buttonRight",KeyEvent.KEYCODE_D);
    buttonKeyCodes[4] = savedData.getInt("buttonAction",KeyEvent.KEYCODE_L);
    buttonKeyCodes[5] = savedData.getInt("buttonClose",KeyEvent.KEYCODE_X);
    buttonKeyCodes[6] = savedData.getInt("buttonReset",KeyEvent.KEYCODE_R);
    buttonKeyCodes[7] = savedData.getInt("buttonPause",KeyEvent.KEYCODE_P);
}
 
Example 15
Source File: LocalResourceListAdapter.java    From android_maplibui with GNU Lesser General Public License v3.0 4 votes vote down vote up
public PathAdapter(LinearLayout linearLayout)
{
    mLinearLayout = linearLayout;
    mContext = linearLayout.getContext();
}
 
Example 16
Source File: Trigger.java    From AndroidAPS with GNU Affero General Public License v3.0 4 votes vote down vote up
public void generateDialog(LinearLayout root, FragmentManager fragmentManager) {
    TextView title = new TextView(root.getContext());
    title.setText(friendlyName());
    root.addView(title);
}
 
Example 17
Source File: PointCreateFeatureToolGroup.java    From geopaparazzi with GNU General Public License v3.0 4 votes vote down vote up
public void initUI() {
    LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
    parent.removeAllViews();

    Context context = parent.getContext();
    IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer();
    int padding = 2;

    if (editLayer != null) {
        gpsStreamButton = new ImageButton(context);
        gpsStreamButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        gpsStreamButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_point_gps_off_24dp));
        gpsStreamButton.setPadding(0, padding, 0, padding);
        gpsStreamButton.setOnTouchListener(this);
        gpsStreamButton.setOnLongClickListener(this);
        gpsStreamButton.setOnClickListener(this);
        parent.addView(gpsStreamButton);

        addVertexButton = new ImageButton(context);
        addVertexButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        addVertexButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_point_center_24dp));
        addVertexButton.setPadding(0, padding, 0, padding);
        addVertexButton.setOnTouchListener(this);
        addVertexButton.setOnClickListener(this);
        parent.addView(addVertexButton);

        addVertexByTapButton = new ImageButton(context);
        addVertexByTapButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT));
        addVertexByTapButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_add_point_tap_off_24dp));
        addVertexByTapButton.setPadding(0, padding, 0, padding);
        addVertexByTapButton.setOnTouchListener(this);
        addVertexByTapButton.setOnClickListener(this);
        parent.addView(addVertexByTapButton);

        undoButton = new ImageButton(context);
        undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp));
        undoButton.setPadding(0, padding, 0, padding);
        undoButton.setOnTouchListener(this);
        undoButton.setOnClickListener(this);
        parent.addView(undoButton);

        commitButton = new ImageButton(context);
        commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp));
        commitButton.setPadding(0, padding, 0, padding);
        commitButton.setOnTouchListener(this);
        commitButton.setOnClickListener(this);
        commitButton.setVisibility(View.GONE);
        parent.addView(commitButton);
    }
}
 
Example 18
Source File: SWPlugin.java    From AndroidAPS with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void generateDialog(LinearLayout layout) {

    Context context = layout.getContext();
    radioGroup = new RadioGroup(context);
    radioGroup.clearCheck();

    ArrayList<PluginBase> pluginsInCategory = MainApp.getSpecificPluginsList(pType);

    radioGroup.setOrientation(LinearLayout.VERTICAL);
    radioGroup.setVisibility(View.VISIBLE);

    TextView pdesc = new TextView(context);
    pdesc.setText(pluginDescription);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.setMargins(0, 0, 0, 40);
    pdesc.setLayoutParams(params);
    layout.addView(pdesc);

    for (int i = 0; i < pluginsInCategory.size(); i++) {
        RadioButton rdbtn = new RadioButton(context);
        PluginBase p = pluginsInCategory.get(i);
        rdbtn.setId(View.generateViewId());
        rdbtn.setText(p.getName());
        if (p.isEnabled(pType))
            rdbtn.setChecked(true);
        rdbtn.setTag(p);
        radioGroup.addView(rdbtn);
        params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.setMargins(80, 0, 0, 0);
        TextView desc = new TextView(context);
        desc.setText(p.getDescription());
        desc.setLayoutParams(params);
        radioGroup.addView(desc);
    }

    radioGroup.setOnCheckedChangeListener((group, checkedId) -> {
        RadioButton rb = group.findViewById(checkedId);
        PluginBase plugin = (PluginBase) rb.getTag();
        plugin.setPluginEnabled(pType, rb.isChecked());
        plugin.setFragmentVisible(pType, rb.isChecked() && makeVisible);
        ConfigBuilderPlugin.getPlugin().processOnEnabledCategoryChanged(plugin, pType);
        ConfigBuilderPlugin.getPlugin().storeSettings("SetupWizard");
        RxBus.INSTANCE.send(new EventConfigBuilderChange());
        RxBus.INSTANCE.send(new EventSWUpdate(false));
    });
    layout.addView(radioGroup);
    super.generateDialog(layout);
}
 
Example 19
Source File: PolygonMainEditingToolGroup.java    From geopaparazzi with GNU General Public License v3.0 4 votes vote down vote up
public void initUI() {

        LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
        Context context = parent.getContext();
        IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer();
        int padding = 2;

        if (editLayer != null) {
            cutButton = new ImageButton(context);
            cutButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            cutButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_cut_24dp));
            cutButton.setPadding(0, padding, 0, padding);
            cutButton.setOnClickListener(this);
            cutButton.setOnTouchListener(this);
            parent.addView(cutButton);

            extendButton = new ImageButton(context);
            extendButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            extendButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_extend_24dp));
            extendButton.setPadding(0, padding, 0, padding);
            extendButton.setOnClickListener(this);
            extendButton.setOnTouchListener(this);
            parent.addView(extendButton);

            createFeatureButton = new ImageButton(context);
            createFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            createFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_create_polygon_24dp));
            createFeatureButton.setPadding(0, padding, 0, padding);
            createFeatureButton.setOnClickListener(this);
            createFeatureButton.setOnTouchListener(this);
            parent.addView(createFeatureButton);

            selectEditableButton = new ImageButton(context);
            selectEditableButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            selectEditableButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_editable_24dp));
            selectEditableButton.setPadding(0, padding, 0, padding);
            selectEditableButton.setOnClickListener(this);
            selectEditableButton.setOnTouchListener(this);
            parent.addView(selectEditableButton);
        }

        selectAllButton = new ImageButton(context);
        selectAllButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        Tool activeTool = EditManager.INSTANCE.getActiveTool();
        if (activeTool instanceof InfoTool) {
            selectAllButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_all_active_24dp));
        } else {
            selectAllButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_select_all_24dp));
        }
        selectAllButton.setPadding(0, padding, 0, padding);
        selectAllButton.setOnClickListener(this);
        selectAllButton.setOnTouchListener(this);
        parent.addView(selectAllButton);

        if (editLayer != null) {
            undoButton = new ImageButton(context);
            undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp));
            undoButton.setPadding(0, padding, 0, padding);
            undoButton.setOnTouchListener(this);
            undoButton.setOnClickListener(this);
            parent.addView(undoButton);
            undoButton.setVisibility(View.GONE);

            commitButton = new ImageButton(context);
            commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp));
            commitButton.setPadding(0, padding, 0, padding);
            commitButton.setOnTouchListener(this);
            commitButton.setOnClickListener(this);
            parent.addView(commitButton);
            commitButton.setVisibility(View.GONE);
        }
    }
 
Example 20
Source File: PolygonOnSelectionToolGroup.java    From geopaparazzi with GNU General Public License v3.0 4 votes vote down vote up
public void initUI() {
        LinearLayout parent = EditManager.INSTANCE.getToolsLayout();
        parent.removeAllViews();

        Context context = parent.getContext();
        IEditableLayer editLayer = EditManager.INSTANCE.getEditLayer();
        int padding = 2;

        if (editLayer != null) {
            deleteFeatureButton = new ImageButton(context);
            deleteFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            deleteFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_delete_feature_24dp));
            deleteFeatureButton.setPadding(0, padding, 0, padding);
            deleteFeatureButton.setOnTouchListener(this);
            deleteFeatureButton.setOnClickListener(this);
            parent.addView(deleteFeatureButton);

//            copyFeatureButton = new ImageButton(context);
//            copyFeatureButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
//                    LayoutParams.WRAP_CONTENT));
//            copyFeatureButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_copy_geoms_24dp));
//            copyFeatureButton.setPadding(0, padding, 0, padding);
//            copyFeatureButton.setOnTouchListener(this);
//            copyFeatureButton.setOnClickListener(this);
//            parent.addView(copyFeatureButton);

            editAttributesButton = new ImageButton(context);
            editAttributesButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT));
            editAttributesButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_view_attributes_24dp));
            editAttributesButton.setPadding(0, padding, 0, padding);
            editAttributesButton.setOnTouchListener(this);
            editAttributesButton.setOnClickListener(this);
            parent.addView(editAttributesButton);

            undoButton = new ImageButton(context);
            undoButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            undoButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_undo_24dp));
            undoButton.setPadding(0, padding, 0, padding);
            undoButton.setOnTouchListener(this);
            undoButton.setOnClickListener(this);
            parent.addView(undoButton);

            commitButton = new ImageButton(context);
            commitButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
            commitButton.setBackground(Compat.getDrawable(context, R.drawable.ic_editing_commit_24dp));
            commitButton.setPadding(0, padding, 0, padding);
            commitButton.setOnTouchListener(this);
            commitButton.setOnClickListener(this);
            parent.addView(commitButton);
            commitButton.setVisibility(View.GONE);
        }
    }