mirror of
https://github.com/wrwrabbit/Partisan-Telegram-Android.git
synced 2026-05-09 19:50:12 +00:00
Update to 5.13.0 (1818)
This commit is contained in:
parent
28eb8dfd0e
commit
f41b228a11
2574 changed files with 1023378 additions and 62330 deletions
|
|
@ -9,11 +9,13 @@
|
|||
package org.telegram.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.SQLite.SQLiteCursor;
|
||||
import org.telegram.SQLite.SQLiteDatabase;
|
||||
|
|
@ -72,8 +74,9 @@ public class CacheControlActivity extends BaseFragment {
|
|||
private long musicSize = -1;
|
||||
private long photoSize = -1;
|
||||
private long videoSize = -1;
|
||||
private long stickersSize = -1;
|
||||
private long totalSize = -1;
|
||||
private boolean[] clear = new boolean[6];
|
||||
private boolean[] clear = new boolean[7];
|
||||
private boolean calculating = true;
|
||||
|
||||
private volatile boolean canceled = false;
|
||||
|
|
@ -114,8 +117,12 @@ public class CacheControlActivity extends BaseFragment {
|
|||
if (canceled) {
|
||||
return;
|
||||
}
|
||||
stickersSize = getDirectorySize(new File(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_CACHE), "acache"), 0);
|
||||
if (canceled) {
|
||||
return;
|
||||
}
|
||||
audioSize = getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_AUDIO), 0);
|
||||
totalSize = cacheSize + videoSize + audioSize + photoSize + documentsSize + musicSize;
|
||||
totalSize = cacheSize + videoSize + audioSize + photoSize + documentsSize + musicSize + stickersSize;
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
calculating = false;
|
||||
if (listAdapter != null) {
|
||||
|
|
@ -139,7 +146,7 @@ public class CacheControlActivity extends BaseFragment {
|
|||
}
|
||||
long size = 0;
|
||||
if (dir.isDirectory()) {
|
||||
size = Utilities.getDirSize(dir.getAbsolutePath(), documentsMusicType);
|
||||
size = Utilities.getDirSize(dir.getAbsolutePath(), documentsMusicType, false);
|
||||
} else if (dir.isFile()) {
|
||||
size += dir.length();
|
||||
}
|
||||
|
|
@ -152,7 +159,7 @@ public class CacheControlActivity extends BaseFragment {
|
|||
progressDialog.show();
|
||||
Utilities.globalQueue.postRunnable(() -> {
|
||||
boolean imagesCleared = false;
|
||||
for (int a = 0; a < 6; a++) {
|
||||
for (int a = 0; a < 7; a++) {
|
||||
if (!clear[a]) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -171,14 +178,21 @@ public class CacheControlActivity extends BaseFragment {
|
|||
} else if (a == 4) {
|
||||
type = FileLoader.MEDIA_DIR_AUDIO;
|
||||
} else if (a == 5) {
|
||||
type = 100;
|
||||
} else if (a == 6) {
|
||||
type = FileLoader.MEDIA_DIR_CACHE;
|
||||
}
|
||||
if (type == -1) {
|
||||
continue;
|
||||
}
|
||||
File file = FileLoader.checkDirectory(type);
|
||||
File file;
|
||||
if (type == 100) {
|
||||
file = new File(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_CACHE), "acache");
|
||||
} else {
|
||||
file = FileLoader.checkDirectory(type);
|
||||
}
|
||||
if (file != null) {
|
||||
Utilities.clearDir(file.getAbsolutePath(), documentsMusicType, Long.MAX_VALUE);
|
||||
Utilities.clearDir(file.getAbsolutePath(), documentsMusicType, Long.MAX_VALUE, false);
|
||||
}
|
||||
if (type == FileLoader.MEDIA_DIR_CACHE) {
|
||||
cacheSize = getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_CACHE), documentsMusicType);
|
||||
|
|
@ -196,10 +210,13 @@ public class CacheControlActivity extends BaseFragment {
|
|||
photoSize = getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_IMAGE), documentsMusicType);
|
||||
} else if (type == FileLoader.MEDIA_DIR_VIDEO) {
|
||||
videoSize = getDirectorySize(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_VIDEO), documentsMusicType);
|
||||
} else if (type == 100) {
|
||||
imagesCleared = true;
|
||||
stickersSize = getDirectorySize(new File(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_CACHE), "acache"), documentsMusicType);
|
||||
}
|
||||
}
|
||||
final boolean imagesClearedFinal = imagesCleared;
|
||||
totalSize = cacheSize + videoSize + audioSize + photoSize + documentsSize + musicSize;
|
||||
totalSize = cacheSize + videoSize + audioSize + photoSize + documentsSize + musicSize + stickersSize;
|
||||
AndroidUtilities.runOnUIThread(() -> {
|
||||
if (imagesClearedFinal) {
|
||||
ImageLoader.getInstance().clearMemory();
|
||||
|
|
@ -265,9 +282,9 @@ public class CacheControlActivity extends BaseFragment {
|
|||
showDialog(builder.create());
|
||||
} else if (position == databaseRow) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
||||
builder.setTitle(LocaleController.getString("LocalDatabaseClearTextTitle", R.string.LocalDatabaseClearTextTitle));
|
||||
builder.setMessage(LocaleController.getString("LocalDatabaseClearText", R.string.LocalDatabaseClearText));
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
builder.setMessage(LocaleController.getString("LocalDatabaseClear", R.string.LocalDatabaseClear));
|
||||
builder.setPositiveButton(LocaleController.getString("CacheClear", R.string.CacheClear), (dialogInterface, i) -> {
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
|
|
@ -368,17 +385,21 @@ public class CacheControlActivity extends BaseFragment {
|
|||
}
|
||||
});
|
||||
});
|
||||
showDialog(builder.create());
|
||||
AlertDialog alertDialog = builder.create();
|
||||
showDialog(alertDialog);
|
||||
TextView button = (TextView) alertDialog.getButton(DialogInterface.BUTTON_POSITIVE);
|
||||
if (button != null) {
|
||||
button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
|
||||
}
|
||||
} else if (position == cacheRow) {
|
||||
if (totalSize <= 0 || getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity());
|
||||
builder.setApplyTopPadding(false);
|
||||
builder.setApplyBottomPadding(false);
|
||||
LinearLayout linearLayout = new LinearLayout(getParentActivity());
|
||||
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
for (int a = 0; a < 6; a++) {
|
||||
for (int a = 0; a < 7; a++) {
|
||||
long size = 0;
|
||||
String name = null;
|
||||
if (a == 0) {
|
||||
|
|
@ -397,6 +418,9 @@ public class CacheControlActivity extends BaseFragment {
|
|||
size = audioSize;
|
||||
name = LocaleController.getString("LocalAudioCache", R.string.LocalAudioCache);
|
||||
} else if (a == 5) {
|
||||
size = stickersSize;
|
||||
name = LocaleController.getString("AnimatedStickers", R.string.AnimatedStickers);
|
||||
} else if (a == 6) {
|
||||
size = cacheSize;
|
||||
name = LocaleController.getString("LocalCache", R.string.LocalCache);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue