package protect.card_locker; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.os.Bundle; import android.text.method.LinkMovementMethod; import android.util.Log; import android.view.MenuItem; import android.widget.TextView; import java.util.ArrayList; import java.util.Calendar; import java.util.List; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.core.text.HtmlCompat; public class AboutActivity extends AppCompatActivity { private static final String TAG = "Catima"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.about_activity); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); if(actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); } final List USED_LIBRARIES = new ArrayList<>(); USED_LIBRARIES.add(new ThirdPartyInfo("Color Picker", "https://github.com/jaredrummler/ColorPicker", "Apache 2.0")); USED_LIBRARIES.add(new ThirdPartyInfo("Commons CSV", "https://commons.apache.org/proper/commons-csv/", "Apache 2.0")); USED_LIBRARIES.add(new ThirdPartyInfo("Guava", "https://github.com/google/guava", "Apache 2.0")); USED_LIBRARIES.add(new ThirdPartyInfo("NumberPickerPreference", "https://github.com/invissvenska/NumberPickerPreference", "GNU LGPL 3.0")); USED_LIBRARIES.add(new ThirdPartyInfo("Zip4j", "https://github.com/srikanth-lingala/zip4j", "Apache 2.0")); USED_LIBRARIES.add(new ThirdPartyInfo("ZXing", "https://github.com/zxing/zxing", "Apache 2.0")); USED_LIBRARIES.add(new ThirdPartyInfo("ZXing Android Embedded", "https://github.com/journeyapps/zxing-android-embedded", "Apache 2.0")); final List USED_ASSETS = new ArrayList<>(); USED_ASSETS.add(new ThirdPartyInfo("Android icons", "https://fonts.google.com/icons?selected=Material+Icons", "Apache 2.0")); StringBuilder libs = new StringBuilder().append("
"); for (ThirdPartyInfo entry : USED_LIBRARIES) { libs.append("
").append(entry.name()).append(" (").append(entry.license()).append(")
"); } StringBuilder resources = new StringBuilder().append("
"); for (ThirdPartyInfo entry : USED_ASSETS) { resources.append("
").append(entry.name()).append(" (").append(entry.license()).append(")
"); } String appName = getString(R.string.app_name); int year = Calendar.getInstance().get(Calendar.YEAR); String version = "?"; try { PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0); version = pi.versionName; } catch (PackageManager.NameNotFoundException e) { Log.w(TAG, "Package name not found", e); } setTitle(String.format(getString(R.string.about_title_fmt), appName)); TextView aboutTextView = findViewById(R.id.aboutText); aboutTextView.setText(HtmlCompat.fromHtml(String.format(getString(R.string.debug_version_fmt), version) + "

" + String.format(getString(R.string.app_revision_fmt), "" + "GitHub" + "") + "

" + String.format(getString(R.string.app_copyright_fmt), year) + "

" + getString(R.string.app_copyright_old) + "

" + getString(R.string.app_license) + "

" + String.format(getString(R.string.app_libraries), libs.toString()) + "

" + String.format(getString(R.string.app_resources), resources.toString()), HtmlCompat.FROM_HTML_MODE_COMPACT)); aboutTextView.setMovementMethod(LinkMovementMethod.getInstance()); } @Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == android.R.id.home) { finish(); } return super.onOptionsItemSelected(item); } }