├── .gitignore ├── .idea ├── gradle.xml ├── misc.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── project │ │ └── radua │ │ └── cardtask │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── ic_launcher-web.png │ ├── java │ │ └── project │ │ │ └── radua │ │ │ └── cardtask │ │ │ ├── CardTaskFloatingWindow.java │ │ │ ├── DBOperate.java │ │ │ ├── FirstActivity.java │ │ │ ├── MainActivity.java │ │ │ ├── SQLiteHelper.java │ │ │ ├── SettingActivity.java │ │ │ ├── WelcomeActivity.java │ │ │ └── painting.java │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── floatin.png │ │ ├── ic_info_black_24dp.xml │ │ ├── ic_launcher_background.xml │ │ ├── ic_notifications_black_24dp.xml │ │ ├── ic_sync_black_24dp.xml │ │ └── test.jpg │ │ ├── layout │ │ ├── activity_first.xml │ │ ├── activity_main.xml │ │ ├── activity_setting.xml │ │ ├── activity_welcome.xml │ │ ├── cardfloatlayout.xml │ │ ├── cardfloatlayout2.xml │ │ ├── cardfloatlayout3.xml │ │ └── content_welcome.xml │ │ ├── menu │ │ └── menu_welcome.xml │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── ic_launcher_background.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── project │ └── radua │ └── cardtask │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CardTask 2 | 3 | cardTask v2.81 4 | 5 | 6 | One think of Open a new App 7 | 8 | 9 | 2019 by Radua in XiangYang of China 10 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "project.radua.cardtask" 7 | minSdkVersion 23 8 | targetSdkVersion 28 9 | versionCode 11 10 | versionName "2.81" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | lintOptions { 20 | checkReleaseBuilds false 21 | // Or, if you prefer, you can continue to check for errors in release builds, 22 | // but continue the build even when errors are found: 23 | abortOnError false 24 | } 25 | } 26 | 27 | dependencies { 28 | implementation fileTree(dir: 'libs', include: ['*.jar']) 29 | implementation 'com.android.support:appcompat-v7:28.0.0-rc02' 30 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 31 | implementation 'com.android.support:design:28.0.0' 32 | implementation 'com.android.support:support-v4:28.0.0' 33 | testImplementation 'junit:junit:4.12' 34 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 35 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 36 | implementation 'com.android.support:recyclerview-v7:28.0.0-rc02' 37 | implementation 'com.android.support:cardview-v7:28.0.0-rc02' 38 | } 39 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/project/radua/cardtask/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package project.radua.cardtask; 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 | * Instrumented 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() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("project.radua.cardtask", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 10 | 11 | 18 | 22 | 23 | 24 | 28 | 32 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /app/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Raduap/CardTask/f649bf9670c9d09d70a677a5137393637da2f341/app/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /app/src/main/java/project/radua/cardtask/CardTaskFloatingWindow.java: -------------------------------------------------------------------------------- 1 | package project.radua.cardtask; 2 | 3 | 4 | import android.animation.ObjectAnimator; 5 | import android.animation.ValueAnimator; 6 | import android.app.Activity; 7 | import android.app.ActivityManager; 8 | import android.app.AppOpsManager; 9 | import android.app.usage.UsageStats; 10 | import android.content.Context; 11 | import android.content.Intent; 12 | import android.app.Service; 13 | import android.content.SharedPreferences; 14 | import android.database.Cursor; 15 | import android.database.sqlite.SQLiteDatabase; 16 | import android.graphics.Bitmap; 17 | import android.graphics.BitmapFactory; 18 | import android.graphics.Canvas; 19 | import android.graphics.Color; 20 | import android.graphics.Paint; 21 | import android.graphics.PixelFormat; 22 | 23 | 24 | import android.graphics.Rect; 25 | import android.graphics.RectF; 26 | import android.graphics.drawable.BitmapDrawable; 27 | import android.graphics.drawable.Drawable; 28 | import android.net.Uri; 29 | import android.os.Build; 30 | import android.os.IBinder; 31 | import android.print.PrintDocumentAdapter; 32 | import android.provider.Settings; 33 | import android.support.constraint.ConstraintLayout; 34 | import android.text.TextUtils; 35 | import android.view.Gravity; 36 | import android.view.LayoutInflater; 37 | import android.view.MotionEvent; 38 | import android.view.View; 39 | import android.view.ViewGroup; 40 | import android.view.WindowManager; 41 | import android.view.animation.Animation; 42 | import android.view.animation.RotateAnimation; 43 | import android.widget.Button; 44 | import android.widget.ImageView; 45 | import android.widget.LinearLayout; 46 | import android.widget.TextView; 47 | import android.widget.Toast; 48 | 49 | import java.util.ArrayList; 50 | import java.util.List; 51 | 52 | 53 | public class CardTaskFloatingWindow extends Service{ 54 | public static boolean isStarted = false; 55 | private WindowManager windowManager; 56 | private WindowManager.LayoutParams layoutParams; 57 | private Button button; 58 | private ImageView imageViewer ; 59 | private SharedPreferences share; 60 | private SQLiteHelper dbhelper; 61 | private int position = 0; 62 | private int ishide = 0; 63 | public int typex = 0; 64 | public int typey = 0; 65 | public int RoundRectSize = 20; 66 | public int CardDuration = 600; 67 | public float IMAGE1_ROTA = -50f; 68 | public float IMAGE2_ROTA = -20f; 69 | public float IMAGE3_ROTA = 10f; 70 | public float IMAGE4_ROTA = 40f; 71 | public float IMAGE5_ROTA = 70f; 72 | public float HIDE_START_ROTAION = 180f; 73 | public float HIDE_FINISH_ROTAION = -180f; 74 | 75 | ConstraintLayout touchLayout; 76 | 77 | @Override 78 | public int onStartCommand(Intent intent, int flags, int startId) { 79 | showFloatingWindow(); 80 | return super.onStartCommand(intent, flags, startId); 81 | } 82 | 83 | @Override 84 | public IBinder onBind(Intent intent) { 85 | return null; 86 | } 87 | 88 | 89 | @Override 90 | 91 | public void onCreate() { 92 | super.onCreate(); 93 | isStarted = true; 94 | windowManager = (WindowManager) getSystemService(WINDOW_SERVICE); 95 | layoutParams = new WindowManager.LayoutParams(); 96 | InitSetting(); 97 | InitView(); 98 | share = getSharedPreferences("positions",Context.MODE_PRIVATE); 99 | 100 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { 101 | layoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; 102 | } else { 103 | layoutParams.type = WindowManager.LayoutParams.TYPE_PHONE; 104 | } 105 | layoutParams.format = PixelFormat.RGBA_8888; 106 | layoutParams.width = 120; 107 | layoutParams.height = 160; 108 | layoutParams.y = typey; 109 | layoutParams.x =typex; 110 | layoutParams.gravity = Gravity.LEFT; 111 | layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS ; 112 | //CheckClick(); 113 | 114 | } 115 | @Override 116 | public void onDestroy(){ 117 | windowManager.removeViewImmediate(button); 118 | 119 | } 120 | public byte[] readImage(){ 121 | SQLiteDatabase db = dbhelper.getWritableDatabase(); 122 | Cursor cur=db.query("User", new String[]{"id","avatar"}, null, null, null, null, null); 123 | byte[] imgData=null; 124 | if(cur.moveToNext()){ 125 | //将Blob数据转化为字节数组 126 | imgData=cur.getBlob(cur.getColumnIndex("avatar")); 127 | } 128 | return imgData; 129 | } 130 | public void showFloatingWindow(){ 131 | if (Settings.canDrawOverlays(this)){ 132 | button = new Button(getApplicationContext()); 133 | button.setBackgroundColor(PixelFormat.RGBA_8888); 134 | button.setBackground(getResources().getDrawable(R.drawable.floatin)); 135 | windowManager.addView(button,layoutParams); 136 | SharedPreferences sfloatimage = getSharedPreferences("pisturefloat",Context.MODE_PRIVATE); 137 | int IMAGECHANGE = 0; 138 | IMAGECHANGE = sfloatimage.getInt("key",0); 139 | if (IMAGECHANGE == 1){ 140 | DBOperate dbOperate = new DBOperate(this); 141 | byte[] imgData = dbOperate.readImage(); 142 | if (imgData != null) { 143 | Bitmap imagebitmap = BitmapFactory.decodeByteArray(imgData, 0, imgData.length); 144 | Drawable drawable = new BitmapDrawable(imagebitmap); 145 | button.setBackground(drawable); 146 | } 147 | } 148 | SharedPreferences sphide = getSharedPreferences("positions",Context.MODE_PRIVATE); 149 | ishide = sphide.getInt("ishide",0); 150 | if (ishide == 1) { 151 | button.setBackgroundResource(R.drawable.hide); 152 | } 153 | button.setOnTouchListener(new FloatingOnTouchListener()); 154 | button.setOnClickListener(new View.OnClickListener() { 155 | @Override 156 | public void onClick(View v) { 157 | layoutParams.width = windowManager.getDefaultDisplay().getWidth(); 158 | layoutParams.x = 0; 159 | layoutParams.height = windowManager.getDefaultDisplay().getHeight(); 160 | layoutParams.y = 0; 161 | windowManager.addView(touchLayout,layoutParams); 162 | windowManager.removeView(button); 163 | CheckClick(); 164 | } 165 | }); 166 | } 167 | } 168 | public void InitSetting(){ 169 | SharedPreferences spsr = getSharedPreferences("speed",Context.MODE_PRIVATE); 170 | CardDuration = spsr.getInt("speed",600); 171 | } 172 | 173 | public void InitView(){ 174 | SharedPreferences spsa = getSharedPreferences("positions",Context.MODE_PRIVATE); 175 | position = spsa.getInt("positions",0); 176 | if (position == 1){ 177 | touchLayout = (ConstraintLayout)LayoutInflater.from(getApplicationContext()).inflate(R.layout.cardfloatlayout2,null); 178 | IMAGE1_ROTA = -20f; 179 | IMAGE2_ROTA = 10f; 180 | IMAGE3_ROTA = 30f; 181 | IMAGE4_ROTA = 55f; 182 | IMAGE5_ROTA = 80f; 183 | HIDE_START_ROTAION = -180f; 184 | HIDE_FINISH_ROTAION = -180f; 185 | int width = windowManager.getDefaultDisplay().getWidth(); 186 | int hidth = windowManager.getDefaultDisplay().getHeight(); 187 | typex =width - 60; 188 | typey =hidth/2 - 30; 189 | } 190 | if (position == 0){ 191 | touchLayout = (ConstraintLayout)LayoutInflater.from(getApplicationContext()).inflate(R.layout.cardfloatlayout,null); 192 | int width = windowManager.getDefaultDisplay().getWidth(); 193 | int hidth = windowManager.getDefaultDisplay().getHeight(); 194 | typex = width - 60; 195 | typey = hidth/5; 196 | } 197 | 198 | if (position == 2) { 199 | touchLayout = (ConstraintLayout)LayoutInflater.from(getApplicationContext()).inflate(R.layout.cardfloatlayout3,null); 200 | int width = windowManager.getDefaultDisplay().getWidth(); 201 | int hidth = windowManager.getDefaultDisplay().getHeight(); 202 | typex =-60; 203 | typey =hidth/5; 204 | } 205 | } 206 | public static void stopservice(Context c){ 207 | Intent intent = new Intent(c,CardTaskFloatingWindow.class); 208 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 209 | c.stopService(intent); 210 | 211 | } 212 | 213 | public void CheckClick() 214 | { 215 | final View imageView = touchLayout.findViewById(R.id.imageView); 216 | final View imageview2 = touchLayout.findViewById(R.id.imageView2); 217 | final View imageview3 = touchLayout.findViewById(R.id.imageView5); 218 | final View imageview4 = touchLayout.findViewById(R.id.imageView6); 219 | final View imageview5 = touchLayout.findViewById(R.id.imageView7); 220 | final View imageview6 = touchLayout.findViewById(R.id.imageView8); 221 | final View imageview7 = touchLayout.findViewById(R.id.imageView9); 222 | final View imageview8 = touchLayout.findViewById(R.id.imageView10); 223 | ObjectAnimator objectAnimator1 = ObjectAnimator.ofFloat(imageView,"rotation",HIDE_START_ROTAION,IMAGE1_ROTA); 224 | objectAnimator1.setDuration(CardDuration); 225 | objectAnimator1.start(); 226 | ObjectAnimator objectAnimator2 = ObjectAnimator.ofFloat(imageview5,"rotation",HIDE_START_ROTAION,IMAGE2_ROTA); 227 | objectAnimator2.setDuration(CardDuration); 228 | objectAnimator2.start(); 229 | final ObjectAnimator objectAnimator3 = ObjectAnimator.ofFloat(imageview6,"rotation",HIDE_START_ROTAION,IMAGE3_ROTA); 230 | objectAnimator3.setDuration(CardDuration); 231 | objectAnimator3.start(); 232 | ObjectAnimator objectAnimator4 = ObjectAnimator.ofFloat(imageview7,"rotation",HIDE_START_ROTAION,IMAGE4_ROTA); 233 | objectAnimator4.setDuration(CardDuration); 234 | objectAnimator4.start(); 235 | ObjectAnimator objectAnimator5 = ObjectAnimator.ofFloat(imageview8,"rotation",HIDE_START_ROTAION,IMAGE5_ROTA); 236 | objectAnimator5.setDuration(CardDuration); 237 | objectAnimator5.start(); 238 | final List stats = new painting().CreatAppList(getApplicationContext()); 239 | PackageInit(stats); 240 | imageView.setOnClickListener(new View.OnClickListener() { 241 | @Override 242 | public void onClick(View v) { 243 | ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(imageView,"rotation",IMAGE1_ROTA,IMAGE3_ROTA); 244 | objectAnimator.setDuration(CardDuration); 245 | objectAnimator.start(); 246 | new painting().TurnToActivity(stats.get(4).getPackageName(),getApplicationContext()); 247 | final ObjectAnimator objectAnimators = ObjectAnimator.ofFloat(imageView,"rotation",IMAGE1_ROTA,HIDE_FINISH_ROTAION); 248 | objectAnimators.setDuration(CardDuration); 249 | RotaImage(imageview5,IMAGE2_ROTA,HIDE_FINISH_ROTAION,CardDuration); 250 | RotaImage(imageview6,IMAGE3_ROTA,HIDE_FINISH_ROTAION,CardDuration); 251 | RotaImage(imageview7,IMAGE4_ROTA,HIDE_FINISH_ROTAION,CardDuration); 252 | RotaImage(imageview8,IMAGE5_ROTA,HIDE_FINISH_ROTAION,CardDuration); 253 | objectAnimators.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 254 | @Override 255 | public void onAnimationUpdate(ValueAnimator animation) { 256 | float value = (float) objectAnimators.getAnimatedValue("rotation"); 257 | if (value == HIDE_FINISH_ROTAION){ 258 | 259 | layoutParams.width = 120; 260 | layoutParams.height = 160; 261 | int width = windowManager.getDefaultDisplay().getWidth(); 262 | layoutParams.x =typex; 263 | int hidth = windowManager.getDefaultDisplay().getHeight(); 264 | layoutParams.y =typey; 265 | try { 266 | windowManager.removeView(touchLayout); 267 | windowManager.addView(button,layoutParams); 268 | }catch (Exception e){ 269 | 270 | } 271 | } 272 | } 273 | }); 274 | objectAnimators.start(); 275 | } 276 | }); 277 | imageview2.setOnClickListener(new View.OnClickListener() { 278 | @Override 279 | public void onClick(View v) { 280 | final ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(imageView,"rotation",IMAGE1_ROTA,HIDE_FINISH_ROTAION); 281 | objectAnimator.setDuration(CardDuration); 282 | RotaImage(imageview5,IMAGE2_ROTA,HIDE_FINISH_ROTAION,CardDuration); 283 | RotaImage(imageview6,IMAGE3_ROTA,HIDE_FINISH_ROTAION,CardDuration); 284 | RotaImage(imageview7,IMAGE4_ROTA,HIDE_FINISH_ROTAION,CardDuration); 285 | RotaImage(imageview8,IMAGE5_ROTA,HIDE_FINISH_ROTAION,CardDuration); 286 | objectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 287 | @Override 288 | public void onAnimationUpdate(ValueAnimator animation) { 289 | float value = (float) objectAnimator.getAnimatedValue("rotation"); 290 | if (value == HIDE_FINISH_ROTAION){ 291 | layoutParams.width = 120; 292 | layoutParams.height = 160; 293 | int width = windowManager.getDefaultDisplay().getWidth(); 294 | layoutParams.x =typex; 295 | int hidth = windowManager.getDefaultDisplay().getHeight(); 296 | layoutParams.y = typey; 297 | try { 298 | windowManager.removeViewImmediate(touchLayout); 299 | windowManager.addView(button,layoutParams); 300 | }catch (Exception e){ 301 | 302 | } 303 | } 304 | } 305 | }); 306 | objectAnimator.start(); 307 | 308 | } 309 | }); 310 | 311 | imageview3.setOnClickListener(new View.OnClickListener() { 312 | @Override 313 | public void onClick(View v) { 314 | final ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(imageView,"rotation",IMAGE1_ROTA,HIDE_FINISH_ROTAION); 315 | objectAnimator.setDuration(CardDuration); 316 | RotaImage(imageview5,IMAGE2_ROTA,HIDE_FINISH_ROTAION,CardDuration); 317 | RotaImage(imageview6,IMAGE3_ROTA,HIDE_FINISH_ROTAION,CardDuration); 318 | RotaImage(imageview7,IMAGE4_ROTA,HIDE_FINISH_ROTAION,CardDuration); 319 | RotaImage(imageview8,IMAGE5_ROTA,HIDE_FINISH_ROTAION,CardDuration); 320 | objectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 321 | @Override 322 | public void onAnimationUpdate(ValueAnimator animation) { 323 | float value = (float) objectAnimator.getAnimatedValue("rotation"); 324 | if (value == HIDE_FINISH_ROTAION){ 325 | layoutParams.width = 120; 326 | layoutParams.height = 160; 327 | int width = windowManager.getDefaultDisplay().getWidth(); 328 | layoutParams.x =typex; 329 | int hidth = windowManager.getDefaultDisplay().getHeight(); 330 | layoutParams.y = typey; 331 | 332 | try { 333 | windowManager.removeView(touchLayout); 334 | windowManager.addView(button,layoutParams); 335 | }catch (Exception e){ 336 | 337 | } 338 | } 339 | } 340 | }); 341 | objectAnimator.start(); 342 | } 343 | }); 344 | 345 | imageview4.setOnClickListener(new View.OnClickListener() { 346 | @Override 347 | public void onClick(View v) { 348 | final ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(imageView,"rotation",IMAGE1_ROTA,HIDE_FINISH_ROTAION); 349 | objectAnimator.setDuration(CardDuration); 350 | RotaImage(imageview5,IMAGE2_ROTA,HIDE_FINISH_ROTAION,CardDuration); 351 | RotaImage(imageview6,IMAGE3_ROTA,HIDE_FINISH_ROTAION,CardDuration); 352 | RotaImage(imageview7,IMAGE4_ROTA,HIDE_FINISH_ROTAION,CardDuration); 353 | RotaImage(imageview8,IMAGE5_ROTA,HIDE_FINISH_ROTAION,CardDuration); 354 | 355 | objectAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 356 | @Override 357 | public void onAnimationUpdate(ValueAnimator animation) { 358 | float value = (float) objectAnimator.getAnimatedValue("rotation"); 359 | if (value == HIDE_FINISH_ROTAION){ 360 | layoutParams.width = 120; 361 | layoutParams.height = 160; 362 | int width = windowManager.getDefaultDisplay().getWidth(); 363 | layoutParams.x =typex; 364 | int hidth = windowManager.getDefaultDisplay().getHeight(); 365 | layoutParams.y = typey; 366 | try { 367 | windowManager.removeView(touchLayout); 368 | windowManager.addView(button,layoutParams); 369 | }catch (Exception e){ 370 | 371 | } 372 | } 373 | } 374 | }); 375 | objectAnimator.start(); 376 | } 377 | }); 378 | 379 | 380 | imageview5.setOnClickListener(new View.OnClickListener() { 381 | @Override 382 | public void onClick(View v) { 383 | new painting().TurnToActivity(stats.get(3).getPackageName(),getApplicationContext()); 384 | final ObjectAnimator objectAnimators = ObjectAnimator.ofFloat(imageView,"rotation",IMAGE1_ROTA,HIDE_FINISH_ROTAION); 385 | objectAnimators.setDuration(CardDuration); 386 | RotaImage(imageview5,IMAGE2_ROTA,HIDE_FINISH_ROTAION,CardDuration); 387 | RotaImage(imageview6,IMAGE3_ROTA,HIDE_FINISH_ROTAION,CardDuration); 388 | RotaImage(imageview7,IMAGE4_ROTA,HIDE_FINISH_ROTAION,CardDuration); 389 | RotaImage(imageview8,IMAGE5_ROTA,HIDE_FINISH_ROTAION,CardDuration); 390 | objectAnimators.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 391 | @Override 392 | public void onAnimationUpdate(ValueAnimator animation) { 393 | float value = (float) objectAnimators.getAnimatedValue("rotation"); 394 | if (value == HIDE_FINISH_ROTAION){ 395 | layoutParams.width = 120; 396 | layoutParams.height = 160; 397 | int width = windowManager.getDefaultDisplay().getWidth(); 398 | layoutParams.x =typex; 399 | int hidth = windowManager.getDefaultDisplay().getHeight(); 400 | layoutParams.y = typey; 401 | 402 | try { 403 | windowManager.removeView(touchLayout); 404 | windowManager.addView(button,layoutParams); 405 | }catch (Exception e){ 406 | 407 | } 408 | } 409 | } 410 | }); 411 | objectAnimators.start(); 412 | } 413 | }); 414 | 415 | imageview6.setOnClickListener(new View.OnClickListener() { 416 | @Override 417 | public void onClick(View v) { 418 | new painting().TurnToActivity(stats.get(2).getPackageName(),getApplicationContext()); 419 | 420 | final ObjectAnimator objectAnimators = ObjectAnimator.ofFloat(imageView,"rotation",IMAGE1_ROTA,HIDE_FINISH_ROTAION); 421 | objectAnimators.setDuration(CardDuration); 422 | RotaImage(imageview5,IMAGE2_ROTA,HIDE_FINISH_ROTAION,CardDuration); 423 | RotaImage(imageview6,IMAGE3_ROTA,HIDE_FINISH_ROTAION,CardDuration); 424 | RotaImage(imageview7,IMAGE4_ROTA,HIDE_FINISH_ROTAION,CardDuration); 425 | RotaImage(imageview8,IMAGE5_ROTA,HIDE_FINISH_ROTAION,CardDuration); 426 | objectAnimators.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 427 | @Override 428 | public void onAnimationUpdate(ValueAnimator animation) { 429 | float value = (float) objectAnimators.getAnimatedValue("rotation"); 430 | if (value == HIDE_FINISH_ROTAION){ 431 | layoutParams.width = 120; 432 | layoutParams.height = 160; 433 | int width = windowManager.getDefaultDisplay().getWidth(); 434 | layoutParams.x =typex; 435 | int hidth = windowManager.getDefaultDisplay().getHeight(); 436 | layoutParams.y = typey; 437 | try { 438 | windowManager.removeView(touchLayout); 439 | windowManager.addView(button,layoutParams); 440 | }catch (Exception e){ 441 | 442 | } 443 | } 444 | } 445 | }); 446 | objectAnimators.start(); 447 | } 448 | }); 449 | 450 | imageview7.setOnClickListener(new View.OnClickListener() { 451 | @Override 452 | public void onClick(View v) { 453 | new painting().TurnToActivity(stats.get(1).getPackageName(),getApplicationContext()); 454 | 455 | final ObjectAnimator objectAnimators = ObjectAnimator.ofFloat(imageView,"rotation",IMAGE1_ROTA,HIDE_FINISH_ROTAION); 456 | objectAnimators.setDuration(CardDuration); 457 | RotaImage(imageview5,IMAGE2_ROTA,HIDE_FINISH_ROTAION,CardDuration); 458 | RotaImage(imageview6,IMAGE3_ROTA,HIDE_FINISH_ROTAION,CardDuration); 459 | RotaImage(imageview7,IMAGE4_ROTA,HIDE_FINISH_ROTAION,CardDuration); 460 | RotaImage(imageview8,IMAGE5_ROTA,HIDE_FINISH_ROTAION,CardDuration); 461 | objectAnimators.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 462 | @Override 463 | public void onAnimationUpdate(ValueAnimator animation) { 464 | float value = (float) objectAnimators.getAnimatedValue("rotation"); 465 | if (value == HIDE_FINISH_ROTAION){ 466 | layoutParams.width = 120; 467 | layoutParams.height = 160; 468 | int width = windowManager.getDefaultDisplay().getWidth(); 469 | layoutParams.x =typex; 470 | int hidth = windowManager.getDefaultDisplay().getHeight(); 471 | layoutParams.y = typey; 472 | try { 473 | windowManager.removeView(touchLayout); 474 | windowManager.addView(button,layoutParams); 475 | }catch (Exception e){ 476 | 477 | } 478 | } 479 | } 480 | }); 481 | objectAnimators.start(); 482 | } 483 | }); 484 | 485 | imageview8.setOnClickListener(new View.OnClickListener() { 486 | @Override 487 | public void onClick(View v) { 488 | new painting().TurnToActivity(stats.get(0).getPackageName(),getApplicationContext()); 489 | 490 | final ObjectAnimator objectAnimators = ObjectAnimator.ofFloat(imageView,"rotation",IMAGE1_ROTA,HIDE_FINISH_ROTAION); 491 | objectAnimators.setDuration(CardDuration); 492 | RotaImage(imageview5,IMAGE2_ROTA,HIDE_FINISH_ROTAION,CardDuration); 493 | RotaImage(imageview6,IMAGE3_ROTA,HIDE_FINISH_ROTAION,CardDuration); 494 | RotaImage(imageview7,IMAGE4_ROTA,HIDE_FINISH_ROTAION,CardDuration); 495 | RotaImage(imageview8,IMAGE5_ROTA,HIDE_FINISH_ROTAION,CardDuration); 496 | objectAnimators.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { 497 | @Override 498 | public void onAnimationUpdate(ValueAnimator animation) { 499 | float value = (float) objectAnimators.getAnimatedValue("rotation"); 500 | if (value == HIDE_FINISH_ROTAION){ 501 | layoutParams.width = 120; 502 | layoutParams.height = 160; 503 | int width = windowManager.getDefaultDisplay().getWidth(); 504 | layoutParams.x =typex; 505 | int hidth = windowManager.getDefaultDisplay().getHeight(); 506 | layoutParams.y = typey; 507 | 508 | try { 509 | windowManager.removeView(touchLayout); 510 | windowManager.addView(button,layoutParams); 511 | }catch (Exception e){ 512 | 513 | } 514 | } 515 | } 516 | }); 517 | objectAnimators.start(); 518 | } 519 | }); 520 | } 521 | 522 | public void RotaImage(View imageView,float num1,float num2,int duration){ 523 | ObjectAnimator objectAnimator = ObjectAnimator.ofFloat(imageView,"rotation",num1,num2); 524 | objectAnimator.setDuration(duration); 525 | objectAnimator.start(); 526 | } 527 | 528 | private class FloatingOnTouchListener implements View.OnTouchListener{ 529 | private int x; 530 | private int y; 531 | 532 | @Override 533 | public boolean onTouch(View view, MotionEvent event){ 534 | switch (event.getAction()){ 535 | case MotionEvent.ACTION_DOWN: 536 | if (layoutParams.x <-50) 537 | { 538 | layoutParams.x = -40; 539 | } 540 | int widthr = windowManager.getDefaultDisplay().getWidth(); 541 | 542 | if (layoutParams.x >widthr-60) 543 | { 544 | layoutParams.x = widthr-60; 545 | } 546 | 547 | x = (int)event.getRawX(); 548 | y = (int)event.getRawY(); 549 | break; 550 | case MotionEvent.ACTION_MOVE: 551 | int nowX = (int) event.getRawX(); 552 | int nowY = (int) event.getRawY(); 553 | int movedX = nowX - x; 554 | int movedY = nowY - y; 555 | x = nowX; 556 | y = nowY; 557 | if (layoutParams.x <-50) 558 | { 559 | layoutParams.x = -40; 560 | movedX = 0; 561 | } 562 | int width = windowManager.getDefaultDisplay().getWidth(); 563 | if (layoutParams.x >width-60) 564 | { 565 | layoutParams.x = width-60; 566 | movedX = 0; 567 | } 568 | int hidth = windowManager.getDefaultDisplay().getHeight(); 569 | if (layoutParams.y < -hidth/2 + 30) 570 | { 571 | layoutParams.y = -hidth/2 + 10; 572 | } 573 | if (layoutParams.y > hidth/2) 574 | { 575 | layoutParams.y = hidth/2; 576 | } 577 | layoutParams.x = layoutParams.x + movedX; 578 | layoutParams.y = layoutParams.y + movedY; 579 | windowManager.updateViewLayout(view,layoutParams); 580 | 581 | break; 582 | default: 583 | break; 584 | } 585 | return false; 586 | 587 | } 588 | 589 | 590 | 591 | } 592 | 593 | 594 | //测试包名以及获取图标的测试化步骤 595 | public void PackageInit(List stats){ 596 | ImageView imageView = touchLayout.findViewById(R.id.imageView); 597 | ImageView imageView1 = touchLayout.findViewById(R.id.imageView7); 598 | ImageView imageView2 = touchLayout.findViewById(R.id.imageView8); 599 | ImageView imageView3 = touchLayout.findViewById(R.id.imageView9); 600 | ImageView imageView4 = touchLayout.findViewById(R.id.imageView10); 601 | painting painting = new painting(); 602 | if (stats.size()<4 603 | )return; 604 | String test = stats.get(4).getPackageName(); 605 | int i =stats.size(); 606 | Drawable drawable; 607 | Bitmap bitmap; 608 | drawable = painting.GetIcon(stats.get(4).getPackageName(),getApplicationContext()); 609 | bitmap = painting.drawableToBitamp(drawable); 610 | Bitmap createbitmap = CreateMDicon(bitmap); 611 | imageView.setImageBitmap(createbitmap); 612 | SetDraw(3,imageView1,stats); 613 | SetDraw(2,imageView2,stats); 614 | SetDraw(1,imageView3,stats); 615 | SetDraw(0,imageView4,stats); 616 | //painting.TurnToActivity(test,getApplicationContext()); 617 | //Drawable drawable; 618 | //drawable = painting.GetIcon(test,getApplicationContext()); 619 | //Bitmap bitmap; 620 | //bitmap = painting.drawableToBitamp(drawable); 621 | //view.setImageBitmap(bitmap); 622 | //imageView.setImageBitmap(bitmap); 623 | } 624 | 625 | public void SetDraw(int num,ImageView imageView,List stats){ 626 | 627 | painting painting = new painting(); 628 | if (stats == null)return; 629 | String test = stats.get(num).getPackageName(); 630 | Drawable drawable; 631 | Bitmap bitmap; 632 | drawable = painting.GetIcon(stats.get(num).getPackageName(),getApplicationContext()); 633 | bitmap = painting.drawableToBitamp(drawable); 634 | Bitmap createbitmap = CreateMDicon(bitmap); 635 | imageView.setImageBitmap(createbitmap); 636 | 637 | } 638 | 639 | 640 | private Boolean hasPermission(){ 641 | AppOpsManager appops = (AppOpsManager)getSystemService(Context.APP_OPS_SERVICE); 642 | int mode =0; 643 | 644 | if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT){ 645 | mode = appops.checkOpNoThrow(AppOpsManager.OPSTR_GET_USAGE_STATS,android.os.Process.myUid(),getPackageName()); 646 | } 647 | 648 | return mode == AppOpsManager.MODE_ALLOWED; 649 | } 650 | 651 | private int MY_PERMISSIONS_PACKAGE_USAGE_STATS; 652 | public void CheckHasPermisson(){ 653 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){ 654 | if (!hasPermission()){ 655 | Toast.makeText(this,"请打开权限",Toast.LENGTH_SHORT); 656 | Context context = getApplicationContext(); 657 | context.startActivity( 658 | new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS) 659 | //MY_PERMISSIONS_PACKAGE_USAGE_STATS 660 | ); 661 | } 662 | } 663 | } 664 | //绘制卡片生成图案 665 | 666 | public Bitmap CreateMDicon(Bitmap bitmap) 667 | { 668 | int ColorIcon = -1; 669 | painting painting = new painting(); 670 | SharedPreferences spsao = getSharedPreferences("pickcolor",Context.MODE_PRIVATE); 671 | int colipositionx = spsao.getInt("x",-1); 672 | int colipositiony = spsao.getInt("y",-1); 673 | ColorIcon = painting.GetColor(bitmap,colipositionx,colipositiony); 674 | int width1; 675 | int hidth1; 676 | int width2 = bitmap.getWidth(); 677 | int hidth2 = bitmap.getHeight(); 678 | Bitmap bitmap1 = Bitmap.createBitmap(width2*3,hidth2*2,Bitmap.Config.ARGB_8888); 679 | Paint paint = new Paint(); 680 | Canvas canvas = new Canvas(bitmap1); 681 | paint.setColor(ColorIcon); 682 | paint.setStyle(Paint.Style.FILL); 683 | Paint paintinit = new Paint(); 684 | paintinit.setColor(Color.WHITE); 685 | paintinit.setStyle(Paint.Style.FILL); 686 | width1 = width2*3; 687 | hidth1 = hidth2*2; 688 | RectF rectinit = new RectF(); 689 | rectinit.left = 0; 690 | rectinit.top = 0; 691 | rectinit.right = width1; 692 | rectinit.bottom = hidth1; 693 | SharedPreferences sps = getSharedPreferences("round",0); 694 | RoundRectSize = sps.getInt("round",20); 695 | canvas.drawRoundRect(rectinit,RoundRectSize,RoundRectSize,paintinit); 696 | canvas.drawRoundRect(rectinit,RoundRectSize,RoundRectSize,paint); 697 | //不同位置绘制的区域不同 698 | SharedPreferences sp = getSharedPreferences("positions",0); 699 | int position = 0; 700 | position = sp.getInt("positions",0); 701 | if (position == 0) { 702 | canvas.drawBitmap(bitmap,width2/4,hidth2-30,null); 703 | } 704 | if (position == 2) { 705 | canvas.drawBitmap(bitmap,width2 + 150,hidth2/3,null); 706 | } 707 | if (position == 1){ 708 | canvas.drawBitmap(bitmap,30,hidth2-30,null); 709 | } 710 | canvas.save(); 711 | return bitmap1; 712 | } 713 | 714 | } 715 | -------------------------------------------------------------------------------- /app/src/main/java/project/radua/cardtask/DBOperate.java: -------------------------------------------------------------------------------- 1 | package project.radua.cardtask; 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 | import android.graphics.BitmapFactory; 9 | 10 | import java.io.ByteArrayOutputStream; 11 | import java.io.IOException; 12 | 13 | public class DBOperate { 14 | 15 | private SQLiteHelper dbhelper; 16 | private Context context; 17 | 18 | //要操作数据库操作实例首先得得到数据库操作实例 19 | public DBOperate(Context context) { 20 | this.context=context; 21 | this.dbhelper = SQLiteHelper.getInstance(context); 22 | } 23 | 24 | public void saveImage(Bitmap bitmap){ 25 | SQLiteDatabase db = dbhelper.getWritableDatabase(); 26 | ContentValues cv=new ContentValues(); 27 | cv.put("_id", 1); 28 | cv.put("avatar", bitmabToBytes(bitmap));//图片转为二进制 29 | db.replace("User", null, cv); 30 | db.close(); 31 | } 32 | 33 | public byte[] readImage(){ 34 | SQLiteDatabase db = dbhelper.getWritableDatabase(); 35 | Cursor cur=db.query("User", new String[]{"_id","avatar"}, null, null, null, null, null); 36 | byte[] imgData=null; 37 | if(cur.moveToNext()){ 38 | //将Blob数据转化为字节数组 39 | imgData=cur.getBlob(cur.getColumnIndex("avatar")); 40 | } 41 | return imgData; 42 | } 43 | //图片转为二进制数据 44 | public byte[] bitmabToBytes(Bitmap bitmap){ 45 | //将图片转化为位图 46 | int size = bitmap.getWidth() * bitmap.getHeight() * 4; 47 | //创建一个字节数组输出流,流的大小为size 48 | ByteArrayOutputStream baos= new ByteArrayOutputStream(size); 49 | try { 50 | //设置位图的压缩格式,质量为100%,并放入字节数组输出流中 51 | bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos); 52 | //将字节数组输出流转化为字节数组byte[] 53 | byte[] imagedata = baos.toByteArray(); 54 | return imagedata; 55 | }catch (Exception e){ 56 | }finally { 57 | try { 58 | //bitmap.recycle(); 59 | baos.close(); 60 | } catch (IOException e) { 61 | e.printStackTrace(); 62 | } 63 | } 64 | return new byte[0]; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /app/src/main/java/project/radua/cardtask/FirstActivity.java: -------------------------------------------------------------------------------- 1 | package project.radua.cardtask; 2 | 3 | import android.content.Intent; 4 | import android.content.SharedPreferences; 5 | import android.content.pm.PackageInfo; 6 | import android.content.pm.PackageManager; 7 | import android.preference.PreferenceManager; 8 | import android.support.v7.app.AppCompatActivity; 9 | import android.os.Bundle; 10 | 11 | public class FirstActivity extends AppCompatActivity { 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | PackageInfo info = null; 17 | try { 18 | info = getPackageManager().getPackageInfo(getPackageName(),0); 19 | } catch (PackageManager.NameNotFoundException e) { 20 | e.printStackTrace(); 21 | } 22 | 23 | int currentVersion = info.versionCode; 24 | SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); 25 | 26 | int lastVersion = sp.getInt("VERSION_KEY",0); 27 | 28 | if (currentVersion>lastVersion){ 29 | sp.edit().putInt("VERSION_KEY",currentVersion).commit(); 30 | Intent intent=new Intent(this,WelcomeActivity.class); 31 | startActivity(intent); 32 | finish(); 33 | }else{ 34 | Intent intent=new Intent(this,MainActivity.class); 35 | startActivity(intent); 36 | finish(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/project/radua/cardtask/MainActivity.java: -------------------------------------------------------------------------------- 1 | package project.radua.cardtask; 2 | 3 | import android.app.AppOpsManager; 4 | import android.app.usage.UsageStats; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | import android.content.SharedPreferences; 8 | import android.net.Uri; 9 | import android.os.Build; 10 | import android.provider.Settings; 11 | import android.support.design.widget.FloatingActionButton; 12 | import android.support.design.widget.Snackbar; 13 | import android.support.v7.app.AppCompatActivity; 14 | import android.os.Bundle; 15 | import android.view.View; 16 | import android.widget.Button; 17 | import android.widget.CompoundButton; 18 | import android.widget.Switch; 19 | import android.widget.TextView; 20 | import android.widget.Toast; 21 | 22 | import java.util.List; 23 | 24 | public class MainActivity extends AppCompatActivity { 25 | 26 | @Override 27 | protected void onCreate(Bundle savedInstanceState) { 28 | super.onCreate(savedInstanceState); 29 | setContentView(R.layout.activity_main); 30 | final FloatingActionButton floatingActionButton = findViewById(R.id.floatingActionButton); 31 | final Switch swit = findViewById(R.id.switch1); 32 | if (!hasPermission()) { 33 | Snackbar.make(floatingActionButton, "请先检查权限是否开启!", Snackbar.LENGTH_INDEFINITE) 34 | .setAction("开启权限", new View.OnClickListener() { 35 | @Override 36 | public void onClick(View v) { 37 | CheckHasPermisson(); 38 | startActivityForResult(new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName())), 0); 39 | } 40 | }) 41 | .show(); 42 | } 43 | final Button cancelbutton = findViewById(R.id.button); 44 | final Switch openswitch = findViewById(R.id.switch1); 45 | floatingActionButton.setOnClickListener(new View.OnClickListener() { 46 | @Override 47 | public void onClick(View v) { 48 | 49 | CheckHasPermisson(); 50 | 51 | painting paintin = new painting(); 52 | 53 | if (paintin.isServiceRunning(getApplicationContext(),"project.radua.cardtask.CardTaskFloatingWindow")==false ) 54 | { 55 | startFloatingService(new View(getApplicationContext())); 56 | 57 | Snackbar.make(floatingActionButton,"点击悬浮窗试一下吧!",Snackbar.LENGTH_LONG).show(); 58 | 59 | cancelbutton.setVisibility(View.VISIBLE); 60 | openswitch.setChecked(true); 61 | }else { 62 | Snackbar.make(floatingActionButton,"已经开启了悬浮窗",Snackbar.LENGTH_LONG).show(); 63 | 64 | } 65 | } 66 | }); 67 | final painting paintrs = new painting(); 68 | if (paintrs.isServiceRunning(MainActivity.this,"project.radua.cardtask.CardTaskFloatingWindow")==false){ 69 | openswitch.setChecked(false); 70 | }else { 71 | openswitch.setChecked(true); 72 | 73 | } 74 | Button button = findViewById(R.id.button); 75 | button.setOnClickListener(new View.OnClickListener() { 76 | @Override 77 | public void onClick(View v) { 78 | if (paintrs.isServiceRunning(MainActivity.this,"project.radua.cardtask.CardTaskFloatingWindow")==true) { 79 | Intent intent = new Intent(getApplicationContext(), CardTaskFloatingWindow.class); 80 | stopService(intent); 81 | SharedPreferences sp = getSharedPreferences("isrun",Context.MODE_PRIVATE); 82 | SharedPreferences.Editor editor = sp.edit(); 83 | editor.putInt("runmode",1); 84 | editor.commit(); 85 | }else{ 86 | SharedPreferences sp = getSharedPreferences("isrun",Context.MODE_PRIVATE); 87 | SharedPreferences.Editor editor = sp.edit(); 88 | editor.putInt("runmode",0); 89 | editor.commit(); 90 | } 91 | Intent intent1 = new Intent(MainActivity.this, SettingActivity.class); 92 | startActivity(intent1); 93 | } 94 | }); 95 | //this.setFinishOnTouchOutside(true) 96 | openswitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { 97 | @Override 98 | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { 99 | if (!isChecked) { 100 | Intent intent = new Intent(MainActivity.this, CardTaskFloatingWindow.class); 101 | stopService(intent); 102 | openswitch.setChecked(false); 103 | }else { 104 | painting painting = new painting(); 105 | if (painting.isServiceRunning(MainActivity.this,"project.radua.cardtask.CardTaskFloatingWindow")==false){ 106 | startFloatingService(new View(getApplicationContext())); 107 | } 108 | } 109 | } 110 | }); 111 | 112 | } 113 | public void startFloatingService(View view) { 114 | Intent intenta = new Intent(MainActivity.this, CardTaskFloatingWindow.class); 115 | 116 | if (!Settings.canDrawOverlays(this)) { 117 | Toast.makeText(this, "当前无权限,请授权", Toast.LENGTH_SHORT); 118 | startActivityForResult(new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName())), 0); 119 | } else { 120 | startService(intenta); 121 | 122 | } 123 | } 124 | private int MY_PERMISSIONS_PACKAGE_USAGE_STATS; 125 | public void CheckHasPermisson(){ 126 | if (Build.VERSION.SDK_INT 127 | >= Build.VERSION_CODES.KITKAT){ 128 | if (!hasPermission()){ 129 | Toast.makeText(this,"请打开权限",Toast.LENGTH_SHORT); 130 | startActivityForResult( 131 | new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS), 132 | MY_PERMISSIONS_PACKAGE_USAGE_STATS 133 | ); 134 | } 135 | } 136 | } 137 | 138 | private Boolean hasPermission(){ 139 | AppOpsManager appops = (AppOpsManager)getSystemService(Context.APP_OPS_SERVICE); 140 | int mode =0; 141 | mode = appops.checkOpNoThrow(AppOpsManager.OPSTR_GET_USAGE_STATS,android.os.Process.myUid(),getPackageName()); 142 | return mode == AppOpsManager.MODE_ALLOWED; 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /app/src/main/java/project/radua/cardtask/SQLiteHelper.java: -------------------------------------------------------------------------------- 1 | package project.radua.cardtask; 2 | 3 | import android.content.Context; 4 | import android.database.sqlite.SQLiteDatabase; 5 | import android.database.sqlite.SQLiteOpenHelper; 6 | 7 | public class SQLiteHelper extends SQLiteOpenHelper { 8 | private static final String dbname="REBOT.db"; 9 | private static final int version=1; 10 | private static SQLiteHelper dbHelper; 11 | //也可以不指定字段的类型、长度,因为int类型也可以保存Char类型的创建学生表 12 | private final String createTb="CREATE TABLE User (_id INTEGER PRIMARY KEY AUTOINCREMENT,name VARCHAR2,avatar BLOB)"; 13 | 14 | public SQLiteHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) { 15 | super(context, name, factory, version); 16 | } 17 | 18 | public SQLiteHelper(Context context){ 19 | super(context, dbname, null, version); 20 | } 21 | 22 | public static SQLiteHelper getInstance(Context context) { 23 | 24 | if (dbHelper == null) { //单例模式 25 | dbHelper = new SQLiteHelper(context); 26 | } 27 | return dbHelper; 28 | } 29 | 30 | @Override 31 | public void onCreate(SQLiteDatabase db) { 32 | // 创建一个数据库表 User ,字段:_id、name、avatar。 33 | db.execSQL(createTb); 34 | } 35 | 36 | @Override 37 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/project/radua/cardtask/SettingActivity.java: -------------------------------------------------------------------------------- 1 | package project.radua.cardtask; 2 | 3 | import android.app.LauncherActivity; 4 | import android.content.ContentProvider; 5 | import android.content.ContentResolver; 6 | import android.content.ContentValues; 7 | import android.content.Context; 8 | import android.content.Intent; 9 | import android.content.SharedPreferences; 10 | import android.database.sqlite.SQLiteDatabase; 11 | import android.graphics.Bitmap; 12 | import android.graphics.BitmapFactory; 13 | import android.net.Uri; 14 | import android.os.Build; 15 | import android.provider.Settings; 16 | import android.support.annotation.RequiresApi; 17 | import android.support.design.widget.Snackbar; 18 | import android.support.v7.app.AppCompatActivity; 19 | import android.os.Bundle; 20 | import android.view.MotionEvent; 21 | import android.view.View; 22 | import android.view.ViewDebug; 23 | import android.view.WindowInsets; 24 | import android.view.inputmethod.InputMethodManager; 25 | import android.widget.ArrayAdapter; 26 | import android.widget.Button; 27 | import android.widget.EditText; 28 | import android.widget.ImageView; 29 | import android.widget.ListView; 30 | import android.widget.RadioButton; 31 | import android.widget.RadioGroup; 32 | import android.widget.TextView; 33 | import android.widget.Toast; 34 | 35 | import java.io.ByteArrayOutputStream; 36 | import java.io.IOException; 37 | import java.util.ArrayList; 38 | import java.util.List; 39 | 40 | public class SettingActivity extends AppCompatActivity { 41 | 42 | RadioButton radioButton1; 43 | RadioButton radioButton2; 44 | RadioButton radioButton3; 45 | RadioButton radioButton4; 46 | RadioButton radioButton5; 47 | Bitmap bitmap; 48 | Button button; 49 | Button button2; 50 | Button button3; 51 | Button button5; 52 | Button button6; 53 | TextView textView; 54 | EditText editText2; 55 | EditText editText3; 56 | ImageView imageView11; 57 | DBOperate dbOperate; 58 | int Speed = 600; 59 | SharedPreferences sp; 60 | SQLiteDatabase db; 61 | public int Position = 0; 62 | public int ishide = 0; 63 | private static final int PICTURE = 10086; 64 | private SQLiteHelper dbHelper; 65 | private Context context; 66 | @RequiresApi(api = Build.VERSION_CODES.O) 67 | @Override 68 | protected void onCreate(Bundle savedInstanceState) { 69 | super.onCreate(savedInstanceState); 70 | setContentView(R.layout.activity_setting); 71 | radioButton1 = findViewById(R.id.radioButton); 72 | radioButton2 = findViewById(R.id.radioButton2); 73 | radioButton3 = findViewById(R.id.radioButton3); 74 | radioButton4 = findViewById(R.id.radioButton4); 75 | radioButton5 = findViewById(R.id.radioButton5); 76 | textView = findViewById(R.id.textView2); 77 | imageView11 = findViewById(R.id.imageView11); 78 | sp = getSharedPreferences("positions", Context.MODE_PRIVATE); 79 | Position = sp.getInt("positions",0); 80 | init(); 81 | if (Position == 0){ 82 | radioButton1.setChecked(true); 83 | } 84 | if (Position == 1){ 85 | radioButton2.setChecked(true); 86 | } 87 | if (Position == 2) { 88 | radioButton3.setChecked(true); 89 | } 90 | ishide = sp.getInt("ishide",0); 91 | if (ishide == 0) 92 | { 93 | radioButton4.setChecked(true); 94 | } 95 | if (ishide == 1) 96 | { 97 | radioButton5.setChecked(true); 98 | } 99 | radioButton1.setOnClickListener(new View.OnClickListener() { 100 | @Override 101 | public void onClick(View v) { 102 | Position = 0; 103 | SharedPreferences.Editor editor = sp.edit(); 104 | editor.putInt("positions",Position); 105 | editor.commit(); 106 | } 107 | }); 108 | radioButton2.setOnClickListener(new View.OnClickListener() { 109 | @Override 110 | public void onClick(View v) { 111 | Position = 1; 112 | SharedPreferences.Editor editor = sp.edit(); 113 | editor.putInt("positions",Position); 114 | editor.commit(); 115 | } 116 | }); 117 | radioButton3.setOnClickListener(new View.OnClickListener() { 118 | @Override 119 | public void onClick(View v) { 120 | Position = 2; 121 | SharedPreferences.Editor editor= sp.edit(); 122 | editor.putInt("positions",Position); 123 | editor.commit(); 124 | 125 | } 126 | }); 127 | radioButton4.setOnClickListener(new View.OnClickListener() { 128 | @Override 129 | public void onClick(View v) { 130 | ishide = 0; 131 | SharedPreferences.Editor editor = sp.edit(); 132 | editor.putInt("ishide",ishide); 133 | editor.commit(); 134 | } 135 | }); 136 | radioButton5.setOnClickListener(new View.OnClickListener() { 137 | @Override 138 | public void onClick(View v) { 139 | ishide = 1; 140 | SharedPreferences.Editor editor = sp.edit(); 141 | editor.putInt("ishide",ishide); 142 | editor.commit(); 143 | } 144 | }); 145 | button = findViewById(R.id.button2); 146 | button.setOnClickListener(new View.OnClickListener() { 147 | @Override 148 | public void onClick(View v) { 149 | EditText editTexts = findViewById(R.id.editText); 150 | String s = editTexts.getText().toString(); 151 | try { 152 | Speed = Integer.parseInt(s); 153 | }catch (Exception e){ 154 | 155 | } 156 | if (Speed < 200 ||Speed > 2000){ 157 | Snackbar.make(button,"请不要输入小于200或大于2000的速度值!",Snackbar.LENGTH_LONG).show(); 158 | editTexts.clearFocus(); 159 | InputMethodManager inputManager = (InputMethodManager) SettingActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE); 160 | inputManager.hideSoftInputFromWindow(editTexts.getWindowToken(),0); 161 | }else { 162 | SharedPreferences sps = getSharedPreferences("speed", Context.MODE_PRIVATE); 163 | SharedPreferences.Editor editor = sps.edit(); 164 | editor.putInt("speed",Speed); 165 | editor.commit(); 166 | Snackbar.make(button,"设置成功",Snackbar.LENGTH_LONG).show(); 167 | editTexts.clearFocus(); 168 | InputMethodManager inputManager = (InputMethodManager) SettingActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE); 169 | inputManager.hideSoftInputFromWindow(editTexts.getWindowToken(),0); 170 | } 171 | } 172 | }); 173 | button2 = findViewById(R.id.button3); 174 | button2.setOnClickListener(new View.OnClickListener() { 175 | @Override 176 | public void onClick(View v) { 177 | EditText editText = findViewById(R.id.editText3); 178 | String s = editText.getText().toString(); 179 | int re = 20; 180 | try{ 181 | re = Integer.parseInt(s); 182 | }catch (Exception e){ 183 | 184 | } 185 | if(re > 200||re < 0){ 186 | Toast.makeText(getApplicationContext(),"超出极限值,请重新输入!",Toast.LENGTH_SHORT).show(); 187 | }else { 188 | SharedPreferences sps = getSharedPreferences("round", Context.MODE_PRIVATE); 189 | SharedPreferences.Editor editor = sps.edit(); 190 | editor.putInt("round",re); 191 | editor.commit(); 192 | Snackbar.make(button,"设置成功",Snackbar.LENGTH_LONG).show(); 193 | editText.clearFocus(); 194 | InputMethodManager inputManager = (InputMethodManager) SettingActivity.this.getSystemService(Context.INPUT_METHOD_SERVICE); 195 | inputManager.hideSoftInputFromWindow(editText.getWindowToken(),0); 196 | } 197 | } 198 | }); 199 | 200 | button3 = findViewById(R.id.button4); 201 | button3.setOnClickListener(new View.OnClickListener() { 202 | @Override 203 | public void onClick(View v) { 204 | Intent intent = new Intent(); 205 | intent.setAction(Intent.ACTION_GET_CONTENT); 206 | intent.setType("image/*"); 207 | //intent.addCategory(Intent.ACTION_OPEN_DOCUMENT); 208 | startActivityForResult(intent,PICTURE); 209 | } 210 | }); 211 | button5 = findViewById(R.id.button5); 212 | button5.setOnClickListener(new View.OnClickListener() { 213 | @Override 214 | public void onClick(View v) { 215 | imageView11.setImageResource(R.drawable.floatin); 216 | SharedPreferences sp = getSharedPreferences("pisturefloat",Context.MODE_PRIVATE); 217 | SharedPreferences.Editor editor = sp.edit(); 218 | editor.putInt("key",0); 219 | editor.commit(); 220 | } 221 | }); 222 | button6 = findViewById(R.id.button6); 223 | editText2 = findViewById(R.id.editText2); 224 | editText3 = findViewById(R.id.editText4); 225 | editText2.setOnClickListener(new View.OnClickListener() { 226 | @Override 227 | public void onClick(View v) { 228 | Snackbar.make(button6,"请输入大于0并且小于90的坐标值",Snackbar.LENGTH_SHORT).show(); 229 | } 230 | }); 231 | button6.setOnClickListener(new View.OnClickListener() { 232 | @Override 233 | public void onClick(View v) { 234 | String s1 = editText2.getText().toString(); 235 | String s2 = editText3.getText().toString(); 236 | int x = Integer.parseInt(s1); 237 | int y = Integer.parseInt(s2); 238 | if (x<0||y<0){ 239 | Snackbar.make(button6,"请输入大于0并且小于90的坐标值",Snackbar.LENGTH_SHORT).show(); 240 | }else if(x>90||y>90){ 241 | Snackbar.make(button6,"请输入大于0并且小于90的坐标值",Snackbar.LENGTH_SHORT).show(); 242 | }else { 243 | SharedPreferences sps = getSharedPreferences("pickcolor",Context.MODE_PRIVATE); 244 | SharedPreferences.Editor spsedit= sps.edit(); 245 | spsedit.putInt("x",x); 246 | spsedit.putInt("y",y); 247 | spsedit.commit(); 248 | Snackbar.make(button6,"取色坐标保存成功!",Snackbar.LENGTH_SHORT).show(); 249 | } 250 | } 251 | }); 252 | } 253 | public void init(){ 254 | dbOperate=new DBOperate(this); 255 | byte[] imgData = dbOperate.readImage(); 256 | try { 257 | Bitmap imagebitmap = BitmapFactory.decodeByteArray(imgData, 0, imgData.length); 258 | imageView11.setImageBitmap(imagebitmap); 259 | SharedPreferences sps = getSharedPreferences("pisturefloat", Context.MODE_PRIVATE); 260 | int asd = sps.getInt("key", 0); 261 | if (asd == 0) { 262 | imageView11.setImageResource(R.drawable.floatin); 263 | } 264 | }catch (Exception e){ 265 | 266 | } 267 | } 268 | @Override 269 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { 270 | if (data == null){ 271 | this.finish(); 272 | return; 273 | } 274 | Uri uri = data.getData(); 275 | switch (requestCode){ 276 | case PICTURE: 277 | ContentResolver cr = this.getContentResolver(); 278 | try{ 279 | bitmap = BitmapFactory.decodeStream(cr.openInputStream(uri)); 280 | imageView11.setImageBitmap(bitmap); 281 | dbOperate.saveImage(bitmap); 282 | SharedPreferences sp = getSharedPreferences("pisturefloat",Context.MODE_PRIVATE); 283 | SharedPreferences.Editor editor = sp.edit(); 284 | editor.putInt("key",1); 285 | editor.commit(); 286 | }catch (Exception e){ 287 | 288 | } 289 | default:break; 290 | } 291 | } 292 | @Override 293 | protected void onDestroy() { 294 | painting painting = new painting(); 295 | if (painting.isServiceRunning(SettingActivity.this, "project.radua.cardtask.CardTaskFloatingWindow") == false) { 296 | SharedPreferences sp = getSharedPreferences("isrun",Context.MODE_PRIVATE); 297 | int isrun = sp.getInt("runmode",0); 298 | if (isrun == 1) { 299 | startFloatingService(new View(getApplicationContext())); 300 | } 301 | } 302 | super.onDestroy(); 303 | } 304 | 305 | public void startFloatingService(View view) { 306 | Intent intenta = new Intent(SettingActivity.this, CardTaskFloatingWindow.class); 307 | 308 | if (!Settings.canDrawOverlays(this)) { 309 | Toast.makeText(this, "当前无权限,请授权", Toast.LENGTH_SHORT); 310 | startActivityForResult(new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName())), 0); 311 | } else { 312 | startService(intenta); 313 | 314 | } 315 | 316 | } 317 | } 318 | -------------------------------------------------------------------------------- /app/src/main/java/project/radua/cardtask/WelcomeActivity.java: -------------------------------------------------------------------------------- 1 | package project.radua.cardtask; 2 | 3 | import android.content.Intent; 4 | import android.content.SharedPreferences; 5 | import android.content.pm.PackageInfo; 6 | import android.content.pm.PackageManager; 7 | import android.os.Bundle; 8 | import android.preference.PreferenceManager; 9 | import android.support.design.widget.FloatingActionButton; 10 | import android.support.design.widget.Snackbar; 11 | import android.support.v7.app.AppCompatActivity; 12 | import android.support.v7.widget.Toolbar; 13 | import android.view.View; 14 | 15 | public class WelcomeActivity extends AppCompatActivity { 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity_welcome); 21 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 22 | setSupportActionBar(toolbar); 23 | 24 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 25 | 26 | 27 | fab.setOnClickListener(new View.OnClickListener() { 28 | @Override 29 | public void onClick(View view) { 30 | Intent intent = new Intent(WelcomeActivity.this,MainActivity.class); 31 | startActivity(intent); 32 | finish(); 33 | } 34 | }); 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /app/src/main/java/project/radua/cardtask/painting.java: -------------------------------------------------------------------------------- 1 | package project.radua.cardtask; 2 | 3 | import android.app.ActivityManager; 4 | import android.app.usage.UsageStats; 5 | import android.app.usage.UsageStatsManager; 6 | import android.content.Context; 7 | import android.content.Intent; 8 | import android.content.SharedPreferences; 9 | import android.content.pm.ApplicationInfo; 10 | import android.content.pm.PackageManager; 11 | import android.graphics.Bitmap; 12 | import android.graphics.Canvas; 13 | import android.graphics.Color; 14 | import android.graphics.Paint; 15 | import android.graphics.PixelFormat; 16 | import android.graphics.drawable.Drawable; 17 | import android.os.Build; 18 | import android.provider.Settings; 19 | import android.text.TextUtils; 20 | import android.view.View; 21 | 22 | import java.util.ArrayList; 23 | import java.util.List; 24 | import android.content.pm.PackageManager; 25 | import android.widget.Toast; 26 | 27 | public class painting { 28 | Paint p = new Paint(); 29 | 30 | 31 | //drawable转换为bitmap的专属方法 32 | public Bitmap drawableToBitamp(Drawable drawable) { 33 | Bitmap bitmap; 34 | int w = drawable.getIntrinsicWidth(); 35 | int h = drawable.getIntrinsicHeight(); 36 | Bitmap.Config config = 37 | drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888 38 | : Bitmap.Config.RGB_565; 39 | bitmap = Bitmap.createBitmap(w, h, config); 40 | //注意,下面三行代码要用到,否在在View或者surfaceview里的canvas.drawBitmap会看不到图 41 | Canvas canvas = new Canvas(bitmap); 42 | drawable.setBounds(0, 0, w, h); 43 | drawable.draw(canvas); 44 | 45 | return bitmap; 46 | } 47 | 48 | //获取app包名列表 49 | public List CreatAppList(Context context) { 50 | List statr = null; 51 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 52 | UsageStatsManager m = (UsageStatsManager) context.getSystemService(Context.USAGE_STATS_SERVICE); 53 | 54 | if (m != null) { 55 | long now = System.currentTimeMillis(); 56 | List stats = m.queryUsageStats(UsageStatsManager.INTERVAL_BEST, now - 60 * 1000, now); 57 | String names = ""; 58 | String nameone = ""; 59 | View view = new View(context); 60 | String str = ""; 61 | //这里写一个冒泡排序,进行app包名的由新到旧排序 62 | for (int i = 0; i < stats.size(); i++) { 63 | for (int j = 0; j < stats.size() - 1; j++) { 64 | if (stats.get(j).getLastTimeUsed() < stats.get(j + 1).getLastTimeUsed()) { 65 | //str = stats.get(j).getPackageName(); 66 | 67 | UsageStats us = stats.get(j); 68 | 69 | stats.set(j, stats.get(j + 1)); 70 | 71 | stats.set(j + 1, us); 72 | 73 | } 74 | } 75 | } 76 | 77 | for (int i=0;i < stats.size();i++) 78 | { 79 | if (stats.get(i).getPackageName().contains("launcher")) 80 | { 81 | stats.remove(i); 82 | } 83 | 84 | } 85 | 86 | for (int i=0;i < stats.size();i++) 87 | { 88 | if (stats.get(i).getPackageName().equals("android")){ 89 | stats.remove(i); 90 | } 91 | } 92 | //示例化的方法 93 | statr = stats; 94 | //最后复制进程名单 95 | 96 | } 97 | 98 | 99 | } 100 | 101 | return statr; 102 | } 103 | 104 | //根据指定包名获取图标信息 105 | public Drawable GetIcon(String string, Context context) { 106 | PackageManager pm = context.getPackageManager(); 107 | try { 108 | ApplicationInfo info = pm.getApplicationInfo(string, PackageManager.GET_META_DATA); 109 | 110 | Drawable appIcon = pm.getApplicationIcon(info); 111 | return appIcon; 112 | } catch (Exception e) { 113 | e.printStackTrace(); 114 | 115 | } 116 | return null; 117 | } 118 | 119 | //获取空bitmap 120 | public void CreatNewMainPicture() { 121 | Bitmap bitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888); 122 | 123 | Canvas canvas = new Canvas(bitmap); 124 | painting paint = new painting(); 125 | } 126 | 127 | //app专属取色 128 | public int GetColor(Bitmap bitmap,int colopositionx,int colopositiony) { 129 | 130 | int positionx = 40; 131 | int positiony = 40; 132 | if (colopositionx != -1||colopositiony != -1){ 133 | positionx = colopositionx; 134 | positiony = colopositiony; 135 | } 136 | int Colo = -1; 137 | Colo = bitmap.getPixel(positionx, positiony); 138 | int a = Color.alpha(Colo); 139 | int r = Color.red(Colo); 140 | int g = Color.green(Colo); 141 | int b = Color.blue(Colo); 142 | int color = Color.argb(a, r, g, b); 143 | return color; 144 | } 145 | 146 | //跳转到指定的包名指向的App中去 147 | public void TurnToActivity(String PakageName, Context context) { 148 | Intent intent = context.getPackageManager().getLaunchIntentForPackage(PakageName); 149 | if (intent == null) return; 150 | context.startActivity(intent); 151 | } 152 | 153 | 154 | //判断是否运行service 155 | public boolean isServiceRunning(Context context, String ServiceName) { 156 | if (TextUtils.isEmpty(ServiceName)) { 157 | return false; 158 | } 159 | ActivityManager myManager = (ActivityManager) context 160 | .getSystemService(Context.ACTIVITY_SERVICE); 161 | ArrayList runningService = (ArrayList) myManager 162 | .getRunningServices(30); 163 | for (int i = 0; i < runningService.size(); i++) { 164 | if (runningService.get(i).service.getClassName().toString() 165 | .equals(ServiceName)) { 166 | return true; 167 | } 168 | } 169 | return false; 170 | } 171 | 172 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/floatin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Raduap/CardTask/f649bf9670c9d09d70a677a5137393637da2f341/app/src/main/res/drawable/floatin.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_info_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_notifications_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sync_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/test.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Raduap/CardTask/f649bf9670c9d09d70a677a5137393637da2f341/app/src/main/res/drawable/test.jpg -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_first.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 21 | 22 | 37 | 38 | 54 | 55 |