diff --git a/app/build.gradle b/app/build.gradle index 37e3f6b..c597d89 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,8 +9,8 @@ android { applicationId "uk.openvk.android.refresh" minSdk 21 targetSdk 33 - versionCode 10 - versionName "0.0.10.alpha" + versionCode 11 + versionName "0.0.11.alpha" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/uk/openvk/android/refresh/api/models/Conversation.java b/app/src/main/java/uk/openvk/android/refresh/api/models/Conversation.java index 6b3aec1..d43a30e 100644 --- a/app/src/main/java/uk/openvk/android/refresh/api/models/Conversation.java +++ b/app/src/main/java/uk/openvk/android/refresh/api/models/Conversation.java @@ -3,6 +3,7 @@ import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Bitmap; +import android.util.Log; import org.droidparts.util.Strings; import org.json.JSONArray; @@ -71,24 +72,27 @@ public ArrayList parseHistory(Context ctx, String response) { startOfDay = startOfDay_calendar.getTime(); Date prev_startOfDay = null; Calendar prevStartOfDay_calendar = Calendar.getInstance(); - if (i > 0) { - prev_startOfDay = new Date(TimeUnit.SECONDS.toMillis(prevItem.getLong("date"))); - prevStartOfDay_calendar.setTime(startOfDay); + if (i > 1) { + prevStartOfDay_calendar.setTime(new Date(TimeUnit.SECONDS.toMillis(prevItem.getLong("date")))); prevStartOfDay_calendar.set(Calendar.HOUR_OF_DAY, 0); prevStartOfDay_calendar.set(Calendar.MINUTE, 0); prevStartOfDay_calendar.set(Calendar.SECOND, 0); prev_startOfDay = prevStartOfDay_calendar.getTime(); } if(prev_startOfDay != null) { + Log.d("compare", String.format("%s", startOfDay.compareTo(prev_startOfDay))); if (startOfDay.compareTo(prev_startOfDay) > 0) { - new Message(2, 0, false, false, item.getLong("date"), new SimpleDateFormat("dd MMMM yyyy").format(startOfDay), ctx); + history.add(new Message(2, 0, false, false, item.getLong("date"), new SimpleDateFormat("d MMMM yyyy").format(startOfDay), ctx)); } } else { - new Message(2, 0, false, false, item.getLong("date"), new SimpleDateFormat("dd MMMM yyyy").format(startOfDay), ctx); + history.add(new Message(2, 0, false, false, item.getLong("date"), new SimpleDateFormat("d MMMM yyyy").format(startOfDay), ctx)); } + } else { + history.add(new Message(2, 0, false, false, item.getLong("date"), new SimpleDateFormat("d MMMM yyyy").format( + new Date(TimeUnit.SECONDS.toMillis(item.getLong("date")))), ctx)); } Message message = new Message(type, item.getLong("id"), incoming, false, item.getLong("date"), item.getString("text"), ctx); - message.timestamp = new SimpleDateFormat("HH:mm").format(item.getLong("date")); + message.timestamp = new SimpleDateFormat("HH:mm").format(TimeUnit.SECONDS.toMillis(item.getLong("date"))); message.author_id = item.getLong("from_id"); prevItem = item; history.add(message); 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 335301e..7e8edc1 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 @@ -35,7 +35,6 @@ import androidx.preference.PreferenceManager; import com.bumptech.glide.Glide; -import com.google.android.material.appbar.AppBarLayout; import com.google.android.material.appbar.MaterialToolbar; import com.google.android.material.bottomnavigation.BottomNavigationView; import com.google.android.material.color.MaterialColors; @@ -112,7 +111,6 @@ public class AppActivity extends MonetCompatActivity { private MenuItem prevBottomMenuItem; private FriendsFragment friendsFragment; private String current_fragment; - private MonetCompat monet; private boolean isDarkTheme; private GroupsFragment groupsFragment; @@ -232,7 +230,8 @@ public void onNothingSelected(AdapterView parent) { }); toolbar.setTitle(""); toolbar.setNavigationOnClickListener(v -> { - if(selectedFragment == mainSettingsFragment || selectedFragment == personalizationFragment) { + if(selectedFragment == mainSettingsFragment || selectedFragment == personalizationFragment + || selectedFragment == aboutAppFragment) { onBackPressed(); } else { drawer.open(); diff --git a/app/src/main/java/uk/openvk/android/refresh/user_interface/activities/ConversationActivity.java b/app/src/main/java/uk/openvk/android/refresh/user_interface/activities/ConversationActivity.java index 7903647..d7ecd82 100644 --- a/app/src/main/java/uk/openvk/android/refresh/user_interface/activities/ConversationActivity.java +++ b/app/src/main/java/uk/openvk/android/refresh/user_interface/activities/ConversationActivity.java @@ -214,6 +214,7 @@ private void receiveState(int message, Bundle data) { conversation_adapter = new MessagesAdapter(this, history, peer_id); llm = new LinearLayoutManager(this); llm.setOrientation(LinearLayoutManager.VERTICAL); + llm.setStackFromEnd(true); messagesView.setLayoutManager(llm); messagesView.setAdapter(conversation_adapter); } else if (message == HandlerMessages.CHAT_DISABLED) { diff --git a/app/src/main/java/uk/openvk/android/refresh/user_interface/activities/NewPostActivity.java b/app/src/main/java/uk/openvk/android/refresh/user_interface/activities/NewPostActivity.java index 55e479a..1b69001 100644 --- a/app/src/main/java/uk/openvk/android/refresh/user_interface/activities/NewPostActivity.java +++ b/app/src/main/java/uk/openvk/android/refresh/user_interface/activities/NewPostActivity.java @@ -33,6 +33,7 @@ import com.kieronquinn.monetcompat.app.MonetCompatActivity; import com.kieronquinn.monetcompat.core.MonetCompat; +import java.lang.reflect.Field; import java.util.Objects; import dev.kdrag0n.monet.theme.ColorScheme; @@ -129,11 +130,21 @@ private void setMonetTheme() { Objects.requireNonNull(getMonet().getMonetColors().getAccent1().get(100)).toLinearSrgb().toSrgb().quantize8(), Global.adjustAlpha(colorOnSurface, 0.6f) }; + Objects.requireNonNull(((TextInputLayout) findViewById(R.id.status_edit_layout)).getEditText()) + .setHighlightColor( + Objects.requireNonNull(getMonet().getMonetColors().getAccent1().get(500)).toLinearSrgb().toSrgb().quantize8()); + Objects.requireNonNull(((TextInputLayout) findViewById(R.id.status_edit_layout)).getEditText()) + .setHintTextColor(new ColorStateList(states, colors)); } else { colors = new int[]{ Objects.requireNonNull(getMonet().getMonetColors().getAccent1().get(500)).toLinearSrgb().toSrgb().quantize8(), Global.adjustAlpha(colorOnSurface, 0.6f) }; + Objects.requireNonNull(((TextInputLayout) findViewById(R.id.status_edit_layout)).getEditText()) + .setHighlightColor( + Objects.requireNonNull(getMonet().getMonetColors().getAccent1().get(200)).toLinearSrgb().toSrgb().quantize8()); + Objects.requireNonNull(((TextInputLayout) findViewById(R.id.status_edit_layout)).getEditText()) + .setHintTextColor(new ColorStateList(states, colors)); } } } diff --git a/app/src/main/java/uk/openvk/android/refresh/user_interface/fragments/app/AboutApplicationFragment.java b/app/src/main/java/uk/openvk/android/refresh/user_interface/fragments/app/AboutApplicationFragment.java index 0a6e57d..878720d 100644 --- a/app/src/main/java/uk/openvk/android/refresh/user_interface/fragments/app/AboutApplicationFragment.java +++ b/app/src/main/java/uk/openvk/android/refresh/user_interface/fragments/app/AboutApplicationFragment.java @@ -17,10 +17,13 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.fragment.app.Fragment; import androidx.preference.PreferenceManager; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import com.google.android.material.imageview.ShapeableImageView; import com.kieronquinn.monetcompat.core.MonetCompat; +import java.util.Objects; + import uk.openvk.android.refresh.BuildConfig; import uk.openvk.android.refresh.Global; import uk.openvk.android.refresh.R; @@ -40,7 +43,11 @@ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup c if(Global.checkMonet(requireContext())) { MonetCompat monet = MonetCompat.getInstance(); boolean isDarkTheme = PreferenceManager.getDefaultSharedPreferences(requireContext()).getBoolean("dark_theme", false); - ((Button) view.findViewById(R.id.source_code_btn)).setTextColor(ColorStateList.valueOf(monet.getAccentColor(requireContext(), isDarkTheme))); + if(isDarkTheme) { + ((Button) view.findViewById(R.id.source_code_btn)).setTextColor(ColorStateList.valueOf(Objects.requireNonNull(monet.getMonetColors().getAccent1().get(100)).toLinearSrgb().toSrgb().quantize8())); + } else { + ((Button) view.findViewById(R.id.source_code_btn)).setTextColor(ColorStateList.valueOf(Objects.requireNonNull(monet.getMonetColors().getAccent1().get(500)).toLinearSrgb().toSrgb().quantize8())); + } } ((Button) view.findViewById(R.id.source_code_btn)).setOnClickListener(new View.OnClickListener() { @Override 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 98cc0a5..2b50f94 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 @@ -133,6 +133,7 @@ void bind(final int position) { } } } else { + msg_text.setTypeface(Global.getFlexibleTypeface(ctx, 500)); msg_text.setText(item.text); } } diff --git a/app/src/main/res/layout-night/conversation.xml b/app/src/main/res/layout-night/conversation.xml index f3c971e..3a10139 100644 --- a/app/src/main/res/layout-night/conversation.xml +++ b/app/src/main/res/layout-night/conversation.xml @@ -13,7 +13,7 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/app_bar" - app:reverseLayout="true"> + app:stackFromEnd="true"> diff --git a/app/src/main/res/layout/conversation.xml b/app/src/main/res/layout/conversation.xml index 3e2c85d..34dc446 100644 --- a/app/src/main/res/layout/conversation.xml +++ b/app/src/main/res/layout/conversation.xml @@ -13,7 +13,7 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/app_toolbar" - app:reverseLayout="true"> + app:stackFromEnd="true">