import android.os.Build;\r
import android.os.Bundle;\r
import android.util.Log;\r
+import android.view.MotionEvent;\r
import android.view.View;\r
import android.widget.Button;\r
+import android.widget.Toast;\r
\r
import java.lang.reflect.Method;\r
\r
+import mobile.miki.util.FTUtils;\r
+\r
public class shutdown_activity extends BaseActivity {\r
\r
String TAG="shutdown_activity";\r
Button btn_yes;\r
Button btn_no;\r
+\r
+\r
@Override\r
protected void onCreate(Bundle savedInstanceState) {\r
super.onCreate(savedInstanceState);\r
setContentView(R.layout.activity_shutdown_activity);\r
+ setclicklistener(true);\r
+ if(FTUtils.isA9()){\r
+ btn_yes.setVisibility(View.GONE);\r
+ }\r
+\r
+ }\r
+\r
+ private void setclicklistener(boolean b){\r
btn_yes =(Button)findViewById(R.id.btn_yes);\r
btn_no =(Button)findViewById(R.id.btn_no);\r
- btn_yes.setClickable(true);\r
- btn_no.setClickable(true);\r
- btn_no.setEnabled(true);\r
- btn_yes.setEnabled(true);\r
\r
- btn_yes.setOnClickListener(new View.OnClickListener() {\r
- @Override\r
- public void onClick(View v) {\r
- //log("shutdown");\r
- finish();\r
- try {\r
-\r
- //获得ServiceManager类\r
- Class ServiceManager = Class\r
- .forName("android.os.ServiceManager");\r
-\r
- //获得ServiceManager的getService方法\r
- Method getService = ServiceManager.getMethod("getService", java.lang.String.class);\r
-\r
- //调用getService获取RemoteService\r
- Object oRemoteService = getService.invoke(null, Context.POWER_SERVICE);\r
-\r
- //获得IPowerManager.Stub类\r
- Class cStub = Class\r
- .forName("android.os.IPowerManager$Stub");\r
- //获得asInterface方法\r
- Method asInterface = cStub.getMethod("asInterface", android.os.IBinder.class);\r
- //调用asInterface方法获取IPowerManager对象\r
- Object oIPowerManager = asInterface.invoke(null, oRemoteService);\r
- //获得shutdown()方法\r
- Method shutdown = oIPowerManager.getClass().getMethod("shutdown",boolean.class,boolean.class);\r
- //调用shutdown()方法\r
- shutdown.invoke(oIPowerManager,false,true);\r
-\r
- } catch (Exception e) {\r
- Log.e(TAG, e.toString(), e);\r
+ if (b==true){\r
+ btn_yes.setClickable(true);\r
+ btn_yes.setEnabled(true);\r
+ btn_yes.setOnClickListener(new View.OnClickListener() {\r
+ @Override\r
+ public void onClick(View v) {\r
+ //log("shutdown");\r
+ finish();\r
+ try {\r
+\r
+ //获得ServiceManager类\r
+ Class ServiceManager = Class\r
+ .forName("android.os.ServiceManager");\r
+\r
+ //获得ServiceManager的getService方法\r
+ Method getService = ServiceManager.getMethod("getService", java.lang.String.class);\r
+\r
+ //调用getService获取RemoteService\r
+ Object oRemoteService = getService.invoke(null, Context.POWER_SERVICE);\r
+\r
+ //获得IPowerManager.Stub类\r
+ Class cStub = Class\r
+ .forName("android.os.IPowerManager$Stub");\r
+ //获得asInterface方法\r
+ Method asInterface = cStub.getMethod("asInterface", android.os.IBinder.class);\r
+ //调用asInterface方法获取IPowerManager对象\r
+ Object oIPowerManager = asInterface.invoke(null, oRemoteService);\r
+ //获得shutdown()方法\r
+ Method shutdown = oIPowerManager.getClass().getMethod("shutdown",boolean.class,boolean.class);\r
+ //调用shutdown()方法\r
+ shutdown.invoke(oIPowerManager,false,true);\r
+\r
+ } catch (Exception e) {\r
+ Log.e(TAG, e.toString(), e);\r
+ }\r
}\r
- }\r
- });\r
+ });\r
+ }\r
+\r
+ btn_no.setClickable(true);\r
+ btn_no.setEnabled(true);\r
\r
btn_no.setOnClickListener(new View.OnClickListener() {\r
@Override\r
}\r
});\r
}\r
+ //(0~20,0~20),(130~170,0~20),(130~170,120~170),(0~20,120~170)\r
+ int[][] mapx={{0,40},{130,240},{0,40},{130,240}};\r
+ int[][] mapy={{100,240},{100,240},{0,40},{0,40}};\r
+ int touchindex=0;\r
+\r
+ @Override\r
+ public boolean dispatchTouchEvent(MotionEvent ev) {\r
+ switch (ev.getAction()) {\r
+ case MotionEvent.ACTION_DOWN:\r
+ //有按下动作时取消定时\r
+\r
+ break;\r
+ case MotionEvent.ACTION_UP:\r
+ //抬起时启动定时\r
+ float x = ev.getX();\r
+ float y= ev.getY();\r
+ if(FTUtils.isA9()){\r
+ if ((x >mapx[touchindex][0] && x < mapx[touchindex][1] ) && (y > mapy[touchindex][0] && y < mapy[touchindex][1])){\r
+ touchindex++;\r
+ if (touchindex ==4){\r
+ touchindex=0;\r
+ btn_yes.setVisibility(View.VISIBLE);\r
+\r
+ }\r
+ }else{\r
+ touchindex=0;\r
+ }\r
+ }\r
+ break;\r
+ }\r
+ return super.dispatchTouchEvent(ev);\r
+\r
+ }\r
+\r
+\r
}\r
android:orientation="vertical"\r
android:background="@android:color/white">\r
\r
+\r
<LinearLayout\r
+ android:id="@+id/pf_layout2"\r
android:layout_width="match_parent"\r
android:layout_height="wrap_content"\r
android:layout_centerInParent="true"\r
android:orientation="vertical">\r
-\r
<TextView\r
android:id="@+id/shutdownText"\r
android:layout_width="wrap_content"\r
android:textStyle="bold" />\r
</LinearLayout>\r
\r
-\r
<LinearLayout\r
android:layout_width="match_parent"\r
android:layout_height="wrap_content"\r
android:id="@+id/btn_no"\r
style="@style/button_white_text"\r
android:layout_width="0dp"\r
- android:layout_height="match_parent"\r
+ android:layout_height="40dp"\r
android:layout_weight="1"\r
android:background="#DA5B17"\r
android:text="@string/rf_no"\r
android:id="@+id/btn_yes"\r
style="@style/button_white_text"\r
android:layout_width="0dp"\r
- android:layout_height="match_parent"\r
+ android:layout_height="40dp"\r
android:layout_weight="1"\r
android:background="#DA5B17"\r
android:text="@string/rf_yes"\r