Java Code Examples for android.view.View#setOnKeyListener()

The following examples show how to use android.view.View#setOnKeyListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextPickerPopup.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);

    closeBtn.setOnClickListener(this);
    if(doneBtn != null) {
        doneBtn.setOnClickListener(this);
    }

    view.setFocusableInTouchMode(true);
    view.requestFocus();
    view.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
                doClose();
                return true;
            } else {
                return false;
            }
        }
    });

    return view;
}
 
Example 2
Source File: RvItemClickSupport.java    From Aria with Apache License 2.0 6 votes vote down vote up
@Override public void onChildViewAttachedToWindow(View view) {
  if (mOnItemClickListener != null) {
    view.setOnClickListener(mOnClickListener);
  }
  if (mOnItemLongClickListener != null) {
    view.setOnLongClickListener(mOnLongClickListener);
  }
  if (mOnItemTouchListener != null) {
    view.setOnTouchListener(mOnTouchListener);
  }
  if (mOnItemFocusChangeListener != null) {
    view.setOnFocusChangeListener(mOnFocusChangeListener);
  }
  if (mOnItemKeyListener != null) {
    view.setOnKeyListener(mOnKeyListener);
  }
}
 
Example 3
Source File: BasePickerView.java    From Android-PickerView with Apache License 2.0 6 votes vote down vote up
public void setKeyBackCancelable(boolean isCancelable) {

        ViewGroup View;
        if (isDialog()) {
            View = dialogView;
        } else {
            View = rootView;
        }

        View.setFocusable(isCancelable);
        View.setFocusableInTouchMode(isCancelable);
        if (isCancelable) {
            View.setOnKeyListener(onKeyBackListener);
        } else {
            View.setOnKeyListener(null);
        }
    }
 
Example 4
Source File: BasePickerView.java    From AndroidFrame with Apache License 2.0 6 votes vote down vote up
public void setKeyBackCancelable(boolean isCancelable) {

        ViewGroup View;
        if (isDialog()) {
            View = dialogView;
        } else {
            View = rootView;
        }

        View.setFocusable(isCancelable);
        View.setFocusableInTouchMode(isCancelable);
        if (isCancelable) {
            View.setOnKeyListener(onKeyBackListener);
        } else {
            View.setOnKeyListener(null);
        }
    }
 
Example 5
Source File: BasePickerView.java    From Android-PickerView with Apache License 2.0 6 votes vote down vote up
public void setKeyBackCancelable(boolean isCancelable) {

        ViewGroup View;
        if (isDialog()) {
            View = dialogView;
        } else {
            View = rootView;
        }

        View.setFocusable(isCancelable);
        View.setFocusableInTouchMode(isCancelable);
        if (isCancelable) {
            View.setOnKeyListener(onKeyBackListener);
        } else {
            View.setOnKeyListener(null);
        }
    }
 
Example 6
Source File: VolumePreference.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
@Override
protected void onBindDialogView(View view) {
    super.onBindDialogView(view);

    final SeekBar seekBar = (SeekBar) view.findViewById(R.id.seekbar);
    mSeekBarVolumizer = new SeekBarVolumizer(getContext(), mStreamType, null, this);
    mSeekBarVolumizer.start();
    mSeekBarVolumizer.setSeekBar(seekBar);

    getPreferenceManager().registerOnActivityStopListener(this);

    // grab focus and key events so that pressing the volume buttons in the
    // dialog doesn't also show the normal volume adjust toast.
    view.setOnKeyListener(this);
    view.setFocusableInTouchMode(true);
    view.requestFocus();
}
 
Example 7
Source File: AlertPopup.java    From arcusandroid with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);

    closeBtn.setOnClickListener(this);

    view.setFocusableInTouchMode(true);
    view.requestFocus();
    view.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
                doClose();
                return true;
            } else {
                return false;
            }
        }
    });

    return view;
}
 
Example 8
Source File: BottomItemDelegate.java    From FastWaiMai with MIT License 5 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    final View rootview = getView();
    if(rootview != null){
        rootview.setFocusableInTouchMode(true);
        rootview.requestFocus();
        //注册Listenner
        rootview.setOnKeyListener(this);
    }
}
 
Example 9
Source File: MapList.java    From Androzic with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
	View view = inflater.inflate(R.layout.list_with_empty_view_and_progressbar, container, false);
	
	progressBar = (ProgressBar) view.findViewById(R.id.progressbar);

	view.setFocusableInTouchMode(true);
	view.requestFocus();
	view.setOnKeyListener(new View.OnKeyListener() {
		@Override
		public boolean onKey(View v, int keyCode, KeyEvent event)
		{
			if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK)
			{
				if (currentTree != mapsTree)
				{
					currentTree = currentTree.parent;
					adapter.notifyDataSetChanged();
					return true;
				}
			}
			return false;
		}
	});

	return view;
}
 
Example 10
Source File: InputImpl.java    From Game with GNU General Public License v3.0 5 votes vote down vote up
public InputImpl(mudclient mudclient, View view) {
    this.mudclient = mudclient;
    this.view = view;
    gestureDetector = new GestureDetector(view.getContext(), this);

    view.setOnTouchListener(this);
    view.setOnKeyListener(this);
}
 
Example 11
Source File: NiboPickerFragment.java    From Nibo with MIT License 5 votes vote down vote up
private void setUpBackPresses(View view) {
    view.setFocusableInTouchMode(true);
    view.requestFocus();
    view.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
                // handle back button's click listener
                presenter.handleBackPress();
                return true;
            }
            return false;
        }
    });
}
 
Example 12
Source File: PaymentTypesAdapter.java    From px-android with MIT License 5 votes vote down vote up
ViewHolder(View itemView) {
    super(itemView);
    mPaymentTypeIdTextView = itemView.findViewById(R.id.mpsdkPaymentTypeTextView);
    itemView.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event != null && event.getAction() == KeyEvent.ACTION_DOWN
                && event.getKeyCode() == KeyEvent.KEYCODE_DPAD_CENTER) {
                mCallback.onSelected(getLayoutPosition());
                return true;
            }
            return false;
        }
    });
}
 
Example 13
Source File: ChatFragment.java    From Game-of-Thrones with Apache License 2.0 5 votes vote down vote up
private void initOnBackPressed(View rootView) {
  rootView.setOnKeyListener((v, keyCode, event) -> {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
      if (emojiPanel.isEmojiAttached()) {
        emojiPanel.dissmissEmojiPopup();
        return true;
      } else {
        return false;
      }
    }
    return false;
  });
}
 
Example 14
Source File: PlayerActivity.java    From Android-Example-HLS-ExoPlayer with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.player_activity);
    View root = findViewById(R.id.root);
    root.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
                toggleControlsVisibility();
            } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
                view.performClick();
            }
            return true;
        }
    });
    root.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE
                    || keyCode == KeyEvent.KEYCODE_MENU) {
                return false;
            }
            return mediaController.dispatchKeyEvent(event);
        }
    });

    shutterView = findViewById(R.id.shutter);
    debugRootView = findViewById(R.id.controls_root);

    videoFrame = (AspectRatioFrameLayout) findViewById(R.id.video_frame);
    surfaceView = (SurfaceView) findViewById(R.id.surface_view);
    surfaceView.getHolder().addCallback(this);
    debugTextView = (TextView) findViewById(R.id.debug_text_view);

    playerStateTextView = (TextView) findViewById(R.id.player_state_view);
    subtitleLayout = (SubtitleLayout) findViewById(R.id.subtitles);

    mediaController = new KeyCompatibleMediaController(this);
    mediaController.setAnchorView(root);
    retryButton = (Button) findViewById(R.id.retry_button);
    retryButton.setOnClickListener(this);
    videoButton = (Button) findViewById(R.id.video_controls);
    audioButton = (Button) findViewById(R.id.audio_controls);
    textButton = (Button) findViewById(R.id.text_controls);

    CookieHandler currentHandler = CookieHandler.getDefault();
    if (currentHandler != defaultCookieManager) {
        CookieHandler.setDefault(defaultCookieManager);
    }

    audioCapabilitiesReceiver = new AudioCapabilitiesReceiver(this, this);
    audioCapabilitiesReceiver.register();
}
 
Example 15
Source File: GridBuilder.java    From GridBuilder with Apache License 2.0 4 votes vote down vote up
/**
 * 向GridLayout容器中添加Grid元素
 *
 * @param gridItem Grid元素
 */
private GridBuilder addItem(GridItem gridItem) {
    View itemLayout = null;
    if (null != mOnViewCreateCallBack) {
        itemLayout = mOnViewCreateCallBack.onViewCreate(mLayoutInflater, null == mGridViewHolder
                ? null : mGridViewHolder.getConvertView(), gridItem);
    }

    if (null == itemLayout) {
        return this;
    }

    GridLayout.LayoutParams layoutParams = new GridLayout.LayoutParams();
    // 优先根据预先取得的width/height设置,但不影响跨列/行数
    layoutParams.width = (gridItem.getWidth() > 0 ? gridItem.getWidth() : gridItem.getColumnSpec() * mBaseWidth)
            + ((gridItem.getColumnSpec() > 1 && gridItem.getWidth() <= 0 ? mHorizontalMargin * (gridItem.getColumnSpec() - 1) : 0));
    layoutParams.height = (gridItem.getHeight() > 0 ? gridItem.getHeight() : gridItem.getRowSpec() * mBaseHeight)
            + ((gridItem.getRowSpec() > 1 && gridItem.getWidth() <= 0 ? mVerticalMargin * (gridItem.getRowSpec() - 1) : 0));

    if (gridItem.getWidth() <= 0) {
        gridItem.setWidth(layoutParams.width);
    }
    if (gridItem.getHeight() <= 0) {
        gridItem.setHeight(layoutParams.height);
    }

    layoutParams.rowSpec = GridLayout.spec(gridItem.getRow(), gridItem.getRowSpec());
    layoutParams.columnSpec = GridLayout.spec(gridItem.getColumn(), gridItem.getColumnSpec());

    // 设置每个item间距,最外层间距也需要设置(因为需要体现边缘item的scale效果)
    if (gridItem.getRow() > 0) {
        layoutParams.topMargin = mVerticalMargin;
    }

    if (gridItem.getColumn() > 0) {
        layoutParams.leftMargin = mHorizontalMargin;
    }

    itemLayout.setLayoutParams(layoutParams);
    itemLayout.setFocusable(true);
    itemLayout.setClickable(true);
    itemLayout.setOnFocusChangeListener(this);
    itemLayout.setOnClickListener(this);
    itemLayout.setOnKeyListener(mOnKeyListener);
    itemLayout.setSoundEffectsEnabled(false);

    if (mGridLayout.getChildCount() == 0 && gridItem == mGridItemList.get(0)) {
        itemLayout.setTag(GridItem.TAG_FIRST_ITEM);
    }
    this.mGridLayout.addView(itemLayout);

    return this;
}
 
Example 16
Source File: VideoPlayerView.java    From iview-android-tv with MIT License 4 votes vote down vote up
public VideoPlayerView(Context context, PlaybackControls controller, View root) {
    mContext = context;
    mediaController = controller;
    shutterView = root.findViewById(R.id.shutter);
    videoFrame = (AspectRatioFrameLayout) root.findViewById(R.id.video_frame);
    surfaceView = (SurfaceView) root.findViewById(R.id.surface_view);
    debugTextView = (TextView) root.findViewById(R.id.debug_text_view);
    debugView = root.findViewById(R.id.debug_view);
    statusTextView = (TextView) root.findViewById(R.id.status);
    playerStateTextView = (TextView) root.findViewById(R.id.player_state_view);
    subtitleLayout = (SubtitleLayout) root.findViewById(R.id.subtitles);
    nextEpisodeCard = root.findViewById(R.id.next_episode_card);
    episodeDetails = root.findViewById(R.id.episode_details);
    episodeTitle = (TextView) root.findViewById(R.id.episode_title);
    seriesTitle = (TextView) root.findViewById(R.id.series_title);
    duration = (TextView) root.findViewById(R.id.duration);

    ImageCardView card = (ImageCardView) root.findViewById(R.id.next_episode);
    card.setFocusable(true);
    card.setFocusableInTouchMode(true);
    card.setInfoVisibility(View.VISIBLE);
    card.setExtraVisibility(View.VISIBLE);
    card.setInfoAreaBackgroundColor(context.getResources().getColor(R.color.black_900));
    Point size = new Point(context.getResources().getDimensionPixelSize(R.dimen.card_width),
            context.getResources().getDimensionPixelSize(R.dimen.card_height));
    nextEpisode = new EpisodeCardView(context, card, size, false);
    nextEpisode.getImageCardView().setCardType(BaseCardView.CARD_TYPE_INFO_OVER);

    debugView.setVisibility(View.GONE);

    root.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            return handleTouchEvents(view, motionEvent);
        }
    });
    root.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            return handleKeyEvents(v, keyCode, event);
        }
    });
}
 
Example 17
Source File: DialerFragment.java    From CSipSimple with GNU General Public License v3.0 4 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.dialer_digit, container, false);
    // Store the backgrounds objects that will be in use later
    /*
    Resources r = getResources();
    
    digitsBackground = r.getDrawable(R.drawable.btn_dial_textfield_active);
    digitsEmptyBackground = r.getDrawable(R.drawable.btn_dial_textfield_normal);
    */

    // Store some object that could be useful later
    digits = (DigitsEditText) v.findViewById(R.id.digitsText);
    dialPad = (Dialpad) v.findViewById(R.id.dialPad);
    callBar = (DialerCallBar) v.findViewById(R.id.dialerCallBar);
    autoCompleteList = (ListView) v.findViewById(R.id.autoCompleteList);
    rewriteTextInfo = (TextView) v.findViewById(R.id.rewriteTextInfo);
    
    accountChooserButton = (AccountChooserButton) v.findViewById(R.id.accountChooserButton);
    
    accountChooserFilterItem = accountChooserButton.addExtraMenuItem(R.string.apply_rewrite);
    accountChooserFilterItem.setCheckable(true);
    accountChooserFilterItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            setRewritingFeature(!accountChooserFilterItem.isChecked());
            return true;
        }
    });
    setRewritingFeature(prefsWrapper.getPreferenceBooleanValue(SipConfigManager.REWRITE_RULES_DIALER));
    
    dialerLayout = (DialerLayout) v.findViewById(R.id.top_digit_dialer);
    //switchTextView = (ImageButton) v.findViewById(R.id.switchTextView);

    // isTablet = Compatibility.isTabletScreen(getActivity());

    // Digits field setup
    if(savedInstanceState != null) {
        isDigit = savedInstanceState.getBoolean(TEXT_MODE_KEY, isDigit);
    }
    
    digits.setOnEditorActionListener(keyboardActionListener);
    
    // Layout 
    dialerLayout.setForceNoList(mDualPane);
    dialerLayout.setAutoCompleteListVisibiltyChangedListener(this);

    // Account chooser button setup
    accountChooserButton.setShowExternals(true);
    accountChooserButton.setOnAccountChangeListener(accountButtonChangeListener);

    // Dialpad
    dialPad.setOnDialKeyListener(this);

    // We only need to add the autocomplete list if we
    autoCompleteList.setAdapter(autoCompleteAdapter);
    autoCompleteList.setOnItemClickListener(autoCompleteListItemListener);
    autoCompleteList.setFastScrollEnabled(true);

    // Bottom bar setup
    callBar.setOnDialActionListener(this);
    callBar.setVideoEnabled(prefsWrapper.getPreferenceBooleanValue(SipConfigManager.USE_VIDEO));

    //switchTextView.setVisibility(Compatibility.isCompatible(11) ? View.GONE : View.VISIBLE);

    // Init other buttons
    initButtons(v);
    // Ensure that current mode (text/digit) is applied
    setTextDialing(!isDigit, true);
    if(initText != null) {
        digits.setText(initText);
        initText = null;
    }

    // Apply third party theme if any
    applyTheme(v);
    v.setOnKeyListener(this);
    applyTextToAutoComplete();
    return v;
}
 
Example 18
Source File: PipService.java    From zidoorecorder with Apache License 2.0 4 votes vote down vote up
/**
 * 初始化控件
 */
private void initView()
{
	mVPip = LayoutInflater.from(getApplicationContext()).inflate(R.layout.view_pip, null);
	View rlPip = (RelativeLayout) mVPip.findViewById(R.id.rl_pip);
	mFmPip = (FrameLayout) rlPip.findViewById(R.id.fm_pip);
	mLnFrameBg = (LinearLayout) rlPip.findViewById(R.id.ln_bg);
	mPgbLoading = (ProgressBar) mFmPip.findViewById(R.id.pgb_loading);
	mRlFrame = (RelativeLayout) mFmPip.findViewById(R.id.rl_frame);
	mTvNoSingle = (TextView) mFmPip.findViewById(R.id.tv_no_single);

	mRlController = (RelativeLayout) mVPip.findViewById(R.id.rl_control);
	mLnController = (LinearLayout) mRlController.findViewById(R.id.ln_controller);
	mLnScale = (LinearLayout) mRlController.findViewById(R.id.ln_scale);
	mLnAudio = (LinearLayout) mRlController.findViewById(R.id.ln_audio);
	mImgSwitch = (ImageView) mLnAudio.findViewById(R.id.img_switch);
	mTvReminds = (TextView) mRlController.findViewById(R.id.tv_reminds);

	mSfPip = (SurfaceView) mFmPip.findViewById(R.id.sf_pip);
	SurfaceHolder holder = mSfPip.getHolder();
	holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
	holder.addCallback(this);

	View move = mLnController.findViewById(R.id.tv_move);
	mTvScale = (TextView) mLnController.findViewById(R.id.tv_scale);
	mTvAudio = (TextView) mLnController.findViewById(R.id.tv_audio);
	View exit = mLnController.findViewById(R.id.tv_exit);
	View audioSwitch = mLnAudio.findViewById(R.id.rl_audio);

	mScales = new TextView[4];
	mScales[0] = mLnScale.findViewById(R.id.tv_scale_0);
	mScales[1] = mLnScale.findViewById(R.id.tv_scale_1);
	mScales[2] = mLnScale.findViewById(R.id.tv_scale_2);
	mScales[3] = mLnScale.findViewById(R.id.tv_scale_3);

	for (int i = 0; i < mScales.length; i++)
	{
		View v = mScales[i];
		v.setTag(i);
		v.setOnClickListener(this);
		v.setOnKeyListener(this);
		v.setOnFocusChangeListener(this);
	}
	mScales[mScaleMode].setSelected(true);

	move.setOnClickListener(this);
	mTvScale.setOnClickListener(this);
	mTvAudio.setOnClickListener(this);
	exit.setOnClickListener(this);
	audioSwitch.setOnClickListener(this);

	move.setOnFocusChangeListener(this);
	mTvScale.setOnFocusChangeListener(this);
	mTvAudio.setOnFocusChangeListener(this);
	exit.setOnFocusChangeListener(this);
	audioSwitch.setOnFocusChangeListener(this);

	move.setOnKeyListener(this);
	mTvScale.setOnKeyListener(this);
	mTvAudio.setOnKeyListener(this);
	exit.setOnKeyListener(this);
	audioSwitch.setOnKeyListener(this);
	mFmPip.setOnKeyListener(this);

	adjustPipFrame(mWindowType.x, mWindowType.y, mWindowType.width, mWindowType.height);

	WindowManager.LayoutParams params = new WindowManager.LayoutParams();
	params.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT;
	params.format = PixelFormat.RGBA_8888; // 设置图片格式,效果为背景透明
	params.flags = WindowManager.LayoutParams.FLAG_FULLSCREEN;
	params.width = WindowManager.LayoutParams.MATCH_PARENT;
	params.height = WindowManager.LayoutParams.MATCH_PARENT;

	((WindowManager) getSystemService(WINDOW_SERVICE)).addView(mVPip, params);
	move.requestFocus();
}
 
Example 19
Source File: ConfirmAuthFragment.java    From DeviceConnect-Android with MIT License 4 votes vote down vote up
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {

    Intent intent = getActivity().getIntent();
    if (intent == null) {
        getActivity().finish();
        return null;
    }
    mThreadId = intent.getLongExtra(ConfirmAuthActivity.EXTRA_THREAD_ID, -1);
    if (mThreadId == -1) {
        getActivity().finish();
        return null;
    }

    String applicationName = intent.getStringExtra(ConfirmAuthActivity.EXTRA_APPLICATION_NAME);
    String packageName = intent.getStringExtra(ConfirmAuthActivity.EXTRA_PACKAGE_NAME);
    String keyword = intent.getStringExtra(ConfirmAuthActivity.EXTRA_KEYWORD);
    String[] displayScopes = intent.getStringArrayExtra(ConfirmAuthActivity.EXTRA_DISPLAY_SCOPES);
    String expirePeriod = toStringExpiredPeriod();
    boolean isForPlugin = intent.getBooleanExtra(ConfirmAuthActivity.EXTRA_IS_FOR_DEVICEPLUGIN, true);
    boolean isAutoFlag= intent.getBooleanExtra(ConfirmAuthActivity.EXTRA_AUTO_FLAG, false);
    long requestTime = intent.getLongExtra(ConfirmAuthActivity.EXTRA_REQUEST_TIME, System.currentTimeMillis());
    long timeout = DEFAULT_TIMEOUT - (System.currentTimeMillis() - requestTime);

    int layoutId;
    if (isForPlugin) {
        layoutId = R.layout.confirm_auth_activity_plugin;
    } else {
        layoutId = R.layout.confirm_auth_activity_manager;
    }
    View view = inflater.inflate(layoutId, container, false);
    view.setFocusableInTouchMode(true);
    view.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(final View v, final int keyCode, final KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP) {
                notApprovalProc();
                return true;
            }
            return false;
        }
    });

    // 有効期限
    TextView textViewExpirePeriod = (TextView) view.findViewById(R.id.textViewExpirePeriod);
    textViewExpirePeriod.setText(expirePeriod);

    // アプリ名
    TextView textViewApplicationName = (TextView) view.findViewById(R.id.textViewAccessToken);
    textViewApplicationName.setText(applicationName);

    // スコープ一覧表示
    ListView listViewScopes = (ListView) view.findViewById(R.id.listViewScopes);
    listViewScopes.setAdapter(new ArrayAdapter<>(getActivity(),
           R.layout.confirm_auth_scopes_list_item, R.id.textViewScope,
            displayScopes));
    
    // 承認ボタン
    Button buttonApproval = (Button) view.findViewById(R.id.buttonApproval);
    buttonApproval.setOnClickListener(mOnButtonApprovalClickListener);

    // 拒否ボタン
    Button buttonReject = (Button) view.findViewById(R.id.buttonReject);
    buttonReject.setOnClickListener(mOnButtonApprovalClickListener);

    if (!isForPlugin) {
        // アプリのアクセス先(=マネージャ)のパッケージ名
        TextView textViewPackageName = (TextView) view.findViewById(R.id.textPackageName);
        textViewPackageName.setText(packageName);
        // キーワード
        TextView textViewKeyword = (TextView) view.findViewById(R.id.textKeyword);
        textViewKeyword.setText(keyword);
    }

    if (timeout > 0) {
        startTimeoutTimer(timeout);
    } else {
        // タイムアウトになっているので、Activityを閉じる
        getActivity().finish();
    }

    if (isAutoFlag) {
        new Handler(Looper.getMainLooper()).post(new Runnable() {
            @Override
            public void run() {
                approvalProc();
            }
        });
    }

    return view;
}
 
Example 20
Source File: Workspace.java    From TurboLauncher with Apache License 2.0 4 votes vote down vote up
/**
 * Adds the specified child in the specified screen. The position and dimension of
 * the child are defined by x, y, spanX and spanY.
 *
 * @param child The child to add in one of the workspace's screens.
 * @param screenId The screen in which to add the child.
 * @param x The X position of the child in the screen's grid.
 * @param y The Y position of the child in the screen's grid.
 * @param spanX The number of cells spanned horizontally by the child.
 * @param spanY The number of cells spanned vertically by the child.
 * @param insert When true, the child is inserted at the beginning of the children list.
 * @param computeXYFromRank When true, we use the rank (stored in screenId) to compute
 *                          the x and y position in which to place hotseat items. Otherwise
 *                          we use the x and y position to compute the rank.
 */
void addInScreen(View child, long container, long screenId, int x, int y, int spanX, int spanY,
        boolean insert, boolean computeXYFromRank) {
    //Reload settings
    reloadSettings();
    if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) {
        if (getScreenWithId(screenId) == null) {
            Log.e(TAG, "Skipping child, screenId " + screenId + " not found");
            // DEBUGGING - Print out the stack trace to see where we are adding from
            new Throwable().printStackTrace();
            return;
        }
    }
    if (screenId == EXTRA_EMPTY_SCREEN_ID) {
        // This should never happen
        throw new RuntimeException("Screen id should not be EXTRA_EMPTY_SCREEN_ID");
    }

    final CellLayout layout;
    if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
        layout = mLauncher.getHotseat().getLayout();
        child.setOnKeyListener(null);

        // Hide folder title in the hotseat
        if (child instanceof FolderIcon) {
            ((FolderIcon) child).setTextVisible(false);
        }

        if (computeXYFromRank) {
            x = mLauncher.getHotseat().getCellXFromOrder((int) screenId);
            y = mLauncher.getHotseat().getCellYFromOrder((int) screenId);
        } else {
            screenId = mLauncher.getHotseat().getOrderInHotseat(x, y);
        }
    } else {
        // Show folder title if not in the hotseat
        if (child instanceof FolderIcon) {
            ((FolderIcon) child).setTextVisible(!mHideIconLabels);
        } else if (child instanceof BubbleTextView) {
            ((BubbleTextView) child).setTextVisibility(!mHideIconLabels);
        }
        layout = getScreenWithId(screenId);
        child.setOnKeyListener(new IconKeyEventListener());
    }

    ViewGroup.LayoutParams genericLp = child.getLayoutParams();
    CellLayout.LayoutParams lp;
    if (genericLp == null || !(genericLp instanceof CellLayout.LayoutParams)) {
        lp = new CellLayout.LayoutParams(x, y, spanX, spanY);
    } else {
        lp = (CellLayout.LayoutParams) genericLp;
        lp.cellX = x;
        lp.cellY = y;
        lp.cellHSpan = spanX;
        lp.cellVSpan = spanY;
    }

    if (spanX < 0 && spanY < 0) {
        lp.isLockedToGrid = false;
    }

    // Get the canonical child id to uniquely represent this view in this screen
    ItemInfo info = (ItemInfo) child.getTag();
    int childId = mLauncher.getViewIdForItem(info);

    boolean markCellsAsOccupied = !(child instanceof Folder);
    if (!layout.addViewToCellLayout(child, insert ? 0 : -1, childId, lp, markCellsAsOccupied)) {
        
    }

    if (!(child instanceof Folder)) {
        if (container != LauncherSettings.Favorites.CONTAINER_HOTSEAT) {
            child.setHapticFeedbackEnabled(false);
        }
        child.setOnLongClickListener(mLongClickListener);
    }
    if (child instanceof DropTarget) {
        mDragController.addDropTarget((DropTarget) child);
    }
}