public Content(Context context, AttributeSet attrs) { super(context, attrs); mText = new TextView(context); mText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); mText.setText(context.getString(R.string.alert_dialog_two_buttons2ultra_msg)); mText.setClickable(false); mText.setOnClickListener(this); mText.setTextIsSelectable(true); addView(mText, new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); setOnSystemUiVisibilityChangeListener(this); }
void setNavVisibility(boolean visible) { int newVis = mBaseSystemUiVisibility; if (!visible) { newVis |= SYSTEM_UI_FLAG_LOW_PROFILE | SYSTEM_UI_FLAG_FULLSCREEN; } final boolean changed = newVis == getSystemUiVisibility(); // Unschedule any pending event to hide navigation if we are // changing the visibility, or making the UI visible. if (changed || visible) { Handler h = getHandler(); if (h != null) { h.removeCallbacks(mNavHider); } } // Set the new desired visibility. setSystemUiVisibility(newVis); mTitleView.setVisibility(visible ? VISIBLE : INVISIBLE); mSeekView.setVisibility(visible ? VISIBLE : INVISIBLE); } }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.show_tabs: getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); item.setChecked(true); return true; case R.id.hide_tabs: getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); item.setChecked(true); return true; case R.id.stable_layout: item.setChecked(!item.isChecked()); mContent.setBaseSystemUiVisibility(item.isChecked() ? View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE : View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); return true; } return false; }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.show_tabs: getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); item.setChecked(true); return true; case R.id.hide_tabs: getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); item.setChecked(true); return true; case R.id.stable_layout: item.setChecked(!item.isChecked()); mContent.setBaseSystemUiVisibility(item.isChecked() ? View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE : View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); return true; } return false; }
void setNavVisibility(boolean visible) { int newVis = mBaseSystemUiVisibility; if (!visible) { newVis |= SYSTEM_UI_FLAG_LOW_PROFILE | SYSTEM_UI_FLAG_FULLSCREEN; } final boolean changed = newVis == getSystemUiVisibility(); // Unschedule any pending event to hide navigation if we are // changing the visibility, or making the UI visible. if (changed || visible) { Handler h = getHandler(); if (h != null) { h.removeCallbacks(mNavHider); } } // Set the new desired visibility. setSystemUiVisibility(newVis); mTitleView.setVisibility(visible ? VISIBLE : INVISIBLE); mSeekView.setVisibility(visible ? VISIBLE : INVISIBLE); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); setContentView(R.layout.content_browser); mContent = (Content)findViewById(R.id.content); mContent.init((TextView)findViewById(R.id.title), (SeekBar)findViewById(R.id.seekbar)); ActionBar bar = getActionBar(); bar.addTab(bar.newTab().setText("Tab 1").setTabListener(this)); bar.addTab(bar.newTab().setText("Tab 2").setTabListener(this)); bar.addTab(bar.newTab().setText("Tab 3").setTabListener(this)); }
@Override public void run() { setNavVisibility(false); } };
@Override public void onSystemUiVisibilityChange(int visibility) { // Detect when we go out of low-profile mode, to also go out // of full screen. We only do this when the low profile mode // is changing from its last state, and turning off. int diff = mLastSystemUiVis ^ visibility; mLastSystemUiVis = visibility; if ((diff&SYSTEM_UI_FLAG_LOW_PROFILE) != 0 && (visibility&SYSTEM_UI_FLAG_LOW_PROFILE) == 0) { setNavVisibility(true); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); setContentView(R.layout.content_browser); mContent = (Content)findViewById(R.id.content); mContent.init((TextView)findViewById(R.id.title), (SeekBar)findViewById(R.id.seekbar)); ActionBar bar = getActionBar(); bar.addTab(bar.newTab().setText("Tab 1").setTabListener(this)); bar.addTab(bar.newTab().setText("Tab 2").setTabListener(this)); bar.addTab(bar.newTab().setText("Tab 3").setTabListener(this)); }
@Override public void run() { setNavVisibility(false); } };
public void init(TextView title, SeekBar seek) { // This called by the containing activity to supply the surrounding // state of the content browser that it will interact with. mTitleView = title; mSeekView = seek; setNavVisibility(true); }
@Override public void onClick(View v) { // When the user clicks, we toggle the visibility of navigation elements. int curVis = getSystemUiVisibility(); setNavVisibility((curVis&SYSTEM_UI_FLAG_LOW_PROFILE) != 0); }
@Override protected void onWindowVisibilityChanged(int visibility) { super.onWindowVisibilityChanged(visibility); // When we become visible, we show our navigation elements briefly // before hiding them. setNavVisibility(true); getHandler().postDelayed(mNavHider, 2000); }
@Override public void onClick(View v) { // When the user clicks, we toggle the visibility of navigation elements. int curVis = getSystemUiVisibility(); setNavVisibility((curVis&SYSTEM_UI_FLAG_LOW_PROFILE) != 0); }
@Override protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); // When the user scrolls, we hide navigation elements. setNavVisibility(false); }
@Override public void onSystemUiVisibilityChange(int visibility) { // Detect when we go out of low-profile mode, to also go out // of full screen. We only do this when the low profile mode // is changing from its last state, and turning off. int diff = mLastSystemUiVis ^ visibility; mLastSystemUiVis = visibility; if ((diff&SYSTEM_UI_FLAG_LOW_PROFILE) != 0 && (visibility&SYSTEM_UI_FLAG_LOW_PROFILE) == 0) { setNavVisibility(true); } }
public Content(Context context, AttributeSet attrs) { super(context, attrs); mText = new TextView(context); mText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); mText.setText(context.getString(R.string.alert_dialog_two_buttons2ultra_msg)); mText.setClickable(false); mText.setOnClickListener(this); mText.setTextIsSelectable(true); addView(mText, new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); setOnSystemUiVisibilityChangeListener(this); }
@Override protected void onWindowVisibilityChanged(int visibility) { super.onWindowVisibilityChanged(visibility); // When we become visible, we show our navigation elements briefly // before hiding them. setNavVisibility(true); getHandler().postDelayed(mNavHider, 2000); }
@Override protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); // When the user scrolls, we hide navigation elements. setNavVisibility(false); }
public void init(TextView title, SeekBar seek) { // This called by the containing activity to supply the surrounding // state of the content browser that it will interact with. mTitleView = title; mSeekView = seek; setNavVisibility(true); }