public class

ChanConfiguration

extends Object
java.lang.Object
   ↳ chan.content.ChanConfiguration

Class Overview

Provides extension configuration.

During construction you can enable the following options using request(String) method:

Static configuration

This configuration remains in RAM only while client is launched. You must configure these settings during construction.

You can configure poster's default name using setDefaultName(String) and setDefaultName(String, String).

You can configure board title and description using setBoardTitle(String, String) and setBoardDescription(String, String).

You can configure bump limit using setBumpLimit(int) and setBumpLimit(String, int). You can change bump limit mode using setBumpLimitMode(BumpLimitMode).

You can configure pages count using setPagesCount(String, int).

You can add supported captchas using addCaptchaType(String).

Dynamic configuration

This configuration can be written to client's preferences and read every time client launches.

You can store poster's default name using storeDefaultName(String, String).

You can store board title and description using storeBoardTitle(String, String) and storeBoardDescription(String, String).

You can store bump limit using storeBumpLimit(String, int).

You can store pages count using storePagesCount(String, int).

You can store any another properties using set(String, String, boolean), set(String, String, int) and set(String, String, String) methods.

You can get stored properties using get(String, String, boolean), get(String, String, int) and get(String, String, String) methods.

Additional features

You can store cookies using storeCookie(String, String, String). Later you can get it using getCookie(String). User can clear cookies in application preferences.

You can get chan's resources using getResources().

You can add additional preferences to chan preferences screen using addCustomPreference(String, boolean) and obtainCustomPreferenceConfiguration(String).

Configuring actions

You can configure board features using obtainBoardConfiguration(String).

You can configure custom captcha using obtainCustomCaptchaConfiguration(String).

You can configure posting using obtainPostingConfiguration(String, boolean).

You can configure deleting using obtainDeletingConfiguration(String).

You can configure reporting using obtainReportingConfiguration(String).

You can configure captcha pass using obtainCaptchaPassConfiguration().

You can configure authorization using obtainUserAuthorizationConfiguration().

You can configure archivation using obtainArchivationConfiguration().

You can configure displayed statistics data using obtainStatisticsConfiguration().

You can configure custom preferences using obtainStatisticsConfiguration().

Summary

Nested Classes
class ChanConfiguration.Archivation

Archivation configuration holder. 

class ChanConfiguration.Authorization

Authorization configuration holder. 

class ChanConfiguration.Board

Board configuration holder. 

enum ChanConfiguration.BumpLimitMode

Mode of bump limit handling. 

class ChanConfiguration.Captcha

Captcha configuration holder. 

class ChanConfiguration.CustomPreference

Custom preference configuration holder. 

class ChanConfiguration.Deleting

Deleting configuration holder. 

class ChanConfiguration.Posting

Posting configuration holder. 

class ChanConfiguration.Reporting

Reporting configuration holder. 

class ChanConfiguration.Statistics

Statistics configuration holder. 

Fields
public static final String CAPTCHA_TYPE_MAILRU
public static final String CAPTCHA_TYPE_RECAPTCHA_1
public static final String CAPTCHA_TYPE_RECAPTCHA_2
public static final String OPTION_ALLOW_CAPTCHA_PASS

Allows user to enter authorization data and skip the captcha.

public static final String OPTION_ALLOW_USER_AUTHORIZATION

Allows user to enter authorization data to access some features.

public static final String OPTION_READ_POSTS_COUNT

Allows client to download posts count in thread.

public static final String OPTION_READ_SINGLE_POST

Allows client to download single post knowing it's board name and post number.

public static final String OPTION_READ_THREAD_PARTIALLY

Allows client to download thread partially.

public static final String OPTION_READ_USER_BOARDS

Allows client to download user boards.

public static final String OPTION_SINGLE_BOARD_MODE

Allows client to use only one board.

Public Constructors
ChanConfiguration()
Public Methods
final void addCaptchaType(String captchaType)

Add captcha type to list of supported capthas.

final void addCustomPreference(String key, boolean defaultValue)

Add custom preference to chan preferences screen.

static <T extends ChanConfiguration> T get(Object object)

Return linked ChanConfiguration instance.

final String get(String boardName, String key, String defaultValue)

Returns stored string value.

final int get(String boardName, String key, int defaultValue)

Returns stored int value.

final boolean get(String boardName, String key, boolean defaultValue)

Returns stored boolean value.

final Context getContext()

Returns application context.

final String getCookie(String cookie)

Returns stored cookie.

final File getDownloadDirectory()

Returns download directory.

final Resources getResources()

Returns resources from chan APK file.

final String getTitle()

Returns a chan title.

final String[] getUserAuthorizationData()

Returns user authorization data.

ChanConfiguration.Archivation obtainArchivationConfiguration()

Calls every time client requests archivation configuration.

ChanConfiguration.Board obtainBoardConfiguration(String boardName)

Calls every time client requests board configuration.

ChanConfiguration.Authorization obtainCaptchaPassConfiguration()

Calls every time client requests captcha pass configuration.

ChanConfiguration.Captcha obtainCustomCaptchaConfiguration(String captchaType)

Calls every time client requests custom captcha configuration.

ChanConfiguration.CustomPreference obtainCustomPreferenceConfiguration(String key)

Calls every time client requests custom captcha configuration.

ChanConfiguration.Deleting obtainDeletingConfiguration(String boardName)

Calls every time client requests deleting configuration.

ChanConfiguration.Posting obtainPostingConfiguration(String boardName, boolean newThread)

Calls every time client requests posting configuration.

ChanConfiguration.Reporting obtainReportingConfiguration(String boardName)

Calls every time client requests reporting configuration.

ChanConfiguration.Statistics obtainStatisticsConfiguration()

Calls every time client requests statistics configuration.

ChanConfiguration.Authorization obtainUserAuthorizationConfiguration()

Calls every time client requests user authorization configuration.

final void request(String option)

Requests option.

final void set(String boardName, String key, boolean value)

Stores boolean value.

final void set(String boardName, String key, int value)

Stores int value.

final void set(String boardName, String key, String value)

Stores string value.

final void setBoardDescription(String boardName, String description)

Set description for board with given boardName.

final void setBoardTitle(String boardName, String title)

Set title for board with given boardName.

final void setBumpLimit(int bumpLimit)

Set bumpLimit for all boards.

final void setBumpLimit(String boardName, int bumpLimit)

Set bumpLimit for specified boardName.

final void setBumpLimitMode(ChanConfiguration.BumpLimitMode mode)
final void setDefaultName(String defaultName)

Set poster's defaultName for all boards.

final void setDefaultName(String boardName, String defaultName)

Set poster's defaultName for specified boardName.

final void setPagesCount(String boardName, int pagesCount)

Set pagesCount for boardName.

final void setSingleBoardName(String boardName)

Set boardName argument for all requests when OPTION_SINGLE_BOARD_MODE enabled.

final void storeBoardDescription(String boardName, String description)

Store description for board with given boardName.

final void storeBoardTitle(String boardName, String title)

Store title for board with given boardName.

final void storeBumpLimit(String boardName, int bumpLimit)

Store bumpLimit for specified boardName.

final void storeCookie(String cookie, String value, String displayName)

Stores cookie.

final void storeDefaultName(String boardName, String defaultName)

Store poster's defaultName for specified boardName.

final void storePagesCount(String boardName, int pagesCount)

Store pagesCount for boardName.

[Expand]
Inherited Methods
From class java.lang.Object

Fields

public static final String CAPTCHA_TYPE_MAILRU

public static final String CAPTCHA_TYPE_RECAPTCHA_1

public static final String CAPTCHA_TYPE_RECAPTCHA_2

public static final String OPTION_ALLOW_CAPTCHA_PASS

Allows user to enter authorization data and skip the captcha. With entered data you will receive captchaPass argument. You can perform authorization and save cookies or another data that represents authorization state. Then you can use them to skip captcha.

If you enable this option, you must implement onCheckAuthorization(chan.content.ChanPerformer.CheckAuthorizationData).

You should also implement obtainCaptchaPassConfiguration().

See also:

public static final String OPTION_ALLOW_USER_AUTHORIZATION

Allows user to enter authorization data to access some features. You can obtain authorization data using getUserAuthorizationData(). With this data you can perform authorization and save cookies or another data that represents authorization state. Then you can grant user rights to read some threads or something like this.

If you enable this option, you must implement onCheckAuthorization(chan.content.ChanPerformer.CheckAuthorizationData).

You should also implement obtainUserAuthorizationConfiguration().

public static final String OPTION_READ_POSTS_COUNT

Allows client to download posts count in thread. This option is necessary for threads watcher.

If you enable this option, you must implement onReadPostsCount(chan.content.ChanPerformer.ReadPostsCountData).

public static final String OPTION_READ_SINGLE_POST

Allows client to download single post knowing it's board name and post number.

If you enable this option, you must implement onReadSinglePost(chan.content.ChanPerformer.ReadSinglePostData).

public static final String OPTION_READ_THREAD_PARTIALLY

Allows client to download thread partially.

public static final String OPTION_READ_USER_BOARDS

Allows client to download user boards.

If you enable this option, you must implement onReadUserBoards(chan.content.ChanPerformer.ReadUserBoardsData).

public static final String OPTION_SINGLE_BOARD_MODE

Allows client to use only one board. That exempts you from obligation to override onReadBoards(chan.content.ChanPerformer.ReadBoardsData) method.

The boardName argument in all methods will be equal to null. You can change this argument using setSingleBoardName(String) method.

Public Constructors

public ChanConfiguration ()

Public Methods

public final void addCaptchaType (String captchaType)

Add captcha type to list of supported capthas. User may choose captcha in application preferences. Client will obtain configuration of custom captchas with obtainCustomCaptchaConfiguration(String).

There is a list of default captcha types: CAPTCHA_TYPE_RECAPTCHA_1, CAPTCHA_TYPE_RECAPTCHA_2 and CAPTCHA_TYPE_MAILRU. Client is able to handle these captchas by itself.

Parameters
captchaType String: Captcha type string.

public final void addCustomPreference (String key, boolean defaultValue)

Add custom preference to chan preferences screen. You can obtain a value using get(String, String, boolean) method with null boardName argument. You also must override obtainCustomPreferenceConfiguration(String) to configure such values as title and summary.

Parameters
key String: Custom preference key.
defaultValue boolean: Default value.

public static T get (Object object)

Return linked ChanConfiguration instance.

Parameters
object Object: Linked object: ChanConfiguration, ChanPerformer, ChanLocator or ChanMarkup.
Returns
T ChanConfiguration instance.

public final String get (String boardName, String key, String defaultValue)

Returns stored string value.

Parameters
boardName String: Board name part of real key.
key String: Key name.
defaultValue String: Value to return if this preference does not exist.
Returns
String Stored value.

public final int get (String boardName, String key, int defaultValue)

Returns stored int value.

Parameters
boardName String: Board name part of real key.
key String: Key name.
defaultValue int: Value to return if this preference does not exist.
Returns
int Stored value.

public final boolean get (String boardName, String key, boolean defaultValue)

Returns stored boolean value.

Parameters
boardName String: Board name part of real key.
key String: Key name.
defaultValue boolean: Value to return if this preference does not exist.
Returns
boolean Stored value.

public final Context getContext ()

Returns application context.

Returns
Context

public final String getCookie (String cookie)

Returns stored cookie.

Parameters
cookie String: Cookie name.
Returns
String Cookie value or null if cookie not found.

public final File getDownloadDirectory ()

Returns download directory.

Returns
File

public final Resources getResources ()

Returns resources from chan APK file.

Returns
Resources

public final String getTitle ()

Returns a chan title. This title is display name used in client.

Returns
String

public final String[] getUserAuthorizationData ()

Returns user authorization data. User can specify authorization data when OPTION_ALLOW_USER_AUTHORIZATION enabled.

Returns
String[] User authorization fields values.

public ChanConfiguration.Archivation obtainArchivationConfiguration ()

Calls every time client requests archivation configuration. You must return new instance of ChanConfiguration.Archivation with archivation configuration.

Returns
ChanConfiguration.Archivation

public ChanConfiguration.Board obtainBoardConfiguration (String boardName)

Calls every time client requests board configuration. You must return new instance of ChanConfiguration.Board with configuration for given boardName.

The boardName argument may be null! In this case you must return the widest configuration for your chan.

Parameters
boardName String: Board name string.
Returns
ChanConfiguration.Board

public ChanConfiguration.Authorization obtainCaptchaPassConfiguration ()

Calls every time client requests captcha pass configuration. You must return new instance of ChanConfiguration.Authorization with captcha pass configuration.

Returns
ChanConfiguration.Authorization

public ChanConfiguration.Captcha obtainCustomCaptchaConfiguration (String captchaType)

Calls every time client requests custom captcha configuration. You must return new instance of ChanConfiguration.Captcha with configuration for given captchaType.

Parameters
captchaType String: Captcha type string.
Returns
ChanConfiguration.Captcha

public ChanConfiguration.CustomPreference obtainCustomPreferenceConfiguration (String key)

Calls every time client requests custom captcha configuration. You must return new instance of ChanConfiguration.CustomPreference with configuration for given key.

Parameters
key String: Custom preference key.
Returns
ChanConfiguration.CustomPreference

public ChanConfiguration.Deleting obtainDeletingConfiguration (String boardName)

Calls every time client requests deleting configuration. You must return new instance of ChanConfiguration.Deleting with configuration for given boardName.

The boardName argument may be null! In this case you must return the widest configuration for your chan.

Parameters
boardName String: Board name string.
Returns
ChanConfiguration.Deleting

public ChanConfiguration.Posting obtainPostingConfiguration (String boardName, boolean newThread)

Calls every time client requests posting configuration. You must return new instance of ChanConfiguration.Posting with configuration for given boardName.

The boardName argument may be null! In this case you must return the widest configuration for your chan.

Parameters
boardName String: Board name string.
newThread boolean: True if user starts new thread.
Returns
ChanConfiguration.Posting

public ChanConfiguration.Reporting obtainReportingConfiguration (String boardName)

Calls every time client requests reporting configuration. You must return new instance of ChanConfiguration.Reporting with configuration for given boardName.

The boardName argument may be null! In this case you must return the widest configuration for your chan.

Parameters
boardName String: Board name string.
Returns
ChanConfiguration.Reporting

public ChanConfiguration.Statistics obtainStatisticsConfiguration ()

Calls every time client requests statistics configuration. You must return new instance of ChanConfiguration.Statistics with statistics configuration.

Returns
ChanConfiguration.Statistics

public ChanConfiguration.Authorization obtainUserAuthorizationConfiguration ()

Calls every time client requests user authorization configuration. You must return new instance of ChanConfiguration.Authorization with user authorization configuration.

Returns
ChanConfiguration.Authorization

public final void request (String option)

Requests option. You can do it only during construction.

Parameters
option String: Option to request.

public final void set (String boardName, String key, boolean value)

Stores boolean value.

Parameters
boardName String: Board name part of key.
key String: Key name.
value boolean: Value to store.

public final void set (String boardName, String key, int value)

Stores int value.

Parameters
boardName String: Board name part of key.
key String: Key name.
value int: Value to store.

public final void set (String boardName, String key, String value)

Stores string value.

Parameters
boardName String: Board name part of key.
key String: Key name.
value String: Value to store.

public final void setBoardDescription (String boardName, String description)

Set description for board with given boardName.

Parameters
boardName String: Board name.
description String: Board description.

public final void setBoardTitle (String boardName, String title)

Set title for board with given boardName.

Parameters
boardName String: Board name.
title String: Board title.

public final void setBumpLimit (int bumpLimit)

Set bumpLimit for all boards.

Parameters
bumpLimit int: Bump limit value.

public final void setBumpLimit (String boardName, int bumpLimit)

Set bumpLimit for specified boardName.

Parameters
boardName String: Board name.
bumpLimit int: Bump limit value.

public final void setBumpLimitMode (ChanConfiguration.BumpLimitMode mode)

Set specified ChanConfiguration.BumpLimitMode.

Parameters
mode ChanConfiguration.BumpLimitMode: Bump limit mode.

public final void setDefaultName (String defaultName)

Set poster's defaultName for all boards.

Parameters
defaultName String: Default name.

public final void setDefaultName (String boardName, String defaultName)

Set poster's defaultName for specified boardName.

Parameters
boardName String: Board name.
defaultName String: Default name.

public final void setPagesCount (String boardName, int pagesCount)

Set pagesCount for boardName.

Parameters
boardName String: Board name.
pagesCount int: Pages count value.

public final void setSingleBoardName (String boardName)

Set boardName argument for all requests when OPTION_SINGLE_BOARD_MODE enabled. That allow you disable this option in the future when chan add multiple boards for example.

Parameters
boardName String: Default board name string.

public final void storeBoardDescription (String boardName, String description)

Store description for board with given boardName.

Parameters
boardName String: Board name.
description String: Board description.

public final void storeBoardTitle (String boardName, String title)

Store title for board with given boardName.

Parameters
boardName String: Board name.
title String: Board title.

public final void storeBumpLimit (String boardName, int bumpLimit)

Store bumpLimit for specified boardName.

Parameters
boardName String: Board name.
bumpLimit int: Bump limit value.

public final void storeCookie (String cookie, String value, String displayName)

Stores cookie. You can specify human-friendly displayName of cookie. User can remove this cookie using cookie manager.

Parameters
cookie String: Cookie name.
value String: Cookie value. Set this argument to null to remove the cookie.
displayName String: Human-friendly name of cookie. May be null if value is null too.

public final void storeDefaultName (String boardName, String defaultName)

Store poster's defaultName for specified boardName.

Parameters
boardName String: Board name.
defaultName String: Default name.

public final void storePagesCount (String boardName, int pagesCount)

Store pagesCount for boardName.

Parameters
boardName String: Board name.
pagesCount int: Pages count value.