aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/AndroidManifest.xml3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPrivateMessagesActivity.java63
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PrivateMessagesDetailRecyclerViewAdapter.java10
-rw-r--r--app/src/main/res/layout/activity_view_private_messages.xml108
-rw-r--r--app/src/main/res/values/strings.xml1
5 files changed, 124 insertions, 61 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index d1ff8e5d..a5f7d9c7 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -26,7 +26,8 @@
<activity android:name=".Activity.ViewPrivateMessagesActivity"
android:parentActivityName=".Activity.MainActivity"
- android:theme="@style/AppTheme.Slidable" />
+ android:theme="@style/AppTheme.Slidable"
+ android:windowSoftInputMode="adjustResize" />
<service
android:name=".Service.DownloadRedditVideoService"
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPrivateMessagesActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPrivateMessagesActivity.java
index c5a78e1a..14538c70 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPrivateMessagesActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPrivateMessagesActivity.java
@@ -2,11 +2,14 @@ package ml.docilealligator.infinityforreddit.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.MenuItem;
-import android.view.Window;
-import android.view.WindowManager;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
import androidx.annotation.NonNull;
import androidx.appcompat.widget.Toolbar;
@@ -20,6 +23,8 @@ import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.appbar.CollapsingToolbarLayout;
import com.r0adkll.slidr.Slidr;
+import java.util.ArrayList;
+
import javax.inject.Inject;
import javax.inject.Named;
@@ -44,6 +49,8 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
private static final String ACCESS_TOKEN_STATE = "ATS";
private static final String ACCOUNT_NAME_STATE = "ANS";
private static final String USER_AVATAR_STATE = "UAS";
+ @BindView(R.id.linear_layout_view_private_messages_activity)
+ LinearLayout mLinearLayout;
@BindView(R.id.coordinator_layout_view_private_messages_activity)
CoordinatorLayout mCoordinatorLayout;
@BindView(R.id.collapsing_toolbar_layout_view_private_messages_activity)
@@ -54,10 +61,19 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
Toolbar mToolbar;
@BindView(R.id.recycler_view_view_private_messages)
RecyclerView mRecyclerView;
+ @BindView(R.id.edit_text_divider_view_private_messages_activity)
+ View mDivider;
+ @BindView(R.id.edit_text_view_private_messages_activity)
+ EditText mEditText;
+ @BindView(R.id.send_image_view_view_private_messages_activity)
+ ImageView mSendImageView;
@Inject
@Named("oauth")
Retrofit mOauthRetrofit;
@Inject
+ @Named("no_oauth")
+ Retrofit mRetrofit;
+ @Inject
RedditDataRoomDatabase mRedditDataRoomDatabase;
@Inject
@Named("default")
@@ -71,11 +87,15 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
private String mAccessToken;
private String mAccountName;
private String mUserAvatar;
+ private ArrayList<ProvideUserAvatarCallback> provideUserAvatarCallbacks;
+ private LoadUserDataAsyncTask loadUserDataAsyncTask;
@Override
protected void onCreate(Bundle savedInstanceState) {
((Infinity) getApplication()).getAppComponent().inject(this);
+ setImmersiveModeNotApplicable();
+
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_private_messages);
@@ -88,22 +108,8 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
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) {
- mRecyclerView.setPadding(0, 0, 0, navBarHeight);
- }
- }
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
+ addOnOffsetChangedListener(mAppBarLayout);
}
Intent intent = getIntent();
@@ -115,6 +121,8 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
setSupportActionBar(mToolbar);
setToolbarGoToTop(mToolbar);
+ provideUserAvatarCallbacks = new ArrayList<>();
+
if (savedInstanceState != null) {
mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
mAccessToken = savedInstanceState.getString(ACCESS_TOKEN_STATE);
@@ -152,10 +160,17 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
public void fetchUserAvatar(String username, ProvideUserAvatarCallback provideUserAvatarCallback) {
if (mUserAvatar == null) {
- new LoadUserDataAsyncTask(mRedditDataRoomDatabase.userDao(), username, mOauthRetrofit, iconImageUrl -> {
- mUserAvatar = iconImageUrl;
- provideUserAvatarCallback.fetchAvatarSuccess(iconImageUrl);
- }).execute();
+ provideUserAvatarCallbacks.add(provideUserAvatarCallback);
+ if (loadUserDataAsyncTask == null) {
+ loadUserDataAsyncTask = new LoadUserDataAsyncTask(mRedditDataRoomDatabase.userDao(), username, mRetrofit, iconImageUrl -> {
+ mUserAvatar = iconImageUrl;
+ for (ProvideUserAvatarCallback provideUserAvatarCallbackInArrayList : provideUserAvatarCallbacks) {
+ provideUserAvatarCallbackInArrayList.fetchAvatarSuccess(iconImageUrl);
+ }
+ provideUserAvatarCallbacks.clear();
+ });
+ loadUserDataAsyncTask.execute();
+ }
} else {
provideUserAvatarCallback.fetchAvatarSuccess(mUserAvatar);
}
@@ -196,8 +211,10 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
@Override
protected void applyCustomTheme() {
- mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
+ mLinearLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
applyAppBarLayoutAndToolbarTheme(mAppBarLayout, mToolbar);
+ mDivider.setBackgroundColor(mCustomThemeWrapper.getDividerColor());
+ mSendImageView.setColorFilter(Color.parseColor("#4185F4"), android.graphics.PorterDuff.Mode.SRC_IN);
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PrivateMessagesDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PrivateMessagesDetailRecyclerViewAdapter.java
index 270d89ac..4b17a966 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PrivateMessagesDetailRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PrivateMessagesDetailRecyclerViewAdapter.java
@@ -5,7 +5,6 @@ import android.graphics.Color;
import android.net.Uri;
import android.text.style.SuperscriptSpan;
import android.text.util.Linkify;
-import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -122,7 +121,6 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
((MessageViewHolder) holder).messageTextView.setOnClickListener(view -> ((MessageViewHolder) holder).itemView.performClick());
((MessageViewHolder) holder).messageTextView.setOnClickListener(view -> {
- Log.i("asfasdf", "asdf " + ((MessageViewHolder) holder).timeTextView.getHeight());
if (((MessageViewHolder) holder).timeTextView.getVisibility() != View.VISIBLE) {
((MessageViewHolder) holder).timeTextView.setVisibility(View.VISIBLE);
mViewPrivateMessagesActivity.delayTransition();
@@ -130,13 +128,6 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
((MessageViewHolder) holder).timeTextView.setVisibility(View.GONE);
mViewPrivateMessagesActivity.delayTransition();
}
- /*if (((MessageViewHolder) holder).timeTextView.getHeight() == 0) {
- ((MessageViewHolder) holder).timeTextView.getLayoutParams().height = ConstraintLayout.LayoutParams.WRAP_CONTENT;
- mViewPrivateMessagesActivity.delayTransition();
- } else {
- mViewPrivateMessagesActivity.delayTransition();
- ((MessageViewHolder) holder).timeTextView.getLayoutParams().height = 0;
- }*/
});
((MessageViewHolder) holder).timeTextView.setText(Utils.getElapsedTime(mViewPrivateMessagesActivity, message.getTimeUTC()));
@@ -202,7 +193,6 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
super.onViewRecycled(holder);
if (holder instanceof MessageViewHolder) {
((MessageViewHolder) holder).messageTextView.setBackground(null);
- //((MessageViewHolder) holder).timeTextView.getLayoutParams().height = 0;
((MessageViewHolder) holder).timeTextView.setVisibility(View.GONE);
}
if (holder instanceof ReceivedMessageViewHolder) {
diff --git a/app/src/main/res/layout/activity_view_private_messages.xml b/app/src/main/res/layout/activity_view_private_messages.xml
index 3819bc4d..b808ede7 100644
--- a/app/src/main/res/layout/activity_view_private_messages.xml
+++ b/app/src/main/res/layout/activity_view_private_messages.xml
@@ -1,43 +1,97 @@
<?xml version="1.0" encoding="utf-8"?>
-<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout 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:id="@+id/linear_layout_view_private_messages_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:id="@+id/coordinator_layout_view_private_messages_activity"
- tools:context=".Activity.ViewPrivateMessagesActivity">
+ android:orientation="vertical">
- <com.google.android.material.appbar.AppBarLayout
- android:id="@+id/appbar_layout_view_private_messages_activity"
+ <androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:theme="@style/AppTheme.AppBarOverlay">
+ android:layout_height="0dp"
+ android:layout_weight="1"
+ android:id="@+id/coordinator_layout_view_private_messages_activity"
+ tools:context=".Activity.ViewPrivateMessagesActivity">
- <com.google.android.material.appbar.CollapsingToolbarLayout
- android:id="@+id/collapsing_toolbar_layout_view_private_messages_activity"
+ <com.google.android.material.appbar.AppBarLayout
+ android:id="@+id/appbar_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">
+ android:layout_height="wrap_content"
+ android:theme="@style/AppTheme.AppBarOverlay">
- <androidx.appcompat.widget.Toolbar
- android:id="@+id/toolbar_view_private_messages_activity"
+ <com.google.android.material.appbar.CollapsingToolbarLayout
+ android:id="@+id/collapsing_toolbar_layout_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" />
+ android:layout_height="match_parent"
+ app:layout_scrollFlags="scroll|enterAlways"
+ app:titleEnabled="false"
+ app:toolbarId="@+id/toolbar_view_private_messages_activity">
- </com.google.android.material.appbar.CollapsingToolbarLayout>
+ <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.AppBarLayout>
+ </com.google.android.material.appbar.CollapsingToolbarLayout>
- <androidx.recyclerview.widget.RecyclerView
- android:id="@+id/recycler_view_view_private_messages"
+ </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" />
+
+ </androidx.coordinatorlayout.widget.CoordinatorLayout>
+
+ <LinearLayout
android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:clipToPadding="false"
- app:layout_behavior="@string/appbar_scrolling_view_behavior" />
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:layout_gravity="bottom">
+
+ <View
+ android:id="@+id/edit_text_divider_view_private_messages_activity"
+ android:layout_width="match_parent"
+ android:layout_height="1dp" />
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+
+ <EditText
+ android:id="@+id/edit_text_view_private_messages_activity"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:padding="16dp"
+ android:hint="@string/message"
+ android:inputType="textMultiLine"
+ android:textSize="?attr/font_default"
+ android:background="#00000000"
+ android:textColor="?attr/primaryTextColor"
+ android:fontFamily="?attr/font_family"
+ android:maxLines="3" />
+
+ <ImageView
+ android:id="@+id/send_image_view_view_private_messages_activity"
+ android:layout_width="56dp"
+ android:layout_height="56dp"
+ android:layout_gravity="center_vertical"
+ android:scaleType="center"
+ android:src="@drawable/ic_send_black_24dp"
+ android:clickable="true"
+ android:focusable="true"
+ android:background="?attr/selectableItemBackgroundBorderless" />
+
+ </LinearLayout>
+
+ </LinearLayout>
-</androidx.coordinatorlayout.widget.CoordinatorLayout> \ No newline at end of file
+</LinearLayout> \ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 18faf6b8..020528fd 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -762,6 +762,7 @@
<string name="popular">Popular</string>
<string name="notifications">Notifications</string>
<string name="messages">Messages</string>
+ <string name="message">Message</string>
<string name="fetch_gfycat_video_failed">Fetch Gfycat video failed</string>
<string name="fetch_redgifs_video_failed">Fetch Redgifs video failed</string>