mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-04-03 18:21:06 +02:00
allow picking any folder for storing the photos and videos
This commit is contained in:
parent
70c07f9688
commit
229f7111f2
@ -3,6 +3,7 @@ package com.simplemobiletools.camera;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.hardware.Camera;
|
||||
import android.os.Environment;
|
||||
|
||||
public class Config {
|
||||
private SharedPreferences mPrefs;
|
||||
@ -31,12 +32,12 @@ public class Config {
|
||||
mPrefs.edit().putBoolean(Constants.IS_DARK_THEME, isDarkTheme).apply();
|
||||
}
|
||||
|
||||
public boolean getUseDCIMFolder() {
|
||||
return mPrefs.getBoolean(Constants.USE_DCIM, true);
|
||||
public String getSavePhotosFolder() {
|
||||
return mPrefs.getString(Constants.SAVE_PHOTOS, Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).toString());
|
||||
}
|
||||
|
||||
public void setUseDCIMFolder(boolean useDCIM) {
|
||||
mPrefs.edit().putBoolean(Constants.USE_DCIM, useDCIM).apply();
|
||||
public void setSavePhotosFolder(String path) {
|
||||
mPrefs.edit().putString(Constants.SAVE_PHOTOS, path).apply();
|
||||
}
|
||||
|
||||
public boolean getForceRatioEnabled() {
|
||||
|
@ -9,7 +9,7 @@ public class Constants {
|
||||
public static final String PREFS_KEY = "Camera";
|
||||
public static final String IS_FIRST_RUN = "is_first_run";
|
||||
public static final String IS_DARK_THEME = "is_dark_theme";
|
||||
public static final String USE_DCIM = "use_dcim";
|
||||
public static final String SAVE_PHOTOS = "save_photos";
|
||||
public static final String SOUND = "sound";
|
||||
public static final String FORCE_RATIO = "force_ratio";
|
||||
public static final String MAX_RESOLUTION = "max_resolution";
|
||||
|
@ -7,7 +7,6 @@ import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Point;
|
||||
import android.hardware.Camera;
|
||||
import android.os.Environment;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.Display;
|
||||
import android.widget.Toast;
|
||||
@ -50,7 +49,7 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static String getOutputMediaFile(Context context, boolean isPhoto) {
|
||||
final File mediaStorageDir = getFolderName(context, isPhoto);
|
||||
final File mediaStorageDir = new File(Config.newInstance(context).getSavePhotosFolder());
|
||||
|
||||
if (!mediaStorageDir.exists()) {
|
||||
if (!mediaStorageDir.mkdirs()) {
|
||||
@ -66,28 +65,6 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
private static File getFolderName(Context context, boolean isPhoto) {
|
||||
if (Config.newInstance(context).getUseDCIMFolder()) {
|
||||
return Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
|
||||
}
|
||||
|
||||
final Resources res = context.getResources();
|
||||
String typeDirectory = res.getString(R.string.photo_directory);
|
||||
if (!isPhoto) {
|
||||
typeDirectory = res.getString(R.string.video_directory);
|
||||
}
|
||||
|
||||
return new File(getMainDirectory(isPhoto), typeDirectory);
|
||||
}
|
||||
|
||||
private static File getMainDirectory(boolean isPhoto) {
|
||||
String type = Environment.DIRECTORY_MOVIES;
|
||||
if (isPhoto) {
|
||||
type = Environment.DIRECTORY_PICTURES;
|
||||
}
|
||||
return Environment.getExternalStoragePublicDirectory(type);
|
||||
}
|
||||
|
||||
public static String formatSeconds(int duration) {
|
||||
final StringBuilder sb = new StringBuilder(8);
|
||||
final int hours = duration / (60 * 60);
|
||||
|
@ -48,10 +48,9 @@ class SettingsActivity : SimpleActivity() {
|
||||
}
|
||||
|
||||
private fun setupUseDCIM() {
|
||||
settings_use_dcim.isChecked = mConfig.useDCIMFolder
|
||||
settings_use_dcim_holder.setOnClickListener {
|
||||
settings_use_dcim.toggle()
|
||||
mConfig.useDCIMFolder = settings_use_dcim.isChecked
|
||||
settings_save_photos.text = mConfig.savePhotosFolder.substring(mConfig.savePhotosFolder.lastIndexOf("/") + 1)
|
||||
settings_save_photos_holder.setOnClickListener {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_use_dcim_holder"
|
||||
android:id="@+id/settings_save_photos_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/settings_padding"
|
||||
@ -47,15 +47,15 @@
|
||||
android:padding="@dimen/activity_margin">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/settings_use_dcim_label"
|
||||
android:id="@+id/settings_save_photos_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:paddingLeft="@dimen/settings_padding"
|
||||
android:text="@string/use_dcim_folder"/>
|
||||
android:text="@string/save_photos"/>
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/settings_use_dcim"
|
||||
<TextView
|
||||
android:id="@+id/settings_save_photos"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
|
@ -7,8 +7,6 @@
|
||||
<string name="video_saving_error">Beim Speichern des Videos ist ein Fehler aufgetreten</string>
|
||||
<string name="video_setup_error">Beim Starten der Aufnahme ist ein Fehler aufgetreten</string>
|
||||
<string name="video_mode_error">Beim Umschalten zum Videomodus ist ein Fehler aufgetreten</string>
|
||||
<string name="video_directory">Simple Videos</string>
|
||||
<string name="photo_directory">Simple Photos</string>
|
||||
<string name="camera_switch_error">Kamerawechsel fehlgeschlagen</string>
|
||||
<string name="no_permissions">Ohne Zugriff auf Kamera und Speicher ist hier nicht viel zu tun</string>
|
||||
<string name="no_audio_permissions">Wir benötigen Zugriff auf das Mirkofon um Videos aufnehmen zu können</string>
|
||||
@ -18,7 +16,7 @@
|
||||
<!-- Settings -->
|
||||
<string name="settings">Einstellungen</string>
|
||||
<string name="dark_theme">Dunkles Design</string>
|
||||
<string name="use_dcim_folder">Speichere Dateien im vorgegebenen DCIM Ordner</string>
|
||||
<string name="save_photos">Save photos and videos to</string>
|
||||
<string name="force_ratio">Erzwinge 16:9 Format</string>
|
||||
<string name="max_photo_size">Maximale Fotoauflösung</string>
|
||||
<string name="max_video_size">Maximale Videoauflösung</string>
|
||||
|
@ -7,8 +7,6 @@
|
||||
<string name="video_saving_error">Errore nel salvataggio del file video</string>
|
||||
<string name="video_setup_error">Errore nella preparazione del registratore video</string>
|
||||
<string name="video_mode_error">Passaggio alla modalità video fallita</string>
|
||||
<string name="video_directory">Simple Video</string>
|
||||
<string name="photo_directory">Simple Foto</string>
|
||||
<string name="camera_switch_error">Cambio fotocamera fallito</string>
|
||||
<string name="no_permissions">Non c\'è molto da fare senza l\'accesso alla fotocamera e all\'archiviazione</string>
|
||||
<string name="no_audio_permissions">È necessario l\'accesso al microfono per registrare i video</string>
|
||||
@ -18,7 +16,7 @@
|
||||
<!-- Settings -->
|
||||
<string name="settings">Impostazioni</string>
|
||||
<string name="dark_theme">Tema scuro</string>
|
||||
<string name="use_dcim_folder">Store media in the default DCIM folder</string>
|
||||
<string name="save_photos">Save photos and videos to</string>
|
||||
<string name="force_ratio">Forza proporzione 16:9</string>
|
||||
<string name="max_photo_size">Limite risoluzione foto</string>
|
||||
<string name="max_video_size">Video resolution limit</string>
|
||||
|
@ -7,8 +7,6 @@
|
||||
<string name="video_saving_error">ビデオファイルの保存時にエラーが発生しました</string>
|
||||
<string name="video_setup_error">レコーダーのセットアップ時にエラーが発生しました</string>
|
||||
<string name="video_mode_error">ビデオモードへの切り替えに失敗しました</string>
|
||||
<string name="video_directory">シンプル ビデオ</string>
|
||||
<string name="photo_directory">シンプル フォト</string>
|
||||
<string name="camera_switch_error">カメラの切り替えに失敗しました</string>
|
||||
<string name="no_permissions">お使いのカメラやストレージにアクセスしないと、ほとんど行うことはありません</string>
|
||||
<string name="no_audio_permissions">ビデオを記録するためにオーディオのアクセス許可が必要です</string>
|
||||
@ -18,7 +16,7 @@
|
||||
<!-- Settings -->
|
||||
<string name="settings">設定</string>
|
||||
<string name="dark_theme">ダークテーマ</string>
|
||||
<string name="use_dcim_folder">Store media in the default DCIM folder</string>
|
||||
<string name="save_photos">Save photos and videos to</string>
|
||||
<string name="force_ratio">強制的に 16:9 レシオにする</string>
|
||||
<string name="max_photo_size">写真解像度の限度</string>
|
||||
<string name="max_video_size">Video resolution limit</string>
|
||||
|
@ -7,8 +7,6 @@
|
||||
<string name="video_saving_error">Ocorreu um erro ao guardar o ficheiro de vídeo</string>
|
||||
<string name="video_setup_error">Ocorreu um erro ao configurar a gravação</string>
|
||||
<string name="video_mode_error">Falha ao mudar para o modo vídeo</string>
|
||||
<string name="video_directory">Vídeos simples</string>
|
||||
<string name="photo_directory">Fotografias simples</string>
|
||||
<string name="camera_switch_error">Falha ao mudar de câmara</string>
|
||||
<string name="no_permissions">É necessária a permissão para aceder à câmara e ao armazenamento</string>
|
||||
<string name="no_audio_permissions">A permissão de áudio é necessária para a gravação de vídeos</string>
|
||||
@ -18,7 +16,7 @@
|
||||
<!-- Settings -->
|
||||
<string name="settings">Definições</string>
|
||||
<string name="dark_theme">Tema escuro</string>
|
||||
<string name="use_dcim_folder">Armazenar multimédia na pasta pré-definida \"DCIM\"</string>
|
||||
<string name="save_photos">Save photos and videos to</string>
|
||||
<string name="force_ratio">Usar rácio 16:9</string>
|
||||
<string name="max_photo_size">Resolução máxima das fotografias</string>
|
||||
<string name="max_video_size">Resolução máxima dos vídeos</string>
|
||||
|
@ -7,8 +7,6 @@
|
||||
<string name="video_saving_error">Произошла ошибка записи видео файла</string>
|
||||
<string name="video_setup_error">Произошла ошибка настройки рекордера</string>
|
||||
<string name="video_mode_error">Переключение в режим видео не удалось</string>
|
||||
<string name="video_directory">Просто Видео</string>
|
||||
<string name="photo_directory">Просто Фото</string>
|
||||
<string name="camera_switch_error">Переключение камеры не удалось</string>
|
||||
<string name="no_permissions">Не так много можно сделать без доступа к камере и хранилищу</string>
|
||||
<string name="no_audio_permissions">Нам нужно аудио разрешение для записи видео</string>
|
||||
@ -18,7 +16,7 @@
|
||||
<!-- Settings -->
|
||||
<string name="settings">Настройки</string>
|
||||
<string name="dark_theme">темная тема</string>
|
||||
<string name="use_dcim_folder">Store media in the default DCIM folder</string>
|
||||
<string name="save_photos">Save photos and videos to</string>
|
||||
<string name="force_ratio">Принудительное соотношение сторон 16:9</string>
|
||||
<string name="max_photo_size">Лимит разрешения фото</string>
|
||||
<string name="max_video_size">Video resolution limit</string>
|
||||
|
@ -7,8 +7,6 @@
|
||||
<string name="video_saving_error">Ett fel uppstod när videofilen skulle sparas</string>
|
||||
<string name="video_setup_error">Ett fel uppstod när inspelningen skulle starta</string>
|
||||
<string name="video_mode_error">Byte till videoläge misslyckades</string>
|
||||
<string name="video_directory">Simple videos</string>
|
||||
<string name="photo_directory">Simple bilder</string>
|
||||
<string name="camera_switch_error">Byte av kamera misslyckades</string>
|
||||
<string name="no_permissions">Inte mycket att göra utan tillgång till din kamera och lagring</string>
|
||||
<string name="no_audio_permissions">För att spela in video krävs ljudrättigheter</string>
|
||||
@ -18,7 +16,7 @@
|
||||
<!-- Settings -->
|
||||
<string name="settings">Inställningar</string>
|
||||
<string name="dark_theme">Mörkt tema</string>
|
||||
<string name="use_dcim_folder">Store media in the default DCIM folder</string>
|
||||
<string name="save_photos">Save photos and videos to</string>
|
||||
<string name="force_ratio">Tvinga 16:9-förhållande</string>
|
||||
<string name="max_photo_size">Bildupplösningsgräns</string>
|
||||
<string name="max_video_size">Video resolution limit</string>
|
||||
|
@ -7,8 +7,6 @@
|
||||
<string name="video_saving_error">An error occurred saving the video file</string>
|
||||
<string name="video_setup_error">An error occurred setting up the recorder</string>
|
||||
<string name="video_mode_error">Switching to video mode failed</string>
|
||||
<string name="video_directory">Simple Videos</string>
|
||||
<string name="photo_directory">Simple Photos</string>
|
||||
<string name="camera_switch_error">Switching camera failed</string>
|
||||
<string name="no_permissions">Not much to do without accessing your camera and storage</string>
|
||||
<string name="no_audio_permissions">We need the audio permission for recording videos</string>
|
||||
@ -18,7 +16,7 @@
|
||||
<!-- Settings -->
|
||||
<string name="settings">Settings</string>
|
||||
<string name="dark_theme">Dark theme</string>
|
||||
<string name="use_dcim_folder">Store media in the default DCIM folder</string>
|
||||
<string name="save_photos">Save photos and videos to</string>
|
||||
<string name="force_ratio">Use 16:9 ratio</string>
|
||||
<string name="max_photo_size">Max photo resolution limit</string>
|
||||
<string name="max_video_size">Max video resolution limit</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user