Back to project page Android-Apps.
The source code is released under:
Apache License
If you think the Android project Android-Apps listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.kniezrec.voiceremote2; //from www. ja v a2 s. c om import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import com.kniezrec.voiceremote2.R; import android.content.Context; public class Commands { /* * Buttons */ public static final int BTN_SOURCE = 1; public static final int BTN_S_HDMI1 = 233; public static final int BTN_POWER_OFF = 2; public static final int BTN_1 = 4; public static final int BTN_2 = 5; public static final int BTN_3 = 6; public static final int BTN_4 = 8; public static final int BTN_5 = 9; public static final int BTN_6 = 10; public static final int BTN_7 = 12; public static final int BTN_8 = 13; public static final int BTN_9 = 14; public static final int BTN_0 = 17; public static final int BTN_VOLUME_UP = 7; public static final int BTN_VOLUME_DOWN = 11; public static final int BTN_CHANNEL_UP = 18; public static final int BTN_CHANNEL_DOWN = 16; public static final int BTN_MUTE = 15; public static final int BTN_MENU = 26; public static final int BTN_INFO = 31; public static final int BTN_ENTER = 104; public static final int BTN_UP = 96; public static final int BTN_DOWN = 97; public static final int BTN_LEFT = 101; public static final int BTN_RIGHT = 98; public static final int BTN_EXIT = 45; public static final int BTN_TELETEXT = 44; public static final int BTN_CHANNEL_LIST = 107; public static final int BTN_PAUSE = 74; public static final int BTN_PLAY = 71; public static final int BTN_STOP = 70; public static final int BTN_INTERNET = 147; public static final int BTN_TOOLS = 75; public static final int BTN_RETURN = 88; public static final int BTN_TIMEOUT_PAUSE = -1; /* * Actions */ public static final int SHOW_ALL = 1000; public static final int SHOW_ALL_BACK = 2000; public static final int SHOW_ONLY_FAV = 1001; public static final int NOT_FOUND = -2; public static final int STOP = 1002; public static final int WRITE = 1004; public static final int TO_QUIET = 1005; public static final int TO_LOUD = 1006; public static final int EXEC_CHN = 1007; private HashMap<String, Integer> hashBTN_POWER_OFF; private HashMap<String, Integer> hashBTN_1; private HashMap<String, Integer> hashBTN_2; private HashMap<String, Integer> hashBTN_3; private HashMap<String, Integer> hashBTN_4; private HashMap<String, Integer> hashBTN_5; private HashMap<String, Integer> hashBTN_6; private HashMap<String, Integer> hashBTN_7; private HashMap<String, Integer> hashBTN_8; private HashMap<String, Integer> hashBTN_9; private HashMap<String, Integer> hashBTN_0; private HashMap<String, Integer> hashBTN_VOLUME_UP; private HashMap<String, Integer> hashBTN_VOLUME_DOWN; private HashMap<String, Integer> hashBTN_CHANNEL_UP; private HashMap<String, Integer> hashBTN_CHANNEL_DOWN; private HashMap<String, Integer> hashBTN_MUTE; private HashMap<String, Integer> hashBTN_INFO; private HashMap<String, Integer> hashBTN_ENTER; private HashMap<String, Integer> hashBTN_UP; private HashMap<String, Integer> hashBTN_DOWN; private HashMap<String, Integer> hashBTN_LEFT; private HashMap<String, Integer> hashBTN_RIGHT; private HashMap<String, Integer> hashBTN_EXIT; private HashMap<String, Integer> hashBTN_TELETEXT; private HashMap<String, Integer> hashBTN_CHANNEL_LIST; private HashMap<String, Integer> hashBTN_PAUSE; private HashMap<String, Integer> hashBTN_PLAY; private HashMap<String, Integer> hashBTN_STOP; private HashMap<String, Integer> hashBTN_INTERNET; private HashMap<String, Integer> hashBTN_RETURN; private HashMap<String, Integer> hashBTN_HDMI; public List<String> toRemove; public List<String> favouriteChannels; public List<String> review; public List<String> review_back; public List<String> stop; public List<String> favouriteList; public List<String> toLoudList; public List<String> toQuietList; public List<String> write; private Context ctx; private final static String SEM = ";"; public ArrayList<HashMap<String, Integer>> all; public ArrayList<HashMap<String, Integer>> numeric; public static final ArrayList<RemoteButton> BUTTONS = new ArrayList<RemoteButton>(); static { BUTTONS.add(new RemoteButton(R.id.src, BTN_SOURCE)); BUTTONS.add(new RemoteButton(R.id.enter, BTN_ENTER)); BUTTONS.add(new RemoteButton(R.id.up, BTN_UP)); BUTTONS.add(new RemoteButton(R.id.down, BTN_DOWN)); BUTTONS.add(new RemoteButton(R.id.left, BTN_LEFT)); BUTTONS.add(new RemoteButton(R.id.right, BTN_RIGHT)); BUTTONS.add(new RemoteButton(R.id.chlist, BTN_CHANNEL_LIST)); BUTTONS.add(new RemoteButton(R.id.off, BTN_POWER_OFF)); } public Commands(Context context) { ctx = context; all = new ArrayList<HashMap<String, Integer>>(); numeric = new ArrayList<HashMap<String, Integer>>(); } private void addToList(int resource, HashMap<String, Integer> map, int code, boolean isNum) { String res; String[] array; res = ctx.getResources().getString(resource); array = res.split(SEM); map = new HashMap<String, Integer>(); Integer _code = Integer.valueOf(code); for (String s : array) { map.put(s, _code); } all.add(map); if (isNum) { numeric.add(map); } } public void loadFavourities(String preference) { favouriteList = null; if (preference != "") { String[] a = preference.split(":"); favouriteList = Arrays.asList(a); } } public void loadResources() { String _value = ctx.getResources().getString(R.string.toRemove); toRemove = Arrays.asList(_value.split(SEM)); _value = ctx.getResources().getString(R.string.write); write = Arrays.asList(_value.split(SEM)); _value = ctx.getResources().getString(R.string.review); review = Arrays.asList(_value.split(SEM)); _value = ctx.getResources().getString(R.string.reviewBack); review_back = Arrays.asList(_value.split(SEM)); _value = ctx.getResources().getString(R.string.favouriteChannels); favouriteChannels = Arrays.asList(_value.split(SEM)); _value = ctx.getResources().getString(R.string.end); stop = Arrays.asList(_value.split(SEM)); _value = ctx.getResources().getString(R.string.toLoud); toLoudList = Arrays.asList(_value.split(SEM)); _value = ctx.getResources().getString(R.string.toQuiet); toQuietList = Arrays.asList(_value.split(SEM)); addToList(R.string.turnOff, hashBTN_POWER_OFF, BTN_POWER_OFF, false); addToList(R.string.O, hashBTN_0, BTN_0, true); addToList(R.string.one, hashBTN_1, BTN_1, true); addToList(R.string.two, hashBTN_2, BTN_2, true); addToList(R.string.three, hashBTN_3, BTN_3, true); addToList(R.string.four, hashBTN_4, BTN_4, true); addToList(R.string.five, hashBTN_5, BTN_5, true); addToList(R.string.six, hashBTN_6, BTN_6, true); addToList(R.string.seven, hashBTN_7, BTN_7, true); addToList(R.string.eight, hashBTN_8, BTN_8, true); addToList(R.string.nine, hashBTN_9, BTN_9, true); addToList(R.string.volUp, hashBTN_VOLUME_UP, BTN_VOLUME_UP, false); addToList(R.string.volDown, hashBTN_VOLUME_DOWN, BTN_VOLUME_DOWN, false); addToList(R.string.prevChannel, hashBTN_CHANNEL_DOWN, BTN_CHANNEL_DOWN, false); addToList(R.string.nextChannel, hashBTN_CHANNEL_UP, BTN_CHANNEL_UP, false); addToList(R.string.mute, hashBTN_MUTE, BTN_MUTE, false); addToList(R.string.info, hashBTN_INFO, BTN_INFO, false); addToList(R.string.enter, hashBTN_ENTER, BTN_ENTER, false); addToList(R.string.up, hashBTN_UP, BTN_UP, false); addToList(R.string.down, hashBTN_DOWN, BTN_DOWN, false); addToList(R.string.left, hashBTN_LEFT, BTN_LEFT, false); addToList(R.string.right, hashBTN_RIGHT, BTN_RIGHT, false); addToList(R.string.exit, hashBTN_EXIT, BTN_EXIT, false); addToList(R.string.teletext, hashBTN_TELETEXT, BTN_TELETEXT, false); addToList(R.string.channelList, hashBTN_CHANNEL_LIST, BTN_CHANNEL_LIST, false); addToList(R.string.pause, hashBTN_PAUSE, BTN_PAUSE, false); addToList(R.string.play, hashBTN_PLAY, BTN_PLAY, false); addToList(R.string.stop, hashBTN_STOP, BTN_STOP, false); addToList(R.string.internet, hashBTN_INTERNET, BTN_INTERNET, false); addToList(R.string.ret, hashBTN_RETURN, BTN_RETURN, false); addToList(R.string.hdmi, hashBTN_HDMI, BTN_S_HDMI1, false); } }