Remove Android TV

This commit is contained in:
Andrew Rabert 2017-03-05 11:24:24 -05:00
parent 5d1889fd1d
commit 4bf393e73e
2 changed files with 45 additions and 62 deletions

View File

@ -28,7 +28,6 @@
<uses-feature android:name="android.hardware.bluetooth" android:required="false" /> <uses-feature android:name="android.hardware.bluetooth" android:required="false" />
<uses-feature android:name="android.hardware.microphone" android:required="false" /> <uses-feature android:name="android.hardware.microphone" android:required="false" />
<uses-feature android:name="android.hardware.wifi" android:required="false" /> <uses-feature android:name="android.hardware.wifi" android:required="false" />
<uses-feature android:name="android.software.leanback" android:required="false"/>
<supports-screens android:anyDensity="true" android:xlargeScreens="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true"/> <supports-screens android:anyDensity="true" android:xlargeScreens="true" android:largeScreens="true" android:normalScreens="true" android:smallScreens="true"/>
@ -45,7 +44,6 @@
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.LEANBACK_LAUNCHER"/>
</intent-filter> </intent-filter>
</activity> </activity>

View File

@ -102,7 +102,6 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte
protected SubsonicFragment currentFragment; protected SubsonicFragment currentFragment;
protected View primaryContainer; protected View primaryContainer;
protected View secondaryContainer; protected View secondaryContainer;
protected boolean tv = false;
protected boolean touchscreen = true; protected boolean touchscreen = true;
protected Handler handler = new Handler(); protected Handler handler = new Handler();
Spinner actionBarSpinner; Spinner actionBarSpinner;
@ -127,9 +126,6 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte
@Override @Override
protected void onCreate(Bundle bundle) { protected void onCreate(Bundle bundle) {
UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE); UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION) {
// tv = true;
}
PackageManager pm = getPackageManager(); PackageManager pm = getPackageManager();
if(!pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN)) { if(!pm.hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN)) {
touchscreen = false; touchscreen = false;
@ -240,11 +236,7 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte
@Override @Override
public void setContentView(int viewId) { public void setContentView(int viewId) {
if(isTv()) { super.setContentView(R.layout.abstract_activity);
super.setContentView(R.layout.static_drawer_activity);
} else {
super.setContentView(R.layout.abstract_activity);
}
rootView = (ViewGroup) findViewById(R.id.content_frame); rootView = (ViewGroup) findViewById(R.id.content_frame);
if(viewId != 0) { if(viewId != 0) {
@ -310,54 +302,52 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte
updateDrawerHeader(); updateDrawerHeader();
if(!isTv()) { drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
// Pass in toolbar if it exists // Pass in toolbar if it exists
Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar); Toolbar toolbar = (Toolbar) findViewById(R.id.main_toolbar);
drawerToggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.common_appname, R.string.common_appname) { drawerToggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.common_appname, R.string.common_appname) {
@Override @Override
public void onDrawerClosed(View view) { public void onDrawerClosed(View view) {
drawerIdle = true; drawerIdle = true;
drawerOpen = false; drawerOpen = false;
if(!showingTabs) { if(!showingTabs) {
populateTabs(); populateTabs();
} }
} }
@Override @Override
public void onDrawerOpened(View view) { public void onDrawerOpened(View view) {
DownloadService downloadService = getDownloadService(); DownloadService downloadService = getDownloadService();
boolean downloadingVisible = downloadService != null && !downloadService.getBackgroundDownloads().isEmpty(); boolean downloadingVisible = downloadService != null && !downloadService.getBackgroundDownloads().isEmpty();
if(lastSelectedPosition == R.id.drawer_downloading) { if(lastSelectedPosition == R.id.drawer_downloading) {
downloadingVisible = true; downloadingVisible = true;
} }
setDrawerItemVisible(R.id.drawer_downloading, downloadingVisible); setDrawerItemVisible(R.id.drawer_downloading, downloadingVisible);
drawerIdle = true; drawerIdle = true;
drawerOpen = true; drawerOpen = true;
} }
@Override @Override
public void onDrawerSlide(View drawerView, float slideOffset) { public void onDrawerSlide(View drawerView, float slideOffset) {
super.onDrawerSlide(drawerView, slideOffset); super.onDrawerSlide(drawerView, slideOffset);
drawerIdle = false; drawerIdle = false;
} }
}; };
drawer.setDrawerListener(drawerToggle); drawer.setDrawerListener(drawerToggle);
drawerToggle.setDrawerIndicatorEnabled(true); drawerToggle.setDrawerIndicatorEnabled(true);
drawer.setOnTouchListener(new View.OnTouchListener() { drawer.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
if (drawerIdle && currentFragment != null && currentFragment.getGestureDetector() != null) { if (drawerIdle && currentFragment != null && currentFragment.getGestureDetector() != null) {
return currentFragment.getGestureDetector().onTouchEvent(event); return currentFragment.getGestureDetector().onTouchEvent(event);
} else { } else {
return false; return false;
} }
} }
}); });
}
// Check whether this is a tablet or not // Check whether this is a tablet or not
secondaryContainer = findViewById(R.id.fragment_second_container); secondaryContainer = findViewById(R.id.fragment_second_container);
@ -795,17 +785,15 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte
} }
spinnerAdapter.notifyDataSetChanged(); spinnerAdapter.notifyDataSetChanged();
actionBarSpinner.setSelection(spinnerAdapter.getCount() - 1); actionBarSpinner.setSelection(spinnerAdapter.getCount() - 1);
if(!isTv()) { getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayShowTitleEnabled(false); getSupportActionBar().setDisplayShowCustomEnabled(true);
getSupportActionBar().setDisplayShowCustomEnabled(true);
}
if(drawerToggle.isDrawerIndicatorEnabled()) { if(drawerToggle.isDrawerIndicatorEnabled()) {
getSupportActionBar().setDisplayHomeAsUpEnabled(false); getSupportActionBar().setDisplayHomeAsUpEnabled(false);
drawerToggle.setDrawerIndicatorEnabled(false); drawerToggle.setDrawerIndicatorEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} }
} else if(!isTv()) { } else {
getSupportActionBar().setDisplayShowTitleEnabled(true); getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setTitle(currentFragment.getTitle()); getSupportActionBar().setTitle(currentFragment.getTitle());
getSupportActionBar().setDisplayShowCustomEnabled(false); getSupportActionBar().setDisplayShowCustomEnabled(false);
@ -843,7 +831,7 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte
} }
private void applyFullscreen() { private void applyFullscreen() {
fullScreen = Util.getPreferences(this).getBoolean(Constants.PREFERENCES_KEY_FULL_SCREEN, false); fullScreen = Util.getPreferences(this).getBoolean(Constants.PREFERENCES_KEY_FULL_SCREEN, false);
if(fullScreen || isTv()) { if(fullScreen ) {
// Hide additional elements on higher Android versions // Hide additional elements on higher Android versions
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | int flags = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
@ -928,9 +916,6 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte
return theme; return theme;
} }
public boolean isTv() {
return tv;
}
public boolean isTouchscreen() { public boolean isTouchscreen() {
return touchscreen; return touchscreen;
} }