Skip to content

Commit

Permalink
Merge branch 'r4.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
Chumva committed Aug 16, 2023
2 parents bb87f30 + 29cf727 commit 8dfec87
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,18 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:background="?attr/list_background_color"
android:orientation="vertical">

<net.osmand.plus.widgets.TextViewEx
android:id="@+id/description"
android:id="@+id/title"
style="@style/TitleStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/content_padding"
android:layout_marginVertical="@dimen/content_padding_small"
android:text="@string/telegram_chats_descr"
android:textColor="?android:textColorSecondary" />

<ListView
android:id="@+id/list_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:divider="@null"
android:paddingBottom="@dimen/bottom_sheet_list_item_height"
tools:listitem="@layout/help_list_item" />
android:textColor="?android:textColorSecondary"
tools:text="@string/telegram_chats_descr" />

</LinearLayout>
2 changes: 1 addition & 1 deletion OsmAnd/src/net/osmand/plus/help/HelpArticleUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static String getTelegramChatName(@NonNull OsmandApplication app, @NonNul
int endIndex = key.indexOf(")");

if (startIndex != -1 && endIndex != -1 && endIndex > startIndex) {
String langKey = key.substring(startIndex, endIndex);
String langKey = key.substring(startIndex + 1, endIndex);
String value = AndroidUtils.getStringByProperty(app, "lang_" + langKey);
if (!Algorithms.isEmpty(value)) {
String telegram = app.getString(R.string.telegram);
Expand Down
43 changes: 41 additions & 2 deletions OsmAnd/src/net/osmand/plus/help/TelegramChatsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
Expand All @@ -12,6 +15,7 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;

Expand Down Expand Up @@ -40,6 +44,7 @@ public class TelegramChatsFragment extends BaseOsmAndFragment implements OnItemC
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);

Bundle arg = getArguments();
if (arg != null && arg.containsKey(TELEGRAM_CHATS)) {
Expand All @@ -51,9 +56,14 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
updateNightMode();
View view = themedInflater.inflate(R.layout.telegram_chats_fragment, container, false);
View view = themedInflater.inflate(R.layout.help_articles_fragment, container, false);

ContextMenuAdapter menuAdapter = new ContextMenuAdapter(app);

menuAdapter.addItem(new ContextMenuItem(null)
.setTitle(getString(R.string.telegram_chats_descr))
.setLayout(R.layout.description_article_item));

if (!Algorithms.isEmpty(telegramChats)) {
for (Map.Entry<String, String> entry : telegramChats.entrySet()) {
String key = entry.getKey();
Expand Down Expand Up @@ -89,6 +99,35 @@ private ContextMenuItem createSocialItem(@NonNull String key, @NonNull String ur
});
}

@Override
public void onResume() {
super.onResume();

HelpActivity activity = (HelpActivity) requireActivity();
ActionBar actionBar = activity.getSupportActionBar();
if (actionBar != null) {
actionBar.setTitle(getString(R.string.telegram_chats));
}
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == android.R.id.home) {
FragmentActivity activity = getActivity();
if (activity != null) {
activity.onBackPressed();
}
return true;
}
return super.onOptionsItemSelected(item);
}

@Override
public void onCreateOptionsMenu(Menu menu, @NonNull MenuInflater inflater) {
menu.clear();
}

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
ContextMenuItem item = adapter.getItem(position);
Expand All @@ -107,7 +146,7 @@ public static void showInstance(@NonNull FragmentManager manager, @NonNull Linke
fragment.setArguments(bundle);
manager.beginTransaction()
.addToBackStack(null)
.add(R.id.fragmentContainer, fragment, TAG)
.replace(R.id.fragmentContainer, fragment, TAG)
.commitAllowingStateLoss();
}
}
Expand Down

0 comments on commit 8dfec87

Please sign in to comment.