This test rule is now in the 'test-rules' support repository. Use that one!
https://developer.android.com/reference/android/support/test/rule/ActivityTestRule.html
| import android.content.Context; | |
| import android.graphics.Bitmap; | |
| import android.graphics.BitmapShader; | |
| import android.graphics.Canvas; | |
| import android.graphics.PorterDuff; | |
| import android.graphics.Shader; | |
| import android.graphics.drawable.BitmapDrawable; | |
| import android.graphics.drawable.ClipDrawable; | |
| import android.graphics.drawable.Drawable; | |
| import android.graphics.drawable.LayerDrawable; |
| /** | |
| * Show the activity over the lockscreen and wake up the device. If you launched the app manually | |
| * both of these conditions are already true. If you deployed from the IDE, however, this will | |
| * save you from hundreds of power button presses and pattern swiping per day! | |
| */ | |
| public static void riseAndShine(Activity activity) { | |
| activity.getWindow().addFlags(FLAG_SHOW_WHEN_LOCKED); | |
| PowerManager power = (PowerManager) activity.getSystemService(POWER_SERVICE); | |
| PowerManager.WakeLock lock = |
This test rule is now in the 'test-rules' support repository. Use that one!
https://developer.android.com/reference/android/support/test/rule/ActivityTestRule.html
| /** | |
| * This is just a copy of Android LocalBroadcastManager from SupportLibrary. | |
| * | |
| * Add sticky broadcast support. PS: not sure it is the best way to do that. | |
| * | |
| */ | |
| public class StickyLocalBroadcastManager { | |
| private static class ReceiverRecord { | |
| final IntentFilter filter; |
| /* | |
| * Copyright 2014 Chris Banes | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
Setup a new Android project with Android Studio. If you already have done this you can skip this step.
| /* | |
| * Copyright (C) 2014 The Android Open Source Project | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
| <?xml version="1.0" encoding="utf-8"?> | |
| <resources> | |
| <!-- google's material design colours from | |
| http://www.google.com/design/spec/style/color.html#color-ui-color-palette --> | |
| <!--reds--> | |
| <color name="md_red_50">#fde0dc</color> | |
| <color name="md_red_100">#f9bdbb</color> | |
| <color name="md_red_200">#f69988</color> |
| import android.content.Context; | |
| import android.content.res.TypedArray; | |
| import android.graphics.Canvas; | |
| import android.graphics.drawable.Drawable; | |
| import android.util.AttributeSet; | |
| import android.widget.ImageView; | |
| public class ForegroundImageView extends ImageView { | |
| private Drawable foreground; |
| # Retrofit, OkHttp, Gson | |
| -keepattributes *Annotation* | |
| -keepattributes Signature | |
| -keep class com.squareup.okhttp.** { *; } | |
| -keep interface com.squareup.okhttp.** { *; } | |
| -dontwarn com.squareup.okhttp.** | |
| -dontwarn rx.** | |
| -dontwarn retrofit.** | |
| -keep class retrofit.** { *; } | |
| -keepclasseswithmembers class * { |