aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlaco0416 <laco0416@gmail.com>2014-09-15 01:28:22 +0900
committerlaco0416 <laco0416@gmail.com>2014-09-15 01:28:22 +0900
commitaea0415636391dc6dd6919f976ff37c846503278 (patch)
tree4397df138b77a197a94c7c05b185234eeea0c8a4
parentaaaa8dc2abff7530fbee0954fc6174bba6bb092e (diff)
downloadSmileEssence-aea0415636391dc6dd6919f976ff37c846503278.tar.gz
Close #61 Review command is back!!!!
-rw-r--r--res/layout/dialog_review.xml67
-rw-r--r--res/values-ja/strings.xml3
-rw-r--r--res/values/commands.xml1
-rw-r--r--res/values/strings.xml3
-rw-r--r--src/net/lacolaco/smileessence/command/Command.java1
-rw-r--r--src/net/lacolaco/smileessence/command/status/StatusCommandReview.java67
-rw-r--r--src/net/lacolaco/smileessence/twitter/util/TwitterUtils.java2
-rw-r--r--src/net/lacolaco/smileessence/view/dialog/ReviewDialogFragment.java138
8 files changed, 281 insertions, 1 deletions
diff --git a/res/layout/dialog_review.xml b/res/layout/dialog_review.xml
new file mode 100644
index 00000000..79a348a1
--- /dev/null
+++ b/res/layout/dialog_review.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ ~ The MIT License (MIT)
+ ~
+ ~ Copyright (c) 2012-2014 lacolaco.net
+ ~
+ ~ Permission is hereby granted, free of charge, to any person obtaining a copy
+ ~ of this software and associated documentation files (the "Software"), to deal
+ ~ in the Software without restriction, including without limitation the rights
+ ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ ~ copies of the Software, and to permit persons to whom the Software is
+ ~ furnished to do so, subject to the following conditions:
+ ~
+ ~ The above copyright notice and this permission notice shall be included in all
+ ~ copies or substantial portions of the Software.
+ ~
+ ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ ~ SOFTWARE.
+ -->
+
+<LinearLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:padding="15dp"
+ android:background="?attr/page_background">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginLeft="5dp"
+ android:layout_marginTop="5dp"
+ android:text="@string/dialog_review_rating_text"
+ android:textAppearance="?android:attr/textAppearanceMedium"/>
+
+ <RatingBar
+ android:id="@+id/rating_review"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:max="5"
+ android:rating="1"
+ android:stepSize="1"/>
+
+ <FrameLayout
+ android:layout_width="match_parent"
+ android:layout_height="40dp"
+ android:layout_gravity="fill"
+ android:background="?attr/button_round_blue">
+
+ <Button
+ android:id="@+id/button_submit"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ style="?attr/custom_button_transparent"
+ android:text="@string/alert_dialog_ok"
+ android:textStyle="bold"
+ android:textColor="?attr/button_blue_foreground"/>
+ </FrameLayout>
+</LinearLayout> \ No newline at end of file
diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml
index 80736b39..2578e219 100644
--- a/res/values-ja/strings.xml
+++ b/res/values-ja/strings.xml
@@ -72,6 +72,7 @@
<string name="format_event_message">%sからのDMを受信</string>
<string name="format_status_command_nanigaja">な~にが%sじゃ</string>
<string name="format_status_command_make_anonymous">???「%s」</string>
+ <string name="format_status_review">%1$s\r\nコメント: \r\n@%2$s ( %3$s )</string>
<string name="setting_category_display_title">表示設定</string>
<string name="setting_category_display_summary">再起動後に有効になります</string>
<string name="setting_text_size_title">文字サイズ</string>
@@ -137,6 +138,7 @@
<string name="dialog_confirm_commands">実行しますか?</string>
<string name="dialog_confirm_clear_account">本当に認証を削除しますか?</string>
<string name="dialog_confirm_delete_query">クエリを削除しますか?</string>
+ <string name="dialog_review_rating_text">星いくつ付けますか?</string>
<string name="notice_tweet_succeeded">投稿しました</string>
<string name="notice_tweet_failed">投稿失敗しました</string>
<string name="notice_favorite_succeeded">ふぁぼりました</string>
@@ -220,6 +222,7 @@
<string name="command_status_add_to_ignore">以後このツイートを無視する</string>
<string name="command_status_copy">入力欄にコピーする</string>
<string name="command_status_congratulate">お祝いする</string>
+ <string name="command_status_review">レビューする</string>
<string name="command_post_morse">モールスに変換する</string>
<string name="command_post_zekamashi">ぜかまし</string>
<string name="command_open_template_list">定型文を挿入する</string>
diff --git a/res/values/commands.xml b/res/values/commands.xml
index 5c9b6bef..f84cd1d4 100644
--- a/res/values/commands.xml
+++ b/res/values/commands.xml
@@ -49,4 +49,5 @@
<item name="key_command_status_search_on_google" type="id"/>
<item name="key_command_status_copy" type="id"/>
<item name="key_command_status_congratulate" type="id"/>
+ <item name="key_command_status_review" type="id"/>
</resources> \ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 85370842..c0272dc5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -71,6 +71,7 @@
<string name="format_event_message">Received %s\'s message</string>
<string name="format_status_command_nanigaja">What\'s %s</string>
<string name="format_status_command_make_anonymous">"??? said \"%s\""</string>
+ <string name="format_status_review">%1$s\r\nCommant: \r\n@%2$s ( %3$s )</string>
<string name="text_message_to_author">" #SmileEssence @laco0416 [%s]"</string>
<string name="setting_category_display_title">Display Setting</string>
<string name="setting_category_display_summary">Enable at next launch.</string>
@@ -136,6 +137,7 @@
<string name="dialog_confirm_clear_account">Clear authentication, Really?</string>
<string name="dialog_title_talk_chain">Talk View</string>
<string name="dialog_title_select_userlist">Select a list</string>
+ <string name="dialog_review_rating_text">How many favs will you give?</string>
<string name="dialog_confirm_delete_query">Delete this query, OK?</string>
<string name="notice_favorite_succeeded">Succeeded to favorite</string>
<string name="notice_favorite_failed">Failed to favorite</string>
@@ -220,6 +222,7 @@
<string name="command_status_add_to_ignore">Ignore this tweet in future</string>
<string name="command_status_copy">Copy to input area</string>
<string name="command_status_congratulate">Congratulate</string>
+ <string name="command_status_review">Review this tweet</string>
<string name="command_post_morse">Parse to morse</string>
<string name="command_post_zekamashi">Zekamasize</string>
<string name="command_open_template_list">Insert Templates</string>
diff --git a/src/net/lacolaco/smileessence/command/Command.java b/src/net/lacolaco/smileessence/command/Command.java
index fcc27e17..608d6edb 100644
--- a/src/net/lacolaco/smileessence/command/Command.java
+++ b/src/net/lacolaco/smileessence/command/Command.java
@@ -100,6 +100,7 @@ public abstract class Command implements IViewModel
commands.add(new StatusCommandNanigaja(activity, status, account));
commands.add(new StatusCommandMakeAnonymous(activity, status, account));
commands.add(new StatusCommandCongratulate(activity, status, account));
+ commands.add(new StatusCommandReview(activity, status));
commands.add(new StatusCommandAddToIgnore(activity, status));
return commands;
}
diff --git a/src/net/lacolaco/smileessence/command/status/StatusCommandReview.java b/src/net/lacolaco/smileessence/command/status/StatusCommandReview.java
new file mode 100644
index 00000000..3d5d5a77
--- /dev/null
+++ b/src/net/lacolaco/smileessence/command/status/StatusCommandReview.java
@@ -0,0 +1,67 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2012-2014 lacolaco.net
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package net.lacolaco.smileessence.command.status;
+
+import android.app.Activity;
+import net.lacolaco.smileessence.R;
+import net.lacolaco.smileessence.view.dialog.DialogHelper;
+import net.lacolaco.smileessence.view.dialog.ReviewDialogFragment;
+import twitter4j.Status;
+
+public class StatusCommandReview extends StatusCommand
+{
+
+ // --------------------------- CONSTRUCTORS ---------------------------
+
+ public StatusCommandReview(Activity activity, Status status)
+ {
+ super(R.id.key_command_status_review, activity, status);
+ }
+
+ // --------------------- GETTER / SETTER METHODS ---------------------
+
+ @Override
+ public String getText()
+ {
+ return getActivity().getString(R.string.command_status_review);
+ }
+
+ @Override
+ public boolean isEnabled()
+ {
+ return !getOriginalStatus().getUser().isProtected();
+ }
+
+ // -------------------------- OTHER METHODS --------------------------
+
+ @Override
+ public boolean execute()
+ {
+ ReviewDialogFragment dialogFragment = new ReviewDialogFragment();
+ dialogFragment.setStatusID(getOriginalStatus().getId());
+ DialogHelper.showDialog(getActivity(), dialogFragment);
+ return false;
+ }
+}
diff --git a/src/net/lacolaco/smileessence/twitter/util/TwitterUtils.java b/src/net/lacolaco/smileessence/twitter/util/TwitterUtils.java
index 97fddaeb..e54cfb65 100644
--- a/src/net/lacolaco/smileessence/twitter/util/TwitterUtils.java
+++ b/src/net/lacolaco/smileessence/twitter/util/TwitterUtils.java
@@ -238,7 +238,7 @@ public class TwitterUtils
*/
public static String getStatusURL(Status status)
{
- return String.format("https://twitter.com/%s/status/%s", status.getUser().getScreenName(), status.getId());
+ return String.format("https://twitter.com/%s/status/%s", getOriginalStatus(status).getUser().getScreenName(), getOriginalStatus(status).getId());
}
/**
diff --git a/src/net/lacolaco/smileessence/view/dialog/ReviewDialogFragment.java b/src/net/lacolaco/smileessence/view/dialog/ReviewDialogFragment.java
new file mode 100644
index 00000000..432b2ddc
--- /dev/null
+++ b/src/net/lacolaco/smileessence/view/dialog/ReviewDialogFragment.java
@@ -0,0 +1,138 @@
+/*
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2012-2014 lacolaco.net
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package net.lacolaco.smileessence.view.dialog;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.DialogFragment;
+import android.content.Context;
+import android.os.Bundle;
+import android.view.View;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.Button;
+import android.widget.RatingBar;
+import net.lacolaco.smileessence.R;
+import net.lacolaco.smileessence.activity.MainActivity;
+import net.lacolaco.smileessence.data.StatusCache;
+import net.lacolaco.smileessence.twitter.util.TwitterUtils;
+import net.lacolaco.smileessence.view.adapter.PostState;
+import twitter4j.Status;
+
+public class ReviewDialogFragment extends DialogFragment implements View.OnClickListener
+{
+
+ // ------------------------------ FIELDS ------------------------------
+
+ private static String statusIDKey = "key";
+ private long statusID;
+ private RatingBar ratingBar;
+
+ // --------------------- GETTER / SETTER METHODS ---------------------
+
+ public void setStatusID(long statusID)
+ {
+ Bundle args = new Bundle();
+ args.putLong(statusIDKey, statusID);
+ setArguments(args);
+ }
+
+ // ------------------------ INTERFACE METHODS ------------------------
+
+
+ // --------------------- Interface OnClickListener ---------------------
+
+ @Override
+ public void onClick(View v)
+ {
+ int id = v.getId();
+ switch(id)
+ {
+ case R.id.button_submit:
+ {
+ execute();
+ break;
+ }
+ }
+ }
+
+ // ------------------------ OVERRIDE METHODS ------------------------
+
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ Bundle args = getArguments();
+ statusID = args.getLong(statusIDKey);
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState)
+ {
+ View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_review, null);
+ ratingBar = (RatingBar) view.findViewById(R.id.rating_review);
+ Button button = (Button) view.findViewById(R.id.button_submit);
+ button.setOnClickListener(this);
+ return new AlertDialog.Builder(getActivity())
+ .setView(view)
+ .create();
+ }
+
+ private void hideIME()
+ {
+ InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.hideSoftInputFromWindow(ratingBar.getWindowToken(), 0);
+ }
+
+ private void execute()
+ {
+ hideIME();
+ Status status = StatusCache.getInstance().get(statusID);
+ int star = (int) ratingBar.getRating();
+ StringBuilder builder = new StringBuilder();
+ for(int i = 0; i < 5; i++)
+ {
+ if(i < star)
+ {
+ builder.append("★");
+ }
+ else
+ {
+ builder.append("☆");
+ }
+ }
+ String formatString = getFormatString();
+ String str = String.format(formatString,
+ builder.toString(), TwitterUtils.getOriginalStatus(status).getUser().getScreenName(), TwitterUtils.getStatusURL(status));
+ PostState.newState().beginTransaction()
+ .setText(str)
+ .setCursor(str.indexOf(":") + 2)
+ .commitWithOpen((MainActivity) getActivity());
+ }
+
+ private String getFormatString()
+ {
+ return getString(R.string.format_status_review);
+ }
+}