Configuration of the Anti-Malware UI for Android

Anti-Malware component for the Android platform can display UI to alert the user about the threat. The UI can be styled so it fits the theme of your app. To properly customize the Malwarelytics Anti-Malware UI, you will need to set the following properties of the tag in the `malwarelytics.xml` file.

<malwarelytics>
    <android>
        <ui
            resourcesFolder="./malwarelytics_resources"
            theme="R.style.CustomAppTheme"
            notificationIcon="R.mipmap.ic_launcher"
            settingsIcon="R.drawable.custom_av_settings_outline"
            deleteIcon="R.drawable.custom_av_delete_outline"
        />
    </android>
</malwarelytics>
  • resourcesFolder is a relative path to a folder. Content of this folder will be copied inside the app resource folder (platforms/android/app/src/main/res). This can be used for adding custom theme file or localization files.
  • theme is a resource reference to your theme. For more information on styling see Styling Threat Screen.
  • notificationIcon is a resource reference to an icon that will be displayed in Malwarelytics notifications. You can use R.mipmap.ic_launcher to reuse your app icon.
  • settingsIcon is a resource reference to a drawable that will be displayed as an uninstall button in Malwarelytics UI. (For example R.drawable.custom_av_settings_outline).
  • deleteIcon is a resource reference to a drawable that will be displayed as a delete button in Malwarelytics UI. (For example R.drawable.custom_av_delete_outline).

Styling Threat Screen

The threat screen can be styled by setting the custom theme for the activity and by changing icons for the image buttons on the screen.

There are two icons. Delete icon and settings icon. The delete icon serves as a button requesting app uninstall (for apps that can be uninstalled). Settings icon serves for button opening app’s detail in system settings (for apps that cannot be uninstalled) where users can disable the app.

The theme for the screen should contain standard Android attributes and can contain a couple of extra attributes defined by the Malwarelytics for Android SDK.

We recommend deriving the theme from AppCompat themes. The usage of ActionBar on the screen is derived from the theme. Use NoActionBar version of the theme for design without the ActionBar (which contains the app name). Alternatively, you can hide the ActionBar by adding

<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>

to your theme.

Following is an example of such a theme.

<resources>
    <style name="CustomAppTheme" parent="Theme.AppCompat.NoActionBar">
        <item name="colorPrimary">#FF0000</item>
        <item name="colorPrimaryDark">#222222</item>
        <item name="colorAccent">#FF0000</item>

        <item name="titleTextColor">@android:color/black</item>

        <!-- <item name="android:windowBackground">@drawable/img_bg_app</item> -->

        <!-- <item name="android:fontFamily">@font/font_family_roboto</item>
        <item name="fontFamily">@font/font_family_roboto</item> -->

        <!-- <item name="buttonStyle">@style/CustomAppTheme.Button.Filled</item> -->
        <item name="imageButtonStyle">@style/CustomAppTheme.ImageButton.Borderless</item>

        <item name="wultra_av_threatTitleTextAppearance">@style/CustomAppTheme.TextAppearance.Title</item>
        <item name="wultra_av_threatTitleStyle">@style/CustomAppTheme.TextView.Title</item>
        <item name="wultra_av_threatDescriptionTextAppearance">@style/CustomAppTheme.TextAppearance.Description</item>
        <item name="wultra_av_threatDescriptionStyle">@style/CustomAppTheme.TextView.Description</item>
        <item name="wultra_av_threatProtipTextAppearance">@style/CustomAppTheme.TextAppearance.Description</item>
        <item name="wultra_av_threatProtipStyle">@style/CustomAppTheme.TextView.Description</item>
        <item name="wultra_av_threatAppNameTextAppearance">@style/CustomAppTheme.AppName.TextAppearance</item>
        <item name="wultra_av_threatPackageNameTextAppearance">@style/CustomAppTheme.TextAppearance.PackageName</item>
    </style>

    <style name="CustomAppTheme.TextAppearance.Button" parent="TextAppearance.AppCompat.Button">
        <item name="android:textColor">@android:color/black</item>
        <item name="android:textSize">19.2sp</item>
        <item name="android:textStyle">bold</item>
    </style>

    <style name="CustomAppTheme.Button.Filled" parent="Widget.AppCompat.Button">
        <item name="android:textAppearance">@style/CustomAppTheme.TextAppearance.Button</item>
        <item name="android:textAllCaps">false</item>
        <!-- <item name="android:background">@drawable/bg_button_filled</item> -->
    </style>

    <style name="CustomAppTheme.ImageButton.Borderless" parent="Widget.AppCompat.ImageButton">
        <!-- <item name="android:background">@drawable/bg_button_borderless</item> -->
    </style>

    <style name="CustomAppTheme.TextView"/>

    <style name="CustomAppTheme.TextView.Title">
        <item name="android:gravity">center</item>
    </style>

    <style name="CustomAppTheme.TextAppearance.Title" parent="TextAppearance.AppCompat.Title">
        <item name="android:textColor">#FF0000</item>
    </style>

    <style name="CustomAppTheme.TextView.Description">
        <item name="android:gravity">center</item>
    </style>

    <style name="CustomAppTheme.AppName.TextAppearance" parent="TextAppearance.AppCompat.Title">
        <item name="android:textAllCaps">false</item>
        <item name="android:textSize">16sp</item>
    </style>

    <style name="CustomAppTheme.TextAppearance.Description" parent="TextAppearance.AppCompat.Medium">
        <item name="android:textColor">@android:color/white</item>
        <item name="android:textSize">16.8sp</item>
    </style>
    <style name="CustomAppTheme.TextAppearance.PackageName" parent="TextAppearance.AppCompat.Title">
        <item name="android:textSize">@dimen/custom_text_size_small</item>
        <item name="android:textColor">@color/customWhite</item>
        <item name="android:fontFamily">sans-serif</item>
        <item name="fontFamily">sans-serif</item>
    </style>
</resources>
Last updated on Sep 21, 2023 (16:46) Edit on Github Send Feedback
Search

5.2.x

Malwarelytics for Cordova