Use AboutLibraries instead of LicenseDialog
This commit is contained in:
parent
29ad1d4eab
commit
f8b583f6d8
10 changed files with 342 additions and 369 deletions
|
@ -146,10 +146,10 @@ So make sure you have a **current backup** before switching!
|
|||
## Acknowledgments:
|
||||
#### Open-source components used:
|
||||
|
||||
* [AboutLibraries](https://github.com/mikepenz/AboutLibraries)
|
||||
* [Apache Commons Codec](https://commons.apache.org/proper/commons-codec/)
|
||||
* [Expandable Layout](https://github.com/AAkira/ExpandableLayout)
|
||||
* [FABsMenu](https://github.com/jahirfiquitiva/FABsMenu)
|
||||
* [LicensesDialog](https://github.com/PSDev/LicensesDialog)
|
||||
* [material-intro](https://github.com/heinrichreimer/material-intro)
|
||||
* [MaterialProgressBar](https://github.com/DreaminginCodeZH/MaterialProgressBar)
|
||||
* [OpenPGP API library](https://github.com/open-keychain/openpgp-api)
|
||||
|
@ -163,6 +163,10 @@ So make sure you have a **current backup** before switching!
|
|||
* [LetterBitmap](http://stackoverflow.com/questions/23122088/colored-boxed-with-letters-a-la-gmail)
|
||||
* [DimensionConverter](https://stackoverflow.com/questions/8343971/how-to-parse-a-dimension-string-and-convert-it-to-a-dimension-value)
|
||||
|
||||
#### Previously used open-source components:
|
||||
|
||||
* [LicensesDialog](https://github.com/PSDev/LicensesDialog)
|
||||
|
||||
#### Previously used code examples:
|
||||
|
||||
* [FloatingActionMenuAndroid](https://github.com/pmahsky/FloatingActionMenuAndroid)
|
||||
|
|
|
@ -31,11 +31,9 @@ android {
|
|||
}
|
||||
}
|
||||
|
||||
ext {
|
||||
supportLibVersion = "27.1.0"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
ext.supportLibVersion = "27.1.0"
|
||||
|
||||
implementation "commons-codec:commons-codec:1.11"
|
||||
implementation "com.android.support:appcompat-v7:$supportLibVersion"
|
||||
implementation "com.android.support:cardview-v7:$supportLibVersion"
|
||||
|
@ -46,8 +44,8 @@ dependencies {
|
|||
implementation "com.heinrichreimersoftware:material-intro:1.6.2"
|
||||
implementation "com.journeyapps:zxing-android-embedded:3.6.0"
|
||||
implementation "com.vanniktech:vntnumberpickerpreference:1.0.0"
|
||||
implementation "de.psdev.licensesdialog:licensesdialog:1.8.3"
|
||||
implementation "me.zhanghai.android.materialprogressbar:library:1.4.2"
|
||||
implementation "org.sufficientlysecure:openpgp-api:12.0"
|
||||
implementation "me.jahirfiquitiva:FABsMenu:1.1.2"
|
||||
implementation "com.mikepenz:aboutlibraries:6.0.6"
|
||||
}
|
||||
|
|
|
@ -22,60 +22,22 @@
|
|||
|
||||
package org.shadowice.flocke.andotp.Activities;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.TabLayout;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentPagerAdapter;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
import android.view.ViewStub;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mikepenz.aboutlibraries.LibsBuilder;
|
||||
|
||||
import org.shadowice.flocke.andotp.Fragments.AboutFragment;
|
||||
import org.shadowice.flocke.andotp.R;
|
||||
import org.shadowice.flocke.andotp.Utilities.Tools;
|
||||
|
||||
import de.psdev.licensesdialog.LicensesDialog;
|
||||
|
||||
public class AboutActivity extends BaseActivity {
|
||||
private static final String GITHUB_URI = "https://github.com/andOTP/andOTP";
|
||||
private static final String CHANGELOG_URI = GITHUB_URI + "/blob/master/CHANGELOG.md";
|
||||
private static final String MIT_URI = GITHUB_URI + "/blob/master/LICENSE.txt";
|
||||
|
||||
private static final String AUTHOR1_GITHUB = "https://github.com/flocke";
|
||||
private static final String AUTHOR1_EXTRA = "https://paypal.me/flocke000";
|
||||
|
||||
private static final String AUTHOR2_GITHUB = "https://github.com/richyhbm";
|
||||
private static final String AUTHOR2_EXTRA = "bitcoin:1KyLwnxXR577gYUtwRMSMhkpsJVoK2bTLN";
|
||||
|
||||
private static final String AUTHOR_ORIGINAL_GITHUB = "https://github.com/0xbb";
|
||||
private static final String AUTHOR_ORIGINAL_EXTRA = AUTHOR_ORIGINAL_GITHUB + "/otp-authenticator";
|
||||
|
||||
private static final String CONTRIBUTORS_URI = GITHUB_URI + "/blob/master/README.md#contributors";
|
||||
private static final String TRANSLATORS_URI = GITHUB_URI + "/blob/master/README.md#translators";
|
||||
|
||||
private static final String BUGREPORT_URI = GITHUB_URI + "/issues";
|
||||
private static final String TRANSLATE_URI = "https://crowdin.com/project/andotp";
|
||||
|
||||
static final int[] imageResources = {
|
||||
R.id.aboutImgVersion, R.id.aboutImgLicense, R.id.aboutImgChangelog, R.id.aboutImgSource,
|
||||
R.id.aboutImgOpenSource, R.id.aboutImgAuthor1, R.id.aboutImgAuthorOriginal, R.id.aboutImgContributors,
|
||||
R.id.aboutImgTranslators, R.id.aboutImgBugs, R.id.aboutImgTranslate
|
||||
};
|
||||
|
||||
static long lastTap = 0;
|
||||
static int taps = 0;
|
||||
static Toast currentToast = null;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -87,194 +49,16 @@ public class AboutActivity extends BaseActivity {
|
|||
setSupportActionBar(toolbar);
|
||||
|
||||
ViewStub stub = findViewById(R.id.container_stub);
|
||||
stub.setLayoutResource(R.layout.content_about);
|
||||
stub.setLayoutResource(R.layout.component_about);
|
||||
|
||||
View v = stub.inflate();
|
||||
|
||||
ColorFilter filter = Tools.getThemeColorFilter(this, android.R.attr.textColorSecondary);
|
||||
for (int i : imageResources) {
|
||||
ImageView imgView = v.findViewById(i);
|
||||
imgView.getDrawable().setColorFilter(filter);
|
||||
}
|
||||
ViewPager viewPager = v.findViewById(R.id.viewPager);
|
||||
TabLayout tabLayout = v.findViewById(R.id.tabLayout);
|
||||
AboutPageAdapter aboutPageAdapter = new AboutPageAdapter(getSupportFragmentManager());
|
||||
|
||||
String versionName = "";
|
||||
try {
|
||||
PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
|
||||
versionName = packageInfo.versionName;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
LinearLayout versionLayout = v.findViewById(R.id.about_layout_version);
|
||||
|
||||
versionLayout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
long thisTap = System.currentTimeMillis();
|
||||
|
||||
if (thisTap - lastTap < 500) {
|
||||
taps = taps + 1;
|
||||
|
||||
if (currentToast != null && taps <= 7)
|
||||
currentToast.cancel();
|
||||
|
||||
if (taps >= 3 && taps <= 7)
|
||||
currentToast = Toast.makeText(getBaseContext(), String.valueOf(taps), Toast.LENGTH_SHORT);
|
||||
|
||||
if (taps == 7) {
|
||||
if (settings.getSpecialFeatures())
|
||||
currentToast = Toast.makeText(getBaseContext(), R.string.about_toast_special_features_enabled, Toast.LENGTH_LONG);
|
||||
else
|
||||
enableSpecialFeatures();
|
||||
}
|
||||
|
||||
if (currentToast != null)
|
||||
currentToast.show();
|
||||
} else {
|
||||
taps = 0;
|
||||
}
|
||||
|
||||
lastTap = thisTap;
|
||||
}
|
||||
});
|
||||
|
||||
TextView version = v.findViewById(R.id.about_text_version);
|
||||
version.setText(versionName);
|
||||
|
||||
LinearLayout license = v.findViewById(R.id.about_layout_license);
|
||||
LinearLayout changelog = v.findViewById(R.id.about_layout_changelog);
|
||||
LinearLayout source = v.findViewById(R.id.about_layout_source);
|
||||
LinearLayout licenses = v.findViewById(R.id.about_layout_licenses);
|
||||
license.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openURI(MIT_URI);
|
||||
}
|
||||
});
|
||||
changelog.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openURI(CHANGELOG_URI);
|
||||
}
|
||||
});
|
||||
source.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openURI(GITHUB_URI);
|
||||
}
|
||||
});
|
||||
licenses.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
showLicenses();
|
||||
}
|
||||
});
|
||||
|
||||
TextView author1GitHub = v.findViewById(R.id.about_author1_github);
|
||||
TextView author1Paypal = v.findViewById(R.id.about_author1_extra);
|
||||
author1GitHub.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openURI(AUTHOR1_GITHUB);
|
||||
}
|
||||
});
|
||||
author1Paypal.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
try {
|
||||
openURI(AUTHOR1_EXTRA);
|
||||
} catch(Exception ignored) {
|
||||
copyToClipboard(AUTHOR1_EXTRA);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
TextView author2GitHub = v.findViewById(R.id.about_author2_github);
|
||||
TextView author2Paypal = v.findViewById(R.id.about_author2_extra);
|
||||
author2GitHub.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openURI(AUTHOR2_GITHUB);
|
||||
}
|
||||
});
|
||||
author2Paypal.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
try {
|
||||
openURI(AUTHOR2_EXTRA);
|
||||
} catch(Exception ignored) {
|
||||
copyToClipboard(AUTHOR2_EXTRA);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
TextView authorOriginalGitHub = v.findViewById(R.id.about_author_original_github);
|
||||
TextView authorOriginalApp = v.findViewById(R.id.about_author_original_extra);
|
||||
authorOriginalGitHub.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openURI(AUTHOR_ORIGINAL_GITHUB);
|
||||
}
|
||||
});
|
||||
authorOriginalApp.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
try {
|
||||
openURI(AUTHOR_ORIGINAL_EXTRA);
|
||||
} catch(Exception ignored) {
|
||||
copyToClipboard(AUTHOR_ORIGINAL_EXTRA);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
LinearLayout contributors = v.findViewById(R.id.about_layout_contributors);
|
||||
LinearLayout translators = v.findViewById(R.id.about_layout_translators);
|
||||
contributors.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openURI(CONTRIBUTORS_URI);
|
||||
}
|
||||
});
|
||||
translators.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openURI(TRANSLATORS_URI);
|
||||
}
|
||||
});
|
||||
|
||||
LinearLayout bugReport = v.findViewById(R.id.about_layout_bugs);
|
||||
LinearLayout translate = v.findViewById(R.id.about_layout_translate);
|
||||
bugReport.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openURI(BUGREPORT_URI);
|
||||
}
|
||||
});
|
||||
translate.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openURI(TRANSLATE_URI);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void enableSpecialFeatures() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setTitle(R.string.about_title_special_features)
|
||||
.setMessage(R.string.about_dialog_special_features)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
settings.setSpecialFeatures(true);
|
||||
Toast.makeText(getBaseContext(), R.string.about_toast_special_features, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {}
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
viewPager.setAdapter(aboutPageAdapter);
|
||||
tabLayout.setupWithViewPager(viewPager);
|
||||
}
|
||||
|
||||
// Go back to the main activity
|
||||
|
@ -290,35 +74,40 @@ public class AboutActivity extends BaseActivity {
|
|||
super.onBackPressed();
|
||||
}
|
||||
|
||||
public void openURI(String uri) {
|
||||
Intent openURI = new Intent(Intent.ACTION_VIEW);
|
||||
openURI.setData(Uri.parse(uri));
|
||||
startActivity(openURI);
|
||||
}
|
||||
private class AboutPageAdapter extends FragmentPagerAdapter {
|
||||
AboutPageAdapter(FragmentManager fm) {
|
||||
super(fm);
|
||||
}
|
||||
|
||||
public void copyToClipboard(String uri) {
|
||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("andOTP", uri);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toast.makeText(this, getString(R.string.about_toast_copied_to_clipboard), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
@Override
|
||||
public Fragment getItem(int pos) {
|
||||
switch(pos) {
|
||||
case 0:
|
||||
return new AboutFragment();
|
||||
case 1:
|
||||
return new LibsBuilder()
|
||||
.withFields(R.string.class.getFields())
|
||||
.supportFragment();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public void showLicenses() {
|
||||
String backgroundColor = Tools.getCSSRGBAString(Tools.getThemeColor(this, R.attr.colorBackgroundFloating));
|
||||
String textColor = Tools.getCSSRGBAString(Tools.getThemeColor(this, android.R.attr.textColorPrimary));
|
||||
String textColorSecondary = Tools.getCSSRGBAString(Tools.getThemeColor(this, android.R.attr.textColorSecondary));
|
||||
|
||||
String cssFormat = getString(R.string.custom_notices_style, backgroundColor, textColor, textColorSecondary);
|
||||
|
||||
LicensesDialog dialog = new LicensesDialog.Builder(this)
|
||||
.setNotices(R.raw.licenses)
|
||||
.setTitle(R.string.about_label_licenses)
|
||||
.setShowFullLicenseText(false)
|
||||
.setIncludeOwnLicense(true)
|
||||
.setNoticesCssStyle(cssFormat)
|
||||
.build();
|
||||
|
||||
dialog.show();
|
||||
@Override
|
||||
public String getPageTitle(int pos) {
|
||||
switch(pos) {
|
||||
case 0:
|
||||
return getString(R.string.about_tab_about);
|
||||
case 1:
|
||||
return getString(R.string.about_tab_libraries);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,263 @@
|
|||
package org.shadowice.flocke.andotp.Fragments;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.shadowice.flocke.andotp.R;
|
||||
import org.shadowice.flocke.andotp.Utilities.Settings;
|
||||
import org.shadowice.flocke.andotp.Utilities.Tools;
|
||||
|
||||
public class AboutFragment extends Fragment {
|
||||
private static final String GITHUB_URI = "https://github.com/andOTP/andOTP";
|
||||
private static final String CHANGELOG_URI = GITHUB_URI + "/blob/master/CHANGELOG.md";
|
||||
private static final String MIT_URI = GITHUB_URI + "/blob/master/LICENSE.txt";
|
||||
|
||||
private static final String AUTHOR1_GITHUB = "https://github.com/flocke";
|
||||
private static final String AUTHOR1_EXTRA = "https://paypal.me/flocke000";
|
||||
|
||||
private static final String AUTHOR2_GITHUB = "https://github.com/richyhbm";
|
||||
private static final String AUTHOR2_EXTRA = "bitcoin:1KyLwnxXR577gYUtwRMSMhkpsJVoK2bTLN";
|
||||
|
||||
private static final String AUTHOR_ORIGINAL_GITHUB = "https://github.com/0xbb";
|
||||
private static final String AUTHOR_ORIGINAL_EXTRA = AUTHOR_ORIGINAL_GITHUB + "/otp-authenticator";
|
||||
|
||||
private static final String CONTRIBUTORS_URI = GITHUB_URI + "/blob/master/README.md#contributors";
|
||||
private static final String TRANSLATORS_URI = GITHUB_URI + "/blob/master/README.md#translators";
|
||||
|
||||
private static final String BUGREPORT_URI = GITHUB_URI + "/issues";
|
||||
private static final String TRANSLATE_URI = "https://crowdin.com/project/andotp";
|
||||
|
||||
private Settings settings;
|
||||
|
||||
static final int[] imageResources = {
|
||||
R.id.aboutImgVersion, R.id.aboutImgLicense, R.id.aboutImgChangelog, R.id.aboutImgSource,
|
||||
R.id.aboutImgAuthor1, R.id.aboutImgAuthorOriginal, R.id.aboutImgContributors,
|
||||
R.id.aboutImgTranslators, R.id.aboutImgBugs, R.id.aboutImgTranslate
|
||||
};
|
||||
|
||||
static long lastTap = 0;
|
||||
static int taps = 0;
|
||||
static Toast currentToast = null;
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.fragment_about, container, false);
|
||||
|
||||
settings = new Settings(getActivity());
|
||||
|
||||
ColorFilter filter = Tools.getThemeColorFilter(getActivity(), android.R.attr.textColorSecondary);
|
||||
for (int i : imageResources) {
|
||||
ImageView imgView = v.findViewById(i);
|
||||
imgView.getDrawable().setColorFilter(filter);
|
||||
}
|
||||
|
||||
String versionName = "";
|
||||
try {
|
||||
PackageInfo packageInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
|
||||
versionName = packageInfo.versionName;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
LinearLayout versionLayout = v.findViewById(R.id.about_layout_version);
|
||||
|
||||
versionLayout.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
long thisTap = System.currentTimeMillis();
|
||||
|
||||
if (thisTap - lastTap < 500) {
|
||||
taps = taps + 1;
|
||||
|
||||
if (currentToast != null && taps <= 7)
|
||||
currentToast.cancel();
|
||||
|
||||
if (taps >= 3 && taps <= 7)
|
||||
currentToast = Toast.makeText(getActivity(), String.valueOf(taps), Toast.LENGTH_SHORT);
|
||||
|
||||
if (taps == 7) {
|
||||
if (settings.getSpecialFeatures())
|
||||
currentToast = Toast.makeText(getActivity(), R.string.about_toast_special_features_enabled, Toast.LENGTH_LONG);
|
||||
else
|
||||
enableSpecialFeatures();
|
||||
}
|
||||
|
||||
if (currentToast != null)
|
||||
currentToast.show();
|
||||
} else {
|
||||
taps = 0;
|
||||
}
|
||||
|
||||
lastTap = thisTap;
|
||||
}
|
||||
});
|
||||
|
||||
TextView version = v.findViewById(R.id.about_text_version);
|
||||
version.setText(versionName);
|
||||
|
||||
LinearLayout license = v.findViewById(R.id.about_layout_license);
|
||||
LinearLayout changelog = v.findViewById(R.id.about_layout_changelog);
|
||||
LinearLayout source = v.findViewById(R.id.about_layout_source);
|
||||
|
||||
license.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openURI(MIT_URI);
|
||||
}
|
||||
});
|
||||
changelog.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openURI(CHANGELOG_URI);
|
||||
}
|
||||
});
|
||||
source.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openURI(GITHUB_URI);
|
||||
}
|
||||
});
|
||||
|
||||
TextView author1GitHub = v.findViewById(R.id.about_author1_github);
|
||||
TextView author1Paypal = v.findViewById(R.id.about_author1_extra);
|
||||
author1GitHub.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openURI(AUTHOR1_GITHUB);
|
||||
}
|
||||
});
|
||||
author1Paypal.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
try {
|
||||
openURI(AUTHOR1_EXTRA);
|
||||
} catch(Exception ignored) {
|
||||
copyToClipboard(AUTHOR1_EXTRA);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
TextView author2GitHub = v.findViewById(R.id.about_author2_github);
|
||||
TextView author2Paypal = v.findViewById(R.id.about_author2_extra);
|
||||
author2GitHub.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openURI(AUTHOR2_GITHUB);
|
||||
}
|
||||
});
|
||||
author2Paypal.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
try {
|
||||
openURI(AUTHOR2_EXTRA);
|
||||
} catch(Exception ignored) {
|
||||
copyToClipboard(AUTHOR2_EXTRA);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
TextView authorOriginalGitHub = v.findViewById(R.id.about_author_original_github);
|
||||
TextView authorOriginalApp = v.findViewById(R.id.about_author_original_extra);
|
||||
authorOriginalGitHub.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openURI(AUTHOR_ORIGINAL_GITHUB);
|
||||
}
|
||||
});
|
||||
authorOriginalApp.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
try {
|
||||
openURI(AUTHOR_ORIGINAL_EXTRA);
|
||||
} catch(Exception ignored) {
|
||||
copyToClipboard(AUTHOR_ORIGINAL_EXTRA);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
LinearLayout contributors = v.findViewById(R.id.about_layout_contributors);
|
||||
LinearLayout translators = v.findViewById(R.id.about_layout_translators);
|
||||
contributors.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openURI(CONTRIBUTORS_URI);
|
||||
}
|
||||
});
|
||||
translators.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openURI(TRANSLATORS_URI);
|
||||
}
|
||||
});
|
||||
|
||||
LinearLayout bugReport = v.findViewById(R.id.about_layout_bugs);
|
||||
LinearLayout translate = v.findViewById(R.id.about_layout_translate);
|
||||
bugReport.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openURI(BUGREPORT_URI);
|
||||
}
|
||||
});
|
||||
translate.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
openURI(TRANSLATE_URI);
|
||||
}
|
||||
});
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
private void enableSpecialFeatures() {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
builder.setTitle(R.string.about_title_special_features)
|
||||
.setMessage(R.string.about_dialog_special_features)
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
settings.setSpecialFeatures(true);
|
||||
Toast.makeText(getActivity(), R.string.about_toast_special_features, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
})
|
||||
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {}
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
}
|
||||
|
||||
public void openURI(String uri) {
|
||||
Intent openURI = new Intent(Intent.ACTION_VIEW);
|
||||
openURI.setData(Uri.parse(uri));
|
||||
startActivity(openURI);
|
||||
}
|
||||
|
||||
public void copyToClipboard(String uri) {
|
||||
ClipboardManager clipboard = (ClipboardManager) getActivity().getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("andOTP", uri);
|
||||
clipboard.setPrimaryClip(clip);
|
||||
Toast.makeText(getActivity(), getString(R.string.about_toast_copied_to_clipboard), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
|
@ -67,14 +67,6 @@ public class Tools {
|
|||
return colorValue;
|
||||
}
|
||||
|
||||
public static String getCSSRGBAString(@ColorInt int color) {
|
||||
int red = Color.red(color);
|
||||
int green = Color.green(color);
|
||||
int blue = Color.blue(color);
|
||||
float alpha = ((float) Color.alpha(color) / 255);
|
||||
return String.format(Locale.ENGLISH, CSS_RGBA_FORMAT, red, green, blue, alpha);
|
||||
}
|
||||
|
||||
/* Create a ColorFilter based on the current theme */
|
||||
public static ColorFilter getThemeColorFilter(Context context, int colorAttr) {
|
||||
return new PorterDuffColorFilter(getThemeColor(context, colorAttr), PorterDuff.Mode.SRC_IN);
|
||||
|
|
21
app/src/main/res/layout/component_about.xml
Normal file
21
app/src/main/res/layout/component_about.xml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<android.support.design.widget.TabLayout
|
||||
android:id="@+id/tabLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:tabMode="fixed" />
|
||||
|
||||
<android.support.v4.view.ViewPager
|
||||
android:id="@+id/viewPager"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
|
@ -205,34 +205,6 @@
|
|||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- licenses -->
|
||||
<LinearLayout
|
||||
android:id="@+id/about_layout_licenses"
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:attr/listPreferredItemHeight"
|
||||
android:paddingTop="@dimen/activity_margin_small"
|
||||
android:paddingBottom="@dimen/activity_margin_small"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/aboutImgOpenSource"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/activity_margin"
|
||||
android:layout_marginEnd="@dimen/activity_margin_large"
|
||||
android:src="@drawable/ic_copyright_gray" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/about_label_licenses"
|
||||
android:textStyle="bold"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.CardView>
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<notices>
|
||||
<notice>
|
||||
<name>Apache Commons Codec</name>
|
||||
<url>https://commons.apache.org/proper/commons-codec</url>
|
||||
<copyright>Copyright 2002-2014 The Apache Software Foundation</copyright>
|
||||
<license>Apache Software License 2.0</license>
|
||||
</notice>
|
||||
<notice>
|
||||
<name>Expandable Layout</name>
|
||||
<url>https://github.com/AAkira/ExpandableLayout</url>
|
||||
<copyright>Copyright (C) 2015 A.Akira</copyright>
|
||||
<license>Apache Software License 2.0</license>
|
||||
</notice>
|
||||
<notice>
|
||||
<name>FABsMenu</name>
|
||||
<url>https://github.com/jahirfiquitiva/FABsMenu</url>
|
||||
<copyright>Copyright (c) 2018 Jahir Fiquitiva</copyright>
|
||||
<license>Apache Software License 2.0</license>
|
||||
</notice>
|
||||
<notice>
|
||||
<name>material-intro</name>
|
||||
<url>https://github.com/heinrichreimer/material-intro</url>
|
||||
<copyright>Copyright (c) 2017 Jan Heinrich Reimer</copyright>
|
||||
<license>MIT License</license>
|
||||
</notice>
|
||||
<notice>
|
||||
<name>MaterialProgressBar</name>
|
||||
<url>https://github.com/DreaminginCodeZH/MaterialProgressBar</url>
|
||||
<copyright>Copyright 2015 Zhang Hai</copyright>
|
||||
<license>Apache Software License 2.0</license>
|
||||
</notice>
|
||||
<notice>
|
||||
<name>OpenPGP API library</name>
|
||||
<url>https://github.com/open-keychain/openpgp-api</url>
|
||||
<copyright>Copyright (C) 2015 Dominik Schürmann</copyright>
|
||||
<license>Apache Software License 2.0</license>
|
||||
</notice>
|
||||
<notice>
|
||||
<name>VNTNumberPickerPreference</name>
|
||||
<url>https://github.com/vanniktech/VNTNumberPickerPreference</url>
|
||||
<copyright>Copyright (C) 2014-2016 Vanniktech - Niklas Baudy</copyright>
|
||||
<license>Apache Software License 2.0</license>
|
||||
</notice>
|
||||
<notice>
|
||||
<name>ZXing Android Embedded</name>
|
||||
<url>https://github.com/journeyapps/zxing-android-embedded</url>
|
||||
<copyright>Copyright (C) 2012-2017 ZXing authors, Journey Mobile</copyright>
|
||||
<license>Apache Software License 2.0</license>
|
||||
</notice>
|
||||
</notices>
|
|
@ -1,17 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="custom_notices_style" translatable="false">
|
||||
body {
|
||||
background-color: %1$s;
|
||||
color: %2$s;
|
||||
font-family: sans-serif;
|
||||
overflow-wrap: break-word;
|
||||
}
|
||||
pre {
|
||||
background-color: %1$s;
|
||||
color: %3$s;
|
||||
white-space: pre-wrap;
|
||||
padding: 1em;
|
||||
}
|
||||
</string>
|
||||
</resources>
|
|
@ -4,10 +4,12 @@
|
|||
|
||||
<string name="about_description">Open source two-factor authentication for Android</string>
|
||||
|
||||
<string name="about_tab_about">About</string>
|
||||
<string name="about_tab_libraries">Libraries</string>
|
||||
|
||||
<!-- Misc -->
|
||||
<string name="about_label_changelog">Changelog</string>
|
||||
<string name="about_label_license">License</string>
|
||||
<string name="about_label_licenses">Open source licenses</string>
|
||||
<string name="about_label_MIT">MIT License</string>
|
||||
<string name="about_label_source">Source code</string>
|
||||
<string name="about_label_version">Version</string>
|
||||
|
|
Loading…
Reference in a new issue