Skip to content

Commit

Permalink
Build 11 - Messages design improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
tretdm committed Feb 7, 2023
1 parent ef2a4f9 commit 39ba4c5
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 14 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -71,24 +72,27 @@ public ArrayList<Message> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ void bind(final int position) {
}
}
} else {
msg_text.setTypeface(Global.getFlexibleTypeface(ctx, 500));
msg_text.setText(item.text);
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout-night/conversation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

</androidx.recyclerview.widget.RecyclerView>

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/conversation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">

</androidx.recyclerview.widget.RecyclerView>

Expand Down

0 comments on commit 39ba4c5

Please sign in to comment.