// Path: app/src/main/java/me/wavever/ganklock/MyApplication.java
// public class MyApplication extends Application{
// 
//     private static Context context;
// 
//     private static PreferenceUtil sp;
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
//         context = getApplicationContext();
//         if (PreferenceUtil.getBoolean(Config.GANK_LOCK_IS_OPEN)) {
//             context.startService(new Intent(context, LockService.class));
//         }
//     }
// 
//     /**
//      * 获得一个全局的Context对象
//      */
//     public static Context getContext() {
//         return context;
//     }
// }
// 
// Path: app/src/main/java/me/wavever/ganklock/ui/activity/LockActivity.java
// public class LockActivity extends BaseMvpActivity<ILockView,LockPresenter> implements ILockView,SwipeUnLockLayout.OnSwipeListener {
// 
//     private static final String TAG = "LockActivity-->";
// 
//     private ViewSwitcher mViewSwitcher;
//     private ImageView mImg;
//     private TextView mTitle;
//     private Bitmap bitmap;
//     private String url;
// 
//     @Override protected int loadView() {
//         return R.layout.activity_lock;
//     }
// 
//     @Override protected void initView() {
//         getWindow().addFlags(LayoutParams.FLAG_DISMISS_KEYGUARD);
//         getWindow().addFlags(LayoutParams.FLAG_SHOW_WHEN_LOCKED);
//         setUI();
//         SwipeUnLockLayout swipeUnLockLayout = (SwipeUnLockLayout) findViewById(
//             R.id.slide_layout);
//         swipeUnLockLayout.setOnSwipeListener(this);
//         mViewSwitcher = (ViewSwitcher) findViewById(R.id.lock_view_switcher);
//         mTitle = (TextView) findViewById(R.id.lock_view_gank_title);
//         TextView mLockViewDate = (TextView) findViewById(R.id.lock_view_date);
//         final String lockDateText = DateUtil.getLockDateText();
//         mLockViewDate.setText(lockDateText);
//         mImg = (ImageView) findViewById(R.id.lock_view_img);
//         url = PreferenceUtil.getString("url");
//         if (url.isEmpty()) {
//             mImg.setImageResource(R.drawable.test_image);
//         } else {
//            getBitmap();
//         }
//         mImg.setOnClickListener(new View.OnClickListener() {
//             @Override public void onClick(View v) {
//                 mViewSwitcher.showNext();
//             }
//         });
// 
//     }
// 
//     private void setUI() {
//         Window window = getWindow();
//         window.getDecorView().setSystemUiVisibility(
//             View.SYSTEM_UI_FLAG_LAYOUT_STABLE
//                 | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
//                 | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
//                 | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
//                 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
//         );
//         if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
//             window.addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS);
//         }
//         if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
//             window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//             //这个属性重复设置会导致NAVIGATION BAR显示
//             //window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
//             window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
//             window.setStatusBarColor(0);
//         }
//     }
// 
//     @Override public void onSwipeFinish() {
//         finish();
//     }
// 
//     @Override public LockPresenter createPresenter() {
//         return new LockPresenter();
//     }
// 
//     @Override
//     public void onWindowFocusChanged(boolean hasFocus) {
//         super.onWindowFocusChanged(hasFocus);
//         if (hasFocus) {
//             setUI();
//         }
//     }
// 
//     private void getBitmap(){
// 
//         Observable.create(new ObservableOnSubscribe<Bitmap>() {
//             @Override
//             public void subscribe(ObservableEmitter<Bitmap> emitter) throws Exception {
//                 try {
//                     bitmap = Picasso.with(LockActivity.this).load(url).get();
//                     emitter.onNext(bitmap);
//                 } catch (IOException e) {
//                     e.printStackTrace();
//                 }
//             }
//         }).subscribeOn(Schedulers.io())
//                 .observeOn(AndroidSchedulers.mainThread())
//                 .subscribe(new Consumer<Bitmap>() {
//                     @Override
//                     public void accept(Bitmap bitmap) throws Exception {
//                         mImg.setImageBitmap(bitmap);
//                     }
//                 });
// 
//     }
// }


import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
import me.wavever.ganklock.MyApplication;
import me.wavever.ganklock.ui.activity.LockActivity;
package me.wavever.ganklock.receiver;


/**
 * Created by wavever on 2015/12/24.
 */
public class GankLockReceiver extends BroadcastReceiver {

    private static final String TAG = GankLockReceiver.class.getSimpleName();


    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        /*if (action.equals(Intent.ACTION_SCREEN_ON)) {
            LockManager.createLockView();
            onPhoneRing();
        }*/
        if (action.equals(Intent.ACTION_SCREEN_OFF)) {
// Path: app/src/main/java/me/wavever/ganklock/MyApplication.java
// public class MyApplication extends Application{
// 
//     private static Context context;
// 
//     private static PreferenceUtil sp;
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
//         context = getApplicationContext();
//         if (PreferenceUtil.getBoolean(Config.GANK_LOCK_IS_OPEN)) {
//             context.startService(new Intent(context, LockService.class));
//         }
//     }
// 
//     /**
//      * 获得一个全局的Context对象
//      */
//     public static Context getContext() {
//         return context;
//     }
// }
// 
// Path: app/src/main/java/me/wavever/ganklock/ui/activity/LockActivity.java
// public class LockActivity extends BaseMvpActivity<ILockView,LockPresenter> implements ILockView,SwipeUnLockLayout.OnSwipeListener {
// 
//     private static final String TAG = "LockActivity-->";
// 
//     private ViewSwitcher mViewSwitcher;
//     private ImageView mImg;
//     private TextView mTitle;
//     private Bitmap bitmap;
//     private String url;
// 
//     @Override protected int loadView() {
//         return R.layout.activity_lock;
//     }
// 
//     @Override protected void initView() {
//         getWindow().addFlags(LayoutParams.FLAG_DISMISS_KEYGUARD);
//         getWindow().addFlags(LayoutParams.FLAG_SHOW_WHEN_LOCKED);
//         setUI();
//         SwipeUnLockLayout swipeUnLockLayout = (SwipeUnLockLayout) findViewById(
//             R.id.slide_layout);
//         swipeUnLockLayout.setOnSwipeListener(this);
//         mViewSwitcher = (ViewSwitcher) findViewById(R.id.lock_view_switcher);
//         mTitle = (TextView) findViewById(R.id.lock_view_gank_title);
//         TextView mLockViewDate = (TextView) findViewById(R.id.lock_view_date);
//         final String lockDateText = DateUtil.getLockDateText();
//         mLockViewDate.setText(lockDateText);
//         mImg = (ImageView) findViewById(R.id.lock_view_img);
//         url = PreferenceUtil.getString("url");
//         if (url.isEmpty()) {
//             mImg.setImageResource(R.drawable.test_image);
//         } else {
//            getBitmap();
//         }
//         mImg.setOnClickListener(new View.OnClickListener() {
//             @Override public void onClick(View v) {
//                 mViewSwitcher.showNext();
//             }
//         });
// 
//     }
// 
//     private void setUI() {
//         Window window = getWindow();
//         window.getDecorView().setSystemUiVisibility(
//             View.SYSTEM_UI_FLAG_LAYOUT_STABLE
//                 | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
//                 | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
//                 | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
//                 | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
//         );
//         if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
//             window.addFlags(LayoutParams.FLAG_TRANSLUCENT_STATUS);
//         }
//         if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
//             window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//             //这个属性重复设置会导致NAVIGATION BAR显示
//             //window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
//             window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
//             window.setStatusBarColor(0);
//         }
//     }
// 
//     @Override public void onSwipeFinish() {
//         finish();
//     }
// 
//     @Override public LockPresenter createPresenter() {
//         return new LockPresenter();
//     }
// 
//     @Override
//     public void onWindowFocusChanged(boolean hasFocus) {
//         super.onWindowFocusChanged(hasFocus);
//         if (hasFocus) {
//             setUI();
//         }
//     }
// 
//     private void getBitmap(){
// 
//         Observable.create(new ObservableOnSubscribe<Bitmap>() {
//             @Override
//             public void subscribe(ObservableEmitter<Bitmap> emitter) throws Exception {
//                 try {
//                     bitmap = Picasso.with(LockActivity.this).load(url).get();
//                     emitter.onNext(bitmap);
//                 } catch (IOException e) {
//                     e.printStackTrace();
//                 }
//             }
//         }).subscribeOn(Schedulers.io())
//                 .observeOn(AndroidSchedulers.mainThread())
//                 .subscribe(new Consumer<Bitmap>() {
//                     @Override
//                     public void accept(Bitmap bitmap) throws Exception {
//                         mImg.setImageBitmap(bitmap);
//                     }
//                 });
// 
//     }
// }


// Path: app/src/main/java/me/wavever/ganklock/receiver/GankLockReceiver.java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
import me.wavever.ganklock.MyApplication;
import me.wavever.ganklock.ui.activity.LockActivity;

package me.wavever.ganklock.receiver;


/**
 * Created by wavever on 2015/12/24.
 */
public class GankLockReceiver extends BroadcastReceiver {

    private static final String TAG = GankLockReceiver.class.getSimpleName();


    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        /*if (action.equals(Intent.ACTION_SCREEN_ON)) {
            LockManager.createLockView();
            onPhoneRing();
        }*/
        if (action.equals(Intent.ACTION_SCREEN_OFF)) {
            Intent mLockIntent = new Intent(context, LockActivity.class);