diff --git a/app/app-release.apk b/app/app-release.apk index 576918e6..179fa638 100644 Binary files a/app/app-release.apk and b/app/app-release.apk differ diff --git a/app/build.gradle b/app/build.gradle index b511d028..f0ce889c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,8 +8,8 @@ android { applicationId "com.sdsmdg.harjot.MusicDNA" minSdkVersion 19 targetSdkVersion 23 - versionCode 1 - versionName "1.0" + versionCode 2 + versionName "0.5.0" } buildTypes { release { diff --git a/app/src/main/java/com/sdsmdg/harjot/MusicDNA/EqualizerFragment.java b/app/src/main/java/com/sdsmdg/harjot/MusicDNA/EqualizerFragment.java index 6cbc700e..e27f0118 100644 --- a/app/src/main/java/com/sdsmdg/harjot/MusicDNA/EqualizerFragment.java +++ b/app/src/main/java/com/sdsmdg/harjot/MusicDNA/EqualizerFragment.java @@ -3,11 +3,18 @@ import android.graphics.Color; import android.graphics.Paint; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.os.Bundle; import android.app.Fragment; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ActionMenuView; +import android.widget.LinearLayout; +import android.widget.SeekBar; +import android.widget.TextView; import com.db.chart.model.LineSet; import com.db.chart.view.AxisController; @@ -30,12 +37,15 @@ public class EqualizerFragment extends Fragment { LineSet dataset; LineChartView chart; Paint paint; + float[] points; + + short numberOfFrequencyBands; + LinearLayout mLinearLayout; public EqualizerFragment() { // Required empty public constructor } - @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -47,17 +57,104 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); - paint = new Paint(); - paint.setColor(Color.parseColor("#777777")); chart = (LineChartView) view.findViewById(R.id.lineChart); - + paint = new Paint(); dataset = new LineSet(); - dataset.setColor(Color.parseColor("#3F334D")); - dataset.addPoint("first", (float) 10.0); - dataset.addPoint("second", (float) 17.0); - dataset.addPoint("third", (float) 8.0); - dataset.addPoint("fourth", (float) 15.0); - dataset.addPoint("fifth", (float) 12.0); + + mLinearLayout = (LinearLayout) view.findViewById(R.id.equalizerContainer); + + TextView equalizerHeading = new TextView(HomeActivity.ctx); + equalizerHeading.setText("Equalizer"); + equalizerHeading.setTextSize(20); + equalizerHeading.setGravity(Gravity.CENTER_HORIZONTAL); + +// mLinearLayout.addView(equalizerHeading); + + numberOfFrequencyBands = PlayerFragment.mEqualizer.getNumberOfBands(); + + points = new float[numberOfFrequencyBands]; + + final short lowerEqualizerBandLevel = PlayerFragment.mEqualizer.getBandLevelRange()[0]; + final short upperEqualizerBandLevel = PlayerFragment.mEqualizer.getBandLevelRange()[1]; + + for (short i = 0; i < numberOfFrequencyBands; i++) { + final short equalizerBandIndex = i; + final TextView frequencyHeaderTextView = new TextView(HomeActivity.ctx); + frequencyHeaderTextView.setLayoutParams(new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT + )); + frequencyHeaderTextView.setGravity(Gravity.CENTER_HORIZONTAL); + frequencyHeaderTextView.setTextColor(Color.parseColor("#FFFFFF")); + frequencyHeaderTextView.setText((PlayerFragment.mEqualizer.getCenterFreq(equalizerBandIndex) / 1000) + "Hz"); + mLinearLayout.addView(frequencyHeaderTextView); + + LinearLayout seekBarRowLayout = new LinearLayout(HomeActivity.ctx); + seekBarRowLayout.setOrientation(LinearLayout.HORIZONTAL); + + TextView lowerEqualizerBandLevelTextView = new TextView(HomeActivity.ctx); + lowerEqualizerBandLevelTextView.setLayoutParams(new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.WRAP_CONTENT + )); + lowerEqualizerBandLevelTextView.setTextColor(Color.parseColor("#FFFFFF")); + lowerEqualizerBandLevelTextView.setText((lowerEqualizerBandLevel / 100) + "dB"); + + TextView upperEqualizerBandLevelTextView = new TextView(HomeActivity.ctx); + lowerEqualizerBandLevelTextView.setLayoutParams(new ViewGroup.LayoutParams( + ViewGroup.LayoutParams.WRAP_CONTENT, + ViewGroup.LayoutParams.WRAP_CONTENT + )); + upperEqualizerBandLevelTextView.setTextColor(Color.parseColor("#FFFFFF")); + upperEqualizerBandLevelTextView.setText((upperEqualizerBandLevel / 100) + "dB"); + + LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT + ); + layoutParams.weight = 1; + + SeekBar seekBar = new SeekBar(HomeActivity.ctx); + seekBar.getProgressDrawable().setColorFilter(new PorterDuffColorFilter(Color.parseColor("#FFA036"), PorterDuff.Mode.SRC_IN)); + seekBar.setId(i); + seekBar.setLayoutParams(layoutParams); + seekBar.setMax(upperEqualizerBandLevel - lowerEqualizerBandLevel); + + points[i] = PlayerFragment.mEqualizer.getBandLevel(equalizerBandIndex) - lowerEqualizerBandLevel; + + dataset.addPoint(frequencyHeaderTextView.getText().toString(), points[i]); + + seekBar.setProgress(PlayerFragment.mEqualizer.getBandLevel(equalizerBandIndex) - lowerEqualizerBandLevel); + seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { + @Override + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { + PlayerFragment.mEqualizer.setBandLevel(equalizerBandIndex, (short) (progress + lowerEqualizerBandLevel)); + points[seekBar.getId()] = PlayerFragment.mEqualizer.getBandLevel(equalizerBandIndex) - lowerEqualizerBandLevel; + dataset.updateValues(points); + chart.notifyDataUpdate(); + } + + @Override + public void onStartTrackingTouch(SeekBar seekBar) { + + } + + @Override + public void onStopTrackingTouch(SeekBar seekBar) { + + } + }); + + seekBarRowLayout.addView(lowerEqualizerBandLevelTextView); + seekBarRowLayout.addView(seekBar); + seekBarRowLayout.addView(upperEqualizerBandLevelTextView); + + mLinearLayout.addView(seekBarRowLayout); + } + + paint.setColor(Color.parseColor("#BBBBBB")); + + dataset.setColor(Color.parseColor("#FFA036")); dataset.setSmooth(true); @@ -65,15 +162,17 @@ public void onViewCreated(View view, Bundle savedInstanceState) { chart.setYAxis(false); chart.setYLabels(AxisController.LabelPosition.NONE); - chart.setGrid(ChartView.GridType.HORIZONTAL,paint); + chart.setGrid(ChartView.GridType.HORIZONTAL, paint); + + chart.setAxisBorderValues(-500, 3500); - Animation anim = new Animation(); - anim.setDuration(1500); - anim.setEasing(new ExpoEase()); - anim.setAlpha(1); +// Animation anim = new Animation(); +// anim.setDuration(500); +// anim.setEasing(new ExpoEase()); +// anim.setAlpha(1); chart.addData(dataset); - chart.show(anim); + chart.show(); } } diff --git a/app/src/main/java/com/sdsmdg/harjot/MusicDNA/HomeActivity.java b/app/src/main/java/com/sdsmdg/harjot/MusicDNA/HomeActivity.java index 91aecb3c..f1440629 100644 --- a/app/src/main/java/com/sdsmdg/harjot/MusicDNA/HomeActivity.java +++ b/app/src/main/java/com/sdsmdg/harjot/MusicDNA/HomeActivity.java @@ -83,7 +83,8 @@ public class HomeActivity extends AppCompatActivity FavouritesFragment.onFavouriteItemClickedListener, ViewPlaylistFragment.onPlaylistPlayAllListener, FavouritesFragment.onFavouritePlayAllListener, - QueueFragment.onQueueSaveListener { + QueueFragment.onQueueSaveListener, + PlayerFragment.onEqualizerClickedListener { public static List localTrackList = new ArrayList<>(); public static List finalLocalSearchResultList = new ArrayList<>(); @@ -187,6 +188,7 @@ public void onTrackSelected(int position) { PlayerFragment.mCallback = this; PlayerFragment.mCallback2 = this; PlayerFragment.mCallback3 = this; + PlayerFragment.mCallback4 = this; int flag = 0; for (int i = 0; i < favouriteTracks.getFavourite().size(); i++) { UnifiedTrack ut = favouriteTracks.getFavourite().get(i); @@ -286,6 +288,7 @@ public void onLocalTrackSelected(int position) { PlayerFragment.mCallback = this; PlayerFragment.mCallback2 = this; PlayerFragment.mCallback3 = this; + PlayerFragment.mCallback4 = this; int flag = 0; for (int i = 0; i < favouriteTracks.getFavourite().size(); i++) { UnifiedTrack ut = favouriteTracks.getFavourite().get(i); @@ -997,30 +1000,35 @@ public void onBackPressed() { if (drawer.isDrawerOpen(GravityCompat.START)) { drawer.closeDrawer(GravityCompat.START); } else { - if (isPlayerVisible) { - hidePlayer(); - showTabs(); - isPlayerVisible = false; - } else if (isLocalVisible) { - hideFragment("local"); - setTitle("Music DNA"); - } else if (isQueueVisible) { - hideFragment("queue"); - setTitle("Music DNA"); - } else if (isStreamVisible) { - hideFragment("stream"); - setTitle("Music DNA"); - } else if (isPlaylistVisible) { - hideFragment("playlist"); - setTitle("Music DNA"); - } else if (isEqualizerVisible) { - hideFragment("equalizer"); - setTitle("Music DNA"); - } else if (isFavouriteVisible) { - hideFragment("favourite"); - setTitle("Music DNA"); + + if (isEqualizerVisible) { + showPlayer(); } else { - super.onBackPressed(); + if (isPlayerVisible) { + hidePlayer(); + showTabs(); + isPlayerVisible = false; + } else if (isLocalVisible) { + hideFragment("local"); + setTitle("Music DNA"); + } else if (isQueueVisible) { + hideFragment("queue"); + setTitle("Music DNA"); + } else if (isStreamVisible) { + hideFragment("stream"); + setTitle("Music DNA"); + } else if (isPlaylistVisible) { + hideFragment("playlist"); + setTitle("Music DNA"); + } else if (isEqualizerVisible) { + hideFragment("equalizer"); + setTitle("Music DNA"); + } else if (isFavouriteVisible) { + hideFragment("favourite"); + setTitle("Music DNA"); + } else { + super.onBackPressed(); + } } } } @@ -1049,10 +1057,6 @@ public boolean onOptionsItemSelected(MenuItem item) { if (id == R.id.action_queue) { showFragment("queue"); } - if (id == R.id.action_equalizer) { - showFragment("equalizer"); - } - return super.onOptionsItemSelected(item); } @@ -1273,24 +1277,24 @@ public void requestPermissions() { } public void hideTabs() { -// toolbar.setAlpha(1.0f); -// -// toolbar.animate() -// .translationY(-1 * toolbar.getHeight()) -// .alpha(0.0f); -// -// toolbar.setVisibility(View.GONE); -// getSupportActionBar().hide(); + final Handler handler = new Handler(); + handler.postDelayed(new Runnable() { + @Override + public void run() { + getSupportActionBar().hide(); + } + }, 270); + } public void showTabs() { -// toolbar.setVisibility(View.VISIBLE); -// toolbar.setAlpha(1.0f); -// -// toolbar.animate() -// .translationY(0) -// .alpha(1.0f); -// getSupportActionBar().show(); + final Handler handler = new Handler(); + handler.postDelayed(new Runnable() { + @Override + public void run() { + getSupportActionBar().show(); + } + }, 30); } public void hidePlayer() { @@ -1299,6 +1303,8 @@ public void hidePlayer() { PlayerFragment.mVisualizerView.setVisibility(View.INVISIBLE); drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); + isPlayerVisible = false; + if (PlayerFragment.cpb != null) { PlayerFragment.cpb.setAlpha(0.0f); PlayerFragment.cpb.setVisibility(View.VISIBLE); @@ -1308,6 +1314,40 @@ public void hidePlayer() { playerContainer.setVisibility(View.VISIBLE); + playerContainer.animate() + .translationY(playerContainer.getHeight() - PlayerFragment.smallPlayer.getHeight() - getSupportActionBar().getHeight()); + + PlayerFragment.player_controller.setAlpha(0.0f); + PlayerFragment.player_controller.setImageDrawable(PlayerFragment.mainTrackController.getDrawable()); + + PlayerFragment.player_controller.animate() + .alpha(1.0f); +// if (PlayerFragment.progressBar2 != null) { +// PlayerFragment.progressBar2.setVisibility(View.VISIBLE); +// PlayerFragment.progressBar2.animate() +// .alpha(1.0f); +// } + + + } + + public void hidePlayer2() { + + if (PlayerFragment.mVisualizerView != null) + PlayerFragment.mVisualizerView.setVisibility(View.INVISIBLE); + drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); + + if (PlayerFragment.cpb != null) { + PlayerFragment.cpb.setAlpha(0.0f); + PlayerFragment.cpb.setVisibility(View.VISIBLE); + PlayerFragment.cpb.animate() + .alpha(1.0f); + } + + isPlayerVisible = false; + + playerContainer.setVisibility(View.VISIBLE); + playerContainer.animate() .translationY(playerContainer.getHeight() - PlayerFragment.smallPlayer.getHeight()); @@ -1331,6 +1371,16 @@ public void showPlayer() { searchView.setQuery("", false); searchView.setIconified(true); + isPlayerVisible = true; + isEqualizerVisible = false; + final Handler handler = new Handler(); + handler.postDelayed(new Runnable() { + @Override + public void run() { + hideFragment("equalizer"); + } + }, 350); + playerContainer.setVisibility(View.VISIBLE); if (PlayerFragment.mVisualizerView != null) PlayerFragment.mVisualizerView.setVisibility(View.INVISIBLE); @@ -1366,8 +1416,8 @@ public void run() { .setDuration(300) .translationY(0); - final Handler handler = new Handler(); - handler.postDelayed(new Runnable() { + final Handler handler2 = new Handler(); + handler2.postDelayed(new Runnable() { @Override public void run() { if (PlayerFragment.mVisualizerView != null) @@ -1856,6 +1906,13 @@ public void onQueueSave() { showSaveQueueDialog(); } + @Override + public void onEqualizerClicked() { + hideAllFrags(); + hidePlayer2(); + showFragment("equalizer"); + } + public static class MyAsyncTask extends AsyncTask { @Override @@ -2031,6 +2088,9 @@ public void stopLoadingIndicator() { } public void showFragment(String type) { + + hideAllFrags(); + if (type.equals("local") && !isLocalVisible) { setTitle("Local"); isLocalVisible = true; @@ -2184,4 +2244,15 @@ public void hideFragment(String type) { } } + public void hideAllFrags() { + hideFragment("local"); + hideFragment("queue"); + hideFragment("stream"); + hideFragment("playlist"); + hideFragment("equalizer"); + hideFragment("favourite"); + + setTitle("Music DNA"); + + } } diff --git a/app/src/main/java/com/sdsmdg/harjot/MusicDNA/PlayerFragment.java b/app/src/main/java/com/sdsmdg/harjot/MusicDNA/PlayerFragment.java index 4040189c..5fb2889a 100644 --- a/app/src/main/java/com/sdsmdg/harjot/MusicDNA/PlayerFragment.java +++ b/app/src/main/java/com/sdsmdg/harjot/MusicDNA/PlayerFragment.java @@ -42,6 +42,7 @@ public class PlayerFragment extends Fragment { // public static OptimizedVisualizerView mVisualizerView; public static MediaPlayer mMediaPlayer; public static Visualizer mVisualizer; + public static Equalizer mEqualizer; static boolean isPrepared = false; @@ -50,6 +51,7 @@ public class PlayerFragment extends Fragment { public static ImageView repeatIcon; public static ImageView shuffleIcon; + public static ImageView equalizerIcon; public static ImageView mainTrackController; public static ImageView nextTrackController; public static ImageView previousTrackController; @@ -86,6 +88,7 @@ public class PlayerFragment extends Fragment { static onSmallPlayerTouchedListener mCallback; static onCompleteListener mCallback2; static onPreviousTrackListener mCallback3; + static onEqualizerClickedListener mCallback4; long startTrack; @@ -97,7 +100,7 @@ public PlayerFragment() { public static void setupVisualizerFxAndUI() { // Create the Visualizer object and attach it to our media player. - Equalizer mEqualizer = new Equalizer(0, mMediaPlayer.getAudioSessionId()); + mEqualizer = new Equalizer(0, mMediaPlayer.getAudioSessionId()); mEqualizer.setEnabled(true); mVisualizer = new Visualizer(mMediaPlayer.getAudioSessionId()); try { @@ -173,6 +176,7 @@ public void onAttach(Context context) { mCallback = (onSmallPlayerTouchedListener) context; mCallback2 = (onCompleteListener) context; mCallback3 = (onPreviousTrackListener) context; + mCallback4 = (onEqualizerClickedListener) context; Log.d("Attached", "TRUE"); } catch (ClassCastException e) { throw new ClassCastException(context.toString() @@ -213,6 +217,10 @@ public interface onPreviousTrackListener { public void onPreviousTrack(); } + public interface onEqualizerClickedListener { + public void onEqualizerClicked(); + } + @Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); @@ -245,6 +253,14 @@ public void onClick(View v) { } }); + equalizerIcon = (ImageView) view.findViewById(R.id.equalizer_icon); + equalizerIcon.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + mCallback4.onEqualizerClicked(); + } + }); + mainTrackController = (ImageView) view.findViewById(R.id.controller); nextTrackController = (ImageView) view.findViewById(R.id.next); previousTrackController = (ImageView) view.findViewById(R.id.previous); @@ -570,6 +586,13 @@ public void onClick(View v) { } }); + equalizerIcon.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + mCallback4.onEqualizerClicked(); + } + }); + isFav = false; if (HomeActivity.isFavourite) { diff --git a/app/src/main/res/layout/fragment_equalizer.xml b/app/src/main/res/layout/fragment_equalizer.xml index 05ac4f3a..0909c096 100644 --- a/app/src/main/res/layout/fragment_equalizer.xml +++ b/app/src/main/res/layout/fragment_equalizer.xml @@ -2,16 +2,31 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="#FFF" + android:background="#000" android:clickable="true" android:padding="10dp" tools:context="com.sdsmdg.harjot.MusicDNA.EqualizerFragment"> - + android:layout_height="200dp" + android:layout_alignParentTop="true"> + + + + diff --git a/app/src/main/res/layout/fragment_player.xml b/app/src/main/res/layout/fragment_player.xml index e9357250..3778ae79 100644 --- a/app/src/main/res/layout/fragment_player.xml +++ b/app/src/main/res/layout/fragment_player.xml @@ -122,6 +122,17 @@ android:layout_alignParentBottom="true" android:padding="5dp"> + + - diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml index 7d57c5c7..7450a4f6 100644 --- a/app/src/main/res/values-v21/styles.xml +++ b/app/src/main/res/values-v21/styles.xml @@ -3,6 +3,7 @@