summaryrefslogtreecommitdiffstats
path: root/fmapp2/src
diff options
context:
space:
mode:
authorEd Falk <efalk@cyngn.com>2015-09-14 12:34:44 -0700
committerMatt Wagantall <mwagantall@cyngn.com>2016-02-19 14:07:46 -0800
commit2259d4d71e2de74f214029f2ccc732dce0e58202 (patch)
tree4e8d3f9cb46b62ba5babda343b1c2b08a57b0518 /fmapp2/src
parent6265c148e9cd8148a103849cccfaa3c432963050 (diff)
downloadandroid_hardware_qcom_fm-2259d4d71e2de74f214029f2ccc732dce0e58202.tar.gz
android_hardware_qcom_fm-2259d4d71e2de74f214029f2ccc732dce0e58202.tar.bz2
android_hardware_qcom_fm-2259d4d71e2de74f214029f2ccc732dce0e58202.zip
FMRadio : Localization of band types
Previously, FmRadio could only display the type names for English and two dialects of Chinese, despite already having a full set of localized names in the resources. This change moves the names from <array>s to <string>s and then uses them in PresetStation.java This looks like a massive change, but it's mostly moving strings to different resource files. Change-Id: I6be12d05f9efdec7ec189d30f625d7f82746b5a6 Issue-id: CYNGNOS-995
Diffstat (limited to 'fmapp2/src')
-rw-r--r--fmapp2/src/com/caf/fmradio/PresetStation.java660
1 files changed, 44 insertions, 616 deletions
diff --git a/fmapp2/src/com/caf/fmradio/PresetStation.java b/fmapp2/src/com/caf/fmradio/PresetStation.java
index 698cdb6..7d09d01 100644
--- a/fmapp2/src/com/caf/fmradio/PresetStation.java
+++ b/fmapp2/src/com/caf/fmradio/PresetStation.java
@@ -30,6 +30,7 @@ package com.caf.fmradio;
import qcom.fmradio.FmReceiver;
import java.util.Locale;
+import android.content.res.Resources;
import android.text.TextUtils;
//import android.util.Log;
@@ -616,622 +617,49 @@ public class PresetStation
public static String parsePTY(int pty)
{
String ptyStr="";
+ Resources res = FMAdapterApp.context.getResources();
int rdsStd = FmSharedPreferences.getFMConfiguration().getRdsStd();
- if(rdsStd == FmReceiver.FM_RDS_STD_RBDS)
- {
- ptyStr = getRBDSPtyString(pty);
- }
- else if(rdsStd == FmReceiver.FM_RDS_STD_RDS)
- {
- ptyStr = getRDSPtyString(pty);
- }
- return (ptyStr);
- }
-
- /**
- * get the Text String for the RBDS Program type Code
- */
- public static String getRBDSPtyString(int pty)
- {
- String ptyStr = "";
-
- switch (pty)
- {
- case 1:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "新聞";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "新闻";
- else
- ptyStr = "News";
- break;
- }
- case 2:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "資訊";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "信息频道";
- else
- ptyStr = "Information";
- break;
- }
- case 3:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "体育";
- else
- ptyStr = "Sports";
- break;
- }
- case 4:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "討論";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "交流";
- else
- ptyStr = "Talk";
- break;
- }
- case 5:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "搖滾";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "摇滚";
- else
- ptyStr = "Rock";
- break;
- }
- case 6:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "古典搖滾";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "经典摇滚";
- else
- ptyStr = "Classic Rock";
- break;
- }
- case 7:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "成人熱門精選";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "成人点击";
- else
- ptyStr = "Adult Hits";
- break;
- }
- case 8:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "輕柔搖滾樂";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "轻摇滚";
- else
- ptyStr = "Soft Rock";
- break;
- }
- case 9:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "前40首最熱門歌曲";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "前40";
- else
- ptyStr = "Top 40";
- break;
- }
- case 10:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "鄉村音樂";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "乡村";
- else
- ptyStr = "Country";
- break;
- }
- case 11:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "懷舊";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "老歌";
- else
- ptyStr = "Oldies";
- break;
- }
- case 12:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "輕柔";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "轻音乐";
- else
- ptyStr = "Soft";
- break;
- }
- case 13:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "思鄉";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "怀旧";
- else
- ptyStr = "Nostalgia";
- break;
- }
- case 14:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "爵士樂";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "爵士";
- else
- ptyStr = "Jazz";
- break;
- }
- case 15:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "古典";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "古典";
- else
- ptyStr = "Classical";
- break;
- }
- case 16:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "節奏藍調";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "节奏布鲁斯";
- else
- ptyStr = "Rhythm and Blues";
- break;
- }
- case 17:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "輕柔節奏藍調";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "轻节奏布鲁斯";
- else
- ptyStr = "Soft Rhythm and Blues";
- break;
- }
- case 18:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "外語";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "外语频道";
- else
- ptyStr = "Foreign Language";
- break;
- }
- case 19:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "宗教音樂";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "宗教音乐";
- else
- ptyStr = "Religious Music";
- break;
- }
- case 20:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "宗教討論";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "宗教交流";
- else
- ptyStr = "Religious Talk";
- break;
- }
- case 21:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "個人";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "个性";
- else
- ptyStr = "Personality";
- break;
- }
- case 22:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "公開";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "公共频道";
- else
- ptyStr = "Public";
- break;
- }
- case 23:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "學院";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "校园";
- else
- ptyStr = "College";
- break;
- }
- case 29:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "天氣";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "天气";
- else
- ptyStr = "Weather";
- break;
- }
- case 30:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "緊急測試";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "紧急 测试";
- else
- ptyStr = "Emergency Test";
- break;
- }
- case 31:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "緊急";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "紧急";
- else
- ptyStr = "Emergency";
- break;
- }
- default:
- {
- ptyStr = "";
- //Log.e(FMRadio.LOGTAG, "Unknown RBDS ProgramType [" + pty + "]");
- break;
- }
- }
- return ptyStr;
- }
-
- /** get the Text String for the Program type Code */
- public static String getRDSPtyString(int pty)
- {
- String ptyStr = "";
- switch (pty)
- {
- case 1:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "新聞";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "新闻";
- else
- ptyStr = "News";
- break;
- }
- case 2:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "新聞時事";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "新闻时事";
- else
- ptyStr = "Current Affairs";
- break;
- }
- case 3:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "資訊";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "信息";
- else
- ptyStr = "Information";
- break;
- }
- case 4:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "體育";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "体育";
- else
- ptyStr = "Sport";
- break;
- }
- case 5:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "教育";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "教育";
- else
- ptyStr = "Education";
- break;
- }
- case 6:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "戲劇";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "戏剧";
- else
- ptyStr = "Drama";
- break;
- }
- case 7:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "文化";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "文化";
- else
- ptyStr = "Culture";
- break;
- }
- case 8:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "科學";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "科学";
- else
- ptyStr = "Science";
- break;
- }
- case 9:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "多樣化";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "变奏";
- else
- ptyStr = "Varied";
- break;
- }
- case 10:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "流行音樂";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "流行音乐";
- else
- ptyStr = "Pop Music";
- break;
- }
- case 11:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "搖滾樂";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "摇滚音乐";
- else
- ptyStr = "Rock Music";
- break;
- }
- case 12:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "輕音樂";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "轻音乐";
- else
- ptyStr = "Easy Listening Music";
- break;
- }
- case 13:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "輕古典音樂";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "轻古典音乐";
- else
- ptyStr = "Light classical";
- break;
- }
- case 14:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "正統古典";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "古典";
- else
- ptyStr = "Serious classical";
- break;
- }
- case 15:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "其他音樂";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "其他音乐";
- else
- ptyStr = "Other Music";
- break;
- }
- case 16:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "天氣";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "天气";
- else
- ptyStr = "Weather";
- break;
- }
- case 17:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "財政";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "经济";
- else
- ptyStr = "Finance";
- break;
- }
- case 18:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "少兒節目";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "儿童节目";
- else
- ptyStr = "Children programs";
- break;
- }
- case 19:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "社會事務";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "社会事务";
- else
- ptyStr = "Social Affairs";
- break;
- }
- case 20:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "宗教";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "宗教";
- else
- ptyStr = "Religion";
- break;
- }
- case 21:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "聽眾來得";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "听众来电";
- else
- ptyStr = "Phone In";
- break;
- }
- case 22:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "旅遊";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "旅行";
- else
- ptyStr = "Travel";
- break;
- }
- case 23:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "休閒";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "休闲";
- else
- ptyStr = "Leisure";
- break;
- }
- case 24:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "爵士樂";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "爵士音乐";
- else
- ptyStr = "Jazz Music";
- break;
- }
- case 25:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "鄉村音樂";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "乡村音乐";
- else
- ptyStr = "Country Music";
- break;
- }
- case 26:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "國樂";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "民族音乐";
- else
- ptyStr = "National Music";
- break;
- }
- case 27:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "懷舊金曲";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "怀旧";
- else
- ptyStr = "Oldies Music";
- break;
- }
- case 28:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "民俗音樂";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "民族音乐";
- else
- ptyStr = "Folk Music";
- break;
- }
- case 29:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "紀實";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "记录";
- else
- ptyStr = "Documentary";
- break;
- }
- case 30:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "緊急測試";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "紧急测试";
- else
- ptyStr = "Emergency Test";
- break;
- }
- case 31:
- {
- if (Locale.getDefault().toString().equals("zh_HK"))
- ptyStr = "緊急";
- else if (Locale.getDefault().toString().equals("zh_CN"))
- ptyStr = "紧急";
- else
- ptyStr = "Emergency";
- break;
- }
- default:
- {
- ptyStr = "";
- //Log.e(FMRadio.LOGTAG, "Unknown RDS ProgramType [" + pty + "]");
- break;
- }
- }
- return ptyStr;
+ int resid;
+ final int[][] typeCodes = { // RDS, RDBS
+ {0, 0},
+ {R.string.typ_News, R.string.typ_News},
+ {R.string.typ_Current_affairs, R.string.typ_Information},
+ {R.string.typ_Information, R.string.typ_Sports},
+ {R.string.typ_Sport, R.string.typ_Talk},
+ {R.string.typ_Education, R.string.typ_Rock},
+ {R.string.typ_Drama, R.string.typ_Classic_Rock},
+ {R.string.typ_Culture, R.string.typ_Adult_hits},
+ {R.string.typ_Science, R.string.typ_Soft_Rock},
+ {R.string.typ_Varied, R.string.typ_Top_40},
+ {R.string.typ_Pop, R.string.typ_Country},
+ {R.string.typ_Rock, R.string.typ_Oldies},
+ {R.string.typ_Easy_listening, R.string.typ_Soft},
+ {R.string.typ_Light_classical, R.string.typ_Nostalgia},
+ {R.string.typ_Serious_classical, R.string.typ_Jazz},
+ {R.string.typ_Other, R.string.typ_Classical},
+ {R.string.typ_Weather, R.string.typ_Rhythm_and_Blues},
+ {R.string.typ_Finance, R.string.typ_Soft_Rhythm_and_Blues},
+ {R.string.typ_Children, R.string.typ_Foreign_language},
+ {R.string.typ_Social_affairs, R.string.typ_Religious_music},
+ {R.string.typ_Religion, R.string.typ_Religious_talk},
+ {R.string.typ_Phone_in, R.string.typ_Personality},
+ {R.string.typ_Travel, R.string.typ_Public},
+ {R.string.typ_Leisure, R.string.typ_College},
+ {R.string.typ_Jazz, R.string.typ_Spanish_talk},
+ {R.string.typ_Country, R.string.typ_Spanish_music},
+ {R.string.typ_National, R.string.typ_Hiphop},
+ {R.string.typ_Oldies, 0},
+ {R.string.typ_Folk, 0},
+ {R.string.typ_Documentary, R.string.typ_Weather},
+ {R.string.typ_Emergency_test, R.string.typ_Emergency_test},
+ {R.string.typ_Emergency, R.string.typ_Emergency},
+ };
+ if (pty < 0 || pty >= typeCodes.length)
+ return ptyStr;
+ resid = typeCodes[pty][rdsStd == FmReceiver.FM_RDS_STD_RDS ? 0 : 1];
+ if (resid == 0)
+ return ptyStr;
+ String s = res.getString(resid);
+ return s;
}
-
-
}