Commit a9f6f6b8 authored by fallenstardust's avatar fallenstardust

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

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