# [Q]Navigation Bar edits in source



## Adam80460 (Jun 7, 2011)

Ok, so I am trying to add the search button to my Navigation bar so it will build when I compile VS. having to do it after.

I got everything lined up correctly, meaning that the button shows, clicks just like it should but it never brings up anything. I edit NavigtionBarView.java by just copying the same styling as the Home and back buttons

I keep geeting this error when compiling


```
frameworks/base/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java:131: cannot find symbol<br />
host C: libcrypto <= external/openssl/crypto/ec/ec_cvt.c<br />
symbol  : variable STATUS_BAR_DISABLE_SEARCH<br />
location: class android.view.View<br />
		final boolean disableSearch = ((disabledFlags & View.STATUS_BAR_DISABLE_SEARCH) != 0);<br />
```
Here is my NavigationBarView.java


```
/*<br />
* Copyright (C) 2008 The Android Open Source Project<br />
*<br />
* Licensed under the Apache License, Version 2.0 (the "License");<br />
* you may not use this file except in compliance with the License.<br />
* You may obtain a copy of the License at<br />
*<br />
*	  [URL=http://www.apache.org/licenses/LICENSE-2]http://www.apache.org/licenses/LICENSE-2[/URL].0<br />
*<br />
* Unless required by applicable law or agreed to in writing, software<br />
* distributed under the License is distributed on an "AS IS" BASIS,<br />
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br />
* See the License for the specific language governing permissions and<br />
* limitations under the License.<br />
*/<br />
package com.android.systemui.statusbar.phone;<br />
import android.animation.Animator;<br />
import android.animation.AnimatorListenerAdapter;<br />
import android.content.Context;<br />
import android.content.res.Resources;<br />
import android.graphics.Rect;<br />
import android.os.ServiceManager;<br />
import android.util.AttributeSet;<br />
import android.util.Slog;<br />
import android.view.animation.AccelerateInterpolator;<br />
import android.view.Display;<br />
import android.view.MotionEvent;<br />
import android.view.View;<br />
import android.view.ViewGroup;<br />
import android.view.Surface;<br />
import android.view.WindowManager;<br />
import android.widget.LinearLayout;<br />
import java.io.FileDescriptor;<br />
import java.io.PrintWriter;<br />
import java.lang.StringBuilder;<br />
import com.android.internal.statusbar.IStatusBarService;<br />
import com.android.systemui.R;<br />
public class NavigationBarView extends LinearLayout {<br />
	final static boolean DEBUG = false;<br />
	final static String TAG = "PhoneStatusBar/NavigationBarView";<br />
	final static boolean DEBUG_DEADZONE = false;<br />
	final static boolean NAVBAR_ALWAYS_AT_RIGHT = true;<br />
	final static boolean ANIMATE_HIDE_TRANSITION = false; // turned off because it introduces unsightly delay when videos goes to full screen<br />
	protected IStatusBarService mBarService;<br />
	final Display mDisplay;<br />
	View mCurrentView = null;<br />
	View[] mRotatedViews = new View[4];<br />
	int mBarSize;<br />
	boolean mVertical;<br />
	boolean mHidden, mLowProfile, mShowMenu;<br />
	int mDisabledFlags = 0;<br />
	public View getRecentsButton() {<br />
		return mCurrentView.findViewById(R.id.recent_apps);<br />
	}<br />
	public View getMenuButton() {<br />
		return mCurrentView.findViewById(R.id.menu);<br />
	}<br />
	public View getBackButton() {<br />
		return mCurrentView.findViewById(R.id.back);<br />
	}<br />
	public View getHomeButton() {<br />
		return mCurrentView.findViewById(R.id.home);<br />
	}<br />
  <br />
  public View getSearchButton() {<br />
		return mCurrentView.findViewById(R.id.search);[<br />
	}<br />
	public NavigationBarView(Context context, AttributeSet attrs) {<br />
		super(context, attrs);<br />
		mHidden = false;<br />
		mDisplay = ((WindowManager)context.getSystemService(<br />
				Context.WINDOW_SERVICE)).getDefaultDisplay();<br />
		mBarService = IStatusBarService.Stub.asInterface(<br />
				ServiceManager.getService(Context.STATUS_BAR_SERVICE));<br />
		final Resources res = mContext.getResources();<br />
		mBarSize = res.getDimensionPixelSize(R.dimen.navigation_bar_size);<br />
		mVertical = false;<br />
		mShowMenu = false;<br />
	}<br />
	View.OnTouchListener mLightsOutListener = new View.OnTouchListener() {<br />
		@Override<br />
		public boolean onTouch(View v, MotionEvent ev) {<br />
			if (ev.getAction() == MotionEvent.ACTION_DOWN) {<br />
				// even though setting the systemUI visibility below will turn these views<br />
				// on, we need them to come up faster so that they can catch this motion<br />
				// event<br />
				setLowProfile(false, false, false);<br />
				try {<br />
					mBarService.setSystemUiVisibility(0);<br />
				} catch (android.os.RemoteException ex) {<br />
				}<br />
			}<br />
			return false;<br />
		}<br />
	};<br />
	public void setDisabledFlags(int disabledFlags) {<br />
		setDisabledFlags(disabledFlags, false);<br />
	}<br />
<br />
	public void setDisabledFlags(int disabledFlags, boolean force) {<br />
		if (!force && mDisabledFlags == disabledFlags) return;<br />
		mDisabledFlags = disabledFlags;<br />
		final boolean disableHome = ((disabledFlags & View.STATUS_BAR_DISABLE_HOME) != 0);<br />
		final boolean disableRecent = ((disabledFlags & View.STATUS_BAR_DISABLE_RECENT) != 0);<br />
		final boolean disableBack = ((disabledFlags & View.STATUS_BAR_DISABLE_BACK) != 0);<br />
		final boolean disableSearch = ((disabledFlags & View.STATUS_BAR_DISABLE_SEARCH) != 0);<br />
		getBackButton()   .setVisibility(disableBack	   ? View.INVISIBLE : View.VISIBLE);<br />
		getHomeButton()   .setVisibility(disableHome	   ? View.INVISIBLE : View.VISIBLE);<br />
		getRecentsButton().setVisibility(disableRecent	 ? View.INVISIBLE : View.VISIBLE);<br />
		getSearchButton().setVisibility(disableSearch	 ? View.INVISIBLE : View.VISIBLE);<br />
}<br />
	  <br />
	  <br />
	 public void setMenuVisibility(final boolean show) {<br />
		setMenuVisibility(show, false);<br />
	}<br />
	public void setMenuVisibility(final boolean show, final boolean force) {<br />
		if (!force && mShowMenu == show) return;<br />
		mShowMenu = show;<br />
		getMenuButton().setVisibility(mShowMenu ? View.VISIBLE : View.INVISIBLE);<br />
	}<br />
	public void setLowProfile(final boolean lightsOut) {<br />
		setLowProfile(lightsOut, true, false);<br />
	}<br />
	public void setLowProfile(final boolean lightsOut, final boolean animate, final boolean force) {<br />
		if (!force && lightsOut == mLowProfile) return;<br />
		mLowProfile = lightsOut;<br />
		if (DEBUG) Slog.d(TAG, "setting lights " + (lightsOut?"out":"on"));<br />
		final View navButtons = mCurrentView.findViewById(R.id.nav_buttons);<br />
		final View lowLights = mCurrentView.findViewById(R.id.lights_out);<br />
		// ok, everyone, stop it right there<br />
		navButtons.animate().cancel();<br />
		lowLights.animate().cancel();<br />
		if (!animate) {<br />
			navButtons.setAlpha(lightsOut ? 0f : 1f);<br />
			lowLights.setAlpha(lightsOut ? 1f : 0f);<br />
			lowLights.setVisibility(lightsOut ? View.VISIBLE : View.GONE);<br />
		} else {<br />
			navButtons.animate()<br />
				.alpha(lightsOut ? 0f : 1f)<br />
				.setDuration(lightsOut ? 600 : 200)<br />
				.start();<br />
			lowLights.setOnTouchListener(mLightsOutListener);<br />
			if (lowLights.getVisibility() == View.GONE) {<br />
				lowLights.setAlpha(0f);<br />
				lowLights.setVisibility(View.VISIBLE);<br />
			}<br />
			lowLights.animate()<br />
				.alpha(lightsOut ? 1f : 0f)<br />
				.setStartDelay(lightsOut ? 500 : 0)<br />
				.setDuration(lightsOut ? 1000 : 300)<br />
				.setInterpolator(new AccelerateInterpolator(2.0f))<br />
				.setListener(lightsOut ? null : new AnimatorListenerAdapter() {<br />
					@Override<br />
					public void onAnimationEnd(Animator _a) {<br />
						lowLights.setVisibility(View.GONE);<br />
					}<br />
				})<br />
				.start();<br />
		}<br />
	}<br />
	public void setHidden(final boolean hide) {<br />
		if (hide == mHidden) return;<br />
		mHidden = hide;<br />
		Slog.d(TAG,<br />
			(hide ? "HIDING" : "SHOWING") + " navigation bar");<br />
		// bring up the lights no matter what<br />
		setLowProfile(false);<br />
	}<br />
	public void onFinishInflate() {<br />
		mRotatedViews[Surface.ROTATION_0] =<br />
		mRotatedViews[Surface.ROTATION_180] = findViewById(R.id.rot0);<br />
		mRotatedViews[Surface.ROTATION_90] = findViewById(R.id.rot90);<br />
	  <br />
		mRotatedViews[Surface.ROTATION_270] = NAVBAR_ALWAYS_AT_RIGHT<br />
												? findViewById(R.id.rot90)<br />
												: findViewById(R.id.rot270);<br />
		for (View v : mRotatedViews) {<br />
			// this helps avoid drawing artifacts with glowing navigation keys<br />
			ViewGroup group = (ViewGroup) v.findViewById(R.id.nav_buttons);<br />
			group.setMotionEventSplittingEnabled(false);<br />
		}<br />
		mCurrentView = mRotatedViews[Surface.ROTATION_0];<br />
	}<br />
	public void reorient() {<br />
		final int rot = mDisplay.getRotation();<br />
		for (int i=0; i<4; i++) {<br />
			mRotatedViews[i].setVisibility(View.GONE);<br />
		}<br />
		mCurrentView = mRotatedViews[rot];<br />
		mCurrentView.setVisibility(View.VISIBLE);<br />
		mVertical = (rot == Surface.ROTATION_90 || rot == Surface.ROTATION_270);<br />
		// force the low profile & disabled states into compliance<br />
		setLowProfile(mLowProfile, false, true /* force */);<br />
		setDisabledFlags(mDisabledFlags, true /* force */);<br />
		setMenuVisibility(mShowMenu, true /* force */);<br />
		if (DEBUG_DEADZONE) {<br />
			mCurrentView.findViewById(R.id.deadzone).setBackgroundColor(0x808080FF);<br />
		}<br />
		if (DEBUG) {<br />
			Slog.d(TAG, "reorient(): rot=" + mDisplay.getRotation());<br />
		}<br />
	}<br />
	private String getResourceName(int resId) {<br />
		if (resId != 0) {<br />
			final android.content.res.Resources res = mContext.getResources();<br />
			try {<br />
				return res.getResourceName(resId);<br />
			} catch (android.content.res.Resources.NotFoundException ex) {<br />
				return "(unknown)";<br />
			}<br />
		} else {<br />
			return "(null)";<br />
		}<br />
	}<br />
	private static String visibilityToString(int vis) {<br />
		switch (vis) {<br />
			case View.INVISIBLE:<br />
				return "INVISIBLE";<br />
			case View.GONE:<br />
				return "GONE";<br />
			default:<br />
				return "VISIBLE";<br />
		}<br />
	}<br />
	public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {<br />
		pw.println("NavigationBarView {");<br />
		final Rect r = new Rect();<br />
		pw.println(String.format("	  this: " + PhoneStatusBar.viewInfo(this)<br />
						+ " " + visibilityToString(getVisibility())));<br />
		getWindowVisibleDisplayFrame(r);<br />
		final boolean offscreen = r.right > mDisplay.getRawWidth()<br />
			|| r.bottom > mDisplay.getRawHeight();<br />
		pw.println("	  window: "<br />
				+ r.toShortString()<br />
				+ " " + visibilityToString(getWindowVisibility())<br />
				+ (offscreen ? " OFFSCREEN!" : ""));<br />
		pw.println(String.format("	  mCurrentView: id=%s (%dx%d) %s",<br />
						getResourceName(mCurrentView.getId()),<br />
						mCurrentView.getWidth(), mCurrentView.getHeight(),<br />
						visibilityToString(mCurrentView.getVisibility())));<br />
		pw.println(String.format("	  disabled=0x%08x vertical=%s hidden=%s low=%s menu=%s",<br />
						mDisabledFlags,<br />
						mVertical ? "true" : "false",<br />
						mHidden ? "true" : "false",<br />
						mLowProfile ? "true" : "false",<br />
						mShowMenu ? "true" : "false"));<br />
		final View back = getBackButton();<br />
		final View home = getHomeButton();<br />
		final View recent = getRecentsButton();<br />
		final View search = getSearchButton();<br />
		final View menu = getMenuButton();<br />
		pw.println("	  back: "<br />
				+ PhoneStatusBar.viewInfo(back)<br />
				+ " " + visibilityToString(back.getVisibility())<br />
				);<br />
		pw.println("	  home: "<br />
				+ PhoneStatusBar.viewInfo(home)<br />
				+ " " + visibilityToString(home.getVisibility())<br />
				);<br />
		pw.println("	  rcnt: "<br />
				+ PhoneStatusBar.viewInfo(recent)<br />
				+ " " + visibilityToString(recent.getVisibility())<br />
				);<br />
		pw.println("	  search: "<br />
				+ PhoneStatusBar.viewInfo(search)<br />
				+ " " + visibilityToString(search.getVisibility())<br />
				);<br />
		pw.println("	  menu: "<br />
				+ PhoneStatusBar.viewInfo(menu)<br />
				+ " " + visibilityToString(menu.getVisibility())<br />
				);<br />
		pw.println("	}");<br />
	}<br />
}<br />
```


----------



## Adam80460 (Jun 7, 2011)

runandhide05 set me straight .. I actually was using the wrong keycode in my navigationbar.xml ...

Sent from my Full AOSP on Toro using RootzWiki


----------

