Search in sources :

Example 1 with PrintContentView

use of com.android.printspooler.widget.PrintContentView 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 2 with PrintContentView

use of com.android.printspooler.widget.PrintContentView in project android_frameworks_base by ResurrectionRemix.

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 3 with PrintContentView

use of com.android.printspooler.widget.PrintContentView in project android_frameworks_base by crdroidandroid.

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 4 with PrintContentView

use of com.android.printspooler.widget.PrintContentView in project android_frameworks_base by AOSPA.

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 5 with PrintContentView

use of com.android.printspooler.widget.PrintContentView in project android_frameworks_base by DirtyUnicorns.

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)

Aggregations

MotionEvent (android.view.MotionEvent)5 View (android.view.View)5 OnClickListener (android.view.View.OnClickListener)5 AdapterView (android.widget.AdapterView)5 OnItemSelectedListener (android.widget.AdapterView.OnItemSelectedListener)5 ArrayAdapter (android.widget.ArrayAdapter)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 PrintContentView (com.android.printspooler.widget.PrintContentView)5