Skip to content

Commit

Permalink
bug fix, layout fix, restructured theme and animations
Browse files Browse the repository at this point in the history
  • Loading branch information
nuclearfog committed Aug 15, 2024
1 parent f51cc08 commit 667f81c
Show file tree
Hide file tree
Showing 24 changed files with 121 additions and 131 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AlphaAnimation;
import android.widget.HorizontalScrollView;
import android.widget.ImageView;
import android.widget.TextView;
Expand All @@ -50,11 +49,13 @@
import org.nuclearfog.apollo.ui.views.RepeatButton;
import org.nuclearfog.apollo.ui.views.ShuffleButton;
import org.nuclearfog.apollo.ui.views.theme.HoloSelector;
import org.nuclearfog.apollo.utils.AnimatorUtils;
import org.nuclearfog.apollo.utils.ApolloUtils;
import org.nuclearfog.apollo.utils.Constants;
import org.nuclearfog.apollo.utils.MusicUtils;
import org.nuclearfog.apollo.utils.NavUtils;
import org.nuclearfog.apollo.utils.ServiceBinder.ServiceBinderCallback;
import org.nuclearfog.apollo.utils.ThemeUtils;

import java.util.List;

Expand Down Expand Up @@ -115,7 +116,9 @@ public abstract class ActivityBase extends AppCompatActivity implements ServiceB
@Override
protected final void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setVolumeControlStream(AudioManager.STREAM_MUSIC);
setContentView(getContentView());
View v = getWindow().getDecorView().getRootView();
// Play and pause button
mPlayPauseButton = findViewById(R.id.action_button_play);
// Shuffle button
Expand All @@ -136,15 +139,15 @@ protected final void onCreate(Bundle savedInstanceState) {
View nextButton = findViewById(R.id.action_button_next);
// background of bottom action bar
View bottomActionBar = findViewById(R.id.bottom_action_bar_background);
// Control the media volume
setVolumeControlStream(AudioManager.STREAM_MUSIC);
// Initialize the broadcast receiver

mPlaybackStatus = new PlaybackStatusReceiver(this);
songLoader = new SongLoader(this);
ThemeUtils mTheme = new ThemeUtils(this);

// set bottom action bar color
bottomActionBar.setBackground(new HoloSelector(this));
// hide player controls
playbackControls.setVisibility(View.INVISIBLE);
// set background
mTheme.setBackground(v);

previousButton.setOnClickListener(this);
nextButton.setOnClickListener(this);
Expand Down Expand Up @@ -223,10 +226,7 @@ protected void onDestroy() {
public void onServiceConnected() {
// fade in playback controls
if (playbackControls.getVisibility() != View.VISIBLE) {
AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f);
anim.setDuration(250);
playbackControls.startAnimation(anim);
playbackControls.setVisibility(View.VISIBLE);
AnimatorUtils.fade(playbackControls, true);
playbackControls.scrollTo(0, 0);
}
// Set the playback drawables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,35 +76,34 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
setContentView(R.layout.activity_audiofx);
Toolbar toolbar = findViewById(R.id.audiofx_toolbar);
RecyclerView eq_bands = findViewById(R.id.audiofx_eq_scroll);
View root = findViewById(R.id.audiofx_root);
presetLabel = findViewById(R.id.audiofx_preset_label);
presetSelector = findViewById(R.id.audiofx_preset);
enableFx = findViewById(R.id.audiofx_enable);
bassBoost = findViewById(R.id.audiofx_bass_boost);
reverb = findViewById(R.id.audiofx_reverb);
presetAdapter = new PresetAdapter();
presetLoader = new PresetLoader(this);

int sessionId = getIntent().getIntExtra(KEY_SESSION_ID, 0);
presetAdapter = new PresetAdapter();
presetLoader = new PresetLoader(this);
audioEffects = AudioEffects.getInstance(this, sessionId);

// set theme colors
ThemeUtils mResources = new ThemeUtils(this);
PreferenceUtils mPrefs = PreferenceUtils.getInstance(this);
ColorFilter colorFilter = new PorterDuffColorFilter(mPrefs.getDefaultThemeColor(), PorterDuff.Mode.SRC_IN);

bassBoost.getProgressDrawable().setColorFilter(colorFilter);
bassBoost.getThumb().setColorFilter(colorFilter);
reverb.getProgressDrawable().setColorFilter(colorFilter);
reverb.getThumb().setColorFilter(colorFilter);
enableFx.getThumbDrawable().setColorFilter(colorFilter);

bassBoost.setMax(BASS_STEPS);
reverb.setMax(AudioEffects.MAX_REVERB);
eq_bands.setLayoutManager(new LinearLayoutManager(this, RecyclerView.HORIZONTAL, false));

presetSelector.setAdapter(presetAdapter);
mResources.setBackground(root);

setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
ThemeUtils mResources = new ThemeUtils(this);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mResources.themeActionBar(getSupportActionBar(), R.string.title_audio_effects);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AlphaAnimation;
import android.widget.ImageView;
import android.widget.TextView;

Expand All @@ -42,8 +41,8 @@
import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
import androidx.fragment.app.FragmentContainerView;
import androidx.lifecycle.ViewModelProvider;
import androidx.viewpager.widget.ViewPager;

import org.nuclearfog.apollo.BuildConfig;
import org.nuclearfog.apollo.R;
Expand All @@ -59,7 +58,6 @@
import org.nuclearfog.apollo.receiver.PlaybackStatusReceiver.PlayStatusListener;
import org.nuclearfog.apollo.service.MusicPlaybackService;
import org.nuclearfog.apollo.store.FavoritesStore;
import org.nuclearfog.apollo.ui.adapters.viewpager.QueueAdapter;
import org.nuclearfog.apollo.ui.fragments.QueueFragment;
import org.nuclearfog.apollo.ui.views.PlayPauseButton;
import org.nuclearfog.apollo.ui.views.PlayerSeekbar;
Expand Down Expand Up @@ -121,10 +119,10 @@ public class AudioPlayerActivity extends AppCompatActivity implements ServiceBin
*/
private ImageView mAlbumArt;

/**
* album art borders
*/
private View controls, albumArtBorder1, albumArtBorder2;
private View controls, albumArtBorder1;

@Nullable
private View albumArtBorder2;
/**
* Tiny artwork
*/
Expand All @@ -141,10 +139,8 @@ public class AudioPlayerActivity extends AppCompatActivity implements ServiceBin
* Broadcast receiver
*/
private PlaybackStatusReceiver mPlaybackStatus;
/**
* ViewPager
*/
private ViewPager mViewPager;

private FragmentContainerView queueContainer;
/**
* Image cache
*/
Expand All @@ -171,13 +167,17 @@ public class AudioPlayerActivity extends AppCompatActivity implements ServiceBin
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set the layout
setVolumeControlStream(AudioManager.STREAM_MUSIC);
// init views
setContentView(R.layout.activity_player_base);
mPlayPauseButton = findViewById(R.id.action_button_play);
mShuffleButton = findViewById(R.id.action_button_shuffle);
mRepeatButton = findViewById(R.id.action_button_repeat);
View root = findViewById(R.id.player_root);
Toolbar toolbar = findViewById(R.id.player_toolbar);
RepeatingImageButton mPreviousButton = findViewById(R.id.action_button_previous);
RepeatingImageButton mNextButton = findViewById(R.id.action_button_next);
queueContainer = findViewById(R.id.audio_player_pager);
controls = findViewById(R.id.audio_player_controls);
mTrackName = findViewById(R.id.audio_player_track_name);
mArtistName = findViewById(R.id.audio_player_artist_name);
Expand All @@ -188,39 +188,26 @@ protected void onCreate(Bundle savedInstanceState) {
mQueueSwitch = findViewById(R.id.audio_player_switch_queue);
mQueueSwitch.setImageResource(R.drawable.btn_switch_queue);
playerSeekbar = findViewById(R.id.player_progress);

// set toolbar
Toolbar toolbar = findViewById(R.id.player_toolbar);
if (toolbar != null) // toolbar only available in portrait mode
setSupportActionBar(toolbar);
// Initialze the theme resources
//
mResources = new ThemeUtils(this);
mPrefs = PreferenceUtils.getInstance(this);
playlistSongLoader = new PlaylistSongLoader(this);
artistSongLoader = new ArtistSongLoader(this);
albumSongLoader = new AlbumSongLoader(this);
songLoader = new SongLoader(this);
// app preferences
mPrefs = PreferenceUtils.getInstance(this);
// Control the media volume
setVolumeControlStream(AudioManager.STREAM_MUSIC);
// Initialize the image fetcher/cache
mImageFetcher = ApolloUtils.getImageFetcher(this);
// Initialize the broadcast receiver
mPlaybackStatus = new PlaybackStatusReceiver(this);
viewModel = new ViewModelProvider(this).get(FragmentViewModel.class);
// Theme the action bar
if (toolbar != null)
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
mResources.themeActionBar(actionBar, R.string.app_name);
actionBar.setDisplayHomeAsUpEnabled(true);
}
viewModel = new ViewModelProvider(this).get(FragmentViewModel.class);
// View pager
mViewPager = findViewById(R.id.audio_player_pager);
// Offscreen pager loading limit
mViewPager.setOffscreenPageLimit(1);
// Initialize the pager adapter and attach
QueueAdapter mPagerAdapter = new QueueAdapter(getSupportFragmentManager());
mViewPager.setAdapter(mPagerAdapter);
// set activity background
mResources.setBackground(root);
// set colors
int themeColor = mPrefs.getDefaultThemeColor();
mShuffleButton.setColor(themeColor);
Expand Down Expand Up @@ -479,13 +466,12 @@ public void onClick(@NonNull View v) {
}
// Show the queue, hide the artwork
else if (v.getId() == R.id.audio_player_switch_queue) {
mViewPager.setVisibility(View.VISIBLE);
AnimatorUtils.fade(queueContainer, true);
// switch buttons
mAlbumArtSmall.setVisibility(View.VISIBLE);
// hide this button
mQueueSwitch.setVisibility(View.INVISIBLE);
// Fade out the artwork
if (albumArtBorder1 != null)
AnimatorUtils.fade(albumArtBorder1, false);
AnimatorUtils.fade(albumArtBorder1, false);
if (albumArtBorder2 != null)
AnimatorUtils.fade(albumArtBorder2, false);
AnimatorUtils.fade(mAlbumArt, false);
Expand All @@ -494,13 +480,12 @@ else if (v.getId() == R.id.audio_player_switch_queue) {
}
// Show the artwork, hide the queue
else if (v.getId() == R.id.audio_player_switch_album_art) {
mViewPager.setVisibility(View.INVISIBLE);
AnimatorUtils.fade(queueContainer, false);
// switch buttons
mQueueSwitch.setVisibility(View.VISIBLE);
// hide this button
mAlbumArtSmall.setVisibility(View.INVISIBLE);
// Fade in the album art
if (albumArtBorder1 != null)
AnimatorUtils.fade(albumArtBorder1, true);
AnimatorUtils.fade(albumArtBorder1, true);
if (albumArtBorder2 != null)
AnimatorUtils.fade(albumArtBorder2, true);
AnimatorUtils.fade(mAlbumArt, true);
Expand Down Expand Up @@ -649,10 +634,7 @@ private void updatePlaybackControls() {
boolean isPlaying = MusicUtils.isPlaying(this);
// fade in player control after initialization
if (controls.getVisibility() != View.VISIBLE && controls.getAnimation() == null) {
AlphaAnimation anim = new AlphaAnimation(0.0f, 1.0f);
anim.setDuration(500);
controls.setVisibility(View.VISIBLE);
controls.startAnimation(anim);
AnimatorUtils.fade(controls, true);
}
// Set the play and pause image
mPlayPauseButton.updateState(isPlaying);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import android.app.SearchManager;
import android.content.Intent;
import android.media.AudioManager;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.ContextMenu;
Expand Down Expand Up @@ -112,23 +111,23 @@ protected void init(Bundle savedInstanceState) {
GridView mGridView = findViewById(R.id.grid_search);
TextView emptyText = findViewById(R.id.grid_search_empty_info);
Toolbar toolbar = findViewById(R.id.grid_search_toolbar);
// Initialize the theme resources
View root = findViewById(R.id.grid_search_root);

mAdapter = new SearchAdapter(this);
albumSongLoader = new AlbumSongLoader(this);
artistSongLoader = new ArtistSongLoader(this);
mLoader = new MusicSearchLoader(this);
ThemeUtils mResources = new ThemeUtils(this);

setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
mResources.themeActionBar(getSupportActionBar(), R.string.app_name);
}
// Control the media volume
setVolumeControlStream(AudioManager.STREAM_MUSIC);
// Get the query
String query = getIntent().getStringExtra(SearchManager.QUERY);
mFilterString = !TextUtils.isEmpty(query) ? query : "";
// Action bar subtitle
mResources.setSubtitle("\"" + mFilterString + "\"");
// Initialize the adapter
mAdapter = new SearchAdapter(this);
albumSongLoader = new AlbumSongLoader(this);
artistSongLoader = new ArtistSongLoader(this);
mResources.setBackground(root);
// Set the prefix
mAdapter.setPrefix(mFilterString);
// Bind the data
Expand All @@ -146,9 +145,7 @@ protected void init(Bundle savedInstanceState) {
} else {
mGridView.setNumColumns(ONE);
}
// Prepare the loader. Either re-connect with an existing one,
// or start a new one.
mLoader = new MusicSearchLoader(this);
// Prepare the loader. Either re-connect with an existing one
mLoader.execute(mFilterString, this);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@

import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import org.nuclearfog.apollo.R;
import org.nuclearfog.apollo.ui.fragments.preference.PreferenceFragment;
import org.nuclearfog.apollo.utils.ThemeUtils;
Expand All @@ -38,13 +40,15 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings_layout);
Toolbar toolbar = findViewById(R.id.settings_toolbar);
View root = findViewById(R.id.settings_root);
// setup toolbar
setSupportActionBar(toolbar);
ActionBar actionbar = getSupportActionBar();
if (actionbar != null) {
actionbar.setDisplayHomeAsUpEnabled(true);
ThemeUtils mResources = new ThemeUtils(this);
mResources.themeActionBar(actionbar, R.string.menu_settings);
mResources.setBackground(root);
}
//attach fragment
if (savedInstanceState == null) {
Expand Down

This file was deleted.

Loading

0 comments on commit 667f81c

Please sign in to comment.