mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 964508 - Rename TwoLineRow members and move icon code to TwoLinePageRow (r=margaret)
This commit is contained in:
parent
a171ee0bfa
commit
92b2c31da3
@ -41,11 +41,11 @@ public class PanelListRow extends TwoLineRow {
|
||||
|
||||
int titleIndex = cursor.getColumnIndexOrThrow(HomeItems.TITLE);
|
||||
final String title = cursor.getString(titleIndex);
|
||||
setPrimaryText(title);
|
||||
setTitle(title);
|
||||
|
||||
int urlIndex = cursor.getColumnIndexOrThrow(HomeItems.URL);
|
||||
final String url = cursor.getString(urlIndex);
|
||||
setSecondaryText(url);
|
||||
setDescription(url);
|
||||
|
||||
int imageIndex = cursor.getColumnIndexOrThrow(HomeItems.IMAGE_URL);
|
||||
final String imageUrl = cursor.getString(imageIndex);
|
||||
|
@ -21,12 +21,19 @@ import android.database.Cursor;
|
||||
import android.graphics.Bitmap;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.TextView;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class TwoLinePageRow extends TwoLineRow
|
||||
implements Tabs.OnTabsChangedListener {
|
||||
|
||||
private static final int NO_ICON = 0;
|
||||
|
||||
private final TextView mDescription;
|
||||
private int mSwitchToTabIconId;
|
||||
private int mPageTypeIconId;
|
||||
|
||||
private final FaviconView mFavicon;
|
||||
|
||||
private boolean mShowIcons;
|
||||
@ -72,6 +79,10 @@ public class TwoLinePageRow extends TwoLineRow
|
||||
|
||||
mShowIcons = true;
|
||||
|
||||
mDescription = (TextView) findViewById(R.id.description);
|
||||
mSwitchToTabIconId = NO_ICON;
|
||||
mPageTypeIconId = NO_ICON;
|
||||
|
||||
mFavicon = (FaviconView) findViewById(R.id.icon);
|
||||
mFaviconListener = new UpdateViewFaviconLoadedListener(mFavicon);
|
||||
}
|
||||
@ -104,6 +115,24 @@ public class TwoLinePageRow extends TwoLineRow
|
||||
}
|
||||
}
|
||||
|
||||
private void setSwitchToTabIcon(int iconId) {
|
||||
if (mSwitchToTabIconId == iconId) {
|
||||
return;
|
||||
}
|
||||
|
||||
mSwitchToTabIconId = iconId;
|
||||
mDescription.setCompoundDrawablesWithIntrinsicBounds(mSwitchToTabIconId, 0, mPageTypeIconId, 0);
|
||||
}
|
||||
|
||||
private void setPageTypeIcon(int iconId) {
|
||||
if (mPageTypeIconId == iconId) {
|
||||
return;
|
||||
}
|
||||
|
||||
mPageTypeIconId = iconId;
|
||||
mDescription.setCompoundDrawablesWithIntrinsicBounds(mSwitchToTabIconId, 0, mPageTypeIconId, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the page URL, so that we can use it to replace "Switch to tab" if the open
|
||||
* tab changes or is closed.
|
||||
@ -122,11 +151,11 @@ public class TwoLinePageRow extends TwoLineRow
|
||||
boolean isPrivate = Tabs.getInstance().getSelectedTab().isPrivate();
|
||||
Tab tab = Tabs.getInstance().getFirstTabForUrl(mPageUrl, isPrivate);
|
||||
if (!mShowIcons || tab == null) {
|
||||
setSecondaryText(mPageUrl);
|
||||
setSecondaryIcon(NO_ICON);
|
||||
setDescription(mPageUrl);
|
||||
setSwitchToTabIcon(NO_ICON);
|
||||
} else {
|
||||
setSecondaryText(R.string.switch_to_tab);
|
||||
setSecondaryIcon(R.drawable.ic_url_bar_tab);
|
||||
setDescription(R.string.switch_to_tab);
|
||||
setSwitchToTabIcon(R.drawable.ic_url_bar_tab);
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,20 +191,20 @@ public class TwoLinePageRow extends TwoLineRow
|
||||
// The bookmark id will be 0 (null in database) when the url
|
||||
// is not a bookmark.
|
||||
if (bookmarkId == 0) {
|
||||
setPrimaryIcon(NO_ICON);
|
||||
setPageTypeIcon(NO_ICON);
|
||||
} else if (display == Combined.DISPLAY_READER) {
|
||||
setPrimaryIcon(R.drawable.ic_url_bar_reader);
|
||||
setPageTypeIcon(R.drawable.ic_url_bar_reader);
|
||||
} else {
|
||||
setPrimaryIcon(R.drawable.ic_url_bar_star);
|
||||
setPageTypeIcon(R.drawable.ic_url_bar_star);
|
||||
}
|
||||
} else {
|
||||
setPrimaryIcon(NO_ICON);
|
||||
setPageTypeIcon(NO_ICON);
|
||||
}
|
||||
}
|
||||
|
||||
// Use the URL instead of an empty title for consistency with the normal URL
|
||||
// bar view - this is the equivalent of getDisplayTitle() in Tab.java
|
||||
setPrimaryText(TextUtils.isEmpty(title) ? url : title);
|
||||
setTitle(TextUtils.isEmpty(title) ? url : title);
|
||||
|
||||
// No point updating the below things if URL has not changed. Prevents evil Favicon flicker.
|
||||
if (url.equals(mPageUrl)) {
|
||||
|
@ -18,13 +18,8 @@ import android.widget.TextView;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public abstract class TwoLineRow extends LinearLayout {
|
||||
protected static final int NO_ICON = 0;
|
||||
|
||||
private final TextView mPrimaryText;
|
||||
private int mPrimaryIconId;
|
||||
|
||||
private final TextView mSecondaryText;
|
||||
private int mSecondaryIconId;
|
||||
private final TextView mTitle;
|
||||
private final TextView mDescription;
|
||||
|
||||
public TwoLineRow(Context context) {
|
||||
this(context, null);
|
||||
@ -35,42 +30,21 @@ public abstract class TwoLineRow extends LinearLayout {
|
||||
|
||||
setGravity(Gravity.CENTER_VERTICAL);
|
||||
|
||||
mSecondaryIconId = NO_ICON;
|
||||
mPrimaryIconId = NO_ICON;
|
||||
|
||||
LayoutInflater.from(context).inflate(R.layout.two_line_row, this);
|
||||
mPrimaryText = (TextView) findViewById(R.id.primary_text);
|
||||
mSecondaryText = (TextView) findViewById(R.id.secondary_text);
|
||||
mTitle = (TextView) findViewById(R.id.title);
|
||||
mDescription = (TextView) findViewById(R.id.description);
|
||||
}
|
||||
|
||||
protected void setPrimaryText(String text) {
|
||||
mPrimaryText.setText(text);
|
||||
protected void setTitle(String text) {
|
||||
mTitle.setText(text);
|
||||
}
|
||||
|
||||
protected void setSecondaryText(String text) {
|
||||
mSecondaryText.setText(text);
|
||||
protected void setDescription(String text) {
|
||||
mDescription.setText(text);
|
||||
}
|
||||
|
||||
protected void setSecondaryText(int stringId) {
|
||||
mSecondaryText.setText(stringId);
|
||||
}
|
||||
|
||||
protected void setPrimaryIcon(int iconId) {
|
||||
if (mPrimaryIconId == iconId) {
|
||||
return;
|
||||
}
|
||||
|
||||
mPrimaryIconId = iconId;
|
||||
mSecondaryText.setCompoundDrawablesWithIntrinsicBounds(mSecondaryIconId, 0, mPrimaryIconId, 0);
|
||||
}
|
||||
|
||||
protected void setSecondaryIcon(int iconId) {
|
||||
if (mSecondaryIconId == iconId) {
|
||||
return;
|
||||
}
|
||||
|
||||
mSecondaryIconId = iconId;
|
||||
mSecondaryText.setCompoundDrawablesWithIntrinsicBounds(mSecondaryIconId, 0, mPrimaryIconId, 0);
|
||||
protected void setDescription(int stringId) {
|
||||
mDescription.setText(stringId);
|
||||
}
|
||||
|
||||
public abstract void updateFromCursor(Cursor cursor);
|
||||
|
@ -18,14 +18,14 @@
|
||||
android:orientation="vertical">
|
||||
|
||||
<org.mozilla.gecko.home.FadedTextView
|
||||
android:id="@+id/primary_text"
|
||||
style="@style/Widget.TwoLineRow.PrimaryText"
|
||||
android:id="@+id/title"
|
||||
style="@style/Widget.TwoLineRow.Title"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
gecko:fadeWidth="30dp"/>
|
||||
|
||||
<TextView android:id="@+id/secondary_text"
|
||||
style="@style/Widget.TwoLineRow.SecondaryText"
|
||||
<TextView android:id="@+id/description"
|
||||
style="@style/Widget.TwoLineRow.Description"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawablePadding="5dp"
|
||||
|
@ -9,7 +9,7 @@
|
||||
<item name="android:orientation">vertical</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.BookmarkFolderView" parent="Widget.TwoLineRow.PrimaryText">
|
||||
<style name="Widget.BookmarkFolderView" parent="Widget.TwoLineRow.Title">
|
||||
<item name="android:paddingLeft">60dip</item>
|
||||
<item name="android:drawablePadding">10dip</item>
|
||||
<item name="android:drawableLeft">@drawable/bookmark_folder</item>
|
||||
|
@ -9,7 +9,7 @@
|
||||
<item name="android:fontFamily">sans-serif-light</item>
|
||||
</style>
|
||||
|
||||
<style name="TextAppearance.Widget.TwoLineRow.PrimaryText" parent="TextAppearance.Medium">
|
||||
<style name="TextAppearance.Widget.TwoLineRow.Title" parent="TextAppearance.Medium">
|
||||
<item name="android:fontFamily">sans-serif-light</item>
|
||||
</style>
|
||||
|
||||
|
@ -111,20 +111,20 @@
|
||||
|
||||
<style name="Widget.TwoLineRow" />
|
||||
|
||||
<style name="Widget.TwoLineRow.PrimaryText">
|
||||
<item name="android:textAppearance">@style/TextAppearance.Widget.TwoLineRow.PrimaryText</item>
|
||||
<style name="Widget.TwoLineRow.Title">
|
||||
<item name="android:textAppearance">@style/TextAppearance.Widget.TwoLineRow.Title</item>
|
||||
<item name="android:singleLine">true</item>
|
||||
<item name="android:ellipsize">none</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.TwoLineRow.SecondaryText">
|
||||
<item name="android:textAppearance">@style/TextAppearance.Widget.TwoLineRow.SecondaryText</item>
|
||||
<style name="Widget.TwoLineRow.Description">
|
||||
<item name="android:textAppearance">@style/TextAppearance.Widget.TwoLineRow.Description</item>
|
||||
<item name="android:includeFontPadding">false</item>
|
||||
<item name="android:singleLine">true</item>
|
||||
<item name="android:ellipsize">middle</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.BookmarkFolderView" parent="Widget.TwoLineRow.PrimaryText">
|
||||
<style name="Widget.BookmarkFolderView" parent="Widget.TwoLineRow.Title">
|
||||
<item name="android:paddingLeft">10dip</item>
|
||||
<item name="android:drawablePadding">10dip</item>
|
||||
<item name="android:drawableLeft">@drawable/bookmark_folder</item>
|
||||
@ -344,9 +344,9 @@
|
||||
|
||||
<style name="TextAppearance.Widget.TwoLineRow" />
|
||||
|
||||
<style name="TextAppearance.Widget.TwoLineRow.PrimaryText" parent="TextAppearance.Medium"/>
|
||||
<style name="TextAppearance.Widget.TwoLineRow.Title" parent="TextAppearance.Medium"/>
|
||||
|
||||
<style name="TextAppearance.Widget.TwoLineRow.SecondaryText" parent="TextAppearance.Micro">
|
||||
<style name="TextAppearance.Widget.TwoLineRow.Description" parent="TextAppearance.Micro">
|
||||
<item name="android:textColor">?android:attr/textColorSecondary</item>
|
||||
</style>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user