From 7942e92dd89dcff7cd95ee32f2ebbec9cbf80180 Mon Sep 17 00:00:00 2001 From: ratan12 Date: Fri, 25 Dec 2015 14:23:31 +0100 Subject: [PATCH 01/46] Remove old forum files --- Atarashii/res/layout/activity_forum_main.xml | 92 -------- .../res/layout/activity_forum_topics.xml | 28 --- .../res/raw/forum_post_spoiler_structure.html | 1 - .../MAL/api/MALModels/Forum.java | 79 ------- .../MAL/forum/ForumsMain.java | 174 --------------- .../MAL/forum/ForumsPosts.java | 138 ------------ .../MAL/forum/ForumsTopics.java | 207 ------------------ .../MAL/forum/PostsInterface.java | 124 ----------- 8 files changed, 843 deletions(-) delete mode 100644 Atarashii/res/layout/activity_forum_main.xml delete mode 100644 Atarashii/res/layout/activity_forum_topics.xml delete mode 100644 Atarashii/res/raw/forum_post_spoiler_structure.html delete mode 100644 Atarashii/src/net/somethingdreadful/MAL/api/MALModels/Forum.java delete mode 100644 Atarashii/src/net/somethingdreadful/MAL/forum/ForumsMain.java delete mode 100644 Atarashii/src/net/somethingdreadful/MAL/forum/ForumsPosts.java delete mode 100644 Atarashii/src/net/somethingdreadful/MAL/forum/ForumsTopics.java delete mode 100644 Atarashii/src/net/somethingdreadful/MAL/forum/PostsInterface.java diff --git a/Atarashii/res/layout/activity_forum_main.xml b/Atarashii/res/layout/activity_forum_main.xml deleted file mode 100644 index 84323b60..00000000 --- a/Atarashii/res/layout/activity_forum_main.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Atarashii/res/layout/activity_forum_topics.xml b/Atarashii/res/layout/activity_forum_topics.xml deleted file mode 100644 index eeb7b5c3..00000000 --- a/Atarashii/res/layout/activity_forum_topics.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/Atarashii/res/raw/forum_post_spoiler_structure.html b/Atarashii/res/raw/forum_post_spoiler_structure.html deleted file mode 100644 index b9900f20..00000000 --- a/Atarashii/res/raw/forum_post_spoiler_structure.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/Forum.java b/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/Forum.java deleted file mode 100644 index 74ac7b48..00000000 --- a/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/Forum.java +++ /dev/null @@ -1,79 +0,0 @@ -package net.somethingdreadful.MAL.api.MALModels; - -import java.io.Serializable; -import java.util.ArrayList; - -import lombok.Getter; -import lombok.Setter; - -public class Forum implements Serializable { - /** - * The ID used to get topic/board - */ - @Setter - @Getter - private int id = 0; - - /** - * The forum board/topic name. - */ - @Setter - @Getter - private String name; - - /** - * The username of the topic creator - */ - @Setter - @Getter - private String username; - - /** - * The number of replies of a topic - */ - @Setter - @Getter - private int replies = 0; - - /** - * The description of a board - */ - @Setter - @Getter - private String description; - - /** - * The info of the last reply inside a topic - */ - @Setter - @Getter - private Forum reply; - - /** - * The children of a forumboard - */ - @Setter - @Getter - private ArrayList children; - - /** - * The comment content in an post - */ - @Setter - @Getter - private String comment; - - /** - * The creation time of this post - */ - @Setter - @Getter - private String time; - - /** - * The userprofile for the user details in topics - */ - @Setter - @Getter - private Profile profile; -} diff --git a/Atarashii/src/net/somethingdreadful/MAL/forum/ForumsMain.java b/Atarashii/src/net/somethingdreadful/MAL/forum/ForumsMain.java deleted file mode 100644 index 3693b82c..00000000 --- a/Atarashii/src/net/somethingdreadful/MAL/forum/ForumsMain.java +++ /dev/null @@ -1,174 +0,0 @@ -package net.somethingdreadful.MAL.forum; - -import android.app.Activity; -import android.app.Fragment; -import android.os.AsyncTask; -import android.os.Bundle; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.ListView; -import android.widget.ProgressBar; -import android.widget.ScrollView; - -import com.crashlytics.android.Crashlytics; - -import net.somethingdreadful.MAL.Card; -import net.somethingdreadful.MAL.ForumActivity; -import net.somethingdreadful.MAL.R; -import net.somethingdreadful.MAL.adapters.ForumMainAdapter; -import net.somethingdreadful.MAL.api.MALApi; -import net.somethingdreadful.MAL.api.MALModels.Forum; -import net.somethingdreadful.MAL.api.MALModels.ForumMain; -import net.somethingdreadful.MAL.dialog.ForumChildDialogFragment; -import net.somethingdreadful.MAL.tasks.ForumJob; -import net.somethingdreadful.MAL.tasks.ForumNetworkTask; - -import butterknife.Bind; -import butterknife.ButterKnife; - -public class ForumsMain extends Fragment implements ForumNetworkTask.ForumNetworkTaskListener { - ForumActivity activity; - View view; - ForumMain record; - ForumMainAdapter myanimelistAdapter; - ForumMainAdapter animemangaAdapter; - ForumMainAdapter generalAdapter; - - @Bind(R.id.general) ListView general; - @Bind(R.id.scrollView) - ScrollView content; - @Bind(R.id.animemanga) ListView animeManga; - @Bind(R.id.myanimelist) ListView myAnimeList; - @Bind(R.id.network_Card) Card networkCard; - @Bind(R.id.progressBar) ProgressBar progressBar; - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) { - super.onCreate(bundle); - view = inflater.inflate(R.layout.activity_forum_main, container, false); - ButterKnife.bind(this, view); - - myanimelistAdapter = new ForumMainAdapter(activity, myAnimeList, getFragmentManager(), ForumJob.BOARD); - animemangaAdapter = new ForumMainAdapter(activity, animeManga, getFragmentManager(), ForumJob.BOARD); - generalAdapter = new ForumMainAdapter(activity, general, getFragmentManager(), ForumJob.BOARD); - - toggle(1); - setListener(); - - if (bundle != null && bundle.getSerializable("main") != null) - apply((ForumMain) bundle.getSerializable("main")); - else - getRecords(); - - return view; - } - - @Override - public void onSaveInstanceState(Bundle state) { - state.putSerializable("main", record); - super.onSaveInstanceState(state); - } - - /** - * Request new records. - */ - private void getRecords() { - if (MALApi.isNetworkAvailable(activity)) - new ForumNetworkTask(activity, this, activity, ForumJob.BOARD, 0).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - else - toggle(2); - } - - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - this.activity = ((ForumActivity) activity); - } - - @Override - public void onForumNetworkTaskFinished(ForumMain result, ForumJob task) { - apply(result); - } - - /** - * Refresh the UI for changes. - * - * @param result The new record that should be applied. - */ - public void apply(ForumMain result) { - try { - myAnimeList.setAdapter(myanimelistAdapter); - animeManga.setAdapter(animemangaAdapter); - general.setAdapter(generalAdapter); - - myanimelistAdapter.supportAddAll(result.getMyAnimeList()); - animemangaAdapter.supportAddAll(result.getAnimeManga()); - generalAdapter.supportAddAll(result.getGeneral()); - record = result; - toggle(0); - } catch (Exception e) { - Crashlytics.log(Log.ERROR, "MALX", "ForumMain.apply(): " + e.getMessage()); - } - } - - /** - * Set all the clicklisteners. - */ - private void setListener() { - myAnimeList.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - requestTopic((Forum) myanimelistAdapter.getItem(position)); - } - }); - animeManga.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - requestTopic((Forum) animemangaAdapter.getItem(position)); - } - }); - general.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - requestTopic((Forum) generalAdapter.getItem(position)); - } - }); - } - - /** - * Create a dialog to ask which subBoard you want to view. - * - * @param item The forum item with the subBoards - */ - private void requestTopic(Forum item) { - if (item.getId() == 0) { - ForumChildDialogFragment info = new ForumChildDialogFragment(); - Bundle args = new Bundle(); - args.putString("title", item.getName()); - args.putString("message", getString(R.string.dialog_message_forum_child)); - args.putSerializable("child", item.getChildren()); - info.setArguments(args); - info.show(getFragmentManager(), "fragment_forum"); - } else { - activity.getTopics(item.getId()); - } - } - - /** - * Handle the viewFlipper. - *

- * 0 = The real content - * 1 = The progress indicator - * 2 = The network not available card - * - * @param number The number of the desired content - */ - private void toggle(int number) { - content.setVisibility(number == 0 ? View.VISIBLE : View.GONE); - progressBar.setVisibility(number == 1 ? View.VISIBLE : View.GONE); - networkCard.setVisibility(number == 2 ? View.VISIBLE : View.GONE); - } -} \ No newline at end of file diff --git a/Atarashii/src/net/somethingdreadful/MAL/forum/ForumsPosts.java b/Atarashii/src/net/somethingdreadful/MAL/forum/ForumsPosts.java deleted file mode 100644 index 75572fb0..00000000 --- a/Atarashii/src/net/somethingdreadful/MAL/forum/ForumsPosts.java +++ /dev/null @@ -1,138 +0,0 @@ -package net.somethingdreadful.MAL.forum; - -import android.annotation.SuppressLint; -import android.app.Activity; -import android.app.Fragment; -import android.os.AsyncTask; -import android.os.Bundle; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.webkit.WebView; -import android.widget.ViewFlipper; - -import com.crashlytics.android.Crashlytics; - -import net.somethingdreadful.MAL.ForumActivity; -import net.somethingdreadful.MAL.R; -import net.somethingdreadful.MAL.Theme; -import net.somethingdreadful.MAL.account.AccountService; -import net.somethingdreadful.MAL.api.MALApi; -import net.somethingdreadful.MAL.api.MALModels.ForumMain; -import net.somethingdreadful.MAL.tasks.ForumJob; -import net.somethingdreadful.MAL.tasks.ForumNetworkTask; - -import butterknife.Bind; -import butterknife.ButterKnife; - -public class ForumsPosts extends Fragment implements ForumNetworkTask.ForumNetworkTaskListener { - View view; - HtmlUtil htmlUtil; - ForumActivity activity; - public ForumMain record; - - @Bind(R.id.webview) - WebView webview; - @Bind(R.id.viewFlipper) ViewFlipper viewFlipper; - - public int id; - public int page = 0; - - @SuppressLint({"AddJavascriptInterface", "SetJavaScriptEnabled"}) - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) { - super.onCreate(bundle); - view = inflater.inflate(R.layout.fragment_forum_posts, container, false); - ButterKnife.bind(this, view); - - htmlUtil = new HtmlUtil(activity); - - if (bundle != null && bundle.getSerializable("posts") != null) { - id = bundle.getInt("id"); - page = bundle.getInt("page"); - apply((ForumMain) bundle.getSerializable("posts")); - } - - webview.getSettings().setJavaScriptEnabled(true); - webview.addJavascriptInterface(new PostsInterface(this), "Posts"); - - return view; - } - - @Override - public void onSaveInstanceState(Bundle state) { - state.putSerializable("posts", record); - state.putInt("id", id); - state.putInt("page", page); - super.onSaveInstanceState(state); - } - - /** - * Change the records in this fragment. - * - * @param id The new id of the record - * @return ForumJob The task of this fragment - */ - public ForumJob setId(int id) { - if (this.id != id) { - this.id = id; - toggle(true); - getRecords(1); - } - return ForumJob.POSTS; - } - - /** - * Get the requested records. - * - * @param page The page number - */ - public void getRecords(int page) { - if (page != this.page) - toggle(true); - this.page = page; - if (MALApi.isNetworkAvailable(activity)) - new ForumNetworkTask(activity, this, activity, ForumJob.POSTS, id).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, String.valueOf(page)); - } - - /** - * Show or hide the progress indicator. - * - * @param loading True if the indicator should be shown - */ - private void toggle(boolean loading) { - viewFlipper.setDisplayedChild(loading ? 1 : 0); - } - - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - this.activity = ((ForumActivity) activity); - } - - @Override - public void onForumNetworkTaskFinished(ForumMain result, ForumJob job) { - apply(result); - } - - /** - * Refresh the UI for changes. - * - * @param result The new record - */ - public void apply(ForumMain result) { - try { - activity.setTitle(getString(R.string.title_activity_forum)); - if (result != null) { - webview.loadDataWithBaseURL(null, htmlUtil.convertList(result, AccountService.getUsername(), page), "text/html", "utf-8", null); - toggle(false); - record = result; - } else { - Theme.Snackbar(activity, R.string.toast_error_Records); - } - } catch (Exception e) { - Crashlytics.log(Log.ERROR, "MALX", "ForumPosts.apply(): " + e.getMessage()); - } - } -} \ No newline at end of file diff --git a/Atarashii/src/net/somethingdreadful/MAL/forum/ForumsTopics.java b/Atarashii/src/net/somethingdreadful/MAL/forum/ForumsTopics.java deleted file mode 100644 index 101b9e8b..00000000 --- a/Atarashii/src/net/somethingdreadful/MAL/forum/ForumsTopics.java +++ /dev/null @@ -1,207 +0,0 @@ -package net.somethingdreadful.MAL.forum; - -import android.app.Activity; -import android.app.Fragment; -import android.os.AsyncTask; -import android.os.Bundle; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AbsListView; -import android.widget.AdapterView; -import android.widget.ListView; -import android.widget.ProgressBar; -import android.widget.RelativeLayout; - -import com.crashlytics.android.Crashlytics; - -import net.somethingdreadful.MAL.Card; -import net.somethingdreadful.MAL.ForumActivity; -import net.somethingdreadful.MAL.R; -import net.somethingdreadful.MAL.adapters.ForumMainAdapter; -import net.somethingdreadful.MAL.api.MALApi; -import net.somethingdreadful.MAL.api.MALModels.Forum; -import net.somethingdreadful.MAL.api.MALModels.ForumMain; -import net.somethingdreadful.MAL.dialog.ForumChildDialogFragment; -import net.somethingdreadful.MAL.tasks.ForumJob; -import net.somethingdreadful.MAL.tasks.ForumNetworkTask; - -import butterknife.Bind; -import butterknife.ButterKnife; - -public class ForumsTopics extends Fragment implements ForumNetworkTask.ForumNetworkTaskListener, AbsListView.OnScrollListener, AdapterView.OnItemClickListener { - View view; - public ForumJob task; - ForumActivity activity; - public ForumMain topic; - public ForumMain subBoard; - public ForumMainAdapter topicsAdapter; - public MALApi.ListType type = MALApi.ListType.MANGA; - - @Bind(R.id.progressBar) ProgressBar progressBar; - @Bind(R.id.content) RelativeLayout content; - @Bind(R.id.network_Card) Card networkCard; - @Bind(R.id.list) ListView topics; - - public int id; - public int page = 0; - boolean loading = true; - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) { - super.onCreate(bundle); - view = inflater.inflate(R.layout.activity_forum_topics, container, false); - ButterKnife.bind(this, view); - - topicsAdapter = new ForumMainAdapter(activity, topics, getFragmentManager(), ForumJob.TOPICS); - - topics.setOnScrollListener(this); - topics.setOnItemClickListener(this); - topics.setAdapter(topicsAdapter); - topicsAdapter.setNotifyOnChange(true); - - toggle(1); - - if (bundle != null && bundle.getSerializable("task") != null) { - topic = (ForumMain) bundle.getSerializable("topic"); - subBoard = (ForumMain) bundle.getSerializable("subBoard"); - id = bundle.getInt("id"); - task = (ForumJob) bundle.getSerializable("task"); - type = (MALApi.ListType) bundle.getSerializable("type"); - page = bundle.getInt("page"); - apply(task == ForumJob.SUBBOARD ? subBoard : topic); - } - - return view; - } - - @Override - public void onSaveInstanceState(Bundle state) { - state.putSerializable("topic", topic); - state.putSerializable("subBoard", subBoard); - state.putInt("id", id); - state.putSerializable("task", task); - state.putSerializable("type", type); - state.putSerializable("page", page); - super.onSaveInstanceState(state); - } - - /** - * Change the records in this fragment. - * - * @param id The new id of the record - * @return ForumJob The task of this fragment - */ - public ForumJob setId(int id, ForumJob task) { - if (this.id != id || this.task != task) { - this.id = id; - this.task = task; - getRecords(1, task); - } - return task; - } - - /** - * Change the records in this fragment (search). - * - * @param query The topic title query - * @return ForumJob The task of this fragment - */ - public ForumJob setId(String query) { - toggle(1); - topicsAdapter.clear(); - if (MALApi.isNetworkAvailable(activity)) - new ForumNetworkTask(activity, this, activity, ForumJob.SEARCH, 0).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, query); - else - toggle(2); - return ForumJob.SEARCH; - } - - /** - * Get the requested records. - * - * @param page The page number - * @param task The task that should be performed - */ - public void getRecords(int page, ForumJob task) { - toggle(1); - this.page = page; - if (page == 1) - topicsAdapter.clear(); - if (MALApi.isNetworkAvailable(activity)) - new ForumNetworkTask(activity, this, activity, task, id).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, String.valueOf(page), type.toString()); - else - toggle(2); - } - - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - this.activity = ((ForumActivity) activity); - } - - @Override - public void onForumNetworkTaskFinished(ForumMain result, ForumJob task) { - if (result != null && result.getList() != null) { - apply(result); - } - toggle(0); - activity.setTitle(getString(R.string.title_activity_forum)); - } - - public void apply(ForumMain result) { - try { - topicsAdapter.supportAddAll(result.getList()); - toggle(0); - loading = false; - activity.setTitle(getString(R.string.title_activity_forum)); - if (task == ForumJob.SUBBOARD) - subBoard = result; - else - topic = result; - } catch (Exception e) { - Crashlytics.log(Log.ERROR, "MALX", "ForumTopics.apply(): " + e.getMessage()); - } - } - - /** - * Handle the viewFlipper. - *

- * 0 = The real content - * 1 = The progress indicator - * 2 = The network not available card - * - * @param number The number of the desired content - */ - private void toggle(int number) { - content.setVisibility(number == 0 ? View.VISIBLE : View.GONE); - progressBar.setVisibility(number == 1 ? View.VISIBLE : View.GONE); - networkCard.setVisibility(number == 2 ? View.VISIBLE : View.GONE); - } - - @Override - public void onScrollStateChanged(AbsListView view, int scrollState) { - } - - @Override - public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { - // don't do anything if there is nothing in the list - if (firstVisibleItem == 0 && visibleItemCount == 0 && totalItemCount == 0) - return; - if (totalItemCount - firstVisibleItem <= (visibleItemCount * 2) && !loading) { - loading = true; - getRecords(page + 1, task); - activity.setTitle(getString(R.string.layout_card_loading)); - } - } - - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - int itemID = ((Forum) topicsAdapter.getItem(position)).getId(); - if (task == ForumJob.SUBBOARD && !ForumChildDialogFragment.DBModificationRequest) - activity.getDiscussion(itemID); - else - activity.getPosts(itemID); - } -} \ No newline at end of file diff --git a/Atarashii/src/net/somethingdreadful/MAL/forum/PostsInterface.java b/Atarashii/src/net/somethingdreadful/MAL/forum/PostsInterface.java deleted file mode 100644 index c4e6d1bf..00000000 --- a/Atarashii/src/net/somethingdreadful/MAL/forum/PostsInterface.java +++ /dev/null @@ -1,124 +0,0 @@ -package net.somethingdreadful.MAL.forum; - -import android.content.Intent; -import android.webkit.JavascriptInterface; - -import net.somethingdreadful.MAL.R; -import net.somethingdreadful.MAL.Theme; -import net.somethingdreadful.MAL.api.MALModels.Forum; -import net.somethingdreadful.MAL.tasks.ForumJob; - -public class PostsInterface { - ForumsPosts posts; - - PostsInterface(ForumsPosts posts) { - this.posts = posts; - } - - /** - * This method will be triggered when the user clicks on an HTML post. - * - * @param id The HTML post id - * @param position The array position of the post - */ - @JavascriptInterface - public void edit(final String id, String position) { - final String comment = posts.record.getList().get(Integer.parseInt(position)).getComment(); - - posts.activity.runOnUiThread(new Runnable() { - @Override - public void run() { - if (comment.contains("embed src")) - Theme.Snackbar(posts.activity, R.string.toast_info_disabled_youtube); - else - posts.activity.getComments(Integer.parseInt(id), comment, ForumJob.UPDATECOMMENT); - } - }); - } - - /** - * This method will be triggered when the user clicks on an HTML post. - * - * @param id The HTML post id - * @param position The array position of the post - */ - @JavascriptInterface - public void quote(final String id, String position) { - Forum record = posts.record.getList().get(Integer.parseInt(position)); - final String comment = "[quote=" + record.getUsername() + "]" + record.getComment() + "[/quote]"; - posts.activity.runOnUiThread(new Runnable() { - @Override - public void run() { - if (comment.contains("embed src")) - Theme.Snackbar(posts.activity, R.string.toast_info_disabled_youtube); - else - posts.activity.getComments(posts.id, posts.activity.message + "
" + comment, ForumJob.ADDCOMMENT); - } - }); - } - - /** - * This method will be triggered when the user clicks on a profile image. - * - * @param position The array position of the post - */ - @JavascriptInterface - public void viewProfile(String position) { - String username = posts.record.getList().get(Integer.parseInt(position)).getUsername(); - Intent profile = new Intent(posts.activity, net.somethingdreadful.MAL.ProfileActivity.class); - profile.putExtra("username", username); - posts.startActivity(profile); - } - - /** - * Go the the previous page. - */ - @JavascriptInterface - public void previous() { - posts.activity.runOnUiThread(new Runnable() { - @Override - public void run() { - posts.activity.posts.getRecords(posts.activity.posts.page - 1); - } - }); - } - - /** - * Go to the next page. - */ - @JavascriptInterface - public void next() { - posts.activity.runOnUiThread(new Runnable() { - @Override - public void run() { - posts.activity.posts.getRecords(posts.activity.posts.page + 1); - } - }); - } - - /** - * Go to the first page. - */ - @JavascriptInterface - public void first() { - posts.activity.runOnUiThread(new Runnable() { - @Override - public void run() { - posts.activity.posts.getRecords(1); - } - }); - } - - /** - * Go to the last page. - */ - @JavascriptInterface - public void last() { - posts.activity.runOnUiThread(new Runnable() { - @Override - public void run() { - posts.activity.posts.getRecords(posts.activity.posts.record.getPages()); - } - }); - } -} \ No newline at end of file From ab93b2e86c4c9e889e114dc088481f332a44db29 Mon Sep 17 00:00:00 2001 From: ratan12 Date: Fri, 25 Dec 2015 14:24:13 +0100 Subject: [PATCH 02/46] Add new forum files --- Atarashii/res/raw/forum_comment.html | 105 ++++++++++++++++++ .../raw/forum_comment_spoiler_structure.html | 1 + Atarashii/res/raw/forum_comment_tiles.html | 14 +++ Atarashii/res/raw/forum_list.html | 47 ++++++++ Atarashii/res/raw/forum_list_tiles.html | 6 + Atarashii/res/raw/forum_menu.html | 46 ++++++++ Atarashii/res/raw/forum_menu_tiles.html | 6 + .../MAL/api/BaseModels/AnimeManga/Forum.java | 82 ++++++++++++++ .../MAL/forum/ForumInterface.java | 40 +++++++ 9 files changed, 347 insertions(+) create mode 100644 Atarashii/res/raw/forum_comment.html create mode 100644 Atarashii/res/raw/forum_comment_spoiler_structure.html create mode 100644 Atarashii/res/raw/forum_comment_tiles.html create mode 100644 Atarashii/res/raw/forum_list.html create mode 100644 Atarashii/res/raw/forum_list_tiles.html create mode 100644 Atarashii/res/raw/forum_menu.html create mode 100644 Atarashii/res/raw/forum_menu_tiles.html create mode 100644 Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/Forum.java create mode 100644 Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java diff --git a/Atarashii/res/raw/forum_comment.html b/Atarashii/res/raw/forum_comment.html new file mode 100644 index 00000000..2defccd3 --- /dev/null +++ b/Atarashii/res/raw/forum_comment.html @@ -0,0 +1,105 @@ + + + + + + + + + \ No newline at end of file diff --git a/Atarashii/res/raw/forum_comment_spoiler_structure.html b/Atarashii/res/raw/forum_comment_spoiler_structure.html new file mode 100644 index 00000000..b9900f20 --- /dev/null +++ b/Atarashii/res/raw/forum_comment_spoiler_structure.html @@ -0,0 +1 @@ +

\ No newline at end of file diff --git a/Atarashii/res/raw/forum_comment_tiles.html b/Atarashii/res/raw/forum_comment_tiles.html new file mode 100644 index 00000000..0411f990 --- /dev/null +++ b/Atarashii/res/raw/forum_comment_tiles.html @@ -0,0 +1,14 @@ +
+ +
+
+
+
+ + + +
+ +
+
\ No newline at end of file diff --git a/Atarashii/res/raw/forum_list.html b/Atarashii/res/raw/forum_list.html new file mode 100644 index 00000000..844c3714 --- /dev/null +++ b/Atarashii/res/raw/forum_list.html @@ -0,0 +1,47 @@ + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/Atarashii/res/raw/forum_list_tiles.html b/Atarashii/res/raw/forum_list_tiles.html new file mode 100644 index 00000000..bc02af35 --- /dev/null +++ b/Atarashii/res/raw/forum_list_tiles.html @@ -0,0 +1,6 @@ + +
+ + | +
+
\ No newline at end of file diff --git a/Atarashii/res/raw/forum_menu.html b/Atarashii/res/raw/forum_menu.html new file mode 100644 index 00000000..8e240610 --- /dev/null +++ b/Atarashii/res/raw/forum_menu.html @@ -0,0 +1,46 @@ + + + + + + + +
+ +
+ + \ No newline at end of file diff --git a/Atarashii/res/raw/forum_menu_tiles.html b/Atarashii/res/raw/forum_menu_tiles.html new file mode 100644 index 00000000..5d9e5a71 --- /dev/null +++ b/Atarashii/res/raw/forum_menu_tiles.html @@ -0,0 +1,6 @@ + +
+ + +
+
\ No newline at end of file diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/Forum.java b/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/Forum.java new file mode 100644 index 00000000..b5bd7337 --- /dev/null +++ b/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/Forum.java @@ -0,0 +1,82 @@ +package net.somethingdreadful.MAL.api.BaseModels.AnimeManga; + +import net.somethingdreadful.MAL.api.MALModels.Profile; + +import java.io.Serializable; +import java.util.ArrayList; + +import lombok.Getter; +import lombok.Setter; + +public class Forum implements Serializable { + + /** + * The ID used to get topic/board + */ + @Setter + @Getter + private int id = 0; + + /** + * The forum board/topic name. + */ + @Setter + @Getter + private String name; + + /** + * The username of the topic creator + */ + @Setter + @Getter + private String username; + + /** + * The number of replies of a topic + */ + @Setter + @Getter + private int replies = 0; + + /** + * The description of a board + */ + @Setter + @Getter + private String description; + + /** + * The info of the last reply inside a topic + */ + @Setter + @Getter + private Forum reply; + + /** + * The children of a forumboard + */ + @Setter + @Getter + private ArrayList children; + + /** + * The comment content in an post + */ + @Setter + @Getter + private String comment; + + /** + * The creation time of this post + */ + @Setter + @Getter + private String time; + + /** + * The userprofile for the user details in topics + */ + @Setter + @Getter + private Profile profile; +} diff --git a/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java b/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java new file mode 100644 index 00000000..a2898d8c --- /dev/null +++ b/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java @@ -0,0 +1,40 @@ +package net.somethingdreadful.MAL.forum; + +import android.webkit.JavascriptInterface; + +import net.somethingdreadful.MAL.ForumActivity; +import net.somethingdreadful.MAL.tasks.ForumJob; + +public class ForumInterface { + ForumActivity forum; + + public ForumInterface(ForumActivity forum) { + this.forum = forum; + } + + /** + * Get the topics from a certain category. + */ + @JavascriptInterface + public void tileClick(final String id) { + forum.runOnUiThread(new Runnable() { + @Override + public void run() { + forum.getRecords(ForumJob.CATEGORY, Integer.parseInt(id)); + } + }); + } + + /** + * Get the posts from a certain topic. + */ + @JavascriptInterface + public void topicClick(final String id) { + forum.runOnUiThread(new Runnable() { + @Override + public void run() { + forum.getRecords(ForumJob.TOPIC, Integer.parseInt(id)); + } + }); + } +} \ No newline at end of file From 90ca033647cc8a69e7d9a3428ebfd5be79aef02a Mon Sep 17 00:00:00 2001 From: ratan12 Date: Fri, 25 Dec 2015 14:26:14 +0100 Subject: [PATCH 03/46] Replace old codes by new one (Forum rewrite) --- Atarashii/res/layout/activity_forum.xml | 26 +- .../somethingdreadful/MAL/ForumActivity.java | 433 +++++++----------- .../net/somethingdreadful/MAL/MALManager.java | 26 +- .../MAL/adapters/ForumMainAdapter.java | 14 +- .../net/somethingdreadful/MAL/api/MALApi.java | 4 +- .../MAL/api/MALInterface.java | 2 +- .../MAL/api/MALModels/ForumMain.java | 24 +- .../MAL/api/MALModels/Profile.java | 17 + .../MAL/dialog/ForumChildDialogFragment.java | 34 +- .../MAL/dialog/MessageDialogFragment.java | 7 - .../somethingdreadful/MAL/forum/HtmlUtil.java | 4 +- .../somethingdreadful/MAL/tasks/ForumJob.java | 11 +- .../MAL/tasks/ForumNetworkTask.java | 34 +- 13 files changed, 245 insertions(+), 391 deletions(-) diff --git a/Atarashii/res/layout/activity_forum.xml b/Atarashii/res/layout/activity_forum.xml index d9a11fcf..5428fdac 100644 --- a/Atarashii/res/layout/activity_forum.xml +++ b/Atarashii/res/layout/activity_forum.xml @@ -3,30 +3,12 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - + android:layout_height="match_parent"/> - - - - - - \ No newline at end of file diff --git a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java index 9ee2630c..b80311a3 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java +++ b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java @@ -1,328 +1,219 @@ package net.somethingdreadful.MAL; -import android.app.FragmentManager; -import android.app.SearchManager; -import android.content.ComponentName; +import android.annotation.SuppressLint; import android.content.Context; -import android.content.Intent; -import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; -import android.support.v4.view.MenuItemCompat; import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.SearchView; -import android.view.Menu; import android.view.MenuItem; -import android.widget.ViewFlipper; +import android.webkit.WebView; -import net.somethingdreadful.MAL.api.MALApi; -import net.somethingdreadful.MAL.api.MALModels.ForumMain; -import net.somethingdreadful.MAL.dialog.ForumChildDialogFragment; -import net.somethingdreadful.MAL.dialog.MessageDialogFragment; -import net.somethingdreadful.MAL.forum.ForumsMain; -import net.somethingdreadful.MAL.forum.ForumsPosts; -import net.somethingdreadful.MAL.forum.ForumsTopics; +import com.crashlytics.android.Crashlytics; + +import net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Forum; +import net.somethingdreadful.MAL.forum.ForumInterface; import net.somethingdreadful.MAL.tasks.ForumJob; import net.somethingdreadful.MAL.tasks.ForumNetworkTask; +import java.io.InputStream; +import java.util.ArrayList; + import butterknife.Bind; import butterknife.ButterKnife; +import lombok.Getter; +import lombok.Setter; -public class ForumActivity extends AppCompatActivity implements MessageDialogFragment.onSendClickListener, ForumNetworkTask.ForumNetworkTaskListener { - Menu menu; - MenuItem search; - public ForumsMain main; - FragmentManager manager; - public ForumsPosts posts; - public String message = ""; - public ForumsTopics topics; - public boolean closeOnBack = false; - - @Bind(R.id.viewFlipper) ViewFlipper viewFlipper; - - public boolean discussion = false; - public ForumJob task = ForumJob.BOARD; +public class ForumActivity extends AppCompatActivity implements ForumNetworkTask.ForumNetworkTaskListener { + @Bind(R.id.webview) + WebView webview; + testforumhtmlunit test; + @SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"}) @Override protected void onCreate(Bundle bundle) { super.onCreate(bundle); Theme.setTheme(this, R.layout.activity_forum, false); Theme.setActionBar(this); ButterKnife.bind(this); + webview.getSettings().setJavaScriptEnabled(true); + webview.addJavascriptInterface(new ForumInterface(this), "Forum"); - handleIntent(getIntent()); - - manager = getFragmentManager(); - main = (ForumsMain) manager.findFragmentById(R.id.main); - topics = (ForumsTopics) manager.findFragmentById(R.id.topics); - posts = (ForumsPosts) manager.findFragmentById(R.id.posts); - - if (getIntent() != null) { - int id = getIntent().getIntExtra("id", 0); - if (id != 0) { - topics.type = (MALApi.ListType) getIntent().getSerializableExtra("listType"); - getDiscussion(id); - closeOnBack = true; - } - } - + test = new testforumhtmlunit(this); if (bundle != null) { - viewFlipper.setDisplayedChild(bundle.getInt("child")); - task = (ForumJob) bundle.getSerializable("task"); - discussion = bundle.getBoolean("discussion"); + test.setForumMenuLayout(bundle.getString("forumMenuLayout")); } + getRecords(ForumJob.MENU, 0); } @Override public void onSaveInstanceState(Bundle state) { - state.putInt("child", viewFlipper.getDisplayedChild()); - state.putSerializable("task", task); - state.putBoolean("discussion", discussion); + state.putString("forumMenuLayout", test.getForumMenuLayout()); super.onSaveInstanceState(state); } - /** - * Switch the view to the topics fragment. - * - * @param id The board id - */ - public void getTopics(int id) { - viewFlipper.setDisplayedChild(1); - setTask(topics.setId(id, ForumJob.TOPICS)); - } - - /** - * Switch the view to the topics fragment. - * - * @param query The query - */ - public void getTopics(String query) { - viewFlipper.setDisplayedChild(1); - setTask(topics.setId(query)); - } - - /** - * Switch the view to the topics fragment to show subBoards. - * - * @param id The subBoard id - */ - public void getSubBoard(int id) { - viewFlipper.setDisplayedChild(1); - topics.type = ((id == 1 || id == 2) ? MALApi.ListType.ANIME : MALApi.ListType.MANGA); - setTask(topics.setId(id, ForumJob.SUBBOARD)); - } - - /** - * Switch the view to the topics posts. - * - * @param id The id of the topic - */ - public void getPosts(int id) { - viewFlipper.setDisplayedChild(2); - setTask(posts.setId(id)); - } - - /** - * Create the edithor dialog. - * - * @param id The comment id - * @param message The comment text - * @param task The task to peform - */ - public void getComments(int id, String message, ForumJob task) { - MessageDialogFragment info = new MessageDialogFragment().setListeners(this); - Bundle args = new Bundle(); - args.putInt("id", id); - args.putString("message", message); - args.putSerializable("task", task); - info.setArguments(args); - info.show(getFragmentManager(), "fragment_forum"); - } - - /** - * Switch the view to the discussion view. - * - * @param id The comment id - */ - public void getDiscussion(int id) { - viewFlipper.setDisplayedChild(1); - setTask(topics.setId(id, ForumJob.DISCUSSION)); - discussion = true; - } - - /** - * Handle the back and home buttons. - */ - public void back() { - switch (task) { - case BOARD: - finish(); - break; - case SUBBOARD: - setTask(ForumJob.BOARD); - viewFlipper.setDisplayedChild(0); - break; - case DISCUSSION: - if (closeOnBack) - finish(); - setTask(ForumJob.SUBBOARD); - topics.task = ForumJob.SUBBOARD; - topics.topicsAdapter.clear(); - topics.apply(topics.subBoard); - discussion = false; + public void getRecords(ForumJob job, int id) { + switch (job) { + case MENU: + if (!test.menuExists()) + new ForumNetworkTask(this, this, job, id).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + else + test.setForumMenu(null); break; - case TOPICS: - case SEARCH: - setTask(ForumJob.BOARD); - viewFlipper.setDisplayedChild(0); + case CATEGORY: + new ForumNetworkTask(this, this, job, id).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, String.valueOf(1)); break; - case POSTS: - if (discussion) { - setTask(ForumJob.DISCUSSION); - } else - setTask(ForumJob.TOPICS); - viewFlipper.setDisplayedChild(1); + case TOPIC: + new ForumNetworkTask(this, this, job, id).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, String.valueOf(1)); break; } - message = ""; - } - - /** - * Refresh the displayed view. - */ - public void refresh() { - if (task == ForumJob.TOPICS) - topics.getRecords(topics.page, topics.task); - else - posts.getRecords(posts.page); - } - - /** - * Change the task & change the menu items. - * - * @param task The new ForumTask - */ - public void setTask(ForumJob task) { - this.task = task; - if (menu != null) { - menu.findItem(R.id.action_add).setVisible((task == ForumJob.POSTS || task == ForumJob.TOPICS) && getTopicStatus() && viewFlipper.getDisplayedChild() != 3); - menu.findItem(R.id.action_send).setVisible(viewFlipper.getDisplayedChild() == 3); - menu.findItem(R.id.action_ViewMALPage).setVisible(viewFlipper.getDisplayedChild() != 3); - search.setVisible(task == ForumJob.BOARD); - } - } - - /** - * Checks if the ID allows to add a topics - * - * @return boolean If true then the ID allows to add comments - */ - public boolean getTopicStatus() { - return task != ForumJob.TOPICS || (topics.id != 5 && topics.id != 14 && topics.id != 15 && topics.id != 17); - } - - @Override - public void onBackPressed() { - back(); } @Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.activity_forum, menu); - this.menu = menu; - - SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); - MenuItem searchItem = menu.findItem(R.id.action_search); - SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); - ComponentName cn = new ComponentName(this, ForumActivity.class); - searchView.setSearchableInfo(searchManager.getSearchableInfo(cn)); - search = searchItem; - - setTask(task); + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case android.R.id.home: + finish(); + } return true; } @Override - protected void onNewIntent(Intent intent) { - handleIntent(intent); - } - - /** - * Handle the intent for the searchView - * - * @param intent The intent given by android - */ - private void handleIntent(Intent intent) { - if (Intent.ACTION_SEARCH.equals(intent.getAction())) { - String query = intent.getStringExtra(SearchManager.QUERY); - getTopics(query); - topics.task = ForumJob.SEARCH; - search.collapseActionView(); - } + public void onBackPressed() { + if (webview.canGoBack()) + webview.goBack(); + else + finish(); } @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case android.R.id.home: - back(); + public void onForumNetworkTaskFinished(ArrayList forum, ForumJob job) { + switch (job) { + case MENU: + test.setForumMenu(forum); break; - case R.id.action_ViewMALPage: - startActivity(new Intent(Intent.ACTION_VIEW, getUri())); + case CATEGORY: + test.setForumList(forum); break; - case R.id.action_add: - if (task == ForumJob.POSTS) - getComments(posts.id, message, ForumJob.ADDCOMMENT); - else if (task == ForumJob.TOPICS) - getComments(topics.id, null, ForumJob.ADDTOPIC); + case TOPIC: + test.setForumComments(forum); break; } - return super.onOptionsItemSelected(item); } - /** - * Get the Uri depending on the ForumTask. - * - * @return Uri The uri of the desired URL to launch - */ - public Uri getUri() { - switch (task) { - case BOARD: - return Uri.parse("http://myanimelist.net/forum/"); - case SUBBOARD: - return Uri.parse("http://myanimelist.net/forum/?subboard=" + topics.id); - case DISCUSSION: - if (ForumChildDialogFragment.DBModificationRequest) - return Uri.parse("http://myanimelist.net/forum/?topicid=" + topics.id); - else - return Uri.parse("http://myanimelist.net/forum/?" + (topics.type == MALApi.ListType.ANIME ? "anime" : "manga") + "id=" + topics.id); - case TOPICS: - return Uri.parse("http://myanimelist.net/forum/?board=" + topics.id); - case POSTS: - return Uri.parse("http://myanimelist.net/forum/?topicid=" + posts.id); + public class testforumhtmlunit { + Context context; + @Getter + @Setter + String forumMenuLayout; + String forumMenuTiles; + String forumListLayout; + String forumListTiles; + String forumCommentsLayout; + String forumCommentsTiles; + String spoilerStructure; + + public testforumhtmlunit(Context context) { + forumMenuLayout = getString(context, R.raw.forum_menu); + forumMenuTiles = getString(context, R.raw.forum_menu_tiles); + forumListLayout = getString(context, R.raw.forum_list); + forumListTiles = getString(context, R.raw.forum_list_tiles); + forumCommentsLayout = getString(context, R.raw.forum_comment); + forumCommentsTiles = getString(context, R.raw.forum_comment_tiles); + spoilerStructure = getString(context, R.raw.forum_comment_spoiler_structure); + this.context = context; } - return null; - } - @Override - public void onSendClicked(String message, String subject, ForumJob task, int id) { - if (task == ForumJob.ADDTOPIC && !message.equals("") && !subject.equals("")) - new ForumNetworkTask(this, this, this, task, id).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, subject, message); - else if (!message.equals("")) - new ForumNetworkTask(this, this, this, task, id).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, message); - } + public boolean menuExists() { + return !forumMenuLayout.contains(""); + } - @Override - public void onForumNetworkTaskFinished(ForumMain result, ForumJob task) { - if (task == ForumJob.ADDCOMMENT) - Theme.Snackbar(this, R.string.toast_info_comment_add); - if (task == ForumJob.ADDTOPIC || task == ForumJob.ADDCOMMENT || task == ForumJob.UPDATECOMMENT) - Theme.Snackbar(this, R.string.toast_info_comment_added); - refresh(); - } + public void setForumMenu(ArrayList menu) { + if (menu != null && menu.size() > 0) { + String forumArray = ""; + String tempTile; + for (Forum item : menu) { + tempTile = forumMenuTiles; + tempTile = tempTile.replace("", String.valueOf(item.getId())); + tempTile = tempTile.replace("", item.getName()); + tempTile = tempTile.replace("", item.getDescription()); + tempTile = tempTile.replace("", getString(context, R.string.dialog_message_last_post)); + forumArray = forumArray + tempTile; + } + forumMenuLayout = forumMenuLayout.replace("", forumArray); + } + if (menuExists()) + webview.loadData(forumMenuLayout, "text/html", "UTF-8"); + } - @Override - public void onCloseClicked(String message) { - this.message = message; + public void setForumList(ArrayList forumList) { + if (forumList != null && forumList.size() > 0) { + String tempForumList; + String forumArray = ""; + String tempTile; + for (Forum item : forumList) { + tempTile = forumListTiles; + tempTile = tempTile.replace("", String.valueOf(item.getId())); + tempTile = tempTile.replace("", item.getName()); + tempTile = tempTile.replace("", item.getReply().getUsername()); + tempTile = tempTile.replace("", DateTools.parseDate(item.getReply().getTime(), true)); + forumArray = forumArray + tempTile; + } + tempForumList = forumListLayout.replace("", forumArray); + webview.loadData(tempForumList, "text/html", "UTF-8"); + } + } + + public void setForumComments(ArrayList forumList) { + if (forumList != null && forumList.size() > 0) { + String tempForumList; + String rank; + String comment; + String forumArray = ""; + String tempTile; + for (Forum item : forumList) { + comment = item.getComment(); + rank = item.getProfile().getSpecialAccesRank(item.getUsername()); + // Spoiler rebuild + comment = comment.replaceAll("
((.|\\n)+?)
((.|\\n)+?)((.|\\n)+?)
", spoilerStructure + "$3
"); + + tempTile = forumCommentsTiles; + tempTile = tempTile.replace("", item.getUsername()); + tempTile = tempTile.replace("", DateTools.parseDate(item.getTime(), true)); + tempTile = tempTile.replace("", comment); + if (item.getProfile().getAvatarUrl().contains("xmlhttp-loader")) + tempTile = tempTile.replace("", "http://cdn.myanimelist.net/images/na.gif"); + else + tempTile = tempTile.replace("", item.getProfile().getAvatarUrl()); + if (!rank.equals("")) + tempTile = tempTile.replace("", rank); + else + tempTile = tempTile.replace("", ""); + + forumArray = forumArray + tempTile; + } + tempForumList = forumCommentsLayout.replace("", forumArray); + webview.loadData(tempForumList, "text/html", "UTF-8"); + } + } + + /** + * Get the string of the given resource file. + * + * @param context The application context + * @param resource The resource of which string we need + * @return String the wanted string + */ + @SuppressWarnings("StatementWithEmptyBody") + private String getString(Context context, int resource) { + try { + InputStream inputStream = context.getResources().openRawResource(resource); + byte[] buffer = new byte[inputStream.available()]; + while (inputStream.read(buffer) != -1) ; + return new String(buffer); + } catch (Exception e) { + Crashlytics.logException(e); + } + return ""; + } } } diff --git a/Atarashii/src/net/somethingdreadful/MAL/MALManager.java b/Atarashii/src/net/somethingdreadful/MAL/MALManager.java index f3843690..4c25a055 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/MALManager.java +++ b/Atarashii/src/net/somethingdreadful/MAL/MALManager.java @@ -9,6 +9,7 @@ import net.somethingdreadful.MAL.api.ALApi; import net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Anime; import net.somethingdreadful.MAL.api.BaseModels.AnimeManga.BrowseList; +import net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Forum; import net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Manga; import net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Reviews; import net.somethingdreadful.MAL.api.BaseModels.AnimeManga.UserList; @@ -267,22 +268,10 @@ public Manga getMangaRecord(int id) { return AccountService.isMAL() ? malApi.getManga(id) : alApi.getManga(id); } - public ForumMain getForum() { - return malApi.getForum(); - } - - public ForumMain getTopics(int id, int page) { - return malApi.getTopics(id, page); - } - public ForumMain getDiscussion(int id, int page, MALApi.ListType type) { return type.equals(MALApi.ListType.ANIME) ? malApi.getAnime(id, page) : malApi.getManga(id, page); } - public ForumMain getPosts(int id, int page) { - return malApi.getPosts(id, page); - } - public ForumMain getSubBoards(int id, int page) { return malApi.getSubBoards(id, page); } @@ -376,6 +365,19 @@ public ArrayList getMangaReviews(int id, int page) { return AccountService.isMAL() ? malApi.getMangaReviews(id, page) : alApi.getMangaReviews(id, page); } + public ArrayList getForumCategories() { + return malApi.getForum().createBaseModel(); + } + + + public ArrayList getCategoryTopics(int id, int page) { + return malApi.getCategoryTopics(id, page).createBaseModel(); + } + + public ArrayList getTopic(int id, int page) { + return malApi.getPosts(id, page).createBaseModel(); + } + public boolean deleteAnime(Anime anime) { return dbMan.deleteAnime(anime.getId()); } diff --git a/Atarashii/src/net/somethingdreadful/MAL/adapters/ForumMainAdapter.java b/Atarashii/src/net/somethingdreadful/MAL/adapters/ForumMainAdapter.java index 46110a3b..3d55954d 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/adapters/ForumMainAdapter.java +++ b/Atarashii/src/net/somethingdreadful/MAL/adapters/ForumMainAdapter.java @@ -15,10 +15,9 @@ import com.crashlytics.android.Crashlytics; -import net.somethingdreadful.MAL.DateTools; import net.somethingdreadful.MAL.R; import net.somethingdreadful.MAL.Theme; -import net.somethingdreadful.MAL.api.MALModels.Forum; +import net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Forum; import net.somethingdreadful.MAL.dialog.InformationDialogFragment; import net.somethingdreadful.MAL.tasks.ForumJob; @@ -71,15 +70,6 @@ public void onClick(View v) { InformationDialogFragment info = new InformationDialogFragment(); Bundle args = new Bundle(); args.putString("title", record.getName()); - if (task == ForumJob.BOARD) - args.putString("message", record.getDescription()); - else - args.putString("message", context.getString(R.string.dialog_message_created_by) - + " " + record.getUsername() - + "\n" - + context.getString(R.string.dialog_message_last_post) - + " " + record.getReply().getUsername() - + ", " + DateTools.parseDate(record.getReply().getTime(), true)); info.setArguments(args); info.show(fm, "fragment_forum"); @@ -96,8 +86,6 @@ public void onClick(View v) { } public void supportAddAll(Collection collection) { - if (task == ForumJob.BOARD) - listview.getLayoutParams().height = (int) (((48 + 1) * collection.size() - 1) * (context.getResources().getDisplayMetrics().densityDpi / 160f)); for (T record : collection) { this.add(record); } diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/MALApi.java b/Atarashii/src/net/somethingdreadful/MAL/api/MALApi.java index 54e9ca93..e4bbda1b 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/MALApi.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/MALApi.java @@ -288,8 +288,8 @@ public ForumMain getForum() { return service.getForum(); } - public ForumMain getTopics(int id, int page) { - return service.getTopics(id, page); + public ForumMain getCategoryTopics(int id, int page) { + return service.getCategoryTopics(id, page); } public ForumMain getAnime(int id, int page) { diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/MALInterface.java b/Atarashii/src/net/somethingdreadful/MAL/api/MALInterface.java index 692246d2..516aa859 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/MALInterface.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/MALInterface.java @@ -102,7 +102,7 @@ Response addManga(@Field("manga_id") int id, @Field("status") String status, @Fi ForumMain getForum(); @GET("/forum/{id}") - ForumMain getTopics(@Path("id") int id, @Query("page") int page); + ForumMain getCategoryTopics(@Path("id") int id, @Query("page") int page); @GET("/forum/anime/{id}") ForumMain getAnime(@Path("id") int id, @Query("page") int page); diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/ForumMain.java b/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/ForumMain.java index f4e1c470..21a8f5ca 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/ForumMain.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/ForumMain.java @@ -2,6 +2,8 @@ import com.google.gson.annotations.SerializedName; +import net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Forum; + import java.io.Serializable; import java.util.ArrayList; @@ -35,10 +37,28 @@ public class ForumMain implements Serializable { /** * A general list for multi use. */ - @Setter @Getter private ArrayList list; + @Setter + @Getter + private ArrayList list; /** * Amount of pages. */ - @Setter @Getter private int pages; + @Setter + @Getter + private int pages; + + + public ArrayList createBaseModel() { + ArrayList model = new ArrayList<>(); + if (getMyAnimeList() != null) + model.addAll(getMyAnimeList()); + if (getGeneral() != null) + model.addAll(getGeneral()); + if (getAnimeManga() != null) + model.addAll(getAnimeManga()); + if (getList() != null) + model.addAll(getList()); + return model; + } } diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/Profile.java b/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/Profile.java index 64f834ac..e3753966 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/Profile.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/Profile.java @@ -42,6 +42,23 @@ public class Profile implements Serializable { @SerializedName("manga_stats") private MangaStats mangaStats; + public String getSpecialAccesRank(String username) { + String rank = getDetails().getAccessRank(); + if (rank.contains("IRC")) + return "IRC"; + else if (rank.contains("News")) + return "News Team"; + else if (rank.contains("Social")) + return "SMT"; + else if (rank.contains("Mod")) + return "Mod"; + else if (rank.contains("Admin")) + return "Admin"; + else if (net.somethingdreadful.MAL.api.BaseModels.Profile.isDeveloper(username)) + return "Atarashii dev"; + return ""; + } + public static class Details implements Serializable { /** * The date of when the user was last online. diff --git a/Atarashii/src/net/somethingdreadful/MAL/dialog/ForumChildDialogFragment.java b/Atarashii/src/net/somethingdreadful/MAL/dialog/ForumChildDialogFragment.java index d4825aae..73014b05 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/dialog/ForumChildDialogFragment.java +++ b/Atarashii/src/net/somethingdreadful/MAL/dialog/ForumChildDialogFragment.java @@ -2,11 +2,9 @@ import android.app.AlertDialog; import android.app.DialogFragment; -import android.content.DialogInterface; import android.os.Bundle; -import net.somethingdreadful.MAL.ForumActivity; -import net.somethingdreadful.MAL.api.MALModels.Forum; +import net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Forum; import java.util.ArrayList; @@ -29,36 +27,6 @@ public AlertDialog onCreateDialog(Bundle savedInstanceState) { message = message.replace("$child2;", child.get(2).getName()); } - builder.setTitle(getArguments().getString("title")); - builder.setMessage(message); - - builder.setPositiveButton(child.get(0).getName(), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - DBModificationRequest = !(child.get(0).getId() == 1 || child.get(0).getId() == 4); - ((ForumActivity) getActivity()).getSubBoard(child.get(0).getId()); - dismiss(); - } - }); - builder.setNeutralButton(child.get(1).getName(), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - DBModificationRequest = !(child.get(1).getId() == 1 || child.get(1).getId() == 4); - ((ForumActivity) getActivity()).getSubBoard(child.get(1).getId()); - dismiss(); - } - }); - if (child.size() == 3) { - builder.setNegativeButton(child.get(2).getName(), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - DBModificationRequest = !(child.get(2).getId() == 1 || child.get(2).getId() == 4); - ((ForumActivity) getActivity()).getSubBoard(child.get(2).getId()); - dismiss(); - } - }); - } - return builder.create(); } } \ No newline at end of file diff --git a/Atarashii/src/net/somethingdreadful/MAL/dialog/MessageDialogFragment.java b/Atarashii/src/net/somethingdreadful/MAL/dialog/MessageDialogFragment.java index 54ee6d27..a8d31262 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/dialog/MessageDialogFragment.java +++ b/Atarashii/src/net/somethingdreadful/MAL/dialog/MessageDialogFragment.java @@ -39,7 +39,6 @@ public Dialog onCreateDialog(Bundle savedInstanceState) { String title = getArguments().getString("title", null); id = getArguments().getInt("id"); - subject.setVisibility(task == ForumJob.ADDTOPIC ? View.VISIBLE : View.GONE); setHeader(title); setClickListener(); @@ -70,12 +69,6 @@ private void setHeader(String title) { header.setText(title); else switch (task) { - case UPDATECOMMENT: - header.setText(getString(R.string.dialog_title_edit_comment)); - break; - case ADDTOPIC: - header.setText(getString(R.string.dialog_title_add_topic)); - break; default: header.setText(getString(R.string.dialog_title_add_comment)); break; diff --git a/Atarashii/src/net/somethingdreadful/MAL/forum/HtmlUtil.java b/Atarashii/src/net/somethingdreadful/MAL/forum/HtmlUtil.java index b1f8e724..2b455cb0 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/forum/HtmlUtil.java +++ b/Atarashii/src/net/somethingdreadful/MAL/forum/HtmlUtil.java @@ -6,10 +6,10 @@ import net.somethingdreadful.MAL.R; import net.somethingdreadful.MAL.Theme; import net.somethingdreadful.MAL.account.AccountService; +import net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Forum; import net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Reviews; import net.somethingdreadful.MAL.api.BaseModels.History; import net.somethingdreadful.MAL.api.BaseModels.Profile; -import net.somethingdreadful.MAL.api.MALModels.Forum; import net.somethingdreadful.MAL.api.MALModels.ForumMain; import java.io.IOException; @@ -26,7 +26,7 @@ public class HtmlUtil { public HtmlUtil(Context context) { structure = getString(context, R.raw.forum_post_structure); postStructure = getString(context, R.raw.forum_post_post_structure); - spoilerStructure = getString(context, R.raw.forum_post_spoiler_structure); + spoilerStructure = getString(context, R.raw.forum_comment_spoiler_structure); this.context = context; } diff --git a/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumJob.java b/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumJob.java index 31f71e7f..6b299bcf 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumJob.java +++ b/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumJob.java @@ -1,14 +1,5 @@ package net.somethingdreadful.MAL.tasks; public enum ForumJob { - BOARD, - SUBBOARD, - TOPICS, - DISCUSSION, - POSTS, - ADDCOMMENT, - ADDTOPIC, - COMMENT, - SEARCH, - UPDATECOMMENT + MENU, CATEGORY, TOPIC } \ No newline at end of file diff --git a/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumNetworkTask.java b/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumNetworkTask.java index 59e28109..2d98b8ef 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumNetworkTask.java +++ b/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumNetworkTask.java @@ -1,7 +1,6 @@ package net.somethingdreadful.MAL.tasks; import android.app.Activity; -import android.content.Context; import android.os.AsyncTask; import android.util.Log; @@ -10,23 +9,19 @@ import net.somethingdreadful.MAL.MALManager; import net.somethingdreadful.MAL.R; import net.somethingdreadful.MAL.Theme; -import net.somethingdreadful.MAL.api.MALApi; -import net.somethingdreadful.MAL.api.MALModels.Forum; -import net.somethingdreadful.MAL.api.MALModels.ForumMain; +import net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Forum; import java.util.ArrayList; import retrofit.RetrofitError; -public class ForumNetworkTask extends AsyncTask { - Context context; +public class ForumNetworkTask extends AsyncTask> { ForumNetworkTaskListener callback; ForumJob type; int id; Activity activity; - public ForumNetworkTask(Context context, ForumNetworkTaskListener callback, Activity activity, ForumJob type, int id) { - this.context = context; + public ForumNetworkTask(ForumNetworkTaskListener callback, Activity activity, ForumJob type, int id) { this.callback = callback; this.type = type; this.id = id; @@ -34,15 +29,22 @@ public ForumNetworkTask(Context context, ForumNetworkTaskListener callback, Acti } @Override - protected ForumMain doInBackground(String... params) { - ForumMain result = new ForumMain(); - MALManager mManager = new MALManager(context); + protected ArrayList doInBackground(String... params) { + ArrayList result = new ArrayList<>(); + MALManager mManager = new MALManager(activity); try { switch (type) { - case BOARD: - result = mManager.getForum(); + case MENU: // list with all categories + result = mManager.getForumCategories(); break; + case CATEGORY: // list with all topics of a certain category + result = mManager.getCategoryTopics(id, Integer.parseInt(params[0])); + break; + case TOPIC: // list with all comments of users + result = mManager.getTopic(id, Integer.parseInt(params[0])); + break; + /* case SUBBOARD: result = mManager.getSubBoards(id, Integer.parseInt(params[0])); break; @@ -69,7 +71,7 @@ protected ForumMain doInBackground(String... params) { break; case SEARCH: result = mManager.search(params[0]); - break; + break;*/ } } catch (RetrofitError re) { if (re.getResponse() != null && activity != null) { @@ -110,12 +112,12 @@ protected ForumMain doInBackground(String... params) { } @Override - protected void onPostExecute(ForumMain result) { + protected void onPostExecute(ArrayList result) { if (callback != null) callback.onForumNetworkTaskFinished(result, type); } public interface ForumNetworkTaskListener { - void onForumNetworkTaskFinished(ForumMain result, ForumJob task); + void onForumNetworkTaskFinished(ArrayList result, ForumJob task); } } From 2d93d1cf8c28fd78641d262c3dedd7c49aa62661 Mon Sep 17 00:00:00 2001 From: ratan12 Date: Mon, 28 Dec 2015 16:15:56 +0100 Subject: [PATCH 04/46] Add progressbar for forums --- Atarashii/res/layout/activity_forum.xml | 7 +++++++ .../src/net/somethingdreadful/MAL/ForumActivity.java | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/Atarashii/res/layout/activity_forum.xml b/Atarashii/res/layout/activity_forum.xml index 5428fdac..03b0e2ad 100644 --- a/Atarashii/res/layout/activity_forum.xml +++ b/Atarashii/res/layout/activity_forum.xml @@ -9,6 +9,13 @@ android:layout_width="match_parent" android:layout_height="match_parent"/> + \ No newline at end of file diff --git a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java index b80311a3..30d2a9b6 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java +++ b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java @@ -6,7 +6,9 @@ import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.MenuItem; +import android.view.View; import android.webkit.WebView; +import android.widget.ProgressBar; import com.crashlytics.android.Crashlytics; @@ -26,6 +28,8 @@ public class ForumActivity extends AppCompatActivity implements ForumNetworkTask.ForumNetworkTaskListener { @Bind(R.id.webview) WebView webview; + @Bind(R.id.progress1) + ProgressBar progress; testforumhtmlunit test; @SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"}) @@ -45,6 +49,10 @@ protected void onCreate(Bundle bundle) { getRecords(ForumJob.MENU, 0); } + public void setLoading(boolean loading) { + progress.setVisibility(loading ? View.VISIBLE : View.GONE); + } + @Override public void onSaveInstanceState(Bundle state) { state.putString("forumMenuLayout", test.getForumMenuLayout()); @@ -52,6 +60,7 @@ public void onSaveInstanceState(Bundle state) { } public void getRecords(ForumJob job, int id) { + setLoading(true); switch (job) { case MENU: if (!test.menuExists()) @@ -98,6 +107,7 @@ public void onForumNetworkTaskFinished(ArrayList forum, ForumJob job) { test.setForumComments(forum); break; } + setLoading(false); } public class testforumhtmlunit { From e0de7f3047265651c49f1a8dbcb28857971da352 Mon Sep 17 00:00:00 2001 From: ratan12 Date: Mon, 28 Dec 2015 16:16:31 +0100 Subject: [PATCH 05/46] Enable subforums --- .../src/net/somethingdreadful/MAL/ForumActivity.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java index 30d2a9b6..804d632b 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java +++ b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java @@ -143,10 +143,20 @@ public void setForumMenu(ArrayList menu) { String tempTile; for (Forum item : menu) { tempTile = forumMenuTiles; - tempTile = tempTile.replace("", String.valueOf(item.getId())); tempTile = tempTile.replace("", item.getName()); tempTile = tempTile.replace("", item.getDescription()); tempTile = tempTile.replace("", getString(context, R.string.dialog_message_last_post)); + + if (item.getChildren() != null) { + tempTile = tempTile.replace("onClick=\"tileClick()\"", ""); + + for (int i = 0; i < item.getChildren().size(); i++) { + Forum child = item.getChildren().get(0); + tempTile = tempTile.replace(child.getName(), "" + child.getName() + ""); + } + } else { + tempTile = tempTile.replace("", String.valueOf(item.getId())); + } forumArray = forumArray + tempTile; } forumMenuLayout = forumMenuLayout.replace("", forumArray); From b8d1238e73ca8482810603f57da3fa14e26cae7d Mon Sep 17 00:00:00 2001 From: ratan12 Date: Mon, 28 Dec 2015 16:16:57 +0100 Subject: [PATCH 06/46] Save webstate to save data (Forums) --- Atarashii/res/raw/forum_list.html | 2 +- .../src/net/somethingdreadful/MAL/ForumActivity.java | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Atarashii/res/raw/forum_list.html b/Atarashii/res/raw/forum_list.html index 844c3714..c90bfde7 100644 --- a/Atarashii/res/raw/forum_list.html +++ b/Atarashii/res/raw/forum_list.html @@ -40,7 +40,7 @@ -
+
diff --git a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java index 804d632b..4a602a94 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java +++ b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java @@ -45,8 +45,10 @@ protected void onCreate(Bundle bundle) { test = new testforumhtmlunit(this); if (bundle != null) { test.setForumMenuLayout(bundle.getString("forumMenuLayout")); + webview.restoreState(bundle.getBundle("webview")); + } else { + getRecords(ForumJob.MENU, 0); } - getRecords(ForumJob.MENU, 0); } public void setLoading(boolean loading) { @@ -56,6 +58,9 @@ public void setLoading(boolean loading) { @Override public void onSaveInstanceState(Bundle state) { state.putString("forumMenuLayout", test.getForumMenuLayout()); + Bundle webviewState = new Bundle(); + webview.saveState(webviewState); + state.putBundle("webview", webviewState); super.onSaveInstanceState(state); } @@ -191,9 +196,8 @@ public void setForumComments(ArrayList forumList) { String forumArray = ""; String tempTile; for (Forum item : forumList) { - comment = item.getComment(); rank = item.getProfile().getSpecialAccesRank(item.getUsername()); - // Spoiler rebuild + comment = item.getComment(); comment = comment.replaceAll("
((.|\\n)+?)
((.|\\n)+?)((.|\\n)+?)
", spoilerStructure + "$3
"); tempTile = forumCommentsTiles; @@ -208,7 +212,6 @@ public void setForumComments(ArrayList forumList) { tempTile = tempTile.replace("", rank); else tempTile = tempTile.replace("", ""); - forumArray = forumArray + tempTile; } tempForumList = forumCommentsLayout.replace("", forumArray); From abce04937367ce1dae69d50955f22b5c54291e48 Mon Sep 17 00:00:00 2001 From: ratan12 Date: Tue, 29 Dec 2015 14:15:39 +0100 Subject: [PATCH 07/46] Fix subboard support because wrong request method was chosen --- Atarashii/res/raw/forum_menu.html | 1 + .../net/somethingdreadful/MAL/ForumActivity.java | 6 ++++-- .../src/net/somethingdreadful/MAL/MALManager.java | 7 +++---- .../somethingdreadful/MAL/forum/ForumInterface.java | 13 +++++++++++++ .../net/somethingdreadful/MAL/tasks/ForumJob.java | 2 +- .../MAL/tasks/ForumNetworkTask.java | 5 +++-- 6 files changed, 25 insertions(+), 9 deletions(-) diff --git a/Atarashii/res/raw/forum_menu.html b/Atarashii/res/raw/forum_menu.html index 8e240610..7379f2cf 100644 --- a/Atarashii/res/raw/forum_menu.html +++ b/Atarashii/res/raw/forum_menu.html @@ -3,6 +3,7 @@ + + + + \ No newline at end of file diff --git a/Atarashii/res/values/strings.xml b/Atarashii/res/values/strings.xml index 94a7b113..a877467a 100644 --- a/Atarashii/res/values/strings.xml +++ b/Atarashii/res/values/strings.xml @@ -150,6 +150,9 @@ Add a comment or topic Topic title Message + Page number + Next + Previous Welcome to Atarashii!\nPlease choose your preferred site. diff --git a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java index 2777949d..d8b275b4 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java +++ b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java @@ -21,6 +21,7 @@ import com.crashlytics.android.Crashlytics; import net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Forum; +import net.somethingdreadful.MAL.dialog.NumberPickerDialogFragment; import net.somethingdreadful.MAL.forum.ForumInterface; import net.somethingdreadful.MAL.tasks.ForumJob; import net.somethingdreadful.MAL.tasks.ForumNetworkTask; @@ -33,7 +34,7 @@ import lombok.Getter; import lombok.Setter; -public class ForumActivity extends AppCompatActivity implements ForumNetworkTask.ForumNetworkTaskListener { +public class ForumActivity extends AppCompatActivity implements ForumNetworkTask.ForumNetworkTaskListener, NumberPickerDialogFragment.onUpdateClickListener { @Bind(R.id.webview) public WebView webview; @@ -190,6 +191,11 @@ public void onForumNetworkTaskFinished(ArrayList forum, ForumJob job) { } } + @Override + public void onUpdated(int number, int id) { + getRecords(ForumJob.TOPIC, Integer.parseInt(String.valueOf(id)), String.valueOf(number)); + } + public class testforumhtmlunit { Context context; @Getter @@ -303,10 +309,13 @@ public void setForumComments(ArrayList forumList) { String comment; String forumArray = ""; String tempTile; + int maxPages = forumList.get(0).getMaxPages(); for (Forum item : forumList) { rank = item.getProfile().getSpecialAccesRank(item.getUsername()); comment = item.getComment(); comment = comment.replaceAll("
((.|\\n)+?)
((.|\\n)+?)((.|\\n)+?)
", spoilerStructure + "$3
"); + comment = comment.replaceAll("
((.|\\n)+?)class=\"quotetext\">((.|\\n)+?)
", spoilerStructure + "$3"); + comment = comment.replaceAll("@(\\w+)", "@$1"); tempTile = forumCommentsTiles; tempTile = tempTile.replace("", item.getUsername()); @@ -323,10 +332,18 @@ public void setForumComments(ArrayList forumList) { forumArray = forumArray + tempTile; } tempForumList = forumCommentsLayout.replace("", forumArray); - tempForumList = tempForumList.replace("", "C " + getId()); // C = Comments, id - if (Integer.parseInt(getPage()) != 1) { - tempForumList = tempForumList.replace("Forum.commentList(" + getPage(), "Forum.commentList(" + (Integer.parseInt(getPage()) + 1)); // T = Topics || S = subboard, id + tempForumList = tempForumList.replace("", "C " + getId() + " " + maxPages); // C = Comments, id, maxPages + if (Integer.parseInt(getPage()) == 1) { + tempForumList = tempForumList.replace("class=\"previous\"", "class=\"previous\" style=\"visibility: hidden;\""); + } else if (Integer.parseInt(getPage()) == maxPages) { + tempForumList = tempForumList.replace("class=\"next\"", "class=\"next\" style=\"visibility: hidden;\""); + } else { + tempForumList = tempForumList.replace("Forum.prevCommentList(" + getPage(), "Forum.prevCommentList(" + (Integer.parseInt(getPage()) - 1)); + tempForumList = tempForumList.replace("Forum.nextCommentList(" + getPage(), "Forum.nextCommentList(" + (Integer.parseInt(getPage()) + 1)); } + tempForumList = tempForumList.replace("", getPage()); + tempForumList = tempForumList.replace("", context.getString(R.string.next)); + tempForumList = tempForumList.replace("", context.getString(R.string.previous)); loadWebview(tempForumList); } } diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/Forum.java b/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/Forum.java index b5bd7337..a75eac85 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/Forum.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/Forum.java @@ -73,6 +73,15 @@ public class Forum implements Serializable { @Getter private String time; + /** + * The max amount of pages + * + * Note: Only the first item will contain this + */ + @Setter + @Getter + private int maxPages; + /** * The userprofile for the user details in topics */ diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/ForumMain.java b/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/ForumMain.java index e04cb861..849e3ff0 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/ForumMain.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/ForumMain.java @@ -57,8 +57,10 @@ public ArrayList createBaseModel() { model.addAll(getAnimeManga()); if (getGeneral() != null) model.addAll(getGeneral()); - if (getList() != null) + if (getList() != null) { model.addAll(getList()); + model.get(0).setMaxPages(getPages()); + } return model; } } diff --git a/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java b/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java index 1ad925a7..52ba60d0 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java +++ b/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java @@ -1,10 +1,14 @@ package net.somethingdreadful.MAL.forum; +import android.app.FragmentManager; import android.content.Intent; +import android.os.Bundle; import android.webkit.JavascriptInterface; import net.somethingdreadful.MAL.ForumActivity; import net.somethingdreadful.MAL.ProfileActivity; +import net.somethingdreadful.MAL.R; +import net.somethingdreadful.MAL.dialog.NumberPickerDialogFragment; import net.somethingdreadful.MAL.tasks.ForumJob; public class ForumInterface { @@ -68,10 +72,47 @@ public void run() { } /** - * Get more pages certain comments. + * Get next comment page. */ @JavascriptInterface - public void commentList(final String page) { + public void nextCommentList(final String page) { + forum.runOnUiThread(new Runnable() { + @Override + public void run() { + String[] details = forum.webview.getTitle().split(" "); + forum.getRecords(ForumJob.TOPIC, Integer.parseInt(details[1]), page); + } + }); + } + + /** + * Get comment page. + */ + @JavascriptInterface + public void pagePicker(final String page) { + forum.runOnUiThread(new Runnable() { + @Override + public void run() { + String[] details = forum.webview.getTitle().split(" "); + Bundle bundle = new Bundle(); + bundle.putInt("id", Integer.parseInt(details[1])); + bundle.putString("title", forum.getString(R.string.Page_number)); + bundle.putInt("current", Integer.parseInt(page)); + bundle.putInt("max", Integer.parseInt(details[2])); + bundle.putInt("min", 1); + FragmentManager fm = forum.getFragmentManager(); + NumberPickerDialogFragment dialogFragment = new NumberPickerDialogFragment().setOnSendClickListener(forum); + dialogFragment.setArguments(bundle); + dialogFragment.show(fm, "fragment_page"); + } + }); + } + + /** + * Get previous comment page. + */ + @JavascriptInterface + public void prevCommentList(final String page) { forum.runOnUiThread(new Runnable() { @Override public void run() { From 797b52729e50cbcb1501dea08cd7aa8936b05ebc Mon Sep 17 00:00:00 2001 From: ratan12 Date: Mon, 1 Feb 2016 21:05:56 +0100 Subject: [PATCH 22/46] Enable pager support for topics (Forum) --- Atarashii/res/raw/forum_list.html | 64 ++++++++++++++++--- Atarashii/res/raw/forum_menu.html | 8 +-- .../somethingdreadful/MAL/ForumActivity.java | 42 +++++++++--- .../MAL/forum/ForumInterface.java | 28 ++++++++ 4 files changed, 122 insertions(+), 20 deletions(-) diff --git a/Atarashii/res/raw/forum_list.html b/Atarashii/res/raw/forum_list.html index 3839ecf0..aba55b83 100644 --- a/Atarashii/res/raw/forum_list.html +++ b/Atarashii/res/raw/forum_list.html @@ -4,19 +4,21 @@ <!-- title --> -
-
+ + + \ No newline at end of file diff --git a/Atarashii/res/raw/forum_menu.html b/Atarashii/res/raw/forum_menu.html index 9d78560c..32df2f2f 100644 --- a/Atarashii/res/raw/forum_menu.html +++ b/Atarashii/res/raw/forum_menu.html @@ -14,10 +14,10 @@ body { background-color:#f2f2f2; font-family:"Open Sans",Arial,sans-serif; - font-size:14px + font-size:14px; } .forum-tags { - margin-top:10px + margin-top:10px; } .tag__section { background:#FFF; @@ -27,10 +27,10 @@ } .tag__section span:nth-of-type(2) { color:#818181; - font-size:0.85em + font-size:0.85em; } .tag__section span:first-of-type:hover { - color:#3498db + color:#3498db; } .tag__section span:first-of-type { padding-bottom:3px; diff --git a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java index d8b275b4..74141811 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java +++ b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java @@ -155,11 +155,13 @@ public void getRecords(ForumJob job, int id, String page) { break; case SUBCATEGORY: test.setSubBoard(true); + break; case CATEGORY: new ForumNetworkTask(this, this, job, id).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, page); break; case TOPIC: new ForumNetworkTask(this, this, job, id).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, page); + break; case SEARCH: new ForumNetworkTask(this, this, job, id).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, query); break; @@ -193,7 +195,18 @@ public void onForumNetworkTaskFinished(ArrayList forum, ForumJob job) { @Override public void onUpdated(int number, int id) { - getRecords(ForumJob.TOPIC, Integer.parseInt(String.valueOf(id)), String.valueOf(number)); + String[] details = webview.getTitle().split(" "); + switch (details[0]) { + case "S": // sub board + getRecords(ForumJob.SUBCATEGORY, Integer.parseInt(String.valueOf(id)), String.valueOf(number)); + break; + case "T": // topic list + getRecords(ForumJob.CATEGORY, Integer.parseInt(String.valueOf(id)), String.valueOf(number)); + break; + case "C": // commments + getRecords(ForumJob.TOPIC, Integer.parseInt(String.valueOf(id)), String.valueOf(number)); + break; + } } public class testforumhtmlunit { @@ -255,22 +268,26 @@ public void setForumMenu(ArrayList menu) { if (menu != null && menu.size() > 0) { String forumArray = ""; String tempTile; + String description; for (Forum item : menu) { tempTile = forumMenuTiles; - tempTile = tempTile.replace("", item.getName()); - tempTile = tempTile.replace("", item.getDescription()); - tempTile = tempTile.replace("", getString(context, R.string.dialog_message_last_post)); + description = item.getDescription(); if (item.getChildren() != null) { tempTile = tempTile.replace("onClick=\"tileClick()\"", ""); + description = description + " "; for (int i = 0; i < item.getChildren().size(); i++) { Forum child = item.getChildren().get(i); - tempTile = tempTile.replace(child.getName(), "" + child.getName() + ""); + description = description + "" + child.getName() + "" + (i < item.getChildren().size() - 1 ? ", " : ""); } } else { tempTile = tempTile.replace("", String.valueOf(item.getId())); } + + tempTile = tempTile.replace("", item.getName()); + tempTile = tempTile.replace("", description); + tempTile = tempTile.replace("", getString(context, R.string.dialog_message_last_post)); forumArray = forumArray + tempTile; } forumMenuLayout = forumMenuLayout.replace("", forumArray); @@ -285,6 +302,7 @@ public void setForumList(ArrayList forumList) { String tempForumList; String forumArray = ""; String tempTile; + int maxPages = forumList.get(0).getMaxPages(); for (Forum item : forumList) { tempTile = forumListTiles; tempTile = tempTile.replace("", String.valueOf(item.getId())); @@ -294,10 +312,18 @@ public void setForumList(ArrayList forumList) { forumArray = forumArray + tempTile; } tempForumList = forumListLayout.replace("", forumArray); - tempForumList = tempForumList.replace("", (getSubBoard() ? "S " : "T ") + getId()); // T = Topics || S = subboard, id - if (Integer.parseInt(getPage()) != 1) { - tempForumList = tempForumList.replace("Forum.topicList(" + getPage(), "Forum.topicList(" + (Integer.parseInt(getPage()) + 1)); // T = Topics || S = subboard, id + tempForumList = tempForumList.replace("", (getSubBoard() ? "S " : "T ") + getId() + " " + maxPages); // T = Topics || S = subboard, id + if (Integer.parseInt(getPage()) == 1) { + tempForumList = tempForumList.replace("class=\"previous\"", "class=\"previous\" style=\"visibility: hidden;\""); } + if (Integer.parseInt(getPage()) == maxPages) { + tempForumList = tempForumList.replace("class=\"next\"", "class=\"next\" style=\"visibility: hidden;\""); + } + tempForumList = tempForumList.replace("Forum.prevTopicList(" + getPage(), "Forum.prevTopicList(" + (Integer.parseInt(getPage()) - 1)); + tempForumList = tempForumList.replace("Forum.nextTopicList(" + getPage(), "Forum.nextTopicList(" + (Integer.parseInt(getPage()) + 1)); + tempForumList = tempForumList.replace("", getPage()); + tempForumList = tempForumList.replace("", context.getString(R.string.next)); + tempForumList = tempForumList.replace("", context.getString(R.string.previous)); loadWebview(tempForumList); } } diff --git a/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java b/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java index 52ba60d0..84cb01c2 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java +++ b/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java @@ -71,6 +71,34 @@ public void run() { }); } + /** + * Get next topic page. + */ + @JavascriptInterface + public void nextTopicList(final String page) { + forum.runOnUiThread(new Runnable() { + @Override + public void run() { + String[] details = forum.webview.getTitle().split(" "); + forum.getRecords(ForumJob.CATEGORY, Integer.parseInt(details[1]), page); + } + }); + } + + /** + * Get topic comment page. + */ + @JavascriptInterface + public void prevTopicList(final String page) { + forum.runOnUiThread(new Runnable() { + @Override + public void run() { + String[] details = forum.webview.getTitle().split(" "); + forum.getRecords(ForumJob.CATEGORY, Integer.parseInt(details[1]), page); + } + }); + } + /** * Get next comment page. */ From b6efef6e41b36fdc29363ef3aa54f0058db1a89f Mon Sep 17 00:00:00 2001 From: ratan12 Date: Mon, 1 Feb 2016 21:06:18 +0100 Subject: [PATCH 23/46] Fix layout bugs forum --- Atarashii/res/raw/forum_comment.html | 43 +++++++++++++++------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/Atarashii/res/raw/forum_comment.html b/Atarashii/res/raw/forum_comment.html index b35bd264..d13bc9ac 100644 --- a/Atarashii/res/raw/forum_comment.html +++ b/Atarashii/res/raw/forum_comment.html @@ -37,48 +37,51 @@ input.spoilerbutton:active {background-color: #1976D2;} .comment markdown { display:block; - padding-left:5px; + padding-left:4px; padding-top:8px; } .comment__user { display:block; float:left; - margin-right:5px; - margin-top:1px; + margin-right:4px; width:60px; } .comment__avatar { -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; - height:60px; + height:58px; transition:0.15s; - width:60px; + width:58px; } .comment__body { -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; background:#FFF; - border:solid 1px #EEE; font-size:0.95em; min-height:50px; overflow:auto; - padding:5px 7px 5px 7px; - margin:5px; + padding:4px; } + + .comment { + margin:4px 8px 4px 8px; + } + .comment__name { border-bottom:solid 1px #EEE; color:#022f70; display:block; font-weight:600; - padding-bottom:3px; + padding-bottom:4px; padding-left:4px; } time-ago { color:#3E454F; float:right; - font-size:0.85em; + font-size:0.80em; + margin-top:1px; margin-right:10px; opacity:0.4; } @@ -96,7 +99,7 @@ background-color:#f2f2f2; font-family:"Open Sans",Arial,sans-serif; font-size:14px; - margin:0; + margin: 6px 0px 0px 0px; } body:after { -webkit-box-sizing:border-box; @@ -107,11 +110,11 @@ .previous { background: #458EDB; - border-radius: 0 3px 3px 0; + border-radius: 0px 3px 3px 0px; color: #fff; display: inline-block; - margin-top: 2px; - margin-bottom: 3px; + margin-top: 4px; + margin-bottom: 8px; padding: 10px; padding-left: 20px; padding-right: 15px; @@ -119,13 +122,13 @@ font-weight: bold; } - .next{ + .next { background: #458EDB; border-radius: 3px 0 0 3px; color: #fff; display: inline-block; - margin-top: 2px; - margin-bottom: 3px; + margin-top: 4px; + margin-bottom: 8px; padding: 10px; padding-left: 15px; padding-right: 20px; @@ -138,16 +141,16 @@ background: #458EDB; border-radius: 3px 3px 3px 3px; color: #fff; - margin-top: 2px; + margin-top: 4px; font-family: sans-serif; font-weight: bold; - margin-bottom: 3px; + margin-bottom: 8px; padding: 10px; padding-left: 15px; padding-right: 15px; position: absolute; left: 50%; - transform: translate(-50%, 0%); } + transform: translate(-50%, 0%); } From b55416cbd22f56b05a9e33bc21b1f9d740166826 Mon Sep 17 00:00:00 2001 From: ratan12 Date: Mon, 1 Feb 2016 21:06:54 +0100 Subject: [PATCH 24/46] Add special command to remove cookies and fix spoiler issues --- .../somethingdreadful/MAL/ForumActivity.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java index 74141811..08697a78 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java +++ b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java @@ -14,6 +14,7 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.webkit.CookieManager; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.ProgressBar; @@ -123,7 +124,13 @@ protected void onNewIntent(Intent intent) { private void handleIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { query = intent.getStringExtra(SearchManager.QUERY); - getRecords(ForumJob.SEARCH, 0, "1"); + if (query.equals("Atarashii:clear")) { + webview.clearCache(true); + CookieManager.getInstance().removeAllCookie(); + finish(); + } else { + getRecords(ForumJob.SEARCH, 0, "1"); + } search.collapseActionView(); } } @@ -340,7 +347,7 @@ public void setForumComments(ArrayList forumList) { rank = item.getProfile().getSpecialAccesRank(item.getUsername()); comment = item.getComment(); comment = comment.replaceAll("
((.|\\n)+?)
((.|\\n)+?)((.|\\n)+?)
", spoilerStructure + "$3"); - comment = comment.replaceAll("
((.|\\n)+?)class=\"quotetext\">((.|\\n)+?)
", spoilerStructure + "$3"); + comment = comment.replaceAll("
((.|\\n)+?)class=\"quotetext\">((.|\\n)+?)
", spoilerStructure + "$3"); comment = comment.replaceAll("@(\\w+)", "@$1"); tempTile = forumCommentsTiles; @@ -361,12 +368,12 @@ public void setForumComments(ArrayList forumList) { tempForumList = tempForumList.replace("", "C " + getId() + " " + maxPages); // C = Comments, id, maxPages if (Integer.parseInt(getPage()) == 1) { tempForumList = tempForumList.replace("class=\"previous\"", "class=\"previous\" style=\"visibility: hidden;\""); - } else if (Integer.parseInt(getPage()) == maxPages) { + } + if (Integer.parseInt(getPage()) == maxPages) { tempForumList = tempForumList.replace("class=\"next\"", "class=\"next\" style=\"visibility: hidden;\""); - } else { - tempForumList = tempForumList.replace("Forum.prevCommentList(" + getPage(), "Forum.prevCommentList(" + (Integer.parseInt(getPage()) - 1)); - tempForumList = tempForumList.replace("Forum.nextCommentList(" + getPage(), "Forum.nextCommentList(" + (Integer.parseInt(getPage()) + 1)); } + tempForumList = tempForumList.replace("Forum.prevCommentList(" + getPage(), "Forum.prevCommentList(" + (Integer.parseInt(getPage()) - 1)); + tempForumList = tempForumList.replace("Forum.nextCommentList(" + getPage(), "Forum.nextCommentList(" + (Integer.parseInt(getPage()) + 1)); tempForumList = tempForumList.replace("", getPage()); tempForumList = tempForumList.replace("", context.getString(R.string.next)); tempForumList = tempForumList.replace("", context.getString(R.string.previous)); From f94e8517ce776de596c03f92bac8613611fd8459 Mon Sep 17 00:00:00 2001 From: ratan12 Date: Tue, 2 Feb 2016 19:22:20 +0100 Subject: [PATCH 25/46] Update design metrics (Forum) --- Atarashii/res/raw/forum_comment.html | 4 ++-- Atarashii/res/raw/forum_list.html | 13 +++---------- Atarashii/res/raw/forum_menu.html | 9 ++------- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/Atarashii/res/raw/forum_comment.html b/Atarashii/res/raw/forum_comment.html index d13bc9ac..b07e525c 100644 --- a/Atarashii/res/raw/forum_comment.html +++ b/Atarashii/res/raw/forum_comment.html @@ -43,7 +43,7 @@ .comment__user { display:block; float:left; - margin-right:4px; + margin-right:2px; width:60px; } .comment__avatar { @@ -99,7 +99,7 @@ background-color:#f2f2f2; font-family:"Open Sans",Arial,sans-serif; font-size:14px; - margin: 6px 0px 0px 0px; + margin: 8px 0px 0px 0px; } body:after { -webkit-box-sizing:border-box; diff --git a/Atarashii/res/raw/forum_list.html b/Atarashii/res/raw/forum_list.html index aba55b83..90e6b6c5 100644 --- a/Atarashii/res/raw/forum_list.html +++ b/Atarashii/res/raw/forum_list.html @@ -9,24 +9,17 @@ function pagePicker() {Forum.pagePicker();} -
-
\ No newline at end of file From e5e03698a350afaef2a133675186078b75f1059e Mon Sep 17 00:00:00 2001 From: ratan12 Date: Tue, 2 Feb 2016 19:22:38 +0100 Subject: [PATCH 26/46] Add stacktrace for dev usage --- Atarashii/src/net/somethingdreadful/MAL/Theme.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Atarashii/src/net/somethingdreadful/MAL/Theme.java b/Atarashii/src/net/somethingdreadful/MAL/Theme.java index 29ebdf09..ae847715 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/Theme.java +++ b/Atarashii/src/net/somethingdreadful/MAL/Theme.java @@ -82,6 +82,7 @@ public void onConfigurationChanged(Configuration newConfig) { public static void logTaskCrash(String className, String message, Exception e) { Crashlytics.log(Log.ERROR, "MALX", className + "." + message + ": " + e.getMessage()); Crashlytics.logException(e); + e.printStackTrace(); Answers.getInstance().logCustom(new CustomEvent("Error (Task)").putCustomAttribute(className, e.getMessage())); } From c13142122a4ff961f5c5e1790421581b8d7c940c Mon Sep 17 00:00:00 2001 From: ratan12 Date: Sat, 6 Feb 2016 14:38:35 +0100 Subject: [PATCH 27/46] Add comment interface --- Atarashii/res/raw/forum_comment.html | 280 +++++++++++------- .../somethingdreadful/MAL/ForumActivity.java | 7 +- .../net/somethingdreadful/MAL/MALManager.java | 8 +- .../MAL/forum/ForumInterface.java | 19 ++ .../somethingdreadful/MAL/tasks/ForumJob.java | 2 +- .../MAL/tasks/ForumNetworkTask.java | 5 + 6 files changed, 210 insertions(+), 111 deletions(-) diff --git a/Atarashii/res/raw/forum_comment.html b/Atarashii/res/raw/forum_comment.html index b07e525c..98eb07de 100644 --- a/Atarashii/res/raw/forum_comment.html +++ b/Atarashii/res/raw/forum_comment.html @@ -7,158 +7,228 @@ function prevCommentList() {Forum.prevCommentList(2);} function profileClick(username) {Forum.profileClick(username);} function pagePicker() {Forum.pagePicker();} + + function bold() {insertAtCursor(document.getElementById("textarea"),"[b][/b]");} + function italics() {insertAtCursor(document.getElementById("textarea"),"[i][/i]");} + function strike() {insertAtCursor(document.getElementById("textarea"),"[s][/s]");} + function spoiler() {insertAtCursor(document.getElementById("textarea"),"[spoiler][/spoiler]");} + function url() {insertAtCursor(document.getElementById("textarea"),"[url=][/url]");} + function image() {insertAtCursor(document.getElementById("textarea"),"[img][/img]");} + function youtube() {insertAtCursor(document.getElementById("textarea"),"[yt][/yt]");} + function list() {insertAtCursor(document.getElementById("textarea"),"[list][/list]");} + function size() {insertAtCursor(document.getElementById("textarea"),"[size=][/size]");} + function center() {insertAtCursor(document.getElementById("textarea"),"[center][/center]");} + function quote() {insertAtCursor(document.getElementById("textarea"),"[quote][/quote]");} + function send() {Forum.sendComment(document.getElementById("textarea").value);} + + function insertAtCursor(myField, myValue) { + var startPos = myField.selectionStart; + var endPos = myField.selectionEnd; + myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); + } + - +
+
+
+ + + + + + + + + + + + + + +
+ +
+
- - - +Previous +Next +1 \ No newline at end of file diff --git a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java index 08697a78..8e98d56b 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java +++ b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java @@ -197,6 +197,11 @@ public void onForumNetworkTaskFinished(ArrayList forum, ForumJob job) { case TOPIC: test.setForumComments(forum); break; + case ADDCOMMENT: + Theme.Snackbar(this, forum != null ? R.string.toast_info_comment_added : R.string.toast_error_Records); + if (forum != null) + test.setForumComments(forum); + break; } } @@ -365,7 +370,7 @@ public void setForumComments(ArrayList forumList) { forumArray = forumArray + tempTile; } tempForumList = forumCommentsLayout.replace("", forumArray); - tempForumList = tempForumList.replace("", "C " + getId() + " " + maxPages); // C = Comments, id, maxPages + tempForumList = tempForumList.replace("", "C " + getId() + " " + maxPages + " " + getPage()); // C = Comments, id, maxPages, page if (Integer.parseInt(getPage()) == 1) { tempForumList = tempForumList.replace("class=\"previous\"", "class=\"previous\" style=\"visibility: hidden;\""); } diff --git a/Atarashii/src/net/somethingdreadful/MAL/MALManager.java b/Atarashii/src/net/somethingdreadful/MAL/MALManager.java index aa1a1f2c..3c33750c 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/MALManager.java +++ b/Atarashii/src/net/somethingdreadful/MAL/MALManager.java @@ -268,10 +268,6 @@ public ForumMain getDiscussion(int id, int page, MALApi.ListType type) { return type.equals(MALApi.ListType.ANIME) ? malApi.getAnime(id, page) : malApi.getManga(id, page); } - public Boolean addComment(int id, String message) { - return malApi.addComment(id, message); - } - public Boolean updateComment(int id, String message) { return malApi.updateComment(id, message); } @@ -385,4 +381,8 @@ public ArrayList search(String query) { public ArrayList getSubCategory(int id, int page) { return malApi.getSubBoards(id, page).createBaseModel(); } + + public boolean addComment(int id, String message) { + return malApi.addComment(id, message); + } } diff --git a/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java b/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java index 84cb01c2..b423506e 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java +++ b/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java @@ -2,6 +2,7 @@ import android.app.FragmentManager; import android.content.Intent; +import android.os.AsyncTask; import android.os.Bundle; import android.webkit.JavascriptInterface; @@ -10,6 +11,7 @@ import net.somethingdreadful.MAL.R; import net.somethingdreadful.MAL.dialog.NumberPickerDialogFragment; import net.somethingdreadful.MAL.tasks.ForumJob; +import net.somethingdreadful.MAL.tasks.ForumNetworkTask; public class ForumInterface { ForumActivity forum; @@ -99,6 +101,23 @@ public void run() { }); } + /** + * Send a comment. + */ + @JavascriptInterface + public void sendComment(final String comment) { + forum.runOnUiThread(new Runnable() { + @Override + public void run() { + if (comment != "") { + forum.setLoading(true); + String[] details = forum.webview.getTitle().split(" "); + new ForumNetworkTask(forum, forum, ForumJob.ADDCOMMENT, Integer.parseInt(details[1])).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, comment, details[3]); + } + } + }); + } + /** * Get next comment page. */ diff --git a/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumJob.java b/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumJob.java index 8ca62f8e..a64e1156 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumJob.java +++ b/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumJob.java @@ -1,5 +1,5 @@ package net.somethingdreadful.MAL.tasks; public enum ForumJob { - MENU, CATEGORY, SUBCATEGORY, TOPIC, SEARCH + MENU, CATEGORY, SUBCATEGORY, TOPIC, SEARCH, ADDCOMMENT; } \ No newline at end of file diff --git a/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumNetworkTask.java b/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumNetworkTask.java index 4aab2249..630c32c4 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumNetworkTask.java +++ b/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumNetworkTask.java @@ -50,6 +50,11 @@ protected ArrayList doInBackground(String... params) { case SEARCH: result = mManager.search(params[0]); break; + case ADDCOMMENT: + result = mManager.addComment(id, params[0]) ? new ArrayList() : null; + if (result != null) + result = mManager.getTopic(id, Integer.parseInt(params[1])); + break; /* case DISCUSSION: if (params[1].equals(MALApi.ListType.ANIME.toString())) From 535017134b784b0d45ffdedf5f9ca4faa9f3a819 Mon Sep 17 00:00:00 2001 From: ratan12 Date: Sun, 7 Feb 2016 13:25:07 +0100 Subject: [PATCH 28/46] Update gradle build version --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 25aadad6..7107859c 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.0.0-alpha9' + classpath 'com.android.tools.build:gradle:2.0.0-beta2' } } From 1f007816334813b96a0bbd80e2d3b7727737e3c6 Mon Sep 17 00:00:00 2001 From: ratan12 Date: Sun, 7 Feb 2016 13:25:25 +0100 Subject: [PATCH 29/46] Fix subboards not working --- Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java index 8e98d56b..353bc08a 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java +++ b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java @@ -162,10 +162,7 @@ public void getRecords(ForumJob job, int id, String page) { break; case SUBCATEGORY: test.setSubBoard(true); - break; case CATEGORY: - new ForumNetworkTask(this, this, job, id).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, page); - break; case TOPIC: new ForumNetworkTask(this, this, job, id).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, page); break; From 9c56e48d86f94b90acfc21d90fe345fba2e044e4 Mon Sep 17 00:00:00 2001 From: ratan12 Date: Sun, 7 Feb 2016 14:18:10 +0100 Subject: [PATCH 30/46] Add short comment message --- Atarashii/res/values/strings.xml | 1 + .../src/net/somethingdreadful/MAL/forum/ForumInterface.java | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Atarashii/res/values/strings.xml b/Atarashii/res/values/strings.xml index a877467a..891cea1e 100644 --- a/Atarashii/res/values/strings.xml +++ b/Atarashii/res/values/strings.xml @@ -44,6 +44,7 @@ The backup has been removed! The backup is not compatible with this site! A widget with the chosen record already exists! + The comment is short! Username mismatch diff --git a/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java b/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java index b423506e..ad3a0562 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java +++ b/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java @@ -9,6 +9,7 @@ import net.somethingdreadful.MAL.ForumActivity; import net.somethingdreadful.MAL.ProfileActivity; import net.somethingdreadful.MAL.R; +import net.somethingdreadful.MAL.Theme; import net.somethingdreadful.MAL.dialog.NumberPickerDialogFragment; import net.somethingdreadful.MAL.tasks.ForumJob; import net.somethingdreadful.MAL.tasks.ForumNetworkTask; @@ -109,10 +110,12 @@ public void sendComment(final String comment) { forum.runOnUiThread(new Runnable() { @Override public void run() { - if (comment != "") { + if (!comment.equals("") && comment.length() > 16) { forum.setLoading(true); String[] details = forum.webview.getTitle().split(" "); new ForumNetworkTask(forum, forum, ForumJob.ADDCOMMENT, Integer.parseInt(details[1])).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, comment, details[3]); + } else { + Theme.Snackbar(forum, R.string.toast_info_comment); } } }); From acfdf748b954eb6978eb67c59d3f80510cf0ac49 Mon Sep 17 00:00:00 2001 From: ratan12 Date: Mon, 8 Feb 2016 19:09:36 +0100 Subject: [PATCH 31/46] Fix record updater --- .../MAL/api/BaseModels/AnimeManga/Anime.java | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/Anime.java b/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/Anime.java index aee7ce37..9d4a0f25 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/Anime.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/Anime.java @@ -4,6 +4,7 @@ import android.text.TextUtils; import net.somethingdreadful.MAL.MALManager; +import net.somethingdreadful.MAL.PrefManager; import net.somethingdreadful.MAL.api.MALApi; import net.somethingdreadful.MAL.api.MALModels.RecordStub; @@ -347,16 +348,16 @@ public void setRewatchValue(int rewatchValue) { public void checkProgress() { boolean completed = false; + boolean started = false; - // Automatically set the max episode on completed - if (getWatchedStatus().equals(GenericRecord.STATUS_COMPLETED) && getEpisodes() > 0) { - setWatchedEpisodes(getEpisodes()); - completed = true; + // Automatically set the status on completed + if (getEpisodes() > 0 && getWatchedEpisodes() == getEpisodes() && !getDirty().contains("watchedStatus")) { + setWatchedStatus(GenericRecord.STATUS_COMPLETED); } - // Automatically set the progress when the max episode has reached - if (getWatchedEpisodes() == getEpisodes() && getEpisodes() > 0) { - setWatchedStatus(GenericRecord.STATUS_COMPLETED); + // Automatically set the max episode on completed + if (getEpisodes() > 0 && getWatchedStatus().equals(GenericRecord.STATUS_COMPLETED) && !getDirty().contains("watchedEpisodes")) { + setWatchedEpisodes(getEpisodes()); completed = true; } @@ -368,7 +369,7 @@ public void checkProgress() { } // Automatically set the end date on completed if it is empty - if (getWatchingEnd() == null || getWatchingEnd().equals("")) { + if ((getWatchingEnd() == null || getWatchingEnd().equals("") || getWatchingEnd().equals("0-00-00")) && PrefManager.getAutoDateSetter()) { final Calendar c = Calendar.getInstance(); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH); @@ -377,20 +378,23 @@ public void checkProgress() { } } + if (getWatchedStatus().equals(GenericRecord.STATUS_WATCHING) && getWatchedEpisodes() == 0 && !getDirty().contains("watchedEpisodes")) { + started = true; + } + // Automatically set the progress when the episode 1 has been watched - if (getWatchedStatus().equals(GenericRecord.STATUS_PLANTOWATCH) && getWatchedEpisodes() == 1) { + if (getWatchedStatus().equals(GenericRecord.STATUS_PLANTOWATCH) && getWatchedEpisodes() == 1 && !getDirty().contains("watchedStatus")) { setWatchedStatus(GenericRecord.STATUS_WATCHING); + started = true; } // Automatically set the start date on start if it is empty - if (getWatchedStatus().equals(GenericRecord.STATUS_WATCHING) && getWatchedEpisodes() == 1) { - if (getWatchingStart() == null || getWatchingStart().equals("")) { - final Calendar c = Calendar.getInstance(); - int year = c.get(Calendar.YEAR); - int month = c.get(Calendar.MONTH); - int day = c.get(Calendar.DAY_OF_MONTH); - setWatchingStart(year + "-" + month + "-" + day); - } + if ((getWatchingStart() == null || getWatchingStart().equals("") || getWatchingStart().equals("0-00-00")) && PrefManager.getAutoDateSetter() && started) { + final Calendar c = Calendar.getInstance(); + int year = c.get(Calendar.YEAR); + int month = c.get(Calendar.MONTH); + int day = c.get(Calendar.DAY_OF_MONTH); + setWatchingStart(year + "-" + month + "-" + day); } } From 44b883a9d51cfbb445f696d78fb74844f307f7ca Mon Sep 17 00:00:00 2001 From: ratan12 Date: Fri, 12 Feb 2016 21:40:13 +0100 Subject: [PATCH 32/46] Add comment updater (forum) --- Atarashii/res/raw/forum_comment.html | 315 ++++++++++-------- Atarashii/res/raw/forum_comment_tiles.html | 8 +- Atarashii/res/values/strings.xml | 1 + .../somethingdreadful/MAL/ForumActivity.java | 3 + .../MAL/forum/ForumInterface.java | 129 ++++++- .../somethingdreadful/MAL/tasks/ForumJob.java | 2 +- .../MAL/tasks/ForumNetworkTask.java | 3 + 7 files changed, 311 insertions(+), 150 deletions(-) diff --git a/Atarashii/res/raw/forum_comment.html b/Atarashii/res/raw/forum_comment.html index 98eb07de..56434d23 100644 --- a/Atarashii/res/raw/forum_comment.html +++ b/Atarashii/res/raw/forum_comment.html @@ -3,203 +3,232 @@ <!-- title --> @@ -222,9 +251,9 @@ - + - + diff --git a/Atarashii/res/raw/forum_comment_tiles.html b/Atarashii/res/raw/forum_comment_tiles.html index 791b67c2..f192c521 100644 --- a/Atarashii/res/raw/forum_comment_tiles.html +++ b/Atarashii/res/raw/forum_comment_tiles.html @@ -1,14 +1,16 @@
-
+
+ + +
- +
\ No newline at end of file diff --git a/Atarashii/res/values/strings.xml b/Atarashii/res/values/strings.xml index 891cea1e..a1ccf1db 100644 --- a/Atarashii/res/values/strings.xml +++ b/Atarashii/res/values/strings.xml @@ -31,6 +31,7 @@ Check your credentials and try again. Sync error while getting friendlist! No anime or manga results found. + The comment could not be converted! Syncing everything. This could take a few seconds. Username and password combination doesn\'t match! Copied the title successfully to the clipboard! diff --git a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java index 353bc08a..d3187fa4 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java +++ b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java @@ -353,7 +353,10 @@ public void setForumComments(ArrayList forumList) { comment = comment.replaceAll("@(\\w+)", "@$1"); tempTile = forumCommentsTiles; + if (item.getUsername().equalsIgnoreCase(AccountService.getUsername())) + tempTile = tempTile.replace("fa-quote-right fa-lg\" id=\"quote\"", "fa-pencil fa-lg\" id=\"edit\""); tempTile = tempTile.replace("", item.getUsername()); + tempTile = tempTile.replace("", Integer.toString(item.getId())); tempTile = tempTile.replace("", DateTools.parseDate(item.getTime(), true)); tempTile = tempTile.replace("", comment); if (item.getProfile().getAvatarUrl().contains("xmlhttp-loader")) diff --git a/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java b/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java index ad3a0562..f6d55ba8 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java +++ b/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java @@ -10,6 +10,7 @@ import net.somethingdreadful.MAL.ProfileActivity; import net.somethingdreadful.MAL.R; import net.somethingdreadful.MAL.Theme; +import net.somethingdreadful.MAL.account.AccountService; import net.somethingdreadful.MAL.dialog.NumberPickerDialogFragment; import net.somethingdreadful.MAL.tasks.ForumJob; import net.somethingdreadful.MAL.tasks.ForumNetworkTask; @@ -21,6 +22,125 @@ public ForumInterface(ForumActivity forum) { this.forum = forum; } + /** + * convert HTML to BBCode + */ + @JavascriptInterface + public void convertHTML(final String username, final String messageID, String bbCode) { + if (bbCode.contains("src=\"http://youtube.com/embed/")) { + forum.runOnUiThread(new Runnable() { + @Override + public void run() { + Theme.Snackbar(forum, R.string.toast_info_disabled_youtube); + } + }); + } else { + bbCode = convertMessageQuote(bbCode); + bbCode = convertUserQuote(bbCode); + bbCode = convertQuote(bbCode); + bbCode = convertQuoteSpoiler(bbCode); + bbCode = convertSpoiler(bbCode); + bbCode = bbCode.replace(" target=\"_blank", ""); //image trash + bbCode = bbCode.replaceAll("((.|\\n)+?)", "[b]$1[/b]"); //Bold text + bbCode = bbCode.replaceAll("((.|\\n)+?)", "[i]$1[/i]"); //Italics + bbCode = bbCode.replaceAll("((.|\\n)+?)", "[u]$1[/u]"); //Underlined text + bbCode = bbCode.replaceAll("
    ((.|\\n)+?)
", "[list]$1[/list]"); //list + bbCode = bbCode.replaceAll("
    ((.|\\n)+?)
", "[list=1]$1[/list]"); //list + bbCode = bbCode.replaceAll("
  • ((.|\\n)+?)
  • ", "[*]$1"); //list items + bbCode = bbCode.replaceAll("
    ((.|\\n)+?)
    ", "$1"); //unknown + bbCode = bbCode.replaceAll("\\[b]@(.+?)\\[/b](.+?)", "@$2"); //@ mention + bbCode = bbCode.replaceAll("((.|\\n)+?)", "[s]$1[/s]"); //Strike-thru text + bbCode = bbCode.replaceAll("((.|\\n)+?)", "[size=$1]$2[/size]"); //resized text + bbCode = bbCode.replaceAll("((.|\\n)+?)", "[color=$1]$2[/color]"); //colored text + bbCode = bbCode.replaceAll("
    ((.|\\n)+?)
    ", "[center]$1[/center]"); //centered text + bbCode = bbCode.replaceAll("
    ((.|\\n)+?)
    ", "[right]$1[/right]"); //right text + bbCode = bbCode.replaceAll("((.|\\n)+?)", "[url=$1]$2[/url]"); //Text link + bbCode = bbCode.replaceAll("", "[img]$1[/img]"); //image + bbCode = bbCode.replaceAll("", "[img align=left]$1[/img]"); //image left + bbCode = bbCode.replaceAll("", "[img align=right]$1[/img]"); //image right + bbCode = bbCode.replaceAll("
    ((.|\\n)+?)
    ", "[code]$[/code]"); //code + + final String finalBbCode = bbCode.replaceAll("
    ", "\n"); //new line + if (finalBbCode.contains("(.+?) said:((.|\\n)+?)
    ", "[quote=$2 message=$1]$3[/quote]"); //real quote + if (HTML.contains("", "[quote=$1]$2[/quote]"); //real quote + if (HTML.contains("
    ")) + return convertUserQuote(HTML); + convertUserQuote = 0; + } + return HTML; + } + + int convertQuote = 0; + private String convertQuote(String HTML) { + convertQuote = convertQuote + 1; + if (convertQuote <= 8) { + HTML = HTML.replaceAll("
    ((.|\\n)+?)
    ", "[quote]$1[/quote]"); //quote + if (HTML.contains("
    ")) + return convertQuote(HTML); + convertQuote = 0; + } + return HTML; + } + + int convertQuoteSpoiler = 0; + private String convertQuoteSpoiler(String HTML) { + convertQuoteSpoiler = convertQuoteSpoiler + 1; + if (convertQuoteSpoiler <= 8) { + HTML = HTML.replaceAll("(.+?) said:((.|\\n)+?)
    ", "[spoiler][quote=$2]$3[/quote][/spoiler]"); //quote + if (HTML.contains("spoiler quotetext\">")) + return convertQuoteSpoiler(HTML); + convertQuoteSpoiler = 0; + } + return HTML; + } + + int convertSpoiler = 0; + private String convertSpoiler(String HTML) { + convertSpoiler = convertSpoiler + 1; + if (convertSpoiler <= 8) { + HTML = HTML.replaceAll("((.|\\n)+?)
    ", "[spoiler]$2[/spoiler]"); //quote + if (HTML.contains("spoiler quotetext\">")) + return convertSpoiler(HTML); + convertSpoiler = 0; + } + return HTML; + } + /** * Get the topics from a certain category. */ @@ -106,14 +226,17 @@ public void run() { * Send a comment. */ @JavascriptInterface - public void sendComment(final String comment) { + public void sendComment(final String comment, final String messageID) { forum.runOnUiThread(new Runnable() { @Override public void run() { - if (!comment.equals("") && comment.length() > 16) { + if (comment.length() > 16) { forum.setLoading(true); String[] details = forum.webview.getTitle().split(" "); - new ForumNetworkTask(forum, forum, ForumJob.ADDCOMMENT, Integer.parseInt(details[1])).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, comment, details[3]); + if (messageID.equals("0")) + new ForumNetworkTask(forum, forum, ForumJob.ADDCOMMENT, Integer.parseInt(details[1])).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, comment, details[3]); + else + new ForumNetworkTask(forum, forum, ForumJob.UPDATECOMMENT, Integer.parseInt(messageID)).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, comment, details[3]); } else { Theme.Snackbar(forum, R.string.toast_info_comment); } diff --git a/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumJob.java b/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumJob.java index a64e1156..6f97ddd1 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumJob.java +++ b/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumJob.java @@ -1,5 +1,5 @@ package net.somethingdreadful.MAL.tasks; public enum ForumJob { - MENU, CATEGORY, SUBCATEGORY, TOPIC, SEARCH, ADDCOMMENT; + MENU, CATEGORY, SUBCATEGORY, TOPIC, SEARCH, ADDCOMMENT, UPDATECOMMENT; } \ No newline at end of file diff --git a/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumNetworkTask.java b/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumNetworkTask.java index 630c32c4..2bef1bcd 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumNetworkTask.java +++ b/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumNetworkTask.java @@ -55,6 +55,9 @@ protected ArrayList doInBackground(String... params) { if (result != null) result = mManager.getTopic(id, Integer.parseInt(params[1])); break; + case UPDATECOMMENT: + result = mManager.updateComment(id, params[0]) ? new ArrayList() : null; + break; /* case DISCUSSION: if (params[1].equals(MALApi.ListType.ANIME.toString())) From 90eb5cd2ac947fd2a9e0c9f44a0f586e52e92728 Mon Sep 17 00:00:00 2001 From: ratan12 Date: Fri, 12 Feb 2016 21:40:25 +0100 Subject: [PATCH 33/46] Update Gson version --- Atarashii/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Atarashii/build.gradle b/Atarashii/build.gradle index 1c116e98..9c33b2d7 100644 --- a/Atarashii/build.gradle +++ b/Atarashii/build.gradle @@ -72,7 +72,7 @@ dependencies { compile 'com.android.support:cardview-v7:23.+' compile 'com.android.support:appcompat-v7:23.+' compile 'com.android.support:design:23.+' - compile 'com.google.code.gson:gson:2.4' + compile 'com.google.code.gson:gson:2.5' compile 'org.apache.commons:commons-lang3:3.4' compile 'com.squareup.okhttp:okhttp:2.5.0' compile 'com.squareup.retrofit:retrofit:1.9.0' From 5ce4a88075abe14dba84c7b547dd69fc6102751d Mon Sep 17 00:00:00 2001 From: ratan12 Date: Fri, 12 Feb 2016 21:40:59 +0100 Subject: [PATCH 34/46] Fix forum crash due multipe requests --- Atarashii/res/raw/forum_menu.html | 2 +- .../somethingdreadful/MAL/ForumActivity.java | 46 +++++++++++-------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/Atarashii/res/raw/forum_menu.html b/Atarashii/res/raw/forum_menu.html index d467e9b9..75cc8af3 100644 --- a/Atarashii/res/raw/forum_menu.html +++ b/Atarashii/res/raw/forum_menu.html @@ -15,7 +15,7 @@ background-color:#f2f2f2; font-family:"Open Sans",Arial,sans-serif; font-size:14px; - margin: 8px 0px 0px 0px; + margin: 8px 0px 8px 0px; } .tag__section { background:#FFF; diff --git a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java index d3187fa4..1ba95488 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java +++ b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java @@ -21,6 +21,7 @@ import com.crashlytics.android.Crashlytics; +import net.somethingdreadful.MAL.account.AccountService; import net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Forum; import net.somethingdreadful.MAL.dialog.NumberPickerDialogFragment; import net.somethingdreadful.MAL.forum.ForumInterface; @@ -45,6 +46,7 @@ public class ForumActivity extends AppCompatActivity implements ForumNetworkTask MenuItem search; Menu menu; String query; + boolean loading = false; @SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"}) @Override @@ -149,26 +151,29 @@ public void onSaveInstanceState(Bundle state) { } public void getRecords(ForumJob job, int id, String page) { - test.setSubBoard(false); - setLoading(true); - test.setId(id); - test.setPage(page); - switch (job) { - case MENU: - if (!test.menuExists()) - new ForumNetworkTask(this, this, job, id).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); - else - test.setForumMenu(null); - break; - case SUBCATEGORY: - test.setSubBoard(true); - case CATEGORY: - case TOPIC: - new ForumNetworkTask(this, this, job, id).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, page); - break; - case SEARCH: - new ForumNetworkTask(this, this, job, id).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, query); - break; + if (!loading) { + loading = true; + test.setSubBoard(false); + setLoading(true); + test.setId(id); + test.setPage(page); + switch (job) { + case MENU: + if (!test.menuExists()) + new ForumNetworkTask(this, this, job, id).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + else + test.setForumMenu(null); + break; + case SUBCATEGORY: + test.setSubBoard(true); + case CATEGORY: + case TOPIC: + new ForumNetworkTask(this, this, job, id).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, page); + break; + case SEARCH: + new ForumNetworkTask(this, this, job, id).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, query); + break; + } } } @@ -200,6 +205,7 @@ public void onForumNetworkTaskFinished(ArrayList forum, ForumJob job) { test.setForumComments(forum); break; } + loading = false; } @Override From 68cc258a1c6be2a29d81ff8acb7ca938d70dba9a Mon Sep 17 00:00:00 2001 From: ratan12 Date: Fri, 12 Feb 2016 21:55:34 +0100 Subject: [PATCH 35/46] Make quote red when the user is updating a comment --- Atarashii/res/raw/forum_comment.html | 2 +- Atarashii/res/raw/forum_comment_tiles.html | 2 +- Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Atarashii/res/raw/forum_comment.html b/Atarashii/res/raw/forum_comment.html index 56434d23..74db894a 100644 --- a/Atarashii/res/raw/forum_comment.html +++ b/Atarashii/res/raw/forum_comment.html @@ -250,7 +250,7 @@ - +
    diff --git a/Atarashii/res/raw/forum_comment_tiles.html b/Atarashii/res/raw/forum_comment_tiles.html index f192c521..94625eaf 100644 --- a/Atarashii/res/raw/forum_comment_tiles.html +++ b/Atarashii/res/raw/forum_comment_tiles.html @@ -7,7 +7,7 @@
    - +
    diff --git a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java index 1ba95488..941fcf05 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java +++ b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java @@ -360,7 +360,7 @@ public void setForumComments(ArrayList forumList) { tempTile = forumCommentsTiles; if (item.getUsername().equalsIgnoreCase(AccountService.getUsername())) - tempTile = tempTile.replace("fa-quote-right fa-lg\" id=\"quote\"", "fa-pencil fa-lg\" id=\"edit\""); + tempTile = tempTile.replace("fa-quote-right fa-lg\"", "fa-pencil fa-lg\" id=\"edit\""); tempTile = tempTile.replace("", item.getUsername()); tempTile = tempTile.replace("", Integer.toString(item.getId())); tempTile = tempTile.replace("", DateTools.parseDate(item.getTime(), true)); From cee821c5dc42ce84cf402639ef6b8348669a6fee Mon Sep 17 00:00:00 2001 From: ratan12 Date: Fri, 12 Feb 2016 22:13:44 +0100 Subject: [PATCH 36/46] Show dialog before updating/adding comments --- .../MAL/forum/ForumInterface.java | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java b/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java index f6d55ba8..0b953fd2 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java +++ b/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java @@ -11,6 +11,7 @@ import net.somethingdreadful.MAL.R; import net.somethingdreadful.MAL.Theme; import net.somethingdreadful.MAL.account.AccountService; +import net.somethingdreadful.MAL.dialog.ChooseDialogFragment; import net.somethingdreadful.MAL.dialog.NumberPickerDialogFragment; import net.somethingdreadful.MAL.tasks.ForumJob; import net.somethingdreadful.MAL.tasks.ForumNetworkTask; @@ -232,11 +233,30 @@ public void sendComment(final String comment, final String messageID) { public void run() { if (comment.length() > 16) { forum.setLoading(true); - String[] details = forum.webview.getTitle().split(" "); - if (messageID.equals("0")) - new ForumNetworkTask(forum, forum, ForumJob.ADDCOMMENT, Integer.parseInt(details[1])).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, comment, details[3]); - else - new ForumNetworkTask(forum, forum, ForumJob.UPDATECOMMENT, Integer.parseInt(messageID)).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, comment, details[3]); + final String[] details = forum.webview.getTitle().split(" "); + + + ChooseDialogFragment lcdf = new ChooseDialogFragment(); + Bundle bundle = new Bundle(); + if (messageID.equals("0")) { + bundle.putString("title", forum.getString(R.string.dialog_title_add_comment)); + bundle.putString("message", forum.getString(R.string.dialog_message_add_comment)); + } else { + bundle.putString("title", forum.getString(R.string.dialog_title_edit_comment)); + bundle.putString("message", forum.getString(R.string.dialog_message_edit_comment)); + } + bundle.putString("positive", forum.getString(android.R.string.yes)); + lcdf.setArguments(bundle); + lcdf.setCallback(new ChooseDialogFragment.onClickListener() { + @Override + public void onPositiveButtonClicked() { + if (messageID.equals("0")) + new ForumNetworkTask(forum, forum, ForumJob.ADDCOMMENT, Integer.parseInt(details[1])).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, comment, details[3]); + else + new ForumNetworkTask(forum, forum, ForumJob.UPDATECOMMENT, Integer.parseInt(messageID)).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, comment, details[3]); + } + }); + lcdf.show(forum.getFragmentManager(), "fragment_sendComment"); } else { Theme.Snackbar(forum, R.string.toast_info_comment); } From af56c22b25a1d3e695bde8266df7258603767b24 Mon Sep 17 00:00:00 2001 From: ratan12 Date: Fri, 12 Feb 2016 22:14:01 +0100 Subject: [PATCH 37/46] Add dialog strings (Forums) --- Atarashii/res/values/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Atarashii/res/values/strings.xml b/Atarashii/res/values/strings.xml index a1ccf1db..8d5edc17 100644 --- a/Atarashii/res/values/strings.xml +++ b/Atarashii/res/values/strings.xml @@ -86,6 +86,8 @@ Last post by Do you want to view the $child1; or $child2; category? It is possible that the chosen backup is not your backup! + Are you sure that your comment should be updated? + Do you really want to add a new comment? Cancel Update Anime From f6b117f631f0d2ffa28b4e793965433c4d0430b1 Mon Sep 17 00:00:00 2001 From: ratan12 Date: Fri, 12 Feb 2016 22:14:28 +0100 Subject: [PATCH 38/46] Fix webview keeps loading issue after updating comments --- Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java index 941fcf05..a469a9bf 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java +++ b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java @@ -199,6 +199,10 @@ public void onForumNetworkTaskFinished(ArrayList forum, ForumJob job) { case TOPIC: test.setForumComments(forum); break; + case UPDATECOMMENT: + Theme.Snackbar(this, forum != null ? R.string.toast_info_comment_added : R.string.toast_error_Records); + setLoading(false); + break; case ADDCOMMENT: Theme.Snackbar(this, forum != null ? R.string.toast_info_comment_added : R.string.toast_error_Records); if (forum != null) From 3d4f7142d1698b508c93ed8d6fbcb4db0fc26872 Mon Sep 17 00:00:00 2001 From: ratan12 Date: Sun, 14 Feb 2016 16:03:58 +0100 Subject: [PATCH 39/46] Replace navigationdrawer with support design --- Atarashii/res/layout/activity_home.xml | 17 +- Atarashii/res/layout/navdrawer_header.xml | 53 ++++ .../res/layout/record_home_navigation.xml | 25 -- .../layout/record_home_navigationdrawer.xml | 205 -------------- Atarashii/res/menu/navdrawer.xml | 68 +++++ .../src/net/somethingdreadful/MAL/Home.java | 257 +++++++++--------- .../MAL/NavigationItems.java | 50 ---- .../MAL/adapters/NavigationDrawerAdapter.java | 65 ----- 8 files changed, 269 insertions(+), 471 deletions(-) create mode 100644 Atarashii/res/layout/navdrawer_header.xml delete mode 100644 Atarashii/res/layout/record_home_navigation.xml delete mode 100644 Atarashii/res/layout/record_home_navigationdrawer.xml create mode 100644 Atarashii/res/menu/navdrawer.xml delete mode 100644 Atarashii/src/net/somethingdreadful/MAL/NavigationItems.java delete mode 100644 Atarashii/src/net/somethingdreadful/MAL/adapters/NavigationDrawerAdapter.java diff --git a/Atarashii/res/layout/activity_home.xml b/Atarashii/res/layout/activity_home.xml index 4aadff46..bf680ce1 100644 --- a/Atarashii/res/layout/activity_home.xml +++ b/Atarashii/res/layout/activity_home.xml @@ -1,8 +1,21 @@ + android:layout_height="match_parent" + android:fitsSystemWindows="true" + tools:context=".Home"> + + diff --git a/Atarashii/res/layout/navdrawer_header.xml b/Atarashii/res/layout/navdrawer_header.xml new file mode 100644 index 00000000..8e63b3f1 --- /dev/null +++ b/Atarashii/res/layout/navdrawer_header.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + diff --git a/Atarashii/res/layout/record_home_navigation.xml b/Atarashii/res/layout/record_home_navigation.xml deleted file mode 100644 index ea325d6b..00000000 --- a/Atarashii/res/layout/record_home_navigation.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - diff --git a/Atarashii/res/layout/record_home_navigationdrawer.xml b/Atarashii/res/layout/record_home_navigationdrawer.xml deleted file mode 100644 index 56843d84..00000000 --- a/Atarashii/res/layout/record_home_navigationdrawer.xml +++ /dev/null @@ -1,205 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Atarashii/res/menu/navdrawer.xml b/Atarashii/res/menu/navdrawer.xml new file mode 100644 index 00000000..f4b7b264 --- /dev/null +++ b/Atarashii/res/menu/navdrawer.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Atarashii/src/net/somethingdreadful/MAL/Home.java b/Atarashii/src/net/somethingdreadful/MAL/Home.java index c7b8ac92..3a19c76f 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/Home.java +++ b/Atarashii/src/net/somethingdreadful/MAL/Home.java @@ -10,11 +10,12 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.content.res.ColorStateList; import android.graphics.Color; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; -import android.support.v4.view.GravityCompat; +import android.support.design.widget.NavigationView; import android.support.v4.view.MenuItemCompat; import android.support.v4.view.ViewPager; import android.support.v4.widget.DrawerLayout; @@ -25,14 +26,12 @@ import android.support.v7.widget.SearchView; import android.support.v7.widget.Toolbar; import android.util.Log; -import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.ImageView; import android.widget.ListView; -import android.widget.RelativeLayout; import android.widget.TextView; import com.crashlytics.android.Crashlytics; @@ -41,7 +40,6 @@ import net.somethingdreadful.MAL.account.AccountService; import net.somethingdreadful.MAL.adapters.IGFPagerAdapter; -import net.somethingdreadful.MAL.adapters.NavigationDrawerAdapter; import net.somethingdreadful.MAL.api.BaseModels.Profile; import net.somethingdreadful.MAL.api.MALApi; import net.somethingdreadful.MAL.dialog.ChooseDialogFragment; @@ -53,7 +51,7 @@ import butterknife.Bind; import butterknife.ButterKnife; -public class Home extends AppCompatActivity implements ChooseDialogFragment.onClickListener, SwipeRefreshLayout.OnRefreshListener, IGF.IGFCallbackListener, APIAuthenticationErrorListener, View.OnClickListener, UserNetworkTask.UserNetworkTaskListener, ViewPager.OnPageChangeListener { +public class Home extends AppCompatActivity implements ChooseDialogFragment.onClickListener, SwipeRefreshLayout.OnRefreshListener, IGF.IGFCallbackListener, APIAuthenticationErrorListener, View.OnClickListener, UserNetworkTask.UserNetworkTaskListener, ViewPager.OnPageChangeListener, NavigationView.OnNavigationItemSelectedListener { IGF af; IGF mf; Menu menu; @@ -63,77 +61,84 @@ public class Home extends AppCompatActivity implements ChooseDialogFragment.onCl DrawerLayout DrawerLayout; IGFPagerAdapter mIGFPagerAdapter; BroadcastReceiver networkReceiver; - ActionBarDrawerToggle mDrawerToggle; - NavigationDrawerAdapter mNavigationDrawerAdapter; - - @Bind(R.id.about) RelativeLayout about; - @Bind(R.id.listview) ListView DrawerList; - @Bind(R.id.logout) RelativeLayout logout; - @Bind(R.id.settings) RelativeLayout settings; - @Bind(R.id.support) RelativeLayout support; String username; boolean networkAvailable; boolean myList = true; //tracks if the user is on 'My List' or not - boolean callbackAnimeError = false; - boolean callbackMangaError = false; int callbackCounter = 0; + @Bind(R.id.navigationView) + NavigationView navigationView; + @Bind(R.id.drawerLayout) + DrawerLayout drawerLayout; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + //Initializing activity and application context = getApplicationContext(); Theme.context = context; + if (AccountService.getAccount() != null) { //The following is state handling code networkAvailable = savedInstanceState == null || savedInstanceState.getBoolean("networkAvailable", true); if (savedInstanceState != null) myList = savedInstanceState.getBoolean("myList"); + //Initializing Theme Theme.setTheme(this, R.layout.activity_home, false); + //Initializing IGF mIGFPagerAdapter = (IGFPagerAdapter) Theme.setActionBar(this, new IGFPagerAdapter(getFragmentManager(), true)); actionBar = getSupportActionBar(); - LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); - DrawerLayout = (DrawerLayout) inflater.inflate(R.layout.record_home_navigationdrawer, (DrawerLayout) findViewById(R.id.drawer_layout)); + //Initializing ButterKnife ButterKnife.bind(this); - DrawerLayout.setDrawerListener(new DrawerListener()); - DrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); + //setup navigation profile information username = AccountService.getUsername(); - ((TextView) DrawerLayout.findViewById(R.id.name)).setText(username); - ((TextView) DrawerLayout.findViewById(R.id.siteName)).setText(getString(AccountService.isMAL() ? R.string.init_hint_myanimelist : R.string.init_hint_anilist)); new UserNetworkTask(context, false, this, this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, username); - logout.setOnClickListener(this); - settings.setOnClickListener(this); - about.setOnClickListener(this); - support.setOnClickListener(this); - Theme.setBackground(this, logout); - Theme.setBackground(this, settings); - Theme.setBackground(this, support); - Theme.setBackground(this, about); + //Initializing NavigationView + navigationView = (NavigationView) findViewById(R.id.navigationView); + navigationView.setNavigationItemSelectedListener(this); + navigationView.getMenu().findItem(R.id.nav_list).setChecked(true); + ((TextView) navigationView.getHeaderView(0).findViewById(R.id.name)).setText(username); + ((TextView) navigationView.getHeaderView(0).findViewById(R.id.siteName)).setText(getString(AccountService.isMAL() ? R.string.init_hint_myanimelist : R.string.init_hint_anilist)); + + //Initializing navigation toggle button + drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); + ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, (Toolbar) findViewById(R.id.actionbar), R.string.drawer_open, R.string.drawer_close) { + @Override + public void onDrawerClosed(View drawerView) { + super.onDrawerClosed(drawerView); + } + @Override + public void onDrawerOpened(View drawerView) { + super.onDrawerOpened(drawerView); + } + }; + drawerLayout.setDrawerListener(drawerToggle); + drawerToggle.syncState(); + //Applying dark theme if (Theme.darkTheme) { - DrawerLayout.findViewById(R.id.scrollView).setBackgroundColor(getResources().getColor(R.color.bg_dark)); - DrawerLayout.findViewById(R.id.divider).setBackgroundColor(getResources().getColor(R.color.bg_dark_card)); - ((ImageView) DrawerLayout.findViewById(R.id.supportImg)).setImageDrawable(getResources().getDrawable(R.drawable.mobihelp_ic_conversation_dark)); - ((TextView) DrawerLayout.findViewById(R.id.logoutText)).setTextColor(getResources().getColor(R.color.text_dark)); - ((TextView) DrawerLayout.findViewById(R.id.settingsText)).setTextColor(getResources().getColor(R.color.text_dark)); - ((TextView) DrawerLayout.findViewById(R.id.supportText)).setTextColor(getResources().getColor(R.color.text_dark)); - ((TextView) DrawerLayout.findViewById(R.id.aboutText)).setTextColor(getResources().getColor(R.color.text_dark)); - } + int[][] states = new int[][] { + new int[] {-android.R.attr.state_checked}, // unchecked + new int[] {android.R.attr.state_checked} // checked + }; - NavigationItems mNavigationContent = new NavigationItems(DrawerList, context); - mNavigationDrawerAdapter = new NavigationDrawerAdapter(this, mNavigationContent.ITEMS); - DrawerList.setAdapter(mNavigationDrawerAdapter); - DrawerList.setOnItemClickListener(new DrawerItemClickListener()); - DrawerList.setOverScrollMode(View.OVER_SCROLL_NEVER); + int[] colors = new int[] { + context.getResources().getColor(R.color.bg_light_card), + context.getResources().getColor(R.color.primary) + }; - mDrawerToggle = new ActionBarDrawerToggle(this, DrawerLayout, (Toolbar) findViewById(R.id.actionbar), R.string.drawer_open, R.string.drawer_close); - mDrawerToggle.syncState(); + ColorStateList myList = new ColorStateList(states, colors); + + navigationView.setBackgroundColor(getResources().getColor(R.color.bg_dark)); + navigationView.setItemTextColor(myList); + navigationView.setItemIconTintList(myList); + } networkReceiver = new BroadcastReceiver() { @Override @@ -163,9 +168,6 @@ public boolean onCreateOptionsMenu(Menu menu) { @Override public boolean onOptionsItemSelected(MenuItem item) { - if (mDrawerToggle.onOptionsItemSelected(item)) { - return true; - } switch (item.getItemId()) { case R.id.listType_all: getRecords(true, TaskJob.GETLIST, 0); @@ -401,18 +403,6 @@ public void onAPIAuthenticationError(MALApi.ListType type, TaskJob job) { @Override public void onClick(View v) { switch (v.getId()) { - case R.id.logout: - showLogoutDialog(); - break; - case R.id.settings: - startActivity(new Intent(this, Settings.class)); - break; - case R.id.support: - Mobihelp.showSupport(this); - break; - case R.id.about: - startActivity(new Intent(this, AboutActivity.class)); - break; case R.id.Image: Intent Profile = new Intent(context, ProfileActivity.class); Profile.putExtra("username", username); @@ -465,6 +455,90 @@ public void onPositiveButtonClicked() { System.exit(0); } + @Override + public boolean onNavigationItemSelected(MenuItem item) { + // disable swipeRefresh for other lists + af.setSwipeRefreshEnabled(myList); + mf.setSwipeRefreshEnabled(myList); + + //Checking if the item should be checked + switch (item.getItemId()) { + case R.id.nav_profile: + break; + case R.id.nav_friends: + break; + case R.id.nav_forum: + break; + case R.id.nav_settings: + break; + case R.id.nav_support: + break; + case R.id.nav_about: + break; + default: + if (item.isChecked()) + item.setChecked(false); + else + item.setChecked(true); + break; + } + + //Closing drawer on item click + drawerLayout.closeDrawers(); + + //Performing the action + switch (item.getItemId()) { + case R.id.nav_list: + getRecords(true, TaskJob.GETLIST, af.list); + break; + case R.id.nav_profile: + Intent Profile = new Intent(context, ProfileActivity.class); + Profile.putExtra("username", username); + startActivity(Profile); + break; + case R.id.nav_friends: + Intent Friends = new Intent(context, ProfileActivity.class); + Friends.putExtra("username", username); + Friends.putExtra("friends", username); + startActivity(Friends); + break; + case R.id.nav_forum: + if (AccountService.isMAL()) { + Intent Forum = new Intent(context, ForumActivity.class); + startActivity(Forum); + } else { + Theme.Snackbar(Home.this, R.string.toast_info_disabled); + } + break; + case R.id.nav_rated: + getRecords(true, TaskJob.GETTOPRATED, af.list); + break; + case R.id.nav_popular: + getRecords(true, TaskJob.GETMOSTPOPULAR, af.list); + break; + case R.id.nav_added: + getRecords(true, TaskJob.GETJUSTADDED, af.list); + break; + case R.id.nav_upcoming: + getRecords(true, TaskJob.GETUPCOMING, af.list); + break; + case R.id.nav_logout: // Others subgroup + showLogoutDialog(); + break; + case R.id.nav_settings: + startActivity(new Intent(this, Settings.class)); + break; + case R.id.nav_support: + Mobihelp.showSupport(this); + break; + case R.id.nav_about: + startActivity(new Intent(this, AboutActivity.class)); + break; + } + myListChanged(); + return false; + } + public class DrawerItemClickListener implements ListView.OnItemClickListener { @Override @@ -474,46 +548,6 @@ public void onItemClick(AdapterView parent, View view, int position, long id) Theme.Snackbar(Home.this, R.string.toast_error_noConnectivity); } myList = ((position <= 3 && myList) || position == 0); - // disable swipeRefresh for other lists - af.setSwipeRefreshEnabled(myList); - mf.setSwipeRefreshEnabled(myList); - switch (position) { - case 0: - getRecords(true, TaskJob.GETLIST, af.list); - break; - case 1: - Intent Profile = new Intent(context, ProfileActivity.class); - Profile.putExtra("username", username); - startActivity(Profile); - break; - case 2: - Intent Friends = new Intent(context, ProfileActivity.class); - Friends.putExtra("username", username); - Friends.putExtra("friends", username); - startActivity(Friends); - break; - case 3: - if (AccountService.isMAL()) { - Intent Forum = new Intent(context, ForumActivity.class); - startActivity(Forum); - } else { - Theme.Snackbar(Home.this, R.string.toast_info_disabled); - } - break; - case 4: - getRecords(true, TaskJob.GETTOPRATED, af.list); - break; - case 5: - getRecords(true, TaskJob.GETMOSTPOPULAR, af.list); - break; - case 6: - getRecords(true, TaskJob.GETJUSTADDED, af.list); - break; - case 7: - getRecords(true, TaskJob.GETUPCOMING, af.list); - break; - } - myListChanged(); /* * This part is for figuring out which item in the nav drawer is selected and highlighting it with colors. @@ -531,29 +565,4 @@ public void onItemClick(AdapterView parent, View view, int position, long id) DrawerLayout.closeDrawers(); } } - - private class DrawerListener implements DrawerLayout.DrawerListener { - @Override - public void onDrawerOpened(View drawerView) { - mDrawerToggle.onDrawerOpened(drawerView); - actionBar.setTitle(getTitle()); - } - - @Override - public void onDrawerClosed(View drawerView) { - mDrawerToggle.onDrawerClosed(drawerView); - actionBar.setTitle(getTitle()); - drawerView.requestFocusFromTouch(); - } - - @Override - public void onDrawerSlide(View drawerView, float slideOffset) { - mDrawerToggle.onDrawerSlide(drawerView, slideOffset); - } - - @Override - public void onDrawerStateChanged(int newState) { - mDrawerToggle.onDrawerStateChanged(newState); - } - } } diff --git a/Atarashii/src/net/somethingdreadful/MAL/NavigationItems.java b/Atarashii/src/net/somethingdreadful/MAL/NavigationItems.java deleted file mode 100644 index 09f4eb7c..00000000 --- a/Atarashii/src/net/somethingdreadful/MAL/NavigationItems.java +++ /dev/null @@ -1,50 +0,0 @@ -package net.somethingdreadful.MAL; - -import android.content.Context; -import android.widget.ListView; - -import net.somethingdreadful.MAL.account.AccountService; - -import java.util.ArrayList; - -public class NavigationItems { - - public ArrayList ITEMS = new ArrayList(); - - public NavigationItems(ListView list, Context context) { - addItem(new NavItem(R.drawable.ic_format_list, R.string.nav_item_my_list)); - addItem(new NavItem(R.drawable.ic_person, R.string.nav_item_my_profile)); - if (AccountService.isMAL()) - addItem(new NavItem(R.drawable.ic_group, R.string.nav_item_my_friends)); - else - addItem(new NavItem(R.drawable.ic_group, R.string.nav_item_my_following)); - addItem(new NavItem(R.drawable.ic_forum_grey, R.string.nav_item_my_forum)); - if (AccountService.isMAL()) { - addItem(new NavItem(R.drawable.ic_star, R.string.nav_item_top_rated)); - addItem(new NavItem(R.drawable.ic_insert_chart, R.string.nav_item_most_popular)); - } else { - addItem(new NavItem(R.drawable.ic_star, R.string.nav_item_year)); - addItem(new NavItem(R.drawable.ic_insert_chart, R.string.nav_item_airing)); - } - addItem(new NavItem(R.drawable.ic_access_time, R.string.nav_item_just_added)); - addItem(new NavItem(R.drawable.ic_event, R.string.nav_item_upcoming)); - - // Calculate the best ListView height and apply it - list.getLayoutParams().height = (int) (ITEMS.size() * 48 * (context.getResources().getDisplayMetrics().densityDpi / 160f)); - } - - public void addItem(NavItem item) { - ITEMS.add(item); - } - - public static class NavItem { - public int icon; - public int title; - - public NavItem(int icon, int title) { - this.icon = icon; - this.title = title; - } - } - -} \ No newline at end of file diff --git a/Atarashii/src/net/somethingdreadful/MAL/adapters/NavigationDrawerAdapter.java b/Atarashii/src/net/somethingdreadful/MAL/adapters/NavigationDrawerAdapter.java deleted file mode 100644 index afd00051..00000000 --- a/Atarashii/src/net/somethingdreadful/MAL/adapters/NavigationDrawerAdapter.java +++ /dev/null @@ -1,65 +0,0 @@ -package net.somethingdreadful.MAL.adapters; - -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.ImageView; -import android.widget.TextView; - -import net.somethingdreadful.MAL.Home; -import net.somethingdreadful.MAL.NavigationItems; -import net.somethingdreadful.MAL.R; -import net.somethingdreadful.MAL.Theme; - -import java.util.ArrayList; - -public class NavigationDrawerAdapter extends ArrayAdapter { - private ArrayList items; - private Home home; - - public NavigationDrawerAdapter(Home home, ArrayList items) { - super(home, R.layout.record_home_navigation, items); - this.items = items; - this.home = home; - } - - public View getView(int position, View v, ViewGroup parent) { - ViewHolder viewHolder; - - if (v == null) { - LayoutInflater vi = home.getLayoutInflater(); - v = vi.inflate(R.layout.record_home_navigation, parent, false); - - viewHolder = new ViewHolder(); - viewHolder.mIcon = (ImageView) v.findViewById(R.id.nav_item_icon); - viewHolder.mTitle = (TextView) v.findViewById(R.id.nav_item_text); - - if (Theme.darkTheme) { - viewHolder.mTitle.setTextColor(home.getResources().getColor(R.color.text_dark)); - Theme.setBackground(home, v); - } - - v.setTag(viewHolder); - } else { - viewHolder = (ViewHolder) v.getTag(); - } - - NavigationItems.NavItem item = items.get(position); - if (item != null) { - if (viewHolder.mIcon != null) { - viewHolder.mIcon.setImageResource(item.icon); - } - if (viewHolder.mTitle != null) { - viewHolder.mTitle.setText(item.title); - } - } - - return v; - } - - static class ViewHolder { - ImageView mIcon; - TextView mTitle; - } -} \ No newline at end of file From 153ee2f4162a81006b68617ce0cf3755d2215ff0 Mon Sep 17 00:00:00 2001 From: ratan12 Date: Sun, 14 Feb 2016 16:04:22 +0100 Subject: [PATCH 40/46] Update menu if networkconnection has changed --- Atarashii/src/net/somethingdreadful/MAL/Home.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Atarashii/src/net/somethingdreadful/MAL/Home.java b/Atarashii/src/net/somethingdreadful/MAL/Home.java index 3a19c76f..5721e262 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/Home.java +++ b/Atarashii/src/net/somethingdreadful/MAL/Home.java @@ -144,6 +144,7 @@ public void onDrawerOpened(View drawerView) { @Override public void onReceive(Context context, Intent intent) { checkNetworkAndDisplayCrouton(); + myListChanged(); } }; } else { @@ -288,10 +289,12 @@ public void setChecked(MenuItem item) { } public void myListChanged() { - menu.findItem(R.id.menu_listType).setVisible(myList); - menu.findItem(R.id.menu_inverse).setVisible(myList || (!AccountService.isMAL() && af.taskjob == TaskJob.GETMOSTPOPULAR)); - menu.findItem(R.id.forceSync).setVisible(myList && networkAvailable); - menu.findItem(R.id.action_search).setVisible(networkAvailable); + if (menu != null) { + menu.findItem(R.id.menu_listType).setVisible(myList); + menu.findItem(R.id.menu_inverse).setVisible(myList || (!AccountService.isMAL() && af.taskjob == TaskJob.GETMOSTPOPULAR)); + menu.findItem(R.id.forceSync).setVisible(myList && networkAvailable); + menu.findItem(R.id.action_search).setVisible(networkAvailable); + } } private void syncNotify() { From dc042d2c88cb58a3a771675eb1fb03ef79339b37 Mon Sep 17 00:00:00 2001 From: ratan12 Date: Sun, 14 Feb 2016 17:29:19 +0100 Subject: [PATCH 41/46] Fix header margin navigationdrawer --- Atarashii/res/layout/navdrawer_header.xml | 6 +-- .../src/net/somethingdreadful/MAL/Home.java | 52 ++++--------------- 2 files changed, 12 insertions(+), 46 deletions(-) diff --git a/Atarashii/res/layout/navdrawer_header.xml b/Atarashii/res/layout/navdrawer_header.xml index 8e63b3f1..47730c89 100644 --- a/Atarashii/res/layout/navdrawer_header.xml +++ b/Atarashii/res/layout/navdrawer_header.xml @@ -1,12 +1,12 @@ + android:layout_height="172dp"> @@ -15,7 +15,7 @@ android:layout_width="64dp" android:layout_height="64dp" android:layout_marginLeft="16dp" - android:layout_marginTop="16dp" + android:layout_marginTop="40dp" android:scaleType="fitStart" android:src="@drawable/ic_person" /> diff --git a/Atarashii/src/net/somethingdreadful/MAL/Home.java b/Atarashii/src/net/somethingdreadful/MAL/Home.java index 5721e262..597dadf2 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/Home.java +++ b/Atarashii/src/net/somethingdreadful/MAL/Home.java @@ -11,7 +11,6 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.res.ColorStateList; -import android.graphics.Color; import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; @@ -29,9 +28,7 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; -import android.widget.AdapterView; import android.widget.ImageView; -import android.widget.ListView; import android.widget.TextView; import com.crashlytics.android.Crashlytics; @@ -63,7 +60,6 @@ public class Home extends AppCompatActivity implements ChooseDialogFragment.onCl BroadcastReceiver networkReceiver; String username; - boolean networkAvailable; boolean myList = true; //tracks if the user is on 'My List' or not int callbackCounter = 0; @@ -72,6 +68,15 @@ public class Home extends AppCompatActivity implements ChooseDialogFragment.onCl @Bind(R.id.drawerLayout) DrawerLayout drawerLayout; + int[][] states = new int[][] { + new int[] {-android.R.attr.state_checked}, // unchecked + new int[] {android.R.attr.state_checked} // checked + }; + int[] colors = new int[] { + context.getResources().getColor(R.color.bg_light_card), + context.getResources().getColor(R.color.primary) + }; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -123,18 +128,7 @@ public void onDrawerOpened(View drawerView) { //Applying dark theme if (Theme.darkTheme) { - int[][] states = new int[][] { - new int[] {-android.R.attr.state_checked}, // unchecked - new int[] {android.R.attr.state_checked} // checked - }; - - int[] colors = new int[] { - context.getResources().getColor(R.color.bg_light_card), - context.getResources().getColor(R.color.primary) - }; - ColorStateList myList = new ColorStateList(states, colors); - navigationView.setBackgroundColor(getResources().getColor(R.color.bg_dark)); navigationView.setItemTextColor(myList); navigationView.setItemIconTintList(myList); @@ -416,7 +410,6 @@ public void onClick(View v) { lcdf.show(getFragmentManager(), "fragment_NDImage"); break; } - DrawerLayout.closeDrawers(); } @Override @@ -541,31 +534,4 @@ public boolean onNavigationItemSelected(MenuItem item) { myListChanged(); return false; } - - public class DrawerItemClickListener implements ListView.OnItemClickListener { - - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - if (!networkAvailable && position > 2) { - position = 0; - Theme.Snackbar(Home.this, R.string.toast_error_noConnectivity); - } - myList = ((position <= 3 && myList) || position == 0); - - /* - * This part is for figuring out which item in the nav drawer is selected and highlighting it with colors. - */ - if (position != 1 && position != 2 && position != 3) { - if (mPreviousView != null) - mPreviousView.setBackgroundColor(Color.parseColor("#00000000")); - if (Theme.darkTheme) - view.setBackgroundColor(getResources().getColor(R.color.bg_dark_card)); - else - view.setBackgroundColor(Color.parseColor("#E8E8E8")); - mPreviousView = view; - } - - DrawerLayout.closeDrawers(); - } - } } From 9854b2a7b0d68be25f04597d661a697f93f3c0da Mon Sep 17 00:00:00 2001 From: ratan12 Date: Sun, 14 Feb 2016 17:30:56 +0100 Subject: [PATCH 42/46] Code cleanup --- Atarashii/src/net/somethingdreadful/MAL/Card.java | 2 +- Atarashii/src/net/somethingdreadful/MAL/IGF.java | 6 +++--- .../MAL/broadcasts/RecordStatusUpdatedReceiver.java | 2 +- .../somethingdreadful/MAL/dialog/ListDialogFragment.java | 2 +- .../somethingdreadful/MAL/dialog/MessageDialogFragment.java | 4 ++-- .../MAL/dialog/NumberPickerDialogFragment.java | 2 +- .../MAL/tasks/APIAuthenticationErrorListener.java | 2 +- Atarashii/src/net/somethingdreadful/MAL/tasks/ForumJob.java | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Atarashii/src/net/somethingdreadful/MAL/Card.java b/Atarashii/src/net/somethingdreadful/MAL/Card.java index b1557cc2..e3eafa42 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/Card.java +++ b/Atarashii/src/net/somethingdreadful/MAL/Card.java @@ -319,6 +319,6 @@ public void addView(View child, int index, ViewGroup.LayoutParams params) { * The Interface that will get triggered by the OnClick method. */ public interface onCardClickListener { - public void onCardClickListener(int id); + void onCardClickListener(int id); } } \ No newline at end of file diff --git a/Atarashii/src/net/somethingdreadful/MAL/IGF.java b/Atarashii/src/net/somethingdreadful/MAL/IGF.java index 8bacc2ff..da4b913c 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/IGF.java +++ b/Atarashii/src/net/somethingdreadful/MAL/IGF.java @@ -777,8 +777,8 @@ public void supportAddAll(Collection collection) { } public interface IGFCallbackListener { - public void onIGFReady(IGF igf); - public void onRecordsLoadingFinished(MALApi.ListType type, TaskJob job, boolean error, boolean resultEmpty, boolean cancelled); - public void onItemClick(int id, ListType listType, String username); + void onIGFReady(IGF igf); + void onRecordsLoadingFinished(MALApi.ListType type, TaskJob job, boolean error, boolean resultEmpty, boolean cancelled); + void onItemClick(int id, ListType listType, String username); } } \ No newline at end of file diff --git a/Atarashii/src/net/somethingdreadful/MAL/broadcasts/RecordStatusUpdatedReceiver.java b/Atarashii/src/net/somethingdreadful/MAL/broadcasts/RecordStatusUpdatedReceiver.java index 39d96cf7..fa3d880d 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/broadcasts/RecordStatusUpdatedReceiver.java +++ b/Atarashii/src/net/somethingdreadful/MAL/broadcasts/RecordStatusUpdatedReceiver.java @@ -25,6 +25,6 @@ public void onReceive(Context context, Intent intent) { } public interface RecordStatusUpdatedListener { - public void onRecordStatusUpdated(MALApi.ListType type); + void onRecordStatusUpdated(MALApi.ListType type); } } diff --git a/Atarashii/src/net/somethingdreadful/MAL/dialog/ListDialogFragment.java b/Atarashii/src/net/somethingdreadful/MAL/dialog/ListDialogFragment.java index 58c40ca2..cbd0a581 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/dialog/ListDialogFragment.java +++ b/Atarashii/src/net/somethingdreadful/MAL/dialog/ListDialogFragment.java @@ -46,7 +46,7 @@ public void onClick(DialogInterface dialog, int which) { * The interface for callback */ public interface onUpdateClickListener { - public void onUpdated(int number, int id); + void onUpdated(int number, int id); } /** diff --git a/Atarashii/src/net/somethingdreadful/MAL/dialog/MessageDialogFragment.java b/Atarashii/src/net/somethingdreadful/MAL/dialog/MessageDialogFragment.java index a8d31262..492ff00a 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/dialog/MessageDialogFragment.java +++ b/Atarashii/src/net/somethingdreadful/MAL/dialog/MessageDialogFragment.java @@ -188,8 +188,8 @@ public boolean onLongClick(View v) { * The interface for callback */ public interface onSendClickListener { - public void onSendClicked(String message, String subject, ForumJob task, int id); - public void onCloseClicked(String message); + void onSendClicked(String message, String subject, ForumJob task, int id); + void onCloseClicked(String message); } /** diff --git a/Atarashii/src/net/somethingdreadful/MAL/dialog/NumberPickerDialogFragment.java b/Atarashii/src/net/somethingdreadful/MAL/dialog/NumberPickerDialogFragment.java index 2c080a81..cce974bc 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/dialog/NumberPickerDialogFragment.java +++ b/Atarashii/src/net/somethingdreadful/MAL/dialog/NumberPickerDialogFragment.java @@ -116,6 +116,6 @@ public NumberPickerDialogFragment setOnSendClickListener(onUpdateClickListener c * The interface for callback */ public interface onUpdateClickListener { - public void onUpdated(int number, int id); + void onUpdated(int number, int id); } } \ No newline at end of file diff --git a/Atarashii/src/net/somethingdreadful/MAL/tasks/APIAuthenticationErrorListener.java b/Atarashii/src/net/somethingdreadful/MAL/tasks/APIAuthenticationErrorListener.java index 9a238386..69196350 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/tasks/APIAuthenticationErrorListener.java +++ b/Atarashii/src/net/somethingdreadful/MAL/tasks/APIAuthenticationErrorListener.java @@ -3,5 +3,5 @@ import net.somethingdreadful.MAL.api.MALApi; public interface APIAuthenticationErrorListener { - public void onAPIAuthenticationError(MALApi.ListType type, TaskJob job); + void onAPIAuthenticationError(MALApi.ListType type, TaskJob job); } diff --git a/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumJob.java b/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumJob.java index 6f97ddd1..523c2026 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumJob.java +++ b/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumJob.java @@ -1,5 +1,5 @@ package net.somethingdreadful.MAL.tasks; public enum ForumJob { - MENU, CATEGORY, SUBCATEGORY, TOPIC, SEARCH, ADDCOMMENT, UPDATECOMMENT; + MENU, CATEGORY, SUBCATEGORY, TOPIC, SEARCH, ADDCOMMENT, UPDATECOMMENT } \ No newline at end of file From 22d6fbf744bcda7e95e7197e1f6b1d8e737efa27 Mon Sep 17 00:00:00 2001 From: ratan12 Date: Sun, 14 Feb 2016 17:35:07 +0100 Subject: [PATCH 43/46] Fix app crash due unset context (Home) --- .../src/net/somethingdreadful/MAL/Home.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Atarashii/src/net/somethingdreadful/MAL/Home.java b/Atarashii/src/net/somethingdreadful/MAL/Home.java index 597dadf2..f88733f8 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/Home.java +++ b/Atarashii/src/net/somethingdreadful/MAL/Home.java @@ -68,15 +68,6 @@ public class Home extends AppCompatActivity implements ChooseDialogFragment.onCl @Bind(R.id.drawerLayout) DrawerLayout drawerLayout; - int[][] states = new int[][] { - new int[] {-android.R.attr.state_checked}, // unchecked - new int[] {android.R.attr.state_checked} // checked - }; - int[] colors = new int[] { - context.getResources().getColor(R.color.bg_light_card), - context.getResources().getColor(R.color.primary) - }; - @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -128,6 +119,16 @@ public void onDrawerOpened(View drawerView) { //Applying dark theme if (Theme.darkTheme) { + int[][] states = new int[][] { + new int[] {-android.R.attr.state_checked}, // unchecked + new int[] {android.R.attr.state_checked} // checked + }; + + int[] colors = new int[] { + context.getResources().getColor(R.color.bg_light_card), + context.getResources().getColor(R.color.primary) + }; + ColorStateList myList = new ColorStateList(states, colors); navigationView.setBackgroundColor(getResources().getColor(R.color.bg_dark)); navigationView.setItemTextColor(myList); From 9ee3f322766998df0224fd1428e413e39206b81f Mon Sep 17 00:00:00 2001 From: ratan12 Date: Sun, 14 Feb 2016 18:44:59 +0100 Subject: [PATCH 44/46] code cleanup part 2 --- Atarashii/AndroidManifest.xml | 4 +- Atarashii/src/Beta/AndroidManifest.xml | 5 +- .../somethingdreadful/MAL/AboutActivity.java | 4 +- .../somethingdreadful/MAL/BackupActivity.java | 14 +-- .../src/net/somethingdreadful/MAL/Card.java | 21 ++-- .../net/somethingdreadful/MAL/DateTools.java | 11 +- .../net/somethingdreadful/MAL/DetailView.java | 54 ++++----- .../somethingdreadful/MAL/FirstTimeInit.java | 10 +- .../somethingdreadful/MAL/ForumActivity.java | 25 ++-- .../src/net/somethingdreadful/MAL/Home.java | 49 +++----- .../src/net/somethingdreadful/MAL/IGF.java | 80 ++++++------ .../net/somethingdreadful/MAL/MALManager.java | 22 +--- .../somethingdreadful/MAL/PrefManager.java | 3 +- .../MAL/ProfileActivity.java | 25 ++-- .../somethingdreadful/MAL/SearchActivity.java | 17 +-- .../MAL/SettingsFragment.java | 4 +- .../src/net/somethingdreadful/MAL/Theme.java | 6 +- .../MAL/account/AccountService.java | 15 +-- .../MAL/adapters/BackupGridviewAdapter.java | 8 +- .../MAL/adapters/DetailViewPagerAdapter.java | 14 +-- .../adapters/DetailViewRelationsAdapter.java | 12 +- .../MAL/adapters/ForumMainAdapter.java | 98 --------------- .../MAL/adapters/FriendsGridviewAdapter.java | 2 +- .../MAL/adapters/IGFPagerAdapter.java | 6 +- .../MAL/adapters/ProfilePagerAdapter.java | 2 +- .../net/somethingdreadful/MAL/api/ALApi.java | 4 +- .../MAL/api/ALInterface.java | 2 +- .../ALModels/AnimeManga/GenericRecord.java | 4 +- .../MAL/api/ALModels/AnimeManga/Reviews.java | 2 +- .../MAL/api/ALModels/Follow.java | 2 +- .../MAL/api/ALModels/History.java | 2 +- .../MAL/api/BaseModels/AnimeManga/Anime.java | 4 +- .../BaseModels/AnimeManga/GenericRecord.java | 22 ++-- .../MAL/api/BaseModels/AnimeManga/Manga.java | 2 +- .../MAL/api/BaseModels/Profile.java | 4 +- .../MAL/api/MALInterface.java | 2 +- .../MALModels/AnimeManga/GenericRecord.java | 6 +- .../MAL/api/MALModels/AnimeManga/Reviews.java | 2 +- .../MAL/api/MALModels/Friend.java | 2 +- .../MAL/api/MALModels/History.java | 2 +- .../MAL/api/UserAgentInterceptor.java | 2 +- .../MAL/broadcasts/AutoSync.java | 6 +- .../RecordStatusUpdatedReceiver.java | 2 +- .../MAL/database/DatabaseManager.java | 9 +- .../MAL/database/DatabaseTest.java | 4 +- .../somethingdreadful/MAL/database/Query.java | 12 +- .../somethingdreadful/MAL/database/Table.java | 4 +- .../MAL/detailView/DetailViewDetails.java | 104 ++++++++++------ .../MAL/detailView/DetailViewGeneral.java | 71 +++++------ .../MAL/detailView/DetailViewPersonal.java | 73 ++++++----- .../MAL/detailView/DetailViewReviews.java | 9 +- .../MAL/detailView/ReviewsInterface.java | 4 +- .../MAL/dialog/DatePickerDialogFragment.java | 4 +- .../MAL/dialog/ForumChildDialogFragment.java | 32 ----- .../MAL/dialog/MangaPickerDialogFragment.java | 12 +- .../MAL/dialog/MessageDialogFragment.java | 23 ++-- .../dialog/NumberPickerDialogFragment.java | 8 +- .../MAL/dialog/RecordPickerDialog.java | 36 +++--- .../MAL/dialog/SearchIdDialogFragment.java | 2 +- .../MAL/dialog/ShareDialogFragment.java | 6 +- .../dialog/StatusPickerDialogFragment.java | 8 +- .../MAL/dialog/UpdateImageDialogFragment.java | 2 +- .../MAL/forum/ForumInterface.java | 12 +- .../somethingdreadful/MAL/forum/HtmlUtil.java | 53 +------- .../MAL/profile/ProfileDetailsAL.java | 25 ++-- .../MAL/profile/ProfileDetailsMAL.java | 114 +++++++++++------- .../MAL/profile/ProfileFriends.java | 18 +-- .../MAL/profile/ProfileHistory.java | 9 +- .../MAL/profile/ProfileHistoryInterface.java | 4 +- .../MAL/tasks/AuthenticationCheckTask.java | 6 +- .../MAL/tasks/BackupTask.java | 2 +- .../MAL/tasks/ForumNetworkTask.java | 8 +- .../MAL/tasks/FriendsNetworkTask.java | 8 +- .../MAL/tasks/NetworkTask.java | 18 +-- .../MAL/tasks/UserNetworkTask.java | 8 +- .../MAL/tasks/WriteDetailTask.java | 10 +- 76 files changed, 565 insertions(+), 736 deletions(-) delete mode 100644 Atarashii/src/net/somethingdreadful/MAL/adapters/ForumMainAdapter.java delete mode 100644 Atarashii/src/net/somethingdreadful/MAL/dialog/ForumChildDialogFragment.java diff --git a/Atarashii/AndroidManifest.xml b/Atarashii/AndroidManifest.xml index 0741d729..eeb84d6f 100644 --- a/Atarashii/AndroidManifest.xml +++ b/Atarashii/AndroidManifest.xml @@ -1,7 +1,5 @@ + package="net.somethingdreadful.MAL"> + package="net.somethingdreadful.MAL"> files = new ArrayList<>(); - int position = 0; + private BackupGridviewAdapter backupGridviewAdapter; + private final ArrayList files = new ArrayList<>(); + private int position = 0; @Bind(R.id.progressBar) ProgressBar progressBar; @Bind(R.id.swiperefresh) - public SwipeRefreshLayout swipeRefresh; + SwipeRefreshLayout swipeRefresh; @Override protected void onCreate(Bundle savedInstanceState) { @@ -54,7 +54,7 @@ protected void onCreate(Bundle savedInstanceState) { Gridview.setVisibility(View.VISIBLE); Gridview.setOnItemClickListener(this); swipeRefresh.setOnRefreshListener(this); - swipeRefresh.setColorScheme(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); + swipeRefresh.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); swipeRefresh.setEnabled(true); toggle(1); getListFiles(); @@ -115,7 +115,7 @@ private void getListFiles() { /** * Refresh the backup list */ - public void refresh() { + private void refresh() { Gridview.setAdapter(backupGridviewAdapter); try { backupGridviewAdapter.supportAddAll(files); diff --git a/Atarashii/src/net/somethingdreadful/MAL/Card.java b/Atarashii/src/net/somethingdreadful/MAL/Card.java index e3eafa42..256197b8 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/Card.java +++ b/Atarashii/src/net/somethingdreadful/MAL/Card.java @@ -22,17 +22,16 @@ public class Card extends RelativeLayout { - public boolean center; - public TextView Header; - public ImageView Image; - public CardView Card; - public RelativeLayout Content; + private final boolean center; + public final TextView Header; + private ImageView Image; + private final CardView Card; + private final RelativeLayout Content; - onCardClickListener listener; + private onCardClickListener listener; private int screenWidth; - private int minHeight; - private Float density; - private LayoutInflater inflater; + private final int minHeight; + private final LayoutInflater inflater; public Card(Context context) { this(context, null); @@ -213,7 +212,7 @@ public void setBelowof(Card res, int amount, int screen) { * * @param color The resource id of the color */ - public void setHeaderColor(int color) { + private void setHeaderColor(int color) { GradientDrawable shape = (GradientDrawable) Header.getBackground(); shape.setColor(getResources().getColor(color)); } @@ -275,7 +274,7 @@ public void setWidth(Integer amount, Integer maxWidth) { * @param maxWidth The maximum width in dp * @return int The width that the card should be */ - public int getWidth(Integer amount, Integer maxWidth) { + private int getWidth(Integer amount, Integer maxWidth) { if (amount == 0) amount = 1; int divider = amount - 1; diff --git a/Atarashii/src/net/somethingdreadful/MAL/DateTools.java b/Atarashii/src/net/somethingdreadful/MAL/DateTools.java index 787c2297..b67ccf17 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/DateTools.java +++ b/Atarashii/src/net/somethingdreadful/MAL/DateTools.java @@ -35,19 +35,12 @@ public static String parseDate(String ISO8601, boolean withTime) { * Parse a date with miliseconds. * * @param time The time in miliseconds - * @param withTime Use true when you want also the time (hours & minutes) * @return String The readable string. */ - public static String parseDate(Long time, boolean withTime) { + public static String parseDate(Long time) { Calendar calander = Calendar.getInstance(); calander.setTimeInMillis(time); - return getDateString(calander.getTime(), withTime); - } - - public static Long getmilis(String time) { - Calendar calander = Calendar.getInstance(); - calander.setTime(parseISO8601(time)); - return calander.getTimeInMillis(); + return getDateString(calander.getTime(), true); } private static Date parseISO8601(String ISO8601) { diff --git a/Atarashii/src/net/somethingdreadful/MAL/DetailView.java b/Atarashii/src/net/somethingdreadful/MAL/DetailView.java index 29606b2e..47dc9268 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/DetailView.java +++ b/Atarashii/src/net/somethingdreadful/MAL/DetailView.java @@ -54,13 +54,13 @@ public class DetailView extends AppCompatActivity implements Serializable, Netwo public ListType type; public Anime animeRecord; public Manga mangaRecord; - public String username; - public DetailViewGeneral general; - public DetailViewDetails details; - public DetailViewPersonal personal; + private String username; + private DetailViewGeneral general; + private DetailViewDetails details; + private DetailViewPersonal personal; public DetailViewReviews reviews; - public DetailViewPagerAdapter PageAdapter; - int recordID; + private DetailViewPagerAdapter PageAdapter; + private int recordID; private ActionBar actionBar; private ViewFlipper viewFlipper; private Menu menu; @@ -89,7 +89,7 @@ public void onCreate(Bundle savedInstanceState) { /* * Set text in all fragments */ - public void setText() { + private void setText() { try { actionBar.setTitle(type == ListType.ANIME ? animeRecord.getTitle() : mangaRecord.getTitle()); if (general != null) @@ -113,7 +113,7 @@ public String nullCheck(String string) { return isEmpty(string) ? getString(R.string.unknown) : string; } - public boolean isEmpty(String string) { + private boolean isEmpty(String string) { return ((string == null || string.equals("") || string.equals("0-00-00"))); } @@ -149,7 +149,7 @@ public boolean isAdded() { /* * Set refreshing on all SwipeRefreshViews */ - public void setRefreshing(Boolean show) { + private void setRefreshing(Boolean show) { if (general != null) { general.swipeRefresh.setRefreshing(show); general.swipeRefresh.setEnabled(!show); @@ -302,17 +302,17 @@ public void setMenu() { /* * Add record to list */ - public void addToList() { + private void addToList() { if (!isEmpty()) { if (type.equals(ListType.ANIME)) { - animeRecord.setCreateFlag(true); + animeRecord.setCreateFlag(); // If the anime hasn't aired mark is planned if (animeRecord.getStatusInt() != 2) animeRecord.setWatchedStatus(PrefManager.getAddList()); else animeRecord.setWatchedStatus(GenericRecord.STATUS_PLANTOWATCH); } else { - mangaRecord.setCreateFlag(true); + mangaRecord.setCreateFlag(); mangaRecord.setReadStatus(PrefManager.getAddList()); } PageAdapter.hidePersonal(false); @@ -323,7 +323,7 @@ public void addToList() { /* * Open the share dialog */ - public void Share() { + private void Share() { Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); @@ -334,7 +334,7 @@ public void Share() { /* * Make the share text for the share dialog */ - public String makeShareText() { + private String makeShareText() { String shareText = PrefManager.getCustomShareText(); shareText = shareText.replace("$title;", actionBar.getTitle()); if (AccountService.isMAL()) @@ -379,17 +379,17 @@ public boolean isDone() { /* * Get the translation from strings.xml */ - private String getStringFromResourceArray(int resArrayId, int notFoundStringId, int index) { + private String getStringFromResourceArray(int resArrayId, int index) { Resources res = getResources(); try { String[] types = res.getStringArray(resArrayId); if (index < 0 || index >= types.length) // make sure to have a valid array index - return res.getString(notFoundStringId); + return res.getString(R.string.unknown); else return types[index]; } catch (Resources.NotFoundException e) { Crashlytics.logException(e); - return res.getString(notFoundStringId); + return res.getString(R.string.unknown); } } @@ -398,9 +398,9 @@ private String getStringFromResourceArray(int resArrayId, int notFoundStringId, */ public String getTypeString(int typesInt) { if (type.equals(ListType.ANIME)) - return getStringFromResourceArray(R.array.mediaType_Anime, R.string.unknown, typesInt); + return getStringFromResourceArray(R.array.mediaType_Anime, typesInt); else - return getStringFromResourceArray(R.array.mediaType_Manga, R.string.unknown, typesInt); + return getStringFromResourceArray(R.array.mediaType_Manga, typesInt); } /* @@ -408,9 +408,9 @@ public String getTypeString(int typesInt) { */ public String getStatusString(int statusInt) { if (type.equals(ListType.ANIME)) - return getStringFromResourceArray(R.array.mediaStatus_Anime, R.string.unknown, statusInt); + return getStringFromResourceArray(R.array.mediaStatus_Anime, statusInt); else - return getStringFromResourceArray(R.array.mediaStatus_Manga, R.string.unknown, statusInt); + return getStringFromResourceArray(R.array.mediaStatus_Manga, statusInt); } /* @@ -419,7 +419,7 @@ public String getStatusString(int statusInt) { public ArrayList getGenresString(ArrayList genresInt) { ArrayList genres = new ArrayList<>(); for (Integer genreInt : genresInt) { - genres.add(getStringFromResourceArray(R.array.genresArray, R.string.unknown, genreInt)); + genres.add(getStringFromResourceArray(R.array.genresArray, genreInt)); } return genres; } @@ -428,11 +428,11 @@ public ArrayList getGenresString(ArrayList genresInt) { * Get the anime or manga classification translations */ public String getClassificationString(Integer classificationInt) { - return getStringFromResourceArray(R.array.classificationArray, R.string.unknown, classificationInt); + return getStringFromResourceArray(R.array.classificationArray, classificationInt); } public String getUserStatusString(int statusInt) { - return getStringFromResourceArray(R.array.mediaStatus_User, R.string.unknown, statusInt); + return getStringFromResourceArray(R.array.mediaStatus_User, statusInt); } /* @@ -441,7 +441,7 @@ public String getUserStatusString(int statusInt) { * Try to fetch them from the Database first to get reading/watching details. * If the record doesn't contains a synopsis this method will get it. */ - public void getRecord(boolean forceUpdate) { + private void getRecord(boolean forceUpdate) { setRefreshing(true); toggleLoadingIndicator(isEmpty()); actionBar.setTitle(R.string.layout_card_loading); @@ -496,9 +496,9 @@ public void onMangaDialogDismissed(int value, int value2) { public void onRemoveConfirmed() { if (type.equals(ListType.ANIME)) - animeRecord.setDeleteFlag(true); + animeRecord.setDeleteFlag(); else - mangaRecord.setDeleteFlag(true); + mangaRecord.setDeleteFlag(); finish(); } diff --git a/Atarashii/src/net/somethingdreadful/MAL/FirstTimeInit.java b/Atarashii/src/net/somethingdreadful/MAL/FirstTimeInit.java index 5ee84db9..066e6f50 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/FirstTimeInit.java +++ b/Atarashii/src/net/somethingdreadful/MAL/FirstTimeInit.java @@ -1,5 +1,6 @@ package net.somethingdreadful.MAL; +import android.annotation.SuppressLint; import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; @@ -32,10 +33,10 @@ import butterknife.ButterKnife; public class FirstTimeInit extends AppCompatActivity implements AuthenticationCheckTask.AuthenticationCheckListener, OnClickListener { - String MalUser; - String MalPass; - Context context; - ProgressDialog dialog; + private String MalUser; + private String MalPass; + private Context context; + private ProgressDialog dialog; @Bind(R.id.edittext_malUser) EditText malUser; @@ -54,6 +55,7 @@ public class FirstTimeInit extends AppCompatActivity implements AuthenticationCh @Bind(R.id.anilist) TextView anilist; + @SuppressLint("SetJavaScriptEnabled") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java index a469a9bf..efb38b08 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java +++ b/Atarashii/src/net/somethingdreadful/MAL/ForumActivity.java @@ -42,11 +42,10 @@ public class ForumActivity extends AppCompatActivity implements ForumNetworkTask WebView webview; @Bind(R.id.progress1) ProgressBar progress; - testforumhtmlunit test; - MenuItem search; - Menu menu; - String query; - boolean loading = false; + private testforumhtmlunit test; + private MenuItem search; + private String query; + private boolean loading = false; @SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"}) @Override @@ -75,8 +74,6 @@ public void onPageFinished(WebView view, String url) { @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_forum, menu); - this.menu = menu; - SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); MenuItem searchItem = menu.findItem(R.id.action_search); SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); @@ -229,16 +226,16 @@ public void onUpdated(int number, int id) { } public class testforumhtmlunit { - Context context; + final Context context; @Getter @Setter String forumMenuLayout; - String forumMenuTiles; - String forumListLayout; - String forumListTiles; - String forumCommentsLayout; - String forumCommentsTiles; - String spoilerStructure; + final String forumMenuTiles; + final String forumListLayout; + final String forumListTiles; + final String forumCommentsLayout; + final String forumCommentsTiles; + final String spoilerStructure; @Getter @Setter int id; diff --git a/Atarashii/src/net/somethingdreadful/MAL/Home.java b/Atarashii/src/net/somethingdreadful/MAL/Home.java index f88733f8..847a0757 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/Home.java +++ b/Atarashii/src/net/somethingdreadful/MAL/Home.java @@ -19,7 +19,6 @@ import android.support.v4.view.ViewPager; import android.support.v4.widget.DrawerLayout; import android.support.v4.widget.SwipeRefreshLayout; -import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.SearchView; @@ -49,20 +48,16 @@ import butterknife.ButterKnife; public class Home extends AppCompatActivity implements ChooseDialogFragment.onClickListener, SwipeRefreshLayout.OnRefreshListener, IGF.IGFCallbackListener, APIAuthenticationErrorListener, View.OnClickListener, UserNetworkTask.UserNetworkTaskListener, ViewPager.OnPageChangeListener, NavigationView.OnNavigationItemSelectedListener { - IGF af; - IGF mf; - Menu menu; - Context context; - View mPreviousView; - ActionBar actionBar; - DrawerLayout DrawerLayout; - IGFPagerAdapter mIGFPagerAdapter; - BroadcastReceiver networkReceiver; - - String username; - boolean networkAvailable; - boolean myList = true; //tracks if the user is on 'My List' or not - int callbackCounter = 0; + private IGF af; + private IGF mf; + private Menu menu; + private Context context; + private BroadcastReceiver networkReceiver; + + private String username; + private boolean networkAvailable; + private boolean myList = true; //tracks if the user is on 'My List' or not + private int callbackCounter = 0; @Bind(R.id.navigationView) NavigationView navigationView; @Bind(R.id.drawerLayout) @@ -85,8 +80,8 @@ public void onCreate(Bundle savedInstanceState) { Theme.setTheme(this, R.layout.activity_home, false); //Initializing IGF - mIGFPagerAdapter = (IGFPagerAdapter) Theme.setActionBar(this, new IGFPagerAdapter(getFragmentManager(), true)); - actionBar = getSupportActionBar(); + Theme.setActionBar(this, new IGFPagerAdapter(getFragmentManager(), true)); + getSupportActionBar(); //Initializing ButterKnife ButterKnife.bind(this); @@ -105,14 +100,6 @@ public void onCreate(Bundle savedInstanceState) { //Initializing navigation toggle button drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout); ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, (Toolbar) findViewById(R.id.actionbar), R.string.drawer_open, R.string.drawer_close) { - @Override - public void onDrawerClosed(View drawerView) { - super.onDrawerClosed(drawerView); - } - @Override - public void onDrawerOpened(View drawerView) { - super.onDrawerOpened(drawerView); - } }; drawerLayout.setDrawerListener(drawerToggle); drawerToggle.syncState(); @@ -210,7 +197,7 @@ public boolean onOptionsItemSelected(MenuItem item) { return super.onOptionsItemSelected(item); } - public void getRecords(boolean clear, TaskJob task, int list) { + private void getRecords(boolean clear, TaskJob task, int list) { if (af != null && mf != null) { af.getRecords(clear, task, list); mf.getRecords(clear, task, list); @@ -235,7 +222,7 @@ public void onPause() { unregisterReceiver(networkReceiver); } - public void synctask(boolean clear) { + private void synctask(boolean clear) { getRecords(clear, TaskJob.FORCESYNC, af.list); } @@ -279,11 +266,11 @@ public boolean onPrepareOptionsMenu(Menu menu) { return true; } - public void setChecked(MenuItem item) { + private void setChecked(MenuItem item) { item.setChecked(true); } - public void myListChanged() { + private void myListChanged() { if (menu != null) { menu.findItem(R.id.menu_listType).setVisible(myList); menu.findItem(R.id.menu_inverse).setVisible(myList || (!AccountService.isMAL() && af.taskjob == TaskJob.GETMOSTPOPULAR)); @@ -325,7 +312,7 @@ private void showLogoutDialog() { lcdf.show(getFragmentManager(), "fragment_LogoutConfirmationDialog"); } - public void checkNetworkAndDisplayCrouton() { + private void checkNetworkAndDisplayCrouton() { if (MALApi.isNetworkAvailable(context) && !networkAvailable) synctask(false); networkAvailable = MALApi.isNetworkAvailable(context); @@ -447,7 +434,7 @@ public void onPageScrollStateChanged(int state) {} @Override public void onPositiveButtonClicked() { - AccountService.clearData(true); + AccountService.clearData(); startActivity(new Intent(this, FirstTimeInit.class)); System.exit(0); } diff --git a/Atarashii/src/net/somethingdreadful/MAL/IGF.java b/Atarashii/src/net/somethingdreadful/MAL/IGF.java index da4b913c..59f9cbb0 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/IGF.java +++ b/Atarashii/src/net/somethingdreadful/MAL/IGF.java @@ -52,37 +52,39 @@ public class IGF extends Fragment implements OnScrollListener, OnItemClickListener, NetworkTask.NetworkTaskListener, RecordStatusUpdatedReceiver.RecordStatusUpdatedListener { public ListType listType = ListType.ANIME; // just to have it proper initialized - Context context; + private Context context; public TaskJob taskjob; - Activity activity; - NetworkTask networkTask; - IGFCallbackListener callback; - ListViewAdapter ga; - ArrayList gl = new ArrayList<>(); - - @Bind(R.id.gridview) GridView Gridview; - @Bind(R.id.viewFlipper) ViewFlipper viewflipper; - @Bind(R.id.swiperefresh) SwipeRefreshLayout swipeRefresh; - - RecordStatusUpdatedReceiver recordStatusReceiver; - - int page = 1; + private Activity activity; + private NetworkTask networkTask; + private IGFCallbackListener callback; + private ListViewAdapter ga; + private ArrayList gl = new ArrayList<>(); + + @Bind(R.id.gridview) + GridView Gridview; + @Bind(R.id.viewFlipper) + ViewFlipper viewflipper; + @Bind(R.id.swiperefresh) + SwipeRefreshLayout swipeRefresh; + + private RecordStatusUpdatedReceiver recordStatusReceiver; + + private int page = 1; public int list = -1; - int resource; - int height = 0; - boolean loading = true; - boolean useSecondaryAmounts; - boolean hasmorepages = false; - boolean clearAfterLoading = false; + private int resource; + private int height = 0; + private boolean loading = true; + private boolean useSecondaryAmounts; + private boolean hasmorepages = false; + private boolean clearAfterLoading = false; /* setSwipeRefreshEnabled() may be called before swipeRefresh exists (before onCreateView() is * called), so save it and apply it in onCreateView() */ - boolean swipeRefreshEnabled = true; + private boolean swipeRefreshEnabled = true; - String query; + private String query; // use setter to change this! private String username; - private boolean ownList = false; // not set directly, is set by setUsername() public boolean popup; @Override @@ -129,12 +131,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle st if (isOnHomeActivity()) swipeRefresh.setOnRefreshListener((Home) getActivity()); - swipeRefresh.setColorScheme( - android.R.color.holo_blue_bright, - android.R.color.holo_green_light, - android.R.color.holo_orange_light, - android.R.color.holo_red_light - ); + swipeRefresh.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); swipeRefresh.setEnabled(swipeRefreshEnabled); if (gl.size() > 0) // there are already records, fragment has been rotated @@ -169,7 +166,7 @@ public void onDetach() { * Set the numbers columns for the best overview. */ @SuppressLint("InlinedApi") - public void setColumns() { + private void setColumns() { int screenWidth = Theme.convert(context.getResources().getConfiguration().screenWidthDp); if (PrefManager.getTraditionalListEnabled()) { Gridview.setNumColumns(1); //remain in the listview mode @@ -233,7 +230,7 @@ private boolean isOnHomeActivity() { * @param anime The Anime record that should increase by one * @param manga The manga record that should increase by one */ - public void setProgressPlusOne(Anime anime, Manga manga) { + private void setProgressPlusOne(Anime anime, Manga manga) { if (listType.equals(ListType.ANIME)) { anime.setWatchedEpisodes(anime.getWatchedEpisodes() + 1); new WriteDetailTask(listType, TaskJob.UPDATE, context, getAuthErrorCallback(), activity).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, anime); @@ -252,7 +249,7 @@ public void setProgressPlusOne(Anime anime, Manga manga) { * @param anime The Anime record that should be marked as complete * @param manga The manga record that should be marked as complete */ - public void setMarkAsComplete(Anime anime, Manga manga) { + private void setMarkAsComplete(Anime anime, Manga manga) { if (listType.equals(ListType.ANIME)) { anime.setWatchedStatus(GenericRecord.STATUS_COMPLETED); gl.remove(anime); @@ -341,7 +338,7 @@ public void getRecords(boolean clear, TaskJob task, int list) { Bundle data = new Bundle(); data.putInt("page", page); networkTask = new NetworkTask(taskjob, listType, activity, data, this, getAuthErrorCallback()); - ArrayList args = new ArrayList(); + ArrayList args = new ArrayList<>(); if (!username.equals("") && isList()) { args.add(username); if (isList()) @@ -373,7 +370,7 @@ public void searchRecords(String search) { /** * Reset the page number of anime/manga lists. */ - public void resetPage() { + private void resetPage() { page = 1; if (Gridview != null) { Gridview.requestFocusFromTouch(); @@ -389,15 +386,15 @@ public void run() { /** * Set the adapter anime/manga. */ - public void setAdapter() { - ga = new ListViewAdapter(context, resource, popup); + private void setAdapter() { + ga = new ListViewAdapter<>(context, resource, popup); ga.setNotifyOnChange(true); } /** * Refresh all the covers. */ - public void refresh() { + private void refresh() { try { filterTime(); if (ga == null) @@ -431,7 +428,7 @@ public void refresh() { * @param job The current taskjob to compare with * @return boolean If true then the list is of the logged in user */ - public boolean isList(TaskJob job) { + private boolean isList(TaskJob job) { return job != null && (job.equals(TaskJob.GETLIST) || job.equals(TaskJob.FORCESYNC)); } @@ -440,7 +437,7 @@ public boolean isList(TaskJob job) { * * @return boolean If true then the list is of the logged in user */ - public boolean isList() { + private boolean isList() { return isList(taskjob); } @@ -467,7 +464,7 @@ public void inverse() { */ private void filterTime() { if (!AccountService.isMAL() && taskjob == TaskJob.GETMOSTPOPULAR && PrefManager.getAiringOnly() && listType == ListType.ANIME) { - ArrayList record = new ArrayList(); + ArrayList record = new ArrayList<>(); for (GenericRecord gr : gl) if (((Anime) gr).getAiring() != null) record.add(gr); @@ -584,7 +581,6 @@ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCoun */ public void setUsername(String username) { this.username = username; - ownList = !(username == null || username.equals("")) && AccountService.getUsername().equals(username); } // user updated record on DetailsView, so update the list if necessary @@ -622,7 +618,7 @@ static class ViewHolder { * The custom adapter for the covers anime/manga. */ public class ListViewAdapter extends ArrayAdapter { - boolean popup; + final boolean popup; public ListViewAdapter(Context context, int resource, boolean popup) { super(context, resource); diff --git a/Atarashii/src/net/somethingdreadful/MAL/MALManager.java b/Atarashii/src/net/somethingdreadful/MAL/MALManager.java index 3c33750c..2658eabe 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/MALManager.java +++ b/Atarashii/src/net/somethingdreadful/MAL/MALManager.java @@ -25,10 +25,9 @@ import java.util.Comparator; public class MALManager { - MALApi malApi; - ALApi alApi; - DatabaseManager dbMan; - Context context; + private MALApi malApi; + private ALApi alApi; + private final DatabaseManager dbMan; public MALManager(Context context) { if (AccountService.isMAL()) @@ -36,7 +35,6 @@ public MALManager(Context context) { else alApi = new ALApi(); dbMan = new DatabaseManager(context); - this.context = context; } public static String listSortFromInt(int i, MALApi.ListType type) { @@ -189,17 +187,9 @@ public void saveMangaToDatabase(Manga manga) { } public boolean cleanDirtyAnimeRecords() { - return cleanDirtyAnimeRecords(true); - } - - public boolean cleanDirtyMangaRecords() { - return cleanDirtyMangaRecords(true); - } - - public boolean cleanDirtyAnimeRecords(boolean dirtyOnly) { boolean totalSuccess = true; - ArrayList dirtyAnimes = dirtyOnly ? dbMan.getDirtyAnimeList() : getAnimeListFromDB(MALApi.ListType.ANIME.toString()); + ArrayList dirtyAnimes = dbMan.getDirtyAnimeList(); if (dirtyAnimes != null) { Crashlytics.log(Log.VERBOSE, "MALX", "MALManager.cleanDirtyAnimeRecords(): Got " + dirtyAnimes.size() + " dirty anime records. Cleaning.."); @@ -219,10 +209,10 @@ public boolean cleanDirtyAnimeRecords(boolean dirtyOnly) { return totalSuccess; } - public boolean cleanDirtyMangaRecords(boolean dirtyOnly) { + public boolean cleanDirtyMangaRecords() { boolean totalSuccess = true; - ArrayList dirtyMangas = dirtyOnly ? dbMan.getDirtyMangaList() : getMangaListFromDB(MALApi.ListType.MANGA.toString()); + ArrayList dirtyMangas = dbMan.getDirtyMangaList(); if (dirtyMangas != null) { Crashlytics.log(Log.VERBOSE, "MALX", "MALManager.cleanDirtyMangaRecords(): Got " + dirtyMangas.size() + " dirty manga records. Cleaning.."); diff --git a/Atarashii/src/net/somethingdreadful/MAL/PrefManager.java b/Atarashii/src/net/somethingdreadful/MAL/PrefManager.java index 087162b8..22f868ae 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/PrefManager.java +++ b/Atarashii/src/net/somethingdreadful/MAL/PrefManager.java @@ -1,5 +1,6 @@ package net.somethingdreadful.MAL; +import android.annotation.SuppressLint; import android.content.Context; import android.content.SharedPreferences; import android.preference.PreferenceManager; @@ -10,9 +11,9 @@ public class PrefManager { private static SharedPreferences prefs; private static SharedPreferences.Editor prefEditor; private static Context context; - private static boolean darkTheme; + @SuppressLint("CommitPrefEdits") public static void create(Context mContext) { context = mContext; prefs = PreferenceManager.getDefaultSharedPreferences(context); diff --git a/Atarashii/src/net/somethingdreadful/MAL/ProfileActivity.java b/Atarashii/src/net/somethingdreadful/MAL/ProfileActivity.java index 4af2e77b..6326dfd0 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/ProfileActivity.java +++ b/Atarashii/src/net/somethingdreadful/MAL/ProfileActivity.java @@ -28,17 +28,18 @@ import butterknife.ButterKnife; public class ProfileActivity extends AppCompatActivity implements UserNetworkTask.UserNetworkTaskListener { - Context context; + private Context context; public Profile record; - ProfileFriends friends; - ProfileDetailsAL detailsAL; - ProfileDetailsMAL detailsMAL; - ProfileHistory history; - boolean isLoading = false; + private ProfileFriends friends; + private ProfileDetailsAL detailsAL; + private ProfileDetailsMAL detailsMAL; + private ProfileHistory history; + private boolean isLoading = false; - @Bind(R.id.pager) ViewPager viewPager; + @Bind(R.id.pager) + ViewPager viewPager; - boolean forcesync = false; + private final boolean forcesync = false; @Override protected void onCreate(Bundle bundle) { @@ -107,11 +108,11 @@ public boolean onOptionsItemSelected(MenuItem item) { return true; } - public String getProfileURL() { + private String getProfileURL() { return AccountService.isMAL() ? "http://myanimelist.net/profile/" : "http://anilist.co/user/"; } - public void refresh() { + private void refresh() { if (record == null) { if (MALApi.isNetworkAvailable(context)) { Theme.Snackbar(this, R.string.toast_error_UserRecord); @@ -145,7 +146,7 @@ record = result; isLoading = false; } - public void setText() { + private void setText() { if (detailsMAL != null) detailsMAL.refresh(); if (detailsAL != null) @@ -201,7 +202,7 @@ public void setFriends(ProfileFriends friends) { viewPager.setCurrentItem(1); } - public void toggle(int number) { + private void toggle(int number) { if (detailsMAL != null) detailsMAL.toggle(number); if (detailsAL != null) diff --git a/Atarashii/src/net/somethingdreadful/MAL/SearchActivity.java b/Atarashii/src/net/somethingdreadful/MAL/SearchActivity.java index 2e780dd2..a9b2e50a 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/SearchActivity.java +++ b/Atarashii/src/net/somethingdreadful/MAL/SearchActivity.java @@ -26,22 +26,14 @@ public class SearchActivity extends AppCompatActivity implements IGF.IGFCallbackListener { public String query; - IGF af; - IGF mf; - IGFPagerAdapter mIGFPagerAdapter; - SearchView searchView; - - boolean callbackAnimeError = false; - boolean callbackMangaError = false; - boolean callbackAnimeResultEmpty = false; - boolean callbackMangaResultEmpty = false; - int callbackCounter = 0; + private IGF af; + private IGF mf; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.theme_viewpager); - mIGFPagerAdapter = (IGFPagerAdapter) Theme.setActionBar(this, new IGFPagerAdapter(getFragmentManager(), true)); + Theme.setActionBar(this, new IGFPagerAdapter(getFragmentManager(), true)); } @Override @@ -66,9 +58,6 @@ private void handleIntent(Intent intent) { FragmentManager fm = getFragmentManager(); (new SearchIdDialogFragment()).show(fm, "fragment_id_search"); } else { - if (searchView != null) { - searchView.setQuery(query, false); - } if (af != null && mf != null) { af.searchRecords(query); mf.searchRecords(query); diff --git a/Atarashii/src/net/somethingdreadful/MAL/SettingsFragment.java b/Atarashii/src/net/somethingdreadful/MAL/SettingsFragment.java index f4187f93..3b4aaa8e 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/SettingsFragment.java +++ b/Atarashii/src/net/somethingdreadful/MAL/SettingsFragment.java @@ -20,7 +20,7 @@ public class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener, Preference.OnPreferenceClickListener, NumberPickerDialogFragment.onUpdateClickListener { private Context context; - AlarmManager alarmMgr; + private AlarmManager alarmMgr; @Override public void onCreate(Bundle savedInstanceState) { @@ -132,7 +132,7 @@ public boolean onPreferenceClick(Preference preference) { return false; } - public void makeNumberpicker(Bundle bundle) { + private void makeNumberpicker(Bundle bundle) { NumberPickerDialogFragment numberPickerDialogFragment = new NumberPickerDialogFragment().setOnSendClickListener(this); numberPickerDialogFragment.setArguments(bundle); numberPickerDialogFragment.show(getActivity().getFragmentManager(), "numberPickerDialogFragment"); diff --git a/Atarashii/src/net/somethingdreadful/MAL/Theme.java b/Atarashii/src/net/somethingdreadful/MAL/Theme.java index ae847715..e983436d 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/Theme.java +++ b/Atarashii/src/net/somethingdreadful/MAL/Theme.java @@ -35,8 +35,8 @@ public class Theme extends Application { public static boolean darkTheme; private static float density; - Locale locale; - Configuration config; + private Locale locale; + private Configuration config; static Context context; @Override @@ -98,7 +98,7 @@ public static boolean isPortrait() { /** * Changes the language to the preferred one. */ - public void setLanguage() { + private void setLanguage() { Resources res = getBaseContext().getResources(); res.updateConfiguration(config, res.getDisplayMetrics()); } diff --git a/Atarashii/src/net/somethingdreadful/MAL/account/AccountService.java b/Atarashii/src/net/somethingdreadful/MAL/account/AccountService.java index 1313675d..3a9cc50f 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/account/AccountService.java +++ b/Atarashii/src/net/somethingdreadful/MAL/account/AccountService.java @@ -27,7 +27,7 @@ public class AccountService extends Service { /** * The account version will be used to peform */ - private static int accountVersion = 2; + private static final int accountVersion = 2; public static void create(Context context) { AccountService.context = context; @@ -116,7 +116,7 @@ public static boolean isMAL() { * @param type The authToken string * @return AccountType The type of account */ - public static AccountType getAccountType(String type) { + private static AccountType getAccountType(String type) { if (AccountType.AniList.toString().equals(type)) return AccountType.AniList; else @@ -126,7 +126,7 @@ public static AccountType getAccountType(String type) { /** * Removes an account from the accountmanager. */ - public static void deleteAccount() { + private static void deleteAccount() { AccountManager accountManager = AccountManager.get(context); accountManager.removeAccount(getAccount(), null, null); account = null; @@ -188,7 +188,7 @@ public static String getAccesToken() { * * @param accountVersion The new accountversion of the account that will be saved */ - public static void setAccountVersion(int accountVersion) { + private static void setAccountVersion(int accountVersion) { if (account != null) { AccountManager accountManager = AccountManager.get(context); accountManager.setUserData(account, "accountVersion", String.valueOf(accountVersion)); @@ -215,13 +215,10 @@ public static String getRefreshToken() { /** * Removes the userdata - * - * @param prefs If true it will remove all the prefrences saved. */ - public static void clearData(boolean prefs) { + public static void clearData() { DatabaseTest.deleteDatabase(context); - if (prefs) - PrefManager.clear(); + PrefManager.clear(); Mobihelp.clearUserData(context); AccountService.deleteAccount(); } diff --git a/Atarashii/src/net/somethingdreadful/MAL/adapters/BackupGridviewAdapter.java b/Atarashii/src/net/somethingdreadful/MAL/adapters/BackupGridviewAdapter.java index 1adc62e9..1ce85010 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/adapters/BackupGridviewAdapter.java +++ b/Atarashii/src/net/somethingdreadful/MAL/adapters/BackupGridviewAdapter.java @@ -23,10 +23,10 @@ import java.util.Collections; public class BackupGridviewAdapter extends ArrayAdapter { - private Context context; + private final Context context; private ArrayList list; - private String username; - private onClickListener onClickListener; + private final String username; + private final onClickListener onClickListener; public BackupGridviewAdapter(Context context, ArrayList list, onClickListener onClickListener) { super(context, R.layout.record_friends_gridview); @@ -75,7 +75,7 @@ public void onClick(View v) { try { viewHolder.username.setText(fileName.substring(fileName.indexOf('_') + 1).replace(".json", "")); - viewHolder.last_online.setText(DateTools.parseDate(Long.parseLong(fileName.substring(6, fileName.indexOf('_'))), true)); + viewHolder.last_online.setText(DateTools.parseDate(Long.parseLong(fileName.substring(6, fileName.indexOf('_'))))); if (!username.equals(viewHolder.username.getText())) viewHolder.username.setTextColor(context.getResources().getColor(R.color.card_red)); else diff --git a/Atarashii/src/net/somethingdreadful/MAL/adapters/DetailViewPagerAdapter.java b/Atarashii/src/net/somethingdreadful/MAL/adapters/DetailViewPagerAdapter.java index 4e3002c8..b2c6b8ed 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/adapters/DetailViewPagerAdapter.java +++ b/Atarashii/src/net/somethingdreadful/MAL/adapters/DetailViewPagerAdapter.java @@ -16,23 +16,21 @@ import net.somethingdreadful.MAL.detailView.DetailViewReviews; public class DetailViewPagerAdapter extends FragmentPagerAdapter { - public int count; - boolean hidePersonal = false; - DetailView activity; - int maxCount = 4; - FragmentManager fm; + private int count; + private boolean hidePersonal = false; + private final DetailView activity; + private int maxCount = 4; public ViewGroup container; private long fragmentId = 0; public DetailViewPagerAdapter(FragmentManager fm, DetailView activity) { super(fm); - this.fm = fm; this.activity = activity; this.maxCount = MALApi.isNetworkAvailable(activity) ? maxCount : maxCount - 1; this.count = getMaxcount(); } - public int getMaxcount() { + private int getMaxcount() { return maxCount; } @@ -107,7 +105,7 @@ public long getItemId(int position) { * * @param number number of items which have been changed */ - public void notifyChangeInPosition(int number) { + private void notifyChangeInPosition(int number) { fragmentId += getCount() + number; } } \ No newline at end of file diff --git a/Atarashii/src/net/somethingdreadful/MAL/adapters/DetailViewRelationsAdapter.java b/Atarashii/src/net/somethingdreadful/MAL/adapters/DetailViewRelationsAdapter.java index fd516b89..66d815e7 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/adapters/DetailViewRelationsAdapter.java +++ b/Atarashii/src/net/somethingdreadful/MAL/adapters/DetailViewRelationsAdapter.java @@ -16,11 +16,11 @@ import java.util.Map; public class DetailViewRelationsAdapter extends BaseExpandableListAdapter { - public Map> list = new LinkedHashMap>(); - public ArrayList headers = new ArrayList<>(); + private final Map> list = new LinkedHashMap<>(); + public final ArrayList headers = new ArrayList<>(); public int visable; - ViewHolder viewHolder; - private Context context; + private ViewHolder viewHolder; + private final Context context; public DetailViewRelationsAdapter(Context context) { this.context = context; @@ -72,7 +72,7 @@ public RecordStub getRecordStub(int groupPos, int childPos) { */ public void addTitles(ArrayList strings, String header) { if (strings != null) { - ArrayList records = new ArrayList(); + ArrayList records = new ArrayList<>(); for (String stub : strings) { RecordStub record = new RecordStub(); record.setTitle(stub); @@ -90,7 +90,7 @@ public void addTitles(ArrayList strings, String header) { */ public void addRelations(RecordStub recordStub, String header) { if (recordStub != null) { - ArrayList record = new ArrayList(); + ArrayList record = new ArrayList<>(); record.add(recordStub); addRelations(record, header); } diff --git a/Atarashii/src/net/somethingdreadful/MAL/adapters/ForumMainAdapter.java b/Atarashii/src/net/somethingdreadful/MAL/adapters/ForumMainAdapter.java deleted file mode 100644 index 3d55954d..00000000 --- a/Atarashii/src/net/somethingdreadful/MAL/adapters/ForumMainAdapter.java +++ /dev/null @@ -1,98 +0,0 @@ -package net.somethingdreadful.MAL.adapters; - -import android.app.Activity; -import android.app.FragmentManager; -import android.content.Context; -import android.os.Bundle; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ArrayAdapter; -import android.widget.ImageView; -import android.widget.ListView; -import android.widget.TextView; - -import com.crashlytics.android.Crashlytics; - -import net.somethingdreadful.MAL.R; -import net.somethingdreadful.MAL.Theme; -import net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Forum; -import net.somethingdreadful.MAL.dialog.InformationDialogFragment; -import net.somethingdreadful.MAL.tasks.ForumJob; - -import java.util.Collection; - -public class ForumMainAdapter extends ArrayAdapter { - private Context context; - private FragmentManager fm; - private ListView listview; - private ForumJob task; - - public ForumMainAdapter(Activity context, ListView listview, FragmentManager fm, ForumJob task) { - super(context, R.layout.record_forum_listview); - this.context = context; - this.listview = listview; - this.fm = fm; - this.task = task; - } - - public View getView(int position, View view, ViewGroup parent) { - final Forum record = ((Forum) this.getItem(position)); - ViewHolder viewHolder; - - if (view == null) { - LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); - view = inflater.inflate(R.layout.record_forum_listview, parent, false); - - viewHolder = new ViewHolder(); - viewHolder.title = (TextView) view.findViewById(R.id.title); - viewHolder.image = (ImageView) view.findViewById(R.id.Image); - - if (Theme.darkTheme) { - viewHolder.title.setTextColor(context.getResources().getColor(R.color.text_dark)); - Theme.setBackground(context, viewHolder.image); - Theme.setBackground(context, view); - } - - view.setTag(viewHolder); - } else { - viewHolder = (ViewHolder) view.getTag(); - } - - try { - viewHolder.title.setText(record.getName()); - if (record.getReply() != null || record.getDescription() != null) { - viewHolder.image.setVisibility(View.VISIBLE); - viewHolder.image.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - InformationDialogFragment info = new InformationDialogFragment(); - Bundle args = new Bundle(); - args.putString("title", record.getName()); - info.setArguments(args); - info.show(fm, "fragment_forum"); - - } - }); - } else { - viewHolder.image.setVisibility(View.GONE); - } - } catch (Exception e) { - Crashlytics.log(Log.ERROR, "MALX", "ForumActivity.ListViewAdapter(): " + e.getMessage()); - Crashlytics.logException(e); - } - return view; - } - - public void supportAddAll(Collection collection) { - for (T record : collection) { - this.add(record); - } - } - - static class ViewHolder { - TextView title; - ImageView image; - } -} \ No newline at end of file diff --git a/Atarashii/src/net/somethingdreadful/MAL/adapters/FriendsGridviewAdapter.java b/Atarashii/src/net/somethingdreadful/MAL/adapters/FriendsGridviewAdapter.java index 508e00bf..935d48bb 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/adapters/FriendsGridviewAdapter.java +++ b/Atarashii/src/net/somethingdreadful/MAL/adapters/FriendsGridviewAdapter.java @@ -26,7 +26,7 @@ import java.util.Collection; public class FriendsGridviewAdapter extends ArrayAdapter { - private Context context; + private final Context context; private ArrayList list; public FriendsGridviewAdapter(Context context, ArrayList list) { diff --git a/Atarashii/src/net/somethingdreadful/MAL/adapters/IGFPagerAdapter.java b/Atarashii/src/net/somethingdreadful/MAL/adapters/IGFPagerAdapter.java index aa1ef068..27205c8d 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/adapters/IGFPagerAdapter.java +++ b/Atarashii/src/net/somethingdreadful/MAL/adapters/IGFPagerAdapter.java @@ -9,8 +9,8 @@ import net.somethingdreadful.MAL.api.MALApi; public class IGFPagerAdapter extends FragmentPagerAdapter { - FragmentManager fm; - boolean popup = true; + private final FragmentManager fm; + private boolean popup = true; /** * Init page adapter @@ -46,7 +46,7 @@ public CharSequence getPageTitle(int position) { return MALApi.getListTypeString(getTag(position)).toUpperCase(); } - public MALApi.ListType getTag(int position) { + private MALApi.ListType getTag(int position) { switch (position) { case 0: return MALApi.ListType.ANIME; diff --git a/Atarashii/src/net/somethingdreadful/MAL/adapters/ProfilePagerAdapter.java b/Atarashii/src/net/somethingdreadful/MAL/adapters/ProfilePagerAdapter.java index 2b18afe6..08600005 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/adapters/ProfilePagerAdapter.java +++ b/Atarashii/src/net/somethingdreadful/MAL/adapters/ProfilePagerAdapter.java @@ -13,7 +13,7 @@ import net.somethingdreadful.MAL.profile.ProfileHistory; public class ProfilePagerAdapter extends FragmentPagerAdapter { - ProfileActivity activity; + private final ProfileActivity activity; public ProfilePagerAdapter(FragmentManager fm, ProfileActivity activity) { super(fm); diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/ALApi.java b/Atarashii/src/net/somethingdreadful/MAL/api/ALApi.java index a6269539..02225c88 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/ALApi.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/ALApi.java @@ -30,14 +30,14 @@ import retrofit.converter.GsonConverter; public class ALApi { - private static String anilistURL = "http://anilist.co/api"; + private static final String anilistURL = "http://anilist.co/api"; private static String accesToken; //It's not best practice to use internals, but there is no other good way to get the OkHttp default UA private static final String okUa = com.squareup.okhttp.internal.Version.userAgent(); private static final String USER_AGENT = "Atarashii! (Linux; Android " + Build.VERSION.RELEASE + "; " + Build.MODEL + " Build/" + Build.DISPLAY + ") " + okUa; - ALInterface service; + private ALInterface service; public ALApi() { setupRESTService(); diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/ALInterface.java b/Atarashii/src/net/somethingdreadful/MAL/api/ALInterface.java index 8d8f3ac4..cfb2a45d 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/ALInterface.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/ALInterface.java @@ -23,7 +23,7 @@ import retrofit.http.Path; import retrofit.http.Query; -public interface ALInterface { +interface ALInterface { @FormUrlEncoded @POST("/auth/access_token") OAuth getAuthCode(@Field("grant_type") String grant_type, @Field("client_id") String client_id, @Field("client_secret") String client_secret, diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/ALModels/AnimeManga/GenericRecord.java b/Atarashii/src/net/somethingdreadful/MAL/api/ALModels/AnimeManga/GenericRecord.java index f429abb5..73cc7d1f 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/ALModels/AnimeManga/GenericRecord.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/ALModels/AnimeManga/GenericRecord.java @@ -173,7 +173,7 @@ public class GenericRecord implements Serializable { @Setter private ArrayList genres; - public net.somethingdreadful.MAL.api.BaseModels.AnimeManga.GenericRecord createGeneralBaseModel(net.somethingdreadful.MAL.api.BaseModels.AnimeManga.GenericRecord model) { + net.somethingdreadful.MAL.api.BaseModels.AnimeManga.GenericRecord createGeneralBaseModel(net.somethingdreadful.MAL.api.BaseModels.AnimeManga.GenericRecord model) { model.setId(getId()); model.setTitle(getTitleRomaji()); model.setTitleEnglish(createTitleArray(getTitleEnglish())); @@ -192,7 +192,7 @@ public net.somethingdreadful.MAL.api.BaseModels.AnimeManga.GenericRecord createG return model; } - public ArrayList createTitleArray(String title) { + private ArrayList createTitleArray(String title) { ArrayList titleArray = new ArrayList<>(); titleArray.add(title); return titleArray; diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/ALModels/AnimeManga/Reviews.java b/Atarashii/src/net/somethingdreadful/MAL/api/ALModels/AnimeManga/Reviews.java index d0da478e..c36d5b89 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/ALModels/AnimeManga/Reviews.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/ALModels/AnimeManga/Reviews.java @@ -47,7 +47,7 @@ public class Reviews implements Serializable { @Getter private Manga manga; - public net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Reviews createBaseModel() { + private net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Reviews createBaseModel() { net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Reviews model = new net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Reviews(); model.setId(getId()); model.setRating(getUserRating()); diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/ALModels/Follow.java b/Atarashii/src/net/somethingdreadful/MAL/api/ALModels/Follow.java index 0caea306..fe0c5206 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/ALModels/Follow.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/ALModels/Follow.java @@ -27,7 +27,7 @@ public class Follow implements Serializable { @SerializedName("image_url_med") private String imageUrlMed; - public Profile createBaseModel() { + private Profile createBaseModel() { net.somethingdreadful.MAL.api.BaseModels.Profile model = new net.somethingdreadful.MAL.api.BaseModels.Profile(); model.setUsername(getDisplayName()); model.setImageUrl(getImageUrlLge()); diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/ALModels/History.java b/Atarashii/src/net/somethingdreadful/MAL/api/ALModels/History.java index 0d330bdc..e46da0d9 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/ALModels/History.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/ALModels/History.java @@ -109,7 +109,7 @@ private class Series { private String type; } - public net.somethingdreadful.MAL.api.BaseModels.History createBaseModel(String username) { + private net.somethingdreadful.MAL.api.BaseModels.History createBaseModel(String username) { net.somethingdreadful.MAL.api.BaseModels.History model = new net.somethingdreadful.MAL.api.BaseModels.History(); if (getSeries() != null && getSeries().getSeriesType() != null) { if (getSeries().getSeriesType().equals("anime")) { diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/Anime.java b/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/Anime.java index 9d4a0f25..41c284b8 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/Anime.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/Anime.java @@ -346,7 +346,7 @@ public void setRewatchValue(int rewatchValue) { this.rewatchValue = rewatchValue; } - public void checkProgress() { + private void checkProgress() { boolean completed = false; boolean started = false; @@ -459,7 +459,7 @@ public boolean getRewatching() { return rewatching; } - public void setRewatching(int cv) { + private void setRewatching(int cv) { rewatching = cv == 1; } diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/GenericRecord.java b/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/GenericRecord.java index 83edc24a..e92c137f 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/GenericRecord.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/GenericRecord.java @@ -35,13 +35,13 @@ public class GenericRecord implements Serializable { public static final String STATUS_REREADING = "rereading"; public static final String STATUS_PLANTOREAD = "plan to read"; - String[] genresList = {"Action", "Adventure", "Cars", "Comedy", "Dementia", "Demons", "Drama", + private final String[] genresList = {"Action", "Adventure", "Cars", "Comedy", "Dementia", "Demons", "Drama", "Ecchi", "Fantasy", "Game", "Harem", "Hentai", "Historical", "Horror", "Josei", "Kids", "Magic", "Martial Arts", "Mecha", "Military", "Music", "Mystery", "Parody", "Police", "Psychological", "Romance", "Samurai", "School", "Sci-Fi", "Seinen", "Shoujo", "Shoujo Ai", "Shounen", "Shounen Ai", "Slice of Life", "Space", "Sports", "Super Power", "Supernatural", "Thriller", "Vampire", "Yaoi", "Yuri"}; - String[] statusList = {"completed", "on-hold", "dropped", "watching", "plan to watch", "reading", "plan to read"}; + private final String[] statusList = {"completed", "on-hold", "dropped", "watching", "plan to watch", "reading", "plan to read"}; /** * The ID of the record @@ -312,15 +312,15 @@ private void setCreateFlag(int createFlag) { this.createFlag = createFlag == 1; } - public void setDeleteFlag(boolean deleteFlag) { - this.deleteFlag = deleteFlag; + public void setDeleteFlag() { + this.deleteFlag = true; } - public void setCreateFlag(boolean createFlag) { - this.createFlag = createFlag; + public void setCreateFlag() { + this.createFlag = true; } - public void addDirtyField(String field) { + void addDirtyField(String field) { if (dirty == null) dirty = new ArrayList<>(); if (!dirty.contains((field))) @@ -332,7 +332,7 @@ public void clearDirty() { } public ArrayList getGenresInt() { - ArrayList result = new ArrayList(); + ArrayList result = new ArrayList<>(); if (getGenres() != null) for (String genre : getGenres()) result.add(Arrays.asList(genresList).indexOf(genre)); @@ -372,7 +372,7 @@ private Field getField(Class c, String property) { } } - protected Object getPropertyValue(String property) { + private Object getPropertyValue(String property) { try { Field field = getField(this.getClass(), property); if (field != null) { @@ -405,7 +405,7 @@ public String getArrayPropertyValue(String property) { return (String) value; } - public int getUserStatusInt(String statusString) { + int getUserStatusInt(String statusString) { return Arrays.asList(statusList).indexOf(statusString); } @@ -417,7 +417,7 @@ public void setPersonalTags(ArrayList tags) { this.tags = tags; } - public static GenericRecord fromCursor(GenericRecord result, Cursor cursor, List columnNames) { + static GenericRecord fromCursor(GenericRecord result, Cursor cursor, List columnNames) { GenericRecord.setFromCursor(true); result.setId(cursor.getInt(columnNames.indexOf(DatabaseTest.COLUMN_ID))); result.setTitle(cursor.getString(columnNames.indexOf("title"))); diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/Manga.java b/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/Manga.java index c77406a0..b64f036b 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/Manga.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/AnimeManga/Manga.java @@ -194,7 +194,7 @@ public void setRereadValue(int rereadValue) { this.rereadValue = rereadValue; } - public void checkProgress() { + private void checkProgress() { boolean completed = false; boolean started = false; diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/Profile.java b/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/Profile.java index 606dd823..6c7f3b28 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/Profile.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/BaseModels/Profile.java @@ -18,8 +18,8 @@ public class Profile implements Serializable { /** * List of developers. */ - static String[] developersMAL = {"ratan12", "motoko"}; - static String[] developersAL = {"ratan12", "motokoaoyama"}; + private static final String[] developersMAL = {"ratan12", "motoko"}; + private static final String[] developersAL = {"ratan12", "motokoaoyama"}; /** * The username of the requested profile. diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/MALInterface.java b/Atarashii/src/net/somethingdreadful/MAL/api/MALInterface.java index 516aa859..86e24f62 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/MALInterface.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/MALInterface.java @@ -22,7 +22,7 @@ import retrofit.http.Path; import retrofit.http.Query; -public interface MALInterface { +interface MALInterface { @GET("/account/verify_credentials") Response verifyAuthentication(); diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/AnimeManga/GenericRecord.java b/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/AnimeManga/GenericRecord.java index 989938ce..e0071bd2 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/AnimeManga/GenericRecord.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/AnimeManga/GenericRecord.java @@ -158,7 +158,7 @@ public class GenericRecord implements Serializable { @SerializedName("personal_comments") private String personalComments; - public net.somethingdreadful.MAL.api.BaseModels.AnimeManga.GenericRecord createGeneralBaseModel(net.somethingdreadful.MAL.api.BaseModels.AnimeManga.GenericRecord model) { + net.somethingdreadful.MAL.api.BaseModels.AnimeManga.GenericRecord createGeneralBaseModel(net.somethingdreadful.MAL.api.BaseModels.AnimeManga.GenericRecord model) { model.setId(getId()); model.setTitle(getTitle()); // MAL is using default romaji model.setTitleEnglish(getOtherTitles().get("english")); @@ -183,13 +183,13 @@ public net.somethingdreadful.MAL.api.BaseModels.AnimeManga.GenericRecord createG return model; } - public ArrayList getTitleArray() { + private ArrayList getTitleArray() { ArrayList title = new ArrayList<>(); title.add(getTitle()); return title; } - public String getImageUrl() { + private String getImageUrl() { if (imageUrl != null) return imageUrl.replace("t.jpg", "l.jpg"); else diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/AnimeManga/Reviews.java b/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/AnimeManga/Reviews.java index f0a0efb1..17ac72d6 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/AnimeManga/Reviews.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/AnimeManga/Reviews.java @@ -93,7 +93,7 @@ public class Reviews implements Serializable { @Getter private String review; - public net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Reviews createBaseModel() { + private net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Reviews createBaseModel() { net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Reviews model = new net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Reviews(); model.setDate(getDate()); model.setRating(getRating()); diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/Friend.java b/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/Friend.java index a4a7928c..e731bce9 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/Friend.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/Friend.java @@ -34,7 +34,7 @@ public class Friend implements Serializable { @Setter private Profile profile; - public net.somethingdreadful.MAL.api.BaseModels.Profile createBaseModel() { + private net.somethingdreadful.MAL.api.BaseModels.Profile createBaseModel() { net.somethingdreadful.MAL.api.BaseModels.Profile model = new net.somethingdreadful.MAL.api.BaseModels.Profile(); model.setUsername(getName()); model.setImageUrl(getProfile().getAvatarUrl()); diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/History.java b/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/History.java index 4c4cc395..cc079f1f 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/History.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/MALModels/History.java @@ -82,7 +82,7 @@ class Series { private String timeUpdated; } - public net.somethingdreadful.MAL.api.BaseModels.History createBaseModel(String username) { + private net.somethingdreadful.MAL.api.BaseModels.History createBaseModel(String username) { net.somethingdreadful.MAL.api.BaseModels.History model = new net.somethingdreadful.MAL.api.BaseModels.History(); if (type.equals("anime")) { model.setAnime(new Anime()); diff --git a/Atarashii/src/net/somethingdreadful/MAL/api/UserAgentInterceptor.java b/Atarashii/src/net/somethingdreadful/MAL/api/UserAgentInterceptor.java index 723277ca..2e6ffd85 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/api/UserAgentInterceptor.java +++ b/Atarashii/src/net/somethingdreadful/MAL/api/UserAgentInterceptor.java @@ -6,7 +6,7 @@ import java.io.IOException; -public class UserAgentInterceptor implements Interceptor { +class UserAgentInterceptor implements Interceptor { private final String userAgent; diff --git a/Atarashii/src/net/somethingdreadful/MAL/broadcasts/AutoSync.java b/Atarashii/src/net/somethingdreadful/MAL/broadcasts/AutoSync.java index f145b939..117695a4 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/broadcasts/AutoSync.java +++ b/Atarashii/src/net/somethingdreadful/MAL/broadcasts/AutoSync.java @@ -25,7 +25,7 @@ import java.util.ArrayList; public class AutoSync extends BroadcastReceiver implements APIAuthenticationErrorListener, NetworkTask.NetworkTaskListener { - static NotificationManager nm; + private static NotificationManager nm; @Override public void onReceive(Context context, Intent intent) { @@ -39,7 +39,7 @@ public void onReceive(Context context, Intent intent) { Intent notificationIntent = new Intent(context, Home.class); PendingIntent contentIntent = PendingIntent.getActivity(context, 1, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); if (networkChange(intent) && !PrefManager.getAutosyncDone() || !networkChange(intent)) { - ArrayList args = new ArrayList(); + ArrayList args = new ArrayList<>(); args.add(AccountService.getUsername()); args.add(""); new NetworkTask(TaskJob.FORCESYNC, MALApi.ListType.ANIME, context, this, this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, args.toArray(new String[args.size()])); @@ -84,7 +84,7 @@ public void onNetworkTaskError(TaskJob job, MALApi.ListType type, Bundle data, b PrefManager.setAutosyncDone(false); } - public boolean networkChange(Intent intent) { + private boolean networkChange(Intent intent) { return intent != null && intent.getAction() != null && intent.getAction().equals(android.net.ConnectivityManager.CONNECTIVITY_ACTION); } } \ No newline at end of file diff --git a/Atarashii/src/net/somethingdreadful/MAL/broadcasts/RecordStatusUpdatedReceiver.java b/Atarashii/src/net/somethingdreadful/MAL/broadcasts/RecordStatusUpdatedReceiver.java index fa3d880d..807112fa 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/broadcasts/RecordStatusUpdatedReceiver.java +++ b/Atarashii/src/net/somethingdreadful/MAL/broadcasts/RecordStatusUpdatedReceiver.java @@ -8,7 +8,7 @@ public class RecordStatusUpdatedReceiver extends BroadcastReceiver { public static final String RECV_IDENT = "net.somethingdreadful.MAL.broadcasts.RecordStatusUpdatedReceiver"; - private RecordStatusUpdatedListener callback; + private final RecordStatusUpdatedListener callback; public RecordStatusUpdatedReceiver(RecordStatusUpdatedListener callback) { this.callback = callback; diff --git a/Atarashii/src/net/somethingdreadful/MAL/database/DatabaseManager.java b/Atarashii/src/net/somethingdreadful/MAL/database/DatabaseManager.java index ee3611ee..872936c2 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/database/DatabaseManager.java +++ b/Atarashii/src/net/somethingdreadful/MAL/database/DatabaseManager.java @@ -19,7 +19,7 @@ import java.util.ArrayList; public class DatabaseManager { - SQLiteDatabase db; + private final SQLiteDatabase db; public DatabaseManager(Context context) { this.db = DatabaseTest.getInstance(context).getWritableDatabase(); @@ -89,7 +89,7 @@ public void saveAnimeList(ArrayList result) { * * @param anime The Anime model */ - public void saveAnimeList(Anime anime) { + private void saveAnimeList(Anime anime) { ContentValues cv = new ContentValues(); cv.put(DatabaseTest.COLUMN_ID, anime.getId()); cv.put("title", anime.getTitle()); @@ -161,7 +161,7 @@ public void saveMangaList(ArrayList result) { * * @param manga The Anime model */ - public void saveMangaList(Manga manga) { + private void saveMangaList(Manga manga) { ContentValues cv = new ContentValues(); cv.put(DatabaseTest.COLUMN_ID, manga.getId()); cv.put("title", manga.getTitle()); @@ -501,14 +501,13 @@ public boolean addWidgetRecord(int id, MALApi.ListType type) { return true; } - public boolean updateWidgetRecord(int oldId, MALApi.ListType oldType, int id, MALApi.ListType type) { + public boolean updateWidgetRecord(int oldId, int id, MALApi.ListType type) { if (checkWidgetID(id, type)) return false; // Remove old record ContentValues cv = new ContentValues(); cv.putNull("widget"); - boolean anime = oldType.equals(MALApi.ListType.ANIME); try { db.beginTransaction(); diff --git a/Atarashii/src/net/somethingdreadful/MAL/database/DatabaseTest.java b/Atarashii/src/net/somethingdreadful/MAL/database/DatabaseTest.java index 24987c69..8f193fb0 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/database/DatabaseTest.java +++ b/Atarashii/src/net/somethingdreadful/MAL/database/DatabaseTest.java @@ -8,8 +8,8 @@ import com.crashlytics.android.Crashlytics; public class DatabaseTest extends SQLiteOpenHelper { - public static final String NAME = "MAL.db"; - public static final int VERSION = 13; + private static final String NAME = "MAL.db"; + private static final int VERSION = 13; private static DatabaseTest instance; public static final String TABLE_ANIME = "anime"; diff --git a/Atarashii/src/net/somethingdreadful/MAL/database/Query.java b/Atarashii/src/net/somethingdreadful/MAL/database/Query.java index 06f1fc87..1f72e75f 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/database/Query.java +++ b/Atarashii/src/net/somethingdreadful/MAL/database/Query.java @@ -13,7 +13,7 @@ import java.util.List; public class Query { - String queryString = ""; + private String queryString = ""; private static SQLiteDatabase db; public static Query newQuery(SQLiteDatabase db) { @@ -26,7 +26,7 @@ public Query selectFrom(String column, String table) { return this; } - public Query innerJoinOn(String table1, String column1, String column2) { + private Query innerJoinOn(String table1, String column1, String column2) { queryString += " INNER JOIN " + table1 + " ON " + column1 + " = " + column2; return this; } @@ -78,7 +78,6 @@ public Cursor run() { /** * Update or insert records. - * * @param table The table where the record should be updated * @param cv The ContentValues which should be updated * @param id The ID of the record @@ -92,7 +91,6 @@ public int updateRecord(String table, ContentValues cv, int id) { /** * Update or insert records. - * * @param table The table where the record should be updated * @param cv The ContentValues which should be updated * @param username The username of the record @@ -251,7 +249,8 @@ private void updateTitles(int id, String table, int titleType, ArrayList * @param id The anime or manga ID * @param anime True if the record is an anime * @param titleType The title type - * @return + * + * @return ArrayList with titles */ public ArrayList getTitles(int id, boolean anime, int titleType) { ArrayList result = new ArrayList<>(); @@ -364,7 +363,8 @@ public ArrayList getRelation(Integer Id, String relationTable, Strin * @param table The table which is separated in anime or manga records * @param column The column name of the id's * @param anime If the record is an anime. - * @return + * + * @return The requested arraylist */ public ArrayList getArrayList(int id, String relTable, String table, String column, boolean anime) { ArrayList result = new ArrayList<>(); diff --git a/Atarashii/src/net/somethingdreadful/MAL/database/Table.java b/Atarashii/src/net/somethingdreadful/MAL/database/Table.java index 65c20a68..333a63be 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/database/Table.java +++ b/Atarashii/src/net/somethingdreadful/MAL/database/Table.java @@ -6,7 +6,7 @@ import com.crashlytics.android.Crashlytics; public class Table { - String queryString = ""; + private String queryString = ""; private static SQLiteDatabase db; public static Table create(SQLiteDatabase db) { @@ -181,7 +181,7 @@ public void createRelation(String table, String refTable1, String refTable2) { run(); } - public void run() { + private void run() { try { db.execSQL(queryString); } catch (Exception e) { diff --git a/Atarashii/src/net/somethingdreadful/MAL/detailView/DetailViewDetails.java b/Atarashii/src/net/somethingdreadful/MAL/detailView/DetailViewDetails.java index 891e3b68..a5a4eb0f 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/detailView/DetailViewDetails.java +++ b/Atarashii/src/net/somethingdreadful/MAL/detailView/DetailViewDetails.java @@ -1,5 +1,6 @@ package net.somethingdreadful.MAL.detailView; +import android.annotation.SuppressLint; import android.app.Activity; import android.app.Fragment; import android.content.Intent; @@ -28,43 +29,65 @@ import butterknife.ButterKnife; public class DetailViewDetails extends Fragment implements Serializable, ExpandableListView.OnChildClickListener { - View view; - Card cardSynopsis; - Card cardMediainfo; - Card cardMediaStats; - Card cardRelations; - Card cardTitles; - Card cardNetwork; - DetailView activity; - ExpandableListView relations; - ExpandableListView titles; - DetailViewRelationsAdapter relation; - DetailViewRelationsAdapter title; - - @Bind(R.id.swiperefresh) public SwipeRefreshLayout swipeRefresh; - - @Bind(R.id.SynopsisContent) TextView synopsis; - @Bind(R.id.type) TextView type; - @Bind(R.id.episodes) TextView episodes; - @Bind(R.id.episodesLabel) TextView episodesLabel; - @Bind(R.id.volumes) TextView volumes; - @Bind(R.id.volumesLabel) TextView volumesLabel; - @Bind(R.id.status) TextView status; - @Bind(R.id.start) TextView start; - @Bind(R.id.startRow) TableRow startRow; - @Bind(R.id.end) TextView end; - @Bind(R.id.endRow) TableRow endRow; - @Bind(R.id.classification) TextView classification; - @Bind(R.id.classificationLabel) TextView classificationLabel; - @Bind(R.id.genres) TextView genres; - @Bind(R.id.producers) TextView producers; - @Bind(R.id.producersRow) TableRow producersRow; - - @Bind(R.id.score) TextView score; - @Bind(R.id.ranked) TextView ranked; - @Bind(R.id.popularity) TextView popularity; - @Bind(R.id.members) TextView members; - @Bind(R.id.favorites) TextView favorites; + private View view; + private Card cardSynopsis; + private Card cardMediainfo; + private Card cardMediaStats; + private Card cardRelations; + private Card cardTitles; + private Card cardNetwork; + private DetailView activity; + private ExpandableListView relations; + private ExpandableListView titles; + private DetailViewRelationsAdapter relation; + private DetailViewRelationsAdapter title; + + @Bind(R.id.swiperefresh) + public SwipeRefreshLayout swipeRefresh; + + @Bind(R.id.SynopsisContent) + TextView synopsis; + @Bind(R.id.type) + TextView type; + @Bind(R.id.episodes) + TextView episodes; + @Bind(R.id.episodesLabel) + TextView episodesLabel; + @Bind(R.id.volumes) + TextView volumes; + @Bind(R.id.volumesLabel) + TextView volumesLabel; + @Bind(R.id.status) + TextView status; + @Bind(R.id.start) + TextView start; + @Bind(R.id.startRow) + TableRow startRow; + @Bind(R.id.end) + TextView end; + @Bind(R.id.endRow) + TableRow endRow; + @Bind(R.id.classification) + TextView classification; + @Bind(R.id.classificationLabel) + TextView classificationLabel; + @Bind(R.id.genres) + TextView genres; + @Bind(R.id.producers) + TextView producers; + @Bind(R.id.producersRow) + TableRow producersRow; + + @Bind(R.id.score) + TextView score; + @Bind(R.id.ranked) + TextView ranked; + @Bind(R.id.popularity) + TextView popularity; + @Bind(R.id.members) + TextView members; + @Bind(R.id.favorites) + TextView favorites; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -88,7 +111,7 @@ else if (!MALApi.isNetworkAvailable(activity)) /* * The scrollview bugs when you use viewflipper in it! */ - public void toggleView(Boolean show) { + private void toggleView(Boolean show) { if (show) { cardSynopsis.setVisibility(View.VISIBLE); cardMediainfo.setVisibility(View.VISIBLE); @@ -115,7 +138,7 @@ public void onAttach(Activity activity) { /** * Set all views once */ - public void setViews() { + private void setViews() { // set all the card views cardSynopsis = (Card) view.findViewById(R.id.synopsis); cardMediainfo = (Card) view.findViewById(R.id.mediainfo); @@ -155,6 +178,7 @@ public void setViews() { /** * Place all the text in the right textview */ + @SuppressLint("SetTextI18n") public void setText() { GenericRecord record = (activity.type.equals(MALApi.ListType.ANIME) ? activity.animeRecord : activity.mangaRecord); if (record.getSynopsis() == null) @@ -243,7 +267,7 @@ public boolean onChildClick(ExpandableListView parent, View v, int groupPos, int /** * Handle the click events (expand and collapse) */ - public void clickListeners() { + private void clickListeners() { titles.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() { @Override public void onGroupExpand(int i) { diff --git a/Atarashii/src/net/somethingdreadful/MAL/detailView/DetailViewGeneral.java b/Atarashii/src/net/somethingdreadful/MAL/detailView/DetailViewGeneral.java index 3a4b9392..0180ce57 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/detailView/DetailViewGeneral.java +++ b/Atarashii/src/net/somethingdreadful/MAL/detailView/DetailViewGeneral.java @@ -9,7 +9,6 @@ import android.text.method.LinkMovementMethod; import android.util.Log; import android.view.LayoutInflater; -import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; @@ -38,26 +37,35 @@ import butterknife.ButterKnife; public class DetailViewGeneral extends Fragment implements Serializable, Card.onCardClickListener { - View view; - Menu menu; - DetailView activity; + private View view; + private DetailView activity; public SwipeRefreshLayout swipeRefresh; - Card cardMain; - Card cardSynopsis; - Card cardMediainfo; - Card cardPersonal; - - @Bind(R.id.SynopsisContent) TextView synopsis; - @Bind(R.id.mediaType) TextView mediaType; - @Bind(R.id.mediaStatus) TextView mediaStatus; - @Bind(R.id.statusText) TextView status; - @Bind(R.id.progress1Text1) TextView progress1Total; - @Bind(R.id.progress1Text2) TextView progress1Current; - @Bind(R.id.progress2Text1) TextView progress2Total; - @Bind(R.id.progress2Text2) TextView progress2Current; - @Bind(R.id.myScore) TextView myScore; - @Bind(R.id.Image) ImageView image; + private Card cardMain; + private Card cardSynopsis; + private Card cardMediainfo; + private Card cardPersonal; + + @Bind(R.id.SynopsisContent) + TextView synopsis; + @Bind(R.id.mediaType) + TextView mediaType; + @Bind(R.id.mediaStatus) + TextView mediaStatus; + @Bind(R.id.statusText) + TextView status; + @Bind(R.id.progress1Text1) + TextView progress1Total; + @Bind(R.id.progress1Text2) + TextView progress1Current; + @Bind(R.id.progress2Text1) + TextView progress2Total; + @Bind(R.id.progress2Text2) + TextView progress2Current; + @Bind(R.id.myScore) + TextView myScore; + @Bind(R.id.Image) + ImageView image; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -75,7 +83,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa /* * Set all views once */ - public void setViews() { + private void setViews() { swipeRefresh = (SwipeRefreshLayout) view.findViewById(R.id.swiperefresh); // set all the card views @@ -102,16 +110,16 @@ public void setViews() { /* * set all the ClickListeners */ - public void setListener() { + private void setListener() { swipeRefresh.setOnRefreshListener(activity); - swipeRefresh.setColorScheme(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); + swipeRefresh.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); swipeRefresh.setEnabled(true); } /* * Manage the progress card */ - public void setCard() { + private void setCard() { if (activity.type != null && activity.type.equals(ListType.ANIME)) { TextView progress1 = (TextView) view.findViewById(R.id.progress1Label); progress1.setText(getString(R.string.card_content_episodes)); @@ -120,22 +128,6 @@ public void setCard() { } } - /* - * set the right menu items. - */ - public void setMenu() { - if (menu != null) { - if (activity.isAdded()) { - menu.findItem(R.id.action_Remove).setVisible(true); - menu.findItem(R.id.action_addToList).setVisible(false); - } else { - menu.findItem(R.id.action_Remove).setVisible(false); - menu.findItem(R.id.action_addToList).setVisible(true); - } - menu.findItem(R.id.action_Remove).setVisible(MALApi.isNetworkAvailable(activity) && menu.findItem(R.id.action_Remove).isVisible()); - } - } - /* * Place all the text in the right textview */ @@ -143,7 +135,6 @@ public void setText() { if (activity.type == null || (activity.animeRecord == null && activity.mangaRecord == null)) // not enough data to do anything return; GenericRecord record; - setMenu(); if (activity.type.equals(ListType.ANIME)) { record = activity.animeRecord; diff --git a/Atarashii/src/net/somethingdreadful/MAL/detailView/DetailViewPersonal.java b/Atarashii/src/net/somethingdreadful/MAL/detailView/DetailViewPersonal.java index 6778ed2c..44ccbc2c 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/detailView/DetailViewPersonal.java +++ b/Atarashii/src/net/somethingdreadful/MAL/detailView/DetailViewPersonal.java @@ -32,31 +32,48 @@ public class DetailViewPersonal extends Fragment implements Serializable, View.OnClickListener { public SwipeRefreshLayout swipeRefresh; - DetailView activity; - View view; - Card cardBasic; - Card cardOther; - Card cardRewatch; - - @Bind(R.id.statusText) TextView status; - @Bind(R.id.progress1Text1) TextView progress1Total; - @Bind(R.id.progress1Text2) TextView progress1Current; - @Bind(R.id.progress2Text1) TextView progress2Total; - @Bind(R.id.progress2Text2) TextView progress2Current; - @Bind(R.id.myScore) TextView myScore; - @Bind(R.id.myStartDate) TextView myStartDate; - @Bind(R.id.myEndDate) TextView myEndDate; - @Bind(R.id.myPriority) TextView myPriority; - @Bind(R.id.myTags) TextView myTags; - @Bind(R.id.comments) TextView comments; - - @Bind(R.id.fansubs) TextView fansubs; - @Bind(R.id.storage) TextView storage; - @Bind(R.id.storage_amount) TextView storageCount; - @Bind(R.id.downloaded) TextView dowloaded; - - @Bind(R.id.priority) TextView priority; - @Bind(R.id.count2Text2) TextView rewatchCount2; + private DetailView activity; + private View view; + private Card cardBasic; + private Card cardOther; + private Card cardRewatch; + + @Bind(R.id.statusText) + TextView status; + @Bind(R.id.progress1Text1) + TextView progress1Total; + @Bind(R.id.progress1Text2) + TextView progress1Current; + @Bind(R.id.progress2Text1) + TextView progress2Total; + @Bind(R.id.progress2Text2) + TextView progress2Current; + @Bind(R.id.myScore) + TextView myScore; + @Bind(R.id.myStartDate) + TextView myStartDate; + @Bind(R.id.myEndDate) + TextView myEndDate; + @Bind(R.id.myPriority) + TextView myPriority; + @Bind(R.id.myTags) + TextView myTags; + @Bind(R.id.comments) + TextView comments; + + @Bind(R.id.fansubs) + TextView fansubs; + @Bind(R.id.storage) + TextView storage; + @Bind(R.id.storage_amount) + TextView storageCount; + @Bind(R.id.downloaded) + TextView dowloaded; + + @Bind(R.id.priority) + TextView priority; + @Bind(R.id.count2Text2) + TextView rewatchCount2; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -73,7 +90,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa return view; } - public void setCard() { + private void setCard() { if (activity.type != null && activity.type.equals(MALApi.ListType.ANIME)) { TextView progress1 = (TextView) view.findViewById(R.id.progress1Label); progress1.setText(getString(R.string.card_content_episodes)); @@ -82,7 +99,7 @@ public void setCard() { } } - public void setListener() { + private void setListener() { swipeRefresh.setOnRefreshListener(activity); swipeRefresh.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); swipeRefresh.setEnabled(true); @@ -298,7 +315,7 @@ public void onClick(View v) { } } - public Bundle bundle(int id, int title) { + private Bundle bundle(int id, int title) { Bundle bundle = new Bundle(); bundle.putInt("id", id); bundle.putString("title", getString(title)); diff --git a/Atarashii/src/net/somethingdreadful/MAL/detailView/DetailViewReviews.java b/Atarashii/src/net/somethingdreadful/MAL/detailView/DetailViewReviews.java index 420c6b67..656b8d11 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/detailView/DetailViewReviews.java +++ b/Atarashii/src/net/somethingdreadful/MAL/detailView/DetailViewReviews.java @@ -29,14 +29,15 @@ import butterknife.ButterKnife; public class DetailViewReviews extends Fragment implements NetworkTask.NetworkTaskListener { - View view; - HtmlUtil htmlUtil; + private View view; + private HtmlUtil htmlUtil; DetailView activity; public ArrayList record; @Bind(R.id.webview) WebView webview; - @Bind(R.id.viewFlipper) ViewFlipper viewFlipper; + @Bind(R.id.viewFlipper) + ViewFlipper viewFlipper; public int id; public int page = 0; @@ -109,7 +110,7 @@ public void onAttach(Activity activity) { * * @param result The new record */ - public void apply(ArrayList result) { + private void apply(ArrayList result) { try { // The activity could be destroyed when this is being loaded because the user pressed back if (activity != null && isAdded()) { diff --git a/Atarashii/src/net/somethingdreadful/MAL/detailView/ReviewsInterface.java b/Atarashii/src/net/somethingdreadful/MAL/detailView/ReviewsInterface.java index d7ee9ff3..12f05073 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/detailView/ReviewsInterface.java +++ b/Atarashii/src/net/somethingdreadful/MAL/detailView/ReviewsInterface.java @@ -3,8 +3,8 @@ import android.content.Intent; import android.webkit.JavascriptInterface; -public class ReviewsInterface { - DetailViewReviews reviews; +class ReviewsInterface { + private final DetailViewReviews reviews; ReviewsInterface(DetailViewReviews reviews) { this.reviews = reviews; diff --git a/Atarashii/src/net/somethingdreadful/MAL/dialog/DatePickerDialogFragment.java b/Atarashii/src/net/somethingdreadful/MAL/dialog/DatePickerDialogFragment.java index 0b586788..719505a4 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/dialog/DatePickerDialogFragment.java +++ b/Atarashii/src/net/somethingdreadful/MAL/dialog/DatePickerDialogFragment.java @@ -19,8 +19,8 @@ import java.util.Locale; public class DatePickerDialogFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener { - Boolean startDate; - DatePickerDialog mDateDialog; + private Boolean startDate; + private DatePickerDialog mDateDialog; @Override public Dialog onCreateDialog(Bundle savedInstanceState) { diff --git a/Atarashii/src/net/somethingdreadful/MAL/dialog/ForumChildDialogFragment.java b/Atarashii/src/net/somethingdreadful/MAL/dialog/ForumChildDialogFragment.java deleted file mode 100644 index 73014b05..00000000 --- a/Atarashii/src/net/somethingdreadful/MAL/dialog/ForumChildDialogFragment.java +++ /dev/null @@ -1,32 +0,0 @@ -package net.somethingdreadful.MAL.dialog; - -import android.app.AlertDialog; -import android.app.DialogFragment; -import android.os.Bundle; - -import net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Forum; - -import java.util.ArrayList; - -public class ForumChildDialogFragment extends DialogFragment { - ArrayList child; - String message; - public static boolean DBModificationRequest; - - @Override - public AlertDialog onCreateDialog(Bundle savedInstanceState) { - AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - message = getArguments().getString("message"); - child = (ArrayList) getArguments().getSerializable("child"); - - if (child.size() == 2) { - message = message.replace("$child1;", child.get(0).getName()); - message = message.replace("$child2;", child.get(1).getName()); - } else { - message = message.replace("$child1;", child.get(0).getName() + ", " + child.get(1).getName()); - message = message.replace("$child2;", child.get(2).getName()); - } - - return builder.create(); - } -} \ No newline at end of file diff --git a/Atarashii/src/net/somethingdreadful/MAL/dialog/MangaPickerDialogFragment.java b/Atarashii/src/net/somethingdreadful/MAL/dialog/MangaPickerDialogFragment.java index 2ad46def..59a23c9f 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/dialog/MangaPickerDialogFragment.java +++ b/Atarashii/src/net/somethingdreadful/MAL/dialog/MangaPickerDialogFragment.java @@ -12,13 +12,13 @@ import net.somethingdreadful.MAL.R; public class MangaPickerDialogFragment extends DialogFragment { - NumberPicker chapterPicker; - NumberPicker volumePicker; - int chaptersTotal; - int chaptersRead; + private NumberPicker chapterPicker; + private NumberPicker volumePicker; + private int chaptersTotal; + private int chaptersRead; - int volumesTotal; - int volumesRead; + private int volumesTotal; + private int volumesRead; private View makeNumberPicker() { View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_manga_picker, null); diff --git a/Atarashii/src/net/somethingdreadful/MAL/dialog/MessageDialogFragment.java b/Atarashii/src/net/somethingdreadful/MAL/dialog/MessageDialogFragment.java index 492ff00a..12ae7e77 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/dialog/MessageDialogFragment.java +++ b/Atarashii/src/net/somethingdreadful/MAL/dialog/MessageDialogFragment.java @@ -1,5 +1,6 @@ package net.somethingdreadful.MAL.dialog; +import android.annotation.SuppressLint; import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; @@ -18,14 +19,14 @@ public class MessageDialogFragment extends DialogFragment implements View.OnClickListener, View.OnLongClickListener { - EditText subject; - EditText message; - TextView header; - ForumJob task; - int id; - View view; - onSendClickListener callback; - TextView send; + private EditText subject; + private EditText message; + private TextView header; + private ForumJob task; + private int id; + private View view; + private onSendClickListener callback; + private TextView send; @Override public Dialog onCreateDialog(Bundle savedInstanceState) { @@ -109,6 +110,7 @@ private View setView(View view) { * * @param BBCode The BBCode string that should be in the message field */ + @SuppressLint("SetTextI18n") private void insert(String BBCode) { int curPos = message.getSelectionStart(); String str = message.getText().toString(); @@ -203,11 +205,6 @@ public MessageDialogFragment setOnSendClickListener(onSendClickListener callback return this; } - public MessageDialogFragment setListeners(onSendClickListener callback) { - setOnSendClickListener(callback); - return this; - } - /** * This will let the dialog remain on the sceen after an orientation. */ diff --git a/Atarashii/src/net/somethingdreadful/MAL/dialog/NumberPickerDialogFragment.java b/Atarashii/src/net/somethingdreadful/MAL/dialog/NumberPickerDialogFragment.java index cce974bc..f66846c2 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/dialog/NumberPickerDialogFragment.java +++ b/Atarashii/src/net/somethingdreadful/MAL/dialog/NumberPickerDialogFragment.java @@ -19,10 +19,10 @@ import net.somethingdreadful.MAL.account.AccountService; public class NumberPickerDialogFragment extends DialogFragment { - NumberPicker numberPicker; - EditText numberInput; + private NumberPicker numberPicker; + private EditText numberInput; private onUpdateClickListener callback; - boolean inputScore = false; + private boolean inputScore = false; private View makeNumberPicker() { View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_episode_picker, null); @@ -90,7 +90,7 @@ private boolean isRating() { * @param key The argument name * @return int The number of the argument */ - public int getValue(String key) { + private int getValue(String key) { try { if (getArguments().getInt("id") == R.id.scorePanel && PrefManager.getScoreType() != 3 && PrefManager.getScoreType() != 1) inputScore = true; diff --git a/Atarashii/src/net/somethingdreadful/MAL/dialog/RecordPickerDialog.java b/Atarashii/src/net/somethingdreadful/MAL/dialog/RecordPickerDialog.java index dc0e58e3..fade28cd 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/dialog/RecordPickerDialog.java +++ b/Atarashii/src/net/somethingdreadful/MAL/dialog/RecordPickerDialog.java @@ -7,7 +7,6 @@ import android.content.Intent; import android.os.Bundle; import android.support.v4.view.ViewPager; -import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.view.Menu; import android.view.MenuItem; @@ -30,19 +29,16 @@ import butterknife.ButterKnife; public class RecordPickerDialog extends AppCompatActivity implements IGF.IGFCallbackListener, APIAuthenticationErrorListener, ViewPager.OnPageChangeListener { - IGF af; - IGF mf; - Menu menu; - Context context; - ActionBar actionBar; - IGFPagerAdapter mIGFPagerAdapter; + private IGF af; + private IGF mf; + private Menu menu; + private Context context; + private IGFPagerAdapter mIGFPagerAdapter; - @Bind(R.id.pager) ViewPager mViewPager; + @Bind(R.id.pager) + ViewPager mViewPager; - String username; - boolean callbackAnimeError = false; - boolean callbackMangaError = false; - int callbackCounter = 0; + private int callbackCounter = 0; private int widgetID; private int recordID; private MALApi.ListType type; @@ -53,16 +49,12 @@ public void onCreate(Bundle savedInstanceState) { setResult(RESULT_CANCELED); context = getApplicationContext(); if (AccountService.getAccount() != null) { - actionBar = getSupportActionBar(); - //The following is state handling code - setContentView(R.layout.activity_home); + // Creates the adapter to return the Animu and Mango fragments mIGFPagerAdapter = new IGFPagerAdapter(getFragmentManager(), false); ButterKnife.bind(this); - username = AccountService.getUsername(); - // Set up the ViewPager with the sections adapter. mViewPager.setAdapter(mIGFPagerAdapter); mViewPager.setPageMargin(32); @@ -140,14 +132,14 @@ public boolean onOptionsItemSelected(MenuItem item) { * On some devices the af & mf will change into null due inactivity. * This is a check to prevent any crashes and set it again. */ - public void checkIGF() { + private void checkIGF() { if (af == null || mf == null) { af = (IGF) mIGFPagerAdapter.getIGF(mViewPager, 0); mf = (IGF) mIGFPagerAdapter.getIGF(mViewPager, 1); } } - public void getRecords(boolean clear, TaskJob task, int list) { + private void getRecords(boolean clear, TaskJob task, int list) { checkIGF(); if (af != null && mf != null) { af.getRecords(clear, task, list); @@ -166,7 +158,7 @@ public void onPause() { super.onPause(); } - public void synctask(boolean clear) { + private void synctask(boolean clear) { getRecords(clear, TaskJob.FORCESYNC, af.list); } @@ -203,7 +195,7 @@ public boolean onPrepareOptionsMenu(Menu menu) { return true; } - public void setChecked(MenuItem item) { + private void setChecked(MenuItem item) { item.setChecked(true); } @@ -257,7 +249,7 @@ public void onItemClick(int id, MALApi.ListType listType, String username) { DatabaseManager db = new DatabaseManager(context); boolean succeeded; if (recordID != 0) - succeeded = db.updateWidgetRecord(recordID, type, id, listType); + succeeded = db.updateWidgetRecord(recordID, id, listType); else succeeded = db.addWidgetRecord(id, listType); diff --git a/Atarashii/src/net/somethingdreadful/MAL/dialog/SearchIdDialogFragment.java b/Atarashii/src/net/somethingdreadful/MAL/dialog/SearchIdDialogFragment.java index f06bd4d8..5156a904 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/dialog/SearchIdDialogFragment.java +++ b/Atarashii/src/net/somethingdreadful/MAL/dialog/SearchIdDialogFragment.java @@ -14,7 +14,7 @@ public class SearchIdDialogFragment extends DialogFragment { - int query; + private int query; @Override public void onAttach(Activity activity) { diff --git a/Atarashii/src/net/somethingdreadful/MAL/dialog/ShareDialogFragment.java b/Atarashii/src/net/somethingdreadful/MAL/dialog/ShareDialogFragment.java index c73a11bb..4b738abd 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/dialog/ShareDialogFragment.java +++ b/Atarashii/src/net/somethingdreadful/MAL/dialog/ShareDialogFragment.java @@ -12,8 +12,8 @@ import net.somethingdreadful.MAL.account.AccountService; public class ShareDialogFragment extends DialogFragment { - String title; - boolean share; + private String title; + private boolean share; @Override public Dialog onCreateDialog(Bundle savedInstanceState) { @@ -71,7 +71,7 @@ public void onClick(DialogInterface dialog, int which) { return builder.create(); } - public String getWebsiteURL() { + private String getWebsiteURL() { return AccountService.isMAL() ? "http://myanimelist.net/" : "http://anilist.co/"; } } \ No newline at end of file diff --git a/Atarashii/src/net/somethingdreadful/MAL/dialog/StatusPickerDialogFragment.java b/Atarashii/src/net/somethingdreadful/MAL/dialog/StatusPickerDialogFragment.java index 58515b27..b654e792 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/dialog/StatusPickerDialogFragment.java +++ b/Atarashii/src/net/somethingdreadful/MAL/dialog/StatusPickerDialogFragment.java @@ -17,9 +17,9 @@ public class StatusPickerDialogFragment extends DialogFragment implements OnCheckedChangeListener { - RadioGroup radio; - ListType type; - String currentStatus; + private RadioGroup radio; + private ListType type; + private String currentStatus; @Override public AlertDialog onCreateDialog(Bundle savedInstanceState) { @@ -43,7 +43,7 @@ public void onClick(DialogInterface dialog, int whichButton) { return builder.create(); } - public View makeRatiobutton() { + private View makeRatiobutton() { View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_status_picker, null); radio = (RadioGroup) view.findViewById(R.id.statusRadioGroup); type = ((DetailView) getActivity()).type; diff --git a/Atarashii/src/net/somethingdreadful/MAL/dialog/UpdateImageDialogFragment.java b/Atarashii/src/net/somethingdreadful/MAL/dialog/UpdateImageDialogFragment.java index 755111bc..afea9f2b 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/dialog/UpdateImageDialogFragment.java +++ b/Atarashii/src/net/somethingdreadful/MAL/dialog/UpdateImageDialogFragment.java @@ -15,7 +15,7 @@ import net.somethingdreadful.MAL.R; public class UpdateImageDialogFragment extends DialogFragment { - EditText input; + private EditText input; private View createView() { View result = getActivity().getLayoutInflater().inflate(R.layout.dialog_update_nav_image, null); diff --git a/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java b/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java index 0b953fd2..8cfe73ba 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java +++ b/Atarashii/src/net/somethingdreadful/MAL/forum/ForumInterface.java @@ -17,7 +17,7 @@ import net.somethingdreadful.MAL.tasks.ForumNetworkTask; public class ForumInterface { - ForumActivity forum; + private final ForumActivity forum; public ForumInterface(ForumActivity forum) { this.forum = forum; @@ -82,7 +82,7 @@ public void run() { } } - int convertMessageQuote = 0; + private int convertMessageQuote = 0; private String convertMessageQuote(String HTML) { convertMessageQuote = convertMessageQuote + 1; if (convertMessageQuote <= 8) { @@ -94,7 +94,7 @@ private String convertMessageQuote(String HTML) { return HTML; } - int convertUserQuote = 0; + private int convertUserQuote = 0; private String convertUserQuote(String HTML) { convertUserQuote = convertUserQuote + 1; if (convertUserQuote <= 8) { @@ -106,7 +106,7 @@ private String convertUserQuote(String HTML) { return HTML; } - int convertQuote = 0; + private int convertQuote = 0; private String convertQuote(String HTML) { convertQuote = convertQuote + 1; if (convertQuote <= 8) { @@ -118,7 +118,7 @@ private String convertQuote(String HTML) { return HTML; } - int convertQuoteSpoiler = 0; + private int convertQuoteSpoiler = 0; private String convertQuoteSpoiler(String HTML) { convertQuoteSpoiler = convertQuoteSpoiler + 1; if (convertQuoteSpoiler <= 8) { @@ -130,7 +130,7 @@ private String convertQuoteSpoiler(String HTML) { return HTML; } - int convertSpoiler = 0; + private int convertSpoiler = 0; private String convertSpoiler(String HTML) { convertSpoiler = convertSpoiler + 1; if (convertSpoiler <= 8) { diff --git a/Atarashii/src/net/somethingdreadful/MAL/forum/HtmlUtil.java b/Atarashii/src/net/somethingdreadful/MAL/forum/HtmlUtil.java index 2b455cb0..0cd9a90a 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/forum/HtmlUtil.java +++ b/Atarashii/src/net/somethingdreadful/MAL/forum/HtmlUtil.java @@ -6,22 +6,20 @@ import net.somethingdreadful.MAL.R; import net.somethingdreadful.MAL.Theme; import net.somethingdreadful.MAL.account.AccountService; -import net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Forum; import net.somethingdreadful.MAL.api.BaseModels.AnimeManga.Reviews; import net.somethingdreadful.MAL.api.BaseModels.History; import net.somethingdreadful.MAL.api.BaseModels.Profile; -import net.somethingdreadful.MAL.api.MALModels.ForumMain; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; public class HtmlUtil { - private Context context; - String structure; - String postStructure; - String spoilerStructure; - String pageString; + private final Context context; + private String structure; + private final String postStructure; + private String spoilerStructure; + private String pageString; public HtmlUtil(Context context) { structure = getString(context, R.raw.forum_post_structure); @@ -124,7 +122,7 @@ public String convertMALComment(String comment) { * @param comment The HTML comment * @return String The BBCode comment */ - public String convertALComment(String comment) { + private String convertALComment(String comment) { comment = comment.replace("\n", "
    "); // New line comment = comment.replace("~~~img(", ""); // Image @@ -228,45 +226,6 @@ public String convertList(Profile record, int page) { return buildList(result, 0, page); } - /** - * Convert a forum array into a HTML list. - * - * @param record The ForumMain object that contains the list which should be converted in a HTML list - * @param username The username of the user, this is used for special rights - * @return String The HTML source - */ - public String convertList(ForumMain record, String username, int page) { - ArrayList list = record.getList(); - String result = ""; - for (int i = 0; i < list.size(); i++) { - Forum post = list.get(i); - String postreal = postStructure; - String comment = post.getComment(); - - comment = comment.replace("data-src=", "width=\"100%\" src="); - comment = comment.replace("img src=", "img width=\"100%\" src="); - - if (post.getUsername().equals(username)) - postreal = postreal.replace("", ""); - else - postreal = postreal.replace("", ""); - if (Profile.isDeveloper(post.getUsername())) - postreal = postreal.replace("=\"title\">", "=\"developer\">"); - if (!post.getProfile().getDetails().getAccessRank().equals("Member")) - postreal = postreal.replace("=\"title\">", "=\"staff\">"); - postreal = postreal.replace("image", post.getProfile().getAvatarUrl() != null ? post.getProfile().getAvatarUrl() : "http://cdn.myanimelist.net/images/na.gif"); - postreal = postreal.replace("Title", post.getUsername()); - postreal = postreal.replace("itemID", String.valueOf(post.getId())); - postreal = postreal.replace("position", String.valueOf(i)); - postreal = postreal.replace("Subhead", DateTools.parseDate(post.getTime(), true)); - postreal = postreal.replace("", comment); - - result = result + postreal; - } - pageString = context.getString(R.string.no_activity); - return buildList(result, record.getPages(), page); - } - /** * Convert a forum array into a HTML list. * diff --git a/Atarashii/src/net/somethingdreadful/MAL/profile/ProfileDetailsAL.java b/Atarashii/src/net/somethingdreadful/MAL/profile/ProfileDetailsAL.java index 3b118dd2..68a7efca 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/profile/ProfileDetailsAL.java +++ b/Atarashii/src/net/somethingdreadful/MAL/profile/ProfileDetailsAL.java @@ -3,7 +3,6 @@ import android.annotation.SuppressLint; import android.app.Activity; import android.app.Fragment; -import android.content.Context; import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.os.Bundle; @@ -32,17 +31,19 @@ import butterknife.ButterKnife; public class ProfileDetailsAL extends Fragment implements SwipeRefreshLayout.OnRefreshListener { - View view; - Context context; + private View view; private HtmlUtil htmlUtil; private ProfileActivity activity; - @Bind(R.id.webview) WebView webview; - Card imagecard; - Card activitycard; + @Bind(R.id.webview) + WebView webview; + private Card imagecard; + private Card activitycard; @Bind(R.id.swiperefresh) public SwipeRefreshLayout swipeRefresh; - @Bind(R.id.progressBar) ProgressBar progressBar; - @Bind(R.id.network_Card) Card networkCard; + @Bind(R.id.progressBar) + ProgressBar progressBar; + @Bind(R.id.network_Card) + Card networkCard; @SuppressLint("SetJavaScriptEnabled") @Override @@ -62,7 +63,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle st swipeRefresh = (SwipeRefreshLayout) view.findViewById(R.id.swiperefresh); swipeRefresh.setOnRefreshListener(this); - swipeRefresh.setColorScheme(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); + swipeRefresh.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); swipeRefresh.setEnabled(true); activity.setDetails(this); @@ -80,7 +81,7 @@ public void onAttach(Activity activity) { this.activity = (ProfileActivity) activity; } - public void card() { + private void card() { Card namecard = (Card) view.findViewById(R.id.name_card); namecard.Header.setText(WordUtils.capitalize(activity.record.getUsername())); } @@ -93,7 +94,7 @@ public void toggle(int number) { public void refresh() { if (activity.record == null) { - if (MALApi.isNetworkAvailable(context)) + if (MALApi.isNetworkAvailable(activity)) Theme.Snackbar(activity, R.string.toast_error_UserRecord); else toggle(2); @@ -103,7 +104,7 @@ public void refresh() { webview.loadDataWithBaseURL(null, htmlUtil.convertList(activity.record, 1), "text/html", "utf-8", null); - Picasso.with(context) + Picasso.with(activity) .load(activity.record.getImageUrl()) .into(new Target() { @Override diff --git a/Atarashii/src/net/somethingdreadful/MAL/profile/ProfileDetailsMAL.java b/Atarashii/src/net/somethingdreadful/MAL/profile/ProfileDetailsMAL.java index b8460ef1..f8b22ea2 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/profile/ProfileDetailsMAL.java +++ b/Atarashii/src/net/somethingdreadful/MAL/profile/ProfileDetailsMAL.java @@ -1,5 +1,6 @@ package net.somethingdreadful.MAL.profile; +import android.annotation.SuppressLint; import android.app.Activity; import android.app.Fragment; import android.content.Intent; @@ -38,42 +39,70 @@ import butterknife.ButterKnife; public class ProfileDetailsMAL extends Fragment implements SwipeRefreshLayout.OnRefreshListener { - View view; - Card imagecard; - Card animecard; - Card mangacard; + private View view; + private Card imagecard; + private Card animecard; + private Card mangacard; private ProfileActivity activity; @Bind(R.id.swiperefresh) public SwipeRefreshLayout swipeRefresh; - @Bind(R.id.progressBar) ProgressBar progressBar; - @Bind(R.id.network_Card) Card networkCard; - - @Bind(R.id.birthdaysmall) TextView tv1; - @Bind(R.id.locationsmall) TextView tv2; - @Bind(R.id.commentspostssmall) TextView tv3; - @Bind(R.id.forumpostssmall) TextView tv4; - @Bind(R.id.lastonlinesmall) TextView tv5; - @Bind(R.id.gendersmall) TextView tv6; - @Bind(R.id.joindatesmall) TextView tv7; - @Bind(R.id.accessranksmall) TextView tv8; - @Bind(R.id.animelistviewssmall) TextView tv9; - @Bind(R.id.mangalistviewssmall) TextView tv10; - @Bind(R.id.atimedayssmall) TextView tv11; - @Bind(R.id.awatchingsmall) TextView tv12; - @Bind(R.id.acompletedpostssmall) TextView tv13; - @Bind(R.id.aonholdsmall) TextView tv14; - @Bind(R.id.adroppedsmall) TextView tv15; - @Bind(R.id.aplantowatchsmall) TextView tv16; - @Bind(R.id.atotalentriessmall) TextView tv17; - @Bind(R.id.mtimedayssmall) TextView tv18; - @Bind(R.id.mwatchingsmall) TextView tv19; - @Bind(R.id.mcompletedpostssmall) TextView tv20; - @Bind(R.id.monholdsmall) TextView tv21; - @Bind(R.id.mdroppedsmall) TextView tv22; - @Bind(R.id.mplantowatchsmall) TextView tv23; - @Bind(R.id.mtotalentriessmall) TextView tv24; - @Bind(R.id.websitesmall) TextView tv25; - @Bind(R.id.websitefront) TextView tv26; + @Bind(R.id.progressBar) + ProgressBar progressBar; + @Bind(R.id.network_Card) + Card networkCard; + + @Bind(R.id.birthdaysmall) + TextView tv1; + @Bind(R.id.locationsmall) + TextView tv2; + @Bind(R.id.commentspostssmall) + TextView tv3; + @Bind(R.id.forumpostssmall) + TextView tv4; + @Bind(R.id.lastonlinesmall) + TextView tv5; + @Bind(R.id.gendersmall) + TextView tv6; + @Bind(R.id.joindatesmall) + TextView tv7; + @Bind(R.id.accessranksmall) + TextView tv8; + @Bind(R.id.animelistviewssmall) + TextView tv9; + @Bind(R.id.mangalistviewssmall) + TextView tv10; + @Bind(R.id.atimedayssmall) + TextView tv11; + @Bind(R.id.awatchingsmall) + TextView tv12; + @Bind(R.id.acompletedpostssmall) + TextView tv13; + @Bind(R.id.aonholdsmall) + TextView tv14; + @Bind(R.id.adroppedsmall) + TextView tv15; + @Bind(R.id.aplantowatchsmall) + TextView tv16; + @Bind(R.id.atotalentriessmall) + TextView tv17; + @Bind(R.id.mtimedayssmall) + TextView tv18; + @Bind(R.id.mwatchingsmall) + TextView tv19; + @Bind(R.id.mcompletedpostssmall) + TextView tv20; + @Bind(R.id.monholdsmall) + TextView tv21; + @Bind(R.id.mdroppedsmall) + TextView tv22; + @Bind(R.id.mplantowatchsmall) + TextView tv23; + @Bind(R.id.mtotalentriessmall) + TextView tv24; + @Bind(R.id.websitesmall) + TextView tv25; + @Bind(R.id.websitefront) + TextView tv26; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) { @@ -91,7 +120,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle st ButterKnife.bind(this, view); swipeRefresh.setOnRefreshListener(this); - swipeRefresh.setColorScheme(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); + swipeRefresh.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); swipeRefresh.setEnabled(true); TextView tv25 = (TextView) view.findViewById(R.id.websitesmall); @@ -118,7 +147,7 @@ public void onAttach(Activity activity) { this.activity = (ProfileActivity) activity; } - public void card() { //settings for hide a card and text userprofile + private void card() { //settings for hide a card and text userprofile if (PrefManager.getHideAnime()) animecard.setVisibility(View.GONE); if (PrefManager.getHideManga()) @@ -132,7 +161,7 @@ public void card() { //settings for hide a card and text userprofile namecard.Header.setText(WordUtils.capitalize(activity.record.getUsername())); } - public void setcolor() { + private void setcolor() { TextView tv8 = (TextView) view.findViewById(R.id.accessranksmall); String name = activity.record.getUsername(); String rank = activity.record.getDetails().getAccessRank() != null ? activity.record.getDetails().getAccessRank() : ""; @@ -155,7 +184,7 @@ public void setcolor() { } } - public void setColor(boolean type) { + private void setColor(boolean type) { int Hue; TextView textview; if (type) { @@ -170,17 +199,17 @@ public void setColor(boolean type) { textview.setTextColor(Color.HSVToColor(new float[]{Hue, 1, (float) 0.7})); } - private String getStringFromResourceArray(int resArrayId, int notFoundStringId, int index) { + private String getStringFromResourceArray(int resArrayId, int index) { try { // getResources will cause a crash if an users clicks the profile fast away Resources res = getResources(); try { String[] types = res.getStringArray(resArrayId); if (index < 0 || index >= types.length) // make sure to have a valid array index - return res.getString(notFoundStringId); + return res.getString(R.string.not_specified); else return types[index]; } catch (Exception e) { - return res.getString(notFoundStringId); + return res.getString(R.string.not_specified); } } catch (Exception e) { Crashlytics.log(Log.ERROR, "MALX", "ProfileDetailsMAL.getStringFromResourceArray(): " + e.getMessage()); @@ -194,7 +223,8 @@ public void toggle(int number) { networkCard.setVisibility(number == 2 ? View.VISIBLE : View.GONE); } - public void setText() { + @SuppressLint("SetTextI18n") + void setText() { if (activity.record.getDetails().getBirthday() == null) { tv1.setText(R.string.not_specified); } else { @@ -218,7 +248,7 @@ public void setText() { tv5.setText(lastOnline.equals("") ? activity.record.getDetails().getLastOnline() : lastOnline); } else tv5.setText("-"); - tv6.setText(getStringFromResourceArray(R.array.gender, R.string.not_specified, activity.record.getDetails().getGenderInt())); + tv6.setText(getStringFromResourceArray(R.array.gender, activity.record.getDetails().getGenderInt())); if (activity.record.getDetails().getJoinDate() != null) { String joinDate = DateTools.parseDate(activity.record.getDetails().getJoinDate(), false); tv7.setText(joinDate.equals("") ? activity.record.getDetails().getJoinDate() : joinDate); diff --git a/Atarashii/src/net/somethingdreadful/MAL/profile/ProfileFriends.java b/Atarashii/src/net/somethingdreadful/MAL/profile/ProfileFriends.java index fcae08eb..cac66f6e 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/profile/ProfileFriends.java +++ b/Atarashii/src/net/somethingdreadful/MAL/profile/ProfileFriends.java @@ -32,16 +32,18 @@ import butterknife.ButterKnife; public class ProfileFriends extends Fragment implements FriendsNetworkTask.FriendsNetworkTaskListener, SwipeRefreshLayout.OnRefreshListener, OnItemClickListener { - GridView Gridview; + private GridView Gridview; private ProfileActivity activity; - FriendsGridviewAdapter listadapter; - ArrayList listarray = new ArrayList<>(); + private FriendsGridviewAdapter listadapter; + private ArrayList listarray = new ArrayList<>(); - @Bind(R.id.network_Card) Card networkCard; - @Bind(R.id.progressBar) ProgressBar progressBar; + @Bind(R.id.network_Card) + Card networkCard; + @Bind(R.id.progressBar) + ProgressBar progressBar; @Bind(R.id.swiperefresh) public SwipeRefreshLayout swipeRefresh; - boolean forcesync = false; + private boolean forcesync = false; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) { @@ -54,7 +56,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle st listadapter = new FriendsGridviewAdapter<>(activity, listarray); swipeRefresh = (SwipeRefreshLayout) view.findViewById(R.id.swiperefresh); swipeRefresh.setOnRefreshListener(this); - swipeRefresh.setColorScheme(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); + swipeRefresh.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); swipeRefresh.setEnabled(true); activity.setFriends(this); @@ -74,7 +76,7 @@ private void toggle(int number) { networkCard.setVisibility(number == 2 ? View.VISIBLE : View.GONE); } - public void refresh() { + private void refresh() { Gridview.setAdapter(listadapter); try { listadapter.supportAddAll(listarray); diff --git a/Atarashii/src/net/somethingdreadful/MAL/profile/ProfileHistory.java b/Atarashii/src/net/somethingdreadful/MAL/profile/ProfileHistory.java index a1392903..58a5764a 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/profile/ProfileHistory.java +++ b/Atarashii/src/net/somethingdreadful/MAL/profile/ProfileHistory.java @@ -27,10 +27,11 @@ public class ProfileHistory extends Fragment implements SwipeRefreshLayout.OnRef private HtmlUtil htmlUtil; public ProfileActivity activity; - @Bind(R.id.webview) WebView webview; + @Bind(R.id.webview) + WebView webview; @Bind(R.id.swiperefresh) public SwipeRefreshLayout swipeRefresh; - @SuppressLint("SetJavaScriptEnabled") + @SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"}) @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bundle) { View view = inflater.inflate(R.layout.fragment_profile_history, container, false); @@ -46,7 +47,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bu swipeRefresh = (SwipeRefreshLayout) view.findViewById(R.id.swiperefresh); swipeRefresh.setOnRefreshListener(this); - swipeRefresh.setColorScheme(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); + swipeRefresh.setColorSchemeResources(android.R.color.holo_blue_bright, android.R.color.holo_green_light, android.R.color.holo_orange_light, android.R.color.holo_red_light); swipeRefresh.setEnabled(true); NfcHelper.disableBeam(activity); @@ -58,7 +59,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle bu * * @param result The new record */ - public void apply(Profile result) { + private void apply(Profile result) { try { if (result != null) { webview.loadDataWithBaseURL(null, htmlUtil.convertList(result, 1), "text/html", "utf-8", null); diff --git a/Atarashii/src/net/somethingdreadful/MAL/profile/ProfileHistoryInterface.java b/Atarashii/src/net/somethingdreadful/MAL/profile/ProfileHistoryInterface.java index 46c450d7..1b213300 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/profile/ProfileHistoryInterface.java +++ b/Atarashii/src/net/somethingdreadful/MAL/profile/ProfileHistoryInterface.java @@ -7,8 +7,8 @@ import net.somethingdreadful.MAL.api.BaseModels.History; import net.somethingdreadful.MAL.api.MALApi; -public class ProfileHistoryInterface { - ProfileHistory history; +class ProfileHistoryInterface { + private final ProfileHistory history; ProfileHistoryInterface(ProfileHistory history) { this.history = history; diff --git a/Atarashii/src/net/somethingdreadful/MAL/tasks/AuthenticationCheckTask.java b/Atarashii/src/net/somethingdreadful/MAL/tasks/AuthenticationCheckTask.java index 92771aad..966cae3b 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/tasks/AuthenticationCheckTask.java +++ b/Atarashii/src/net/somethingdreadful/MAL/tasks/AuthenticationCheckTask.java @@ -19,9 +19,8 @@ import retrofit.RetrofitError; public class AuthenticationCheckTask extends AsyncTask { - private AuthenticationCheckListener callback; - private String username; - Activity activity; + private final AuthenticationCheckListener callback; + private final Activity activity; public AuthenticationCheckTask(AuthenticationCheckListener callback, Activity activity) { this.callback = callback; @@ -47,7 +46,6 @@ protected Boolean doInBackground(String... params) { AccountService.setRefreshToken(auth.refresh_token); PrefManager.setNavigationBackground(profile.getImageUrlBanner()); - username = profile.getUsername(); return true; } } catch (RetrofitError re) { diff --git a/Atarashii/src/net/somethingdreadful/MAL/tasks/BackupTask.java b/Atarashii/src/net/somethingdreadful/MAL/tasks/BackupTask.java index 4f2cff3f..53889cb2 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/tasks/BackupTask.java +++ b/Atarashii/src/net/somethingdreadful/MAL/tasks/BackupTask.java @@ -30,7 +30,7 @@ public class BackupTask extends AsyncTask { private final Context context; private ArrayList animeResult; private ArrayList mangaResult; - private ArrayList files = new ArrayList<>(); + private final ArrayList files = new ArrayList<>(); public BackupTask(BackupTaskListener callback, Context context) { this.callback = callback; diff --git a/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumNetworkTask.java b/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumNetworkTask.java index 2bef1bcd..c866c372 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumNetworkTask.java +++ b/Atarashii/src/net/somethingdreadful/MAL/tasks/ForumNetworkTask.java @@ -16,10 +16,10 @@ import retrofit.RetrofitError; public class ForumNetworkTask extends AsyncTask> { - ForumNetworkTaskListener callback; - ForumJob type; - int id; - Activity activity; + private final ForumNetworkTaskListener callback; + private final ForumJob type; + private final int id; + private final Activity activity; public ForumNetworkTask(ForumNetworkTaskListener callback, Activity activity, ForumJob type, int id) { this.callback = callback; diff --git a/Atarashii/src/net/somethingdreadful/MAL/tasks/FriendsNetworkTask.java b/Atarashii/src/net/somethingdreadful/MAL/tasks/FriendsNetworkTask.java index c579b7ec..29dd37d8 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/tasks/FriendsNetworkTask.java +++ b/Atarashii/src/net/somethingdreadful/MAL/tasks/FriendsNetworkTask.java @@ -19,10 +19,10 @@ import retrofit.RetrofitError; public class FriendsNetworkTask extends AsyncTask> { - FriendsNetworkTaskListener callback; - private Context context; - private boolean forcesync; - Activity activity; + private final FriendsNetworkTaskListener callback; + private final Context context; + private final boolean forcesync; + private final Activity activity; public FriendsNetworkTask(Context context, boolean forcesync, FriendsNetworkTaskListener callback, Activity activity) { this.context = context; diff --git a/Atarashii/src/net/somethingdreadful/MAL/tasks/NetworkTask.java b/Atarashii/src/net/somethingdreadful/MAL/tasks/NetworkTask.java index 0633667d..92b7f35b 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/tasks/NetworkTask.java +++ b/Atarashii/src/net/somethingdreadful/MAL/tasks/NetworkTask.java @@ -23,15 +23,15 @@ import retrofit.RetrofitError; public class NetworkTask extends AsyncTask { - TaskJob job; - MALApi.ListType type; - Activity activity; - Context context; - Bundle data; - NetworkTaskListener callback; - APIAuthenticationErrorListener authErrorCallback; - Object taskResult; - TaskJob[] arrayTasks = {TaskJob.GETLIST, TaskJob.FORCESYNC, TaskJob.GETMOSTPOPULAR, TaskJob.GETTOPRATED, + private TaskJob job; + private MALApi.ListType type; + private Activity activity; + private Context context; + private Bundle data; + private NetworkTaskListener callback; + private APIAuthenticationErrorListener authErrorCallback; + private Object taskResult; + private final TaskJob[] arrayTasks = {TaskJob.GETLIST, TaskJob.FORCESYNC, TaskJob.GETMOSTPOPULAR, TaskJob.GETTOPRATED, TaskJob.GETJUSTADDED, TaskJob.GETUPCOMING, TaskJob.SEARCH, TaskJob.REVIEWS}; diff --git a/Atarashii/src/net/somethingdreadful/MAL/tasks/UserNetworkTask.java b/Atarashii/src/net/somethingdreadful/MAL/tasks/UserNetworkTask.java index 6f3576ae..c237be0b 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/tasks/UserNetworkTask.java +++ b/Atarashii/src/net/somethingdreadful/MAL/tasks/UserNetworkTask.java @@ -20,10 +20,10 @@ import retrofit.RetrofitError; public class UserNetworkTask extends AsyncTask { - Context context; - boolean forcesync; - UserNetworkTaskListener callback; - private Activity activity; + private final Context context; + private final boolean forcesync; + private final UserNetworkTaskListener callback; + private final Activity activity; public UserNetworkTask(Context context, boolean forcesync, UserNetworkTaskListener callback, Activity activity) { this.context = context; diff --git a/Atarashii/src/net/somethingdreadful/MAL/tasks/WriteDetailTask.java b/Atarashii/src/net/somethingdreadful/MAL/tasks/WriteDetailTask.java index 241bdff1..374af411 100644 --- a/Atarashii/src/net/somethingdreadful/MAL/tasks/WriteDetailTask.java +++ b/Atarashii/src/net/somethingdreadful/MAL/tasks/WriteDetailTask.java @@ -24,11 +24,11 @@ import retrofit.RetrofitError; public class WriteDetailTask extends AsyncTask { - Context context; - ListType type = ListType.ANIME; - TaskJob job; - APIAuthenticationErrorListener authErrorCallback; - private Activity activity; + private final Context context; + private ListType type = ListType.ANIME; + private final TaskJob job; + private final APIAuthenticationErrorListener authErrorCallback; + private final Activity activity; public WriteDetailTask(ListType type, TaskJob job, Context context, APIAuthenticationErrorListener authErrorCallback, Activity activity) { this.context = context; From ab5c76d4b7c837f31bef7de4a88fea22603a75df Mon Sep 17 00:00:00 2001 From: ratan12 Date: Sun, 14 Feb 2016 18:50:25 +0100 Subject: [PATCH 45/46] Cleanup resources --- .../res/drawable-hdpi/drawer_shadow.9.png | Bin 161 -> 0 bytes Atarashii/res/drawable-hdpi/ic_send.png | Bin 515 -> 0 bytes .../res/drawable-mdpi/drawer_shadow.9.png | Bin 142 -> 0 bytes Atarashii/res/drawable-mdpi/ic_send.png | Bin 352 -> 0 bytes .../res/drawable-xhdpi/drawer_shadow.9.png | Bin 174 -> 0 bytes Atarashii/res/drawable-xhdpi/ic_send.png | Bin 565 -> 0 bytes .../res/drawable-xxhdpi/drawer_shadow.9.png | Bin 208 -> 0 bytes Atarashii/res/drawable-xxhdpi/ic_send.png | Bin 822 -> 0 bytes Atarashii/res/drawable-xxxhdpi/ic_send.png | Bin 1092 -> 0 bytes Atarashii/res/drawable/card_header.xml | 1 - .../res/layout-w720dp/activity_about.xml | 1 - .../activity_detailview_details.xml | 1 - .../activity_detailview_general.xml | 2 - .../activity_detailview_personal.xml | 1 - .../layout-w720dp/fragment_profile_mal.xml | 1 - Atarashii/res/layout/activity_about.xml | 1 - Atarashii/res/layout/activity_firstrun.xml | 2 - Atarashii/res/layout/activity_settings.xml | 1 - .../res/layout/card_about_translations.xml | 1 - .../card_detailview_details_mediainfo.xml | 6 --- .../card_detailview_details_mediastats.xml | 5 --- .../card_detailview_general_personal.xml | 4 -- .../layout/card_detailview_personal_basic.xml | 12 ------ .../layout/card_detailview_personal_other.xml | 6 --- .../card_detailview_personal_rewatch.xml | 2 - Atarashii/res/layout/card_profile_details.xml | 1 - Atarashii/res/layout/dialog_manga_picker.xml | 2 - Atarashii/res/layout/dialog_status_picker.xml | 1 - Atarashii/res/layout/fragment_profile_al.xml | 1 - Atarashii/res/layout/fragment_profile_mal.xml | 1 - Atarashii/res/layout/navdrawer_header.xml | 1 - .../res/layout/record_forum_listview.xml | 37 ------------------ .../res/layout/record_friends_gridview.xml | 3 +- Atarashii/res/menu/navdrawer.xml | 4 +- 34 files changed, 2 insertions(+), 96 deletions(-) delete mode 100644 Atarashii/res/drawable-hdpi/drawer_shadow.9.png delete mode 100644 Atarashii/res/drawable-hdpi/ic_send.png delete mode 100644 Atarashii/res/drawable-mdpi/drawer_shadow.9.png delete mode 100644 Atarashii/res/drawable-mdpi/ic_send.png delete mode 100644 Atarashii/res/drawable-xhdpi/drawer_shadow.9.png delete mode 100644 Atarashii/res/drawable-xhdpi/ic_send.png delete mode 100644 Atarashii/res/drawable-xxhdpi/drawer_shadow.9.png delete mode 100644 Atarashii/res/drawable-xxhdpi/ic_send.png delete mode 100644 Atarashii/res/drawable-xxxhdpi/ic_send.png delete mode 100644 Atarashii/res/layout/record_forum_listview.xml diff --git a/Atarashii/res/drawable-hdpi/drawer_shadow.9.png b/Atarashii/res/drawable-hdpi/drawer_shadow.9.png deleted file mode 100644 index 236bff558af07faa3921ba35e2515edf62d04bb9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 161 zcmeAS@N?(olHy`uVBq!ia0vp^JV0#3!3HEVSgovp6icy_X9x!n)NrJ90QsB+9+AZi z4BVX{%xHe{^je^xv!{z=h{y5dAOHW`Gf#YA@1xt%!004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00002VoOIv0RM-N%)bBt010qN zS#tmY3ljhU3ljkVnw%H_00DbRL_t(o!|j;AR>Ck8hrf=jPPj>Y6< z$|O7hxclc7#20|wy6MC@4%Jf-Xm6U^xHM~f`Xyh|ODmu;u~FV;ET0-t?vBup4f7o~Dc$>Panz{Ys5_3IkJ=Dut;?&0#(I zg7>|oy27%yV8A_JVPF-dR)=L$=UBPa9M-2-ao!hLCK9O{FtJoEm`G|4JL3|Ap-tq4 zERec;Qn%<}Fq~pAbZF^GEsF&aZOjH-KJGPhVxE06i0inwr1}LO*|<{@MlAhd$A4h^ z+B*p&R#h~bjnAKyYJ9~qm1>mreg6WP5%W^E^xgW-fms@|D*CCf9Q!U1SLb#$!*2gs zb#26Z#p%Ne#OWTMCF1mAfk2#2;1Qn9zEN&xFRv@4{%ojqC*q3Y+zSg2ac(7(r#NXb zs3J~M<~rqEp8`J7tThkA&aq6xTulVMbZIWi8rXlsz5($PxaEKa74ZN7002ovPDHLk FV1nhd)J*^Y diff --git a/Atarashii/res/drawable-mdpi/drawer_shadow.9.png b/Atarashii/res/drawable-mdpi/drawer_shadow.9.png deleted file mode 100644 index ffe3a28d77c72094021013c6442560803b3d344c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 142 zcmeAS@N?(olHy`uVBq!ia0vp^96+qZ!3HFgEN0vWQY^(zo*^7SP{WbZ0pxQQctjR6 zFmQK*Fr)d&(`$i(2A(dCAr_~TfBgS%&&>BhUX5L;x$y=|hic;t)=0q~!&M0(2Uj#r iT+R^X@#lD(V-Z7IzK5^$|k0wldT1B8K;Lb6AYF9SoB8UsT^3j@P1pisjL z28L1t28LG&3=CE?7#PG0=Ijcz0ZK3>dAqwX{BQ3+vmeOgEbxddW?AL~`x1rW}?Jxo?=F4jO4N$iMJ$(A&xU$0E+I zGIx{bJH3;wxk^84FU*`(#~t8*daCr@DglS%b0?MAX3Q`ZDZA)@K_D%VGewNI(Pxq2 zgs2eqppI9Lf`QT+3cuJ=W%f>-9Oe3avYD!Usbi9s(?08bak5Rc<;uP@|nU=UzFz%6x@#ly{E6Z5RU$2Hhw*i>Gs`(~~C zr~2_>(e4Ka`gpa)&de}Ks*u{@U5E@m-v9X3<$3NT3r3p*`<7|@n1Ecw;OXk;vd$@? F2>^8yH@N@+ diff --git a/Atarashii/res/drawable-xhdpi/ic_send.png b/Atarashii/res/drawable-xhdpi/ic_send.png deleted file mode 100644 index 2c7a80266242bf7f54b74bcb9cbe98281e7f2088..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 565 zcmV-50?Pe~P)004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00002VoOIv0RM-N%)bBt010qN zS#tmY3ljhU3ljkVnw%H_00FH@L_t(&-tF02Zh}w{fZ^Z91=I!9ChZ!#5l9regNo~@ ztuCap1xzmwgjACP=Q1;r=HRO)U*-ql9A-~U>zE}_0wquaO$xMQ#S6`JK%d-D^URu$ z>3{%EY{}V82h<)1a{GWoAb^^Z!ZP3(s0*0!b`8)Mv)*qS1#|})1@r?M1oQ_f2Mh(N z1-t}(d;eZMU@S;HpbV%BxaK$=P#dr!j|(UZYL7iRo6vw7ps0Xapx}U-prC;IAkTm{ zpe|s>yB}!5!`Wxa+&7t9I|8c6*h?pSJOkW$Br7PWB~EIe8T6gh85>UFmwng_Mk4wAF~-lp z;kp{Wb;!-2KT_p>>(IQp_C~q}XfTrf1KLO=J5WPKKK=w`1M-Muu?+HxqzMX&qy-9& zqydUrt4eRjIISgYHmr`6l)4*M?jXTPu^{nCF`$}4K2j*?K&BIE2-Np#K{b*e$RLtC z$S9HvNMQ3)4rKm@YzXwq%080R?neS8Py!{;KLz~&$HDh8V7w~v00000NkvXXu0mjf D^l|4S diff --git a/Atarashii/res/drawable-xxhdpi/drawer_shadow.9.png b/Atarashii/res/drawable-xxhdpi/drawer_shadow.9.png deleted file mode 100644 index b91e9d7f285e8110ba3ba4e72cc6f0416eb3a30a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 208 zcmeAS@N?(olHy`uVBq!ia0vp^VnCe4!3HEl*p=S^DajJoh?3y^w370~qErUQl>DSr z1<%~X^wgl##FWaylc_d9MMa)2jv*QM-d<4Ta$*#5x!8O#VbcvCx78OjjCM19-`|n` zlcQ;yJWqK-!X?h+v^9}Es?F+hJ07=b>sdT*QRcgm+^%b8|A7C`|A*gYPjm3$2miRv cpZdzQt0C%<%j~>EK-(ESUHx3vIVCg!0CP)0sQ>@~ diff --git a/Atarashii/res/drawable-xxhdpi/ic_send.png b/Atarashii/res/drawable-xxhdpi/ic_send.png deleted file mode 100644 index 899f6e4090a94fec64acd3045c3b1808ed1f6bd6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 822 zcmV-61Ihe}P)004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00002VoOIv0RM-N%)bBt010qN zS#tmY3ljhU3ljkVnw%H_00OQ_L_t(|+U?v=PQpMG$MGMEuJr(7qL=YPUZgEsK|O;a z=t0!ViW8`8{ELgm2%*^N%$qlFCa>;HL_c}ol+u~nIYpXBM_~$6n8FmMFoh{hVG3&j zJHZ6sDZ<_`Lmy{&P7k&VV2(>i43z2_K9uFR}&N_ zElg0D^sp+-TV%Kn8KxiDUzlfjkpug}7TN31agH1h>A`}9$pH%zCLfGB%sSXNIv#%` zQ<(g)-!Kade1;hc<~_`iuqw<6avx#V!T7HiO7yA2lmP>PS6onrDF;RzrYsm?m=a-C znCB>5!jua84Ku^Y?(dNda|*K#wvVHwub#yn5FcUYcyxuW9$oZSp!;!z*?y@u>^zOb zbX|iEF;Al~sTbF|=DENa`F~;h-8JBQo+Szl@X8P4nCFHtL+{4l2Ycwvn3HN)sOVzS1^0SgkJZ&004R> z004l5008;`004mK004C`008P>0026e000+ooVrmw00002VoOIv0RM-N%)bBt010qN zS#tmY3ljhU3ljkVnw%H_00X>9L_t(|+U?!jZqq;z#_HR+kBpe2E84o$*gZ7WiU*kt3(u4l&I_6|ggewu%5H(9&&l&}`97JvW*AOHaf zKmY;|fUp1rAOHafKmY;|fUrV<4(KJlqH6&8{^lFqr?2#!cIXp;d_eh{&4P~exUDkZ|+a>;I`=!Kt7-{xc6?B4gur?YFu#DfXd*Wxg*?VbAf))-KGCJ z4=$q~fEF*)!EpeY4$cqslkTkey-Wtj31l)jexPY^+jIq>#lgLEv(&Q-bWOJzzW;?o z+SMFfY#{Z)r2xv;xVVPvSppi-E%u+LFu1fp3WG}zGz~7JK7b4a=LZ_oMuMOJrMQN> z0+8C^BmkA`+y%EMFE~HYgl;DP-v|s&7En34`88Z0KuUs>3M3{tKhQ6_Az;Gu;4(S_ z(DLAR-Ki^p7OY_r+-EsJzo{ketgVLNbODv?tT@7r03;$ftw3dPZ`~{%)dlp2bgan1 z=?97&oDHCe!Px+3llazA6P5XFHVK`C2)+6#K=b&DWUr-7Fo;0g^dirw-}O^5E*< zaaiYk1q3H=OJ?f%%7e@3L=R9s^W_ar+os-_^ED{0;Rd>aV$av8IHf$X1GM!I&;tgb z{1xd`b7D_sKprwD)^T4$Z73>f){E|F5&+nhGCY@I=+-csJf65bNhTtO2n{6$+%`L!42fvH=t^ zD*Zr_qtXn-_PH?*AbFcv5=EsE=-kcC9=1aXi7FIG!j{Z#9XrHy0M!_kbf6@Ac(ekE zh$<8){jDj4L?sWX_O0KNfdobs3KahaOG5AWA^}KrRCNQ1zvon)Ko`Z4%E)a3xoaIYtfRsg*7D!=Kp+M{2E?I3NM-I5vx3S zB(oG1Cy>dgLV=b&{K#xn96+X{S`Wy`(=y@!HROq6p+NHwfox1vs{%FPA#2rv8W~k6 z&;h+@=95)Jfv^AsAOHafKmY;|fB=LAAOHafKmY;|fB=Lwzy1OYUhr_<;-JR>0000< KMNUMnLSTZs=GUeG diff --git a/Atarashii/res/drawable/card_header.xml b/Atarashii/res/drawable/card_header.xml index b0a1eef5..ed6377a2 100644 --- a/Atarashii/res/drawable/card_header.xml +++ b/Atarashii/res/drawable/card_header.xml @@ -1,6 +1,5 @@ diff --git a/Atarashii/res/layout-w720dp/activity_detailview_general.xml b/Atarashii/res/layout-w720dp/activity_detailview_general.xml index 25ed6ea8..8bf4302f 100644 --- a/Atarashii/res/layout-w720dp/activity_detailview_general.xml +++ b/Atarashii/res/layout-w720dp/activity_detailview_general.xml @@ -9,7 +9,6 @@ android:id="@+id/scrollView"> @@ -44,7 +43,6 @@ diff --git a/Atarashii/res/layout-w720dp/fragment_profile_mal.xml b/Atarashii/res/layout-w720dp/fragment_profile_mal.xml index f6ca28fe..bdb9cca0 100644 --- a/Atarashii/res/layout-w720dp/fragment_profile_mal.xml +++ b/Atarashii/res/layout-w720dp/fragment_profile_mal.xml @@ -13,7 +13,6 @@ android:layout_height="fill_parent"> diff --git a/Atarashii/res/layout/activity_about.xml b/Atarashii/res/layout/activity_about.xml index 84242095..343f5b1c 100644 --- a/Atarashii/res/layout/activity_about.xml +++ b/Atarashii/res/layout/activity_about.xml @@ -10,7 +10,6 @@ android:layout_height="fill_parent"> diff --git a/Atarashii/res/layout/activity_firstrun.xml b/Atarashii/res/layout/activity_firstrun.xml index cfc8c01a..460b99c6 100644 --- a/Atarashii/res/layout/activity_firstrun.xml +++ b/Atarashii/res/layout/activity_firstrun.xml @@ -88,7 +88,6 @@ android:textSize="16sp" /> diff --git a/Atarashii/res/layout/activity_settings.xml b/Atarashii/res/layout/activity_settings.xml index 12a4cc3a..2313454c 100644 --- a/Atarashii/res/layout/activity_settings.xml +++ b/Atarashii/res/layout/activity_settings.xml @@ -4,7 +4,6 @@ android:layout_height="match_parent"> diff --git a/Atarashii/res/layout/card_detailview_personal_basic.xml b/Atarashii/res/layout/card_detailview_personal_basic.xml index 7a21225a..feee29fc 100644 --- a/Atarashii/res/layout/card_detailview_personal_basic.xml +++ b/Atarashii/res/layout/card_detailview_personal_basic.xml @@ -18,13 +18,11 @@ android:background="@drawable/highlite_details"> diff --git a/Atarashii/res/layout/fragment_profile_al.xml b/Atarashii/res/layout/fragment_profile_al.xml index 39a53dab..b97021e0 100644 --- a/Atarashii/res/layout/fragment_profile_al.xml +++ b/Atarashii/res/layout/fragment_profile_al.xml @@ -13,7 +13,6 @@ android:layout_height="fill_parent"> diff --git a/Atarashii/res/layout/fragment_profile_mal.xml b/Atarashii/res/layout/fragment_profile_mal.xml index 104dd38a..3cd90300 100644 --- a/Atarashii/res/layout/fragment_profile_mal.xml +++ b/Atarashii/res/layout/fragment_profile_mal.xml @@ -13,7 +13,6 @@ android:layout_height="fill_parent"> diff --git a/Atarashii/res/layout/navdrawer_header.xml b/Atarashii/res/layout/navdrawer_header.xml index 47730c89..1f422a1a 100644 --- a/Atarashii/res/layout/navdrawer_header.xml +++ b/Atarashii/res/layout/navdrawer_header.xml @@ -1,5 +1,4 @@ diff --git a/Atarashii/res/layout/record_forum_listview.xml b/Atarashii/res/layout/record_forum_listview.xml deleted file mode 100644 index 08c00a27..00000000 --- a/Atarashii/res/layout/record_forum_listview.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/Atarashii/res/layout/record_friends_gridview.xml b/Atarashii/res/layout/record_friends_gridview.xml index b29a5ae4..30eb81a1 100644 --- a/Atarashii/res/layout/record_friends_gridview.xml +++ b/Atarashii/res/layout/record_friends_gridview.xml @@ -20,8 +20,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" - android:layout_marginLeft="72dp" - android:id="@+id/relativeLayout"> + android:layout_marginLeft="72dp"> - + Date: Sun, 14 Feb 2016 18:56:12 +0100 Subject: [PATCH 46/46] Fix settings crash --- Atarashii/res/layout/activity_settings.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/Atarashii/res/layout/activity_settings.xml b/Atarashii/res/layout/activity_settings.xml index 2313454c..12a4cc3a 100644 --- a/Atarashii/res/layout/activity_settings.xml +++ b/Atarashii/res/layout/activity_settings.xml @@ -4,6 +4,7 @@ android:layout_height="match_parent">