Skip to content

Advanced dashboard configurations

Sarsa Murmu edited this page May 13, 2023 · 2 revisions

Advanced dashboard configurations

These configurations are optional. You would need basic programming knowledge to be able to configure these options.

How to configure it?

Open CandyBar.java inside app/src/main/java/.../application then you will see something like this (Note that all OneSignal related codes are omitted)

public class CandyBar extends CandyBarApplication {

  @NonNull
  @Override
  public Configuration onInit() {
      // Sample configuration
      Configuration configuration = new Configuration();

      configuration.setGenerateAppFilter(true);
      configuration.setGenerateAppMap(true);
      configuration.setGenerateThemeResources(true);

      return configuration;
  }

}

Here you can add any configuration that you like.

Configurations

Appearance

These configurations control the appearance of the app

  • setNavigationIcon(NavigationIcon): Change navigation icon (top left)
  • setNavigationViewHeaderStyle(NavigationViewHeaderStyle): Change navigation drawer header style
  • setHomeGridStyle(GridStyle): Change home grid style, card or flat
  • setApplyGridStyle(GridStyle): Change apply grid style, card or flat
  • setWallpapersGridStyle(GridStyle): Change wallpapers grid style, card or flat
  • setRequestStyle(Style): Change request style, card or flat
  • setAboutStyle(Style): Change about style, card or flat
  • setSocialIconColor(IconColor): Change icon color of social buttons that appears in About section
  • setShadowEnabled(boolean): Enable or disable shadow
  • setShadowEnabled(ShadowOptions): Use options for shadow, see here for more info
  • setDashboardThemingEnabled(boolean): Enable or disable dashboard theme. If disabled users would not be able to change dashboard theme from settings
  • setWallpaperGridPreviewQuality(int): Set wallpaper grid thumbnail preview quality
  • setColoredApplyCard(boolean): Enable or disable auto generated color for launchers card

Behavior

These configuration control the behavior of the app

  • setAutomaticIconsCountEnabled(boolean): Enable or disable automatic icons counting
  • setCustomIconsCount(int): Set custom number for icons count
  • setShowTabIconsCount(boolean): Show icons count in tab inside icons section
  • setShowTabAllIcons(boolean): Add tab showing all icons inside icons section
  • setTabAllIconsTitle(String): Set all icons tab title, default it "All Icons"
  • setCategoryForTabAllIcons(String[]): Set which category will be included inside all icons tab, default all categories will be included
  • setCrashReportEnabled(boolean): Enable or disable crash report
  • setWallpaperJsonStructure(JsonStructure): Use different json structure for cloud wallpapers, read here for more info
  • setOtherApps(OtherApp[]): Show more apps inside a dialog, see here for more info
  • setGenerateAppFilter(boolean): Generate appfilter.xml when building icon request
  • setGenerateAppMap(boolean): Generate appmap.xml when building icon request
  • setGenerateThemeResources(boolean): Generate theme_resources.xml when building icon request
  • setIncludeIconRequestToEmailBody(boolean): Include icon request text to email body
  • setEmailBodyGenerator(EmailBodyGenerator): Set custom generator for generating email bodies
  • setDonationLinks(DonationLink[]): Show donation links instead of play store in-app purchases
  • setConfigHandler(ConfigHandler): Set a handler that can control the loading of wallpaper or config JSON links
  • setAnalyticsHandler(AnalyticsHandler): Set a handler for uploading of analytics
  • setFilterRequestHandler(FilterRequestHandler): Set a handler for determining which app should be included in requests

Still confused?

Here is a sample configuration

public class CandyBar extends CandyBarApplication {

    @NonNull
    @Override
    public Configuration onInit() {
        Configuration configuration = new Configuration();

        configuration.setGenerateAppFilter(true);
        configuration.setGenerateAppMap(true);
        configuration.setGenerateThemeResources(true);

        configuration.setNavigationIcon(NavigationIcon.STYLE_4);
        configuration.setNavigationViewHeaderStyle(NavigationViewHeader.NONE);

        configuration.setHomeGridStyle(GridStyle.FLAT);
        configuration.setApplyGridStyle(GridStyle.FLAT);
        configuration.setWallpapersGridStyle(GridStyle.FLAT);
        configuration.setRequestStyle(Style.PORTRAIT_FLAT_LANDSCAPE_FLAT);
        configuration.setAboutStyle(Style.PORTRAIT_FLAT_LANDSCAPE_FLAT);

        configuration.setShowTabAllIcons(true);
        configuration.setCategoryForTabAllIcons(new String[] {
                "Games", "Apps"
        });

        return configuration;
    }
}

Show More Apps

You can show more apps inside a dialog that will show when the users press "More apps" cards in the home section.

Configuration configuration = new Configuration();
...
OtherApp[] otherApps = new OtherApp[] {
        new OtherApp(
                // You can use png file (without extension) inside drawable-nodpi folder or url
                "icon",
                "Title",
                "Description",
                "http://www.url.com"),
        new OtherApp(
                // You can use png file (without extension) inside drawable-nodpi folder or url
                "https://avatars1.githubusercontent.com/u/23138905?v=3&s=300",
                "Title",
                "Description, long description. This is an example of long description.",
                "https://play.google.com/store/apps/details?id=com.material.dashboard.candybar.demo")
};
configuration.setOtherApps(otherApps);

Donation Links

By default, the dashboard uses the play store in-app purchases for donation. But instead of this, you can also show a dialog with links to other donation options (like links to Ko-fi, PayPal, etc.). Here's how you would do it

Configuration configuration = new Configuration();
...
DonationLink[] donationLinks= new DonationLink[] {
        new DonationLink(
                // You can use png file (without extension) inside drawable-nodpi folder or url
                "icon",
                "Title",
                "Description",
                "http://www.url.com"),
        new DonationLink(
                // You can use png file (without extension) inside drawable-nodpi folder or url
                "ko_fi",
                "Ko-fi",
                "Donate me on Ko-fi",
                "https://ko-fi.com/someuser")
};
configuration.setDonationLinks(donationLinks);

Custom email body generator

configuration.setEmailBodyGenerator(requests -> {
    StringBuilder emailBody = new StringBuilder();
    
    for (Request request : requests) {
        emailBody.append("Name: ").append(request.getName()).append("\n");
        emailBody.append("Package Name: ").append(request.getPackageName()).append("\n");
        emailBody.append("\n\n");
    }
    
    return emailBody.toString();
});

Config handler

You can use this to change your links to wallpaper and config JSON. Use cases are A/B testing, firebase integration etc.

configuration.setConfigHandler(new Configuration.ConfigHandler() {
    @Override
    public String wallpaperJson(Context context) {
        // ... Code to return JSON link based on conditions
        
        // Return the default JSON
        return context.getResources().getString(R.string.wallpaper_json);
    }

    @Override
    public String configJson(Context context) {
        // ... Code to return JSON link based on conditions

        // Return the default JSON
        return context.getResources().getString(R.string.config_json);
    }
});

Analytics

Here is a sample configuration to use analytics with Firebase (By @moertel)

configuration.setAnalyticsHandler(new Configuration.AnalyticsHandler() {
    @Override
    public void logEvent(String eventName, HashMap<String, Object> params) {
        Bundle bundle = new Bundle();
        for (Map.Entry<String, Object> entry : params.entrySet()) {
            if (entry.getValue() instanceof String) {
                bundle.putString(entry.getKey(), (String) entry.getValue());
            } else if (entry.getValue() instanceof Integer) {
                bundle.putInt(entry.getKey(), (Integer) entry.getValue());
            }
        }
        mFirebaseAnalytics.logEvent(eventName, bundle);
    }
    @Override
    public void logException(Exception exception) {
        FirebaseCrashlytics.getInstance().recordException(exception);
    }
})

Filter icon request

Sometimes you want to exclude some apps from icon request. For example, if you want to exclude all webapks you can do something like this

configuration.setFilterRequestHandler((request) -> {
    // Return `true` to include the request
    // Return `false` to exclude the request
    
    String pkg = request.getPackageName();
    if (pkg == null) return true;
    return !(pkg.startsWith("org.chromium.webapk") || pkg.startsWith("com.sec.android.app.sbrowser.webapk"));
});

Shadow Options

You can use these options to disable or enable shadow.

Configuration configuration = new Configuration();
...
ShadowOptions options = new ShadowOptions();
// Enable or disable toolbar shadow
options.setToolbarEnabled(true);
// Enable or disable card shadow
options.setCardEnabled(false);
// Enable or disable floating action button shadow
options.setFabEnabled(true);
// Enable or disable tap intro shadow
options.setTapIntroEnabled(true);

// Don't forget to pass it to configuration
configuration.setShadowEnabled(options);
Clone this wiki locally