diff --git a/res/drawable/ic_menu_preferences.xml b/res/drawable/ic_menu_preferences.xml
new file mode 100644
index 0000000..cfa9a7c
--- /dev/null
+++ b/res/drawable/ic_menu_preferences.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout-large-notouch/activity_updates.xml b/res/layout-large-notouch/activity_updates.xml
new file mode 100644
index 0000000..09823bc
--- /dev/null
+++ b/res/layout-large-notouch/activity_updates.xml
@@ -0,0 +1,129 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/org/lineageos/updater/UpdatesActivity.java b/src/org/lineageos/updater/UpdatesActivity.java
index 6e93153..32d31f9 100644
--- a/src/org/lineageos/updater/UpdatesActivity.java
+++ b/src/org/lineageos/updater/UpdatesActivity.java
@@ -15,11 +15,13 @@
*/
package org.lineageos.updater;
+import android.app.UiModeManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
+import android.content.res.Configuration;
import android.content.ServiceConnection;
import android.content.SharedPreferences;
import android.icu.text.DateFormat;
@@ -37,12 +39,14 @@ import android.view.View;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
+import android.widget.Button;
import android.widget.Spinner;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.preference.PreferenceManager;
@@ -81,11 +85,16 @@ public class UpdatesActivity extends UpdatesListActivity {
private View mRefreshIconView;
private RotateAnimation mRefreshAnimation;
+ private boolean mIsTV;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_updates);
+ UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE);
+ mIsTV = uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_TELEVISION;
+
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
mAdapter = new UpdatesListAdapter(this);
recyclerView.setAdapter(mAdapter);
@@ -114,10 +123,12 @@ public class UpdatesActivity extends UpdatesListActivity {
}
};
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
- getSupportActionBar().setDisplayShowTitleEnabled(false);
- getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ if (!mIsTV) {
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+ getSupportActionBar().setDisplayShowTitleEnabled(false);
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ }
TextView headerTitle = (TextView) findViewById(R.id.header_title);
headerTitle.setText(getString(R.string.header_title_text,
@@ -133,35 +144,50 @@ public class UpdatesActivity extends UpdatesListActivity {
headerBuildDate.setText(StringGenerator.getDateLocalizedUTC(this,
DateFormat.LONG, BuildInfoUtils.getBuildDateTimestamp()));
- // Switch between header title and appbar title minimizing overlaps
- final CollapsingToolbarLayout collapsingToolbar =
- (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
- final AppBarLayout appBar = (AppBarLayout) findViewById(R.id.app_bar);
- appBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
- boolean mIsShown = false;
+ if (!mIsTV) {
+ // Switch between header title and appbar title minimizing overlaps
+ final CollapsingToolbarLayout collapsingToolbar =
+ (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
+ final AppBarLayout appBar = (AppBarLayout) findViewById(R.id.app_bar);
+ appBar.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
+ boolean mIsShown = false;
- @Override
- public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
- int scrollRange = appBarLayout.getTotalScrollRange();
- if (!mIsShown && scrollRange + verticalOffset < 10) {
- collapsingToolbar.setTitle(getString(R.string.display_name));
- mIsShown = true;
- } else if (mIsShown && scrollRange + verticalOffset > 100) {
- collapsingToolbar.setTitle(null);
- mIsShown = false;
+ @Override
+ public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
+ int scrollRange = appBarLayout.getTotalScrollRange();
+ if (!mIsShown && scrollRange + verticalOffset < 10) {
+ collapsingToolbar.setTitle(getString(R.string.display_name));
+ mIsShown = true;
+ } else if (mIsShown && scrollRange + verticalOffset > 100) {
+ collapsingToolbar.setTitle(null);
+ mIsShown = false;
+ }
}
+ });
+
+ mRefreshAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f,
+ Animation.RELATIVE_TO_SELF, 0.5f);
+ mRefreshAnimation.setInterpolator(new LinearInterpolator());
+ mRefreshAnimation.setDuration(1000);
+
+ if (!Utils.hasTouchscreen(this)) {
+ // This can't be collapsed without a touchscreen
+ appBar.setExpanded(false);
}
- });
-
- if (!Utils.hasTouchscreen(this)) {
- // This can't be collapsed without a touchscreen
- appBar.setExpanded(false);
+ } else {
+ findViewById(R.id.refresh).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ downloadUpdatesList(true);
+ }
+ });
+ findViewById(R.id.preferences).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ showPreferencesDialog();
+ }
+ });
}
-
- mRefreshAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f,
- Animation.RELATIVE_TO_SELF, 0.5f);
- mRefreshAnimation.setInterpolator(new LinearInterpolator());
- mRefreshAnimation.setDuration(1000);
}
@Override
@@ -393,20 +419,35 @@ public class UpdatesActivity extends UpdatesListActivity {
}
private void refreshAnimationStart() {
- if (mRefreshIconView == null) {
- mRefreshIconView = findViewById(R.id.menu_refresh);
- }
- if (mRefreshIconView != null) {
- mRefreshAnimation.setRepeatCount(Animation.INFINITE);
- mRefreshIconView.startAnimation(mRefreshAnimation);
- mRefreshIconView.setEnabled(false);
+ if (!mIsTV) {
+ if (mRefreshIconView == null) {
+ mRefreshIconView = findViewById(R.id.menu_refresh);
+ }
+ if (mRefreshIconView != null) {
+ mRefreshAnimation.setRepeatCount(Animation.INFINITE);
+ mRefreshIconView.startAnimation(mRefreshAnimation);
+ mRefreshIconView.setEnabled(false);
+ }
+ } else {
+ findViewById(R.id.recycler_view).setVisibility(View.GONE);
+ findViewById(R.id.no_new_updates_view).setVisibility(View.GONE);
+ findViewById(R.id.refresh_progress).setVisibility(View.VISIBLE);
}
}
private void refreshAnimationStop() {
- if (mRefreshIconView != null) {
- mRefreshAnimation.setRepeatCount(0);
- mRefreshIconView.setEnabled(true);
+ if (!mIsTV) {
+ if (mRefreshIconView != null) {
+ mRefreshAnimation.setRepeatCount(0);
+ mRefreshIconView.setEnabled(true);
+ }
+ } else {
+ findViewById(R.id.refresh_progress).setVisibility(View.GONE);
+ if (mAdapter.getItemCount() > 0) {
+ findViewById(R.id.recycler_view).setVisibility(View.VISIBLE);
+ } else {
+ findViewById(R.id.no_new_updates_view).setVisibility(View.VISIBLE);
+ }
}
}