mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-08-31 21:41:33 +00:00
Add button on action bar to enter full screen mode
This commit is contained in:
parent
0ed61d89c3
commit
1fe2e4f083
5 changed files with 30 additions and 19 deletions
|
@ -1,6 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_reading_fullscreen"
|
||||
android:icon="@drawable/newsblur_share"
|
||||
android:showAsAction="always"
|
||||
android:title="@string/menu_fullscreen"
|
||||
android:visible="false"/>
|
||||
<item
|
||||
android:id="@+id/menu_reading_sharenewsblur"
|
||||
android:icon="@drawable/newsblur_share"
|
||||
|
|
|
@ -103,6 +103,7 @@
|
|||
<string name="menu_mark_previous_stories_as_read">Mark previous as read</string>
|
||||
<string name="menu_mark_story_as_read">Mark as read</string>
|
||||
<string name="menu_mark_unread">Mark as unread</string>
|
||||
<string name="menu_fullscreen">Full Screen</string>
|
||||
|
||||
<string name="toast_error_loading_stories">Error loading stories</string>
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ import com.newsblur.util.DefaultFeedView;
|
|||
import com.newsblur.util.FeedUtils;
|
||||
import com.newsblur.util.PrefsUtils;
|
||||
import com.newsblur.util.UIUtils;
|
||||
import com.newsblur.util.ViewUtils;
|
||||
import com.newsblur.view.NonfocusScrollview.ScrollChangeListener;
|
||||
|
||||
public abstract class Reading extends NbFragmentActivity implements OnPageChangeListener, OnSeekBarChangeListener, ScrollChangeListener, FeedUtils.ActionCompletionListener, LoaderManager.LoaderCallbacks<Cursor> {
|
||||
|
@ -210,6 +211,7 @@ public abstract class Reading extends NbFragmentActivity implements OnPageChange
|
|||
Story story = readingAdapter.getStory(pager.getCurrentItem());
|
||||
if (story == null ) { return false; }
|
||||
menu.findItem(R.id.menu_reading_save).setTitle(story.starred ? R.string.menu_unsave_story : R.string.menu_save_story);
|
||||
menu.findItem(R.id.menu_reading_fullscreen).setVisible(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -249,7 +251,10 @@ public abstract class Reading extends NbFragmentActivity implements OnPageChange
|
|||
} else if (item.getItemId() == R.id.menu_reading_markunread) {
|
||||
this.markStoryUnread(story);
|
||||
return true;
|
||||
} else {
|
||||
} else if (item.getItemId() == R.id.menu_reading_fullscreen) {
|
||||
ViewUtils.hideSystemUI(getWindow().getDecorView());
|
||||
return true;
|
||||
} else {
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -562,28 +562,12 @@ public class ReadingItemFragment extends Fragment implements ClassifierDialogFra
|
|||
@Override
|
||||
public boolean onSingleTapUp(MotionEvent e) {
|
||||
if ((view.getSystemUiVisibility() & View.SYSTEM_UI_FLAG_IMMERSIVE) != 0) {
|
||||
showSystemUI();
|
||||
ViewUtils.showSystemUI(view);
|
||||
} else {
|
||||
hideSystemUI();
|
||||
ViewUtils.hideSystemUI(view);
|
||||
}
|
||||
|
||||
return super.onSingleTapUp(e);
|
||||
}
|
||||
|
||||
private void hideSystemUI() {
|
||||
view.setSystemUiVisibility(
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_IMMERSIVE);
|
||||
}
|
||||
|
||||
private void showSystemUI() {
|
||||
// Some layout/drawing artifacts as we don't use the FLAG_LAYOUT flags but otherwise the overlays wouldn't appear
|
||||
// and the action bar would overlap the content
|
||||
view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,4 +127,19 @@ public class ViewUtils {
|
|||
v.setPadding(oldPadL, oldPadT, oldPadR, oldPadB);
|
||||
}
|
||||
|
||||
public static void showSystemUI(View view) {
|
||||
// Some layout/drawing artifacts as we don't use the FLAG_LAYOUT flags but otherwise the overlays wouldn't appear
|
||||
// and the action bar would overlap the content
|
||||
view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
|
||||
}
|
||||
|
||||
public static void hideSystemUI(View view) {
|
||||
view.setSystemUiVisibility(
|
||||
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_IMMERSIVE);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue