update version codes and application id throughout the codebase

This commit is contained in:
dkanada 2021-04-24 18:45:59 +09:00
commit 2b7d7308d3
11 changed files with 30 additions and 43 deletions

View file

@ -16,7 +16,7 @@ import com.dkanada.gramophone.R;
import com.dkanada.gramophone.util.ImageUtil;
import com.dkanada.gramophone.util.PreferenceUtil;
@RequiresApi(Build.VERSION_CODES.N_MR1)
@RequiresApi(Build.VERSION_CODES.O)
public final class AppShortcutIconGenerator {
public static Icon generateThemedIcon(Context context, int iconId) {

View file

@ -4,6 +4,7 @@ import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.dkanada.gramophone.BuildConfig;
import com.dkanada.gramophone.views.shortcuts.shortcuttype.LatestShortcutType;
import com.dkanada.gramophone.views.shortcuts.shortcuttype.ShuffleShortcutType;
import com.dkanada.gramophone.views.shortcuts.shortcuttype.FrequentShortcutType;
@ -11,24 +12,23 @@ import com.dkanada.gramophone.model.Playlist;
import com.dkanada.gramophone.service.MusicService;
public class AppShortcutLauncherActivity extends Activity {
public static final String KEY_SHORTCUT_TYPE = "com.dkanada.gramophone.views.shortcuts.ShortcutType";
public static final String EXTRA_SHORTCUT = BuildConfig.APPLICATION_ID + ".extra.shortcut";
public static final int SHORTCUT_TYPE_SHUFFLE = 0;
public static final int SHORTCUT_TYPE_FREQUENT = 1;
public static final int SHORTCUT_TYPE_LATEST = 2;
public static final int SHORTCUT_TYPE_NONE = 3;
public static final int SHORTCUT_TYPE_DEFAULT = 3;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
int shortcutType = SHORTCUT_TYPE_NONE;
int shortcutType = SHORTCUT_TYPE_DEFAULT;
// Set shortcutType from the intent extras
Bundle extras = getIntent().getExtras();
if (extras != null) {
// noinspection WrongConstant
shortcutType = extras.getInt(KEY_SHORTCUT_TYPE, SHORTCUT_TYPE_NONE);
shortcutType = extras.getInt(EXTRA_SHORTCUT, SHORTCUT_TYPE_DEFAULT);
}
switch (shortcutType) {

View file

@ -15,11 +15,11 @@ import com.dkanada.gramophone.views.shortcuts.shortcuttype.FrequentShortcutType;
import java.util.Arrays;
import java.util.List;
@TargetApi(Build.VERSION_CODES.N_MR1)
@TargetApi(Build.VERSION_CODES.O)
public class DynamicShortcutManager {
private Context context;
private ShortcutManager shortcutManager;
private final Context context;
private final ShortcutManager shortcutManager;
public DynamicShortcutManager(Context context) {
this.context = context;
@ -46,11 +46,11 @@ public class DynamicShortcutManager {
}
public List<ShortcutInfo> getDefaultShortcuts() {
return (Arrays.asList(
return Arrays.asList(
new ShuffleShortcutType(context).getShortcutInfo(),
new FrequentShortcutType(context).getShortcutInfo(),
new LatestShortcutType(context).getShortcutInfo()
));
);
}
public static void reportShortcutUsed(Context context, String shortcutId){

View file

@ -7,12 +7,13 @@ import android.content.pm.ShortcutInfo;
import android.os.Build;
import android.os.Bundle;
import com.dkanada.gramophone.BuildConfig;
import com.dkanada.gramophone.views.shortcuts.AppShortcutLauncherActivity;
@TargetApi(Build.VERSION_CODES.N_MR1)
@TargetApi(Build.VERSION_CODES.O)
public abstract class BaseShortcutType {
static final String ID_PREFIX = "com.dkanada.gramophone.views.shortcuts.id.";
static final String PREFIX = BuildConfig.APPLICATION_ID + ".views.shortcut";
Context context;
@ -21,25 +22,19 @@ public abstract class BaseShortcutType {
}
static public String getId() {
return ID_PREFIX + "invalid";
return PREFIX + ".base";
}
abstract ShortcutInfo getShortcutInfo();
/**
* Creates an Intent that will launch MainActivtiy and immediately play {@param songs} in either shuffle or normal mode
*
* @param shortcutType Describes the type of shortcut to create (ShuffleAll, TopTracks, custom playlist, etc.)
* @return
*/
Intent getPlaySongsIntent(int shortcutType) {
Intent intent = new Intent(context, AppShortcutLauncherActivity.class);
intent.setAction(Intent.ACTION_VIEW);
Bundle b = new Bundle();
b.putInt(AppShortcutLauncherActivity.KEY_SHORTCUT_TYPE, shortcutType);
Bundle bundle = new Bundle();
bundle.putInt(AppShortcutLauncherActivity.EXTRA_SHORTCUT, shortcutType);
intent.putExtras(b);
intent.putExtras(bundle);
return intent;
}

View file

@ -9,14 +9,14 @@ import com.dkanada.gramophone.R;
import com.dkanada.gramophone.views.shortcuts.AppShortcutIconGenerator;
import com.dkanada.gramophone.views.shortcuts.AppShortcutLauncherActivity;
@TargetApi(Build.VERSION_CODES.N_MR1)
@TargetApi(Build.VERSION_CODES.O)
public final class FrequentShortcutType extends BaseShortcutType {
public FrequentShortcutType(Context context) {
super(context);
}
public static String getId() {
return ID_PREFIX + "top_tracks";
return PREFIX + ".frequent";
}
public ShortcutInfo getShortcutInfo() {

View file

@ -9,14 +9,14 @@ import com.dkanada.gramophone.R;
import com.dkanada.gramophone.views.shortcuts.AppShortcutIconGenerator;
import com.dkanada.gramophone.views.shortcuts.AppShortcutLauncherActivity;
@TargetApi(Build.VERSION_CODES.N_MR1)
@TargetApi(Build.VERSION_CODES.O)
public final class LatestShortcutType extends BaseShortcutType {
public LatestShortcutType(Context context) {
super(context);
}
public static String getId() {
return ID_PREFIX + "last_added";
return PREFIX + ".latest";
}
public ShortcutInfo getShortcutInfo() {

View file

@ -9,14 +9,14 @@ import com.dkanada.gramophone.R;
import com.dkanada.gramophone.views.shortcuts.AppShortcutIconGenerator;
import com.dkanada.gramophone.views.shortcuts.AppShortcutLauncherActivity;
@TargetApi(Build.VERSION_CODES.N_MR1)
@TargetApi(Build.VERSION_CODES.O)
public final class ShuffleShortcutType extends BaseShortcutType {
public ShuffleShortcutType(Context context) {
super(context);
}
public static String getId() {
return ID_PREFIX + "shuffle_all";
return PREFIX + ".shuffle";
}
public ShortcutInfo getShortcutInfo() {