diff --git a/app/src/main/java/uk/openvk/android/refresh/user_interface/activities/AppActivity.java b/app/src/main/java/uk/openvk/android/refresh/user_interface/activities/AppActivity.java
index fec3294..335301e 100644
--- a/app/src/main/java/uk/openvk/android/refresh/user_interface/activities/AppActivity.java
+++ b/app/src/main/java/uk/openvk/android/refresh/user_interface/activities/AppActivity.java
@@ -341,57 +341,61 @@ public void onClick(View v) {
}
private void setMonetTheme() {
- if(Global.checkMonet(this)) {
- MaterialToolbar toolbar = findViewById(R.id.app_toolbar);
- if(!isDarkTheme) {
- toolbar.setBackgroundColor(Objects.requireNonNull(getMonet().getMonetColors().getAccent1().get(600)).toLinearSrgb().toSrgb().quantize8());
- drawer.setStatusBarBackgroundColor(Objects.requireNonNull(getMonet().getMonetColors().getAccent1().get(700)).toLinearSrgb().toSrgb().quantize8());
- }
- int colorOnSurface = MaterialColors.getColor(this, com.google.android.material.R.attr.colorOnSurface, Color.BLACK);
- NavigationView navView = findViewById(R.id.nav_view);
- int[][] states = new int[][] {
- new int[] { android.R.attr.state_checked}, new int[] { }
- };
- int[] colors;
- if(isDarkTheme) {
- colors = new int[]{
- Objects.requireNonNull(getMonet().getMonetColors().getAccent1().get(100)).toLinearSrgb().toSrgb().quantize8(),
- Global.adjustAlpha(colorOnSurface, 0.6f)
- };
- } else {
- colors = new int[]{
- Objects.requireNonNull(getMonet().getMonetColors().getAccent1().get(500)).toLinearSrgb().toSrgb().quantize8(),
- Global.adjustAlpha(colorOnSurface, 0.6f)
- };
- }
- ColorStateList csl = new ColorStateList(states, colors);
- navView.setItemIconTintList(csl);
- navView.setItemTextColor(csl);
-
- BottomNavigationView b_navView = findViewById(R.id.bottom_nav_view);
- if(isDarkTheme) {
- colors = new int[]{
- Objects.requireNonNull(getMonet().getMonetColors().getAccent1().get(100)).toLinearSrgb().toSrgb().quantize8(),
- Global.adjustAlpha(colorOnSurface, 0.6f)
- };
- } else {
- colors = new int[]{
- Objects.requireNonNull(getMonet().getMonetColors().getAccent1().get(500)).toLinearSrgb().toSrgb().quantize8(),
- Global.adjustAlpha(colorOnSurface, 0.6f)
+ try {
+ if (Global.checkMonet(this)) {
+ MaterialToolbar toolbar = findViewById(R.id.app_toolbar);
+ if (!isDarkTheme) {
+ toolbar.setBackgroundColor(Objects.requireNonNull(getMonet().getMonetColors().getAccent1().get(600)).toLinearSrgb().toSrgb().quantize8());
+ drawer.setStatusBarBackgroundColor(Objects.requireNonNull(getMonet().getMonetColors().getAccent1().get(700)).toLinearSrgb().toSrgb().quantize8());
+ }
+ int colorOnSurface = MaterialColors.getColor(this, com.google.android.material.R.attr.colorOnSurface, Color.BLACK);
+ NavigationView navView = findViewById(R.id.nav_view);
+ int[][] states = new int[][]{
+ new int[]{android.R.attr.state_checked}, new int[]{}
};
+ int[] colors;
+ if (isDarkTheme) {
+ colors = new int[]{
+ Objects.requireNonNull(getMonet().getMonetColors().getAccent1().get(100)).toLinearSrgb().toSrgb().quantize8(),
+ Global.adjustAlpha(colorOnSurface, 0.6f)
+ };
+ } else {
+ colors = new int[]{
+ Objects.requireNonNull(getMonet().getMonetColors().getAccent1().get(500)).toLinearSrgb().toSrgb().quantize8(),
+ Global.adjustAlpha(colorOnSurface, 0.6f)
+ };
+ }
+ ColorStateList csl = new ColorStateList(states, colors);
+ navView.setItemIconTintList(csl);
+ navView.setItemTextColor(csl);
+
+ BottomNavigationView b_navView = findViewById(R.id.bottom_nav_view);
+ if (isDarkTheme) {
+ colors = new int[]{
+ Objects.requireNonNull(getMonet().getMonetColors().getAccent1().get(100)).toLinearSrgb().toSrgb().quantize8(),
+ Global.adjustAlpha(colorOnSurface, 0.6f)
+ };
+ } else {
+ colors = new int[]{
+ Objects.requireNonNull(getMonet().getMonetColors().getAccent1().get(500)).toLinearSrgb().toSrgb().quantize8(),
+ Global.adjustAlpha(colorOnSurface, 0.6f)
+ };
+ }
+ csl = new ColorStateList(states, colors);
+ b_navView.setItemTextColor(csl);
+ b_navView.setItemIconTintList(csl);
+ b_navView.setItemRippleColor(ColorStateList.valueOf(getMonet().getPrimaryColor(this, isDarkTheme)));
+ FloatingActionButton fab = findViewById(R.id.fab_newpost);
+ if (isDarkTheme) {
+ fab.setBackgroundTintList(ColorStateList.valueOf(Objects.requireNonNull(getMonet().getMonetColors().getAccent1().get(600)).toLinearSrgb().toSrgb().quantize8()));
+ } else {
+ fab.setBackgroundTintList(ColorStateList.valueOf(Objects.requireNonNull(getMonet().getMonetColors().getAccent1().get(100)).toLinearSrgb().toSrgb().quantize8()));
+ }
+ fab.setImageTintList(ColorStateList.valueOf(getMonet().getAccentColor(this, isDarkTheme)));
+ fab.setRippleColor(ColorStateList.valueOf(getMonet().getPrimaryColor(this, isDarkTheme)));
}
- csl = new ColorStateList(states, colors);
- b_navView.setItemTextColor(csl);
- b_navView.setItemIconTintList(csl);
- b_navView.setItemRippleColor(ColorStateList.valueOf(getMonet().getPrimaryColor(this, isDarkTheme)));
- FloatingActionButton fab = findViewById(R.id.fab_newpost);
- if(isDarkTheme) {
- fab.setBackgroundTintList(ColorStateList.valueOf(Objects.requireNonNull(getMonet().getMonetColors().getAccent1().get(600)).toLinearSrgb().toSrgb().quantize8()));
- } else {
- fab.setBackgroundTintList(ColorStateList.valueOf(Objects.requireNonNull(getMonet().getMonetColors().getAccent1().get(100)).toLinearSrgb().toSrgb().quantize8()));
- }
- fab.setImageTintList(ColorStateList.valueOf(getMonet().getAccentColor(this, isDarkTheme)));
- fab.setRippleColor(ColorStateList.valueOf(getMonet().getPrimaryColor(this, isDarkTheme)));
+ } catch (Exception ex) {
+ ex.printStackTrace();
}
}
@@ -867,8 +871,12 @@ public void recreate() {
@Override
public void onMonetColorsChanged(@NonNull MonetCompat monet, @NonNull ColorScheme monetColors, boolean isInitialChange) {
- super.onMonetColorsChanged(monet, monetColors, isInitialChange);
- getMonet().updateMonetColors();
- setMonetTheme();
+ try {
+ super.onMonetColorsChanged(monet, monetColors, isInitialChange);
+ getMonet().updateMonetColors();
+ setMonetTheme();
+ } catch (Exception ex){
+ ex.printStackTrace();
+ }
}
}
diff --git a/app/src/main/java/uk/openvk/android/refresh/user_interface/activities/GroupIntentActivity.java b/app/src/main/java/uk/openvk/android/refresh/user_interface/activities/GroupIntentActivity.java
index d49cefb..b39b6ea 100644
--- a/app/src/main/java/uk/openvk/android/refresh/user_interface/activities/GroupIntentActivity.java
+++ b/app/src/main/java/uk/openvk/android/refresh/user_interface/activities/GroupIntentActivity.java
@@ -76,6 +76,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
setAPIWrapper();
createFragments();
setAppBar();
+ setMonetTheme();
} catch (Exception ex) {
ex.printStackTrace();
}
diff --git a/app/src/main/java/uk/openvk/android/refresh/user_interface/layouts/TightTextView.java b/app/src/main/java/uk/openvk/android/refresh/user_interface/layouts/TightTextView.java
new file mode 100644
index 0000000..fd54d3e
--- /dev/null
+++ b/app/src/main/java/uk/openvk/android/refresh/user_interface/layouts/TightTextView.java
@@ -0,0 +1,47 @@
+package uk.openvk.android.refresh.user_interface.layouts;
+
+import android.content.Context;
+import android.text.Layout;
+import android.util.AttributeSet;
+
+public class TightTextView extends androidx.appcompat.widget.AppCompatTextView {
+ public TightTextView(Context context) {
+ super(context);
+ }
+
+ public TightTextView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public TightTextView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+ int specModeW = MeasureSpec.getMode(widthMeasureSpec);
+ if (specModeW != MeasureSpec.EXACTLY) {
+ Layout layout = getLayout();
+ if (layout != null) {
+ int w = (int) Math.ceil(getMaxLineWidth(layout)) + getCompoundPaddingLeft() + getCompoundPaddingRight();
+ if (w < getMeasuredWidth()) {
+ super.onMeasure(MeasureSpec.makeMeasureSpec(w, MeasureSpec.AT_MOST),
+ heightMeasureSpec);
+ }
+ }
+ }
+ }
+
+ private float getMaxLineWidth(Layout layout) {
+ float max_width = 0.0f;
+ int lines = layout.getLineCount();
+ for (int i = 0; i < lines; i++) {
+ if (layout.getLineWidth(i) > max_width) {
+ max_width = layout.getLineWidth(i);
+ }
+ }
+ return max_width;
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/uk/openvk/android/refresh/user_interface/list_adapters/DialogSingleChoiceAdapter.java b/app/src/main/java/uk/openvk/android/refresh/user_interface/list_adapters/DialogSingleChoiceAdapter.java
index 8007570..621d222 100644
--- a/app/src/main/java/uk/openvk/android/refresh/user_interface/list_adapters/DialogSingleChoiceAdapter.java
+++ b/app/src/main/java/uk/openvk/android/refresh/user_interface/list_adapters/DialogSingleChoiceAdapter.java
@@ -104,6 +104,7 @@ public void onClick(View v) {
if(frg != null) {
if(dlgBuilder != null) {
dlgBuilder.clearCheck(checkedItem);
+ checkedItem = position;
checkedTv.setChecked(true);
}
((PersonalizationFragment) frg).onMenuItemClicked(list, position);
diff --git a/app/src/main/java/uk/openvk/android/refresh/user_interface/list_adapters/MessagesAdapter.java b/app/src/main/java/uk/openvk/android/refresh/user_interface/list_adapters/MessagesAdapter.java
index 691ff3a..98cc0a5 100644
--- a/app/src/main/java/uk/openvk/android/refresh/user_interface/list_adapters/MessagesAdapter.java
+++ b/app/src/main/java/uk/openvk/android/refresh/user_interface/list_adapters/MessagesAdapter.java
@@ -2,18 +2,27 @@
import android.annotation.SuppressLint;
import android.content.Context;
+import android.content.res.ColorStateList;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
+import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.annotation.NonNull;
+import androidx.cardview.widget.CardView;
+import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.RecyclerView;
+import com.google.android.material.card.MaterialCardView;
+import com.google.android.material.color.MaterialColors;
+import com.kieronquinn.monetcompat.core.MonetCompat;
+
import java.util.ArrayList;
+import java.util.Objects;
import uk.openvk.android.refresh.Global;
import uk.openvk.android.refresh.R;
@@ -54,20 +63,36 @@ public int getItemCount() {
public class Holder extends RecyclerView.ViewHolder {
private final View convertView;
private final TextView msg_text;
+ private final TextView msg_text_2;
private final TextView msg_timestamp;
+ private final TextView msg_timestamp_2;
+ private final LinearLayout horizontal_layout;
+ private final LinearLayout vertical_layout;
public Holder(View view) {
super(view);
this.convertView = view;
+ this.horizontal_layout = (LinearLayout) view.findViewById(R.id.text_layout_horizontal);
+ this.vertical_layout = (LinearLayout) view.findViewById(R.id.text_layout_vertical);
this.msg_text = (TextView) view.findViewById(R.id.msg_text);
this.msg_timestamp = (TextView) view.findViewById(R.id.timestamp);
+ this.msg_text_2 = (TextView) view.findViewById(R.id.msg_text_2);
+ this.msg_timestamp_2 = (TextView) view.findViewById(R.id.timestamp_vertical);
}
@SuppressLint({"SimpleDateFormat", "UseCompatLoadingForDrawables"})
void bind(final int position) {
final Message item = getItem(position);
if(item.type < 2) {
- msg_text.setText(item.text);
+ if(item.text.length() < 20) {
+ vertical_layout.setVisibility(View.GONE);
+ horizontal_layout.setVisibility(View.VISIBLE);
+ msg_text.setText(item.text);
+ } else {
+ vertical_layout.setVisibility(View.VISIBLE);
+ horizontal_layout.setVisibility(View.GONE);
+ msg_text_2.setText(item.text);
+ }
msg_timestamp.setText(item.timestamp);
if(item.type == 1) {
if(item.isError) {
@@ -89,6 +114,24 @@ void bind(final int position) {
.centerCrop()
.into((ImageView) convertView.findViewById(R.id.companion_avatar));
}
+ CardView cardView;
+ boolean isDarkTheme = PreferenceManager.getDefaultSharedPreferences(ctx).getBoolean("dark_theme", false);
+ if(item.type == 0) {
+ cardView = ((CardView) convertView.findViewById(R.id.incoming_msg_layout));
+ if (Global.checkMonet(ctx)) {
+ MonetCompat monet = MonetCompat.getInstance();
+ cardView.setCardBackgroundColor(
+ Objects.requireNonNull(monet.getMonetColors().getAccent1().get(500)).toLinearSrgb().toSrgb().quantize8());
+ } else {
+ if (isDarkTheme) {
+ cardView.setCardBackgroundColor(
+ MaterialColors.getColor(convertView, androidx.appcompat.R.attr.colorPrimaryDark));
+ } else {
+ cardView.setCardBackgroundColor(
+ MaterialColors.getColor(convertView, androidx.appcompat.R.attr.colorAccent));
+ }
+ }
+ }
} else {
msg_text.setText(item.text);
}
diff --git a/app/src/main/res/layout-night/incoming_msg.xml b/app/src/main/res/layout-night/incoming_msg.xml
index 247d139..d537d43 100644
--- a/app/src/main/res/layout-night/incoming_msg.xml
+++ b/app/src/main/res/layout-night/incoming_msg.xml
@@ -31,24 +31,26 @@
app:layout_constraintTop_toTopOf="parent">
+ android:paddingBottom="4dp"
+ android:visibility="gone">
-
+ android:textSize="16sp"
+ android:maxWidth="220dp"
+ tools:ignore="HardcodedText" />
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout-night/outcoming_msg.xml b/app/src/main/res/layout-night/outcoming_msg.xml
index a28c097..13646c7 100644
--- a/app/src/main/res/layout-night/outcoming_msg.xml
+++ b/app/src/main/res/layout-night/outcoming_msg.xml
@@ -18,24 +18,26 @@
app:layout_constraintTop_toTopOf="parent">
+ android:paddingBottom="4dp"
+ android:visibility="gone">
-
+ android:maxWidth="220dp"
+ android:text="Incoming message text example"
+ android:textColor="@android:color/white"
+ android:textSize="16sp"
+ tools:ignore="HardcodedText" />
+ android:textColor="#8fffffff"
+ android:textSize="10sp" />
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/incoming_msg.xml b/app/src/main/res/layout/incoming_msg.xml
index 997ff6f..b50561d 100644
--- a/app/src/main/res/layout/incoming_msg.xml
+++ b/app/src/main/res/layout/incoming_msg.xml
@@ -7,8 +7,8 @@
+ android:paddingBottom="4dp"
+ android:visibility="gone">
-
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/outcoming_msg.xml b/app/src/main/res/layout/outcoming_msg.xml
index 38e795c..da76d31 100644
--- a/app/src/main/res/layout/outcoming_msg.xml
+++ b/app/src/main/res/layout/outcoming_msg.xml
@@ -18,24 +18,26 @@
app:layout_constraintTop_toTopOf="parent">
+ android:paddingBottom="4dp"
+ android:visibility="gone">
-
+ android:maxWidth="220dp"
+ android:text="Incoming message text example"
+ android:textColor="@android:color/black"
+ android:textSize="16sp"
+ tools:ignore="HardcodedText" />
+ android:textColor="#8f000000"
+ android:textSize="10sp" />
+
+
+
+
+
+
+