Small fixes, theming updates, moved a literal title and literal array to string resources

This commit is contained in:
Aidan Follestad 2015-04-16 18:20:15 -05:00
commit e07614d065
12 changed files with 154 additions and 91 deletions

View file

@ -45,14 +45,11 @@ import com.squareup.picasso.Picasso;
import java.util.ArrayList; import java.util.ArrayList;
/* /**
* * A lot of hackery is done in this activity. Changing things may will brake the whole activity.
* A lot of hackery is done in this activity. Changing things may will brake the whole activity. * <p/>
* * Should be kinda stable ONLY AS IT IS!!!
* Should be kinda stable ONLY AS IT IS!!! */
*
* */
public class AlbumDetailActivity extends AbsFabActivity { public class AlbumDetailActivity extends AbsFabActivity {
public static final String TAG = AlbumDetailActivity.class.getSimpleName(); public static final String TAG = AlbumDetailActivity.class.getSimpleName();
@ -130,6 +127,16 @@ public class AlbumDetailActivity extends AbsFabActivity {
if (Util.hasLollipopSDK()) startPostponedEnterTransition(); if (Util.hasLollipopSDK()) startPostponedEnterTransition();
} }
@Override
protected boolean shouldColorStatusBar() {
return false;
}
@Override
protected boolean shouldColorNavBar() {
return false;
}
@Override @Override
public String getTag() { public String getTag() {
return TAG; return TAG;

View file

@ -54,20 +54,14 @@ import com.squareup.picasso.Picasso;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/* /**
* * A lot of hackery is done in this activity. Changing things may will brake the whole activity.
* A lot of hackery is done in this activity. Changing things may will brake the whole activity. * <p/>
* * Should be kinda stable ONLY AS IT IS!!!
* Should be kinda stable ONLY AS IT IS!!! */
*
* */
public class ArtistDetailActivity extends AbsFabActivity { public class ArtistDetailActivity extends AbsFabActivity {
public static final String TAG = ArtistDetailActivity.class.getSimpleName(); public static final String TAG = ArtistDetailActivity.class.getSimpleName();
public static final String ARG_ARTIST_ID = "com.kabouzeid.gramophone.artist.id";
public static final String ARG_ARTIST_NAME = "com.kabouzeid.gramophone.artist.name";
private Artist artist; private Artist artist;
private ObservableListView songListView; private ObservableListView songListView;
@ -83,7 +77,6 @@ public class ArtistDetailActivity extends AbsFabActivity {
private View songListHeader; private View songListHeader;
private RecyclerView albumRecyclerView; private RecyclerView albumRecyclerView;
private Spanned biography; private Spanned biography;
private final SmallObservableScrollViewCallbacks observableScrollViewCallbacks = new SmallObservableScrollViewCallbacks() { private final SmallObservableScrollViewCallbacks observableScrollViewCallbacks = new SmallObservableScrollViewCallbacks() {
@ -134,13 +127,26 @@ public class ArtistDetailActivity extends AbsFabActivity {
getIntentExtras(); getIntentExtras();
initViews(); initViews();
setUpObservableListViewParams(); setUpObservableListViewParams();
setUpToolBar();
setUpViews(); setUpViews();
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(null);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
if (Util.hasLollipopSDK()) fixLollipopTransitionImageWrongSize(); if (Util.hasLollipopSDK()) fixLollipopTransitionImageWrongSize();
if (Util.hasLollipopSDK()) startPostponedEnterTransition(); if (Util.hasLollipopSDK()) startPostponedEnterTransition();
} }
@Override
protected boolean shouldColorStatusBar() {
return false;
}
@Override
protected boolean shouldColorNavBar() {
return false;
}
private void initViews() { private void initViews() {
artistIv = (ImageView) findViewById(R.id.artist_image); artistIv = (ImageView) findViewById(R.id.artist_image);
toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar = (Toolbar) findViewById(R.id.toolbar);
@ -299,12 +305,6 @@ public class ArtistDetailActivity extends AbsFabActivity {
getWindow().setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color)); getWindow().setNavigationBarColor(DialogUtils.resolveColor(this, R.attr.default_bar_color));
} }
private void setUpToolBar() {
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(null);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
private void getIntentExtras() { private void getIntentExtras() {
Bundle intentExtras = getIntent().getExtras(); Bundle intentExtras = getIntent().getExtras();
final int artistId = intentExtras.getInt(AppKeys.E_ARTIST); final int artistId = intentExtras.getInt(AppKeys.E_ARTIST);

View file

@ -52,8 +52,8 @@ import java.util.List;
public class MainActivity extends AbsFabActivity public class MainActivity extends AbsFabActivity
implements NavigationDrawerFragment.NavigationDrawerCallbacks, KabViewsDisableAble { implements NavigationDrawerFragment.NavigationDrawerCallbacks, KabViewsDisableAble {
public static final String TAG = MainActivity.class.getSimpleName();
public static final String TAG = MainActivity.class.getSimpleName();
private DrawerLayout drawerLayout; private DrawerLayout drawerLayout;
private ActionBarDrawerToggle drawerToggle; private ActionBarDrawerToggle drawerToggle;
private NavigationDrawerFragment navigationDrawerFragment; private NavigationDrawerFragment navigationDrawerFragment;
@ -81,6 +81,16 @@ public class MainActivity extends AbsFabActivity
handlePlaybackIntent(getIntent()); handlePlaybackIntent(getIntent());
} }
@Override
protected boolean shouldColorStatusBar() {
return false;
}
@Override
protected boolean shouldColorNavBar() {
return false;
}
private void setUpViewPager() { private void setUpViewPager() {
pagerAdapter = new PagerAdapter(this, getSupportFragmentManager()); pagerAdapter = new PagerAdapter(this, getSupportFragmentManager());
final PagerAdapter.MusicFragments[] fragments = PagerAdapter.MusicFragments.values(); final PagerAdapter.MusicFragments[] fragments = PagerAdapter.MusicFragments.values();

View file

@ -49,8 +49,8 @@ import com.squareup.picasso.Picasso;
import java.io.File; import java.io.File;
public class MusicControllerActivity extends AbsFabActivity { public class MusicControllerActivity extends AbsFabActivity {
public static final String TAG = MusicControllerActivity.class.getSimpleName();
public static final String TAG = MusicControllerActivity.class.getSimpleName();
private static final int DEFAULT_DELAY = 350; private static final int DEFAULT_DELAY = 350;
private static final int DEFAULT_ANIMATION_TIME = 1000; private static final int DEFAULT_ANIMATION_TIME = 1000;
@ -88,7 +88,19 @@ public class MusicControllerActivity extends AbsFabActivity {
prepareViewsForOpenAnimation(); prepareViewsForOpenAnimation();
setUpToolBar(); setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
getSupportActionBar().setTitle(null);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
protected boolean shouldColorStatusBar() {
return false; // let other code handle this below
}
@Override
protected boolean shouldColorNavBar() {
return false; // let other code handle this below
} }
private void moveSeekBarIntoPlace() { private void moveSeekBarIntoPlace() {
@ -235,12 +247,6 @@ public class MusicControllerActivity extends AbsFabActivity {
footer.setScaleY(0); footer.setScaleY(0);
} }
private void setUpToolBar() {
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
getSupportActionBar().setTitle(null);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override @Override
public String getTag() { public String getTag() {
return TAG; return TAG;

View file

@ -21,7 +21,6 @@ import com.kabouzeid.gramophone.ui.activities.base.AbsFabActivity;
import com.kabouzeid.gramophone.util.NavigationUtil; import com.kabouzeid.gramophone.util.NavigationUtil;
import com.kabouzeid.gramophone.util.PlaylistsUtil; import com.kabouzeid.gramophone.util.PlaylistsUtil;
import com.kabouzeid.gramophone.util.PreferenceUtils; import com.kabouzeid.gramophone.util.PreferenceUtils;
import com.kabouzeid.gramophone.util.Util;
import java.util.ArrayList; import java.util.ArrayList;
@ -37,13 +36,6 @@ public class PlaylistDetailActivity extends AbsFabActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_playlist_detail); setContentView(R.layout.activity_playlist_detail);
final int primary = PreferenceUtils.getInstance(this).getThemeColorPrimary();
final int primaryDark = PreferenceUtils.getInstance(this).getThemeColorPrimaryDarker();
if (Util.hasLollipopSDK()) {
getWindow().setStatusBarColor(primaryDark);
getWindow().setNavigationBarColor(primaryDark);
}
getIntentExtras(); getIntentExtras();
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view); RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
@ -70,12 +62,22 @@ public class PlaylistDetailActivity extends AbsFabActivity {
recyclerView.setOnScrollListener(dragSortRecycler.getScrollListener()); recyclerView.setOnScrollListener(dragSortRecycler.getScrollListener());
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setBackgroundColor(primary); toolbar.setBackgroundColor(PreferenceUtils.getInstance(this).getThemeColorPrimary());
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
getSupportActionBar().setTitle(playlist.name); getSupportActionBar().setTitle(playlist.name);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} }
@Override
protected boolean shouldColorStatusBar() {
return true;
}
@Override
protected boolean shouldColorNavBar() {
return true;
}
private void getIntentExtras() { private void getIntentExtras() {
Bundle intentExtras = getIntent().getExtras(); Bundle intentExtras = getIntent().getExtras();
final int playlistId = intentExtras.getInt(AppKeys.E_PLAYLIST); final int playlistId = intentExtras.getInt(AppKeys.E_PLAYLIST);

View file

@ -36,8 +36,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public class SearchActivity extends AbsBaseActivity { public class SearchActivity extends AbsBaseActivity {
public static final String TAG = SearchActivity.class.getSimpleName();
public static final String TAG = SearchActivity.class.getSimpleName();
private ListView listView; private ListView listView;
private SearchView searchView; private SearchView searchView;
@ -49,13 +49,6 @@ public class SearchActivity extends AbsBaseActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search); setContentView(R.layout.activity_search);
final int primary = PreferenceUtils.getInstance(this).getThemeColorPrimary();
final int primaryDark = PreferenceUtils.getInstance(this).getThemeColorPrimaryDarker();
if (Util.hasLollipopSDK()) {
getWindow().setStatusBarColor(primaryDark);
getWindow().setNavigationBarColor(primaryDark);
}
listView = (ListView) findViewById(R.id.list); listView = (ListView) findViewById(R.id.list);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
@ -99,11 +92,21 @@ public class SearchActivity extends AbsBaseActivity {
}); });
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setBackgroundColor(primary); toolbar.setBackgroundColor(PreferenceUtils.getInstance(this).getThemeColorPrimary());
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} }
@Override
protected boolean shouldColorStatusBar() {
return true;
}
@Override
protected boolean shouldColorNavBar() {
return true;
}
@Override @Override
public String getTag() { public String getTag() {
return TAG; return TAG;

View file

@ -4,7 +4,6 @@ import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.media.audiofx.AudioEffect; import android.media.audiofx.AudioEffect;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.ListPreference; import android.preference.ListPreference;
import android.preference.Preference; import android.preference.Preference;
@ -34,8 +33,6 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
setContentView(R.layout.activity_preferences); setContentView(R.layout.activity_preferences);
mToolbar = (Toolbar) findViewById(R.id.toolbar); mToolbar = (Toolbar) findViewById(R.id.toolbar);
mToolbar.setBackgroundColor(PreferenceUtils.getInstance(this).getThemeColorPrimary()); mToolbar.setBackgroundColor(PreferenceUtils.getInstance(this).getThemeColorPrimary());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
getWindow().setStatusBarColor(PreferenceUtils.getInstance(this).getThemeColorPrimaryDarker());
setSupportActionBar(mToolbar); setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
@ -43,6 +40,16 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
getFragmentManager().beginTransaction().replace(R.id.content_frame, new SettingsFragment()).commit(); getFragmentManager().beginTransaction().replace(R.id.content_frame, new SettingsFragment()).commit();
} }
@Override
protected boolean shouldColorStatusBar() {
return true;
}
@Override
protected boolean shouldColorNavBar() {
return true;
}
@Override @Override
public void onColorSelection(int title, int color) { public void onColorSelection(int title, int color) {
if (title == R.string.primary_color) { if (title == R.string.primary_color) {

View file

@ -1,5 +1,6 @@
package com.kabouzeid.gramophone.ui.activities.base; package com.kabouzeid.gramophone.ui.activities.base;
import android.annotation.TargetApi;
import android.app.ActivityManager; import android.app.ActivityManager;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
import android.os.Build; import android.os.Build;
@ -17,9 +18,9 @@ import com.kabouzeid.gramophone.util.Util;
*/ */
public abstract class ThemeBaseActivity extends ActionBarActivity implements KabViewsDisableAble { public abstract class ThemeBaseActivity extends ActionBarActivity implements KabViewsDisableAble {
private boolean mLastDarkTheme; // private boolean mLastDarkTheme;
private int mLastPrimary; // private int mLastPrimary;
private int mLastAccent; // private int mLastAccent;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -28,40 +29,50 @@ public abstract class ThemeBaseActivity extends ActionBarActivity implements Kab
setupTheme(); setupTheme();
} }
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void setupTheme() { private void setupTheme() {
// Apply colors to system UI if necessary
final int primaryDark = PreferenceUtils.getInstance(this).getThemeColorPrimaryDarker();
if (Util.hasLollipopSDK()) {
if (shouldColorStatusBar())
getWindow().setStatusBarColor(primaryDark);
if (shouldColorNavBar())
getWindow().setNavigationBarColor(primaryDark);
}
// Persist current values so the Activity knows if they change // Persist current values so the Activity knows if they change
mLastDarkTheme = PreferenceUtils.getInstance(this).getGeneralTheme() == 1; // mLastDarkTheme = PreferenceUtils.getInstance(this).getGeneralTheme() == 1;
mLastPrimary = PreferenceUtils.getInstance(this).getThemeColorPrimary(); // mLastPrimary = PreferenceUtils.getInstance(this).getThemeColorPrimary();
mLastAccent = PreferenceUtils.getInstance(this).getThemeColorAccent(); // mLastAccent = PreferenceUtils.getInstance(this).getThemeColorAccent();
// Accent colors in dialogs, and any dynamic views that pull from this singleton // Accent colors in dialogs, and any dynamic views that pull from this singleton
ThemeSingleton.get().positiveColor = mLastAccent; ThemeSingleton.get().positiveColor = PreferenceUtils.getInstance(this).getThemeColorAccent();
ThemeSingleton.get().negativeColor = ThemeSingleton.get().positiveColor; ThemeSingleton.get().negativeColor = ThemeSingleton.get().positiveColor;
ThemeSingleton.get().neutralColor = ThemeSingleton.get().positiveColor; ThemeSingleton.get().neutralColor = ThemeSingleton.get().positiveColor;
ThemeSingleton.get().widgetColor = ThemeSingleton.get().positiveColor; ThemeSingleton.get().widgetColor = ThemeSingleton.get().positiveColor;
// Dark theme // Dark theme
ThemeSingleton.get().darkTheme = mLastDarkTheme; ThemeSingleton.get().darkTheme = PreferenceUtils.getInstance(this).getGeneralTheme() == 1;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// Sets color of entry in the system recents page // Sets color of entry in the system recents page
ActivityManager.TaskDescription td = new ActivityManager.TaskDescription( ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(
getString(R.string.app_name), getString(R.string.app_name),
BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher), BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher),
mLastPrimary); PreferenceUtils.getInstance(this).getThemeColorPrimary());
setTaskDescription(td); setTaskDescription(td);
} }
} }
@Override // @Override
protected void onResume() { // protected void onResume() {
super.onResume(); // super.onResume();
if (mLastDarkTheme != (PreferenceUtils.getInstance(this).getGeneralTheme() == 1) || // if (mLastDarkTheme != (PreferenceUtils.getInstance(this).getGeneralTheme() == 1) ||
mLastPrimary != PreferenceUtils.getInstance(this).getThemeColorPrimary() || // mLastPrimary != PreferenceUtils.getInstance(this).getThemeColorPrimary() ||
mLastAccent != PreferenceUtils.getInstance(this).getThemeColorAccent()) { // mLastAccent != PreferenceUtils.getInstance(this).getThemeColorAccent()) {
// Theme colors changed, recreate the Activity // // Theme colors changed, recreate the Activity
recreate(); // recreate();
} // }
} // }
protected void setUpTranslucence(boolean statusBarTranslucent, boolean navigationBarTranslucent) { protected void setUpTranslucence(boolean statusBarTranslucent, boolean navigationBarTranslucent) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
@ -73,4 +84,8 @@ public abstract class ThemeBaseActivity extends ActionBarActivity implements Kab
} }
} }
} }
protected abstract boolean shouldColorStatusBar();
protected abstract boolean shouldColorNavBar();
} }

View file

@ -95,7 +95,20 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
initViews(); initViews();
setUpViews(); setUpViews();
setUpToolBar();
setSupportActionBar(toolBar);
getSupportActionBar().setTitle(getResources().getString(R.string.tag_editor));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
protected boolean shouldColorStatusBar() {
return false;
}
@Override
protected boolean shouldColorNavBar() {
return false;
} }
private void initViews() { private void initViews() {
@ -129,8 +142,8 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
new MaterialDialog.Builder(AbsTagEditorActivity.this) new MaterialDialog.Builder(AbsTagEditorActivity.this)
.title("Update image") .title(R.string.update_image)
.items(new CharSequence[]{"Download from LastFM", "Pick from internal storage", "Web search", "Delete"}) .items(R.array.update_albumcover_options)
.itemsCallback(new MaterialDialog.ListCallback() { .itemsCallback(new MaterialDialog.ListCallback() {
@Override @Override
public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
@ -149,9 +162,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
break; break;
} }
} }
}) }).show();
.build()
.show();
} }
}); });
} }
@ -201,12 +212,6 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
} }
} }
private void setUpToolBar() {
setSupportActionBar(toolBar);
getSupportActionBar().setTitle(getResources().getString(R.string.tag_editor));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
protected abstract int getContentViewResId(); protected abstract int getContentViewResId();
protected abstract List<String> getSongPaths(); protected abstract List<String> getSongPaths();

View file

@ -32,8 +32,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class AlbumTagEditorActivity extends AbsTagEditorActivity implements TextWatcher { public class AlbumTagEditorActivity extends AbsTagEditorActivity implements TextWatcher {
public static final String TAG = AlbumTagEditorActivity.class.getSimpleName();
public static final String TAG = AlbumTagEditorActivity.class.getSimpleName();
private Bitmap albumArtBitmap; private Bitmap albumArtBitmap;
private boolean deleteAlbumArt; private boolean deleteAlbumArt;

View file

@ -16,8 +16,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class SongTagEditorActivity extends AbsTagEditorActivity implements TextWatcher { public class SongTagEditorActivity extends AbsTagEditorActivity implements TextWatcher {
public static final String TAG = SongTagEditorActivity.class.getSimpleName();
public static final String TAG = SongTagEditorActivity.class.getSimpleName();
private EditText songTitle; private EditText songTitle;
private EditText albumTitle; private EditText albumTitle;
private EditText artistName; private EditText artistName;

View file

@ -97,5 +97,13 @@
<string name="accent_color">Accent Color</string> <string name="accent_color">Accent Color</string>
<string name="primary_color_desc">The primary theme color, defaults to indigo.</string> <string name="primary_color_desc">The primary theme color, defaults to indigo.</string>
<string name="accent_color_desc">The accent theme color, defaults to pink.</string> <string name="accent_color_desc">The accent theme color, defaults to pink.</string>
<string name="update_image">Update Image</string>
<string-array name="update_albumcover_options">
<item>Download from LastFM</item>
<item>Pick from Local Storage</item>
<item>Web Search</item>
<item>Delete</item>
</string-array>
</resources> </resources>