Android Open Source - PassGraph Sensitive Point






From Project

Back to project page PassGraph.

License

The source code is released under:

GNU General Public License

If you think the Android project PassGraph listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package littlesoft.widgets;
//from  w  w  w .  jav a  2 s . c o m
import android.content.Context;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.LightingColorFilter;
import android.widget.ImageView;
import android.view.MotionEvent;
import android.view.View;




public class SensitivePoint extends ImageView implements View.OnTouchListener{
  private ColorFilter  colors[] = {new LightingColorFilter(Color.GREEN,0), new LightingColorFilter(Color.RED,0), new LightingColorFilter(Color.BLUE,0)};
  private int activation = 0;
  private boolean activable=true;
  
  private double margin=0.95;
  
  
  public SensitivePoint(Context c){
    super(c);
    setOnTouchListener(this);
    

  }
  
  public void setMargin(int cents){
    margin = cents/100.0;
  }

  public int getMargin(){
    return (int)(margin*100.0);
  }
  
  public void reset(){
    activable = true;
    activation = 0;
    setColorFilter(null);
  }
  
  public int getValue(){
    return activation;
  }
  
  @Override
  public boolean onTouch(View v, MotionEvent ev) {
    
      if (ev.getAction() == MotionEvent.ACTION_MOVE) {
        int point[] = new int[2];        
        int center[] = new int[2];
        
        getLocationOnScreen(point);
        center[0] = (point[0] + getWidth()/2);
        center[1] = (point[1] + getHeight()/2);
        int d = Math.min(getWidth(), getHeight())/2;
        d *= margin;
        d = d*d;
        
        boolean activate = ((center[0] -ev.getX())*(center[0] -ev.getX()) ) + ( (center[1] -ev.getY())* (center[1] -ev.getY()) ) < d;
        
        if(activate && activable){
          activation = ++activation %3;
          setColorFilter(colors[activation]);
        }
        activable = !activate;
      }
    return false;
  }


  


  

}




Java Source Code List

littlesoft.FirerObserver.java
littlesoft.Firer.java
littlesoft.MutableDouble.java
littlesoft.widgets.PassGraphTest.java
littlesoft.widgets.PassGraphWidget.java
littlesoft.widgets.SensitivePoint.java
littlesoft.widgets.util.SystemUiHiderBase.java
littlesoft.widgets.util.SystemUiHiderHoneycomb.java
littlesoft.widgets.util.SystemUiHider.java