aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2015-10-12 01:36:55 +0900
committerKazuki Yamaguchi <k@rhe.jp>2015-10-12 01:36:55 +0900
commitd9d4df5bde3522df703c7278bb5aeca1f5cbf23b (patch)
tree962171b8d0adfd0a2d13855cd8a05fd85bff758a
parent7431b2bda549a59f9cd0c6ee15f73018b56deaeb (diff)
downloadSmileEssence-d9d4df5bde3522df703c7278bb5aeca1f5cbf23b.tar.gz
Command: ツイート本文と同じ文字サイズをコマンドによるメニューの文字サイズにつかう
-rw-r--r--app/src/main/java/net/lacolaco/smileessence/activity/EditExtractionActivity.java4
-rw-r--r--app/src/main/java/net/lacolaco/smileessence/command/Command.java6
-rw-r--r--app/src/main/java/net/lacolaco/smileessence/entity/Template.java4
-rw-r--r--app/src/main/java/net/lacolaco/smileessence/view/ExpandedListView.java29
-rw-r--r--app/src/main/java/net/lacolaco/smileessence/view/dialog/MessageDetailDialogFragment.java107
-rw-r--r--app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusDetailDialogFragment.java52
-rw-r--r--app/src/main/res/layout/dialog_status_detail.xml28
-rw-r--r--app/src/main/res/layout/list_item_simple_text.xml41
-rw-r--r--app/src/main/res/layout/menu_item_simple_text.xml6
9 files changed, 203 insertions, 74 deletions
diff --git a/app/src/main/java/net/lacolaco/smileessence/activity/EditExtractionActivity.java b/app/src/main/java/net/lacolaco/smileessence/activity/EditExtractionActivity.java
index 9db52c25..c4e998f6 100644
--- a/app/src/main/java/net/lacolaco/smileessence/activity/EditExtractionActivity.java
+++ b/app/src/main/java/net/lacolaco/smileessence/activity/EditExtractionActivity.java
@@ -223,9 +223,9 @@ public class EditExtractionActivity extends Activity implements AdapterView.OnIt
@Override
public View getView(Activity activity, LayoutInflater inflater, View convertedView) {
if (convertedView == null) {
- convertedView = inflater.inflate(R.layout.menu_item_simple_text, null);
+ convertedView = inflater.inflate(R.layout.list_item_simple_text, null);
}
- TextView textView = (TextView) convertedView.findViewById(R.id.textView_menuItem_simple);
+ TextView textView = (TextView) convertedView.findViewById(R.id.list_item_textview);
textView.setText(ew.getPatternString());
return convertedView;
}
diff --git a/app/src/main/java/net/lacolaco/smileessence/command/Command.java b/app/src/main/java/net/lacolaco/smileessence/command/Command.java
index 2bee06e9..b1b4b194 100644
--- a/app/src/main/java/net/lacolaco/smileessence/command/Command.java
+++ b/app/src/main/java/net/lacolaco/smileessence/command/Command.java
@@ -39,6 +39,7 @@ import net.lacolaco.smileessence.entity.CommandSetting;
import net.lacolaco.smileessence.entity.DirectMessage;
import net.lacolaco.smileessence.entity.Tweet;
import net.lacolaco.smileessence.entity.User;
+import net.lacolaco.smileessence.preference.UserPreferenceHelper;
import net.lacolaco.smileessence.viewmodel.IViewModel;
import java.util.ArrayList;
@@ -142,11 +143,12 @@ public abstract class Command implements IViewModel {
// --------------------- Interface IViewModel ---------------------
@Override
- public View getView(Activity activity, LayoutInflater inflater, View convertedView) {
+ public final View getView(Activity activity, LayoutInflater inflater, View convertedView) {
if (convertedView == null) {
convertedView = inflater.inflate(R.layout.menu_item_simple_text, null);
}
- TextView textView = (TextView) convertedView.findViewById(R.id.textView_menuItem_simple);
+ TextView textView = (TextView) convertedView.findViewById(R.id.list_item_textview);
+ textView.setTextSize(UserPreferenceHelper.getInstance().getTextSize());
textView.setText(getText());
return convertedView;
}
diff --git a/app/src/main/java/net/lacolaco/smileessence/entity/Template.java b/app/src/main/java/net/lacolaco/smileessence/entity/Template.java
index 089c4493..ce6de3b3 100644
--- a/app/src/main/java/net/lacolaco/smileessence/entity/Template.java
+++ b/app/src/main/java/net/lacolaco/smileessence/entity/Template.java
@@ -73,9 +73,9 @@ public class Template extends Model implements IViewModel {
@Override
public View getView(Activity activity, LayoutInflater inflater, View convertedView) {
if (convertedView == null) {
- convertedView = inflater.inflate(R.layout.menu_item_simple_text, null);
+ convertedView = inflater.inflate(R.layout.list_item_simple_text, null);
}
- TextView textView = (TextView) convertedView.findViewById(R.id.textView_menuItem_simple);
+ TextView textView = (TextView) convertedView.findViewById(R.id.list_item_textview);
textView.setText(this.text);
return convertedView;
}
diff --git a/app/src/main/java/net/lacolaco/smileessence/view/ExpandedListView.java b/app/src/main/java/net/lacolaco/smileessence/view/ExpandedListView.java
new file mode 100644
index 00000000..e0a4a651
--- /dev/null
+++ b/app/src/main/java/net/lacolaco/smileessence/view/ExpandedListView.java
@@ -0,0 +1,29 @@
+package net.lacolaco.smileessence.view;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.ViewGroup;
+import android.widget.ListView;
+
+public class ExpandedListView extends ListView {
+ public ExpandedListView(Context context) {
+ super(context);
+ }
+
+ public ExpandedListView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public ExpandedListView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ @Override
+ public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
+ super.onMeasure(widthMeasureSpec, expandSpec);
+
+ ViewGroup.LayoutParams params = getLayoutParams();
+ params.height = getMeasuredHeight();
+ }
+}
diff --git a/app/src/main/java/net/lacolaco/smileessence/view/dialog/MessageDetailDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/MessageDetailDialogFragment.java
index db4c309f..f2aaae61 100644
--- a/app/src/main/java/net/lacolaco/smileessence/view/dialog/MessageDetailDialogFragment.java
+++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/MessageDetailDialogFragment.java
@@ -28,25 +28,26 @@ import android.app.AlertDialog;
import android.app.Dialog;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
-import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.ImageButton;
-import android.widget.LinearLayout;
import android.widget.ListView;
import net.lacolaco.smileessence.Application;
import net.lacolaco.smileessence.R;
import net.lacolaco.smileessence.activity.MainActivity;
import net.lacolaco.smileessence.command.Command;
import net.lacolaco.smileessence.command.CommandOpenURL;
+import net.lacolaco.smileessence.command.CommandOpenUserDetail;
+import net.lacolaco.smileessence.entity.Account;
import net.lacolaco.smileessence.entity.DirectMessage;
import net.lacolaco.smileessence.notification.Notificator;
import net.lacolaco.smileessence.twitter.task.DeleteMessageTask;
import net.lacolaco.smileessence.view.DialogHelper;
import net.lacolaco.smileessence.view.adapter.MessageListAdapter;
-import net.lacolaco.smileessence.view.listener.ListItemClickListener;
+import net.lacolaco.smileessence.view.adapter.UnorderedCustomListAdapter;
import net.lacolaco.smileessence.viewmodel.MessageViewModel;
import java.util.ArrayList;
+import java.util.List;
public class MessageDetailDialogFragment extends StackableDialogFragment implements View.OnClickListener {
@@ -152,53 +153,85 @@ public class MessageDetailDialogFragment extends StackableDialogFragment impleme
DialogHelper.showDialog(getActivity(), dialogFragment);
}
- private ArrayList<Command> getCommands() {
- ArrayList<Command> commands = new ArrayList<>();
- // URL
- for (String url : message.getUrlsExpanded()) {
- commands.add(new CommandOpenURL(getActivity(), url));
- }
- for (String url : message.getMediaUrls()) {
- commands.add(new CommandOpenURL(getActivity(), url));
- }
- return commands;
- }
-
private View getTitleView() {
MainActivity activity = (MainActivity) getActivity();
+
View view = activity.getLayoutInflater().inflate(R.layout.dialog_status_detail, null);
- View messageHeader = view.findViewById(R.id.layout_status_header);
+
MessageViewModel statusViewModel = new MessageViewModel(message);
- messageHeader = statusViewModel.getView(activity, activity.getLayoutInflater(), messageHeader);
+ View messageHeader = statusViewModel.getView(activity, activity.getLayoutInflater(), view.findViewById(R.id.layout_status_header));
messageHeader.setClickable(false);
- int background = ((ColorDrawable) messageHeader.getBackground()).getColor();
- view.setBackgroundColor(background);
- ImageButton reply = (ImageButton) view.findViewById(R.id.button_status_detail_reply);
- reply.setOnClickListener(this);
- ImageButton delete = (ImageButton) view.findViewById(R.id.button_status_detail_delete);
- delete.setVisibility(Application.getInstance().getCurrentAccount().canDelete(message) ? View.VISIBLE : View.GONE);
- delete.setOnClickListener(this);
- ImageButton menuButton = (ImageButton) view.findViewById(R.id.button_status_detail_menu);
- menuButton.setOnClickListener(this);
- LinearLayout commandsLayout = (LinearLayout) view.findViewById(R.id.linearlayout_status_detail_menu);
- commandsLayout.setClickable(true);
- // commands
- ArrayList<Command> commands = getCommands();
- Command.filter(commands);
- for (final Command command : commands) {
- View commandView = command.getView(activity, activity.getLayoutInflater(), null);
- commandView.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.transparent));
- commandView.setOnClickListener(new ListItemClickListener(activity, command::execute));
- commandsLayout.addView(commandView);
- }
+
+ view.setBackgroundColor(((ColorDrawable) messageHeader.getBackground()).getColor());
+ updateViewButtons(view);
+ updateViewMenu(view);
+
// status only parts
+ view.findViewById(R.id.detail_dialog_divider_top).setVisibility(View.GONE);
view.findViewById(R.id.button_status_detail_retweet).setVisibility(View.GONE);
view.findViewById(R.id.button_status_detail_favorite).setVisibility(View.GONE);
view.findViewById(R.id.image_status_detail_fav_count).setVisibility(View.GONE);
view.findViewById(R.id.image_status_detail_rt_count).setVisibility(View.GONE);
+
return view;
}
+ private void updateViewButtons(View view) {
+ Account account = Application.getInstance().getCurrentAccount();
+
+ //--- buttons
+ ImageButton reply = (ImageButton) view.findViewById(R.id.button_status_detail_reply);
+ reply.setOnClickListener(this);
+
+ ImageButton delete = (ImageButton) view.findViewById(R.id.button_status_detail_delete);
+ delete.setOnClickListener(this);
+ delete.setVisibility(account.canDelete(message) ? View.VISIBLE : View.GONE);
+ }
+
+ private void updateViewMenu(View view) {
+ MainActivity activity = ((MainActivity) getActivity());
+ // -- menu dialog
+ ImageButton menu = (ImageButton) view.findViewById(R.id.button_status_detail_menu);
+ menu.setOnClickListener(this);
+
+ // -- menu embedded in dialog
+ View divider = view.findViewById(R.id.detail_dialog_divider_bottom);
+ ListView listView = (ListView) view.findViewById(R.id.listview_status_detail_menu);
+ List<Command> commands = getCommands();
+ Command.filter(commands);
+ if (commands.size() > 0) {
+ divider.setVisibility(View.VISIBLE);
+ listView.setVisibility(View.VISIBLE);
+ final UnorderedCustomListAdapter<Command> adapter = new UnorderedCustomListAdapter<>(activity);
+ adapter.addItemsToBottom(commands);
+ adapter.updateForce();
+ listView.setAdapter(adapter);
+ listView.setOnItemClickListener((parent, view1, position, id) -> {
+ Command command = (Command) parent.getItemAtPosition(position);
+ command.execute();
+ });
+ } else {
+ divider.setVisibility(View.GONE);
+ listView.setVisibility(View.GONE);
+ }
+ }
+
+ private List<Command> getCommands() {
+ List<Command> commands = new ArrayList<>();
+ // Mentions
+ for (String screenName : message.getMentions()) {
+ commands.add(new CommandOpenUserDetail(getActivity(), screenName));
+ }
+ // URL
+ for (String url : message.getUrlsExpanded()) {
+ commands.add(new CommandOpenURL(getActivity(), url));
+ }
+ for (String url : message.getMediaUrls()) {
+ commands.add(new CommandOpenURL(getActivity(), url));
+ }
+ return commands;
+ }
+
private void openMenu() {
MessageMenuDialogFragment fragment = new MessageMenuDialogFragment();
fragment.setMessageID(getMessageID());
diff --git a/app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusDetailDialogFragment.java b/app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusDetailDialogFragment.java
index 2f0d7c91..ed4f592c 100644
--- a/app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusDetailDialogFragment.java
+++ b/app/src/main/java/net/lacolaco/smileessence/view/dialog/StatusDetailDialogFragment.java
@@ -30,12 +30,16 @@ import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.view.View;
-import android.widget.*;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.TextView;
import net.lacolaco.smileessence.Application;
import net.lacolaco.smileessence.R;
import net.lacolaco.smileessence.activity.MainActivity;
import net.lacolaco.smileessence.command.Command;
import net.lacolaco.smileessence.command.CommandOpenURL;
+import net.lacolaco.smileessence.command.CommandOpenUserDetail;
import net.lacolaco.smileessence.data.PostState;
import net.lacolaco.smileessence.entity.Account;
import net.lacolaco.smileessence.entity.RBinding;
@@ -47,11 +51,12 @@ import net.lacolaco.smileessence.util.Themes;
import net.lacolaco.smileessence.util.UIObserverBundle;
import net.lacolaco.smileessence.view.DialogHelper;
import net.lacolaco.smileessence.view.adapter.StatusListAdapter;
-import net.lacolaco.smileessence.view.listener.ListItemClickListener;
+import net.lacolaco.smileessence.view.adapter.UnorderedCustomListAdapter;
import net.lacolaco.smileessence.viewmodel.StatusViewModel;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
+import java.util.List;
public class StatusDetailDialogFragment extends StackableDialogFragment implements View.OnClickListener {
@@ -129,7 +134,10 @@ public class StatusDetailDialogFragment extends StackableDialogFragment implemen
final StatusListAdapter adapter = new StatusListAdapter(getActivity());
listView.setAdapter(adapter);
+ View replyDivider = header.findViewById(R.id.detail_dialog_divider_top);
+
if (tweet.getInReplyToStatusId() != -1) {
+ replyDivider.setVisibility(View.VISIBLE);
listView.setVisibility(View.VISIBLE);
Tweet replyToIfPresent = tweet.getInReplyToIfPresent();
if (replyToIfPresent != null) {
@@ -144,6 +152,7 @@ public class StatusDetailDialogFragment extends StackableDialogFragment implemen
.execute();
}
} else {
+ replyDivider.setVisibility(View.GONE);
listView.setVisibility(View.GONE);
}
@@ -208,8 +217,8 @@ public class StatusDetailDialogFragment extends StackableDialogFragment implemen
Account account = Application.getInstance().getCurrentAccount();
//--- buttons
- ImageButton message = (ImageButton) view.findViewById(R.id.button_status_detail_reply);
- message.setOnClickListener(this);
+ ImageButton reply = (ImageButton) view.findViewById(R.id.button_status_detail_reply);
+ reply.setOnClickListener(this);
ImageButton retweet = (ImageButton) view.findViewById(R.id.button_status_detail_retweet);
retweet.setOnClickListener(this);
@@ -240,18 +249,29 @@ public class StatusDetailDialogFragment extends StackableDialogFragment implemen
private void updateViewMenu(View view) {
MainActivity activity = ((MainActivity) getActivity());
- //--- menu
+ // -- menu dialog
ImageButton menu = (ImageButton) view.findViewById(R.id.button_status_detail_menu);
menu.setOnClickListener(this);
- LinearLayout commandsLayout = (LinearLayout) view.findViewById(R.id.linearlayout_status_detail_menu);
- commandsLayout.setClickable(true);
- ArrayList<Command> commands = getCommands();
+
+ // -- menu embedded in dialog
+ View divider = view.findViewById(R.id.detail_dialog_divider_bottom);
+ ListView listView = (ListView) view.findViewById(R.id.listview_status_detail_menu);
+ List<Command> commands = getCommands();
Command.filter(commands);
- for (final Command command : commands) {
- View commandView = command.getView(activity, activity.getLayoutInflater(), null);
- commandView.setBackgroundColor(ContextCompat.getColor(getActivity(), R.color.transparent));
- commandView.setOnClickListener(new ListItemClickListener(activity, command::execute));
- commandsLayout.addView(commandView);
+ if (commands.size() > 0) {
+ divider.setVisibility(View.VISIBLE);
+ listView.setVisibility(View.VISIBLE);
+ final UnorderedCustomListAdapter<Command> adapter = new UnorderedCustomListAdapter<>(activity);
+ adapter.addItemsToBottom(commands);
+ adapter.updateForce();
+ listView.setAdapter(adapter);
+ listView.setOnItemClickListener((parent, view1, position, id) -> {
+ Command command = (Command) parent.getItemAtPosition(position);
+ command.execute();
+ });
+ } else {
+ divider.setVisibility(View.GONE);
+ listView.setVisibility(View.GONE);
}
}
@@ -271,8 +291,12 @@ public class StatusDetailDialogFragment extends StackableDialogFragment implemen
});
}
- private ArrayList<Command> getCommands() {
+ private List<Command> getCommands() {
ArrayList<Command> commands = new ArrayList<>();
+ // Mentions
+ for (String screenName : tweet.getMentions()) {
+ commands.add(new CommandOpenUserDetail(getActivity(), screenName));
+ }
// URL
for (String url : tweet.getUrlsExpanded()) {
commands.add(new CommandOpenURL(getActivity(), url));
diff --git a/app/src/main/res/layout/dialog_status_detail.xml b/app/src/main/res/layout/dialog_status_detail.xml
index fb64e0ba..42270c36 100644
--- a/app/src/main/res/layout/dialog_status_detail.xml
+++ b/app/src/main/res/layout/dialog_status_detail.xml
@@ -24,7 +24,6 @@
~ SOFTWARE.
-->
-
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -42,9 +41,10 @@
android:minHeight="100dp" />
<FrameLayout
- android:layout_width="match_parent"
- android:layout_height="1px"
- android:background="?attr/color_list_divider" />
+ android:id="@+id/detail_dialog_divider_top"
+ android:layout_width="match_parent"
+ android:layout_height="1px"
+ android:background="?attr/color_list_divider" />
<include
android:id="@+id/layout_status_header"
@@ -162,16 +162,16 @@
</LinearLayout>
<FrameLayout
- android:layout_width="match_parent"
- android:layout_height="1px"
- android:background="?attr/color_list_divider" />
+ android:id="@+id/detail_dialog_divider_bottom"
+ android:layout_width="match_parent"
+ android:layout_height="1px"
+ android:background="?attr/color_list_divider" />
- <LinearLayout
- android:id="@+id/linearlayout_status_detail_menu"
- style="?attr/custom_button_transparent"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="?attr/page_background"
- android:orientation="vertical" />
+ <net.lacolaco.smileessence.view.ExpandedListView
+ android:id="@+id/listview_status_detail_menu"
+ style="?attr/custom_button_transparent"
+ android:background="?attr/page_background"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
</LinearLayout>
</ScrollView>
diff --git a/app/src/main/res/layout/list_item_simple_text.xml b/app/src/main/res/layout/list_item_simple_text.xml
new file mode 100644
index 00000000..09df441b
--- /dev/null
+++ b/app/src/main/res/layout/list_item_simple_text.xml
@@ -0,0 +1,41 @@
+<?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.
+ -->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="?android:attr/activatedBackgroundIndicator"
+ android:orientation="vertical">
+
+ <TextView
+ android:id="@+id/list_item_textview"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginBottom="14dp"
+ android:layout_marginTop="14dp"
+ android:paddingLeft="10dp"
+ android:textAppearance="?android:attr/textAppearanceSmall" />
+</FrameLayout> \ No newline at end of file
diff --git a/app/src/main/res/layout/menu_item_simple_text.xml b/app/src/main/res/layout/menu_item_simple_text.xml
index ec3a576e..1321f357 100644
--- a/app/src/main/res/layout/menu_item_simple_text.xml
+++ b/app/src/main/res/layout/menu_item_simple_text.xml
@@ -31,11 +31,11 @@
android:orientation="vertical">
<TextView
- android:id="@+id/textView_menuItem_simple"
+ android:id="@+id/list_item_textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="14dp"
- android:layout_marginTop="14dp"
+ android:layout_marginBottom="10dp"
+ android:layout_marginTop="10dp"
android:paddingLeft="10dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
</FrameLayout> \ No newline at end of file