Search in sources :

Example 46 with OnClickListener

use of android.view.View.OnClickListener in project platform_frameworks_base by android.

the class PrintErrorFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    CharSequence message = getArguments().getCharSequence(EXTRA_MESSAGE);
    if (!TextUtils.isEmpty(message)) {
        TextView messageView = (TextView) view.findViewById(R.id.message);
        messageView.setText(message);
    }
    Button actionButton = (Button) view.findViewById(R.id.action_button);
    final int action = getArguments().getInt(EXTRA_ACTION);
    switch(action) {
        case ACTION_RETRY:
            {
                actionButton.setVisibility(View.VISIBLE);
                actionButton.setText(R.string.print_error_retry);
            }
            break;
        case ACTION_NONE:
            {
                actionButton.setVisibility(View.GONE);
            }
            break;
    }
    actionButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View view) {
            Activity activity = getActivity();
            if (activity instanceof OnActionListener) {
                ((OnActionListener) getActivity()).onActionPerformed();
            }
        }
    });
}
Also used : Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) Activity(android.app.Activity) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Example 47 with OnClickListener

use of android.view.View.OnClickListener in project platform_frameworks_base by android.

the class SelectPrinterActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getActionBar().setIcon(R.drawable.ic_print);
    setContentView(R.layout.select_printer_activity);
    mEnabledPrintServices = new ArrayMap<>();
    mPrinterRegistry = new PrinterRegistry(this, null, LOADER_ID_PRINT_REGISTRY, LOADER_ID_PRINT_REGISTRY_INT);
    // Hook up the list view.
    mListView = (ListView) findViewById(android.R.id.list);
    final DestinationAdapter adapter = new DestinationAdapter();
    adapter.registerDataSetObserver(new DataSetObserver() {

        @Override
        public void onChanged() {
            if (!isFinishing() && adapter.getCount() <= 0) {
                updateEmptyView(adapter);
            }
        }

        @Override
        public void onInvalidated() {
            if (!isFinishing()) {
                updateEmptyView(adapter);
            }
        }
    });
    mListView.setAdapter(adapter);
    mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (!((DestinationAdapter) mListView.getAdapter()).isActionable(position)) {
                return;
            }
            PrinterInfo printer = (PrinterInfo) mListView.getAdapter().getItem(position);
            if (printer == null) {
                startAddPrinterActivity();
            } else {
                onPrinterSelected(printer);
            }
        }
    });
    findViewById(R.id.button).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            startAddPrinterActivity();
        }
    });
    registerForContextMenu(mListView);
    getLoaderManager().initLoader(LOADER_ID_ENABLED_PRINT_SERVICES, null, this);
    // If some are disabled and some are enabled show a toast to notify the user
    if (savedInstanceState == null || !savedInstanceState.getBoolean(KEY_NOT_FIRST_CREATE)) {
        List<PrintServiceInfo> allServices = ((PrintManager) getSystemService(Context.PRINT_SERVICE)).getPrintServices(PrintManager.ALL_SERVICES);
        boolean hasEnabledServices = false;
        boolean hasDisabledServices = false;
        if (allServices != null) {
            final int numServices = allServices.size();
            for (int i = 0; i < numServices; i++) {
                if (allServices.get(i).isEnabled()) {
                    hasEnabledServices = true;
                } else {
                    hasDisabledServices = true;
                }
            }
        }
        if (!hasEnabledServices) {
            startAddPrinterActivity();
        } else if (hasDisabledServices) {
            String disabledServicesSetting = Settings.Secure.getString(getContentResolver(), Settings.Secure.DISABLED_PRINT_SERVICES);
            if (!TextUtils.isEmpty(disabledServicesSetting)) {
                Toast.makeText(this, getString(R.string.print_services_disabled_toast), Toast.LENGTH_LONG).show();
            }
        }
    }
}
Also used : PrintManager(android.print.PrintManager) DataSetObserver(android.database.DataSetObserver) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) SearchView(android.widget.SearchView) TextView(android.widget.TextView) ListView(android.widget.ListView) PrintServiceInfo(android.printservice.PrintServiceInfo) OnClickListener(android.view.View.OnClickListener) AdapterView(android.widget.AdapterView) PrinterInfo(android.print.PrinterInfo)

Example 48 with OnClickListener

use of android.view.View.OnClickListener in project platform_frameworks_base by android.

the class PrintActivity method bindUi.

private void bindUi() {
    // Summary
    mSummaryContainer = findViewById(R.id.summary_content);
    mSummaryCopies = (TextView) findViewById(R.id.copies_count_summary);
    mSummaryPaperSize = (TextView) findViewById(R.id.paper_size_summary);
    // Options container
    mOptionsContent = (PrintContentView) findViewById(R.id.options_content);
    mOptionsContent.setOptionsStateChangeListener(this);
    mOptionsContent.setOpenOptionsController(this);
    OnItemSelectedListener itemSelectedListener = new MyOnItemSelectedListener();
    OnClickListener clickListener = new MyClickListener();
    // Copies
    mCopiesEditText = (EditText) findViewById(R.id.copies_edittext);
    mCopiesEditText.setOnFocusChangeListener(mSelectAllOnFocusListener);
    mCopiesEditText.setText(MIN_COPIES_STRING);
    mCopiesEditText.setSelection(mCopiesEditText.getText().length());
    mCopiesEditText.addTextChangedListener(new EditTextWatcher());
    // Destination.
    mPrintersObserver = new PrintersObserver();
    mDestinationSpinnerAdapter.registerDataSetObserver(mPrintersObserver);
    mDestinationSpinner = (Spinner) findViewById(R.id.destination_spinner);
    mDestinationSpinner.setAdapter(mDestinationSpinnerAdapter);
    mDestinationSpinner.setOnItemSelectedListener(itemSelectedListener);
    // Media size.
    mMediaSizeSpinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, android.R.id.text1);
    mMediaSizeSpinner = (Spinner) findViewById(R.id.paper_size_spinner);
    mMediaSizeSpinner.setAdapter(mMediaSizeSpinnerAdapter);
    mMediaSizeSpinner.setOnItemSelectedListener(itemSelectedListener);
    // Color mode.
    mColorModeSpinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, android.R.id.text1);
    mColorModeSpinner = (Spinner) findViewById(R.id.color_spinner);
    mColorModeSpinner.setAdapter(mColorModeSpinnerAdapter);
    mColorModeSpinner.setOnItemSelectedListener(itemSelectedListener);
    // Duplex mode.
    mDuplexModeSpinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, android.R.id.text1);
    mDuplexModeSpinner = (Spinner) findViewById(R.id.duplex_spinner);
    mDuplexModeSpinner.setAdapter(mDuplexModeSpinnerAdapter);
    mDuplexModeSpinner.setOnItemSelectedListener(itemSelectedListener);
    // Orientation
    mOrientationSpinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, android.R.id.text1);
    String[] orientationLabels = getResources().getStringArray(R.array.orientation_labels);
    mOrientationSpinnerAdapter.add(new SpinnerItem<>(ORIENTATION_PORTRAIT, orientationLabels[0]));
    mOrientationSpinnerAdapter.add(new SpinnerItem<>(ORIENTATION_LANDSCAPE, orientationLabels[1]));
    mOrientationSpinner = (Spinner) findViewById(R.id.orientation_spinner);
    mOrientationSpinner.setAdapter(mOrientationSpinnerAdapter);
    mOrientationSpinner.setOnItemSelectedListener(itemSelectedListener);
    // Range options
    ArrayAdapter<SpinnerItem<Integer>> rangeOptionsSpinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_dropdown_item, android.R.id.text1);
    mRangeOptionsSpinner = (Spinner) findViewById(R.id.range_options_spinner);
    mRangeOptionsSpinner.setAdapter(rangeOptionsSpinnerAdapter);
    mRangeOptionsSpinner.setOnItemSelectedListener(itemSelectedListener);
    updatePageRangeOptions(PrintDocumentInfo.PAGE_COUNT_UNKNOWN);
    // Page range
    mPageRangeTitle = (TextView) findViewById(R.id.page_range_title);
    mPageRangeEditText = (EditText) findViewById(R.id.page_range_edittext);
    mPageRangeEditText.setVisibility(View.INVISIBLE);
    mPageRangeTitle.setVisibility(View.INVISIBLE);
    mPageRangeEditText.setOnFocusChangeListener(mSelectAllOnFocusListener);
    mPageRangeEditText.addTextChangedListener(new RangeTextWatcher());
    // Advanced options button.
    mMoreOptionsButton = (Button) findViewById(R.id.more_options_button);
    mMoreOptionsButton.setOnClickListener(clickListener);
    // Print button
    mPrintButton = (ImageView) findViewById(R.id.print_button);
    mPrintButton.setOnClickListener(clickListener);
    // The UI is now initialized
    mIsOptionsUiBound = true;
    // Special prompt instead of destination spinner for the first time the user printed
    if (!hasUserEverPrinted()) {
        mShowDestinationPrompt = true;
        mSummaryCopies.setEnabled(false);
        mSummaryPaperSize.setEnabled(false);
        mDestinationSpinner.setOnTouchListener(new View.OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                mShowDestinationPrompt = false;
                mSummaryCopies.setEnabled(true);
                mSummaryPaperSize.setEnabled(true);
                updateOptionsUi();
                mDestinationSpinner.setOnTouchListener(null);
                mDestinationSpinnerAdapter.notifyDataSetChanged();
                return false;
            }
        });
    }
}
Also used : ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) PrintContentView(com.android.printspooler.widget.PrintContentView) MotionEvent(android.view.MotionEvent) OnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener) OnClickListener(android.view.View.OnClickListener) ArrayAdapter(android.widget.ArrayAdapter)

Example 49 with OnClickListener

use of android.view.View.OnClickListener in project Conversations by siacs.

the class MessageAdapter method displayOpenableMessage.

private void displayOpenableMessage(ViewHolder viewHolder, final Message message) {
    viewHolder.image.setVisibility(View.GONE);
    viewHolder.messageBody.setVisibility(View.GONE);
    viewHolder.download_button.setVisibility(View.VISIBLE);
    viewHolder.download_button.setText(activity.getString(R.string.open_x_file, UIHelper.getFileDescriptionString(activity, message)));
    viewHolder.download_button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            openDownloadable(message);
        }
    });
}
Also used : OnClickListener(android.view.View.OnClickListener) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) CopyTextView(eu.siacs.conversations.ui.widget.CopyTextView)

Example 50 with OnClickListener

use of android.view.View.OnClickListener in project Conversations by siacs.

the class MessageAdapter method displayLocationMessage.

private void displayLocationMessage(ViewHolder viewHolder, final Message message) {
    viewHolder.image.setVisibility(View.GONE);
    viewHolder.messageBody.setVisibility(View.GONE);
    viewHolder.download_button.setVisibility(View.VISIBLE);
    viewHolder.download_button.setText(R.string.show_location);
    viewHolder.download_button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            showLocation(message);
        }
    });
}
Also used : OnClickListener(android.view.View.OnClickListener) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) CopyTextView(eu.siacs.conversations.ui.widget.CopyTextView)

Aggregations

OnClickListener (android.view.View.OnClickListener)794 View (android.view.View)792 TextView (android.widget.TextView)492 Button (android.widget.Button)265 ImageView (android.widget.ImageView)256 Intent (android.content.Intent)183 ListView (android.widget.ListView)112 AdapterView (android.widget.AdapterView)91 ScrollView (android.widget.ScrollView)52 LinearLayout (android.widget.LinearLayout)49 Bundle (android.os.Bundle)43 LayoutInflater (android.view.LayoutInflater)35 ViewGroup (android.view.ViewGroup)30 ArrayList (java.util.ArrayList)30 BindView (butterknife.BindView)29 KeyEvent (android.view.KeyEvent)28 EditText (android.widget.EditText)28 DialogInterface (android.content.DialogInterface)27 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)25 FragmentManager (android.support.v4.app.FragmentManager)23