OSDN Git Service

Remove hardcoded package name references
authorAlexander Martinz <amartinz@shiftphones.com>
Thu, 31 Jan 2019 17:08:07 +0000 (18:08 +0100)
committerMichael Bestas <mkbestas@lineageos.org>
Tue, 19 Mar 2019 20:56:33 +0000 (22:56 +0200)
Change-Id: I9992994eb45c9e83dfa55b0a5277dce97afa26d3
Signed-off-by: Alexander Martinz <amartinz@shiftphones.com>
AndroidManifest-gradle.xml
src/org/lineageos/eleven/BuildConstants.java [new file with mode: 0644]
src/org/lineageos/eleven/MusicPlaybackService.java
src/org/lineageos/eleven/adapters/AlbumArtPagerAdapter.java
src_aosp/org/lineageos/eleven/BuildConfig.java

index 374e80d..8a8e6fc 100644 (file)
@@ -92,7 +92,7 @@
                 <data android:mimeType="vnd.android.cursor.dir/artists" />
             </intent-filter>
             <intent-filter>
-                <action android:name="org.lineageos.eleven.AUDIO_PLAYER" />
+                <action android:name="${applicationId}.AUDIO_PLAYER" />
 
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
diff --git a/src/org/lineageos/eleven/BuildConstants.java b/src/org/lineageos/eleven/BuildConstants.java
new file mode 100644 (file)
index 0000000..9e730ce
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2019 The LineageOS Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.lineageos.eleven;
+
+public class BuildConstants {
+    public static final String PACKAGE_NAME = BuildConfig.APPLICATION_ID;
+}
index 362f77b..1725234 100644 (file)
@@ -102,96 +102,96 @@ public class MusicPlaybackService extends Service {
     /**
      * Indicates that the music has paused or resumed
      */
-    public static final String PLAYSTATE_CHANGED = "org.lineageos.eleven.playstatechanged";
+    public static final String PLAYSTATE_CHANGED = BuildConstants.PACKAGE_NAME + ".playstatechanged";
 
     /**
      * Indicates that music playback position within
      * a title was changed
      */
-    public static final String POSITION_CHANGED = "org.lineageos.eleven.positionchanged";
+    public static final String POSITION_CHANGED = BuildConstants.PACKAGE_NAME + ".positionchanged";
 
     /**
      * Indicates the meta data has changed in some way, like a track change
      */
-    public static final String META_CHANGED = "org.lineageos.eleven.metachanged";
+    public static final String META_CHANGED = BuildConstants.PACKAGE_NAME + ".metachanged";
 
     /**
      * Indicates the queue has been updated
      */
-    public static final String QUEUE_CHANGED = "org.lineageos.eleven.queuechanged";
+    public static final String QUEUE_CHANGED = BuildConstants.PACKAGE_NAME + ".queuechanged";
 
     /**
      * Indicates the queue has been updated
      */
-    public static final String PLAYLIST_CHANGED = "org.lineageos.eleven.playlistchanged";
+    public static final String PLAYLIST_CHANGED = BuildConstants.PACKAGE_NAME + ".playlistchanged";
 
     /**
      * Indicates the repeat mode changed
      */
-    public static final String REPEATMODE_CHANGED = "org.lineageos.eleven.repeatmodechanged";
+    public static final String REPEATMODE_CHANGED = BuildConstants.PACKAGE_NAME + ".repeatmodechanged";
 
     /**
      * Indicates the shuffle mode changed
      */
-    public static final String SHUFFLEMODE_CHANGED = "org.lineageos.eleven.shufflemodechanged";
+    public static final String SHUFFLEMODE_CHANGED = BuildConstants.PACKAGE_NAME + ".shufflemodechanged";
 
     /**
      * Indicates the track fails to play
      */
-    public static final String TRACK_ERROR = "org.lineageos.eleven.trackerror";
+    public static final String TRACK_ERROR = BuildConstants.PACKAGE_NAME + ".trackerror";
 
     /**
      * For backwards compatibility reasons, also provide sticky
      * broadcasts under the music package
      */
-    public static final String ELEVEN_PACKAGE_NAME = "org.lineageos.eleven";
+    public static final String ELEVEN_PACKAGE_NAME = BuildConstants.PACKAGE_NAME;
     public static final String MUSIC_PACKAGE_NAME = "com.android.music";
 
     /**
      * Called to indicate a general service commmand. Used in
      * {@link MediaButtonIntentReceiver}
      */
-    public static final String SERVICECMD = "org.lineageos.eleven.musicservicecommand";
+    public static final String SERVICECMD = BuildConstants.PACKAGE_NAME + ".musicservicecommand";
 
     /**
      * Called to go toggle between pausing and playing the music
      */
-    public static final String TOGGLEPAUSE_ACTION = "org.lineageos.eleven.togglepause";
+    public static final String TOGGLEPAUSE_ACTION = BuildConstants.PACKAGE_NAME + ".togglepause";
 
     /**
      * Called to go to pause the playback
      */
-    public static final String PAUSE_ACTION = "org.lineageos.eleven.pause";
+    public static final String PAUSE_ACTION = BuildConstants.PACKAGE_NAME + ".pause";
 
     /**
      * Called to go to stop the playback
      */
-    public static final String STOP_ACTION = "org.lineageos.eleven.stop";
+    public static final String STOP_ACTION = BuildConstants.PACKAGE_NAME + ".stop";
 
     /**
      * Called to go to the previous track or the beginning of the track if partway through the track
      */
-    public static final String PREVIOUS_ACTION = "org.lineageos.eleven.previous";
+    public static final String PREVIOUS_ACTION = BuildConstants.PACKAGE_NAME + ".previous";
 
     /**
      * Called to go to the previous track regardless of how far in the current track the playback is
      */
-    public static final String PREVIOUS_FORCE_ACTION = "org.lineageos.eleven.previous.force";
+    public static final String PREVIOUS_FORCE_ACTION = BuildConstants.PACKAGE_NAME + ".previous.force";
 
     /**
      * Called to go to the next track
      */
-    public static final String NEXT_ACTION = "org.lineageos.eleven.next";
+    public static final String NEXT_ACTION = BuildConstants.PACKAGE_NAME + ".next";
 
     /**
      * Called to change the repeat mode
      */
-    public static final String REPEAT_ACTION = "org.lineageos.eleven.repeat";
+    public static final String REPEAT_ACTION = BuildConstants.PACKAGE_NAME + ".repeat";
 
     /**
      * Called to change the shuffle mode
      */
-    public static final String SHUFFLE_ACTION = "org.lineageos.eleven.shuffle";
+    public static final String SHUFFLE_ACTION = BuildConstants.PACKAGE_NAME + ".shuffle";
 
     public static final String FROM_MEDIA_BUTTON = "frommediabutton";
 
@@ -201,22 +201,22 @@ public class MusicPlaybackService extends Service {
      * Used to easily notify a list that it should refresh. i.e. A playlist
      * changes
      */
-    public static final String REFRESH = "org.lineageos.eleven.refresh";
+    public static final String REFRESH = BuildConstants.PACKAGE_NAME + ".refresh";
 
     /**
      * Used by the alarm intent to shutdown the service after being idle
      */
-    private static final String SHUTDOWN = "org.lineageos.eleven.shutdown";
+    private static final String SHUTDOWN = BuildConstants.PACKAGE_NAME + ".shutdown";
 
     /**
      * Called to notify of a timed text
      */
-    public static final String NEW_LYRICS = "org.lineageos.eleven.lyrics";
+    public static final String NEW_LYRICS = BuildConstants.PACKAGE_NAME + ".lyrics";
 
     /**
      * Called to update the remote control client
      */
-    public static final String UPDATE_LOCKSCREEN = "org.lineageos.eleven.updatelockscreen";
+    public static final String UPDATE_LOCKSCREEN = BuildConstants.PACKAGE_NAME + ".updatelockscreen";
 
     public static final String CMDNAME = "command";
 
@@ -339,6 +339,8 @@ public class MusicPlaybackService extends Service {
      */
     public static final int MAX_HISTORY_SIZE = 1000;
 
+    private static final String ACTION_AUDIO_PLAYER = BuildConstants.PACKAGE_NAME + ".AUDIO_PLAYER";
+
     private static final String CHANNEL_NAME = "eleven_playback";
 
     public interface TrackErrorExtra {
@@ -1644,7 +1646,7 @@ public class MusicPlaybackService extends Service {
                 .setMediaSession(mSession.getSessionToken())
                 .setShowActionsInCompactView(0, 1, 2);
 
-        Intent nowPlayingIntent = new Intent("org.lineageos.eleven.AUDIO_PLAYER")
+        Intent nowPlayingIntent = new Intent(ACTION_AUDIO_PLAYER)
                 .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         PendingIntent clickIntent = PendingIntent.getActivity(this, 0, nowPlayingIntent, 0);
         BitmapWithColors artwork = getAlbumArt(false);
index 94ffb07..166f148 100644 (file)
@@ -27,6 +27,7 @@ import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 
+import org.lineageos.eleven.BuildConstants;
 import org.lineageos.eleven.MusicPlaybackService;
 import org.lineageos.eleven.R;
 import org.lineageos.eleven.cache.ICacheListener;
@@ -152,7 +153,8 @@ public class AlbumArtPagerAdapter extends FragmentStatePagerAdapter {
      * and handles loading the album art for a given audio id
      */
     public static class AlbumArtFragment extends Fragment implements ICacheListener {
-        private static final String ID = "org.lineageos.eleven.adapters.AlbumArtPagerAdapter.AlbumArtFragment.ID";
+        private static final String ID = BuildConstants.PACKAGE_NAME +
+                ".adapters.AlbumArtPagerAdapter.AlbumArtFragment.ID";
 
         private View mRootView;
         private AlbumArtistLoader mTask;
index 5b6bb8a..efea3a9 100644 (file)
@@ -16,5 +16,7 @@
 package org.lineageos.eleven;
 
 public final class BuildConfig {
+    public static final String APPLICATION_ID = "org.lineageos.eleven";
+
     public static final boolean DEBUG = Boolean.parseBoolean("false");
 }