Skip to content
This repository has been archived by the owner on Jul 25, 2019. It is now read-only.

Commit

Permalink
Add powered by
Browse files Browse the repository at this point in the history
  • Loading branch information
austintaylor committed Jan 9, 2014
1 parent 855ee8a commit fd00ef5
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 4 deletions.
1 change: 1 addition & 0 deletions UVDemo/src/com/uservoice/uvdemo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ protected void onCreate(Bundle savedInstanceState) {
// Config config = new Config("yoursite.uservoice.com");
Config config = new Config("demo.uservoice.com");
// config.setTopicId(9579);
// config.setShowKnowledgeBase(false);
UserVoice.init(config, this);

// hack to always show the overflow menu in the action bar
Expand Down
27 changes: 27 additions & 0 deletions UserVoiceSDK/res/layout/uv_powered_by_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/uv_listPreferredItemHeightSmall"
android:orientation="vertical"
android:paddingTop="30dp"
android:paddingBottom="20dp">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/uv_powered_by_uservoice"
android:textColor="#999999"
android:textSize="14sp" />

<TextView
android:id="@+id/uv_version"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="Android SDK v1.0"
android:textColor="#CCCCCC"
android:textSize="12sp" />

</LinearLayout>
2 changes: 2 additions & 0 deletions UserVoiceSDK/res/values-en/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,7 @@
<string name="uv_password_dialog_title">Please enter your password</string>
<string name="uv_article_browse_question">Was this article helpful?</string>
<string name="uv_thanks">Thanks!</string>
<string name="uv_powered_by_uservoice">Powered by UserVoice</string>
<string name="uv_android_sdk">Android SDK</string>

</resources>
2 changes: 2 additions & 0 deletions UserVoiceSDK/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,7 @@
<string name="uv_password_dialog_title">Please enter your password</string>
<string name="uv_article_browse_question">Was this article helpful?</string>
<string name="uv_thanks">Thanks!</string>
<string name="uv_powered_by_uservoice">Powered by UserVoice</string>
<string name="uv_android_sdk">Android SDK</string>

</resources>
3 changes: 1 addition & 2 deletions UserVoiceSDK/src/com/uservoice/uservoicesdk/UserVoice.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public static void track(String event) {
}

public static String getVersion() {
// TODO get this from the package version maybe
return "0.0.1";
return "1.0.0";
}
}
24 changes: 22 additions & 2 deletions UserVoiceSDK/src/com/uservoice/uservoicesdk/ui/PortalAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.uservoice.uservoicesdk.Config;
import com.uservoice.uservoicesdk.R;
import com.uservoice.uservoicesdk.Session;
import com.uservoice.uservoicesdk.UserVoice;
import com.uservoice.uservoicesdk.activity.ContactActivity;
import com.uservoice.uservoicesdk.activity.ForumActivity;
import com.uservoice.uservoicesdk.activity.SearchActivity;
Expand All @@ -37,6 +38,7 @@ public class PortalAdapter extends SearchAdapter<BaseModel> implements AdapterVi
private static int LOADING = 3;
private static int CONTACT = 4;
private static int ARTICLE = 5;
private static int POWERED_BY = 6;

private LayoutInflater inflater;
private final FragmentActivity context;
Expand Down Expand Up @@ -137,6 +139,9 @@ public int getCount() {
rows += shouldShowArticles() ? getArticles().size() : getTopics().size();
}
}
if (!Session.getInstance().getClientConfig().isWhiteLabel()) {
rows += 1;
}
return rows;
}
}
Expand Down Expand Up @@ -222,6 +227,8 @@ else if (type == CONTACT)
view = inflater.inflate(R.layout.uv_text_item, null);
else if (type == ARTICLE)
view = inflater.inflate(R.layout.uv_text_item, null);
else if (type == POWERED_BY)
view = inflater.inflate(R.layout.uv_powered_by_item, null);
}

if (type == FORUM) {
Expand Down Expand Up @@ -251,11 +258,14 @@ else if (type == ARTICLE)
TextView textView = (TextView) view.findViewById(R.id.uv_text);
Article article = (Article) getItem(position);
textView.setText(article.getTitle());
} else if (type == POWERED_BY) {
TextView textView = (TextView) view.findViewById(R.id.uv_version);
textView.setText(context.getString(R.string.uv_android_sdk) + " v" + UserVoice.getVersion());
}

View divider = view.findViewById(R.id.uv_divider);
if (divider != null)
divider.setVisibility(position == getCount() - 1 ? View.GONE : View.VISIBLE);
divider.setVisibility((position == getCount() - 2 && getItemViewType(getCount() - 1) == POWERED_BY) || position == getCount() - 1 ? View.GONE : View.VISIBLE);
if (type == FORUM)
divider.setVisibility(View.GONE);

Expand All @@ -278,7 +288,17 @@ public int getItemViewType(int position) {
return LOADING;
return type;
}
return getTopics() == null || (shouldShowArticles() && getArticles() == null) ? LOADING : (shouldShowArticles() ? ARTICLE : TOPIC);
if (Session.getInstance().getConfig().shouldShowKnowledgeBase()) {
if (getTopics() == null || (shouldShowArticles() && getArticles() == null)) {
if (position - staticRows.size() == 0)
return LOADING;
} else if (shouldShowArticles() && position - staticRows.size() < getArticles().size()) {
return ARTICLE;
} else if (!shouldShowArticles() && position - staticRows.size() < getTopics().size()) {
return TOPIC;
}
}
return POWERED_BY;
}

public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Expand Down

0 comments on commit fd00ef5

Please sign in to comment.