Implemented reportShortcutUsed() to track shortcut usage
This commit is contained in:
parent
d17f0407dd
commit
0a871af744
6 changed files with 29 additions and 3 deletions
|
|
@ -6,6 +6,9 @@ import android.os.Bundle;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.kabouzeid.gramophone.R;
|
import com.kabouzeid.gramophone.R;
|
||||||
|
import com.kabouzeid.gramophone.appshortcuts.shortcuttype.LastAddedShortcutType;
|
||||||
|
import com.kabouzeid.gramophone.appshortcuts.shortcuttype.ShuffleAllShortcutType;
|
||||||
|
import com.kabouzeid.gramophone.appshortcuts.shortcuttype.TopTracksShortcutType;
|
||||||
import com.kabouzeid.gramophone.loader.LastAddedLoader;
|
import com.kabouzeid.gramophone.loader.LastAddedLoader;
|
||||||
import com.kabouzeid.gramophone.loader.SongLoader;
|
import com.kabouzeid.gramophone.loader.SongLoader;
|
||||||
import com.kabouzeid.gramophone.loader.TopAndRecentlyPlayedTracksLoader;
|
import com.kabouzeid.gramophone.loader.TopAndRecentlyPlayedTracksLoader;
|
||||||
|
|
@ -44,14 +47,17 @@ public class AppShortcutLauncherActivity extends Activity {
|
||||||
case SHUFFLE_ALL:
|
case SHUFFLE_ALL:
|
||||||
launchMainActivityWithSongs(PlayMode.SHUFFLE,
|
launchMainActivityWithSongs(PlayMode.SHUFFLE,
|
||||||
SongLoader.getAllSongs(getApplicationContext()));
|
SongLoader.getAllSongs(getApplicationContext()));
|
||||||
|
DynamicShortcutManager.reportShortcutUsed(this, ShuffleAllShortcutType.getId());
|
||||||
break;
|
break;
|
||||||
case TOP_TRACKS:
|
case TOP_TRACKS:
|
||||||
launchMainActivityWithSongs(PlayMode.NORMAL,
|
launchMainActivityWithSongs(PlayMode.NORMAL,
|
||||||
TopAndRecentlyPlayedTracksLoader.getRecentlyPlayedTracks(getApplicationContext()));
|
TopAndRecentlyPlayedTracksLoader.getRecentlyPlayedTracks(getApplicationContext()));
|
||||||
|
DynamicShortcutManager.reportShortcutUsed(this, TopTracksShortcutType.getId());
|
||||||
break;
|
break;
|
||||||
case LAST_ADDED:
|
case LAST_ADDED:
|
||||||
launchMainActivityWithSongs(PlayMode.NORMAL,
|
launchMainActivityWithSongs(PlayMode.NORMAL,
|
||||||
LastAddedLoader.getLastAddedSongs(getApplicationContext()));
|
LastAddedLoader.getLastAddedSongs(getApplicationContext()));
|
||||||
|
DynamicShortcutManager.reportShortcutUsed(this, LastAddedShortcutType.getId());
|
||||||
break;
|
break;
|
||||||
case NONE:
|
case NONE:
|
||||||
shortcutError();
|
shortcutError();
|
||||||
|
|
|
||||||
|
|
@ -58,4 +58,8 @@ public class DynamicShortcutManager {
|
||||||
new LastAddedShortcutType(mContext).getShortcutInfo()
|
new LastAddedShortcutType(mContext).getShortcutInfo()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void reportShortcutUsed(Context context, String shortcutId){
|
||||||
|
context.getSystemService(ShortcutManager.class).reportShortcutUsed(shortcutId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,10 @@ public abstract class BaseShortcutType {
|
||||||
|
|
||||||
abstract ShortcutInfo getShortcutInfo();
|
abstract ShortcutInfo getShortcutInfo();
|
||||||
|
|
||||||
|
static public String getId(){
|
||||||
|
return ID_PREFIX + "invalid";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an Intent that will launch MainActivtiy and immediately play {@param songs} in either shuffle or normal mode
|
* Creates an Intent that will launch MainActivtiy and immediately play {@param songs} in either shuffle or normal mode
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,15 @@ public final class LastAddedShortcutType extends BaseShortcutType {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShortcutInfo getShortcutInfo() {
|
public ShortcutInfo getShortcutInfo() {
|
||||||
return new ShortcutInfo.Builder(mContext, ID_PREFIX + "last_added")
|
return new ShortcutInfo.Builder(mContext, getId())
|
||||||
.setShortLabel(mContext.getString(R.string.app_shortcut_last_added_short))
|
.setShortLabel(mContext.getString(R.string.app_shortcut_last_added_short))
|
||||||
.setLongLabel(mContext.getString(R.string.app_shortcut_last_added_long))
|
.setLongLabel(mContext.getString(R.string.app_shortcut_last_added_long))
|
||||||
.setIcon(AppShortcutIconGenerator.generateThemedIcon(mContext, R.drawable.ic_app_shortcut_last_added))
|
.setIcon(AppShortcutIconGenerator.generateThemedIcon(mContext, R.drawable.ic_app_shortcut_last_added))
|
||||||
.setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.ShortcutType.LAST_ADDED))
|
.setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.ShortcutType.LAST_ADDED))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getId(){
|
||||||
|
return ID_PREFIX + "last_added";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,15 @@ public final class ShuffleAllShortcutType extends BaseShortcutType {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShortcutInfo getShortcutInfo() {
|
public ShortcutInfo getShortcutInfo() {
|
||||||
return new ShortcutInfo.Builder(mContext, ID_PREFIX + "shuffle_all")
|
return new ShortcutInfo.Builder(mContext, getId())
|
||||||
.setShortLabel(mContext.getString(R.string.app_shortcut_shuffle_all_short))
|
.setShortLabel(mContext.getString(R.string.app_shortcut_shuffle_all_short))
|
||||||
.setLongLabel(mContext.getString(R.string.app_shortcut_shuffle_all_long))
|
.setLongLabel(mContext.getString(R.string.app_shortcut_shuffle_all_long))
|
||||||
.setIcon(AppShortcutIconGenerator.generateThemedIcon(mContext, R.drawable.ic_app_shortcut_shuffle_all))
|
.setIcon(AppShortcutIconGenerator.generateThemedIcon(mContext, R.drawable.ic_app_shortcut_shuffle_all))
|
||||||
.setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.ShortcutType.SHUFFLE_ALL))
|
.setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.ShortcutType.SHUFFLE_ALL))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getId() {
|
||||||
|
return ID_PREFIX + "shuffle_all";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,15 @@ public final class TopTracksShortcutType extends BaseShortcutType {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShortcutInfo getShortcutInfo() {
|
public ShortcutInfo getShortcutInfo() {
|
||||||
return new ShortcutInfo.Builder(mContext, ID_PREFIX + "top_tracks")
|
return new ShortcutInfo.Builder(mContext, getId())
|
||||||
.setShortLabel(mContext.getString(R.string.app_shortcut_top_tracks_short))
|
.setShortLabel(mContext.getString(R.string.app_shortcut_top_tracks_short))
|
||||||
.setLongLabel(mContext.getString(R.string.app_shortcut_top_tracks_long))
|
.setLongLabel(mContext.getString(R.string.app_shortcut_top_tracks_long))
|
||||||
.setIcon(AppShortcutIconGenerator.generateThemedIcon(mContext, R.drawable.ic_app_shortcut_top_tracks))
|
.setIcon(AppShortcutIconGenerator.generateThemedIcon(mContext, R.drawable.ic_app_shortcut_top_tracks))
|
||||||
.setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.ShortcutType.TOP_TRACKS))
|
.setIntent(getPlaySongsIntent(AppShortcutLauncherActivity.ShortcutType.TOP_TRACKS))
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getId() {
|
||||||
|
return ID_PREFIX + "top_tracks";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue