removed some unused resources

updated version code
added progress bar for video
This commit is contained in:
Mariotaku Lee 2015-04-09 01:41:37 +08:00
parent 3babd63c0f
commit efa748dea2
10 changed files with 96 additions and 205 deletions

View File

@ -10,7 +10,7 @@ android {
applicationId "org.mariotaku.twidere"
minSdkVersion 14
targetSdkVersion 22
versionCode 106
versionCode 107
versionName "0.3.0"
multiDexEnabled true
}

View File

@ -19,11 +19,14 @@ package org.mariotaku.twidere.activity.support;
import android.content.Intent;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnErrorListener;
import android.media.MediaPlayer.OnPreparedListener;
import android.net.Uri;
import android.os.AsyncTask.Status;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
@ -42,6 +45,8 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLayoutChangeListener;
import android.view.ViewGroup;
import android.widget.MediaController;
import android.widget.ProgressBar;
import com.davemorrissey.labs.subscaleview.ImageSource;
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
@ -181,7 +186,7 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
}
public static final class VideoPageFragment extends BaseSupportFragment
implements VideoLoadingListener, OnPreparedListener {
implements VideoLoadingListener, OnPreparedListener, OnErrorListener, OnCompletionListener {
private static final String[] SUPPORTED_VIDEO_TYPES;
@ -193,10 +198,19 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
}
}
private TextureVideoView mVideoView;
private VideoLoader mVideoLoader;
private TextureVideoView mVideoView;
private ProgressBar mVideoViewProgress;
private boolean mPlayAudio;
private VideoPlayProgressRunnable mVideoProgressRunnable;
@Override
public void onCompletion(MediaPlayer mp) {
// mVideoViewProgress.removeCallbacks(mVideoProgressRunnable);
// mVideoViewProgress.setVisibility(View.GONE);
}
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@ -207,12 +221,51 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mVideoLoader = TwidereApplication.getInstance(getActivity()).getVideoLoader();
mVideoProgressRunnable = new VideoPlayProgressRunnable(mVideoViewProgress.getHandler(),
mVideoViewProgress, mVideoView);
final String url = getBestVideoUrl(getMedia());
if (url != null) {
mVideoLoader.loadVideo(url, this);
}
mVideoView.setOnPreparedListener(this);
mVideoView.setOnErrorListener(this);
mVideoView.setOnCompletionListener(this);
}
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
mVideoViewProgress.removeCallbacks(mVideoProgressRunnable);
mVideoViewProgress.setVisibility(View.GONE);
return true;
}
private static class VideoPlayProgressRunnable implements Runnable {
private final Handler mHandler;
private final ProgressBar mProgressBar;
private final MediaController.MediaPlayerControl mMediaPlayerControl;
VideoPlayProgressRunnable(Handler handler, ProgressBar progressBar,
MediaController.MediaPlayerControl mediaPlayerControl) {
mHandler = handler;
mProgressBar = progressBar;
mMediaPlayerControl = mediaPlayerControl;
mProgressBar.setMax(1000);
}
@Override
public void run() {
final int duration = mMediaPlayerControl.getDuration();
final int position = mMediaPlayerControl.getCurrentPosition();
if (duration <= 0 || position < 0) return;
mProgressBar.setProgress(Math.round(1000 * position / (float) duration));
mHandler.postDelayed(this, 16);
}
}
@Override
public void onPrepared(MediaPlayer mp) {
if (getUserVisibleHint()) {
@ -223,6 +276,8 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
mp.setVolume(0, 0);
}
mp.start();
mVideoViewProgress.setVisibility(View.VISIBLE);
mVideoViewProgress.post(mVideoProgressRunnable);
}
}
@ -240,6 +295,7 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
public void onBaseViewCreated(View view, Bundle savedInstanceState) {
super.onBaseViewCreated(view, savedInstanceState);
mVideoView = (TextureVideoView) view.findViewById(R.id.video_view);
mVideoViewProgress = (ProgressBar) view.findViewById(R.id.video_view_progress);
}
@Override
@ -265,15 +321,14 @@ public final class MediaViewerActivity extends ThemedActionBarActivity implement
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
// if (mVideoView != null && mVideoView.isPlaying()) {
// mVideoView.pause();
// }
if (!isVisibleToUser && mVideoView != null && mVideoView.isPlaying()) {
mVideoView.pause();
}
}
@Override
public void onVideoLoadingComplete(String uri, VideoLoadingListener listener, File file) {
mVideoView.setVideoURI(Uri.fromFile(file));
mVideoView.setOnPreparedListener(this);
}
@Override

View File

@ -2,7 +2,7 @@
<!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
~ Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
@ -18,8 +18,9 @@
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<WebView
android:id="@+id/webview"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<clip xmlns:android="http://schemas.android.com/apk/res/android"
android:clipOrientation="horizontal">
<shape android:shape="rectangle">
<solid android:color="@color/branding_color"/>
</shape>
</clip>

View File

@ -1,40 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<com.mobeta.android.dslv.DragSortListView
android:id="@android:id/list"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:collapsed_height="2dp"
app:drag_enabled="true"
app:drag_handle_id="@+id/drag_handle"
app:drag_scroll_start="0.33"
app:float_alpha="0.6"
app:float_background_color="@android:color/transparent"
app:max_drag_scroll_speed="0.5"
app:remove_enabled="false"
app:slide_shuffle_speed="0.3"
app:sort_enabled="true"
app:track_drag_sort="true"
app:use_default_controller="true"
tools:context=".fragment.AccountsManagerFragment"/>

View File

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<GridView
android:id="@android:id/list"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:horizontalSpacing="@dimen/element_spacing_small"
android:numColumns="8"
android:stretchMode="columnWidth"
android:verticalSpacing="@dimen/element_spacing_small"/>

View File

@ -1,67 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<org.mariotaku.twidere.view.ExtendedFrameLayout
android:id="@+id/details_container"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<ProgressBar
android:id="@+id/details_load_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone"/>
<LinearLayout
android:id="@+id/error_retry_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:padding="16dp"
android:visibility="gone">
<TextView
android:id="@+id/error_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:visibility="gone"/>
<Button
android:id="@+id/retry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:minWidth="84dp"
android:text="@string/retry"
android:textAppearance="?android:attr/textAppearanceSmall"/>
</LinearLayout>
</FrameLayout>

View File

@ -23,18 +23,38 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.sprylab.android.widget.TextureVideoView
android:id="@+id/video_view"
<RelativeLayout
android:layout_width="match_parent"
android:layout_gravity="center"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content"
android:layout_gravity="center">
<com.sprylab.android.widget.TextureVideoView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
<ProgressBar
android:id="@+id/video_view_progress"
style="?android:progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="@dimen/element_spacing_xsmall"
android:layout_alignBottom="@+id/video_view"
android:layout_gravity="bottom"
android:background="@color/bg_color_video_playback_progress"
android:indeterminateDrawable="@android:color/transparent"
android:progressDrawable="@drawable/progress_bar_video"
android:visibility="gone"/>
</RelativeLayout>
<ProgressBar
android:visibility="gone"
android:id="@+id/progress"
android:layout_width="@dimen/element_size_normal"
android:layout_height="@dimen/element_size_normal"
android:layout_gravity="center"/>
android:layout_gravity="center"
android:visibility="gone"/>
</FrameLayout>

View File

@ -1,37 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<org.mariotaku.twidere.view.SquareRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="@dimen/element_spacing_xsmall">
<org.mariotaku.twidere.view.ForegroundColorView
android:id="@+id/color"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:background="?android:activatedBackgroundIndicator"
android:foreground="?android:selectableItemBackground"
android:padding="@dimen/element_spacing_xsmall"/>
</org.mariotaku.twidere.view.SquareRelativeLayout>

View File

@ -31,5 +31,6 @@
<color name="background_color_card_item_dark">#1a1a1a</color>
<color name="background_color_card_item_light">#fafafa</color>
<color name="background_color_action_bar_dark">#212121</color>
<color name="bg_color_video_playback_progress">#A0000000</color>
</resources>

View File

@ -154,10 +154,7 @@
<string name="reported_user_for_spam">Reported this user for spam.</string>
<string name="reported_users_for_spam">Reported these users for spam.</string>
<string name="filename_hint">Filename</string>
<string name="overwrite_confirm">File exists, overwrite?</string>
<string name="save_as">Save as</string>
<string name="please_wait">Please wait.</string>
<string name="file_saved_to">File saved to <xliff:g id="filename">%s</xliff:g> .</string>
<string name="saved_to_gallery">Saved to gallery.</string>
<string name="proxy">Proxy</string>
<string name="http_proxy">HTTP Proxy</string>
@ -229,9 +226,6 @@
<string name="tabs">Tabs</string>
<string name="add_tab">Add tab</string>
<string name="edit_tab">Edit tab</string>
<string name="move_up">Move up</string>
<string name="move_down">Move down</string>
<string name="unsaved_change_back_pressed">You have unsaved changes, press BACK again to discard.</string>
<string name="invalid_settings">Found invalid settings.</string>
<string name="icon">Icon</string>
<string name="pick_file">Pick file</string>
@ -250,7 +244,6 @@
<string name="error_message_image_uploader_not_found">Image uploader not found, maybe it was uninstalled.</string>
<string name="image_upload_format">Tweet format with image</string>
<string name="image_upload_format_summary">\"[LINK]\" = Image link\n\"[TEXT]\" = Tweet content\n(Extension only)</string>
<string name="tweet_shortener">Tweet shortener</string>
<string name="status_shortener">Tweet shortener</string>
<string name="status_shortener_default">None (Abort sending)</string>
<string name="error_message_status_too_long">Tweet too long.</string>
@ -262,15 +255,11 @@
<string name="show_absolute_time_summary">Show absolute time in tweets</string>
<string name="user_mentions">User mentions</string>
<string name="dual_pane_layout">Dual Pane Layout</string>
<string name="landscape">Landscape</string>
<string name="portrait">Portrait</string>
<string name="quick_send">Hit \"Enter\" to Send</string>
<string name="quick_send_summary">Send tweet when hit \"Enter\".</string>
<string name="unsaved_status">Tweet not sent or saved yet.</string>
<string name="discard">Discard</string>
<string name="Nitems_selected_quantity_one">1 item selected</string>
<string name="Nitems_selected_quantity_other"><xliff:g id="items">%d</xliff:g> items selected</string>
<string name="view">View</string>
<string name="custom_host_mapping">Custom host mapping</string>
<string name="custom_host_mapping_summary">Host mapping like /etc/hosts, but does not require any additional permissions.</string>
<string name="host_mapping_host">Host</string>
@ -308,8 +297,6 @@
<string name="incoming_friendships">Pending follow requests</string>
<string name="send_follow_request">Send follow request</string>
<string name="follow_request_sent">Follow request sent</string>
<string name="separate_retweet_action">Separate retweet action</string>
<string name="separate_retweet_action_summary">Show both retweet and quote action in tweet menu</string>
<string name="status">Tweet</string>
<string name="preview">Preview</string>
<string name="connection_timeout">Connection timeout</string>