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;
/*
*
* A lot of hackery is done in this activity. Changing things may will brake the whole activity.
*
* Should be kinda stable ONLY AS IT IS!!!
*
* */
/**
* 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!!!
*/
public class AlbumDetailActivity extends AbsFabActivity {
public static final String TAG = AlbumDetailActivity.class.getSimpleName();
@ -130,6 +127,16 @@ public class AlbumDetailActivity extends AbsFabActivity {
if (Util.hasLollipopSDK()) startPostponedEnterTransition();
}
@Override
protected boolean shouldColorStatusBar() {
return false;
}
@Override
protected boolean shouldColorNavBar() {
return false;
}
@Override
public String getTag() {
return TAG;

View file

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

View file

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

View file

@ -49,8 +49,8 @@ import com.squareup.picasso.Picasso;
import java.io.File;
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_ANIMATION_TIME = 1000;
@ -88,7 +88,19 @@ public class MusicControllerActivity extends AbsFabActivity {
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() {
@ -235,12 +247,6 @@ public class MusicControllerActivity extends AbsFabActivity {
footer.setScaleY(0);
}
private void setUpToolBar() {
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
getSupportActionBar().setTitle(null);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
public String getTag() {
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.PlaylistsUtil;
import com.kabouzeid.gramophone.util.PreferenceUtils;
import com.kabouzeid.gramophone.util.Util;
import java.util.ArrayList;
@ -37,13 +36,6 @@ public class PlaylistDetailActivity extends AbsFabActivity {
super.onCreate(savedInstanceState);
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();
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
@ -70,12 +62,22 @@ public class PlaylistDetailActivity extends AbsFabActivity {
recyclerView.setOnScrollListener(dragSortRecycler.getScrollListener());
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setBackgroundColor(primary);
toolbar.setBackgroundColor(PreferenceUtils.getInstance(this).getThemeColorPrimary());
setSupportActionBar(toolbar);
getSupportActionBar().setTitle(playlist.name);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
protected boolean shouldColorStatusBar() {
return true;
}
@Override
protected boolean shouldColorNavBar() {
return true;
}
private void getIntentExtras() {
Bundle intentExtras = getIntent().getExtras();
final int playlistId = intentExtras.getInt(AppKeys.E_PLAYLIST);

View file

@ -36,8 +36,8 @@ import java.util.ArrayList;
import java.util.List;
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 SearchView searchView;
@ -49,13 +49,6 @@ public class SearchActivity extends AbsBaseActivity {
super.onCreate(savedInstanceState);
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.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
@ -99,11 +92,21 @@ public class SearchActivity extends AbsBaseActivity {
});
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setBackgroundColor(primary);
toolbar.setBackgroundColor(PreferenceUtils.getInstance(this).getThemeColorPrimary());
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
protected boolean shouldColorStatusBar() {
return true;
}
@Override
protected boolean shouldColorNavBar() {
return true;
}
@Override
public String getTag() {
return TAG;

View file

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

View file

@ -1,5 +1,6 @@
package com.kabouzeid.gramophone.ui.activities.base;
import android.annotation.TargetApi;
import android.app.ActivityManager;
import android.graphics.BitmapFactory;
import android.os.Build;
@ -17,9 +18,9 @@ import com.kabouzeid.gramophone.util.Util;
*/
public abstract class ThemeBaseActivity extends ActionBarActivity implements KabViewsDisableAble {
private boolean mLastDarkTheme;
private int mLastPrimary;
private int mLastAccent;
// private boolean mLastDarkTheme;
// private int mLastPrimary;
// private int mLastAccent;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -28,40 +29,50 @@ public abstract class ThemeBaseActivity extends ActionBarActivity implements Kab
setupTheme();
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
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
mLastDarkTheme = PreferenceUtils.getInstance(this).getGeneralTheme() == 1;
mLastPrimary = PreferenceUtils.getInstance(this).getThemeColorPrimary();
mLastAccent = PreferenceUtils.getInstance(this).getThemeColorAccent();
// mLastDarkTheme = PreferenceUtils.getInstance(this).getGeneralTheme() == 1;
// mLastPrimary = PreferenceUtils.getInstance(this).getThemeColorPrimary();
// mLastAccent = PreferenceUtils.getInstance(this).getThemeColorAccent();
// 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().neutralColor = ThemeSingleton.get().positiveColor;
ThemeSingleton.get().widgetColor = ThemeSingleton.get().positiveColor;
// Dark theme
ThemeSingleton.get().darkTheme = mLastDarkTheme;
ThemeSingleton.get().darkTheme = PreferenceUtils.getInstance(this).getGeneralTheme() == 1;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
// Sets color of entry in the system recents page
ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(
getString(R.string.app_name),
BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher),
mLastPrimary);
PreferenceUtils.getInstance(this).getThemeColorPrimary());
setTaskDescription(td);
}
}
@Override
protected void onResume() {
super.onResume();
if (mLastDarkTheme != (PreferenceUtils.getInstance(this).getGeneralTheme() == 1) ||
mLastPrimary != PreferenceUtils.getInstance(this).getThemeColorPrimary() ||
mLastAccent != PreferenceUtils.getInstance(this).getThemeColorAccent()) {
// Theme colors changed, recreate the Activity
recreate();
}
}
// @Override
// protected void onResume() {
// super.onResume();
// if (mLastDarkTheme != (PreferenceUtils.getInstance(this).getGeneralTheme() == 1) ||
// mLastPrimary != PreferenceUtils.getInstance(this).getThemeColorPrimary() ||
// mLastAccent != PreferenceUtils.getInstance(this).getThemeColorAccent()) {
// // Theme colors changed, recreate the Activity
// recreate();
// }
// }
protected void setUpTranslucence(boolean statusBarTranslucent, boolean navigationBarTranslucent) {
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();
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() {
@ -129,8 +142,8 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
@Override
public void onClick(View v) {
new MaterialDialog.Builder(AbsTagEditorActivity.this)
.title("Update image")
.items(new CharSequence[]{"Download from LastFM", "Pick from internal storage", "Web search", "Delete"})
.title(R.string.update_image)
.items(R.array.update_albumcover_options)
.itemsCallback(new MaterialDialog.ListCallback() {
@Override
public void onSelection(MaterialDialog dialog, View view, int which, CharSequence text) {
@ -149,9 +162,7 @@ public abstract class AbsTagEditorActivity extends AbsBaseActivity {
break;
}
}
})
.build()
.show();
}).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 List<String> getSongPaths();

View file

@ -32,8 +32,8 @@ import java.util.List;
import java.util.Map;
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 boolean deleteAlbumArt;

View file

@ -16,8 +16,8 @@ import java.util.List;
import java.util.Map;
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 albumTitle;
private EditText artistName;

View file

@ -97,5 +97,13 @@
<string name="accent_color">Accent Color</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="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>