Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 530a0f8ce1 | |||
| 022fb3dd99 |
98
.gitea/workflows/release.yml
Normal file
98
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,98 @@
|
||||
name: Android Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# ------------------- Checkout -------------------
|
||||
- name: Checkout
|
||||
uses: https://git.daemonlord.ru/actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
tags: true
|
||||
|
||||
# ------------------- Setup JDK -------------------
|
||||
- name: Set up JDK 17
|
||||
uses: https://git.daemonlord.ru/actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 17
|
||||
|
||||
# ------------------- Install Node.js -------------------
|
||||
- name: Install Node.js
|
||||
run: |
|
||||
curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
|
||||
apt-get install -y nodejs
|
||||
|
||||
# ------------------- Extract version -------------------
|
||||
- name: Extract versionName
|
||||
id: extract_version
|
||||
run: |
|
||||
VERSION=$(grep -oP 'versionName\s+"[^"]+"' app/build.gradle | head -n1 | cut -d'"' -f2 | tr -d '\r\n')
|
||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
||||
echo "Detected version: $VERSION"
|
||||
|
||||
# ------------------- Stop if already released -------------------
|
||||
- name: Stop if version already released
|
||||
id: stop
|
||||
run: |
|
||||
VERSION=${{ steps.extract_version.outputs.version }}
|
||||
if git show-ref --tags --quiet --verify "refs/tags/$VERSION"; then
|
||||
echo "Version $VERSION already released, stopping job."
|
||||
echo "CONTINUE=false" >> $GITHUB_ENV
|
||||
else
|
||||
echo "Version $VERSION not released yet, continuing workflow..."
|
||||
echo "CONTINUE=true" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
# ------------------- Decode keystore -------------------
|
||||
- name: Decode keystore
|
||||
if: env.CONTINUE == 'true'
|
||||
run: |
|
||||
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > app/release.keystore
|
||||
|
||||
- name: Make Gradlew executable
|
||||
if: env.CONTINUE == 'true'
|
||||
run: chmod +x ./gradlew
|
||||
|
||||
# ------------------- Set up Android SDK -------------------
|
||||
- name: Set up Android SDK
|
||||
if: env.CONTINUE == 'true'
|
||||
uses: https://git.daemonlord.ru/actions/setup-android@v3
|
||||
|
||||
# ------------------- Build Release APK -------------------
|
||||
- name: Build Release APK
|
||||
if: env.CONTINUE == 'true'
|
||||
env:
|
||||
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
|
||||
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
|
||||
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
|
||||
run: ./gradlew --no-daemon assembleRelease
|
||||
|
||||
# ------------------- Git tag -------------------
|
||||
- name: Create git tag
|
||||
if: env.CONTINUE == 'true'
|
||||
run: |
|
||||
git tag $VERSION
|
||||
git push origin $VERSION
|
||||
|
||||
# ------------------- Gitea release -------------------
|
||||
- name: Create Gitea Release
|
||||
if: env.CONTINUE == 'true'
|
||||
uses: https://git.daemonlord.ru/actions/gitea-release-action@v1
|
||||
with:
|
||||
server_url: https://git.daemonlord.ru
|
||||
repository: ${{ gitea.repository }}
|
||||
token: ${{ secrets.API_TOKEN }}
|
||||
tag_name: ${{ steps.extract_version.outputs.version }}
|
||||
name: Release ${{ steps.extract_version.outputs.version }}
|
||||
body: |
|
||||
Android release ${{ steps.extract_version.outputs.version }}
|
||||
files: |
|
||||
app/build/outputs/apk/release/*.apk
|
||||
@@ -4,26 +4,39 @@ plugins {
|
||||
|
||||
android {
|
||||
namespace 'com.anabasis.vkchatmanager'
|
||||
compileSdk {
|
||||
version = release(36)
|
||||
}
|
||||
compileSdk 36
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.anabasis.vkchatmanager"
|
||||
minSdk 26
|
||||
targetSdk 36
|
||||
versionCode 3
|
||||
versionName "1.1.1"
|
||||
versionCode 10200
|
||||
versionName "1.2.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
// --- Настройка signingConfigs ---
|
||||
signingConfigs {
|
||||
release {
|
||||
// Путь к keystore — от корня проекта
|
||||
storeFile file("release.keystore")
|
||||
storePassword System.getenv("KEYSTORE_PASSWORD") ?: "change_me"
|
||||
keyAlias System.getenv("KEY_ALIAS") ?: "change_me"
|
||||
keyPassword System.getenv("KEY_PASSWORD") ?: "change_me"
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled true
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
|
||||
// Используем signingConfig release
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
targetCompatibility JavaVersion.VERSION_17
|
||||
@@ -31,7 +44,6 @@ android {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
implementation libs.recyclerview
|
||||
implementation libs.viewpager2
|
||||
implementation libs.material
|
||||
|
||||
@@ -17,7 +17,6 @@ import android.widget.Toast;
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.graphics.Insets;
|
||||
import androidx.core.view.ViewCompat;
|
||||
@@ -42,21 +41,23 @@ import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
private enum UserAction {
|
||||
ADD, REMOVE, SET_ADMIN
|
||||
}
|
||||
private VkApiClient api;
|
||||
|
||||
private final List<VkChat> office = new ArrayList<>();
|
||||
private final List<VkChat> retail = new ArrayList<>();
|
||||
private final List<VkChat> warehouse = new ArrayList<>();
|
||||
private final List<VkChat> coffee = new ArrayList<>();
|
||||
private final List<VkChat> other = new ArrayList<>();
|
||||
|
||||
private final List<Integer> userIdsToProcess = new ArrayList<>();
|
||||
|
||||
private final List<String> userNamesToProcess = new ArrayList<>();
|
||||
private final Map<Integer, String> usersToProcess = new LinkedHashMap<>();
|
||||
|
||||
private LinearProgressIndicator progressBar;
|
||||
private androidx.swiperefreshlayout.widget.SwipeRefreshLayout swipeRefresh;
|
||||
@@ -74,13 +75,13 @@ public class MainActivity extends AppCompatActivity {
|
||||
result -> {
|
||||
if (result.getResultCode() == RESULT_OK) {
|
||||
recreate();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
|
||||
setContentView(R.layout.activity_main);
|
||||
@@ -154,8 +155,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
});
|
||||
|
||||
addBtn.setOnClickListener(v -> processUsers(true));
|
||||
removeBtn.setOnClickListener(v -> processUsers(false));
|
||||
addBtn.setOnClickListener(v -> processUsers(UserAction.ADD));
|
||||
removeBtn.setOnClickListener(v -> processUsers(UserAction.REMOVE));
|
||||
showUsersBtn.setOnClickListener(v -> showUsers());
|
||||
}
|
||||
|
||||
@@ -187,6 +188,11 @@ public class MainActivity extends AppCompatActivity {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (id == R.id.action_set_admin) {
|
||||
processUsers(UserAction.SET_ADMIN);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (id == R.id.action_token_status) {
|
||||
showTokenStatus();
|
||||
return true;
|
||||
@@ -383,8 +389,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
/* ===================== LINKS ===================== */
|
||||
|
||||
private void processLinksList(List<String> links) {
|
||||
userIdsToProcess.clear();
|
||||
userNamesToProcess.clear();
|
||||
usersToProcess.clear();
|
||||
|
||||
setUiEnabled(false);
|
||||
|
||||
@@ -394,8 +399,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
String screen = extractScreenName(link);
|
||||
int uid = api.resolveUserId(screen);
|
||||
if (uid > 0) {
|
||||
userIdsToProcess.add(uid);
|
||||
userNamesToProcess.add(api.getUserName(uid));
|
||||
usersToProcess.put(uid, api.getUserName(uid));
|
||||
}
|
||||
} catch (TokenExpiredException e) {
|
||||
runOnUiThread(this::handleTokenExpired);
|
||||
@@ -406,7 +410,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
setUiEnabled(true);
|
||||
Toast.makeText(
|
||||
this,
|
||||
getString(R.string.users_loaded_message, userIdsToProcess.size()),
|
||||
getString(R.string.users_loaded_message, usersToProcess.size()),
|
||||
Toast.LENGTH_SHORT
|
||||
).show();
|
||||
});
|
||||
@@ -431,16 +435,16 @@ public class MainActivity extends AppCompatActivity {
|
||||
return link;
|
||||
}
|
||||
|
||||
/* ===================== ADD / REMOVE ===================== */
|
||||
/* ===================== ADD / REMOVE / SET_ADMIN ===================== */
|
||||
|
||||
private void showUsers() {
|
||||
if (userNamesToProcess.isEmpty()) {
|
||||
if (usersToProcess.isEmpty()) {
|
||||
Toast.makeText(this, getString(R.string.user_list_empty), Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder msg = new StringBuilder();
|
||||
for (String name : userNamesToProcess) {
|
||||
for (String name : usersToProcess.values()) {
|
||||
msg.append("• ").append(name).append("\n");
|
||||
}
|
||||
|
||||
@@ -451,10 +455,13 @@ public class MainActivity extends AppCompatActivity {
|
||||
.show();
|
||||
}
|
||||
|
||||
private void processUsers(boolean add) {
|
||||
private void processUsers(UserAction action) {
|
||||
|
||||
List<VkChat> chats = getCurrentFragment().getSelected();
|
||||
if (chats.isEmpty() || userIdsToProcess.isEmpty()) {
|
||||
ChatListFragment currentFragment = getCurrentFragment();
|
||||
if (currentFragment == null) return;
|
||||
|
||||
List<VkChat> chats = currentFragment.getSelected();
|
||||
if (chats.isEmpty() || usersToProcess.isEmpty()) {
|
||||
Toast.makeText(this,
|
||||
getString(R.string.no_chats_or_users_selected_message),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
@@ -462,10 +469,20 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append(add ? getString(R.string.add_users_dialog_message) : getString(R.string.remove_users_dialog_message));
|
||||
switch (action) {
|
||||
case ADD:
|
||||
msg.append(getString(R.string.add_users_dialog_message));
|
||||
break;
|
||||
case REMOVE:
|
||||
msg.append(getString(R.string.remove_users_dialog_message));
|
||||
break;
|
||||
case SET_ADMIN:
|
||||
msg.append(getString(R.string.set_admin_dialog_message));
|
||||
break;
|
||||
}
|
||||
msg.append("\n\n");
|
||||
|
||||
for (String name : userNamesToProcess) {
|
||||
for (String name : usersToProcess.values()) {
|
||||
msg.append("• ").append(name).append("\n");
|
||||
}
|
||||
|
||||
@@ -480,18 +497,18 @@ public class MainActivity extends AppCompatActivity {
|
||||
.setTitle(getString(R.string.confirmation_dialog_title))
|
||||
.setMessage(msg.toString())
|
||||
.setPositiveButton(getString(R.string.confirm_button), (d, w) ->
|
||||
executeUsers(add, chats))
|
||||
executeUsers(action, chats))
|
||||
.setNegativeButton(getString(R.string.cancel_button), null)
|
||||
.show();
|
||||
}
|
||||
|
||||
private void executeUsers(boolean add, List<VkChat> chats) {
|
||||
private void executeUsers(UserAction action, List<VkChat> chats) {
|
||||
setUiEnabled(false);
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
progressBar.setIndeterminate(false);
|
||||
progressBar.setProgress(0, true);
|
||||
|
||||
int totalOps = chats.size() * userIdsToProcess.size();
|
||||
int totalOps = chats.size() * usersToProcess.size();
|
||||
progressBar.setMax(totalOps);
|
||||
|
||||
new Thread(() -> {
|
||||
@@ -499,19 +516,27 @@ public class MainActivity extends AppCompatActivity {
|
||||
int done = 0;
|
||||
|
||||
for (VkChat c : chats) {
|
||||
for (int i = 0; i < userIdsToProcess.size(); i++) {
|
||||
int uid = userIdsToProcess.get(i);
|
||||
String userName = userNamesToProcess.get(i);
|
||||
for (Map.Entry<Integer, String> user : usersToProcess.entrySet()) {
|
||||
int uid = user.getKey();
|
||||
String userName = user.getValue();
|
||||
String resultMessage;
|
||||
|
||||
try {
|
||||
if (add) {
|
||||
api.addUser(c.id, uid, true);
|
||||
resultMessage = getString(R.string.op_success_add_format, userName, c.title);
|
||||
} else {
|
||||
api.removeUser(c.id, uid);
|
||||
resultMessage = getString(R.string.op_success_remove_format, userName, c.title);
|
||||
}
|
||||
resultMessage = switch (action) {
|
||||
case ADD -> {
|
||||
api.addUser(c.id, uid, true);
|
||||
yield getString(R.string.op_success_add_format, userName, c.title);
|
||||
}
|
||||
case REMOVE -> {
|
||||
api.removeUser(c.id, uid);
|
||||
yield getString(R.string.op_success_remove_format, userName, c.title);
|
||||
}
|
||||
case SET_ADMIN -> {
|
||||
api.setMemberRole(c.id, uid, "admin");
|
||||
yield getString(R.string.op_success_set_admin_format, userName, c.title);
|
||||
}
|
||||
};
|
||||
|
||||
} catch (TokenExpiredException e) {
|
||||
runOnUiThread(this::handleTokenExpired);
|
||||
return;
|
||||
|
||||
@@ -59,6 +59,13 @@ public class VkApiClient {
|
||||
"&member_id=" + userId);
|
||||
}
|
||||
|
||||
public void setMemberRole(int chatId, int userId, String role) throws Exception {
|
||||
call("messages.setMemberRole",
|
||||
"peer_id=" + (2000000000 + chatId) +
|
||||
"&member_id=" + userId +
|
||||
"&role=" + role);
|
||||
}
|
||||
|
||||
public int resolveUserId(String screenName) throws Exception {
|
||||
|
||||
JSONObject resp = call(
|
||||
@@ -84,4 +91,4 @@ public class VkApiClient {
|
||||
return u.getString("first_name") + " " + u.getString("last_name");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@
|
||||
<item
|
||||
android:id="@+id/action_deselect_all"
|
||||
android:title="@string/action_deselect_all" />
|
||||
<item
|
||||
android:id="@+id/action_set_admin"
|
||||
android:title="@string/action_set_admin" />
|
||||
<item
|
||||
android:id="@+id/action_token_status"
|
||||
android:title="@string/action_token_status" />
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
<string name="no_chats_or_users_selected_message">Не выбраны чаты или пользователи</string>
|
||||
<string name="add_users_dialog_message">Добавить пользователей:</string>
|
||||
<string name="remove_users_dialog_message">Удалить пользователей:</string>
|
||||
<string name="set_admin_dialog_message">Назначить администратором:</string>
|
||||
<string name="in_chats_dialog_message">В чаты:</string>
|
||||
<string name="confirmation_dialog_title">Подтверждение</string>
|
||||
<string name="confirm_button">Подтвердить</string>
|
||||
@@ -27,6 +28,7 @@
|
||||
<string name="action_refresh">Обновить</string>
|
||||
<string name="action_select_all">Выбрать все</string>
|
||||
<string name="action_deselect_all">Снять выбор</string>
|
||||
<string name="action_set_admin">Назначить администратором</string>
|
||||
<string name="action_token_status">Статус токена</string>
|
||||
<string name="token_status_title">Статус токена</string>
|
||||
<string name="token_status_perpetual">Токен бессрочный</string>
|
||||
@@ -39,6 +41,7 @@
|
||||
<string name="op_unknown_error">неизвестная ошибка</string>
|
||||
<string name="op_success_add_format">✅ %1$s в %2$s: Успешно</string>
|
||||
<string name="op_success_remove_format">✅ %1$s из %2$s: Успешно</string>
|
||||
<string name="op_success_set_admin_format">✅ %1$s в %2$s: Назначен администратором</string>
|
||||
<string name="op_failure_format">❌ %1$s в %2$s: %3$s</string>
|
||||
<string name="action_sign_out">Выйти</string>
|
||||
<string name="api_error">Ошибка API: %s</string>
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
<string name="no_chats_or_users_selected_message">No chats or users selected</string>
|
||||
<string name="add_users_dialog_message">Add users:</string>
|
||||
<string name="remove_users_dialog_message">Remove users:</string>
|
||||
<string name="set_admin_dialog_message">Set as admin:</string>
|
||||
<string name="in_chats_dialog_message">In chats:</string>
|
||||
<string name="confirmation_dialog_title">Confirmation</string>
|
||||
<string name="confirm_button">Confirm</string>
|
||||
@@ -27,6 +28,7 @@
|
||||
<string name="action_refresh">Refresh</string>
|
||||
<string name="action_select_all">Select All</string>
|
||||
<string name="action_deselect_all">Deselect All</string>
|
||||
<string name="action_set_admin">Set as Admin</string>
|
||||
<string name="action_token_status">Token Status</string>
|
||||
<string name="token_status_title">Token Status</string>
|
||||
<string name="token_status_perpetual">Token is perpetual</string>
|
||||
@@ -39,6 +41,7 @@
|
||||
<string name="op_unknown_error">unknown error</string>
|
||||
<string name="op_success_add_format">✅ %1$s in %2$s: Success</string>
|
||||
<string name="op_success_remove_format">✅ %1$s from %2$s: Success</string>
|
||||
<string name="op_success_set_admin_format">✅ %1$s in %2$s: Is now an admin</string>
|
||||
<string name="op_failure_format">❌ %1$s in %2$s: %3$s</string>
|
||||
<string name="action_sign_out">Sign Out</string>
|
||||
<string name="api_error">API error: %s</string>
|
||||
|
||||
BIN
assets/app_icon.png
Normal file
BIN
assets/app_icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.5 KiB |
BIN
assets/icon.png
Normal file
BIN
assets/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.5 KiB |
Reference in New Issue
Block a user