diff --git a/app/src/main/assets/special_thanks.csv b/app/src/main/assets/special_thanks.csv new file mode 100644 index 000000000..348e3208e --- /dev/null +++ b/app/src/main/assets/special_thanks.csv @@ -0,0 +1,3 @@ +221 Pixels;Logo design;https://avatars2.githubusercontent.com/u/58243143?s=60&v=4 +ByteHamster;Forum admin;https://avatars2.githubusercontent.com/u/5811634?s=60&v=4 +Keunes;Communications;https://avatars2.githubusercontent.com/u/11229646?s=60&v=4 diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java index 406585808..05ea521a9 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java @@ -10,6 +10,7 @@ import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.BugReportActivity; import de.danoeh.antennapod.activity.PreferenceActivity; import de.danoeh.antennapod.core.util.IntentUtils; +import de.danoeh.antennapod.fragment.preferences.about.AboutFragment; public class MainPreferencesFragment extends PreferenceFragmentCompat { private static final String TAG = "MainPreferencesFragment"; diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/AboutFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/AboutFragment.java similarity index 72% rename from app/src/main/java/de/danoeh/antennapod/fragment/preferences/AboutFragment.java rename to app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/AboutFragment.java index 0fa7bd4bb..b440d053b 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/AboutFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/AboutFragment.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.fragment.preferences; +package de.danoeh.antennapod.fragment.preferences.about; import android.content.ClipData; import android.content.ClipboardManager; @@ -27,14 +27,9 @@ public class AboutFragment extends PreferenceFragmentCompat { Snackbar.make(getView(), R.string.copied_to_clipboard, Snackbar.LENGTH_SHORT).show(); return true; }); - findPreference("about_developers").setOnPreferenceClickListener((preference) -> { - getFragmentManager().beginTransaction().replace(R.id.content, new AboutDevelopersFragment()) - .addToBackStack(getString(R.string.developers)).commit(); - return true; - }); - findPreference("about_translators").setOnPreferenceClickListener((preference) -> { - getFragmentManager().beginTransaction().replace(R.id.content, new AboutTranslatorsFragment()) - .addToBackStack(getString(R.string.translators)).commit(); + findPreference("about_contributors").setOnPreferenceClickListener((preference) -> { + getParentFragmentManager().beginTransaction().replace(R.id.content, new ContributorsPagerFragment()) + .addToBackStack(getString(R.string.contributors)).commit(); return true; }); findPreference("about_privacy_policy").setOnPreferenceClickListener((preference) -> { @@ -42,7 +37,7 @@ public class AboutFragment extends PreferenceFragmentCompat { return true; }); findPreference("about_licenses").setOnPreferenceClickListener((preference) -> { - getFragmentManager().beginTransaction().replace(R.id.content, new AboutLicensesFragment()) + getParentFragmentManager().beginTransaction().replace(R.id.content, new LicensesFragment()) .addToBackStack(getString(R.string.translators)).commit(); return true; }); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/ContributorsPagerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/ContributorsPagerFragment.java new file mode 100644 index 000000000..20cef1313 --- /dev/null +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/ContributorsPagerFragment.java @@ -0,0 +1,95 @@ +package de.danoeh.antennapod.fragment.preferences.about; + +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import androidx.annotation.NonNull; +import androidx.fragment.app.Fragment; +import androidx.viewpager2.adapter.FragmentStateAdapter; +import androidx.viewpager2.widget.ViewPager2; +import com.google.android.material.tabs.TabLayout; +import com.google.android.material.tabs.TabLayoutMediator; +import de.danoeh.antennapod.R; +import de.danoeh.antennapod.activity.PreferenceActivity; + +/** + * Displays the 'about->Contributors' pager screen. + */ +public class ContributorsPagerFragment extends Fragment { + + public static final String TAG = "StatisticsFragment"; + + private static final int POS_DEVELOPERS = 0; + private static final int POS_TRANSLATORS = 1; + private static final int POS_SPECIAL_THANKS = 2; + private static final int TOTAL_COUNT = 3; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + } + + public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + super.onCreateView(inflater, container, savedInstanceState); + setHasOptionsMenu(true); + + View rootView = inflater.inflate(R.layout.pager_fragment, container, false); + ViewPager2 viewPager = rootView.findViewById(R.id.viewpager); + viewPager.setAdapter(new StatisticsPagerAdapter(this)); + // Give the TabLayout the ViewPager + TabLayout tabLayout = rootView.findViewById(R.id.sliding_tabs); + new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> { + switch (position) { + case POS_DEVELOPERS: + tab.setText(R.string.developers); + break; + case POS_TRANSLATORS: + tab.setText(R.string.translators); + break; + case POS_SPECIAL_THANKS: + tab.setText(R.string.special_thanks); + break; + default: + break; + } + }).attach(); + + rootView.findViewById(R.id.toolbar).setVisibility(View.GONE); + + return rootView; + } + + @Override + public void onStart() { + super.onStart(); + ((PreferenceActivity) getActivity()).getSupportActionBar().setTitle(R.string.contributors); + } + + public static class StatisticsPagerAdapter extends FragmentStateAdapter { + + StatisticsPagerAdapter(@NonNull Fragment fragment) { + super(fragment); + } + + @NonNull + @Override + public Fragment createFragment(int position) { + switch (position) { + case POS_TRANSLATORS: + return new TranslatorsFragment(); + case POS_SPECIAL_THANKS: + return new SpecialThanksFragment(); + default: + case POS_DEVELOPERS: + return new DevelopersFragment(); + } + } + + @Override + public int getItemCount() { + return TOTAL_COUNT; + } + } +} diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/AboutDevelopersFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/DevelopersFragment.java similarity index 83% rename from app/src/main/java/de/danoeh/antennapod/fragment/preferences/AboutDevelopersFragment.java rename to app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/DevelopersFragment.java index 62a5eb306..60d9f95dd 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/AboutDevelopersFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/DevelopersFragment.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.fragment.preferences; +package de.danoeh.antennapod.fragment.preferences.about; import android.os.Bundle; import android.view.View; @@ -19,7 +19,7 @@ import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; -public class AboutDevelopersFragment extends ListFragment { +public class DevelopersFragment extends ListFragment { private Disposable developersLoader; @Override @@ -44,7 +44,7 @@ public class AboutDevelopersFragment extends ListFragment { .observeOn(AndroidSchedulers.mainThread()) .subscribe( developers -> setListAdapter(new SimpleIconListAdapter<>(getContext(), developers)), - error -> Toast.makeText(getContext(), "Error while loading developers", Toast.LENGTH_LONG).show() + error -> Toast.makeText(getContext(), error.getMessage(), Toast.LENGTH_LONG).show() ); } @@ -56,10 +56,4 @@ public class AboutDevelopersFragment extends ListFragment { developersLoader.dispose(); } } - - @Override - public void onStart() { - super.onStart(); - ((PreferenceActivity) getActivity()).getSupportActionBar().setTitle(R.string.developers); - } } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/AboutLicensesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/LicensesFragment.java similarity index 95% rename from app/src/main/java/de/danoeh/antennapod/fragment/preferences/AboutLicensesFragment.java rename to app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/LicensesFragment.java index 536d11e01..97565a613 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/AboutLicensesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/LicensesFragment.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.fragment.preferences; +package de.danoeh.antennapod.fragment.preferences.about; import android.os.Bundle; import android.view.View; @@ -28,7 +28,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; -public class AboutLicensesFragment extends ListFragment { +public class LicensesFragment extends ListFragment { private Disposable licensesLoader; private final ArrayList licenses = new ArrayList<>(); @@ -59,7 +59,7 @@ public class AboutLicensesFragment extends ListFragment { .observeOn(AndroidSchedulers.mainThread()) .subscribe( developers -> setListAdapter(new SimpleIconListAdapter(getContext(), developers)), - error -> Toast.makeText(getContext(), "Error while loading licenses", Toast.LENGTH_LONG).show() + error -> Toast.makeText(getContext(), error.getMessage(), Toast.LENGTH_LONG).show() ); } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/SpecialThanksFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/SpecialThanksFragment.java new file mode 100644 index 000000000..6db1389ea --- /dev/null +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/SpecialThanksFragment.java @@ -0,0 +1,58 @@ +package de.danoeh.antennapod.fragment.preferences.about; + +import android.os.Bundle; +import android.view.View; +import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.ListFragment; +import de.danoeh.antennapod.R; +import de.danoeh.antennapod.activity.PreferenceActivity; +import de.danoeh.antennapod.adapter.SimpleIconListAdapter; +import io.reactivex.Single; +import io.reactivex.SingleOnSubscribe; +import io.reactivex.android.schedulers.AndroidSchedulers; +import io.reactivex.disposables.Disposable; +import io.reactivex.schedulers.Schedulers; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; + +public class SpecialThanksFragment extends ListFragment { + private Disposable translatorsLoader; + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + getListView().setDivider(null); + getListView().setSelector(android.R.color.transparent); + + translatorsLoader = Single.create((SingleOnSubscribe>) emitter -> { + ArrayList translators = new ArrayList<>(); + BufferedReader reader = new BufferedReader(new InputStreamReader( + getContext().getAssets().open("special_thanks.csv"))); + String line; + while ((line = reader.readLine()) != null) { + String[] info = line.split(";"); + translators.add(new SimpleIconListAdapter.ListItem(info[0], info[1], info[2])); + } + emitter.onSuccess(translators); + }) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe( + translators -> setListAdapter(new SimpleIconListAdapter<>(getContext(), translators)), + error -> Toast.makeText(getContext(), error.getMessage(), Toast.LENGTH_LONG).show() + ); + + } + + @Override + public void onStop() { + super.onStop(); + if (translatorsLoader != null) { + translatorsLoader.dispose(); + } + } +} diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/AboutTranslatorsFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/TranslatorsFragment.java similarity index 83% rename from app/src/main/java/de/danoeh/antennapod/fragment/preferences/AboutTranslatorsFragment.java rename to app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/TranslatorsFragment.java index 914dbb9a2..e8d8e113b 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/AboutTranslatorsFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/about/TranslatorsFragment.java @@ -1,4 +1,4 @@ -package de.danoeh.antennapod.fragment.preferences; +package de.danoeh.antennapod.fragment.preferences.about; import android.os.Bundle; import android.view.View; @@ -19,7 +19,7 @@ import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; -public class AboutTranslatorsFragment extends ListFragment { +public class TranslatorsFragment extends ListFragment { private Disposable translatorsLoader; @Override @@ -43,7 +43,7 @@ public class AboutTranslatorsFragment extends ListFragment { .observeOn(AndroidSchedulers.mainThread()) .subscribe( translators -> setListAdapter(new SimpleIconListAdapter<>(getContext(), translators)), - error -> Toast.makeText(getContext(), "Error while loading translators", Toast.LENGTH_LONG).show() + error -> Toast.makeText(getContext(), error.getMessage(), Toast.LENGTH_LONG).show() ); } @@ -55,10 +55,4 @@ public class AboutTranslatorsFragment extends ListFragment { translatorsLoader.dispose(); } } - - @Override - public void onStart() { - super.onStart(); - ((PreferenceActivity) getActivity()).getSupportActionBar().setTitle(R.string.translators); - } } diff --git a/app/src/main/res/xml/preferences_about.xml b/app/src/main/res/xml/preferences_about.xml index 9b8d744e1..475a1152f 100644 --- a/app/src/main/res/xml/preferences_about.xml +++ b/app/src/main/res/xml/preferences_about.xml @@ -10,15 +10,10 @@ android:icon="?attr/ic_unfav" android:summary="1.7.2 (asd8qs)"/> - + android:summary="@string/contributors_summary" + android:title="@string/contributors"/> About AntennaPod version + Contributors + Everyone can help to make AntennaPod better - with code, translations or by helping users in our forum Developers - Everyone can help to make AntennaPod better Translators - Translations are created by users of AntennaPod using Transifex + Special thanks Privacy policy Licenses AntennaPod uses other great software