Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
64536a3
General section if Site Settings added. Using REST API to pull site info
tonyr59h Jun 24, 2015
02c99d7
Updating API interface to access title field.
tonyr59h Jun 29, 2015
03a4ee9
Smoothing SeekBarPreferenceAnimation and clamping.
tonyr59h Jul 1, 2015
90f6fb0
Updating Title, Tagline, and Visibility after prompting user to sync.
tonyr59h Jul 2, 2015
a39a4b8
Replaced alert dialog with a Save menu option to save changes.
tonyr59h Jul 2, 2015
6613fa8
Notifying of changes to SeekBarPreference value.
tonyr59h Jul 2, 2015
7db4e62
SeekBarPreference can handle arbitrary number of discrete points.
tonyr59h Jul 2, 2015
c192c59
Merge branch 'develop' into feature/2886-general-site-settings
tonyr59h Jul 8, 2015
6f0d04a
Adding remaining preferences, updating design.
tonyr59h Jul 10, 2015
e5abc59
Removing unused Preferences.
tonyr59h Jul 10, 2015
a89a9be
Merge branch 'develop' into feature/2886-general-site-settings
tonyr59h Jul 10, 2015
9e928a0
Saving only changed settings, using resources for language.
tonyr59h Jul 11, 2015
1b21ba4
Updating ActionBar title. Save button is now Undo.
tonyr59h Jul 14, 2015
c41a8a1
Disabling Address field until it's implemented. Fixing initial summar…
tonyr59h Jul 14, 2015
731c899
Merge branch 'develop' into feature/2886-general-site-settings
tonyr59h Jul 14, 2015
1b142d9
Removing unused layout.
tonyr59h Jul 14, 2015
f3c555f
Addressing code review. Closing Activity on settings fetch error.
tonyr59h Jul 15, 2015
4df1aed
Fixing build!
tonyr59h Jul 15, 2015
08712ef
Removing Undo button.
tonyr59h Jul 15, 2015
0f5f8e5
Merge branch 'develop' into feature/2886-general-site-settings
tonyr59h Jul 15, 2015
a6ef9ca
Removing unused undoChanges method.
tonyr59h Jul 20, 2015
ef4b29b
Toasting and leaving Settings if no network is available.
tonyr59h Jul 20, 2015
ef633c6
Moving preference initialization to onResume to avoid crash.
tonyr59h Jul 20, 2015
79f4dd4
Merge branch 'develop' into feature/2886-general-site-settings
tonyr59h Jul 20, 2015
be7953c
Merge branch 'feature/site-settings-review' into feature/2886-general…
tonyr59h Jul 28, 2015
048327c
Title should be "Settings", no reference to blog title.
tonyr59h Jul 29, 2015
7dbd896
Changing display for privacy setting to match design.
tonyr59h Jul 29, 2015
bc945f0
Fixing language retrieval, saving, and display.
tonyr59h Jul 29, 2015
d92f800
Adding support for fetching self-hosted settings; title, tag, address
tonyr59h Jul 29, 2015
76e3d8f
Hiding unavailable settings for self-hosted sites and handling rotation.
tonyr59h Jul 30, 2015
9e14479
Making TypefaceCache members private.
tonyr59h Aug 1, 2015
f220793
Adding custom preference views to show subtext and info button.
tonyr59h Aug 1, 2015
395483d
Clicking info button opens help document.
tonyr59h Aug 1, 2015
763ce43
Cleaning up layout. Adding ripple effect to info button
tonyr59h Aug 2, 2015
8c99caf
Hints displayed on Preference long click.
tonyr59h Aug 4, 2015
c4eefbf
Fixing build
tonyr59h Aug 4, 2015
0f05b42
Capitalize first letter of language strings.
tonyr59h Aug 4, 2015
c184137
Fixing RTL language display.
tonyr59h Aug 4, 2015
6ed9e7d
Language/privacy updated to use more generic DetailListPreference.
tonyr59h Aug 4, 2015
03e1f72
Improving language string generation. Details shown in selected locale.
tonyr59h Aug 4, 2015
5c024dc
Merge branch 'feature/site-settings-review' into feature/2886-general…
tonyr59h Aug 4, 2015
d76785f
Updating detail strings for language dialog when new language is chosen.
tonyr59h Aug 5, 2015
36969fe
Fixing crash on pre-21 API devices.
tonyr59h Aug 5, 2015
7ea9be0
RTL adjustments and handling region-encoded language codes.
tonyr59h Aug 5, 2015
dcedfab
Setting self-hosted changes to title and tagline.
tonyr59h Aug 5, 2015
83a7642
Merge branch 'feature/site-settings-review' into feature/2886-general…
tonyr59h Aug 5, 2015
703bc28
Updating to use method string constants.
tonyr59h Aug 5, 2015
1fd0488
Using resources for DetailListPreference title layout.
tonyr59h Aug 5, 2015
89b635b
Using start instead of left in DetailListPreference layout.
tonyr59h Aug 5, 2015
e230cc3
Using string resource and fixing typo.
tonyr59h Aug 6, 2015
03b6d03
Adding shadow to Settings action bar with recommended 4dp elevation.
tonyr59h Aug 6, 2015
39f08ff
Fixing radio button issue on privacy preference.
tonyr59h Aug 6, 2015
ee1a307
Styling the AlertDialog to better match mock-ups.
tonyr59h Aug 13, 2015
be8c146
Styling preference screen based on mock-ups.
tonyr59h Aug 13, 2015
74e516c
Merge branch 'feature/site-settings-review' into feature/2886-general…
tonyr59h Aug 17, 2015
fff72f6
More design improvements. Dividers as expected in the preference list.
tonyr59h Aug 18, 2015
3b18601
Using correct font for preference category headers.
tonyr59h Aug 18, 2015
ec2490f
Using custom Action Bar layout to use OpenSans
tonyr59h Aug 18, 2015
f48b6f8
Fixing size
tonyr59h Aug 18, 2015
879ca78
Finishing touches on styling.
tonyr59h Aug 18, 2015
6ad00d6
Adjusting fonts
tonyr59h Aug 21, 2015
fe9346e
Fixing list preference cancel bug.
tonyr59h Aug 22, 2015
47c9bf0
Disabling Settings editing when connection is lost.
tonyr59h Aug 24, 2015
5a72a63
Updating MySiteFragment view when blog name is changed.
tonyr59h Aug 24, 2015
4dd5f54
Replacing HTML entities and updating blog with self-hosted title changes
tonyr59h Aug 24, 2015
cf8b955
Keyboard hidden when dialog dismissed, cursor placed at end of text.
tonyr59h Aug 24, 2015
9a27aec
Merge branch 'feature/site-settings-review' into feature/2886-general…
tonyr59h Aug 24, 2015
bfeb69a
Fixing incorrect dialog text and some HTML entity issues
tonyr59h Aug 25, 2015
24d9181
Fixing self-hosted title change bug and handling empty title change.
tonyr59h Aug 25, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions WordPress/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
<activity
android:name=".ui.prefs.BlogPreferencesActivity"
android:theme="@style/CalypsoTheme"
android:configChanges="orientation|screenSize"
android:windowSoftInputMode="stateHidden"/>
<activity
android:name=".ui.prefs.LicensesActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,4 +336,14 @@ public void onStart() {
public void onEventMainThread(CoreEvents.MainViewPagerScrolled event) {
mFabView.setTranslationY(mFabTargetYTranslation * event.mXOffset);
}

@SuppressWarnings("unused")
public void onEventMainThread(CoreEvents.BlogListChanged event) {
if (!isAdded() || (mBlog = WordPress.getBlog(mBlog.getLocalTableBlogId())) == null) return;

// Update view if blog has a new name
if (!mBlogTitleTextView.getText().equals(mBlog.getBlogName())) {
mBlogTitleTextView.setText(mBlog.getBlogName());
}
}
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
package org.wordpress.android.ui.prefs;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import org.wordpress.android.R;
import org.wordpress.android.WordPress;
import org.wordpress.android.models.AccountHelper;
import org.wordpress.android.models.Blog;
import org.wordpress.android.networking.ConnectionChangeReceiver;
import org.wordpress.android.ui.ActivityLauncher;
import org.wordpress.android.ui.stats.datasets.StatsTable;
import org.wordpress.android.util.AnalyticsUtils;
import org.wordpress.android.util.CoreEvents.UserSignedOutCompletely;
import org.wordpress.android.util.StringUtils;
import org.wordpress.android.util.ToastUtils;

import de.greenrobot.event.EventBus;
Expand All @@ -37,65 +24,42 @@ public class BlogPreferencesActivity extends AppCompatActivity {
public static final String ARG_LOCAL_BLOG_ID = "local_blog_id";
public static final int RESULT_BLOG_REMOVED = RESULT_FIRST_USER;

private static final String KEY_SETTINGS_FRAGMENT = "settings-fragment";

// The blog this activity is managing settings for.
private Blog blog;
private boolean mBlogDeleted;
private EditText mUsernameET;
private EditText mPasswordET;
private EditText mHttpUsernameET;
private EditText mHttpPasswordET;
private CheckBox mFullSizeCB;
private CheckBox mScaledCB;
private Spinner mImageWidthSpinner;
private EditText mScaledImageWidthET;
private Blog mBlog;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.blog_preferences);

Integer id = getIntent().getIntExtra(ARG_LOCAL_BLOG_ID, -1);
blog = WordPress.getBlog(id);
mBlog = WordPress.getBlog(id);

if (blog == null) {
if (mBlog == null) {
Toast.makeText(this, getString(R.string.blog_not_found), Toast.LENGTH_SHORT).show();
finish();
return;
}

ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setElevation(0.0f);
actionBar.setTitle(StringUtils.unescapeHTML(blog.getNameOrHostUrl()));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setElevation(getResources().getDimension(R.dimen.appbar_elevation));
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setCustomView(R.layout.site_settings_actionbar);
}

mUsernameET = (EditText) findViewById(R.id.username);
mPasswordET = (EditText) findViewById(R.id.password);
mHttpUsernameET = (EditText) findViewById(R.id.httpuser);
mHttpPasswordET = (EditText) findViewById(R.id.httppassword);
mScaledImageWidthET = (EditText) findViewById(R.id.scaledImageWidth);
mFullSizeCB = (CheckBox) findViewById(R.id.fullSizeImage);
mScaledCB = (CheckBox) findViewById(R.id.scaledImage);
mImageWidthSpinner = (Spinner) findViewById(R.id.maxImageWidth);
Button removeBlogButton = (Button) findViewById(R.id.remove_account);
FragmentManager fragmentManager = getFragmentManager();
Fragment siteSettingsFragment = fragmentManager.findFragmentByTag(KEY_SETTINGS_FRAGMENT);

// remove blog & credentials apply only to dot org
if (blog.isDotcomFlag()) {
View credentialsRL = findViewById(R.id.sectionContent);
credentialsRL.setVisibility(View.GONE);
removeBlogButton.setVisibility(View.GONE);
} else {
removeBlogButton.setVisibility(View.VISIBLE);
removeBlogButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
removeBlogWithConfirmation();
}
});
if (siteSettingsFragment == null) {
siteSettingsFragment = new SiteSettingsFragment();
siteSettingsFragment.setArguments(getIntent().getExtras());
getFragmentManager().beginTransaction()
.replace(android.R.id.content, siteSettingsFragment, KEY_SETTINGS_FRAGMENT)
.commit();
}

loadSettingsForBlog();
}

@Override
Expand All @@ -105,58 +69,21 @@ public void finish() {
}

@Override
protected void onPause() {
super.onPause();

if (mBlogDeleted) {
return;
}

blog.setUsername(mUsernameET.getText().toString());
blog.setPassword(mPasswordET.getText().toString());
blog.setHttpuser(mHttpUsernameET.getText().toString());
blog.setHttppassword(mHttpPasswordET.getText().toString());

blog.setFullSizeImage(mFullSizeCB.isChecked());
blog.setScaledImage(mScaledCB.isChecked());
if (blog.isScaledImage()) {
EditText scaledImgWidth = (EditText) findViewById(R.id.scaledImageWidth);

boolean error = false;
int width = 0;
try {
width = Integer.parseInt(scaledImgWidth.getText().toString().trim());
} catch (NumberFormatException e) {
error = true;
}

if (width == 0) {
error = true;
}

if (error) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(BlogPreferencesActivity.this);
dialogBuilder.setTitle(getResources().getText(R.string.error));
dialogBuilder.setMessage(getResources().getText(R.string.scaled_image_error));
dialogBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
});
dialogBuilder.setCancelable(true);
dialogBuilder.create().show();
return;
} else {
blog.setScaledImageWidth(width);
}
}

blog.setMaxImageWidth(mImageWidthSpinner.getSelectedItem().toString());
protected void onStart() {
super.onStart();
EventBus.getDefault().register(this);
}

WordPress.wpDB.saveBlog(blog);
@Override
protected void onStop() {
EventBus.getDefault().unregister(this);
super.onStop();
}

if (WordPress.getCurrentBlog().getLocalTableBlogId() == blog.getLocalTableBlogId()) {
WordPress.currentBlog = blog;
}
@Override
protected void onPause() {
super.onPause();
WordPress.wpDB.saveBlog(mBlog);
}

@Override
Expand All @@ -170,134 +97,18 @@ public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}

private void loadSettingsForBlog() {
ArrayAdapter<Object> spinnerArrayAdapter = new ArrayAdapter<Object>(this,
R.layout.simple_spinner_item, new String[]{
"Original Size", "100", "200", "300", "400", "500", "600", "700", "800",
"900", "1000", "1100", "1200", "1300", "1400", "1500", "1600", "1700",
"1800", "1900", "2000"
});
spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mImageWidthSpinner.setAdapter(spinnerArrayAdapter);
mImageWidthSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
CheckBox fullSizeImageCheckBox = (CheckBox) findViewById(R.id.fullSizeImage);
// Original size selected. Do not show the link to full image.
if (id == 0) {
fullSizeImageCheckBox.setVisibility(View.GONE);
} else {
fullSizeImageCheckBox.setVisibility(View.VISIBLE);
}
}

@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});

mUsernameET.setText(blog.getUsername());
mPasswordET.setText(blog.getPassword());
mHttpUsernameET.setText(blog.getHttpuser());
mHttpPasswordET.setText(blog.getHttppassword());
TextView httpUserLabel = (TextView) findViewById(R.id.l_httpuser);
if (blog.isDotcomFlag()) {
mHttpUsernameET.setVisibility(View.GONE);
mHttpPasswordET.setVisibility(View.GONE);
httpUserLabel.setVisibility(View.GONE);
} else {
mHttpUsernameET.setVisibility(View.VISIBLE);
mHttpPasswordET.setVisibility(View.VISIBLE);
httpUserLabel.setVisibility(View.VISIBLE);
}

mFullSizeCB.setChecked(blog.isFullSizeImage());
mScaledCB.setChecked(blog.isScaledImage());

this.mScaledImageWidthET.setText("" + blog.getScaledImageWidth());
showScaledSetting(blog.isScaledImage());

CheckBox scaledImage = (CheckBox) findViewById(R.id.scaledImage);
scaledImage.setChecked(false);
scaledImage.setVisibility(View.GONE);

// sets up a state listener for the full-size checkbox
CheckBox fullSizeImageCheckBox = (CheckBox) findViewById(R.id.fullSizeImage);
fullSizeImageCheckBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CheckBox fullSize = (CheckBox) findViewById(R.id.fullSizeImage);
if (fullSize.isChecked()) {
CheckBox scaledImage = (CheckBox) findViewById(R.id.scaledImage);
if (scaledImage.isChecked()) {
scaledImage.setChecked(false);
showScaledSetting(false);
}
}
}
});

int imageWidthPosition = spinnerArrayAdapter.getPosition(blog.getMaxImageWidth());
mImageWidthSpinner.setSelection((imageWidthPosition >= 0) ? imageWidthPosition : 0);
if (mImageWidthSpinner.getSelectedItemPosition() ==
0) //Original size selected. Do not show the link to full image.
{
fullSizeImageCheckBox.setVisibility(View.GONE);
} else {
fullSizeImageCheckBox.setVisibility(View.VISIBLE);
}
}

/**
* Hides / shows the scaled image settings
*/
private void showScaledSetting(boolean show) {
TextView tw = (TextView) findViewById(R.id.l_scaledImage);
EditText et = (EditText) findViewById(R.id.scaledImageWidth);
tw.setVisibility(show ? View.VISIBLE : View.GONE);
et.setVisibility(show ? View.VISIBLE : View.GONE);
}
@SuppressWarnings("unused")
public void onEventMainThread(ConnectionChangeReceiver.ConnectionChangeEvent event) {
FragmentManager fragmentManager = getFragmentManager();
SiteSettingsFragment siteSettingsFragment =
(SiteSettingsFragment) fragmentManager.findFragmentByTag(KEY_SETTINGS_FRAGMENT);

/**
* Remove the blog this activity is managing settings for.
*/
private void removeBlogWithConfirmation() {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
dialogBuilder.setTitle(getResources().getText(R.string.remove_account));
dialogBuilder.setMessage(getResources().getText(R.string.sure_to_remove_account));
dialogBuilder.setPositiveButton(getResources().getText(R.string.yes), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
removeBlog();
}
});
dialogBuilder.setNegativeButton(getResources().getText(R.string.no), null);
dialogBuilder.setCancelable(false);
dialogBuilder.create().show();
}

private void removeBlog() {
if (WordPress.wpDB.deleteBlog(this, blog.getLocalTableBlogId())) {
StatsTable.deleteStatsForBlog(this,blog.getLocalTableBlogId()); // Remove stats data
AnalyticsUtils.refreshMetadata();
ToastUtils.showToast(this, R.string.blog_removed_successfully);
WordPress.wpDB.deleteLastBlogId();
WordPress.currentBlog = null;
mBlogDeleted = true;
setResult(RESULT_BLOG_REMOVED);
if (siteSettingsFragment != null) {
siteSettingsFragment.allowEditing(event.isConnected());

// If the last blog is removed and the user is not signed in wpcom, broadcast a UserSignedOut event
if (!AccountHelper.isSignedIn()) {
EventBus.getDefault().post(new UserSignedOutCompletely());
if (!event.isConnected()) {
ToastUtils.showToast(this, getString(R.string.site_settings_disconnected_toast));
}

finish();
} else {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
dialogBuilder.setTitle(getResources().getText(R.string.error));
dialogBuilder.setMessage(getResources().getText(R.string.could_not_remove_account));
dialogBuilder.setPositiveButton("OK", null);
dialogBuilder.setCancelable(true);
dialogBuilder.create().show();
}
}
}
Loading