| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.widget; |
| 18 |
|
| 19 |
import android.annotation.Widget; |
| 20 |
import android.compat.annotation.UnsupportedAppUsage; |
| 21 |
import android.content.Context; |
| 22 |
import android.util.AttributeSet; |
| 23 |
import android.view.LayoutInflater; |
| 24 |
import android.view.MotionEvent; |
| 25 |
import android.view.View; |
| 26 |
import android.view.animation.AlphaAnimation; |
| 27 |
|
| 28 |
import com.android.internal.R; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
@Deprecated |
| 38 |
@Widget |
| 39 |
public class ZoomControls extends LinearLayout { |
| 40 |
|
| 41 |
@UnsupportedAppUsage |
| 42 |
private final ZoomButton mZoomIn; |
| 43 |
@UnsupportedAppUsage |
| 44 |
private final ZoomButton mZoomOut; |
| 45 |
|
| 46 |
public ZoomControls(Context context) { |
| 47 |
this(context, null); |
| 48 |
} |
| 49 |
|
| 50 |
public ZoomControls(Context context, AttributeSet attrs) { |
| 51 |
super(context, attrs); |
| 52 |
setFocusable(false); |
| 53 |
|
| 54 |
LayoutInflater inflater = (LayoutInflater) context |
| 55 |
.getSystemService(Context.LAYOUT_INFLATER_SERVICE); |
| 56 |
inflater.inflate(R.layout.zoom_controls, this, |
| 57 |
true); |
| 58 |
|
| 59 |
mZoomIn = (ZoomButton) findViewById(R.id.zoomIn); |
| 60 |
mZoomOut = (ZoomButton) findViewById(R.id.zoomOut); |
| 61 |
} |
| 62 |
|
| 63 |
public void setOnZoomInClickListener(OnClickListener listener) { |
| 64 |
mZoomIn.setOnClickListener(listener); |
| 65 |
} |
| 66 |
|
| 67 |
public void setOnZoomOutClickListener(OnClickListener listener) { |
| 68 |
mZoomOut.setOnClickListener(listener); |
| 69 |
} |
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
public void setZoomSpeed(long speed) { |
| 76 |
mZoomIn.setZoomSpeed(speed); |
| 77 |
mZoomOut.setZoomSpeed(speed); |
| 78 |
} |
| 79 |
|
| 80 |
@Override |
| 81 |
public boolean onTouchEvent(MotionEvent event) { |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
return true; |
| 87 |
} |
| 88 |
|
| 89 |
public void show() { |
| 90 |
fade(View.VISIBLE, 0.0f, 1.0f); |
| 91 |
} |
| 92 |
|
| 93 |
public void hide() { |
| 94 |
fade(View.GONE, 1.0f, 0.0f); |
| 95 |
} |
| 96 |
|
| 97 |
private void fade(int visibility, float startAlpha, float endAlpha) { |
| 98 |
AlphaAnimation anim = new AlphaAnimation(startAlpha, endAlpha); |
| 99 |
anim.setDuration(500); |
| 100 |
startAnimation(anim); |
| 101 |
setVisibility(visibility); |
| 102 |
} |
| 103 |
|
| 104 |
public void setIsZoomInEnabled(boolean isEnabled) { |
| 105 |
mZoomIn.setEnabled(isEnabled); |
| 106 |
} |
| 107 |
|
| 108 |
public void setIsZoomOutEnabled(boolean isEnabled) { |
| 109 |
mZoomOut.setEnabled(isEnabled); |
| 110 |
} |
| 111 |
|
| 112 |
@Override |
| 113 |
public boolean hasFocus() { |
| 114 |
return mZoomIn.hasFocus() || mZoomOut.hasFocus(); |
| 115 |
} |
| 116 |
|
| 117 |
@Override |
| 118 |
public CharSequence getAccessibilityClassName() { |
| 119 |
return ZoomControls.class.getName(); |
| 120 |
} |
| 121 |
} |