comment 使用 Linkify
This commit is contained in:
1 parent
d8fc3f0a51
commit
0735fa2425
6 files changed
+39
-87
No files matched your search
@@ -29,6 +29,7 @@
|
||||
android:layout_below="@id/user"
|
||||
android:layout_marginTop="8.0dp"
|
||||
android:layout_marginRight="12.0dp"
|
||||
android:layout_marginBottom="8.0dp" />
|
||||
android:layout_marginBottom="8.0dp"
|
||||
android:autoLink="web" />
|
||||
|
||||
</RelativeLayout>
|
||||
@@ -1,14 +0,0 @@
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/text1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="16sp"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingLeft="24dp"
|
||||
android:paddingRight="24dp"
|
||||
android:minHeight="48dp"
|
||||
android:maxHeight="48dp"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end" />
|
||||
@@ -220,6 +220,10 @@
|
||||
<string name="vote_succeeded">投票成功</string>
|
||||
<string name="vote_failed">投票失败</string>
|
||||
|
||||
|
||||
<string name="uploader_others">该用户上传的其他内容</string>
|
||||
|
||||
|
||||
<!-- rating -->
|
||||
<string name="rating10">根本把持不住</string>
|
||||
<string name="rating9">好极了</string>
|
||||
@@ -234,6 +238,7 @@
|
||||
<string name="rating0">感觉快要窒息了</string>
|
||||
|
||||
<!-- Util -->
|
||||
<string name="copyed">已复制</string>
|
||||
<string name="send">发送</string>
|
||||
<string name="detail">详情</string>
|
||||
<string name="comment">评论</string>
|
||||
|
||||
+5
-14
@@ -1,19 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
|
||||
<string-array name="list_list_title">
|
||||
<item>@string/homepage</item>
|
||||
<item>@string/favourite</item>
|
||||
<item>@android:string/search_go</item>
|
||||
<item>@string/download</item>
|
||||
</string-array>
|
||||
|
||||
<integer-array name="list_list_icon">
|
||||
<item>@drawable/ic_action_home</item>
|
||||
<item>@drawable/ic_action_home</item>
|
||||
<item>@drawable/ic_action_home</item>
|
||||
<item>@drawable/ic_action_home</item>
|
||||
</integer-array>
|
||||
|
||||
<string-array name="min_rating">
|
||||
<item>@string/star_2</item>
|
||||
@@ -30,6 +16,11 @@
|
||||
<item>lofi.e-hentai.org (980x)</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="comment_long_click">
|
||||
<item>@android:string/copy</item>
|
||||
<item>@string/uploader_others</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="page_scaling_entries">
|
||||
<item>@string/actual_size</item>
|
||||
<item>@string/fit_to_width</item>
|
||||
|
||||
@@ -228,6 +228,9 @@
|
||||
<string name="rate_succeeded">Rate succeeded</string>
|
||||
<string name="rate_failed">Rate failed</string>
|
||||
|
||||
|
||||
<string name="uploader_others">该用户上传的其他内容</string>
|
||||
|
||||
<!-- Category -->
|
||||
<string name="doujinshi" translatable="false">DOUJINSHI</string>
|
||||
<string name="manga" translatable="false">MANGA</string>
|
||||
@@ -255,6 +258,7 @@
|
||||
<string name="rating0">DISASTER</string>
|
||||
|
||||
<!-- Util -->
|
||||
<string name="copyed">Copyed</string>
|
||||
<string name="send">Send</string>
|
||||
<string name="detail">Detail</string>
|
||||
<string name="comment">Comment</string>
|
||||
|
||||
@@ -22,6 +22,7 @@ import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.Html;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -104,73 +105,37 @@ public class CommentsSectionFragment extends Fragment
|
||||
public boolean onItemLongClick(AdapterView<?> parent, View view,
|
||||
int position, long id) {
|
||||
final Comment c = (Comment)parent.getItemAtPosition(position);
|
||||
final List<String> urls = new ArrayList<String>();
|
||||
urls.add(getString(android.R.string.copy));
|
||||
urls.add("该用户上传的其他内容");
|
||||
|
||||
Pattern p = Pattern.compile("[a-zA-Z]+://[^\\s<>\"]*");
|
||||
Matcher m = p.matcher(c.comment);
|
||||
|
||||
while (m.find()) {
|
||||
String url = m.group();
|
||||
if (!urls.contains(url))
|
||||
urls.add(url);
|
||||
}
|
||||
|
||||
// Long Click dialog
|
||||
mLongClickDialog = new DialogBuilder(mActivity)
|
||||
.setTitle(R.string.what_to_do)
|
||||
.setAdapter(new BaseAdapter() {
|
||||
@Override
|
||||
public int getCount() {
|
||||
return urls.size();
|
||||
}
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return urls.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView,
|
||||
ViewGroup parent) {
|
||||
LayoutInflater inflater = LayoutInflater.from(mActivity);
|
||||
if (position < 2) {
|
||||
convertView = inflater.inflate(R.layout.list_item_text, null);
|
||||
} else {
|
||||
convertView = inflater.inflate(R.layout.list_url_text, null);
|
||||
}
|
||||
((TextView)convertView.findViewById(
|
||||
android.R.id.text1)).setText(urls.get(position));
|
||||
return convertView;
|
||||
}
|
||||
|
||||
}, new AdapterView.OnItemClickListener() {
|
||||
.setTitle(R.string.what_to_do).setItems(R.array.comment_long_click,
|
||||
new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view,
|
||||
int position, long id) {
|
||||
if (position == 0) {
|
||||
switch (position) {
|
||||
case 0:
|
||||
ClipboardManager cm = (ClipboardManager)mActivity
|
||||
.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cm.setPrimaryClip(ClipData.newPlainText(null, c.comment));
|
||||
Toast.makeText(mActivity, "已复制", Toast.LENGTH_SHORT).show(); // TODO
|
||||
} else if (position == 1) {
|
||||
Toast.makeText(mActivity, getString(R.string.copyed),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
break;
|
||||
|
||||
case 1:
|
||||
ListUrls lus = new ListUrls(ListUrls.ALL_TYPE,
|
||||
"uploader:" + mActivity.getGalleryInfo().uploader, 0);
|
||||
// TOOD
|
||||
} else if (position > 1) {
|
||||
String str = (String)parent.getItemAtPosition(position);
|
||||
Uri uri = Uri.parse(str);
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW,uri);
|
||||
startActivity(intent);
|
||||
// TODO
|
||||
break;
|
||||
}
|
||||
mLongClickDialog.dismiss();
|
||||
}
|
||||
}).create();
|
||||
}).setNegativeButton(android.R.string.cancel,
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
mLongClickDialog.dismiss();
|
||||
}
|
||||
}).create();
|
||||
mLongClickDialog.show();
|
||||
return true;
|
||||
}
|
||||
@@ -218,10 +183,10 @@ public class CommentsSectionFragment extends Fragment
|
||||
}
|
||||
|
||||
// No one can post one comment at same this time
|
||||
if (!isUserSame || !isTimeSame)
|
||||
((TextView)convertView.findViewById(R.id.comment))
|
||||
.setText(Html.fromHtml(c.comment));
|
||||
|
||||
if (!isUserSame || !isTimeSame) {
|
||||
TextView comment = ((TextView)convertView.findViewById(R.id.comment));
|
||||
comment.setText(Html.fromHtml(c.comment));
|
||||
}
|
||||
return convertView;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user