fix layout

This commit is contained in:
Christian Schabesberger 2017-02-27 16:38:01 +01:00
parent c14771534f
commit ce2ceb8a1b
5 changed files with 129 additions and 3 deletions

View file

@ -155,7 +155,6 @@
<activity
android:name=".ChannelActivity"
android:label="@string/title_activity_channel"
android:launchMode="singleTask"/>
<activity

View file

@ -7,6 +7,8 @@ import android.os.Handler;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
@ -26,6 +28,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.info_list.InfoItemBuilder;
import org.schabi.newpipe.info_list.InfoListAdapter;
import org.schabi.newpipe.report.ErrorActivity;
import org.schabi.newpipe.settings.SettingsActivity;
import org.schabi.newpipe.util.NavStack;
import java.io.IOException;
@ -303,6 +306,41 @@ public class ChannelActivity extends ThemableActivity {
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.menu_channel, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
super.onOptionsItemSelected(item);
switch(item.getItemId()) {
case R.id.action_settings: {
Intent intent = new Intent(this, SettingsActivity.class);
startActivity(intent);
return true;
}
case R.id.menu_item_openInBrowser: {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.setData(Uri.parse(channelUrl));
startActivity(Intent.createChooser(intent, getString(R.string.choose_browser)));
}
case R.id.menu_item_share:
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, channelUrl);
intent.setType("text/plain");
startActivity(Intent.createChooser(intent, getString(R.string.share_dialog_title)));
case android.R.id.home:
NavStack.getInstance().openMainActivity(this);
default:
return super.onOptionsItemSelected(item);
}
}
private String buildSubscriberString(long count) {
String out = "";

View file

@ -797,8 +797,11 @@ public class VideoItemDetailFragment extends Fragment {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
super.onOptionsItemSelected(item);
return actionBarHandler.onItemSelected(item);
if(!actionBarHandler.onItemSelected(item)) {
return super.onOptionsItemSelected(item);
} else {
return true;
}
}
public void setOnInvokeCreateOptionsMenuListener(OnInvokeCreateOptionsMenuListener listener) {

View file

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/channel_banner_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:scaleType="center"
android:src="@drawable/channel_banner"
android:background="@android:color/black"
android:adjustViewBounds="true"/>
<RelativeLayout
android:id="@+id/channel_avatar_layout"
android:layout_alignTop="@id/channel_banner_image"
android:layout_width="@dimen/channel_avatar_halo_size"
android:layout_height="@dimen/channel_avatar_halo_size"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp"
android:layout_marginTop="60dp">
<ImageView
android:id="@+id/channel_avatar_halo"
android:layout_width="@dimen/channel_avatar_halo_size"
android:layout_height="@dimen/channel_avatar_halo_size"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:src="@drawable/white_circle" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/channel_avatar_view"
android:layout_width="@dimen/channel_avatar_size"
android:layout_height="@dimen/channel_avatar_size"
android:src="@drawable/buddy"
android:layout_centerInParent="true"/>
</RelativeLayout>
<TextView
android:id="@+id/channel_title_view"
android:layout_below="@id/channel_banner_image"
android:layout_toEndOf="@id/channel_avatar_layout"
android:layout_toRightOf="@id/channel_avatar_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/video_item_detail_title_text_size"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<LinearLayout
android:id="@+id/channel_subscriber_layout"
android:layout_below="@id/channel_banner_image"
android:layout_toEndOf="@id/channel_title_view"
android:layout_toRightOf="@id/channel_title_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/channel_subscribe_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/subscribe"
android:layout_marginLeft="4dp"
android:layout_marginStart="4dp"/>
<TextView
android:id="@+id/channel_subscriber_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"/>
</LinearLayout>
</RelativeLayout>

View file

@ -2,6 +2,16 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="org.schabi.newpipe.ChannelActivity">
<item android:id="@+id/menu_item_openInBrowser"
app:showAsAction="never"
android:title="@string/open_in_browser" />
<item android:id="@+id/menu_item_share"
android:title="@string/share"
app:showAsAction="ifRoom"
android:icon="?attr/share"/>
<item
android:id="@+id/action_settings"
android:orderInCategory="100"