Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce Overdraw on About activity #4222

Open
wants to merge 7 commits into
base: release/4.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (C) 2014-2024 Arpit Khurana <[email protected]>, Vishal Nehra <[email protected]>,
* Emmanuel Messulam<[email protected]>, Raymond Lai <airwave209gt at gmail.com> 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 <http://www.gnu.org/licenses/>.
*/
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<LanguageModel>) : RecyclerView.Adapter<ContributorAdapter.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,
) {
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)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (C) 2014-2024 Arpit Khurana <[email protected]>, Vishal Nehra <[email protected]>,
* Emmanuel Messulam<[email protected]>, Raymond Lai <airwave209gt at gmail.com> 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 <http://www.gnu.org/licenses/>.
*/
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<LanguageModel>) : RecyclerView.Adapter<LanguageAdapter.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,
) {
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)
}
}
22 changes: 22 additions & 0 deletions app/src/main/java/com/amaze/filemanager/models/LanguageModel.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (C) 2014-2024 Arpit Khurana <[email protected]>, Vishal Nehra <[email protected]>,
* Emmanuel Messulam<[email protected]>, Raymond Lai <airwave209gt at gmail.com> 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 <http://www.gnu.org/licenses/>.
*/
package com.amaze.filemanager.models

data class LanguageModel(var title: String, var description: String)
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@

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;
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;
Expand All @@ -56,6 +59,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 {
Expand All @@ -64,6 +69,10 @@ 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 ContributorAdapter contributorAdapter;
private RecyclerView recyclerView;
private RecyclerView contributorRecyclerView;
private AppBarLayout mAppBarLayout;
private CollapsingToolbarLayout mCollapsingToolbarLayout;
private AppCompatTextView mTitleTextView;
Expand Down Expand Up @@ -104,6 +113,8 @@ 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);
Expand All @@ -123,6 +134,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(
Expand Down Expand Up @@ -163,6 +176,17 @@ public void onCreate(@Nullable Bundle savedInstanceState) {
}
}

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));
}

/**
* Calculates aspect ratio for the Amaze header
*
Expand Down Expand Up @@ -233,11 +257,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
Expand Down
123 changes: 123 additions & 0 deletions app/src/main/java/com/amaze/filemanager/utils/DataUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -84,6 +87,126 @@ private static class DataUtilsHolder {
private static final DataUtils INSTANCE = new DataUtils();
}

public static List<LanguageModel> getLanguages(Context context) {

var data = new ArrayList<LanguageModel>();

data.add(
new LanguageModel(
context.getString(R.string.german_translation_title),
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)));
data.add(
new LanguageModel(
context.getString(R.string.french_translation_title),
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)));
data.add(
new LanguageModel(
context.getString(R.string.spanish_translation_title),
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)));
data.add(
new LanguageModel(
context.getString(R.string.chinese_translation_title),
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)));
data.add(
new LanguageModel(
context.getString(R.string.turkish_translation_title),
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)));
data.add(
new LanguageModel(
context.getString(R.string.portuguese_translation_title),
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)));
data.add(
new LanguageModel(
context.getString(R.string.korean_translation_title),
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)));
data.add(
new LanguageModel(
context.getString(R.string.dutch_translation_title),
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)));
data.add(
new LanguageModel(
context.getString(R.string.vietnamese_translation_title),
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)));
data.add(
new LanguageModel(
context.getString(R.string.tamil_translation_title),
context.getString(R.string.tamil_translation_summary)));

return data;
}

public static List<LanguageModel> getContributors(Context context) {

var data = new ArrayList<LanguageModel>();

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;
}
Expand Down
Loading
Loading