2017-07-04 09:31:53 +02:00
|
|
|
package org.schabi.newpipe.about;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.os.Bundle;
|
2020-03-31 19:20:15 +02:00
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.MenuItem;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
|
2020-10-18 01:15:10 +02:00
|
|
|
import androidx.annotation.NonNull;
|
2020-03-31 19:20:15 +02:00
|
|
|
import androidx.appcompat.app.AppCompatActivity;
|
2019-10-04 14:59:08 +02:00
|
|
|
import androidx.fragment.app.Fragment;
|
2020-10-31 20:54:39 +01:00
|
|
|
import androidx.fragment.app.FragmentActivity;
|
2020-10-18 01:15:10 +02:00
|
|
|
import androidx.viewpager2.adapter.FragmentStateAdapter;
|
2020-03-31 19:20:15 +02:00
|
|
|
|
2020-10-18 01:15:10 +02:00
|
|
|
import com.google.android.material.tabs.TabLayoutMediator;
|
2017-07-04 09:31:53 +02:00
|
|
|
|
|
|
|
import org.schabi.newpipe.BuildConfig;
|
|
|
|
import org.schabi.newpipe.R;
|
2020-10-31 07:04:48 +01:00
|
|
|
import org.schabi.newpipe.databinding.ActivityAboutBinding;
|
|
|
|
import org.schabi.newpipe.databinding.FragmentAboutBinding;
|
2017-07-04 09:31:53 +02:00
|
|
|
import org.schabi.newpipe.util.ThemeHelper;
|
|
|
|
|
2020-01-28 20:48:42 +01:00
|
|
|
import static org.schabi.newpipe.util.Localization.assureCorrectAppLanguage;
|
2020-05-31 12:17:54 +02:00
|
|
|
import static org.schabi.newpipe.util.ShareUtils.openUrlInBrowser;
|
2020-01-09 09:40:05 +01:00
|
|
|
|
2017-07-04 09:31:53 +02:00
|
|
|
public class AboutActivity extends AppCompatActivity {
|
|
|
|
/**
|
2020-03-31 19:20:15 +02:00
|
|
|
* List of all software components.
|
2017-07-04 09:31:53 +02:00
|
|
|
*/
|
2020-11-18 23:52:30 +01:00
|
|
|
private static final SoftwareComponent[] SOFTWARE_COMPONENTS = {
|
2020-03-31 19:20:15 +02:00
|
|
|
new SoftwareComponent("Giga Get", "2014 - 2015", "Peter Cai",
|
2020-11-15 14:41:43 +01:00
|
|
|
"https://github.com/PaperAirplane-Dev-Team/GigaGet", StandardLicenses.GPL3),
|
2020-03-31 19:20:15 +02:00
|
|
|
new SoftwareComponent("NewPipe Extractor", "2017 - 2020", "Christian Schabesberger",
|
|
|
|
"https://github.com/TeamNewPipe/NewPipeExtractor", StandardLicenses.GPL3),
|
|
|
|
new SoftwareComponent("Jsoup", "2017", "Jonathan Hedley",
|
|
|
|
"https://github.com/jhy/jsoup", StandardLicenses.MIT),
|
|
|
|
new SoftwareComponent("Rhino", "2015", "Mozilla",
|
|
|
|
"https://www.mozilla.org/rhino/", StandardLicenses.MPL2),
|
|
|
|
new SoftwareComponent("ACRA", "2013", "Kevin Gaudin",
|
|
|
|
"http://www.acra.ch", StandardLicenses.APACHE2),
|
|
|
|
new SoftwareComponent("Universal Image Loader", "2011 - 2015", "Sergey Tarasevich",
|
|
|
|
"https://github.com/nostra13/Android-Universal-Image-Loader",
|
|
|
|
StandardLicenses.APACHE2),
|
|
|
|
new SoftwareComponent("CircleImageView", "2014 - 2020", "Henning Dodenhof",
|
|
|
|
"https://github.com/hdodenhof/CircleImageView", StandardLicenses.APACHE2),
|
|
|
|
new SoftwareComponent("NoNonsense-FilePicker", "2016", "Jonas Kalderstam",
|
|
|
|
"https://github.com/spacecowboy/NoNonsense-FilePicker", StandardLicenses.MPL2),
|
|
|
|
new SoftwareComponent("ExoPlayer", "2014 - 2020", "Google Inc",
|
|
|
|
"https://github.com/google/ExoPlayer", StandardLicenses.APACHE2),
|
|
|
|
new SoftwareComponent("RxAndroid", "2015 - 2018", "The RxAndroid authors",
|
|
|
|
"https://github.com/ReactiveX/RxAndroid", StandardLicenses.APACHE2),
|
|
|
|
new SoftwareComponent("RxJava", "2016 - 2020", "RxJava Contributors",
|
|
|
|
"https://github.com/ReactiveX/RxJava", StandardLicenses.APACHE2),
|
|
|
|
new SoftwareComponent("RxBinding", "2015 - 2018", "Jake Wharton",
|
|
|
|
"https://github.com/JakeWharton/RxBinding", StandardLicenses.APACHE2),
|
|
|
|
new SoftwareComponent("PrettyTime", "2012 - 2020", "Lincoln Baxter, III",
|
|
|
|
"https://github.com/ocpsoft/prettytime", StandardLicenses.APACHE2),
|
|
|
|
new SoftwareComponent("Markwon", "2017 - 2020", "Noties",
|
|
|
|
"https://github.com/noties/Markwon", StandardLicenses.APACHE2),
|
|
|
|
new SoftwareComponent("Groupie", "2016", "Lisa Wray",
|
|
|
|
"https://github.com/lisawray/groupie", StandardLicenses.MIT)
|
2017-07-04 09:31:53 +02:00
|
|
|
};
|
|
|
|
|
2020-10-18 01:15:10 +02:00
|
|
|
private static final int POS_ABOUT = 0;
|
|
|
|
private static final int POS_LICENSE = 1;
|
|
|
|
private static final int TOTAL_COUNT = 2;
|
2017-07-04 09:31:53 +02:00
|
|
|
|
|
|
|
@Override
|
2020-03-31 19:20:15 +02:00
|
|
|
protected void onCreate(final Bundle savedInstanceState) {
|
2020-01-28 20:48:42 +01:00
|
|
|
assureCorrectAppLanguage(this);
|
2017-07-04 09:31:53 +02:00
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
ThemeHelper.setTheme(this);
|
2020-10-31 07:04:48 +01:00
|
|
|
setTitle(getString(R.string.title_activity_about));
|
2017-07-04 09:31:53 +02:00
|
|
|
|
2020-10-31 07:04:48 +01:00
|
|
|
final ActivityAboutBinding aboutBinding = ActivityAboutBinding.inflate(getLayoutInflater());
|
|
|
|
setContentView(aboutBinding.getRoot());
|
2017-07-04 09:31:53 +02:00
|
|
|
|
2020-10-31 07:04:48 +01:00
|
|
|
setSupportActionBar(aboutBinding.toolbar);
|
2017-07-04 09:31:53 +02:00
|
|
|
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
|
|
|
// Create the adapter that will return a fragment for each of the three
|
|
|
|
// primary sections of the activity.
|
2020-10-31 07:04:48 +01:00
|
|
|
final SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(this);
|
2017-07-04 09:31:53 +02:00
|
|
|
|
|
|
|
// Set up the ViewPager with the sections adapter.
|
2020-10-31 07:04:48 +01:00
|
|
|
aboutBinding.container.setAdapter(mSectionsPagerAdapter);
|
2017-07-04 09:31:53 +02:00
|
|
|
|
2020-10-31 07:04:48 +01:00
|
|
|
new TabLayoutMediator(aboutBinding.tabs, aboutBinding.container, (tab, position) -> {
|
2020-10-18 01:15:10 +02:00
|
|
|
switch (position) {
|
|
|
|
default:
|
|
|
|
case POS_ABOUT:
|
|
|
|
tab.setText(R.string.tab_about);
|
|
|
|
break;
|
|
|
|
case POS_LICENSE:
|
|
|
|
tab.setText(R.string.tab_licenses);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}).attach();
|
2017-07-04 09:31:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-03-31 19:20:15 +02:00
|
|
|
public boolean onOptionsItemSelected(final MenuItem item) {
|
2020-08-16 10:24:58 +02:00
|
|
|
final int id = item.getItemId();
|
2017-07-04 09:31:53 +02:00
|
|
|
|
|
|
|
switch (id) {
|
2017-07-11 12:52:20 +02:00
|
|
|
case android.R.id.home:
|
|
|
|
finish();
|
|
|
|
return true;
|
2017-07-04 09:31:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A placeholder fragment containing a simple view.
|
|
|
|
*/
|
|
|
|
public static class AboutFragment extends Fragment {
|
2020-03-31 19:20:15 +02:00
|
|
|
public AboutFragment() { }
|
2017-07-04 09:31:53 +02:00
|
|
|
|
|
|
|
/**
|
2020-03-31 19:20:15 +02:00
|
|
|
* Created a new instance of this fragment for the given section number.
|
|
|
|
*
|
|
|
|
* @return New instance of {@link AboutFragment}
|
2017-07-04 09:31:53 +02:00
|
|
|
*/
|
|
|
|
public static AboutFragment newInstance() {
|
|
|
|
return new AboutFragment();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-10-31 07:04:48 +01:00
|
|
|
public View onCreateView(@NonNull final LayoutInflater inflater, final ViewGroup container,
|
2020-03-31 19:20:15 +02:00
|
|
|
final Bundle savedInstanceState) {
|
2020-10-31 07:04:48 +01:00
|
|
|
final FragmentAboutBinding aboutBinding =
|
|
|
|
FragmentAboutBinding.inflate(inflater, container, false);
|
|
|
|
final Context context = getContext();
|
2018-05-24 17:10:28 +02:00
|
|
|
|
2020-10-31 07:04:48 +01:00
|
|
|
aboutBinding.appVersion.setText(BuildConfig.VERSION_NAME);
|
2017-07-04 09:31:53 +02:00
|
|
|
|
2020-10-31 07:04:48 +01:00
|
|
|
aboutBinding.githubLink.setOnClickListener(nv ->
|
2020-05-31 12:17:54 +02:00
|
|
|
openUrlInBrowser(context, context.getString(R.string.github_url)));
|
2017-07-04 09:31:53 +02:00
|
|
|
|
2020-10-31 07:04:48 +01:00
|
|
|
aboutBinding.donationLink.setOnClickListener(v ->
|
2020-05-31 12:17:54 +02:00
|
|
|
openUrlInBrowser(context, context.getString(R.string.donation_url)));
|
2017-12-05 17:07:31 +01:00
|
|
|
|
2020-10-31 07:04:48 +01:00
|
|
|
aboutBinding.websiteLink.setOnClickListener(nv ->
|
2020-05-31 12:17:54 +02:00
|
|
|
openUrlInBrowser(context, context.getString(R.string.website_url)));
|
2017-12-05 17:07:31 +01:00
|
|
|
|
2020-10-31 07:04:48 +01:00
|
|
|
aboutBinding.privacyPolicyLink.setOnClickListener(v ->
|
2020-05-31 12:17:54 +02:00
|
|
|
openUrlInBrowser(context, context.getString(R.string.privacy_policy_url)));
|
2017-07-04 09:31:53 +02:00
|
|
|
|
2020-10-31 07:04:48 +01:00
|
|
|
return aboutBinding.getRoot();
|
2017-07-04 09:31:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-10-18 01:15:10 +02:00
|
|
|
* A {@link FragmentStateAdapter} that returns a fragment corresponding to
|
2017-07-04 09:31:53 +02:00
|
|
|
* one of the sections/tabs/pages.
|
|
|
|
*/
|
2020-10-18 01:15:10 +02:00
|
|
|
public static class SectionsPagerAdapter extends FragmentStateAdapter {
|
2020-10-31 20:54:39 +01:00
|
|
|
public SectionsPagerAdapter(final FragmentActivity fa) {
|
|
|
|
super(fa);
|
2017-07-04 09:31:53 +02:00
|
|
|
}
|
|
|
|
|
2020-10-18 01:15:10 +02:00
|
|
|
@NonNull
|
2017-07-04 09:31:53 +02:00
|
|
|
@Override
|
2020-10-18 01:15:10 +02:00
|
|
|
public Fragment createFragment(final int position) {
|
2017-07-04 09:31:53 +02:00
|
|
|
switch (position) {
|
2020-10-18 01:15:10 +02:00
|
|
|
default:
|
|
|
|
case POS_ABOUT:
|
2017-07-04 09:31:53 +02:00
|
|
|
return AboutFragment.newInstance();
|
2020-10-18 01:15:10 +02:00
|
|
|
case POS_LICENSE:
|
2017-07-04 09:31:53 +02:00
|
|
|
return LicenseFragment.newInstance(SOFTWARE_COMPONENTS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-10-18 01:15:10 +02:00
|
|
|
public int getItemCount() {
|
2017-07-04 09:31:53 +02:00
|
|
|
// Show 2 total pages.
|
2020-10-18 01:15:10 +02:00
|
|
|
return TOTAL_COUNT;
|
2017-07-04 09:31:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|