Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 530a0f8ce1 | |||
| 022fb3dd99 | |||
| 098828d8d5 | |||
| 56c5100557 | |||
| 6b65ec1bc4 |
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,38 +4,50 @@ plugins {
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
namespace 'com.anabasis.vkchatmanager'
|
namespace 'com.anabasis.vkchatmanager'
|
||||||
compileSdk {
|
compileSdk 36
|
||||||
version = release(36)
|
|
||||||
}
|
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.anabasis.vkchatmanager"
|
applicationId "com.anabasis.vkchatmanager"
|
||||||
minSdk 26
|
minSdk 26
|
||||||
targetSdk 36
|
targetSdk 36
|
||||||
versionCode 1
|
versionCode 10200
|
||||||
versionName "1.0"
|
versionName "1.2.0"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
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 {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
minifyEnabled true
|
minifyEnabled true
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
|
||||||
|
// Используем signingConfig release
|
||||||
|
signingConfig signingConfigs.release
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_11
|
sourceCompatibility JavaVersion.VERSION_17
|
||||||
targetCompatibility JavaVersion.VERSION_11
|
targetCompatibility JavaVersion.VERSION_17
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
implementation libs.recyclerview
|
||||||
implementation 'androidx.recyclerview:recyclerview:1.3.2'
|
implementation libs.viewpager2
|
||||||
implementation 'androidx.viewpager2:viewpager2:1.1.0'
|
implementation libs.material
|
||||||
implementation "com.google.android.material:material:1.12.0"
|
implementation libs.swiperefreshlayout
|
||||||
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
|
implementation libs.okhttp
|
||||||
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
|
implementation libs.json
|
||||||
implementation 'org.json:json:20240303'
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,10 +42,13 @@ public class ChatListFragment extends Fragment {
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
chats = (ArrayList<VkChat>)
|
Bundle arguments = getArguments();
|
||||||
getArguments().getSerializable(ARG_CHATS);
|
if (arguments != null) {
|
||||||
|
chats = (ArrayList<VkChat>) arguments.getSerializable(ARG_CHATS);
|
||||||
|
}
|
||||||
if (chats == null) chats = new ArrayList<>();
|
if (chats == null) chats = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,11 +93,4 @@ public class ChatListFragment extends Fragment {
|
|||||||
if (c.selected) res.add(c);
|
if (c.selected) res.add(c);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public void updateChats() {
|
|
||||||
if (adapter != null) {
|
|
||||||
adapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,19 +1,22 @@
|
|||||||
package com.anabasis.vkchatmanager;
|
package com.anabasis.vkchatmanager;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.activity.result.ActivityResultLauncher;
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
import androidx.activity.result.contract.ActivityResultContracts;
|
import androidx.activity.result.contract.ActivityResultContracts;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.core.graphics.Insets;
|
import androidx.core.graphics.Insets;
|
||||||
import androidx.core.view.ViewCompat;
|
import androidx.core.view.ViewCompat;
|
||||||
@@ -38,21 +41,23 @@ import org.json.JSONArray;
|
|||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private enum UserAction {
|
||||||
|
ADD, REMOVE, SET_ADMIN
|
||||||
|
}
|
||||||
private VkApiClient api;
|
private VkApiClient api;
|
||||||
|
|
||||||
private final List<VkChat> office = new ArrayList<>();
|
private final List<VkChat> office = new ArrayList<>();
|
||||||
private final List<VkChat> retail = new ArrayList<>();
|
private final List<VkChat> retail = new ArrayList<>();
|
||||||
private final List<VkChat> warehouse = new ArrayList<>();
|
private final List<VkChat> warehouse = new ArrayList<>();
|
||||||
private final List<VkChat> coffee = new ArrayList<>();
|
private final List<VkChat> coffee = new ArrayList<>();
|
||||||
private final List<VkChat> other = new ArrayList<>();
|
private final List<VkChat> other = new ArrayList<>();
|
||||||
|
|
||||||
private final List<Integer> userIdsToProcess = new ArrayList<>();
|
private final Map<Integer, String> usersToProcess = new LinkedHashMap<>();
|
||||||
|
|
||||||
private final List<String> userNamesToProcess = new ArrayList<>();
|
|
||||||
|
|
||||||
private LinearProgressIndicator progressBar;
|
private LinearProgressIndicator progressBar;
|
||||||
private androidx.swiperefreshlayout.widget.SwipeRefreshLayout swipeRefresh;
|
private androidx.swiperefreshlayout.widget.SwipeRefreshLayout swipeRefresh;
|
||||||
@@ -70,13 +75,13 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
result -> {
|
result -> {
|
||||||
if (result.getResultCode() == RESULT_OK) {
|
if (result.getResultCode() == RESULT_OK) {
|
||||||
recreate();
|
recreate();
|
||||||
|
} else {
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
|
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
@@ -150,8 +155,8 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
addBtn.setOnClickListener(v -> processUsers(true));
|
addBtn.setOnClickListener(v -> processUsers(UserAction.ADD));
|
||||||
removeBtn.setOnClickListener(v -> processUsers(false));
|
removeBtn.setOnClickListener(v -> processUsers(UserAction.REMOVE));
|
||||||
showUsersBtn.setOnClickListener(v -> showUsers());
|
showUsersBtn.setOnClickListener(v -> showUsers());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,11 +188,21 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (id == R.id.action_set_admin) {
|
||||||
|
processUsers(UserAction.SET_ADMIN);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (id == R.id.action_token_status) {
|
if (id == R.id.action_token_status) {
|
||||||
showTokenStatus();
|
showTokenStatus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (id == R.id.action_about) {
|
||||||
|
showAboutDialog();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (id == R.id.action_sign_out) {
|
if (id == R.id.action_sign_out) {
|
||||||
TokenManager.clear(this);
|
TokenManager.clear(this);
|
||||||
recreate();
|
recreate();
|
||||||
@@ -207,6 +222,30 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
/* ===================== UI ===================== */
|
/* ===================== UI ===================== */
|
||||||
|
|
||||||
|
private void showAboutDialog() {
|
||||||
|
View dialogView = LayoutInflater.from(this).inflate(R.layout.dialog_about, null);
|
||||||
|
|
||||||
|
TextView appNameVersion = dialogView.findViewById(R.id.app_name_version);
|
||||||
|
TextView appDescription = dialogView.findViewById(R.id.app_description);
|
||||||
|
TextView appCreator = dialogView.findViewById(R.id.app_creator);
|
||||||
|
|
||||||
|
try {
|
||||||
|
PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||||
|
String version = pInfo.versionName;
|
||||||
|
appNameVersion.setText(getString(R.string.app_name_version_format, getString(R.string.app_name), version));
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
appNameVersion.setText(getString(R.string.app_name));
|
||||||
|
}
|
||||||
|
|
||||||
|
appDescription.setText(R.string.about_description);
|
||||||
|
appCreator.setText(R.string.about_creator);
|
||||||
|
|
||||||
|
new MaterialAlertDialogBuilder(this)
|
||||||
|
.setView(dialogView)
|
||||||
|
.setPositiveButton(R.string.ok_button, null)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
private void showTokenStatus() {
|
private void showTokenStatus() {
|
||||||
long exp = TokenManager.expiration(this);
|
long exp = TokenManager.expiration(this);
|
||||||
String message;
|
String message;
|
||||||
@@ -350,8 +389,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
/* ===================== LINKS ===================== */
|
/* ===================== LINKS ===================== */
|
||||||
|
|
||||||
private void processLinksList(List<String> links) {
|
private void processLinksList(List<String> links) {
|
||||||
userIdsToProcess.clear();
|
usersToProcess.clear();
|
||||||
userNamesToProcess.clear();
|
|
||||||
|
|
||||||
setUiEnabled(false);
|
setUiEnabled(false);
|
||||||
|
|
||||||
@@ -361,8 +399,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
String screen = extractScreenName(link);
|
String screen = extractScreenName(link);
|
||||||
int uid = api.resolveUserId(screen);
|
int uid = api.resolveUserId(screen);
|
||||||
if (uid > 0) {
|
if (uid > 0) {
|
||||||
userIdsToProcess.add(uid);
|
usersToProcess.put(uid, api.getUserName(uid));
|
||||||
userNamesToProcess.add(api.getUserName(uid));
|
|
||||||
}
|
}
|
||||||
} catch (TokenExpiredException e) {
|
} catch (TokenExpiredException e) {
|
||||||
runOnUiThread(this::handleTokenExpired);
|
runOnUiThread(this::handleTokenExpired);
|
||||||
@@ -373,7 +410,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
setUiEnabled(true);
|
setUiEnabled(true);
|
||||||
Toast.makeText(
|
Toast.makeText(
|
||||||
this,
|
this,
|
||||||
getString(R.string.users_loaded_message, userIdsToProcess.size()),
|
getString(R.string.users_loaded_message, usersToProcess.size()),
|
||||||
Toast.LENGTH_SHORT
|
Toast.LENGTH_SHORT
|
||||||
).show();
|
).show();
|
||||||
});
|
});
|
||||||
@@ -398,16 +435,16 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ===================== ADD / REMOVE ===================== */
|
/* ===================== ADD / REMOVE / SET_ADMIN ===================== */
|
||||||
|
|
||||||
private void showUsers() {
|
private void showUsers() {
|
||||||
if (userNamesToProcess.isEmpty()) {
|
if (usersToProcess.isEmpty()) {
|
||||||
Toast.makeText(this, getString(R.string.user_list_empty), Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, getString(R.string.user_list_empty), Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder msg = new StringBuilder();
|
StringBuilder msg = new StringBuilder();
|
||||||
for (String name : userNamesToProcess) {
|
for (String name : usersToProcess.values()) {
|
||||||
msg.append("• ").append(name).append("\n");
|
msg.append("• ").append(name).append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,10 +455,13 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processUsers(boolean add) {
|
private void processUsers(UserAction action) {
|
||||||
|
|
||||||
List<VkChat> chats = getCurrentFragment().getSelected();
|
ChatListFragment currentFragment = getCurrentFragment();
|
||||||
if (chats.isEmpty() || userIdsToProcess.isEmpty()) {
|
if (currentFragment == null) return;
|
||||||
|
|
||||||
|
List<VkChat> chats = currentFragment.getSelected();
|
||||||
|
if (chats.isEmpty() || usersToProcess.isEmpty()) {
|
||||||
Toast.makeText(this,
|
Toast.makeText(this,
|
||||||
getString(R.string.no_chats_or_users_selected_message),
|
getString(R.string.no_chats_or_users_selected_message),
|
||||||
Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
@@ -429,10 +469,20 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder msg = new StringBuilder();
|
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");
|
msg.append("\n\n");
|
||||||
|
|
||||||
for (String name : userNamesToProcess) {
|
for (String name : usersToProcess.values()) {
|
||||||
msg.append("• ").append(name).append("\n");
|
msg.append("• ").append(name).append("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -447,18 +497,18 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
.setTitle(getString(R.string.confirmation_dialog_title))
|
.setTitle(getString(R.string.confirmation_dialog_title))
|
||||||
.setMessage(msg.toString())
|
.setMessage(msg.toString())
|
||||||
.setPositiveButton(getString(R.string.confirm_button), (d, w) ->
|
.setPositiveButton(getString(R.string.confirm_button), (d, w) ->
|
||||||
executeUsers(add, chats))
|
executeUsers(action, chats))
|
||||||
.setNegativeButton(getString(R.string.cancel_button), null)
|
.setNegativeButton(getString(R.string.cancel_button), null)
|
||||||
.show();
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void executeUsers(boolean add, List<VkChat> chats) {
|
private void executeUsers(UserAction action, List<VkChat> chats) {
|
||||||
setUiEnabled(false);
|
setUiEnabled(false);
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
progressBar.setIndeterminate(false);
|
progressBar.setIndeterminate(false);
|
||||||
progressBar.setProgress(0, true);
|
progressBar.setProgress(0, true);
|
||||||
|
|
||||||
int totalOps = chats.size() * userIdsToProcess.size();
|
int totalOps = chats.size() * usersToProcess.size();
|
||||||
progressBar.setMax(totalOps);
|
progressBar.setMax(totalOps);
|
||||||
|
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
@@ -466,19 +516,27 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
int done = 0;
|
int done = 0;
|
||||||
|
|
||||||
for (VkChat c : chats) {
|
for (VkChat c : chats) {
|
||||||
for (int i = 0; i < userIdsToProcess.size(); i++) {
|
for (Map.Entry<Integer, String> user : usersToProcess.entrySet()) {
|
||||||
int uid = userIdsToProcess.get(i);
|
int uid = user.getKey();
|
||||||
String userName = userNamesToProcess.get(i);
|
String userName = user.getValue();
|
||||||
String resultMessage;
|
String resultMessage;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (add) {
|
resultMessage = switch (action) {
|
||||||
api.addUser(c.id, uid, true);
|
case ADD -> {
|
||||||
resultMessage = getString(R.string.op_success_add_format, userName, c.title);
|
api.addUser(c.id, uid, true);
|
||||||
} else {
|
yield getString(R.string.op_success_add_format, userName, c.title);
|
||||||
api.removeUser(c.id, uid);
|
}
|
||||||
resultMessage = getString(R.string.op_success_remove_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) {
|
} catch (TokenExpiredException e) {
|
||||||
runOnUiThread(this::handleTokenExpired);
|
runOnUiThread(this::handleTokenExpired);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package com.anabasis.vkchatmanager.dialogs;
|
|||||||
|
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
|
|
||||||
@@ -33,7 +32,7 @@ public class MultiLinkDialog extends DialogFragment {
|
|||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
|
|
||||||
View view = LayoutInflater.from(requireContext()).inflate(R.layout.dialog_multilink, null);
|
View view = getLayoutInflater().inflate(R.layout.dialog_multilink, null);
|
||||||
EditText input = view.findViewById(R.id.linksInput);
|
EditText input = view.findViewById(R.id.linksInput);
|
||||||
|
|
||||||
return new MaterialAlertDialogBuilder(requireContext())
|
return new MaterialAlertDialogBuilder(requireContext())
|
||||||
|
|||||||
@@ -23,20 +23,21 @@ public class VkApiClient {
|
|||||||
"&v=5.131";
|
"&v=5.131";
|
||||||
|
|
||||||
Request r = new Request.Builder().url(url).build();
|
Request r = new Request.Builder().url(url).build();
|
||||||
Response res = client.newCall(r).execute();
|
try (Response res = client.newCall(r).execute()) {
|
||||||
|
|
||||||
String body = res.body().string();
|
|
||||||
JSONObject json = new JSONObject(body);
|
|
||||||
|
|
||||||
if (json.has("error")) {
|
String body = res.body().string();
|
||||||
JSONObject error = json.getJSONObject("error");
|
JSONObject json = new JSONObject(body);
|
||||||
if (error.getInt("error_code") == 5) {
|
|
||||||
throw new TokenExpiredException();
|
if (json.has("error")) {
|
||||||
|
JSONObject error = json.getJSONObject("error");
|
||||||
|
if (error.getInt("error_code") == 5) {
|
||||||
|
throw new TokenExpiredException();
|
||||||
|
}
|
||||||
|
throw new Exception(error.getString("error_msg"));
|
||||||
}
|
}
|
||||||
throw new Exception(error.getString("error_msg"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return json;
|
return json;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONArray getChats() throws Exception {
|
public JSONArray getChats() throws Exception {
|
||||||
@@ -58,6 +59,13 @@ public class VkApiClient {
|
|||||||
"&member_id=" + userId);
|
"&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 {
|
public int resolveUserId(String screenName) throws Exception {
|
||||||
|
|
||||||
JSONObject resp = call(
|
JSONObject resp = call(
|
||||||
|
|||||||
@@ -121,7 +121,9 @@
|
|||||||
<androidx.viewpager2.widget.ViewPager2
|
<androidx.viewpager2.widget.ViewPager2
|
||||||
android:id="@+id/pager"
|
android:id="@+id/pager"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent"
|
||||||
|
android:paddingStart="16dp"
|
||||||
|
android:paddingEnd="16dp" />
|
||||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|||||||
40
app/src/main/res/layout/dialog_about.xml
Normal file
40
app/src/main/res/layout/dialog_about.xml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="24dp"
|
||||||
|
android:gravity="center_horizontal">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/app_icon"
|
||||||
|
android:layout_width="72dp"
|
||||||
|
android:layout_height="72dp"
|
||||||
|
android:src="@mipmap/ic_launcher_round"
|
||||||
|
android:contentDescription="@string/app_name" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/app_name_version"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:textAppearance="?attr/textAppearanceTitleLarge"
|
||||||
|
tools:text="VK Chat Manager v1.0" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/app_description"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textAppearance="?attr/textAppearanceBodyMedium" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/app_creator"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:textAppearance="?attr/textAppearanceBodySmall" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -12,10 +12,16 @@
|
|||||||
<item
|
<item
|
||||||
android:id="@+id/action_deselect_all"
|
android:id="@+id/action_deselect_all"
|
||||||
android:title="@string/action_deselect_all" />
|
android:title="@string/action_deselect_all" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_set_admin"
|
||||||
|
android:title="@string/action_set_admin" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_token_status"
|
android:id="@+id/action_token_status"
|
||||||
android:title="@string/action_token_status" />
|
android:title="@string/action_token_status" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_about"
|
||||||
|
android:title="@string/action_about" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_sign_out"
|
android:id="@+id/action_sign_out"
|
||||||
android:title="@string/action_sign_out" />
|
android:title="@string/action_sign_out" />
|
||||||
</menu>
|
</menu>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
<string name="no_chats_or_users_selected_message">Не выбраны чаты или пользователи</string>
|
<string name="no_chats_or_users_selected_message">Не выбраны чаты или пользователи</string>
|
||||||
<string name="add_users_dialog_message">Добавить пользователей:</string>
|
<string name="add_users_dialog_message">Добавить пользователей:</string>
|
||||||
<string name="remove_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="in_chats_dialog_message">В чаты:</string>
|
||||||
<string name="confirmation_dialog_title">Подтверждение</string>
|
<string name="confirmation_dialog_title">Подтверждение</string>
|
||||||
<string name="confirm_button">Подтвердить</string>
|
<string name="confirm_button">Подтвердить</string>
|
||||||
@@ -27,6 +28,7 @@
|
|||||||
<string name="action_refresh">Обновить</string>
|
<string name="action_refresh">Обновить</string>
|
||||||
<string name="action_select_all">Выбрать все</string>
|
<string name="action_select_all">Выбрать все</string>
|
||||||
<string name="action_deselect_all">Снять выбор</string>
|
<string name="action_deselect_all">Снять выбор</string>
|
||||||
|
<string name="action_set_admin">Назначить администратором</string>
|
||||||
<string name="action_token_status">Статус токена</string>
|
<string name="action_token_status">Статус токена</string>
|
||||||
<string name="token_status_title">Статус токена</string>
|
<string name="token_status_title">Статус токена</string>
|
||||||
<string name="token_status_perpetual">Токен бессрочный</string>
|
<string name="token_status_perpetual">Токен бессрочный</string>
|
||||||
@@ -39,8 +41,13 @@
|
|||||||
<string name="op_unknown_error">неизвестная ошибка</string>
|
<string name="op_unknown_error">неизвестная ошибка</string>
|
||||||
<string name="op_success_add_format">✅ %1$s в %2$s: Успешно</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_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="op_failure_format">❌ %1$s в %2$s: %3$s</string>
|
||||||
<string name="action_sign_out">Выйти</string>
|
<string name="action_sign_out">Выйти</string>
|
||||||
<string name="api_error">Ошибка API: %s</string>
|
<string name="api_error">Ошибка API: %s</string>
|
||||||
|
<string name="action_about">О приложении</string>
|
||||||
<string name="token_expired_message">Ваша сессия истекла. Пожалуйста, войдите снова.</string>
|
<string name="token_expired_message">Ваша сессия истекла. Пожалуйста, войдите снова.</string>
|
||||||
|
<string name="app_name_version_format">%1$s v%2$s</string>
|
||||||
|
<string name="about_description">Это приложение предназначено для управления чатами ВКонтакте.</string>
|
||||||
|
<string name="about_creator">Создатель: Александр Денисов</string>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
<string name="no_chats_or_users_selected_message">No chats or users selected</string>
|
<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="add_users_dialog_message">Add users:</string>
|
||||||
<string name="remove_users_dialog_message">Remove 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="in_chats_dialog_message">In chats:</string>
|
||||||
<string name="confirmation_dialog_title">Confirmation</string>
|
<string name="confirmation_dialog_title">Confirmation</string>
|
||||||
<string name="confirm_button">Confirm</string>
|
<string name="confirm_button">Confirm</string>
|
||||||
@@ -27,6 +28,7 @@
|
|||||||
<string name="action_refresh">Refresh</string>
|
<string name="action_refresh">Refresh</string>
|
||||||
<string name="action_select_all">Select All</string>
|
<string name="action_select_all">Select All</string>
|
||||||
<string name="action_deselect_all">Deselect 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="action_token_status">Token Status</string>
|
||||||
<string name="token_status_title">Token Status</string>
|
<string name="token_status_title">Token Status</string>
|
||||||
<string name="token_status_perpetual">Token is perpetual</string>
|
<string name="token_status_perpetual">Token is perpetual</string>
|
||||||
@@ -39,8 +41,13 @@
|
|||||||
<string name="op_unknown_error">unknown error</string>
|
<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_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_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="op_failure_format">❌ %1$s in %2$s: %3$s</string>
|
||||||
<string name="action_sign_out">Sign Out</string>
|
<string name="action_sign_out">Sign Out</string>
|
||||||
<string name="api_error">API error: %s</string>
|
<string name="api_error">API error: %s</string>
|
||||||
|
<string name="action_about">About</string>
|
||||||
<string name="token_expired_message">Your session has expired. Please log in again.</string>
|
<string name="token_expired_message">Your session has expired. Please log in again.</string>
|
||||||
|
<string name="app_name_version_format">%1$s v%2$s</string>
|
||||||
|
<string name="about_description">This application is designed for managing VK chats.</string>
|
||||||
|
<string name="about_creator">Created by: Alex Denisov</string>
|
||||||
</resources>
|
</resources>
|
||||||
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 |
@@ -1,20 +1,20 @@
|
|||||||
[versions]
|
[versions]
|
||||||
agp = "9.0.0"
|
agp = "9.0.0"
|
||||||
coreKtx = "1.17.0"
|
|
||||||
junit = "4.13.2"
|
|
||||||
junitVersion = "1.3.0"
|
|
||||||
espressoCore = "3.7.0"
|
|
||||||
appcompat = "1.7.1"
|
|
||||||
material = "1.13.0"
|
material = "1.13.0"
|
||||||
|
recyclerview = "1.4.0"
|
||||||
|
viewpager2 = "1.1.0"
|
||||||
|
swiperefreshlayout = "1.2.0"
|
||||||
|
okhttp = "5.3.2"
|
||||||
|
json = "20251224"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
|
|
||||||
junit = { group = "junit", name = "junit", version.ref = "junit" }
|
|
||||||
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
|
|
||||||
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
|
|
||||||
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
|
|
||||||
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
|
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
|
||||||
|
recyclerview = { group = "androidx.recyclerview", name = "recyclerview", version.ref = "recyclerview" }
|
||||||
|
viewpager2 = { group = "androidx.viewpager2", name = "viewpager2", version.ref = "viewpager2" }
|
||||||
|
swiperefreshlayout = { group = "androidx.swiperefreshlayout", name = "swiperefreshlayout", version.ref = "swiperefreshlayout" }
|
||||||
|
okhttp = { group = "com.squareup.okhttp3", name = "okhttp", version.ref = "okhttp" }
|
||||||
|
json = { group = "org.json", name = "json", version.ref = "json" }
|
||||||
|
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ pluginManagement {
|
|||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencyResolutionManagement {
|
dependencyResolutionManagement {
|
||||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||||
repositories {
|
repositories {
|
||||||
|
|||||||
Reference in New Issue
Block a user