Package com.swrve.sdk

Class SwrveHelper


  • public final class SwrveHelper
    extends java.lang.Object
    Used internally to provide MD5, token generation and other helper methods.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static java.lang.String buildModel  
    • Constructor Summary

      Constructors 
      Constructor Description
      SwrveHelper()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Date addTimeInterval​(java.util.Date origin, int value, int unit)  
      static java.util.Map<java.lang.String,​java.lang.String> combineTwoStringMaps​(java.util.Map<java.lang.String,​java.lang.String> baseMap, java.util.Map<java.lang.String,​java.lang.String> overridingMap)  
      static org.json.JSONObject convertPayloadToJSONObject​(android.os.Bundle bundle)  
      static float convertPixelsToDp​(float px, android.content.Context context)  
      static java.lang.String createHMACWithMD5​(java.lang.String source, java.lang.String key)  
      static java.lang.String encodeParameters​(java.util.Map<java.lang.String,​java.lang.String> params)  
      static java.lang.String generateSessionToken​(java.lang.String apiKey, int appId, java.lang.String userId)  
      static java.lang.String getAppInstallTime​(android.content.Context context)  
      static java.util.Map<java.lang.String,​java.lang.String> getBundleAsMap​(android.os.Bundle propertyBundle)  
      static int getDisplayHeight​(android.content.Context context)  
      static int getDisplayWidth​(android.content.Context context)  
      static java.lang.String getPlatformDeviceType​(android.content.Context context)  
      static java.lang.String getPlatformOS​(android.content.Context context)  
      static java.lang.String getPlatformOS​(android.content.Context context, SwrveFlavour sdkFlavour)  
      static java.lang.String getRemotePushId​(android.os.Bundle msg)  
      static java.lang.String getSilentPushId​(android.os.Bundle msg)  
      static com.swrve.sdk.ISwrveCommon.SupportedUIMode getSupportedUIMode​(android.content.Context context)  
      static int getTargetSdkVersion​(android.content.Context context)  
      static float getTextSizeToFitImage​(android.graphics.Paint paint, java.lang.String text, int width, int height)  
      static boolean hasFileAccess​(java.lang.String filePath)  
      static boolean isMobile​(android.content.Context context)  
      static boolean isNotNullOrEmpty​(java.lang.String val)  
      static boolean isNullOrEmpty​(java.lang.String val)  
      static boolean isNullOrEmpty​(java.util.Map<java.lang.String,​java.lang.String> val)  
      static boolean isSwrvePush​(android.os.Bundle msg)  
      static java.util.Map<java.lang.String,​java.lang.String> JSONToMap​(org.json.JSONObject obj)  
      static void logAndThrowException​(java.lang.String reason)  
      static java.lang.String md5​(java.lang.String text)  
      static java.lang.String readStringFromInputStream​(java.io.InputStream is)  
      static boolean sdkAvailable()  
      static boolean sdkAvailable​(java.util.List<java.lang.String> modelBlackList)  
      static boolean serverErrorResponseCode​(int responseCode)  
      static java.lang.String sha1​(byte[] bytesOfMessage)  
      static boolean successResponseCode​(int responseCode)  
      static java.lang.String toLanguageTag​(java.util.Locale locale)  
      static boolean userErrorResponseCode​(int responseCode)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • buildModel

        protected static java.lang.String buildModel
    • Constructor Detail

      • SwrveHelper

        public SwrveHelper()
    • Method Detail

      • isNullOrEmpty

        public static boolean isNullOrEmpty​(java.lang.String val)
      • isNotNullOrEmpty

        public static boolean isNotNullOrEmpty​(java.lang.String val)
      • isNullOrEmpty

        public static boolean isNullOrEmpty​(java.util.Map<java.lang.String,​java.lang.String> val)
      • generateSessionToken

        public static java.lang.String generateSessionToken​(java.lang.String apiKey,
                                                            int appId,
                                                            java.lang.String userId)
      • toLanguageTag

        public static java.lang.String toLanguageTag​(java.util.Locale locale)
      • md5

        public static java.lang.String md5​(java.lang.String text)
      • sha1

        public static java.lang.String sha1​(byte[] bytesOfMessage)
      • JSONToMap

        public static java.util.Map<java.lang.String,​java.lang.String> JSONToMap​(org.json.JSONObject obj)
                                                                                throws org.json.JSONException
        Throws:
        org.json.JSONException
      • encodeParameters

        public static java.lang.String encodeParameters​(java.util.Map<java.lang.String,​java.lang.String> params)
                                                 throws java.io.UnsupportedEncodingException
        Throws:
        java.io.UnsupportedEncodingException
      • getDisplayWidth

        public static int getDisplayWidth​(android.content.Context context)
      • getDisplayHeight

        public static int getDisplayHeight​(android.content.Context context)
      • userErrorResponseCode

        public static boolean userErrorResponseCode​(int responseCode)
      • successResponseCode

        public static boolean successResponseCode​(int responseCode)
      • serverErrorResponseCode

        public static boolean serverErrorResponseCode​(int responseCode)
      • logAndThrowException

        public static void logAndThrowException​(java.lang.String reason)
                                         throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • addTimeInterval

        public static java.util.Date addTimeInterval​(java.util.Date origin,
                                                     int value,
                                                     int unit)
      • readStringFromInputStream

        public static java.lang.String readStringFromInputStream​(java.io.InputStream is)
                                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • createHMACWithMD5

        public static java.lang.String createHMACWithMD5​(java.lang.String source,
                                                         java.lang.String key)
                                                  throws java.security.NoSuchAlgorithmException,
                                                         java.security.InvalidKeyException
        Throws:
        java.security.NoSuchAlgorithmException
        java.security.InvalidKeyException
      • sdkAvailable

        public static boolean sdkAvailable()
      • sdkAvailable

        public static boolean sdkAvailable​(java.util.List<java.lang.String> modelBlackList)
      • hasFileAccess

        public static boolean hasFileAccess​(java.lang.String filePath)
      • getTargetSdkVersion

        public static int getTargetSdkVersion​(android.content.Context context)
      • getPlatformDeviceType

        public static java.lang.String getPlatformDeviceType​(android.content.Context context)
      • getPlatformOS

        public static java.lang.String getPlatformOS​(android.content.Context context)
      • getPlatformOS

        public static java.lang.String getPlatformOS​(android.content.Context context,
                                                     SwrveFlavour sdkFlavour)
      • getSupportedUIMode

        public static com.swrve.sdk.ISwrveCommon.SupportedUIMode getSupportedUIMode​(android.content.Context context)
      • isMobile

        public static boolean isMobile​(android.content.Context context)
      • isSwrvePush

        public static boolean isSwrvePush​(android.os.Bundle msg)
      • getRemotePushId

        public static java.lang.String getRemotePushId​(android.os.Bundle msg)
      • getSilentPushId

        public static java.lang.String getSilentPushId​(android.os.Bundle msg)
      • getBundleAsMap

        public static java.util.Map<java.lang.String,​java.lang.String> getBundleAsMap​(android.os.Bundle propertyBundle)
      • getAppInstallTime

        public static java.lang.String getAppInstallTime​(android.content.Context context)
      • convertPayloadToJSONObject

        public static org.json.JSONObject convertPayloadToJSONObject​(android.os.Bundle bundle)
      • combineTwoStringMaps

        public static java.util.Map<java.lang.String,​java.lang.String> combineTwoStringMaps​(java.util.Map<java.lang.String,​java.lang.String> baseMap,
                                                                                                  java.util.Map<java.lang.String,​java.lang.String> overridingMap)
      • getTextSizeToFitImage

        public static float getTextSizeToFitImage​(android.graphics.Paint paint,
                                                  java.lang.String text,
                                                  int width,
                                                  int height)
      • convertPixelsToDp

        public static float convertPixelsToDp​(float px,
                                              android.content.Context context)