Add ViewPrivateMessagesActivity. Rename getSharedPreferences to getDefaultSharedPreferences in BaseActivity.

This commit is contained in:
Alex Ning 2020-06-29 13:15:23 +08:00
parent d1fc84f9d0
commit 04f16d5664
44 changed files with 394 additions and 102 deletions

View File

@ -24,6 +24,10 @@
android:usesCleartextTraffic="true"
tools:replace="android:label">
<activity android:name=".Activity.ViewPrivateMessagesActivity"
android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.Slidable" />
<service
android:name=".Service.DownloadRedditVideoService"
android:enabled="true"
@ -118,7 +122,7 @@
android:parentActivityName=".Activity.MainActivity"
android:theme="@style/PreferenceActivityTheme" />
<activity
android:name=".Activity.ViewMessageActivity"
android:name=".Activity.InboxActivity"
android:label="@string/view_message_activity_label"
android:parentActivityName=".Activity.MainActivity"
android:theme="@style/AppTheme.Slidable" />
@ -324,4 +328,4 @@
android:exported="false" />
</application>
</manifest>
</manifest>

View File

@ -156,7 +156,7 @@ public class AccountPostsActivity extends BaseActivity implements SortTypeSelect
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -147,7 +147,7 @@ public class AccountSavedThingActivity extends BaseActivity implements ActivityT
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -58,7 +58,7 @@ public abstract class BaseActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
customThemeWrapper = getCustomThemeWrapper();
SharedPreferences mSharedPreferences = getSharedPreferences();
SharedPreferences mSharedPreferences = getDefaultSharedPreferences();
boolean systemDefault = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
int systemThemeType = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.THEME_KEY, "2"));
immersiveInterface = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
@ -174,7 +174,7 @@ public abstract class BaseActivity extends AppCompatActivity {
}
}
protected abstract SharedPreferences getSharedPreferences();
protected abstract SharedPreferences getDefaultSharedPreferences();
protected abstract CustomThemeWrapper getCustomThemeWrapper();
@ -229,7 +229,7 @@ public abstract class BaseActivity extends AppCompatActivity {
}
public int getNavBarHeight() {
if (getSharedPreferences().getBoolean(SharedPreferencesUtils.IMMERSIVE_INTERFACE_IGNORE_NAV_BAR_KEY, false)) {
if (getDefaultSharedPreferences().getBoolean(SharedPreferencesUtils.IMMERSIVE_INTERFACE_IGNORE_NAV_BAR_KEY, false)) {
return 0;
}

View File

@ -259,7 +259,7 @@ public class CommentActivity extends BaseActivity {
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -210,7 +210,7 @@ public class CreateMultiRedditActivity extends BaseActivity {
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -135,7 +135,7 @@ public class CustomThemeListingActivity extends BaseActivity implements
}
@Override
protected SharedPreferences getSharedPreferences() {
protected SharedPreferences getDefaultSharedPreferences() {
return sharedPreferences;
}

View File

@ -229,7 +229,7 @@ public class CustomizeThemeActivity extends BaseActivity {
}
@Override
protected SharedPreferences getSharedPreferences() {
protected SharedPreferences getDefaultSharedPreferences() {
return sharedPreferences;
}

View File

@ -113,7 +113,7 @@ public class EditCommentActivity extends BaseActivity {
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -244,7 +244,7 @@ public class EditMultiRedditActivity extends BaseActivity {
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -116,7 +116,7 @@ public class EditPostActivity extends BaseActivity {
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -174,7 +174,7 @@ public class FilteredThingActivity extends BaseActivity implements SortTypeSelec
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -39,14 +39,14 @@ import ml.docilealligator.infinityforreddit.AsyncTask.SwitchAccountAsyncTask;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Event.SwitchAccountEvent;
import ml.docilealligator.infinityforreddit.FetchMessages;
import ml.docilealligator.infinityforreddit.Fragment.ViewMessagesFragment;
import ml.docilealligator.infinityforreddit.Fragment.InboxFragment;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit;
public class ViewMessageActivity extends BaseActivity implements ActivityToolbarInterface {
public class InboxActivity extends BaseActivity implements ActivityToolbarInterface {
public static final String EXTRA_NEW_ACCOUNT_NAME = "ENAN";
@ -54,17 +54,17 @@ public class ViewMessageActivity extends BaseActivity implements ActivityToolbar
private static final String ACCESS_TOKEN_STATE = "ATS";
private static final String NEW_ACCOUNT_NAME_STATE = "NANS";
@BindView(R.id.coordinator_layout_view_message_activity)
@BindView(R.id.coordinator_layout_inbox_activity)
CoordinatorLayout mCoordinatorLayout;
@BindView(R.id.collapsing_toolbar_layout_view_message_activity)
@BindView(R.id.collapsing_toolbar_layout_inbox_activity)
CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.appbar_layout_view_message_activity)
@BindView(R.id.appbar_layout_inbox_activity)
AppBarLayout mAppBarLayout;
@BindView(R.id.toolbar_view_message_activity)
@BindView(R.id.toolbar_inbox_activity)
Toolbar mToolbar;
@BindView(R.id.tab_layout_view_message_activity)
@BindView(R.id.tab_layout_inbox_activity)
TabLayout tabLayout;
@BindView(R.id.view_pager_view_message_activity)
@BindView(R.id.view_pager_inbox_activity)
ViewPager viewPager;
@Inject
@Named("oauth")
@ -88,7 +88,7 @@ public class ViewMessageActivity extends BaseActivity implements ActivityToolbar
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_message);
setContentView(R.layout.activity_inbox);
ButterKnife.bind(this);
@ -134,7 +134,7 @@ public class ViewMessageActivity extends BaseActivity implements ActivityToolbar
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}
@ -202,14 +202,14 @@ public class ViewMessageActivity extends BaseActivity implements ActivityToolbar
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.view_message_activity, menu);
getMenuInflater().inflate(R.menu.inbox_activity, menu);
applyMenuItemTheme(menu);
return true;
}
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
if (item.getItemId() == R.id.action_refresh_view_message_activity) {
if (item.getItemId() == R.id.action_refresh_inbox_activity) {
if (sectionsPagerAdapter != null) {
sectionsPagerAdapter.refresh();
}
@ -262,8 +262,8 @@ public class ViewMessageActivity extends BaseActivity implements ActivityToolbar
}
private class SectionsPagerAdapter extends FragmentPagerAdapter {
private ViewMessagesFragment tab1;
private ViewMessagesFragment tab2;
private InboxFragment tab1;
private InboxFragment tab2;
public SectionsPagerAdapter(@NonNull FragmentManager fm) {
super(fm, FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
@ -273,17 +273,17 @@ public class ViewMessageActivity extends BaseActivity implements ActivityToolbar
@Override
public Fragment getItem(int position) {
if (position == 0) {
ViewMessagesFragment fragment = new ViewMessagesFragment();
InboxFragment fragment = new InboxFragment();
Bundle bundle = new Bundle();
bundle.putString(ViewMessagesFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(ViewMessagesFragment.EXTRA_MESSAGE_WHERE, FetchMessages.WHERE_INBOX);
bundle.putString(InboxFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(InboxFragment.EXTRA_MESSAGE_WHERE, FetchMessages.WHERE_INBOX);
fragment.setArguments(bundle);
return fragment;
} else {
ViewMessagesFragment fragment = new ViewMessagesFragment();
InboxFragment fragment = new InboxFragment();
Bundle bundle = new Bundle();
bundle.putString(ViewMessagesFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(ViewMessagesFragment.EXTRA_MESSAGE_WHERE, FetchMessages.WHERE_MESSAGES);
bundle.putString(InboxFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putString(InboxFragment.EXTRA_MESSAGE_WHERE, FetchMessages.WHERE_MESSAGES);
fragment.setArguments(bundle);
return fragment;
}
@ -309,9 +309,9 @@ public class ViewMessageActivity extends BaseActivity implements ActivityToolbar
public Object instantiateItem(@NonNull ViewGroup container, int position) {
Fragment fragment = (Fragment) super.instantiateItem(container, position);
if (position == 0) {
tab1 = (ViewMessagesFragment) fragment;
tab1 = (InboxFragment) fragment;
} else if (position == 1) {
tab2 = (ViewMessagesFragment) fragment;
tab2 = (InboxFragment) fragment;
}
return fragment;

View File

@ -218,7 +218,7 @@ public class LoginActivity extends BaseActivity {
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -292,7 +292,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}
@ -444,7 +444,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
});
messageBottomAppBar.setOnClickListener(view -> {
Intent intent = new Intent(this, ViewMessageActivity.class);
Intent intent = new Intent(this, InboxActivity.class);
startActivity(intent);
});
@ -483,7 +483,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
intent = new Intent(MainActivity.this, MultiRedditListingActivity.class);
break;
case R.string.inbox:
intent = new Intent(MainActivity.this, ViewMessageActivity.class);
intent = new Intent(MainActivity.this, InboxActivity.class);
break;
case R.string.upvoted:
intent = new Intent(MainActivity.this, AccountPostsActivity.class);

View File

@ -252,7 +252,7 @@ public class MultiRedditListingActivity extends BaseActivity {
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -371,7 +371,7 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -310,7 +310,7 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -314,7 +314,7 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -376,7 +376,7 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -202,7 +202,7 @@ public class ReportActivity extends BaseActivity {
}
@Override
protected SharedPreferences getSharedPreferences() {
protected SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -136,7 +136,7 @@ public class RulesActivity extends BaseActivity {
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -184,7 +184,7 @@ public class SearchActivity extends BaseActivity {
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -176,7 +176,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -117,7 +117,7 @@ public class SearchSubredditsResultActivity extends BaseActivity implements Acti
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -150,7 +150,7 @@ public class SelectedSubredditsActivity extends BaseActivity implements Activity
}
@Override
protected SharedPreferences getSharedPreferences() {
protected SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -91,7 +91,7 @@ public class SettingsActivity extends BaseActivity implements
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -235,7 +235,7 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -138,7 +138,7 @@ public class SubredditSelectionActivity extends BaseActivity implements Activity
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -149,7 +149,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -332,7 +332,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -377,7 +377,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -0,0 +1,165 @@
package ml.docilealligator.infinityforreddit.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import androidx.appcompat.widget.Toolbar;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.r0adkll.slidr.Slidr;
import java.util.ArrayList;
import javax.inject.Inject;
import javax.inject.Named;
import butterknife.BindView;
import butterknife.ButterKnife;
import ml.docilealligator.infinityforreddit.ActivityToolbarInterface;
import ml.docilealligator.infinityforreddit.AsyncTask.GetCurrentAccountAsyncTask;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.Message;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
import retrofit2.Retrofit;
public class ViewPrivateMessagesActivity extends BaseActivity implements ActivityToolbarInterface {
public static final String EXTRA_PRIVATE_MESSAGES = "EPM";
public static final String EXTRA_SENDER_USERNAME = "ESU";
private static final String NULL_ACCESS_TOKEN_STATE = "NATS";
private static final String ACCESS_TOKEN_STATE = "ATS";
@BindView(R.id.coordinator_layout_view_private_messages_activity)
CoordinatorLayout mCoordinatorLayout;
@BindView(R.id.collapsing_toolbar_layout_view_private_messages_activity)
CollapsingToolbarLayout collapsingToolbarLayout;
@BindView(R.id.appbar_layout_view_private_messages_activity)
AppBarLayout mAppBarLayout;
@BindView(R.id.toolbar_view_private_messages_activity)
Toolbar mToolbar;
@BindView(R.id.recycler_view_view_private_messages)
RecyclerView mRecyclerView;
@BindView(R.id.fab_view_private_messages_activity)
FloatingActionButton mFab;
@Inject
@Named("oauth")
Retrofit mOauthRetrofit;
@Inject
RedditDataRoomDatabase mRedditDataRoomDatabase;
@Inject
@Named("default")
SharedPreferences mSharedPreferences;
@Inject
CustomThemeWrapper mCustomThemeWrapper;
private LinearLayoutManager mLinearLayoutManager;
private ArrayList<Message> privateMessages;
private boolean mNullAccessToken = false;
private String mAccessToken;
@Override
protected void onCreate(Bundle savedInstanceState) {
((Infinity) getApplication()).getAppComponent().inject(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_private_messages);
ButterKnife.bind(this);
applyCustomTheme();
if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL, true)) {
Slidr.attach(this);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Window window = getWindow();
if (isChangeStatusBarIconColor()) {
addOnOffsetChangedListener(mAppBarLayout);
}
if (isImmersiveInterface()) {
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
adjustToolbar(mToolbar);
int navBarHeight = getNavBarHeight();
if (navBarHeight > 0) {
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) mFab.getLayoutParams();
params.bottomMargin = navBarHeight;
mFab.setLayoutParams(params);
}
}
}
Intent intent = getIntent();
privateMessages = intent.getParcelableArrayListExtra(EXTRA_PRIVATE_MESSAGES);
mToolbar.setTitle(intent.getStringExtra(EXTRA_SENDER_USERNAME));
setSupportActionBar(mToolbar);
setToolbarGoToTop(mToolbar);
if (savedInstanceState != null) {
mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);
if (!mNullAccessToken && mAccessToken == null) {
getCurrentAccountAndBindView();
} else {
bindView();
}
} else {
getCurrentAccountAndBindView();
}
}
private void getCurrentAccountAndBindView() {
new GetCurrentAccountAsyncTask(mRedditDataRoomDatabase.accountDao(), account -> {
if (account == null) {
mNullAccessToken = true;
} else {
mAccessToken = account.getAccessToken();
}
bindView();
}).execute();
}
private void bindView() {
}
@Override
protected SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}
@Override
protected CustomThemeWrapper getCustomThemeWrapper() {
return mCustomThemeWrapper;
}
@Override
protected void applyCustomTheme() {
mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
applyAppBarLayoutAndToolbarTheme(mAppBarLayout, mToolbar);
applyFABTheme(mFab);
}
@Override
public void onLongPress() {
if (mLinearLayoutManager != null) {
mLinearLayoutManager.scrollToPositionWithOffset(0, 0);
}
}
}

View File

@ -413,7 +413,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}
@ -542,7 +542,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
goBackToMainPageBottomAppBar.setOnClickListener(view -> EventBus.getDefault().post(new GoBackToMainPageEvent()));
messageBottomAppBar.setOnClickListener(view -> {
Intent intent = new Intent(this, ViewMessageActivity.class);
Intent intent = new Intent(this, InboxActivity.class);
startActivity(intent);
});

View File

@ -430,7 +430,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
}
@Override
public SharedPreferences getSharedPreferences() {
public SharedPreferences getDefaultSharedPreferences() {
return mSharedPreferences;
}

View File

@ -12,7 +12,6 @@ import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.paging.PagedListAdapter;
@ -28,6 +27,7 @@ import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
import io.noties.markwon.linkify.LinkifyPlugin;
import io.noties.markwon.simple.ext.SimpleExtPlugin;
import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewPrivateMessagesActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.FetchMessages;
@ -155,7 +155,10 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
intent.setData(uri);
mContext.startActivity(intent);
} else if (mMessageType == FetchMessages.MESSAGE_TYPE_PRIVATE_MESSAGE) {
Toast.makeText(mContext, "To be implemented", Toast.LENGTH_SHORT).show();
Intent intent = new Intent(mContext, ViewPrivateMessagesActivity.class);
intent.putExtra(ViewPrivateMessagesActivity.EXTRA_SENDER_USERNAME, message.getAuthor());
intent.putExtra(ViewPrivateMessagesActivity.EXTRA_PRIVATE_MESSAGES, message.getReplies());
mContext.startActivity(intent);
}
if (message.isNew()) {

View File

@ -34,15 +34,17 @@ import ml.docilealligator.infinityforreddit.Activity.SubscribedThingListingActiv
import ml.docilealligator.infinityforreddit.Activity.ThemePreviewActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewImageOrGifActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewImgurMediaActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewMessageActivity;
import ml.docilealligator.infinityforreddit.Activity.InboxActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewMultiRedditDetailActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewPostDetailActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewPrivateMessagesActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewUserDetailActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewVideoActivity;
import ml.docilealligator.infinityforreddit.Fragment.CommentsListingFragment;
import ml.docilealligator.infinityforreddit.BottomSheetFragment.FlairBottomSheetFragment;
import ml.docilealligator.infinityforreddit.Fragment.FollowedUsersListingFragment;
import ml.docilealligator.infinityforreddit.Fragment.InboxFragment;
import ml.docilealligator.infinityforreddit.Fragment.MultiRedditListingFragment;
import ml.docilealligator.infinityforreddit.Fragment.PostFragment;
import ml.docilealligator.infinityforreddit.Fragment.SidebarFragment;
@ -50,7 +52,6 @@ import ml.docilealligator.infinityforreddit.Fragment.SubredditListingFragment;
import ml.docilealligator.infinityforreddit.Fragment.SubscribedSubredditsListingFragment;
import ml.docilealligator.infinityforreddit.Fragment.UserListingFragment;
import ml.docilealligator.infinityforreddit.Fragment.ViewImgurVideoFragment;
import ml.docilealligator.infinityforreddit.Fragment.ViewMessagesFragment;
import ml.docilealligator.infinityforreddit.Service.DownloadRedditVideoService;
import ml.docilealligator.infinityforreddit.Service.SubmitPostService;
import ml.docilealligator.infinityforreddit.Settings.AdvancedPreferenceFragment;
@ -119,7 +120,7 @@ public interface AppComponent {
void inject(PullNotificationWorker pullNotificationWorker);
void inject(ViewMessageActivity viewMessageActivity);
void inject(InboxActivity inboxActivity);
void inject(NotificationPreferenceFragment notificationPreferenceFragment);
@ -175,5 +176,7 @@ public interface AppComponent {
void inject(MultiRedditListingFragment multiRedditListingFragment);
void inject(ViewMessagesFragment viewMessagesFragment);
void inject(InboxFragment inboxFragment);
void inject(ViewPrivateMessagesActivity viewPrivateMessagesActivity);
}

View File

@ -37,19 +37,19 @@ import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import retrofit2.Retrofit;
public class ViewMessagesFragment extends Fragment implements FragmentCommunicator {
public class InboxFragment extends Fragment implements FragmentCommunicator {
public static final String EXTRA_ACCESS_TOKEN = "EAT";
public static final String EXTRA_MESSAGE_WHERE = "EMT";
@BindView(R.id.swipe_refresh_layout_view_messages_fragment)
@BindView(R.id.swipe_refresh_layout_inbox_fragment)
SwipeRefreshLayout mSwipeRefreshLayout;
@BindView(R.id.recycler_view_view_messages_fragment)
@BindView(R.id.recycler_view_inbox_fragment)
RecyclerView mRecyclerView;
@BindView(R.id.fetch_messages_info_linear_layout_view_messages_fragment)
@BindView(R.id.fetch_messages_info_linear_layout_inbox_fragment)
LinearLayout mFetchMessageInfoLinearLayout;
@BindView(R.id.fetch_messages_info_image_view_view_messages_fragment)
@BindView(R.id.fetch_messages_info_image_view_inbox_fragment)
ImageView mFetchMessageInfoImageView;
@BindView(R.id.fetch_messages_info_text_view_view_messages_fragment)
@BindView(R.id.fetch_messages_info_text_view_inbox_fragment)
TextView mFetchMessageInfoTextView;
MessageViewModel mMessageViewModel;
@Inject
@ -68,14 +68,14 @@ public class ViewMessagesFragment extends Fragment implements FragmentCommunicat
private LinearLayoutManager mLinearLayoutManager;
private BaseActivity mActivity;
public ViewMessagesFragment() {
public InboxFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_view_messages, container, false);
View rootView = inflater.inflate(R.layout.fragment_inbox, container, false);
((Infinity) mActivity.getApplication()).getAppComponent().inject(this);

View File

@ -1,8 +1,11 @@
package ml.docilealligator.infinityforreddit;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.ArrayList;
public class Message {
public class Message implements Parcelable {
static final String TYPE_COMMENT = "t1";
static final String TYPE_ACCOUNT = "t2";
static final String TYPE_LINK = "t3";
@ -55,6 +58,40 @@ public class Message {
}
protected Message(Parcel in) {
kind = in.readString();
subredditName = in.readString();
subredditNamePrefixed = in.readString();
id = in.readString();
fullname = in.readString();
subject = in.readString();
author = in.readString();
parentFullName = in.readString();
title = in.readString();
body = in.readString();
context = in.readString();
distinguished = in.readString();
formattedTime = in.readString();
wasComment = in.readByte() != 0;
isNew = in.readByte() != 0;
score = in.readInt();
nComments = in.readInt();
timeUTC = in.readLong();
replies = in.createTypedArrayList(Message.CREATOR);
}
public static final Creator<Message> CREATOR = new Creator<Message>() {
@Override
public Message createFromParcel(Parcel in) {
return new Message(in);
}
@Override
public Message[] newArray(int size) {
return new Message[size];
}
};
public String getKind() {
return kind;
}
@ -138,4 +175,32 @@ public class Message {
public void setReplies(ArrayList<Message> replies) {
this.replies = replies;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(kind);
parcel.writeString(subredditName);
parcel.writeString(subredditNamePrefixed);
parcel.writeString(id);
parcel.writeString(fullname);
parcel.writeString(subject);
parcel.writeString(author);
parcel.writeString(parentFullName);
parcel.writeString(title);
parcel.writeString(body);
parcel.writeString(context);
parcel.writeString(distinguished);
parcel.writeString(formattedTime);
parcel.writeByte((byte) (wasComment ? 1 : 0));
parcel.writeByte((byte) (isNew ? 1 : 0));
parcel.writeInt(score);
parcel.writeInt(nComments);
parcel.writeLong(timeUTC);
parcel.writeTypedList(replies);
}
}

View File

@ -28,8 +28,8 @@ import javax.inject.Named;
import ml.docilealligator.infinityforreddit.API.RedditAPI;
import ml.docilealligator.infinityforreddit.Account.Account;
import ml.docilealligator.infinityforreddit.Activity.InboxActivity;
import ml.docilealligator.infinityforreddit.Activity.LinkResolverActivity;
import ml.docilealligator.infinityforreddit.Activity.ViewMessageActivity;
import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.Utils.APIUtils;
import ml.docilealligator.infinityforreddit.Utils.JSONUtils;
@ -149,8 +149,8 @@ public class PullNotificationWorker extends Worker {
PendingIntent pendingIntent = PendingIntent.getActivity(context, accountIndex * 6, intent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(pendingIntent);
} else if (kind.equals(Message.TYPE_ACCOUNT)) {
Intent intent = new Intent(context, ViewMessageActivity.class);
intent.putExtra(ViewMessageActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
Intent intent = new Intent(context, InboxActivity.class);
intent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
PendingIntent summaryPendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 1, intent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(summaryPendingIntent);
} else if (kind.equals(Message.TYPE_LINK)) {
@ -162,18 +162,18 @@ public class PullNotificationWorker extends Worker {
PendingIntent pendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 2, intent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(pendingIntent);
} else if (kind.equals(Message.TYPE_MESSAGE)) {
Intent intent = new Intent(context, ViewMessageActivity.class);
intent.putExtra(ViewMessageActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
Intent intent = new Intent(context, InboxActivity.class);
intent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
PendingIntent summaryPendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 3, intent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(summaryPendingIntent);
} else if (kind.equals(Message.TYPE_SUBREDDIT)) {
Intent intent = new Intent(context, ViewMessageActivity.class);
intent.putExtra(ViewMessageActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
Intent intent = new Intent(context, InboxActivity.class);
intent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
PendingIntent summaryPendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 4, intent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(summaryPendingIntent);
} else {
Intent intent = new Intent(context, ViewMessageActivity.class);
intent.putExtra(ViewMessageActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
Intent intent = new Intent(context, InboxActivity.class);
intent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
PendingIntent summaryPendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 5, intent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(summaryPendingIntent);
}
@ -186,8 +186,8 @@ public class PullNotificationWorker extends Worker {
summaryBuilder.setStyle(inboxStyle);
Intent summaryIntent = new Intent(context, ViewMessageActivity.class);
summaryIntent.putExtra(ViewMessageActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
Intent summaryIntent = new Intent(context, InboxActivity.class);
summaryIntent.putExtra(InboxActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
PendingIntent summaryPendingIntent = PendingIntent.getActivity(context, accountIndex * 6 + 6, summaryIntent, PendingIntent.FLAG_UPDATE_CURRENT);
summaryBuilder.setContentIntent(summaryPendingIntent);

View File

@ -4,25 +4,25 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/coordinator_layout_view_message_activity"
tools:context=".Activity.ViewMessageActivity">
android:id="@+id/coordinator_layout_inbox_activity"
tools:context=".Activity.InboxActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar_layout_view_message_activity"
android:id="@+id/appbar_layout_inbox_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar_layout_view_message_activity"
android:id="@+id/collapsing_toolbar_layout_inbox_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways"
app:titleEnabled="false"
app:toolbarId="@+id/toolbar_view_message_activity">
app:toolbarId="@+id/toolbar_inbox_activity">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar_view_message_activity"
android:id="@+id/toolbar_inbox_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
@ -32,7 +32,7 @@
</com.google.android.material.appbar.CollapsingToolbarLayout>
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_layout_view_message_activity"
android:id="@+id/tab_layout_inbox_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
@ -46,7 +46,7 @@
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/view_pager_view_message_activity"
android:id="@+id/view_pager_inbox_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />

View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/coordinator_layout_view_private_messages_activity"
tools:context=".Activity.ViewPrivateMessagesActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbar_layout_view_private_messages_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar_layout_view_private_messages_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways"
app:titleEnabled="false"
app:toolbarId="@+id/toolbar_view_private_messages_activity">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar_view_private_messages_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:navigationIcon="?attr/homeAsUpIndicator" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view_view_private_messages"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_view_private_messages_activity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@drawable/ic_add_day_night_24dp"
app:tint="@android:color/white" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>

View File

@ -3,15 +3,15 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Fragment.ViewMessagesFragment">
tools:context=".Fragment.InboxFragment">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout_view_messages_fragment"
android:id="@+id/swipe_refresh_layout_inbox_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view_view_messages_fragment"
android:id="@+id/recycler_view_inbox_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false" />
@ -19,7 +19,7 @@
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
<LinearLayout
android:id="@+id/fetch_messages_info_linear_layout_view_messages_fragment"
android:id="@+id/fetch_messages_info_linear_layout_inbox_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
@ -28,12 +28,12 @@
android:visibility="gone">
<ImageView
android:id="@+id/fetch_messages_info_image_view_view_messages_fragment"
android:id="@+id/fetch_messages_info_image_view_inbox_fragment"
android:layout_width="150dp"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/fetch_messages_info_text_view_view_messages_fragment"
android:id="@+id/fetch_messages_info_text_view_inbox_fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"

View File

@ -2,7 +2,7 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_refresh_view_message_activity"
android:id="@+id/action_refresh_inbox_activity"
android:orderInCategory="1"
android:title="@string/action_refresh"
app:showAsAction="never" />