1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-12-23 11:21:29 +00:00

Merge branch 'master' of github.com:syncthing/syncthing-android

This commit is contained in:
Felix Ableitner 2015-04-01 23:06:36 +02:00
commit eb10eaae9d
19 changed files with 29 additions and 70 deletions

View file

@ -10,6 +10,7 @@ import android.preference.EditTextPreference;
import android.preference.Preference;
import android.preference.PreferenceScreen;
import android.support.v4.preference.PreferenceFragment;
import android.text.InputType;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
@ -56,8 +57,6 @@ public class FolderSettingsFragment extends PreferenceFragment
private Preference mDirectory;
private EditTextPreference mRescanInterval;
private CheckBoxPreference mFolderMaster;
private PreferenceScreen mDevices;
@ -87,8 +86,6 @@ public class FolderSettingsFragment extends PreferenceFragment
mFolderId.setOnPreferenceChangeListener(this);
mDirectory = findPreference("directory");
mDirectory.setOnPreferenceClickListener(this);
mRescanInterval = (EditTextPreference) findPreference("rescan_interval");
mRescanInterval.setOnPreferenceChangeListener(this);
mFolderMaster = (CheckBoxPreference) findPreference("folder_master");
mFolderMaster.setOnPreferenceChangeListener(this);
mDevices = (PreferenceScreen) findPreference("devices");
@ -106,7 +103,7 @@ public class FolderSettingsFragment extends PreferenceFragment
mFolder = new RestApi.Folder();
mFolder.ID = "";
mFolder.Path = "";
mFolder.RescanIntervalS = 0;
mFolder.RescanIntervalS = 259200; // Scan every 3 days (in case inotify dropped some changes)
mFolder.DeviceIds = new ArrayList<>();
mFolder.Versioning = new RestApi.Versioning();
}
@ -156,8 +153,6 @@ public class FolderSettingsFragment extends PreferenceFragment
mFolderId.setText(mFolder.ID);
mFolderId.setSummary(mFolder.ID);
mDirectory.setSummary(mFolder.Path);
mRescanInterval.setText(Integer.toString(mFolder.RescanIntervalS));
mRescanInterval.setSummary(Integer.toString(mFolder.RescanIntervalS));
mFolderMaster.setChecked(mFolder.ReadOnly);
List<RestApi.Device> devicesList = mSyncthingService.getApi().getDevices(false);
for (RestApi.Device n : devicesList) {
@ -241,6 +236,15 @@ public class FolderSettingsFragment extends PreferenceFragment
public boolean onPreferenceChange(Preference preference, Object o) {
if (preference instanceof EditTextPreference) {
EditTextPreference pref = (EditTextPreference) preference;
if ((pref.getEditText().getInputType() & InputType.TYPE_CLASS_NUMBER) > 0) {
try {
o = Integer.parseInt((String) o);
o = o.toString();
} catch (NumberFormatException e) {
Log.w(TAG, "Invalid number: " + o);
return false;
}
}
pref.setSummary((String) o);
}
@ -252,11 +256,6 @@ public class FolderSettingsFragment extends PreferenceFragment
mFolder.Path = (String) o;
folderUpdated();
return true;
} else if (preference.equals(mRescanInterval)) {
mFolder.RescanIntervalS = Integer.parseInt((String) o);
mRescanInterval.setSummary((String) o);
folderUpdated();
return true;
} else if (preference.equals(mFolderMaster)) {
mFolder.ReadOnly = (Boolean) o;
folderUpdated();
@ -291,10 +290,14 @@ public class FolderSettingsFragment extends PreferenceFragment
folderUpdated();
return true;
} else if (preference.equals(mVersioningKeep)) {
((RestApi.SimpleVersioning) mFolder.Versioning)
.setParams(Integer.parseInt((String) o));
folderUpdated();
return true;
try {
((RestApi.SimpleVersioning) mFolder.Versioning)
.setParams(Integer.parseInt((String) o));
folderUpdated();
return true;
} catch (NumberFormatException e) {
Log.w(TAG, "Invalid versioning option: "+ o);
}
}
return false;

View file

@ -172,10 +172,17 @@ public class SettingsFragment extends PreferenceFragment
public boolean onPreferenceChange(Preference preference, Object o) {
// Convert new value to integer if input type is number.
if (preference instanceof EditTextPreference) {
EditTextPreference etp = (EditTextPreference) preference;
if (etp.getEditText().getInputType() == InputType.TYPE_CLASS_NUMBER) {
o = Integer.parseInt((String) o);
EditTextPreference pref = (EditTextPreference) preference;
if ((pref.getEditText().getInputType() & InputType.TYPE_CLASS_NUMBER) > 0) {
try {
o = Integer.parseInt((String) o);
o = o.toString();
} catch (NumberFormatException e) {
Log.w(TAG, "Invalid number: " + o);
return false;
}
}
pref.setSummary((String) o);
}
if (preference.equals(mSyncOnlyCharging) || preference.equals(mSyncOnlyWifi)) {
@ -216,14 +223,6 @@ public class SettingsFragment extends PreferenceFragment
((SyncthingActivity) getActivity()).getApi().requireRestart(getActivity());
}
// Set the preference value as summary.
if (preference instanceof EditTextPreference) {
String value = (o instanceof String)
? (String) o
: Integer.toString((Integer) o);
preference.setSummary(value);
}
return true;
}

View file

@ -52,8 +52,6 @@
<!--Setting title-->
<string name="directory">Adresář</string>
<!--Setting title-->
<string name="rescan_interval">Interval opakování skenování</string>
<!--Setting title-->
<string name="folder_master">Master adresář</string>
<!--Setting title-->
<string name="devices">Přístroje</string>

View file

@ -52,8 +52,6 @@
<!--Setting title-->
<string name="directory">Verzeichnis</string>
<!--Setting title-->
<string name="rescan_interval">Suchintervall</string>
<!--Setting title-->
<string name="folder_master">Originalverzeichnis</string>
<!--Setting title-->
<string name="devices">Geräte</string>

View file

@ -51,8 +51,6 @@
<!--Setting title-->
<string name="directory">Directorio</string>
<!--Setting title-->
<string name="rescan_interval">Intervalo de Reescanéo</string>
<!--Setting title-->
<string name="folder_master">Carpeta Maestra</string>
<!--Setting title-->
<string name="devices">Dispositivos</string>

View file

@ -52,8 +52,6 @@
<!--Setting title-->
<string name="directory">Dossier</string>
<!--Setting title-->
<string name="rescan_interval">Intervalle d\'analyse</string>
<!--Setting title-->
<string name="folder_master">Dossier maitre</string>
<!--Setting title-->
<string name="devices">Machines</string>

View file

@ -50,8 +50,6 @@
<!--Setting title-->
<string name="directory">Cartella</string>
<!--Setting title-->
<string name="rescan_interval">Intervallo Scansione</string>
<!--Setting title-->
<string name="folder_master">Cartella Principale</string>
<!--Setting title-->
<string name="devices">Dispositivi</string>

View file

@ -52,8 +52,6 @@
<!--Setting title-->
<string name="directory">ディレクトリー</string>
<!--Setting title-->
<string name="rescan_interval">再スキャン間隔</string>
<!--Setting title-->
<string name="folder_master">フォルダーマスター</string>
<!--Setting title-->
<string name="devices">デバイス</string>

View file

@ -52,8 +52,6 @@
<!--Setting title-->
<string name="directory">Map</string>
<!--Setting title-->
<string name="rescan_interval">Herscanningstussenpose</string>
<!--Setting title-->
<string name="folder_master">Maphoofd</string>
<!--Setting title-->
<string name="devices">Apparaten</string>

View file

@ -51,8 +51,6 @@
<!--Setting title-->
<string name="directory">Katalog</string>
<!--Setting title-->
<string name="rescan_interval">Czas między skanowaniem</string>
<!--Setting title-->
<string name="folder_master">Folder nadrzędny</string>
<!--Setting title-->
<string name="devices">Urządzenia</string>

View file

@ -52,8 +52,6 @@
<!--Setting title-->
<string name="directory">Pasta</string>
<!--Setting title-->
<string name="rescan_interval">Intervalo entre verificações</string>
<!--Setting title-->
<string name="folder_master">Pasta Mestre</string>
<!--Setting title-->
<string name="devices">Dispositivos</string>

View file

@ -52,8 +52,6 @@
<!--Setting title-->
<string name="directory">Pasta</string>
<!--Setting title-->
<string name="rescan_interval">Intervalo entre verificações</string>
<!--Setting title-->
<string name="folder_master">Pasta Mestre</string>
<!--Setting title-->
<string name="devices">Dispositivos</string>

View file

@ -51,8 +51,6 @@
<!--Setting title-->
<string name="directory">Папка</string>
<!--Setting title-->
<string name="rescan_interval">Интервал Сканирования</string>
<!--Setting title-->
<string name="folder_master">Главная папка</string>
<!--Setting title-->
<string name="devices">Устройства</string>

View file

@ -52,8 +52,6 @@
<!--Setting title-->
<string name="directory">Dizin</string>
<!--Setting title-->
<string name="rescan_interval">Yeniden Tarama Aralığı</string>
<!--Setting title-->
<string name="folder_master">Ana Klasör</string>
<!--Setting title-->
<string name="devices">Cihazlar</string>

View file

@ -52,8 +52,6 @@
<!--Setting title-->
<string name="directory">目录</string>
<!--Setting title-->
<string name="rescan_interval">扫描间隔</string>
<!--Setting title-->
<string name="folder_master">主文件夹</string>
<!--Setting title-->
<string name="devices">设备</string>

View file

@ -51,8 +51,6 @@
<!--Setting title-->
<string name="directory">資料夾</string>
<!--Setting title-->
<string name="rescan_interval">重新掃描間隔</string>
<!--Setting title-->
<string name="folder_master">主資料夾</string>
<!--Setting title-->
<string name="devices">裝置</string>

View file

@ -89,9 +89,6 @@
<!-- Setting title -->
<string name="directory">Directory</string>
<!-- Setting title -->
<string name="rescan_interval">Rescan Interval</string>
<!-- Setting title -->
<string name="folder_master">Folder Master</string>

View file

@ -11,12 +11,6 @@
android:key="directory"
android:title="@string/directory" />
<EditTextPreference
android:persistent="false"
android:key="rescan_interval"
android:title="@string/rescan_interval"
android:inputType="numberDecimal" />
<CheckBoxPreference
android:persistent="false"
android:key="folder_master"

View file

@ -15,12 +15,6 @@
android:enabled="false"
style="?android:preferenceInformationStyle" />
<EditTextPreference
android:persistent="false"
android:key="rescan_interval"
android:title="@string/rescan_interval"
android:inputType="numberDecimal" />
<CheckBoxPreference
android:persistent="false"
android:key="folder_master"