use of android.support.v4.content.ContextCompat.getDrawable in project philm by chrisbanes.
the class SideMenuFragment method getIcon.
Drawable getIcon(SideMenuItem item, ColorStateList colorStateList) {
Drawable d = mIcons.get(item);
if (d != null) {
return d;
}
switch(item) {
case DISCOVER:
d = ContextCompat.getDrawable(getContext(), R.drawable.ic_btn_movie);
break;
case LIBRARY:
d = ContextCompat.getDrawable(getContext(), R.drawable.ic_btn_collection);
break;
case WATCHLIST:
d = ContextCompat.getDrawable(getContext(), R.drawable.ic_btn_watchlist);
break;
case SEARCH:
d = ContextCompat.getDrawable(getContext(), R.drawable.ic_btn_search);
break;
}
d = DrawableCompat.wrap(d.mutate());
DrawableCompat.setTintList(d, colorStateList);
mIcons.put(item, d);
return d;
}
use of android.support.v4.content.ContextCompat.getDrawable in project Shuttle by timusus.
the class BaseWidgetConfigureActivity method updateWidgetUI.
public void updateWidgetUI() {
backgroundColor = prefs.getInt(BaseWidgetProvider.ARG_WIDGET_BACKGROUND_COLOR + appWidgetId, ContextCompat.getColor(this, R.color.white));
textColor = prefs.getInt(BaseWidgetProvider.ARG_WIDGET_TEXT_COLOR + appWidgetId, ContextCompat.getColor(this, R.color.white));
Drawable backgroundButtonDrawable = DrawableCompat.wrap(ContextCompat.getDrawable(this, R.drawable.bg_rounded));
backgroundButtonDrawable.setBounds(0, 0, 60, 60);
backgroundColorButton.setCompoundDrawables(backgroundButtonDrawable, null, null, null);
Drawable textButtonDrawable = ContextCompat.getDrawable(this, R.drawable.bg_rounded);
textButtonDrawable.setBounds(0, 0, 60, 60);
textColorButton.setCompoundDrawables(textButtonDrawable, null, null, null);
Fragment fragment = adapter.getRegisteredFragment(pager.getCurrentItem());
if (fragment != null) {
View view = fragment.getView();
if (view != null) {
View widgetLayout = view.findViewById(getRootViewId());
widgetLayout.setBackgroundColor(ColorUtils.adjustAlpha(backgroundColor, alpha));
TextView text1 = widgetLayout.findViewById(R.id.text1);
TextView text2 = widgetLayout.findViewById(R.id.text2);
TextView text3 = widgetLayout.findViewById(R.id.text3);
Song song = mediaManager.getSong();
String trackName = null;
String artistName = null;
String albumName = null;
if (song != null) {
trackName = song.name;
artistName = song.albumArtistName;
albumName = song.albumName;
}
if (trackName != null && text1 != null) {
text1.setText(trackName);
text1.setTextColor(textColor);
}
if (artistName != null && albumName != null && text2 != null && text3 == null) {
text2.setText(artistName + " • " + albumName);
text2.setTextColor(textColor);
} else if (artistName != null && albumName != null && text2 != null) {
text2.setText(albumName);
text2.setTextColor(textColor);
text3.setText(artistName);
text3.setTextColor(textColor);
}
ImageButton shuffleButton = widgetLayout.findViewById(R.id.shuffle_button);
ImageButton prevButton = widgetLayout.findViewById(R.id.prev_button);
ImageButton playButton = widgetLayout.findViewById(R.id.play_button);
ImageButton skipButton = widgetLayout.findViewById(R.id.next_button);
ImageButton repeatButton = widgetLayout.findViewById(R.id.repeat_button);
final ImageView albumArt = widgetLayout.findViewById(R.id.album_art);
if (albumArt != null) {
if (!showAlbumArt) {
albumArt.setVisibility(View.GONE);
return;
} else {
albumArt.setVisibility(View.VISIBLE);
if (pager.getCurrentItem() == 1) {
int colorFilterColor = ContextCompat.getColor(this, R.color.color_filter);
albumArt.setColorFilter(colorFilterColor);
prefs.edit().putInt(BaseWidgetProvider.ARG_WIDGET_COLOR_FILTER + appWidgetId, colorFilterColor).apply();
} else {
prefs.edit().putInt(BaseWidgetProvider.ARG_WIDGET_COLOR_FILTER + appWidgetId, -1).apply();
}
}
Glide.with(this).load(mediaManager.getSong()).diskCacheStrategy(DiskCacheStrategy.ALL).placeholder(R.drawable.ic_placeholder_light_medium).into(albumArt);
}
}
}
}
use of android.support.v4.content.ContextCompat.getDrawable in project qksms by moezbhatti.
the class ThemeManager method showColorPicker.
private static void showColorPicker(QKActivity context, View.OnClickListener saveListener) {
final QKDialog dialog = new QKDialog();
View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_color_picker, null, false);
ColorPickerViewHolder holder = new ColorPickerViewHolder(view);
holder.mTab1.setBackgroundDrawable(getRippleBackground());
holder.mTab2.setBackgroundDrawable(getRippleBackground());
holder.mTab1.setOnClickListener(v -> holder.mPager.setCurrentItem(0));
holder.mTab2.setOnClickListener(v -> holder.mPager.setCurrentItem(1));
ColorPickerPagerAdapter adapter = new ColorPickerPagerAdapter(context);
holder.mPager.setAdapter(adapter);
holder.mPager.setOffscreenPageLimit(1);
holder.mPager.addOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
super.onPageSelected(position);
holder.mTab1.setTextColor(position == 0 ? getColor() : getTextOnBackgroundPrimary());
holder.mTab2.setTextColor(position == 1 ? getColor() : getTextOnBackgroundPrimary());
}
});
int swatchColor = getSwatchColor(getColor());
holder.mPalette.init(19, 4, color -> {
holder.mPalette.init(getSwatch(color).length, 4, color2 -> {
setActiveColor(color2);
saveListener.onClick(null);
dialog.dismiss();
});
holder.mPalette.drawPalette(getSwatch(color), getColor());
});
holder.mPalette.drawPalette(PALETTE, swatchColor);
if (swatchColor == getColor()) {
// If the current theme was set from the RGB picker, show that page instead
holder.mPager.setCurrentItem(1);
}
SeekBar.OnSeekBarChangeListener seekListener = new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
int color = getColor();
color = Color.rgb(seekBar == holder.mRed ? progress : Color.red(color), seekBar == holder.mGreen ? progress : Color.green(color), seekBar == holder.mBlue ? progress : Color.blue(color));
if (seekBar == holder.mRed)
holder.mRedValue.setText(String.valueOf(progress));
if (seekBar == holder.mGreen)
holder.mGreenValue.setText(String.valueOf(progress));
if (seekBar == holder.mBlue)
holder.mBlueValue.setText(String.valueOf(progress));
setActiveColor(color);
String colorString = Integer.toHexString(color);
holder.mHex.setTextChangedListenerEnabled(false);
holder.mHex.setText(colorString.substring(colorString.length() > 6 ? colorString.length() - 6 : 0));
holder.mHex.setTextChangedListenerEnabled(true);
holder.mError.setVisibility(View.INVISIBLE);
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
}
};
Drawable thumbRed = ContextCompat.getDrawable(mContext, R.drawable.seek_thumb);
Drawable thumbGreen = ContextCompat.getDrawable(mContext, R.drawable.seek_thumb);
Drawable thumbBlue = ContextCompat.getDrawable(mContext, R.drawable.seek_thumb);
LiveViewManager.registerView(QKPreference.THEME, holder.mPreview, key -> {
holder.mPreview.setBackgroundColor(getColor());
holder.mRed.getProgressDrawable().setColorFilter(getColor(), PorterDuff.Mode.MULTIPLY);
holder.mGreen.getProgressDrawable().setColorFilter(getColor(), PorterDuff.Mode.MULTIPLY);
holder.mBlue.getProgressDrawable().setColorFilter(getColor(), PorterDuff.Mode.MULTIPLY);
if (holder.mPager.getCurrentItem() == 0) {
holder.mTab1.setTextColor(getColor());
} else {
holder.mTab2.setTextColor(getColor());
}
});
LiveViewManager.registerView(QKPreference.BACKGROUND, holder.mHex, key -> {
holder.mHex.getBackground().setColorFilter(0x22888888, PorterDuff.Mode.MULTIPLY);
holder.mError.setColorFilter(getTextOnBackgroundSecondary(), PorterDuff.Mode.SRC_ATOP);
});
holder.mRed.setThumb(thumbRed);
holder.mRed.setOnSeekBarChangeListener(seekListener);
holder.mGreen.setThumb(thumbGreen);
holder.mGreen.setOnSeekBarChangeListener(seekListener);
holder.mBlue.setThumb(thumbBlue);
holder.mBlue.setOnSeekBarChangeListener(seekListener);
holder.mRed.setProgress(Color.red(getColor()));
holder.mGreen.setProgress(Color.green(getColor()));
holder.mBlue.setProgress(Color.blue(getColor()));
String colorString = Integer.toHexString(getColor());
holder.mHex.setText(colorString.substring(colorString.length() > 6 ? colorString.length() - 6 : 0));
holder.mHex.setOnEditorActionListener((v, actionId, event) -> {
if (actionId == EditorInfo.IME_ACTION_DONE) {
holder.mHex.clearFocus();
KeyboardUtils.hide(mContext, holder.mHex);
}
return false;
});
holder.mHex.setTextChangedListener(s -> {
if (s.length() == 6) {
int color = Color.parseColor("#" + s.toString());
holder.mError.setVisibility(View.INVISIBLE);
if (color != getColor()) {
holder.mRed.setProgress(Color.red(color));
holder.mGreen.setProgress(Color.green(color));
holder.mBlue.setProgress(Color.blue(color));
}
} else {
holder.mError.setVisibility(View.VISIBLE);
}
});
dialog.setContext(context).setCustomView(view).setNegativeButton(R.string.cancel, v -> setActiveColor(getThemeColor())).setPositiveButton(R.string.save, saveListener).show();
}
use of android.support.v4.content.ContextCompat.getDrawable in project Shuttle by timusus.
the class BaseWidgetConfigure method updateWidgetUI.
public void updateWidgetUI() {
backgroundColor = prefs.getInt(BaseWidgetProvider.ARG_WIDGET_BACKGROUND_COLOR + appWidgetId, ContextCompat.getColor(this, R.color.white));
textColor = prefs.getInt(BaseWidgetProvider.ARG_WIDGET_TEXT_COLOR + appWidgetId, ContextCompat.getColor(this, R.color.white));
Drawable backgroundButtonDrawable = DrawableCompat.wrap(ContextCompat.getDrawable(this, R.drawable.bg_rounded));
backgroundButtonDrawable.setBounds(0, 0, 60, 60);
backgroundColorButton.setCompoundDrawables(backgroundButtonDrawable, null, null, null);
Drawable textButtonDrawable = ContextCompat.getDrawable(this, R.drawable.bg_rounded);
textButtonDrawable.setBounds(0, 0, 60, 60);
textColorButton.setCompoundDrawables(textButtonDrawable, null, null, null);
Fragment fragment = adapter.getRegisteredFragment(pager.getCurrentItem());
if (fragment != null) {
View view = fragment.getView();
if (view != null) {
View widgetLayout = view.findViewById(getRootViewId());
widgetLayout.setBackgroundColor(ColorUtils.adjustAlpha(backgroundColor, alpha));
TextView text1 = widgetLayout.findViewById(R.id.text1);
TextView text2 = widgetLayout.findViewById(R.id.text2);
TextView text3 = widgetLayout.findViewById(R.id.text3);
String trackName = MusicUtils.getSongName();
String artistName = MusicUtils.getAlbumArtistName();
final String albumName = MusicUtils.getAlbumName();
if (trackName != null && text1 != null) {
text1.setText(trackName);
text1.setTextColor(textColor);
}
if (artistName != null && albumName != null && text2 != null && text3 == null) {
text2.setText(artistName + " | " + albumName);
text2.setTextColor(textColor);
} else if (artistName != null && albumName != null && text2 != null) {
text2.setText(albumName);
text2.setTextColor(textColor);
text3.setText(artistName);
text3.setTextColor(textColor);
}
ImageButton shuffleButton = widgetLayout.findViewById(R.id.shuffle_button);
ImageButton prevButton = widgetLayout.findViewById(R.id.prev_button);
ImageButton playButton = widgetLayout.findViewById(R.id.play_button);
ImageButton skipButton = widgetLayout.findViewById(R.id.next_button);
ImageButton repeatButton = widgetLayout.findViewById(R.id.repeat_button);
final ImageView albumArt = widgetLayout.findViewById(R.id.album_art);
if (albumArt != null) {
if (!showAlbumArt) {
albumArt.setVisibility(View.GONE);
return;
} else {
albumArt.setVisibility(View.VISIBLE);
if (pager.getCurrentItem() == 1) {
int colorFilterColor = ContextCompat.getColor(this, R.color.color_filter);
albumArt.setColorFilter(colorFilterColor);
prefs.edit().putInt(BaseWidgetProvider.ARG_WIDGET_COLOR_FILTER + appWidgetId, colorFilterColor).apply();
} else {
prefs.edit().putInt(BaseWidgetProvider.ARG_WIDGET_COLOR_FILTER + appWidgetId, -1).apply();
}
}
Glide.with(this).load(MusicUtils.getSong()).diskCacheStrategy(DiskCacheStrategy.ALL).placeholder(R.drawable.ic_placeholder_light_medium).into(albumArt);
}
}
}
}
use of android.support.v4.content.ContextCompat.getDrawable in project AmazeFileManager by TeamAmaze.
the class DatabaseViewerActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
this.checkStorage = false;
super.onCreate(savedInstanceState);
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
if (getAppTheme().equals(AppTheme.DARK)) {
setTheme(R.style.appCompatDark);
getWindow().getDecorView().setBackgroundColor(Utils.getColor(this, R.color.holo_dark_background));
} else if (getAppTheme().equals(AppTheme.BLACK)) {
setTheme(R.style.appCompatBlack);
getWindow().getDecorView().setBackgroundColor(Utils.getColor(this, android.R.color.black));
}
setContentView(R.layout.activity_db_viewer);
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if (SDK_INT >= 21) {
ActivityManager.TaskDescription taskDescription = new ActivityManager.TaskDescription("Amaze", ((BitmapDrawable) ContextCompat.getDrawable(this, R.mipmap.ic_launcher)).getBitmap(), getColorPreference().getColor(ColorUsage.getPrimary(MainActivity.currentTab)));
setTaskDescription(taskDescription);
}
getSupportActionBar().setBackgroundDrawable(getColorPreference().getDrawable(ColorUsage.getPrimary(MainActivity.currentTab)));
boolean useNewStack = sharedPref.getBoolean(PreferencesConstants.PREFERENCE_TEXTEDITOR_NEWSTACK, false);
getSupportActionBar().setDisplayHomeAsUpEnabled(!useNewStack);
if (SDK_INT == 20 || SDK_INT == 19) {
SystemBarTintManager tintManager = new SystemBarTintManager(this);
tintManager.setStatusBarTintEnabled(true);
tintManager.setStatusBarTintColor(getColorPreference().getColor(ColorUsage.getPrimary(MainActivity.currentTab)));
FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.parentdb).getLayoutParams();
SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
p.setMargins(0, config.getStatusBarHeight(), 0, 0);
} else if (SDK_INT >= 21) {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(PreferenceUtils.getStatusColor(getColorPreference().getColorAsString(ColorUsage.getPrimary(MainActivity.currentTab))));
if (getBoolean(PREFERENCE_COLORED_NAVIGATION))
window.setNavigationBarColor(PreferenceUtils.getStatusColor(getColorPreference().getColorAsString(ColorUsage.getPrimary(MainActivity.currentTab))));
}
path = getIntent().getStringExtra("path");
pathFile = new File(path);
listView = findViewById(R.id.listView);
load(pathFile);
listView.setOnItemClickListener((parent, view, position, id) -> {
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
DbViewerFragment fragment = new DbViewerFragment();
Bundle bundle = new Bundle();
bundle.putString("table", arrayList.get(position));
fragment.setArguments(bundle);
fragmentTransaction.add(R.id.content_frame, fragment);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
});
}
Aggregations