Commit b29b29e4 authored by Geoffrey Métais's avatar Geoffrey Métais

Move Stream fragment in a Dialog, backport on TV

parent 53b85d0d
......@@ -490,7 +490,7 @@
<activity
android:name=".gui.DialogActivity"
android:configChanges="orientation|screenSize"
android:theme="@style/TransparentTheme" />
android:theme="@style/VLCTransparentTheme" />
<service android:name=".extensions.ExtensionManagerService" />
<service android:name=".PlaybackService" >
......
......@@ -11,6 +11,7 @@
android:paddingEnd="10dp"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:focusable="true"
android:clickable="true" >
<TextView
android:id="@+id/mrl_item_title"
......
......@@ -4,7 +4,10 @@
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/mrl_root"
android:layout_width="match_parent" android:layout_height="match_parent">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/background_default_darker"
android:padding="@dimen/default_margin">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
......@@ -26,19 +29,20 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignBottom="@+id/mrl_edit"
android:layout_alignTop="@+id/mrl_edit"
android:scaleType="center"
android:src="@drawable/ic_send"
android:layout_marginRight="10dp"/>
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/mrl_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:layout_marginLeft="15dp"
android:layout_below="@+id/mrl_edit"/>
<include layout="@layout/shadow_top"/>
android:layout_below="@+id/mrl_edit"
android:background="?attr/background_default"/>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
......@@ -251,6 +251,18 @@
<item name="list_title">@color/bt_list_title</item>
</style>
<style name="VLCTransparentTheme" parent="Theme.VLC">
<item name="android:background">@android:color/transparent</item>
<item name="background">@android:color/transparent</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@android:color/transparent</item>
<item name="android:windowContentOverlay">@android:color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@android:color/transparent</item>
</style>
<style name="TextView" parent="android:Widget.TextView">
<item name="android:textDirection">locale</item>
</style>
......
......@@ -24,32 +24,58 @@
package org.videolan.vlc.gui;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.app.AppCompatDelegate;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.dialogs.VlcDialog;
import org.videolan.vlc.gui.dialogs.VlcLoginDialog;
import org.videolan.vlc.gui.dialogs.VlcProgressDialog;
import org.videolan.vlc.gui.dialogs.VlcQuestionDialog;
import org.videolan.vlc.gui.network.MRLPanelFragment;
public class DialogActivity extends AppCompatActivity {
static {
AppCompatDelegate.setDefaultNightMode(PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext()).getBoolean("daynight", false) ? AppCompatDelegate.MODE_NIGHT_AUTO : AppCompatDelegate.MODE_NIGHT_NO);
}
public static final String KEY_LOGIN = "LoginDialog";
public static final String KEY_QUESTION = "QuestionDialog";
public static final String KEY_PROGRESS = "ProgressDialog";
public static final String KEY_STREAM = "streamDialog";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
boolean enableBlackTheme = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("enable_black_theme", false);
if (VLCApplication.showTvUi() || enableBlackTheme) {
setTheme(R.style.Theme_VLC_Black);
}
String key = getIntent().getAction();
if (key.startsWith(KEY_LOGIN))
setupLoginDialog(key);
else if (key.startsWith(KEY_QUESTION))
setupQuestionDialog(key);
else if (key.startsWith(KEY_PROGRESS))
setupProgressDialog(key);
else
finish();
switch (key) {
case KEY_LOGIN:
setupLoginDialog(key);
break;
case KEY_QUESTION:
setupQuestionDialog(key);
break;
case KEY_PROGRESS:
setupProgressDialog(key);
break;
case KEY_STREAM:
setupStreamDialog();
break;
default:
finish();
}
}
private void setupStreamDialog() {
new MRLPanelFragment().show(getSupportFragmentManager(), "fragment_mrl");
}
private void setupLoginDialog(String key) {
......
......@@ -76,6 +76,7 @@ import org.videolan.vlc.gui.browser.ExtensionBrowser;
import org.videolan.vlc.gui.browser.FileBrowserFragment;
import org.videolan.vlc.gui.browser.MediaBrowserFragment;
import org.videolan.vlc.gui.browser.NetworkBrowserFragment;
import org.videolan.vlc.gui.dialogs.AdvOptionsDialog;
import org.videolan.vlc.gui.helpers.UiTools;
import org.videolan.vlc.gui.network.MRLPanelFragment;
import org.videolan.vlc.gui.preferences.PreferencesActivity;
......@@ -437,8 +438,6 @@ public class MainActivity extends AudioPlayerContainerActivity implements Filter
return new FileBrowserFragment();
case R.id.nav_history:
return new HistoryFragment();
case R.id.nav_mrl:
return new MRLPanelFragment();
case R.id.nav_network:
return new NetworkBrowserFragment();
default:
......@@ -818,6 +817,9 @@ public class MainActivity extends AudioPlayerContainerActivity implements Filter
case R.id.nav_settings:
startActivityForResult(new Intent(this, PreferencesActivity.class), ACTIVITY_RESULT_PREFERENCES);
break;
case R.id.nav_mrl:
new MRLPanelFragment().show(getSupportFragmentManager(), "fragment_mrl");
break;
case R.id.nav_directories:
if (TextUtils.equals(BuildConfig.FLAVOR_target, "chrome")) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
......
......@@ -20,12 +20,12 @@
*****************************************************************************/
package org.videolan.vlc.gui.network;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TextInputLayout;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.support.v4.app.DialogFragment;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
......@@ -35,56 +35,42 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.ImageView;
import android.widget.TextView;
import org.videolan.medialibrary.media.HistoryItem;
import org.videolan.medialibrary.media.MediaWrapper;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.DialogActivity;
import org.videolan.vlc.gui.helpers.UiTools;
import org.videolan.vlc.interfaces.IHistory;
import org.videolan.vlc.media.MediaUtils;
public class MRLPanelFragment extends Fragment implements IHistory, View.OnKeyListener, TextView.OnEditorActionListener, View.OnClickListener {
public class MRLPanelFragment extends DialogFragment implements View.OnKeyListener, TextView.OnEditorActionListener, View.OnClickListener {
private static final String TAG = "VLC/MrlPanelFragment";
public static final String KEY_MRL = "mrl";
private RecyclerView mRecyclerView;
private MRLAdapter mAdapter;
private RecyclerView.LayoutManager mLayoutManager;
TextInputLayout mEditText;
ImageView mSend;
View mRootView;
private TextInputLayout mEditText;
public MRLPanelFragment(){}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(R.string.open_mrl_dialog_title);
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
int theme = UiTools.isBlackThemeEnabled() ? R.style.Theme_VLC_Black : R.style.Theme_VLC;
setStyle(DialogFragment.STYLE_NO_FRAME, theme);
View v = inflater.inflate(R.layout.mrl_panel, container, false);
mRootView = v.findViewById(R.id.mrl_root);
mEditText = (TextInputLayout) v.findViewById(R.id.mrl_edit);
mSend = (ImageView) v.findViewById(R.id.send);
mEditText.getEditText().setOnKeyListener(this);
mEditText.getEditText().setOnEditorActionListener(this);
mEditText.setHint(getString(R.string.open_mrl_dialog_msg));
mRecyclerView = (RecyclerView) v.findViewById(R.id.mrl_list);
mRecyclerView.addItemDecoration(new DividerItemDecoration(v.getContext(), DividerItemDecoration.VERTICAL));
mLayoutManager = new LinearLayoutManager(getActivity());
mRecyclerView.setLayoutManager(mLayoutManager);
RecyclerView recyclerView = (RecyclerView) v.findViewById(R.id.mrl_list);
recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL));
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
mAdapter = new MRLAdapter();
mRecyclerView.setAdapter(mAdapter);
mSend.setOnClickListener(this);
recyclerView.setAdapter(mAdapter);
v.findViewById(R.id.send).setOnClickListener(this);
return v;
}
public void onStart(){
public void onStart() {
super.onStart();
getActivity().findViewById(R.id.fab).setVisibility(View.INVISIBLE);
getActivity().supportInvalidateOptionsMenu();
updateHistory();
}
......@@ -112,9 +98,9 @@ public class MRLPanelFragment extends Fragment implements IHistory, View.OnKeyLi
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
return (keyCode == EditorInfo.IME_ACTION_DONE ||
keyCode == EditorInfo.IME_ACTION_GO ||
keyCode == EditorInfo.IME_ACTION_GO ||
(event.getAction() == KeyEvent.ACTION_DOWN &&
event.getKeyCode() == KeyEvent.KEYCODE_ENTER))
event.getKeyCode() == KeyEvent.KEYCODE_ENTER))
&& processUri();
}
......@@ -132,15 +118,8 @@ public class MRLPanelFragment extends Fragment implements IHistory, View.OnKeyLi
return false;
}
public void clearHistory(){
VLCApplication.getMLInstance().clearHistory();
mAdapter.setList(new HistoryItem[0]);
getActivity().supportInvalidateOptionsMenu();
}
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
return false;
}
......@@ -152,4 +131,12 @@ public class MRLPanelFragment extends Fragment implements IHistory, View.OnKeyLi
public void onClick(View v) {
processUri();
}
@Override
public void onDestroy() {
super.onDestroy();
Activity activity = getActivity();
if (activity != null && activity instanceof DialogActivity)
activity.finish();
}
}
......@@ -96,6 +96,7 @@ public class MainTvActivity extends BaseTvActivity implements OnItemViewSelected
public static final long HEADER_NETWORK = 3;
public static final long HEADER_DIRECTORIES = 4;
public static final long HEADER_MISC = 5;
public static final long HEADER_STREAM = 6;
public static final long ID_SETTINGS = 0;
public static final long ID_ABOUT = 1;
......@@ -527,6 +528,7 @@ public class MainTvActivity extends BaseTvActivity implements OnItemViewSelected
if (AndroidDevices.hasLANConnection()) {
final ArrayList<MediaWrapper> favs = MediaDatabase.getInstance().getAllNetworkFav();
mBrowserAdapter.add(new CardPresenter.SimpleCard(HEADER_NETWORK, getString(R.string.network_browsing), R.drawable.ic_menu_network_big));
mBrowserAdapter.add(new CardPresenter.SimpleCard(HEADER_STREAM, getString(R.string.open_mrl), R.drawable.ic_menu_network_big));
if (!favs.isEmpty()) {
for (MediaWrapper fav : favs) {
......
......@@ -31,6 +31,7 @@ import org.videolan.medialibrary.media.MediaLibraryItem;
import org.videolan.medialibrary.media.MediaWrapper;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.DialogActivity;
import org.videolan.vlc.gui.tv.audioplayer.AudioPlayerActivity;
import org.videolan.vlc.gui.tv.browser.VerticalGridActivity;
import org.videolan.vlc.media.MediaUtils;
......@@ -76,10 +77,15 @@ public class TvUtil {
activity.startActivity(intent);
}
} else if (item instanceof CardPresenter.SimpleCard){
Intent intent = new Intent(activity, VerticalGridActivity.class);
intent.putExtra(MainTvActivity.BROWSER_TYPE, ((CardPresenter.SimpleCard) item).getId());
intent.setData(((CardPresenter.SimpleCard) item).getUri());
activity.startActivity(intent);
if (((CardPresenter.SimpleCard) item).getId() == MainTvActivity.HEADER_STREAM) {
activity.startActivity(new Intent(activity, DialogActivity.class).setAction(DialogActivity.KEY_STREAM)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
} else {
Intent intent = new Intent(activity, VerticalGridActivity.class);
intent.putExtra(MainTvActivity.BROWSER_TYPE, ((CardPresenter.SimpleCard) item).getId());
intent.setData(((CardPresenter.SimpleCard) item).getUri());
activity.startActivity(intent);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment