Skip to content

Commit

Permalink
程序锁
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyAF committed May 11, 2016
1 parent 5cb3975 commit 6674939
Show file tree
Hide file tree
Showing 26 changed files with 647 additions and 81 deletions.
1 change: 0 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ dependencies {
compile 'com.github.bumptech.glide:glide:3.5.2'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:cardview-v7:23.3.0'
compile 'me.imid.swipebacklayout.lib:library:1.0.0'
compile 'com.balysv:material-ripple:1.0.2'
compile 'de.greenrobot:greendao:1.3.7'
compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.GET_TASKS"/><!-- 获得正在运行的应用程序权限 -->
<uses-permission android:name="android.permission.SYSTEM_OVERLAY_WINDOW" />

<application
android:allowBackup="true"
Expand Down Expand Up @@ -42,6 +43,18 @@
<activity android:name=".util.image.SelectImageActivity"
android:theme="@style/EditTheme"/>

<!-- 开机启动 -->
<receiver android:name=".ProtectBC" android:enabled="true" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
<!-- 后台服务监视应用程序状态并保护 exported="true"表示可以导出服务 -->
<service
android:name=".service.ProgramProtectService"
android:exported="true">
</service>

</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import android.view.View;

import com.luckyaf.strongbox.R;
import com.luckyaf.strongbox.activity.base.BaseSwipeBackActivity;
import com.luckyaf.strongbox.activity.base.BaseActivity;
import com.luckyaf.strongbox.adapter.ProgramAdapter;
import com.luckyaf.strongbox.bean.MyProgram;

Expand All @@ -21,7 +21,7 @@
*
* @auhter Created by luckyAF on 16/4/27
*/
public class AddLockProgramActivity extends BaseSwipeBackActivity{
public class AddLockProgramActivity extends BaseActivity{
private Toolbar mToolbar;
private MenuItem menuItem;
private ArrayList<ResolveInfo> mApps = new ArrayList<>();
Expand Down Expand Up @@ -65,16 +65,17 @@ public void initListener(){

}

@Override
protected int getContentView() {
return R.layout.activity_add_lock_program;
}

@Override
protected void initToolbar() {

}

@Override
protected boolean isApplyTranslucency() {
return false;
}

@Override
public void onClick(View v) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import com.luckyaf.strongbox.MyApplication;
import com.luckyaf.strongbox.R;
import com.luckyaf.strongbox.activity.base.BaseSwipeBackActivity;
import com.luckyaf.strongbox.activity.base.BaseActivity;
import com.luckyaf.strongbox.util.ToastUtils;

import de.greenrobot.dao.query.Query;
Expand All @@ -27,7 +27,7 @@
*
* @auhter Created by luckyAF on 16/4/27
*/
public class EditContactActivity extends BaseSwipeBackActivity implements TextWatcher {
public class EditContactActivity extends BaseActivity implements TextWatcher {

private Toolbar mToolbar;
private Button deleteButton;
Expand Down Expand Up @@ -114,16 +114,17 @@ public void View2Data() {

}

@Override
protected int getContentView() {
return R.layout.activity_edit_contact;
}

@Override
protected void initToolbar() {

}

@Override
protected boolean isApplyTranslucency() {
return false;
}

@Override
public void onClick(View v) {
switch (v.getId()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import com.luckyaf.strongbox.MyApplication;
import com.luckyaf.strongbox.R;
import com.luckyaf.strongbox.activity.base.BaseSwipeBackActivity;
import com.luckyaf.strongbox.activity.base.BaseActivity;
import com.luckyaf.strongbox.util.DateUtils;
import com.luckyaf.strongbox.util.ToastUtils;

Expand All @@ -28,7 +28,7 @@
*
* @auhter Created by luckyAF on 16/4/10
*/
public class EditDiaryActivity extends BaseSwipeBackActivity implements TextWatcher {
public class EditDiaryActivity extends BaseActivity implements TextWatcher {
private Toolbar mToolbar;
private MenuItem itemDone;
private MenuItem itemDelete;
Expand All @@ -44,7 +44,7 @@ public class EditDiaryActivity extends BaseSwipeBackActivity implements TextWatc
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getContentView());
setContentView(R.layout.activity_edit_diary);
initWidget();
initData();
initListener();
Expand All @@ -57,6 +57,11 @@ protected void initToolbar() {

}

@Override
protected boolean isApplyTranslucency() {
return false;
}

public void initWidget(){
mToolbar = (Toolbar)findViewById(R.id.toolbar_edit);
initToolBar(mToolbar);
Expand Down Expand Up @@ -126,11 +131,6 @@ public void onClick(View v) {
}


@Override
protected int getContentView() {
return R.layout.activity_edit_diary;
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_edit_diary, menu);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import com.luckyaf.strongbox.MyApplication;
import com.luckyaf.strongbox.R;
import com.luckyaf.strongbox.activity.base.BaseSwipeBackActivity;
import com.luckyaf.strongbox.activity.base.BaseActivity;
import com.luckyaf.strongbox.util.DateUtils;
import com.luckyaf.strongbox.util.ToastUtils;

Expand All @@ -33,7 +33,7 @@
*
* @auhter Created by luckyAF on 16/3/30
*/
public class EditPassWordActivity extends BaseSwipeBackActivity implements TextWatcher{
public class EditPassWordActivity extends BaseActivity implements TextWatcher{
private Toolbar mToolbar;
private Button deleteButton;
private ImageButton changeButton;
Expand All @@ -60,17 +60,17 @@ protected void onCreate(Bundle savedInstanceState) {
initListener();
}

@Override
protected int getContentView() {
return R.layout.activity_edit_password;
}


@Override
protected void initToolbar() {

}

@Override
protected boolean isApplyTranslucency() {
return false;
}

public void initWidget() {
mToolbar = (Toolbar)findViewById(R.id.toolbar_edit);
initToolBar(mToolbar);
Expand Down
36 changes: 24 additions & 12 deletions app/src/main/java/com/luckyaf/strongbox/activity/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.luckyaf.strongbox.activity;

import android.content.Intent;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
Expand Down Expand Up @@ -133,52 +134,63 @@ public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
String title = getString(R.string.app_name);;
String title = getString(R.string.app_name);
Boolean isChanged = false;
Bundle bundle = new Bundle();
switch (item.getItemId()){
case R.id.nav_index:
_currentFragment = IndexFragment.newInstance(bundle);
title = getString(R.string.menu_index);
isChanged = true;
break;
case R.id.nav_file:
_currentFragment = FileMainFragment.newInstance(bundle);
title = getString(R.string.menu_file);
isChanged = true;
break;
case R.id.nav_program:
_currentFragment = ProgramFragment.newInstance(bundle);
title = getString(R.string.menu_program);
isChanged = true;
break;
case R.id.nav_contact:
_currentFragment = ContactFragment.newInstance(bundle);
title = getString(R.string.menu_contact);
isChanged = true;
break;
case R.id.nav_diary:
_currentFragment = DiaryFragment.newInstance(bundle);
title = getString(R.string.menu_diary);
isChanged = true;
break;
case R.id.nav_code_book:
_currentFragment = CodeBookFragment.newInstance(bundle);
title = getString(R.string.menu_code_books);
isChanged = true;
break;
case R.id.nav_settings:
_currentFragment = SettingsFragment.newInstance(bundle);
title = getString(R.string.menu_settings);
//_currentFragment = SettingsFragment.newInstance(bundle);
//title = getString(R.string.menu_settings);
Intent intent = new Intent(this,SettingsActivity.class);
startActivity(intent);
break;
default:
_currentFragment = _lastFragment;
break;
}


if(!_currentFragment.isAdded()){
fragmentTransaction.hide(_lastFragment).add(R.id.frame_main,_currentFragment).commit();
}else{
fragmentTransaction.hide(_lastFragment).show(_currentFragment).commit();
if(isChanged){
if(!_currentFragment.isAdded()){
fragmentTransaction.hide(_lastFragment).add(R.id.frame_main,_currentFragment).commit();
}else{
fragmentTransaction.hide(_lastFragment).show(_currentFragment).commit();
}
_lastFragment = _currentFragment;
_mToolbar.setTitle(title);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
}
_lastFragment = _currentFragment;
_mToolbar.setTitle(title);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);

return true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.luckyaf.strongbox.activity;

import android.view.View;

import com.luckyaf.strongbox.activity.base.BaseActivity;

/**
* 类描述:
*
* @auhter Created by luckyAF on 16/5/11
*/
public class SettingsActivity extends BaseActivity {

@Override
protected void initToolbar() {

}

@Override
protected boolean isApplyTranslucency() {
return false;
}

@Override
public void onClick(View v) {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ public void onEqualsClick(View view){
VibrateUtils.vShort(mContext);
calculator();
dealResult();
input = "";
}

public void dealResult(){
Expand Down Expand Up @@ -212,25 +211,22 @@ public void calculator(){
String text = input;
if (text.equals(result)) {
//clearWithHistory(false); //clear after an Enter on result
input = result;
result = "";
setInput(input);
setResult(result);
} else {
// mHistory.enter(text);
try {
result = evaluate(text);
} catch (SyntaxException e) {
isError = true;

result = mErrorString;
}
if (text.equals(result)) {
//no need to show result, it is exactly what the user entered
// clearWithHistory(true);
} else {
//setText(mResult);
//mEqualButton.setText(mEnterString);
}
if(isError){
setError(isError);
setResult(result);
input="";
}else{
input = result;
result = "";
Expand All @@ -239,6 +235,7 @@ public void calculator(){
}

}
//input = "";

}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.luckyaf.strongbox.fragment.settings;

import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;

/**
* 类描述:
*
* @auhter Created by luckyAF on 16/5/11
*/
public class BaseSettingsFragment extends PreferenceFragment {
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {

return super.onPreferenceTreeClick(preferenceScreen,preference);
}
}
Loading

0 comments on commit 6674939

Please sign in to comment.