Permalink
Browse files

bug fix, change to PreferenceFragment

  • Loading branch information...
1 parent 9c2df6f commit a136ef098d948a4960b7924d543e337c14457e8c Codeskraps committed Mar 11, 2013
View
4 AndroidManifest.xml
@@ -1,7 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.codeskraps.lolo"
- android:versionCode="21"
- android:versionName="2.1" >
+ android:versionCode="22"
+ android:versionName="2.1.1" >
<!-- Remember to update the info code version -->
View
3 README.rdoc
@@ -31,6 +31,9 @@ Install from Google Play
* http://play.google.com/store/apps/details?id=com.codeskraps.lolo
== ChangeLog
+<b>v2.1.1</b>
+* Bug Fix
+
<b>v2.1</b>
* Bug Fix
View
BIN libs/android-support-v4.jar
Binary file not shown.
View
4 res/layout/prefs.xml
@@ -9,8 +9,8 @@
android:layout_height="1dp"
android:background="#FF0000" />
- <ListView
- android:id="@android:id/list"
+ <FrameLayout
+ android:id="@+id/pre_fl"
android:layout_width="match_parent"
android:layout_height="match_parent" />
View
2 res/values/strings.xml
@@ -48,7 +48,7 @@
</string-array>
<string name="prefsCat_Info">Information</string>
- <string name="prefsInfo_Title">091 Labs lo-lo v2.1</string>
+ <string name="prefsInfo_Title">091 Labs lo-lo v2.1.1</string>
<string name="prefsInfo_summary">GNU GPL License v3 &#8211; 2013</string>
<!-- WordPress Acount -->
View
2 res/xml/loloinfo.xml
@@ -3,6 +3,6 @@
android:initialLayout="@layout/widget"
android:minHeight="56dip"
android:minWidth="56dip"
- android:configure="com.codeskraps.lolo.PrefsActivity"
+ android:configure="com.codeskraps.lolo.home.PrefsActivity"
android:previewImage="@drawable/open" />
View
263 src/com/codeskraps/lolo/home/PrefsActivity.java
@@ -31,8 +31,9 @@
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
-import android.preference.PreferenceActivity;
+import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
+import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MenuItem;
@@ -43,138 +44,18 @@
import com.codeskraps.lolo.twitter.TwitterAccountActivity;
import com.codeskraps.lolo.twitter.TwitterSignInActivity;
-public class PrefsActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener,
- OnPreferenceClickListener {
+public class PrefsActivity extends FragmentActivity {
private static final String TAG = PrefsActivity.class.getSimpleName();
- private SharedPreferences prefs = null;
- private ListPreference lstOnClick = null;
- private EditTextPreference eURL = null;
- private CheckBoxPreference chkSync = null;
- private CheckBoxPreference chk24 = null;
- private ListPreference lstInterval = null;
-
- private String[] entries_OnClick = null;
- private String[] entries_Interval = null;
-
@Override
protected void onCreate(Bundle savedInstanceState) {
- if (BuildConfig.DEBUG) Log.d(TAG, "onCreate");
super.onCreate(savedInstanceState);
getActionBar().setDisplayHomeAsUpEnabled(true);
- addPreferencesFromResource(R.xml.preferences);
- setContentView(R.layout.prefs);
-
- prefs = PreferenceManager.getDefaultSharedPreferences(this);
- prefs.registerOnSharedPreferenceChangeListener(this);
-
- entries_OnClick = getResources().getStringArray(R.array.OnClick_entries);
- entries_Interval = getResources().getStringArray(R.array.interval_entries);
-
- lstOnClick = (ListPreference) findPreference(Constants.ONCLICK);
- eURL = (EditTextPreference) findPreference(Constants.EURL);
- chkSync = (CheckBoxPreference) findPreference(Constants.SHOW_SYNC);
- chk24 = (CheckBoxPreference) findPreference(Constants.HOUR24);
- lstInterval = (ListPreference) findPreference(Constants.INTERVAL);
- // ((Preference) findPreference(Constants.WORDPRESS_ACOUNT))
- // .setOnPreferenceClickListener(this);
- ((Preference) findPreference(Constants.TWITTER_ACCOUNT)).setOnPreferenceClickListener(this);
- ((Preference) findPreference(Constants.ABOUT)).setOnPreferenceClickListener(this);
- }
-
- @Override
- protected void onResume() {
- super.onResume();
-
- prefs.registerOnSharedPreferenceChangeListener(this);
-
- String lstSync = prefs.getString(Constants.LAST_SYNC, null);
- if (lstSync == null) chkSync.setSummary(getString(R.string.prefsSync_summarNot));
- else chkSync.setSummary(lstSync);
-
- boolean hour24 = prefs.getBoolean(Constants.HOUR24, true);
- if (hour24) chk24.setSummary(getString(R.string.prefs24_summaryTwo));
- else chk24.setSummary(getString(R.string.prefs24_summaryOne));
-
- String onClick = prefs.getString(Constants.ONCLICK, "0");
- int action = Integer.parseInt(onClick);
- lstOnClick.setSummary(entries_OnClick[action]);
-
- String url = prefs.getString(Constants.EURL, getString(R.string.prefsURL_default));
- String urlSummary = String.format("%s %s", getString(R.string.prefsURL_summary), url);
- eURL.setSummary(urlSummary);
-
- String intervalString = prefs.getString(Constants.INTERVAL, "1");
- int interval = Integer.parseInt(intervalString);
- lstInterval.setSummary(entries_Interval[interval]);
-
- if (action != 3) eURL.setEnabled(false);
-
- if (prefs.getBoolean(Constants.FIRST_LAUNCH, true)) {
- startActivity(new Intent(this, AboutActivity.class));
- SharedPreferences.Editor editor = prefs.edit();
- editor.putBoolean(Constants.FIRST_LAUNCH, false);
- editor.commit();
- }
- }
-
- @Override
- protected void onPause() {
- if (BuildConfig.DEBUG) Log.d(TAG, "onPause");
- super.onPause();
- prefs.unregisterOnSharedPreferenceChangeListener(this);
- }
-
- @Override
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
- if (BuildConfig.DEBUG) Log.d(TAG, "onSharedPreferenceChanged");
-
- if (key.equals(Constants.HOUR24)) {
- if (prefs.getBoolean(Constants.HOUR24, true)) chk24
- .setSummary(getString(R.string.prefs24_summaryTwo));
- else chk24.setSummary(getString(R.string.prefs24_summaryOne));
-
- } else if (key.equals(Constants.ONCLICK)) {
- String onClick = prefs.getString(Constants.ONCLICK, "0");
- int action = Integer.parseInt(onClick);
- lstOnClick.setSummary(entries_OnClick[action]);
-
- if (action != 3) eURL.setEnabled(false);
- else eURL.setEnabled(true);
-
- } else if (key.equals(Constants.EURL)) {
- String url = prefs.getString(Constants.EURL, getString(R.string.prefsURL_default));
- String urlSummary = String.format("%s %s", getString(R.string.prefsURL_summary), url);
- eURL.setSummary(urlSummary);
-
- } else if (key.equals(Constants.INTERVAL)) {
- String intervalString = prefs.getString(Constants.INTERVAL, "1");
- int interval = Integer.parseInt(intervalString);
- lstInterval.setSummary(entries_Interval[interval]);
- }
- }
- @Override
- public boolean onPreferenceClick(Preference pref) {
- if (pref.getKey().equals(Constants.ABOUT)) {
- startActivity(new Intent(this, AboutActivity.class));
- } else if (pref.getKey().equals(Constants.WORDPRESS_ACOUNT)) {
- startActivity(new Intent(this, AddAcount.class));
- } else if (pref.getKey().equals(Constants.TWITTER_ACCOUNT)) {
- SharedPreferences prefs = PreferenceManager
- .getDefaultSharedPreferences(getApplication());
- String token = prefs.getString(Constants.ACCESS_TOKEN, null);
- String secret = prefs.getString(Constants.ACCESS_SECRET, null);
-
- if (token == null || secret == null) {
- startActivity(new Intent(this, TwitterSignInActivity.class));
- } else {
- startActivity(new Intent(this, TwitterAccountActivity.class));
- }
- }
+ setContentView(R.layout.prefs);
- return true;
+ getFragmentManager().beginTransaction().add(R.id.pre_fl, new PrefsFragment()).commit();
}
@Override
@@ -223,4 +104,138 @@ public boolean onOptionsItemSelected(MenuItem item) {
}
return true;
}
+
+ public static class PrefsFragment extends PreferenceFragment implements
+ OnSharedPreferenceChangeListener, OnPreferenceClickListener {
+
+ private SharedPreferences prefs = null;
+ private ListPreference lstOnClick = null;
+ private EditTextPreference eURL = null;
+ private CheckBoxPreference chkSync = null;
+ private CheckBoxPreference chk24 = null;
+ private ListPreference lstInterval = null;
+
+ private String[] entries_OnClick = null;
+ private String[] entries_Interval = null;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ if (BuildConfig.DEBUG) Log.d(TAG, "onCreate");
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.preferences);
+
+ prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
+ prefs.registerOnSharedPreferenceChangeListener(this);
+
+ entries_OnClick = getResources().getStringArray(R.array.OnClick_entries);
+ entries_Interval = getResources().getStringArray(R.array.interval_entries);
+
+ lstOnClick = (ListPreference) findPreference(Constants.ONCLICK);
+ eURL = (EditTextPreference) findPreference(Constants.EURL);
+ chkSync = (CheckBoxPreference) findPreference(Constants.SHOW_SYNC);
+ chk24 = (CheckBoxPreference) findPreference(Constants.HOUR24);
+ lstInterval = (ListPreference) findPreference(Constants.INTERVAL);
+ // ((Preference) findPreference(Constants.WORDPRESS_ACOUNT))
+ // .setOnPreferenceClickListener(this);
+ ((Preference) findPreference(Constants.TWITTER_ACCOUNT))
+ .setOnPreferenceClickListener(this);
+ ((Preference) findPreference(Constants.ABOUT)).setOnPreferenceClickListener(this);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+
+ prefs.registerOnSharedPreferenceChangeListener(this);
+
+ String lstSync = prefs.getString(Constants.LAST_SYNC, null);
+ if (lstSync == null) chkSync.setSummary(getString(R.string.prefsSync_summarNot));
+ else chkSync.setSummary(lstSync);
+
+ boolean hour24 = prefs.getBoolean(Constants.HOUR24, true);
+ if (hour24) chk24.setSummary(getString(R.string.prefs24_summaryTwo));
+ else chk24.setSummary(getString(R.string.prefs24_summaryOne));
+
+ String onClick = prefs.getString(Constants.ONCLICK, "0");
+ int action = Integer.parseInt(onClick);
+ lstOnClick.setSummary(entries_OnClick[action]);
+
+ String url = prefs.getString(Constants.EURL, getString(R.string.prefsURL_default));
+ String urlSummary = String.format("%s %s", getString(R.string.prefsURL_summary), url);
+ eURL.setSummary(urlSummary);
+
+ String intervalString = prefs.getString(Constants.INTERVAL, "1");
+ int interval = Integer.parseInt(intervalString);
+ lstInterval.setSummary(entries_Interval[interval]);
+
+ if (action != 3) eURL.setEnabled(false);
+
+ if (prefs.getBoolean(Constants.FIRST_LAUNCH, true)) {
+ startActivity(new Intent(getActivity(), AboutActivity.class));
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.putBoolean(Constants.FIRST_LAUNCH, false);
+ editor.commit();
+ }
+ }
+
+ @Override
+ public void onPause() {
+ if (BuildConfig.DEBUG) Log.d(TAG, "onPause");
+ super.onPause();
+ prefs.unregisterOnSharedPreferenceChangeListener(this);
+ }
+
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+ if (BuildConfig.DEBUG) Log.d(TAG, "onSharedPreferenceChanged");
+
+ if (key.equals(Constants.HOUR24)) {
+ if (prefs.getBoolean(Constants.HOUR24, true)) chk24
+ .setSummary(getString(R.string.prefs24_summaryTwo));
+ else chk24.setSummary(getString(R.string.prefs24_summaryOne));
+
+ } else if (key.equals(Constants.ONCLICK)) {
+ String onClick = prefs.getString(Constants.ONCLICK, "0");
+ int action = Integer.parseInt(onClick);
+ lstOnClick.setSummary(entries_OnClick[action]);
+
+ if (action != 3) eURL.setEnabled(false);
+ else eURL.setEnabled(true);
+
+ } else if (key.equals(Constants.EURL)) {
+ String url = prefs.getString(Constants.EURL, getString(R.string.prefsURL_default));
+ String urlSummary = String.format("%s %s", getString(R.string.prefsURL_summary),
+ url);
+ eURL.setSummary(urlSummary);
+
+ } else if (key.equals(Constants.INTERVAL)) {
+ String intervalString = prefs.getString(Constants.INTERVAL, "1");
+ int interval = Integer.parseInt(intervalString);
+ lstInterval.setSummary(entries_Interval[interval]);
+ }
+ }
+
+ @Override
+ public boolean onPreferenceClick(Preference pref) {
+ if (pref.getKey().equals(Constants.ABOUT)) {
+ startActivity(new Intent(getActivity(), AboutActivity.class));
+ } else if (pref.getKey().equals(Constants.WORDPRESS_ACOUNT)) {
+ startActivity(new Intent(getActivity(), AddAcount.class));
+ } else if (pref.getKey().equals(Constants.TWITTER_ACCOUNT)) {
+ SharedPreferences prefs = PreferenceManager
+ .getDefaultSharedPreferences(getActivity());
+ String token = prefs.getString(Constants.ACCESS_TOKEN, null);
+ String secret = prefs.getString(Constants.ACCESS_SECRET, null);
+
+ if (token == null || secret == null) {
+ startActivity(new Intent(getActivity(), TwitterSignInActivity.class));
+ } else {
+ startActivity(new Intent(getActivity(), TwitterAccountActivity.class));
+ }
+ }
+
+ return true;
+ }
+ }
}
View
13 src/com/codeskraps/lolo/twitter/TwitterSignInActivity.java
@@ -84,10 +84,15 @@ protected Boolean doInBackground(STEP... params) {
requestToken = service.getRequestToken();
} else if (step == STEP.one) {
- String token = service.getAuthorizationUrl(requestToken);
+ try {
+ String token = service.getAuthorizationUrl(requestToken);
- Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(token));
- startActivity(browserIntent);
+ Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(token));
+ startActivity(browserIntent);
+ } catch (Exception e) {
+ Log.i(TAG, "Handled: twitter key - " + e, e);
+ return true;
+ }
} else if (step == STEP.two) {
try {
@@ -109,7 +114,7 @@ protected Boolean doInBackground(STEP... params) {
return false;
} catch (Exception e) {
- Log.i(TAG, "Handled: twitter key - " + e.getMessage(), e);
+ Log.i(TAG, "Handled: twitter key - " + e, e);
return true;
}
}

0 comments on commit a136ef0

Please sign in to comment.