From 9fb3be4196b3d19c7cd941661cadf13fb995abcf Mon Sep 17 00:00:00 2001 From: talhaasif2023 Date: Thu, 18 Jul 2024 18:06:59 +0500 Subject: [PATCH 1/7] working ------ --- .../ui/activities/AboutActivity.java | 4 +- app/src/main/res/layout/activity_about.xml | 162 ++++++++++++++++-- 2 files changed, 151 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java b/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java index e74c7f46e9..878e9f9e9e 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java +++ b/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java @@ -233,11 +233,11 @@ public void onClick(View v) { } break; - case R.id.relative_layout_changelog: + case R.id.click_layout_changelog: openURL(URL_REPO_CHANGELOG, this); break; - case R.id.relative_layout_licenses: + case R.id.click_layout_licenses: LibsBuilder libsBuilder = new LibsBuilder() .withLibraries("apachemina") // Not auto-detected for some reason diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index eb593f9e3e..ae536f84fd 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -2,6 +2,7 @@ @@ -73,7 +74,113 @@ app:cardElevation="@dimen/material_generic_card_elevation" > - + + + + + + + + + + + + + + + + + + + + + + - - + –> - - - + –> - + <!– licenses –> - + --> @@ -203,6 +310,37 @@ app:cardElevation="@dimen/material_generic_card_elevation" > + + + + + + + + - - + --> - - Date: Fri, 19 Jul 2024 12:14:05 +0500 Subject: [PATCH 2/7] activity_about.xml overdraw issue fixed --- .../filemanager/adapters/LanguageAdapter.java | 52 + .../filemanager/models/LanguageModel.java | 28 + .../ui/activities/AboutActivity.java | 19 + .../amaze/filemanager/utils/DataUtils.java | 51 + app/src/main/res/layout/activity_about.xml | 1967 ++++++----------- app/src/main/res/layout/language_item.xml | 33 + 6 files changed, 819 insertions(+), 1331 deletions(-) create mode 100644 app/src/main/java/com/amaze/filemanager/adapters/LanguageAdapter.java create mode 100644 app/src/main/java/com/amaze/filemanager/models/LanguageModel.java create mode 100644 app/src/main/res/layout/language_item.xml diff --git a/app/src/main/java/com/amaze/filemanager/adapters/LanguageAdapter.java b/app/src/main/java/com/amaze/filemanager/adapters/LanguageAdapter.java new file mode 100644 index 0000000000..edf5f5ab5f --- /dev/null +++ b/app/src/main/java/com/amaze/filemanager/adapters/LanguageAdapter.java @@ -0,0 +1,52 @@ +package com.amaze.filemanager.adapters;// MyRecyclerViewAdapter.java +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.amaze.filemanager.R; +import com.amaze.filemanager.models.LanguageModel; + +import java.util.List; + +public class LanguageAdapter extends RecyclerView.Adapter { + + private List dataList; + + public LanguageAdapter(List dataList) { + this.dataList = dataList; + } + + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.language_item, parent, false); + return new ViewHolder(view); + } + + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + LanguageModel dataModel = dataList.get(position); + holder.title.setText(dataModel.getTitle()); + holder.description.setText(dataModel.getDescription()); + } + + @Override + public int getItemCount() { + return dataList.size(); + } + + public static class ViewHolder extends RecyclerView.ViewHolder { + public TextView title; + public TextView description; + + public ViewHolder(View itemView) { + super(itemView); + title = itemView.findViewById(R.id.tvTitle); + description = itemView.findViewById(R.id.tvDescription); + } + } +} diff --git a/app/src/main/java/com/amaze/filemanager/models/LanguageModel.java b/app/src/main/java/com/amaze/filemanager/models/LanguageModel.java new file mode 100644 index 0000000000..9cb2367fed --- /dev/null +++ b/app/src/main/java/com/amaze/filemanager/models/LanguageModel.java @@ -0,0 +1,28 @@ +package com.amaze.filemanager.models; + +// DataModel.java +public class LanguageModel { + private String title; + private String description; + + public LanguageModel(String text,String description) { + this.title = text; + this.description = description; + } + + public String getTitle() { + return title; + } + + public void setTitle(String text) { + this.title = text; + } + + public String getDescription() { + return description; + } + + public void setDescription(String text) { + this.description = text; + } +} diff --git a/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java b/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java index 878e9f9e9e..a44d306c64 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java +++ b/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java @@ -31,10 +31,12 @@ import com.amaze.filemanager.LogHelper; import com.amaze.filemanager.R; +import com.amaze.filemanager.adapters.LanguageAdapter; import com.amaze.filemanager.ui.activities.superclasses.ThemedActivity; import com.amaze.filemanager.ui.dialogs.share.ShareTask; import com.amaze.filemanager.ui.theme.AppTheme; import com.amaze.filemanager.utils.Billing; +import com.amaze.filemanager.utils.DataUtils; import com.amaze.filemanager.utils.PreferenceUtils; import com.amaze.filemanager.utils.Utils; import com.google.android.material.appbar.AppBarLayout; @@ -56,6 +58,8 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.core.content.FileProvider; import androidx.palette.graphics.Palette; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; /** Created by vishal on 27/7/16. */ public class AboutActivity extends ThemedActivity implements View.OnClickListener { @@ -64,6 +68,8 @@ public class AboutActivity extends ThemedActivity implements View.OnClickListene private static final int HEADER_HEIGHT = 1024; private static final int HEADER_WIDTH = 500; + private LanguageAdapter languageAdapter; + private RecyclerView recyclerView; private AppBarLayout mAppBarLayout; private CollapsingToolbarLayout mCollapsingToolbarLayout; private AppCompatTextView mTitleTextView; @@ -104,6 +110,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { } setContentView(R.layout.activity_about); + recyclerView = findViewById(R.id.rvLanguage); mAppBarLayout = findViewById(R.id.appBarLayout); mCollapsingToolbarLayout = findViewById(R.id.collapsing_toolbar_layout); mTitleTextView = findViewById(R.id.text_view_title); @@ -123,6 +130,8 @@ public void onCreate(@Nullable Bundle savedInstanceState) { Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.about_header); + initAdapter(); + // It will generate colors based on the image in an AsyncTask. Palette.from(bitmap) .generate( @@ -163,6 +172,16 @@ public void onCreate(@Nullable Bundle savedInstanceState) { } } + private void initAdapter(){ + + + + languageAdapter = new LanguageAdapter(DataUtils.getLanguages(this)); + recyclerView.setAdapter(languageAdapter); + recyclerView.setLayoutManager(new LinearLayoutManager(this)); + + } + /** * Calculates aspect ratio for the Amaze header * diff --git a/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java b/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java index 8e090417d4..4abe573208 100644 --- a/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java +++ b/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java @@ -28,9 +28,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.amaze.filemanager.R; import com.amaze.filemanager.adapters.data.LayoutElementParcelable; import com.amaze.filemanager.application.AppConfig; import com.amaze.filemanager.fileoperations.filesystem.OpenMode; +import com.amaze.filemanager.models.LanguageModel; import com.cloudrail.si.interfaces.CloudStorage; import com.cloudrail.si.services.Box; import com.cloudrail.si.services.Dropbox; @@ -42,6 +44,7 @@ import com.googlecode.concurrenttrees.radixinverted.ConcurrentInvertedRadixTree; import com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree; +import android.content.Context; import android.text.TextUtils; import android.view.MenuItem; @@ -84,6 +87,54 @@ private static class DataUtilsHolder { private static final DataUtils INSTANCE = new DataUtils(); } + public static List getLanguages(Context context){ + + var data = new ArrayList(); + + var lang1 = new LanguageModel(context.getString(R.string.german_translation_title),context.getString(R.string.german_translation_summary)); + var lang2 = new LanguageModel(context.getString(R.string.italian_translation_title),context.getString(R.string.italian_translation_summary)); + var lang3 = new LanguageModel(context.getString(R.string.french_translation_title),context.getString(R.string.french_translation_summary)); + var lang4 = new LanguageModel(context.getString(R.string.russian_translation_title),context.getString(R.string.russian_translation_summary)); + var lang5 = new LanguageModel(context.getString(R.string.spanish_translation_title),context.getString(R.string.spanish_translation_summary)); + var lang6 = new LanguageModel(context.getString(R.string.basque_translation_title),context.getString(R.string.basque_translation_summary)); + var lang7 = new LanguageModel(context.getString(R.string.chinese_translation_title),context.getString(R.string.chinese_translation_summary)); + var lang8 = new LanguageModel(context.getString(R.string.serbian_translation_title),context.getString(R.string.serbian_translation_summary)); + var lang9 = new LanguageModel(context.getString(R.string.turkish_translation_title),context.getString(R.string.turkish_translation_summary)); + var lang10 = new LanguageModel(context.getString(R.string.ukrainian_translation_title),context.getString(R.string.ukrainian_translation_summary)); + var lang11 = new LanguageModel(context.getString(R.string.portuguese_translation_title),context.getString(R.string.portuguese_translation_summary)); + var lang12 = new LanguageModel(context.getString(R.string.polish_translation_title),context.getString(R.string.polish_translation_summary)); + var lang13 = new LanguageModel(context.getString(R.string.korean_translation_title),context.getString(R.string.korean_translation_summary)); + var lang14 = new LanguageModel(context.getString(R.string.greek_translation_title),context.getString(R.string.greek_translation_summary)); + var lang15 = new LanguageModel(context.getString(R.string.dutch_translation_title),context.getString(R.string.dutch_translation_summary)); + var lang16 = new LanguageModel(context.getString(R.string.romanian_translation_title),context.getString(R.string.romanian_translation_summary)); + var lang17 = new LanguageModel(context.getString(R.string.vietnamese_translation_title),context.getString(R.string.vietnamese_translation_summary)); + var lang18 = new LanguageModel(context.getString(R.string.japanese_translation_title),context.getString(R.string.japanese_translation_summary)); + var lang19 = new LanguageModel(context.getString(R.string.tamil_translation_title),context.getString(R.string.tamil_translation_summary)); + + data.add(lang1); + data.add(lang2); + data.add(lang3); + data.add(lang4); + data.add(lang5); + data.add(lang6); + data.add(lang7); + data.add(lang8); + data.add(lang9); + data.add(lang10); + data.add(lang11); + data.add(lang12); + data.add(lang13); + data.add(lang14); + data.add(lang15); + data.add(lang16); + data.add(lang17); + data.add(lang18); + data.add(lang19); + + return data; + + } + public static DataUtils getInstance() { return DataUtilsHolder.INSTANCE; } diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index ae536f84fd..a69389292f 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -180,126 +180,6 @@ - @@ -312,7 +192,9 @@ + android:layout_height="wrap_content" + android:paddingEnd="16dp" + > - - - + - - - - - - - - - - - - - - - - - - + android:text="@string/github" + android:textColor="@color/accent_red" + android:layout_marginTop="@dimen/material_generic" + android:textSize="@dimen/material_generic_title" + app:layout_constraintStart_toStartOf="@id/text_view_author_1_title" + app:layout_constraintTop_toBottomOf="@id/text_view_author_1_title" + android:onClick="onClick"/> + - - + + + + - - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - - + android:text="@string/github" + android:textColor="@color/accent_red" + android:textSize="@dimen/material_generic_title" + android:onClick="onClick" + android:layout_marginTop="@dimen/material_generic" + app:layout_constraintStart_toStartOf="@id/text_view_developer_1_title" + app:layout_constraintTop_toBottomOf="@id/text_view_developer_1_title" + /> + - - + + - - - - - - - - - - - + android:text="@string/github" + android:textColor="@color/accent_red" + android:textSize="@dimen/material_generic_title" + android:onClick="onClick" + android:layout_marginTop="@dimen/material_generic" + app:layout_constraintStart_toStartOf="@id/text_view_developer_2_title" + app:layout_constraintTop_toBottomOf="@id/text_view_developer_2_title" + /> + - - + + - - - - - - - - - - + android:text="@string/github" + android:textColor="@color/accent_red" + android:textSize="@dimen/material_generic_title" + android:onClick="onClick" + android:layout_marginTop="@dimen/material_generic" + android:layout_marginBottom="25dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="@id/text_view_developer_3_title" + app:layout_constraintTop_toBottomOf="@id/text_view_developer_3_title" + /> + + @@ -640,316 +417,315 @@ app:cardElevation="@dimen/material_generic_card_elevation" > - + android:layout_height="wrap_content"> - - + - - + + + - - - - - - - - - - - + + + + + + + + - - - - - - - - - - + + + + + + + + - - - - - - - - - - + + + + + + + + - - - - - - - - - - + + + + + + + + - - - - - - - - - - + + + + + + - - - - - - - - - + + + + + + - - - - - - - - + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/relative_layout_rate" /> + + + @@ -960,484 +736,34 @@ app:cardElevation="@dimen/material_generic_card_elevation" > - + android:layout_height="wrap_content"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - + android:layout_height="wrap_content" + android:layout_marginTop="25dp" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toBottomOf="@id/tvTranslator" + /> + + @@ -1448,197 +774,176 @@ app:cardElevation="@dimen/material_generic_card_elevation" > - + android:layout_height="wrap_content"> + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/language_item.xml b/app/src/main/res/layout/language_item.xml new file mode 100644 index 0000000000..aa9038e46e --- /dev/null +++ b/app/src/main/res/layout/language_item.xml @@ -0,0 +1,33 @@ + + + + + + + + \ No newline at end of file From 50e27cefd5eec2bd443afbed42b15cbd6aa8a360 Mon Sep 17 00:00:00 2001 From: hammad Date: Sat, 20 Jul 2024 14:39:41 +0500 Subject: [PATCH 3/7] changes for spotless check --- .../filemanager/adapters/LanguageAdapter.java | 90 ++++++++++------- .../filemanager/models/LanguageModel.java | 56 +++++++---- .../ui/activities/AboutActivity.java | 5 +- .../amaze/filemanager/utils/DataUtils.java | 98 +++++++++++++++---- 4 files changed, 172 insertions(+), 77 deletions(-) diff --git a/app/src/main/java/com/amaze/filemanager/adapters/LanguageAdapter.java b/app/src/main/java/com/amaze/filemanager/adapters/LanguageAdapter.java index edf5f5ab5f..5351c3e3a2 100644 --- a/app/src/main/java/com/amaze/filemanager/adapters/LanguageAdapter.java +++ b/app/src/main/java/com/amaze/filemanager/adapters/LanguageAdapter.java @@ -1,4 +1,30 @@ -package com.amaze.filemanager.adapters;// MyRecyclerViewAdapter.java +/* + * Copyright (C) 2014-2024 Arpit Khurana , Vishal Nehra , + * Emmanuel Messulam, Raymond Lai and Contributors. + * + * This file is part of Amaze File Manager. + * + * Amaze File Manager is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.amaze.filemanager.adapters; // MyRecyclerViewAdapter.java + +import java.util.List; + +import com.amaze.filemanager.R; +import com.amaze.filemanager.models.LanguageModel; + import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -7,46 +33,42 @@ import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; -import com.amaze.filemanager.R; -import com.amaze.filemanager.models.LanguageModel; - -import java.util.List; - public class LanguageAdapter extends RecyclerView.Adapter { - private List dataList; + private List dataList; - public LanguageAdapter(List dataList) { - this.dataList = dataList; - } + public LanguageAdapter(List dataList) { + this.dataList = dataList; + } - @NonNull - @Override - public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.language_item, parent, false); - return new ViewHolder(view); - } + @NonNull + @Override + public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = + LayoutInflater.from(parent.getContext()).inflate(R.layout.language_item, parent, false); + return new ViewHolder(view); + } - @Override - public void onBindViewHolder(@NonNull ViewHolder holder, int position) { - LanguageModel dataModel = dataList.get(position); - holder.title.setText(dataModel.getTitle()); - holder.description.setText(dataModel.getDescription()); - } + @Override + public void onBindViewHolder(@NonNull ViewHolder holder, int position) { + LanguageModel dataModel = dataList.get(position); + holder.title.setText(dataModel.getTitle()); + holder.description.setText(dataModel.getDescription()); + } - @Override - public int getItemCount() { - return dataList.size(); - } + @Override + public int getItemCount() { + return dataList.size(); + } - public static class ViewHolder extends RecyclerView.ViewHolder { - public TextView title; - public TextView description; + public static class ViewHolder extends RecyclerView.ViewHolder { + public TextView title; + public TextView description; - public ViewHolder(View itemView) { - super(itemView); - title = itemView.findViewById(R.id.tvTitle); - description = itemView.findViewById(R.id.tvDescription); - } + public ViewHolder(View itemView) { + super(itemView); + title = itemView.findViewById(R.id.tvTitle); + description = itemView.findViewById(R.id.tvDescription); } + } } diff --git a/app/src/main/java/com/amaze/filemanager/models/LanguageModel.java b/app/src/main/java/com/amaze/filemanager/models/LanguageModel.java index 9cb2367fed..63e879dddf 100644 --- a/app/src/main/java/com/amaze/filemanager/models/LanguageModel.java +++ b/app/src/main/java/com/amaze/filemanager/models/LanguageModel.java @@ -1,28 +1,48 @@ +/* + * Copyright (C) 2014-2024 Arpit Khurana , Vishal Nehra , + * Emmanuel Messulam, Raymond Lai and Contributors. + * + * This file is part of Amaze File Manager. + * + * Amaze File Manager is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package com.amaze.filemanager.models; // DataModel.java public class LanguageModel { - private String title; - private String description; + private String title; + private String description; - public LanguageModel(String text,String description) { - this.title = text; - this.description = description; - } + public LanguageModel(String text, String description) { + this.title = text; + this.description = description; + } - public String getTitle() { - return title; - } + public String getTitle() { + return title; + } - public void setTitle(String text) { - this.title = text; - } + public void setTitle(String text) { + this.title = text; + } - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String text) { - this.description = text; - } + public void setDescription(String text) { + this.description = text; + } } diff --git a/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java b/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java index a44d306c64..71131be927 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java +++ b/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java @@ -172,14 +172,11 @@ public void onCreate(@Nullable Bundle savedInstanceState) { } } - private void initAdapter(){ - - + private void initAdapter() { languageAdapter = new LanguageAdapter(DataUtils.getLanguages(this)); recyclerView.setAdapter(languageAdapter); recyclerView.setLayoutManager(new LinearLayoutManager(this)); - } /** diff --git a/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java b/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java index 4abe573208..f87db6ca30 100644 --- a/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java +++ b/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java @@ -87,29 +87,86 @@ private static class DataUtilsHolder { private static final DataUtils INSTANCE = new DataUtils(); } - public static List getLanguages(Context context){ + public static List getLanguages(Context context) { var data = new ArrayList(); - var lang1 = new LanguageModel(context.getString(R.string.german_translation_title),context.getString(R.string.german_translation_summary)); - var lang2 = new LanguageModel(context.getString(R.string.italian_translation_title),context.getString(R.string.italian_translation_summary)); - var lang3 = new LanguageModel(context.getString(R.string.french_translation_title),context.getString(R.string.french_translation_summary)); - var lang4 = new LanguageModel(context.getString(R.string.russian_translation_title),context.getString(R.string.russian_translation_summary)); - var lang5 = new LanguageModel(context.getString(R.string.spanish_translation_title),context.getString(R.string.spanish_translation_summary)); - var lang6 = new LanguageModel(context.getString(R.string.basque_translation_title),context.getString(R.string.basque_translation_summary)); - var lang7 = new LanguageModel(context.getString(R.string.chinese_translation_title),context.getString(R.string.chinese_translation_summary)); - var lang8 = new LanguageModel(context.getString(R.string.serbian_translation_title),context.getString(R.string.serbian_translation_summary)); - var lang9 = new LanguageModel(context.getString(R.string.turkish_translation_title),context.getString(R.string.turkish_translation_summary)); - var lang10 = new LanguageModel(context.getString(R.string.ukrainian_translation_title),context.getString(R.string.ukrainian_translation_summary)); - var lang11 = new LanguageModel(context.getString(R.string.portuguese_translation_title),context.getString(R.string.portuguese_translation_summary)); - var lang12 = new LanguageModel(context.getString(R.string.polish_translation_title),context.getString(R.string.polish_translation_summary)); - var lang13 = new LanguageModel(context.getString(R.string.korean_translation_title),context.getString(R.string.korean_translation_summary)); - var lang14 = new LanguageModel(context.getString(R.string.greek_translation_title),context.getString(R.string.greek_translation_summary)); - var lang15 = new LanguageModel(context.getString(R.string.dutch_translation_title),context.getString(R.string.dutch_translation_summary)); - var lang16 = new LanguageModel(context.getString(R.string.romanian_translation_title),context.getString(R.string.romanian_translation_summary)); - var lang17 = new LanguageModel(context.getString(R.string.vietnamese_translation_title),context.getString(R.string.vietnamese_translation_summary)); - var lang18 = new LanguageModel(context.getString(R.string.japanese_translation_title),context.getString(R.string.japanese_translation_summary)); - var lang19 = new LanguageModel(context.getString(R.string.tamil_translation_title),context.getString(R.string.tamil_translation_summary)); + var lang1 = + new LanguageModel( + context.getString(R.string.german_translation_title), + context.getString(R.string.german_translation_summary)); + var lang2 = + new LanguageModel( + context.getString(R.string.italian_translation_title), + context.getString(R.string.italian_translation_summary)); + var lang3 = + new LanguageModel( + context.getString(R.string.french_translation_title), + context.getString(R.string.french_translation_summary)); + var lang4 = + new LanguageModel( + context.getString(R.string.russian_translation_title), + context.getString(R.string.russian_translation_summary)); + var lang5 = + new LanguageModel( + context.getString(R.string.spanish_translation_title), + context.getString(R.string.spanish_translation_summary)); + var lang6 = + new LanguageModel( + context.getString(R.string.basque_translation_title), + context.getString(R.string.basque_translation_summary)); + var lang7 = + new LanguageModel( + context.getString(R.string.chinese_translation_title), + context.getString(R.string.chinese_translation_summary)); + var lang8 = + new LanguageModel( + context.getString(R.string.serbian_translation_title), + context.getString(R.string.serbian_translation_summary)); + var lang9 = + new LanguageModel( + context.getString(R.string.turkish_translation_title), + context.getString(R.string.turkish_translation_summary)); + var lang10 = + new LanguageModel( + context.getString(R.string.ukrainian_translation_title), + context.getString(R.string.ukrainian_translation_summary)); + var lang11 = + new LanguageModel( + context.getString(R.string.portuguese_translation_title), + context.getString(R.string.portuguese_translation_summary)); + var lang12 = + new LanguageModel( + context.getString(R.string.polish_translation_title), + context.getString(R.string.polish_translation_summary)); + var lang13 = + new LanguageModel( + context.getString(R.string.korean_translation_title), + context.getString(R.string.korean_translation_summary)); + var lang14 = + new LanguageModel( + context.getString(R.string.greek_translation_title), + context.getString(R.string.greek_translation_summary)); + var lang15 = + new LanguageModel( + context.getString(R.string.dutch_translation_title), + context.getString(R.string.dutch_translation_summary)); + var lang16 = + new LanguageModel( + context.getString(R.string.romanian_translation_title), + context.getString(R.string.romanian_translation_summary)); + var lang17 = + new LanguageModel( + context.getString(R.string.vietnamese_translation_title), + context.getString(R.string.vietnamese_translation_summary)); + var lang18 = + new LanguageModel( + context.getString(R.string.japanese_translation_title), + context.getString(R.string.japanese_translation_summary)); + var lang19 = + new LanguageModel( + context.getString(R.string.tamil_translation_title), + context.getString(R.string.tamil_translation_summary)); data.add(lang1); data.add(lang2); @@ -132,7 +189,6 @@ public static List getLanguages(Context context){ data.add(lang19); return data; - } public static DataUtils getInstance() { From e8c7236bf66968e4fae81007f547ad7bd7875d34 Mon Sep 17 00:00:00 2001 From: talhaasif2023 Date: Mon, 22 Jul 2024 09:47:25 +0500 Subject: [PATCH 4/7] changes applied --- .../filemanager/adapters/LanguageAdapter.java | 74 ---------- .../filemanager/adapters/LanguageAdapter.kt | 51 +++++++ .../{LanguageModel.java => LanguageModel.kt} | 30 +--- .../filemanager/ui/fragments/TabFragment.java | 9 ++ .../ui/views/appbar/SearchView.java | 18 ++- .../amaze/filemanager/utils/DataUtils.java | 135 +++++++----------- 6 files changed, 123 insertions(+), 194 deletions(-) delete mode 100644 app/src/main/java/com/amaze/filemanager/adapters/LanguageAdapter.java create mode 100644 app/src/main/java/com/amaze/filemanager/adapters/LanguageAdapter.kt rename app/src/main/java/com/amaze/filemanager/models/{LanguageModel.java => LanguageModel.kt} (63%) diff --git a/app/src/main/java/com/amaze/filemanager/adapters/LanguageAdapter.java b/app/src/main/java/com/amaze/filemanager/adapters/LanguageAdapter.java deleted file mode 100644 index 5351c3e3a2..0000000000 --- a/app/src/main/java/com/amaze/filemanager/adapters/LanguageAdapter.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2014-2024 Arpit Khurana , Vishal Nehra , - * Emmanuel Messulam, Raymond Lai and Contributors. - * - * This file is part of Amaze File Manager. - * - * Amaze File Manager is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.amaze.filemanager.adapters; // MyRecyclerViewAdapter.java - -import java.util.List; - -import com.amaze.filemanager.R; -import com.amaze.filemanager.models.LanguageModel; - -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.RecyclerView; - -public class LanguageAdapter extends RecyclerView.Adapter { - - private List dataList; - - public LanguageAdapter(List dataList) { - this.dataList = dataList; - } - - @NonNull - @Override - public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { - View view = - LayoutInflater.from(parent.getContext()).inflate(R.layout.language_item, parent, false); - return new ViewHolder(view); - } - - @Override - public void onBindViewHolder(@NonNull ViewHolder holder, int position) { - LanguageModel dataModel = dataList.get(position); - holder.title.setText(dataModel.getTitle()); - holder.description.setText(dataModel.getDescription()); - } - - @Override - public int getItemCount() { - return dataList.size(); - } - - public static class ViewHolder extends RecyclerView.ViewHolder { - public TextView title; - public TextView description; - - public ViewHolder(View itemView) { - super(itemView); - title = itemView.findViewById(R.id.tvTitle); - description = itemView.findViewById(R.id.tvDescription); - } - } -} diff --git a/app/src/main/java/com/amaze/filemanager/adapters/LanguageAdapter.kt b/app/src/main/java/com/amaze/filemanager/adapters/LanguageAdapter.kt new file mode 100644 index 0000000000..4b98cc31d1 --- /dev/null +++ b/app/src/main/java/com/amaze/filemanager/adapters/LanguageAdapter.kt @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2014-2024 Arpit Khurana , Vishal Nehra , + * Emmanuel Messulam, Raymond Lai and Contributors. + * + * This file is part of Amaze File Manager. + * + * Amaze File Manager is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.amaze.filemanager.adapters + +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.amaze.filemanager.R +import com.amaze.filemanager.models.LanguageModel + +class LanguageAdapter(private val dataList: List) : RecyclerView.Adapter() { + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { + val view = + LayoutInflater.from(parent.context).inflate(R.layout.language_item, parent, false) + return ViewHolder(view) + } + + override fun onBindViewHolder(holder: ViewHolder, position: Int) { + val dataModel = dataList[position] + holder.title.text = dataModel.title + holder.description.text = dataModel.description + } + + override fun getItemCount(): Int { + return dataList.size + } + + class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + var title: TextView = itemView.findViewById(R.id.tvTitle) + var description: TextView = itemView.findViewById(R.id.tvDescription) + } +} diff --git a/app/src/main/java/com/amaze/filemanager/models/LanguageModel.java b/app/src/main/java/com/amaze/filemanager/models/LanguageModel.kt similarity index 63% rename from app/src/main/java/com/amaze/filemanager/models/LanguageModel.java rename to app/src/main/java/com/amaze/filemanager/models/LanguageModel.kt index 63e879dddf..42805b3566 100644 --- a/app/src/main/java/com/amaze/filemanager/models/LanguageModel.java +++ b/app/src/main/java/com/amaze/filemanager/models/LanguageModel.kt @@ -17,32 +17,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ +package com.amaze.filemanager.models -package com.amaze.filemanager.models; - -// DataModel.java -public class LanguageModel { - private String title; - private String description; - - public LanguageModel(String text, String description) { - this.title = text; - this.description = description; - } - - public String getTitle() { - return title; - } - - public void setTitle(String text) { - this.title = text; - } - - public String getDescription() { - return description; - } - - public void setDescription(String text) { - this.description = text; - } -} +data class LanguageModel(var title: String,var description: String) diff --git a/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java b/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java index 9cfe88053c..4e684dabb4 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java +++ b/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java @@ -54,6 +54,7 @@ import android.graphics.drawable.ColorDrawable; import android.os.Build; import android.os.Bundle; +import android.util.Log; import android.view.HapticFeedbackConstants; import android.view.LayoutInflater; import android.view.View; @@ -106,6 +107,12 @@ public class TabFragment extends Fragment { private final ArgbEvaluator evaluator = new ArgbEvaluator(); private ConstraintLayout dragPlaceholder; + @Override + public void onResume() { + super.onResume(); + LOG.error("onResume called"); + } + @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -170,6 +177,8 @@ public View onCreateView( sectionsPagerAdapter.notifyDataSetChanged(); } + + if (indicator != null) indicator.setViewPager(viewPager); UserColorPreferences userColorPreferences = requireMainActivity().getCurrentColorPreference(); diff --git a/app/src/main/java/com/amaze/filemanager/ui/views/appbar/SearchView.java b/app/src/main/java/com/amaze/filemanager/ui/views/appbar/SearchView.java index 1397fcaee0..bf658ff0dd 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/views/appbar/SearchView.java +++ b/app/src/main/java/com/amaze/filemanager/ui/views/appbar/SearchView.java @@ -61,12 +61,14 @@ import android.text.TextWatcher; import android.text.style.ForegroundColorSpan; import android.text.style.StyleSpan; +import android.util.Log; import android.view.ContextThemeWrapper; import android.view.View; import android.view.ViewAnimationUtils; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; +import android.widget.Toast; import androidx.appcompat.widget.AppCompatButton; import androidx.appcompat.widget.AppCompatEditText; @@ -372,11 +374,16 @@ private void resetSearchMode() { * @param searchTerm The search term that resulted in the search results */ private void updateResultList(List newResults, String searchTerm) { - ArrayList items = new ArrayList<>(newResults); - Collections.sort( - items, new SearchResultListSorter(DirSortBy.NONE_ON_TOP, sortType, searchTerm)); - searchRecyclerViewAdapter.submitList(items); - searchRecyclerViewAdapter.notifyDataSetChanged(); + if (newResults==null){ + Toast.makeText(mainActivity, "No data found",Toast.LENGTH_SHORT).show(); + }else { + Log.e("TAG", "updateResultList: " + newResults + " " + searchTerm); + ArrayList items = new ArrayList<>(newResults); + Collections.sort( + items, new SearchResultListSorter(DirSortBy.NONE_ON_TOP, sortType, searchTerm)); + searchRecyclerViewAdapter.submitList(items); + searchRecyclerViewAdapter.notifyDataSetChanged(); + } } /** show search view with a circular reveal animation */ @@ -478,6 +485,7 @@ private void onSortTypeSelected(MaterialDialog dialog, int index, SortOrder sort updateSearchResultsSortButtonDisplay(); LiveData> lastSearchLiveData = mainActivity.getCurrentMainFragment().getMainActivityViewModel().getLastSearchLiveData(); + Log.e("TAG", "onSortTypeSelected: " + lastSearchLiveData.getValue()); updateResultList(lastSearchLiveData.getValue(), getSearchTerm()); } diff --git a/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java b/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java index f87db6ca30..aaa9f86fc1 100644 --- a/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java +++ b/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java @@ -20,13 +20,11 @@ package com.amaze.filemanager.utils; -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; +import android.content.Context; +import android.text.TextUtils; +import android.view.MenuItem; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import androidx.annotation.Nullable; import com.amaze.filemanager.R; import com.amaze.filemanager.adapters.data.LayoutElementParcelable; @@ -44,11 +42,13 @@ import com.googlecode.concurrenttrees.radixinverted.ConcurrentInvertedRadixTree; import com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree; -import android.content.Context; -import android.text.TextUtils; -import android.view.MenuItem; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import androidx.annotation.Nullable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; /** Singleton class to handle data for various services */ @@ -91,102 +91,63 @@ public static List getLanguages(Context context) { var data = new ArrayList(); - var lang1 = - new LanguageModel( + data.add(new LanguageModel( context.getString(R.string.german_translation_title), - context.getString(R.string.german_translation_summary)); - var lang2 = - new LanguageModel( + context.getString(R.string.german_translation_summary))); + data.add(new LanguageModel( context.getString(R.string.italian_translation_title), - context.getString(R.string.italian_translation_summary)); - var lang3 = - new LanguageModel( + context.getString(R.string.italian_translation_summary))); + data.add(new LanguageModel( context.getString(R.string.french_translation_title), - context.getString(R.string.french_translation_summary)); - var lang4 = - new LanguageModel( + context.getString(R.string.french_translation_summary))); + data.add(new LanguageModel( context.getString(R.string.russian_translation_title), - context.getString(R.string.russian_translation_summary)); - var lang5 = - new LanguageModel( + context.getString(R.string.russian_translation_summary))); + data.add(new LanguageModel( context.getString(R.string.spanish_translation_title), - context.getString(R.string.spanish_translation_summary)); - var lang6 = - new LanguageModel( + context.getString(R.string.spanish_translation_summary))); + data.add(new LanguageModel( context.getString(R.string.basque_translation_title), - context.getString(R.string.basque_translation_summary)); - var lang7 = - new LanguageModel( + context.getString(R.string.basque_translation_summary))); + data.add(new LanguageModel( context.getString(R.string.chinese_translation_title), - context.getString(R.string.chinese_translation_summary)); - var lang8 = - new LanguageModel( + context.getString(R.string.chinese_translation_summary))); + data.add(new LanguageModel( context.getString(R.string.serbian_translation_title), - context.getString(R.string.serbian_translation_summary)); - var lang9 = - new LanguageModel( + context.getString(R.string.serbian_translation_summary))); + data.add(new LanguageModel( context.getString(R.string.turkish_translation_title), - context.getString(R.string.turkish_translation_summary)); - var lang10 = - new LanguageModel( + context.getString(R.string.turkish_translation_summary))); + data.add(new LanguageModel( context.getString(R.string.ukrainian_translation_title), - context.getString(R.string.ukrainian_translation_summary)); - var lang11 = - new LanguageModel( + context.getString(R.string.ukrainian_translation_summary))); + data.add(new LanguageModel( context.getString(R.string.portuguese_translation_title), - context.getString(R.string.portuguese_translation_summary)); - var lang12 = - new LanguageModel( + context.getString(R.string.portuguese_translation_summary))); + data.add(new LanguageModel( context.getString(R.string.polish_translation_title), - context.getString(R.string.polish_translation_summary)); - var lang13 = - new LanguageModel( + context.getString(R.string.polish_translation_summary))); + data.add(new LanguageModel( context.getString(R.string.korean_translation_title), - context.getString(R.string.korean_translation_summary)); - var lang14 = - new LanguageModel( + context.getString(R.string.korean_translation_summary))); + data.add(new LanguageModel( context.getString(R.string.greek_translation_title), - context.getString(R.string.greek_translation_summary)); - var lang15 = - new LanguageModel( + context.getString(R.string.greek_translation_summary))); + data.add(new LanguageModel( context.getString(R.string.dutch_translation_title), - context.getString(R.string.dutch_translation_summary)); - var lang16 = - new LanguageModel( + context.getString(R.string.dutch_translation_summary))); + data.add(new LanguageModel( context.getString(R.string.romanian_translation_title), - context.getString(R.string.romanian_translation_summary)); - var lang17 = - new LanguageModel( + context.getString(R.string.romanian_translation_summary))); + data.add(new LanguageModel( context.getString(R.string.vietnamese_translation_title), - context.getString(R.string.vietnamese_translation_summary)); - var lang18 = - new LanguageModel( + context.getString(R.string.vietnamese_translation_summary))); + data.add(new LanguageModel( context.getString(R.string.japanese_translation_title), - context.getString(R.string.japanese_translation_summary)); - var lang19 = - new LanguageModel( + context.getString(R.string.japanese_translation_summary))); + data.add(new LanguageModel( context.getString(R.string.tamil_translation_title), - context.getString(R.string.tamil_translation_summary)); - - data.add(lang1); - data.add(lang2); - data.add(lang3); - data.add(lang4); - data.add(lang5); - data.add(lang6); - data.add(lang7); - data.add(lang8); - data.add(lang9); - data.add(lang10); - data.add(lang11); - data.add(lang12); - data.add(lang13); - data.add(lang14); - data.add(lang15); - data.add(lang16); - data.add(lang17); - data.add(lang18); - data.add(lang19); + context.getString(R.string.tamil_translation_summary))); return data; } From 7550bbd8e027429ef50e659f3c2d8d9c61b05df2 Mon Sep 17 00:00:00 2001 From: talhaasif2023 Date: Mon, 22 Jul 2024 10:09:31 +0500 Subject: [PATCH 5/7] changes made for spotless check --- .../filemanager/adapters/LanguageAdapter.kt | 10 ++- .../amaze/filemanager/models/LanguageModel.kt | 2 +- .../filemanager/ui/fragments/TabFragment.java | 3 - .../ui/views/appbar/SearchView.java | 8 +- .../amaze/filemanager/utils/DataUtils.java | 77 ++++++++++++------- 5 files changed, 61 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/com/amaze/filemanager/adapters/LanguageAdapter.kt b/app/src/main/java/com/amaze/filemanager/adapters/LanguageAdapter.kt index 4b98cc31d1..3b1a252d32 100644 --- a/app/src/main/java/com/amaze/filemanager/adapters/LanguageAdapter.kt +++ b/app/src/main/java/com/amaze/filemanager/adapters/LanguageAdapter.kt @@ -28,13 +28,19 @@ import com.amaze.filemanager.R import com.amaze.filemanager.models.LanguageModel class LanguageAdapter(private val dataList: List) : RecyclerView.Adapter() { - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { + override fun onCreateViewHolder( + parent: ViewGroup, + viewType: Int, + ): ViewHolder { val view = LayoutInflater.from(parent.context).inflate(R.layout.language_item, parent, false) return ViewHolder(view) } - override fun onBindViewHolder(holder: ViewHolder, position: Int) { + override fun onBindViewHolder( + holder: ViewHolder, + position: Int, + ) { val dataModel = dataList[position] holder.title.text = dataModel.title holder.description.text = dataModel.description diff --git a/app/src/main/java/com/amaze/filemanager/models/LanguageModel.kt b/app/src/main/java/com/amaze/filemanager/models/LanguageModel.kt index 42805b3566..1903454460 100644 --- a/app/src/main/java/com/amaze/filemanager/models/LanguageModel.kt +++ b/app/src/main/java/com/amaze/filemanager/models/LanguageModel.kt @@ -19,4 +19,4 @@ */ package com.amaze.filemanager.models -data class LanguageModel(var title: String,var description: String) +data class LanguageModel(var title: String, var description: String) diff --git a/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java b/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java index 4e684dabb4..8b7ccbe01f 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java +++ b/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java @@ -54,7 +54,6 @@ import android.graphics.drawable.ColorDrawable; import android.os.Build; import android.os.Bundle; -import android.util.Log; import android.view.HapticFeedbackConstants; import android.view.LayoutInflater; import android.view.View; @@ -177,8 +176,6 @@ public View onCreateView( sectionsPagerAdapter.notifyDataSetChanged(); } - - if (indicator != null) indicator.setViewPager(viewPager); UserColorPreferences userColorPreferences = requireMainActivity().getCurrentColorPreference(); diff --git a/app/src/main/java/com/amaze/filemanager/ui/views/appbar/SearchView.java b/app/src/main/java/com/amaze/filemanager/ui/views/appbar/SearchView.java index bf658ff0dd..0d6cc43adf 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/views/appbar/SearchView.java +++ b/app/src/main/java/com/amaze/filemanager/ui/views/appbar/SearchView.java @@ -374,13 +374,13 @@ private void resetSearchMode() { * @param searchTerm The search term that resulted in the search results */ private void updateResultList(List newResults, String searchTerm) { - if (newResults==null){ - Toast.makeText(mainActivity, "No data found",Toast.LENGTH_SHORT).show(); - }else { + if (newResults == null) { + Toast.makeText(mainActivity, "No data found", Toast.LENGTH_SHORT).show(); + } else { Log.e("TAG", "updateResultList: " + newResults + " " + searchTerm); ArrayList items = new ArrayList<>(newResults); Collections.sort( - items, new SearchResultListSorter(DirSortBy.NONE_ON_TOP, sortType, searchTerm)); + items, new SearchResultListSorter(DirSortBy.NONE_ON_TOP, sortType, searchTerm)); searchRecyclerViewAdapter.submitList(items); searchRecyclerViewAdapter.notifyDataSetChanged(); } diff --git a/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java b/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java index aaa9f86fc1..70999f9a93 100644 --- a/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java +++ b/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java @@ -20,11 +20,13 @@ package com.amaze.filemanager.utils; -import android.content.Context; -import android.text.TextUtils; -import android.view.MenuItem; +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; -import androidx.annotation.Nullable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.amaze.filemanager.R; import com.amaze.filemanager.adapters.data.LayoutElementParcelable; @@ -42,13 +44,11 @@ import com.googlecode.concurrenttrees.radixinverted.ConcurrentInvertedRadixTree; import com.googlecode.concurrenttrees.radixinverted.InvertedRadixTree; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import android.content.Context; +import android.text.TextUtils; +import android.view.MenuItem; -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; +import androidx.annotation.Nullable; /** Singleton class to handle data for various services */ @@ -91,61 +91,80 @@ public static List getLanguages(Context context) { var data = new ArrayList(); - data.add(new LanguageModel( + data.add( + new LanguageModel( context.getString(R.string.german_translation_title), context.getString(R.string.german_translation_summary))); - data.add(new LanguageModel( + data.add( + new LanguageModel( context.getString(R.string.italian_translation_title), context.getString(R.string.italian_translation_summary))); - data.add(new LanguageModel( + data.add( + new LanguageModel( context.getString(R.string.french_translation_title), context.getString(R.string.french_translation_summary))); - data.add(new LanguageModel( + data.add( + new LanguageModel( context.getString(R.string.russian_translation_title), context.getString(R.string.russian_translation_summary))); - data.add(new LanguageModel( + data.add( + new LanguageModel( context.getString(R.string.spanish_translation_title), context.getString(R.string.spanish_translation_summary))); - data.add(new LanguageModel( + data.add( + new LanguageModel( context.getString(R.string.basque_translation_title), context.getString(R.string.basque_translation_summary))); - data.add(new LanguageModel( + data.add( + new LanguageModel( context.getString(R.string.chinese_translation_title), context.getString(R.string.chinese_translation_summary))); - data.add(new LanguageModel( + data.add( + new LanguageModel( context.getString(R.string.serbian_translation_title), context.getString(R.string.serbian_translation_summary))); - data.add(new LanguageModel( + data.add( + new LanguageModel( context.getString(R.string.turkish_translation_title), context.getString(R.string.turkish_translation_summary))); - data.add(new LanguageModel( + data.add( + new LanguageModel( context.getString(R.string.ukrainian_translation_title), context.getString(R.string.ukrainian_translation_summary))); - data.add(new LanguageModel( + data.add( + new LanguageModel( context.getString(R.string.portuguese_translation_title), context.getString(R.string.portuguese_translation_summary))); - data.add(new LanguageModel( + data.add( + new LanguageModel( context.getString(R.string.polish_translation_title), context.getString(R.string.polish_translation_summary))); - data.add(new LanguageModel( + data.add( + new LanguageModel( context.getString(R.string.korean_translation_title), context.getString(R.string.korean_translation_summary))); - data.add(new LanguageModel( + data.add( + new LanguageModel( context.getString(R.string.greek_translation_title), context.getString(R.string.greek_translation_summary))); - data.add(new LanguageModel( + data.add( + new LanguageModel( context.getString(R.string.dutch_translation_title), context.getString(R.string.dutch_translation_summary))); - data.add(new LanguageModel( + data.add( + new LanguageModel( context.getString(R.string.romanian_translation_title), context.getString(R.string.romanian_translation_summary))); - data.add(new LanguageModel( + data.add( + new LanguageModel( context.getString(R.string.vietnamese_translation_title), context.getString(R.string.vietnamese_translation_summary))); - data.add(new LanguageModel( + data.add( + new LanguageModel( context.getString(R.string.japanese_translation_title), context.getString(R.string.japanese_translation_summary))); - data.add(new LanguageModel( + data.add( + new LanguageModel( context.getString(R.string.tamil_translation_title), context.getString(R.string.tamil_translation_summary))); From 12d083587fb3eb6bbd2ef36dbab16b2bb08f3a41 Mon Sep 17 00:00:00 2001 From: Hammad Rafiq Date: Wed, 24 Jul 2024 13:50:48 +0500 Subject: [PATCH 6/7] recyclerview added for contributors section in activity_about.xml --- .../adapters/ContributorAdapter.kt | 57 +++++++ .../ui/activities/AboutActivity.java | 8 + .../ui/views/appbar/SearchView.java | 18 +-- .../amaze/filemanager/utils/DataUtils.java | 36 +++++ app/src/main/res/layout/activity_about.xml | 151 +----------------- 5 files changed, 111 insertions(+), 159 deletions(-) create mode 100644 app/src/main/java/com/amaze/filemanager/adapters/ContributorAdapter.kt diff --git a/app/src/main/java/com/amaze/filemanager/adapters/ContributorAdapter.kt b/app/src/main/java/com/amaze/filemanager/adapters/ContributorAdapter.kt new file mode 100644 index 0000000000..80fc31bb2b --- /dev/null +++ b/app/src/main/java/com/amaze/filemanager/adapters/ContributorAdapter.kt @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2014-2024 Arpit Khurana , Vishal Nehra , + * Emmanuel Messulam, Raymond Lai and Contributors. + * + * This file is part of Amaze File Manager. + * + * Amaze File Manager is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.amaze.filemanager.adapters + +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView +import com.amaze.filemanager.R +import com.amaze.filemanager.models.LanguageModel + +class ContributorAdapter(private val dataList: List) : RecyclerView.Adapter() { + override fun onCreateViewHolder( + parent: ViewGroup, + viewType: Int, + ): ViewHolder { + val view = + LayoutInflater.from(parent.context).inflate(R.layout.language_item, parent, false) + return ViewHolder(view) + } + + override fun onBindViewHolder( + holder: ViewHolder, + position: Int, + ) { + val dataModel = dataList[position] + holder.title.text = dataModel.title + holder.description.text = dataModel.description + } + + override fun getItemCount(): Int { + return dataList.size + } + + class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { + var title: TextView = itemView.findViewById(R.id.tvTitle) + var description: TextView = itemView.findViewById(R.id.tvDescription) + } +} diff --git a/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java b/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java index 71131be927..bf0e696252 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java +++ b/app/src/main/java/com/amaze/filemanager/ui/activities/AboutActivity.java @@ -31,6 +31,7 @@ import com.amaze.filemanager.LogHelper; import com.amaze.filemanager.R; +import com.amaze.filemanager.adapters.ContributorAdapter; import com.amaze.filemanager.adapters.LanguageAdapter; import com.amaze.filemanager.ui.activities.superclasses.ThemedActivity; import com.amaze.filemanager.ui.dialogs.share.ShareTask; @@ -69,7 +70,9 @@ public class AboutActivity extends ThemedActivity implements View.OnClickListene private static final int HEADER_WIDTH = 500; private LanguageAdapter languageAdapter; + private ContributorAdapter contributorAdapter; private RecyclerView recyclerView; + private RecyclerView contributorRecyclerView; private AppBarLayout mAppBarLayout; private CollapsingToolbarLayout mCollapsingToolbarLayout; private AppCompatTextView mTitleTextView; @@ -111,6 +114,7 @@ public void onCreate(@Nullable Bundle savedInstanceState) { setContentView(R.layout.activity_about); recyclerView = findViewById(R.id.rvLanguage); + contributorRecyclerView = findViewById(R.id.rvContributors); mAppBarLayout = findViewById(R.id.appBarLayout); mCollapsingToolbarLayout = findViewById(R.id.collapsing_toolbar_layout); mTitleTextView = findViewById(R.id.text_view_title); @@ -177,6 +181,10 @@ private void initAdapter() { languageAdapter = new LanguageAdapter(DataUtils.getLanguages(this)); recyclerView.setAdapter(languageAdapter); recyclerView.setLayoutManager(new LinearLayoutManager(this)); + + contributorAdapter = new ContributorAdapter(DataUtils.getContributors(this)); + contributorRecyclerView.setAdapter(contributorAdapter); + contributorRecyclerView.setLayoutManager(new LinearLayoutManager(this)); } /** diff --git a/app/src/main/java/com/amaze/filemanager/ui/views/appbar/SearchView.java b/app/src/main/java/com/amaze/filemanager/ui/views/appbar/SearchView.java index 0d6cc43adf..1397fcaee0 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/views/appbar/SearchView.java +++ b/app/src/main/java/com/amaze/filemanager/ui/views/appbar/SearchView.java @@ -61,14 +61,12 @@ import android.text.TextWatcher; import android.text.style.ForegroundColorSpan; import android.text.style.StyleSpan; -import android.util.Log; import android.view.ContextThemeWrapper; import android.view.View; import android.view.ViewAnimationUtils; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; -import android.widget.Toast; import androidx.appcompat.widget.AppCompatButton; import androidx.appcompat.widget.AppCompatEditText; @@ -374,16 +372,11 @@ private void resetSearchMode() { * @param searchTerm The search term that resulted in the search results */ private void updateResultList(List newResults, String searchTerm) { - if (newResults == null) { - Toast.makeText(mainActivity, "No data found", Toast.LENGTH_SHORT).show(); - } else { - Log.e("TAG", "updateResultList: " + newResults + " " + searchTerm); - ArrayList items = new ArrayList<>(newResults); - Collections.sort( - items, new SearchResultListSorter(DirSortBy.NONE_ON_TOP, sortType, searchTerm)); - searchRecyclerViewAdapter.submitList(items); - searchRecyclerViewAdapter.notifyDataSetChanged(); - } + ArrayList items = new ArrayList<>(newResults); + Collections.sort( + items, new SearchResultListSorter(DirSortBy.NONE_ON_TOP, sortType, searchTerm)); + searchRecyclerViewAdapter.submitList(items); + searchRecyclerViewAdapter.notifyDataSetChanged(); } /** show search view with a circular reveal animation */ @@ -485,7 +478,6 @@ private void onSortTypeSelected(MaterialDialog dialog, int index, SortOrder sort updateSearchResultsSortButtonDisplay(); LiveData> lastSearchLiveData = mainActivity.getCurrentMainFragment().getMainActivityViewModel().getLastSearchLiveData(); - Log.e("TAG", "onSortTypeSelected: " + lastSearchLiveData.getValue()); updateResultList(lastSearchLiveData.getValue(), getSearchTerm()); } diff --git a/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java b/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java index 70999f9a93..74b83d8f1a 100644 --- a/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java +++ b/app/src/main/java/com/amaze/filemanager/utils/DataUtils.java @@ -171,6 +171,42 @@ public static List getLanguages(Context context) { return data; } + public static List getContributors(Context context) { + + var data = new ArrayList(); + + data.add( + new LanguageModel( + context.getString(R.string.contributor_1_title), + context.getString(R.string.contributors_1_summary))); + data.add( + new LanguageModel( + context.getString(R.string.contributor_2_title), + context.getString(R.string.contributors_2_summary))); + data.add( + new LanguageModel( + context.getString(R.string.contributor_3_title), + context.getString(R.string.contributors_3_summary))); + data.add( + new LanguageModel( + context.getString(R.string.contributor_4_title), + context.getString(R.string.contributors_4_summary))); + data.add( + new LanguageModel( + context.getString(R.string.contributor_5_title), + context.getString(R.string.contributors_5_summary))); + data.add( + new LanguageModel( + context.getString(R.string.contributor_6_title), + context.getString(R.string.contributors_6_summary))); + data.add( + new LanguageModel( + context.getString(R.string.contributor_7_title), + context.getString(R.string.contributors_7_summary))); + + return data; + } + public static DataUtils getInstance() { return DataUtilsHolder.INSTANCE; } diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index a69389292f..e912c70ba6 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -791,155 +791,14 @@ android:textColor="@android:color/darker_gray" /> - - - - - - - - - - - - - - - - - - - - - - From 1c4cdd435c3ae042b2867a4c9d7eef7df18b2113 Mon Sep 17 00:00:00 2001 From: VishnuSanal Date: Thu, 25 Jul 2024 22:54:53 +0530 Subject: [PATCH 7/7] chore: cleanup --- .../com/amaze/filemanager/ui/fragments/TabFragment.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java b/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java index 8b7ccbe01f..9cfe88053c 100644 --- a/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java +++ b/app/src/main/java/com/amaze/filemanager/ui/fragments/TabFragment.java @@ -106,12 +106,6 @@ public class TabFragment extends Fragment { private final ArgbEvaluator evaluator = new ArgbEvaluator(); private ConstraintLayout dragPlaceholder; - @Override - public void onResume() { - super.onResume(); - LOG.error("onResume called"); - } - @Override public View onCreateView( LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {