Video autoplay option added.

captchafix
Florens Douwes 11 years ago
parent 7e0c024a99
commit 07c1dae22f
  1. 4
      Chan/res/values/strings.xml
  2. 8
      Chan/res/xml/preference.xml
  3. 4
      Chan/src/org/floens/chan/core/ChanPreferences.java
  4. 16
      Chan/src/org/floens/chan/ui/fragment/ImageViewFragment.java

@ -94,9 +94,7 @@
<string name="preference_general">General</string>
<string name="preference_open_link_confirmation">Ask before opening links</string>
<string name="preference_enable_video">Enable videos</string>
<string name="preference_enable_video_enabled">Displaying videos</string>
<string name="preference_enable_video_disabled">Not displaying videos</string>
<string name="preference_autoplay">Start playing videos directly</string>
<string name="preference_default_name">Default name</string>
<string name="preference_default_email">Default email</string>

@ -22,11 +22,9 @@
android:key="preference_open_link_confirmation"
android:title="@string/preference_open_link_confirmation" />
<CheckBoxPreference
android:defaultValue="true"
android:key="preference_enable_video"
android:title="@string/preference_enable_video"
android:summaryOn="@string/preference_enable_video_enabled"
android:summaryOff="@string/preference_enable_video_disabled" />
android:defaultValue="false"
android:key="preference_autoplay"
android:title="@string/preference_autoplay" />
<EditTextPreference
android:key="preference_default_name"

@ -55,8 +55,8 @@ public class ChanPreferences {
return Integer.parseInt(number) * 1000L;
}
public static boolean getVideosEnabled() {
return ChanApplication.getPreferences().getBoolean("preference_enable_video", true);
public static boolean getVideoAutoPlay() {
return ChanApplication.getPreferences().getBoolean("preference_autoplay", false);
}
}

@ -1,6 +1,7 @@
package org.floens.chan.ui.fragment;
import org.floens.chan.R;
import org.floens.chan.core.ChanPreferences;
import org.floens.chan.core.model.Post;
import org.floens.chan.ui.activity.ImageViewActivity;
import org.floens.chan.ui.adapter.ImageViewAdapter;
@ -73,6 +74,10 @@ public class ImageViewFragment extends Fragment implements ThumbnailImageViewCal
isVideo = true;
activity.invalidateActionBar();
showProgressBar(false);
if (ChanPreferences.getVideoAutoPlay()) {
startVideo();
}
} else {
imageView.setBigImage(post.imageUrl);
}
@ -105,7 +110,8 @@ public class ImageViewFragment extends Fragment implements ThumbnailImageViewCal
VideoView view = imageView.getVideoView();
if (view != null) {
item.setIcon((videoSetIconToPause || view.isPlaying()) ? R.drawable.ic_action_pause : R.drawable.ic_action_play);
item.setIcon((videoSetIconToPause || view.isPlaying()) ? R.drawable.ic_action_pause
: R.drawable.ic_action_play);
}
videoSetIconToPause = false;
}
@ -113,8 +119,7 @@ public class ImageViewFragment extends Fragment implements ThumbnailImageViewCal
public void customOnOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_image_play_state) {
if (!videoVisible) {
videoVisible = true;
imageView.setVideo(post.imageUrl);
startVideo();
} else {
VideoView view = imageView.getVideoView();
if (view != null) {
@ -130,6 +135,11 @@ public class ImageViewFragment extends Fragment implements ThumbnailImageViewCal
}
}
private void startVideo() {
videoVisible = true;
imageView.setVideo(post.imageUrl);
}
public void showProgressBar(boolean e) {
showProgressBar = e;
activity.callOnSelect();

Loading…
Cancel
Save