diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 1ee87448..8b0971d2 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -34,15 +34,18 @@ + android:label="@string/about" + android:parentActivityName=".activities.MainActivity"/> + android:label="@string/third_party_licences" + android:parentActivityName=".activities.AboutActivity"/> + android:label="@string/settings" + android:parentActivityName=".activities.MainActivity"/> mSongs; private static Snackbar mSnackbar; private static List mToBeDeleted; + private static Bitmap mPlayBitmap; + private static Bitmap mPauseBitmap; private static boolean mIsSnackbarShown; - private static int mSelectedItemsCnt; private static boolean mIsNumericProgressShown; + private static int mSelectedItemsCnt; @Override protected void onCreate(Bundle savedInstanceState) { @@ -81,6 +85,7 @@ public class MainActivity extends AppCompatActivity mBus = BusProvider.getInstance(); mBus.register(this); mProgressBar.setOnSeekBarChangeListener(this); + mConfig = Config.newInstance(getApplicationContext()); if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { initializePlayer(); @@ -93,10 +98,12 @@ public class MainActivity extends AppCompatActivity protected void onResume() { super.onResume(); mIsNumericProgressShown = Config.newInstance(getApplicationContext()).getIsNumericProgressEnabled(); - if (mIsNumericProgressShown) + setupIconColors(); + if (mIsNumericProgressShown) { mProgress.setVisibility(View.VISIBLE); - else + } else { mProgress.setVisibility(View.GONE); + } } @Override @@ -141,6 +148,15 @@ public class MainActivity extends AppCompatActivity setVolumeControlStream(AudioManager.STREAM_MUSIC); } + private void setupIconColors() { + final Resources res = getResources(); + final int color = mTitleTV.getCurrentTextColor(); + mPreviousBtn.setImageBitmap(Utils.getColoredIcon(res, color, R.mipmap.previous)); + mNextBtn.setImageBitmap(Utils.getColoredIcon(res, color, R.mipmap.next)); + mPlayBitmap = Utils.getColoredIcon(res, color, R.mipmap.play); + mPauseBitmap = Utils.getColoredIcon(res, color, R.mipmap.pause); + } + private void songPicked(int pos) { final Intent intent = new Intent(this, MusicService.class); intent.putExtra(Constants.SONG_POS, pos); @@ -202,11 +218,11 @@ public class MainActivity extends AppCompatActivity @Subscribe public void songStateChanged(Events.SongStateChanged event) { - int id = R.mipmap.play; - if (event.getIsPlaying()) - id = R.mipmap.pause; - - mPlayPauseBtn.setImageDrawable(getResources().getDrawable(id)); + if (event.getIsPlaying()) { + mPlayPauseBtn.setImageBitmap(mPauseBitmap); + } else { + mPlayPauseBtn.setImageBitmap(mPlayBitmap); + } } @Subscribe diff --git a/app/src/main/java/com/simplemobiletools/musicplayer/activities/SettingsActivity.java b/app/src/main/java/com/simplemobiletools/musicplayer/activities/SettingsActivity.java index 24d45f0a..d5c0456d 100644 --- a/app/src/main/java/com/simplemobiletools/musicplayer/activities/SettingsActivity.java +++ b/app/src/main/java/com/simplemobiletools/musicplayer/activities/SettingsActivity.java @@ -3,7 +3,7 @@ package com.simplemobiletools.musicplayer.activities; import android.content.Intent; import android.media.audiofx.Equalizer; import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; +import android.support.v4.app.TaskStackBuilder; import android.support.v7.widget.AppCompatSpinner; import android.support.v7.widget.SwitchCompat; import android.widget.ArrayAdapter; @@ -18,7 +18,8 @@ import butterknife.ButterKnife; import butterknife.OnClick; import butterknife.OnItemSelected; -public class SettingsActivity extends AppCompatActivity { +public class SettingsActivity extends SimpleActivity { + @BindView(R.id.settings_dark_theme) SwitchCompat mDarkThemeSwitch; @BindView(R.id.settings_shuffle) SwitchCompat mShuffleSwitch; @BindView(R.id.settings_numeric_progress) SwitchCompat mNumericProgressSwitch; @BindView(R.id.settings_sorting) AppCompatSpinner mSortingSpinner; @@ -39,6 +40,11 @@ public class SettingsActivity extends AppCompatActivity { setupNumericProgress(); setupSorting(); setupEqualizer(); + setupDarkTheme(); + } + + private void setupDarkTheme() { + mDarkThemeSwitch.setChecked(mConfig.getIsDarkTheme()); } private void setupShuffle() { @@ -53,16 +59,11 @@ public class SettingsActivity extends AppCompatActivity { mSortingSpinner.setSelection(mConfig.getSorting()); } - private void setupEqualizer() { - final int cnt = mEqualizer.getNumberOfPresets(); - final String[] presets = new String[cnt]; - for (short i = 0; i < cnt; i++) { - presets[i] = mEqualizer.getPresetName(i); - } - final ArrayAdapter arrayAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, presets); - arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - mEqualizerSpinner.setAdapter(arrayAdapter); - mEqualizerSpinner.setSelection(mConfig.getEqualizer()); + @OnClick(R.id.settings_dark_theme_holder) + public void handleDarkTheme() { + mDarkThemeSwitch.setChecked(!mDarkThemeSwitch.isChecked()); + mConfig.setIsDarkTheme(mDarkThemeSwitch.isChecked()); + restartActivity(); } @OnClick(R.id.settings_shuffle_holder) @@ -94,6 +95,22 @@ public class SettingsActivity extends AppCompatActivity { startService(intent); } + private void restartActivity() { + TaskStackBuilder.create(getApplicationContext()).addNextIntentWithParentStack(getIntent()).startActivities(); + } + + private void setupEqualizer() { + final int cnt = mEqualizer.getNumberOfPresets(); + final String[] presets = new String[cnt]; + for (short i = 0; i < cnt; i++) { + presets[i] = mEqualizer.getPresetName(i); + } + final ArrayAdapter arrayAdapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, presets); + arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + mEqualizerSpinner.setAdapter(arrayAdapter); + mEqualizerSpinner.setSelection(mConfig.getEqualizer()); + } + private void updatePlaylist() { final Intent intent = new Intent(this, MusicService.class); intent.putExtra(Constants.UPDATE_ACTIVITY, true); diff --git a/app/src/main/java/com/simplemobiletools/musicplayer/activities/SimpleActivity.java b/app/src/main/java/com/simplemobiletools/musicplayer/activities/SimpleActivity.java new file mode 100644 index 00000000..614f288c --- /dev/null +++ b/app/src/main/java/com/simplemobiletools/musicplayer/activities/SimpleActivity.java @@ -0,0 +1,31 @@ +package com.simplemobiletools.musicplayer.activities; + +import android.os.Bundle; +import android.support.annotation.Nullable; +import android.support.v7.app.AppCompatActivity; +import android.view.MenuItem; + +import com.simplemobiletools.musicplayer.Config; +import com.simplemobiletools.musicplayer.R; + +public class SimpleActivity extends AppCompatActivity { + protected Config mConfig; + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + mConfig = Config.newInstance(getApplicationContext()); + setTheme(mConfig.getIsDarkTheme() ? R.style.AppTheme_Dark : R.style.AppTheme); + super.onCreate(savedInstanceState); + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + finish(); + return true; + default: + return super.onOptionsItemSelected(item); + } + } +} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 805e9e0e..93c0905d 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -57,7 +57,6 @@ android:fontFamily="sans-serif-light" android:gravity="center_horizontal" android:maxLines="1" - android:textColor="@android:color/black" android:textSize="18sp"/> + + + + + + + + diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index d0840d1c..5f1d84eb 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -20,6 +20,7 @@ Impostazioni + Tema scuro Mischia Mostra anche l\'avanzamento in numeri Ordina tracce per diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index ca12b36e..a5045dfb 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -20,6 +20,7 @@ 設定 + ダークテーマ シャッフル 再生状況を数値でも表示する トラックの並び替え diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index f2f76c52..b70c4aae 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -21,6 +21,7 @@ Inställningar + Mörkt tema Blanda Visa även förloppet i siffror Sortera låtar efter diff --git a/app/src/main/res/values/array.xml b/app/src/main/res/values/array.xml index e500f39e..c2f98013 100644 --- a/app/src/main/res/values/array.xml +++ b/app/src/main/res/values/array.xml @@ -1,6 +1,6 @@ - + @string/title @string/artist diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2e1f63bd..d11a0f4a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -21,6 +21,7 @@ Settings + Dark theme Shuffle Display progress in numbers too Sort tracks by diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 44999e73..86bc5625 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -11,6 +11,17 @@ @style/SpinnerItem.DropDownItem + +