Commit a9f6f6b8 authored by fallenstardust's avatar fallenstardust

mycard移除drawer布局,将用户信息和聊天室入口移至可见区域

parent f96b272f
......@@ -213,10 +213,6 @@ public class MyCard {
public interface MyCardListener {
void onLogin(String name, String icon, String statu);
void openDrawer();
void closeDrawer();
void backHome();
void share(String text);
......@@ -281,7 +277,7 @@ public class MyCard {
activity.runOnUiThread(mListener::puzzleMode);
}
}
*/
@JavascriptInterface
public void openDrawer() {
if (mListener != null) {
......@@ -289,6 +285,13 @@ public class MyCard {
}
}
@JavascriptInterface
public void closeDrawer() {
if (mListener != null) {
activity.runOnUiThread(mListener::closeDrawer);
}
}
*/
@JavascriptInterface
public void backHome() {
if (mListener != null) {
......@@ -305,13 +308,6 @@ public class MyCard {
}
}
@JavascriptInterface
public void closeDrawer() {
if (mListener != null) {
activity.runOnUiThread(mListener::closeDrawer);
}
}
@JavascriptInterface
public void join(String host, int port, String name, String room) {
try {
......
......@@ -40,11 +40,10 @@ import cn.garymb.ygomobile.lite.R;
import cn.garymb.ygomobile.ui.mycard.mcchat.SplashActivity;
import cn.garymb.ygomobile.utils.glide.GlideCompat;
public class MycardFragment extends BaseFragemnt implements View.OnClickListener, MyCard.MyCardListener, NavigationView.OnNavigationItemSelectedListener {
public class MycardFragment extends BaseFragemnt implements View.OnClickListener, MyCard.MyCardListener {
private static final int FILECHOOSER_RESULTCODE = 10;
private static final int TYPE_MC_LOGIN = 0;
protected DrawerLayout mDrawerlayout;
private MyCardWebView mWebViewPlus;
private MyCard mMyCard;
private ImageView mHeadView;
......@@ -74,10 +73,7 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View view;
if (isHorizontal)
view = inflater.inflate(R.layout.mycard_horizontal_fragment, container, false);
else
view = inflater.inflate(R.layout.fragment_mycard, container, false);
view = inflater.inflate(R.layout.fragment_mycard, container, false);
initView(view);
return view;
}
......@@ -86,21 +82,16 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
YGOStarter.onCreated(getActivity());
mMyCard = new MyCard(getActivity());
mWebViewPlus = view.findViewById(R.id.webbrowser);
mDrawerlayout = view.findViewById(R.id.drawer_layout);
mProgressBar = view.findViewById(R.id.progressBar);
tv_back_mc = view.findViewById(R.id.tv_back_mc);
mProgressBar.setMax(100);
tv_back_mc = view.findViewById(R.id.tv_back_mc);
tv_back_mc.setOnClickListener(this);
NavigationView navigationView = view.findViewById(R.id.nav_main);
navigationView.setNavigationItemSelectedListener(this);
View navHead = navigationView.getHeaderView(0);
mHeadView = navHead.findViewById(R.id.img_head);
mNameView = navHead.findViewById(R.id.tv_name);
mStatusView = navHead.findViewById(R.id.tv_dp);
mHeadView = view.findViewById(R.id.img_head);
mNameView = view.findViewById(R.id.tv_name);
mStatusView = view.findViewById(R.id.tv_dp);
//mWebViewPlus.enableHtml5();
tv_back_mc.setOnClickListener(this);
WebSettings settings = mWebViewPlus.getSettings();
settings.setUserAgentString(settings.getUserAgentString() + MessageFormat.format(
" YGOMobile/{0} ({1} {2,number,#})",
......@@ -218,20 +209,17 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
}
private boolean doMenu(int id) {
closeDrawer();
switch (id) {
case R.id.action_home:
onHome();
break;
break;/*
case R.id.action_arena:
mWebViewPlus.loadUrl(mMyCard.getArenaUrl());
break;
case R.id.action_bbs:
mWebViewPlus.loadUrl(mMyCard.getBBSUrl());
break;
case R.id.action_chat:
startActivity(new Intent(getActivity(), SplashActivity.class));
break;
break;*/
default:
return false;
}
......@@ -277,18 +265,12 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
@Override
public void onBackPressed() {
if (mDrawerlayout.isDrawerOpen(Gravity.LEFT)) {
closeDrawer();
return;
}
if (mWebViewPlus.getUrl().equals(mMyCard.getMcMainUrl())) {
//finish();
return;
}
if (mWebViewPlus.canGoBack()) {
mWebViewPlus.goBack();
} else {
//finish();
}
}
......@@ -303,6 +285,9 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
case R.id.tv_back_mc:
onHome();
break;
case R.id.rl_chat:
startActivity(new Intent(getActivity(), SplashActivity.class));
break;
}
}
......@@ -314,20 +299,6 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
handler.sendMessage(message);
}
@Override
public void openDrawer() {
if (!mDrawerlayout.isDrawerOpen(Gravity.LEFT)) {
mDrawerlayout.openDrawer(Gravity.LEFT);
}
}
@Override
public void closeDrawer() {
if (mDrawerlayout.isDrawerOpen(Gravity.LEFT)) {
mDrawerlayout.closeDrawer(Gravity.LEFT);
}
}
@Override
public void backHome() {
......@@ -348,15 +319,4 @@ public class MycardFragment extends BaseFragemnt implements View.OnClickListener
public void onHome() {
mWebViewPlus.loadUrl(mMyCard.getHomeUrl());
}
/**
* Called when an item in the navigation menu is selected.
*
* @param item The selected item
* @return true to display the item as the selected item
*/
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
return false;
}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
tools:openDrawer="left">
android:background="@drawable/dialogshort"
android:weightSum="10"
android:orientation="vertical">
<LinearLayout
android:orientation="vertical"
<RelativeLayout
android:id="@+id/rl_head"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingTop="10dp"
android:paddingRight="20dp"
android:paddingBottom="10dp">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/img_head"
android:layout_width="@dimen/label_width_50dp"
android:layout_height="@dimen/label_width_50dp"
android:src="@drawable/avatar" />
<androidx.appcompat.widget.AppCompatTextView
android:visibility="gone"
android:id="@+id/tv_back_mc"
android:background="@drawable/click_background"
android:textColor="@color/black"
android:layout_width="match_parent"
android:text="返回萌卡大厅"
android:textSize="13sp"
android:textStyle="bold"
android:gravity="center"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:layout_height="wrap_content"/>
<cn.garymb.ygomobile.ui.mycard.MyCardWebView
android:id="@+id/webbrowser"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/img_head"
android:text="@string/mc_chat"
android:textColor="@color/holo_green_bright"
android:textSize="18sp"
android:textStyle="bold" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tv_name"
android:layout_marginTop="5dp"
android:layout_toRightOf="@id/img_head"
android:ellipsize="end"
android:lines="1"
android:text="account"
android:textColor="@color/holo_orange_bright"
android:textSize="13sp" />
<androidx.appcompat.widget.AppCompatImageButton
android:layout_width="@dimen/dp_40"
android:layout_height="@dimen/dp_40"
android:nextFocusRight="@string/mc_chat"/>
<ProgressBar
android:id="@+id/progressBar"
style="@style/StyleProgressBarMini"
android:layout_width="match_parent"
android:layout_height="5px" />
</RelativeLayout>
</cn.garymb.ygomobile.ui.mycard.MyCardWebView>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_back_mc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/list_item_bg"
android:gravity="center"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:text="@string/back_to_mycard_home"
android:textColor="@color/holo_green_bright"
android:textSize="13sp"
android:textStyle="bold"
android:visibility="gone" />
<cn.garymb.ygomobile.ui.mycard.MyCardWebView
android:id="@+id/webbrowser"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="8">
<ProgressBar
android:id="@+id/progressBar"
style="@style/StyleProgressBarMini"
android:layout_width="match_parent"
android:layout_height="5px" />
</LinearLayout>
</cn.garymb.ygomobile.ui.mycard.MyCardWebView>
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_main"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="left"
android:background="@color/white"
app:headerLayout="@layout/nav_mycard_head"
app:itemIconTint="@color/gold"
app:itemTextColor="@color/mediumPurple"
app:menu="@menu/nav_mycard_menu" />
<RelativeLayout
android:id="@+id/rl_chat"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@drawable/list_item_bg"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingTop="10dp"
android:paddingRight="20dp"
android:paddingBottom="10dp">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_message_s"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/mc_chat"
android:textColor="@color/holo_green_bright"
android:textSize="18sp"
android:textStyle="bold" />
</androidx.drawerlayout.widget.DrawerLayout>
\ No newline at end of file
<ProgressBar
android:id="@+id/pb_chat_loading"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="5dp"
android:layout_toRightOf="@id/tv_message_s" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/tv_message_s"
android:layout_marginTop="5dp"
android:ellipsize="end"
android:lines="1"
android:text=""
android:textColor="@color/holo_orange_bright"
android:textSize="13sp" />
</RelativeLayout>
</LinearLayout>
\ No newline at end of file
......@@ -8,12 +8,4 @@
android:id="@+id/action_chat"
android:icon="@drawable/ic_send_black_24dp"
android:title="@string/mc_chat" />
<item
android:id="@+id/action_bbs"
android:icon="@drawable/ic_forum"
android:title="@string/bbs" />
<item
android:id="@+id/action_arena"
android:icon="@drawable/ic_highlight"
android:title="@string/arena" />
</menu>
......@@ -328,4 +328,5 @@
<string name="personal">나의</string>
<string name="login_mycard">로그인</string>
<string name="logout_mycard">로그아웃\?</string>
<string name="back_to_mycard_home">return to MyCard homepage</string>
</resources>
......@@ -328,4 +328,5 @@
<string name="replay">查看录像</string>
<string name="bot_mode">人机练习</string>
<string name="personal">我的</string>
<string name="back_to_mycard_home">返回萌卡首页</string>
</resources>
......@@ -338,4 +338,5 @@
<string name="personal">My</string>
<string name="login_mycard">login</string>
<string name="logout_mycard">Logout mycard\?</string>
<string name="back_to_mycard_home">return to MyCard homepage</string>
</resources>
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