~singpolyma/cheogram-android

684dfe53ee82fc8f48a9c712d9528c4db725d31e — Stephen Paul Weber 1 year, 3 months ago cf3b1ea
Fix for API less than 24
M src/main/java/eu/siacs/conversations/ui/ConversationFragment.java => src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +10 -3
@@ 2382,9 2382,16 @@ public class ConversationFragment extends XmppFragment
            intent.putExtra("android.provider.extra.INITIAL_URI", Uri.parse(dir));
        } else {
            new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/" + dir + "/User Pack").mkdirs();
            Intent tmp = ((StorageManager) activity.getSystemService(Context.STORAGE_SERVICE)).getPrimaryStorageVolume().createOpenDocumentTreeIntent();
            Uri uri = tmp.getParcelableExtra("android.provider.extra.INITIAL_URI");
            intent.putExtra("android.provider.extra.INITIAL_URI", Uri.parse(uri.toString().replace("/root/", "/document/") + "%3APictures%2F" + dir));
            Uri uri;
            if (Build.VERSION.SDK_INT >= 24) {
                Intent tmp = ((StorageManager) activity.getSystemService(Context.STORAGE_SERVICE)).getPrimaryStorageVolume().createOpenDocumentTreeIntent();
                uri = tmp.getParcelableExtra("android.provider.extra.INITIAL_URI");
                uri = Uri.parse(uri.toString().replace("/root/", "/document/") + "%3APictures%2F" + dir);
            } else {
                uri = Uri.parse("content://com.android.externalstorage.documents/document/primary%3APictures%2F" + dir);
            }
            intent.putExtra("android.provider.extra.INITIAL_URI", uri);
            intent.putExtra("android.content.extra.SHOW_ADVANCED", true);
        }

        Toast.makeText(activity, "Choose a sticker pack to add this sticker to", Toast.LENGTH_SHORT).show();

M src/main/java/eu/siacs/conversations/ui/SettingsActivity.java => src/main/java/eu/siacs/conversations/ui/SettingsActivity.java +10 -5
@@ 378,11 378,16 @@ public class SettingsActivity extends XmppActivity implements OnSharedPreference

        final Preference stickerDir = mSettingsFragment.findPreference("sticker_directory");
        if (stickerDir != null) {
            stickerDir.setOnPreferenceClickListener((p) -> {
                Intent intent = ((StorageManager) getSystemService(Context.STORAGE_SERVICE)).getPrimaryStorageVolume().createOpenDocumentTreeIntent();
                startActivityForResult(Intent.createChooser(intent, "Choose sticker location"), 0);
                return true;
            });
            if (Build.VERSION.SDK_INT >= 24) {
                stickerDir.setOnPreferenceClickListener((p) -> {
                    Intent intent = ((StorageManager) getSystemService(Context.STORAGE_SERVICE)).getPrimaryStorageVolume().createOpenDocumentTreeIntent();
                    startActivityForResult(Intent.createChooser(intent, "Choose sticker location"), 0);
                    return true;
                });
            } else {
                PreferenceCategory expertMedia = (PreferenceCategory) mSettingsFragment.findPreference("expert_media");
                expertMedia.removePreference(stickerDir);
            }
        }

        final Preference clearBlockedMedia = mSettingsFragment.findPreference("clear_blocked_media");