Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,6 @@ public void onEventMainThread(ConnectionChangeReceiver.ConnectionChangeEvent eve
(SiteSettingsFragment) fragmentManager.findFragmentByTag(KEY_SETTINGS_FRAGMENT);

if (siteSettingsFragment != null) {
siteSettingsFragment.allowEditing(event.isConnected());

if (!event.isConnected()) {
ToastUtils.showToast(this, getString(R.string.site_settings_disconnected_toast));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {
mPreviewImages.add((ImageView) v.findViewById(R.id.related_post_image2));
mPreviewImages.add((ImageView) v.findViewById(R.id.related_post_image3));

WPPrefUtils.layoutAsSubhead(mShowHeader);
WPPrefUtils.layoutAsSubhead(mShowImages);

Bundle args = getArguments();
if (args != null) {
mShowRelatedPosts.setChecked(args.getBoolean(SHOW_RELATED_POSTS_KEY));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ public class SiteSettingsFragment extends PreferenceFragment
private Preference mModerationHoldPref;
private Preference mBlacklistPref;

// This Device settings
private DetailListPreference mImageWidthPref;
private WPSwitchPreference mUploadAndLinkPref;

// Delete site option (NOTE: only for WP.org)
private Preference mDeleteSitePref;

Expand Down Expand Up @@ -207,9 +211,9 @@ public void onResume() {
public void run() {
// initialize settings with locally cached values, fetch remote on first pass
mSiteSettings.init(true);
// stop future calls from fetching remote settings
}
}, FETCH_DELAY);
// stop future calls from fetching remote settings
mShouldFetch = false;
}
}
Expand Down Expand Up @@ -428,6 +432,13 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
setDetailListPreferenceValue(mFormatPref,
newValue.toString(),
mSiteSettings.getDefaultPostFormatDisplay());
} else if (preference == mImageWidthPref) {
mBlog.setMaxImageWidth(newValue.toString());
setDetailListPreferenceValue(mImageWidthPref,
mBlog.getMaxImageWidth(),
mBlog.getMaxImageWidth());
} else if (preference == mUploadAndLinkPref) {
mBlog.setFullSizeImage(Boolean.valueOf(newValue.toString()));
} else {
return false;
}
Expand Down Expand Up @@ -498,22 +509,13 @@ public void onCredentialsValidated(Exception error) {
}
}

public void allowEditing(boolean allow) {
// Address won't be editable until the app supports domain name changes
if (mAddressPref != null) mAddressPref.setEnabled(false);
if (mTitlePref != null) mTitlePref.setEnabled(allow);
if (mTaglinePref != null) mTaglinePref.setEnabled(allow);
if (mPrivacyPref != null) mPrivacyPref.setEnabled(allow);
if (mLanguagePref != null) mLanguagePref.setEnabled(allow);
}

private void setupPreferenceList(ListView prefList, Resources res) {
if (prefList == null || res == null) return;

// customize list dividers
prefList.setDividerHeight(1);
//noinspection deprecation
prefList.setDivider(getResources().getDrawable(R.drawable.preferences_divider));
prefList.setDivider(res.getDrawable(R.drawable.preferences_divider));
prefList.setDividerHeight(res.getDimensionPixelSize(R.dimen.site_settings_divider_height));
// handle long clicks on preferences to display hints
prefList.setOnItemLongClickListener(this);
// required to customize (Calypso) preference views
Expand Down Expand Up @@ -555,6 +557,8 @@ private void initPreferences() {
mMultipleLinksPref = getClickPref(R.string.pref_key_site_multiple_links);
mModerationHoldPref = getClickPref(R.string.pref_key_site_moderation_hold);
mBlacklistPref = getClickPref(R.string.pref_key_site_blacklist);
mImageWidthPref = (DetailListPreference) getChangePref(R.string.pref_key_site_image_width);
mUploadAndLinkPref = (WPSwitchPreference) getChangePref(R.string.pref_key_site_upload_and_link_image);
mDeleteSitePref = getClickPref(R.string.pref_key_site_delete_site);

// .com sites hide the Account category, self-hosted sites hide the Related Posts preference
Expand Down Expand Up @@ -633,6 +637,9 @@ private void setPreferencesFromSiteSettings() {
setDetailListPreferenceValue(mPrivacyPref,
String.valueOf(mSiteSettings.getPrivacy()),
mSiteSettings.getPrivacyDescription());
setDetailListPreferenceValue(mImageWidthPref,
mBlog.getMaxImageWidth(),
mBlog.getMaxImageWidth());
setCategories();
setPostFormats();
setAllowComments(mSiteSettings.getAllowComments());
Expand All @@ -652,6 +659,7 @@ private void setPreferencesFromSiteSettings() {
.getQuantityString(R.plurals.site_settings_multiple_links_summary,
mSiteSettings.getMultipleLinks(),
mSiteSettings.getMultipleLinks()));
mUploadAndLinkPref.setChecked(mBlog.isFullSizeImage());
mIdentityRequiredPreference.setChecked(mSiteSettings.getIdentityRequired());
mUserAccountRequiredPref.setChecked(mSiteSettings.getUserAccountRequired());
mThreadingPref.setValue(String.valueOf(mSiteSettings.getThreadingLevels()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,27 +669,16 @@ public SiteSettingsInterface init(boolean fetchRemote) {
* If there is a change in verification status the listener is notified.
*/
protected void credentialsVerified(boolean valid) {
if (valid) {
if (!mSettings.hasVerifiedCredentials) {
notifyCredentialsVerifiedOnUiThread(null);
}
mRemoteSettings.hasVerifiedCredentials = mSettings.hasVerifiedCredentials = true;
} else {
if (mSettings.hasVerifiedCredentials) {
notifyCredentialsVerifiedOnUiThread(new AuthenticationError());
}
mRemoteSettings.hasVerifiedCredentials = mSettings.hasVerifiedCredentials = false;
}
Exception e = valid ? null : new AuthenticationError();
if (mSettings.hasVerifiedCredentials != valid) notifyCredentialsVerifiedOnUiThread(e);
mRemoteSettings.hasVerifiedCredentials = mSettings.hasVerifiedCredentials = valid;
}

/**
* Helper method to create an XML-RPC interface for the current blog.
*/
protected XMLRPCClientInterface instantiateInterface() {
if (mBlog == null) {
return null;
}

if (mBlog == null) return null;
return XMLRPCFactory.instantiate(mBlog.getUri(), mBlog.getHttpuser(), mBlog.getHttppassword());
}

Expand Down
4 changes: 2 additions & 2 deletions WordPress/src/main/res/layout/blog_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@
android:layout_width="match_parent"
android:layout_height="wrap_content" />

<CheckBox
<org.wordpress.android.widgets.WPCheckBox
android:id="@+id/fullSizeImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/grey_dark"
android:layout_marginTop="@dimen/margin_medium"
android:text="@string/upload_full_size_image" />

<CheckBox
<org.wordpress.android.widgets.WPCheckBox
android:id="@+id/scaledImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down
4 changes: 2 additions & 2 deletions WordPress/src/main/res/layout/number_picker_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:textSize="@dimen/text_sz_large"
android:textColor="@color/number_picker_title"
android:textColor="@color/calypso_title_text"
app:fontFamily="openSans"
app:fontVariation="normal" />

Expand Down Expand Up @@ -45,7 +45,7 @@
android:layout_marginBottom="8dp"
android:duplicateParentState="true"
android:textSize="@dimen/text_sz_large"
android:textColor="@color/number_picker_title"
android:textColor="@color/calypso_title_text"
app:fontFamily="openSans"
app:fontVariation="normal" />

Expand Down
12 changes: 6 additions & 6 deletions WordPress/src/main/res/layout/related_posts_dialog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@
app:fontFamily="openSans"
app:fontVariation="normal" />

<CheckBox
<org.wordpress.android.widgets.WPCheckBox

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Niicceee cc: @nbradbury :)

android:id="@+id/show_header_checkbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:textColor="@color/grey_dark"
android:textSize="@dimen/text_sz_medium"
android:textColor="@color/calypso_title_text"
android:textSize="@dimen/text_sz_large"
android:text="@string/site_settings_rp_show_header_title" />

<CheckBox
<org.wordpress.android.widgets.WPCheckBox
android:id="@+id/show_images_checkbox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:textColor="@color/grey_dark"
android:textSize="@dimen/text_sz_medium"
android:textColor="@color/calypso_title_text"
android:textSize="@dimen/text_sz_large"
android:text="@string/site_settings_rp_show_images_title" />

<View
Expand Down
56 changes: 55 additions & 1 deletion WordPress/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<string name="select_categories">Select categories</string>
<string name="tags_separate_with_commas">Tags (separate tags with commas)</string>
<string name="post_content">Content (tap to add text and media)</string>
<string name="max_thumbnail_px_width">Default image width</string>
<string name="max_thumbnail_px_width">Default Image Width</string>
<string name="password">Password</string>
<string name="blogs">Blogs</string>
<string name="account_details">Account details</string>
Expand Down Expand Up @@ -441,6 +441,9 @@
<string name="pref_key_site_location" translatable="false">wp_pref_site_location</string>
<string name="pref_key_site_category" translatable="false">wp_pref_site_default_category</string>
<string name="pref_key_site_format" translatable="false">wp_pref_site_default_format</string>
<string name="pref_key_site_this_device" translatable="false">wp_pref_site_default_this_device</string>
<string name="pref_key_site_image_width" translatable="false">wp_pref_site_default_image_width</string>
<string name="pref_key_site_upload_and_link_image" translatable="false">wp_pref_site_upload_and_link_image</string>
<string name="pref_key_site_discussion" translatable="false">wp_pref_site_discussion</string>
<string name="pref_key_site_allow_comments" translatable="false">wp_pref_site_allow_comments</string>
<string name="pref_key_site_allow_comments_nested" translatable="false">wp_pref_site_allow_comments_nested</string>
Expand Down Expand Up @@ -491,6 +494,7 @@
<string name="site_settings_discussion_header">@string/discussion</string>
<string name="site_settings_discussion_new_posts_header">Defaults for New Posts</string>
<string name="site_settings_comments_header">@string/comments</string>
<string name="site_settings_this_device_header">This Device</string>

<!-- Preference Titles -->
<string name="site_settings_title_title">Site Title</string>
Expand All @@ -503,6 +507,8 @@
<string name="site_settings_location_title">Enable Location</string>
<string name="site_settings_default_category_title">Default Category</string>
<string name="site_settings_default_format_title">Default Format</string>
<string name="site_settings_default_image_width_title">@string/max_thumbnail_px_width</string>
<string name="site_settings_upload_and_link_image_title">@string/upload_full_size_image</string>
<string name="site_settings_related_posts_title">@string/related_posts</string>
<string name="site_settings_more_title">@string/more</string>
<string name="site_settings_allow_comments_title">Allow Comments</string>
Expand Down Expand Up @@ -574,6 +580,29 @@
<item>@string/site_settings_privacy_hidden_summary</item>
<item>@string/site_settings_privacy_private_summary</item>
</string-array>
<string-array name="site_settings_image_width_entries">
<item>Original Size</item>
<item>100</item>
<item>200</item>
<item>300</item>
<item>400</item>
<item>500</item>
<item>600</item>
<item>700</item>
<item>800</item>
<item>900</item>
<item>1000</item>
<item>1100</item>
<item>1200</item>
<item>1300</item>
<item>1400</item>
<item>1500</item>
<item>1600</item>
<item>1700</item>
<item>1800</item>
<item>1900</item>
<item>2000</item>
</string-array>

<!-- Preference Values -->
<string-array name="site_settings_auto_approve_values">
Expand Down Expand Up @@ -602,6 +631,29 @@
<item>0</item>
<item>-1</item>
</string-array>
<string-array name="site_settings_image_width_values">
<item>Original Size</item>
<item>100</item>
<item>200</item>
<item>300</item>
<item>400</item>
<item>500</item>
<item>600</item>
<item>700</item>
<item>800</item>
<item>900</item>
<item>1000</item>
<item>1100</item>
<item>1200</item>
<item>1300</item>
<item>1400</item>
<item>1500</item>
<item>1600</item>
<item>1700</item>
<item>1800</item>
<item>1900</item>
<item>2000</item>
</string-array>

<!-- Hints (long press) -->
<string name="site_settings_title_hint">In a few words, explain what this site is about</string>
Expand All @@ -614,6 +666,8 @@
<string name="site_settings_location_hint">Automatically add location data to your posts</string>
<string name="site_settings_category_hint">Sets new post category</string>
<string name="site_settings_format_hint">Sets new post format</string>
<string name="site_settings_image_width_hint">Resizes images in posts to this width</string>
<string name="site_settings_upload_and_link_image_hint">Enable to always upload the fullsize image</string>
<string name="site_settings_related_posts_hint">Show or hide related posts in reader</string>
<string name="site_settings_more_hint">View all available Discussion settings</string>
<string name="site_settings_discussion_hint">View and change your sites discussion settings</string>
Expand Down
33 changes: 27 additions & 6 deletions WordPress/src/main/res/xml/site_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@
android:key="@string/pref_key_site_writing"
android:title="@string/site_settings_writing_header">

<org.wordpress.android.ui.prefs.WPSwitchPreference
android:id="@+id/pref_enable_location"
android:key="@string/pref_key_site_location"
android:title="@string/site_settings_location_title"
app:longClickHint="@string/site_settings_location_hint" />

<org.wordpress.android.ui.prefs.DetailListPreference
android:id="@+id/pref_default_category"
android:key="@string/pref_key_site_category"
Expand Down Expand Up @@ -258,6 +252,33 @@

</PreferenceCategory>

<PreferenceCategory
android:id="@+id/pref_this_device"
android:key="@string/pref_key_site_this_device"
android:title="@string/site_settings_this_device_header">

<org.wordpress.android.ui.prefs.WPSwitchPreference
android:id="@+id/pref_enable_location"
android:key="@string/pref_key_site_location"
android:title="@string/site_settings_location_title"
app:longClickHint="@string/site_settings_location_hint" />

<org.wordpress.android.ui.prefs.DetailListPreference
android:id="@+id/pref_default_image_width"
android:key="@string/pref_key_site_image_width"
android:title="@string/site_settings_default_image_width_title"
android:entries="@array/site_settings_image_width_entries"
android:entryValues="@array/site_settings_image_width_values"
app:longClickHint="@string/site_settings_image_width_hint" />

<org.wordpress.android.ui.prefs.WPSwitchPreference
android:id="@+id/pref_upload_and_link_image"
android:key="@string/pref_key_site_upload_and_link_image"
android:title="@string/site_settings_upload_and_link_image_title"
app:longClickHint="@string/site_settings_upload_and_link_image_hint" />

</PreferenceCategory>

<Preference
android:id="@+id/pref_delete_site"
android:key="@string/pref_key_site_delete_site"
Expand Down