mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 909375: Set url as title if title is not available on context menu. [r=margaret]
This commit is contained in:
parent
c3af9047dd
commit
c07163f2f2
@ -26,7 +26,6 @@ import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
@ -46,9 +45,6 @@ abstract class HomeFragment extends Fragment {
|
||||
// Share MIME type.
|
||||
private static final String SHARE_MIME_TYPE = "text/plain";
|
||||
|
||||
// URL to Title replacement regex.
|
||||
private static final String REGEX_URL_TO_TITLE = "^([a-z]+://)?(www\\.)?";
|
||||
|
||||
// Whether the fragment can load its content or not
|
||||
// This is used to defer data loading until the editing
|
||||
// mode animation ends.
|
||||
@ -87,7 +83,7 @@ abstract class HomeFragment extends Fragment {
|
||||
MenuInflater inflater = new MenuInflater(view.getContext());
|
||||
inflater.inflate(R.menu.home_contextmenu, menu);
|
||||
|
||||
menu.setHeaderTitle(info.title);
|
||||
menu.setHeaderTitle(info.getDisplayTitle());
|
||||
|
||||
// Hide the "Edit" menuitem if this item isn't a bookmark.
|
||||
if (info.bookmarkId < 0) {
|
||||
@ -126,7 +122,7 @@ abstract class HomeFragment extends Fragment {
|
||||
Log.e(LOGTAG, "Can't share because URL is null");
|
||||
} else {
|
||||
GeckoAppShell.openUriExternal(info.url, SHARE_MIME_TYPE, "", "",
|
||||
Intent.ACTION_SEND, info.title);
|
||||
Intent.ACTION_SEND, info.getDisplayTitle());
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,8 +132,7 @@ abstract class HomeFragment extends Fragment {
|
||||
return false;
|
||||
}
|
||||
|
||||
String shortcutTitle = TextUtils.isEmpty(info.title) ? info.url.replaceAll(REGEX_URL_TO_TITLE, "") : info.title;
|
||||
new AddToLauncherTask(info.url, shortcutTitle).execute();
|
||||
new AddToLauncherTask(info.url, info.getDisplayTitle()).execute();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.MotionEvent;
|
||||
@ -110,6 +111,10 @@ public class HomeListView extends ListView
|
||||
* A ContextMenuInfo for HomeListView that adds details from the cursor.
|
||||
*/
|
||||
public static class HomeContextMenuInfo extends AdapterContextMenuInfo {
|
||||
|
||||
// URL to Title replacement regex.
|
||||
private static final String REGEX_URL_TO_TITLE = "^([a-z]+://)?(www\\.)?";
|
||||
|
||||
public int bookmarkId;
|
||||
public int historyId;
|
||||
public String url;
|
||||
@ -179,5 +184,9 @@ public class HomeListView extends ListView
|
||||
display = Combined.DISPLAY_NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
public String getDisplayTitle() {
|
||||
return TextUtils.isEmpty(title) ? url.replaceAll(REGEX_URL_TO_TITLE, "") : title;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user