mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 03:07:26 +01:00
Directly adding user to multireddit is available.
This commit is contained in:
parent
54e0b2f332
commit
f2fbebd434
@ -74,6 +74,7 @@ import ml.docilealligator.infinityforreddit.R;
|
|||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
import ml.docilealligator.infinityforreddit.SortType;
|
import ml.docilealligator.infinityforreddit.SortType;
|
||||||
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
import ml.docilealligator.infinityforreddit.SortTypeSelectionCallback;
|
||||||
|
import ml.docilealligator.infinityforreddit.asynctasks.AddSubredditOrUserToMultiReddit;
|
||||||
import ml.docilealligator.infinityforreddit.asynctasks.CheckIsFollowingUserAsyncTask;
|
import ml.docilealligator.infinityforreddit.asynctasks.CheckIsFollowingUserAsyncTask;
|
||||||
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
import ml.docilealligator.infinityforreddit.asynctasks.GetCurrentAccount;
|
||||||
import ml.docilealligator.infinityforreddit.asynctasks.SwitchAccountAsyncTask;
|
import ml.docilealligator.infinityforreddit.asynctasks.SwitchAccountAsyncTask;
|
||||||
@ -90,6 +91,7 @@ import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent;
|
|||||||
import ml.docilealligator.infinityforreddit.fragments.CommentsListingFragment;
|
import ml.docilealligator.infinityforreddit.fragments.CommentsListingFragment;
|
||||||
import ml.docilealligator.infinityforreddit.fragments.PostFragment;
|
import ml.docilealligator.infinityforreddit.fragments.PostFragment;
|
||||||
import ml.docilealligator.infinityforreddit.message.ReadMessage;
|
import ml.docilealligator.infinityforreddit.message.ReadMessage;
|
||||||
|
import ml.docilealligator.infinityforreddit.multireddit.MultiReddit;
|
||||||
import ml.docilealligator.infinityforreddit.post.Post;
|
import ml.docilealligator.infinityforreddit.post.Post;
|
||||||
import ml.docilealligator.infinityforreddit.post.PostDataSource;
|
import ml.docilealligator.infinityforreddit.post.PostDataSource;
|
||||||
import ml.docilealligator.infinityforreddit.readpost.InsertReadPost;
|
import ml.docilealligator.infinityforreddit.readpost.InsertReadPost;
|
||||||
@ -115,6 +117,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
public static final String EXTRA_NEW_ACCOUNT_NAME = "ENAN";
|
public static final String EXTRA_NEW_ACCOUNT_NAME = "ENAN";
|
||||||
public static final int GIVE_AWARD_REQUEST_CODE = 200;
|
public static final int GIVE_AWARD_REQUEST_CODE = 200;
|
||||||
public static final int EDIT_COMMENT_REQUEST_CODE = 300;
|
public static final int EDIT_COMMENT_REQUEST_CODE = 300;
|
||||||
|
public static final int ADD_TO_MULTIREDDIT_REQUEST_CODE = 400;
|
||||||
|
|
||||||
private static final String FETCH_USER_INFO_STATE = "FSIS";
|
private static final String FETCH_USER_INFO_STATE = "FSIS";
|
||||||
private static final String NULL_ACCESS_TOKEN_STATE = "NATS";
|
private static final String NULL_ACCESS_TOKEN_STATE = "NATS";
|
||||||
@ -913,20 +916,20 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
int itemId = item.getItemId();
|
||||||
case android.R.id.home:
|
if (itemId == android.R.id.home) {
|
||||||
finish();
|
finish();
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_sort_view_user_detail_activity:
|
} else if (itemId == R.id.action_sort_view_user_detail_activity) {
|
||||||
userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag());
|
userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag());
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_search_view_user_detail_activity:
|
} else if (itemId == R.id.action_search_view_user_detail_activity) {
|
||||||
Intent intent = new Intent(this, SearchActivity.class);
|
Intent intent = new Intent(this, SearchActivity.class);
|
||||||
intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, username);
|
intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, username);
|
||||||
intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_IS_USER, true);
|
intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_IS_USER, true);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_refresh_view_user_detail_activity:
|
} else if (itemId == R.id.action_refresh_view_user_detail_activity) {
|
||||||
if (mMenu != null) {
|
if (mMenu != null) {
|
||||||
mMenu.findItem(R.id.action_lazy_mode_view_user_detail_activity).setTitle(R.string.action_start_lazy_mode);
|
mMenu.findItem(R.id.action_lazy_mode_view_user_detail_activity).setTitle(R.string.action_start_lazy_mode);
|
||||||
}
|
}
|
||||||
@ -934,7 +937,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
mFetchUserInfoSuccess = false;
|
mFetchUserInfoSuccess = false;
|
||||||
fetchUserInfo();
|
fetchUserInfo();
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_lazy_mode_view_user_detail_activity:
|
} else if (itemId == R.id.action_lazy_mode_view_user_detail_activity) {
|
||||||
MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_user_detail_activity);
|
MenuItem lazyModeItem = mMenu.findItem(R.id.action_lazy_mode_view_user_detail_activity);
|
||||||
if (isInLazyMode) {
|
if (isInLazyMode) {
|
||||||
isInLazyMode = false;
|
isInLazyMode = false;
|
||||||
@ -955,10 +958,10 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_change_post_layout_view_user_detail_activity:
|
} else if (itemId == R.id.action_change_post_layout_view_user_detail_activity) {
|
||||||
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
|
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_share_view_user_detail_activity:
|
} else if (itemId == R.id.action_share_view_user_detail_activity) {
|
||||||
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||||
shareIntent.setType("text/plain");
|
shareIntent.setType("text/plain");
|
||||||
shareIntent.putExtra(Intent.EXTRA_TEXT, "https://www.reddit.com/user/" + username);
|
shareIntent.putExtra(Intent.EXTRA_TEXT, "https://www.reddit.com/user/" + username);
|
||||||
@ -968,7 +971,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
Toast.makeText(this, R.string.no_app, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.no_app, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_send_private_message_view_user_detail_activity:
|
} else if (itemId == R.id.action_send_private_message_view_user_detail_activity) {
|
||||||
if (mAccessToken == null) {
|
if (mAccessToken == null) {
|
||||||
Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show();
|
||||||
return true;
|
return true;
|
||||||
@ -978,12 +981,19 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
pmIntent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, username);
|
pmIntent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, username);
|
||||||
startActivity(pmIntent);
|
startActivity(pmIntent);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_report_view_user_detail_activity:
|
} else if (itemId == R.id.action_add_to_multireddit_view_user_detail_activity) {
|
||||||
|
if (mAccessToken == null) {
|
||||||
|
Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Intent intent = new Intent(this, MultiredditSelectionActivity.class);
|
||||||
|
startActivityForResult(intent, ADD_TO_MULTIREDDIT_REQUEST_CODE);
|
||||||
|
} else if (itemId == R.id.action_report_view_user_detail_activity) {
|
||||||
Intent reportIntent = new Intent(this, LinkResolverActivity.class);
|
Intent reportIntent = new Intent(this, LinkResolverActivity.class);
|
||||||
reportIntent.setData(Uri.parse("https://www.reddithelp.com/en/categories/rules-reporting/account-and-community-restrictions/what-should-i-do-if-i-see-something-i"));
|
reportIntent.setData(Uri.parse("https://www.reddithelp.com/en/categories/rules-reporting/account-and-community-restrictions/what-should-i-do-if-i-see-something-i"));
|
||||||
startActivity(reportIntent);
|
startActivity(reportIntent);
|
||||||
return true;
|
return true;
|
||||||
case R.id.action_block_user_view_user_detail_activity:
|
} else if (itemId == R.id.action_block_user_view_user_detail_activity) {
|
||||||
if (mAccessToken == null) {
|
if (mAccessToken == null) {
|
||||||
Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, R.string.login_first, Toast.LENGTH_SHORT).show();
|
||||||
return true;
|
return true;
|
||||||
@ -1030,6 +1040,28 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
data.getExtras().getInt(EditCommentActivity.EXTRA_EDITED_COMMENT_POSITION));
|
data.getExtras().getInt(EditCommentActivity.EXTRA_EDITED_COMMENT_POSITION));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (requestCode == ADD_TO_MULTIREDDIT_REQUEST_CODE) {
|
||||||
|
if (data != null) {
|
||||||
|
MultiReddit multiReddit = data.getParcelableExtra(MultiredditSelectionActivity.EXTRA_RETURN_MULTIREDDIT);
|
||||||
|
if (multiReddit != null) {
|
||||||
|
AddSubredditOrUserToMultiReddit.addSubredditOrUserToMultiReddit(mOauthRetrofit,
|
||||||
|
mAccessToken, multiReddit.getPath(), "u_" + username,
|
||||||
|
new AddSubredditOrUserToMultiReddit.AddSubredditOrUserToMultiRedditListener() {
|
||||||
|
@Override
|
||||||
|
public void success() {
|
||||||
|
Toast.makeText(ViewUserDetailActivity.this,
|
||||||
|
getString(R.string.add_subreddit_or_user_to_multireddit_success, username, multiReddit.getDisplayName()), Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void failed(int code) {
|
||||||
|
Toast.makeText(ViewUserDetailActivity.this,
|
||||||
|
getString(R.string.add_subreddit_or_user_to_multireddit_failed, username, multiReddit.getDisplayName()), Toast.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,12 +45,18 @@
|
|||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_report_view_user_detail_activity"
|
android:id="@+id/action_add_to_multireddit_view_user_detail_activity"
|
||||||
android:orderInCategory="8"
|
android:orderInCategory="8"
|
||||||
|
android:title="@string/action_add_to_multireddit"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/action_report_view_user_detail_activity"
|
||||||
|
android:orderInCategory="9"
|
||||||
android:title="@string/action_report" />
|
android:title="@string/action_report" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/action_block_user_view_user_detail_activity"
|
android:id="@+id/action_block_user_view_user_detail_activity"
|
||||||
android:orderInCategory="9"
|
android:orderInCategory="10"
|
||||||
android:title="@string/action_block_user" />
|
android:title="@string/action_block_user" />
|
||||||
</menu>
|
</menu>
|
||||||
|
Loading…
Reference in New Issue
Block a user