mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-11-10 21:59:11 +01:00
Compare commits
7 Commits
alpha_vers
...
alpha_vers
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b82e4d9d37 | ||
|
|
1f3d9e58d8 | ||
|
|
31e28fb146 | ||
|
|
2fbcb95db8 | ||
|
|
7f74877fd8 | ||
|
|
2c6cc3e3d5 | ||
|
|
d4d533c4f0 |
@@ -42,7 +42,7 @@ LemmInfinity is currently in the early stages of development. Expect many unfini
|
||||
- [x] Functionality for post upvotes/downvotes
|
||||
- [x] Functionality to browse comments
|
||||
- [ ] Capability for creating a new post
|
||||
- [ ] Ability to create comments
|
||||
- [x] Ability to create comments
|
||||
- [ ] Elimination of code/string references specific to Reddit
|
||||
- [ ] Incorporation of private messaging feature
|
||||
- [ ] Feature for saving posts
|
||||
|
||||
Binary file not shown.
@@ -8,8 +8,8 @@ android {
|
||||
applicationId "eu.toldi.infinityforlemmy"
|
||||
minSdk 21
|
||||
targetSdk 33
|
||||
versionCode 121
|
||||
versionName "0.0.1"
|
||||
versionCode 122
|
||||
versionName "0.0.2"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
@@ -175,7 +175,7 @@ dependencies {
|
||||
implementation 'com.lsjwzh:materialloadingprogressbar:0.5.8-RELEASE'
|
||||
|
||||
// Customizable TextView
|
||||
implementation files("Modules/customtextview-2.1.aar")
|
||||
implementation 'com.libRG:customtextview:2.4'
|
||||
|
||||
// Dismiss gesturing
|
||||
implementation 'app.futured.hauler:hauler:5.0.0'
|
||||
|
||||
@@ -45,14 +45,10 @@ import eu.toldi.infinityforlemmy.post.PostPagingSource;
|
||||
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
public class AccountSavedThingActivity extends BaseActivity implements ActivityToolbarInterface,
|
||||
PostLayoutBottomSheetFragment.PostLayoutSelectionCallback, MarkPostAsReadInterface {
|
||||
|
||||
@Inject
|
||||
@Named("oauth")
|
||||
Retrofit mOauthRetrofit;
|
||||
@Inject
|
||||
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||
@Inject
|
||||
|
||||
@@ -26,6 +26,7 @@ import javax.inject.Named;
|
||||
import eu.toldi.infinityforlemmy.Infinity;
|
||||
import eu.toldi.infinityforlemmy.R;
|
||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
|
||||
public class LinkResolverActivity extends AppCompatActivity {
|
||||
@@ -38,8 +39,8 @@ public class LinkResolverActivity extends AppCompatActivity {
|
||||
private static final String POST_PATTERN_2 = "/(u|U|user)/[\\w-]+/comments/\\w+/?\\w+/?";
|
||||
private static final String POST_PATTERN_3 = "/[\\w-]+$";
|
||||
private static final String COMMENT_PATTERN = "/(r|u|U|user)/[\\w-]+/comments/\\w+/?[\\w-]+/\\w+/?";
|
||||
private static final String SUBREDDIT_PATTERN = "/[rR]/[\\w-]+/?";
|
||||
private static final String USER_PATTERN = "/(u|U|user)/[\\w-]+/?";
|
||||
private static final String SUBREDDIT_PATTERN = "(?:https?://[\\w.-]+)?/c/[\\w-]+(@[\\w.-]+)?";
|
||||
private static final String USER_PATTERN = "(?:https?://[\\w.-]+)?/u(sers)?/[\\w-]+(@[\\w.-]+)?";
|
||||
private static final String SIDEBAR_PATTERN = "/[rR]/[\\w-]+/about/sidebar";
|
||||
private static final String MULTIREDDIT_PATTERN = "/user/[\\w-]+/m/\\w+/?";
|
||||
private static final String MULTIREDDIT_PATTERN_2 = "/[rR]/(\\w+\\+?)+/?";
|
||||
@@ -156,6 +157,18 @@ public class LinkResolverActivity extends AppCompatActivity {
|
||||
intent.putExtra(ViewImageOrGifActivity.EXTRA_IMAGE_URL_KEY, uri.toString());
|
||||
intent.putExtra(ViewImageOrGifActivity.EXTRA_FILE_NAME_KEY, id + ".jpg");
|
||||
startActivity(intent);
|
||||
} else if (uri.toString().matches(SUBREDDIT_PATTERN)) {
|
||||
Intent intent = new Intent(this, ViewSubredditDetailActivity.class);
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, uri.getScheme() != null ? LemmyUtils.actorID2FullName(uri.toString()) : path.substring(3));
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||
startActivity(intent);
|
||||
} else if (uri.toString().matches(USER_PATTERN)) {
|
||||
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, uri.getScheme() != null ? LemmyUtils.actorID2FullName(uri.toString()) : path.substring(3));
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||
startActivity(intent);
|
||||
} else if (authority.equals("v.redd.it")) {
|
||||
Intent intent = new Intent(this, ViewVideoActivity.class);
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_V_REDD_IT);
|
||||
@@ -219,18 +232,6 @@ public class LinkResolverActivity extends AppCompatActivity {
|
||||
intent.putExtra(WikiActivity.EXTRA_SUBREDDIT_NAME, segments.get(1));
|
||||
intent.putExtra(WikiActivity.EXTRA_WIKI_PATH, wikiPage);
|
||||
startActivity(intent);
|
||||
} else if (path.matches(SUBREDDIT_PATTERN)) {
|
||||
Intent intent = new Intent(this, ViewSubredditDetailActivity.class);
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, path.substring(3));
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||
startActivity(intent);
|
||||
} else if (path.matches(USER_PATTERN)) {
|
||||
Intent intent = new Intent(this, ViewUserDetailActivity.class);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, segments.get(1));
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_MESSAGE_FULLNAME, messageFullname);
|
||||
intent.putExtra(ViewUserDetailActivity.EXTRA_NEW_ACCOUNT_NAME, newAccountName);
|
||||
startActivity(intent);
|
||||
} else if (path.matches(SIDEBAR_PATTERN)) {
|
||||
Intent intent = new Intent(this, ViewSubredditDetailActivity.class);
|
||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, path.substring(3, path.length() - 14));
|
||||
|
||||
@@ -71,6 +71,7 @@ import javax.inject.Named;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import eu.toldi.infinityforlemmy.ActivityToolbarInterface;
|
||||
import eu.toldi.infinityforlemmy.FetchMyInfo;
|
||||
import eu.toldi.infinityforlemmy.FetchSubscribedThing;
|
||||
import eu.toldi.infinityforlemmy.Infinity;
|
||||
import eu.toldi.infinityforlemmy.MarkPostAsReadInterface;
|
||||
@@ -1022,7 +1023,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
|
||||
private void loadSubscriptions() {
|
||||
if (mAccessToken != null && !mFetchSubscriptionsSuccess) {
|
||||
FetchSubscribedThing.fetchSubscribedThing(mRetrofit.getRetrofit(), mAccessToken, mAccountName, null,
|
||||
FetchSubscribedThing.fetchSubscribedThing(mRetrofit.getRetrofit(), mAccessToken, mAccountQualifiedName, null,
|
||||
new ArrayList<>(), new ArrayList<>(),
|
||||
new ArrayList<>(),
|
||||
new FetchSubscribedThing.FetchSubscribedThingListener() {
|
||||
@@ -1034,7 +1035,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
mExecutor,
|
||||
new Handler(),
|
||||
mRedditDataRoomDatabase,
|
||||
mAccountName,
|
||||
mAccountQualifiedName,
|
||||
subscribedSubredditData,
|
||||
subscribedUserData,
|
||||
subredditData,
|
||||
@@ -1051,7 +1052,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
|
||||
private void loadUserData() {
|
||||
if (!mFetchUserInfoSuccess) {
|
||||
FetchUserData.fetchUserData(mRedditDataRoomDatabase, mOauthRetrofit, mAccessToken,
|
||||
FetchUserData.fetchUserData(mRedditDataRoomDatabase, mRetrofit.getRetrofit(), mAccessToken,
|
||||
mAccountName, new FetchUserData.FetchUserDataListener() {
|
||||
@Override
|
||||
public void onFetchUserDataSuccess(UserData userData, int inboxCount) {
|
||||
@@ -1068,19 +1069,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
||||
mFetchUserInfoSuccess = false;
|
||||
}
|
||||
});
|
||||
/*FetchMyInfo.fetchAccountInfo(mOauthRetrofit, mRedditDataRoomDatabase, mAccessToken,
|
||||
new FetchMyInfo.FetchMyInfoListener() {
|
||||
@Override
|
||||
public void onFetchMyInfoSuccess(String name, String profileImageUrl, String bannerImageUrl, int karma) {
|
||||
mAccountName = name;
|
||||
mFetchUserInfoSuccess = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchMyInfoFailed(boolean parseFailed) {
|
||||
mFetchUserInfoSuccess = false;
|
||||
}
|
||||
});*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -233,6 +233,8 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
private int fabOption;
|
||||
private MaterialAlertDialogBuilder nsfwWarningBuilder;
|
||||
|
||||
private boolean hideSubredditDescription;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||
@@ -336,7 +338,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
}
|
||||
|
||||
lockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
|
||||
boolean hideSubredditDescription = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_SUBREDDIT_DESCRIPTION, false);
|
||||
hideSubredditDescription = mSharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_SUBREDDIT_DESCRIPTION, false);
|
||||
|
||||
subredditName = getIntent().getStringExtra(EXTRA_SUBREDDIT_NAME_KEY);
|
||||
qualifiedName = getIntent().getStringExtra(EXTRA_COMMUNITY_FULL_NAME_KEY);
|
||||
@@ -364,8 +366,97 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
checkNewAccountAndBindView();
|
||||
|
||||
fetchSubredditData();
|
||||
if (subredditName != null) {
|
||||
setupVisibleElements();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (sectionsPagerAdapter != null) {
|
||||
return sectionsPagerAdapter.handleKeyDown(keyCode) || super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SharedPreferences getDefaultSharedPreferences() {
|
||||
return mSharedPreferences;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CustomThemeWrapper getCustomThemeWrapper() {
|
||||
return mCustomThemeWrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyCustomTheme() {
|
||||
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||
appBarLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
appBarLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
collapsingToolbarLayout.setScrimVisibleHeightTrigger(toolbar.getHeight() + tabLayout.getHeight() + getStatusBarHeight() * 2);
|
||||
}
|
||||
});
|
||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar, false);
|
||||
expandedTabTextColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTextColor();
|
||||
expandedTabIndicatorColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabIndicator();
|
||||
expandedTabBackgroundColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabBackground();
|
||||
collapsedTabTextColor = mCustomThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTextColor();
|
||||
collapsedTabIndicatorColor = mCustomThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTabIndicator();
|
||||
collapsedTabBackgroundColor = mCustomThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTabBackground();
|
||||
linearLayout.setBackgroundColor(expandedTabBackgroundColor);
|
||||
subredditNameTextView.setTextColor(mCustomThemeWrapper.getSubreddit());
|
||||
subscribeSubredditChip.setTextColor(mCustomThemeWrapper.getChipTextColor());
|
||||
int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
|
||||
nSubscribersTextView.setTextColor(primaryTextColor);
|
||||
nOnlineSubscribersTextView.setTextColor(primaryTextColor);
|
||||
sinceTextView.setTextColor(primaryTextColor);
|
||||
creationTimeTextView.setTextColor(primaryTextColor);
|
||||
descriptionTextView.setTextColor(primaryTextColor);
|
||||
navigationWrapper.applyCustomTheme(mCustomThemeWrapper.getBottomAppBarIconColor(), mCustomThemeWrapper.getBottomAppBarBackgroundColor());
|
||||
applyTabLayoutTheme(tabLayout);
|
||||
applyFABTheme(navigationWrapper.floatingActionButton);
|
||||
if (typeface != null) {
|
||||
subredditNameTextView.setTypeface(typeface);
|
||||
subscribeSubredditChip.setTypeface(typeface);
|
||||
nSubscribersTextView.setTypeface(typeface);
|
||||
nOnlineSubscribersTextView.setTypeface(typeface);
|
||||
sinceTextView.setTypeface(typeface);
|
||||
creationTimeTextView.setTypeface(typeface);
|
||||
descriptionTextView.setTypeface(typeface);
|
||||
}
|
||||
unsubscribedColor = mCustomThemeWrapper.getUnsubscribed();
|
||||
subscribedColor = mCustomThemeWrapper.getSubscribed();
|
||||
}
|
||||
|
||||
private void checkNewAccountAndBindView() {
|
||||
if (mNewAccountName != null) {
|
||||
if (mAccountName == null || !mAccountName.equals(mNewAccountName)) {
|
||||
SwitchAccount.switchAccount(mRedditDataRoomDatabase,mRetrofit, mCurrentAccountSharedPreferences,
|
||||
mExecutor, new Handler(), mNewAccountName, newAccount -> {
|
||||
EventBus.getDefault().post(new SwitchAccountEvent(getClass().getName()));
|
||||
Toast.makeText(this, R.string.account_switched, Toast.LENGTH_SHORT).show();
|
||||
|
||||
mNewAccountName = null;
|
||||
if (newAccount != null) {
|
||||
mAccessToken = newAccount.getAccessToken();
|
||||
mAccountName = newAccount.getAccountName();
|
||||
}
|
||||
|
||||
bindView();
|
||||
});
|
||||
} else {
|
||||
bindView();
|
||||
}
|
||||
} else {
|
||||
bindView();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupVisibleElements() {
|
||||
subredditNameTextView.setText(subredditName);
|
||||
communityFullNameTextView.setText(qualifiedName);
|
||||
|
||||
@@ -486,97 +577,17 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (sectionsPagerAdapter != null) {
|
||||
return sectionsPagerAdapter.handleKeyDown(keyCode) || super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SharedPreferences getDefaultSharedPreferences() {
|
||||
return mSharedPreferences;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CustomThemeWrapper getCustomThemeWrapper() {
|
||||
return mCustomThemeWrapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void applyCustomTheme() {
|
||||
coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||
appBarLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
|
||||
@Override
|
||||
public void onGlobalLayout() {
|
||||
appBarLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
|
||||
collapsingToolbarLayout.setScrimVisibleHeightTrigger(toolbar.getHeight() + tabLayout.getHeight() + getStatusBarHeight() * 2);
|
||||
}
|
||||
});
|
||||
applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, collapsingToolbarLayout, toolbar, false);
|
||||
expandedTabTextColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTextColor();
|
||||
expandedTabIndicatorColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabIndicator();
|
||||
expandedTabBackgroundColor = mCustomThemeWrapper.getTabLayoutWithExpandedCollapsingToolbarTabBackground();
|
||||
collapsedTabTextColor = mCustomThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTextColor();
|
||||
collapsedTabIndicatorColor = mCustomThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTabIndicator();
|
||||
collapsedTabBackgroundColor = mCustomThemeWrapper.getTabLayoutWithCollapsedCollapsingToolbarTabBackground();
|
||||
linearLayout.setBackgroundColor(expandedTabBackgroundColor);
|
||||
subredditNameTextView.setTextColor(mCustomThemeWrapper.getSubreddit());
|
||||
subscribeSubredditChip.setTextColor(mCustomThemeWrapper.getChipTextColor());
|
||||
int primaryTextColor = mCustomThemeWrapper.getPrimaryTextColor();
|
||||
nSubscribersTextView.setTextColor(primaryTextColor);
|
||||
nOnlineSubscribersTextView.setTextColor(primaryTextColor);
|
||||
sinceTextView.setTextColor(primaryTextColor);
|
||||
creationTimeTextView.setTextColor(primaryTextColor);
|
||||
descriptionTextView.setTextColor(primaryTextColor);
|
||||
navigationWrapper.applyCustomTheme(mCustomThemeWrapper.getBottomAppBarIconColor(), mCustomThemeWrapper.getBottomAppBarBackgroundColor());
|
||||
applyTabLayoutTheme(tabLayout);
|
||||
applyFABTheme(navigationWrapper.floatingActionButton);
|
||||
if (typeface != null) {
|
||||
subredditNameTextView.setTypeface(typeface);
|
||||
subscribeSubredditChip.setTypeface(typeface);
|
||||
nSubscribersTextView.setTypeface(typeface);
|
||||
nOnlineSubscribersTextView.setTypeface(typeface);
|
||||
sinceTextView.setTypeface(typeface);
|
||||
creationTimeTextView.setTypeface(typeface);
|
||||
descriptionTextView.setTypeface(typeface);
|
||||
}
|
||||
unsubscribedColor = mCustomThemeWrapper.getUnsubscribed();
|
||||
subscribedColor = mCustomThemeWrapper.getSubscribed();
|
||||
}
|
||||
|
||||
private void checkNewAccountAndBindView() {
|
||||
if (mNewAccountName != null) {
|
||||
if (mAccountName == null || !mAccountName.equals(mNewAccountName)) {
|
||||
SwitchAccount.switchAccount(mRedditDataRoomDatabase,mRetrofit, mCurrentAccountSharedPreferences,
|
||||
mExecutor, new Handler(), mNewAccountName, newAccount -> {
|
||||
EventBus.getDefault().post(new SwitchAccountEvent(getClass().getName()));
|
||||
Toast.makeText(this, R.string.account_switched, Toast.LENGTH_SHORT).show();
|
||||
|
||||
mNewAccountName = null;
|
||||
if (newAccount != null) {
|
||||
mAccessToken = newAccount.getAccessToken();
|
||||
mAccountName = newAccount.getAccountName();
|
||||
}
|
||||
|
||||
bindView();
|
||||
});
|
||||
} else {
|
||||
bindView();
|
||||
}
|
||||
} else {
|
||||
bindView();
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchSubredditData() {
|
||||
if (!mFetchSubredditInfoSuccess) {
|
||||
FetchSubredditData.fetchSubredditData(mOauthRetrofit, mRetrofit.getRetrofit(), qualifiedName, mAccessToken, new FetchSubredditData.FetchSubredditDataListener() {
|
||||
@Override
|
||||
public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) {
|
||||
qualifiedName = LemmyUtils.actorID2FullName(subredditData.getActorId());
|
||||
if (subredditName == null) {
|
||||
subredditName = subredditData.getTitle();
|
||||
setupVisibleElements();
|
||||
}
|
||||
|
||||
mNCurrentOnlineSubscribers = nCurrentOnlineSubscribers;
|
||||
nOnlineSubscribersTextView.setText(getString(R.string.online_subscribers_number_detail, nCurrentOnlineSubscribers));
|
||||
InsertSubredditData.insertSubredditData(mExecutor, new Handler(), mRedditDataRoomDatabase,
|
||||
|
||||
@@ -107,6 +107,7 @@ import eu.toldi.infinityforlemmy.user.UserData;
|
||||
import eu.toldi.infinityforlemmy.user.UserFollowing;
|
||||
import eu.toldi.infinityforlemmy.user.UserViewModel;
|
||||
import eu.toldi.infinityforlemmy.utils.APIUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.LemmyUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.SharedPreferencesUtils;
|
||||
import eu.toldi.infinityforlemmy.utils.Utils;
|
||||
import io.noties.markwon.AbstractMarkwonPlugin;
|
||||
@@ -230,6 +231,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
private String mMessageFullname;
|
||||
private String mNewAccountName;
|
||||
|
||||
private UserData mUserData;
|
||||
|
||||
//private MaterialAlertDialogBuilder nsfwWarningBuilder;
|
||||
|
||||
@Override
|
||||
@@ -271,9 +274,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null);
|
||||
lockBottomAppBar = mSharedPreferences.getBoolean(SharedPreferencesUtils.LOCK_BOTTOM_APP_BAR, false);
|
||||
|
||||
if (username.equalsIgnoreCase("me")) {
|
||||
username = mAccountName;
|
||||
}
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
mMessageFullname = getIntent().getStringExtra(EXTRA_MESSAGE_FULLNAME);
|
||||
@@ -288,8 +288,13 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
|
||||
fetchUserInfo();
|
||||
|
||||
Resources resources = getResources();
|
||||
if (mUserData != null) {
|
||||
setupVisibleElements();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupVisibleElements() {
|
||||
Resources resources = getResources();
|
||||
String title = username;
|
||||
userNameTextView.setText(title);
|
||||
qualifiedNameTextView.setText(qualifiedName);
|
||||
@@ -404,7 +409,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
return true;
|
||||
});
|
||||
|
||||
userViewModel = new ViewModelProvider(this, new UserViewModel.Factory(getApplication(), mRedditDataRoomDatabase, username))
|
||||
userViewModel = new ViewModelProvider(this, new UserViewModel.Factory(getApplication(), mRedditDataRoomDatabase, LemmyUtils.qualifiedUserName2ActorId(qualifiedName)))
|
||||
.get(UserViewModel.class);
|
||||
userViewModel.getUserLiveData().observe(this, userData -> {
|
||||
if (userData != null) {
|
||||
@@ -524,20 +529,20 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
|
||||
CheckIsFollowingUser.checkIsFollowingUser(mExecutor, new Handler(), mRedditDataRoomDatabase,
|
||||
username, mAccountName, new CheckIsFollowingUser.CheckIsFollowingUserListener() {
|
||||
@Override
|
||||
public void isSubscribed() {
|
||||
subscribeUserChip.setText(R.string.unfollow);
|
||||
subscribeUserChip.setChipBackgroundColor(ColorStateList.valueOf(subscribedColor));
|
||||
subscriptionReady = true;
|
||||
}
|
||||
@Override
|
||||
public void isSubscribed() {
|
||||
subscribeUserChip.setText(R.string.unfollow);
|
||||
subscribeUserChip.setChipBackgroundColor(ColorStateList.valueOf(subscribedColor));
|
||||
subscriptionReady = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void isNotSubscribed() {
|
||||
subscribeUserChip.setText(R.string.follow);
|
||||
subscribeUserChip.setChipBackgroundColor(ColorStateList.valueOf(unsubscribedColor));
|
||||
subscriptionReady = true;
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void isNotSubscribed() {
|
||||
subscribeUserChip.setText(R.string.follow);
|
||||
subscribeUserChip.setChipBackgroundColor(ColorStateList.valueOf(unsubscribedColor));
|
||||
subscriptionReady = true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
subscribeUserChip.setVisibility(View.GONE);
|
||||
}
|
||||
@@ -1071,6 +1076,9 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
||||
FetchUserData.fetchUserData(mRetrofit.getRetrofit(), qualifiedName, new FetchUserData.FetchUserDataListener() {
|
||||
@Override
|
||||
public void onFetchUserDataSuccess(UserData userData, int inboxCount) {
|
||||
mUserData = userData;
|
||||
username = userData.getName();
|
||||
setupVisibleElements();
|
||||
new ViewUserDetailActivity.InsertUserDataAsyncTask(mRedditDataRoomDatabase.userDao(), userData,
|
||||
() -> mFetchUserInfoSuccess = true).execute();
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ public interface LemmyAPI {
|
||||
@Query("sort") String sort,
|
||||
@Query("page") Integer page,
|
||||
@Query("limit") Integer limit,
|
||||
@Query("saved_only") Boolean saved_only,
|
||||
@Query("auth") String access_token);
|
||||
|
||||
@GET("api/v3/community/list")
|
||||
|
||||
@@ -252,7 +252,7 @@ public class PostPagingSource extends ListenableFuturePagingSource<Integer, Post
|
||||
|
||||
private ListenableFuture<LoadResult<Integer, Post>> loadUserPosts(@NonNull LoadParams<Integer> loadParams, LemmyAPI api) {
|
||||
ListenableFuture<Response<String>> userPosts;
|
||||
userPosts = api.getUserPosts(subredditOrUserName, sortType.getType().value,loadParams.getKey(),25,accessToken);
|
||||
userPosts = api.getUserPosts(subredditOrUserName, sortType.getType().value, loadParams.getKey(), 25, userWhere.equals(USER_WHERE_SAVED), accessToken);
|
||||
|
||||
|
||||
ListenableFuture<LoadResult<Integer, Post>> pageFuture = Futures.transform(userPosts, this::transformData, executor);
|
||||
|
||||
@@ -20,6 +20,9 @@ public interface UserDao {
|
||||
@Query("SELECT * FROM users WHERE name = :userName COLLATE NOCASE LIMIT 1")
|
||||
LiveData<UserData> getUserLiveData(String userName);
|
||||
|
||||
@Query("SELECT * FROM users WHERE actor_id = :actor_id COLLATE NOCASE LIMIT 1")
|
||||
LiveData<UserData> getUserLiveDataByQualifiedName(String actor_id);
|
||||
|
||||
@Query("SELECT * FROM users WHERE name = :userName COLLATE NOCASE LIMIT 1")
|
||||
UserData getUserData(String userName);
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@ public class UserRepository {
|
||||
private UserDao mUserDao;
|
||||
private LiveData<UserData> mUserLiveData;
|
||||
|
||||
UserRepository(RedditDataRoomDatabase redditDataRoomDatabase, String userName) {
|
||||
UserRepository(RedditDataRoomDatabase redditDataRoomDatabase, String actor_id) {
|
||||
mUserDao = redditDataRoomDatabase.userDao();
|
||||
mUserLiveData = mUserDao.getUserLiveData(userName);
|
||||
mUserLiveData = mUserDao.getUserLiveData(actor_id);
|
||||
}
|
||||
|
||||
LiveData<UserData> getUserLiveData() {
|
||||
|
||||
BIN
signed.apk.idsig
Normal file
BIN
signed.apk.idsig
Normal file
Binary file not shown.
Reference in New Issue
Block a user