Example usage for android.widget TextView setContentDescription

List of usage examples for android.widget TextView setContentDescription

Introduction

In this page you can find the example usage for android.widget TextView setContentDescription.

Prototype

@RemotableViewMethod
public void setContentDescription(CharSequence contentDescription) 

Source Link

Document

Sets the View 's content description.

Usage

From source file:com.android.messaging.ui.conversation.ConversationFragment.java

public void updateActionBar(final ActionBar actionBar) {
    if (mComposeMessageView == null || !mComposeMessageView.updateActionBar(actionBar)) {
        updateActionAndStatusBarColor(actionBar);
        // We update this regardless of whether or not the action bar is showing so that we
        // don't get a race when it reappears.
        actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
        actionBar.setDisplayHomeAsUpEnabled(true);
        // Reset the back arrow to its default
        actionBar.setHomeAsUpIndicator(0);
        View customView = actionBar.getCustomView();
        if (customView == null || customView.getId() != R.id.conversation_title_container) {
            final LayoutInflater inflator = (LayoutInflater) getActivity()
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            customView = inflator.inflate(R.layout.action_bar_conversation_name, null);
            customView.setOnClickListener(new View.OnClickListener() {
                @Override/*w  w w.  ja v  a2  s . com*/
                public void onClick(final View v) {
                    onBackPressed();
                }
            });
            actionBar.setCustomView(customView);
        }

        final TextView conversationNameView = (TextView) customView.findViewById(R.id.conversation_title);
        final String conversationName = getConversationName();
        if (!TextUtils.isEmpty(conversationName)) {
            // RTL : To format conversation title if it happens to be phone numbers.
            final BidiFormatter bidiFormatter = BidiFormatter.getInstance();
            final String formattedName = bidiFormatter.unicodeWrap(UiUtils.commaEllipsize(conversationName,
                    conversationNameView.getPaint(), conversationNameView.getWidth(),
                    getString(R.string.plus_one), getString(R.string.plus_n)).toString(),
                    TextDirectionHeuristicsCompat.LTR);
            conversationNameView.setText(formattedName);
            // In case phone numbers are mixed in the conversation name, we need to vocalize it.
            final String vocalizedConversationName = AccessibilityUtil.getVocalizedPhoneNumber(getResources(),
                    conversationName);
            conversationNameView.setContentDescription(vocalizedConversationName);
            getActivity().setTitle(conversationName);
        } else {
            final String appName = getString(R.string.app_name);
            conversationNameView.setText(appName);
            getActivity().setTitle(appName);
        }

        // When conversation is showing and media picker is not showing, then hide the action
        // bar only when we are in landscape mode, with IME open.
        if (mHost.isImeOpen() && UiUtils.isLandscapeMode()) {
            actionBar.hide();
        } else {
            actionBar.show();
        }
    }
}

From source file:com.samknows.measurement.activity.SamKnowsAggregateStatViewerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    /*//from  w  ww  . jav a  2  s  .  co  m
     * device = (DeviceDescription) getIntent().getSerializableExtra(
     * Constants.INTENT_EXTRA_DEVICE); isCurrentDevice =
     * getIntent().getBooleanExtra(
     * Constants.INTENT_EXTRA_IS_CURRENT_DEVICE, false);
     * 
     * List<DeviceDescription> devices = AppSettings.getInstance()
     * .getDevices(); String imei =
     * PhoneIdentityDataCollector.getImei(this); currentDevice = new
     * CurrentDeviceDescription(imei); OtherUtils.removeDeviceForImei(imei,
     * devices);
     */

    this.setTitle(getString(R.string.average_results_title));

    setContentView(R.layout.page_views);

    dbHelper = new DBHelper(SamKnowsAggregateStatViewerActivity.this);
    dbHelperAsync = new DBHelper(SamKnowsAggregateStatViewerActivity.this);
    adapter = new MyPagerAdapter(this);

    viewPager = (ViewPager) findViewById(R.id.viewPager);

    viewPager.setAdapter(adapter);
    // viewPager.setOffscreenPageLimit(3);

    final TextView tvHeader = (TextView) findViewById(R.id.textViewHeader);

    viewPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int page) {
            tvHeader.setText(getString(R.string.page) + " " + (page + 1));
            if (page == 0) {
                on_aggregate_page = true;
                boolean db_refresh = false;

                SamKnowsAggregateStatViewerActivity.this.setTitle(getString(R.string.average_results));

                TextView timestamp;
                View v;
                v = viewPager.findViewWithTag(page);

                timestamp = (TextView) v.findViewById(R.id.average_results_title);

                timestamp.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);

                if (setTotalArchiveRecords()) {
                    adapter = new MyPagerAdapter(SamKnowsAggregateStatViewerActivity.this);
                    viewPager = (ViewPager) findViewById(R.id.viewPager);
                    viewPager.setAdapter(adapter);
                }

            } else {
                TextView timestamp;
                View v;
                v = viewPager.findViewWithTag(page);

                timestamp = (TextView) v.findViewById(R.id.timestamp);
                timestamp.setContentDescription(getString(R.string.archive_result) + " " + timestamp.getText());
                timestamp.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
                on_aggregate_page = false;
                SamKnowsAggregateStatViewerActivity.this.setTitle(getString(R.string.archive_result));
            }
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

        }

        @Override
        public void onPageScrollStateChanged(int state) {
            if (state == ViewPager.SCROLL_STATE_SETTLING) {

            }

        }
    });

    Util.initializeFonts(this);
    Util.overrideFonts(this, findViewById(android.R.id.content));

}

From source file:com.android.leanlauncher.Workspace.java

private void addAllAppsIcon() {
    // Add the Apps button
    LayoutInflater inflater = LayoutInflater.from(getContext());
    TextView allAppsButton = (TextView) inflater.inflate(R.layout.all_apps_button, mWorkspace, false);
    Drawable d = getResources().getDrawable(R.drawable.all_apps_button_icon);
    Utilities.resizeIconDrawable(d);
    allAppsButton.setCompoundDrawables(null, d, null, null);
    allAppsButton.setContentDescription(getResources().getString(R.string.all_apps_button_label));

    mLauncher.setAllAppsButton(allAppsButton);

    allAppsButton.setOnTouchListener(mLauncher.getHapticFeedbackTouchListener());
    allAppsButton.setOnClickListener(mLauncher);
    CellLayout.LayoutParams lp = new CellLayout.LayoutParams((mWorkspace.getCountX() - 1) / 2,
            mWorkspace.getCountY() - 1, 1, 1);
    lp.canReorder = false;/*from ww  w .  ja  va2s.c  o  m*/
    mWorkspace.addViewToCellLayout(allAppsButton, -1, allAppsButton.getId(), lp, true);
}

From source file:com.samknows.measurement.activity.SamKnowsTestViewerActivity.java

/** Called when the activity is first created. */
@Override//from w  w  w. j  a  v  a 2  s .  c  o  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    cxt = this;

    Bundle b = getIntent().getExtras();
    int testID = -1;

    if (b != null) {
        testID = b.getInt("testID");
    }

    storage = CachingStorage.getInstance();
    config = storage.loadScheduleConfig();
    if (config == null) {
        config = new ScheduleConfig();
    }
    testList = config.manual_tests;
    array_spinner = new String[testList.size() + 1];
    array_spinner_int = new int[testList.size() + 1];

    this.setTitle(R.string.running_test);

    // choose which test to run
    setContentView(R.layout.individual_stat_test);

    Util.initializeFonts(this);
    Util.overrideFonts(this, findViewById(android.R.id.content));
    try {

        handler = new Handler() {

            @Override
            public void handleMessage(Message msg) {
                TextView tv = null;

                JSONObject message_json;
                message_json = (JSONObject) msg.obj;
                String value;
                int success;
                int testname;
                int status_complete;
                int metric;

                try {

                    String type = message_json.getString(TestResult.JSON_TYPE_ID);

                    if (type == "completed") {

                        result = 1;
                        SamKnowsTestViewerActivity.this.finish();
                        overridePendingTransition(0, 0);
                    }

                    if (type == "test") {
                        testname = message_json.getInt(TestResult.JSON_TESTNUMBER);
                        status_complete = message_json.getInt(TestResult.JSON_STATUS_COMPLETE);
                        value = message_json.getString(TestResult.JSON_HRRESULT);
                        if (status_complete == 100 && message_json.has(TestResult.JSON_SUCCESS)) {

                            success = message_json.getInt(TestResult.JSON_SUCCESS);
                            if (success == 0) {
                                value = getString(R.string.failed);
                            }
                        }

                        switch (testname) {
                        // active metrics
                        case TestResult.DOWNLOAD_TEST_ID:
                            pw = (ProgressWheel) findViewById(R.id.ProgressWheel1);
                            tv = (TextView) findViewById(R.id.download_result);
                            pw.setProgress((int) (status_complete * 3.6));
                            pw.setContentDescription("Status " + status_complete + "%");
                            if (status_complete == 100) {
                                pw.setVisibility(View.GONE);
                                tv.setText(value);
                                tv.setContentDescription(getString(R.string.download) + " " + value);
                                tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
                            } else {
                                pw.setVisibility(View.VISIBLE);
                                tv.setText("");
                            }
                            break;
                        case TestResult.UPLOAD_TEST_ID:
                            pw = (ProgressWheel) findViewById(R.id.ProgressWheel2);
                            tv = (TextView) findViewById(R.id.upload_result);
                            pw.setProgress((int) (status_complete * 3.6));
                            pw.setContentDescription("Status " + status_complete + "%");
                            if (status_complete == 100) {
                                pw.setVisibility(View.GONE);

                                tv.setText(value);
                                tv.setContentDescription(getString(R.string.upload) + " " + value);
                                tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
                            } else {
                                pw.setVisibility(View.VISIBLE);
                                tv.setText("");
                            }
                            break;
                        case TestResult.PACKETLOSS_TEST_ID:
                            pw = (ProgressWheel) findViewById(R.id.ProgressWheel3);
                            tv = (TextView) findViewById(R.id.packetloss_result);
                            pw.setProgress((int) (status_complete * 3.6));
                            pw.setContentDescription("Status " + status_complete + "%");
                            if (status_complete == 100) {
                                pw.setVisibility(View.GONE);
                                tv.setText(value);
                                tv.setContentDescription(getString(R.string.packet_loss) + " " + value);
                                tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
                            } else {
                                pw.setVisibility(View.VISIBLE);
                                tv.setText("");
                            }
                            break;
                        case TestResult.LATENCY_TEST_ID:
                            pw = (ProgressWheel) findViewById(R.id.ProgressWheel4);
                            tv = (TextView) findViewById(R.id.latency_result);
                            pw.setProgress((int) (status_complete * 3.6));
                            pw.setContentDescription("Status " + status_complete + "%");
                            if (status_complete == 100) {
                                pw.setVisibility(View.GONE);
                                tv.setText(value);
                                tv.setContentDescription(getString(R.string.latency) + " " + value);
                                tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
                            } else {
                                pw.setVisibility(View.VISIBLE);
                                tv.setText("");
                            }
                            break;
                        case TestResult.JITTER_TEST_ID:
                            pw = (ProgressWheel) findViewById(R.id.ProgressWheel5);
                            tv = (TextView) findViewById(R.id.jitter_result);
                            pw.setProgress((int) (status_complete * 3.6));
                            pw.setContentDescription("Status " + status_complete + "%");
                            if (status_complete == 100) {
                                pw.setVisibility(View.GONE);
                                tv.setText(value);
                                tv.setContentDescription(getString(R.string.jitter) + " " + value);
                                tv.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED);
                            } else {
                                pw.setVisibility(View.VISIBLE);
                                tv.setText("");
                            }
                            break;

                        }
                    }

                    if (type == "passivemetric") {
                        metric = message_json.getInt("metric");
                        value = message_json.getString("value");

                        switch (metric) {

                        // passive metrics
                        case 1:
                            tv = (TextView) findViewById(R.id.passivemetric1);
                            tv.setText(value);
                            break;

                        case 2:
                            tv = (TextView) findViewById(R.id.passivemetric2);
                            tv.setText(value);
                            break;

                        case 3:
                            tv = (TextView) findViewById(R.id.passivemetric3);
                            tv.setText(value);
                            break;

                        case 4:
                            tv = (TextView) findViewById(R.id.passivemetric4);
                            tv.setText(value);
                            break;

                        case 5:
                            tv = (TextView) findViewById(R.id.passivemetric5);
                            tv.setText(value);
                            break;

                        case 6:
                            tv = (TextView) findViewById(R.id.passivemetric6);
                            tv.setText(value);
                            break;

                        case 7:
                            tv = (TextView) findViewById(R.id.passivemetric7);
                            tv.setText(value);
                            break;

                        case 8:
                            tv = (TextView) findViewById(R.id.passivemetric8);
                            tv.setText(value);
                            break;

                        case 9:
                            tv = (TextView) findViewById(R.id.passivemetric9);
                            tv.setText(value);
                            break;

                        case 10:
                            tv = (TextView) findViewById(R.id.passivemetric10);
                            tv.setText(value);
                            break;

                        case 11:
                            tv = (TextView) findViewById(R.id.passivemetric11);
                            tv.setText(value);
                            break;
                        case 12:
                            tv = (TextView) findViewById(R.id.passivemetric12);
                            tv.setText(value);
                            break;
                        case 13:
                            tv = (TextView) findViewById(R.id.passivemetric13);
                            tv.setText(value);
                            break;
                        case 14:
                            tv = (TextView) findViewById(R.id.passivemetric14);
                            tv.setText(value);
                            break;
                        case 15:
                            tv = (TextView) findViewById(R.id.passivemetric15);
                            tv.setText(value);
                            break;
                        case 16:
                            tv = (TextView) findViewById(R.id.passivemetric16);
                            tv.setText(value);
                            break;
                        case 17:
                            tv = (TextView) findViewById(R.id.passivemetric17);
                            tv.setText(value);
                            break;
                        case 18:
                            tv = (TextView) findViewById(R.id.passivemetric18);
                            tv.setText(value);
                            break;
                        case 19:
                            tv = (TextView) findViewById(R.id.passivemetric19);
                            tv.setText(value);
                            break;
                        case 20:
                            tv = (TextView) findViewById(R.id.passivemetric20);
                            tv.setText(value);
                            break;
                        case 21:
                            tv = (TextView) findViewById(R.id.passivemetric21);
                            tv.setText(value);
                            break;
                        case 22:
                            tv = (TextView) findViewById(R.id.passivemetric22);
                            tv.setText(value);
                            break;
                        case 23:
                            tv = (TextView) findViewById(R.id.passivemetric23);
                            tv.setText(value);
                            break;
                        case 24:
                            tv = (TextView) findViewById(R.id.passivemetric24);
                            tv.setText(value);
                            break;
                        case 25:
                            tv = (TextView) findViewById(R.id.passivemetric25);
                            tv.setText(value);
                            break;
                        case 26:
                            tv = (TextView) findViewById(R.id.passivemetric26);
                            tv.setText(value);
                            break;
                        case 27:
                            tv = (TextView) findViewById(R.id.passivemetric27);
                            tv.setText(value);
                            break;
                        case 28:
                            tv = (TextView) findViewById(R.id.passivemetric28);
                            tv.setText(value);
                            break;
                        case 29:
                            tv = (TextView) findViewById(R.id.passivemetric29);
                            tv.setText(value);
                            break;
                        case 30:
                            tv = (TextView) findViewById(R.id.passivemetric30);
                            tv.setText(value);
                            break;
                        case 31:
                            tv = (TextView) findViewById(R.id.passivemetric31);
                            tv.setText(value);
                            break;
                        case 32:
                            tv = (TextView) findViewById(R.id.passivemetric32);
                            tv.setText(value);
                            break;
                        default:
                            //

                        }
                        if (!value.equals("") && tv != null) {

                            TableLayout tl1 = (TableLayout) findViewById(R.id.passive_metrics_status);
                            tl1.setVisibility(View.GONE);
                            TableLayout tl = (TableLayout) tv.getParent().getParent();
                            tl.setVisibility(View.VISIBLE);
                        }

                        if (value.equals("") && tv != null) {
                            TableLayout tl = (TableLayout) tv.getParent().getParent();
                            tl.setVisibility(View.GONE);
                        }

                    }

                } catch (JSONException e) {
                    Logger.e(this, e.getMessage());
                }
            }
        };

        launchTest(testID);
    } catch (Throwable t) {
        Logger.e(this, "handler or test failure", t);
    }
}

From source file:dk.bearware.gui.MainActivity.java

private void setupButtons() {

    final Button tx_btn = (Button) findViewById(R.id.transmit_voice);
    tx_btn.setOnTouchListener(new OnTouchListener() {

        boolean tx_state = false;
        long tx_down_start = 0;

        @Override//from w w  w  . j  ava2s.  c o  m
        public boolean onTouch(View v, MotionEvent event) {
            boolean tx = event.getAction() != MotionEvent.ACTION_UP;

            if (tx != tx_state) {

                if (!tx) {
                    if (System.currentTimeMillis() - tx_down_start < 800) {
                        tx = true;
                        tx_down_start = 0;
                    } else {
                        tx_down_start = System.currentTimeMillis();
                    }

                    //Log.i(TAG, "TX is now: " + tx + " diff " + (System.currentTimeMillis() - tx_down_start));
                }

                if (ttservice.isVoiceActivationEnabled())
                    ttservice.enableVoiceActivation(false);
                ttservice.enableVoiceTransmission(tx);
            }
            tx_state = tx;
            return true;
        }
    });

    final ImageButton decVol = (ImageButton) findViewById(R.id.volDec);
    final ImageButton incVol = (ImageButton) findViewById(R.id.volInc);
    final ImageButton decMike = (ImageButton) findViewById(R.id.mikeDec);
    final ImageButton incMike = (ImageButton) findViewById(R.id.mikeInc);
    final TextView mikeLevel = (TextView) findViewById(R.id.mikelevel_text);
    final TextView volLevel = (TextView) findViewById(R.id.vollevel_text);

    OnTouchListener listener = new OnTouchListener() {
        Handler handler = new Handler();
        Runnable runnable;

        @Override
        public boolean onTouch(final View v, MotionEvent event) {
            if (ttclient == null)
                return false;

            if (event.getAction() == MotionEvent.ACTION_DOWN) {
                adjustLevel(v);

                runnable = new Runnable() {

                    @Override
                    public void run() {
                        boolean done = adjustLevel(v);
                        if (!done)
                            handler.postDelayed(this, 100);
                    }
                };
                handler.postDelayed(runnable, 100);
            } else if (event.getAction() == MotionEvent.ACTION_UP) {
                if (runnable != null)
                    handler.removeCallbacks(runnable);
            }
            return false;
        }

        boolean adjustLevel(View view) {
            if (view == decVol) {

                // pressing +/- aborts mute state
                if (ttservice.isMute()) {
                    ttservice.setMute(false);
                    ImageButton speakerBtn = (ImageButton) findViewById(R.id.speakerBtn);
                    adjustMuteButton(speakerBtn);
                }

                int v = ttclient.getSoundOutputVolume();
                v = Utils.refVolumeToPercent(v);
                v = Utils.refVolume(v - 1);
                if (v >= SoundLevel.SOUND_VOLUME_MIN) {
                    ttclient.setSoundOutputVolume(v);
                    volLevel.setText(Utils.refVolumeToPercent(v) + "%");
                    volLevel.setContentDescription(
                            getString(R.string.speaker_volume_description, volLevel.getText()));
                    if (v == SoundLevel.SOUND_VOLUME_DEFAULT)
                        return true;
                } else
                    return true;
            } else if (view == incVol) {

                // pressing +/- aborts mute state
                if (ttservice.isMute()) {
                    ttservice.setMute(false);
                    ImageButton speakerBtn = (ImageButton) findViewById(R.id.speakerBtn);
                    adjustMuteButton(speakerBtn);
                }

                int v = ttclient.getSoundOutputVolume();
                v = Utils.refVolumeToPercent(v);
                v = Utils.refVolume(v + 1);
                if (v <= SoundLevel.SOUND_VOLUME_MAX) {
                    ttclient.setSoundOutputVolume(v);
                    volLevel.setText(Utils.refVolumeToPercent(v) + "%");
                    volLevel.setContentDescription(
                            getString(R.string.speaker_volume_description, volLevel.getText()));
                    if (v == SoundLevel.SOUND_VOLUME_DEFAULT)
                        return true;
                } else
                    return true;
            } else if (view == decMike) {
                if (ttservice.isVoiceActivationEnabled()) {
                    int x = ttclient.getVoiceActivationLevel() - 1;
                    if (x >= SoundLevel.SOUND_VU_MIN) {
                        ttclient.setVoiceActivationLevel(x);
                        mikeLevel.setText(x + "%");
                        mikeLevel.setContentDescription(
                                getString(R.string.vox_level_description, mikeLevel.getText()));
                    } else
                        return true;
                } else {
                    int g = ttclient.getSoundInputGainLevel();
                    g = Utils.refGainToPercent(g);
                    g = Utils.refGain(g - 1);
                    if (g >= SoundLevel.SOUND_GAIN_MIN) {
                        ttclient.setSoundInputGainLevel(g);
                        mikeLevel.setText(Utils.refVolumeToPercent(g) + "%");
                        mikeLevel.setContentDescription(
                                getString(R.string.mic_gain_description, mikeLevel.getText()));
                        if (g == SoundLevel.SOUND_GAIN_DEFAULT)
                            return true;
                    } else
                        return true;
                }
            } else if (view == incMike) {
                if (ttservice.isVoiceActivationEnabled()) {
                    int x = ttclient.getVoiceActivationLevel() + 1;
                    if (x <= SoundLevel.SOUND_VU_MAX) {
                        ttclient.setVoiceActivationLevel(x);
                        mikeLevel.setText(x + "%");
                        mikeLevel.setContentDescription(
                                getString(R.string.vox_level_description, mikeLevel.getText()));
                    } else
                        return true;
                } else {
                    int g = ttclient.getSoundInputGainLevel();
                    g = Utils.refGainToPercent(g);
                    g = Utils.refGain(g + 1);
                    if (g <= SoundLevel.SOUND_GAIN_MAX) {
                        ttclient.setSoundInputGainLevel(g);
                        mikeLevel.setText(Utils.refVolumeToPercent(g) + "%");
                        mikeLevel.setContentDescription(
                                getString(R.string.mic_gain_description, mikeLevel.getText()));
                        if (g == SoundLevel.SOUND_VOLUME_DEFAULT)
                            return true;
                    } else
                        return true;
                }
            }
            return false;
        }
    };
    decVol.setOnTouchListener(listener);
    incVol.setOnTouchListener(listener);
    decMike.setOnTouchListener(listener);
    incMike.setOnTouchListener(listener);

    ImageButton speakerBtn = (ImageButton) findViewById(R.id.speakerBtn);
    speakerBtn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if ((mConnection != null) && mConnection.isBound()) {
                ttservice.setMute(!ttservice.isMute());
                adjustMuteButton((ImageButton) v);

                int level = ttservice.isMute() ? 0 : Utils.refVolumeToPercent(ttclient.getSoundOutputVolume());
                volLevel.setText(level + "%");
                volLevel.setContentDescription(
                        getString(R.string.speaker_volume_description, volLevel.getText()));
            }
        }
    });

    ImageButton voxSwitch = (ImageButton) findViewById(R.id.voxSwitch);
    voxSwitch.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if ((mConnection != null) && mConnection.isBound()) {
                if (ttservice.isVoiceTransmissionEnabled())
                    ttservice.enableVoiceTransmission(false);
                ttservice.enableVoiceActivation(!ttservice.isVoiceActivationEnabled());
            }
        }
    });
}

From source file:org.nypl.simplified.app.MainSettingsAccountActivity.java

@Override
protected void onResume() {
    super.onResume();

    final Resources rr = NullCheck.notNull(this.getResources());
    final TableLayout in_table_with_code = NullCheck.notNull(this.table_with_code);
    final TableLayout in_table_signup = NullCheck.notNull(this.table_signup);
    final TextView in_account_name_text = NullCheck.notNull(this.account_name_text);
    final TextView in_account_subtitle_text = NullCheck.notNull(this.account_subtitle_text);
    final ImageView in_account_icon = NullCheck.notNull(this.account_icon);
    final TextView in_barcode_text = NullCheck.notNull(this.barcode_text);
    final TextView in_pin_text = NullCheck.notNull(this.pin_text);
    final ImageView in_barcode_image = NullCheck.notNull(this.barcode_image);
    final TextView in_barcode_image_toggle = NullCheck.notNull(this.barcode_image_toggle);
    final Button in_login = NullCheck.notNull(this.login);
    final CheckBox in_eula_checkbox = NullCheck.notNull(this.findViewById(R.id.eula_checkbox));

    in_account_name_text.setText(this.account.getName());
    in_account_subtitle_text.setText(this.account.getSubtitle());

    try {//from  w  w  w. j ava 2 s .c o  m
        in_account_icon.setImageBitmap(this.account.getLogoBitmap());
    } catch (IllegalArgumentException e) {
        in_account_icon.setImageResource(R.drawable.librarylogomagic);
    }

    final BooksType userAccount;
    if (this.account == null) {
        userAccount = Simplified.getCatalogAppServices().getBooks();
    } else {
        userAccount = Simplified.getBooks(this.account, this,
                Simplified.getCatalogAppServices().getAdobeDRMExecutor());
    }

    final AccountsDatabaseType accounts_database = Simplified.getAccountsDatabase(this.account, this);
    if (!accounts_database.accountGetCredentials().isSome()) {
        this.sync_table_row.setVisibility(View.GONE);
        LOG.debug("No user currently signed in, bypassing UI update and Sync Status Initiation.");
        return;
    }

    final AccountCredentials creds = ((Some<AccountCredentials>) accounts_database.accountGetCredentials())
            .get();

    if (syncButtonShouldBeVisible()) {
        if (this.annotationsManager == null) {
            this.annotationsManager = new AnnotationsManager(this.account, creds, this);
            checkServerSyncPermission(userAccount);
        }
        this.sync_table_row.setVisibility(View.VISIBLE);
        this.advanced_table_row.setVisibility(View.VISIBLE);
    } else {
        this.sync_table_row.setVisibility(View.GONE);
        this.advanced_table_row.setVisibility(View.GONE);
    }

    if (account.supportsBarcodeDisplay()) {
        Bitmap barcodeBitmap = generateBarcodeImage(creds.getBarcode().toString());
        if (barcodeBitmap != null) {
            in_barcode_image.setImageBitmap(barcodeBitmap);

            in_barcode_image_toggle.setVisibility(View.VISIBLE);
            in_barcode_image_toggle.setOnClickListener(view -> {
                if (in_barcode_image_toggle.getText() == getText(R.string.settings_toggle_barcode_show)) {
                    in_barcode_image.setVisibility(View.VISIBLE);
                    in_barcode_image_toggle.setText(R.string.settings_toggle_barcode_hide);
                } else {
                    in_barcode_image.setVisibility(View.GONE);
                    in_barcode_image_toggle.setText(R.string.settings_toggle_barcode_show);
                }
            });
        }
    }

    in_table_with_code.setVisibility(View.VISIBLE);
    in_table_signup.setVisibility(View.GONE);

    in_barcode_text.setText(creds.getBarcode().toString());
    in_barcode_text.setContentDescription(creds.getBarcode().toString().replaceAll(".(?=.)", "$0,"));
    in_pin_text.setText(creds.getPin().toString());
    in_pin_text.setContentDescription(creds.getPin().toString().replaceAll(".(?=.)", "$0,"));

    in_eula_checkbox.setEnabled(false);

    in_login.setText(rr.getString(R.string.settings_log_out));
    in_login.setOnClickListener(view -> {
        final LogoutDialog dialog = LogoutDialog.newDialog();
        dialog.setOnConfirmListener(() -> {
            //Delete cache if logging out of current active library account
            userAccount.accountLogout(creds, this, this, this);
            if (this.account == Simplified.getCurrentAccount()) {
                userAccount.destroyBookStatusCache();
            }
        });
        final FragmentManager fm = this.getFragmentManager();
        dialog.show(fm, "logout-confirm");
    });
}