
言語 🇯🇵 日本語
ドキュメント
はじめに
使い方
認証
設定
FastComments Android Library
これは FastComments の公式 Android ライブラリです。
Android 用 FastComments コメントウィジェット
リポジトリ
機能 
- 🔄 ライブコメント(リアルタイム更新)
- 📱 ネイティブAndroidのUIコンポーネント
- 🧵 返信対応のスレッド形式ディスカッション
- 👤 セキュアなSSO認証
- 👍 スタイルをカスタマイズ可能な投票システム
- 🔔 ユーザー通知とプレゼンス(オンライン状態)
- 🔍 コメントのモデレーション機能
- 📱 ソーシャルフィードとの統合
- ♾️ 無限スクロールのページネーション
- 🎨 包括的なテーマ設定
インストール 
アプリの build.gradle.kts ファイルに FastComments SDK を追加してください:
dependencies {
implementation("com.fastcomments:sdk:0.0.1")
}
プロジェクトの settings.gradle.kts に Repsy リポジトリが含まれていることを確認してください:
dependencyResolutionManagement {
repositories {
maven {
url = uri("https://repo.repsy.io/mvn/winrid/fastcomments")
}
// other repositories...
}
}
基本的な使い方 
1. レイアウトに FastCommentsView を追加する
<com.fastcomments.sdk.FastCommentsView
android:id="@+id/commentsView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
2. SDK を初期化して設定する
// SDK を構成
val config = CommentWidgetConfig(
"your-tenant-id",
"page-url-id",
"Page Title",
"yourdomain.com",
"Site Name"
)
// 追加の設定オプション
config.voteStyle = VoteStyle.UpDown // または VoteStyle.Heart
config.enableInfiniteScrolling = true
config.hasDarkBackground = true // ダークモード対応
// SDK を初期化
val sdk = FastCommentsSDK(config)
// レイアウト内のコメントビューを取得
val commentsView = findViewById<FastCommentsView>(R.id.commentsView)
// ビューに SDK インスタンスを設定
commentsView.setSDK(sdk)
// コメントを読み込む
commentsView.load()
セキュアな SSO 認証 
ユーザーのために安全な認証を実装する:
// ユーザーデータを作成(理想的にはサーバー側で)
val userData = SecureSSOUserData(
"user-id",
"user@example.com",
"User Name",
"https://path-to-avatar.jpg"
)
// SSOトークンを生成(サーバー側で行うべき!)
val sso = FastCommentsSSO.createSecure("YOUR_API_KEY", userData)
val token = sso.prepareToSend()
// 設定に追加
config.sso = token
フィード統合 
コメント付きのソーシャルメディア風フィードを表示する:
// Configure the SDK
CommentWidgetConfig config = new CommentWidgetConfig();
config.tenantId = "your-tenant-id";
config.urlId = "page-url-id";
// Initialize the Feed SDK
FastCommentsFeedSDK feedSDK = new FastCommentsFeedSDK(config);
// Set up the feed view
FastCommentsFeedView feedView = findViewById(R.id.feedView);
feedView.setSDK(feedSDK);
// Set interaction listener
feedView.setFeedViewInteractionListener(new FastCommentsFeedView.OnFeedViewInteractionListener() {
@Override
public void onFeedLoaded(List<FeedPost> posts) {
// フィードの読み込みに成功
}
@Override
public void onFeedError(String errorMessage) {
// エラーを処理する
}
@Override
public void onPostSelected(FeedPost post) {
// ユーザーが投稿を選択した
}
@Override
public void onCommentsRequested(FeedPost post) {
// 投稿のコメントを表示する
CommentsDialog dialog = new CommentsDialog(context, post, feedSDK);
dialog.show();
}
});
// Load the feed
feedView.load();
ライブチャット統合 
アプリにリアルタイムチャットインターフェースを追加する:
// レイアウトXMLに LiveChatView を追加
// <com.fastcomments.sdk.LiveChatView
// android:id="@+id/liveChatView"
// android:layout_width="match_parent"
// android:layout_height="match_parent" />
// Create a configuration for the SDK
val config = CommentWidgetConfig().apply {
tenantId = "your-tenant-id"
urlId = "chat-room-identifier"
pageTitle = "Chat Room Name"
}
LiveChatView.setupLiveChatConfig(config)
// Optional: Add user authentication
val userData = SimpleSSOUserData(
"User Name",
"user@example.com",
"https://path-to-avatar.jpg"
)
val sso = FastCommentsSSO(userData)
config.sso = sso.prepareToSend()
// Initialize the SDK
val sdk = FastCommentsSDK().configure(config)
// Set up the live chat view
val liveChatView = findViewById<LiveChatView>(R.id.liveChatView)
liveChatView.setSDK(sdk)
liveChatView.load()
// ライフサイクル処理を忘れずに
override fun onResume() {
super.onResume()
sdk.refreshLiveEvents()
}
override fun onDestroy() {
super.onDestroy()
sdk.cleanup()
}
設定オプション 
SDKはCommentWidgetConfigクラスを使って多くの設定オプションを提供します:
| Option | Description |
|---|---|
tenantId |
あなたの FastComments アカウントID |
urlId |
現在のページを表すID |
sso |
認証用のSSOトークン |
allowAnon |
匿名コメントを許可する |
voteStyle |
UpDown または Heart の投票スタイル |
hideAvatars |
ユーザーのアバターを非表示にする |
hasDarkBackground |
ダークモードを示す |
customCSS |
カスタムCSSスタイル |
enableInfiniteScrolling |
無限スクロールによるページネーションを有効にする |
readonly |
コメントの投稿を無効にするが、コメントは表示する |
disableVoting |
投票機能を無効にする |
disableLiveCommenting |
リアルタイム更新を無効にする |
| --- |
テーマの包括的なカスタマイズ 
FastComments SDK のすべてのボタンと UI 要素はテーマ可能です。アプリのブランディングを完全に制御するには FastCommentsTheme.Builder を使用してください。
プログラムによるテーマ設定(推奨)
val theme = FastCommentsTheme.Builder()
// アクションボタン: 送信、投票、メニュー、いいね/共有ボタン
.setActionButtonColor(Color.parseColor("#FF1976D2"))
// 返信ボタン: コメント返信ボタン
.setReplyButtonColor(Color.parseColor("#FF4CAF50"))
// トグルボタン: 返信の表示/非表示ボタン
.setToggleRepliesButtonColor(Color.parseColor("#FFFF5722"))
// もっと読み込むボタン: ページネーションボタン
.setLoadMoreButtonTextColor(Color.parseColor("#FF9C27B0"))
.setPrimaryColor(Color.parseColor("#FF6200EE"))
.setLinkColor(Color.parseColor("#FF1976D2"))
.setDialogHeaderBackgroundColor(Color.parseColor("#FF333333"))
.build()
// テーマを適用
sdk.setTheme(theme)
簡単なカラーの上書き
Override color resources in your colors.xml for simple branding:
<!-- アプリの res/values/colors.xml 内 -->
<resources>
<!-- すべての主要な UI 要素を変更 -->
<color name="primary">#FF1976D2</color>
<!-- または特定のボタン種別をカスタマイズ -->
<color name="fastcomments_action_button_color">#FF1976D2</color>
<color name="fastcomments_reply_button_color">#FF4CAF50</color>
<color name="fastcomments_toggle_replies_button_color">#FFFF5722</color>
<color name="fastcomments_load_more_button_text_color">#FF9C27B0</color>
</resources>
テーマ対応ボタンの範囲
SDK のすべてのボタンでテーマがサポートされています:
- 送信ボタン、投票ボタン、メニューボタン、返信ボタン
- 返信の表示/非表示ボタン、もっと読み込むボタン
- フィードのアクションボタン(いいね、コメント、共有)
- ダイアログボタン(送信、キャンセル、保存)
- フィード投稿内の動的タスクボタン
詳細なテーマ設定のドキュメントは THEMING.md を参照してください。
メモリ管理 
メモリリークの防止
Activities または Fragments で FastComments ビューを使用する際にメモリリークを防ぐため、ビューが不要になったら常に cleanup() を呼び出してください:
アクティビティ内:
@Override
protected void onDestroy() {
super.onDestroy();
// メモリリークを防ぐため、FastComments ビューをクリーンアップします
if (feedView != null) {
feedView.cleanup();
}
if (commentsView != null) {
commentsView.cleanup();
}
}
フラグメント内:
@Override
public void onDestroyView() {
super.onDestroyView();
// フラグメントのビューが破棄されたときに FastComments ビューをクリーンアップします
if (feedView != null) {
feedView.cleanup();
feedView = null;
}
}
@Override
public void onDestroy() {
super.onDestroy();
// フラグメントが破棄されたときの追加のクリーンアップ
if (feedSDK != null) {
feedSDK.cleanup();
feedSDK = null;
}
}
フラグメントを切り替えるとき:
// FastComments ビューを含むフラグメントを置換または削除する前に
Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.container);
if (currentFragment instanceof YourFragmentWithFeedView) {
((YourFragmentWithFeedView) currentFragment).cleanupFeedView();
}
// その後、フラグメントトランザクションを実行します
getSupportFragmentManager().beginTransaction()
.replace(R.id.container, newFragment)
.commit();
重要: メモリリークを防ぐために常に cleanup() メソッドを呼び出してください。特に次の場合:
- アクティビティが破棄されるとき
- フラグメントのビューが破棄されるとき
- フラグメントを切り替えるとき
- FastComments コンポーネントを含む画面から離れるとき
サポートが必要ですか?
Android ライブラリで問題が発生したり質問がある場合は、次のいずれかを行ってください:
貢献
貢献は歓迎します!貢献ガイドラインについては GitHub リポジトリ をご覧ください。