Skip to content

Commit 1a4b51f

Browse files
Mawi137stevengill
authored andcommitted
CB-12011: (android) added the possibility to change the spinner color on Android 5.0+ apps
1 parent 0b75c1f commit 1a4b51f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/android/SplashScreen.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Licensed to the Apache Software Foundation (ASF) under one
2424
import android.content.Context;
2525
import android.content.DialogInterface;
2626
import android.content.res.Configuration;
27+
import android.content.res.ColorStateList;
2728
import android.graphics.Color;
2829
import android.graphics.drawable.ColorDrawable;
2930
import android.os.Handler;
@@ -366,6 +367,27 @@ public void onCancel(DialogInterface dialog) {
366367
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
367368
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
368369
progressBar.setLayoutParams(layoutParams);
370+
371+
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
372+
String colorName = preferences.getString("SplashScreenSpinnerColor", null);
373+
if(colorName != null){
374+
int[][] states = new int[][] {
375+
new int[] { android.R.attr.state_enabled}, // enabled
376+
new int[] {-android.R.attr.state_enabled}, // disabled
377+
new int[] {-android.R.attr.state_checked}, // unchecked
378+
new int[] { android.R.attr.state_pressed} // pressed
379+
};
380+
int progressBarColor = Color.parseColor(colorName);
381+
int[] colors = new int[] {
382+
progressBarColor,
383+
progressBarColor,
384+
progressBarColor,
385+
progressBarColor
386+
};
387+
ColorStateList colorStateList = new ColorStateList(states, colors);
388+
progressBar.setIndeterminateTintList(colorStateList);
389+
}
390+
}
369391

370392
centeredLayout.addView(progressBar);
371393

0 commit comments

Comments
 (0)