This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : AppCompatActivity() { | |
@Named(BuildModule.buildType) | |
@Inject | |
lateinit var buildType: String | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
DaggerMainComponent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ImageController @Inject constructor( | |
@Named(BuildModule.sdkVersion) private val sdkVersion | |
) { | |
fun decodeAndProcessImage(uri: Uri) { | |
val bitmap = if (sdkVersion < Build.VERSION_CODES.P) { | |
MediaStore.Images.Media.getBitmap(contentResolver, uri) | |
} else { | |
val source = ImageDecoder.createSource(contentResolver, uri) | |
ImageDecoder.decodeBitmap(source) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module | |
class BuildModule { | |
companion object { | |
const val buildType = "com.example.dagger.modules.BuildModule.buildType" | |
const val debug = "com.example.dagger.modules.BuildModule.debug" | |
const val sdkVersion = "com.example.dagger.modules.BuildModule.sdkVersion" | |
} | |
@Provides | |
@Named(debug) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
if ("debug" == "release") { | |
window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE) | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : AppCompatActivity() { | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
if (BuildConfig.BUILD_TYPE == "release") { | |
window.setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE) | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object TestHelpers { | |
// Usage: TestHelpers.setSdkVersion(Build.VERSION_CODES.P) | |
fun setSdkVersion(version: Int) { | |
val field = Build.VERSION::class.java.getField("SDK_INT") | |
field.isAccessible = true | |
val modifiersField = Field::class.java.getDeclaredField("modifiers") | |
modifiersField.isAccessible = true | |
modifiersField.setInt(field, field.modifiers and Modifier.FINAL.inv()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ImageController { | |
fun decodeAndProcessImage(uri: Uri) { | |
val bitmap = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) { | |
MediaStore.Images.Media.getBitmap(contentResolver, uri) | |
} else { | |
val source = ImageDecoder.createSource(contentResolver, uri) | |
ImageDecoder.decodeBitmap(source) | |
} | |
// Do something with the Bitmap |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<color name="launcher_background_color">@android:color/system_accent1_100</color> | |
<color name="launcher_foreground_android_color">@android:color/system_neutral1_800</color> | |
</resources> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<color name="launcher_background_color">@android:color/system_neutral1_800</color> | |
<color name="launcher_foreground_android_color">@android:color/system_accent1_100</color> | |
</resources> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<color name="launcher_background_color">#3DDC84</color> | |
<color name="launcher_foreground_android_color">#FFFFFF</color> | |
</resources> |