From 6f77e4912b27c673679a29707f5aed9bfaf5997f Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Wed, 4 May 2016 02:34:32 +0200 Subject: [PATCH 1/2] Updated Syncthing to v0.13.0-beta.3 --- ext/syncthing/src/github.com/syncthing/syncthing | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/syncthing/src/github.com/syncthing/syncthing b/ext/syncthing/src/github.com/syncthing/syncthing index 94c6110f..0155b6f8 160000 --- a/ext/syncthing/src/github.com/syncthing/syncthing +++ b/ext/syncthing/src/github.com/syncthing/syncthing @@ -1 +1 @@ -Subproject commit 94c6110f2e10ab8dbb0a416556701317ecd437cc +Subproject commit 0155b6f84171724686694417cd8015bdffb31e22 From 12997d6b368339714502de5a0e5632851c54e032 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Sun, 10 Apr 2016 00:15:48 +0200 Subject: [PATCH 2/2] Added support for folder labels. --- .../fragments/FolderFragment.java | 112 ++++++++++-------- .../syncthingandroid/syncthing/RestApi.java | 3 + .../syncthingandroid/util/ConfigXml.java | 1 + .../syncthingandroid/util/FoldersAdapter.java | 4 +- .../ic_label_outline_black_24dp.png | Bin 0 -> 403 bytes .../ic_label_outline_black_24dp.png | Bin 0 -> 292 bytes .../ic_label_outline_black_24dp.png | Bin 0 -> 483 bytes .../ic_label_outline_black_24dp.png | Bin 0 -> 649 bytes .../ic_label_outline_black_24dp.png | Bin 0 -> 812 bytes src/main/res/layout/fragment_folder.xml | 15 ++- src/main/res/layout/item_folder_list.xml | 2 +- src/main/res/values/strings.xml | 6 + 12 files changed, 89 insertions(+), 54 deletions(-) create mode 100644 src/main/res/drawable-hdpi/ic_label_outline_black_24dp.png create mode 100644 src/main/res/drawable-mdpi/ic_label_outline_black_24dp.png create mode 100644 src/main/res/drawable-xhdpi/ic_label_outline_black_24dp.png create mode 100644 src/main/res/drawable-xxhdpi/ic_label_outline_black_24dp.png create mode 100644 src/main/res/drawable-xxxhdpi/ic_label_outline_black_24dp.png diff --git a/src/main/java/com/nutomic/syncthingandroid/fragments/FolderFragment.java b/src/main/java/com/nutomic/syncthingandroid/fragments/FolderFragment.java index 0d119c46..76570c85 100644 --- a/src/main/java/com/nutomic/syncthingandroid/fragments/FolderFragment.java +++ b/src/main/java/com/nutomic/syncthingandroid/fragments/FolderFragment.java @@ -68,57 +68,52 @@ public class FolderFragment extends Fragment private RestApi.Folder mFolder; + private EditText mLabelView; private EditText mIdView; - private TextView mPathView; - private SwitchCompat mFolderMasterView; - private ViewGroup mDevicesContainer; - private TextView mVersioningKeepView; private boolean mIsCreateMode; + private boolean mFolderNeedsToUpdate; private KeepVersionsDialogFragment mKeepVersionsDialogFragment = new KeepVersionsDialogFragment(); - private TextWatcher mIdTextWatcher = new TextWatcherAdapter() { + private TextWatcher mTextWatcher = new TextWatcherAdapter() { @Override public void afterTextChanged(Editable s) { - mFolder.id = s.toString(); - updateFolder(); + mFolder.label = mLabelView.getText().toString(); + mFolder.id = mIdView.getText().toString(); + mFolder.path = mPathView.getText().toString(); + mFolderNeedsToUpdate = true; } }; - private TextWatcher mPathTextWatcher = new TextWatcherAdapter() { - @Override - public void afterTextChanged(Editable s) { - mFolder.path = s.toString(); - } - }; - - private CompoundButton.OnCheckedChangeListener mMasterCheckedListener = new CompoundButton.OnCheckedChangeListener() { + private CompoundButton.OnCheckedChangeListener mCheckedListener = + new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton view, boolean isChecked) { - mFolder.readOnly = isChecked; - updateFolder(); - } - }; - - private CompoundButton.OnCheckedChangeListener mOnShareChangeListener = new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton view, boolean isChecked) { - RestApi.Device device = (RestApi.Device) view.getTag(); - if (isChecked) { - mFolder.deviceIds.add(device.deviceID); - } else { - mFolder.deviceIds.remove(device.deviceID); + switch (view.getId()) { + case R.id.master: + mFolder.readOnly = isChecked; + mFolderNeedsToUpdate = true; + break; + case R.id.share_device_id: + RestApi.Device device = (RestApi.Device) view.getTag(); + if (isChecked) { + mFolder.deviceIds.add(device.deviceID); + } else { + mFolder.deviceIds.remove(device.deviceID); + } + mFolderNeedsToUpdate = true; + break; } - updateFolder(); } }; - private KeepVersionsDialogFragment.OnValueChangeListener mOnValueChangeListener = new KeepVersionsDialogFragment.OnValueChangeListener() { + private KeepVersionsDialogFragment.OnValueChangeListener mOnValueChangeListener = + new KeepVersionsDialogFragment.OnValueChangeListener() { @Override public void onValueChange(int intValue) { if (intValue == 0) { @@ -129,7 +124,7 @@ public class FolderFragment extends Fragment ((SimpleVersioning) mFolder.versioning).setParams(intValue); mVersioningKeepView.setText(valueOf(intValue)); } - updateFolder(); + mFolderNeedsToUpdate = true; } }; @@ -144,13 +139,6 @@ public class FolderFragment extends Fragment } }; - private View.OnClickListener mVersioningContainerClickListener = new View.OnClickListener() { - @Override - public void onClick(View v) { - mKeepVersionsDialogFragment.show(getFragmentManager(), KEEP_VERSIONS_DIALOG_TAG); - } - }; - @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -179,6 +167,17 @@ public class FolderFragment extends Fragment } } + @Override + public void onPause() { + super.onPause(); + + // We don't want to update every time a TextView's character changes, + // so we hold off until the view stops being visible to the user. + if (mFolderNeedsToUpdate) { + updateFolder(); + } + } + /** * Save current settings in case we are in create mode and they aren't yet stored in the config. */ @@ -197,6 +196,7 @@ public class FolderFragment extends Fragment public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); + mLabelView = (EditText) view.findViewById(R.id.label); mIdView = (EditText) view.findViewById(R.id.id); mPathView = (TextView) view.findViewById(R.id.directory); mFolderMasterView = (SwitchCompat) view.findViewById(R.id.master); @@ -204,9 +204,17 @@ public class FolderFragment extends Fragment mDevicesContainer = (ViewGroup) view.findViewById(R.id.devicesContainer); mPathView.setOnClickListener(mPathViewClickListener); - view.findViewById(R.id.versioningContainer).setOnClickListener(mVersioningContainerClickListener); + view.findViewById(R.id.versioningContainer).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + mKeepVersionsDialogFragment.show(getFragmentManager(), KEEP_VERSIONS_DIALOG_TAG); + } + }); - if (!mIsCreateMode) { + if (mIsCreateMode) { + // Open keyboard on label view in edit mode. + mLabelView.requestFocus(); + } else { prepareEditMode(); } } @@ -214,8 +222,9 @@ public class FolderFragment extends Fragment @Override public void onDestroyView() { super.onDestroyView(); - mIdView.removeTextChangedListener(mIdTextWatcher); - mPathView.removeTextChangedListener(mPathTextWatcher); + mLabelView.removeTextChangedListener(mTextWatcher); + mIdView.removeTextChangedListener(mTextWatcher); + mPathView.removeTextChangedListener(mTextWatcher); } @Override @@ -252,21 +261,23 @@ public class FolderFragment extends Fragment } private void updateViewsAndSetListeners() { - mIdView.removeTextChangedListener(mIdTextWatcher); - mPathView.removeTextChangedListener(mPathTextWatcher); + mLabelView.removeTextChangedListener(mTextWatcher); + mIdView.removeTextChangedListener(mTextWatcher); + mPathView.removeTextChangedListener(mTextWatcher); mFolderMasterView.setOnCheckedChangeListener(null); mKeepVersionsDialogFragment.setOnValueChangeListener(null); // Update views + mLabelView.setText(mFolder.label); mIdView.setText(mFolder.id); mPathView.setText(mFolder.path); mFolderMasterView.setChecked(mFolder.readOnly); List devicesList = mSyncthingService.getApi().getDevices(false); + mDevicesContainer.removeAllViews(); if (devicesList.isEmpty()) { addEmptyDeviceListView(); } else { - mDevicesContainer.removeAllViews(); for (RestApi.Device n : devicesList) { addDeviceViewAndSetListener(n, LayoutInflater.from(getActivity())); } @@ -283,9 +294,10 @@ public class FolderFragment extends Fragment mKeepVersionsDialogFragment.setValue(versions); // Keep state updated - mIdView.addTextChangedListener(mIdTextWatcher); - mPathView.addTextChangedListener(mPathTextWatcher); - mFolderMasterView.setOnCheckedChangeListener(mMasterCheckedListener); + mLabelView.addTextChangedListener(mTextWatcher); + mIdView.addTextChangedListener(mTextWatcher); + mPathView.addTextChangedListener(mTextWatcher); + mFolderMasterView.setOnCheckedChangeListener(mCheckedListener); mKeepVersionsDialogFragment.setOnValueChangeListener(mOnValueChangeListener); } @@ -343,7 +355,7 @@ public class FolderFragment extends Fragment if (resultCode == Activity.RESULT_OK && requestCode == DIRECTORY_REQUEST_CODE) { mFolder.path = data.getStringExtra(FolderPickerActivity.EXTRA_RESULT_DIRECTORY); mPathView.setText(mFolder.path); - updateFolder(); + mFolderNeedsToUpdate = true; } } @@ -384,7 +396,7 @@ public class FolderFragment extends Fragment deviceView.setChecked(mFolder.deviceIds.contains(device.deviceID)); deviceView.setText(RestApi.getDeviceDisplayName(device)); deviceView.setTag(device); - deviceView.setOnCheckedChangeListener(mOnShareChangeListener); + deviceView.setOnCheckedChangeListener(mCheckedListener); } private void updateFolder() { diff --git a/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java b/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java index b5e08a8b..21768c9c 100644 --- a/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java +++ b/src/main/java/com/nutomic/syncthingandroid/syncthing/RestApi.java @@ -84,6 +84,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener, public static class Folder implements Serializable { public String path; + public String label; public String id; public String invalid; public List deviceIds; @@ -473,6 +474,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener, JSONObject json = folders.getJSONObject(i); Folder r = new Folder(); r.path = json.getString("path"); + r.label = json.getString("label"); r.id = json.getString("id"); // TODO: Field seems to be missing sometimes. // https://github.com/syncthing/syncthing-android/issues/291 @@ -872,6 +874,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener, } } r.put("path", folder.path); + r.put("label", folder.label); r.put("id", folder.id); r.put("ignorePerms", true); r.put("readOnly", folder.readOnly); diff --git a/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java b/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java index fab8be61..7ce3e7cd 100644 --- a/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java +++ b/src/main/java/com/nutomic/syncthingandroid/util/ConfigXml.java @@ -232,6 +232,7 @@ public class ConfigXml { .replace(" ", "_") .toLowerCase(Locale.US) .replaceAll("[^a-z0-9_-]", ""); + folder.setAttribute("label", mContext.getString(R.string.default_folder_label)); folder.setAttribute("id", mContext.getString(R.string.default_folder_id, model)); folder.setAttribute("path", Environment .getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath()); diff --git a/src/main/java/com/nutomic/syncthingandroid/util/FoldersAdapter.java b/src/main/java/com/nutomic/syncthingandroid/util/FoldersAdapter.java index 39805fc3..76a30cb5 100644 --- a/src/main/java/com/nutomic/syncthingandroid/util/FoldersAdapter.java +++ b/src/main/java/com/nutomic/syncthingandroid/util/FoldersAdapter.java @@ -37,7 +37,7 @@ public class FoldersAdapter extends ArrayAdapter if (convertView == null) convertView = mInflater.inflate(R.layout.item_folder_list, parent, false); - TextView id = (TextView) convertView.findViewById(R.id.id); + TextView label = (TextView) convertView.findViewById(R.id.label); TextView state = (TextView) convertView.findViewById(R.id.state); TextView directory = (TextView) convertView.findViewById(R.id.directory); TextView items = (TextView) convertView.findViewById(R.id.items); @@ -46,7 +46,7 @@ public class FoldersAdapter extends ArrayAdapter RestApi.Folder folder = getItem(position); RestApi.Model model = mModels.get(folder.id); - id.setText(folder.id); + label.setText(TextUtils.isEmpty(folder.label) ? folder.id : folder.label); state.setTextColor(getContext().getResources().getColor(R.color.text_green)); directory.setText(folder.path); if (model != null) { diff --git a/src/main/res/drawable-hdpi/ic_label_outline_black_24dp.png b/src/main/res/drawable-hdpi/ic_label_outline_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..8b58b07fc68eca577e8f66e657ec6c63dc2e773d GIT binary patch literal 403 zcmV;E0c`$>P)WItn@n4&oq)I9Lb4?L3Izx6 zllM9(rIud)n$eyqc_F{NCnP7d^^X<%F&mT8(PG83yoctXHRF*sf3=}lTkNRnW;~*c zq*dLu#YAP40!4)um?=GaE!%1Y`s%IVumz}O9TO&<)wdQ^7f!*V{xA^xu91|jUi}x) zo1AwHn+pSR z>@vh!!m2n*j>67p!2n+5e1w29roo=O`metXMys!VgBXFl^F}dp1=7+Hx_Y!zTZ&gk xH&O;8nR~J6wt4tx>V$u+PWV5zf6caj=o809HnfGJK(+t?002ovPDHLkV1jRHr5peN literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-mdpi/ic_label_outline_black_24dp.png b/src/main/res/drawable-mdpi/ic_label_outline_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..7ca623c5864cda27cd290425ed4edb7ed9e03337 GIT binary patch literal 292 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM0wlfaz7_*1rX+877l!}s{b%+Ad7K3vkw8&y zVGw3ym^BBap1s7=*OmPN3#X`>%65%7HlWZ}PZ!4!i_=dp*>*7n3b;O8UmB3Xoan@? zZd%CB_DpIk_oT=U?+@&3#i?n6$C}cbnmD9hsOT;#JAK;rsM6mQ4E~L8$0z( zU$cC7bfkyz`neI0K8MvUi9A@oY(mB>NsIgYC!D|H=li>GNll-dUev3FOy2cMokc4S zoQVomkNL3Y+Vw40b9|j!cTMZwm^>q3TF0NLw!SNYTaD`Xd~sYefAJii_2tWEJUcc$ i=-Bd<{G_LQf3inwD9n>Q@mmP!0R~T3KbLh*2~7a$;c!m? literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-xhdpi/ic_label_outline_black_24dp.png b/src/main/res/drawable-xhdpi/ic_label_outline_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..7681beb027c6709fcc7387b2ea3ea4d49a3d6d82 GIT binary patch literal 483 zcmV<90UZ8`P)De(Tn7M-I1@KU zuMPmL^CIQP{;Xyy0k5oyixAfVaIL&50d35QdnBy`FiQsj6;c$`1BU4rm*G-GQu002ovPDHLkV1o03#lZjo literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-xxhdpi/ic_label_outline_black_24dp.png b/src/main/res/drawable-xxhdpi/ic_label_outline_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..39a002d9f29dd16112497320f704038af4bdf4d1 GIT binary patch literal 649 zcmV;40(Sk0P)LO#i?J8c zph5)8CicT3HQmng< z8or_yC5q(9QreGDj5{Pe{o_UMvDwJPu;bWWk9DApljJD76FN`74~wIXR^Hd27IGNt z^J%?a;FLR|xNjvi%Heub4mga-${OFdM2cSV*lzKl`8(t-)BF(WH0QL1c6dldgwBSla;#!Bakol;EniP?-$7B446MR|vi`YvkKRb%o#!?~K!OL|X`^_$ks^ z=L0H8p)DqjJVb}C5Pam7aU!Iue?M3unB$8`#~IWXDv@DN;MgeNl&42wUiC5h*Pvw3w<)-~8`gXS_`Rzt1 z?~~2~AKW!)S>w&XE7pu&`ak_iH5Cf$=00000NkvXXu0mjfS}iA5 literal 0 HcmV?d00001 diff --git a/src/main/res/drawable-xxxhdpi/ic_label_outline_black_24dp.png b/src/main/res/drawable-xxxhdpi/ic_label_outline_black_24dp.png new file mode 100644 index 0000000000000000000000000000000000000000..2446c9a17bc8c9a0c73123da68f07b5b807afe94 GIT binary patch literal 812 zcmV+{1JnG8P)9oZ%(;fGE>o=YBtm(`-d(R9gilQirq9}@@D9Zmypx`%J=_5jz z>VkU(4)hEAWJr@_^)Ljgxyd-wt0x->{u}Y1*mYWqOu+5Z_9pjoD0a)UdkzIDL z$|_3$=2$bbF>2)qWJwr}Wh29K1YnIhBkQ48jsU!7$;fWeEJpyQ`0Yq)h}*|nnF5 z4erZX2d>j*WRq-55$NQSktiS*#Esgz_6oC%If{-*_aaBa0DsB(~d& zdCC7cGwY~H?s}&5n6KsNi8DU^Bg?!jPg9@vW%#y-90wFg`XVsRMyd68KDKDE%+7~P ziuuwT2)DEG6h}N9e%kWV!9NM)SRh1u5pOn@gCvuMDo-1Q2iHQB2u;R>8z}md`_?Q! qNt3iZ8&ecTQ4~c{6h%=K#f86@e}DUKK1Q + android:showDividers="middle" + android:focusableInTouchMode="true"> + + Folder ID + + Folder Label + Directory @@ -418,6 +421,9 @@ Please report any problems you encounter via Github. Failed to create a Syncthing config. Please check the logs. + + Camera + %1$s-photos