Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1983b8e
新增我的模块,首页导航改为下方导航
shiqizhenyes Dec 17, 2021
ba8e6d3
升级AGP 插件
shiqizhenyes Dec 17, 2021
586d8d0
添加support 兼容库
shiqizhenyes Dec 17, 2021
56ae8d5
完善首页功能及我的页面功能逻辑
shiqizhenyes Dec 17, 2021
b3f5c2b
添加已收藏图标,删除旧图标
shiqizhenyes Dec 17, 2021
6faa099
更换收藏图标代码
shiqizhenyes Dec 17, 2021
45eef8d
修复首页数据key 顺序错误,修复发帖崩溃
shiqizhenyes Dec 17, 2021
cd1c6f4
调整我的页面配色
shiqizhenyes Dec 18, 2021
3a99656
优化我的页面和个人信息页面跳转动画
shiqizhenyes Dec 18, 2021
d6d366a
优化启动图标,替换快捷方式图标
shiqizhenyes Dec 18, 2021
9bfc53d
删除无用的图标
shiqizhenyes Dec 18, 2021
3a52223
替换主题模块菜单图标
shiqizhenyes Dec 19, 2021
6f8d9dc
修复appbar 高度显示错误,优化状态栏沉浸逻辑
shiqizhenyes Dec 19, 2021
ec51107
优化节点话题页状态栏效果
shiqizhenyes Dec 19, 2021
48140d1
优化底部导航菜单配色
shiqizhenyes Dec 20, 2021
3ec6b82
优化底部菜单图标大小
shiqizhenyes Dec 20, 2021
386cab8
优化底部导航菜单文字显示效果
shiqizhenyes Dec 22, 2021
3b55c22
优化顶部toolbar 显示效果
shiqizhenyes Dec 22, 2021
ba5a012
优化我的页面配色效果
shiqizhenyes Dec 22, 2021
a97df2d
优化sectionView 控件ripple 效果
shiqizhenyes Dec 22, 2021
d809a55
替换我的页面选项箭头图标
shiqizhenyes Dec 22, 2021
e80f8ea
部分页面添加返回按钮
shiqizhenyes Dec 22, 2021
8680498
Merge branch 'main' into main
shiqizhenyes Dec 22, 2021
5de6273
优化辅助功能talkback 体验
shiqizhenyes Dec 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
exclude group: 'com.google.code.findbugs'
Expand Down
1 change: 1 addition & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<application
android:name=".general.App"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:theme="@style/DayTheme">
Expand Down
23 changes: 23 additions & 0 deletions app/src/main/java/me/ghui/v2er/general/Navigator.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@
import android.content.Context;
import android.content.Intent;
import androidx.core.app.ActivityOptionsCompat;
import androidx.core.util.Pair;

import android.view.View;

import java.io.Serializable;
import java.lang.ref.WeakReference;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;


/**
Expand Down Expand Up @@ -75,6 +81,23 @@ public Navigator addFlag(int flag) {
return this;
}

public Navigator shareElement(View... sourceViews) {
Pair<View, String>[] sharedElements;
List<View> sourceViewList = new ArrayList<>(sourceViews.length);
Collections.addAll(sourceViewList, sourceViews);
sourceViewList.removeIf(sourceView -> sourceView.getTransitionName() == null || sourceView.getTransitionName().isEmpty());
sharedElements = new Pair[sourceViewList.size()];
for (int i = 0; i < sourceViewList.size(); i++) {
sharedElements[i] = new Pair<>(sourceViewList.get(i),
sourceViewList.get(i).getTransitionName());
}
if (sharedElements.length > 0) {
mOptionsCompat = ActivityOptionsCompat.
makeSceneTransitionAnimation((Activity) mFrom.get(), sharedElements);
}
return this;
}

public Navigator shareElement(View sourceView) {
if (sourceView != null && sourceView.getTransitionName() != null) {
mOptionsCompat = ActivityOptionsCompat.
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/java/me/ghui/v2er/general/PageHost.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import me.ghui.v2er.module.settings.ContactFragment;
import me.ghui.v2er.module.settings.SettingFragment;
import me.ghui.v2er.util.Utils;
import me.ghui.v2er.widget.BaseToolBar;

public class PageHost extends BaseActivity {
public static final String PAGE_ID = "PageHost.pageId";
Expand All @@ -21,7 +22,6 @@ protected int attachLayoutRes() {
@Override
protected void init() {
super.init();
Utils.setPaddingForStatusBar(mRootView);
mPage = (Page) getIntent().getSerializableExtra(PAGE_ID);
if (mPage == null) {
throw new RuntimeException("wrong page id");
Expand All @@ -38,6 +38,14 @@ public void reloadMode(int mode) {
.reload();
}

@Override
protected void configToolBar(BaseToolBar toolBar) {
super.configToolBar(toolBar);
if (toolBar != null) {
toolBar.displayHomeAsUpButton(this);
}
}

private Fragment getFragment(Page pageID) {
Fragment fragment;
String title;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package me.ghui.v2er.helper;

import android.widget.ImageView;

import com.google.android.material.bottomnavigation.BottomNavigationItemView;
import com.google.android.material.bottomnavigation.BottomNavigationMenuView;
import com.google.android.material.bottomnavigation.BottomNavigationView;

public class BottomNavigationViewHelper {

/**
* 设置图片尺寸
* @param view
* @param width
* @param height
*/
public static void setImageSize(BottomNavigationView view, int width, int height) {
BottomNavigationMenuView menuView = (BottomNavigationMenuView) view.getChildAt(0);
try {
for (int i = 0; i < menuView.getChildCount(); i++) {
BottomNavigationItemView item = (BottomNavigationItemView) menuView.getChildAt(i);
ImageView imageView = item.findViewById(com.google.android.material.R.id.icon);
imageView.getLayoutParams().width = width;
imageView.getLayoutParams().height = height;
}
} catch (Exception e) {
e.printStackTrace();
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package me.ghui.v2er.injector.component;

import dagger.Component;
import me.ghui.v2er.injector.module.MineModule;
import me.ghui.v2er.injector.scope.PerFragment;
import me.ghui.v2er.module.home.MineFragment;

@PerFragment
@Component(dependencies = AppComponent.class, modules = MineModule.class)
public interface MineComponent {
void inject(MineFragment fragment);
}
29 changes: 29 additions & 0 deletions app/src/main/java/me/ghui/v2er/injector/module/MineModule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package me.ghui.v2er.injector.module;

import dagger.Module;
import dagger.Provides;
import me.ghui.v2er.adapter.base.MultiItemTypeAdapter;
import me.ghui.v2er.injector.scope.PerFragment;
import me.ghui.v2er.module.home.MineContract;
import me.ghui.v2er.module.home.MineFragment;
import me.ghui.v2er.module.home.MinePresenter;
import me.ghui.v2er.module.home.MsgContract;
import me.ghui.v2er.module.home.MsgPresenter;
import me.ghui.v2er.network.bean.UserPageInfo;

@Module
public class MineModule {

private MineFragment mView;

public MineModule(MineFragment mView) {
this.mView = mView;
}

@PerFragment
@Provides
public MineContract.IPresenter providePresenter() {
return new MinePresenter(mView);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ protected void configToolBar(BaseToolBar toolBar) {
super.configToolBar(toolBar);
//设置右上角的填充菜单
toolBar.inflateMenu(R.menu.append_topic_menu);
Utils.setPaddingForStatusBar(toolBar);
Utils.setPaddingForNavbar(mRootView);
toolBar.setOnMenuItemClickListener(item -> {
String content = mContentET.getText().toString();
if (Check.isEmpty(content)) {
Expand Down
47 changes: 46 additions & 1 deletion app/src/main/java/me/ghui/v2er/module/base/BaseActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;

import androidx.annotation.CallSuper;
Expand All @@ -12,6 +13,7 @@

import com.google.android.material.appbar.AppBarLayout;

import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.appcompat.app.AppCompatActivity;
Expand All @@ -24,14 +26,18 @@
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toolbar;

import com.r0adkll.slidr.model.SlidrInterface;
import com.trello.rxlifecycle2.LifecycleTransformer;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.lang.reflect.Field;
import java.util.Stack;

import javax.inject.Inject;
Expand Down Expand Up @@ -87,7 +93,7 @@ public abstract class BaseActivity<T extends BaseContract.IPresenter> extends Rx
@Nullable
protected SlidrInterface mSlidrInterface;
protected DayNightModeEvent mDayNightModeEvent;

private boolean displayStatusBarArea = true;

protected static String KEY(String key) {
return Utils.KEY(key);
Expand All @@ -105,6 +111,16 @@ public void setFirstLoadingDelay(long delay) {
@LayoutRes
protected abstract int attachLayoutRes();


/**
* 显示状态栏区域
* 在attachToolbar调用,或者之前
* @param displayStatusBarArea
*/
public void displayStatusBarArea(boolean displayStatusBarArea) {
this.displayStatusBarArea = displayStatusBarArea;
}

/**
* Set a default Toolbar, if you don't want certain page to have a toolbar,
* just return null;
Expand Down Expand Up @@ -343,6 +359,26 @@ protected void autoLoad() {
}
}

/**
* 查找Appbar
* @param viewGroup
*/
private void findAppbar(ViewGroup viewGroup) {
if (viewGroup instanceof BaseToolBar) {
mToolbar = (BaseToolBar) viewGroup;
} else {
int childCount = viewGroup.getChildCount();
for (int i = 0; i < childCount; i++) {
View childView = viewGroup.getChildAt(i);
if (childView instanceof ViewGroup) {
findAppbar((ViewGroup) childView);
} else {
continue;
}
}
}
}

protected ViewGroup onCreateRootView() {
if ((mToolbar = attachToolbar()) != null) {
LinearLayout rootView = new LinearLayout(this);
Expand Down Expand Up @@ -377,6 +413,15 @@ protected ViewGroup onCreateRootView() {
mRootView.setId(R.id.act_root_view_framelayout);
mRootView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
mRootView.addView(mContentView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
if (displayStatusBarArea) {
mRootView.setFitsSystemWindows(true);
} else {
mRootView.setFitsSystemWindows(false);
findAppbar(mRootView);
if (mToolbar != null) {
Utils.setPaddingForStatusBar(mToolbar);
}
}
mRootView.setBackgroundColor(pageColor());
return mRootView;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ protected void configToolBar(BaseToolBar toolBar) {
super.configToolBar(toolBar);
toolBar.inflateMenu(R.menu.post_topic_menu);//设置右上角的填充菜单
toolBar.setOnMenuItemClickListener(this);
Utils.setPaddingForStatusBar(toolBar);
Utils.setPaddingForNavbar(mRootView);
toolBar.displayHomeAsUpButton(this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected void startInject() {
@Override
protected void configToolBar(BaseToolBar toolBar) {
super.configToolBar(toolBar);
Utils.setPaddingForStatusBar(toolBar);
toolBar.displayHomeAsUpButton(this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ protected SwipeRefreshLayout.OnRefreshListener attachOnRefreshListener() {
@Override
protected void configToolBar(BaseToolBar toolBar) {
super.configToolBar(toolBar);
Utils.setPaddingForStatusBar(toolBar);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,12 @@ protected int attachLayoutRes() {

protected void configToolBar() {
mToolbar.setTitle(getTitle());
mToolbar.setElevation(0);
mToolbar.displayHomeAsUpButton(this);
mToolbar.setOnDoubleTapListener(this);
mToolbar.setNavigationOnClickListener(view -> {
if (isTaskRoot()) finishToHome();
else onBackPressed();
});
Utils.setPaddingForStatusBar(mToolbar);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ protected BaseToolBar attachToolbar() {

@Override
protected void init() {
Utils.setPaddingForStatusBar(mToolBar);
mToolBar.inflateMenu(R.menu.gallery_toolbar_menu);
mToolBar.setOverflowIcon(getDrawable(R.drawable.ic_more_vert_white));
mToolBar.setOnMenuItemClickListener(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ protected void configWebView(WebSettings settings) {
@Override
protected void configToolBar(BaseToolBar toolBar) {
super.configToolBar(toolBar);
Utils.setPaddingForStatusBar(toolBar);
mToolbar.inflateMenu(R.menu.wapview_menu);
mToolbar.setOnMenuItemClickListener(menuItem -> {
switch (menuItem.getItemId()) {
Expand Down
Loading