diff options
Diffstat (limited to 'org.fox.ttrss/src/main/java/org/fox')
8 files changed, 47 insertions, 24 deletions
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java index e639a825..9461e6a5 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/CommonActivity.java @@ -345,7 +345,8 @@ public class CommonActivity extends AppCompatActivity implements SharedPreferenc } String[] filter = new String[] { "enable_cats", "headline_mode", "widget_update_interval", - "headlines_swipe_to_dismiss", "headlines_mark_read_scroll", "headlines_request_size" }; + "headlines_swipe_to_dismiss", "headlines_mark_read_scroll", "headlines_request_size", + "force_phone_layout" }; m_needRestart = Arrays.asList(filter).indexOf(key) != -1; } diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/DetailActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/DetailActivity.java index 74e41842..3452ffa8 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/DetailActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/DetailActivity.java @@ -38,7 +38,11 @@ public class DetailActivity extends OnlineActivity implements HeadlinesEventList super.onCreate(savedInstanceState); - setContentView(R.layout.activity_detail); + if (m_prefs.getBoolean("force_phone_layout", false)) { + setContentView(R.layout.activity_detail_phone); + } else { + setContentView(R.layout.activity_detail); + } Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java index ac94d420..71fbdd08 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java @@ -50,17 +50,6 @@ import android.widget.ProgressBar; import android.widget.RelativeLayout; import android.widget.TextView; -import androidx.appcompat.app.ActionBar; -import androidx.core.app.ActivityCompat; -import androidx.core.app.ActivityOptionsCompat; -import androidx.core.view.ViewCompat; -import androidx.recyclerview.widget.DefaultItemAnimator; -import androidx.recyclerview.widget.DividerItemDecoration; -import androidx.recyclerview.widget.ItemTouchHelper; -import androidx.recyclerview.widget.LinearLayoutManager; -import androidx.recyclerview.widget.RecyclerView; -import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; - import com.amulyakhare.textdrawable.TextDrawable; import com.amulyakhare.textdrawable.util.ColorGenerator; import com.bumptech.glide.Glide; @@ -92,6 +81,16 @@ import java.util.HashMap; import java.util.List; import java.util.TimeZone; +import androidx.appcompat.app.ActionBar; +import androidx.core.app.ActivityCompat; +import androidx.core.app.ActivityOptionsCompat; +import androidx.core.view.ViewCompat; +import androidx.recyclerview.widget.DefaultItemAnimator; +import androidx.recyclerview.widget.DividerItemDecoration; +import androidx.recyclerview.widget.ItemTouchHelper; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import icepick.State; import jp.wasabeef.glide.transformations.CropCircleTransformation; @@ -442,6 +441,8 @@ public class HeadlinesFragment extends StateSavedFragment { } m_list.setOnScrollListener(new RecyclerView.OnScrollListener() { + boolean m_forcePhoneLayout = m_prefs.getBoolean("force_phone_layout", false); + @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); @@ -498,7 +499,7 @@ public class HeadlinesFragment extends StateSavedFragment { } } - if (!m_activity.isTablet() && m_articles.size() > 0) { + if ((m_forcePhoneLayout || !m_activity.isTablet()) && m_articles.size() > 0) { m_amountScrolled += dy; ActionBar bar = m_activity.getSupportActionBar(); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/MasterActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/MasterActivity.java index 1b638d48..44a9a7c3 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/MasterActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/MasterActivity.java @@ -58,7 +58,11 @@ public class MasterActivity extends OnlineActivity implements HeadlinesEventList super.onCreate(savedInstanceState); - setContentView(R.layout.activity_master); + if (m_prefs.getBoolean("force_phone_layout", false)) { + setContentView(R.layout.activity_master_phone); + } else { + setContentView(R.layout.activity_master); + } setSmallScreen(findViewById(R.id.sw600dp_anchor) == null); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/PreferencesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/PreferencesFragment.java index 1735f0df..1fb663d1 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/PreferencesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/PreferencesFragment.java @@ -1,6 +1,5 @@ package org.fox.ttrss; -import android.app.Activity; import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; @@ -42,13 +41,15 @@ public class PreferencesFragment extends PreferenceFragment { } }); + CommonActivity activity = (CommonActivity) getActivity(); + + findPreference("force_phone_layout").setEnabled(activity.isTablet()); + try { String version; int versionCode; String buildTimestamp; - Activity activity = getActivity(); - PackageInfo packageInfo = activity.getPackageManager(). getPackageInfo(activity.getPackageName(), 0); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineDetailActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineDetailActivity.java index 3106ab20..9fcf6072 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineDetailActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineDetailActivity.java @@ -39,7 +39,11 @@ public class OfflineDetailActivity extends OfflineActivity implements OfflineHea super.onCreate(savedInstanceState); - setContentView(R.layout.activity_detail); + if (m_prefs.getBoolean("force_phone_layout", false)) { + setContentView(R.layout.activity_detail_phone); + } else { + setContentView(R.layout.activity_detail); + } Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java index 06a86cec..811cc015 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineHeadlinesFragment.java @@ -107,6 +107,8 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis private ListView m_list; private int m_listPreviousVisibleItem; + boolean m_forcePhoneLayout; + public void initialize(int feedId, boolean isCat, boolean compactMode) { m_feedId = feedId; m_feedIsCat = isCat; @@ -356,6 +358,8 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis m_list = view.findViewById(R.id.headlines_list); + m_forcePhoneLayout = m_prefs.getBoolean("force_phone_layout", false); + FloatingActionButton fab = view.findViewById(R.id.headlines_fab); fab.setVisibility(View.GONE); @@ -648,7 +652,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis holder.textImage.setImageDrawable(textDrawable); - Glide.with(OfflineHeadlinesFragment.this) + Glide.with(getContext()) .load(afi.flavorImageUri) .placeholder(textDrawable) .bitmapTransform(new CropCircleTransformation(getActivity())) @@ -1000,7 +1004,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis try { - Glide.with(OfflineHeadlinesFragment.this) + Glide.with(getContext()) .load(afi.flavorImageUri) //.dontTransform() .diskCacheStrategy(DiskCacheStrategy.NONE) @@ -1320,7 +1324,7 @@ public class OfflineHeadlinesFragment extends Fragment implements OnItemClickLis } } - if (!m_activity.isTablet()) { + if (m_forcePhoneLayout || !m_activity.isTablet()) { if (m_adapter.getCount() > 0) { if (firstVisibleItem > m_listPreviousVisibleItem) { m_activity.getSupportActionBar().hide(); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineMasterActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineMasterActivity.java index 4e40ca27..cdaa794e 100755 --- a/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineMasterActivity.java +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/offline/OfflineMasterActivity.java @@ -47,8 +47,12 @@ public class OfflineMasterActivity extends OfflineActivity implements OfflineHea setAppTheme(m_prefs); super.onCreate(savedInstanceState); - - setContentView(R.layout.activity_master); + + if (m_prefs.getBoolean("force_phone_layout", false)) { + setContentView(R.layout.activity_master_phone); + } else { + setContentView(R.layout.activity_master); + } Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); |