Merge branch 'master' into feat/last_added_interval

This commit is contained in:
Eugene Cheung 2017-06-01 14:40:27 -04:00 committed by GitHub
commit fe6bc5911e
13 changed files with 151 additions and 42 deletions

View file

@ -201,12 +201,7 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
registerReceiver(widgetIntentReceiver, new IntentFilter(APP_WIDGET_UPDATE));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
playingNotification = new PlayingNotificationImpl24();
} else {
playingNotification = new PlayingNotificationImpl();
}
playingNotification.init(this);
initNotification();
mediaStoreObserver = new MediaStoreObserver(playerHandler);
throttledSeekHandler = new ThrottledSeekHandler(playerHandler);
@ -557,8 +552,17 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
return (getAudioManager().requestAudioFocus(audioFocusListener, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN) == AudioManager.AUDIOFOCUS_REQUEST_GRANTED);
}
private void updateNotification() {
if (getCurrentSong().id != -1) {
public void initNotification() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && !PreferenceUtil.getInstance(this).classicNotification()) {
playingNotification = new PlayingNotificationImpl24();
} else {
playingNotification = new PlayingNotificationImpl();
}
playingNotification.init(this);
}
public void updateNotification() {
if (playingNotification != null && getCurrentSong().id != -1) {
playingNotification.update();
}
}

View file

@ -32,10 +32,11 @@ import de.psdev.licensesdialog.LicensesDialog;
@SuppressWarnings("FieldCanBeLocal")
public class AboutActivity extends AbsBaseActivity implements View.OnClickListener {
private static String GITHUB = "https://github.com/kabouzeid/Phonograph";
private static String GOOGLE_PLUS = "https://google.com/+KarimAbouZeid23697";
private static String TWITTER = "https://twitter.com/karim23697";
private static String GITHUB = "https://github.com/kabouzeid";
private static String WEBSITE = "http://kabouzeid.com/";
private static String WEBSITE = "https://kabouzeid.com/";
private static String GOOGLE_PLUS_COMMUNITY = "https://plus.google.com/u/0/communities/106227738496107108513";
private static String TRANSLATE = "https://phonograph.oneskyapp.com/collaboration/project?id=26521";
@ -61,6 +62,8 @@ public class AboutActivity extends AbsBaseActivity implements View.OnClickListen
LinearLayout intro;
@BindView(R.id.licenses)
LinearLayout licenses;
@BindView(R.id.write_an_email)
LinearLayout writeAnEmail;
@BindView(R.id.add_to_google_plus_circles)
LinearLayout addToGooglePlusCircles;
@BindView(R.id.follow_on_twitter)
@ -132,6 +135,7 @@ public class AboutActivity extends AbsBaseActivity implements View.OnClickListen
forkOnGitHub.setOnClickListener(this);
visitWebsite.setOnClickListener(this);
reportBugs.setOnClickListener(this);
writeAnEmail.setOnClickListener(this);
joinGooglePlusCommunity.setOnClickListener(this);
translate.setOnClickListener(this);
rateOnGooglePlay.setOnClickListener(this);
@ -180,6 +184,12 @@ public class AboutActivity extends AbsBaseActivity implements View.OnClickListen
openUrl(WEBSITE);
} else if (v == reportBugs) {
startActivity(new Intent(this, BugReportActivity.class));
} else if (v == writeAnEmail) {
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setData(Uri.parse("mailto:contact@kabouzeid.com"));
intent.putExtra(Intent.EXTRA_EMAIL, "contact@kabouzeid.com");
intent.putExtra(Intent.EXTRA_SUBJECT, "Phonograph");
startActivity(Intent.createChooser(intent, "E-Mail"));
} else if (v == joinGooglePlusCommunity) {
openUrl(GOOGLE_PLUS_COMMUNITY);
} else if (v == translate) {

View file

@ -26,8 +26,10 @@ import com.kabouzeid.appthemehelper.common.prefs.supportv7.ATEPreferenceFragment
import com.kabouzeid.appthemehelper.util.ColorUtil;
import com.kabouzeid.gramophone.R;
import com.kabouzeid.gramophone.appshortcuts.DynamicShortcutManager;
import com.kabouzeid.gramophone.helper.MusicPlayerRemote;
import com.kabouzeid.gramophone.preferences.NowPlayingScreenPreference;
import com.kabouzeid.gramophone.preferences.NowPlayingScreenPreferenceDialog;
import com.kabouzeid.gramophone.service.MusicService;
import com.kabouzeid.gramophone.ui.activities.base.AbsBaseActivity;
import com.kabouzeid.gramophone.util.NavigationUtil;
import com.kabouzeid.gramophone.util.PreferenceUtil;
@ -127,6 +129,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
public void onCreatePreferences(Bundle bundle, String s) {
addPreferencesFromResource(R.xml.pref_general);
addPreferencesFromResource(R.xml.pref_colors);
addPreferencesFromResource(R.xml.pref_notification);
addPreferencesFromResource(R.xml.pref_now_playing_screen);
addPreferencesFromResource(R.xml.pref_images);
addPreferencesFromResource(R.xml.pref_lockscreen);
@ -199,7 +202,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
}
});
ATEColorPreference primaryColorPref = (ATEColorPreference) findPreference("primary_color");
final ATEColorPreference primaryColorPref = (ATEColorPreference) findPreference("primary_color");
final int primaryColor = ThemeStore.primaryColor(getActivity());
primaryColorPref.setColor(primaryColor, ColorUtil.darkenColor(primaryColor));
primaryColorPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@ -215,7 +218,7 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
}
});
ATEColorPreference accentColorPref = (ATEColorPreference) findPreference("accent_color");
final ATEColorPreference accentColorPref = (ATEColorPreference) findPreference("accent_color");
final int accentColor = ThemeStore.accentColor(getActivity());
accentColorPref.setColor(accentColor, ColorUtil.darkenColor(accentColor));
accentColorPref.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@ -249,7 +252,30 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
});
}
TwoStatePreference colorAppShortcuts = (TwoStatePreference) findPreference("should_color_app_shortcuts");
final TwoStatePreference classicNotification = (TwoStatePreference) findPreference("classic_notification");
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
classicNotification.setEnabled(false);
classicNotification.setSummary(R.string.pref_only_nougat);
} else {
classicNotification.setChecked(PreferenceUtil.getInstance(getActivity()).classicNotification());
classicNotification.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
//Save preference
PreferenceUtil.getInstance(getActivity()).setClassicNotification((Boolean)newValue);
final MusicService service = MusicPlayerRemote.musicService;
if (service != null) {
service.initNotification();
service.updateNotification();
}
return true;
}
});
}
final TwoStatePreference colorAppShortcuts = (TwoStatePreference) findPreference("should_color_app_shortcuts");
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
colorAppShortcuts.setEnabled(false);
colorAppShortcuts.setSummary(R.string.pref_only_nougat_mr1);
@ -262,16 +288,14 @@ public class SettingsActivity extends AbsBaseActivity implements ColorChooserDia
PreferenceUtil.getInstance(getActivity()).setColoredAppShortcuts((Boolean)newValue);
//Update app shortcuts
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
new DynamicShortcutManager(getActivity()).updateDynamicShortcuts();
}
new DynamicShortcutManager(getActivity()).updateDynamicShortcuts();
return true;
}
});
}
Preference equalizer = findPreference("equalizer");
final Preference equalizer = findPreference("equalizer");
if (!hasEqualizer()) {
equalizer.setEnabled(false);
equalizer.setSummary(getResources().getString(R.string.no_equalizer));

View file

@ -91,7 +91,7 @@ public class BugReportActivity extends AbsThemeActivity {
@BindView(R.id.button_send)
FloatingActionButton sendFab;
private static final String ISSUE_TRACKER_LINK = "https://github.com/kabouzeid/phonograph-issue-tracker";
private static final String ISSUE_TRACKER_LINK = "https://github.com/kabouzeid/Phonograph";
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -274,7 +274,7 @@ public class BugReportActivity extends AbsThemeActivity {
onSaveExtraInfo(extraInfo);
Report report = new Report(bugTitle, bugDescription, deviceInfo, extraInfo);
GithubTarget target = new GithubTarget("kabouzeid", "phonograph-issue-tracker");
GithubTarget target = new GithubTarget("kabouzeid", "Phonograph");
ReportIssueAsyncTask.report(this, report, target, login);
}

View file

@ -44,6 +44,8 @@ public final class PreferenceUtil {
public static final String FORCE_SQUARE_ALBUM_COVER = "force_square_album_art";
public static final String COLORED_NOTIFICATION = "colored_notification";
public static final String CLASSIC_NOTIFICATION = "classic_notification";
public static final String COLORED_APP_SHORTCUTS = "colored_app_shortcuts";
public static final String AUDIO_DUCKING = "audio_ducking";
@ -149,6 +151,16 @@ public final class PreferenceUtil {
return mPreferences.getBoolean(COLORED_NOTIFICATION, true);
}
public final boolean classicNotification() {
return mPreferences.getBoolean(CLASSIC_NOTIFICATION, false);
}
public void setClassicNotification(final boolean value) {
final SharedPreferences.Editor editor = mPreferences.edit();
editor.putBoolean(CLASSIC_NOTIFICATION, value);
editor.apply();
}
public void setColoredAppShortcuts(final boolean value) {
final SharedPreferences.Editor editor = mPreferences.edit();
editor.putBoolean(COLORED_APP_SHORTCUTS, value);

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0"
android:width="24dp">
<path
android:fillColor="#FFFFFF"
android:pathData="M20,4L4,4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2L22,6c0,-1.1 -0.9,-2 -2,-2zM20,8l-8,5 -8,-5L4,6l8,5 8,-5v2z" />
</vector>

View file

@ -144,6 +144,37 @@
</LinearLayout>
<LinearLayout
android:id="@+id/fork_on_git_hub"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/rectSelector"
android:clickable="true"
android:gravity="center_vertical"
android:minHeight="@dimen/md_listitem_height"
android:orientation="horizontal"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<com.kabouzeid.gramophone.views.IconImageView
android:id="@+id/icon_github"
android:layout_width="24dp"
android:layout_height="24dp"
app:srcCompat="@drawable/ic_github_circle_white_24dp"
tools:ignore="ContentDescription,UnusedAttribute" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:layout_marginStart="32dp"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="@string/fork_on_git_hub"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
</LinearLayout>
<LinearLayout
android:id="@+id/licenses"
android:layout_width="match_parent"

View file

@ -68,6 +68,37 @@
</LinearLayout>
<LinearLayout
android:id="@+id/write_an_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/rectSelector"
android:clickable="true"
android:gravity="center_vertical"
android:minHeight="@dimen/md_listitem_height"
android:orientation="horizontal"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<com.kabouzeid.gramophone.views.IconImageView
android:id="@+id/icon_email"
android:layout_width="24dp"
android:layout_height="24dp"
app:srcCompat="@drawable/ic_email_white_24dp"
tools:ignore="ContentDescription,UnusedAttribute" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:layout_marginStart="32dp"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="@string/write_an_email"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
</LinearLayout>
<LinearLayout
android:id="@+id/add_to_google_plus_circles"
android:layout_width="match_parent"
@ -130,37 +161,6 @@
</LinearLayout>
<LinearLayout
android:id="@+id/fork_on_git_hub"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/rectSelector"
android:clickable="true"
android:gravity="center_vertical"
android:minHeight="@dimen/md_listitem_height"
android:orientation="horizontal"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<com.kabouzeid.gramophone.views.IconImageView
android:id="@+id/icon_github"
android:layout_width="24dp"
android:layout_height="24dp"
app:srcCompat="@drawable/ic_github_circle_white_24dp"
tools:ignore="ContentDescription,UnusedAttribute" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="32dp"
android:layout_marginStart="32dp"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:text="@string/fork_on_git_hub"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead" />
</LinearLayout>
<LinearLayout
android:id="@+id/visit_website"
android:layout_width="match_parent"

View file

@ -124,6 +124,7 @@
<string name="pref_header_images">Images</string>
<string name="pref_header_lockscreen">Lockscreen</string>
<string name="pref_header_playlists">Playlists</string>
<string name="pref_header_notification">Notification</string>
<string name="pref_title_navigation_bar">Colored navigation bar</string>
<string name="pref_title_app_shortcuts">Colored app shortcuts</string>
<string name="pref_title_set_default_start_page">Start page</string>
@ -131,6 +132,7 @@
<string name="pref_title_auto_download_artist_images">Auto download artist images</string>
<string name="pref_title_blurred_album_art">Blur album cover</string>
<string name="pref_title_colored_notification">Colored notification</string>
<string name="pref_title_classic_notification">Classic notification design</string>
<string name="pref_title_ignore_media_store_artwork">Ignore Media Store covers</string>
<string name="pref_title_gapless_playback">Gapless playback</string>
<string name="pref_title_force_square_album_art">Square album cover</string>
@ -165,10 +167,12 @@
<string name="empty">Empty</string>
<string name="playlist_name_empty">Playlist name</string>
<string name="song">Song</string>
<string name="pref_only_lollipop">"Only available on Lollipop."</string>
<string name="pref_only_nougat_mr1">"Only available on Nougat 7.1."</string>
<string name="pref_only_lollipop">"Only available on Lollipop or above."</string>
<string name="pref_only_nougat">"Only available on Nougat 7.0 or above."</string>
<string name="pref_only_nougat_mr1">"Only available on Nougat 7.1 or above."</string>
<string name="pref_summary_album_art_on_lockscreen">Uses the current songs album cover as lockscreen wallpaper.</string>
<string name="pref_summary_blurred_album_art">Blurs the album cover on the lockscreen. Can cause problems with third party apps and widgets.</string>
<string name="pref_summary_classic_notification">Use the classic notification design.</string>
<string name="pref_summary_colored_notification">"Colors the notification in the album cover\u2019s vibrant color."</string>
<string name="pref_summary_gapless_playback">"Can cause playback issues on some devices."</string>
<string name="pref_summary_force_square_album_art">Album covers in the now playing view are always squared.</string>
@ -222,6 +226,7 @@
<string name="version">Version</string>
<string name="application">Application</string>
<string name="author">Author</string>
<string name="write_an_email">Write an email</string>
<string name="add_to_google_plus_circles">Add to Google Plus circles</string>
<string name="follow_on_twitter">Follow on Twitter</string>
<string name="fork_on_git_hub">Fork on GitHub</string>

View file

@ -14,12 +14,6 @@
android:summary="@string/accent_color_desc"
android:title="@string/accent_color" />
<com.kabouzeid.appthemehelper.common.prefs.supportv7.ATESwitchPreference
android:defaultValue="true"
android:key="colored_notification"
android:summary="@string/pref_summary_colored_notification"
android:title="@string/pref_title_colored_notification" />
<com.kabouzeid.appthemehelper.common.prefs.supportv7.ATESwitchPreference
android:defaultValue="false"
android:key="should_color_navigation_bar"

View file

@ -0,0 +1,19 @@
<android.support.v7.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<com.kabouzeid.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory android:title="@string/pref_header_notification">
<com.kabouzeid.appthemehelper.common.prefs.supportv7.ATESwitchPreference
android:defaultValue="true"
android:key="colored_notification"
android:summary="@string/pref_summary_colored_notification"
android:title="@string/pref_title_colored_notification" />
<com.kabouzeid.appthemehelper.common.prefs.supportv7.ATESwitchPreference
android:defaultValue="false"
android:key="classic_notification"
android:summary="@string/pref_summary_classic_notification"
android:title="@string/pref_title_classic_notification" />
</com.kabouzeid.appthemehelper.common.prefs.supportv7.ATEPreferenceCategory>
</android.support.v7.preference.PreferenceScreen>