Search in sources :

Example 1 with MainActivity

use of net.sourceforge.opencamera.MainActivity in project OpenCamera by ageback.

the class PopupView method createButtonOptions.

static List<View> createButtonOptions(ViewGroup parent, Context context, int total_width_dp, Map<String, View> test_ui_buttons, List<String> supported_options, int icons_id, int values_id, String prefix_string, boolean include_prefix, String current_value, String test_key, final ButtonOptionsPopupListener listener) {
    if (MyDebug.LOG)
        Log.d(TAG, "createButtonOptions");
    final List<View> buttons = new ArrayList<>();
    if (supported_options != null) {
        final long debug_time = System.nanoTime();
        LinearLayout ll2 = new LinearLayout(context);
        ll2.setOrientation(LinearLayout.HORIZONTAL);
        if (MyDebug.LOG)
            Log.d(TAG, "addButtonOptionsToPopup time 1: " + (System.nanoTime() - debug_time));
        String[] icons = icons_id != -1 ? context.getResources().getStringArray(icons_id) : null;
        String[] values = values_id != -1 ? context.getResources().getStringArray(values_id) : null;
        if (MyDebug.LOG)
            Log.d(TAG, "addButtonOptionsToPopup time 2: " + (System.nanoTime() - debug_time));
        final float scale = context.getResources().getDisplayMetrics().density;
        if (MyDebug.LOG)
            Log.d(TAG, "addButtonOptionsToPopup time 2.04: " + (System.nanoTime() - debug_time));
        int button_width_dp = total_width_dp / supported_options.size();
        boolean use_scrollview = false;
        if (button_width_dp < 40) {
            button_width_dp = 40;
            use_scrollview = true;
        }
        // convert dps to pixels
        final int button_width = (int) (button_width_dp * scale + 0.5f);
        View.OnClickListener on_click_listener = new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                String supported_option = (String) v.getTag();
                if (MyDebug.LOG)
                    Log.d(TAG, "clicked: " + supported_option);
                listener.onClick(supported_option);
            }
        };
        View current_view = null;
        if (MyDebug.LOG)
            Log.d(TAG, "addButtonOptionsToPopup time 2.05: " + (System.nanoTime() - debug_time));
        for (final String supported_option : supported_options) {
            if (MyDebug.LOG)
                Log.d(TAG, "addButtonOptionsToPopup time 2.06: " + (System.nanoTime() - debug_time));
            if (MyDebug.LOG)
                Log.d(TAG, "supported_option: " + supported_option);
            int resource = -1;
            if (MyDebug.LOG)
                Log.d(TAG, "addButtonOptionsToPopup time 2.08: " + (System.nanoTime() - debug_time));
            if (icons != null && values != null) {
                int index = -1;
                for (int i = 0; i < values.length && index == -1; i++) {
                    if (values[i].equals(supported_option))
                        index = i;
                }
                if (MyDebug.LOG)
                    Log.d(TAG, "index: " + index);
                if (index != -1) {
                    resource = context.getResources().getIdentifier(icons[index], null, context.getApplicationContext().getPackageName());
                }
            }
            if (MyDebug.LOG)
                Log.d(TAG, "addButtonOptionsToPopup time 2.1: " + (System.nanoTime() - debug_time));
            String button_string;
            // also some devices report e.g. "ISO100" etc
            if (prefix_string.length() == 0) {
                button_string = supported_option;
            } else if (prefix_string.equalsIgnoreCase("ISO") && supported_option.length() >= 4 && supported_option.substring(0, 4).equalsIgnoreCase("ISO_")) {
                button_string = (include_prefix ? prefix_string : "") + "\n" + supported_option.substring(4);
            } else if (prefix_string.equalsIgnoreCase("ISO") && supported_option.length() >= 3 && supported_option.substring(0, 3).equalsIgnoreCase("ISO")) {
                button_string = (include_prefix ? prefix_string : "") + "\n" + supported_option.substring(3);
            } else {
                button_string = (include_prefix ? prefix_string : "") + "\n" + supported_option;
            }
            if (MyDebug.LOG)
                Log.d(TAG, "button_string: " + button_string);
            if (MyDebug.LOG)
                Log.d(TAG, "addButtonOptionsToPopup time 2.105: " + (System.nanoTime() - debug_time));
            View view;
            if (resource != -1) {
                ImageButton image_button = new ImageButton(context);
                if (MyDebug.LOG)
                    Log.d(TAG, "addButtonOptionsToPopup time 2.11: " + (System.nanoTime() - debug_time));
                view = image_button;
                buttons.add(view);
                ll2.addView(view);
                if (MyDebug.LOG)
                    Log.d(TAG, "addButtonOptionsToPopup time 2.12: " + (System.nanoTime() - debug_time));
                // image_button.setImageResource(resource);
                final MainActivity main_activity = (MainActivity) context;
                Bitmap bm = main_activity.getPreloadedBitmap(resource);
                if (bm != null)
                    image_button.setImageBitmap(bm);
                else {
                    if (MyDebug.LOG)
                        Log.d(TAG, "failed to find bitmap for resource " + resource + "!");
                }
                if (MyDebug.LOG)
                    Log.d(TAG, "addButtonOptionsToPopup time 2.13: " + (System.nanoTime() - debug_time));
                image_button.setScaleType(ScaleType.FIT_CENTER);
                image_button.setBackgroundColor(Color.TRANSPARENT);
                // convert dps to pixels
                final int padding = (int) (7 * scale + 0.5f);
                view.setPadding(padding, padding, padding, padding);
            } else {
                Button button = new Button(context);
                // workaround for Android 6 crash!
                button.setBackgroundColor(Color.TRANSPARENT);
                view = button;
                buttons.add(view);
                ll2.addView(view);
                button.setText(button_string);
                button.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12.0f);
                button.setTextColor(Color.WHITE);
                // need 0 padding so we have enough room to display text for ISO buttons, when there are 6 ISO settings
                // convert dps to pixels
                final int padding = (int) (0 * scale + 0.5f);
                view.setPadding(padding, padding, padding, padding);
            }
            if (MyDebug.LOG)
                Log.d(TAG, "addButtonOptionsToPopup time 2.2: " + (System.nanoTime() - debug_time));
            ViewGroup.LayoutParams params = view.getLayoutParams();
            params.width = button_width;
            // be careful of making the height too smaller, as harder to touch buttons; remember that this also affects the
            // ISO buttons on exposure panel, and not just the main popup!
            // convert dps to pixels
            params.height = (int) (50 * scale + 0.5f);
            view.setLayoutParams(params);
            view.setContentDescription(button_string);
            if (supported_option.equals(current_value)) {
                setButtonSelected(view, true);
                current_view = view;
            } else {
                setButtonSelected(view, false);
            }
            if (MyDebug.LOG)
                Log.d(TAG, "addButtonOptionsToPopup time 2.3: " + (System.nanoTime() - debug_time));
            view.setTag(supported_option);
            view.setOnClickListener(on_click_listener);
            if (MyDebug.LOG)
                Log.d(TAG, "addButtonOptionsToPopup time 2.35: " + (System.nanoTime() - debug_time));
            if (test_ui_buttons != null)
                test_ui_buttons.put(test_key + "_" + supported_option, view);
            if (MyDebug.LOG) {
                Log.d(TAG, "addButtonOptionsToPopup time 2.4: " + (System.nanoTime() - debug_time));
                Log.d(TAG, "added to popup_buttons: " + test_key + "_" + supported_option + " view: " + view);
                if (test_ui_buttons != null)
                    Log.d(TAG, "test_ui_buttons is now: " + test_ui_buttons);
            }
        }
        if (MyDebug.LOG)
            Log.d(TAG, "addButtonOptionsToPopup time 3: " + (System.nanoTime() - debug_time));
        if (use_scrollview) {
            if (MyDebug.LOG)
                Log.d(TAG, "using scrollview");
            // convert dps to pixels;
            final int total_width = (int) (total_width_dp * scale + 0.5f);
            final HorizontalScrollView scroll = new HorizontalScrollView(context);
            scroll.addView(ll2);
            {
                ViewGroup.LayoutParams params = new LayoutParams(total_width, LayoutParams.WRAP_CONTENT);
                scroll.setLayoutParams(params);
            }
            parent.addView(scroll);
            if (current_view != null) {
                // scroll to the selected button
                final View final_current_view = current_view;
                parent.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

                    @Override
                    public void onGlobalLayout() {
                        // scroll so selected button is centred
                        int jump_x = final_current_view.getLeft() - (total_width - button_width) / 2;
                        // scrollTo should automatically clamp to the bounds of the view, but just in case
                        jump_x = Math.min(jump_x, total_width - 1);
                        if (jump_x > 0) {
                            scroll.scrollTo(jump_x, 0);
                        }
                    }
                });
            }
        } else {
            if (MyDebug.LOG)
                Log.d(TAG, "not using scrollview");
            parent.addView(ll2);
        }
        if (MyDebug.LOG)
            Log.d(TAG, "addButtonOptionsToPopup time 4: " + (System.nanoTime() - debug_time));
    }
    return buttons;
}
Also used : ViewGroup(android.view.ViewGroup) OnGlobalLayoutListener(android.view.ViewTreeObserver.OnGlobalLayoutListener) ArrayList(java.util.ArrayList) MainActivity(net.sourceforge.opencamera.MainActivity) HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) ImageButton(android.widget.ImageButton) Bitmap(android.graphics.Bitmap) ImageButton(android.widget.ImageButton) RadioButton(android.widget.RadioButton) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) HorizontalScrollView(android.widget.HorizontalScrollView) LinearLayout(android.widget.LinearLayout)

Example 2 with MainActivity

use of net.sourceforge.opencamera.MainActivity in project OpenCamera by ageback.

the class PopupView method addRadioOptionsToGroup.

private void addRadioOptionsToGroup(final RadioGroup rg, SharedPreferences sharedPreferences, List<String> supported_options_entries, List<String> supported_options_values, final String title, final String preference_key, final String default_value, final String test_key, final RadioOptionsListener listener) {
    if (MyDebug.LOG)
        Log.d(TAG, "addRadioOptionsToGroup: " + title);
    String current_option_value = sharedPreferences.getString(preference_key, default_value);
    final long debug_time = System.nanoTime();
    final MainActivity main_activity = (MainActivity) this.getContext();
    int count = 0;
    for (int i = 0; i < supported_options_entries.size(); i++) {
        final String supported_option_entry = supported_options_entries.get(i);
        final String supported_option_value = supported_options_values.get(i);
        if (MyDebug.LOG) {
            Log.d(TAG, "supported_option_entry: " + supported_option_entry);
            Log.d(TAG, "supported_option_value: " + supported_option_value);
        }
        if (MyDebug.LOG)
            Log.d(TAG, "addRadioOptionsToGroup time 1: " + (System.nanoTime() - debug_time));
        RadioButton button = new RadioButton(this.getContext());
        if (MyDebug.LOG)
            Log.d(TAG, "addRadioOptionsToGroup time 2: " + (System.nanoTime() - debug_time));
        button.setId(count);
        button.setText(supported_option_entry);
        button.setTextColor(Color.WHITE);
        if (MyDebug.LOG)
            Log.d(TAG, "addRadioOptionsToGroup time 3: " + (System.nanoTime() - debug_time));
        if (MyDebug.LOG)
            Log.d(TAG, "addRadioOptionsToGroup time 4: " + (System.nanoTime() - debug_time));
        rg.addView(button);
        if (MyDebug.LOG)
            Log.d(TAG, "addRadioOptionsToGroup time 5: " + (System.nanoTime() - debug_time));
        if (supported_option_value.equals(current_option_value)) {
            // button.setChecked(true);
            rg.check(count);
        }
        count++;
        button.setContentDescription(supported_option_entry);
        if (MyDebug.LOG)
            Log.d(TAG, "addRadioOptionsToGroup time 6: " + (System.nanoTime() - debug_time));
        button.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                if (MyDebug.LOG) {
                    Log.d(TAG, "clicked current_option entry: " + supported_option_entry);
                    Log.d(TAG, "clicked current_option entry: " + supported_option_value);
                }
                SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(main_activity);
                SharedPreferences.Editor editor = sharedPreferences.edit();
                editor.putString(preference_key, supported_option_value);
                editor.apply();
                if (listener != null) {
                    listener.onClick(supported_option_value);
                } else {
                    main_activity.updateForSettings(title + ": " + supported_option_entry);
                    main_activity.closePopup();
                }
            }
        });
        if (MyDebug.LOG)
            Log.d(TAG, "addRadioOptionsToGroup time 7: " + (System.nanoTime() - debug_time));
        main_activity.getMainUI().getTestUIButtonsMap().put(test_key + "_" + supported_option_value, button);
        if (MyDebug.LOG)
            Log.d(TAG, "addRadioOptionsToGroup time 8: " + (System.nanoTime() - debug_time));
    }
    if (MyDebug.LOG)
        Log.d(TAG, "addRadioOptionsToGroup time total: " + (System.nanoTime() - debug_time));
}
Also used : SharedPreferences(android.content.SharedPreferences) MainActivity(net.sourceforge.opencamera.MainActivity) RadioButton(android.widget.RadioButton) HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView)

Example 3 with MainActivity

use of net.sourceforge.opencamera.MainActivity in project OpenCamera by ageback.

the class PopupView method addRadioOptionsToPopup.

/**
 * Adds a set of radio options to the popup menu.
 * @param sharedPreferences         The SharedPreferences.
 * @param supported_options_entries The strings to display on the radio options.
 * @param supported_options_values  A corresponding array of values. These aren't shown to the
 *                                  user, but are the values that will be set in the
 *                                  sharedPreferences, and passed to the listener.
 * @param title                     The text to display as a title for this radio group.
 * @param preference_key            The preference key to use for the values in the
 *                                  sharedPreferences.
 * @param default_value             The default value for the preference_key in the
 *                                  sharedPreferences.
 * @param test_key                  Used for testing, a tag to identify the RadioGroup that's
 *                                  created.
 * @param listener                  If null, selecting an option will call
 *                                  MainActivity.updateForSettings() and close the popup. If
 *                                  not null, instead selecting an option will call the
 *                                  listener.
 */
private void addRadioOptionsToPopup(final SharedPreferences sharedPreferences, final List<String> supported_options_entries, final List<String> supported_options_values, final String title, final String preference_key, final String default_value, final String test_key, final RadioOptionsListener listener) {
    if (MyDebug.LOG)
        Log.d(TAG, "addRadioOptionsToPopup: " + title);
    if (supported_options_entries != null) {
        final MainActivity main_activity = (MainActivity) this.getContext();
        final long debug_time = System.nanoTime();
        // addTitleToPopup(title);
        final Button button = new Button(this.getContext());
        // workaround for Android 6 crash!
        button.setBackgroundColor(Color.TRANSPARENT);
        button.setText(title + "...");
        this.addView(button);
        if (MyDebug.LOG)
            Log.d(TAG, "addRadioOptionsToPopup time 1: " + (System.nanoTime() - debug_time));
        final RadioGroup rg = new RadioGroup(this.getContext());
        rg.setOrientation(RadioGroup.VERTICAL);
        rg.setVisibility(View.GONE);
        main_activity.getMainUI().getTestUIButtonsMap().put(test_key, rg);
        if (MyDebug.LOG)
            Log.d(TAG, "addRadioOptionsToPopup time 2: " + (System.nanoTime() - debug_time));
        button.setOnClickListener(new OnClickListener() {

            private boolean opened = false;

            private boolean created = false;

            @Override
            public void onClick(View view) {
                if (MyDebug.LOG)
                    Log.d(TAG, "clicked to open radio buttons menu: " + title);
                if (opened) {
                    // rg.removeAllViews();
                    rg.setVisibility(View.GONE);
                    final ScrollView popup_container = (ScrollView) main_activity.findViewById(R.id.popup_container);
                    // need to invalidate/requestLayout so that the scrollview's scroll positions update - otherwise scrollBy below doesn't work properly, when the user reopens the radio buttons
                    popup_container.invalidate();
                    popup_container.requestLayout();
                } else {
                    if (!created) {
                        addRadioOptionsToGroup(rg, sharedPreferences, supported_options_entries, supported_options_values, title, preference_key, default_value, test_key, listener);
                        created = true;
                    }
                    rg.setVisibility(View.VISIBLE);
                    final ScrollView popup_container = (ScrollView) main_activity.findViewById(R.id.popup_container);
                    popup_container.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

                        @SuppressWarnings("deprecation")
                        @Override
                        public void onGlobalLayout() {
                            if (MyDebug.LOG)
                                Log.d(TAG, "onGlobalLayout()");
                            // stop listening - only want to call this once!
                            if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
                                popup_container.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                            } else {
                                popup_container.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                            }
                            // so that the user sees the options appear, if the button is at the bottom of the current scrollview position
                            if (rg.getChildCount() > 0) {
                                int id = rg.getCheckedRadioButtonId();
                                if (id >= 0 && id < rg.getChildCount()) {
                                    popup_container.smoothScrollBy(0, rg.getChildAt(id).getBottom());
                                }
                            }
                        }
                    });
                }
                opened = !opened;
            }
        });
        this.addView(rg);
        if (MyDebug.LOG)
            Log.d(TAG, "addRadioOptionsToPopup time 5: " + (System.nanoTime() - debug_time));
    }
}
Also used : RadioGroup(android.widget.RadioGroup) HorizontalScrollView(android.widget.HorizontalScrollView) ScrollView(android.widget.ScrollView) ImageButton(android.widget.ImageButton) RadioButton(android.widget.RadioButton) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) OnGlobalLayoutListener(android.view.ViewTreeObserver.OnGlobalLayoutListener) MainActivity(net.sourceforge.opencamera.MainActivity) HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView)

Example 4 with MainActivity

use of net.sourceforge.opencamera.MainActivity in project OpenCamera by ageback.

the class PopupView method switchToWhiteBalance.

public void switchToWhiteBalance(String selected_value) {
    if (MyDebug.LOG)
        Log.d(TAG, "switchToWhiteBalance: " + selected_value);
    final MainActivity main_activity = (MainActivity) this.getContext();
    final Preview preview = main_activity.getPreview();
    boolean close_popup = false;
    int temperature = -1;
    if (selected_value.equals("manual")) {
        if (preview.getCameraController() != null) {
            String current_white_balance = preview.getCameraController().getWhiteBalance();
            if (current_white_balance == null || !current_white_balance.equals("manual")) {
                // try to choose a default manual white balance temperature as close as possible to the current auto
                if (MyDebug.LOG)
                    Log.d(TAG, "changed to manual white balance");
                close_popup = true;
                if (preview.getCameraController().captureResultHasWhiteBalanceTemperature()) {
                    temperature = preview.getCameraController().captureResultWhiteBalanceTemperature();
                    if (MyDebug.LOG)
                        Log.d(TAG, "default to manual white balance temperature: " + temperature);
                    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(main_activity);
                    SharedPreferences.Editor editor = sharedPreferences.edit();
                    editor.putInt(PreferenceKeys.WhiteBalanceTemperaturePreferenceKey, temperature);
                    editor.apply();
                }
            // otherwise default to the saved value
            }
        }
    }
    if (preview.getCameraController() != null) {
        preview.getCameraController().setWhiteBalance(selected_value);
        if (temperature > 0) {
            preview.getCameraController().setWhiteBalanceTemperature(temperature);
            // also need to update the slider!
            main_activity.setManualWBSeekbar();
        }
    }
    // keep popup open, unless switching to manual
    if (close_popup) {
        main_activity.closePopup();
    }
// main_activity.updateForSettings(getResources().getString(R.string.white_balance) + ": " + selected_value);
// main_activity.closePopup();
}
Also used : SharedPreferences(android.content.SharedPreferences) Preview(net.sourceforge.opencamera.Preview.Preview) MainActivity(net.sourceforge.opencamera.MainActivity)

Example 5 with MainActivity

use of net.sourceforge.opencamera.MainActivity in project OpenCamera by ageback.

the class PopupView method addArrayOptionsToPopup.

/**
 * Adds a set of options to the popup menu, where there user can select one option out of an array of values, using previous or
 *  next buttons to switch between them.
 * @param supported_options The strings for the array of values to choose from.
 * @param title Title to display.
 * @param title_in_options Prepend the title to each of the values, rather than above the values.
 * @param title_in_options_first_only If title_in_options is true, only prepend to the first option.
 * @param current_index Index in the supported_options array of the currently selected option.
 * @param cyclic Whether the user can cycle beyond the start/end, to wrap around.
 * @param test_key Used to keep track of the UI elements created, for testing.
 * @param listener Listener called when previous/next buttons are clicked (and hence the option
 *                 changed).
 */
private void addArrayOptionsToPopup(final List<String> supported_options, final String title, final boolean title_in_options, final boolean title_in_options_first_only, final int current_index, final boolean cyclic, final String test_key, final ArrayOptionsPopupListener listener) {
    if (supported_options != null && current_index != -1) {
        if (!title_in_options) {
            addTitleToPopup(title);
        }
        final MainActivity main_activity = (MainActivity) this.getContext();
        /*final Button prev_button = new Button(this.getContext());
			//prev_button.setBackgroundResource(R.drawable.exposure);
			prev_button.setBackgroundColor(Color.TRANSPARENT); // workaround for Android 6 crash!
			prev_button.setText("<");
			this.addView(prev_button);*/
        LinearLayout ll2 = new LinearLayout(this.getContext());
        ll2.setOrientation(LinearLayout.HORIZONTAL);
        final TextView resolution_text_view = new TextView(this.getContext());
        setArrayOptionsText(supported_options, title, resolution_text_view, title_in_options, title_in_options_first_only, current_index);
        resolution_text_view.setTextColor(Color.WHITE);
        resolution_text_view.setGravity(Gravity.CENTER);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1.0f);
        resolution_text_view.setLayoutParams(params);
        final float scale = getResources().getDisplayMetrics().density;
        // convert dps to pixels
        final int padding = (int) (0 * scale + 0.5f);
        // convert dps to pixels
        final int button_w = (int) (60 * scale + 0.5f);
        // convert dps to pixels
        final int button_h = (int) (30 * scale + 0.5f);
        final Button prev_button = new Button(this.getContext());
        // workaround for Android 6 crash!
        prev_button.setBackgroundColor(Color.TRANSPARENT);
        ll2.addView(prev_button);
        prev_button.setText("<");
        prev_button.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12.0f);
        prev_button.setPadding(padding, padding, padding, padding);
        ViewGroup.LayoutParams vg_params = prev_button.getLayoutParams();
        vg_params.width = button_w;
        vg_params.height = button_h;
        prev_button.setLayoutParams(vg_params);
        prev_button.setVisibility((cyclic || current_index > 0) ? View.VISIBLE : View.INVISIBLE);
        main_activity.getMainUI().getTestUIButtonsMap().put(test_key + "_PREV", prev_button);
        ll2.addView(resolution_text_view);
        main_activity.getMainUI().getTestUIButtonsMap().put(test_key, resolution_text_view);
        final Button next_button = new Button(this.getContext());
        // workaround for Android 6 crash!
        next_button.setBackgroundColor(Color.TRANSPARENT);
        ll2.addView(next_button);
        next_button.setText(">");
        next_button.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12.0f);
        next_button.setPadding(padding, padding, padding, padding);
        vg_params = next_button.getLayoutParams();
        vg_params.width = button_w;
        vg_params.height = button_h;
        next_button.setLayoutParams(vg_params);
        next_button.setVisibility((cyclic || current_index < supported_options.size() - 1) ? View.VISIBLE : View.INVISIBLE);
        main_activity.getMainUI().getTestUIButtonsMap().put(test_key + "_NEXT", next_button);
        prev_button.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                int new_index = listener.onClickPrev();
                if (new_index != -1) {
                    setArrayOptionsText(supported_options, title, resolution_text_view, title_in_options, title_in_options_first_only, new_index);
                    prev_button.setVisibility((cyclic || new_index > 0) ? View.VISIBLE : View.INVISIBLE);
                    next_button.setVisibility((cyclic || new_index < supported_options.size() - 1) ? View.VISIBLE : View.INVISIBLE);
                }
            }
        });
        next_button.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                int new_index = listener.onClickNext();
                if (new_index != -1) {
                    setArrayOptionsText(supported_options, title, resolution_text_view, title_in_options, title_in_options_first_only, new_index);
                    prev_button.setVisibility((cyclic || new_index > 0) ? View.VISIBLE : View.INVISIBLE);
                    next_button.setVisibility((cyclic || new_index < supported_options.size() - 1) ? View.VISIBLE : View.INVISIBLE);
                }
            }
        });
        this.addView(ll2);
    }
}
Also used : ViewGroup(android.view.ViewGroup) MainActivity(net.sourceforge.opencamera.MainActivity) HorizontalScrollView(android.widget.HorizontalScrollView) View(android.view.View) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) ImageButton(android.widget.ImageButton) RadioButton(android.widget.RadioButton) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Aggregations

MainActivity (net.sourceforge.opencamera.MainActivity)7 View (android.view.View)4 HorizontalScrollView (android.widget.HorizontalScrollView)4 RadioButton (android.widget.RadioButton)4 ScrollView (android.widget.ScrollView)4 TextView (android.widget.TextView)4 SharedPreferences (android.content.SharedPreferences)3 Button (android.widget.Button)3 CompoundButton (android.widget.CompoundButton)3 ImageButton (android.widget.ImageButton)3 ViewGroup (android.view.ViewGroup)2 OnGlobalLayoutListener (android.view.ViewTreeObserver.OnGlobalLayoutListener)2 LinearLayout (android.widget.LinearLayout)2 AlertDialog (android.app.AlertDialog)1 DialogInterface (android.content.DialogInterface)1 Bitmap (android.graphics.Bitmap)1 RadioGroup (android.widget.RadioGroup)1 ArrayList (java.util.ArrayList)1 Preview (net.sourceforge.opencamera.Preview.Preview)1