Skip to content

Commit

Permalink
Merge pull request #688 from LoxiaLiSA/master
Browse files Browse the repository at this point in the history
aa
  • Loading branch information
CeuiLiSA authored Jan 15, 2025
2 parents 81a6c72 + ea43c2f commit a478a85
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
applicationId "ceui.lisa.pixiv"
minSdkVersion 21
targetSdkVersion 34
versionCode 330
versionName "4.2.6"
versionCode 500
versionName "5.0.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

javaCompileOptions {
Expand Down
29 changes: 28 additions & 1 deletion app/src/main/java/ceui/lisa/activities/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package ceui.lisa.activities;

import static android.provider.DocumentsContract.EXTRA_INITIAL_URI;

import android.Manifest;
import android.annotation.SuppressLint;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.provider.MediaStore;
import android.text.TextUtils;
Expand All @@ -21,13 +24,17 @@
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;

import com.blankj.utilcode.util.AppUtils;
import com.bumptech.glide.Glide;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.navigation.NavigationView;
import com.qmuiteam.qmui.skin.QMUISkinManager;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
import com.tbruyelle.rxpermissions3.RxPermissions;

import java.io.File;
Expand Down Expand Up @@ -225,7 +232,7 @@ protected void initData() {
if (!SessionManager.INSTANCE.isLoggedIn()) {
SessionManager.INSTANCE.updateSession(sUserModel);
}
if (BuildConfig.IS_DEBUG_MODE || true) {
if (Shaft.getMMKV().getBoolean(SessionManager.USE_NEW_UI_KEY, false)) {
startActivity(new Intent(this, HomeActivity.class));
finish();
} else {
Expand Down Expand Up @@ -323,6 +330,26 @@ public boolean onNavigationItemSelected(MenuItem item) {
intent.putExtra(Params.URL, "https://www.pixiv.net/upload.php");
intent.putExtra(Params.TITLE, getString(R.string.string_444));
intent.putExtra(Params.PREFER_PRESERVE, true);
} else if (id == R.id.nav_turn_on_v5) {
FragmentActivity activity = this;
new QMUIDialog.MessageDialogBuilder(activity)
.setTitle(activity.getResources().getString(R.string.app_name))
.setMessage(activity.getResources().getString(R.string.new_ui_desc))
.setSkinManager(QMUISkinManager.defaultInstance(activity))
.addAction(0, activity.getResources().getString(R.string.string_142),
(dialog, index) -> dialog.dismiss())
.addAction(0, activity.getResources().getString(R.string.use_new_ui),
(dialog, index) -> {
try {
dialog.dismiss();
Shaft.getMMKV().putBoolean(SessionManager.USE_NEW_UI_KEY, true);
AppUtils.relaunchApp();
} catch (Exception e) {
Common.showToast(e.toString());
e.printStackTrace();
}
})
.show();
}
if (intent != null) {
startActivity(intent);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/ceui/pixiv/session/SessionManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import timber.log.Timber
object SessionManager {

private const val USER_KEY = "LoggedInUserJsonKey"
const val USE_NEW_UI_KEY = "use-v5-ui"
const val COOKIE_KEY = "web-api-cookie"
const val CONTENT_LANGUAGE_KEY = "content-language"

Expand Down
1 change: 1 addition & 0 deletions app/src/main/java/ceui/pixiv/ui/common/ListMode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ object ListMode {
const val VERTICAL = 1
const val VERTICAL_NO_MARGIN = 2
const val VERTICAL_COMMENT = 100
const val VERTICAL_TABCELL = 101
const val STAGGERED_GRID = 3
const val GRID = 4
const val GRID_AND_SECTION_HEADER = 5
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/ceui/pixiv/ui/common/PixivFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,12 @@ fun Fragment.setUpLayoutManager(listView: RecyclerView, listMode: Int = ListMode
R.drawable.list_divider,
marginLeft = 48.ppppx
))
} else if (listMode == ListMode.VERTICAL_TABCELL) {
listView.layoutManager = LinearLayoutManager(requireContext())
listView.addItemDecoration(BottomDividerDecoration(
requireContext(),
R.drawable.list_divider,
))
} else if (listMode == ListMode.VERTICAL_NO_MARGIN) {
listView.layoutManager = LinearLayoutManager(ctx)
} else if (listMode == ListMode.GRID) {
Expand Down
16 changes: 14 additions & 2 deletions app/src/main/java/ceui/pixiv/ui/user/MineProfileFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package ceui.pixiv.ui.user
import android.os.Bundle
import android.view.View
import ceui.lisa.R
import ceui.lisa.activities.Shaft
import ceui.lisa.databinding.FragmentPixivListBinding
import ceui.loxia.Client
import ceui.loxia.ObjectPool
import ceui.loxia.User
import ceui.loxia.launchSuspend
import ceui.loxia.pushFragment
import ceui.pixiv.session.SessionManager
import ceui.pixiv.ui.common.CommonAdapter
Expand All @@ -19,6 +21,8 @@ import ceui.pixiv.ui.common.pixivValueViewModel
import ceui.pixiv.ui.common.setUpRefreshState
import ceui.pixiv.ui.common.viewBinding
import ceui.pixiv.ui.novel.NovelSeriesFragmentArgs
import ceui.pixiv.widgets.alertYesOrCancel
import com.blankj.utilcode.util.AppUtils

class MineProfileFragment : PixivFragment(R.layout.fragment_pixiv_list) {

Expand All @@ -38,7 +42,7 @@ class MineProfileFragment : PixivFragment(R.layout.fragment_pixiv_list) {
super.onViewCreated(view, savedInstanceState)
val adapter = CommonAdapter(viewLifecycleOwner)
binding.listView.adapter = adapter
setUpRefreshState(binding, viewModel, ListMode.VERTICAL_NO_MARGIN)
setUpRefreshState(binding, viewModel, ListMode.VERTICAL_TABCELL)
val liveUser = ObjectPool.get<User>(SessionManager.loggedInUid)
liveUser.observe(viewLifecycleOwner) { user ->
adapter.submitList(
Expand Down Expand Up @@ -79,7 +83,7 @@ class MineProfileFragment : PixivFragment(R.layout.fragment_pixiv_list) {
UserFriendsFragmentArgs(SessionManager.loggedInUid).toBundle()
)
},
TabCellHolder("屏蔽列表").onItemClick {
TabCellHolder(getString(R.string.blocking_list)).onItemClick {
pushFragment(
R.id.navigation_blocking_item_list,
)
Expand All @@ -94,6 +98,14 @@ class MineProfileFragment : PixivFragment(R.layout.fragment_pixiv_list) {
R.id.navigation_settings,
)
},
TabCellHolder(getString(R.string.turn_off_v5_ui)).onItemClick {
launchSuspend {
if (alertYesOrCancel(getString(R.string.alert_when_turn_off_v5_ui))) {
Shaft.getMMKV().putBoolean(SessionManager.USE_NEW_UI_KEY, false)
AppUtils.relaunchApp()
}
}
},
)
)
}
Expand Down
Binary file added app/src/main/res/drawable-xhdpi/page_bg_img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions app/src/main/res/drawable/baseline_auto_awesome_24.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">

<path android:fillColor="@android:color/white" android:pathData="M19,9l1.25,-2.75L23,5l-2.75,-1.25L19,1l-1.25,2.75L15,5l2.75,1.25L19,9zM11.5,9.5L9,4 6.5,9.5 1,12l5.5,2.5L9,20l2.5,-5.5L17,12l-5.5,-2.5zM19,15l-1.25,2.75L15,19l2.75,1.25L19,23l1.25,-2.75L23,19l-2.75,-1.25L19,15z"/>

</vector>
3 changes: 2 additions & 1 deletion app/src/main/res/layout/activity_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

<ImageView
android:layout_width="match_parent"
android:background="@color/page_default_background"
android:src="@drawable/page_bg_img"
android:scaleType="centerCrop"
android:layout_height="match_parent"/>

<androidx.fragment.app.FragmentContainerView
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/layout/cell_tab.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="70dp"
android:background="@drawable/cell_background"
android:padding="20dp">

Expand All @@ -26,6 +27,7 @@
android:text="@{holder.title}"
android:textColor="@color/text00"
android:textSize="16sp"
app:layout_constraintBottom_toTopOf="@+id/secondary_title"
app:layout_constraintEnd_toStartOf="@+id/show_more"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/menu/activity_main_drawer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
android:id="@+id/nav_manage"
android:icon="@drawable/ic_baseline_settings_24"
android:title="@string/app_settings" />

<item
android:id="@+id/nav_turn_on_v5"
android:icon="@drawable/baseline_auto_awesome_24"
android:title="@string/turn_on_v5_ui" />
</group>

<item android:title="@string/string_318">
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -738,4 +738,10 @@
<string name="novel_series">小说系列</string>
<string name="total_works_count">系列中包含%1$d个作品</string>
<string name="download_all_artworks">下载系列全部作品</string>
<string name="turn_on_v5_ui">体验新版UI(公测中)</string>
<string name="use_new_ui">体验新版</string>
<string name="turn_off_v5_ui">切换为旧版UI</string>
<string name="new_ui_desc">全新UI已经准备就绪,功能也接近移植完成,开始先行体验吧!!(新版暂未支持直连,需要自备梯子,可以自由切换回老版本)</string>
<string name="alert_when_turn_off_v5_ui">确认切换为旧版UI吗</string>
<string name="blocking_list">屏蔽列表</string>
</resources>

0 comments on commit a478a85

Please sign in to comment.