diff --git a/LockScreenApp/.classpath b/LockScreenApp/.classpath
index a4f1e40..c3c8602 100644
--- a/LockScreenApp/.classpath
+++ b/LockScreenApp/.classpath
@@ -1,8 +1,9 @@
+
+
-
-
+
diff --git a/LockScreenApp/AndroidManifest.xml b/LockScreenApp/AndroidManifest.xml
index 21fc9df..6d20b95 100644
--- a/LockScreenApp/AndroidManifest.xml
+++ b/LockScreenApp/AndroidManifest.xml
@@ -1,60 +1,44 @@
+ package="com.mehuljoisar.lockscreen"
+ android:versionCode="3"
+ android:versionName="1.2" >
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
+
-
+ android:name=".utils.LockscreenIntentReceiver"
+ android:enabled="true" >
+
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/LockScreenApp/libs/android-support-v4.jar b/LockScreenApp/libs/android-support-v4.jar
new file mode 100644
index 0000000..e74b0d7
Binary files /dev/null and b/LockScreenApp/libs/android-support-v4.jar differ
diff --git a/LockScreenApp/project.properties b/LockScreenApp/project.properties
index ea89160..2329cec 100644
--- a/LockScreenApp/project.properties
+++ b/LockScreenApp/project.properties
@@ -8,4 +8,4 @@
# project structure.
# Project target.
-target=android-8
+target=Google Inc.:Google APIs:22
diff --git a/LockScreenApp/res/color/selector_txt_btn_unlock.xml b/LockScreenApp/res/color/selector_txt_btn_unlock.xml
new file mode 100644
index 0000000..7167cea
--- /dev/null
+++ b/LockScreenApp/res/color/selector_txt_btn_unlock.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/LockScreenApp/res/drawable-hdpi/ic_launcher.png b/LockScreenApp/res/drawable-hdpi/ic_launcher.png
index 8074c4c..96a442e 100644
Binary files a/LockScreenApp/res/drawable-hdpi/ic_launcher.png and b/LockScreenApp/res/drawable-hdpi/ic_launcher.png differ
diff --git a/LockScreenApp/res/drawable-ldpi/ic_launcher.png b/LockScreenApp/res/drawable-ldpi/ic_launcher.png
deleted file mode 100644
index 1095584..0000000
Binary files a/LockScreenApp/res/drawable-ldpi/ic_launcher.png and /dev/null differ
diff --git a/LockScreenApp/res/drawable-mdpi/ic_launcher.png b/LockScreenApp/res/drawable-mdpi/ic_launcher.png
index a07c69f..359047d 100644
Binary files a/LockScreenApp/res/drawable-mdpi/ic_launcher.png and b/LockScreenApp/res/drawable-mdpi/ic_launcher.png differ
diff --git a/LockScreenApp/res/drawable-xhdpi/ic_launcher.png b/LockScreenApp/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..71c6d76
Binary files /dev/null and b/LockScreenApp/res/drawable-xhdpi/ic_launcher.png differ
diff --git a/LockScreenApp/res/drawable-xxhdpi/ic_launcher.png b/LockScreenApp/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..4df1894
Binary files /dev/null and b/LockScreenApp/res/drawable-xxhdpi/ic_launcher.png differ
diff --git a/LockScreenApp/res/drawable/droid.jpg b/LockScreenApp/res/drawable/droid.jpg
deleted file mode 100644
index f0fc601..0000000
Binary files a/LockScreenApp/res/drawable/droid.jpg and /dev/null differ
diff --git a/LockScreenApp/res/drawable/droid1.jpg b/LockScreenApp/res/drawable/droid1.jpg
deleted file mode 100644
index b0d7b85..0000000
Binary files a/LockScreenApp/res/drawable/droid1.jpg and /dev/null differ
diff --git a/LockScreenApp/res/drawable/droidupdated.JPG b/LockScreenApp/res/drawable/droidupdated.JPG
deleted file mode 100644
index eeb0955..0000000
Binary files a/LockScreenApp/res/drawable/droidupdated.JPG and /dev/null differ
diff --git a/LockScreenApp/res/drawable/home.jpg b/LockScreenApp/res/drawable/home.jpg
deleted file mode 100644
index 4b9846e..0000000
Binary files a/LockScreenApp/res/drawable/home.jpg and /dev/null differ
diff --git a/LockScreenApp/res/drawable/home1.jpg b/LockScreenApp/res/drawable/home1.jpg
deleted file mode 100644
index f438311..0000000
Binary files a/LockScreenApp/res/drawable/home1.jpg and /dev/null differ
diff --git a/LockScreenApp/res/drawable/home128.jpg b/LockScreenApp/res/drawable/home128.jpg
deleted file mode 100644
index e2258a4..0000000
Binary files a/LockScreenApp/res/drawable/home128.jpg and /dev/null differ
diff --git a/LockScreenApp/res/drawable/homeupdated.JPG b/LockScreenApp/res/drawable/homeupdated.JPG
deleted file mode 100644
index c360925..0000000
Binary files a/LockScreenApp/res/drawable/homeupdated.JPG and /dev/null differ
diff --git a/LockScreenApp/res/drawable/images.jpg b/LockScreenApp/res/drawable/images.jpg
deleted file mode 100644
index f80a8c8..0000000
Binary files a/LockScreenApp/res/drawable/images.jpg and /dev/null differ
diff --git a/LockScreenApp/res/drawable/images0.png b/LockScreenApp/res/drawable/images0.png
deleted file mode 100644
index 541c612..0000000
Binary files a/LockScreenApp/res/drawable/images0.png and /dev/null differ
diff --git a/LockScreenApp/res/drawable/index.jpg b/LockScreenApp/res/drawable/index.jpg
deleted file mode 100644
index 6b1d08d..0000000
Binary files a/LockScreenApp/res/drawable/index.jpg and /dev/null differ
diff --git a/LockScreenApp/res/drawable/index1.jpg b/LockScreenApp/res/drawable/index1.jpg
deleted file mode 100644
index 3ebb9b5..0000000
Binary files a/LockScreenApp/res/drawable/index1.jpg and /dev/null differ
diff --git a/LockScreenApp/res/drawable/lockicon.jpg b/LockScreenApp/res/drawable/lockicon.jpg
deleted file mode 100644
index 381fd6e..0000000
Binary files a/LockScreenApp/res/drawable/lockicon.jpg and /dev/null differ
diff --git a/LockScreenApp/res/drawable/main.xml b/LockScreenApp/res/drawable/main.xml
deleted file mode 100644
index 96f5519..0000000
--- a/LockScreenApp/res/drawable/main.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/LockScreenApp/res/drawable/phone.jpg b/LockScreenApp/res/drawable/phone.jpg
deleted file mode 100644
index f438311..0000000
Binary files a/LockScreenApp/res/drawable/phone.jpg and /dev/null differ
diff --git a/LockScreenApp/res/drawable/phone150.jpg b/LockScreenApp/res/drawable/phone150.jpg
deleted file mode 100644
index 54f9785..0000000
Binary files a/LockScreenApp/res/drawable/phone150.jpg and /dev/null differ
diff --git a/LockScreenApp/res/drawable/phone2.jpg b/LockScreenApp/res/drawable/phone2.jpg
deleted file mode 100644
index c8f519b..0000000
Binary files a/LockScreenApp/res/drawable/phone2.jpg and /dev/null differ
diff --git a/LockScreenApp/res/drawable/phone3.jpg b/LockScreenApp/res/drawable/phone3.jpg
deleted file mode 100644
index 03c5942..0000000
Binary files a/LockScreenApp/res/drawable/phone3.jpg and /dev/null differ
diff --git a/LockScreenApp/res/drawable/phoneupdated.JPG b/LockScreenApp/res/drawable/phoneupdated.JPG
deleted file mode 100644
index 388bae1..0000000
Binary files a/LockScreenApp/res/drawable/phoneupdated.JPG and /dev/null differ
diff --git a/LockScreenApp/res/drawable/phoneupdated1.JPG b/LockScreenApp/res/drawable/phoneupdated1.JPG
deleted file mode 100644
index 08031b8..0000000
Binary files a/LockScreenApp/res/drawable/phoneupdated1.JPG and /dev/null differ
diff --git a/LockScreenApp/res/drawable/selector_bg_btn_unlock.xml b/LockScreenApp/res/drawable/selector_bg_btn_unlock.xml
new file mode 100644
index 0000000..daf7c32
--- /dev/null
+++ b/LockScreenApp/res/drawable/selector_bg_btn_unlock.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/LockScreenApp/res/layout/activity_lockscreen.xml b/LockScreenApp/res/layout/activity_lockscreen.xml
new file mode 100644
index 0000000..6c9dd00
--- /dev/null
+++ b/LockScreenApp/res/layout/activity_lockscreen.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/LockScreenApp/res/layout/custom_lock_screen.xml b/LockScreenApp/res/layout/custom_lock_screen.xml
deleted file mode 100644
index 4bc1520..0000000
--- a/LockScreenApp/res/layout/custom_lock_screen.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/LockScreenApp/res/layout/main.xml b/LockScreenApp/res/layout/main.xml
deleted file mode 100644
index 410d5f4..0000000
--- a/LockScreenApp/res/layout/main.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/LockScreenApp/res/values-w820dp/dimens.xml b/LockScreenApp/res/values-w820dp/dimens.xml
new file mode 100644
index 0000000..f9f069f
--- /dev/null
+++ b/LockScreenApp/res/values-w820dp/dimens.xml
@@ -0,0 +1,10 @@
+
+
+
+ 64dp
+
+
diff --git a/LockScreenApp/res/values/colors.xml b/LockScreenApp/res/values/colors.xml
new file mode 100644
index 0000000..2f57147
--- /dev/null
+++ b/LockScreenApp/res/values/colors.xml
@@ -0,0 +1,8 @@
+
+
+
+ #F5DC49
+ #000000
+ #FFFFFF
+
+
\ No newline at end of file
diff --git a/LockScreenApp/res/values/dimens.xml b/LockScreenApp/res/values/dimens.xml
new file mode 100644
index 0000000..2e0e2ae
--- /dev/null
+++ b/LockScreenApp/res/values/dimens.xml
@@ -0,0 +1,7 @@
+
+
+
+ 16dp
+ 16dp
+
+
diff --git a/LockScreenApp/res/values/strings.xml b/LockScreenApp/res/values/strings.xml
index 958e775..120aa78 100644
--- a/LockScreenApp/res/values/strings.xml
+++ b/LockScreenApp/res/values/strings.xml
@@ -1,10 +1,9 @@
- Hello World, LockScreenAppActivity!
LockScreenApp
- Unlock
- #F5DC49
-
+ Click on UNLOCK button to unlock the screen
+ UNLOCK
+
\ No newline at end of file
diff --git a/LockScreenApp/res/values/style.xml b/LockScreenApp/res/values/style.xml
index 18d054a..c825ed4 100644
--- a/LockScreenApp/res/values/style.xml
+++ b/LockScreenApp/res/values/style.xml
@@ -1,11 +1,13 @@
-
-
+
+
+
+
\ No newline at end of file
diff --git a/LockScreenApp/src/com/lockscreen/LockScreenAppActivity.java b/LockScreenApp/src/com/lockscreen/LockScreenAppActivity.java
deleted file mode 100644
index 260f234..0000000
--- a/LockScreenApp/src/com/lockscreen/LockScreenAppActivity.java
+++ /dev/null
@@ -1,423 +0,0 @@
-package com.lockscreen;
-import receiver.lockScreenReeiver;
-import android.app.Activity;
-import android.app.KeyguardManager;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.net.Uri;
-import android.os.Bundle;
-import android.os.PowerManager;
-import android.telephony.PhoneStateListener;
-import android.telephony.TelephonyManager;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.Window;
-import android.view.WindowManager;
-import android.view.ViewGroup.MarginLayoutParams;
-import android.widget.Button;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.RelativeLayout;
-import android.widget.Toast;
-import android.widget.RelativeLayout.LayoutParams;
-
-public class LockScreenAppActivity extends Activity {
-
- /** Called when the activity is first created. */
- KeyguardManager.KeyguardLock k1;
- boolean inDragMode;
- int selectedImageViewX;
- int selectedImageViewY;
- int windowwidth;
- int windowheight;
- ImageView droid,phone,home;
- //int phone_x,phone_y;
- int home_x,home_y;
- int[] droidpos;
-
- private LayoutParams layoutParams;
-
- @Override
- public void onAttachedToWindow() {
- // TODO Auto-generated method stub
- this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG|WindowManager.LayoutParams.FLAG_FULLSCREEN);
-
- super.onAttachedToWindow();
- }
-/*@Override
-protected void onNewIntent(Intent intent) {
- // TODO Auto-generated method stub
- super.onNewIntent(intent);
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON|WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED|WindowManager.LayoutParams.FLAG_FULLSCREEN);
-
-}*/
- public void onCreate(Bundle savedInstanceState) {
-
- super.onCreate(savedInstanceState);
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON|WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED|WindowManager.LayoutParams.FLAG_FULLSCREEN);
-
-
-
- setContentView(R.layout.main);
- droid =(ImageView)findViewById(R.id.droid);
-
-
-
- System.out.println("measured width"+droid.getMeasuredWidth());
- System.out.println(" width"+droid.getWidth());
-
-
- if(getIntent()!=null&&getIntent().hasExtra("kill")&&getIntent().getExtras().getInt("kill")==1){
- // Toast.makeText(this, "" + "kill activityy", Toast.LENGTH_SHORT).show();
- finish();
- }
-
- try{
- // initialize receiver
-
-
- startService(new Intent(this,MyService.class));
-
-
-
-
- /* KeyguardManager km =(KeyguardManager)getSystemService(KEYGUARD_SERVICE);
- k1 = km.newKeyguardLock("IN");
- k1.disableKeyguard();*/
- StateListener phoneStateListener = new StateListener();
- TelephonyManager telephonyManager =(TelephonyManager)getSystemService(TELEPHONY_SERVICE);
- telephonyManager.listen(phoneStateListener,PhoneStateListener.LISTEN_CALL_STATE);
-
- windowwidth=getWindowManager().getDefaultDisplay().getWidth();
- System.out.println("windowwidth"+windowwidth);
- windowheight=getWindowManager().getDefaultDisplay().getHeight();
- System.out.println("windowheight"+windowheight);
-
- MarginLayoutParams marginParams2 = new MarginLayoutParams(droid.getLayoutParams());
-
- marginParams2.setMargins((windowwidth/24)*10,((windowheight/32)*8),0,0);
-
- //marginParams2.setMargins(((windowwidth-droid.getWidth())/2),((windowheight/32)*8),0,0);
- RelativeLayout.LayoutParams layoutdroid = new RelativeLayout.LayoutParams(marginParams2);
-
- droid.setLayoutParams(layoutdroid);
-
- /* phone =(ImageView)findViewById(R.id.phone);
- MarginLayoutParams marginParams = new MarginLayoutParams(phone.getLayoutParams());
- marginParams.setMargins(0,windowheight/32,windowwidth/24,0);
- LinearLayout.LayoutParams layoutParams1 = new LinearLayout.LayoutParams(marginParams);
- phone.setLayoutParams(layoutParams1);
-*/
-
- LinearLayout homelinear = (LinearLayout)findViewById(R.id.homelinearlayout);
- homelinear.setPadding(0,0,0,(windowheight/32)*3);
- home =(ImageView)findViewById(R.id.home);
-
- MarginLayoutParams marginParams1 = new MarginLayoutParams(home.getLayoutParams());
-
- marginParams1.setMargins((windowwidth/24)*10,0,(windowheight/32)*8,0);
- // marginParams1.setMargins(((windowwidth-home.getWidth())/2),0,(windowheight/32)*10,0);
- LinearLayout.LayoutParams layout = new LinearLayout.LayoutParams(marginParams1);
-
- home.setLayoutParams(layout);
-
-
-
- droid.setOnTouchListener(new View.OnTouchListener() {
-
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- // TODO Auto-generated method stub
- layoutParams = (LayoutParams) v.getLayoutParams();
-
- switch(event.getAction())
- {
-
- case MotionEvent.ACTION_DOWN:
- int[] hompos=new int[2];
- // int[] phonepos=new int[2];
- droidpos=new int[2];
- //phone.getLocationOnScreen(phonepos);
- home.getLocationOnScreen(hompos);
- home_x=hompos[0];
- home_y=hompos[1];
- // phone_x=phonepos[0];
- // phone_y=phonepos[1];
-
-
- break;
- case MotionEvent.ACTION_MOVE:
- int x_cord = (int)event.getRawX();
- int y_cord = (int)event.getRawY();
-
- if(x_cord>windowwidth-(windowwidth/24)){x_cord=windowwidth-(windowwidth/24)*2;}
- if(y_cord>windowheight-(windowheight/32)){y_cord=windowheight-(windowheight/32)*2;}
-
- layoutParams.leftMargin = x_cord ;
- layoutParams.topMargin = y_cord;
-
- droid.getLocationOnScreen(droidpos);
- v.setLayoutParams(layoutParams);
-
- if(((x_cord-home_x)<=(windowwidth/24)*5 && (home_x-x_cord)<=(windowwidth/24)*4)&&((home_y-y_cord)<=(windowheight/32)*5))
- {
- System.out.println("home overlapps");
- System.out.println("homeee"+home_x+" "+(int)event.getRawX()+" "+x_cord+" "+droidpos[0]);
-
- System.out.println("homeee"+home_y+" "+(int)event.getRawY()+" "+y_cord+" "+droidpos[1]);
-
- v.setVisibility(View.GONE);
-
- // startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("content://contacts/people/")));
- finish();
- }
- else{
- System.out.println("homeee"+home_x+" "+(int)event.getRawX()+" "+x_cord+" "+droidpos[0]);
-
- System.out.println("homeee"+home_y+" "+(int)event.getRawY()+" "+y_cord+" "+droidpos[1]);
-
-
- System.out.println("home notttt overlapps");
- }
- /* if(((x_cord-phone_x)>=128 && (x_cord-phone_x)<=171 )&&((phone_y-y_cord)<=10))
- {
- System.out.println("phone overlapps");
- finish();
- }
- else{
- System.out.println(phone_x+" "+(int)event.getRawX()+" "+x_cord+" "+droidpos[0]);
-
- System.out.println(phone_y+" "+(int)event.getRawY()+" "+y_cord+" "+droidpos[1]);
-
-
- System.out.println("phone not overlapps" +
- " overlapps");
- }*/
- // v.invalidate();
-
-
-
-
- break;
- case MotionEvent.ACTION_UP:
-
-
- int x_cord1 = (int)event.getRawX();
- int y_cord2 = (int)event.getRawY();
-
- if(((x_cord1-home_x)<=(windowwidth/24)*5 && (home_x-x_cord1)<=(windowwidth/24)*4)&&((home_y-y_cord2)<=(windowheight/32)*5))
- {
- System.out.println("home overlapps");
- System.out.println("homeee"+home_x+" "+(int)event.getRawX()+" "+x_cord1+" "+droidpos[0]);
-
- System.out.println("homeee"+home_y+" "+(int)event.getRawY()+" "+y_cord2+" "+droidpos[1]);
-
- // startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("content://contacts/people/")));
- //finish();
- }
- else{
-
- layoutParams.leftMargin = (windowwidth/24)*10;
- layoutParams.topMargin = (windowheight/32)*8;
- v.setLayoutParams(layoutParams);
-
-
- }
-
-
-
-
- }
-
- return true;
- }
- });
-
-/*
- Button close =(Button)findViewById(R.id.lockk);
- close.setOnClickListener(new View.OnClickListener() {
-
- public void onClick(View v) {
- //k1.reenableKeyguard();
- //startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("content://contacts/people/")));
-
-
- finish();
- }
- });
-*/
-
-
-
- //PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
-
- // PowerManager.WakeLock w1 =pm.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP|PowerManager.FULL_WAKE_LOCK,"MyApp");
- // w1.acquire();
- // w1.release();
- }catch (Exception e) {
- // TODO: handle exception
- }
-
- }
- class StateListener extends PhoneStateListener{
- @Override
- public void onCallStateChanged(int state, String incomingNumber) {
-
- super.onCallStateChanged(state, incomingNumber);
- switch(state){
- case TelephonyManager.CALL_STATE_RINGING:
- break;
- case TelephonyManager.CALL_STATE_OFFHOOK:
- System.out.println("call Activity off hook");
- finish();
-
-
-
- break;
- case TelephonyManager.CALL_STATE_IDLE:
- break;
- }
- }
- };
- public void onSlideTouch( View view, MotionEvent event )
- {
- switch(event.getAction())
- {
- case MotionEvent.ACTION_DOWN:
- break;
- case MotionEvent.ACTION_MOVE:
- int x_cord = (int)event.getRawX();
- int y_cord = (int)event.getRawY();
-
- if(x_cord>windowwidth){x_cord=windowwidth;}
- if(y_cord>windowheight){y_cord=windowheight;}
-
- layoutParams.leftMargin = x_cord -25;
- layoutParams.topMargin = y_cord - 75;
-
- view.setLayoutParams(layoutParams);
- break;
- default:
- break;
-
-
-
-
- }
-
- //When the user pushes down on an ImageView
- /* if ( event.getAction() == MotionEvent.ACTION_DOWN )
- {
- inDragMode = true; //Set a variable so we know we started draggin the imageView
- //Set the selected ImageView X and Y exact position
- selectedImageViewX = Math.abs((int)event.getRawX()-((ImageView)view).getLeft());
- selectedImageViewY = Math.abs((int)event.getRawY()-((ImageView)view).getTop());
- //Bring the imageView in front
- ((ImageView)view).bringToFront();
- }
-
- //When the user let's the ImageView go (raises finger)
- if ( event.getAction() == MotionEvent.ACTION_UP )
- {
- inDragMode = false; //Reset the variable which let's us know we're not in drag mode anymore
- }
-
- //When the user keeps his finger on te screen and drags it (slides it)
- if ( event.getAction() == MotionEvent.ACTION_MOVE )
- {
- //If we've started draggin the imageView
- if ( inDragMode )
- {
- //Get the imageView object
- // ImageView slide = (ImageView)findViewById(R.id.slide);
- //Get a parameters object (THIS EXAMPLE IS FOR A RELATIVE LAYOUT)
- RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)view.getLayoutParams();
- //Change the position of the imageview accordingly
- params.setMargins((int)event.getRawX()-selectedImageViewX, (int)event.getRawY()-selectedImageViewY, 0, 0);
- //Set the new params
- view.setLayoutParams(params);
-
- //If we hit a limit with our imageView position
- /*if((int)event.getRawX())
- {
- //Open another activity
- Intent it = new Intent(Slide.this,NextActivity.class);
- startActivity(it);
- }
- }
- }*/
-
- }
-
- @Override
- public void onBackPressed() {
- // Don't allow back to dismiss.
- return;
- }
-
- //only used in lockdown mode
- @Override
- protected void onPause() {
- super.onPause();
-
- // Don't hang around.
- // finish();
- }
-
- @Override
- protected void onStop() {
- super.onStop();
-
- // Don't hang around.
- // finish();
- }
-
-
-
-
-
- @Override
- public boolean onKeyDown(int keyCode, android.view.KeyEvent event) {
-
- if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)||(keyCode == KeyEvent.KEYCODE_POWER)||(keyCode == KeyEvent.KEYCODE_VOLUME_UP)||(keyCode == KeyEvent.KEYCODE_CAMERA)) {
- //this is where I can do my stuff
- return true; //because I handled the event
- }
- if((keyCode == KeyEvent.KEYCODE_HOME)){
-
- return true;
- }
-
- return false;
-
- }
-
- public boolean dispatchKeyEvent(KeyEvent event) {
- if (event.getKeyCode() == KeyEvent.KEYCODE_POWER ||(event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN)||(event.getKeyCode() == KeyEvent.KEYCODE_POWER)) {
- //Intent i = new Intent(this, NewActivity.class);
- //startActivity(i);
- return false;
- }
- if((event.getKeyCode() == KeyEvent.KEYCODE_HOME)){
-
- System.out.println("alokkkkkkkkkkkkkkkkk");
- return true;
- }
- return false;
- }
-
- /*public void unloack(){
-
- finish();
-
- }*/
- public void onDestroy(){
- // k1.reenableKeyguard();
-
- super.onDestroy();
- }
-
-}
\ No newline at end of file
diff --git a/LockScreenApp/src/com/lockscreen/MyService.java b/LockScreenApp/src/com/lockscreen/MyService.java
deleted file mode 100644
index 2e69fc0..0000000
--- a/LockScreenApp/src/com/lockscreen/MyService.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package com.lockscreen;
-
-import receiver.lockScreenReeiver;
-import android.app.KeyguardManager;
-import android.app.Service;
-import android.content.BroadcastReceiver;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.Bundle;
-import android.os.IBinder;
-import android.telephony.PhoneStateListener;
-import android.telephony.TelephonyManager;
-import android.view.WindowManager;
-import android.widget.Toast;
-
-public class MyService extends Service{
- BroadcastReceiver mReceiver;
- // Intent myIntent;
- @Override
- public IBinder onBind(Intent intent) {
- // TODO Auto-generated method stub
- return null;
- }
-
-
-@Override
-public void onCreate() {
- KeyguardManager.KeyguardLock k1;
-
- //getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON|WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
-
- KeyguardManager km =(KeyguardManager)getSystemService(KEYGUARD_SERVICE);
- k1= km.newKeyguardLock("IN");
- k1.disableKeyguard();
-
-
-
-
- /*try{
- StateListener phoneStateListener = new StateListener();
- TelephonyManager telephonyManager =(TelephonyManager)getSystemService(TELEPHONY_SERVICE);
- telephonyManager.listen(phoneStateListener,PhoneStateListener.LISTEN_CALL_STATE);
- }catch(Exception e){
- System.out.println(e);
- }*/
-
- /* myIntent = new Intent(MyService.this,LockScreenAppActivity.class);
- myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- Bundle myKillerBundle = new Bundle();
- myKillerBundle.putInt("kill",1);
- myIntent.putExtras(myKillerBundle);*/
-
- IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
- filter.addAction(Intent.ACTION_SCREEN_OFF);
-
- mReceiver = new lockScreenReeiver();
- registerReceiver(mReceiver, filter);
-
-
- super.onCreate();
-
-
-}
-@Override
-public void onStart(Intent intent, int startId) {
- // TODO Auto-generated method stub
-
- super.onStart(intent, startId);
-}
-
-/*class StateListener extends PhoneStateListener{
- @Override
- public void onCallStateChanged(int state, String incomingNumber) {
-
- super.onCallStateChanged(state, incomingNumber);
- switch(state){
- case TelephonyManager.CALL_STATE_RINGING:
- break;
- case TelephonyManager.CALL_STATE_OFFHOOK:
- System.out.println("call Activity off hook");
- getApplication().startActivity(myIntent);
-
-
-
- break;
- case TelephonyManager.CALL_STATE_IDLE:
- break;
- }
- }
-};*/
-
-
-@Override
-public void onDestroy() {
- unregisterReceiver(mReceiver);
- super.onDestroy();
-}
-}
diff --git a/LockScreenApp/src/com/lockscreen/StartLockScreen.java b/LockScreenApp/src/com/lockscreen/StartLockScreen.java
deleted file mode 100644
index 2259e2c..0000000
--- a/LockScreenApp/src/com/lockscreen/StartLockScreen.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.lockscreen;
-
-import android.app.Activity;
-import android.app.KeyguardManager;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.WindowManager;
-
-public class StartLockScreen extends Activity {
-/* KeyguardManager.KeyguardLock k1;
-
- public void onAttachedToWindow() {
- // TODO Auto-generated method stub
- this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
- super.onAttachedToWindow();
- }*/
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- startService(new Intent(this,MyService.class));
- finish();
-
-
- /*getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON|WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
- KeyguardManager km =(KeyguardManager)getSystemService(KEYGUARD_SERVICE);
- k1 = km.newKeyguardLock("IN");
- k1.disableKeyguard();*/
-
-
- }
-
-}
diff --git a/LockScreenApp/src/com/mehuljoisar/lockscreen/LockScreenActivity.java b/LockScreenApp/src/com/mehuljoisar/lockscreen/LockScreenActivity.java
new file mode 100644
index 0000000..eef2c96
--- /dev/null
+++ b/LockScreenApp/src/com/mehuljoisar/lockscreen/LockScreenActivity.java
@@ -0,0 +1,194 @@
+package com.mehuljoisar.lockscreen;
+
+import android.app.Activity;
+import android.app.KeyguardManager;
+import android.content.Intent;
+import android.os.Bundle;
+import android.telephony.PhoneStateListener;
+import android.telephony.TelephonyManager;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.WindowManager;
+import android.view.WindowManager.LayoutParams;
+import android.widget.Button;
+
+import com.mehuljoisar.lockscreen.utils.LockscreenService;
+import com.mehuljoisar.lockscreen.utils.LockscreenUtils;
+
+public class LockScreenActivity extends Activity implements
+ LockscreenUtils.OnLockStatusChangedListener {
+
+ // User-interface
+ private Button btnUnlock;
+
+ // Member variables
+ private LockscreenUtils mLockscreenUtils;
+
+ // Set appropriate flags to make the screen appear over the keyguard
+ @Override
+ public void onAttachedToWindow() {
+ this.getWindow().setType(
+ WindowManager.LayoutParams.TYPE_KEYGUARD_DIALOG);
+ this.getWindow().addFlags(
+ WindowManager.LayoutParams.FLAG_FULLSCREEN
+ | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
+ | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
+ | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
+ );
+
+ super.onAttachedToWindow();
+ }
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.activity_lockscreen);
+
+ init();
+
+ // unlock screen in case of app get killed by system
+ if (getIntent() != null && getIntent().hasExtra("kill")
+ && getIntent().getExtras().getInt("kill") == 1) {
+ enableKeyguard();
+ unlockHomeButton();
+ } else {
+
+ try {
+ // disable keyguard
+ disableKeyguard();
+
+ // lock home button
+ lockHomeButton();
+
+ // start service for observing intents
+ startService(new Intent(this, LockscreenService.class));
+
+ // listen the events get fired during the call
+ StateListener phoneStateListener = new StateListener();
+ TelephonyManager telephonyManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
+ telephonyManager.listen(phoneStateListener,
+ PhoneStateListener.LISTEN_CALL_STATE);
+
+ } catch (Exception e) {
+ }
+
+ }
+ }
+
+ private void init() {
+ mLockscreenUtils = new LockscreenUtils();
+ btnUnlock = (Button) findViewById(R.id.btnUnlock);
+ btnUnlock.setOnClickListener(new View.OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ // unlock home button and then screen on button press
+ unlockHomeButton();
+ }
+ });
+ }
+
+ // Handle events of calls and unlock screen if necessary
+ private class StateListener extends PhoneStateListener {
+ @Override
+ public void onCallStateChanged(int state, String incomingNumber) {
+
+ super.onCallStateChanged(state, incomingNumber);
+ switch (state) {
+ case TelephonyManager.CALL_STATE_RINGING:
+ unlockHomeButton();
+ break;
+ case TelephonyManager.CALL_STATE_OFFHOOK:
+ break;
+ case TelephonyManager.CALL_STATE_IDLE:
+ break;
+ }
+ }
+ };
+
+ // Don't finish Activity on Back press
+ @Override
+ public void onBackPressed() {
+ return;
+ }
+
+ // Handle button clicks
+ @Override
+ public boolean onKeyDown(int keyCode, android.view.KeyEvent event) {
+
+ if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)
+ || (keyCode == KeyEvent.KEYCODE_POWER)
+ || (keyCode == KeyEvent.KEYCODE_VOLUME_UP)
+ || (keyCode == KeyEvent.KEYCODE_CAMERA)) {
+ return true;
+ }
+ if ((keyCode == KeyEvent.KEYCODE_HOME)) {
+
+ return true;
+ }
+
+ return false;
+
+ }
+
+ // handle the key press events here itself
+ public boolean dispatchKeyEvent(KeyEvent event) {
+ if (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_UP
+ || (event.getKeyCode() == KeyEvent.KEYCODE_VOLUME_DOWN)
+ || (event.getKeyCode() == KeyEvent.KEYCODE_POWER)) {
+ return false;
+ }
+ if ((event.getKeyCode() == KeyEvent.KEYCODE_HOME)) {
+
+ return true;
+ }
+ return false;
+ }
+
+ // Lock home button
+ public void lockHomeButton() {
+ mLockscreenUtils.lock(LockScreenActivity.this);
+ }
+
+ // Unlock home button and wait for its callback
+ public void unlockHomeButton() {
+ mLockscreenUtils.unlock();
+ }
+
+ // Simply unlock device when home button is successfully unlocked
+ @Override
+ public void onLockStatusChanged(boolean isLocked) {
+ if (!isLocked) {
+ unlockDevice();
+ }
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ unlockHomeButton();
+ }
+
+ @SuppressWarnings("deprecation")
+ private void disableKeyguard() {
+ KeyguardManager mKM = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
+ KeyguardManager.KeyguardLock mKL = mKM.newKeyguardLock("IN");
+ mKL.disableKeyguard();
+ }
+
+ @SuppressWarnings("deprecation")
+ private void enableKeyguard() {
+ KeyguardManager mKM = (KeyguardManager) getSystemService(KEYGUARD_SERVICE);
+ KeyguardManager.KeyguardLock mKL = mKM.newKeyguardLock("IN");
+ mKL.reenableKeyguard();
+ }
+
+ //Simply unlock device by finishing the activity
+ private void unlockDevice()
+ {
+ finish();
+ }
+
+}
\ No newline at end of file
diff --git a/LockScreenApp/src/com/mehuljoisar/lockscreen/utils/LockscreenIntentReceiver.java b/LockScreenApp/src/com/mehuljoisar/lockscreen/utils/LockscreenIntentReceiver.java
new file mode 100644
index 0000000..59346f4
--- /dev/null
+++ b/LockScreenApp/src/com/mehuljoisar/lockscreen/utils/LockscreenIntentReceiver.java
@@ -0,0 +1,30 @@
+package com.mehuljoisar.lockscreen.utils;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+import com.mehuljoisar.lockscreen.LockScreenActivity;
+
+public class LockscreenIntentReceiver extends BroadcastReceiver {
+
+ // Handle actions and display Lockscreen
+ @Override
+ public void onReceive(Context context, Intent intent) {
+
+ if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)
+ || intent.getAction().equals(Intent.ACTION_SCREEN_ON)
+ || intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) {
+ start_lockscreen(context);
+ }
+
+ }
+
+ // Display lock screen
+ private void start_lockscreen(Context context) {
+ Intent mIntent = new Intent(context, LockScreenActivity.class);
+ mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ context.startActivity(mIntent);
+ }
+
+}
diff --git a/LockScreenApp/src/com/mehuljoisar/lockscreen/utils/LockscreenService.java b/LockScreenApp/src/com/mehuljoisar/lockscreen/utils/LockscreenService.java
new file mode 100644
index 0000000..c319f2a
--- /dev/null
+++ b/LockScreenApp/src/com/mehuljoisar/lockscreen/utils/LockscreenService.java
@@ -0,0 +1,59 @@
+package com.mehuljoisar.lockscreen.utils;
+
+import android.app.Notification;
+import android.app.Service;
+import android.content.BroadcastReceiver;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.graphics.Bitmap;
+import android.os.IBinder;
+import android.provider.SyncStateContract.Constants;
+import android.support.v4.app.NotificationCompat;
+
+import com.mehuljoisar.lockscreen.R;
+
+public class LockscreenService extends Service {
+
+ private BroadcastReceiver mReceiver;
+
+ @Override
+ public IBinder onBind(Intent intent) {
+ return null;
+ }
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ }
+
+ // Register for Lockscreen event intents
+ @Override
+ public int onStartCommand(Intent intent, int flags, int startId) {
+ IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
+ filter.addAction(Intent.ACTION_SCREEN_OFF);
+ mReceiver = new LockscreenIntentReceiver();
+ registerReceiver(mReceiver, filter);
+ startForeground();
+ return START_STICKY;
+ }
+
+ // Run service in foreground so it is less likely to be killed by system
+ private void startForeground() {
+ Notification notification = new NotificationCompat.Builder(this)
+ .setContentTitle(getResources().getString(R.string.app_name))
+ .setTicker(getResources().getString(R.string.app_name))
+ .setContentText("Running")
+ .setSmallIcon(R.drawable.ic_launcher)
+ .setContentIntent(null)
+ .setOngoing(true)
+ .build();
+ startForeground(9999,notification);
+ }
+
+ // Unregister receiver
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ unregisterReceiver(mReceiver);
+ }
+}
diff --git a/LockScreenApp/src/com/mehuljoisar/lockscreen/utils/LockscreenUtils.java b/LockScreenApp/src/com/mehuljoisar/lockscreen/utils/LockscreenUtils.java
new file mode 100644
index 0000000..8e67ee5
--- /dev/null
+++ b/LockScreenApp/src/com/mehuljoisar/lockscreen/utils/LockscreenUtils.java
@@ -0,0 +1,85 @@
+package com.mehuljoisar.lockscreen.utils;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.KeyguardManager;
+import android.content.Context;
+import android.view.Gravity;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
+import android.view.WindowManager;
+import android.view.WindowManager.LayoutParams;
+
+import com.mehuljoisar.lockscreen.R;
+
+public class LockscreenUtils {
+
+ // Member variables
+ private OverlayDialog mOverlayDialog;
+ private OnLockStatusChangedListener mLockStatusChangedListener;
+
+ // Interface to communicate with owner activity
+ public interface OnLockStatusChangedListener
+ {
+ public void onLockStatusChanged(boolean isLocked);
+ }
+
+ // Reset the variables
+ public LockscreenUtils() {
+ reset();
+ }
+
+ // Display overlay dialog with a view to prevent home button click
+ public void lock(Activity activity) {
+ if (mOverlayDialog == null) {
+ mOverlayDialog = new OverlayDialog(activity);
+ mOverlayDialog.show();
+ mLockStatusChangedListener = (OnLockStatusChangedListener) activity;
+ }
+ }
+
+ // Reset variables
+ public void reset() {
+ if (mOverlayDialog != null) {
+ mOverlayDialog.dismiss();
+ mOverlayDialog = null;
+ }
+ }
+
+ // Unlock the home button and give callback to unlock the screen
+ public void unlock() {
+ if (mOverlayDialog != null) {
+ mOverlayDialog.dismiss();
+ mOverlayDialog = null;
+ if(mLockStatusChangedListener!=null)
+ {
+ mLockStatusChangedListener.onLockStatusChanged(false);
+ }
+ }
+ }
+
+ // Create overlay dialog for lockedscreen to disable hardware buttons
+ private static class OverlayDialog extends AlertDialog {
+
+ public OverlayDialog(Activity activity) {
+ super(activity, R.style.OverlayDialog);
+ WindowManager.LayoutParams params = getWindow().getAttributes();
+ params.type = LayoutParams.TYPE_SYSTEM_ERROR;
+ params.dimAmount = 0.0F;
+ params.width = 0;
+ params.height = 0;
+ params.gravity = Gravity.BOTTOM;
+ getWindow().setAttributes(params);
+ getWindow().setFlags(LayoutParams.FLAG_SHOW_WHEN_LOCKED | LayoutParams.FLAG_NOT_TOUCH_MODAL,
+ 0xffffff);
+ setOwnerActivity(activity);
+ setCancelable(false);
+ }
+
+ // consume touch events
+ public final boolean dispatchTouchEvent(MotionEvent motionevent) {
+ return true;
+ }
+
+ }
+}
diff --git a/LockScreenApp/src/receiver/lockScreenReeiver.java b/LockScreenApp/src/receiver/lockScreenReeiver.java
deleted file mode 100644
index 8eb1704..0000000
--- a/LockScreenApp/src/receiver/lockScreenReeiver.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package receiver;
-
-import android.app.KeyguardManager;
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-
-import android.widget.Toast;
-
-import com.lockscreen.LockScreenAppActivity;
-
-public class lockScreenReeiver extends BroadcastReceiver {
- public static boolean wasScreenOn = true;
-
- @Override
- public void onReceive(Context context, Intent intent) {
-
- //Toast.makeText(context, "" + "enterrrrrr", Toast.LENGTH_SHORT).show();
- if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
- //Toast.makeText(context, "" + "screeen off", Toast.LENGTH_SHORT).show();
-
- wasScreenOn=false;
- Intent intent11 = new Intent(context,LockScreenAppActivity.class);
- intent11.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-
- context.startActivity(intent11);
-
- // do whatever you need to do here
- //wasScreenOn = false;
- } else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
-
- wasScreenOn=true;
- Intent intent11 = new Intent(context,LockScreenAppActivity.class);
- intent11.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-
- //context.startActivity(intent11);
- //Toast.makeText(context, "" + "start activity", Toast.LENGTH_SHORT).show();
- // and do whatever you need to do here
- // wasScreenOn = true;
- }
- else if(intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED))
- {
- /* KeyguardManager.KeyguardLock k1;
- KeyguardManager km =(KeyguardManager)context.getSystemService(context.KEYGUARD_SERVICE);
- k1 = km.newKeyguardLock("IN");
- k1.disableKeyguard();
-*/
- Intent intent11 = new Intent(context, LockScreenAppActivity.class);
-
- intent11.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(intent11);
-
- // Intent intent = new Intent(context, LockPage.class);
- // context.startActivity(intent);
- // Intent serviceLauncher = new Intent(context, UpdateService.class);
- // context.startService(serviceLauncher);
- // Log.v("TEST", "Service loaded at start");
- }
-
- }
-
-
-}
diff --git a/README.md b/README.md
index 345e879..44f4869 100644
--- a/README.md
+++ b/README.md
@@ -2,30 +2,27 @@ LockScreenApp
=============
+Features:
+- Lockscreen over the screen
+- Hardware home button disabled
+- On-going notification to prevent app being killed by OS
It provides lockscreen in API 8 or above.
Initial
-
-
+
Locked
-
-
-
-Trying to unlock by dragging image
-
-
-
+
Unlocked
-
+