Change sticker directory + long press to save sticker of others + save received/send image as sticker

This commit is contained in:
12aw 2024-01-09 18:11:28 +01:00
parent 38bd934895
commit 9a1c33c1a3
5 changed files with 32 additions and 22 deletions

View file

@ -28,19 +28,6 @@
"versionName": "1.7.8.5",
"outputFile": "monocles chat-1.7.8.5-git-x86-release.apk"
},
{
"type": "ONE_OF_MANY",
"filters": [
{
"filterType": "ABI",
"value": "armeabi-v7a"
}
],
"attributes": [],
"versionCode": 15601,
"versionName": "1.7.8.5",
"outputFile": "monocles chat-1.7.8.5-git-armeabi-v7a-release.apk"
},
{
"type": "ONE_OF_MANY",
"filters": [
@ -66,6 +53,19 @@
"versionCode": 15604,
"versionName": "1.7.8.5",
"outputFile": "monocles chat-1.7.8.5-git-arm64-v8a-release.apk"
},
{
"type": "ONE_OF_MANY",
"filters": [
{
"filterType": "ABI",
"value": "armeabi-v7a"
}
],
"attributes": [],
"versionCode": 15601,
"versionName": "1.7.8.5",
"outputFile": "monocles chat-1.7.8.5-git-armeabi-v7a-release.apk"
}
],
"elementType": "File"

View file

@ -121,6 +121,16 @@ public class DownloadDefaultStickers extends Service {
mDatabaseBackend.saveCid(cid, file, sticker.getString("url"));
}
File nomediastickers = new File(mStickerDir.getAbsolutePath() + "/" + sticker.getString("pack") + "/" + ".nomedia");
File nomediastickersfolder = new File(mStickerDir.getAbsolutePath() + "/" + ".nomedia");
try {
nomediastickers.createNewFile();
nomediastickersfolder.createNewFile();
} catch (final Exception e) {
e.printStackTrace();
}
if (file != null) {
MediaScannerConnection.scanFile(
getBaseContext(),
@ -187,7 +197,7 @@ public class DownloadDefaultStickers extends Service {
}
private File stickerDir() {
return new File(this.getFilesDir() + File.separator + "Stickers");
return new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + File.separator + APP_DIRECTORY + File.separator + "Stickers");
}
@Override

View file

@ -779,7 +779,7 @@ public class XmppConnectionService extends Service {
}
private File stickerDir() {
return new File(this.getFilesDir() + File.separator + "Stickers");
return new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + File.separator + APP_DIRECTORY + File.separator + "Stickers");
}
public void rescanStickers() {

View file

@ -2014,7 +2014,7 @@ public class ConversationFragment extends XmppFragment
final String path = m.getRelativeFilePath();
Log.d(Config.LOGTAG, "Path = " + path);
if (path == null || !path.startsWith("/") || path.contains(getConversationsDirectory(this.activity, "null").getAbsolutePath())) {
//saveAsSticker.setVisible(true); TODO: Enable it again with better storage handling
saveAsSticker.setVisible(true);
blockMedia.setVisible(true);
deleteFile.setVisible(true);
deleteFile.setTitle(activity.getString(R.string.delete_x_file, UIHelper.getFileDescriptionString(activity, m)));
@ -3236,14 +3236,14 @@ public class ConversationFragment extends XmppFragment
InputStream in;
OutputStream out;
try {
File stickerfolder = new File(activity.getFilesDir() + File.separator + "Stickers" + File.separator + "User");
File stickerfolder = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + File.separator + APP_DIRECTORY + File.separator + "Stickers" + File.separator + "User");
//create output directory if it doesn't exist
if (!stickerfolder.exists()) {
stickerfolder.mkdirs();
}
String filename = "user_" + getConversation().getName() + "_" + System.currentTimeMillis();
File newSticker = new File(activity.getFilesDir() + File.separator + "Stickers" + File.separator + "User" + File.separator + filename);
File newSticker = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + File.separator + APP_DIRECTORY + File.separator + "Stickers" + File.separator + "User" + File.separator + filename);
in = activity.getContentResolver().openInputStream(imageUri);
out = new FileOutputStream(newSticker);

View file

@ -186,13 +186,13 @@ public class SettingsActivity extends XmppActivity implements OnSharedPreference
InputStream in;
OutputStream out;
try {
File stickerfolder = new File(this.getFilesDir() + File.separator + STICKER_DIR + File.separator + "Custom");
File stickerfolder = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + File.separator + APP_DIRECTORY + File.separator + "Stickers" + File.separator + "Custom");
//create output directory if it doesn't exist
if (!stickerfolder.exists()) {
stickerfolder.mkdirs();
}
String filename = getFileName(imageUri);
File newSticker = new File(this.getFilesDir() + File.separator + STICKER_DIR + File.separator + "Custom" + File.separator + filename);
File newSticker = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + File.separator + APP_DIRECTORY + File.separator + "Stickers" + File.separator + "Custom" + File.separator + filename);
in = getContentResolver().openInputStream(imageUri);
out = new FileOutputStream(newSticker);
@ -225,13 +225,13 @@ public class SettingsActivity extends XmppActivity implements OnSharedPreference
InputStream in;
OutputStream out;
try {
File stickerfolder = new File(this.getFilesDir() + File.separator + STICKER_DIR + File.separator + "Custom");
File stickerfolder = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + File.separator + APP_DIRECTORY + File.separator + "Stickers" + File.separator + "Custom");
//create output directory if it doesn't exist
if (!stickerfolder.exists()) {
stickerfolder.mkdirs();
}
String filename = getFileName(imageUri);
File newSticker = new File(this.getFilesDir() + File.separator + STICKER_DIR + File.separator + "Custom" + File.separator + filename);
File newSticker = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + File.separator + APP_DIRECTORY + File.separator + "Stickers" + File.separator + "Custom" + File.separator + filename);
in = getContentResolver().openInputStream(imageUri);
out = new FileOutputStream(newSticker);