diff --git a/app/src/main/java/org/autojs/autojs/network/NodeBB.java b/app/src/main/java/org/autojs/autojs/network/NodeBB.java index 577afa0d..24a4806c 100644 --- a/app/src/main/java/org/autojs/autojs/network/NodeBB.java +++ b/app/src/main/java/org/autojs/autojs/network/NodeBB.java @@ -4,6 +4,7 @@ import android.content.Context; import android.util.Log; import com.google.gson.GsonBuilder; +import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory; import com.jakewharton.retrofit2.adapter.rxjava2.HttpException; import com.jakewharton.retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory; import org.autojs.autojs.R; @@ -40,6 +41,7 @@ public class NodeBB { .setLenient() .create())) .addCallAdapterFactory(RxJava2CallAdapterFactory.create()) + .addCallAdapterFactory(CoroutineCallAdapterFactory.create()) .client(new OkHttpClient.Builder() .cookieJar(new WebkitCookieManagerProxy()) .build()) diff --git a/app/src/main/java/org/autojs/autojs/network/TopicService.kt b/app/src/main/java/org/autojs/autojs/network/TopicService.kt new file mode 100644 index 00000000..ea01b1f4 --- /dev/null +++ b/app/src/main/java/org/autojs/autojs/network/TopicService.kt @@ -0,0 +1,23 @@ +package org.autojs.autojs.network + +import org.autojs.autojs.network.api.TopicApi +import org.autojs.autojs.network.entity.topic.Topic + +object TopicService { + + private const val CID_SCRIPTS = 9L + private val mRetrofit = NodeBB.getInstance().retrofit + private val mTopicApi = mRetrofit.create(TopicApi::class.java) + + suspend fun getTopics(cid: Long): List { + val category = mTopicApi.getCategory(cid).await() + return category.topics.filter { + it.appInfo != null + } + } + + suspend fun getScriptsTopics(): List { + return getTopics(CID_SCRIPTS) + } + +} \ No newline at end of file diff --git a/app/src/main/java/org/autojs/autojs/network/api/TopicApi.kt b/app/src/main/java/org/autojs/autojs/network/api/TopicApi.kt new file mode 100644 index 00000000..a98a1b75 --- /dev/null +++ b/app/src/main/java/org/autojs/autojs/network/api/TopicApi.kt @@ -0,0 +1,17 @@ +package org.autojs.autojs.network.api + +import kotlinx.coroutines.Deferred +import org.autojs.autojs.network.entity.topic.Category +import org.autojs.autojs.network.entity.topic.Topic +import retrofit2.http.GET +import retrofit2.http.Path + +interface TopicApi { + + @GET("/api/category/{cid}") + fun getCategory(@Path("cid") cid: Long): Deferred + + @GET("/api/topic/{tid}") + fun getTopic(@Path("tid") cid: Long): Deferred + +} \ No newline at end of file diff --git a/app/src/main/java/org/autojs/autojs/network/entity/topic/AppInfo.java b/app/src/main/java/org/autojs/autojs/network/entity/topic/AppInfo.java new file mode 100644 index 00000000..30ad856c --- /dev/null +++ b/app/src/main/java/org/autojs/autojs/network/entity/topic/AppInfo.java @@ -0,0 +1,171 @@ + +package org.autojs.autojs.network.entity.topic; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +@SuppressWarnings("unused") +public class AppInfo { + + @SerializedName("details") + private String mDetails; + @SerializedName("email") + private String mEmail; + @SerializedName("file") + private String mFile; + @SerializedName("minSdkVersion") + private long mMinSdkVersion; + @SerializedName("name") + private String mName; + @SerializedName("package") + private String mPackage; + @SerializedName("permissions") + private List mPermissions; + @SerializedName("qq") + private String mQq; + @SerializedName("releaseNotes") + private String mReleaseNotes; + @SerializedName("screenshots") + private List mScreenshots; + @SerializedName("summary") + private String mSummary; + @SerializedName("userGuide") + private String mUserGuide; + @SerializedName("version") + private String mVersion; + @SerializedName("versionCode") + private long mVersionCode; + + public String getDetails() { + return mDetails; + } + + public void setDetails(String details) { + mDetails = details; + } + + public String getEmail() { + return mEmail; + } + + public void setEmail(String email) { + mEmail = email; + } + + public String getFile() { + return mFile; + } + + public void setFile(String file) { + mFile = file; + } + + public long getMinSdkVersion() { + return mMinSdkVersion; + } + + public void setMinSdkVersion(long minSdkVersion) { + mMinSdkVersion = minSdkVersion; + } + + public String getName() { + return mName; + } + + public void setName(String name) { + mName = name; + } + + public String getPackage() { + return mPackage; + } + + public void setPackage(String packageName) { + mPackage = packageName; + } + + public List getPermissions() { + return mPermissions; + } + + public void setPermissions(List permissions) { + mPermissions = permissions; + } + + public String getQq() { + return mQq; + } + + public void setQq(String qq) { + mQq = qq; + } + + public String getReleaseNotes() { + return mReleaseNotes; + } + + public void setReleaseNotes(String releaseNotes) { + mReleaseNotes = releaseNotes; + } + + public List getScreenshots() { + return mScreenshots; + } + + public void setScreenshots(List screenshots) { + mScreenshots = screenshots; + } + + public String getSummary() { + return mSummary; + } + + public void setSummary(String summary) { + mSummary = summary; + } + + public String getUserGuide() { + return mUserGuide; + } + + public void setUserGuide(String userGuide) { + mUserGuide = userGuide; + } + + public String getVersion() { + return mVersion; + } + + public void setVersion(String version) { + mVersion = version; + } + + public long getVersionCode() { + return mVersionCode; + } + + public void setVersionCode(long versionCode) { + mVersionCode = versionCode; + } + + @Override + public String toString() { + return "ScriptApp{" + + "mDetails='" + mDetails + '\'' + + ", mEmail='" + mEmail + '\'' + + ", mFile='" + mFile + '\'' + + ", mMinSdkVersion=" + mMinSdkVersion + + ", mName='" + mName + '\'' + + ", mPackage='" + mPackage + '\'' + + ", mPermissions=" + mPermissions + + ", mQq='" + mQq + '\'' + + ", mReleaseNotes='" + mReleaseNotes + '\'' + + ", mScreenshots=" + mScreenshots + + ", mSummary='" + mSummary + '\'' + + ", mUserGuide='" + mUserGuide + '\'' + + ", mVersion='" + mVersion + '\'' + + ", mVersionCode=" + mVersionCode + + '}'; + } +} diff --git a/app/src/main/java/org/autojs/autojs/network/entity/topic/Category.java b/app/src/main/java/org/autojs/autojs/network/entity/topic/Category.java new file mode 100644 index 00000000..fe597305 --- /dev/null +++ b/app/src/main/java/org/autojs/autojs/network/entity/topic/Category.java @@ -0,0 +1,176 @@ + +package org.autojs.autojs.network.entity.topic; + +import java.util.List; +import com.google.gson.annotations.SerializedName; + +@SuppressWarnings("unused") +public class Category { + + @SerializedName("cid") + private String mCid; + @SerializedName("description") + private String mDescription; + @SerializedName("descriptionParsed") + private String mDescriptionParsed; + @SerializedName("link") + private String mLink; + @SerializedName("loggedIn") + private Boolean mLoggedIn; + @SerializedName("name") + private String mName; + @SerializedName("nextStart") + private Long mNextStart; + @SerializedName("numRecentReplies") + private String mNumRecentReplies; + @SerializedName("pagination") + private Pagination mPagination; + @SerializedName("parentCid") + private String mParentCid; + @SerializedName("post_count") + private String mPostCount; + @SerializedName("privileges") + private Privileges mPrivileges; + @SerializedName("slug") + private String mSlug; + @SerializedName("title") + private String mTitle; + @SerializedName("topic_count") + private String mTopicCount; + @SerializedName("topics") + private List mTopics; + @SerializedName("totalPostCount") + private Long mTotalPostCount; + @SerializedName("totalTopicCount") + private Long mTotalTopicCount; + @SerializedName("url") + private String mUrl; + + public String getDescription() { + return mDescription; + } + + public void setDescription(String description) { + mDescription = description; + } + + public String getDescriptionParsed() { + return mDescriptionParsed; + } + + public void setDescriptionParsed(String descriptionParsed) { + mDescriptionParsed = descriptionParsed; + } + public String getLink() { + return mLink; + } + + public void setLink(String link) { + mLink = link; + } + + public Boolean getLoggedIn() { + return mLoggedIn; + } + + public void setLoggedIn(Boolean loggedIn) { + mLoggedIn = loggedIn; + } + + public String getName() { + return mName; + } + + public void setName(String name) { + mName = name; + } + + public Long getNextStart() { + return mNextStart; + } + + public void setNextStart(Long nextStart) { + mNextStart = nextStart; + } + + public String getNumRecentReplies() { + return mNumRecentReplies; + } + + public void setNumRecentReplies(String numRecentReplies) { + mNumRecentReplies = numRecentReplies; + } + + public String getParentCid() { + return mParentCid; + } + + public void setParentCid(String parentCid) { + mParentCid = parentCid; + } + + public String getPostCount() { + return mPostCount; + } + + public void setPostCount(String postCount) { + mPostCount = postCount; + } + + public Privileges getPrivileges() { + return mPrivileges; + } + + public void setPrivileges(Privileges privileges) { + mPrivileges = privileges; + } + + public String getSlug() { + return mSlug; + } + + public void setSlug(String slug) { + mSlug = slug; + } + + public String getTitle() { + return mTitle; + } + + public void setTitle(String title) { + mTitle = title; + } + + public String getTopicCount() { + return mTopicCount; + } + + public void setTopicCount(String topicCount) { + mTopicCount = topicCount; + } + + public List getTopics() { + return mTopics; + } + + public void setTopics(List topics) { + mTopics = topics; + } + + public Long getTotalPostCount() { + return mTotalPostCount; + } + + public void setTotalPostCount(Long totalPostCount) { + mTotalPostCount = totalPostCount; + } + + public Long getTotalTopicCount() { + return mTotalTopicCount; + } + + public void setTotalTopicCount(Long totalTopicCount) { + mTotalTopicCount = totalTopicCount; + } + +} diff --git a/app/src/main/java/org/autojs/autojs/network/entity/topic/Page.java b/app/src/main/java/org/autojs/autojs/network/entity/topic/Page.java new file mode 100644 index 00000000..96cfa49e --- /dev/null +++ b/app/src/main/java/org/autojs/autojs/network/entity/topic/Page.java @@ -0,0 +1,30 @@ + +package org.autojs.autojs.network.entity.topic; + +import com.google.gson.annotations.SerializedName; + +@SuppressWarnings("unused") +public class Page { + + @SerializedName("active") + private boolean mActive; + @SerializedName("page") + private long mPage; + + public boolean getActive() { + return mActive; + } + + public void setActive(boolean active) { + mActive = active; + } + + public long getPage() { + return mPage; + } + + public void setPage(long page) { + mPage = page; + } + +} diff --git a/app/src/main/java/org/autojs/autojs/network/entity/topic/Pagination.java b/app/src/main/java/org/autojs/autojs/network/entity/topic/Pagination.java new file mode 100644 index 00000000..827cf3bc --- /dev/null +++ b/app/src/main/java/org/autojs/autojs/network/entity/topic/Pagination.java @@ -0,0 +1,71 @@ + +package org.autojs.autojs.network.entity.topic; + +import java.util.List; +import com.google.gson.annotations.SerializedName; + +@SuppressWarnings("unused") +public class Pagination { + + @SerializedName("currentPage") + private Long mCurrentPage; + @SerializedName("next") + private Page mNext; + @SerializedName("pageCount") + private Long mPageCount; + @SerializedName("pages") + private List mPages; + @SerializedName("prev") + private Page mPrev; + @SerializedName("rel") + private List mRel; + + public Long getCurrentPage() { + return mCurrentPage; + } + + public void setCurrentPage(Long currentPage) { + mCurrentPage = currentPage; + } + + public Page getNext() { + return mNext; + } + + public void setNext(Page next) { + mNext = next; + } + + public Long getPageCount() { + return mPageCount; + } + + public void setPageCount(Long pageCount) { + mPageCount = pageCount; + } + + public List getPages() { + return mPages; + } + + public void setPages(List pages) { + mPages = pages; + } + + public Page getPrev() { + return mPrev; + } + + public void setPrev(Page prev) { + mPrev = prev; + } + + public List getRel() { + return mRel; + } + + public void setRel(List rel) { + mRel = rel; + } + +} diff --git a/app/src/main/java/org/autojs/autojs/network/entity/topic/Post.java b/app/src/main/java/org/autojs/autojs/network/entity/topic/Post.java new file mode 100644 index 00000000..e7bf1911 --- /dev/null +++ b/app/src/main/java/org/autojs/autojs/network/entity/topic/Post.java @@ -0,0 +1,182 @@ + +package org.autojs.autojs.network.entity.topic; + +import com.google.gson.annotations.SerializedName; + +import org.autojs.autojs.network.entity.user.User; + +@SuppressWarnings("unused") +public class Post { + + @SerializedName("content") + private String mContent; + @SerializedName("downvoted") + private boolean mDownvoted; + @SerializedName("downvotes") + private long mDownvotes; + @SerializedName("edited") + private String mEdited; + @SerializedName("editedISO") + private String mEditedISO; + @SerializedName("index") + private long mIndex; + @SerializedName("pid") + private String mPid; + @SerializedName("replies") + private Replies mReplies; + @SerializedName("selfPost") + private boolean mSelfPost; + @SerializedName("tid") + private String mTid; + @SerializedName("timestamp") + private String mTimestamp; + @SerializedName("timestampISO") + private String mTimestampISO; + @SerializedName("uid") + private String mUid; + @SerializedName("upvoted") + private boolean mUpvoted; + @SerializedName("upvotes") + private long mUpvotes; + @SerializedName("user") + private User mUser; + @SerializedName("votes") + private long mVotes; + + public String getContent() { + return mContent; + } + + public void setContent(String content) { + mContent = content; + } + + public boolean getDownvoted() { + return mDownvoted; + } + + public void setDownvoted(boolean downvoted) { + mDownvoted = downvoted; + } + + public long getDownvotes() { + return mDownvotes; + } + + public void setDownvotes(long downvotes) { + mDownvotes = downvotes; + } + + public String getEdited() { + return mEdited; + } + + public void setEdited(String edited) { + mEdited = edited; + } + + public String getEditedISO() { + return mEditedISO; + } + + public void setEditedISO(String editedISO) { + mEditedISO = editedISO; + } + + public long getIndex() { + return mIndex; + } + + public void setIndex(long index) { + mIndex = index; + } + + public String getPid() { + return mPid; + } + + public void setPid(String pid) { + mPid = pid; + } + + public Replies getReplies() { + return mReplies; + } + + public void setReplies(Replies replies) { + mReplies = replies; + } + + public boolean getSelfPost() { + return mSelfPost; + } + + public void setSelfPost(boolean selfPost) { + mSelfPost = selfPost; + } + + public String getTid() { + return mTid; + } + + public void setTid(String tid) { + mTid = tid; + } + + public String getTimestamp() { + return mTimestamp; + } + + public void setTimestamp(String timestamp) { + mTimestamp = timestamp; + } + + public String getTimestampISO() { + return mTimestampISO; + } + + public void setTimestampISO(String timestampISO) { + mTimestampISO = timestampISO; + } + + public String getUid() { + return mUid; + } + + public void setUid(String uid) { + mUid = uid; + } + + public boolean getUpvoted() { + return mUpvoted; + } + + public void setUpvoted(boolean upvoted) { + mUpvoted = upvoted; + } + + public long getUpvotes() { + return mUpvotes; + } + + public void setUpvotes(long upvotes) { + mUpvotes = upvotes; + } + + public User getUser() { + return mUser; + } + + public void setUser(User user) { + mUser = user; + } + + public long getVotes() { + return mVotes; + } + + public void setVotes(long votes) { + mVotes = votes; + } + +} diff --git a/app/src/main/java/org/autojs/autojs/network/entity/topic/Privileges.java b/app/src/main/java/org/autojs/autojs/network/entity/topic/Privileges.java new file mode 100644 index 00000000..8b63dd7c --- /dev/null +++ b/app/src/main/java/org/autojs/autojs/network/entity/topic/Privileges.java @@ -0,0 +1,100 @@ + +package org.autojs.autojs.network.entity.topic; + +import com.google.gson.annotations.SerializedName; + +@SuppressWarnings("unused") +public class Privileges { + + @SerializedName("cid") + private String mCid; + @SerializedName("editable") + private Boolean mEditable; + @SerializedName("isAdminOrMod") + private Boolean mIsAdminOrMod; + @SerializedName("read") + private Boolean mRead; + @SerializedName("topics:create") + private Boolean mTopicsCreate; + @SerializedName("topics:read") + private Boolean mTopicsRead; + @SerializedName("topics:tag") + private Boolean mTopicsTag; + @SerializedName("uid") + private Long mUid; + @SerializedName("view_deleted") + private Boolean mViewDeleted; + + public String getCid() { + return mCid; + } + + public void setCid(String cid) { + mCid = cid; + } + + public Boolean getEditable() { + return mEditable; + } + + public void setEditable(Boolean editable) { + mEditable = editable; + } + + public Boolean getIsAdminOrMod() { + return mIsAdminOrMod; + } + + public void setIsAdminOrMod(Boolean isAdminOrMod) { + mIsAdminOrMod = isAdminOrMod; + } + + public Boolean getRead() { + return mRead; + } + + public void setRead(Boolean read) { + mRead = read; + } + + public Boolean getTopicsCreate() { + return mTopicsCreate; + } + + public void setTopicsCreate(Boolean topicsCreate) { + mTopicsCreate = topicsCreate; + } + + public Boolean getTopicsRead() { + return mTopicsRead; + } + + public void setTopicsRead(Boolean topicsRead) { + mTopicsRead = topicsRead; + } + + public Boolean getTopicsTag() { + return mTopicsTag; + } + + public void setTopicsTag(Boolean topicsTag) { + mTopicsTag = topicsTag; + } + + public Long getUid() { + return mUid; + } + + public void setUid(Long uid) { + mUid = uid; + } + + public Boolean getViewDeleted() { + return mViewDeleted; + } + + public void setViewDeleted(Boolean viewDeleted) { + mViewDeleted = viewDeleted; + } + +} diff --git a/app/src/main/java/org/autojs/autojs/network/entity/topic/Replies.java b/app/src/main/java/org/autojs/autojs/network/entity/topic/Replies.java new file mode 100644 index 00000000..7e9dcd17 --- /dev/null +++ b/app/src/main/java/org/autojs/autojs/network/entity/topic/Replies.java @@ -0,0 +1,53 @@ + +package org.autojs.autojs.network.entity.topic; + +import java.util.List; +import com.google.gson.annotations.SerializedName; + +import org.autojs.autojs.network.entity.user.User; + +@SuppressWarnings("unused") +public class Replies { + + @SerializedName("count") + private long mCount; + @SerializedName("hasMore") + private boolean mHasMore; + @SerializedName("text") + private String mText; + @SerializedName("users") + private List mUsers; + + public long getCount() { + return mCount; + } + + public void setCount(long count) { + mCount = count; + } + + public boolean getHasMore() { + return mHasMore; + } + + public void setHasMore(boolean hasMore) { + mHasMore = hasMore; + } + + public String getText() { + return mText; + } + + public void setText(String text) { + mText = text; + } + + public List getUsers() { + return mUsers; + } + + public void setUsers(List users) { + mUsers = users; + } + +} diff --git a/app/src/main/java/org/autojs/autojs/network/entity/topic/Topic.java b/app/src/main/java/org/autojs/autojs/network/entity/topic/Topic.java new file mode 100644 index 00000000..49b78df6 --- /dev/null +++ b/app/src/main/java/org/autojs/autojs/network/entity/topic/Topic.java @@ -0,0 +1,379 @@ + +package org.autojs.autojs.network.entity.topic; + +import android.text.Html; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.annotations.SerializedName; + +import org.autojs.autojs.network.entity.user.User; + +@SuppressWarnings("unused") +public class Topic { + + private static final Gson GSON = new Gson(); + + @SerializedName("category") + private Category mCategory; + @SerializedName("cid") + private String mCid; + @SerializedName("deleted") + private boolean mDeleted; + @SerializedName("downvotes") + private long mDownvotes; + @SerializedName("icons") + private List mIcons; + @SerializedName("ignored") + private boolean mIgnored; + @SerializedName("index") + private long mIndex; + @SerializedName("isOwner") + private boolean mIsOwner; + @SerializedName("lastposttime") + private String mLastposttime; + @SerializedName("lastposttimeISO") + private String mLastposttimeISO; + @SerializedName("locked") + private boolean mLocked; + @SerializedName("mainPid") + private String mMainPid; + @SerializedName("pinned") + private boolean mPinned; + @SerializedName("postcount") + private String mPostcount; + @SerializedName("slug") + private String mSlug; + @SerializedName("tags") + private List mTags; + @SerializedName("thumb") + private String mThumb; + @SerializedName("tid") + private String mTid; + @SerializedName("timestamp") + private String mTimestamp; + @SerializedName("timestampISO") + private String mTimestampISO; + @SerializedName("title") + private String mTitle; + @SerializedName("titleRaw") + private String mTitleRaw; + @SerializedName("uid") + private String mUid; + @SerializedName("unread") + private boolean mUnread; + @SerializedName("unreplied") + private boolean mUnreplied; + @SerializedName("upvotes") + private long mUpvotes; + @SerializedName("user") + private User mUser; + @SerializedName("viewcount") + private String mViewcount; + @SerializedName("votes") + private long mVotes; + @SerializedName("posts") + private List mPosts = new ArrayList<>(); + @SerializedName("teaser") + private Post mTeaser; + + private AppInfo mAppInfo; + + public Category getCategory() { + return mCategory; + } + + public void setCategory(Category category) { + mCategory = category; + } + + public String getCid() { + return mCid; + } + + public void setCid(String cid) { + mCid = cid; + } + + public boolean getDeleted() { + return mDeleted; + } + + public void setDeleted(boolean deleted) { + mDeleted = deleted; + } + + public long getDownvotes() { + return mDownvotes; + } + + public void setDownvotes(long downvotes) { + mDownvotes = downvotes; + } + + public List getIcons() { + return mIcons; + } + + public void setIcons(List icons) { + mIcons = icons; + } + + public boolean getIgnored() { + return mIgnored; + } + + public void setIgnored(boolean ignored) { + mIgnored = ignored; + } + + public long getIndex() { + return mIndex; + } + + public void setIndex(long index) { + mIndex = index; + } + + public boolean getIsOwner() { + return mIsOwner; + } + + public void setIsOwner(boolean isOwner) { + mIsOwner = isOwner; + } + + public String getLastposttime() { + return mLastposttime; + } + + public void setLastposttime(String lastposttime) { + mLastposttime = lastposttime; + } + + public String getLastposttimeISO() { + return mLastposttimeISO; + } + + public void setLastposttimeISO(String lastposttimeISO) { + mLastposttimeISO = lastposttimeISO; + } + + public boolean getLocked() { + return mLocked; + } + + public void setLocked(boolean locked) { + mLocked = locked; + } + + public String getMainPid() { + return mMainPid; + } + + public void setMainPid(String mainPid) { + mMainPid = mainPid; + } + + public boolean getPinned() { + return mPinned; + } + + public void setPinned(boolean pinned) { + mPinned = pinned; + } + + public String getPostcount() { + return mPostcount; + } + + public void setPostcount(String postcount) { + mPostcount = postcount; + } + + public String getSlug() { + return mSlug; + } + + public void setSlug(String slug) { + mSlug = slug; + } + + public List getTags() { + return mTags; + } + + public void setTags(List tags) { + mTags = tags; + } + + public String getThumb() { + return mThumb; + } + + public void setThumb(String thumb) { + mThumb = thumb; + } + + public String getTid() { + return mTid; + } + + public void setTid(String tid) { + mTid = tid; + } + + public String getTimestamp() { + return mTimestamp; + } + + public void setTimestamp(String timestamp) { + mTimestamp = timestamp; + } + + public String getTimestampISO() { + return mTimestampISO; + } + + public void setTimestampISO(String timestampISO) { + mTimestampISO = timestampISO; + } + + public String getTitle() { + return mTitle; + } + + public void setTitle(String title) { + mTitle = title; + } + + public String getTitleRaw() { + return mTitleRaw; + } + + public void setTitleRaw(String titleRaw) { + mTitleRaw = titleRaw; + } + + public String getUid() { + return mUid; + } + + public void setUid(String uid) { + mUid = uid; + } + + public boolean getUnread() { + return mUnread; + } + + public void setUnread(boolean unread) { + mUnread = unread; + } + + public boolean getUnreplied() { + return mUnreplied; + } + + public void setUnreplied(boolean unreplied) { + mUnreplied = unreplied; + } + + public long getUpvotes() { + return mUpvotes; + } + + public void setUpvotes(long upvotes) { + mUpvotes = upvotes; + } + + public User getUser() { + return mUser; + } + + public void setUser(User user) { + mUser = user; + } + + public String getViewcount() { + return mViewcount; + } + + public void setViewcount(String viewcount) { + mViewcount = viewcount; + } + + public long getVotes() { + return mVotes; + } + + public void setVotes(long votes) { + mVotes = votes; + } + + public List getPosts() { + return mPosts; + } + + public void setPosts(List posts) { + mPosts = posts; + } + + public AppInfo getAppInfo() { + if (mAppInfo != null) { + return mAppInfo; + } + if (mTeaser == null || mTeaser.getContent() == null) { + return null; + } + try { + String decoded = Html.fromHtml(mTeaser.getContent()).toString(); + AppInfo appInfo = GSON.fromJson(decoded, AppInfo.class); + mAppInfo = appInfo; + return appInfo; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + @Override + public String toString() { + return "Topic{" + + "mCategory=" + mCategory + + ", mCid='" + mCid + '\'' + + ", mDeleted=" + mDeleted + + ", mDownvotes=" + mDownvotes + + ", mIcons=" + mIcons + + ", mIgnored=" + mIgnored + + ", mIndex=" + mIndex + + ", mIsOwner=" + mIsOwner + + ", mLastposttime='" + mLastposttime + '\'' + + ", mLastposttimeISO='" + mLastposttimeISO + '\'' + + ", mLocked=" + mLocked + + ", mMainPid='" + mMainPid + '\'' + + ", mPinned=" + mPinned + + ", mPostcount='" + mPostcount + '\'' + + ", mSlug='" + mSlug + '\'' + + ", mTags=" + mTags + + ", mThumb='" + mThumb + '\'' + + ", mTid='" + mTid + '\'' + + ", mTimestamp='" + mTimestamp + '\'' + + ", mTimestampISO='" + mTimestampISO + '\'' + + ", mTitle='" + mTitle + '\'' + + ", mTitleRaw='" + mTitleRaw + '\'' + + ", mUid='" + mUid + '\'' + + ", mUnread=" + mUnread + + ", mUnreplied=" + mUnreplied + + ", mUpvotes=" + mUpvotes + + ", mUser=" + mUser + + ", mViewcount='" + mViewcount + '\'' + + ", mVotes=" + mVotes + + ", mPosts=" + mPosts + + ", mTeaser=" + mTeaser + + ", mAppInfo=" + mAppInfo + + '}'; + } +} diff --git a/app/src/main/java/org/autojs/autojs/ui/main/MainActivity.java b/app/src/main/java/org/autojs/autojs/ui/main/MainActivity.java index 624ea6e0..f2e38e2c 100644 --- a/app/src/main/java/org/autojs/autojs/ui/main/MainActivity.java +++ b/app/src/main/java/org/autojs/autojs/ui/main/MainActivity.java @@ -52,7 +52,7 @@ import org.autojs.autojs.ui.floating.FloatyWindowManger; import org.autojs.autojs.ui.log.LogActivity_; import org.autojs.autojs.ui.main.community.CommunityFragment; import org.autojs.autojs.ui.main.community.CommunityFragment_; -import org.autojs.autojs.ui.main.sample.MarketFragment_; +import org.autojs.autojs.ui.main.market.MarketFragment; import org.autojs.autojs.ui.main.scripts.MyScriptListFragment_; import org.autojs.autojs.ui.main.task.TaskManagerFragment_; import org.autojs.autojs.ui.settings.SettingsActivity_; @@ -172,7 +172,7 @@ public class MainActivity extends BaseActivity implements OnActivityResultDelega .add(new MyScriptListFragment_(), R.string.text_file) .add(new DocsFragment_(), R.string.text_tutorial) .add(new CommunityFragment_(), R.string.text_community) - .add(new MarketFragment_(), R.string.text_market) + .add(new MarketFragment(), R.string.text_market) .add(new TaskManagerFragment_(), R.string.text_manage) .build(); mViewPager.setAdapter(mPagerAdapter); diff --git a/app/src/main/java/org/autojs/autojs/ui/main/market/MarketFragment.kt b/app/src/main/java/org/autojs/autojs/ui/main/market/MarketFragment.kt new file mode 100644 index 00000000..fdde2062 --- /dev/null +++ b/app/src/main/java/org/autojs/autojs/ui/main/market/MarketFragment.kt @@ -0,0 +1,98 @@ +package org.autojs.autojs.ui.main.market + +import android.app.Activity +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.google.android.material.floatingactionbutton.FloatingActionButton +import com.stardust.autojs.workground.WrapContentLinearLayoutManager +import kotlinx.android.synthetic.main.fragment_market.* +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch +import org.autojs.autojs.R +import org.autojs.autojs.network.TopicService +import org.autojs.autojs.network.entity.topic.Topic +import org.autojs.autojs.ui.main.ViewPagerFragment +import org.autojs.autojs.ui.widget.AvatarView +import org.joda.time.format.DateTimeFormat + +class MarketFragment : ViewPagerFragment(0) { + + private val mTopics = ArrayList() + + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { + return inflater.inflate(R.layout.fragment_market, container, false) + } + + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + topicsView.layoutManager = WrapContentLinearLayoutManager(context) + topicsView.adapter = Adapter() + swipeRefreshLayout.setOnRefreshListener { + refresh() + } + refresh() + } + + private fun refresh() { + GlobalScope.launch(Dispatchers.Main) { + swipeRefreshLayout.isRefreshing = true + val topics = TopicService.getScriptsTopics() + mTopics.clear() + mTopics.addAll(topics) + topicsView.adapter!!.notifyDataSetChanged() + swipeRefreshLayout.isRefreshing = false + } + } + + override fun onBackPressed(activity: Activity): Boolean { + return false + } + + override fun onFabClick(fab: FloatingActionButton) { + + } + + inner class TopicViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + + val rootView: TextView = itemView.findViewById(R.id.root) + val titleView: TextView = itemView.findViewById(R.id.title) + val avatarView: AvatarView = itemView.findViewById(R.id.avatar) + val usernameView: TextView = itemView.findViewById(R.id.username) + val dateView: TextView = itemView.findViewById(R.id.date) + + } + + inner class Adapter : RecyclerView.Adapter() { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TopicViewHolder { + return TopicViewHolder(LayoutInflater.from(parent.context).inflate(R.layout.item_topic, parent, false)) + } + + override fun getItemCount(): Int { + return mTopics.size + } + + override fun onBindViewHolder(holder: TopicViewHolder, position: Int) { + + val topic = mTopics[position] + holder.run { + val root = topic.appInfo.permissions.contains("root") + rootView.text = if (root) { + "Root" + } else { + "免Root" + } + titleView.text = topic.title + avatarView.setUser(topic.user) + usernameView.text = topic.user.username + + dateView.text = DateTimeFormat.mediumDateTime().print(topic.timestamp.toLong()) + } + } + + } +} \ No newline at end of file diff --git a/app/src/main/java/org/autojs/autojs/ui/main/sample/MarketFragment.java b/app/src/main/java/org/autojs/autojs/ui/main/sample/MarketFragment.java deleted file mode 100644 index 5de77050..00000000 --- a/app/src/main/java/org/autojs/autojs/ui/main/sample/MarketFragment.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.autojs.autojs.ui.main.sample; - -import android.app.Activity; -import android.os.Bundle; -import androidx.annotation.Nullable; -import com.google.android.material.floatingactionbutton.FloatingActionButton; - -import org.autojs.autojs.R; -import org.autojs.autojs.ui.main.QueryEvent; -import org.autojs.autojs.ui.main.ViewPagerFragment; - -import com.stardust.util.BackPressedHandler; - -import org.androidannotations.annotations.AfterViews; -import org.androidannotations.annotations.EFragment; -import org.greenrobot.eventbus.EventBus; -import org.greenrobot.eventbus.Subscribe; - -/** - * Created by Stardust on 2017/10/28. - */ -@EFragment(R.layout.fragment_market) -public class MarketFragment extends ViewPagerFragment implements BackPressedHandler { - - - public MarketFragment() { - super(ROTATION_GONE); - } - - @Override - public void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - EventBus.getDefault().register(this); - } - - @AfterViews - void setUpViews() { - - } - - @Override - public void onResume() { - super.onResume(); - ((BackPressedHandler.HostActivity) getActivity()) - .getBackPressedObserver() - .registerHandlerAtFront(this); - } - - @Override - public void onPause() { - super.onPause(); - ((BackPressedHandler.HostActivity) getActivity()) - .getBackPressedObserver() - .unregisterHandler(this); - } - - @Override - protected void onFabClick(FloatingActionButton fab) { - - } - - - @Override - public boolean onBackPressed(Activity activity) { - return false; - } - - - @Subscribe - public void onQuerySummit(QueryEvent event) { - if (!isShown()) { - return; - } - if (event == QueryEvent.CLEAR) { - return; - } - - } - - - @Override - public void onDestroy() { - super.onDestroy(); - EventBus.getDefault().unregister(this); - } - - -} diff --git a/app/src/main/res/drawable-xhdpi/upvote.png b/app/src/main/res/drawable-xhdpi/upvote.png new file mode 100644 index 00000000..b505ef0d Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/upvote.png differ diff --git a/app/src/main/res/drawable/bg_label_root_permission.xml b/app/src/main/res/drawable/bg_label_root_permission.xml new file mode 100644 index 00000000..c51d54d8 --- /dev/null +++ b/app/src/main/res/drawable/bg_label_root_permission.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/download.png b/app/src/main/res/drawable/download.png new file mode 100644 index 00000000..1977b4ae Binary files /dev/null and b/app/src/main/res/drawable/download.png differ diff --git a/app/src/main/res/drawable/downvote.png b/app/src/main/res/drawable/downvote.png new file mode 100644 index 00000000..dca391c5 Binary files /dev/null and b/app/src/main/res/drawable/downvote.png differ diff --git a/app/src/main/res/drawable/ic_money_black.png b/app/src/main/res/drawable/ic_money_black.png deleted file mode 100644 index ce917dda..00000000 Binary files a/app/src/main/res/drawable/ic_money_black.png and /dev/null differ diff --git a/app/src/main/res/drawable/skip_circle_bg.xml b/app/src/main/res/drawable/skip_circle_bg.xml deleted file mode 100644 index 57e57d7d..00000000 --- a/app/src/main/res/drawable/skip_circle_bg.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/drawable/star.png b/app/src/main/res/drawable/star.png new file mode 100644 index 00000000..ffba2ec1 Binary files /dev/null and b/app/src/main/res/drawable/star.png differ diff --git a/app/src/main/res/layout/divider_project_toolbar.xml b/app/src/main/res/layout/divider_project_toolbar.xml deleted file mode 100644 index e64d9253..00000000 --- a/app/src/main/res/layout/divider_project_toolbar.xml +++ /dev/null @@ -1,5 +0,0 @@ - - \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_market.xml b/app/src/main/res/layout/fragment_market.xml index 68b14d65..a6a7bedb 100644 --- a/app/src/main/res/layout/fragment_market.xml +++ b/app/src/main/res/layout/fragment_market.xml @@ -1,9 +1,14 @@ - + + - \ No newline at end of file + \ No newline at end of file diff --git a/app/src/main/res/layout/item_topic.xml b/app/src/main/res/layout/item_topic.xml new file mode 100644 index 00000000..c5723433 --- /dev/null +++ b/app/src/main/res/layout/item_topic.xml @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/menu/menu_sample_options.xml b/app/src/main/res/menu/menu_sample_options.xml deleted file mode 100644 index e37a6548..00000000 --- a/app/src/main/res/menu/menu_sample_options.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml index 2741b21e..42284aa2 100644 --- a/app/src/main/res/values-en/strings.xml +++ b/app/src/main/res/values-en/strings.xml @@ -32,13 +32,11 @@ Stardust Source Code Copied - Donate https://github.com/hyb1996/NoRootScriptDroid [UiAutomator]Download:http://www.coolapk.com/apk/org.autojs.autojs Floating Window Bug Report Press again to exit - No running scipts %d script(s) is(are) stopped Running Open by other apps @@ -50,13 +48,11 @@ Error Copy debugging log This is a software developer(。・・)ノ - lol Please choose Crash~ o(≧口≦)o (ಥ _ ಥ)Exit or submit a bug report or copy debugging log to the developer(≧∇≦)ノ Clear Console - Submit Bug report Submission Failed Submitted successfully Cannot process file @@ -66,7 +62,6 @@ Recording stopped Copy File writing failed - Join in QQ Group Use the volume keys to control Stop or start recording when volume changes key_use_volume_control_record @@ -139,7 +134,6 @@ Issue Unknown error Send by email - Invalid name Import failed No brower installed. Choose a script @@ -150,7 +144,6 @@ Check for updates failed Download Download now - Dowloading Download failed Do not ask again for this version Beautify code diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml index 6181d8b3..e586a865 100644 --- a/app/src/main/res/values-night/colors.xml +++ b/app/src/main/res/values-night/colors.xml @@ -3,7 +3,6 @@ #202020 #333333 #252525 - #7F7F80 #9a9a9a #808080 #111214 diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index a9c7e701..47b14279 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -10,14 +10,11 @@ #9DA0A2 #282C2F #f0f0f0 - #ef5350 - #777777 #111214 #FFFFFF #FFFFFF #FFFFFF - @android:color/primary_text_light #484C4F #9DA0A2 #f2f3f5 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0d5ffaf7..99eb1d8c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -33,14 +33,11 @@ hybbbb1996@gmail.com 软件源代码 已复制到剪贴板 - 打赏作者 https://github.com/hyb1996/NoRootScriptDroid [Auto.js]下载地址:http://www.coolapk.com/apk/org.autojs.autojs 悬浮窗 错误报告 再按一次退出程序 - 很抱歉(ಥ _ ಥ)程序遇到未知错误,即将停止运行\n错误代码: - 没有正在运行的脚本 已停止%d个正在运行的脚本 开始运行 用其他应用打开 @@ -52,14 +49,12 @@ 错误 复制调试信息 这是软件开发者(。・・)ノ - 略略略 请选择 崩溃了o(≧口≦)o 将会自动提交错误信息。您也可以手动复制调试信息提交给开发者(*^▽^*)或者点击\"退出\"退出程序o(╥﹏╥)o 清空 控制台 日志 - 提交错误报告 提交失败 提交成功 无法处理文件 @@ -69,7 +64,6 @@ 录制结束 复制到剪贴板 文件写入失败 - 加入QQ互赞&交流群 使用音量下键控制 开启悬浮窗后每次音量下键会开始或停止脚本录制 key_use_volume_control_record @@ -104,7 +98,6 @@ key_use_volume_control_running 音量上键停止所有脚本 需要启用无障碍服务 - 名称不能为空 导入失败 没有浏览器耶o(╯□╰)o快去安装一个吧 刷新 @@ -126,7 +119,6 @@ 更新日志 下载地址 直接下载 - 下载中 下载失败 此版本不再提示 格式化代码 @@ -151,12 +143,6 @@ 在布局层次中查看 在布局范围中查看 更多 - 跳过 %d - key_ad_showing_mode - 广告 - 欣赏广告 - 广告显示设置 - Default 保存成功,请刷新目录 循环运行 循环间隔(秒) @@ -166,7 +152,6 @@ 延迟多少秒后开始循环 格式错误 打开无障碍服务 - 布局抓取失败,请关闭悬浮窗后动一下页面重试 使用root权限开启失败 处理中 删除失败 @@ -184,7 +169,6 @@ 文件夹 文件 教程 - 脚本 社区 管理 未登录 @@ -201,12 +185,10 @@ 时间 大小 类型 - 捐赠 编辑器主题 跳转到行 信息 查找/替换 - 粘贴 复制全部 复制行 删除行 @@ -219,14 +201,10 @@ 向上 正则语法与JavaScript中相同, 可使用$1~9代替被捕获的匹配 跳转 - 转到定义 转到文件末尾 转到文件开始 转到行首 转到行尾 - 重构 - 选择变量 - 显示变量类型 退出悬浮窗 保存到 取消下载 @@ -267,9 +245,7 @@ 注册失败 注册成功 示例代码 - 导入到我的脚本 重置为初始内容 - 重置失败 重置成功 无法读取文件 服务 @@ -338,9 +314,6 @@ 退出登录 操作失败,请稍后重试 稳定模式通过省略布局细节使脚本抓取布局时更稳定,但同时获取到的屏幕上的控件可能会减少。\n\n重新启动无障碍服务才能生效。 - 获取权限失败 :-( - 重新授予 - 软件需要显示启动页广告来维持服务器和软件的开发和维护,因此需要\"读取手机状态\"的权限。\n如果您不喜欢广告,可以在设置中设定广告每天只显示一次。 2184044085\n3566596539\npJTCkHuhypD9i3UBQ55XQw==RtXsgCTVFA7VYhLeF1TSkg== 8 56 @@ -354,7 +327,6 @@ 布局层次分析 布局分析 指针位置[Root] - 跳过 更改脚本文件夹路径 key_script_dir_path /脚本/ @@ -369,7 +341,6 @@ 停止 增加监视的变量或表达式 变量或表达式 - 变量 删除所有断点 长按\"运行\"图标也可以启动调试 调试 [%s] @@ -379,7 +350,6 @@ 结果 关闭 执行 - 使用系统闹钟唤醒Auto.js 连接失败: %s 确定要删除%s吗 特定事件(广播)触发运行 @@ -387,8 +357,6 @@ 类/包名 查看文档 import - key_ad_type - 广告类型设置 市场 运行配置 主脚本名称 @@ -431,8 +399,6 @@ Auto.js启动时 查看使用统计权限 通过\"查看使用统计\"权限可以获取本设备过去使用应用的情况,从而使获取当前应用(currentPackage)时更准确。 - 手势监听 - 开启后将支持events手势事件,但Auto.js崩溃时可能会导致屏幕失灵 打开方式 描述至少要 %d 个字.