├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml └── runConfigurations.xml ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro ├── src │ ├── androidTest │ │ └── java │ │ │ └── com │ │ │ └── sscience │ │ │ └── stopapp │ │ │ └── ExampleInstrumentedTest.java │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── sscience │ │ │ │ └── stopapp │ │ │ │ ├── AppInfoApplication.java │ │ │ │ ├── activity │ │ │ │ ├── AboutActivity.java │ │ │ │ ├── AppListActivity.java │ │ │ │ ├── ComponentDetailsActivity.java │ │ │ │ ├── MainActivity.java │ │ │ │ ├── SettingActivity.java │ │ │ │ └── ShortcutActivity.java │ │ │ │ ├── adapter │ │ │ │ ├── AboutAdapter.java │ │ │ │ ├── AppAdapter.java │ │ │ │ ├── AppListAdapter.java │ │ │ │ ├── AppListPagerAdapter.java │ │ │ │ ├── ComponentDetailsAdapter.java │ │ │ │ ├── ComponentPagerAdapter.java │ │ │ │ └── DisableAppAdapter.java │ │ │ │ ├── base │ │ │ │ ├── BaseActivity.java │ │ │ │ ├── BaseFragment.java │ │ │ │ ├── BasePresenter.java │ │ │ │ └── BaseView.java │ │ │ │ ├── bean │ │ │ │ ├── AppInfo.java │ │ │ │ └── ComponentInfo.java │ │ │ │ ├── database │ │ │ │ ├── AppInfoDBController.java │ │ │ │ └── AppInfoDBOpenHelper.java │ │ │ │ ├── fragment │ │ │ │ ├── AppListFragment.java │ │ │ │ ├── ComponentDetailsFragment.java │ │ │ │ └── MainFragment.java │ │ │ │ ├── model │ │ │ │ ├── AppsRepository.java │ │ │ │ ├── GetAppsCallback.java │ │ │ │ ├── GetComponentCallback.java │ │ │ │ └── GetRootCallback.java │ │ │ │ ├── presenter │ │ │ │ ├── AppsContract.java │ │ │ │ ├── AppsPresenter.java │ │ │ │ ├── ComponentDetailsContract.java │ │ │ │ ├── ComponentDetailsPresenter.java │ │ │ │ ├── DisableAppsContract.java │ │ │ │ └── DisableAppsPresenter.java │ │ │ │ ├── service │ │ │ │ ├── MyAccessibilityService.java │ │ │ │ └── RootActionIntentService.java │ │ │ │ ├── util │ │ │ │ ├── BackgroundWorker.java │ │ │ │ ├── CommonUtil.java │ │ │ │ ├── DiffCallBack.java │ │ │ │ ├── ImageUtil.java │ │ │ │ ├── SharedPreferenceUtil.java │ │ │ │ ├── ShortcutsManager.java │ │ │ │ └── WeakHandler.java │ │ │ │ └── widget │ │ │ │ ├── AppInfoComparator.java │ │ │ │ ├── ComponentComparator.java │ │ │ │ ├── DragSelectTouchListener.java │ │ │ │ ├── MoveFloatingActionButton.java │ │ │ │ └── ScrollAwareFABBehavior.java │ │ └── res │ │ │ ├── drawable-hdpi │ │ │ ├── about_logo.png │ │ │ ├── app_logo_splash.png │ │ │ ├── ic_action_search.png │ │ │ ├── ic_android.png │ │ │ ├── ic_disable_app.png │ │ │ ├── ic_enable_app.png │ │ │ ├── ic_gray_add.png │ │ │ ├── ic_shortcut_add.png │ │ │ ├── ic_white_fab_confirm.png │ │ │ ├── ic_white_fab_disable.png │ │ │ ├── ic_white_fab_enable.png │ │ │ ├── ic_white_fab_share.png │ │ │ └── no_data.png │ │ │ ├── drawable-xhdpi │ │ │ ├── about_logo.png │ │ │ ├── app_logo_splash.png │ │ │ ├── ic_action_search.png │ │ │ ├── ic_disable_app.png │ │ │ ├── ic_enable_app.png │ │ │ ├── ic_gray_add.png │ │ │ ├── ic_shortcut_add.png │ │ │ ├── ic_white_fab_confirm.png │ │ │ ├── ic_white_fab_disable.png │ │ │ ├── ic_white_fab_enable.png │ │ │ ├── ic_white_fab_share.png │ │ │ └── no_data.png │ │ │ ├── drawable-xxhdpi │ │ │ ├── about_logo.png │ │ │ ├── app_logo_splash.png │ │ │ ├── ic_action_search.png │ │ │ ├── ic_color_lens_black.png │ │ │ ├── ic_content_copy_black.png │ │ │ ├── ic_delete_black.png │ │ │ ├── ic_disable_app.png │ │ │ ├── ic_enable_app.png │ │ │ ├── ic_format_indent_decrease_black.png │ │ │ ├── ic_gray_add.png │ │ │ ├── ic_highlight_off_black.png │ │ │ ├── ic_open_in_new_black.png │ │ │ ├── ic_play_circle_outline_black.png │ │ │ ├── ic_playlist_play_black.png │ │ │ ├── ic_shortcut_add.png │ │ │ ├── ic_white_fab_confirm.png │ │ │ ├── ic_white_fab_disable.png │ │ │ ├── ic_white_fab_enable.png │ │ │ ├── ic_white_fab_share.png │ │ │ ├── no_data.png │ │ │ └── shadow.xml │ │ │ ├── drawable-xxxhdpi │ │ │ ├── about_logo.png │ │ │ ├── app_logo_splash.png │ │ │ ├── ic_action_search.png │ │ │ ├── ic_disable_app.png │ │ │ ├── ic_enable_app.png │ │ │ ├── ic_gray_add.png │ │ │ ├── ic_shortcut_add.png │ │ │ ├── ic_white_fab_confirm.png │ │ │ ├── ic_white_fab_disable.png │ │ │ ├── ic_white_fab_enable.png │ │ │ ├── ic_white_fab_share.png │ │ │ └── no_data.png │ │ │ ├── drawable │ │ │ ├── layout_divider.xml │ │ │ ├── share_logo.png │ │ │ └── splash_screen.xml │ │ │ ├── layout │ │ │ ├── activity_about.xml │ │ │ ├── activity_app_list.xml │ │ │ ├── activity_component_details.xml │ │ │ ├── activity_main.xml │ │ │ ├── activity_setting.xml │ │ │ ├── app_bar_main.xml │ │ │ ├── dialog_edit_app_name.xml │ │ │ ├── fragment_app_list.xml │ │ │ ├── fragment_main.xml │ │ │ ├── item_about.xml │ │ │ ├── item_app.xml │ │ │ ├── item_component_details.xml │ │ │ ├── item_disable.xml │ │ │ ├── select_launcher_icon.xml │ │ │ └── view_empty.xml │ │ │ ├── menu │ │ │ ├── menu_main.xml │ │ │ └── menu_search.xml │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_square.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_square.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_android.png │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_square.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_android.png │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_square.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_android.png │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_square.png │ │ │ ├── values-en │ │ │ └── strings.xml │ │ │ ├── values-w820dp │ │ │ └── dimens.xml │ │ │ ├── values │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── strings.xml │ │ │ └── styles.xml │ │ │ ├── xml-v25 │ │ │ └── shortcuts.xml │ │ │ └── xml │ │ │ └── accessibility_service_config.xml │ └── test │ │ └── java │ │ └── com │ │ └── sscience │ │ └── stopapp │ │ └── ExampleUnitTest.java ├── stopapp_release_3_v1.1.1_20170316121413.apk ├── stopapp_release_5_v1.2.1_20170406105104.apk └── stopapp_release_6_v1.3_20170427191236.apk ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── screenshot ├── Screenshot_20170214-180852.png ├── Screenshot_20170316-120548.png └── Screenshot_20170427-190046.png └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # StopApp 2 | stop apps when you do not need to use or rarely used 3 | 4 | Screenshot 5 | ------------------------- 6 | ![image](https://github.com/XYScience/StopApp/raw/master/screenshot/Screenshot_20170214-180852.png) 7 | ![image](https://github.com/XYScience/StopApp/raw/master/screenshot/Screenshot_20170316-120548.png) 8 | ![image](https://github.com/XYScience/StopApp/raw/master/screenshot/Screenshot_20170427-190046.png) 9 | 10 | License 11 | ------------------------- 12 | StopApp is released under the [Apache 2.0 license](https://github.com/XYScience/StopApp/blob/master/LICENSE). 13 | 14 | ``` 15 | Copyright 2017 SScience 16 | 17 | Licensed under the Apache License, Version 2.0 (the "License"); 18 | you may not use this file except in compliance with the License. 19 | You may obtain a copy of the License at 20 | 21 | http://www.apache.org/licenses/LICENSE-2.0 22 | 23 | Unless required by applicable law or agreed to in writing, software 24 | distributed under the License is distributed on an "AS IS" BASIS, 25 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | See the License for the specific language governing permissions and 27 | limitations under the License. 28 | ``` 29 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "25.0.2" 6 | defaultConfig { 7 | applicationId "com.sscience.stopapp" 8 | minSdkVersion 21 9 | targetSdkVersion 25 10 | versionCode 6 11 | versionName "1.3" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | applicationVariants.all { variant -> 21 | variant.outputs.each { output -> 22 | def outputFile = output.outputFile 23 | if (outputFile != null && outputFile.name.endsWith('.apk')) { 24 | if ("release".equals(buildType.name)) { 25 | // apk_渠道名-版本号-版本名称-编译时间.apk 26 | def fileName = "stopapp_release_${defaultConfig.versionCode}_v${defaultConfig.versionName}_${releaseTime()}.apk" 27 | output.outputFile = new File(outputFile.parent, fileName) 28 | } 29 | } 30 | } 31 | } 32 | } 33 | 34 | def releaseTime() { 35 | return new Date().format("yyyyMMddHHmmss") 36 | } 37 | 38 | dependencies { 39 | compile fileTree(include: ['*.jar'], dir: 'libs') 40 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 41 | exclude group: 'com.android.support', module: 'support-annotations' 42 | }) 43 | testCompile 'junit:junit:4.12' 44 | compile 'com.google.android:flexbox:0.2.6' 45 | compile 'com.github.XYScience:MyLogger:0.1.1' 46 | compile 'com.github.XYScience:BaseRecyclerViewAdapter:1.1.2' 47 | } 48 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in D:\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/sscience/stopapp/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.sscience.stopapp", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 16 | 21 | 22 | 23 | 24 | 27 | 28 | 29 | 37 | 43 | 44 | 45 | 46 | 47 | 50 | 51 | 52 | 58 | 59 | 60 | 61 | 62 | 65 | 66 | 67 | 71 | 72 | 76 | 77 | 81 | 82 | 86 | 87 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 105 | 106 | 110 | 111 | 112 | 113 | 114 | 115 | 118 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/AppInfoApplication.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | 6 | import com.science.myloggerlibrary.MyLogger; 7 | 8 | /** 9 | * @author SScience 10 | * @description 11 | * @email chentushen.science@gmail.com 12 | * @data 2017/3/6 13 | */ 14 | public class AppInfoApplication extends Application { 15 | 16 | public static Context CONTEXT; 17 | 18 | @Override 19 | public void onCreate() { 20 | super.onCreate(); 21 | CONTEXT = this; 22 | MyLogger.IS_DEBUG = true; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/activity/AboutActivity.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.activity; 2 | 3 | import android.content.Context; 4 | import android.content.DialogInterface; 5 | import android.content.Intent; 6 | import android.net.Uri; 7 | import android.os.Bundle; 8 | import android.support.annotation.Nullable; 9 | import android.support.design.widget.AppBarLayout; 10 | import android.support.design.widget.FloatingActionButton; 11 | import android.support.v4.view.ViewCompat; 12 | import android.support.v7.app.AlertDialog; 13 | import android.support.v7.widget.DividerItemDecoration; 14 | import android.support.v7.widget.LinearLayoutManager; 15 | import android.support.v7.widget.RecyclerView; 16 | import android.view.View; 17 | import android.widget.TextView; 18 | 19 | import com.science.baserecyclerviewadapter.interfaces.OnItemClickListener; 20 | import com.sscience.stopapp.R; 21 | import com.sscience.stopapp.adapter.AboutAdapter; 22 | import com.sscience.stopapp.base.BaseActivity; 23 | import com.sscience.stopapp.util.CommonUtil; 24 | 25 | import java.util.ArrayList; 26 | import java.util.HashMap; 27 | import java.util.List; 28 | import java.util.Map; 29 | 30 | import static com.sscience.stopapp.R.id.recyclerView; 31 | 32 | /** 33 | * @author SScience 34 | * @description 35 | * @email chentushen.science@gmail.com 36 | * @data 2017/2/6 37 | */ 38 | 39 | public class AboutActivity extends BaseActivity { 40 | 41 | private RecyclerView mRecyclerView; 42 | private AboutAdapter mAboutAdapter; 43 | 44 | public static void actionStartActivity(Context context) { 45 | Intent intent = new Intent(context, AboutActivity.class); 46 | context.startActivity(intent); 47 | } 48 | 49 | @Override 50 | protected int getContentLayout() { 51 | getWindow().setStatusBarColor(getResources().getColor(android.R.color.transparent)); 52 | return R.layout.activity_about; 53 | } 54 | 55 | @Override 56 | protected void doOnCreate(@Nullable Bundle savedInstanceState) { 57 | setToolbar(""); 58 | 59 | TextView tvVersion = (TextView) findViewById(R.id.tv_version); 60 | tvVersion.setText(getString(R.string.version, CommonUtil.getAppVersion(this))); 61 | 62 | mRecyclerView = (RecyclerView) findViewById(recyclerView); 63 | mRecyclerView.setHasFixedSize(true); 64 | LinearLayoutManager manager = new LinearLayoutManager(this); 65 | mRecyclerView.setLayoutManager(manager); 66 | mRecyclerView.addItemDecoration(new DividerItemDecoration(this, manager.getOrientation())); 67 | mAboutAdapter = new AboutAdapter(this, mRecyclerView); 68 | mRecyclerView.setAdapter(mAboutAdapter); 69 | 70 | List> aboutList = new ArrayList<>(); 71 | Map map1 = new HashMap<>(); 72 | map1.put("title", getString(R.string.about_app)); 73 | map1.put("subtitle", getString(R.string.about_app_detail)); 74 | aboutList.add(map1); 75 | Map map2 = new HashMap<>(); 76 | map2.put("title", getString(R.string.source_code_address)); 77 | map2.put("subtitle", getString(R.string.source_code_address_detail)); 78 | aboutList.add(map2); 79 | Map map3 = new HashMap<>(); 80 | map3.put("title", getString(R.string.report_issues)); 81 | map3.put("subtitle", getString(R.string.report_issues_detail)); 82 | aboutList.add(map3); 83 | Map map4 = new HashMap<>(); 84 | map4.put("title", getString(R.string.feedback_suggestions)); 85 | map4.put("subtitle", getString(R.string.feedback_suggestions_detail)); 86 | aboutList.add(map4); 87 | mAboutAdapter.setData(false, aboutList); 88 | 89 | initListener(); 90 | } 91 | 92 | private void initListener() { 93 | AppBarLayout appBarLayout = (AppBarLayout) findViewById(R.id.appbar_layout); 94 | final TextView toolbarTitle = (TextView) findViewById(R.id.toolbar_title); 95 | appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() { 96 | @Override 97 | public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { 98 | int maxScroll = appBarLayout.getTotalScrollRange() - (int) getResources().getDimension(R.dimen.abc_action_bar_default_height_material); 99 | float percentage = (float) Math.abs(verticalOffset) / (float) maxScroll; 100 | ViewCompat.setAlpha(toolbarTitle, percentage); 101 | } 102 | }); 103 | 104 | mAboutAdapter.setOnItemClickListener(new OnItemClickListener>() { 105 | @Override 106 | public void onItemClick(Map maps, int i) { 107 | switch (i) { 108 | case 0: 109 | aboutApp(); 110 | break; 111 | case 1: 112 | startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/XYScience/StopApp"))); 113 | break; 114 | case 2: 115 | startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/XYScience/StopApp/issues"))); 116 | break; 117 | case 3: 118 | feedbackToEmail(); 119 | break; 120 | } 121 | } 122 | }); 123 | 124 | FloatingActionButton fabShare = (FloatingActionButton) findViewById(R.id.fab_share); 125 | fabShare.setOnClickListener(new View.OnClickListener() { 126 | @Override 127 | public void onClick(View v) { 128 | Intent intent = new Intent(Intent.ACTION_SEND); 129 | intent.setType("text/plain"); 130 | intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_content) + 131 | "https://play.google.com/store/apps/details?id=com.sscience.stopapp、\n" + 132 | "http://coolapk.com/apk/com.sscience.stopapp"); 133 | startActivity(Intent.createChooser(intent, getString(R.string.share_title))); 134 | } 135 | }); 136 | } 137 | 138 | private void aboutApp() { 139 | AlertDialog.Builder builder = new AlertDialog.Builder(this); 140 | builder.setTitle(R.string.about_app); 141 | builder.setMessage(R.string.about_app_dialog); 142 | builder.setPositiveButton(getString(R.string.confirm), new DialogInterface.OnClickListener() { 143 | @Override 144 | public void onClick(DialogInterface dialog, int which) { 145 | dialog.dismiss(); 146 | } 147 | }); 148 | builder.show(); 149 | } 150 | 151 | private void feedbackToEmail() { 152 | Intent data = new Intent(Intent.ACTION_SENDTO); 153 | data.setData(Uri.parse("mailto:chentushen.science@gmail.com")); 154 | data.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.send_email_subject)); 155 | data.putExtra(Intent.EXTRA_TEXT, "----------\n" + getString(R.string.send_email_app_name) + getString(R.string.app_name) 156 | + getString(R.string.send_email_app_version) + CommonUtil.getAppVersion(AboutActivity.this) 157 | + getString(R.string.send_email_phone_model) + CommonUtil.getPhoneModel() 158 | + getString(R.string.android_version) + CommonUtil.getAndroidVersion() 159 | + "\n----------" 160 | + getString(R.string.leave_feedback)); 161 | startActivity(Intent.createChooser(data, getString(R.string.choose_email_app))); 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/activity/AppListActivity.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.activity; 2 | 3 | import android.app.Activity; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.support.annotation.Nullable; 7 | import android.support.design.widget.CoordinatorLayout; 8 | import android.support.design.widget.TabLayout; 9 | import android.support.v4.view.ViewPager; 10 | import android.view.MenuItem; 11 | 12 | import com.sscience.stopapp.R; 13 | import com.sscience.stopapp.adapter.AppListPagerAdapter; 14 | import com.sscience.stopapp.base.BaseActivity; 15 | import com.sscience.stopapp.bean.AppInfo; 16 | import com.sscience.stopapp.util.ShortcutsManager; 17 | 18 | import java.util.List; 19 | 20 | /** 21 | * @author SScience 22 | * @description 23 | * @email chentushen.science@gmail.com 24 | * @data 2017/1/15 25 | */ 26 | 27 | public class AppListActivity extends BaseActivity { 28 | 29 | public static final String EXTRA_MANUAL_SHORTCUT = "extra_manual_shortcut"; 30 | public CoordinatorLayout mCoordinatorLayout; 31 | public ViewPager mViewPager; 32 | private boolean isAbleApp; 33 | 34 | public static void actionStartActivity(Activity activity, int requestCode, boolean isManualShortcut) { 35 | Intent intent = new Intent(activity, AppListActivity.class); 36 | intent.putExtra(EXTRA_MANUAL_SHORTCUT, isManualShortcut); 37 | activity.startActivityForResult(intent, requestCode); 38 | } 39 | 40 | @Override 41 | protected int getContentLayout() { 42 | return R.layout.activity_app_list; 43 | } 44 | 45 | @Override 46 | protected void doOnCreate(@Nullable Bundle savedInstanceState) { 47 | 48 | if (getIntent().getBooleanExtra(EXTRA_MANUAL_SHORTCUT, false)) { 49 | setToolbar(getString(R.string.add_shortcut_apps)); 50 | } else { 51 | setToolbar(getString(R.string.add_apps)); 52 | } 53 | 54 | mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorLayout); 55 | TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout); 56 | mViewPager = (ViewPager) findViewById(R.id.viewpager); 57 | final AppListPagerAdapter myPagerAdapter = new AppListPagerAdapter(getSupportFragmentManager(), this); 58 | mViewPager.setAdapter(myPagerAdapter); 59 | mViewPager.setOffscreenPageLimit(2); 60 | tabLayout.setupWithViewPager(mViewPager); 61 | 62 | initListener(); 63 | } 64 | 65 | private void initListener() { 66 | } 67 | 68 | public void addAppShortcut(List infoList) { 69 | ShortcutsManager shortcutsManager = new ShortcutsManager(AppListActivity.this); 70 | shortcutsManager.addAppShortcut(infoList); 71 | } 72 | 73 | public void removeAppShortcut(String appPackageName) { 74 | ShortcutsManager shortcutsManager = new ShortcutsManager(AppListActivity.this); 75 | shortcutsManager.removeShortcut(appPackageName, getString(R.string.shortcut_num_limit)); 76 | } 77 | 78 | public void setAbleApp(boolean ableApp) { 79 | isAbleApp = ableApp; 80 | } 81 | 82 | @Override 83 | public boolean onOptionsItemSelected(MenuItem item) { 84 | if (item.getItemId() == android.R.id.home) { 85 | if (isAbleApp) { 86 | Intent intent = new Intent(this, MainActivity.class); 87 | setResult(RESULT_OK, intent); 88 | } 89 | finish(); 90 | return true; 91 | } else { 92 | return super.onOptionsItemSelected(item); 93 | } 94 | } 95 | 96 | @Override 97 | public void onBackPressed() { 98 | if (isAbleApp) { 99 | Intent intent = new Intent(this, MainActivity.class); 100 | setResult(RESULT_OK, intent); 101 | finish(); 102 | } else { 103 | super.onBackPressed(); 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/activity/ComponentDetailsActivity.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.activity; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | import android.support.annotation.Nullable; 7 | import android.support.design.widget.CoordinatorLayout; 8 | import android.support.design.widget.TabLayout; 9 | import android.support.v4.view.ViewPager; 10 | 11 | import com.sscience.stopapp.R; 12 | import com.sscience.stopapp.adapter.ComponentPagerAdapter; 13 | import com.sscience.stopapp.base.BaseActivity; 14 | import com.sscience.stopapp.bean.AppInfo; 15 | 16 | /** 17 | * @author SScience 18 | * @description 19 | * @email chentushen.science@gmail.com 20 | * @data 2017/4/4 21 | */ 22 | public class ComponentDetailsActivity extends BaseActivity { 23 | 24 | public static final String EXTRA_APP_NAME = "app_name"; 25 | public static final String EXTRA_APP_PACKAGE_NAME = "app_package_name"; 26 | public CoordinatorLayout mCoordinatorLayout; 27 | public ViewPager mViewPager; 28 | 29 | public static void actionStartActivity(Context context, AppInfo appInfo) { 30 | Intent intent = new Intent(context, ComponentDetailsActivity.class); 31 | intent.putExtra(EXTRA_APP_NAME, appInfo.getAppName()); 32 | intent.putExtra(EXTRA_APP_PACKAGE_NAME, appInfo.getAppPackageName()); 33 | context.startActivity(intent); 34 | } 35 | 36 | @Override 37 | protected int getContentLayout() { 38 | return R.layout.activity_component_details; 39 | } 40 | 41 | @Override 42 | protected void doOnCreate(@Nullable Bundle savedInstanceState) { 43 | setToolbar(getIntent().getStringExtra(EXTRA_APP_NAME)); 44 | 45 | mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorLayout); 46 | TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout); 47 | mViewPager = (ViewPager) findViewById(R.id.viewpager); 48 | final ComponentPagerAdapter myPagerAdapter = new ComponentPagerAdapter(getSupportFragmentManager(), this); 49 | mViewPager.setAdapter(myPagerAdapter); 50 | mViewPager.setOffscreenPageLimit(3); 51 | tabLayout.setupWithViewPager(mViewPager); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/activity/ShortcutActivity.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.activity; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | 7 | import com.sscience.stopapp.service.RootActionIntentService; 8 | 9 | /** 10 | * @author SScience 11 | * @description 12 | * @email chentushen.science@gmail.com 13 | * @data 2017/2/7 14 | */ 15 | 16 | public class ShortcutActivity extends AppCompatActivity { 17 | 18 | public static final String OPEN_APP_SHORTCUT = "com.sscience.stopapp.OPEN_APP_SHORTCUT"; 19 | public static final String EXTRA_PACKAGE_NAME = "extra_package_name"; 20 | 21 | public void onCreate(Bundle savedInstanceState) { 22 | super.onCreate(savedInstanceState); 23 | 24 | String packageName = getIntent().getStringExtra(EXTRA_PACKAGE_NAME); 25 | Intent component = new Intent(this, RootActionIntentService.class); 26 | component.putExtra(EXTRA_PACKAGE_NAME, packageName); 27 | startService(component); 28 | finish(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/adapter/AboutAdapter.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.adapter; 2 | 3 | import android.content.Context; 4 | import android.support.v7.widget.RecyclerView; 5 | 6 | import com.science.baserecyclerviewadapter.base.BaseCommonAdapter; 7 | import com.science.baserecyclerviewadapter.base.ViewHolder; 8 | import com.sscience.stopapp.R; 9 | 10 | import java.util.List; 11 | import java.util.Map; 12 | 13 | /** 14 | * @author SScience 15 | * @description 16 | * @email chentushen.science@gmail.com 17 | * @data 2017/2/7 18 | */ 19 | 20 | public class AboutAdapter extends BaseCommonAdapter>> { 21 | 22 | public AboutAdapter(Context context, RecyclerView recyclerView) { 23 | super(context, recyclerView); 24 | } 25 | 26 | @Override 27 | public void convertCommon(ViewHolder viewHolder, List> s, int i) { 28 | viewHolder.setText(R.id.tv_title, s.get(i).get("title")); 29 | viewHolder.setText(R.id.tv_subtitle, s.get(i).get("subtitle")); 30 | } 31 | 32 | @Override 33 | public int getItemLayoutId() { 34 | return R.layout.item_about; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/adapter/AppAdapter.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.adapter; 2 | 3 | import android.app.Activity; 4 | import android.content.res.Resources; 5 | import android.graphics.ColorMatrix; 6 | import android.graphics.ColorMatrixColorFilter; 7 | import android.os.Bundle; 8 | import android.support.v7.widget.RecyclerView; 9 | import android.widget.ImageView; 10 | import android.widget.TextView; 11 | 12 | import com.science.baserecyclerviewadapter.base.BaseCommonAdapter; 13 | import com.science.baserecyclerviewadapter.base.ViewHolder; 14 | import com.sscience.stopapp.R; 15 | import com.sscience.stopapp.bean.AppInfo; 16 | 17 | import java.util.List; 18 | 19 | import static com.sscience.stopapp.util.DiffCallBack.BUNDLE_PAYLOAD; 20 | 21 | 22 | /** 23 | * @author SScience 24 | * @description 25 | * @email chentushen.science@gmail.com 26 | * @data 2017/1/15 27 | */ 28 | 29 | public abstract class AppAdapter extends BaseCommonAdapter> { 30 | 31 | public ColorMatrixColorFilter mColorFilterGrey, mColorFilterNormal, mColorFilter50; // 设置图片灰度 32 | private ColorMatrix mMatrix; 33 | private Resources mResources; 34 | 35 | public AppAdapter(Activity activity, RecyclerView recyclerView) { 36 | super(activity, recyclerView); 37 | mResources = activity.getResources(); 38 | mMatrix = new ColorMatrix(); 39 | mMatrix.setSaturation(0); // 参数大于1将增加饱和度,0~1之间会减少饱和度。0值将产生一幅灰度图像。 40 | mColorFilterGrey = new ColorMatrixColorFilter(mMatrix); 41 | mMatrix.setSaturation(1); // 参数大于1将增加饱和度,0~1之间会减少饱和度。0值将产生一幅灰度图像。 42 | mColorFilterNormal = new ColorMatrixColorFilter(mMatrix); 43 | mMatrix.setSaturation(0.2f); // 参数大于1将增加饱和度,0~1之间会减少饱和度。0值将产生一幅灰度图像。 44 | mColorFilter50 = new ColorMatrixColorFilter(mMatrix); 45 | } 46 | 47 | @Override 48 | public void convertCommon(final ViewHolder viewHolder, List appInfo, final int position) { 49 | final AppInfo info = appInfo.get(position); 50 | viewHolder.setImageBitmap(R.id.iv_app_icon, info.getAppIcon()); 51 | viewHolder.setText(R.id.tv_app_name, info.getAppName()); 52 | } 53 | 54 | @Override 55 | public void convertDiff(ViewHolder holder, int position, List payloads) { 56 | Bundle payload = (Bundle) payloads.get(0); 57 | int isEnable = payload.getInt(BUNDLE_PAYLOAD); 58 | ((TextView) holder.getView(R.id.tv_app_name)).setTextColor(isEnable == 1 59 | ? mResources.getColor(R.color.textPrimary) : mResources.getColor(R.color.translucentBg)); 60 | if (isEnable == 1) { 61 | mMatrix.setSaturation(1); 62 | mColorFilterNormal = new ColorMatrixColorFilter(mMatrix); 63 | ((ImageView) holder.getView(R.id.iv_app_icon)).setColorFilter(mColorFilterNormal); 64 | } else { 65 | mMatrix.setSaturation(0); 66 | mColorFilterGrey = new ColorMatrixColorFilter(mMatrix); 67 | ((ImageView) holder.getView(R.id.iv_app_icon)).setColorFilter(mColorFilterGrey); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/adapter/AppListAdapter.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.adapter; 2 | 3 | import android.app.Activity; 4 | import android.content.res.Resources; 5 | import android.support.v7.widget.AppCompatCheckBox; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.widget.CompoundButton; 8 | import android.widget.Filter; 9 | import android.widget.Filterable; 10 | import android.widget.ImageView; 11 | import android.widget.TextView; 12 | import android.widget.Toast; 13 | 14 | import com.science.baserecyclerviewadapter.base.ViewHolder; 15 | import com.sscience.stopapp.R; 16 | import com.sscience.stopapp.activity.AppListActivity; 17 | import com.sscience.stopapp.bean.AppInfo; 18 | 19 | import java.util.ArrayList; 20 | import java.util.List; 21 | import java.util.Set; 22 | 23 | /** 24 | * @author SScience 25 | * @description 26 | * @email chentushen.science@gmail.com 27 | * @data 2017/1/15 28 | */ 29 | 30 | public class AppListAdapter extends AppAdapter implements Filterable { 31 | private AppListActivity mAppListActivity; 32 | private Resources mResources; 33 | private AppFilter mAppFilter; 34 | private List mOriginalAppInfo; 35 | private Set mDisablePackages; 36 | 37 | public AppListAdapter(Activity activity, RecyclerView recyclerView, Set disablePackages) { 38 | super(activity, recyclerView); 39 | mAppListActivity = (AppListActivity) activity; 40 | mResources = mAppListActivity.getResources(); 41 | mDisablePackages = disablePackages; 42 | } 43 | 44 | public void addDisableAppList(AppInfo appInfo, boolean isAbleApp) { 45 | if (isAbleApp) { 46 | mDisablePackages.add(appInfo.getAppPackageName()); 47 | } else { 48 | mDisablePackages.remove(appInfo.getAppPackageName()); 49 | } 50 | } 51 | 52 | public Set getDisablePackages() { 53 | return mDisablePackages; 54 | } 55 | 56 | @Override 57 | public int getItemLayoutId() { 58 | return R.layout.item_app; 59 | } 60 | 61 | @Override 62 | public void convertCommon(ViewHolder viewHolder, final List appInfo, final int position) { 63 | super.convertCommon(viewHolder, appInfo, position); 64 | final AppInfo info = appInfo.get(position); 65 | viewHolder.setText(R.id.tv_app_package_name, info.getAppPackageName()); 66 | ((TextView) viewHolder.getView(R.id.tv_app_name)).setTextColor(info.isEnable() == 1 67 | ? mResources.getColor(R.color.textPrimary) 68 | : mResources.getColor(R.color.translucentBg)); 69 | ((ImageView) viewHolder.getView(R.id.iv_app_icon)).getDrawable().setColorFilter(info.isEnable() == 1 70 | ? mColorFilterNormal : mColorFilterGrey); 71 | ((TextView) viewHolder.getView(R.id.tv_app_package_name)).setTextColor(info.isEnable() == 1 72 | ? mResources.getColor(R.color.textSecondary) 73 | : mResources.getColor(R.color.translucentBg)); 74 | AppCompatCheckBox cb = viewHolder.getView(R.id.cb_select_apps); 75 | cb.setOnCheckedChangeListener(null); // CheckBox在执行setChecked时会触发setOnCheckedChangeListener 76 | cb.setChecked(mDisablePackages.contains(info.getAppPackageName())); 77 | cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { 78 | @Override 79 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 80 | if (mCheckedChangeListener != null) { 81 | mCheckedChangeListener.onCheckedChanged(info, position, isChecked); 82 | } 83 | } 84 | }); 85 | } 86 | 87 | @Override 88 | public Filter getFilter() { 89 | if (mAppFilter == null) { 90 | mAppFilter = new AppFilter(); 91 | mOriginalAppInfo = getData(); 92 | } 93 | return mAppFilter; 94 | } 95 | 96 | class AppFilter extends Filter { 97 | 98 | @Override 99 | protected FilterResults performFiltering(CharSequence constraint) { 100 | List newAppInfo = new ArrayList<>(); 101 | if (constraint != null && constraint.toString().trim().length() > 0) { 102 | for (AppInfo appInfo : mOriginalAppInfo) { 103 | if (appInfo.getAppName().toLowerCase().contains(constraint.toString().toLowerCase())) { 104 | newAppInfo.add(appInfo); 105 | } 106 | } 107 | } else { 108 | newAppInfo = mOriginalAppInfo; 109 | } 110 | FilterResults filterResults = new FilterResults(); 111 | filterResults.count = newAppInfo.size(); 112 | filterResults.values = newAppInfo; 113 | return filterResults; 114 | } 115 | 116 | @Override 117 | protected void publishResults(CharSequence constraint, FilterResults results) { 118 | List newAppInfo = (List) results.values; 119 | setData(false, newAppInfo); 120 | if (newAppInfo.size() > 0) { 121 | notifyDataSetChanged(); 122 | } else { 123 | Toast.makeText(mAppListActivity, "暂时无此应用!", Toast.LENGTH_SHORT).show(); 124 | } 125 | } 126 | } 127 | 128 | public interface OnCheckedChangeListener { 129 | void onCheckedChanged(AppInfo info, int position, boolean isChecked); 130 | } 131 | 132 | private OnCheckedChangeListener mCheckedChangeListener; 133 | 134 | public void setCheckedChangeListener(OnCheckedChangeListener checkedChangeListener) { 135 | mCheckedChangeListener = checkedChangeListener; 136 | } 137 | } 138 | 139 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/adapter/AppListPagerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.adapter; 2 | 3 | import android.content.Context; 4 | import android.support.v4.app.Fragment; 5 | import android.support.v4.app.FragmentManager; 6 | import android.support.v4.app.FragmentStatePagerAdapter; 7 | import android.view.ViewGroup; 8 | 9 | import com.sscience.stopapp.R; 10 | import com.sscience.stopapp.fragment.AppListFragment; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | /** 16 | * @author SScience 17 | * @description 18 | * @email chentushen.science@gmail.com 19 | * @data 2017/1/15 20 | */ 21 | 22 | public class AppListPagerAdapter extends FragmentStatePagerAdapter { 23 | 24 | private List tabNames; 25 | private List mFragments; 26 | 27 | public AppListPagerAdapter(FragmentManager fm, Context context) { 28 | super(fm); 29 | mFragments = new ArrayList<>(); 30 | tabNames = new ArrayList<>(); 31 | tabNames.add(context.getString(R.string.user_apps)); 32 | tabNames.add(context.getString(R.string.system_apps)); 33 | } 34 | 35 | @Override 36 | public Object instantiateItem(ViewGroup container, int position) { 37 | AppListFragment fragment = (AppListFragment) super.instantiateItem(container, position); 38 | mFragments.add(fragment); 39 | return fragment; 40 | } 41 | 42 | @Override 43 | public Fragment getItem(int position) { 44 | return AppListFragment.newInstance(position); 45 | } 46 | 47 | public AppListFragment getFragments(int position) { 48 | return mFragments.get(position); 49 | } 50 | 51 | @Override 52 | public int getCount() { 53 | return tabNames.size(); 54 | } 55 | 56 | /** 57 | * 这个函数就是给TabLayout的Tab设定Title 58 | */ 59 | @Override 60 | public CharSequence getPageTitle(int position) { 61 | return tabNames.get(position); 62 | } 63 | } -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/adapter/ComponentDetailsAdapter.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.adapter; 2 | 3 | import android.app.Activity; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.support.v7.widget.SwitchCompat; 6 | 7 | import com.science.baserecyclerviewadapter.base.BaseCommonAdapter; 8 | import com.science.baserecyclerviewadapter.base.ViewHolder; 9 | import com.sscience.stopapp.R; 10 | import com.sscience.stopapp.bean.ComponentInfo; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | * @author SScience 16 | * @description 17 | * @email chentushen.science@gmail.com 18 | * @data 2017/4/4 19 | */ 20 | public class ComponentDetailsAdapter extends BaseCommonAdapter> { 21 | 22 | public ComponentDetailsAdapter(Activity activity, RecyclerView recyclerView) { 23 | super(activity, recyclerView); 24 | } 25 | 26 | @Override 27 | public int getItemLayoutId() { 28 | return R.layout.item_component_details; 29 | } 30 | 31 | @Override 32 | public void convertCommon(ViewHolder viewHolder, List list, int i) { 33 | ComponentInfo componentInfo = list.get(i); 34 | viewHolder.setText(R.id.tv_component, componentInfo.getComponentName() 35 | .substring(componentInfo.getComponentName().lastIndexOf(".") + 1)); 36 | SwitchCompat sc = viewHolder.getView(R.id.switch_component); 37 | sc.setChecked(componentInfo.isEnable()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/adapter/ComponentPagerAdapter.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.adapter; 2 | 3 | import android.content.Context; 4 | import android.support.v4.app.Fragment; 5 | import android.support.v4.app.FragmentManager; 6 | import android.support.v4.app.FragmentStatePagerAdapter; 7 | import android.view.ViewGroup; 8 | 9 | import com.sscience.stopapp.R; 10 | import com.sscience.stopapp.fragment.ComponentDetailsFragment; 11 | 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | 15 | /** 16 | * @author SScience 17 | * @description 18 | * @email chentushen.science@gmail.com 19 | * @data 2017/1/15 20 | */ 21 | 22 | public class ComponentPagerAdapter extends FragmentStatePagerAdapter { 23 | 24 | private List tabNames; 25 | private List mFragments; 26 | 27 | public ComponentPagerAdapter(FragmentManager fm, Context context) { 28 | super(fm); 29 | mFragments = new ArrayList<>(); 30 | tabNames = new ArrayList<>(); 31 | tabNames.add(context.getString(R.string.component_activity)); 32 | tabNames.add(context.getString(R.string.component_service)); 33 | tabNames.add(context.getString(R.string.component_receiver)); 34 | tabNames.add(context.getString(R.string.component_provider)); 35 | } 36 | 37 | @Override 38 | public Object instantiateItem(ViewGroup container, int position) { 39 | ComponentDetailsFragment fragment = (ComponentDetailsFragment) super.instantiateItem(container, position); 40 | mFragments.add(fragment); 41 | return fragment; 42 | } 43 | 44 | @Override 45 | public Fragment getItem(int position) { 46 | return ComponentDetailsFragment.newInstance(position); 47 | } 48 | 49 | public ComponentDetailsFragment getFragments(int position) { 50 | return mFragments.get(position); 51 | } 52 | 53 | @Override 54 | public int getCount() { 55 | return tabNames.size(); 56 | } 57 | 58 | /** 59 | * 这个函数就是给TabLayout的Tab设定Title 60 | */ 61 | @Override 62 | public CharSequence getPageTitle(int position) { 63 | return tabNames.get(position); 64 | } 65 | } -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/adapter/DisableAppAdapter.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.adapter; 2 | 3 | import android.app.Activity; 4 | import android.support.v7.widget.RecyclerView; 5 | import android.widget.Filter; 6 | import android.widget.Filterable; 7 | import android.widget.ImageView; 8 | import android.widget.TextView; 9 | import android.widget.Toast; 10 | 11 | import com.science.baserecyclerviewadapter.base.ViewHolder; 12 | import com.sscience.stopapp.R; 13 | import com.sscience.stopapp.activity.MainActivity; 14 | import com.sscience.stopapp.bean.AppInfo; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | /** 20 | * @author SScience 21 | * @description 22 | * @email chentushen.science@gmail.com 23 | * @data 2017/1/15 24 | */ 25 | 26 | public class DisableAppAdapter extends AppAdapter implements Filterable { 27 | 28 | private MainActivity mMainActivity; 29 | private AppFilter mAppFilter; 30 | public List mOriginalAppInfo; 31 | 32 | public DisableAppAdapter(Activity activity, RecyclerView recyclerView) { 33 | super(activity, recyclerView); 34 | mMainActivity = (MainActivity) activity; 35 | } 36 | 37 | @Override 38 | public int getItemLayoutId() { 39 | return R.layout.item_disable; 40 | } 41 | 42 | @Override 43 | public void convertCommon(ViewHolder viewHolder, List appInfo, final int position) { 44 | super.convertCommon(viewHolder, appInfo, position); 45 | final AppInfo info = appInfo.get(position); 46 | TextView tvAppName = viewHolder.getView(R.id.tv_app_name); 47 | ImageView ivAppIcon = viewHolder.getView(R.id.iv_app_icon); 48 | if (mMainActivity.getSelection().contains(info)) { 49 | tvAppName.setTextColor(mMainActivity.getResources().getColor(R.color.textPrepareColor)); 50 | ivAppIcon.getDrawable().setColorFilter(mColorFilter50); 51 | } else { 52 | tvAppName.setTextColor(info.isEnable() == 1 53 | ? mMainActivity.getResources().getColor(R.color.textPrimary) 54 | : mMainActivity.getResources().getColor(R.color.translucentBg)); 55 | ivAppIcon.getDrawable().setColorFilter(info.isEnable() == 1 56 | ? mColorFilterNormal : mColorFilterGrey); 57 | } 58 | // AppCompatCheckBox cb = viewHolder.getView(R.id.cb_select_apps); 59 | // cb.setOnCheckedChangeListener(null); // CheckBox在执行setChecked时会触发setOnCheckedChangeListener 60 | // cb.setChecked(mMainActivity.getSelection().contains(info.getAppPackageName())); 61 | // cb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { 62 | // @Override 63 | // public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 64 | // Set selections = mMainActivity.getSelection(); 65 | // if (isChecked) { 66 | // selections.add(info.getAppPackageName()); 67 | // } else { 68 | // selections.remove(info.getAppPackageName()); 69 | // } 70 | // mMainActivity.checkSelection(); 71 | // } 72 | // }); 73 | } 74 | 75 | @Override 76 | public Filter getFilter() { 77 | if (mAppFilter == null) { 78 | mAppFilter = new AppFilter(); 79 | mOriginalAppInfo = getData(); 80 | } 81 | return mAppFilter; 82 | } 83 | 84 | class AppFilter extends Filter { 85 | 86 | @Override 87 | protected FilterResults performFiltering(CharSequence constraint) { 88 | List newAppInfo = new ArrayList<>(); 89 | if (constraint != null && constraint.toString().trim().length() > 0) { 90 | for (AppInfo appInfo : mOriginalAppInfo) { 91 | if (appInfo.getAppName().toLowerCase().contains(constraint.toString().toLowerCase())) { 92 | newAppInfo.add(appInfo); 93 | } 94 | } 95 | } else { 96 | newAppInfo = mOriginalAppInfo; 97 | } 98 | FilterResults filterResults = new FilterResults(); 99 | filterResults.count = newAppInfo.size(); 100 | filterResults.values = newAppInfo; 101 | return filterResults; 102 | } 103 | 104 | @Override 105 | protected void publishResults(CharSequence constraint, FilterResults results) { 106 | List newAppInfo = (List) results.values; 107 | setData(false, newAppInfo); 108 | if (newAppInfo.size() > 0) { 109 | notifyDataSetChanged(); 110 | } else { 111 | Toast.makeText(mMainActivity, R.string.search_no_app, Toast.LENGTH_SHORT).show(); 112 | } 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/base/BaseActivity.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.base; 2 | 3 | import android.content.DialogInterface; 4 | import android.content.pm.PackageManager; 5 | import android.os.Bundle; 6 | import android.support.annotation.NonNull; 7 | import android.support.annotation.Nullable; 8 | import android.support.design.widget.Snackbar; 9 | import android.support.v4.app.ActivityCompat; 10 | import android.support.v4.content.ContextCompat; 11 | import android.support.v4.view.ViewCompat; 12 | import android.support.v7.app.AlertDialog; 13 | import android.support.v7.app.AppCompatActivity; 14 | import android.support.v7.widget.Toolbar; 15 | import android.view.MenuItem; 16 | import android.view.View; 17 | import android.view.animation.Interpolator; 18 | 19 | import com.sscience.stopapp.R; 20 | 21 | 22 | /** 23 | * @author SScience 24 | * @description 25 | * @email chentushen.science@gmail.com 26 | * @data 2017/1/15 27 | */ 28 | 29 | public abstract class BaseActivity extends AppCompatActivity { 30 | 31 | private static final int REQUEST_PERMISSION_CODE = 1000; 32 | 33 | protected abstract int getContentLayout(); 34 | 35 | protected abstract void doOnCreate(@Nullable Bundle savedInstanceState); 36 | 37 | private PermissionCallback mPermissionCallback; 38 | 39 | public interface PermissionCallback { 40 | void hasPermission(); 41 | 42 | void noPermission(); 43 | } 44 | 45 | @Override 46 | protected void onCreate(@Nullable Bundle savedInstanceState) { 47 | super.onCreate(savedInstanceState); 48 | setContentView(getContentLayout()); 49 | doOnCreate(savedInstanceState); 50 | } 51 | 52 | public Toolbar setToolbar(String title) { 53 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 54 | toolbar.setTitle(title); 55 | setSupportActionBar(toolbar); 56 | if (getSupportActionBar() != null && !title.equals(getString(R.string.app_name))) { 57 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 58 | } 59 | return toolbar; 60 | } 61 | 62 | @Override 63 | public boolean onOptionsItemSelected(MenuItem item) { 64 | if (item.getItemId() == android.R.id.home) { 65 | finish(); 66 | } 67 | return super.onOptionsItemSelected(item); 68 | } 69 | 70 | // Android6.0+权限检查 start 71 | 72 | /** 73 | * 权限请求入口 74 | * 75 | * @param permissionTip 76 | * @param permissionCallback 77 | * @param permissions 78 | */ 79 | public void performCodeWithPermission(String permissionTip, PermissionCallback permissionCallback, String... permissions) { 80 | if (permissions == null || permissions.length == 0) { 81 | return; 82 | } else { 83 | mPermissionCallback = permissionCallback; 84 | if (checkPermissionGranted(permissions)) { 85 | // 有权限 86 | if (mPermissionCallback != null) { 87 | mPermissionCallback.hasPermission(); 88 | mPermissionCallback = null; 89 | } 90 | } else { 91 | // 没有权限 92 | requestPermission(permissionTip, permissions); 93 | } 94 | } 95 | } 96 | 97 | private void requestPermission(final String permissionTip, final String[] permissions) { 98 | if (shouldShowRequestPermissionRationale(permissions)) { 99 | //如果用户之前拒绝过此权限,再提示一次准备授权相关权限 100 | new AlertDialog.Builder(this) 101 | .setTitle(getString(R.string.tip)) 102 | .setMessage(permissionTip) 103 | .setPositiveButton(R.string.allow, new DialogInterface.OnClickListener() { 104 | @Override 105 | public void onClick(DialogInterface dialog, int which) { 106 | ActivityCompat.requestPermissions(BaseActivity.this, permissions, REQUEST_PERMISSION_CODE); 107 | } 108 | }).setNegativeButton(getString(R.string.deny), new DialogInterface.OnClickListener() { 109 | @Override 110 | public void onClick(DialogInterface dialog, int which) { 111 | if (mPermissionCallback != null) { 112 | mPermissionCallback.noPermission(); 113 | mPermissionCallback = null; 114 | } 115 | } 116 | }).show(); 117 | } else { 118 | ActivityCompat.requestPermissions(BaseActivity.this, permissions, REQUEST_PERMISSION_CODE); 119 | } 120 | } 121 | 122 | /** 123 | * 首次安装请求返回false;如果用户之前拒绝过权限,则返回true;用户在权限对话框中选择了"不再显示”后,则返回false 124 | * (MIUI阉割了这个方法/(ㄒoㄒ)/~~) 125 | * 126 | * @param permissions 127 | * @return 128 | */ 129 | private boolean shouldShowRequestPermissionRationale(String[] permissions) { 130 | boolean flag = false; 131 | for (String p : permissions) { 132 | if (ActivityCompat.shouldShowRequestPermissionRationale(this, p)) { 133 | flag = true; 134 | break; 135 | } 136 | } 137 | return flag; 138 | } 139 | 140 | /** 141 | * 检测应用是否已经具有权限 142 | * 143 | * @param permissions 144 | * @return 145 | */ 146 | private boolean checkPermissionGranted(String[] permissions) { 147 | boolean flag = true; 148 | for (String p : permissions) { 149 | if (ContextCompat.checkSelfPermission(this, p) != PackageManager.PERMISSION_GRANTED) { 150 | flag = false; // 没有权限 151 | break; 152 | } 153 | } 154 | return flag; 155 | } 156 | 157 | @Override 158 | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { 159 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); 160 | if (requestCode == REQUEST_PERMISSION_CODE) { 161 | if (verifyPermissions(grantResults)) { 162 | if (mPermissionCallback != null) { 163 | mPermissionCallback.hasPermission(); 164 | mPermissionCallback = null; 165 | } 166 | } else { 167 | if (mPermissionCallback != null) { 168 | mPermissionCallback.noPermission(); 169 | mPermissionCallback = null; 170 | } 171 | } 172 | } else { 173 | super.onRequestPermissionsResult(requestCode, permissions, grantResults); 174 | } 175 | } 176 | 177 | private boolean verifyPermissions(int[] grantResults) { 178 | // At least one result must be checked. 179 | if (grantResults.length < 1) { 180 | return false; 181 | } 182 | 183 | // Verify that each required permission has been granted, otherwise return false. 184 | for (int result : grantResults) { 185 | if (result != PackageManager.PERMISSION_GRANTED) { 186 | return false; 187 | } 188 | } 189 | return true; 190 | } 191 | // Android6.0+权限检查 end 192 | 193 | // tip start 194 | public void snackBarShow(View view, int contentRes) { 195 | snackBarShow(view, getString(contentRes)); 196 | } 197 | 198 | public void snackBarShow(View view, String content) { 199 | Snackbar.make(view, content, Snackbar.LENGTH_LONG).show(); 200 | } 201 | // tip end 202 | 203 | /** 204 | * view渐显or渐隐动画 205 | * 206 | * @param view 207 | * @param alpha 208 | * @param interpolator 209 | */ 210 | protected void setInterpolator(View view, float alpha, Interpolator interpolator) { 211 | view.setClickable(alpha == 1); 212 | ViewCompat.animate(view).alpha(alpha).setInterpolator(interpolator); 213 | } 214 | } 215 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/base/BaseFragment.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.base; 2 | 3 | import android.os.Bundle; 4 | import android.os.Message; 5 | import android.support.annotation.Nullable; 6 | import android.support.design.widget.Snackbar; 7 | import android.support.v4.app.Fragment; 8 | import android.support.v4.widget.SwipeRefreshLayout; 9 | import android.view.LayoutInflater; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | 13 | import com.sscience.stopapp.R; 14 | import com.sscience.stopapp.util.WeakHandler; 15 | 16 | /** 17 | * @author SScience 18 | * @description 19 | * @email chentushen.science@gmail.com 20 | * @data 2017/1/5 21 | */ 22 | 23 | public abstract class BaseFragment extends Fragment implements WeakHandler.IHandler, SwipeRefreshLayout.OnRefreshListener { 24 | 25 | protected boolean isVisible; 26 | private boolean isFirst = false; 27 | public WeakHandler mWeakHandler; 28 | private SwipeRefreshLayout mSwipeRefreshLayout; 29 | 30 | protected abstract int getContentLayout(); 31 | 32 | protected abstract void doCreateView(View view); 33 | 34 | @Nullable 35 | @Override 36 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 37 | View view = inflater.inflate(getContentLayout(), container, false); 38 | doCreateView(view); 39 | isFirst = true; 40 | mWeakHandler = new WeakHandler(this); 41 | return view; 42 | } 43 | 44 | @Override 45 | public void onDestroy() { 46 | super.onDestroy(); 47 | mWeakHandler.removeCallbacksAndMessages(null); 48 | } 49 | 50 | // weakReference start 51 | @Override 52 | public void handleMessage(Message msg) { 53 | } 54 | // weakReference end 55 | 56 | // refresh start 57 | protected SwipeRefreshLayout initRefreshLayout(View view) { 58 | mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.swipeRefreshLayout); 59 | mSwipeRefreshLayout.setOnRefreshListener(this); 60 | mSwipeRefreshLayout.setColorSchemeResources(android.R.color.black); 61 | return mSwipeRefreshLayout; 62 | } 63 | 64 | protected boolean isRefreshing() { 65 | return mSwipeRefreshLayout.isRefreshing(); 66 | } 67 | 68 | protected void setRefreshing(boolean refreshing) { 69 | mSwipeRefreshLayout.setRefreshing(refreshing); 70 | } 71 | 72 | protected void setSwipeRefreshEnable(boolean enable) { 73 | if (mSwipeRefreshLayout != null) { 74 | mSwipeRefreshLayout.setEnabled(enable); 75 | } 76 | } 77 | 78 | protected boolean getSwipeRefreshLayout() { 79 | if (mSwipeRefreshLayout != null) { 80 | return mSwipeRefreshLayout.isEnabled(); 81 | } 82 | return false; 83 | } 84 | 85 | @Override 86 | public void onRefresh() { 87 | } 88 | // refresh end 89 | 90 | // lazy load start 91 | 92 | /** 93 | * viewpager切换时调用,而且是在onCreateView之前调用 94 | * 95 | * @param isVisibleToUser true:用户可见 96 | */ 97 | @Override 98 | public void setUserVisibleHint(boolean isVisibleToUser) { 99 | super.setUserVisibleHint(isVisibleToUser); 100 | if (isVisibleToUser) { 101 | isVisible = true; 102 | onVisible(); 103 | } else { 104 | isVisible = false; 105 | onInVisible(); 106 | } 107 | } 108 | 109 | /** 110 | * 使用add(), hide(),show()添加fragment时 111 | * 刚开始add()时,当前fragment会调用该方法,但是目标fragment不会调用; 112 | * 所以先add()所有fragment,即先初始化控件,但不初始化数据。 113 | * 114 | * @param hidden 115 | */ 116 | @Override 117 | public void onHiddenChanged(boolean hidden) { 118 | super.onHiddenChanged(hidden); 119 | if (!hidden) { 120 | isVisible = true; 121 | onVisible(); 122 | } else { 123 | isVisible = false; 124 | onInVisible(); 125 | } 126 | } 127 | 128 | @Override 129 | public void onResume() { 130 | super.onResume(); 131 | if (getUserVisibleHint()) { 132 | onVisible(); 133 | } 134 | } 135 | 136 | private void onVisible() { 137 | if (isFirst && isVisible) { 138 | onLazyLoad(); 139 | isFirst = false; // 控制fragment可见时,是否自动加载数据。 140 | } 141 | } 142 | 143 | /** 144 | * fragment可见时再加载数据 145 | */ 146 | public abstract void onLazyLoad(); 147 | 148 | private void onInVisible() { 149 | 150 | } 151 | // lazy load end 152 | 153 | // tip start 154 | public void snackBarShow(View view, int contentRes) { 155 | snackBarShow(view, getString(contentRes)); 156 | } 157 | 158 | public void snackBarShow(View view, String content) { 159 | Snackbar.make(view, content, Snackbar.LENGTH_LONG).show(); 160 | } 161 | // tip end 162 | 163 | } 164 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/base/BasePresenter.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.base; 2 | 3 | /** 4 | * @author SScience 5 | * @description 6 | * @email chentushen.science@gmail.com 7 | * @data 2017/1/15 8 | */ 9 | 10 | public interface BasePresenter { 11 | void start(); 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/base/BaseView.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.base; 2 | 3 | /** 4 | * @author SScience 5 | * @description 6 | * @email chentushen.science@gmail.com 7 | * @data 2017/1/15 8 | */ 9 | 10 | public interface BaseView { 11 | void setPresenter(T presenter); 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/bean/AppInfo.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.bean; 2 | 3 | import android.graphics.Bitmap; 4 | 5 | import java.io.Serializable; 6 | 7 | /** 8 | * @author SScience 9 | * @description 实现Clonable接口,覆盖并实现clone方法,除了调用父类中的clone方法得到新的对象, 10 | * 还要将该类中的引用变量也clone出来。 11 | * @email chentushen.science@gmail.com 12 | * @data 2017/1/15 13 | */ 14 | 15 | public class AppInfo implements Serializable, Cloneable { 16 | 17 | private static final long serialVersionUID = -2984090829607150673L; 18 | public final static String APP_PACKAGE_NAME = "appPackageName"; 19 | public final static String APP_NAME = "appName"; 20 | public final static String APP_ICON = "appIcon"; 21 | public final static String IS_ENABLE = "isEnable"; 22 | public final static String IS_SYSTEM_APP = "isSystemApp"; 23 | 24 | public String appName; 25 | public String appPackageName; 26 | public Bitmap appIcon; 27 | public int isEnable; 28 | public int isSystemApp; 29 | 30 | public String getAppName() { 31 | return appName; 32 | } 33 | 34 | public void setAppName(String appName) { 35 | this.appName = appName; 36 | } 37 | 38 | public String getAppPackageName() { 39 | return appPackageName; 40 | } 41 | 42 | public void setAppPackageName(String appPackageName) { 43 | this.appPackageName = appPackageName; 44 | } 45 | 46 | public Bitmap getAppIcon() { 47 | return appIcon; 48 | } 49 | 50 | public void setAppIcon(Bitmap appIcon) { 51 | this.appIcon = appIcon; 52 | } 53 | 54 | public int isEnable() { 55 | return isEnable; 56 | } 57 | 58 | public void setEnable(int enable) { 59 | isEnable = enable; 60 | } 61 | 62 | public int isSystemApp() { 63 | return isSystemApp; 64 | } 65 | 66 | public void setSystemApp(int systemApp) { 67 | isSystemApp = systemApp; 68 | } 69 | 70 | @Override 71 | public AppInfo clone() throws CloneNotSupportedException { 72 | AppInfo appInfo = null; 73 | try { 74 | appInfo = (AppInfo) super.clone(); 75 | 76 | } catch (CloneNotSupportedException e) { 77 | e.printStackTrace(); 78 | } 79 | return appInfo; 80 | } 81 | 82 | public boolean equals(Object obj) { 83 | if (!(obj instanceof AppInfo)) 84 | return false; 85 | if (obj == this) 86 | return true; 87 | return this.appPackageName.equals(((AppInfo) obj).appPackageName); 88 | } 89 | 90 | @Override 91 | public int hashCode() { 92 | return appPackageName.length(); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/bean/ComponentInfo.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.bean; 2 | 3 | /** 4 | * @author SScience 5 | * @description 6 | * @email chentushen.science@gmail.com 7 | * @data 2017/4/4 8 | */ 9 | public class ComponentInfo { 10 | 11 | public final static String COMPONENT_PACKAGE_NAME = "packageName"; 12 | public final static String COMPONENT_NAME = "componentName"; 13 | public final static String IS_ENABLE = "isEnable"; 14 | 15 | public String packageName; 16 | public String componentName; 17 | public boolean isEnable; 18 | 19 | public String getPackageName() { 20 | return packageName; 21 | } 22 | 23 | public void setPackageName(String packageName) { 24 | this.packageName = packageName; 25 | } 26 | 27 | public String getComponentName() { 28 | return componentName; 29 | } 30 | 31 | public void setComponentName(String componentName) { 32 | this.componentName = componentName; 33 | } 34 | 35 | public boolean isEnable() { 36 | return isEnable; 37 | } 38 | 39 | public void setEnable(boolean enable) { 40 | isEnable = enable; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/database/AppInfoDBController.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.database; 2 | 3 | import android.content.ContentValues; 4 | import android.content.Context; 5 | import android.database.Cursor; 6 | import android.database.sqlite.SQLiteDatabase; 7 | import android.graphics.Bitmap; 8 | 9 | import com.science.myloggerlibrary.MyLogger; 10 | import com.sscience.stopapp.bean.AppInfo; 11 | import com.sscience.stopapp.util.CommonUtil; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | /** 17 | * @author SScience 18 | * @description 19 | * @email chentushen.science@gmail.com 20 | * @data 2017/3/6 21 | */ 22 | 23 | public class AppInfoDBController { 24 | 25 | private final SQLiteDatabase mSQLiteDatabase; 26 | 27 | public AppInfoDBController(Context context) { 28 | AppInfoDBOpenHelper openHelper = new AppInfoDBOpenHelper(context); 29 | 30 | mSQLiteDatabase = openHelper.getWritableDatabase(); 31 | } 32 | 33 | /** 34 | * 获取主页停用列表apps 35 | * 36 | * @param tableName 37 | * @return 38 | */ 39 | public List getDisableApps(String tableName) { 40 | final Cursor cursor = mSQLiteDatabase.rawQuery("SELECT * FROM " + tableName, null); 41 | 42 | final List list = new ArrayList<>(); 43 | try { 44 | if (!cursor.moveToLast()) { 45 | return list; 46 | } 47 | do { 48 | AppInfo appInfo = new AppInfo(); 49 | appInfo.setAppPackageName(cursor.getString(cursor.getColumnIndex(AppInfo.APP_PACKAGE_NAME))); 50 | appInfo.setAppName(cursor.getString(cursor.getColumnIndex(AppInfo.APP_NAME))); 51 | MyLogger.e(cursor.getString(cursor.getColumnIndex(AppInfo.APP_NAME))); 52 | appInfo.setAppIcon(CommonUtil.getImage(cursor.getBlob(cursor.getColumnIndex(AppInfo.APP_ICON)))); 53 | appInfo.setEnable(cursor.getInt(cursor.getColumnIndex(AppInfo.IS_ENABLE))); 54 | appInfo.setSystemApp(cursor.getInt(cursor.getColumnIndex(AppInfo.IS_SYSTEM_APP))); 55 | list.add(appInfo); 56 | } while (cursor.moveToPrevious()); 57 | } finally { 58 | if (cursor != null && !cursor.isClosed()) { 59 | cursor.close(); 60 | } 61 | } 62 | 63 | return list; 64 | } 65 | 66 | /** 67 | * 搜索app 68 | * 69 | * @param tableName 70 | * @param packageName 71 | * @return 72 | */ 73 | public boolean searchApp(String tableName, String packageName) { 74 | boolean isExist = false; 75 | Cursor cursor = null; 76 | try { 77 | cursor = mSQLiteDatabase.query(tableName, null, AppInfo.APP_PACKAGE_NAME + " = ?", 78 | new String[]{packageName}, null, null, null); 79 | isExist = null != cursor && cursor.moveToFirst(); 80 | } catch (Exception e) { 81 | MyLogger.e(e.toString()); 82 | } finally { 83 | if (null != cursor && !cursor.isClosed()) { 84 | cursor.close(); 85 | } 86 | } 87 | return isExist; 88 | } 89 | 90 | /** 91 | * 添加app 92 | * 93 | * @param appInfo 94 | * @param tableName 95 | */ 96 | public void addDisableApp(AppInfo appInfo, String tableName) { 97 | ContentValues cv = new ContentValues(); 98 | cv.put(AppInfo.APP_PACKAGE_NAME, appInfo.getAppPackageName()); 99 | cv.put(AppInfo.APP_NAME, appInfo.getAppName()); 100 | cv.put(AppInfo.APP_ICON, CommonUtil.getBytes(appInfo.getAppIcon())); 101 | cv.put(AppInfo.IS_ENABLE, appInfo.isEnable()); 102 | cv.put(AppInfo.IS_SYSTEM_APP, appInfo.isSystemApp()); 103 | mSQLiteDatabase.insert(tableName, null, cv); 104 | } 105 | 106 | /** 107 | * 删除app 108 | * 109 | * @param packageName 110 | * @param tableName 111 | */ 112 | public void deleteDisableApp(String packageName, String tableName) { 113 | String deleteQuery = "DELETE FROM " + tableName 114 | + " where " + AppInfo.APP_PACKAGE_NAME + " = '" + packageName + "'"; 115 | mSQLiteDatabase.execSQL(deleteQuery); 116 | } 117 | 118 | /** 119 | * 清空表 120 | * 121 | * @param tableName 122 | */ 123 | public void clearDisableApp(String tableName) { 124 | String deleteQuery = "DELETE FROM " + tableName; 125 | mSQLiteDatabase.execSQL(deleteQuery); 126 | } 127 | 128 | /** 129 | * 更新app是否停用 130 | * 131 | * @param packageName 132 | * @param isEnable 133 | * @param tableName 134 | */ 135 | public void updateDisableApp(String packageName, int isEnable, String tableName) { 136 | ContentValues cv = new ContentValues(); 137 | cv.put(AppInfo.IS_ENABLE, isEnable); 138 | String[] args = {packageName}; 139 | mSQLiteDatabase.update(tableName, cv, AppInfo.APP_PACKAGE_NAME + "=?", args); 140 | } 141 | 142 | /** 143 | * 更新app名 144 | * 145 | * @param packageName 146 | * @param appName 147 | * @param tableName 148 | */ 149 | public void updateAppName(String packageName, String appName, String tableName) { 150 | ContentValues cv = new ContentValues(); 151 | cv.put(AppInfo.APP_NAME, appName); 152 | String[] args = {packageName}; 153 | mSQLiteDatabase.update(tableName, cv, AppInfo.APP_PACKAGE_NAME + "=?", args); 154 | } 155 | 156 | /** 157 | * 更新app logo 158 | * 159 | * @param packageName 160 | * @param appIcon 161 | * @param tableName 162 | */ 163 | public void updateAppIcon(String packageName, Bitmap appIcon, String tableName) { 164 | ContentValues cv = new ContentValues(); 165 | cv.put(AppInfo.APP_ICON, CommonUtil.getBytes(appIcon)); 166 | String[] args = {packageName}; 167 | mSQLiteDatabase.update(tableName, cv, AppInfo.APP_PACKAGE_NAME + "=?", args); 168 | } 169 | 170 | } 171 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/database/AppInfoDBOpenHelper.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.database; 2 | 3 | import android.content.Context; 4 | import android.database.sqlite.SQLiteDatabase; 5 | import android.database.sqlite.SQLiteOpenHelper; 6 | 7 | import com.sscience.stopapp.bean.AppInfo; 8 | 9 | /** 10 | * @author SScience 11 | * @description 12 | * @email chentushen.science@gmail.com 13 | * @data 2017/3/6 14 | */ 15 | 16 | public class AppInfoDBOpenHelper extends SQLiteOpenHelper { 17 | 18 | // Database Version 19 | private static final int DATABASE_VERSION = 2; 20 | // Database Name 21 | private static final String DATABASE_NAME = "appInfo.db"; 22 | // AppInfo Table Names 23 | public static final String TABLE_NAME_APP_INFO = "table_appInfo"; 24 | // Shortcut App Table Names 25 | public static final String TABLE_NAME_SHORTCUT_APP_INFO = "table_shortcut_appInfo"; 26 | 27 | // // Table create statement 28 | // private static final String CREATE_TABLE_APP_INFO = 29 | // "CREATE TABLE IF NOT EXISTS " 30 | // + TABLE_NAME_APP_INFO 31 | // + String.format( 32 | // "(" 33 | // + "%s VARCHAR PRIMARY KEY, " // appPackageName 34 | // + "%s VARCHAR, " // appName 35 | // + "%s BLOB, " // appIcon 36 | // + "%s INTEGER, " // isEnable 37 | // + "%s INTEGER " // isSystemApp 38 | // + ")" 39 | // , AppInfo.APP_PACKAGE_NAME 40 | // , AppInfo.APP_NAME 41 | // , AppInfo.APP_ICON 42 | // , AppInfo.IS_ENABLE 43 | // , AppInfo.IS_SYSTEM_APP 44 | // 45 | // ); 46 | 47 | public AppInfoDBOpenHelper(Context context) { 48 | super(context, DATABASE_NAME, null, DATABASE_VERSION); 49 | } 50 | 51 | private static String createTable(String tableName) { 52 | String createTable = "CREATE TABLE IF NOT EXISTS " 53 | + tableName 54 | + String.format( 55 | "(" 56 | + "%s VARCHAR PRIMARY KEY, " // appPackageName 57 | + "%s VARCHAR, " // appName 58 | + "%s BLOB, " // appIcon 59 | + "%s INTEGER, " // isEnable 60 | + "%s INTEGER " // isSystemApp 61 | + ")" 62 | , AppInfo.APP_PACKAGE_NAME 63 | , AppInfo.APP_NAME 64 | , AppInfo.APP_ICON 65 | , AppInfo.IS_ENABLE 66 | , AppInfo.IS_SYSTEM_APP 67 | 68 | ); 69 | return createTable; 70 | } 71 | 72 | @Override 73 | public void onCreate(SQLiteDatabase db) { 74 | db.execSQL(createTable(TABLE_NAME_APP_INFO)); 75 | db.execSQL(createTable(TABLE_NAME_SHORTCUT_APP_INFO)); 76 | } 77 | 78 | @Override 79 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 80 | if (oldVersion == 1 && newVersion == 2) { 81 | // on upgrade drop older tables 82 | db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME_APP_INFO); 83 | // create new table 84 | onCreate(db); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/fragment/ComponentDetailsFragment.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.fragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.widget.DividerItemDecoration; 5 | import android.support.v7.widget.LinearLayoutManager; 6 | import android.support.v7.widget.RecyclerView; 7 | import android.view.View; 8 | 9 | import com.science.baserecyclerviewadapter.interfaces.OnItemClickListener; 10 | import com.sscience.stopapp.R; 11 | import com.sscience.stopapp.activity.ComponentDetailsActivity; 12 | import com.sscience.stopapp.adapter.ComponentDetailsAdapter; 13 | import com.sscience.stopapp.base.BaseFragment; 14 | import com.sscience.stopapp.bean.ComponentInfo; 15 | import com.sscience.stopapp.presenter.ComponentDetailsContract; 16 | import com.sscience.stopapp.presenter.ComponentDetailsPresenter; 17 | 18 | import java.util.List; 19 | 20 | import static com.sscience.stopapp.activity.ComponentDetailsActivity.EXTRA_APP_PACKAGE_NAME; 21 | import static com.sscience.stopapp.fragment.AppListFragment.TAB_CATEGORY; 22 | 23 | /** 24 | * @author SScience 25 | * @description 26 | * @email chentushen.science@gmail.com 27 | * @data 2017/4/4 28 | */ 29 | public class ComponentDetailsFragment extends BaseFragment implements ComponentDetailsContract.View { 30 | 31 | private ComponentDetailsContract.Presenter mPresenter; 32 | private ComponentDetailsAdapter mComponentDetailsAdapter; 33 | private String packageName; 34 | 35 | public static ComponentDetailsFragment newInstance(int tabCategory) { 36 | ComponentDetailsFragment fragment = new ComponentDetailsFragment(); 37 | Bundle args = new Bundle(); 38 | args.putInt(TAB_CATEGORY, tabCategory); 39 | fragment.setArguments(args); 40 | return fragment; 41 | } 42 | 43 | @Override 44 | protected int getContentLayout() { 45 | return R.layout.fragment_app_list; 46 | } 47 | 48 | @Override 49 | protected void doCreateView(View view) { 50 | new ComponentDetailsPresenter(getActivity(), this); 51 | RecyclerView mRecyclerView = (RecyclerView) view.findViewById(R.id.recyclerView); 52 | mRecyclerView.setHasFixedSize(true); 53 | LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); 54 | mRecyclerView.setLayoutManager(layoutManager); 55 | mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), layoutManager.getOrientation())); 56 | 57 | mComponentDetailsAdapter = new ComponentDetailsAdapter(getActivity(), mRecyclerView); 58 | mRecyclerView.setAdapter(mComponentDetailsAdapter); 59 | 60 | int tabCategory = getArguments().getInt(TAB_CATEGORY); 61 | packageName = getActivity().getIntent().getStringExtra(EXTRA_APP_PACKAGE_NAME); 62 | mPresenter.getComponent(tabCategory, packageName); 63 | 64 | initListener(); 65 | } 66 | 67 | private void initListener() { 68 | mComponentDetailsAdapter.setOnItemClickListener(new OnItemClickListener() { 69 | @Override 70 | public void onItemClick(ComponentInfo componentInfo, int position) { 71 | mPresenter.pmComponent(componentInfo, position); 72 | } 73 | }); 74 | } 75 | 76 | @Override 77 | public void onLazyLoad() { 78 | 79 | } 80 | 81 | @Override 82 | public void setPresenter(ComponentDetailsContract.Presenter presenter) { 83 | if (presenter != null) { 84 | mPresenter = presenter; 85 | } 86 | } 87 | 88 | @Override 89 | public void getComponent(List list) { 90 | if (list.isEmpty()) { 91 | mComponentDetailsAdapter.showLoadFailed(R.drawable.empty 92 | , getResources().getString(R.string.no_data), ""); 93 | } else { 94 | mComponentDetailsAdapter.setData(list); 95 | } 96 | } 97 | 98 | @Override 99 | public void onRoot(boolean isRoot, ComponentInfo componentInfo, int position) { 100 | if (isRoot) { 101 | componentInfo.setEnable(!componentInfo.isEnable()); 102 | mComponentDetailsAdapter.updateItem(position, componentInfo); 103 | } else { 104 | snackBarShow(((ComponentDetailsActivity) getActivity()).mCoordinatorLayout 105 | , getString(R.string.if_want_to_use_please_grant_app_root)); 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/model/GetAppsCallback.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.model; 2 | 3 | import com.sscience.stopapp.bean.AppInfo; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author SScience 9 | * @description 10 | * @email chentushen.science@gmail.com 11 | * @data 2017/4/4 12 | */ 13 | public interface GetAppsCallback { 14 | 15 | /** 16 | * 如果appList为null, 则未获取root权限 17 | * 18 | * @param appList 19 | */ 20 | void onAppsLoaded(List appList); 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/model/GetComponentCallback.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.model; 2 | 3 | import com.sscience.stopapp.bean.ComponentInfo; 4 | 5 | import java.util.List; 6 | 7 | /** 8 | * @author SScience 9 | * @description 10 | * @email chentushen.science@gmail.com 11 | * @data 2017/4/4 12 | */ 13 | public interface GetComponentCallback { 14 | 15 | /** 16 | * 如果appList为null, 则未获取root权限 17 | * 18 | * @param componentList 19 | */ 20 | void onComponentLoaded(List componentList); 21 | } 22 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/model/GetRootCallback.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.model; 2 | 3 | /** 4 | * @author SScience 5 | * @description 6 | * @email chentushen.science@gmail.com 7 | * @data 2017/4/4 8 | */ 9 | public interface GetRootCallback { 10 | 11 | void onRoot(boolean isRoot); 12 | } 13 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/presenter/AppsContract.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.presenter; 2 | 3 | import com.sscience.stopapp.base.BasePresenter; 4 | import com.sscience.stopapp.base.BaseView; 5 | import com.sscience.stopapp.bean.AppInfo; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author SScience 11 | * @description 12 | * @email chentushen.science@gmail.com 13 | * @data 2017/1/29 14 | */ 15 | 16 | public interface AppsContract { 17 | 18 | interface View extends BaseView { 19 | void getApps(List apps); 20 | 21 | void hadAddDisableApps(); 22 | 23 | void addDisableAppsSuccess(); 24 | 25 | void getRootError(String cmd); 26 | 27 | void uninstallSuccess(String appName, int position); 28 | 29 | void ableApp(AppInfo appInfo, int position, boolean isChecked, boolean isAbleApp); 30 | } 31 | 32 | interface Presenter extends BasePresenter { 33 | void getApps(int appStyle); 34 | 35 | void addDisableAppsSuccess(List appList); 36 | 37 | void uninstallApp(AppInfo appInfo, int position); 38 | 39 | void addDisableApps(AppInfo appInfo); 40 | 41 | void ableApp(AppInfo appInfo, int position, boolean isChecked); 42 | 43 | List getApps(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/presenter/AppsPresenter.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.presenter; 2 | 3 | import android.content.Context; 4 | 5 | import com.sscience.stopapp.bean.AppInfo; 6 | import com.sscience.stopapp.database.AppInfoDBController; 7 | import com.sscience.stopapp.database.AppInfoDBOpenHelper; 8 | import com.sscience.stopapp.model.AppsRepository; 9 | import com.sscience.stopapp.model.GetAppsCallback; 10 | import com.sscience.stopapp.model.GetRootCallback; 11 | import com.sscience.stopapp.widget.AppInfoComparator; 12 | 13 | import java.util.ArrayList; 14 | import java.util.Collections; 15 | import java.util.List; 16 | 17 | import static com.sscience.stopapp.model.AppsRepository.COMMAND_ENABLE; 18 | import static com.sscience.stopapp.model.AppsRepository.COMMAND_UNINSTALL; 19 | 20 | /** 21 | * @author SScience 22 | * @description 23 | * @email chentushen.science@gmail.com 24 | * @data 2017/1/29 25 | */ 26 | 27 | public class AppsPresenter implements AppsContract.Presenter { 28 | 29 | private Context mContext; 30 | private AppsContract.View mView; 31 | private AppsRepository mAppsRepository; 32 | private List mAppInfos; 33 | private AppInfoDBController mAppInfoDBController; 34 | 35 | public AppsPresenter(Context context, AppsContract.View view) { 36 | mContext = context; 37 | mView = view; 38 | mView.setPresenter(this); 39 | mAppsRepository = new AppsRepository(context); 40 | mAppInfos = new ArrayList<>(); 41 | mAppInfoDBController = new AppInfoDBController(mContext); 42 | } 43 | 44 | @Override 45 | public void start() { 46 | 47 | } 48 | 49 | @Override 50 | public void getApps(int appFlag) { 51 | mAppsRepository.getApps(appFlag, new GetAppsCallback() { 52 | @Override 53 | public void onAppsLoaded(List apps) { 54 | Collections.sort(apps, new AppInfoComparator());// 排序 55 | mAppInfos = apps; 56 | mView.getApps(apps); 57 | } 58 | }); 59 | } 60 | 61 | @Override 62 | public List getApps() { 63 | return mAppInfos; 64 | } 65 | 66 | @Override 67 | public void addDisableApps(AppInfo appInfo) { 68 | List disableApps = mAppInfoDBController.getDisableApps(AppInfoDBOpenHelper.TABLE_NAME_APP_INFO); 69 | if (disableApps.contains(appInfo)) { 70 | mView.hadAddDisableApps(); 71 | return; 72 | } 73 | List appList = new ArrayList<>(); 74 | appList.add(appInfo); 75 | addDisableAppsSuccess(appList); 76 | } 77 | 78 | @Override 79 | public void uninstallApp(final AppInfo appInfo, final int position) { 80 | mAppsRepository.getRoot(COMMAND_UNINSTALL + appInfo.getAppPackageName(), new GetRootCallback() { 81 | 82 | @Override 83 | public void onRoot(boolean isRoot) { 84 | if (isRoot) { 85 | mAppInfoDBController.deleteDisableApp(appInfo.getAppPackageName(), AppInfoDBOpenHelper.TABLE_NAME_APP_INFO); 86 | mView.uninstallSuccess(appInfo.getAppName(), position); 87 | } else { 88 | mView.getRootError(COMMAND_UNINSTALL); 89 | } 90 | } 91 | }); 92 | } 93 | 94 | @Override 95 | public void addDisableAppsSuccess(List appList) { 96 | for (AppInfo appInfo : appList) { 97 | mAppInfoDBController.addDisableApp(appInfo, AppInfoDBOpenHelper.TABLE_NAME_APP_INFO); 98 | } 99 | mView.addDisableAppsSuccess(); 100 | } 101 | 102 | @Override 103 | public void ableApp(final AppInfo appInfo, final int position, final boolean isChecked) { 104 | mAppsRepository.getRoot( 105 | (isChecked ? AppsRepository.COMMAND_DISABLE : COMMAND_ENABLE) + appInfo.getAppPackageName(), 106 | new GetRootCallback() { 107 | @Override 108 | public void onRoot(boolean isRoot) { 109 | if (!isRoot) { 110 | mView.ableApp(appInfo, position, isChecked, false); 111 | mView.getRootError(isChecked ? AppsRepository.COMMAND_DISABLE : COMMAND_ENABLE); 112 | } 113 | } 114 | }); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/presenter/ComponentDetailsContract.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.presenter; 2 | 3 | import com.sscience.stopapp.base.BasePresenter; 4 | import com.sscience.stopapp.base.BaseView; 5 | import com.sscience.stopapp.bean.ComponentInfo; 6 | 7 | import java.util.List; 8 | 9 | /** 10 | * @author SScience 11 | * @description 12 | * @email chentushen.science@gmail.com 13 | * @data 2017/4/4 14 | */ 15 | public interface ComponentDetailsContract { 16 | 17 | interface View extends BaseView { 18 | void getComponent(List list); 19 | 20 | void onRoot(boolean isRoot, ComponentInfo componentInfo, int position); 21 | } 22 | 23 | interface Presenter extends BasePresenter { 24 | void getComponent(int tabCategory, String packageName); 25 | 26 | void pmComponent(ComponentInfo componentInfo, int position); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/presenter/ComponentDetailsPresenter.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.presenter; 2 | 3 | import android.content.Context; 4 | 5 | import com.sscience.stopapp.bean.ComponentInfo; 6 | import com.sscience.stopapp.model.AppsRepository; 7 | import com.sscience.stopapp.model.GetRootCallback; 8 | import com.sscience.stopapp.widget.ComponentComparator; 9 | 10 | import java.util.Collections; 11 | import java.util.List; 12 | 13 | /** 14 | * @author SScience 15 | * @description 16 | * @email chentushen.science@gmail.com 17 | * @data 2017/4/4 18 | */ 19 | public class ComponentDetailsPresenter implements ComponentDetailsContract.Presenter { 20 | 21 | private ComponentDetailsContract.View mView; 22 | private AppsRepository mAppsRepository; 23 | 24 | public ComponentDetailsPresenter(Context context, ComponentDetailsContract.View view) { 25 | mView = view; 26 | mView.setPresenter(this); 27 | mAppsRepository = new AppsRepository(context); 28 | } 29 | 30 | @Override 31 | public void start() { 32 | 33 | } 34 | 35 | @Override 36 | public void getComponent(int tabCategory, String packageName) { 37 | List mComponents = mAppsRepository.getComponentInfo(packageName, tabCategory); 38 | Collections.sort(mComponents, new ComponentComparator());// 排序 39 | mView.getComponent(mComponents); 40 | } 41 | 42 | @Override 43 | public void pmComponent(final ComponentInfo componentInfo, final int position) { 44 | final String cmd = (componentInfo.isEnable() ? AppsRepository.COMMAND_DISABLE : AppsRepository.COMMAND_ENABLE) 45 | + componentInfo.getPackageName() + "/" 46 | + componentInfo.getComponentName(); 47 | mAppsRepository.getRoot(cmd, new GetRootCallback() { 48 | @Override 49 | public void onRoot(boolean isRoot) { 50 | mView.onRoot(isRoot, componentInfo, position); 51 | } 52 | }); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/presenter/DisableAppsContract.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.presenter; 2 | 3 | import android.graphics.Bitmap; 4 | 5 | import com.sscience.stopapp.base.BasePresenter; 6 | import com.sscience.stopapp.base.BaseView; 7 | import com.sscience.stopapp.bean.AppInfo; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author SScience 13 | * @description 14 | * @email chentushen.science@gmail.com 15 | * @data 2017/1/15 16 | */ 17 | 18 | public interface DisableAppsContract { 19 | 20 | interface View extends BaseView { 21 | /** 22 | * 获取apps,包括所有apps;系统apps;用户apps;停用apps 23 | * 24 | * @param apps 25 | */ 26 | void getApps(List apps); 27 | 28 | void upDateItemIfLaunch(AppInfo appInfo, int position); 29 | 30 | /** 31 | * 停用或启用app成功 32 | * 33 | * @param apps 停用或启用app成功后需要更新列表(app停用or启用状态) 34 | */ 35 | void getRootSuccess(List apps, List appsNew); 36 | 37 | /** 38 | * 获取root失败 39 | */ 40 | void getRootError(); 41 | 42 | /** 43 | * 卸载app 44 | * 45 | * @param appName 46 | * @param position 47 | */ 48 | void uninstallSuccess(String appName, int position); 49 | } 50 | 51 | interface Presenter extends BasePresenter { 52 | 53 | /** 54 | * 获取apps。 55 | * 56 | * @param appFlag 0:all;1:system;2:user;3:disable 57 | */ 58 | void getDisableAppsFromRoot(int appFlag); 59 | 60 | void pmCommand(String cmd, int flag, AppInfo appInfo, int position); 61 | 62 | /** 63 | * 在停用(待停用)列表点击item启动app 64 | * 65 | * @param appInfo 点击启动的app信息 66 | * @param position 点击启动的位置 67 | */ 68 | void launchApp(AppInfo appInfo, int position); 69 | 70 | /** 71 | * 停用(待停用)列表批量操作app:停用apps or 清除apps 72 | */ 73 | void batchApps(int type); 74 | 75 | /** 76 | * 得到停用(待停用)列表apps包名 77 | * 78 | * @return 79 | */ 80 | List getDisableAppPackageNames(); 81 | 82 | void uninstallApp(AppInfo appInfo, int position); 83 | 84 | void updateAppName(String packageName, String appName); 85 | 86 | void updateAppIcon(String packageName, Bitmap appIcon); 87 | 88 | void updateHomeApps(); 89 | 90 | void cancelTask(); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/service/MyAccessibilityService.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.service; 2 | 3 | import android.accessibilityservice.AccessibilityService; 4 | import android.content.Intent; 5 | import android.os.CountDownTimer; 6 | import android.text.TextUtils; 7 | import android.view.KeyEvent; 8 | import android.view.accessibility.AccessibilityEvent; 9 | import android.widget.Toast; 10 | 11 | import com.science.myloggerlibrary.MyLogger; 12 | import com.sscience.stopapp.R; 13 | import com.sscience.stopapp.activity.SettingActivity; 14 | import com.sscience.stopapp.database.AppInfoDBController; 15 | import com.sscience.stopapp.database.AppInfoDBOpenHelper; 16 | import com.sscience.stopapp.model.AppsRepository; 17 | import com.sscience.stopapp.model.GetRootCallback; 18 | import com.sscience.stopapp.presenter.DisableAppsPresenter; 19 | import com.sscience.stopapp.util.CommonUtil; 20 | import com.sscience.stopapp.util.SharedPreferenceUtil; 21 | 22 | /** 23 | * @author SScience 24 | * @description 25 | * @email chentushen.science@gmail.com 26 | * @data 2017/4/2 27 | */ 28 | public class MyAccessibilityService extends AccessibilityService { 29 | 30 | private AppInfoDBController mDBController; 31 | private AppsRepository mAppsRepository; 32 | private CountDownTimer mCountDownTimer; 33 | private String foregroundPackageName; 34 | private boolean isActionBack; 35 | 36 | @Override 37 | public void onAccessibilityEvent(AccessibilityEvent event) { 38 | if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) { 39 | String packageName = (String) SharedPreferenceUtil.get(this, DisableAppsPresenter.SP_LAUNCH_APP, ""); 40 | int spAutoDisable = (int) SharedPreferenceUtil.get(this, SettingActivity.SP_AUTO_DISABLE_APPS, -1); 41 | if (spAutoDisable != -1 && spAutoDisable == 666) { 42 | actionBackDisableApp(event, packageName); 43 | } 44 | foregroundPackageName = event.getPackageName().toString(); 45 | if (spAutoDisable != -1 && spAutoDisable != 666) { 46 | actionHomeDisableApp(spAutoDisable, foregroundPackageName, packageName); 47 | } 48 | } 49 | } 50 | 51 | @Override 52 | public boolean onKeyEvent(KeyEvent event) { 53 | int keyCode = event.getKeyCode(); 54 | switch (keyCode) { 55 | case KeyEvent.KEYCODE_BACK: 56 | isActionBack = true; 57 | break; 58 | 59 | default: 60 | isActionBack = false; 61 | break; 62 | } 63 | return super.onKeyEvent(event); 64 | } 65 | 66 | /** 67 | * 按返回键推出app自动冻结(目前只支持物理返回按键) 68 | */ 69 | private void actionBackDisableApp(AccessibilityEvent event, final String packageName) { 70 | if (!TextUtils.equals(foregroundPackageName, packageName)) { 71 | // 如果上一个前台应用不是启动的停用app,表明早已退出启动的停用app 72 | return; 73 | } 74 | // 获取当前的前台应用,如果当前的前台应用不是启动的停用app,且是按了返回键,则是按返回键退出app 75 | foregroundPackageName = event.getPackageName().toString(); 76 | if (!TextUtils.equals(foregroundPackageName, packageName) && isActionBack) { 77 | isActionBack = false; 78 | mAppsRepository.getRoot(AppsRepository.COMMAND_DISABLE + packageName, new GetRootCallback() { 79 | @Override 80 | public void onRoot(boolean isRoot) { 81 | if (isRoot) { 82 | MyLogger.e("已退出App自动冻结的App:" + packageName); 83 | updateDisableApp(packageName); 84 | } else { 85 | Toast.makeText(MyAccessibilityService.this, getString(R.string.if_want_to_use_please_grant_app_root), Toast.LENGTH_SHORT).show(); 86 | } 87 | } 88 | }); 89 | mAppsRepository.cancelTask(); 90 | } 91 | } 92 | 93 | /** 94 | * 回到桌面自动冻结(可一定时间后冻结) 95 | */ 96 | private void actionHomeDisableApp(int spAutoDisable, String foregroundPackageName, final String packageName) { 97 | if (TextUtils.equals(foregroundPackageName, packageName)) { 98 | if (mCountDownTimer != null) { 99 | mCountDownTimer.cancel(); 100 | mCountDownTimer = null; 101 | } 102 | } 103 | if (TextUtils.isEmpty(packageName) || !TextUtils.equals(foregroundPackageName, CommonUtil.getLauncherPackageName(this))) { 104 | return; 105 | } 106 | if (mCountDownTimer == null) { 107 | mCountDownTimer = new CountDownTimer(spAutoDisable * 1000, 1000) { 108 | @Override 109 | public void onTick(long millisUntilFinished) { 110 | } 111 | 112 | @Override 113 | public void onFinish() { 114 | mAppsRepository.getRoot(AppsRepository.COMMAND_DISABLE + packageName, new GetRootCallback() { 115 | @Override 116 | public void onRoot(boolean isRoot) { 117 | if (isRoot) { 118 | MyLogger.e("回到桌面已自动冻结的App:" + packageName); 119 | updateDisableApp(packageName); 120 | } else { 121 | Toast.makeText(MyAccessibilityService.this, getString(R.string.if_want_to_use_please_grant_app_root), Toast.LENGTH_SHORT).show(); 122 | } 123 | } 124 | }); 125 | mAppsRepository.cancelTask(); 126 | } 127 | }; 128 | mCountDownTimer.start(); 129 | } 130 | } 131 | 132 | private void updateDisableApp(String packageName) { 133 | // 切换到主界面时,更新app列表 134 | SharedPreferenceUtil.put(MyAccessibilityService.this, RootActionIntentService.APP_UPDATE_HOME_APPS, true); 135 | // 避免重复更新 136 | SharedPreferenceUtil.put(MyAccessibilityService.this, DisableAppsPresenter.SP_LAUNCH_APP, ""); 137 | mDBController.updateDisableApp(packageName, 0, AppInfoDBOpenHelper.TABLE_NAME_APP_INFO); 138 | } 139 | 140 | @Override 141 | protected void onServiceConnected() { 142 | MyLogger.e("无障碍服务已开启"); 143 | mDBController = new AppInfoDBController(this); 144 | mAppsRepository = new AppsRepository(this); 145 | } 146 | 147 | @Override 148 | public boolean onUnbind(Intent intent) { 149 | MyLogger.e("无障碍服务已关闭"); 150 | if (mCountDownTimer != null) { 151 | mCountDownTimer.cancel(); 152 | mCountDownTimer = null; 153 | } 154 | mDBController = null; 155 | mAppsRepository = null; 156 | return super.onUnbind(intent); 157 | } 158 | 159 | @Override 160 | public void onInterrupt() { 161 | 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/service/RootActionIntentService.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.service; 2 | 3 | import android.app.IntentService; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.os.Handler; 7 | import android.widget.Toast; 8 | 9 | import com.science.myloggerlibrary.MyLogger; 10 | import com.sscience.stopapp.R; 11 | import com.sscience.stopapp.activity.SettingActivity; 12 | import com.sscience.stopapp.activity.ShortcutActivity; 13 | import com.sscience.stopapp.database.AppInfoDBController; 14 | import com.sscience.stopapp.database.AppInfoDBOpenHelper; 15 | import com.sscience.stopapp.model.AppsRepository; 16 | import com.sscience.stopapp.model.GetRootCallback; 17 | import com.sscience.stopapp.presenter.DisableAppsPresenter; 18 | import com.sscience.stopapp.util.CommonUtil; 19 | import com.sscience.stopapp.util.SharedPreferenceUtil; 20 | import com.sscience.stopapp.util.ShortcutsManager; 21 | 22 | /** 23 | * @author SScience 24 | * @description 25 | * @email chentushen.science@gmail.com 26 | * @data 2017/2/8 27 | */ 28 | 29 | public class RootActionIntentService extends IntentService { 30 | 31 | private Handler mHandler; 32 | public static final String APP_UPDATE_HOME_APPS = "app_update_home_apps"; 33 | 34 | /** 35 | * Creates an IntentService. Invoked by your subclass's constructor. 36 | *

37 | * Used to name the worker thread, important only for debugging. 38 | */ 39 | public RootActionIntentService() { 40 | super("RootActionIntentService"); 41 | mHandler = new Handler(); 42 | } 43 | 44 | @Override 45 | protected void onHandleIntent(Intent intent) { 46 | String packageName = intent.getStringExtra(ShortcutActivity.EXTRA_PACKAGE_NAME); 47 | MyLogger.e("-----------" + packageName); 48 | launchAppIntent(packageName); 49 | stopSelf(); 50 | } 51 | 52 | private void launchAppIntent(String packageName) { 53 | if (!CommonUtil.isAppInstalled(RootActionIntentService.this, packageName)) { 54 | ShortcutsManager manager = new ShortcutsManager(RootActionIntentService.this); 55 | manager.removeShortcut(packageName, getString(R.string.app_had_uninstall)); 56 | } else { 57 | try { 58 | // 存储启动的app,用于自动冻结 59 | SharedPreferenceUtil.put(this, DisableAppsPresenter.SP_LAUNCH_APP, packageName); 60 | Intent resolveIntent = getPackageManager().getLaunchIntentForPackage(packageName); 61 | startActivity(resolveIntent); 62 | } catch (NullPointerException e) { 63 | enableApp(packageName); 64 | } 65 | int spAutoDisable = (int) SharedPreferenceUtil.get(this, SettingActivity.SP_AUTO_DISABLE_APPS, -1); 66 | if (spAutoDisable != -1) { 67 | AppsRepository appsRepository = new AppsRepository(this); 68 | appsRepository.openAccessibilityServices(null); 69 | } 70 | } 71 | } 72 | 73 | private void enableApp(final String packageName) { 74 | new AppsRepository(RootActionIntentService.this).getRoot(AppsRepository.COMMAND_ENABLE + packageName, new GetRootCallback() { 75 | 76 | @Override 77 | public void onRoot(boolean isRoot) { 78 | if (isRoot) { 79 | // 已停用的app启动,则需更新主页app为启用 80 | SharedPreferenceUtil.put(RootActionIntentService.this, APP_UPDATE_HOME_APPS, true); 81 | AppInfoDBController appInfoDBController = new AppInfoDBController(RootActionIntentService.this); 82 | appInfoDBController.updateDisableApp(packageName, 1, AppInfoDBOpenHelper.TABLE_NAME_APP_INFO); 83 | launchAppIntent(packageName); 84 | } else { 85 | mHandler.post(new DisplayToast(RootActionIntentService.this 86 | , getString(R.string.if_want_to_use_please_grant_app_root))); 87 | } 88 | } 89 | }); 90 | } 91 | 92 | public class DisplayToast implements Runnable { 93 | private final Context mContext; 94 | String mText; 95 | 96 | public DisplayToast(Context mContext, String text) { 97 | this.mContext = mContext; 98 | mText = text; 99 | } 100 | 101 | public void run() { 102 | Toast.makeText(mContext, mText, Toast.LENGTH_SHORT).show(); 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/util/BackgroundWorker.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.util; 2 | 3 | import java.util.concurrent.ExecutorService; 4 | import java.util.concurrent.Executors; 5 | import java.util.concurrent.Future; 6 | 7 | /** 8 | * @author SScience 9 | * @description 线程池 10 | * @email chentushen.science@gmail.com 11 | * @data 2017/1/15 12 | */ 13 | 14 | public class BackgroundWorker { 15 | private ExecutorService mThreadPool; 16 | private static BackgroundWorker mWorker; 17 | 18 | private BackgroundWorker() { 19 | mThreadPool = Executors.newCachedThreadPool(); 20 | } 21 | 22 | public static BackgroundWorker getInstance() { 23 | if (mWorker == null) { 24 | synchronized (BackgroundWorker.class) { 25 | if (mWorker == null) { 26 | mWorker = new BackgroundWorker(); 27 | } 28 | } 29 | } 30 | return mWorker; 31 | } 32 | 33 | public Future submitTask(Runnable task) { 34 | return mThreadPool.submit(task); 35 | } 36 | 37 | public void executeTask(Runnable task) { 38 | mThreadPool.execute(task); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/util/DiffCallBack.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.util; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v7.util.DiffUtil; 6 | 7 | import com.sscience.stopapp.bean.AppInfo; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | * @author SScience 13 | * @description 14 | * @email chentushen.science@gmail.com 15 | * @data 2017/1/15 16 | */ 17 | 18 | public class DiffCallBack extends DiffUtil.Callback { 19 | 20 | public static final String BUNDLE_PAYLOAD = "bundle_payload"; 21 | private List mOldData, mNewData; 22 | 23 | public DiffCallBack(List oldData, List newData) { 24 | mOldData = oldData; 25 | mNewData = newData; 26 | } 27 | 28 | @Override 29 | public int getOldListSize() { 30 | return mOldData != null ? mOldData.size() : 0; 31 | } 32 | 33 | @Override 34 | public int getNewListSize() { 35 | return mNewData != null ? mNewData.size() : 0; 36 | } 37 | 38 | @Override 39 | public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) { 40 | return mOldData.get(oldItemPosition).getAppPackageName().equals(mNewData.get(newItemPosition).getAppPackageName()); 41 | } 42 | 43 | @Override 44 | public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) { 45 | if (mOldData.get(oldItemPosition).isEnable() != mNewData.get(newItemPosition).isEnable()) { 46 | return false; 47 | } 48 | return true; 49 | } 50 | 51 | @Nullable 52 | @Override 53 | public Object getChangePayload(int oldItemPosition, int newItemPosition) { 54 | AppInfo oldBean = mOldData.get(oldItemPosition); 55 | AppInfo newBean = mNewData.get(newItemPosition); 56 | Bundle payLoad = new Bundle(); 57 | if (oldBean.isEnable() != newBean.isEnable()) { 58 | payLoad.putInt(BUNDLE_PAYLOAD, newBean.isEnable()); 59 | } 60 | if (payLoad == null) { 61 | return null; 62 | } 63 | return payLoad; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/util/ImageUtil.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.util; 2 | 3 | import android.content.Context; 4 | import android.database.Cursor; 5 | import android.graphics.Bitmap; 6 | import android.graphics.BitmapFactory; 7 | import android.graphics.Canvas; 8 | import android.graphics.Matrix; 9 | import android.graphics.Paint; 10 | import android.media.ExifInterface; 11 | import android.net.Uri; 12 | import android.provider.MediaStore; 13 | 14 | import java.io.FileInputStream; 15 | import java.io.FileNotFoundException; 16 | import java.io.IOException; 17 | import java.io.InputStream; 18 | 19 | /** 20 | * @author SScience 21 | * @description 22 | * @email chentushen.science@gmail.com 23 | * @data 2017/4/12 24 | */ 25 | 26 | public class ImageUtil { 27 | 28 | public static Bitmap getScaledBitmap(Context context, Uri imageUri, float maxWidth, float maxHeight) { 29 | String filePath = getRealPathFromURI(context, imageUri); 30 | Bitmap scaledBitmap = null; 31 | 32 | BitmapFactory.Options options = new BitmapFactory.Options(); 33 | 34 | //by setting this field as true, the actual bitmap pixels are not loaded in the memory. Just the bounds are loaded. If 35 | //you try the use the bitmap here, you will get null. 36 | options.inJustDecodeBounds = true; 37 | Bitmap bmp = BitmapFactory.decodeFile(filePath, options); 38 | if (bmp == null) { 39 | InputStream inputStream = null; 40 | try { 41 | inputStream = new FileInputStream(filePath); 42 | BitmapFactory.decodeStream(inputStream, null, options); 43 | inputStream.close(); 44 | } catch (FileNotFoundException exception) { 45 | exception.printStackTrace(); 46 | } catch (IOException exception) { 47 | exception.printStackTrace(); 48 | } 49 | } 50 | 51 | int actualHeight = options.outHeight; 52 | int actualWidth = options.outWidth; 53 | 54 | if (actualHeight == -1 || actualWidth == -1){ 55 | try { 56 | ExifInterface exifInterface = new ExifInterface(filePath); 57 | actualHeight = exifInterface.getAttributeInt(ExifInterface.TAG_IMAGE_LENGTH, ExifInterface.ORIENTATION_NORMAL);//获取图片的高度 58 | actualWidth = exifInterface.getAttributeInt(ExifInterface.TAG_IMAGE_WIDTH, ExifInterface.ORIENTATION_NORMAL);//获取图片的宽度 59 | } catch (IOException e) { 60 | e.printStackTrace(); 61 | } 62 | } 63 | 64 | if (actualWidth < 0 || actualHeight < 0) { 65 | Bitmap bitmap2 = BitmapFactory.decodeFile(filePath); 66 | if (bitmap2 != null){ 67 | actualWidth = bitmap2.getWidth(); 68 | actualHeight = bitmap2.getHeight(); 69 | }else{ 70 | return null; 71 | } 72 | } 73 | 74 | float imgRatio = (float) actualWidth / actualHeight; 75 | float maxRatio = maxWidth / maxHeight; 76 | 77 | //width and height values are set maintaining the aspect ratio of the image 78 | if (actualHeight > maxHeight || actualWidth > maxWidth) { 79 | if (imgRatio < maxRatio) { 80 | imgRatio = maxHeight / actualHeight; 81 | actualWidth = (int) (imgRatio * actualWidth); 82 | actualHeight = (int) maxHeight; 83 | } else if (imgRatio > maxRatio) { 84 | imgRatio = maxWidth / actualWidth; 85 | actualHeight = (int) (imgRatio * actualHeight); 86 | actualWidth = (int) maxWidth; 87 | } else { 88 | actualHeight = (int) maxHeight; 89 | actualWidth = (int) maxWidth; 90 | } 91 | } 92 | 93 | //setting inSampleSize value allows to load a scaled down version of the original image 94 | options.inSampleSize = calculateInSampleSize(options, actualWidth, actualHeight); 95 | 96 | //inJustDecodeBounds set to false to load the actual bitmap 97 | options.inJustDecodeBounds = false; 98 | 99 | //this options allow android to claim the bitmap memory if it runs low on memory 100 | options.inPurgeable = true; 101 | options.inInputShareable = true; 102 | options.inTempStorage = new byte[16 * 1024]; 103 | 104 | try { 105 | //load the bitmap getTempFile its path 106 | bmp = BitmapFactory.decodeFile(filePath, options); 107 | if (bmp == null) { 108 | InputStream inputStream = null; 109 | try { 110 | inputStream = new FileInputStream(filePath); 111 | BitmapFactory.decodeStream(inputStream, null, options); 112 | inputStream.close(); 113 | } catch (FileNotFoundException exception) { 114 | exception.printStackTrace(); 115 | } catch (IOException exception) { 116 | exception.printStackTrace(); 117 | } 118 | } 119 | } catch (OutOfMemoryError exception) { 120 | exception.printStackTrace(); 121 | } 122 | try { 123 | scaledBitmap = Bitmap.createBitmap(actualWidth, actualHeight, Bitmap.Config.ARGB_8888); 124 | } catch (OutOfMemoryError exception) { 125 | exception.printStackTrace(); 126 | } 127 | 128 | float ratioX = actualWidth / (float) options.outWidth; 129 | float ratioY = actualHeight / (float) options.outHeight; 130 | 131 | Matrix scaleMatrix = new Matrix(); 132 | scaleMatrix.setScale(ratioX, ratioY, 0, 0); 133 | 134 | Canvas canvas = new Canvas(scaledBitmap); 135 | canvas.setMatrix(scaleMatrix); 136 | canvas.drawBitmap(bmp, 0, 0, new Paint(Paint.FILTER_BITMAP_FLAG)); 137 | 138 | //check the rotation of the image and display it properly 139 | ExifInterface exif; 140 | try { 141 | exif = new ExifInterface(filePath); 142 | int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 0); 143 | Matrix matrix = new Matrix(); 144 | if (orientation == 6) { 145 | matrix.postRotate(90); 146 | } else if (orientation == 3) { 147 | matrix.postRotate(180); 148 | } else if (orientation == 8) { 149 | matrix.postRotate(270); 150 | } 151 | scaledBitmap = Bitmap.createBitmap(scaledBitmap, 0, 0, 152 | scaledBitmap.getWidth(), scaledBitmap.getHeight(), 153 | matrix, true); 154 | } catch (IOException e) { 155 | e.printStackTrace(); 156 | } 157 | 158 | return scaledBitmap; 159 | } 160 | 161 | /** 162 | * 计算inSampleSize 163 | */ 164 | private static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) { 165 | final int height = options.outHeight; 166 | final int width = options.outWidth; 167 | int inSampleSize = 1; 168 | 169 | if (height > reqHeight || width > reqWidth) { 170 | final int heightRatio = Math.round((float) height / (float) reqHeight); 171 | final int widthRatio = Math.round((float) width / (float) reqWidth); 172 | inSampleSize = heightRatio < widthRatio ? heightRatio : widthRatio; 173 | } 174 | 175 | final float totalPixels = width * height; 176 | final float totalReqPixelsCap = reqWidth * reqHeight * 2; 177 | 178 | while (totalPixels / (inSampleSize * inSampleSize) > totalReqPixelsCap) { 179 | inSampleSize++; 180 | } 181 | 182 | return inSampleSize; 183 | } 184 | 185 | //file uri to real location in filesystem 186 | public static String getRealPathFromURI(Context context, Uri uri) { 187 | Cursor cursor = context.getContentResolver().query(uri, null, null, null, null); 188 | if (cursor == null) { 189 | // Uri.fromFile(File file)生成的file://uri 190 | return uri.getPath(); 191 | } else { 192 | // content://uri 193 | cursor.moveToFirst(); 194 | int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA); 195 | return cursor.getString(idx); 196 | } 197 | } 198 | } 199 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/util/SharedPreferenceUtil.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.util; 2 | 3 | import android.content.Context; 4 | import android.content.SharedPreferences; 5 | import android.content.SharedPreferences.Editor; 6 | import android.support.v4.content.SharedPreferencesCompat; 7 | 8 | import java.util.Map; 9 | import java.util.Set; 10 | 11 | /** 12 | * @author SScience 13 | * @description 14 | * @email chentushen.science@gmail.com 15 | * @data 2016/11/27 16 | */ 17 | 18 | public class SharedPreferenceUtil { 19 | 20 | public static String FILL_NAME = "file_disable_apps"; 21 | 22 | /** 23 | * 存入某个key对应的value值 24 | * 25 | * @param context 26 | * @param key 27 | * @param value 28 | */ 29 | public static void put(Context context, String key, Object value) { 30 | SharedPreferences sp = context.getSharedPreferences(FILL_NAME, Context.MODE_PRIVATE); 31 | Editor edit = sp.edit(); 32 | if (value instanceof String) { 33 | edit.putString(key, (String) value); 34 | } else if (value instanceof Integer) { 35 | edit.putInt(key, (Integer) value); 36 | } else if (value instanceof Boolean) { 37 | edit.putBoolean(key, (Boolean) value); 38 | } else if (value instanceof Float) { 39 | edit.putFloat(key, (Float) value); 40 | } else if (value instanceof Long) { 41 | edit.putLong(key, (Long) value); 42 | } else if (value instanceof Set) { 43 | edit.putStringSet(key, (Set) value); 44 | } 45 | SharedPreferencesCompat.EditorCompat.getInstance().apply(edit); 46 | } 47 | 48 | /** 49 | * 得到某个key对应的值 50 | * 51 | * @param context 52 | * @param key 53 | * @param defValue 54 | * @return 55 | */ 56 | public static Object get(Context context, String key, Object defValue) { 57 | SharedPreferences sp = context.getSharedPreferences(FILL_NAME, Context.MODE_PRIVATE); 58 | if (defValue instanceof String) { 59 | return sp.getString(key, (String) defValue); 60 | } else if (defValue instanceof Integer) { 61 | return sp.getInt(key, (Integer) defValue); 62 | } else if (defValue instanceof Boolean) { 63 | return sp.getBoolean(key, (Boolean) defValue); 64 | } else if (defValue instanceof Float) { 65 | return sp.getFloat(key, (Float) defValue); 66 | } else if (defValue instanceof Long) { 67 | return sp.getLong(key, (Long) defValue); 68 | } else if (defValue instanceof Set) { 69 | return sp.getStringSet(key, (Set) defValue); 70 | } 71 | return null; 72 | } 73 | 74 | /** 75 | * 返回所有数据 76 | * 77 | * @param context 78 | * @return 79 | */ 80 | public static Map getAll(Context context) { 81 | SharedPreferences sp = context.getSharedPreferences(FILL_NAME, Context.MODE_PRIVATE); 82 | return sp.getAll(); 83 | } 84 | 85 | /** 86 | * 移除某个key值已经对应的值 87 | * 88 | * @param context 89 | * @param key 90 | */ 91 | public static void remove(Context context, String key) { 92 | SharedPreferences sp = context.getSharedPreferences(FILL_NAME, Context.MODE_PRIVATE); 93 | Editor edit = sp.edit(); 94 | edit.remove(key); 95 | SharedPreferencesCompat.EditorCompat.getInstance().apply(edit); 96 | } 97 | 98 | /** 99 | * 清除所有内容 100 | * 101 | * @param context 102 | */ 103 | public static void clear(Context context) { 104 | SharedPreferences sp = context.getSharedPreferences(FILL_NAME, Context.MODE_PRIVATE); 105 | Editor edit = sp.edit(); 106 | edit.clear(); 107 | SharedPreferencesCompat.EditorCompat.getInstance().apply(edit); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/util/ShortcutsManager.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.util; 2 | 3 | import android.content.Context; 4 | import android.content.Intent; 5 | import android.content.pm.ShortcutInfo; 6 | import android.content.pm.ShortcutManager; 7 | import android.graphics.drawable.Icon; 8 | import android.os.Build; 9 | 10 | import com.sscience.stopapp.R; 11 | import com.sscience.stopapp.activity.ShortcutActivity; 12 | import com.sscience.stopapp.bean.AppInfo; 13 | import com.sscience.stopapp.database.AppInfoDBController; 14 | import com.sscience.stopapp.database.AppInfoDBOpenHelper; 15 | 16 | import java.util.ArrayList; 17 | import java.util.Arrays; 18 | import java.util.List; 19 | 20 | /** 21 | * @author SScience 22 | * @description 23 | * @email chentushen.science@gmail.com 24 | * @data 2017/2/7 25 | */ 26 | 27 | public class ShortcutsManager { 28 | 29 | private Context mContext; 30 | public static final String SP_ADD_SHORTCUT_MODE = "sp_shortcut"; // shortcut添加方式 31 | public static final String SP_MANUAL_SHORTCUT = "sp_manual_shortcut"; // shortcut手动添加 32 | public static final String SP_AUTO_SHORTCUT = "sp_auto_shortcut"; // shortcut自动添加 33 | private ShortcutManager mShortcutManager; 34 | private AppInfoDBController mDBController; 35 | 36 | public ShortcutsManager(Context context) { 37 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { 38 | mContext = context; 39 | mShortcutManager = context.getSystemService(ShortcutManager.class); 40 | mDBController = new AppInfoDBController(context); 41 | } 42 | } 43 | 44 | /** 45 | * 添加App Shortcut 46 | */ 47 | public void addAppShortcut(List appList) { 48 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { 49 | List appInfoDB = new ArrayList<>( 50 | mDBController.getDisableApps(AppInfoDBOpenHelper.TABLE_NAME_SHORTCUT_APP_INFO)); 51 | 52 | for (AppInfo appInfo : appList) { 53 | if (!mDBController.searchApp(AppInfoDBOpenHelper.TABLE_NAME_SHORTCUT_APP_INFO, appInfo.getAppPackageName())) { 54 | appInfoDB.add(appInfo); 55 | } 56 | } 57 | 58 | mDBController.clearDisableApp(AppInfoDBOpenHelper.TABLE_NAME_SHORTCUT_APP_INFO); 59 | List shortcutList = new ArrayList<>(); 60 | for (int i = appInfoDB.size() - 1; i >= 0; i--) { 61 | if (shortcutList.size() < 4) { 62 | shortcutList.add(getShortcut(appInfoDB.get(i))); 63 | mDBController.addDisableApp(appInfoDB.get(i), AppInfoDBOpenHelper.TABLE_NAME_SHORTCUT_APP_INFO); 64 | } else { 65 | removeShortcut(appInfoDB.get(i).getAppPackageName(), mContext.getString(R.string.shortcut_num_limit)); 66 | } 67 | } 68 | mShortcutManager.setDynamicShortcuts(shortcutList); 69 | } 70 | } 71 | 72 | /** 73 | * 构造App Shortcut Intent 74 | * 75 | * @param appInfo 76 | * @return 77 | */ 78 | private ShortcutInfo getShortcut(AppInfo appInfo) { 79 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { 80 | ShortcutInfo shortcut = new ShortcutInfo.Builder(mContext, appInfo.getAppPackageName()) 81 | .setShortLabel(appInfo.getAppName()) 82 | .setIcon(Icon.createWithBitmap(appInfo.getAppIcon())) 83 | .setIntent( 84 | new Intent(ShortcutActivity.OPEN_APP_SHORTCUT) 85 | .putExtra(ShortcutActivity.EXTRA_PACKAGE_NAME, appInfo.getAppPackageName()) 86 | // this dynamic shortcut set up a back stack using Intents, when pressing back, will go to MainActivity 87 | // the last Intent is what the shortcut really opened 88 | // new Intent[]{ 89 | // new Intent(Intent.ACTION_MAIN, Uri.EMPTY, mContext, MainActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK), 90 | // new Intent(AppListActivity.ACTION_OPEN_DYNAMIC) 91 | // // intent's action must be set 92 | // } 93 | ) 94 | .build(); 95 | 96 | return shortcut; 97 | } else { 98 | return null; 99 | } 100 | } 101 | 102 | /** 103 | * 如果桌面有Pinning Shortcuts,且对应的app被用户卸载,则要disable并提示 104 | * 105 | * @param shortcutID 106 | */ 107 | public void removeShortcut(String shortcutID, String test) { 108 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { 109 | mShortcutManager.disableShortcuts(Arrays.asList(shortcutID), test); 110 | mShortcutManager.removeDynamicShortcuts(Arrays.asList(shortcutID)); 111 | mDBController.deleteDisableApp(shortcutID, AppInfoDBOpenHelper.TABLE_NAME_SHORTCUT_APP_INFO); 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/util/WeakHandler.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.util; 2 | 3 | import android.os.Handler; 4 | import android.os.Message; 5 | 6 | import java.lang.ref.WeakReference; 7 | 8 | /** 9 | * @author SScience 10 | * @description 弱引用 11 | * @email chentushen.science@gmail.com 12 | * @data 2017/1/15 13 | */ 14 | 15 | public class WeakHandler extends Handler { 16 | 17 | public interface IHandler { 18 | void handleMessage(Message msg); 19 | } 20 | 21 | private WeakReference wf; 22 | 23 | public WeakHandler(IHandler handler) { 24 | this.wf = new WeakReference<>(handler); 25 | } 26 | 27 | @Override 28 | public void handleMessage(Message msg) { 29 | super.handleMessage(msg); 30 | IHandler handler = wf.get(); 31 | if (handler != null) { 32 | handler.handleMessage(msg); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/widget/AppInfoComparator.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.widget; 2 | 3 | import android.text.TextUtils; 4 | 5 | import com.sscience.stopapp.bean.AppInfo; 6 | 7 | import java.text.Collator; 8 | import java.util.Comparator; 9 | 10 | /** 11 | * @author SScience 12 | * @description 根据应用名排序 13 | * @email chentushen.science@gmail.com 14 | * @data 2017/2/6 15 | */ 16 | 17 | public class AppInfoComparator implements Comparator { 18 | 19 | private final Collator sCollator = Collator.getInstance(); 20 | 21 | @Override 22 | public int compare(AppInfo appInfo1, AppInfo appInfo2) { 23 | String sa = appInfo1.getAppName(); 24 | if (TextUtils.isEmpty(sa)) { 25 | sa = appInfo1.getAppPackageName(); 26 | } 27 | String sb = appInfo2.getAppName(); 28 | if (TextUtils.isEmpty(sb)) { 29 | sb = appInfo2.getAppPackageName(); 30 | } 31 | return sCollator.compare(sa, sb); // 参考自ApplicationInfo.java中的DisplayNameComparator 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/widget/ComponentComparator.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.widget; 2 | 3 | import com.sscience.stopapp.bean.ComponentInfo; 4 | 5 | import java.text.Collator; 6 | import java.util.Comparator; 7 | 8 | /** 9 | * @author SScience 10 | * @description 根据应用名排序 11 | * @email chentushen.science@gmail.com 12 | * @data 2017/2/6 13 | */ 14 | 15 | public class ComponentComparator implements Comparator { 16 | 17 | private final Collator sCollator = Collator.getInstance(); 18 | 19 | @Override 20 | public int compare(ComponentInfo componentInfo1, ComponentInfo componentInfo2) { 21 | String sa = componentInfo1.getComponentName().substring(componentInfo1.getComponentName().lastIndexOf(".") + 1); 22 | String sb = componentInfo2.getComponentName().substring(componentInfo2.getComponentName().lastIndexOf(".") + 1); 23 | return sCollator.compare(sa, sb); // 参考自ApplicationInfo.java中的DisplayNameComparator 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/widget/MoveFloatingActionButton.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.widget; 2 | 3 | import android.content.Context; 4 | import android.support.design.widget.FloatingActionButton; 5 | import android.util.AttributeSet; 6 | import android.view.MotionEvent; 7 | import android.view.View; 8 | import android.view.ViewConfiguration; 9 | 10 | /** 11 | * @author SScience 12 | * @description 13 | * @email chentushen.science@gmail.com 14 | * @data 2017/3/29 15 | */ 16 | 17 | public class MoveFloatingActionButton extends FloatingActionButton implements View.OnTouchListener { 18 | 19 | private Context mContext; 20 | private float mPosY; 21 | private float mCurPosY; 22 | 23 | public MoveFloatingActionButton(Context context) { 24 | super(context); 25 | mContext = context; 26 | setOnTouchListener(this); 27 | } 28 | 29 | public MoveFloatingActionButton(Context context, AttributeSet attrs) { 30 | super(context, attrs); 31 | mContext = context; 32 | setOnTouchListener(this); 33 | } 34 | 35 | @Override 36 | public boolean onTouch(View v, MotionEvent event) { 37 | switch (event.getAction()) { 38 | case MotionEvent.ACTION_DOWN: 39 | mPosY = event.getRawY(); 40 | mCurPosY = mPosY; 41 | break; 42 | case MotionEvent.ACTION_MOVE: 43 | mCurPosY = event.getRawY(); 44 | break; 45 | case MotionEvent.ACTION_UP: 46 | int touchSlop = ViewConfiguration.get(mContext).getScaledPagingTouchSlop(); 47 | if (mCurPosY - mPosY > 0 && (Math.abs(mCurPosY - mPosY) > touchSlop)) { 48 | //向下滑動 49 | if (mOnMoveListener != null) { 50 | mOnMoveListener.onMove(false); 51 | } 52 | } else if (mCurPosY - mPosY < 0 && 53 | (Math.abs(mCurPosY - mPosY) > touchSlop)) { 54 | //向上滑动 55 | if (mOnMoveListener != null) { 56 | mOnMoveListener.onMove(true); 57 | } 58 | } 59 | break; 60 | } 61 | return false; 62 | } 63 | 64 | public interface OnMoveListener { 65 | void onMove(boolean isMoveUp); 66 | } 67 | 68 | private OnMoveListener mOnMoveListener; 69 | 70 | public void setOnMoveListener(OnMoveListener onMoveListener) { 71 | mOnMoveListener = onMoveListener; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /app/src/main/java/com/sscience/stopapp/widget/ScrollAwareFABBehavior.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp.widget; 2 | 3 | import android.content.Context; 4 | import android.support.design.widget.CoordinatorLayout; 5 | import android.support.design.widget.FloatingActionButton; 6 | import android.support.v4.view.ViewCompat; 7 | import android.support.v4.view.ViewPropertyAnimatorListener; 8 | import android.support.v4.view.animation.FastOutSlowInInterpolator; 9 | import android.util.AttributeSet; 10 | import android.view.View; 11 | import android.view.ViewGroup; 12 | import android.view.animation.Interpolator; 13 | 14 | /** 15 | * @author SScience 16 | * @description 17 | * @email chentushen.science@gmail.com 18 | * @data 2017/1/15 19 | */ 20 | 21 | public class ScrollAwareFABBehavior extends FloatingActionButton.Behavior { 22 | 23 | private static final Interpolator INTERPOLATOR = new FastOutSlowInInterpolator(); 24 | private boolean mIsAnimatingOut = false; 25 | 26 | public ScrollAwareFABBehavior() { 27 | } 28 | 29 | public ScrollAwareFABBehavior(Context context, AttributeSet attrs) { 30 | super(); 31 | } 32 | 33 | @Override 34 | public boolean onStartNestedScroll(final CoordinatorLayout coordinatorLayout, final FloatingActionButton child, 35 | final View directTargetChild, final View target, final int nestedScrollAxes) { 36 | // Ensure we react to vertical scrolling 37 | return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL; 38 | } 39 | 40 | @Override 41 | public void onNestedScroll(final CoordinatorLayout coordinatorLayout, final FloatingActionButton child, 42 | final View target, final int dxConsumed, final int dyConsumed, 43 | final int dxUnconsumed, final int dyUnconsumed) { 44 | super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed); 45 | if (dyConsumed > 0 && !this.mIsAnimatingOut) { 46 | // User scrolled down and the FAB is currently visible -> hide the FAB 47 | animateOut(child); 48 | } else if (dyConsumed < 0) { 49 | // User scrolled up and the FAB is currently not visible -> show the FAB 50 | animateIn(child); 51 | } 52 | } 53 | 54 | // Same animation that FloatingActionButton.Behavior uses to hide the FAB when the AppBarLayout exits 55 | private void animateOut(final FloatingActionButton button) { 56 | ViewCompat.animate(button).translationY(button.getHeight() + getMarginBottom(button)).setInterpolator(INTERPOLATOR).withLayer() 57 | .setListener(new ViewPropertyAnimatorListener() { 58 | public void onAnimationStart(View view) { 59 | ScrollAwareFABBehavior.this.mIsAnimatingOut = true; 60 | } 61 | 62 | public void onAnimationCancel(View view) { 63 | ScrollAwareFABBehavior.this.mIsAnimatingOut = false; 64 | } 65 | 66 | public void onAnimationEnd(View view) { 67 | ScrollAwareFABBehavior.this.mIsAnimatingOut = false; 68 | } 69 | }).start(); 70 | } 71 | 72 | // Same animation that FloatingActionButton.Behavior uses to show the FAB when the AppBarLayout enters 73 | private void animateIn(FloatingActionButton button) { 74 | ViewCompat.animate(button).translationY(0) 75 | .setInterpolator(INTERPOLATOR).withLayer().setListener(null) 76 | .start(); 77 | } 78 | 79 | 80 | private int getMarginBottom(View v) { 81 | int marginBottom = 0; 82 | final ViewGroup.LayoutParams layoutParams = v.getLayoutParams(); 83 | if (layoutParams instanceof ViewGroup.MarginLayoutParams) { 84 | marginBottom = ((ViewGroup.MarginLayoutParams) layoutParams).bottomMargin; 85 | } 86 | return marginBottom; 87 | } 88 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/about_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-hdpi/about_logo.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/app_logo_splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-hdpi/app_logo_splash.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_action_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-hdpi/ic_action_search.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_android.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-hdpi/ic_android.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_disable_app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-hdpi/ic_disable_app.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_enable_app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-hdpi/ic_enable_app.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_gray_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-hdpi/ic_gray_add.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_shortcut_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-hdpi/ic_shortcut_add.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_white_fab_confirm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-hdpi/ic_white_fab_confirm.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_white_fab_disable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-hdpi/ic_white_fab_disable.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_white_fab_enable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-hdpi/ic_white_fab_enable.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_white_fab_share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-hdpi/ic_white_fab_share.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/no_data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-hdpi/no_data.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/about_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xhdpi/about_logo.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/app_logo_splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xhdpi/app_logo_splash.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_action_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xhdpi/ic_action_search.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_disable_app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xhdpi/ic_disable_app.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_enable_app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xhdpi/ic_enable_app.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_gray_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xhdpi/ic_gray_add.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_shortcut_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xhdpi/ic_shortcut_add.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_white_fab_confirm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xhdpi/ic_white_fab_confirm.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_white_fab_disable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xhdpi/ic_white_fab_disable.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_white_fab_enable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xhdpi/ic_white_fab_enable.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_white_fab_share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xhdpi/ic_white_fab_share.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/no_data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xhdpi/no_data.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/about_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxhdpi/about_logo.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/app_logo_splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxhdpi/app_logo_splash.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_action_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxhdpi/ic_action_search.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_color_lens_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxhdpi/ic_color_lens_black.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_content_copy_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxhdpi/ic_content_copy_black.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_delete_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxhdpi/ic_delete_black.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_disable_app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxhdpi/ic_disable_app.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_enable_app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxhdpi/ic_enable_app.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_format_indent_decrease_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxhdpi/ic_format_indent_decrease_black.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_gray_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxhdpi/ic_gray_add.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_highlight_off_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxhdpi/ic_highlight_off_black.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_open_in_new_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxhdpi/ic_open_in_new_black.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_play_circle_outline_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxhdpi/ic_play_circle_outline_black.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_playlist_play_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxhdpi/ic_playlist_play_black.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_shortcut_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxhdpi/ic_shortcut_add.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_white_fab_confirm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxhdpi/ic_white_fab_confirm.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_white_fab_disable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxhdpi/ic_white_fab_disable.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_white_fab_enable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxhdpi/ic_white_fab_enable.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_white_fab_share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxhdpi/ic_white_fab_share.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/no_data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxhdpi/no_data.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/shadow.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/about_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxxhdpi/about_logo.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/app_logo_splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxxhdpi/app_logo_splash.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_action_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxxhdpi/ic_action_search.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_disable_app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxxhdpi/ic_disable_app.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_enable_app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxxhdpi/ic_enable_app.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_gray_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxxhdpi/ic_gray_add.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_shortcut_add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxxhdpi/ic_shortcut_add.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_white_fab_confirm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxxhdpi/ic_white_fab_confirm.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_white_fab_disable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxxhdpi/ic_white_fab_disable.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_white_fab_enable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxxhdpi/ic_white_fab_enable.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/ic_white_fab_share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxxhdpi/ic_white_fab_share.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxxhdpi/no_data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable-xxxhdpi/no_data.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/layout_divider.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/share_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/drawable/share_logo.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/splash_screen.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_about.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 14 | 15 | 23 | 24 | 31 | 32 | 42 | 43 | 51 | 52 | 53 | 54 | 59 | 60 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 80 | 81 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_app_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 21 | 22 | 30 | 31 | 32 | 40 | 41 | 42 | 43 | 48 | 49 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_component_details.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 21 | 22 | 30 | 31 | 32 | 33 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_setting.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 18 | 19 | 29 | 30 | 37 | 38 | 45 | 46 | 56 | 57 | 66 | 67 | 68 | 69 | 76 | 77 | 84 | 85 | 95 | 96 | 105 | 106 | 107 | 108 | 115 | 116 | 123 | 124 | 135 | 136 | 145 | 146 | 147 | 148 | 155 | 156 | 163 | 164 | 174 | 175 | 182 | 183 | 184 | 185 | 186 | -------------------------------------------------------------------------------- /app/src/main/res/layout/app_bar_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/layout/dialog_edit_app_name.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 18 | 19 | 26 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_app_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/layout/fragment_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_about.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 16 | 23 | 24 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_app.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 20 | 21 | 31 | 32 | 43 | 44 | 51 | 52 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_component_details.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 19 | 20 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_disable.xml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 22 | 23 | 35 | 36 | -------------------------------------------------------------------------------- /app/src/main/res/layout/select_launcher_icon.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 21 | 22 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/layout/view_empty.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 2 |

6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 21 | 22 | 28 | 29 | 34 | 35 | 40 | 41 | -------------------------------------------------------------------------------- /app/src/main/res/menu/menu_search.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/mipmap-hdpi/ic_launcher_square.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/mipmap-mdpi/ic_launcher_square.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_android.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/mipmap-xhdpi/ic_android.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/mipmap-xhdpi/ic_launcher_square.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_android.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/mipmap-xxhdpi/ic_android.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/mipmap-xxhdpi/ic_launcher_square.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_android.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/mipmap-xxxhdpi/ic_android.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/src/main/res/mipmap-xxxhdpi/ic_launcher_square.png -------------------------------------------------------------------------------- /app/src/main/res/values-en/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Stop App 5 | Tip 6 | Allow 7 | OK 8 | Deny 9 | Quick Disable 10 | Settings 11 | About 12 | Change Launcher Icon 13 | Custom App Shortcuts 14 | Select 15 | Cancel 16 | Round Icon 17 | Rounded Rectangle Icon 18 | The launcher icon is switched and may take a few seconds to half a minute to take effect! 19 | All apps 20 | System apps 21 | User apps 22 | Disable apps 23 | Would you like to disable [ % s ] ? 24 | Join the stop app list 25 | Out off the stop app list 26 | Uninstall app 27 | Component details 28 | Failure to get root permission!Please grant the root permission! 29 | Quick disable 30 | Quick enable 31 | There are no applications that need to be disabled(ˉ▽ˉ) 32 | Add 33 | Add apps 34 | Add complete! 35 | The app has been disabled(*^_^*) 36 | V %s 37 | About app 38 | about the features of this app 39 | Open source project address 40 | the source code address of the app 41 | Bug report 42 | please submit the bug if you encounter any bug during use 43 | Feedback 44 | please e-mail if you have any comments or suggestions 45 | Share with 46 | Check out the open source App [Stop app]:\n 47 | Focus on freezing app which is not commonly used 48 | Stop App Feedback 49 | App Name: 50 | \nApp Version: 51 | \nDevice Model: 52 | \nAndroid Version: 53 | \nPlease write your feedback here: 54 | Please select email app 55 | Add disable app 56 | Uninstall [%s] successfully 57 | Enable apps successfully 58 | The application is not installed 59 | You can add shortcuts up to 4 60 | Add Shortcut apps 61 | You have not add any shortcut apps 62 | add shortcut 63 | Does not support shortcuts 64 | Open App 65 | Deselect 66 | Enable App 67 | Add Shortcut 68 | Remove from list and enable 69 | Custom app 70 | Custom logo 71 | Custom app name 72 | Remove from list 73 | Press again to exit the app 74 | Successfully created shortcuts! 75 | Successfully operate! 76 | Successfully enable app! 77 | Successfully remove apps from list! 78 | Successfully remove and enable apps from list! 79 | Successfully Disable apps! 80 | Add App Shortcut 81 | Remove App Shortcut 82 | If your app targets Android 7.1 (API level 25) or higher, you can define shortcuts to specific actions in your app. 83 | Your Android version does not support App Shortcut! 84 | Display system disabled apps 85 | Display all disabled apps 86 | Display the system apps on the home page 87 | Display the all apps on the home page 88 | Automatically disable app by accessibility service 89 | Automatically disable app %s 90 | Automatically disable app after action back 91 | Stop App-Automatically Disable 92 | Automatically Disable 93 | Did not find anything 94 | Activity 95 | Service 96 | Receiver 97 | Provider 98 | No data! 99 | search by app name 100 | Do you want to uninstall the [%s] ? 101 | app 102 | Enter custom app name 103 | The picture that you select is too large, please select again! 104 | Custom icons need to read the gallery, please grant read and write permissions! 105 | If you want to custom app logo, you must grant the permission! 106 | The customized logo that you select please follow the android icon specification, the icon size is best not to exceed 40kb! 107 | Automatic disable conditions 108 | after Home immediately 109 | after Home 30s 110 | after Home 60s 111 | after action Back 112 | close auto disable 113 | 114 | 115 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFFFFF 4 | #B2B2B2 5 | #000000 6 | #DCDCDC 7 | #EEEEEE 8 | #48000000 9 | 10 | #212121 11 | #757575 12 | #FFBE00 13 | #737373 14 | 15 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 小黑屋 5 | 提示 6 | 允许 7 | 确定 8 | 拒绝 9 | 一键停用 10 | 设置 11 | 关于 12 | 切换桌面图标 13 | 自定义App Shortcuts 14 | 选择 15 | 取消 16 | 圆形 17 | 圆角矩形 18 | 桌面图标已切换,可能需要数秒到半分钟后生效 19 | 所有应用 20 | 系统应用 21 | 用户应用 22 | 停用应用 23 | 要把 [ %s ] 关进小黑屋吗? 24 | 加入小黑屋 25 | 移除小黑屋 26 | 卸载应用 27 | 组件详情 28 | 暂时没有root权限!请授予本应用root权限! 29 | 一键停用 30 | 一键启用 31 | 小黑屋空空如也(ˉ▽ˉ) 32 | 添加 33 | 添加应用 34 | 添加完成! 35 | 该应用已经加入小黑屋(*^_^*) 36 | V %s 37 | 关于应用 38 | 关于本应用的功能 39 | 开源地址 40 | 本应用源代码地址 41 | 报告错误 42 | 使用遇到任何问题,欢迎联系报告 43 | 反馈建议 44 | 有任何意见或建议,欢迎邮件反馈 45 | 请选择分享方式 46 | 试下免费开源的停用App[小黑屋]吧:\n 47 | 专注停用不(liu)常(mang)用应用,我是小黑屋,我为自己带盐 48 | 小黑屋应用反馈 49 | App名: 50 | \nApp版本: 51 | \n设备型号: 52 | \nAndroid版本: 53 | \n在下面写下您的反馈建议: 54 | 请选择邮件发送软件 55 | 添加停用应用 56 | 卸载[%s]成功 57 | 从列表移除成功 58 | 未安装该应用 59 | App Shortcut最多添加4个 60 | 添加Shortcut应用 61 | 你还未自定义Shortcut应用 62 | 添加快捷方式 63 | 该应用没有用户界面,不支持桌面快捷方式! 64 | 打开应用 65 | 取消选择 66 | 启用应用 67 | 桌面快捷方式 68 | 移除并且启用 69 | 自定义App 70 | 自定义图标 71 | 自定义应用名 72 | 移出小黑屋 73 | 再按一次退出 74 | 创建快捷方式成功! 75 | 操作完成! 76 | 启用应用成功! 77 | 成功移出小黑屋! 78 | 成功移除小黑屋并启用! 79 | 成功关进小黑屋! 80 | 添加App Shortcut 81 | 移除App Shortcut 82 | 长按App图标呼出常用的快捷方式列表,仅支持Android 7.1+ 83 | 你的系统版本小于7.1,不支持App Shortcut! 84 | 显示系统停用Apps 85 | 显示所有停用Apps 86 | 在主页停用列表显示系统Apps 87 | 在主页停用列表显示所有Apps 88 | 通过无障碍服务,自动停用App 89 | %s自动停用App 90 | 按返回键退出App时,自动停用App 91 | 小黑屋-自动停用 92 | 自动停用 93 | 暂时无此应用! 94 | 界面 95 | 服务 96 | 广播接收器 97 | 内容提供者 98 | 没有任何数据! 99 | 按应用名搜索 100 | 确认卸载 [%s] 吗? 101 | 应用 102 | 输入应用名 103 | 选择的图片过大,请重新选择! 104 | 自定义图标需要读取图库文件,请授予小黑屋读写权限! 105 | 授予读写权限才能自定义图标! 106 | 选取的图标请按照Google Android启动图标设计规范,大小最好不要超过40kb,以免图标压缩失真! 107 | 自动停用条件 108 | Home键退出立即 109 | Home键退出30秒后 110 | Home键退出60秒后 111 | 返回键退出立即(仅支持物理按键) 112 | 关闭自动停用 113 | 114 | 115 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/res/xml-v25/shortcuts.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 12 | 16 | 17 | -------------------------------------------------------------------------------- /app/src/main/res/xml/accessibility_service_config.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /app/src/test/java/com/sscience/stopapp/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.sscience.stopapp; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/stopapp_release_3_v1.1.1_20170316121413.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/stopapp_release_3_v1.1.1_20170316121413.apk -------------------------------------------------------------------------------- /app/stopapp_release_5_v1.2.1_20170406105104.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/stopapp_release_5_v1.2.1_20170406105104.apk -------------------------------------------------------------------------------- /app/stopapp_release_6_v1.3_20170427191236.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/app/stopapp_release_6_v1.3_20170427191236.apk -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | maven { url "https://jitpack.io" } 19 | } 20 | } 21 | 22 | task clean(type: Delete) { 23 | delete rootProject.buildDir 24 | } 25 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /screenshot/Screenshot_20170214-180852.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/screenshot/Screenshot_20170214-180852.png -------------------------------------------------------------------------------- /screenshot/Screenshot_20170316-120548.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/screenshot/Screenshot_20170316-120548.png -------------------------------------------------------------------------------- /screenshot/Screenshot_20170427-190046.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/XYScience/StopApp/9e126174a7e1141bb479f23183a1d3e1c2a1b55c/screenshot/Screenshot_20170427-190046.png -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | --------------------------------------------------------------------------------