diff options
Diffstat (limited to 'app')
23 files changed, 73 insertions, 76 deletions
diff --git a/app/app.iml b/app/app.iml index 512f9daa..0e6b07ce 100644 --- a/app/app.iml +++ b/app/app.iml @@ -21,7 +21,7 @@ <option name="ALLOW_USER_CONFIGURATION" value="false" /> <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" /> <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" /> - <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" /> + <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res;file://$MODULE_DIR$/src/debug/res" /> <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" /> </configuration> </facet> diff --git a/app/build.gradle b/app/build.gradle index 8bc5145b..26392afc 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -14,6 +14,9 @@ android { versionName "1.0.11.1" } buildTypes { + debug { + applicationIdSuffix ".debug" + } release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' diff --git a/app/src/debug/res/values/app_info.xml b/app/src/debug/res/values/app_info.xml new file mode 100644 index 00000000..46a00c0d --- /dev/null +++ b/app/src/debug/res/values/app_info.xml @@ -0,0 +1,4 @@ +<resources xmlns:tools="http://schemas.android.com/tools" + tools:ignore="MissingTranslation"> + <string name="app_name">dSmileEssence</string> +</resources>
\ No newline at end of file diff --git a/app/src/main/java/net/lacolaco/smileessence/Application.java b/app/src/main/java/net/lacolaco/smileessence/Application.java index 73430181..2837f699 100644 --- a/app/src/main/java/net/lacolaco/smileessence/Application.java +++ b/app/src/main/java/net/lacolaco/smileessence/Application.java @@ -48,7 +48,7 @@ public class Application extends com.activeandroid.app.Application { public int getThemeResId() { if (resId == -1) { - resId = Themes.getThemeResId(UserPreferenceHelper.getInstance().get(R.string.key_setting_theme, 0)); + resId = Themes.getThemeResId(UserPreferenceHelper.getInstance().getThemeIndex()); } return resId; } diff --git a/app/src/main/java/net/lacolaco/smileessence/activity/EditTabActivity.java b/app/src/main/java/net/lacolaco/smileessence/activity/EditTabActivity.java index c8d309b7..f7bbd025 100644 --- a/app/src/main/java/net/lacolaco/smileessence/activity/EditTabActivity.java +++ b/app/src/main/java/net/lacolaco/smileessence/activity/EditTabActivity.java @@ -51,6 +51,7 @@ public class EditTabActivity extends Activity { private EditableCheckBoxModel[] getCheckBoxItems() { List<EditableCheckBoxModel> models = new ArrayList<>(); + UserPreferenceHelper pref = UserPreferenceHelper.getInstance(); EditableCheckBoxModel post = new EditableCheckBoxModel(getString(R.string.page_name_post)); post.setChecked(true).setInputText(String.valueOf(0)).setFreezing(true); diff --git a/app/src/main/java/net/lacolaco/smileessence/activity/MainActivity.java b/app/src/main/java/net/lacolaco/smileessence/activity/MainActivity.java index b9f9fc16..fa27e70d 100644 --- a/app/src/main/java/net/lacolaco/smileessence/activity/MainActivity.java +++ b/app/src/main/java/net/lacolaco/smileessence/activity/MainActivity.java @@ -75,11 +75,6 @@ public class MainActivity extends Activity { private Uri cameraTempFilePath; private UserStreamListener userStreamListener; - // --------------------- GETTER / SETTER METHODS --------------------- - public int getRequestCountPerPage() { - return UserPreferenceHelper.getInstance().get(R.string.key_setting_timelines, 20); - } - public Uri getCameraTempFilePath() { return cameraTempFilePath; } @@ -88,30 +83,6 @@ public class MainActivity extends Activity { this.cameraTempFilePath = cameraTempFilePath; } - public String getLastSearch() { - return InternalPreferenceHelper.getInstance().get(R.string.key_last_used_search_query, ""); - } - - public void setLastSearch(String query) { - InternalPreferenceHelper.getInstance().set(R.string.key_last_used_search_query, query); - } - - private long getLastUsedAccountID() { - return InternalPreferenceHelper.getInstance().get(R.string.key_last_used_account_id, -1L); - } - - private void setLastUsedAccountID(Account account) { - InternalPreferenceHelper.getInstance().set(R.string.key_last_used_account_id, account.getId()); - } - - public String getLastUserList() { - return InternalPreferenceHelper.getInstance().get(R.string.key_last_used_user_list, ""); - } - - public void setLastUserList(String lastUserList) { - InternalPreferenceHelper.getInstance().set(R.string.key_last_used_user_list, lastUserList); - } - /** * Returns whether twitter stream is running * @@ -400,13 +371,13 @@ public class MainActivity extends Activity { data.getStringExtra(OAuthSession.KEY_SCREEN_NAME)); account.save(); Application.setCurrentAccount(account); - setLastUsedAccountID(account); + InternalPreferenceHelper.getInstance().set(R.string.key_last_used_account_id, account.getId()); startMainLogic(); } } private boolean setupLastUsedAccount() { - long lastId = getLastUsedAccountID(); + long lastId = InternalPreferenceHelper.getInstance().get(R.string.key_last_used_account_id, -1L); Account account = null; if (lastId != -1) { account = Account.load(Account.class, lastId); diff --git a/app/src/main/java/net/lacolaco/smileessence/entity/DirectMessage.java b/app/src/main/java/net/lacolaco/smileessence/entity/DirectMessage.java index aba37462..8c80b0f2 100644 --- a/app/src/main/java/net/lacolaco/smileessence/entity/DirectMessage.java +++ b/app/src/main/java/net/lacolaco/smileessence/entity/DirectMessage.java @@ -8,7 +8,6 @@ import java.util.Date; import java.util.List; public class DirectMessage extends EntitySupport { - // キャッシュ これも weak reference private static Cache<Long, DirectMessage> storage = CacheBuilder.newBuilder().weakValues().build(); public synchronized static DirectMessage fetch(long statusId) { diff --git a/app/src/main/java/net/lacolaco/smileessence/entity/Tweet.java b/app/src/main/java/net/lacolaco/smileessence/entity/Tweet.java index 6d07e464..52d23617 100644 --- a/app/src/main/java/net/lacolaco/smileessence/entity/Tweet.java +++ b/app/src/main/java/net/lacolaco/smileessence/entity/Tweet.java @@ -10,7 +10,6 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; public class Tweet extends EntitySupport { - // キャッシュ こっちは soft reference private static Cache<Long, Tweet> storage = CacheBuilder.newBuilder().softValues().build(); public synchronized static Tweet fetch(long statusId) { diff --git a/app/src/main/java/net/lacolaco/smileessence/entity/User.java b/app/src/main/java/net/lacolaco/smileessence/entity/User.java index 71a4f928..7834e9ce 100644 --- a/app/src/main/java/net/lacolaco/smileessence/entity/User.java +++ b/app/src/main/java/net/lacolaco/smileessence/entity/User.java @@ -5,7 +5,6 @@ import com.google.common.cache.CacheBuilder; import net.lacolaco.smileessence.util.UIObservable; public class User extends UIObservable { - // 重複防止用キャッシュ こっちは weak reference private static Cache<Long, User> storage = CacheBuilder.newBuilder().weakValues().build(); public synchronized static User fetch(long userId) { diff --git a/app/src/main/java/net/lacolaco/smileessence/preference/InternalPreferenceHelper.java b/app/src/main/java/net/lacolaco/smileessence/preference/InternalPreferenceHelper.java index a99d7639..50bc3b12 100644 --- a/app/src/main/java/net/lacolaco/smileessence/preference/InternalPreferenceHelper.java +++ b/app/src/main/java/net/lacolaco/smileessence/preference/InternalPreferenceHelper.java @@ -42,12 +42,9 @@ public class InternalPreferenceHelper extends SharedPreferenceHelper { private InternalPreferenceHelper() { } - // --------------------------- CONSTRUCTORS --------------------------- - + // --------------------------- OVERRIDE --------------------------- @Override protected SharedPreferences getPreferences() { - return Application.getContext().getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE); - } } diff --git a/app/src/main/java/net/lacolaco/smileessence/preference/UserPreferenceHelper.java b/app/src/main/java/net/lacolaco/smileessence/preference/UserPreferenceHelper.java index 059af552..cba6555d 100644 --- a/app/src/main/java/net/lacolaco/smileessence/preference/UserPreferenceHelper.java +++ b/app/src/main/java/net/lacolaco/smileessence/preference/UserPreferenceHelper.java @@ -27,6 +27,8 @@ package net.lacolaco.smileessence.preference; import android.content.SharedPreferences; import android.preference.PreferenceManager; import net.lacolaco.smileessence.Application; +import net.lacolaco.smileessence.R; +import net.lacolaco.smileessence.util.Themes; public class UserPreferenceHelper extends SharedPreferenceHelper { // --------------------------- CONSTRUCTORS --------------------------- @@ -41,9 +43,25 @@ public class UserPreferenceHelper extends SharedPreferenceHelper { } // --------------------- GETTER / SETTER METHODS --------------------- - @Override protected SharedPreferences getPreferences() { return PreferenceManager.getDefaultSharedPreferences(Application.getContext()); } + + // --------------------- HELPER METHODS --------------------- + public int getThemeIndex() { + return get(R.string.key_setting_theme, Themes.THEME_DARK); + } + + public int getTextSize() { + return get(R.string.key_setting_text_size, 10); + } + + public int getNameStyle() { + return get(R.string.key_setting_namestyle, 0); + } + + public int getRequestCountPerPage() { + return get(R.string.key_setting_timelines, 20); + } } diff --git a/app/src/main/java/net/lacolaco/smileessence/view/HomeFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/HomeFragment.java index 0674698e..e3b81ac6 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/HomeFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/HomeFragment.java @@ -34,6 +34,7 @@ import net.lacolaco.smileessence.entity.Account; import net.lacolaco.smileessence.entity.Tweet; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; +import net.lacolaco.smileessence.preference.UserPreferenceHelper; import net.lacolaco.smileessence.twitter.StatusFilter; import net.lacolaco.smileessence.twitter.task.HomeTimelineTask; import net.lacolaco.smileessence.util.UIHandler; @@ -68,7 +69,7 @@ public class HomeFragment extends CustomListFragment<StatusListAdapter> { }); final Account account = Application.getCurrentAccount(); new HomeTimelineTask(account) - .setCount(((MainActivity) getActivity()).getRequestCountPerPage()) + .setCount(UserPreferenceHelper.getInstance().getRequestCountPerPage()) .onFail(e -> Notificator.getInstance().publish(R.string.notice_error_get_home, NotificationType.ALERT)) .onDoneUI(tweets -> { for (Tweet tweet : tweets) { @@ -95,7 +96,7 @@ public class HomeFragment extends CustomListFragment<StatusListAdapter> { } final Account currentAccount = Application.getCurrentAccount(); new HomeTimelineTask(currentAccount) - .setCount(((MainActivity) getActivity()).getRequestCountPerPage()) + .setCount(UserPreferenceHelper.getInstance().getRequestCountPerPage()) .setSinceId(adapter.getTopID()) .onFail(e -> Notificator.getInstance().publish(R.string.notice_error_get_home, NotificationType.ALERT)) .onDoneUI(tweets -> { @@ -115,7 +116,7 @@ public class HomeFragment extends CustomListFragment<StatusListAdapter> { final StatusListAdapter adapter = getAdapter(); final Account currentAccount = Application.getCurrentAccount(); new HomeTimelineTask(currentAccount) - .setCount(((MainActivity) getActivity()).getRequestCountPerPage()) + .setCount(UserPreferenceHelper.getInstance().getRequestCountPerPage()) .setMaxId(adapter.getLastID() - 1) .onFail(e -> Notificator.getInstance().publish(R.string.notice_error_get_home, NotificationType.ALERT)) .onDoneUI(tweets -> { diff --git a/app/src/main/java/net/lacolaco/smileessence/view/MentionsFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/MentionsFragment.java index c22d7ed4..ccdb5f28 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/MentionsFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/MentionsFragment.java @@ -35,6 +35,7 @@ import net.lacolaco.smileessence.entity.ExtractionWord; import net.lacolaco.smileessence.entity.Tweet; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; +import net.lacolaco.smileessence.preference.UserPreferenceHelper; import net.lacolaco.smileessence.twitter.StatusFilter; import net.lacolaco.smileessence.twitter.task.MentionsTimelineTask; import net.lacolaco.smileessence.view.adapter.StatusListAdapter; @@ -74,7 +75,7 @@ public class MentionsFragment extends CustomListFragment<StatusListAdapter> { final Account account = Application.getCurrentAccount(); final StatusListAdapter adapter_ = adapter; new MentionsTimelineTask(account) - .setCount(((MainActivity) getActivity()).getRequestCountPerPage()) + .setCount(UserPreferenceHelper.getInstance().getRequestCountPerPage()) .onFail(x -> Notificator.getInstance().publish(R.string.notice_error_get_mentions, NotificationType.ALERT)) .onDoneUI(tweets -> { for (Tweet tweet : tweets) { @@ -93,7 +94,7 @@ public class MentionsFragment extends CustomListFragment<StatusListAdapter> { final Account currentAccount = Application.getCurrentAccount(); final StatusListAdapter adapter = getAdapter(); new MentionsTimelineTask(currentAccount) - .setCount(((MainActivity) getActivity()).getRequestCountPerPage()) + .setCount(UserPreferenceHelper.getInstance().getRequestCountPerPage()) .setSinceId(adapter.getTopID()) .onFail(x -> Notificator.getInstance().publish(R.string.notice_error_get_mentions, NotificationType.ALERT)) .onDoneUI(tweets -> { @@ -111,7 +112,7 @@ public class MentionsFragment extends CustomListFragment<StatusListAdapter> { final Account currentAccount = Application.getCurrentAccount(); final StatusListAdapter adapter = getAdapter(); new MentionsTimelineTask(currentAccount) - .setCount(((MainActivity) getActivity()).getRequestCountPerPage()) + .setCount(UserPreferenceHelper.getInstance().getRequestCountPerPage()) .setMaxId(adapter.getLastID() - 1) .onFail(x -> Notificator.getInstance().publish(R.string.notice_error_get_mentions, NotificationType.ALERT)) .onDoneUI(tweets -> { diff --git a/app/src/main/java/net/lacolaco/smileessence/view/MessagesFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/MessagesFragment.java index ce346e00..f90c0b7e 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/MessagesFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/MessagesFragment.java @@ -29,11 +29,11 @@ import android.widget.ListView; import com.handmark.pulltorefresh.library.PullToRefreshBase; import net.lacolaco.smileessence.Application; import net.lacolaco.smileessence.R; -import net.lacolaco.smileessence.activity.MainActivity; import net.lacolaco.smileessence.entity.Account; import net.lacolaco.smileessence.entity.DirectMessage; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; +import net.lacolaco.smileessence.preference.UserPreferenceHelper; import net.lacolaco.smileessence.twitter.StatusFilter; import net.lacolaco.smileessence.twitter.task.DirectMessagesTask; import net.lacolaco.smileessence.twitter.task.SentDirectMessagesTask; @@ -69,7 +69,7 @@ public class MessagesFragment extends CustomListFragment<MessageListAdapter> { }); final Account account = Application.getCurrentAccount(); new DirectMessagesTask(account) - .setCount(((MainActivity) getActivity()).getRequestCountPerPage()) + .setCount(UserPreferenceHelper.getInstance().getRequestCountPerPage()) .onFail(x -> Notificator.getInstance().publish(R.string.notice_error_get_messages, NotificationType.ALERT)) .onDoneUI(directMessages -> { for (DirectMessage message : directMessages) { @@ -78,7 +78,7 @@ public class MessagesFragment extends CustomListFragment<MessageListAdapter> { adapter.notifyDataSetChanged(); }).execute(); new SentDirectMessagesTask(account) - .setCount(((MainActivity) getActivity()).getRequestCountPerPage()) + .setCount(UserPreferenceHelper.getInstance().getRequestCountPerPage()) .onFail(x -> Notificator.getInstance().publish(R.string.notice_error_get_messages, NotificationType.ALERT)) .onDoneUI(directMessages -> { for (DirectMessage message : directMessages) { @@ -95,7 +95,7 @@ public class MessagesFragment extends CustomListFragment<MessageListAdapter> { final Account currentAccount = Application.getCurrentAccount(); final MessageListAdapter adapter = getAdapter(); new DirectMessagesTask(currentAccount) - .setCount(((MainActivity) getActivity()).getRequestCountPerPage()) + .setCount(UserPreferenceHelper.getInstance().getRequestCountPerPage()) .setSinceId(adapter.getTopID()) .onFail(x -> Notificator.getInstance().publish(R.string.notice_error_get_messages, NotificationType.ALERT)) .onDoneUI(directMessages -> { @@ -112,7 +112,7 @@ public class MessagesFragment extends CustomListFragment<MessageListAdapter> { final Account currentAccount = Application.getCurrentAccount(); final MessageListAdapter adapter = getAdapter(); new DirectMessagesTask(currentAccount) - .setCount(((MainActivity) getActivity()).getRequestCountPerPage()) + .setCount(UserPreferenceHelper.getInstance().getRequestCountPerPage()) .setMaxId(adapter.getLastID() - 1) .onFail(x -> Notificator.getInstance().publish(R.string.notice_error_get_messages, NotificationType.ALERT)) .onDoneUI(directMessages -> { diff --git a/app/src/main/java/net/lacolaco/smileessence/view/PostFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/PostFragment.java index 39571e77..663582c2 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/PostFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/PostFragment.java @@ -216,7 +216,7 @@ public class PostFragment extends PageFragment implements TextWatcher, View.OnFo buttonTweet.setOnClickListener(this); editText = getEditText(v); textViewCount = getCountTextView(v); - int textSize = UserPreferenceHelper.getInstance().get(R.string.key_setting_text_size, 10); + int textSize = UserPreferenceHelper.getInstance().getTextSize(); editText.addTextChangedListener(this); editText.setOnFocusChangeListener(this); editText.setTextSize(textSize + 4); diff --git a/app/src/main/java/net/lacolaco/smileessence/view/SearchFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/SearchFragment.java index 1fcde85c..1bd03c73 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/SearchFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/SearchFragment.java @@ -48,6 +48,8 @@ import net.lacolaco.smileessence.entity.SearchQuery; import net.lacolaco.smileessence.entity.Tweet; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; +import net.lacolaco.smileessence.preference.InternalPreferenceHelper; +import net.lacolaco.smileessence.preference.UserPreferenceHelper; import net.lacolaco.smileessence.twitter.StatusFilter; import net.lacolaco.smileessence.twitter.task.SearchTask; import net.lacolaco.smileessence.util.UIHandler; @@ -82,7 +84,7 @@ public class SearchFragment extends CustomListFragment<SearchListAdapter> implem setAdapter(adapter); final MainActivity activity = (MainActivity) getActivity(); - String lastUsedSearchQuery = activity.getLastSearch(); + String lastUsedSearchQuery = InternalPreferenceHelper.getInstance().get(R.string.key_last_used_search_query, ""); if (!TextUtils.isEmpty(lastUsedSearchQuery)) { startSearch(lastUsedSearchQuery); } @@ -142,7 +144,7 @@ public class SearchFragment extends CustomListFragment<SearchListAdapter> implem } final Query query = new Query(); query.setQuery(queryString); - query.setCount(activity.getRequestCountPerPage()); + query.setCount(UserPreferenceHelper.getInstance().getRequestCountPerPage()); query.setResultType(Query.RECENT); if (adapter.getCount() > 0) { query.setSinceId(adapter.getTopID()); @@ -183,7 +185,7 @@ public class SearchFragment extends CustomListFragment<SearchListAdapter> implem } final Query query = new Query(); query.setQuery(queryString); - query.setCount(activity.getRequestCountPerPage()); + query.setCount(UserPreferenceHelper.getInstance().getRequestCountPerPage()); query.setResultType(Query.RECENT); if (adapter.getCount() > 0) { query.setMaxId(adapter.getLastID() - 1); @@ -328,7 +330,7 @@ public class SearchFragment extends CustomListFragment<SearchListAdapter> implem } public void startSearch(final String queryString) { - ((MainActivity) getActivity()).setLastSearch(queryString); + InternalPreferenceHelper.getInstance().set(R.string.key_last_used_search_query, queryString); if (!TextUtils.isEmpty(queryString)) { final SearchListAdapter adapter = getAdapter(); adapter.initSearch(queryString); @@ -336,7 +338,7 @@ public class SearchFragment extends CustomListFragment<SearchListAdapter> implem adapter.updateForce(); final Query query = new Query(); query.setQuery(queryString); - query.setCount(((MainActivity) getActivity()).getRequestCountPerPage()); + query.setCount(UserPreferenceHelper.getInstance().getRequestCountPerPage()); query.setResultType(Query.RECENT); new SearchTask(Application.getCurrentAccount(), query) .onDoneUI(queryResult -> { diff --git a/app/src/main/java/net/lacolaco/smileessence/view/UserListFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/UserListFragment.java index e11877fe..208b2f7d 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/UserListFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/UserListFragment.java @@ -42,6 +42,8 @@ import net.lacolaco.smileessence.entity.Account; import net.lacolaco.smileessence.entity.Tweet; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; +import net.lacolaco.smileessence.preference.InternalPreferenceHelper; +import net.lacolaco.smileessence.preference.UserPreferenceHelper; import net.lacolaco.smileessence.twitter.StatusFilter; import net.lacolaco.smileessence.twitter.task.UserListStatusesTask; import net.lacolaco.smileessence.util.UIHandler; @@ -74,7 +76,7 @@ public class UserListFragment extends CustomListFragment<UserListListAdapter> im UserListListAdapter adapter = new UserListListAdapter(getActivity()); setAdapter(adapter); - String lastUserList = getMainActivity().getLastUserList(); + String lastUserList = InternalPreferenceHelper.getInstance().get(R.string.key_last_used_user_list, ""); if (!TextUtils.isEmpty(lastUserList)) { startUserList(lastUserList); } @@ -107,7 +109,7 @@ public class UserListFragment extends CustomListFragment<UserListListAdapter> im return; } new UserListStatusesTask(currentAccount, listFullName) - .setCount(((MainActivity) getActivity()).getRequestCountPerPage()) + .setCount(UserPreferenceHelper.getInstance().getRequestCountPerPage()) .setSinceId(adapter.getTopID()) .onFail(x -> Notificator.getInstance().publish(R.string.notice_error_get_list, NotificationType.ALERT)) .onDoneUI(tweets -> { @@ -135,7 +137,7 @@ public class UserListFragment extends CustomListFragment<UserListListAdapter> im return; } new UserListStatusesTask(currentAccount, listFullName) - .setCount(((MainActivity) getActivity()).getRequestCountPerPage()) + .setCount(UserPreferenceHelper.getInstance().getRequestCountPerPage()) .setMaxId(adapter.getLastID() - 1) .onFail(x -> Notificator.getInstance().publish(R.string.notice_error_get_list, NotificationType.ALERT)) .onDoneUI(tweets -> { @@ -196,13 +198,13 @@ public class UserListFragment extends CustomListFragment<UserListListAdapter> im } public void startUserList(String listFullName) { - getMainActivity().setLastUserList(listFullName); + InternalPreferenceHelper.getInstance().set(R.string.key_last_used_user_list, listFullName); final UserListListAdapter adapter = getAdapter(); adapter.setListFullName(listFullName); adapter.clear(); adapter.updateForce(); new UserListStatusesTask(Application.getCurrentAccount(), listFullName) - .setCount(((MainActivity) getActivity()).getRequestCountPerPage()) + .setCount(UserPreferenceHelper.getInstance().getRequestCountPerPage()) .onFail(x -> Notificator.getInstance().publish(R.string.notice_error_get_list, NotificationType.ALERT)) .onDoneUI(tweets -> { for (Tweet tweet : tweets) { diff --git a/app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusDetailDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusDetailDialogFragment.java index 333698ba..a6b73148 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusDetailDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusDetailDialogFragment.java @@ -218,7 +218,7 @@ public class StatusDetailDialogFragment extends StackableDialogFragment implemen if (tweet.isFavoritedBy(account.getUserId())) { favorite.setImageDrawable(getResources().getDrawable(R.drawable.icon_favorite_on)); } else { - retweet.setImageDrawable(Themes.getStyledDrawable(getActivity(), themeResId, R.attr.icon_favorite_off)); + favorite.setImageDrawable(Themes.getStyledDrawable(getActivity(), themeResId, R.attr.icon_favorite_off)); } ImageButton delete = (ImageButton) view.findViewById(R.id.button_status_detail_delete); diff --git a/app/src/main/java/net/lacolaco/smileessence/view/dialog/UserDetailDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/UserDetailDialogFragment.java index 31613e9d..aa494893 100644 --- a/app/src/main/java/net/lacolaco/smileessence/view/dialog/UserDetailDialogFragment.java +++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/UserDetailDialogFragment.java @@ -48,6 +48,7 @@ import net.lacolaco.smileessence.entity.Tweet; import net.lacolaco.smileessence.entity.User; import net.lacolaco.smileessence.notification.NotificationType; import net.lacolaco.smileessence.notification.Notificator; +import net.lacolaco.smileessence.preference.UserPreferenceHelper; import net.lacolaco.smileessence.twitter.task.FollowTask; import net.lacolaco.smileessence.twitter.task.ShowFriendshipTask; import net.lacolaco.smileessence.twitter.task.UnfollowTask; @@ -151,7 +152,7 @@ public class UserDetailDialogFragment extends StackableDialogFragment implements public void onPullDownToRefresh(final PullToRefreshBase<ListView> refreshView) { Account currentAccount = Application.getCurrentAccount(); new UserTimelineTask(currentAccount, getUserID()) - .setCount(((MainActivity) getActivity()).getRequestCountPerPage()) + .setCount(UserPreferenceHelper.getInstance().getRequestCountPerPage()) .setSinceId(adapter.getTopID()) .onFail(x -> Notificator.getInstance().publish(R.string.notice_error_get_user_timeline, NotificationType.ALERT)) .onDoneUI(tweets -> { @@ -168,7 +169,7 @@ public class UserDetailDialogFragment extends StackableDialogFragment implements public void onPullUpToRefresh(final PullToRefreshBase<ListView> refreshView) { Account currentAccount = Application.getCurrentAccount(); new UserTimelineTask(currentAccount, getUserID()) - .setCount(((MainActivity) getActivity()).getRequestCountPerPage()) + .setCount(UserPreferenceHelper.getInstance().getRequestCountPerPage()) .setMaxId(adapter.getLastID() - 1) .onFail(x -> Notificator.getInstance().publish(R.string.notice_error_get_user_timeline, NotificationType.ALERT)) .onDoneUI(tweets -> { @@ -241,7 +242,7 @@ public class UserDetailDialogFragment extends StackableDialogFragment implements Account account = Application.getCurrentAccount(); tabHost.getTabWidget().getChildTabViewAt(1).setVisibility(View.GONE); new UserTimelineTask(account, user.getId()) - .setCount(((MainActivity) getActivity()).getRequestCountPerPage()) + .setCount(UserPreferenceHelper.getInstance().getRequestCountPerPage()) .onFail(x -> Notificator.getInstance().publish(R.string.notice_error_get_user_timeline, NotificationType.ALERT)) .onDoneUI(tweets -> { for (Tweet tweet : tweets) { diff --git a/app/src/main/java/net/lacolaco/smileessence/viewmodel/EventViewModel.java b/app/src/main/java/net/lacolaco/smileessence/viewmodel/EventViewModel.java index e834b1bf..f478cf38 100644 --- a/app/src/main/java/net/lacolaco/smileessence/viewmodel/EventViewModel.java +++ b/app/src/main/java/net/lacolaco/smileessence/viewmodel/EventViewModel.java @@ -115,8 +115,7 @@ public class EventViewModel implements IViewModel { convertedView.setTag(bundle); } - int textSize = UserPreferenceHelper.getInstance().get(R.string.key_setting_text_size, 10); - int nameStyle = UserPreferenceHelper.getInstance().get(R.string.key_setting_namestyle, 0); + int textSize = UserPreferenceHelper.getInstance().getTextSize(); int theme = ((Application) activity.getApplication()).getThemeResId(); TextView header = (TextView) convertedView.findViewById(R.id.textview_status_header); diff --git a/app/src/main/java/net/lacolaco/smileessence/viewmodel/MessageViewModel.java b/app/src/main/java/net/lacolaco/smileessence/viewmodel/MessageViewModel.java index 91665122..f58c051a 100644 --- a/app/src/main/java/net/lacolaco/smileessence/viewmodel/MessageViewModel.java +++ b/app/src/main/java/net/lacolaco/smileessence/viewmodel/MessageViewModel.java @@ -118,8 +118,8 @@ public class MessageViewModel implements IViewModel { } private void updateViewSender(Activity activity, View convertedView) { - int textSize = UserPreferenceHelper.getInstance().get(R.string.key_setting_text_size, 10); - int nameStyle = UserPreferenceHelper.getInstance().get(R.string.key_setting_namestyle, 0); + int textSize = UserPreferenceHelper.getInstance().getTextSize(); + int nameStyle = UserPreferenceHelper.getInstance().getNameStyle(); int theme = ((Application) activity.getApplication()).getThemeResId(); NetworkImageView icon = (NetworkImageView) convertedView.findViewById(R.id.imageview_status_icon); @@ -138,7 +138,7 @@ public class MessageViewModel implements IViewModel { } private void updateViewBody(Activity activity, View convertedView) { - int textSize = UserPreferenceHelper.getInstance().get(R.string.key_setting_text_size, 10); + int textSize = UserPreferenceHelper.getInstance().getTextSize(); int theme = ((Application) activity.getApplication()).getThemeResId(); TextView content = (TextView) convertedView.findViewById(R.id.textview_status_text); diff --git a/app/src/main/java/net/lacolaco/smileessence/viewmodel/StatusViewModel.java b/app/src/main/java/net/lacolaco/smileessence/viewmodel/StatusViewModel.java index 4e59745e..56e7562b 100644 --- a/app/src/main/java/net/lacolaco/smileessence/viewmodel/StatusViewModel.java +++ b/app/src/main/java/net/lacolaco/smileessence/viewmodel/StatusViewModel.java @@ -125,8 +125,8 @@ public class StatusViewModel implements IViewModel { } private void updateViewUser(MainActivity activity, View convertedView) { - int textSize = UserPreferenceHelper.getInstance().get(R.string.key_setting_text_size, 10); - int nameStyle = UserPreferenceHelper.getInstance().get(R.string.key_setting_namestyle, 0); + int textSize = UserPreferenceHelper.getInstance().getTextSize(); + int nameStyle = UserPreferenceHelper.getInstance().getNameStyle(); int theme = ((Application) activity.getApplication()).getThemeResId(); NetworkImageView icon = (NetworkImageView) convertedView.findViewById(R.id.imageview_status_icon); @@ -142,7 +142,7 @@ public class StatusViewModel implements IViewModel { } private void updateViewBody(MainActivity activity, View convertedView) { - int textSize = UserPreferenceHelper.getInstance().get(R.string.key_setting_text_size, 10); + int textSize = UserPreferenceHelper.getInstance().getTextSize(); int theme = ((Application) activity.getApplication()).getThemeResId(); TextView content = (TextView) convertedView.findViewById(R.id.textview_status_text); diff --git a/app/src/main/res/values/app_info.xml b/app/src/main/res/values/app_info.xml index 8a924181..60cee8e7 100644 --- a/app/src/main/res/values/app_info.xml +++ b/app/src/main/res/values/app_info.xml @@ -24,7 +24,7 @@ <resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation"> - <string name="app_name">rSmileEssence</string> + <string name="app_name">SmileEssence</string> <string name="app_version_full">1.0.11 \"Dolphin\"</string> <string name="app_url">http://smileessence.lacolaco.net</string> <string name="app_author">Developed by laco0416</string> |