Send Intent when Media Store changes. Removed possible memory leak from PreferenceUtil.
This commit is contained in:
parent
b808491206
commit
e0a6535f9f
9 changed files with 104 additions and 153 deletions
|
|
@ -257,7 +257,7 @@ public class MainActivity extends AbsFabActivity
|
|||
}
|
||||
|
||||
private void setUpDrawerLayout() {
|
||||
drawerLayout.setStatusBarBackgroundColor(PreferenceUtil.getInstance(this).getThemeColorPrimaryDarker());
|
||||
drawerLayout.setStatusBarBackgroundColor(getThemeColorPrimaryDarker());
|
||||
setUpNavigationView();
|
||||
}
|
||||
|
||||
|
|
@ -600,7 +600,7 @@ public class MainActivity extends AbsFabActivity
|
|||
cab = new MaterialCab(this, R.id.cab_stub)
|
||||
.setMenu(menu)
|
||||
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
|
||||
.setBackgroundColor(PreferenceUtil.getInstance(this).getThemeColorPrimary())
|
||||
.setBackgroundColor(getThemeColorPrimary())
|
||||
.start(callback);
|
||||
return cab;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ public class PlaylistDetailActivity extends AbsFabActivity implements CabHolder
|
|||
cab = new MaterialCab(this, R.id.cab_stub)
|
||||
.setMenu(menu)
|
||||
.setCloseDrawableRes(R.drawable.ic_close_white_24dp)
|
||||
.setBackgroundColor(PreferenceUtil.getInstance(this).getThemeColorPrimary())
|
||||
.setBackgroundColor(getThemeColorPrimary())
|
||||
.start(callback);
|
||||
return cab;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import android.widget.TextView;
|
|||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.adapter.SearchAdapter;
|
||||
import com.kabouzeid.gramophone.ui.activities.base.AbsBaseActivity;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
||||
import com.kabouzeid.gramophone.util.Util;
|
||||
|
||||
import butterknife.ButterKnife;
|
||||
|
|
@ -66,7 +65,7 @@ public class SearchActivity extends AbsBaseActivity {
|
|||
}
|
||||
});
|
||||
|
||||
toolbar.setBackgroundColor(PreferenceUtil.getInstance(this).getThemeColorPrimary());
|
||||
toolbar.setBackgroundColor(getThemeColorPrimary());
|
||||
setSupportActionBar(toolbar);
|
||||
//noinspection ConstantConditions
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
|
|
|||
|
|
@ -18,9 +18,7 @@ import android.view.MenuItem;
|
|||
import com.afollestad.materialdialogs.util.DialogUtils;
|
||||
import com.kabouzeid.gramophone.R;
|
||||
import com.kabouzeid.gramophone.dialogs.ColorChooserDialog;
|
||||
import com.kabouzeid.gramophone.helper.PlayingNotificationHelper;
|
||||
import com.kabouzeid.gramophone.prefs.ColorChooserPreference;
|
||||
import com.kabouzeid.gramophone.service.MusicService;
|
||||
import com.kabouzeid.gramophone.ui.activities.base.AbsBaseActivity;
|
||||
import com.kabouzeid.gramophone.util.NavigationUtil;
|
||||
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
||||
|
|
@ -35,7 +33,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
setContentView(R.layout.activity_preferences);
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
toolbar.setBackgroundColor(PreferenceUtil.getInstance(this).getThemeColorPrimary());
|
||||
toolbar.setBackgroundColor(getThemeColorPrimary());
|
||||
setSupportActionBar(toolbar);
|
||||
//noinspection ConstantConditions
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
|
@ -92,25 +90,25 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
});
|
||||
|
||||
ColorChooserPreference primaryColor = (ColorChooserPreference) findPreference("primary_color");
|
||||
primaryColor.setColor(PreferenceUtil.getInstance(getActivity()).getThemeColorPrimary(),
|
||||
primaryColor.setColor(((SettingsActivity) getActivity()).getThemeColorPrimary(),
|
||||
DialogUtils.resolveColor(getActivity(), android.R.attr.textColorPrimary));
|
||||
primaryColor.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(@NonNull Preference preference) {
|
||||
new ColorChooserDialog().show(getActivity(), preference.getTitleRes(),
|
||||
PreferenceUtil.getInstance(getActivity()).getThemeColorPrimary());
|
||||
((SettingsActivity) getActivity()).getThemeColorPrimary());
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
ColorChooserPreference accentColor = (ColorChooserPreference) findPreference("accent_color");
|
||||
accentColor.setColor(PreferenceUtil.getInstance(getActivity()).getThemeColorAccent(),
|
||||
accentColor.setColor(((SettingsActivity) getActivity()).getThemeColorAccent(),
|
||||
DialogUtils.resolveColor(getActivity(), android.R.attr.textColorPrimary));
|
||||
accentColor.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
|
||||
@Override
|
||||
public boolean onPreferenceClick(@NonNull Preference preference) {
|
||||
new ColorChooserDialog().show(getActivity(), preference.getTitleRes(),
|
||||
PreferenceUtil.getInstance(getActivity()).getThemeColorAccent());
|
||||
((SettingsActivity) getActivity()).getThemeColorAccent());
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
|
@ -121,33 +119,6 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
|
|||
colorNavBar.setSummary(R.string.pref_only_lollipop);
|
||||
}
|
||||
|
||||
Preference coloredNotification = findPreference("colored_notification");
|
||||
coloredNotification.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
getActivity().sendBroadcast(new Intent(PlayingNotificationHelper.ACTION_NOTIFICATION_COLOR_PREFERENCE_CHANGED).putExtra(PlayingNotificationHelper.EXTRA_NOTIFICATION_COLORED, (boolean) newValue));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
Preference albumArtOnLockscreen = findPreference("album_art_on_lockscreen");
|
||||
albumArtOnLockscreen.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
getActivity().sendBroadcast(new Intent(MusicService.SETTING_ALBUM_ART_ON_LOCKSCREEN_CHANGED).putExtra(MusicService.SETTING_BOOLEAN_EXTRA, (boolean) newValue));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
Preference gaplessPlayback = findPreference("gapless_playback");
|
||||
gaplessPlayback.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
getActivity().sendBroadcast(new Intent(MusicService.SETTING_GAPLESS_PLAYBACK_CHANGED).putExtra(MusicService.SETTING_BOOLEAN_EXTRA, (boolean) newValue));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
Preference ignoreMediaStoreArtwork = findPreference("ignore_media_store_artwork");
|
||||
ignoreMediaStoreArtwork.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -35,9 +35,9 @@ public abstract class AbsThemeActivity extends AppCompatActivity implements KabV
|
|||
|
||||
|
||||
private void setupTheme() {
|
||||
colorPrimary = PreferenceUtil.getInstance(this).getThemeColorPrimary();
|
||||
colorPrimary = PreferenceUtil.getInstance(this).getThemeColorPrimary(this);
|
||||
colorPrimaryDarker = ColorUtil.shiftColorDown(colorPrimary);
|
||||
colorAccent = PreferenceUtil.getInstance(this).getThemeColorAccent();
|
||||
colorAccent = PreferenceUtil.getInstance(this).getThemeColorAccent(this);
|
||||
|
||||
ThemeSingleton.get().positiveColor = colorAccent;
|
||||
ThemeSingleton.get().negativeColor = ThemeSingleton.get().positiveColor;
|
||||
|
|
@ -46,7 +46,7 @@ public abstract class AbsThemeActivity extends AppCompatActivity implements KabV
|
|||
ThemeSingleton.get().darkTheme = PreferenceUtil.getInstance(this).getGeneralTheme() == R.style.Theme_MaterialMusic;
|
||||
|
||||
if (!overridesTaskColor()) {
|
||||
notifyTaskColorChange(PreferenceUtil.getInstance(this).getThemeColorPrimary());
|
||||
notifyTaskColorChange(getThemeColorPrimary());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
|
||||
|
||||
private void resetColors() {
|
||||
paletteColorPrimary = PreferenceUtil.getInstance(this).getThemeColorPrimary();
|
||||
paletteColorPrimary = getThemeColorPrimary();
|
||||
observableScrollViewCallbacks.onScrollChanged(observableScrollView.getCurrentScrollY(), false, false);
|
||||
setStatusBarColor(paletteColorPrimary);
|
||||
if (PreferenceUtil.getInstance(this).coloredNavigationBarTagEditor())
|
||||
|
|
@ -252,7 +252,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
|
|||
observableScrollViewCallbacks.onScrollChanged(observableScrollView.getCurrentScrollY(), false, false);
|
||||
|
||||
paletteColorPrimary = getIntent().getIntExtra(EXTRA_PALETTE,
|
||||
PreferenceUtil.getInstance(this).getThemeColorPrimary());
|
||||
getThemeColorPrimary());
|
||||
toolbar.setBackgroundColor(paletteColorPrimary);
|
||||
header.setBackgroundColor(paletteColorPrimary);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue