| @@ -74,6 +74,8 @@ android { | |||
| shrinkResources false | |||
| buildConfigField "String", "BASE_URL", '"http://192.168.69.99:9009"' | |||
| buildConfigField "String", "M_URL", '"http://192.168.69.112:8098"' | |||
| // buildConfigField "String", "BASE_URL", '"https://oa.live.educlouddata.com"' | |||
| // buildConfigField "String", "M_URL", '"https://m.live.educlouddata.com/"' | |||
| buildConfigField "String", "APP_NAME", '"家校互通(开发)"' | |||
| } | |||
| @@ -5,9 +5,11 @@ import android.content.Context | |||
| import android.util.Log | |||
| import com.blankj.utilcode.util.Utils | |||
| import com.lzy.okgo.OkGo | |||
| import com.lzy.okgo.model.HttpHeaders | |||
| import com.umeng.analytics.MobclickAgent | |||
| import com.umeng.commonsdk.UMConfigure | |||
| import com.yzx.webebook.adapter.ImageAdapter | |||
| import com.yzx.webebook.model.User | |||
| import com.yzx.webebook.modules.ActivityWXModule | |||
| import org.apache.weex.InitConfig | |||
| import org.apache.weex.WXEnvironment | |||
| @@ -44,7 +46,14 @@ class App : Application() { | |||
| Log.i("welog", "WXSDKEngine.isInitializedApplication: " + WXSDKEngine.isInitialized()) | |||
| Log.i("welog", "WXSDKEngine.registerModule: $registerSuccess") | |||
| OkGo.getInstance().init(this) | |||
| val headers = HttpHeaders() | |||
| val user = User.getUser() | |||
| headers.put("phone",user.phone) | |||
| headers.put("token",user.token) | |||
| OkGo.getInstance() | |||
| .addCommonHeaders(headers) | |||
| .init(this) | |||
| Utils.init(this) | |||
| @@ -13,8 +13,8 @@ import com.yzx.webebook.config.Config | |||
| import com.yzx.webebook.model.User | |||
| import com.yzx.webebook.model.bean.CollBookBean | |||
| import com.yzx.webebook.model.local.BookRepository | |||
| import com.yzx.webebook.presenter.base.BasePresenter | |||
| import com.yzx.webebook.utils.MD5Utils | |||
| import com.yzx.webebook.presenter.ReadPresenter | |||
| import com.yzx.webebook.presenter.ReadView | |||
| import kotlinx.android.synthetic.main.activity_main.* | |||
| import org.jetbrains.anko.startActivity | |||
| import org.jetbrains.anko.toast | |||
| @@ -24,7 +24,7 @@ import org.jetbrains.anko.toast | |||
| * Yun.Lei | |||
| * 2020年5月6日14:49:10 | |||
| */ | |||
| class MainActivity : BaseActivity<BasePresenter<*>>() { | |||
| class MainActivity : BaseActivity<ReadPresenter>(),ReadView { | |||
| override val inflateId: Int | |||
| @@ -67,7 +67,7 @@ class MainActivity : BaseActivity<BasePresenter<*>>() { | |||
| Config.APP_NAME = "家校互通(本地)" | |||
| Config.BASE_URL = mBaseUrl | |||
| Config.M_URL = mUrl | |||
| User.clearUserInfo() | |||
| // User.clearUserInfo() | |||
| startActivity<HomeActivity>() | |||
| } | |||
| btn4.setOnClickListener { | |||
| @@ -88,7 +88,9 @@ class MainActivity : BaseActivity<BasePresenter<*>>() { | |||
| } | |||
| btn7.setOnClickListener { | |||
| startActivity<ReadActivity>() | |||
| mPresenter?.loadCategory("17") | |||
| } | |||
| /*OkGo.post<String>("https://fileupload.oa.qbjjyyun.net/edufile/fileUpload") | |||
| @@ -144,9 +146,9 @@ class MainActivity : BaseActivity<BasePresenter<*>>() { | |||
| } | |||
| fun saveDb(){ | |||
| val path = "/storage/emulated/0/sgyy.txt"; | |||
| val path = "/storage/emulated/0/xxjs.pdf"; | |||
| val collBook = CollBookBean() | |||
| collBook._id = MD5Utils.strToMd5By16(path) | |||
| collBook._id = "xxjs" | |||
| collBook.title = "三国演义sgyy" | |||
| collBook.author = "yzx" | |||
| collBook.shortIntro = "" | |||
| @@ -160,7 +162,7 @@ class MainActivity : BaseActivity<BasePresenter<*>>() { | |||
| .saveCollBooks(mutableListOf(collBook)) | |||
| } | |||
| override fun initPresenter(): BasePresenter<*>? = null | |||
| override fun initPresenter(): ReadPresenter = ReadPresenter(this) | |||
| @SuppressLint("SetTextI18n") | |||
| override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { | |||
| @@ -184,4 +186,18 @@ class MainActivity : BaseActivity<BasePresenter<*>>() { | |||
| backInfo.text = json | |||
| } | |||
| } | |||
| override fun finishChapter() { | |||
| } | |||
| override fun errorChapter() { | |||
| } | |||
| override fun showCategory(localId: String?) { | |||
| // startActivity<ReadActivity>("book_id" to "xxjs") | |||
| } | |||
| } | |||
| @@ -83,9 +83,9 @@ public class ReadActivity extends BaseActivity<ReadPresenter> implements ReadVie | |||
| DrawerLayout mDlSlide; | |||
| /*************top_menu_view*******************/ | |||
| AppBarLayout mAblTopMenu; | |||
| TextView mTvCommunity; | |||
| TextView mTvBrief; | |||
| // AppBarLayout mAblTopMenu; | |||
| // TextView mTvCommunity; | |||
| // TextView mTvBrief; | |||
| /***************content_view******************/ | |||
| PageView mPvPage; | |||
| /***************bottom_menu_view***************************/ | |||
| @@ -143,11 +143,15 @@ public class ReadActivity extends BaseActivity<ReadPresenter> implements ReadVie | |||
| public void onReceive(Context context, Intent intent) { | |||
| if (intent.getAction().equals(Intent.ACTION_BATTERY_CHANGED)) { | |||
| int level = intent.getIntExtra("level", 0); | |||
| mPageLoader.updateBattery(level); | |||
| if (mPageLoader != null) { | |||
| mPageLoader.updateBattery(level); | |||
| } | |||
| } | |||
| // 监听分钟的变化 | |||
| else if (intent.getAction().equals(Intent.ACTION_TIME_TICK)) { | |||
| mPageLoader.updateTime(); | |||
| if (mPageLoader != null) { | |||
| mPageLoader.updateTime(); | |||
| } | |||
| } | |||
| } | |||
| }; | |||
| @@ -195,9 +199,8 @@ public class ReadActivity extends BaseActivity<ReadPresenter> implements ReadVie | |||
| @Override | |||
| public void initView() { | |||
| mDlSlide = findViewById(R.id.read_dl_slide); | |||
| mAblTopMenu = findViewById(R.id.read_abl_top_menu); | |||
| mTvCommunity = findViewById(R.id.read_tv_community); | |||
| mTvBrief = findViewById(R.id.read_tv_brief); | |||
| // mTvCommunity = findViewById(R.id.read_tv_community); | |||
| // mTvBrief = findViewById(R.id.read_tv_brief); | |||
| mPvPage = findViewById(R.id.read_pv_page); | |||
| mTvPageTip = findViewById(R.id.read_tv_page_tip); | |||
| mLlBottomMenu = findViewById(R.id.read_ll_bottom_menu); | |||
| @@ -208,28 +211,25 @@ public class ReadActivity extends BaseActivity<ReadPresenter> implements ReadVie | |||
| mTvNightMode = findViewById(R.id.read_tv_night_mode); | |||
| mTvSetting = findViewById(R.id.read_tv_setting); | |||
| mLvCategory = findViewById(R.id.read_iv_category); | |||
| } | |||
| @Override | |||
| public void initData() { | |||
| // mCollBook = getIntent().getParcelableExtra(EXTRA_COLL_BOOK); | |||
| mCollBook = BookRepository.getInstance().getCollBook("75979111277b0955"); | |||
| String id = getIntent().getStringExtra("book_id"); | |||
| loadBookData(id); | |||
| } | |||
| private void loadBookData(String id) { | |||
| mCollBook = BookRepository.getInstance().getCollBook(id); | |||
| isCollected = getIntent().getBooleanExtra(EXTRA_IS_COLLECTED, false); | |||
| isNightMode = ReadSettingManager.getInstance().isNightMode(); | |||
| isFullScreen = ReadSettingManager.getInstance().isFullScreen(); | |||
| mBookId = mCollBook.get_id(); | |||
| Log.d(TAG, "initData: " + mCollBook.toString()); | |||
| //获取页面加载器 | |||
| mPageLoader = mPvPage.getPageLoader(mCollBook); | |||
| //禁止滑动展示DrawerLayout | |||
| mDlSlide.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); | |||
| //侧边打开后,返回键能够起作用 | |||
| @@ -258,13 +258,6 @@ public class ReadActivity extends BaseActivity<ReadPresenter> implements ReadVie | |||
| PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); | |||
| mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "ireader:keep bright"); | |||
| //隐藏StatusBar | |||
| mPvPage.post( | |||
| () -> hideSystemBar() | |||
| ); | |||
| //初始化TopMenu | |||
| initTopMenu(); | |||
| //初始化BottomMenu | |||
| initBottomMenu(); | |||
| @@ -279,20 +272,25 @@ public class ReadActivity extends BaseActivity<ReadPresenter> implements ReadVie | |||
| mPageLoader.getCollBook().setBookChapters(bookChapterBeen); | |||
| // 刷新章节列表 | |||
| mPageLoader.refreshChapterList(); | |||
| // 如果是网络小说并被标记更新的,则从网络下载目录 | |||
| // if (mCollBook.isUpdate() && !mCollBook.isLocal()) { | |||
| // getMPresenter().loadCategory(mBookId); | |||
| // } | |||
| LogUtils.e(throwable); | |||
| } | |||
| ); | |||
| addDisposable(disposable); | |||
| initClick(); | |||
| } | |||
| private void saveBookInfo() { | |||
| if(mCollBook!=null){ | |||
| mCollBook.setLastRead(StringUtils. | |||
| dateConvert(System.currentTimeMillis(), Constant.FORMAT_BOOK_DATE)); | |||
| BookRepository.getInstance() | |||
| .saveCollBookWithAsync(mCollBook); | |||
| } | |||
| } | |||
| private void initClick(){ | |||
| private void initClick() { | |||
| mPageLoader.setOnPageChangeListener( | |||
| new PageLoader.OnPageChangeListener() { | |||
| @@ -444,20 +442,6 @@ public class ReadActivity extends BaseActivity<ReadPresenter> implements ReadVie | |||
| } | |||
| ); | |||
| // mTvBrief.setOnClickListener( | |||
| // (v) -> BookDetailActivity.startActivity(this, mBookId) | |||
| // ); | |||
| // mTvCommunity.setOnClickListener( | |||
| // (v) -> { | |||
| // Intent intent = new Intent(this, CommunityActivity.class); | |||
| // startActivity(intent); | |||
| // } | |||
| // ); | |||
| mSettingDialog.setOnDismissListener( | |||
| dialog -> hideSystemBar() | |||
| ); | |||
| } | |||
| @Nullable | |||
| @@ -467,8 +451,8 @@ public class ReadActivity extends BaseActivity<ReadPresenter> implements ReadVie | |||
| } | |||
| @Override | |||
| public void showCategory(List<BookChapterBean> bookChapterList) { | |||
| public void showCategory(String localId) { | |||
| loadBookData(localId); | |||
| } | |||
| @Override | |||
| @@ -481,12 +465,6 @@ public class ReadActivity extends BaseActivity<ReadPresenter> implements ReadVie | |||
| } | |||
| private void initTopMenu() { | |||
| // if (Build.VERSION.SDK_INT >= 19) { | |||
| // mAblTopMenu.setPadding(0, ScreenUtils.getStatusBarHeight(), 0, 0); | |||
| // } | |||
| } | |||
| private void initBottomMenu() { | |||
| //判断是否全屏 | |||
| if (ReadSettingManager.getInstance().isFullScreen()) { | |||
| @@ -505,7 +483,6 @@ public class ReadActivity extends BaseActivity<ReadPresenter> implements ReadVie | |||
| @Override | |||
| public void onWindowFocusChanged(boolean hasFocus) { | |||
| super.onWindowFocusChanged(hasFocus); | |||
| Log.d(TAG, "onWindowFocusChanged: " + mAblTopMenu.getMeasuredHeight()); | |||
| } | |||
| private void toggleNightMode() { | |||
| @@ -564,8 +541,7 @@ public class ReadActivity extends BaseActivity<ReadPresenter> implements ReadVie | |||
| * @return 是否隐藏成功 | |||
| */ | |||
| private boolean hideReadMenu() { | |||
| hideSystemBar(); | |||
| if (mAblTopMenu.getVisibility() == VISIBLE) { | |||
| if (mLlBottomMenu.getVisibility() == VISIBLE) { | |||
| toggleMenu(true); | |||
| return true; | |||
| } else if (mSettingDialog.isShowing()) { | |||
| @@ -575,21 +551,6 @@ public class ReadActivity extends BaseActivity<ReadPresenter> implements ReadVie | |||
| return false; | |||
| } | |||
| private void showSystemBar() { | |||
| //显示 | |||
| // SystemBarUtils.showUnStableStatusBar(this); | |||
| // if (isFullScreen) { | |||
| // SystemBarUtils.showUnStableNavBar(this); | |||
| // } | |||
| } | |||
| private void hideSystemBar() { | |||
| //隐藏 | |||
| // SystemBarUtils.hideStableStatusBar(this); | |||
| // if (isFullScreen) { | |||
| // SystemBarUtils.hideStableNavBar(this); | |||
| // } | |||
| } | |||
| /** | |||
| * 切换菜单栏的可视状态 | |||
| @@ -598,24 +559,12 @@ public class ReadActivity extends BaseActivity<ReadPresenter> implements ReadVie | |||
| private void toggleMenu(boolean hideStatusBar) { | |||
| initMenuAnim(); | |||
| if (mAblTopMenu.getVisibility() == View.VISIBLE) { | |||
| if (mLlBottomMenu.getVisibility() == View.VISIBLE) { | |||
| //关闭 | |||
| mAblTopMenu.startAnimation(mTopOutAnim); | |||
| mLlBottomMenu.startAnimation(mBottomOutAnim); | |||
| mAblTopMenu.setVisibility(GONE); | |||
| mLlBottomMenu.setVisibility(GONE); | |||
| mTvPageTip.setVisibility(GONE); | |||
| if (hideStatusBar) { | |||
| hideSystemBar(); | |||
| } | |||
| } else { | |||
| mAblTopMenu.setVisibility(View.VISIBLE); | |||
| mLlBottomMenu.setVisibility(View.VISIBLE); | |||
| mAblTopMenu.startAnimation(mTopInAnim); | |||
| mLlBottomMenu.startAnimation(mBottomInAnim); | |||
| showSystemBar(); | |||
| } | |||
| } | |||
| @@ -634,7 +583,7 @@ public class ReadActivity extends BaseActivity<ReadPresenter> implements ReadVie | |||
| @Override | |||
| public void onBackPressed() { | |||
| if (mAblTopMenu.getVisibility() == View.VISIBLE) { | |||
| if (mLlBottomMenu.getVisibility() == View.VISIBLE) { | |||
| // 非全屏下才收缩,全屏下直接退出 | |||
| if (!ReadSettingManager.getInstance().isFullScreen()) { | |||
| toggleMenu(true); | |||
| @@ -649,7 +598,7 @@ public class ReadActivity extends BaseActivity<ReadPresenter> implements ReadVie | |||
| } | |||
| if (!mCollBook.isLocal() && !isCollected | |||
| && !mCollBook.getBookChapters().isEmpty()) { | |||
| && !mCollBook.getBookChapters().isEmpty() && false) { | |||
| AlertDialog alertDialog = new AlertDialog.Builder(this) | |||
| .setTitle("加入书架") | |||
| .setMessage("喜欢本书就加入书架吧") | |||
| @@ -676,10 +625,6 @@ public class ReadActivity extends BaseActivity<ReadPresenter> implements ReadVie | |||
| // 退出 | |||
| private void exit() { | |||
| // 返回给BookDetail。 | |||
| // Intent result = new Intent(); | |||
| // result.putExtra(BookDetailActivity.RESULT_IS_COLLECTED, isCollected); | |||
| // setResult(Activity.RESULT_OK, result); | |||
| // 退出 | |||
| super.onBackPressed(); | |||
| } | |||
| @@ -693,14 +638,19 @@ public class ReadActivity extends BaseActivity<ReadPresenter> implements ReadVie | |||
| @Override | |||
| protected void onResume() { | |||
| super.onResume(); | |||
| mWakeLock.acquire(); | |||
| if (mWakeLock != null) { | |||
| mWakeLock.acquire(); | |||
| } | |||
| } | |||
| @Override | |||
| protected void onPause() { | |||
| super.onPause(); | |||
| mWakeLock.release(); | |||
| if (isCollected) { | |||
| if (mWakeLock != null) { | |||
| mWakeLock.release(); | |||
| } | |||
| if (mPageLoader != null) { | |||
| saveBookInfo(); | |||
| mPageLoader.saveRecord(); | |||
| } | |||
| } | |||
| @@ -745,7 +695,6 @@ public class ReadActivity extends BaseActivity<ReadPresenter> implements ReadVie | |||
| @Override | |||
| protected void onActivityResult(int requestCode, int resultCode, Intent data) { | |||
| super.onActivityResult(requestCode, resultCode, data); | |||
| // SystemBarUtils.hideStableStatusBar(this); | |||
| if (requestCode == REQUEST_MORE_SETTING) { | |||
| boolean fullScreen = ReadSettingManager.getInstance().isFullScreen(); | |||
| if (isFullScreen != fullScreen) { | |||
| @@ -754,12 +703,6 @@ public class ReadActivity extends BaseActivity<ReadPresenter> implements ReadVie | |||
| initBottomMenu(); | |||
| } | |||
| // 设置显示状态 | |||
| // if (isFullScreen) { | |||
| // SystemBarUtils.hideStableNavBar(this); | |||
| // } else { | |||
| // SystemBarUtils.showStableNavBar(this); | |||
| // } | |||
| } | |||
| } | |||
| } | |||
| @@ -14,28 +14,29 @@ import android.view.View | |||
| import android.view.ViewGroup | |||
| import android.webkit.* | |||
| import android.widget.LinearLayout | |||
| import android.widget.ProgressBar | |||
| import android.widget.TextView | |||
| import androidx.annotation.RequiresApi | |||
| import androidx.core.widget.ContentLoadingProgressBar | |||
| import com.allenliu.versionchecklib.callback.APKDownloadListener | |||
| import com.allenliu.versionchecklib.v2.AllenVersionChecker | |||
| import com.allenliu.versionchecklib.v2.builder.UIData | |||
| import com.allenliu.versionchecklib.v2.callback.CustomDownloadingDialogListener | |||
| import com.blankj.utilcode.util.AppUtils | |||
| import com.blankj.utilcode.util.SPUtils | |||
| import com.blankj.utilcode.util.ToastUtils | |||
| import com.google.gson.Gson | |||
| import com.google.gson.reflect.TypeToken | |||
| import com.lzy.okgo.OkGo | |||
| import com.lzy.okgo.callback.StringCallback | |||
| import com.lzy.okgo.model.Response | |||
| import com.yzx.webebook.MainActivity | |||
| import com.yzx.webebook.R | |||
| import com.yzx.webebook.activity.base.BaseActivity | |||
| import com.yzx.webebook.config.Config | |||
| import com.yzx.webebook.model.BaseBean | |||
| import com.yzx.webebook.model.User | |||
| import com.yzx.webebook.model.Version | |||
| import com.yzx.webebook.model.local.BookRepository | |||
| import com.yzx.webebook.presenter.ReadPresenter | |||
| import com.yzx.webebook.presenter.ReadView | |||
| import com.yzx.webebook.presenter.base.BasePresenter | |||
| import com.yzx.webebook.widget.BaseDialog | |||
| import kotlinx.android.synthetic.main.activity_web.* | |||
| @@ -44,7 +45,6 @@ import org.jetbrains.anko.find | |||
| import org.jetbrains.anko.startActivity | |||
| import org.jetbrains.anko.toast | |||
| import org.json.JSONObject | |||
| import java.io.File | |||
| import java.util.* | |||
| /** | |||
| @@ -476,6 +476,30 @@ class YzxJavascriptInterface(var ctx: Activity) { | |||
| sp.remove("unit_count") | |||
| ctx.startActivity<HomeActivity>() | |||
| } | |||
| @JavascriptInterface | |||
| fun readPage(bookTaskId:String){ | |||
| val presenter = ReadPresenter(object :ReadView{ | |||
| override fun finishChapter() { | |||
| } | |||
| override fun errorChapter() { | |||
| } | |||
| override fun showCategory(localId: String?) { | |||
| val collBook = BookRepository.getInstance().getCollBook(localId) | |||
| if(collBook.cover.endsWith(".txt")){ | |||
| ctx.startActivity<ReadActivity>("book_id" to localId) | |||
| }else{ | |||
| ToastUtils.showLong("暂不支持该格式预览!") | |||
| } | |||
| } | |||
| }) | |||
| presenter.loadCategory(bookTaskId) | |||
| } | |||
| } | |||
| @@ -0,0 +1,23 @@ | |||
| package com.yzx.webebook.model | |||
| class Book { | |||
| var book_name:String = "" | |||
| var file_type:String = "" | |||
| var book_file_identity:String = "" | |||
| var book_file_id:String = "" | |||
| var author:String = "" | |||
| var read_requires:String = "" | |||
| var volumes:MutableList<Volumes> = mutableListOf() | |||
| } | |||
| class Volumes{ | |||
| var id:String = "" | |||
| var title:String = "" | |||
| var sections:MutableList<Sections> = mutableListOf() | |||
| } | |||
| class Sections{ | |||
| var id:String = "" | |||
| var title:String = "" | |||
| var content:String = "" | |||
| } | |||
| @@ -95,7 +95,7 @@ public class ReadSettingManager { | |||
| } | |||
| public PageMode getPageMode() { | |||
| int mode = sharedPreUtils.getInt(SHARED_READ_PAGE_MODE, PageMode.SIMULATION.ordinal()); | |||
| int mode = sharedPreUtils.getInt(SHARED_READ_PAGE_MODE, PageMode.NONE.ordinal()); | |||
| return PageMode.values()[mode]; | |||
| } | |||
| @@ -1,24 +1,145 @@ | |||
| package com.yzx.webebook.presenter; | |||
| import android.util.Log; | |||
| import com.blankj.utilcode.util.TimeUtils; | |||
| import com.google.gson.Gson; | |||
| import com.google.gson.reflect.TypeToken; | |||
| import com.lzy.okgo.OkGo; | |||
| import com.lzy.okgo.callback.FileCallback; | |||
| import com.lzy.okgo.callback.StringCallback; | |||
| import com.lzy.okgo.model.HttpHeaders; | |||
| import com.lzy.okgo.model.Response; | |||
| import com.yzx.webebook.config.Config; | |||
| import com.yzx.webebook.model.BaseBean; | |||
| import com.yzx.webebook.model.Book; | |||
| import com.yzx.webebook.model.Sections; | |||
| import com.yzx.webebook.model.User; | |||
| import com.yzx.webebook.model.Volumes; | |||
| import com.yzx.webebook.model.bean.CollBookBean; | |||
| import com.yzx.webebook.model.local.BookRepository; | |||
| import com.yzx.webebook.presenter.base.BasePresenter; | |||
| import com.yzx.webebook.utils.FileUtils; | |||
| import com.yzx.webebook.utils.MD5Utils; | |||
| import com.yzx.webebook.widget.page.TxtChapter; | |||
| import org.jetbrains.annotations.NotNull; | |||
| import java.io.File; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| public class ReadPresenter extends BasePresenter<ReadView> { | |||
| static String NOTE_FOLDER_DIR = "/mnt/sdcard/ebook/book/"; | |||
| public ReadPresenter(@NotNull ReadView view) { | |||
| super(view); | |||
| } | |||
| public void loadCategory(String bookId){ | |||
| public void loadCategory(String bookTaskId) { | |||
| User user = User.Companion.getUser(); | |||
| String localId = user.getUser_id() + "_" + bookTaskId; | |||
| CollBookBean collBook = BookRepository.getInstance().getCollBook(localId); | |||
| if (collBook != null) { | |||
| getMView().showCategory(localId); | |||
| } else { | |||
| String url = Config.INSTANCE.getBASE_URL() + "/parent/readTask/getBookWarehouseContent"; | |||
| HttpHeaders headers = new HttpHeaders(); | |||
| headers.put("phone", user.getPhone()); | |||
| headers.put("token", user.getToken()); | |||
| OkGo.<String>post(url) | |||
| .tag(this) | |||
| .params("id", bookTaskId) | |||
| .headers(headers) | |||
| .execute(new StringCallback() { | |||
| @Override | |||
| public void onSuccess(Response<String> response) { | |||
| Log.d("ReadActivity", "onSuccess: " + response.body()); | |||
| Gson gson = new Gson(); | |||
| BaseBean<Book> bean = gson.fromJson(response.body(), new TypeToken<BaseBean<Book>>() { | |||
| }.getType()); | |||
| if ("txt".equals(bean.getData().getFile_type())) { | |||
| downloadBook(bean.getData(), bookTaskId); | |||
| } else { | |||
| Book book = bean.getData(); | |||
| StringBuilder builder = new StringBuilder(); | |||
| if (book.getVolumes().size() > 0) { | |||
| for (Volumes volume : book.getVolumes()) { | |||
| builder.append(volume.getTitle()); | |||
| for (Sections section : volume.getSections()) { | |||
| builder.append(section.getTitle()); | |||
| builder.append(section.getContent()); | |||
| } | |||
| } | |||
| } | |||
| String filePath = FileUtils.writeTxtToFile(builder.toString(), NOTE_FOLDER_DIR, user.getUser_id() + "_" + bookTaskId + ".txt"); | |||
| CollBookBean bookBean = new CollBookBean(); | |||
| String localId = user.getUser_id() + "_" + bookTaskId; | |||
| bookBean.set_id(localId); | |||
| bookBean.setAuthor(book.getAuthor()); | |||
| bookBean.setTitle(book.getBook_name()); | |||
| bookBean.setShortIntro(book.getRead_requires()); | |||
| bookBean.setLastChapter("开始阅读"); | |||
| bookBean.setUpdate(true); | |||
| bookBean.setIsLocal(true); | |||
| bookBean.setLastRead(TimeUtils.getNowString()); | |||
| bookBean.setUpdated(TimeUtils.getNowString()); | |||
| bookBean.setCover(filePath); | |||
| List<CollBookBean> list = new ArrayList<CollBookBean>(); | |||
| list.add(bookBean); | |||
| BookRepository.getInstance() | |||
| .saveCollBooks(list); | |||
| getMView().showCategory(localId); | |||
| } | |||
| } | |||
| @Override | |||
| public void onError(Response<String> response) { | |||
| super.onError(response); | |||
| } | |||
| }); | |||
| } | |||
| } | |||
| private void downloadBook(Book data, String bookTaskId) { | |||
| User user = User.Companion.getUser(); | |||
| OkGo.<File>get("https://" + data.getBook_file_identity() + ".oa.qbjjyyun.net/edufile/download?uniqueKey=" + data.getBook_file_id()) | |||
| .tag(this) | |||
| .execute(new FileCallback(NOTE_FOLDER_DIR, user.getUser_id() + "_" + data.getBook_name() + "." + data.getFile_type()) { | |||
| @Override | |||
| public void onSuccess(Response<File> response) { | |||
| File file = response.body(); | |||
| CollBookBean bookBean = new CollBookBean(); | |||
| String localId = user.getUser_id() + "_" + bookTaskId; | |||
| bookBean.set_id(localId); | |||
| bookBean.setAuthor(data.getAuthor()); | |||
| bookBean.setTitle(data.getBook_name()); | |||
| bookBean.setShortIntro(data.getRead_requires()); | |||
| bookBean.setLastChapter("开始阅读"); | |||
| bookBean.setUpdate(true); | |||
| bookBean.setIsLocal(true); | |||
| bookBean.setLastRead(TimeUtils.getNowString()); | |||
| bookBean.setUpdated(TimeUtils.getNowString()); | |||
| bookBean.setCover(file.getAbsolutePath()); | |||
| List<CollBookBean> list = new ArrayList<CollBookBean>(); | |||
| list.add(bookBean); | |||
| BookRepository.getInstance() | |||
| .saveCollBooks(list); | |||
| getMView().showCategory(localId); | |||
| } | |||
| }); | |||
| } | |||
| public void loadChapter(String bookId, List<TxtChapter> bookChapterList){ | |||
| public void loadChapter(String bookId, List<TxtChapter> bookChapterList) { | |||
| } | |||
| } | |||
| @@ -8,7 +8,7 @@ import java.util.List; | |||
| public interface ReadView extends IView { | |||
| void showCategory(List<BookChapterBean> bookChapterList); | |||
| void showCategory(String localId); | |||
| void finishChapter(); | |||
| void errorChapter(); | |||
| } | |||
| @@ -1,6 +1,7 @@ | |||
| package com.yzx.webebook.utils; | |||
| import android.os.Environment; | |||
| import android.util.Log; | |||
| import com.yzx.webebook.App; | |||
| @@ -11,6 +12,7 @@ import java.io.FileInputStream; | |||
| import java.io.FileNotFoundException; | |||
| import java.io.FileReader; | |||
| import java.io.IOException; | |||
| import java.io.RandomAccessFile; | |||
| import java.io.Reader; | |||
| import java.text.DecimalFormat; | |||
| import java.util.ArrayList; | |||
| @@ -267,4 +269,60 @@ public class FileUtils { | |||
| } | |||
| return charset; | |||
| } | |||
| // 将字符串写入到文本文件中 | |||
| public static String writeTxtToFile(String strcontent, String filePath, String fileName) { | |||
| //生成文件夹之后,再生成文件,不然会出错 | |||
| makeFilePath(filePath, fileName); | |||
| String strFilePath = filePath + fileName; | |||
| // 每次写入时,都换行写 | |||
| String strContent = strcontent + "\r\n"; | |||
| try { | |||
| File file = new File(strFilePath); | |||
| if (!file.exists()) { | |||
| Log.d("TestFile", "Create the file:" + strFilePath); | |||
| file.getParentFile().mkdirs(); | |||
| file.createNewFile(); | |||
| } | |||
| RandomAccessFile raf = new RandomAccessFile(file, "rwd"); | |||
| raf.seek(file.length()); | |||
| raf.write(strContent.getBytes()); | |||
| raf.close(); | |||
| return strFilePath; | |||
| } catch (Exception e) { | |||
| Log.e("TestFile", "Error on write File:" + e); | |||
| return ""; | |||
| } | |||
| } | |||
| //生成文件 | |||
| public static File makeFilePath(String filePath, String fileName) { | |||
| File file = null; | |||
| makeRootDirectory(filePath); | |||
| try { | |||
| file = new File(filePath + fileName); | |||
| if (!file.exists()) { | |||
| file.createNewFile(); | |||
| } | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| } | |||
| return file; | |||
| } | |||
| //生成文件夹 | |||
| public static void makeRootDirectory(String filePath) { | |||
| File file = null; | |||
| try { | |||
| file = new File(filePath); | |||
| if (!file.exists()) { | |||
| file.mkdir(); | |||
| } | |||
| } catch (Exception e) { | |||
| Log.i("error:", e + ""); | |||
| } | |||
| } | |||
| } | |||
| @@ -6,6 +6,7 @@ import android.content.Intent; | |||
| import android.graphics.drawable.Drawable; | |||
| import android.os.Bundle; | |||
| import android.view.Gravity; | |||
| import android.view.View; | |||
| import android.view.Window; | |||
| import android.view.WindowManager; | |||
| import android.widget.CheckBox; | |||
| @@ -30,16 +31,18 @@ import com.yzx.webebook.widget.page.PageLoader; | |||
| import com.yzx.webebook.widget.page.PageMode; | |||
| import com.yzx.webebook.widget.page.PageStyle; | |||
| import java.util.ArrayList; | |||
| import java.util.Arrays; | |||
| import java.util.List; | |||
| /** | |||
| * Created by newbiechen on 17-5-18. | |||
| */ | |||
| public class ReadSettingDialog extends Dialog { | |||
| public class ReadSettingDialog extends Dialog implements View.OnClickListener { | |||
| private static final String TAG = "ReadSettingDialog"; | |||
| private static final int DEFAULT_TEXT_SIZE = 16; | |||
| private static final int DEFAULT_TEXT_SIZE = 28; | |||
| ImageView mIvBrightnessMinus; | |||
| SeekBar mSbBrightness; | |||
| @@ -74,6 +77,8 @@ public class ReadSettingDialog extends Dialog { | |||
| private boolean isTextDefault; | |||
| private List<View> sizeBtnList = new ArrayList<>(); | |||
| public ReadSettingDialog(@NonNull Activity activity, PageLoader mPageLoader) { | |||
| super(activity, R.style.ReadSettingDialog); | |||
| mActivity = activity; | |||
| @@ -108,6 +113,20 @@ public class ReadSettingDialog extends Dialog { | |||
| mRbNone = findViewById(R.id.read_setting_rb_none); | |||
| mRvBg = findViewById(R.id.read_setting_rv_bg); | |||
| mTvMore = findViewById(R.id.read_setting_tv_more); | |||
| sizeBtnList.clear(); | |||
| sizeBtnList.add(findViewById(R.id.size_btn_1)); | |||
| sizeBtnList.add(findViewById(R.id.size_btn_2)); | |||
| sizeBtnList.add(findViewById(R.id.size_btn_3)); | |||
| sizeBtnList.add(findViewById(R.id.size_btn_4)); | |||
| sizeBtnList.add(findViewById(R.id.size_btn_5)); | |||
| sizeBtnList.add(findViewById(R.id.size_btn_6)); | |||
| sizeBtnList.add(findViewById(R.id.size_btn_7)); | |||
| for (View view : sizeBtnList) { | |||
| int index = sizeBtnList.indexOf(view); | |||
| view.setTag(28 + index * 6); | |||
| view.setOnClickListener(this); | |||
| } | |||
| } | |||
| //设置Dialog显示的位置 | |||
| @@ -115,8 +134,8 @@ public class ReadSettingDialog extends Dialog { | |||
| Window window = getWindow(); | |||
| WindowManager.LayoutParams lp = window.getAttributes(); | |||
| lp.width = WindowManager.LayoutParams.MATCH_PARENT; | |||
| lp.height = WindowManager.LayoutParams.WRAP_CONTENT; | |||
| lp.gravity = Gravity.BOTTOM; | |||
| lp.height = WindowManager.LayoutParams.MATCH_PARENT; | |||
| lp.gravity = Gravity.CENTER; | |||
| window.setAttributes(lp); | |||
| } | |||
| @@ -129,6 +148,18 @@ public class ReadSettingDialog extends Dialog { | |||
| isTextDefault = mSettingManager.isDefaultTextSize(); | |||
| mPageMode = mSettingManager.getPageMode(); | |||
| mPageStyle = mSettingManager.getPageStyle(); | |||
| for (View view : sizeBtnList) { | |||
| int size = (int) view.getTag(); | |||
| int fontSize = ScreenUtils.dpToPx(size); | |||
| TextView tv = (TextView) view; | |||
| if (mTextSize == fontSize) { | |||
| tv.setText("O"); | |||
| } else { | |||
| tv.setText("|"); | |||
| } | |||
| } | |||
| } | |||
| private void initWidget() { | |||
| @@ -139,6 +170,8 @@ public class ReadSettingDialog extends Dialog { | |||
| initPageMode(); | |||
| //RecyclerView | |||
| setUpAdapter(); | |||
| } | |||
| private void setUpAdapter() { | |||
| @@ -330,4 +363,18 @@ public class ReadSettingDialog extends Dialog { | |||
| } | |||
| return mCbBrightnessAuto.isChecked(); | |||
| } | |||
| @Override | |||
| public void onClick(View v) { | |||
| int size = (int) v.getTag(); | |||
| for (View view : sizeBtnList) { | |||
| TextView tv = (TextView) view; | |||
| tv.setText("|"); | |||
| } | |||
| ((TextView) v).setText("O"); | |||
| int fontSize = ScreenUtils.dpToPx(size); | |||
| mPageLoader.setTextSize(fontSize); | |||
| dismiss(); | |||
| } | |||
| } | |||
| @@ -41,7 +41,7 @@ import io.reactivex.disposables.Disposable; | |||
| public class LocalPageLoader extends PageLoader { | |||
| private static final String TAG = "LocalPageLoader"; | |||
| //默认从文件中获取数据的长度 | |||
| private final static int BUFFER_SIZE = 512 * 1024; | |||
| private final static int BUFFER_SIZE = 10 * 1024; | |||
| //没有标题的时候,每个章节的最大长度 | |||
| private final static int MAX_LENGTH_WITH_NO_CHAPTER = 10 * 1024; | |||
| @@ -36,8 +36,8 @@ public class PageView extends View { | |||
| private int mStartY = 0; | |||
| private boolean isMove = false; | |||
| // 初始化参数 | |||
| private int mBgColor = 0xFFCEC29C; | |||
| private PageMode mPageMode = PageMode.SIMULATION; | |||
| private int mBgColor = 0xFFFFFFFF; | |||
| private PageMode mPageMode = PageMode.NONE; | |||
| // 是否允许点击 | |||
| private boolean canTouch = true; | |||
| // 唤醒菜单的区域 | |||
| @@ -99,26 +99,26 @@ public class PageView extends View { | |||
| //视图未初始化的时候,禁止调用 | |||
| if (mViewWidth == 0 || mViewHeight == 0) return; | |||
| switch (mPageMode) { | |||
| case SIMULATION: | |||
| mPageAnim = new SimulationPageAnim(mViewWidth, mViewHeight, this, mPageAnimListener); | |||
| break; | |||
| case COVER: | |||
| mPageAnim = new CoverPageAnim(mViewWidth, mViewHeight, this, mPageAnimListener); | |||
| break; | |||
| case SLIDE: | |||
| mPageAnim = new SlidePageAnim(mViewWidth, mViewHeight, this, mPageAnimListener); | |||
| break; | |||
| case NONE: | |||
| mPageAnim = new NonePageAnim(mViewWidth, mViewHeight, this, mPageAnimListener); | |||
| break; | |||
| case SCROLL: | |||
| mPageAnim = new ScrollPageAnim(mViewWidth, mViewHeight, 0, | |||
| mPageLoader.getMarginHeight(), this, mPageAnimListener); | |||
| break; | |||
| default: | |||
| mPageAnim = new SimulationPageAnim(mViewWidth, mViewHeight, this, mPageAnimListener); | |||
| } | |||
| // switch (mPageMode) { | |||
| // case SIMULATION: | |||
| // mPageAnim = new SimulationPageAnim(mViewWidth, mViewHeight, this, mPageAnimListener); | |||
| // break; | |||
| // case COVER: | |||
| // mPageAnim = new CoverPageAnim(mViewWidth, mViewHeight, this, mPageAnimListener); | |||
| // break; | |||
| // case SLIDE: | |||
| // mPageAnim = new SlidePageAnim(mViewWidth, mViewHeight, this, mPageAnimListener); | |||
| // break; | |||
| // case NONE: | |||
| // mPageAnim = new NonePageAnim(mViewWidth, mViewHeight, this, mPageAnimListener); | |||
| // break; | |||
| // case SCROLL: | |||
| // mPageAnim = new ScrollPageAnim(mViewWidth, mViewHeight, 0, | |||
| // mPageLoader.getMarginHeight(), this, mPageAnimListener); | |||
| // break; | |||
| // default: | |||
| // } | |||
| mPageAnim = new NonePageAnim(mViewWidth, mViewHeight, this, mPageAnimListener); | |||
| } | |||
| public Bitmap getNextBitmap() { | |||
| @@ -1,8 +1,8 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <selector xmlns:android="http://schemas.android.com/apk/res/android"> | |||
| <item android:color="@color/light_red" android:state_checked="true" /> | |||
| <item android:color="@color/light_red" android:state_pressed="true" /> | |||
| <item android:color="@color/light_red" android:state_selected="true" /> | |||
| <item android:color="@color/black" android:state_checked="true" /> | |||
| <item android:color="@color/black" android:state_pressed="true" /> | |||
| <item android:color="@color/black" android:state_selected="true" /> | |||
| <!--必须放在最后一行,否则上面的效果全都不能用--> | |||
| <item android:color="@color/white"/> | |||
| <item android:color="@color/gray"/> | |||
| </selector> | |||
| @@ -4,20 +4,18 @@ | |||
| <item android:id="@android:id/background"> | |||
| <shape> | |||
| <size android:height="1dp" /> | |||
| <gradient | |||
| android:endColor="@android:color/darker_gray" | |||
| android:startColor="@android:color/darker_gray" /> | |||
| android:endColor="@color/orange" | |||
| android:startColor="@color/orange" /> | |||
| </shape> | |||
| </item> | |||
| <item android:id="@android:id/progress"> | |||
| <clip> | |||
| <shape> | |||
| <size android:height="3dp" /> | |||
| <gradient | |||
| android:endColor="@color/orange" | |||
| android:startColor="@color/orange" /> | |||
| android:endColor="#000000" | |||
| android:startColor="#000000" /> | |||
| </shape> | |||
| </clip> | |||
| </item> | |||
| @@ -4,5 +4,5 @@ | |||
| <corners android:radius="3dp"/> | |||
| <solid android:color="@color/nb.read.menu.bg"/> | |||
| <stroke android:width="1dp" | |||
| android:color="@color/light_red"/> | |||
| android:color="@color/black"/> | |||
| </shape> | |||
| @@ -0,0 +1,9 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <shape xmlns:android="http://schemas.android.com/apk/res/android"> | |||
| <solid android:color="#FFFFFF" /> | |||
| <corners android:radius="5dp"/> | |||
| <stroke | |||
| android:width="2dp" | |||
| android:color="#000000" /> | |||
| </shape> | |||
| @@ -10,8 +10,7 @@ | |||
| <RelativeLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent" | |||
| android:background="@color/white"> | |||
| android:layout_height="match_parent"> | |||
| <!--阅读页面--> | |||
| <com.yzx.webebook.widget.page.PageView | |||
| @@ -40,41 +39,41 @@ | |||
| android:visibility="gone" /> | |||
| <com.google.android.material.appbar.AppBarLayout | |||
| android:id="@+id/read_abl_top_menu" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:background="@color/nb.read.menu.bg" | |||
| android:visibility="gone" | |||
| tools:visibility="visible"> | |||
| <androidx.appcompat.widget.Toolbar | |||
| android:id="@+id/toolbar" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:minHeight="?attr/actionBarSize" | |||
| android:theme="@style/Theme.ToolBar.Menu"> | |||
| <RelativeLayout | |||
| android:layout_width="120dp" | |||
| android:layout_height="50dp" | |||
| android:layout_gravity="right" | |||
| android:background="@color/nb.read.menu.bg"> | |||
| <TextView | |||
| android:id="@+id/read_tv_brief" | |||
| style="@style/NB.Theme.TextAppearance.Read.TopMenu" | |||
| android:layout_alignParentRight="true" | |||
| android:text="btn1" /> | |||
| <TextView | |||
| android:id="@+id/read_tv_community" | |||
| style="@style/NB.Theme.TextAppearance.Read.TopMenu" | |||
| android:layout_toLeftOf="@id/read_tv_brief" | |||
| android:text="btn2" /> | |||
| </RelativeLayout> | |||
| </androidx.appcompat.widget.Toolbar> | |||
| </com.google.android.material.appbar.AppBarLayout> | |||
| <!-- <com.google.android.material.appbar.AppBarLayout--> | |||
| <!-- android:id="@+id/read_abl_top_menu"--> | |||
| <!-- android:layout_width="match_parent"--> | |||
| <!-- android:layout_height="wrap_content"--> | |||
| <!-- android:background="@color/nb.read.menu.bg"--> | |||
| <!-- android:visibility="gone"--> | |||
| <!-- tools:visibility="visible">--> | |||
| <!-- <androidx.appcompat.widget.Toolbar--> | |||
| <!-- android:id="@+id/toolbar"--> | |||
| <!-- android:layout_width="match_parent"--> | |||
| <!-- android:layout_height="wrap_content"--> | |||
| <!-- android:minHeight="?attr/actionBarSize"--> | |||
| <!-- android:theme="@style/Theme.ToolBar.Menu">--> | |||
| <!-- <RelativeLayout--> | |||
| <!-- android:layout_width="120dp"--> | |||
| <!-- android:layout_height="50dp"--> | |||
| <!-- android:layout_gravity="right"--> | |||
| <!-- android:background="@color/nb.read.menu.bg">--> | |||
| <!-- <TextView--> | |||
| <!-- android:id="@+id/read_tv_brief"--> | |||
| <!-- style="@style/NB.Theme.TextAppearance.Read.TopMenu"--> | |||
| <!-- android:layout_alignParentRight="true"--> | |||
| <!-- android:text="btn1" />--> | |||
| <!-- <TextView--> | |||
| <!-- android:id="@+id/read_tv_community"--> | |||
| <!-- style="@style/NB.Theme.TextAppearance.Read.TopMenu"--> | |||
| <!-- android:layout_toLeftOf="@id/read_tv_brief"--> | |||
| <!-- android:text="btn2" />--> | |||
| <!-- </RelativeLayout>--> | |||
| <!-- </androidx.appcompat.widget.Toolbar>--> | |||
| <!-- </com.google.android.material.appbar.AppBarLayout>--> | |||
| <!--底部页面--> | |||
| <LinearLayout | |||
| @@ -82,12 +81,15 @@ | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:layout_alignParentBottom="true" | |||
| android:background="@color/nb.read.menu.bg" | |||
| android:background="@color/white" | |||
| android:clickable="true" | |||
| android:orientation="vertical" | |||
| android:visibility="gone" | |||
| tools:visibility="visible"> | |||
| <View | |||
| android:layout_width="match_parent" | |||
| android:layout_height="1dp" | |||
| android:background="#000000"/> | |||
| <!--页面进度栏--> | |||
| <LinearLayout | |||
| android:layout_width="match_parent" | |||
| @@ -144,12 +146,6 @@ | |||
| android:drawableTop="@mipmap/ic_read_menu_night" | |||
| android:text="夜间" /> | |||
| <!-- <TextView | |||
| style="@style/NB.Theme.TextAppearance.Read.BottomMenu.Button" | |||
| android:id="@+id/read_tv_download" | |||
| android:drawableTop="@drawable/ic_read_menu_download" | |||
| android:text="@string/nb.read.download" />--> | |||
| <TextView | |||
| android:id="@+id/read_tv_setting" | |||
| style="@style/NB.Theme.TextAppearance.Read.BottomMenu.Button" | |||
| @@ -161,7 +157,7 @@ | |||
| <!--侧滑栏--> | |||
| <LinearLayout | |||
| android:layout_width="300dp" | |||
| android:layout_width="500dp" | |||
| android:layout_height="match_parent" | |||
| android:layout_gravity="start" | |||
| android:background="@color/white" | |||
| @@ -188,7 +184,7 @@ | |||
| android:id="@+id/read_iv_category" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="match_parent" | |||
| android:scrollbars="vertical"></ListView> | |||
| android:scrollbars="vertical"/> | |||
| </RelativeLayout> | |||
| </LinearLayout> | |||
| </androidx.drawerlayout.widget.DrawerLayout> | |||
| @@ -13,25 +13,135 @@ | |||
| ~ See the License for the specific language governing permissions and | |||
| ~ limitations under the License. | |||
| --> | |||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
| xmlns:tools="http://schemas.android.com/tools" | |||
| <RelativeLayout 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/read_setting_ll_menu" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="280dp" | |||
| android:clickable="true" | |||
| android:layout_alignParentBottom="true" | |||
| android:layout_height="match_parent" | |||
| android:layout_centerHorizontal="true" | |||
| android:background="@color/nb.read.menu.bg" | |||
| android:clickable="true" | |||
| android:orientation="vertical" | |||
| android:paddingLeft="12dp" | |||
| android:paddingRight="12dp"> | |||
| android:paddingLeft="30dp" | |||
| android:paddingRight="30dp"> | |||
| <LinearLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_marginLeft="50dp" | |||
| android:layout_marginRight="50dp" | |||
| android:layout_height="wrap_content" | |||
| android:layout_centerInParent="true" | |||
| android:orientation="vertical" | |||
| android:padding="30dp" | |||
| android:background="@drawable/shape_dialog"> | |||
| <TextView | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="设置字体大小" | |||
| android:textColor="@color/black" | |||
| android:textSize="30dp" /> | |||
| <LinearLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginTop="30dp" | |||
| android:orientation="horizontal"> | |||
| <TextView | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="A" | |||
| android:textColor="@color/black" | |||
| android:textSize="20dp" /> | |||
| <TextView | |||
| android:id="@+id/size_btn_1" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_weight="1" | |||
| android:gravity="center" | |||
| android:text="|" | |||
| android:textColor="@color/black" | |||
| android:textSize="30dp" /> | |||
| <TextView | |||
| android:id="@+id/size_btn_2" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_weight="1" | |||
| android:gravity="center" | |||
| android:text="|" | |||
| android:textColor="@color/black" | |||
| android:textSize="30dp" /> | |||
| <TextView | |||
| android:id="@+id/size_btn_3" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_weight="1" | |||
| android:gravity="center" | |||
| android:text="|" | |||
| android:textColor="@color/black" | |||
| android:textSize="30dp" /> | |||
| <TextView | |||
| android:id="@+id/size_btn_4" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_weight="1" | |||
| android:gravity="center" | |||
| android:text="|" | |||
| android:textColor="@color/black" | |||
| android:textSize="30dp" /> | |||
| <TextView | |||
| android:id="@+id/size_btn_5" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_weight="1" | |||
| android:gravity="center" | |||
| android:text="|" | |||
| android:textColor="@color/black" | |||
| android:textSize="30dp" /> | |||
| <TextView | |||
| android:id="@+id/size_btn_6" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_weight="1" | |||
| android:gravity="center" | |||
| android:text="|" | |||
| android:textColor="@color/black" | |||
| android:textSize="30dp" /> | |||
| <TextView | |||
| android:id="@+id/size_btn_7" | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:layout_weight="1" | |||
| android:gravity="center" | |||
| android:text="|" | |||
| android:textColor="@color/black" | |||
| android:textSize="30dp" /> | |||
| <TextView | |||
| android:layout_width="wrap_content" | |||
| android:layout_height="wrap_content" | |||
| android:text="A" | |||
| android:textColor="@color/black" | |||
| android:textSize="50dp" /> | |||
| </LinearLayout> | |||
| </LinearLayout> | |||
| <LinearLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginTop="@dimen/nb.read_setting.divider" | |||
| android:gravity="center_vertical" | |||
| android:orientation="horizontal" | |||
| android:layout_marginTop="@dimen/nb.read_setting.divider"> | |||
| android:visibility="gone"> | |||
| <ImageView | |||
| android:id="@+id/read_setting_iv_brightness_minus" | |||
| @@ -59,36 +169,37 @@ | |||
| android:layout_marginRight="20dp" | |||
| android:scaleType="center" | |||
| android:src="@mipmap/ic_brightness_plus" /> | |||
| <CheckBox | |||
| android:id="@+id/read_setting_cb_brightness_auto" | |||
| style="@style/NB.Theme.TextAppearance.Read.BottomMenu" | |||
| android:layout_width="40dp" | |||
| android:layout_height="35dp" | |||
| android:background="@drawable/selector_btn_read_setting" | |||
| android:button="@null" | |||
| android:gravity="center" | |||
| android:text="系统" | |||
| android:button="@null" | |||
| android:textColor="@color/selector_btn_read_setting" | |||
| android:background="@drawable/selector_btn_read_setting" | |||
| style="@style/NB.Theme.TextAppearance.Read.BottomMenu"/> | |||
| android:textColor="@color/selector_btn_read_setting" /> | |||
| </LinearLayout> | |||
| <LinearLayout | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginTop="@dimen/nb.read_setting.divider" | |||
| android:gravity="center_vertical" | |||
| android:orientation="horizontal" | |||
| android:layout_marginTop="@dimen/nb.read_setting.divider"> | |||
| android:visibility="gone"> | |||
| <TextView | |||
| android:id="@+id/read_setting_tv_font_minus" | |||
| android:layout_width="100dp" | |||
| style="@style/NB.Theme.TextAppearance.Read.BottomMenu" | |||
| android:layout_width="200dp" | |||
| android:layout_height="@dimen/nb.read_setting.btn_height" | |||
| android:background="@drawable/shape_btn_read_setting_normal" | |||
| android:gravity="center" | |||
| android:text="Aa-" | |||
| android:textSize="14dp" | |||
| android:background="@drawable/shape_btn_read_setting_normal" | |||
| style="@style/NB.Theme.TextAppearance.Read.BottomMenu"/> | |||
| android:textSize="14dp" /> | |||
| <TextView | |||
| android:id="@+id/read_setting_tv_font" | |||
| android:layout_width="0dp" | |||
| @@ -96,121 +207,123 @@ | |||
| android:layout_weight="1" | |||
| android:gravity="center" | |||
| android:text="15" | |||
| android:textSize="14dp" | |||
| android:textColor="@color/white"/> | |||
| android:textColor="@color/black" | |||
| android:textSize="14dp" /> | |||
| <TextView | |||
| android:id="@+id/read_setting_tv_font_plus" | |||
| android:layout_width="100dp" | |||
| style="@style/NB.Theme.TextAppearance.Read.BottomMenu" | |||
| android:layout_width="200dp" | |||
| android:layout_height="@dimen/nb.read_setting.btn_height" | |||
| android:layout_marginRight="20dp" | |||
| android:background="@drawable/shape_btn_read_setting_normal" | |||
| android:gravity="center" | |||
| android:padding="5dp" | |||
| android:text="Aa+" | |||
| android:textSize="18dp" | |||
| android:background="@drawable/shape_btn_read_setting_normal" | |||
| style="@style/NB.Theme.TextAppearance.Read.BottomMenu" /> | |||
| android:textSize="18dp" /> | |||
| <CheckBox | |||
| android:id="@+id/read_setting_cb_font_default" | |||
| android:layout_width="40dp" | |||
| style="@style/NB.Theme.TextAppearance.Read.BottomMenu" | |||
| android:layout_width="100dp" | |||
| android:layout_height="@dimen/nb.read_setting.btn_height" | |||
| android:gravity="center" | |||
| android:text="默认" | |||
| android:button="@null" | |||
| android:textColor="@color/selector_btn_read_setting" | |||
| android:background="@drawable/selector_btn_read_setting" | |||
| style="@style/NB.Theme.TextAppearance.Read.BottomMenu" /> | |||
| android:button="@null" | |||
| android:gravity="center" | |||
| android:text="默认" /> | |||
| </LinearLayout> | |||
| <RadioGroup | |||
| android:id="@+id/read_setting_rg_page_mode" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginTop="@dimen/nb.read_setting.divider" | |||
| android:orientation="horizontal" | |||
| android:layout_marginTop="@dimen/nb.read_setting.divider"> | |||
| android:visibility="gone"> | |||
| <RadioButton | |||
| android:id="@+id/read_setting_rb_simulation" | |||
| style="@style/NB.Theme.TextAppearance.Read.BottomMenu" | |||
| android:layout_width="0dp" | |||
| android:layout_height="@dimen/nb.read_setting.btn_height" | |||
| android:layout_weight="1" | |||
| android:text="仿真" | |||
| android:textSize="14dp" | |||
| android:layout_marginRight="18dp" | |||
| android:gravity="center" | |||
| android:button="@null" | |||
| android:layout_weight="1" | |||
| android:background="@drawable/selector_btn_read_setting" | |||
| style="@style/NB.Theme.TextAppearance.Read.BottomMenu"/> | |||
| android:button="@null" | |||
| android:gravity="center" | |||
| android:text="仿真" | |||
| android:textSize="14dp" /> | |||
| <RadioButton | |||
| android:id="@+id/read_setting_rb_cover" | |||
| style="@style/NB.Theme.TextAppearance.Read.BottomMenu" | |||
| android:layout_width="0dp" | |||
| android:layout_height="@dimen/nb.read_setting.btn_height" | |||
| android:layout_weight="1" | |||
| android:text="覆盖" | |||
| android:textSize="14dp" | |||
| android:gravity="center" | |||
| android:layout_marginRight="18dp" | |||
| android:button="@null" | |||
| android:layout_weight="1" | |||
| android:background="@drawable/selector_btn_read_setting" | |||
| style="@style/NB.Theme.TextAppearance.Read.BottomMenu"/> | |||
| android:button="@null" | |||
| android:gravity="center" | |||
| android:text="覆盖" | |||
| android:textSize="14dp" /> | |||
| <RadioButton | |||
| android:id="@+id/read_setting_rb_slide" | |||
| style="@style/NB.Theme.TextAppearance.Read.BottomMenu" | |||
| android:layout_width="0dp" | |||
| android:layout_height="@dimen/nb.read_setting.btn_height" | |||
| android:layout_marginRight="18dp" | |||
| android:layout_weight="1" | |||
| android:background="@drawable/selector_btn_read_setting" | |||
| android:button="@null" | |||
| android:gravity="center" | |||
| android:text="滑动" | |||
| android:textSize="14dp" | |||
| android:gravity="center" | |||
| android:layout_marginRight="18dp" | |||
| android:button="@null" | |||
| android:background="@drawable/selector_btn_read_setting" | |||
| android:visibility="gone" | |||
| style="@style/NB.Theme.TextAppearance.Read.BottomMenu"/> | |||
| android:visibility="gone" /> | |||
| <RadioButton | |||
| android:id="@+id/read_setting_rb_scroll" | |||
| style="@style/NB.Theme.TextAppearance.Read.BottomMenu" | |||
| android:layout_width="0dp" | |||
| android:layout_height="@dimen/nb.read_setting.btn_height" | |||
| android:layout_weight="1" | |||
| android:text="滚动" | |||
| android:textSize="14dp" | |||
| android:gravity="center" | |||
| android:layout_marginRight="18dp" | |||
| android:button="@null" | |||
| android:layout_weight="1" | |||
| android:background="@drawable/selector_btn_read_setting" | |||
| style="@style/NB.Theme.TextAppearance.Read.BottomMenu"/> | |||
| android:button="@null" | |||
| android:gravity="center" | |||
| android:text="滚动" | |||
| android:textSize="14dp" /> | |||
| <RadioButton | |||
| android:id="@+id/read_setting_rb_none" | |||
| style="@style/NB.Theme.TextAppearance.Read.BottomMenu" | |||
| android:layout_width="0dp" | |||
| android:layout_height="@dimen/nb.read_setting.btn_height" | |||
| android:layout_weight="1" | |||
| android:text="无" | |||
| android:textSize="14dp" | |||
| android:gravity="center" | |||
| android:button="@null" | |||
| android:background="@drawable/selector_btn_read_setting" | |||
| style="@style/NB.Theme.TextAppearance.Read.BottomMenu"/> | |||
| android:button="@null" | |||
| android:gravity="center" | |||
| android:text="无" | |||
| android:textSize="14dp" /> | |||
| </RadioGroup> | |||
| <androidx.recyclerview.widget.RecyclerView | |||
| android:id="@+id/read_setting_rv_bg" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="40dp" | |||
| android:layout_marginLeft="5dp" | |||
| android:layout_marginRight="5dp" | |||
| android:layout_marginTop="@dimen/nb.read_setting.divider" | |||
| android:scrollbars="none" /> | |||
| android:layout_marginRight="5dp" | |||
| android:scrollbars="none" | |||
| android:visibility="gone" /> | |||
| <TextView | |||
| android:id="@+id/read_setting_tv_more" | |||
| android:layout_width="match_parent" | |||
| android:layout_height="wrap_content" | |||
| android:layout_marginTop="20dp" | |||
| android:gravity="center_horizontal" | |||
| android:text="更多设置 >>" | |||
| android:textColor="@color/nb.read.menu.text" | |||
| android:gravity="center_horizontal" | |||
| android:layout_marginTop="20dp"/> | |||
| </LinearLayout> | |||
| android:visibility="gone" /> | |||
| </RelativeLayout> | |||
| @@ -80,10 +80,10 @@ | |||
| <color name="nb.download.finish">#8bd715</color> | |||
| <!--read--> | |||
| <color name="nb.read.bg_1">#CEC29C</color> | |||
| <color name="nb.read.bg_2">#CCEBCC</color> | |||
| <color name="nb.read.bg_3">#AAAAAA</color> | |||
| <color name="nb.read.bg_4">#D1CEC5</color> | |||
| <color name="nb.read.bg_1">#FFFFFF</color> | |||
| <color name="nb.read.bg_2">#FFFFFF</color> | |||
| <color name="nb.read.bg_3">#FFFFFF</color> | |||
| <color name="nb.read.bg_4">#FFFFFF</color> | |||
| <color name="nb.read.bg_5">#001C27</color> | |||
| <color name="nb.read.bg_6">#DDCEC29C</color> | |||
| @@ -95,9 +95,9 @@ | |||
| <color name="nb.read.font_5">#627176</color> | |||
| <color name="nb.read.bg.night">#000000</color> | |||
| <color name="nb.read.font_night">#99ffffff</color> | |||
| <color name="nb.read.font_night">#ffffffff</color> | |||
| <color name="nb.read.menu.bg">#191919</color> | |||
| <color name="nb.read.menu.bg">#ffffff</color> | |||
| <color name="nb.read.menu.text">#CBCBCB</color> | |||
| <color name="nb.read.bar.translucent">#88000000</color> | |||
| </resources> | |||
| @@ -32,11 +32,11 @@ | |||
| <!--必须要加上这句才能实现真正的半透明,--> | |||
| <item name="android:windowIsTranslucent">false</item> | |||
| <!--直接写windowEnter或者windowExit 是无效的-->Re | |||
| <item name="android:windowAnimationStyle">@style/anim_slide_left_in_right_out</item> | |||
| <!-- <item name="android:windowAnimationStyle">@style/anim_slide_left_in_right_out</item>--> | |||
| </style> | |||
| <style name="ReadSettingDialog" parent="CommonDialog"> | |||
| <item name="android:windowAnimationStyle">@style/anim_slide_bottom_in_out</item> | |||
| <!-- <item name="android:windowAnimationStyle">@style/anim_slide_bottom_in_out</item>--> | |||
| </style> | |||
| <!--animation--> | |||
| @@ -38,7 +38,7 @@ | |||
| <item name="android:textColor">@color/nb.read.menu.text</item> | |||
| </style> | |||
| <style name="NB.Theme.TextAppearance.Read.BottomMenu"> | |||
| <item name="android:textColor">@color/nb.read.menu.text</item> | |||
| <item name="android:textColor">#000000</item> | |||
| </style> | |||