Android Open Source - GestureLock Main Activity






From Project

Back to project page GestureLock.

License

The source code is released under:

Apache License

If you think the Android project GestureLock 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 com.gusturelock;
/*from  w  w  w  .j av a  2 s  .c  o  m*/
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;

/*
 * Author: Ruils ?????????????? 
 * Blog: http://blog.csdn.net/ruils
 * QQ: 5452781
 * Email: 5452781@qq.com
 */

public class MainActivity extends Activity implements OnClickListener {
    // 12-01 18:26:09.907: I/ActivityManager(519): Displayed
    // com.android.settings/.ChooseLockPattern: +236ms
    // 12-01 19:35:14.870: I/ActivityManager(519): Displayed
    // com.android.settings/.ConfirmLockPattern: +366ms (total +439ms)

    private static final String TAG = "MainActivity";

    public static final String LOCK = "lock";
    public static final String LOCK_KEY = "lock_key";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        SharedPreferences preferences = getSharedPreferences(LOCK, MODE_PRIVATE);

        String lockPattenString = preferences.getString(LOCK_KEY, null);

        if (lockPattenString != null) {
            Intent intent = new Intent(this, LockActivity.class);
            startActivity(intent);

        }

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.lock:
            Intent intent = new Intent(this, LockSetupActivity.class);
            startActivity(intent);
            break;
        case R.id.unlock:
            getSharedPreferences(LOCK, MODE_PRIVATE).edit().clear().commit();
            break;

        default:
            break;
        }

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}




Java Source Code List

com.gusturelock.LockActivity.java
com.gusturelock.LockPatternView.java
com.gusturelock.LockSetupActivity.java
com.gusturelock.MainActivity.java