Android Open Source - Android-Apps Mapper






From Project

Back to project page Android-Apps.

License

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.

Java Source Code

package com.kniezrec.voiceremotefree;
/*from ww  w. ja v  a2s.co m*/
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import android.content.SharedPreferences;
import android.content.res.Resources;
import android.util.Log;

public final class Mapper {

  public static Integer[] parseNumber(String nr) {
    Integer[] integers = null;
    try {
      Integer.valueOf(nr);
      char[] arr = nr.toCharArray();
      integers = new Integer[arr.length];
      for (int i = 0; i < arr.length; i++) {
        switch (arr[i]) {
        case '0':
          integers[i] = Integer.valueOf(Commands.BTN_0);
          break;
        case '1':
          integers[i] = Integer.valueOf(Commands.BTN_1);
          break;
        case '2':
          integers[i] = Integer.valueOf(Commands.BTN_2);
          break;
        case '3':
          integers[i] = Integer.valueOf(Commands.BTN_3);
          break;
        case '4':
          integers[i] = Integer.valueOf(Commands.BTN_4);
          break;
        case '5':
          integers[i] = Integer.valueOf(Commands.BTN_5);
          break;
        case '6':
          integers[i] = Integer.valueOf(Commands.BTN_6);
          break;
        case '7':
          integers[i] = Integer.valueOf(Commands.BTN_7);
          break;
        case '8':
          integers[i] = Integer.valueOf(Commands.BTN_8);
          break;
        case '9':
          integers[i] = Integer.valueOf(Commands.BTN_9);
          break;

        default:
          break;
        }
      }
      return integers;
    } catch (NumberFormatException e) {
      return null;
    }
  }

  private static int parseString(String s) {
    int v;
    try {
      v = Integer.parseInt(s);
    } catch (NumberFormatException e) {
      v = 0;
      Log.v("", e.getMessage());
    }

    return v;
  }

  public static Integer[][] checkActions(Set<String> set,
      ArrayList<String> textMatchList, SharedPreferences prefs) {
    ArrayList<Integer[]> parsed;
    String voice = textMatchList.get(0);
    if (set.contains(voice)) {
      parsed = new ArrayList<Integer[]>();
      String tmp = prefs.getString(voice + NewAction.SUFFIX, "");
      String[] _tmpArr = tmp.split(NewAction.SEP);
      int code;
      for (String s : _tmpArr) {
        if (s.startsWith(NewAction.CH_SEP)) {
          parsed.add(parseNumber(s.substring(3)));
        } else {
          code = parseString(s);
          Integer[] _arr = new Integer[1];
          switch (code) {
          case 0:
            _arr[0] = Integer.valueOf(Commands.BTN_UP);
            break;
          case 1:
            _arr[0] = Integer.valueOf(Commands.BTN_DOWN);
            break;
          case 2:
            _arr[0] = Integer.valueOf(Commands.BTN_LEFT);
            break;
          case 3:
            _arr[0] = Integer.valueOf(Commands.BTN_RIGHT);
            break;
          case 4:
            _arr[0] = Integer.valueOf(Commands.BTN_EXIT);
            break;
          case 5:
            _arr[0] = Integer.valueOf(Commands.BTN_ENTER);
            break;
          case 6:
            _arr[0] = Integer.valueOf(Commands.BTN_TOOLS);
            break;
          case 7:
            _arr[0] = Integer.valueOf(Commands.BTN_RETURN);
            break;
          case 8:
            _arr[0] = Integer.valueOf(Commands.BTN_CHANNEL_LIST);
            break;
          case 9:
            _arr[0] = Integer.valueOf(Commands.BTN_MENU);
            break;
          case 10:
            _arr[0] = Integer.valueOf(Commands.BTN_CHANNEL_UP);
            break;
          case 11:
            _arr[0] = Integer.valueOf(Commands.BTN_CHANNEL_DOWN);
            break;
          case 12:
            _arr[0] = Integer.valueOf(Commands.BTN_VOLUME_UP);
            break;
          case 13:
            _arr[0] = Integer.valueOf(Commands.BTN_VOLUME_DOWN);
            break;
          case 14:
            _arr[0] = Integer.valueOf(Commands.BTN_MUTE);
            break;
          case 15:
            _arr[0] = Integer.valueOf(Commands.BTN_INFO);
            break;
          case 16:
            _arr[0] = Integer.valueOf(Commands.BTN_TELETEXT);
            break;
          case 17:
            _arr[0] = Integer.valueOf(Commands.BTN_PAUSE);
            break;
          case 18:
            _arr[0] = Integer.valueOf(Commands.BTN_PLAY);
            break;
          case 19:
            _arr[0] = Integer.valueOf(Commands.BTN_STOP);
            break;
          case 20:
            _arr[0] = Integer.valueOf(Commands.BTN_INTERNET);
            break;
          case 21:
            _arr[0] = Integer.valueOf(Commands.BTN_SOURCE);
            break;
          case 22:
            _arr[0] = Integer.valueOf(Commands.BTN_POWER_OFF);
            break;
          case 24:
            _arr[0] = Integer.valueOf(Commands.BTN_S_HDMI1);
            break;
          case 25:
            _arr[0] = Integer.valueOf(Commands.BTN_TIMEOUT_PAUSE);
            break;
          default:
            break;
          }
          parsed.add(_arr);
        }
      }
      return parsed.toArray(new Integer[parsed.size()][]);
    }
    return null;
  }

  public static Integer[] mapResult(ArrayList<String> textMatchList,
      Commands cmds, SharedPreferences pref) {
    String resOne = null;
    if (textMatchList == null)
      return null;

    resOne = textMatchList.get(0);
    Integer[] codes;
    Integer tmp;
    for (String s : cmds.toRemove) {
      if (resOne.startsWith(s)) {
        resOne = resOne.replace(s, "");
        resOne = resOne.trim();
        codes = parseNumber(resOne);
        if (codes != null) {
          return codes;
        }

        for (HashMap<String, Integer> map : cmds.numeric) {
          tmp = map.get(resOne);
          if (tmp != null) {
            codes = new Integer[1];
            codes[0] = tmp;
            return codes;
          }
        }
        break;
      }
    }

    codes = parseNumber(resOne);
    if (codes != null) {
      return codes;
    }

    for (HashMap<String, Integer> map : cmds.all) {
      tmp = map.get(resOne);
      if (tmp != null) {
        codes = new Integer[1];
        codes[0] = tmp;
        return codes;
      }
    }

    Map<String, ?> keys = pref.getAll();
    Object value = keys.get(resOne);
    if (value != null) {
      if (value instanceof Integer) {
        codes = new Integer[1];
        codes[0] = (Integer) value;
        return codes;
      } else {
        String _val = new String(value.toString());
        codes = parseNumber(_val.substring(0, _val.length() - 1));
        return codes;
      }
    }

    return null;
  }

  public static int mapOptionToAction(String id) {
    int _id = Integer.parseInt(id);
    switch (_id) {
    case 1:
      return Commands.BTN_VOLUME_UP;
    case 2:
      return Commands.BTN_VOLUME_DOWN;
    case 3:
      return Commands.BTN_MUTE;
    case 4:
      return Commands.BTN_CHANNEL_UP;
    case 5:
      return Commands.BTN_CHANNEL_DOWN;
    case 6:
      return Commands.BTN_INFO;
    case 7:
      return Commands.BTN_ENTER;
    case 8:
      return Commands.BTN_UP;
    case 9:
      return Commands.BTN_DOWN;
    case 10:
      return Commands.BTN_LEFT;
    case 11:
      return Commands.BTN_RIGHT;
    case 12:
      return Commands.BTN_EXIT;
    case 13:
      return Commands.BTN_TELETEXT;
    case 14:
      return Commands.BTN_PAUSE;
    case 15:
      return Commands.BTN_PLAY;
    case 16:
      return Commands.BTN_STOP;
    case 17:
      return Commands.BTN_INTERNET;
    case 18:
      return Commands.BTN_POWER_OFF;
    case 19:
      return Commands.BTN_RETURN;
    case 20:
      return Commands.BTN_CHANNEL_LIST;
    case 21:
      return Commands.BTN_S_HDMI1;

    default:
      return -1;
    }

  }

  public static String mapActionToName(String actionId, Resources res) {
    int action = 0;
    int step = 0;
    try {
      action = Integer.parseInt(actionId);
    } catch (NumberFormatException e) {
      step = 1;
    }

    switch (action) {
    case Commands.BTN_VOLUME_UP:
      step = 1;
      break;
    case Commands.BTN_VOLUME_DOWN:
      step = 2;
      break;
    case Commands.BTN_MUTE:
      step = 3;
      break;
    case Commands.BTN_CHANNEL_UP:
      step = 4;
      break;
    case Commands.BTN_CHANNEL_DOWN:
      step = 5;
      break;
    case Commands.BTN_INFO:
      step = 6;
      break;
    case Commands.BTN_ENTER:
      step = 7;
      break;
    case Commands.BTN_UP:
      step = 8;
      break;
    case Commands.BTN_DOWN:
      step = 9;
      break;
    case Commands.BTN_LEFT:
      step = 10;
      break;
    case Commands.BTN_RIGHT:
      step = 11;
      break;
    case Commands.BTN_EXIT:
      step = 12;
      break;
    case Commands.BTN_TELETEXT:
      step = 13;
      break;
    case Commands.BTN_PAUSE:
      step = 14;
      break;
    case Commands.BTN_PLAY:
      step = 15;
      break;
    case Commands.BTN_STOP:
      step = 16;
      break;
    case Commands.BTN_INTERNET:
      step = 17;
      break;
    case Commands.BTN_POWER_OFF:
      step = 18;
      break;
    case Commands.BTN_RETURN:
      step = 19;
      break;
    case Commands.BTN_CHANNEL_LIST:
      step = 20;
      break;
    case Commands.BTN_S_HDMI1:
      step = 21;
      break;

    default:
      break;
    }

    String[] list = res.getStringArray(R.array.buttons);
    return list[step];
  }

  public static String mapIntToName(String step, Resources res) {
    int _step = 0;
    try {
      _step = Integer.parseInt(step);
    } catch (NumberFormatException e) {
      return "Action";
    }
    String[] list = res.getStringArray(R.array.buttons2);
    return list[_step];
  }
}




Java Source Code List

com.kniezrec.remoterecorder.Communication.java
com.kniezrec.remoterecorder.MainServiceConnection.java
com.kniezrec.remoterecorder.MainService.java
com.kniezrec.remoterecorder.RequestType.java
com.kniezrec.remoterecorder.Request.java
com.kniezrec.voiceremote2.BSeriesKeyCodeSenderFactory.java
com.kniezrec.voiceremote2.BSeriesSender.java
com.kniezrec.voiceremote2.CSeriesButtons.java
com.kniezrec.voiceremote2.CSeriesKeyCodeSenderFactory.java
com.kniezrec.voiceremote2.CSeriesSender.java
com.kniezrec.voiceremote2.CommandsFragment.java
com.kniezrec.voiceremote2.Commands.java
com.kniezrec.voiceremote2.Discovery.java
com.kniezrec.voiceremote2.FSeriesButtons.java
com.kniezrec.voiceremote2.Group.java
com.kniezrec.voiceremote2.HelpFragment.java
com.kniezrec.voiceremote2.HostnamePreference.java
com.kniezrec.voiceremote2.KeyCodeSender.java
com.kniezrec.voiceremote2.ListActionsFragment.java
com.kniezrec.voiceremote2.MainActivity.java
com.kniezrec.voiceremote2.MainFragment.java
com.kniezrec.voiceremote2.Mapper.java
com.kniezrec.voiceremote2.MyExpandableListAdapter.java
com.kniezrec.voiceremote2.NewActionEdit.java
com.kniezrec.voiceremote2.NewActionSingleEdit.java
com.kniezrec.voiceremote2.NewAction.java
com.kniezrec.voiceremote2.RemoteButton.java
com.kniezrec.voiceremote2.SenderFactory.java
com.kniezrec.voiceremote2.Sender.java
com.kniezrec.voiceremote2.SettingsActivity.java
com.kniezrec.voiceremote2.TextSender.java
com.kniezrec.voiceremotefree.BSeriesKeyCodeSenderFactory.java
com.kniezrec.voiceremotefree.BSeriesSender.java
com.kniezrec.voiceremotefree.CSeriesButtons.java
com.kniezrec.voiceremotefree.CSeriesKeyCodeSenderFactory.java
com.kniezrec.voiceremotefree.CSeriesSender.java
com.kniezrec.voiceremotefree.Commands.java
com.kniezrec.voiceremotefree.Discovery.java
com.kniezrec.voiceremotefree.FSeriesButtons.java
com.kniezrec.voiceremotefree.HelpActivity.java
com.kniezrec.voiceremotefree.HostnamePreference.java
com.kniezrec.voiceremotefree.KeyCodeSender.java
com.kniezrec.voiceremotefree.ListActionsActivity.java
com.kniezrec.voiceremotefree.MainActivity.java
com.kniezrec.voiceremotefree.Mapper.java
com.kniezrec.voiceremotefree.NewActionEdit.java
com.kniezrec.voiceremotefree.NewActionSingleEdit.java
com.kniezrec.voiceremotefree.NewAction.java
com.kniezrec.voiceremotefree.RemoteButton.java
com.kniezrec.voiceremotefree.SenderFactory.java
com.kniezrec.voiceremotefree.Sender.java
com.kniezrec.voiceremotefree.Setings.java
com.kniezrec.voiceremotefree.SettingsActivity.java
com.kniezrec.voiceremotefree.TextSender.java
com.kniezrec.xbmcgear.connection.AndroidApplication.java
com.kniezrec.xbmcgear.connection.Connection.java
com.kniezrec.xbmcgear.connection.GearJSON.java
com.kniezrec.xbmcgear.connection.JSONRPCRequest.java
com.kniezrec.xbmcgear.connection.JSONRequestFactory.java
com.kniezrec.xbmcgear.connection.NSDResolve.java
com.kniezrec.xbmcgear.connection.NSDSearch.java
com.kniezrec.xbmcgear.connection.ProviderConnection.java
com.kniezrec.xbmcgear.connection.ProviderService.java
com.kniezrec.xbmcgear.connection.ResponseParser.java
com.kniezrec.xbmcgear.connection.WakeOnLan.java
com.kniezrec.xbmcgear.player.Kodi.java
com.kniezrec.xbmcgear.player.Player.java
com.kniezrec.xbmcgear.player.Playlist.java
com.kniezrec.xbmcgear.player.Song.java
com.kniezrec.xbmcgear.player.Video.java
com.kniezrec.xbmcgear.preferences.HostTable.java
com.kniezrec.xbmcgear.preferences.Host.java
com.kniezrec.xbmcgear.preferences.HostsDataSource.java
com.kniezrec.xbmcgear.preferences.HostsDatabaseHelper.java
com.kniezrec.xbmcgear.preferences.SharedPreferencesUtil.java
com.kniezrec.xbmcgear.presentation.AnimationManager.java
com.kniezrec.xbmcgear.presentation.AutoConfigurationActivity.java
com.kniezrec.xbmcgear.presentation.HostSetActivity.java
com.kniezrec.xbmcgear.presentation.InstanceActivity.java
com.kniezrec.xbmcgear.presentation.MainActivity.java
com.kniezrec.xbmcgear.presentation.StyleDialogFragment.java
com.kniezrec.xbmcgear.presentation.ViewMode.java
com.uraroji.garage.android.lame.SimpleLame.java
com.uraroji.garage.android.mp3recvoice.RecMicToMp3.java
de.quist.samy.remocon.Base64.java
de.quist.samy.remocon.Base64.java
de.quist.samy.remocon.ConnectionDeniedException.java
de.quist.samy.remocon.ConnectionDeniedException.java
de.quist.samy.remocon.Key.java
de.quist.samy.remocon.Key.java
de.quist.samy.remocon.Loggable.java
de.quist.samy.remocon.Loggable.java
de.quist.samy.remocon.RemoteReader.java
de.quist.samy.remocon.RemoteReader.java
de.quist.samy.remocon.RemoteSession.java
de.quist.samy.remocon.RemoteSession.java