fix paths for cache directory [Christian Schneppe]

This commit is contained in:
12aw 2022-03-19 18:07:27 +01:00
parent b672d48d49
commit e23a75470f
7 changed files with 27 additions and 31 deletions

View file

@ -47,23 +47,23 @@ public class StorageHelper {
} }
public static String getGlobalPicturesPath() { public static String getGlobalPicturesPath() {
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + File.separator + "blabber.im" + File.separator; return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + File.separator + "monocles chat" + File.separator;
} }
public static String getGlobalVideosPath() { public static String getGlobalVideosPath() {
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES) + File.separator + "blabber.im" + File.separator; return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES) + File.separator + "monocles chat" + File.separator;
} }
public static String getGlobalDocumentsPath() { public static String getGlobalDocumentsPath() {
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + File.separator + "blabber.im" + File.separator; return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + File.separator + "monocles chat" + File.separator;
} }
public static String getGlobalDownloadsPath() { public static String getGlobalDownloadsPath() {
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + File.separator + "blabber.im" + File.separator; return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + File.separator + "monocles chat" + File.separator;
} }
public static String getGlobalAudiosPath() { public static String getGlobalAudiosPath() {
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC) + File.separator + "blabber.im" + File.separator; return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC) + File.separator + "monocles chat" + File.separator;
} }
public static String getAppUpdateDirectory() { public static String getAppUpdateDirectory() {

View file

@ -105,7 +105,7 @@ public class FileBackend {
private static final SimpleDateFormat fileDateFormat = new SimpleDateFormat("yyyyMMdd_HHmmssSSS", Locale.US); private static final SimpleDateFormat fileDateFormat = new SimpleDateFormat("yyyyMMdd_HHmmssSSS", Locale.US);
private static final String FILE_PROVIDER = ".files"; private static final String FILE_PROVIDER = ".files";
public static final String APP_DIRECTORY = "blabber.im"; public static final String APP_DIRECTORY = "monocles chat";
public static final String FILES = "Files"; public static final String FILES = "Files";
public static final String SENT_FILES = "Files" + File.separator + "Sent"; public static final String SENT_FILES = "Files" + File.separator + "Sent";
public static final String AUDIOS = "Audios"; public static final String AUDIOS = "Audios";
@ -1199,14 +1199,7 @@ public class FileBackend {
} }
public static Uri getUriForFile(Context context, File file) { public static Uri getUriForFile(Context context, File file) {
if (PreferenceManager.getDefaultSharedPreferences(context) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N || PreferenceManager.getDefaultSharedPreferences(context).getBoolean(SettingsActivity.USE_INNER_STORAGE, context.getResources().getBoolean(R.bool.use_inner_storage))) {
.getBoolean(SettingsActivity.USE_INNER_STORAGE, true)) {
File dataUser0File = new File(file.getAbsolutePath().replace(File.separator + "data" + File.separator + "data", File.separator + "data" + File.separator + "user" + File.separator + "0"));
return FileProvider.getUriForFile(context
, getAuthority(context)
, dataUser0File.exists() ? dataUser0File : file);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
try { try {
return FileProvider.getUriForFile(context, getAuthority(context), file); return FileProvider.getUriForFile(context, getAuthority(context), file);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {

View file

@ -160,8 +160,8 @@ public class AttachFileToConversationRunnable implements Runnable, TranscoderLis
onTranscodeCanceled(); onTranscodeCanceled();
return null; return null;
} else if (estimatedFileSize >= sizeAfterCompression && sizeAfterCompression <= originalFileSize) { } else if (estimatedFileSize >= sizeAfterCompression && sizeAfterCompression <= originalFileSize) {
return Transcoder.into(file.getAbsolutePath()). return Transcoder.into(file.getAbsolutePath())
addDataSource(mXmppConnectionService, uri) .addDataSource(mXmppConnectionService, uri)
.setVideoTrackStrategy(TranscoderStrategies.VIDEO(mXmppConnectionService.getCompressVideoBitratePreference(), mXmppConnectionService.getCompressVideoResolutionPreference())) .setVideoTrackStrategy(TranscoderStrategies.VIDEO(mXmppConnectionService.getCompressVideoBitratePreference(), mXmppConnectionService.getCompressVideoResolutionPreference()))
.setAudioTrackStrategy(mXmppConnectionService.getCompressAudioPreference()) .setAudioTrackStrategy(mXmppConnectionService.getCompressAudioPreference())
.setListener(this) .setListener(this)
@ -186,8 +186,8 @@ public class AttachFileToConversationRunnable implements Runnable, TranscoderLis
newResoloution = mXmppConnectionService.getResources().getInteger(R.integer.high_video_res); newResoloution = mXmppConnectionService.getResources().getInteger(R.integer.high_video_res);
audioStrategy = TranscoderStrategies.AUDIO_HQ; audioStrategy = TranscoderStrategies.AUDIO_HQ;
} }
return Transcoder.into(file.getAbsolutePath()). return Transcoder.into(file.getAbsolutePath())
addDataSource(mXmppConnectionService, uri) .addDataSource(mXmppConnectionService, uri)
.setVideoTrackStrategy(TranscoderStrategies.VIDEO(newBitrate, newResoloution)) .setVideoTrackStrategy(TranscoderStrategies.VIDEO(newBitrate, newResoloution))
.setAudioTrackStrategy(audioStrategy) .setAudioTrackStrategy(audioStrategy)
.setListener(this) .setListener(this)

View file

@ -876,7 +876,7 @@ public class XmppConnectionService extends Service {
expireOldFiles(); expireOldFiles();
deleteWebpreviewCache(); deleteWebpreviewCache();
} }
// move files from /blabber.im/ --> /Android/data/ for Android >= 30 // move files from /monocles chat/ --> /Android/data/ for Android >= 30
if (Compatibility.runsThirty() && (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED if (Compatibility.runsThirty() && (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
&& ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)) { && ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)) {
StorageHelper.migrateStorage(this); StorageHelper.migrateStorage(this);

View file

@ -14,7 +14,7 @@
\n\nYou should have received a copy of the GNU General Public License \n\nYou should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses along with this program. If not, see https://www.gnu.org/licenses
\n\nDownload the full original source code at https://github.com/siacs/Conversations (Copyright © Daniel Gultsch) \n\nDownload the full original source code at https://github.com/siacs/Conversations (Copyright © Daniel Gultsch)
\n\nDownload the modified source code at https://codeberg.org/kriztan/blabber.im \n\nDownload the modified source code at https://codeberg.org/Arne/monocles_chat
\n\nOr at https://codeberg.org/Arne/monocles_chat \n\nOr at https://codeberg.org/Arne/monocles_chat
\n\nYou can buy me a coffee by making a donation in form of a gift in sense of § 516 ff BGB i.e. a gratuitous donation via PayPal for arne-bruen@monocles.de \n\nYou can buy me a coffee by making a donation in form of a gift in sense of § 516 ff BGB i.e. a gratuitous donation via PayPal for arne-bruen@monocles.de
</string> </string>

View file

@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<paths> <paths>
<root-path
name="root"
path="." />
<external-path <external-path
name="external" name="external"
path="/" /> path="/" />

View file

@ -75,23 +75,23 @@ public class StorageHelper {
} }
public static String getGlobalPicturesPath() { public static String getGlobalPicturesPath() {
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + File.separator + "blabber.im" + File.separator; return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + File.separator + "monocles chat" + File.separator;
} }
public static String getGlobalVideosPath() { public static String getGlobalVideosPath() {
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES) + File.separator + "blabber.im"+ File.separator; return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MOVIES) + File.separator + "monocles chat"+ File.separator;
} }
public static String getGlobalDocumentsPath() { public static String getGlobalDocumentsPath() {
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + File.separator + "blabber.im"+ File.separator; return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS) + File.separator + "monocles chat"+ File.separator;
} }
public static String getGlobalDownloadsPath() { public static String getGlobalDownloadsPath() {
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + File.separator + "blabber.im"+ File.separator; return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + File.separator + "monocles chat"+ File.separator;
} }
public static String getGlobalAudiosPath() { public static String getGlobalAudiosPath() {
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC) + File.separator + "blabber.im"+ File.separator; return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC) + File.separator + "monocles chat"+ File.separator;
} }
public static String getAppUpdateDirectory() { public static String getAppUpdateDirectory() {
@ -110,19 +110,19 @@ public class StorageHelper {
if (!isMigrated) { if (!isMigrated) {
try { try {
Log.d(Config.LOGTAG, "Migrating Media for Android 11"); Log.d(Config.LOGTAG, "Migrating Media for Android 11");
final File oldAudiosDirectory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "blabber.im" + File.separator + "Media" + File.separator + "blabber.im Audios" + File.separator); final File oldAudiosDirectory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "monocles chat" + File.separator + "Media" + File.separator + "monocles chat Audios" + File.separator);
final File newAudiosDirectory = new File(xmppConnectionService.getExternalMediaDirs()[0].getAbsolutePath() + File.separator + APP_DIRECTORY + " " + AUDIOS + File.separator); final File newAudiosDirectory = new File(xmppConnectionService.getExternalMediaDirs()[0].getAbsolutePath() + File.separator + APP_DIRECTORY + " " + AUDIOS + File.separator);
final File oldFilesDirectory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "blabber.im" + File.separator + "Media" + File.separator + "blabber.im Files" + File.separator); final File oldFilesDirectory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "monocles chat" + File.separator + "Media" + File.separator + "monocles chat Files" + File.separator);
final File newFilesDirectory = new File(xmppConnectionService.getExternalMediaDirs()[0].getAbsolutePath() + File.separator + APP_DIRECTORY + " " + FILES + File.separator); final File newFilesDirectory = new File(xmppConnectionService.getExternalMediaDirs()[0].getAbsolutePath() + File.separator + APP_DIRECTORY + " " + FILES + File.separator);
final File oldImagesDirectory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "blabber.im" + File.separator + "Media" + File.separator + "blabber.im Images" + File.separator); final File oldImagesDirectory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "monocles chat" + File.separator + "Media" + File.separator + "monocles chat Images" + File.separator);
final File newImagesDirectory = new File(xmppConnectionService.getExternalMediaDirs()[0].getAbsolutePath() + File.separator + APP_DIRECTORY + " " + IMAGES + File.separator); final File newImagesDirectory = new File(xmppConnectionService.getExternalMediaDirs()[0].getAbsolutePath() + File.separator + APP_DIRECTORY + " " + IMAGES + File.separator);
final File oldVideosDirectory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "blabber.im" + File.separator + "Media" + File.separator + "blabber.im Videos" + File.separator); final File oldVideosDirectory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "monocles chat" + File.separator + "Media" + File.separator + "monocles chat Videos" + File.separator);
final File newVideosDirectory = new File(xmppConnectionService.getExternalMediaDirs()[0].getAbsolutePath() + File.separator + APP_DIRECTORY + " " + VIDEOS + File.separator); final File newVideosDirectory = new File(xmppConnectionService.getExternalMediaDirs()[0].getAbsolutePath() + File.separator + APP_DIRECTORY + " " + VIDEOS + File.separator);
final File oldDatabaseDirectory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "blabber.im" + File.separator + "Database" + File.separator); final File oldDatabaseDirectory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "monocles chat" + File.separator + "Database" + File.separator);
final File newDatabaseDirectory = new File(getBackupDirectory(null)); final File newDatabaseDirectory = new File(getBackupDirectory(null));
final File oldChatsDirectory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "blabber.im" + File.separator + "Chats" + File.separator); final File oldChatsDirectory = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "monocles chat" + File.separator + "Chats" + File.separator);
final File newChatsDirectory = new File(getAppLogsDirectory()); final File newChatsDirectory = new File(getAppLogsDirectory());
try { try {