Example usage for android.media ToneGenerator ToneGenerator

List of usage examples for android.media ToneGenerator ToneGenerator

Introduction

In this page you can find the example usage for android.media ToneGenerator ToneGenerator.

Prototype

public ToneGenerator(int streamType, int volume) 

Source Link

Document

ToneGenerator class contructor specifying output stream type and volume.

Usage

From source file:jmri.enginedriver.throttle.java

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@SuppressLint({ "Recycle", "SetJavaScriptEnabled", "ClickableViewAccessibility" })
@Override//w w w . j a  va 2 s  . c o m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState != null) {
        try {
            // restore the requested throttle direction so we can update the
            // direction indication while we wait for an update from WiT
            for (int throttleIndex = 0; throttleIndex < mainapp.maxThrottlesCurrentScreen; throttleIndex++) {
                if (savedInstanceState
                        .getSerializable("dir" + mainapp.throttleIntToString(throttleIndex)) != null)
                    dirs[throttleIndex] = (int) savedInstanceState.getSerializable("dir" + throttleIndex);
            }
        } catch (Exception ignored) { // log the error, but otherwise keep going.
            Log.d("Engine_Driver",
                    "Restore of saved instance state failed " + android.os.Build.VERSION.SDK_INT);
        }
    }

    mainapp = (threaded_application) this.getApplication();

    prefs = getSharedPreferences("jmri.enginedriver_preferences", 0);

    if (mainapp.isForcingFinish()) { // expedite
        mainapp.appIsFinishing = true;
        return;
    }

    mainapp.applyTheme(this);
    setTitle(getApplicationContext().getResources().getString(R.string.app_name_throttle)); // needed in case the language was changed from the default

    //        setContentView(R.layout.throttle);
    setContentView(layoutViewId);

    getCommonPrefs(true); // get all the common preferences
    setThottleNumLimits();

    getDirectionButtonPrefs();

    webViewIsOn = !webViewLocation.equals(WEB_VIEW_LOCATION_NONE);
    keepWebViewLocation = webViewLocation;

    isScreenLocked = false;

    // get the screen brightness on create
    screenBrightnessOriginal = getScreenBrightness();
    screenBrightnessModeOriginal = getScreenBrightnessMode();

    // myGesture = new GestureDetector(this);
    GestureOverlayView ov = findViewById(R.id.throttle_overlay);
    ov.addOnGestureListener(this);
    ov.setGestureVisible(false);

    direction_button_touch_listener dbtl;
    function_button_touch_listener fbtl;
    select_function_button_touch_listener sfbt;
    arrow_speed_button_touch_listener asbl;

    bSels = new Button[mainapp.maxThrottles];
    bRSpds = new Button[mainapp.maxThrottles];
    bLSpds = new Button[mainapp.maxThrottles];

    tvLeftDirInds = new TextView[mainapp.maxThrottles];
    tvRightDirInds = new TextView[mainapp.maxThrottles];

    bFwds = new Button[mainapp.maxThrottles];
    bStops = new Button[mainapp.maxThrottles];
    bRevs = new Button[mainapp.maxThrottles];
    sbs = new SeekBar[mainapp.maxThrottles];

    tvGamePads = new TextView[mainapp.maxThrottles];
    tvSpdLabs = new TextView[mainapp.maxThrottles];
    tvSpdVals = new TextView[mainapp.maxThrottles];
    tvVols = new TextView[mainapp.maxThrottles];

    lls = new LinearLayout[mainapp.maxThrottles];
    llSetSpds = new LinearLayout[mainapp.maxThrottles];
    llLocoIds = new LinearLayout[mainapp.maxThrottles];
    llLocoDirs = new LinearLayout[mainapp.maxThrottles];

    fbs = new ViewGroup[mainapp.maxThrottles];

    tops = new int[mainapp.maxThrottles];
    bottoms = new int[mainapp.maxThrottles];

    functionMaps = (LinkedHashMap<Integer, Button>[]) new LinkedHashMap<?, ?>[mainapp.maxThrottles];

    displayUnitScales = new double[mainapp.maxThrottles];

    changeTimers = new ChangeDelay[mainapp.maxThrottles];

    // throttle layouts
    vThrotScr = findViewById(R.id.throttle_screen);
    vThrotScrWrap = findViewById(R.id.throttle_screen_wrapper);

    for (int i = 0; i < mainapp.maxThrottles; i++) {
        // set listener for select loco buttons
        Button bSel = findViewById(R.id.button_select_loco_0);
        TextView tvLeft = findViewById(R.id.loco_left_direction_indicaton_0);
        TextView tvRight = findViewById(R.id.loco_right_direction_indicaton_0);
        switch (i) {
        case 1:
            bSel = findViewById(R.id.button_select_loco_1);
            tvLeft = findViewById(R.id.loco_left_direction_indicaton_1);
            tvRight = findViewById(R.id.loco_right_direction_indicaton_1);
            break;
        case 2:
            bSel = findViewById(R.id.button_select_loco_2);
            tvLeft = findViewById(R.id.loco_left_direction_indicaton_2);
            tvRight = findViewById(R.id.loco_right_direction_indicaton_2);
            break;
        case 3:
            bSel = findViewById(R.id.button_select_loco_3);
            tvLeft = findViewById(R.id.loco_left_direction_indicaton_3);
            tvRight = findViewById(R.id.loco_right_direction_indicaton_3);
            break;
        case 4:
            bSel = findViewById(R.id.button_select_loco_4);
            tvLeft = findViewById(R.id.loco_left_direction_indicaton_4);
            tvRight = findViewById(R.id.loco_right_direction_indicaton_4);
            break;
        case 5:
            bSel = findViewById(R.id.button_select_loco_5);
            tvLeft = findViewById(R.id.loco_left_direction_indicaton_5);
            tvRight = findViewById(R.id.loco_right_direction_indicaton_5);
            break;
        }
        bSels[i] = bSel;
        bSels[i].setClickable(true);
        sfbt = new select_function_button_touch_listener(i);
        bSels[i].setOnClickListener(sfbt);
        bSels[i].setOnTouchListener(sfbt);
        bSels[i].setOnLongClickListener(sfbt); // Consist Light Edit
        tvLeftDirInds[i] = tvLeft;
        tvRightDirInds[i] = tvRight;

        // Arrow Keys
        try {

            Button bRight = findViewById(R.id.right_speed_button_0);
            Button bLeft = findViewById(R.id.left_speed_button_0);
            switch (i) {
            case 1:
                bRight = findViewById(R.id.right_speed_button_1);
                bLeft = findViewById(R.id.left_speed_button_1);
                break;
            case 2:
                bRight = findViewById(R.id.right_speed_button_2);
                bLeft = findViewById(R.id.left_speed_button_2);
                break;
            case 3:
                bRight = findViewById(R.id.right_speed_button_3);
                bLeft = findViewById(R.id.left_speed_button_3);
                break;
            case 4:
                bRight = findViewById(R.id.right_speed_button_4);
                bLeft = findViewById(R.id.left_speed_button_4);
                break;
            case 5:
                bRight = findViewById(R.id.right_speed_button_5);
                bLeft = findViewById(R.id.left_speed_button_5);
                break;
            }
            bRSpds[i] = bRight;
            bRSpds[i].setClickable(true);
            asbl = new arrow_speed_button_touch_listener(i, "right");
            bRSpds[i].setOnLongClickListener(asbl);
            bRSpds[i].setOnTouchListener(asbl);
            bRSpds[i].setOnClickListener(asbl);

            bLSpds[i] = bLeft;
            bLSpds[i].setClickable(true);
            asbl = new arrow_speed_button_touch_listener(i, "left");
            bLSpds[i].setOnLongClickListener(asbl);
            bLSpds[i].setOnTouchListener(asbl);
            bLSpds[i].setOnClickListener(asbl);

        } catch (Exception ex) {
            Log.d("debug", "onCreate: " + ex.getMessage());
        }

        // set listeners for 3 direction buttons for each throttle
        //----------------------------------------
        Button bFwd = findViewById(R.id.button_fwd_0);
        Button bStop = findViewById(R.id.button_stop_0);
        Button bRev = findViewById(R.id.button_rev_0);
        View v = findViewById(R.id.speed_cell_0);
        switch (i) {
        case 1:
            bFwd = findViewById(R.id.button_fwd_1);
            bStop = findViewById(R.id.button_stop_1);
            bRev = findViewById(R.id.button_rev_1);
            v = findViewById(R.id.speed_cell_1);
            break;
        case 2:
            bFwd = findViewById(R.id.button_fwd_2);
            bStop = findViewById(R.id.button_stop_2);
            bRev = findViewById(R.id.button_rev_2);
            v = findViewById(R.id.speed_cell_2);
            break;
        case 3:
            bFwd = findViewById(R.id.button_fwd_3);
            bStop = findViewById(R.id.button_stop_3);
            bRev = findViewById(R.id.button_rev_3);
            v = findViewById(R.id.speed_cell_3);
            break;
        case 4:
            bFwd = findViewById(R.id.button_fwd_4);
            bStop = findViewById(R.id.button_stop_4);
            bRev = findViewById(R.id.button_rev_4);
            v = findViewById(R.id.speed_cell_4);
            break;
        case 5:
            bFwd = findViewById(R.id.button_fwd_5);
            bStop = findViewById(R.id.button_stop_5);
            bRev = findViewById(R.id.button_rev_5);
            v = findViewById(R.id.speed_cell_5);
            break;
        }

        bFwds[i] = bFwd;
        dbtl = new direction_button_touch_listener(direction_button.LEFT, i);
        bFwds[i].setOnTouchListener(dbtl);

        bStops[i] = bStop;
        fbtl = new function_button_touch_listener(function_button.STOP, i);
        bStops[i].setOnTouchListener(fbtl);

        bRevs[i] = bRev;
        dbtl = new direction_button_touch_listener(direction_button.RIGHT, i);
        bRevs[i].setOnTouchListener(dbtl);

        fbtl = new function_button_touch_listener(function_button.SPEED_LABEL, i);
        v.setOnTouchListener(fbtl);

        // set up listeners for all throttles
        SeekBar s = findViewById(R.id.speed_0);
        switch (i) {
        case 1:
            s = findViewById(R.id.speed_1);
            break;
        case 2:
            s = findViewById(R.id.speed_2);
            break;
        case 3:
            s = findViewById(R.id.speed_3);
            break;
        case 4:
            s = findViewById(R.id.speed_4);
            break;
        case 5:
            s = findViewById(R.id.speed_5);
            break;
        }
        throttle_listener thl;
        sbs[i] = s;
        thl = new throttle_listener(i);
        sbs[i].setOnSeekBarChangeListener(thl);
        sbs[i].setOnTouchListener(thl);

        max_throttle_change = 1;
        //          displaySpeedSteps = false;

        switch (i) {
        case 0:
            lls[i] = findViewById(R.id.throttle_0);
            //                    llSetSpds[i] = (LinearLayout) findViewById(R.id.throttle_0_setspeed);
            llLocoIds[i] = findViewById(R.id.loco_buttons_group_0);
            llLocoDirs[i] = findViewById(R.id.dir_buttons_table_0);
            tvVols[i] = findViewById(R.id.volume_indicator_0); // volume indicators
            tvGamePads[i] = findViewById(R.id.gamepad_indicator_0); // gamepad indicators
            tvSpdLabs[i] = findViewById(R.id.speed_label_0); // set_default_function_labels();
            tvSpdVals[i] = findViewById(R.id.speed_value_label_0);
            //**//                    fbs[i] = (ViewGroup) findViewById(R.id.function_buttons_table_0);
            break;
        case 1:
            lls[i] = findViewById(R.id.throttle_1);
            //                    llSetSpds[i] = (LinearLayout) findViewById(R.id.throttle_1_setspeed);
            llLocoIds[i] = findViewById(R.id.loco_buttons_group_1);
            llLocoDirs[i] = findViewById(R.id.dir_buttons_table_1);
            tvVols[i] = findViewById(R.id.volume_indicator_1); // volume indicators
            tvGamePads[i] = findViewById(R.id.gamepad_indicator_1); // gamepad indicators
            tvSpdLabs[i] = findViewById(R.id.speed_label_1); // set_default_function_labels();
            tvSpdVals[i] = findViewById(R.id.speed_value_label_1);
            //**//                    fbs[i] = (ViewGroup) findViewById(R.id.function_buttons_table_1);
            break;
        case 2:
            lls[i] = findViewById(R.id.throttle_2);
            //                    llSetSpds[i] = (LinearLayout) findViewById(R.id.throttle_2_setspeed);
            llLocoIds[i] = findViewById(R.id.loco_buttons_group_2);
            llLocoDirs[i] = findViewById(R.id.dir_buttons_table_2);
            tvVols[i] = findViewById(R.id.volume_indicator_2); // volume indicators
            tvGamePads[i] = findViewById(R.id.gamepad_indicator_2); // gamepad indicators
            tvSpdLabs[i] = findViewById(R.id.speed_label_2); // set_default_function_labels();
            tvSpdVals[i] = findViewById(R.id.speed_value_label_2);
            //**//                    fbs[i] = (ViewGroup) findViewById(R.id.function_buttons_table_2);
            break;
        case 3:
            lls[i] = findViewById(R.id.throttle_3);
            //                    llSetSpds[i] = (LinearLayout) findViewById(R.id.throttle_3_setspeed);
            llLocoIds[i] = findViewById(R.id.loco_buttons_group_3);
            llLocoDirs[i] = findViewById(R.id.dir_buttons_table_3);
            tvVols[i] = findViewById(R.id.volume_indicator_3); // volume indicators
            tvGamePads[i] = findViewById(R.id.gamepad_indicator_3); // gamepad indicators
            tvSpdLabs[i] = findViewById(R.id.speed_label_3); // set_default_function_labels();
            tvSpdVals[i] = findViewById(R.id.speed_value_label_3);
            //**//                    fbs[i] = (ViewGroup) findViewById(R.id.function_buttons_table_3);
            break;
        case 4:
            lls[i] = findViewById(R.id.throttle_4);
            //                    llSetSpds[i] = (LinearLayout) findViewById(R.id.throttle_4_setspeed);
            llLocoIds[i] = findViewById(R.id.loco_buttons_group_4);
            llLocoDirs[i] = findViewById(R.id.dir_buttons_table_4);
            tvVols[i] = findViewById(R.id.volume_indicator_4); // volume indicators
            tvGamePads[i] = findViewById(R.id.gamepad_indicator_4); // gamepad indicators
            tvSpdLabs[i] = findViewById(R.id.speed_label_4); // set_default_function_labels();
            tvSpdVals[i] = findViewById(R.id.speed_value_label_4);
            //**//                    fbs[i] = (ViewGroup) findViewById(R.id.function_buttons_table_4);
            break;
        case 5:
            lls[i] = findViewById(R.id.throttle_5);
            //                    llSetSpds[i] = (LinearLayout) findViewById(R.id.throttle_5_setspeed);
            llLocoIds[i] = findViewById(R.id.loco_buttons_group_5);
            llLocoDirs[i] = findViewById(R.id.dir_buttons_table_5);
            tvVols[i] = findViewById(R.id.volume_indicator_5); // volume indicators
            tvGamePads[i] = findViewById(R.id.gamepad_indicator_5); // gamepad indicators
            tvSpdLabs[i] = findViewById(R.id.speed_label_5); // set_default_function_labels();
            tvSpdVals[i] = findViewById(R.id.speed_value_label_5);
            //**//                    fbs[i] = (ViewGroup) findViewById(R.id.function_buttons_table_5);
            break;
        }

        // set throttle change delay timers
        changeTimers[i] = new ChangeDelay(i);

    }

    clearVolumeAndGamepadAdditionalIndicators();

    setDirectionButtonLabels(); // set all the direction button labels

    // set label and dcc functions (based on settings) or hide if no label
    setAllFunctionLabelsAndListeners();

    if (mVelocityTracker == null) {
        mVelocityTracker = VelocityTracker.obtain();
    }

    setActiveThrottle(0); // set the throttle the volume keys control depending on the preference to the default 0

    webView = findViewById(R.id.throttle_webview);
    String databasePath = webView.getContext().getDir("databases", Context.MODE_PRIVATE).getPath();
    webView.getSettings().setDatabasePath(databasePath);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setBuiltInZoomControls(true); // Enable Multitouch
    // if supported
    webView.getSettings().setUseWideViewPort(true); // Enable greater
    // zoom-out
    webView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);
    webView.setInitialScale((int) (100 * scale));
    // webView.getSettings().setLoadWithOverviewMode(true); // size image to
    // fill width

    // open all links inside the current view (don't start external web
    // browser)
    noUrl = getApplicationContext().getResources().getString(R.string.blank_page_url);

    WebViewClient EDWebClient = new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            return false;
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            if (!noUrl.equals(url)) { // if url is legit
                currentUrl = url;
                if (firstUrl == null) { // if this is the first legit url 
                    firstUrl = url;
                    clearHistory = true;
                }
                if (clearHistory) { // keep clearing history until off this page
                    if (url.equals(firstUrl)) { // (works around Android bug)
                        webView.clearHistory();
                    } else {
                        clearHistory = false;
                    }
                }
            }
        }
    };

    webView.setWebViewClient(EDWebClient);
    if (currentUrl == null || savedInstanceState == null || webView.restoreState(savedInstanceState) == null) {
        load_webview(); // reload if no saved state or no page had loaded when state was saved
    }
    // put pointer to this activity's handler in main app's shared variable
    mainapp.throttle_msg_handler = new throttle_handler();

    // set throttle change delay timers
    for (int throttleIndex = 0; throttleIndex < mainapp.maxThrottles; throttleIndex++) {
        changeTimers[throttleIndex] = new ChangeDelay(throttleIndex);
    }
    // tone generator for feedback sounds
    try {
        tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION,
                preferences.getIntPrefValue(prefs, "prefGamePadFeedbackVolume", getApplicationContext()
                        .getResources().getString(R.string.prefGamePadFeedbackVolumeDefaultValue)));
    } catch (RuntimeException e) {
        Log.e("Engine_Driver", "new ToneGenerator failed. Runtime Exception, OS "
                + android.os.Build.VERSION.SDK_INT + " Message: " + e);
    }
    // set GamePad Support
    setGamepadKeys();

    // initialise ESU MCII
    if (IS_ESU_MCII) {
        Log.d("Engine_Driver", "ESU_MCII: Initialise fragments...");
        int zeroTrim = preferences.getIntPrefValue(prefs, "prefEsuMc2ZeroTrim",
                getApplicationContext().getResources().getString(R.string.prefEsuMc2ZeroTrimDefaultValue));
        esuThrottleFragment = ThrottleFragment.newInstance(zeroTrim);
        esuThrottleFragment.setOnThrottleListener(esuOnThrottleListener);
        esuStopButtonFragment = StopButtonFragment.newInstance();
        esuStopButtonFragment.setOnStopButtonListener(esuOnStopButtonListener);
        Log.d("Engine_Driver", "ESU_MCII: ...fragments initialised");

        getSupportFragmentManager().beginTransaction().add(esuThrottleFragment, "mc2:throttle")
                .add(esuStopButtonFragment, "mc2:stopKey").commit();
        esuMc2Led.setState(EsuMc2Led.RED, EsuMc2LedState.OFF, true);
        esuMc2Led.setState(EsuMc2Led.GREEN, EsuMc2LedState.STEADY_FLASH, true);

        // Now apply knob zero trim
        updateEsuMc2ZeroTrim();
        Log.d("Engine_Driver", "ESU_MCII: Initialisation complete");
    }

    setupSensor(); // setup the support for shake actions.

    setupTts();

    if (prefs.getBoolean("prefImportServerAuto",
            getApplicationContext().getResources().getBoolean(R.bool.prefImportServerAutoDefaultValue))) {
        autoImportFromURL();
    }

}

From source file:jmri.enginedriver.throttle.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    case ACTIVITY_SELECT_LOCO:
        if (resultCode == select_loco.RESULT_LOCO_EDIT)
            ActivityConsistUpdate(resultCode, data.getExtras());
        if ((getConsist(whichVolume) != null) && (!getConsist(whichVolume).isActive())) {
            setNextActiveThrottle(); // if consist on Volume throttle was released, move to next throttle
        } else {//w  w w  . j av  a2s. c  om
            if (IS_ESU_MCII) {
                esuMc2Led.setState(EsuMc2Led.GREEN, EsuMc2LedState.STEADY_FLASH, true);
            }
            setActiveThrottle(whichVolume);
        }
        break;
    case ACTIVITY_CONSIST: // edit loco or edit consist
        if (resultCode == ConsistEdit.RESULT_CON_EDIT)
            ActivityConsistUpdate(resultCode, data.getExtras());
        break;
    case ACTIVITY_CONSIST_LIGHTS: // edit consist lights
        break; // nothing to do
    case ACTIVITY_PREFS: { // edit prefs
        if (resultCode == preferences.RESULT_GAMEPAD) { // gamepad pref changed
            // update tone generator volume
            if (tg != null) {
                tg.release();
                try {
                    tg = new ToneGenerator(AudioManager.STREAM_NOTIFICATION,
                            preferences.getIntPrefValue(prefs, "prefGamePadFeedbackVolume",
                                    getApplicationContext().getResources()
                                            .getString(R.string.prefGamePadFeedbackVolumeDefaultValue)));
                } catch (RuntimeException e) {
                    Log.e("Engine_Driver", "new ToneGenerator failed. Runtime Exception, OS "
                            + android.os.Build.VERSION.SDK_INT + " Message: " + e);
                }
            }
            // update GamePad Support
            setGamepadKeys();
        }
        if (resultCode == preferences.RESULT_ESUMCII) { // ESU MCII pref change
            // update zero trim values
            updateEsuMc2ZeroTrim();
        }
        // in case the preference has changed but the current screen does not support the number selected.
        setThottleNumLimits();

        getKidsTimerPrefs();
        if (prefKidsTimer.equals(PREF_KIDS_TIMER_NONE)) {
            kidsTimerActions(KIDS_TIMER_DISABLED, 0);
        }

        break;
    }
    case ACTIVITY_GAMEPAD_TEST: {
        if (data != null) {
            String whichGamepadNo = data.getExtras().getString("whichGamepadNo");
            if (whichGamepadNo != null) {
                int result = Integer.valueOf(whichGamepadNo.substring(1, 2));
                int gamepadNo = Integer.valueOf(whichGamepadNo.substring(0, 1));
                switch (result) {
                case GAMEPAD_TEST_PASS:
                    gamePadDeviceIdsTested[gamepadNo] = GAMEPAD_GOOD;
                    speakWords(TTS_MSG_GAMEPAD_GAMEPAD_TEST_COMPLETE, ' ');
                    break;
                case GAMEPAD_TEST_SKIPPED:
                    gamePadDeviceIdsTested[gamepadNo] = GAMEPAD_GOOD;
                    speakWords(TTS_MSG_GAMEPAD_GAMEPAD_TEST_SKIPPED, ' ');
                    break;
                case GAMEPAD_TEST_FAIL:
                    gamePadDeviceIdsTested[gamepadNo] = GAMEPAD_BAD;
                    speakWords(TTS_MSG_GAMEPAD_GAMEPAD_TEST_FAIL, ' ');
                    break;
                case GAMEPAD_TEST_RESET:
                    gamepadCount = 0;
                    for (int i = 0; i < gamePadDeviceIds.length; i++) {
                        gamePadDeviceIds[i] = 0;
                        gamePadDeviceIdsTested[i] = 0;
                    }
                    for (int i = 0; i < 3; i++) {
                        gamePadIds[i] = 0;
                        gamePadThrottleAssignment[0] = -1;
                    }
                    mainapp.setGamepadTestMenuOption(TMenu, gamepadCount);
                    setGamepadIndicator();
                    speakWords(TTS_MSG_GAMEPAD_GAMEPAD_TEST_RESET, ' ');
                    break;
                default:
                    Log.e("Engine_Driver", "OnActivityResult(ACTIVITY_GAMEPAD_TEST) invalid result!");
                }
            }
        } else {
            Log.e("Engine_Driver", "OnActivityResult(ACTIVITY_GAMEPAD_TEST) called with null data!");
        }
        break;
    }
    }

    // loop through all function buttons and
    // set label and dcc functions (based on settings) or hide if no label
    setAllFunctionLabelsAndListeners();
    set_labels();

}