Scan files so they show up under images (Cheogram)

This commit is contained in:
Arne 2023-05-23 12:14:14 +02:00
parent ba9c63b6e8
commit 1d0cdab857

View file

@ -14,6 +14,7 @@ import android.provider.DocumentsContract;
import android.preference.PreferenceManager;
import android.provider.MediaStore;
import android.util.Log;
import android.media.MediaScannerConnection;
import androidx.core.app.NotificationCompat;
@ -96,6 +97,19 @@ public class DownloadDefaultStickers extends Service {
mDatabaseBackend.saveCid(cid, file, sticker.getString("url"));
}
MediaScannerConnection.scanFile(
getBaseContext(),
new String[] { file.getAbsolutePath() },
null,
new MediaScannerConnection.MediaScannerConnectionClient() {
@Override
public void onMediaScannerConnected() {}
@Override
public void onScanCompleted(String path, Uri uri) {}
}
);
try {
File copyright = new File(mStickerDir.getAbsolutePath() + "/" + sticker.getString("pack") + "/copyright.txt");
OutputStreamWriter w = new OutputStreamWriter(new FileOutputStream(copyright, true), "utf-8");