Advertisement
Guest User

NPConfig.java

a guest
May 13th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.77 KB | None | 0 0
  1. /**
  2. * Generated by smali2java 1.0.0.558
  3. * Copyright (C) 2013 Hensence.com
  4. */
  5.  
  6. package com.nubee.platform.config;
  7.  
  8. import android.graphics.drawable.Drawable;
  9. import android.content.Context;
  10. import android.content.SharedPreferences;
  11. import com.nubee.platform.NubeePlatform;
  12. import android.content.res.Resources;
  13. import android.graphics.drawable.BitmapDrawable;
  14. import android.content.pm.PackageManager;
  15. import android.content.pm.PackageInfo;
  16. import android.os.Build;
  17. import com.nubee.platform.NPLog;
  18.  
  19. public class NPConfig {
  20. private static final String COMMON_SERVER_URL_DEVELOPMENT = "http://nbpf-stg-common.s3.amazonaws.com/public/";
  21. private static final String COMMON_SERVER_URL_LIVE = "http://d2tio84stn3klc.cloudfront.net/public/";
  22. private static final String COMMON_SERVER_URL_STAGING = "http://nbpf-stg-common.s3.amazonaws.com/public/";
  23. private static final String FAQ_SERVER_URL_DEVELOPMENT = "http://nbpf-stg-faq.nbpf.nubee.com/public/";
  24. private static final String FAQ_SERVER_URL_LIVE = "http://nbpf-pro-faq.nbpf.nubee.com/public/";
  25. private static final String FAQ_SERVER_URL_STAGING = "http://nbpf-stg-faq.nbpf.nubee.com/public/";
  26. public static final String FAQ_VERSION = "001";
  27. public static final String GAME_LIST_VERSION = "001";
  28. private static final String NEW_SERVER_URL_DEVELOPMENT = "https://st-%s-connect.nubee.com/";
  29. private static final String NEW_SERVER_URL_LIVE = "https://%s-connect.nubee.com/";
  30. private static final String NEW_SERVER_URL_STAGING = "https://st-%s-connect.nubee.com/";
  31. private static final String OLD_SERVER_URL_DEVELOPMENT = "https://dev-nbpf.nubee.com/";
  32. private static final String OLD_SERVER_URL_LIVE = "https://connect.nubee.com/";
  33. private static final String OLD_SERVER_URL_STAGING = "https://st-nbpf.nubee.com/";
  34. private static final String PARAM_NAME_APP_ID = "APP_ID";
  35. private static final String PARAM_NAME_BACKGROUND_DRAWABLE_ID = "BACKGROUND_DRAWABLE_ID";
  36. private static final String PARAM_NAME_GCM_ACTIVITY_CLASS_NAME = "GCM_ACTIVITY_CLASS_NAME";
  37. private static final String PARAM_NAME_GCM_LARGE_ICON_ID = "GCM_LARGE_ICON_ID";
  38. private static final String PARAM_NAME_GCM_SENDER_ID = "GCM_SENDER_ID";
  39. private static final String PARAM_NAME_GCM_SMALL_ICON_ID = "GCM_ICON_ID";
  40. private static final String PARAM_NAME_GCM_TITLE_ID = "GCM_TITLE_ID";
  41. private static final String PARAM_NAME_HASHSALT = "HASHSALT";
  42. private static final String PARAM_NAME_IS_DEBUG = "IS_DEBUG";
  43. private static final String PARAM_NAME_LOGGING_LEVEL = "LOGGING_LEVEL";
  44. private static final String PARAM_NAME_LOG_TAG = "LOG_TAG";
  45. private static final String PREF_FILE_NAME = "CONFIG";
  46. public static final String SDK_VERSION = "2.1.5";
  47. private String mServerUrlDevelopment;
  48. private String mServerUrlLive;
  49. private String mServerUrlStaging;
  50.  
  51. public final String getServerUrl(int serverType) {
  52. switch(serverType) {
  53. case 0:
  54. {
  55. return mServerUrlDevelopment;
  56. }
  57. case 1:
  58. {
  59. return mServerUrlStaging;
  60. }
  61. case 2:
  62. {
  63. return mServerUrlLive;
  64. }
  65. }
  66. return mServerUrlLive;
  67. }
  68.  
  69. private void setupServerUrl() {
  70. if(mUseOldServerUrl) {
  71. mServerUrlDevelopment = "https://dev-nbpf.nubee.com/";
  72. mServerUrlStaging = "https://st-nbpf.nubee.com/";
  73. mServerUrlLive = "https://connect.nubee.com/";
  74. return;
  75. }
  76. mServerUrlDevelopment = String.format("https://st-%s-connect.nubee.com/", mAppId);
  77. mServerUrlStaging = String.format("https://st-%s-connect.nubee.com/", mAppId, mAppId);
  78. mServerUrlLive = String.format("https://%s-connect.nubee.com/", mAppId, mAppId, mAppId);
  79. }
  80.  
  81. public final String getFaqServerUrl(int serverType) {
  82. switch(serverType) {
  83. case 0:
  84. {
  85. return "http://nbpf-stg-faq.nbpf.nubee.com/public/";
  86. }
  87. case 1:
  88. {
  89. return "http://nbpf-stg-faq.nbpf.nubee.com/public/";
  90. }
  91. case 2:
  92. {
  93. return "http://nbpf-pro-faq.nbpf.nubee.com/public/";
  94. }
  95. }
  96. return "http://nbpf-pro-faq.nbpf.nubee.com/public/";
  97. }
  98.  
  99. public final String getCommonServerUrl(int serverType) {
  100. switch(serverType) {
  101. case 0:
  102. {
  103. return "http://nbpf-stg-common.s3.amazonaws.com/public/";
  104. }
  105. case 1:
  106. {
  107. return "http://nbpf-stg-common.s3.amazonaws.com/public/";
  108. }
  109. case 2:
  110. {
  111. return "http://d2tio84stn3klc.cloudfront.net/public/";
  112. }
  113. }
  114. return "http://nbpf-pro-faq.nbpf.nubee.com/public/";
  115. }
  116. protected String mAppId = 0x0;
  117. protected String mHashSalt = 0x0;
  118. protected int mBackgroundDrawableId = 0x0;
  119. protected Drawable mBackgroundDrawable = 0x0;
  120. private static String mUserAgent = 0x0;
  121. private boolean mUseOldServerUrl = false;
  122.  
  123. public NPConfig(String appId, String hashSalt) {
  124. mAppId = appId;
  125. mHashSalt = hashSalt;
  126. setupServerUrl();
  127. }
  128.  
  129. public NPConfig(String appId, String hashSalt, boolean useOldServerUrl) {
  130. mAppId = appId;
  131. mHashSalt = hashSalt;
  132. mUseOldServerUrl = useOldServerUrl;
  133. setupServerUrl();
  134. }
  135.  
  136. public String getAppId() {
  137. return mAppId;
  138. }
  139.  
  140. public String getHashSalt() {
  141. return mHashSalt;
  142. }
  143.  
  144. public NPConfig setBackgroundDrawable(Drawable drawable) {
  145. mBackgroundDrawable = drawable;
  146. return this;
  147. }
  148.  
  149. public NPConfig setBackgroundDrawableId(int drawableId) {
  150. mBackgroundDrawableId = drawableId;
  151. return this;
  152. }
  153.  
  154. public Drawable getBackgroundDrawable(Context context) {
  155. if(mBackgroundDrawable != null) {
  156. return mBackgroundDrawable;
  157. }
  158. if(mBackgroundDrawableId > 0) {
  159. return (BitmapDrawable)context.getResources().getDrawable(mBackgroundDrawableId);
  160. }
  161. return null;
  162. }
  163.  
  164. public final NPConst.StoreType getStoreType() {
  165. return NPConstStore.STORE_TYPE;
  166. }
  167.  
  168. public final String getUserAgent(Context context) {
  169. // :( Parsing error. Please contact me.
  170. }
  171.  
  172. public final String getUserAgent() {
  173. return mUserAgent;
  174. }
  175. protected String mBase64EncodedPublicKey = 0x0;
  176.  
  177. public NPConfig setupInAppBilling(String base64EncodedPublickey) {
  178. mBase64EncodedPublicKey = base64EncodedPublickey;
  179. return this;
  180. }
  181.  
  182. public String getBase64EncodedPublicKey() {
  183. return mBase64EncodedPublicKey;
  184. }
  185. protected String mGcmSenderId = 0x0;
  186.  
  187. public NPConfig setupGCM(String senderId, String activityClassName, int iconId, int titleId) {
  188. mGcmSenderId = senderId;
  189. mNotificationActivityClassName = activityClassName;
  190. mNotificationSmallIconId = iconId;
  191. mNotificationLargeIconId = 0x0;
  192. mNotificationTitleId = titleId;
  193. return this;
  194. }
  195.  
  196. public NPConfig setupGCM(String senderId, String activityClassName, int smallIconId, int largeIconId, int titleId) {
  197. mGcmSenderId = senderId;
  198. mNotificationActivityClassName = activityClassName;
  199. mNotificationSmallIconId = smallIconId;
  200. mNotificationLargeIconId = largeIconId;
  201. mNotificationTitleId = titleId;
  202. return this;
  203. }
  204.  
  205. public String getGcmSenderId() {
  206. return mGcmSenderId;
  207. }
  208. protected boolean mEnableGameList = false;
  209.  
  210. public NPConfig setEnableGameList(boolean enableGameList) {
  211. mEnableGameList = enableGameList;
  212. return this;
  213. }
  214.  
  215. public boolean isEnableGameList() {
  216. return mEnableGameList;
  217. }
  218. protected boolean mEnableFaqCommon = true;
  219.  
  220. public NPConfig setEnableFaqCommon(boolean enableFaqCommon) {
  221. mEnableFaqCommon = enableFaqCommon;
  222. return this;
  223. }
  224.  
  225. public boolean isEnableFaqCommon() {
  226. return mEnableFaqCommon;
  227. }
  228. protected String mNotificationActivityClassName = 0x0;
  229. protected int mNotificationSmallIconId = 0x0;
  230. protected int mNotificationLargeIconId = 0x0;
  231. protected int mNotificationTitleId = 0x0;
  232.  
  233. public NPConfig setupNotification(String activityClassName, int iconId, int titleId) {
  234. mNotificationActivityClassName = activityClassName;
  235. mNotificationSmallIconId = iconId;
  236. mNotificationLargeIconId = 0x0;
  237. mNotificationTitleId = titleId;
  238. return this;
  239. }
  240.  
  241. public NPConfig setupNotification(String activityClassName, int smallIconId, int largeIconId, int titleId) {
  242. mNotificationActivityClassName = activityClassName;
  243. mNotificationSmallIconId = smallIconId;
  244. mNotificationLargeIconId = largeIconId;
  245. mNotificationTitleId = titleId;
  246. return this;
  247. }
  248.  
  249. public String getNotificationActivityClassName() {
  250. return mNotificationActivityClassName;
  251. }
  252.  
  253. public int getNotificationSmallIcon() {
  254. return mNotificationSmallIconId;
  255. }
  256.  
  257. public int getNotificationLargeIcon() {
  258. return mNotificationLargeIconId;
  259. }
  260.  
  261. public String getNotificationTitle(Context context) {
  262. if(mNotificationTitleId > 0) {
  263. return context.getString(mNotificationTitleId);
  264. }
  265. return null;
  266. }
  267. protected String mLogTag = "Platform";
  268. protected boolean mIsDebug = false;
  269. protected NPConfig.ELOGGING_LEVEL mLoggingLevel = NPConfig.ELOGGING_LEVEL.ELOGGING_NONE;
  270. protected NPConfig.ELOGGING_LEVEL mCustomLoggingLevel = 0x0;
  271.  
  272. public NPConfig setLoggingLevel(NPConfig.ELOGGING_LEVEL loggingLevel) {
  273. mCustomLoggingLevel = loggingLevel;
  274. mLoggingLevel = mCustomLoggingLevel;
  275. return this;
  276. }
  277.  
  278. public NPConfig.ELOGGING_LEVEL getLoggingLevel() {
  279. return mLoggingLevel;
  280. }
  281.  
  282. public NPConfig setLogTag(String tag) {
  283. mLogTag = tag;
  284. return this;
  285. }
  286.  
  287. public String getLogTag() {
  288. return mLogTag;
  289. }
  290.  
  291. public NPConfig setDebug(boolean debug) {
  292. mIsDebug = debug;
  293. if(mCustomLoggingLevel == null) {
  294. if(mIsDebug) {
  295. mLoggingLevel = NPConfig.ELOGGING_LEVEL.ELOGGING_VERBOSE;
  296. return this;
  297. }
  298. mLoggingLevel = NPConfig.ELOGGING_LEVEL.ELOGGING_NONE;
  299. }
  300. return this;
  301. }
  302.  
  303. public boolean isDebug() {
  304. return mIsDebug;
  305. }
  306.  
  307. public void saveToPreference(Context context) {
  308. SharedPreferences pref = context.getSharedPreferences("CONFIG", 0x0);
  309. SharedPreferences.Editor editor = pref.edit();
  310. editor.putString("GCM_ACTIVITY_CLASS_NAME", mNotificationActivityClassName);
  311. editor.putInt("GCM_ICON_ID", mNotificationSmallIconId);
  312. editor.putInt("GCM_LARGE_ICON_ID", mNotificationLargeIconId);
  313. editor.putInt("GCM_TITLE_ID", mNotificationTitleId);
  314. editor.commit();
  315. NPLog.d("Platform", "NPConfig.saveToPreference");
  316. }
  317.  
  318. public static NPConfig createNPConfigFromPreference(Context context) {
  319. // :( Parsing error. Please contact me.
  320. }
  321.  
  322. public static NPConfig sharedInstanceForService(Context context) {
  323. NPConfig config = NubeePlatform.getConfig();
  324. if(config == null) {
  325. config = createNPConfigFromPreference(context);
  326. }
  327. return config;
  328. }
  329. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement