mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-07 11:17:25 +01:00
Add an EditText and a send button in ViewPrivateMessagesActivity. Rewrite the code of fetchUserAvatar in ViewPrivateMessagesActivity.
This commit is contained in:
parent
bde545b75f
commit
a00f7ced6c
@ -26,7 +26,8 @@
|
|||||||
|
|
||||||
<activity android:name=".Activity.ViewPrivateMessagesActivity"
|
<activity android:name=".Activity.ViewPrivateMessagesActivity"
|
||||||
android:parentActivityName=".Activity.MainActivity"
|
android:parentActivityName=".Activity.MainActivity"
|
||||||
android:theme="@style/AppTheme.Slidable" />
|
android:theme="@style/AppTheme.Slidable"
|
||||||
|
android:windowSoftInputMode="adjustResize" />
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".Service.DownloadRedditVideoService"
|
android:name=".Service.DownloadRedditVideoService"
|
||||||
|
@ -2,11 +2,14 @@ package ml.docilealligator.infinityforreddit.Activity;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.graphics.Color;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.Window;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
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.google.android.material.appbar.CollapsingToolbarLayout;
|
||||||
import com.r0adkll.slidr.Slidr;
|
import com.r0adkll.slidr.Slidr;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
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 ACCESS_TOKEN_STATE = "ATS";
|
||||||
private static final String ACCOUNT_NAME_STATE = "ANS";
|
private static final String ACCOUNT_NAME_STATE = "ANS";
|
||||||
private static final String USER_AVATAR_STATE = "UAS";
|
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)
|
@BindView(R.id.coordinator_layout_view_private_messages_activity)
|
||||||
CoordinatorLayout mCoordinatorLayout;
|
CoordinatorLayout mCoordinatorLayout;
|
||||||
@BindView(R.id.collapsing_toolbar_layout_view_private_messages_activity)
|
@BindView(R.id.collapsing_toolbar_layout_view_private_messages_activity)
|
||||||
@ -54,10 +61,19 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
Toolbar mToolbar;
|
Toolbar mToolbar;
|
||||||
@BindView(R.id.recycler_view_view_private_messages)
|
@BindView(R.id.recycler_view_view_private_messages)
|
||||||
RecyclerView mRecyclerView;
|
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
|
@Inject
|
||||||
@Named("oauth")
|
@Named("oauth")
|
||||||
Retrofit mOauthRetrofit;
|
Retrofit mOauthRetrofit;
|
||||||
@Inject
|
@Inject
|
||||||
|
@Named("no_oauth")
|
||||||
|
Retrofit mRetrofit;
|
||||||
|
@Inject
|
||||||
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
RedditDataRoomDatabase mRedditDataRoomDatabase;
|
||||||
@Inject
|
@Inject
|
||||||
@Named("default")
|
@Named("default")
|
||||||
@ -71,11 +87,15 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
private String mAccessToken;
|
private String mAccessToken;
|
||||||
private String mAccountName;
|
private String mAccountName;
|
||||||
private String mUserAvatar;
|
private String mUserAvatar;
|
||||||
|
private ArrayList<ProvideUserAvatarCallback> provideUserAvatarCallbacks;
|
||||||
|
private LoadUserDataAsyncTask loadUserDataAsyncTask;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||||
|
|
||||||
|
setImmersiveModeNotApplicable();
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
setContentView(R.layout.activity_view_private_messages);
|
setContentView(R.layout.activity_view_private_messages);
|
||||||
@ -88,22 +108,8 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
Slidr.attach(this);
|
Slidr.attach(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && isChangeStatusBarIconColor()) {
|
||||||
Window window = getWindow();
|
addOnOffsetChangedListener(mAppBarLayout);
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
@ -115,6 +121,8 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
setSupportActionBar(mToolbar);
|
setSupportActionBar(mToolbar);
|
||||||
setToolbarGoToTop(mToolbar);
|
setToolbarGoToTop(mToolbar);
|
||||||
|
|
||||||
|
provideUserAvatarCallbacks = new ArrayList<>();
|
||||||
|
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
|
mNullAccessToken = savedInstanceState.getBoolean(NULL_ACCESS_TOKEN_STATE);
|
||||||
mAccessToken = savedInstanceState.getString(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) {
|
public void fetchUserAvatar(String username, ProvideUserAvatarCallback provideUserAvatarCallback) {
|
||||||
if (mUserAvatar == null) {
|
if (mUserAvatar == null) {
|
||||||
new LoadUserDataAsyncTask(mRedditDataRoomDatabase.userDao(), username, mOauthRetrofit, iconImageUrl -> {
|
provideUserAvatarCallbacks.add(provideUserAvatarCallback);
|
||||||
mUserAvatar = iconImageUrl;
|
if (loadUserDataAsyncTask == null) {
|
||||||
provideUserAvatarCallback.fetchAvatarSuccess(iconImageUrl);
|
loadUserDataAsyncTask = new LoadUserDataAsyncTask(mRedditDataRoomDatabase.userDao(), username, mRetrofit, iconImageUrl -> {
|
||||||
}).execute();
|
mUserAvatar = iconImageUrl;
|
||||||
|
for (ProvideUserAvatarCallback provideUserAvatarCallbackInArrayList : provideUserAvatarCallbacks) {
|
||||||
|
provideUserAvatarCallbackInArrayList.fetchAvatarSuccess(iconImageUrl);
|
||||||
|
}
|
||||||
|
provideUserAvatarCallbacks.clear();
|
||||||
|
});
|
||||||
|
loadUserDataAsyncTask.execute();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
provideUserAvatarCallback.fetchAvatarSuccess(mUserAvatar);
|
provideUserAvatarCallback.fetchAvatarSuccess(mUserAvatar);
|
||||||
}
|
}
|
||||||
@ -196,8 +211,10 @@ public class ViewPrivateMessagesActivity extends BaseActivity implements Activit
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void applyCustomTheme() {
|
protected void applyCustomTheme() {
|
||||||
mCoordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
mLinearLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor());
|
||||||
applyAppBarLayoutAndToolbarTheme(mAppBarLayout, mToolbar);
|
applyAppBarLayoutAndToolbarTheme(mAppBarLayout, mToolbar);
|
||||||
|
mDivider.setBackgroundColor(mCustomThemeWrapper.getDividerColor());
|
||||||
|
mSendImageView.setColorFilter(Color.parseColor("#4185F4"), android.graphics.PorterDuff.Mode.SRC_IN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -5,7 +5,6 @@ import android.graphics.Color;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.text.style.SuperscriptSpan;
|
import android.text.style.SuperscriptSpan;
|
||||||
import android.text.util.Linkify;
|
import android.text.util.Linkify;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
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 -> ((MessageViewHolder) holder).itemView.performClick());
|
||||||
|
|
||||||
((MessageViewHolder) holder).messageTextView.setOnClickListener(view -> {
|
((MessageViewHolder) holder).messageTextView.setOnClickListener(view -> {
|
||||||
Log.i("asfasdf", "asdf " + ((MessageViewHolder) holder).timeTextView.getHeight());
|
|
||||||
if (((MessageViewHolder) holder).timeTextView.getVisibility() != View.VISIBLE) {
|
if (((MessageViewHolder) holder).timeTextView.getVisibility() != View.VISIBLE) {
|
||||||
((MessageViewHolder) holder).timeTextView.setVisibility(View.VISIBLE);
|
((MessageViewHolder) holder).timeTextView.setVisibility(View.VISIBLE);
|
||||||
mViewPrivateMessagesActivity.delayTransition();
|
mViewPrivateMessagesActivity.delayTransition();
|
||||||
@ -130,13 +128,6 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
|||||||
((MessageViewHolder) holder).timeTextView.setVisibility(View.GONE);
|
((MessageViewHolder) holder).timeTextView.setVisibility(View.GONE);
|
||||||
mViewPrivateMessagesActivity.delayTransition();
|
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()));
|
((MessageViewHolder) holder).timeTextView.setText(Utils.getElapsedTime(mViewPrivateMessagesActivity, message.getTimeUTC()));
|
||||||
@ -202,7 +193,6 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
|||||||
super.onViewRecycled(holder);
|
super.onViewRecycled(holder);
|
||||||
if (holder instanceof MessageViewHolder) {
|
if (holder instanceof MessageViewHolder) {
|
||||||
((MessageViewHolder) holder).messageTextView.setBackground(null);
|
((MessageViewHolder) holder).messageTextView.setBackground(null);
|
||||||
//((MessageViewHolder) holder).timeTextView.getLayoutParams().height = 0;
|
|
||||||
((MessageViewHolder) holder).timeTextView.setVisibility(View.GONE);
|
((MessageViewHolder) holder).timeTextView.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
if (holder instanceof ReceivedMessageViewHolder) {
|
if (holder instanceof ReceivedMessageViewHolder) {
|
||||||
|
@ -1,43 +1,97 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?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:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/linear_layout_view_private_messages_activity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:id="@+id/coordinator_layout_view_private_messages_activity"
|
android:orientation="vertical">
|
||||||
tools:context=".Activity.ViewPrivateMessagesActivity">
|
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
android:id="@+id/appbar_layout_view_private_messages_activity"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="0dp"
|
||||||
android:theme="@style/AppTheme.AppBarOverlay">
|
android:layout_weight="1"
|
||||||
|
android:id="@+id/coordinator_layout_view_private_messages_activity"
|
||||||
|
tools:context=".Activity.ViewPrivateMessagesActivity">
|
||||||
|
|
||||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:id="@+id/collapsing_toolbar_layout_view_private_messages_activity"
|
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_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:layout_scrollFlags="scroll|enterAlways"
|
android:clipToPadding="false"
|
||||||
app:titleEnabled="false"
|
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||||
app:toolbarId="@+id/toolbar_view_private_messages_activity">
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
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>
|
<LinearLayout
|
||||||
|
|
||||||
</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_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:clipToPadding="false"
|
android:orientation="vertical"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
android:layout_gravity="bottom">
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
<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>
|
||||||
|
|
||||||
|
</LinearLayout>
|
@ -762,6 +762,7 @@
|
|||||||
<string name="popular">Popular</string>
|
<string name="popular">Popular</string>
|
||||||
<string name="notifications">Notifications</string>
|
<string name="notifications">Notifications</string>
|
||||||
<string name="messages">Messages</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_gfycat_video_failed">Fetch Gfycat video failed</string>
|
||||||
<string name="fetch_redgifs_video_failed">Fetch Redgifs video failed</string>
|
<string name="fetch_redgifs_video_failed">Fetch Redgifs video failed</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user