diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/CustomTitleView.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/CustomTitleView.java new file mode 100644 index 0000000000..8e1a307c0e --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/CustomTitleView.java @@ -0,0 +1,80 @@ +package org.dolphinemu.dolphinemu.ui.main; + +import android.content.Context; +import android.graphics.drawable.Drawable; +import android.support.v17.leanback.widget.TitleViewAdapter; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.LinearLayout; +import android.widget.TextView; + +import org.dolphinemu.dolphinemu.R; + +public class CustomTitleView extends LinearLayout implements TitleViewAdapter.Provider { + private final TextView mTitleView; + private final View mBadgeView; + + private final TitleViewAdapter mTitleViewAdapter = new TitleViewAdapter() { + @Override + public View getSearchAffordanceView() + { + return null; + } + + @Override + public void setTitle(CharSequence titleText) + { + CustomTitleView.this.setTitle(titleText); + } + + @Override + public void setBadgeDrawable(Drawable drawable) + { + CustomTitleView.this.setBadgeDrawable(drawable); + } + }; + + public CustomTitleView(Context context) + { + this(context, null); + } + + public CustomTitleView(Context context, AttributeSet attrs) + { + this(context, attrs, 0); + } + + public CustomTitleView(Context context, AttributeSet attrs, int defStyle) + { + super(context, attrs, defStyle); + View root = LayoutInflater.from(context).inflate(R.layout.tv_title, this); + mTitleView = (TextView) root.findViewById(R.id.title); + mBadgeView = root.findViewById(R.id.badge); + } + + public void setTitle(CharSequence title) + { + if (title != null) + { + mTitleView.setText(title); + mTitleView.setVisibility(View.VISIBLE); + mBadgeView.setVisibility(View.VISIBLE); + } + } + + public void setBadgeDrawable(Drawable drawable) + { + if (drawable != null) + { + mTitleView.setVisibility(View.GONE); + mBadgeView.setVisibility(View.VISIBLE); + } + } + + @Override + public TitleViewAdapter getTitleViewAdapter() + { + return mTitleViewAdapter; + } +} \ No newline at end of file diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainPresenter.java index ecffb14ac0..24878ab244 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/MainPresenter.java @@ -2,9 +2,8 @@ package org.dolphinemu.dolphinemu.ui.main; import android.database.Cursor; - +import org.dolphinemu.dolphinemu.BuildConfig; import org.dolphinemu.dolphinemu.DolphinApplication; -import org.dolphinemu.dolphinemu.NativeLibrary; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.model.GameDatabase; import org.dolphinemu.dolphinemu.utils.SettingsFile; @@ -27,9 +26,7 @@ public final class MainPresenter public void onCreate() { - // TODO Rather than calling into native code, this should use the commented line below. - // String versionName = BuildConfig.VERSION_NAME; - String versionName = NativeLibrary.GetVersionString(); + String versionName = BuildConfig.VERSION_NAME; mView.setVersionString(versionName); } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/TvMainActivity.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/TvMainActivity.java index 17dad7a41e..c579190456 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/TvMainActivity.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/ui/main/TvMainActivity.java @@ -17,6 +17,7 @@ import android.support.v17.leanback.widget.OnItemViewClickedListener; import android.support.v17.leanback.widget.Presenter; import android.support.v17.leanback.widget.Row; import android.support.v17.leanback.widget.RowPresenter; +import android.support.v4.content.ContextCompat; import android.widget.Toast; import org.dolphinemu.dolphinemu.R; @@ -45,6 +46,16 @@ public final class TvMainActivity extends Activity implements MainView super.onCreate(savedInstanceState); setContentView(R.layout.activity_tv_main); + setupUI(); + + mPresenter.onCreate(); + + // Stuff in this block only happens when this activity is newly created (i.e. not a rotation) + if (savedInstanceState == null) + StartupHandler.HandleInit(this); + } + + void setupUI() { final FragmentManager fragmentManager = getFragmentManager(); mBrowseFragment = new BrowseFragment(); fragmentManager @@ -54,14 +65,9 @@ public final class TvMainActivity extends Activity implements MainView // Set display parameters for the BrowseFragment mBrowseFragment.setHeadersState(BrowseFragment.HEADERS_ENABLED); - mBrowseFragment.setTitle(getString(R.string.app_name)); - mBrowseFragment.setBadgeDrawable(getResources().getDrawable( - R.drawable.ic_launcher, null)); - mBrowseFragment.setBrandColor(getResources().getColor(R.color.dolphin_blue_dark)); + mBrowseFragment.setBrandColor(ContextCompat.getColor(this, R.color.dolphin_blue_dark)); buildRowsAdapter(); - mPresenter.onCreate(); - mBrowseFragment.setOnItemViewClickedListener( new OnItemViewClickedListener() { @@ -88,12 +94,7 @@ public final class TvMainActivity extends Activity implements MainView } } }); - - // Stuff in this block only happens when this activity is newly created (i.e. not a rotation) - if (savedInstanceState == null) - StartupHandler.HandleInit(this); } - /** * MainView */ @@ -101,7 +102,7 @@ public final class TvMainActivity extends Activity implements MainView @Override public void setVersionString(String version) { - // No-op + mBrowseFragment.setTitle(version); } @Override diff --git a/Source/Android/app/src/main/res/layout/titleview.xml b/Source/Android/app/src/main/res/layout/titleview.xml new file mode 100644 index 0000000000..e88e12fecf --- /dev/null +++ b/Source/Android/app/src/main/res/layout/titleview.xml @@ -0,0 +1,7 @@ + + \ No newline at end of file diff --git a/Source/Android/app/src/main/res/layout/tv_title.xml b/Source/Android/app/src/main/res/layout/tv_title.xml new file mode 100644 index 0000000000..424feafba1 --- /dev/null +++ b/Source/Android/app/src/main/res/layout/tv_title.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Source/Android/app/src/main/res/values/styles.xml b/Source/Android/app/src/main/res/values/styles.xml index 1728bb8bcd..eb8cf73dcb 100644 --- a/Source/Android/app/src/main/res/values/styles.xml +++ b/Source/Android/app/src/main/res/values/styles.xml @@ -113,7 +113,7 @@ -