Skip to content

Commit 40db5bc

Browse files
author
zhangwei
committed
Merge branch 'dev/adapter_android35' into dev/4.5.3
2 parents 5e8dc87 + 8140798 commit 40db5bc

21 files changed

Lines changed: 306 additions & 259 deletions

File tree

.git-hooks/install-hooks.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ else
5353
print_green "pre-commit is already installed!"
5454
fi
5555

56-
# Check if gitleaks is installed
56+
# Check if gitleaks is installed (required)
5757
if ! command -v gitleaks &> /dev/null; then
58-
print_yellow "gitleaks not found, please install it..."
58+
print_red "gitleaks not found - this is a required security tool!"
5959
print_yellow "Installation guide: https://github.com/gitleaks/gitleaks#installing"
6060

6161
# Attempt automatic installation (based on OS)
@@ -77,6 +77,8 @@ if ! command -v gitleaks &> /dev/null; then
7777
print_red "Please install gitleaks manually and try again"
7878
exit 1
7979
fi
80+
else
81+
print_green "gitleaks is installed!"
8082
fi
8183

8284
# Check required files and directories

.git-hooks/post-commit

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,17 @@
33
# Check if required hooks are installed
44
if [ ! -f ".git/hooks/commit-msg" ] || [ ! -x ".git/hooks/commit-msg" ]; then
55
echo "============================================================"
6-
echo "Note: Git hooks for checking Chinese characters in commit messages are not installed."
6+
echo "⚠️ Note: Git hooks for checking commit messages are not installed."
77
echo "Please run the following commands to install:"
88
echo ""
99
echo " 1. Install pre-commit:"
1010
echo " pip install pre-commit"
1111
echo ""
12-
echo " 2. Install pre-commit hook:"
13-
echo " pre-commit install"
12+
echo " 2. Install hooks:"
13+
echo " .git-hooks/install-hooks.sh"
1414
echo ""
15-
echo " 3. Install commit-msg hook:"
16-
echo " pre-commit install --hook-type commit-msg"
17-
echo " cp .git-hooks/check-commit-message.sh .git/hooks/commit-msg"
18-
echo " chmod +x .git/hooks/commit-msg"
19-
echo ""
20-
echo "These hooks will help detect sensitive information leaks and Chinese characters in commit messages."
15+
echo "These hooks will help detect sensitive information leaks and"
16+
echo "Chinese characters in commit messages."
2117
echo "============================================================"
2218
fi
2319

.git-hooks/pre-commit

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
# Check if gitleaks is configured
44
if ! command -v gitleaks &> /dev/null; then
55
echo "============================================================"
6-
echo "Gitleaks not detected. This is a required tool to prevent sensitive information leaks."
7-
echo "Please install gitleaks first: https://github.com/gitleaks/gitleaks#installing"
6+
echo "❌ ERROR: Gitleaks not detected."
7+
echo "This is a required tool to prevent sensitive information leaks."
8+
echo ""
9+
echo "Please install gitleaks first:"
10+
echo " macOS: brew install gitleaks"
11+
echo " Other: https://github.com/gitleaks/gitleaks#installing"
12+
echo ""
813
echo "After installation, run: ./.git-hooks/install-hooks.sh"
914
echo "============================================================"
1015
exit 1
@@ -14,12 +19,12 @@ fi
1419
if [ -f ".gitleaks.toml" ]; then
1520
gitleaks detect --source . --config .gitleaks.toml
1621
if [ $? -ne 0 ]; then
17-
echo "Gitleaks detected sensitive information. Commit rejected."
22+
echo "Gitleaks detected sensitive information. Commit rejected."
1823
echo "Please review the output above and remove sensitive information."
1924
exit 1
2025
fi
2126
else
22-
echo "No .gitleaks.toml configuration file found, skipping sensitive information check."
27+
echo "⚠️ No .gitleaks.toml configuration file found, skipping sensitive information check."
2328
fi
2429

2530
exit 0

.git-hooks/run-gitleaks.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
# Try to find gitleaks in common locations
4+
GITLEAKS_CMD=""
5+
6+
# Check if gitleaks is in PATH
7+
if command -v gitleaks &> /dev/null; then
8+
GITLEAKS_CMD="gitleaks"
9+
# Check Homebrew locations (Intel Mac)
10+
elif [ -f "/usr/local/bin/gitleaks" ]; then
11+
GITLEAKS_CMD="/usr/local/bin/gitleaks"
12+
# Check Homebrew locations (Apple Silicon Mac)
13+
elif [ -f "/opt/homebrew/bin/gitleaks" ]; then
14+
GITLEAKS_CMD="/opt/homebrew/bin/gitleaks"
15+
# Check if installed via other package managers
16+
elif [ -f "$HOME/.local/bin/gitleaks" ]; then
17+
GITLEAKS_CMD="$HOME/.local/bin/gitleaks"
18+
fi
19+
20+
# If gitleaks not found, exit with error
21+
if [ -z "$GITLEAKS_CMD" ]; then
22+
echo "============================================================"
23+
echo "❌ ERROR: gitleaks not found!"
24+
echo ""
25+
echo "Please install gitleaks:"
26+
echo " macOS: brew install gitleaks"
27+
echo " Linux: https://github.com/gitleaks/gitleaks#installing"
28+
echo ""
29+
echo "After installation, run: ./.git-hooks/install-hooks.sh"
30+
echo "============================================================"
31+
exit 1
32+
fi
33+
34+
# Run gitleaks with provided arguments
35+
exec "$GITLEAKS_CMD" "$@"

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repos:
44
- id: gitleaks
55
name: Detect hardcoded secrets
66
description: Ensures no secrets are committed
7-
entry: gitleaks protect
7+
entry: .git-hooks/run-gitleaks.sh protect
88
args: ["--config=.gitleaks.toml", "--staged", "--verbose"]
99
language: system
1010
pass_filenames: false

Android/APIExample-Audio/app/build.gradle

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,23 +98,20 @@ dependencies {
9898
// implementation "io.agora.rtc:drm:${agoraSdkVersion}"
9999
}
100100

101+
implementation 'androidx.core:core-ktx:1.13.1'
101102
implementation 'androidx.appcompat:appcompat:1.7.0'
102-
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
103-
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.8.22"
103+
implementation 'com.google.android.material:material:1.12.0'
104+
implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
104105

105106
// Java language implementation
106-
implementation "androidx.navigation:navigation-fragment:2.7.0"
107-
implementation "androidx.navigation:navigation-ui:2.7.0"
107+
implementation "androidx.navigation:navigation-fragment:2.8.5"
108+
implementation "androidx.navigation:navigation-ui:2.8.5"
108109

109-
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
110110
implementation 'androidx.recyclerview:recyclerview:1.3.2'
111111
testImplementation 'junit:junit:4.13.2'
112112
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
113113
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
114114

115-
implementation 'io.github.luizgrp.sectionedrecyclerviewadapter:sectionedrecyclerviewadapter:1.2.0'
116-
implementation 'de.javagl:obj:0.2.1'
117-
118-
implementation "com.squareup.okhttp3:okhttp:4.10.0"
119-
implementation "com.squareup.okhttp3:logging-interceptor:4.10.0"
115+
implementation "com.squareup.okhttp3:okhttp:4.12.0"
116+
implementation "com.squareup.okhttp3:logging-interceptor:4.12.0"
120117
}

Android/APIExample-Audio/app/src/main/java/io/agora/api/example/MainFragment.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020
import androidx.recyclerview.widget.RecyclerView;
2121

2222
import io.agora.api.example.annotation.Example;
23-
import io.agora.api.example.common.adapter.ExampleSection;
23+
import io.agora.api.example.common.adapter.SectionAdapter;
2424
import io.agora.api.example.common.model.Examples;
25-
import io.github.luizgrp.sectionedrecyclerviewadapter.SectionedRecyclerViewAdapter;
2625

2726
/**
2827
* A fragment representing a list of Items.
@@ -78,10 +77,10 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
7877
} else {
7978
recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount));
8079
}
81-
SectionedRecyclerViewAdapter sectionedAdapter = new SectionedRecyclerViewAdapter();
82-
sectionedAdapter.addSection(new ExampleSection(BASIC, Examples.ITEM_MAP.get(BASIC), mListener));
83-
sectionedAdapter.addSection(new ExampleSection(ADVANCED, Examples.ITEM_MAP.get(ADVANCED), mListener));
84-
recyclerView.setAdapter(sectionedAdapter);
80+
SectionAdapter sectionAdapter = new SectionAdapter(mListener);
81+
sectionAdapter.addSection(BASIC, Examples.ITEM_MAP.get(BASIC));
82+
sectionAdapter.addSection(ADVANCED, Examples.ITEM_MAP.get(ADVANCED));
83+
recyclerView.setAdapter(sectionAdapter);
8584
}
8685
return view;
8786
}

Android/APIExample-Audio/app/src/main/java/io/agora/api/example/common/adapter/ExampleSection.java

Lines changed: 0 additions & 79 deletions
This file was deleted.
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
package io.agora.api.example.common.adapter;
2+
3+
import android.view.LayoutInflater;
4+
import android.view.View;
5+
import android.view.ViewGroup;
6+
import android.widget.TextView;
7+
8+
import androidx.annotation.NonNull;
9+
import androidx.recyclerview.widget.RecyclerView;
10+
11+
import java.util.ArrayList;
12+
import java.util.List;
13+
14+
import io.agora.api.example.MainFragment;
15+
import io.agora.api.example.R;
16+
import io.agora.api.example.annotation.Example;
17+
18+
/**
19+
* Adapter for multiple sections with headers and items
20+
*/
21+
public class SectionAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
22+
private static final int TYPE_HEADER = 0;
23+
private static final int TYPE_ITEM = 1;
24+
25+
private final List<Object> items = new ArrayList<>();
26+
private final MainFragment.OnListFragmentInteractionListener listener;
27+
28+
public SectionAdapter(MainFragment.OnListFragmentInteractionListener listener) {
29+
this.listener = listener;
30+
}
31+
32+
public void addSection(String title, List<Example> sectionItems) {
33+
items.add(title);
34+
if (sectionItems != null) {
35+
items.addAll(sectionItems);
36+
}
37+
}
38+
39+
@Override
40+
public int getItemViewType(int position) {
41+
return items.get(position) instanceof String ? TYPE_HEADER : TYPE_ITEM;
42+
}
43+
44+
@NonNull
45+
@Override
46+
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
47+
if (viewType == TYPE_HEADER) {
48+
View view = LayoutInflater.from(parent.getContext())
49+
.inflate(R.layout.layout_main_list_section, parent, false);
50+
return new HeaderViewHolder(view);
51+
} else {
52+
View view = LayoutInflater.from(parent.getContext())
53+
.inflate(R.layout.layout_main_list_item, parent, false);
54+
return new ItemViewHolder(view);
55+
}
56+
}
57+
58+
@Override
59+
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
60+
if (holder instanceof HeaderViewHolder) {
61+
((HeaderViewHolder) holder).bind((String) items.get(position));
62+
} else if (holder instanceof ItemViewHolder) {
63+
((ItemViewHolder) holder).bind((Example) items.get(position), listener);
64+
}
65+
}
66+
67+
@Override
68+
public int getItemCount() {
69+
return items.size();
70+
}
71+
72+
static class HeaderViewHolder extends RecyclerView.ViewHolder {
73+
final TextView nameView;
74+
75+
HeaderViewHolder(View view) {
76+
super(view);
77+
nameView = view.findViewById(R.id.item_name);
78+
}
79+
80+
void bind(String title) {
81+
nameView.setText(title);
82+
}
83+
}
84+
85+
static class ItemViewHolder extends RecyclerView.ViewHolder {
86+
final View view;
87+
final TextView nameView;
88+
89+
ItemViewHolder(View itemView) {
90+
super(itemView);
91+
view = itemView;
92+
nameView = itemView.findViewById(R.id.item_name);
93+
}
94+
95+
void bind(Example item, MainFragment.OnListFragmentInteractionListener listener) {
96+
nameView.setText(view.getContext().getString(item.name()));
97+
view.setOnClickListener(v -> {
98+
if (listener != null) {
99+
listener.onListFragmentInteraction(item);
100+
}
101+
});
102+
}
103+
}
104+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
plugins {
3-
id 'com.android.application' version '8.5.0' apply false
3+
id 'com.android.application' version '8.7.3' apply false
44
id 'org.jetbrains.kotlin.android' version '1.9.24' apply false
55
}

0 commit comments

Comments
 (0)