Added changelog. Auto hide bottom bar and fab if playing queue is empty
This commit is contained in:
parent
eea6ba69ca
commit
73f3214b23
10 changed files with 211 additions and 4 deletions
|
|
@ -51,7 +51,7 @@ android {
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 22
|
targetSdkVersion 22
|
||||||
versionCode 60
|
versionCode 60
|
||||||
versionName "0.9.43b dev-1"
|
versionName "0.9.43b beta1"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
|
|
||||||
51
app/src/main/assets/changelog.html
Normal file
51
app/src/main/assets/changelog.html
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style type="text/css">
|
||||||
|
* {
|
||||||
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
|
{style-placeholder}
|
||||||
|
a {
|
||||||
|
color: #{link-color};
|
||||||
|
}
|
||||||
|
a:active {
|
||||||
|
color: #{link-color-active};
|
||||||
|
}
|
||||||
|
ol {
|
||||||
|
list-style-position: inside;
|
||||||
|
padding-left: 0;
|
||||||
|
padding-right: 0;
|
||||||
|
}
|
||||||
|
li {
|
||||||
|
padding-top: 8px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<p>You can view the changelog dialog again at any time from the <i>about</i> section.</p>
|
||||||
|
|
||||||
|
<h3>Version 0.9.43 beta1</h3>
|
||||||
|
|
||||||
|
<ol>
|
||||||
|
<li><b>NEW:</b> Well, the changelog dialog itself obviously ;)
|
||||||
|
</li>
|
||||||
|
<li><b>NEW:</b> Sliding panel! (You can hide it from the settings if you don't like it).
|
||||||
|
</li>
|
||||||
|
<li><b>IMPROVE:</b> Much better color generation.
|
||||||
|
</li>
|
||||||
|
<li><b>REVERT:</b> Brought back the shuffle button to the songs list.
|
||||||
|
</li>
|
||||||
|
<li><b>FIX:</b> Last.fm scrobbling.
|
||||||
|
</li>
|
||||||
|
<li><b>FIX:</b> Readability issues with the black and white accent colors.
|
||||||
|
</li>
|
||||||
|
<li><b>FIX:</b> Playlists not being updated when adding a new playlist.
|
||||||
|
</li>
|
||||||
|
<li><b>FIX:</b> Some icons not being colored correctly.
|
||||||
|
</li>
|
||||||
|
<li><b>TRANSLATIONS:</b> Translation updates from OneSky.
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
@ -39,6 +39,14 @@ public class AboutDialog extends LeakDetectDialogFragment {
|
||||||
getActivity().getResources().getText(R.string.credits_4))
|
getActivity().getResources().getText(R.string.credits_4))
|
||||||
)
|
)
|
||||||
.positiveText(android.R.string.ok)
|
.positiveText(android.R.string.ok)
|
||||||
|
.neutralText(R.string.changelog)
|
||||||
|
.callback(new MaterialDialog.ButtonCallback() {
|
||||||
|
@Override
|
||||||
|
public void onNeutral(MaterialDialog dialog) {
|
||||||
|
super.onNeutral(dialog);
|
||||||
|
ChangelogDialog.create().show(getActivity().getSupportFragmentManager(), "CHANGE_LOG_DIALOG");
|
||||||
|
}
|
||||||
|
})
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,96 @@
|
||||||
|
package com.kabouzeid.gramophone.dialogs;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.app.Dialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
import android.view.InflateException;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.webkit.WebView;
|
||||||
|
|
||||||
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
|
import com.afollestad.materialdialogs.ThemeSingleton;
|
||||||
|
import com.kabouzeid.gramophone.R;
|
||||||
|
import com.kabouzeid.gramophone.util.ColorUtil;
|
||||||
|
import com.kabouzeid.gramophone.util.PreferenceUtil;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Aidan Follestad (afollestad)
|
||||||
|
*/
|
||||||
|
public class ChangelogDialog extends LeakDetectDialogFragment {
|
||||||
|
|
||||||
|
public static ChangelogDialog create() {
|
||||||
|
return new ChangelogDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressLint("InflateParams")
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
final View customView;
|
||||||
|
try {
|
||||||
|
customView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_web_view, null);
|
||||||
|
} catch (InflateException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return new MaterialDialog.Builder(getActivity())
|
||||||
|
.title(android.R.string.dialog_alert_title)
|
||||||
|
.content("This device doesn't support web view, which is necessary to view the change log. It is missing a system component.")
|
||||||
|
.positiveText(android.R.string.ok)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
MaterialDialog dialog = new MaterialDialog.Builder(getActivity())
|
||||||
|
.title(R.string.changelog)
|
||||||
|
.customView(customView, false)
|
||||||
|
.positiveText(android.R.string.ok)
|
||||||
|
.showListener(new DialogInterface.OnShowListener() {
|
||||||
|
@Override
|
||||||
|
public void onShow(DialogInterface dialog) {
|
||||||
|
try {
|
||||||
|
PackageInfo pInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
|
||||||
|
int currentVersion = pInfo.versionCode;
|
||||||
|
PreferenceUtil.getInstance(getActivity()).setLastChangeLogVersion(currentVersion);
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.build();
|
||||||
|
|
||||||
|
final WebView webView = (WebView) customView.findViewById(R.id.web_view);
|
||||||
|
try {
|
||||||
|
// Load from changelog.html in the assets folder
|
||||||
|
StringBuilder buf = new StringBuilder();
|
||||||
|
InputStream json = getActivity().getAssets().open("changelog.html");
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(json, "UTF-8"));
|
||||||
|
String str;
|
||||||
|
while ((str = in.readLine()) != null)
|
||||||
|
buf.append(str);
|
||||||
|
in.close();
|
||||||
|
|
||||||
|
// Inject color values for WebView body background and links
|
||||||
|
webView.loadData(buf.toString()
|
||||||
|
.replace("{style-placeholder}", ThemeSingleton.get().darkTheme ?
|
||||||
|
"body { background-color: #444444; color: #fff; }" :
|
||||||
|
"body { background-color: #EDEDED; color: #000; }")
|
||||||
|
.replace("{link-color}", colorToHex(ThemeSingleton.get().positiveColor.getDefaultColor()))
|
||||||
|
.replace("{link-color-active}", colorToHex(ColorUtil.shiftColorUp(ThemeSingleton.get().positiveColor.getDefaultColor())))
|
||||||
|
, "text/html", "UTF-8");
|
||||||
|
} catch (Throwable e) {
|
||||||
|
webView.loadData("<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", "UTF-8");
|
||||||
|
}
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String colorToHex(int color) {
|
||||||
|
return Integer.toHexString(color).substring(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3,6 +3,8 @@ package com.kabouzeid.gramophone.ui.activities;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
@ -36,6 +38,7 @@ import com.afollestad.materialdialogs.ThemeSingleton;
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
import com.kabouzeid.gramophone.adapter.PagerAdapter;
|
import com.kabouzeid.gramophone.adapter.PagerAdapter;
|
||||||
import com.kabouzeid.gramophone.dialogs.AboutDialog;
|
import com.kabouzeid.gramophone.dialogs.AboutDialog;
|
||||||
|
import com.kabouzeid.gramophone.dialogs.ChangelogDialog;
|
||||||
import com.kabouzeid.gramophone.dialogs.CreatePlaylistDialog;
|
import com.kabouzeid.gramophone.dialogs.CreatePlaylistDialog;
|
||||||
import com.kabouzeid.gramophone.dialogs.SleepTimerDialog;
|
import com.kabouzeid.gramophone.dialogs.SleepTimerDialog;
|
||||||
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
|
||||||
|
|
@ -99,7 +102,6 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
|
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
|
||||||
|
|
@ -116,6 +118,8 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
||||||
if (shouldColorNavigationBar())
|
if (shouldColorNavigationBar())
|
||||||
setNavigationBarThemeColor();
|
setNavigationBarThemeColor();
|
||||||
setStatusBarThemeColor();
|
setStatusBarThemeColor();
|
||||||
|
|
||||||
|
checkChangelog();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -603,4 +607,16 @@ public class MainActivity extends AbsSlidingMusicPanelActivity
|
||||||
hideBottomBarListeners.remove(listener);
|
hideBottomBarListeners.remove(listener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkChangelog() {
|
||||||
|
try {
|
||||||
|
PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||||
|
int currentVersion = pInfo.versionCode;
|
||||||
|
if (currentVersion != PreferenceUtil.getInstance(this).getLastChangelogVersion()) {
|
||||||
|
ChangelogDialog.create().show(getSupportFragmentManager(), "CHANGE_LOG_DIALOG");
|
||||||
|
}
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -165,6 +165,8 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
||||||
setUpPlayPauseButton();
|
setUpPlayPauseButton();
|
||||||
setUpMiniPlayer();
|
setUpMiniPlayer();
|
||||||
setUpSlidingPanel();
|
setUpSlidingPanel();
|
||||||
|
// ensures that the fab and the mini player are hidden if the queue is empty
|
||||||
|
getCurrentSong();
|
||||||
|
|
||||||
initAppearanceVarsFromSharedPrefs();
|
initAppearanceVarsFromSharedPrefs();
|
||||||
PreferenceUtil.getInstance(this).registerOnSharedPreferenceChangedListener(this);
|
PreferenceUtil.getInstance(this).registerOnSharedPreferenceChangedListener(this);
|
||||||
|
|
@ -710,10 +712,10 @@ public abstract class AbsSlidingMusicPanelActivity extends AbsMusicServiceActivi
|
||||||
song = MusicPlayerRemote.getCurrentSong();
|
song = MusicPlayerRemote.getCurrentSong();
|
||||||
if (song.id == -1) {
|
if (song.id == -1) {
|
||||||
playPauseFab.setVisibility(View.GONE);
|
playPauseFab.setVisibility(View.GONE);
|
||||||
slidingUpPanelLayout.setVisibility(View.GONE);
|
hideBottomBar(true);
|
||||||
} else {
|
} else {
|
||||||
playPauseFab.setVisibility(View.VISIBLE);
|
playPauseFab.setVisibility(View.VISIBLE);
|
||||||
slidingUpPanelLayout.setVisibility(View.VISIBLE);
|
hideBottomBar(PreferenceUtil.getInstance(this).hideBottomBar());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,15 @@ public class ColorUtil {
|
||||||
return (alpha << 24) + (0x00ffffff & Color.HSVToColor(hsv));
|
return (alpha << 24) + (0x00ffffff & Color.HSVToColor(hsv));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("ResourceType")
|
||||||
|
public static int shiftColorUp(@ColorInt int color) {
|
||||||
|
int alpha = Color.alpha(color);
|
||||||
|
float[] hsv = new float[3];
|
||||||
|
Color.colorToHSV(color, hsv);
|
||||||
|
hsv[2] *= 1.1f; // value component
|
||||||
|
return (alpha << 24) + (0x00ffffff & Color.HSVToColor(hsv));
|
||||||
|
}
|
||||||
|
|
||||||
public static float getLuminance(@ColorInt int color) {
|
public static float getLuminance(@ColorInt int color) {
|
||||||
return (Color.red(color) * 0.299f + Color.green(color) * 0.587f + Color.blue(color) * 0.114f);
|
return (Color.red(color) * 0.299f + Color.green(color) * 0.587f + Color.blue(color) * 0.114f);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,8 @@ public final class PreferenceUtil {
|
||||||
|
|
||||||
public static final String HIDE_BOTTOM_BAR = "hide_bottom_bar";
|
public static final String HIDE_BOTTOM_BAR = "hide_bottom_bar";
|
||||||
|
|
||||||
|
public static final String LAST_CHANGELOG_VERSION = "last_changelog_version";
|
||||||
|
|
||||||
private static PreferenceUtil sInstance;
|
private static PreferenceUtil sInstance;
|
||||||
|
|
||||||
private final SharedPreferences mPreferences;
|
private final SharedPreferences mPreferences;
|
||||||
|
|
@ -311,4 +313,12 @@ public final class PreferenceUtil {
|
||||||
public final boolean artistColoredFooters() {
|
public final boolean artistColoredFooters() {
|
||||||
return mPreferences.getBoolean(ARTIST_COLORED_FOOTERS, true);
|
return mPreferences.getBoolean(ARTIST_COLORED_FOOTERS, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLastChangeLogVersion(int version) {
|
||||||
|
mPreferences.edit().putInt(LAST_CHANGELOG_VERSION, version).apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getLastChangelogVersion() {
|
||||||
|
return mPreferences.getInt(LAST_CHANGELOG_VERSION, -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
14
app/src/main/res/layout/dialog_web_view.xml
Normal file
14
app/src/main/res/layout/dialog_web_view.xml
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:paddingLeft="16dp"
|
||||||
|
android:paddingRight="16dp">
|
||||||
|
|
||||||
|
<WebView
|
||||||
|
android:id="@+id/web_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:scrollbars="none" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
@ -179,4 +179,5 @@
|
||||||
<string name="list">List</string>
|
<string name="list">List</string>
|
||||||
<string name="colored_footers">Colored footers</string>
|
<string name="colored_footers">Colored footers</string>
|
||||||
<string name="special_thanks_to">Special thanks to</string>
|
<string name="special_thanks_to">Special thanks to</string>
|
||||||
|
<string name="changelog">Changelog</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue