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 3 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,74 @@
/*
VishnuSanal marked this conversation as resolved.
Show resolved Hide resolved
* 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; // 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<LanguageAdapter.ViewHolder> {

private List<LanguageModel> dataList;

public LanguageAdapter(List<LanguageModel> 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);
}
}
}
48 changes: 48 additions & 0 deletions app/src/main/java/com/amaze/filemanager/models/LanguageModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
VishnuSanal marked this conversation as resolved.
Show resolved Hide resolved
* 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;

// 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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(
Expand Down Expand Up @@ -163,6 +172,13 @@ 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
*
Expand Down Expand Up @@ -233,11 +249,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
107 changes: 107 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,110 @@ private static class DataUtilsHolder {
private static final DataUtils INSTANCE = new DataUtils();
}

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

var data = new ArrayList<LanguageModel>();

var lang1 =
VishnuSanal marked this conversation as resolved.
Show resolved Hide resolved
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;
}
Expand Down
Loading
Loading