diff --git a/app/build.gradle b/app/build.gradle index e4b4585f..2cd2f9c0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -47,6 +47,7 @@ dependencies { compile 'com.android.support:design:24.1.0' //Don't update. Broken up to 25.0.0 compile 'com.android.support:support-v4:24.2.1' compile 'com.android.support:customtabs:24.2.1' + compile 'com.android.support:cardview-v7:24.2.1' // More libraries compile 'com.jakewharton:butterknife:8.0.1' diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/AboutActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/AboutActivity.java index 2caa1c72..056a4a2e 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/activity/AboutActivity.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/AboutActivity.java @@ -21,8 +21,10 @@ package com.github.dfa.diaspora_android.activity; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; +import android.content.Intent; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; +import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.support.design.widget.AppBarLayout; @@ -37,6 +39,7 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Button; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; @@ -58,6 +61,7 @@ import java.util.Observer; import butterknife.BindView; import butterknife.ButterKnife; +import butterknife.OnClick; /** * Activity that holds some fragments that show information about the app in a tab layout @@ -146,12 +150,24 @@ public class AboutActivity extends ThemedActivity public static final String TAG = "com.github.dfa.diaspora_android.AboutActivity.AboutFragment"; - @BindView(R.id.fragment_about__about_text) - TextView aboutText; - @BindView(R.id.fragment_about__app_version) TextView appVersion; + @BindView(R.id.fragment_about__spread_the_word_text) + HtmlTextView spreadText; + + @BindView(R.id.fragment_about__contribute_button) + Button contributeBtn; + + @BindView(R.id.fragment_about__translate_button) + Button translateBtn; + + @BindView(R.id.fragment_about__feedback_button) + Button feedbackBtn; + + @BindView(R.id.fragment_about__spread_the_word_button) + Button spreadBtn; + public AboutFragment() { } @@ -174,7 +190,12 @@ public class AboutActivity extends ThemedActivity @Override protected void applyColorToViews() { - ThemeHelper.updateTextViewLinkColor(aboutText); + ThemeHelper.getInstance(getAppSettings()); + ThemeHelper.updateTextViewLinkColor(spreadText); + contributeBtn.setTextColor(ThemeHelper.getAccentColor()); + feedbackBtn.setTextColor(ThemeHelper.getAccentColor()); + spreadBtn.setTextColor(ThemeHelper.getAccentColor()); + translateBtn.setTextColor(ThemeHelper.getAccentColor()); } @Override @@ -191,6 +212,28 @@ public class AboutActivity extends ThemedActivity public boolean onBackPressed() { return false; } + + @OnClick({R.id.fragment_about__contribute_button, R.id.fragment_about__translate_button, R.id.fragment_about__feedback_button, R.id.fragment_about__spread_the_word_button}) + public void buttonClicked(View view) { + switch (view.getId()) { + case R.id.fragment_about__contribute_button: + Helpers.openInExternalBrowser(getContext(), getString(R.string.fragment_about__contribute_link)); + break; + case R.id.fragment_about__translate_button: + Helpers.openInExternalBrowser(getContext(), getString(R.string.fragment_about__translate_link)); + break; + case R.id.fragment_about__feedback_button: + Helpers.openInExternalBrowser(getContext(), getString(R.string.fragment_About__feedback_link)); + break; + case R.id.fragment_about__spread_the_word_button: + Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); + sharingIntent.setType("text/plain"); + sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getString(R.string.app_name)); + sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, getString(R.string.fragment_about__spread_the_word_share_text, getString(R.string.fragment_about__fdroid_link))); + startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.action_share_dotdotdot))); + break; + } + } } /** @@ -199,11 +242,20 @@ public class AboutActivity extends ThemedActivity public static class LicenseFragment extends ThemedFragment { public static final String TAG = "com.github.dfa.diaspora_android.AboutActivity.LicenseFragment"; - @BindView(R.id.fragment_license__licensetext) - HtmlTextView textLicenseBox; + @BindView(R.id.fragment_license__maintainers_text) + HtmlTextView maintainers; - @BindView(R.id.fragment_license__3rdparty) - HtmlTextView textLicense3partyBox; + @BindView(R.id.fragment_license__contributors_text) + HtmlTextView contributors; + + @BindView(R.id.fragment_license__thirdparty_libs_text) + HtmlTextView thirdPartyLibs; + + @BindView(R.id.fragment_license__license_button) + Button licenseBtn; + + @BindView(R.id.fragment_license__leafpic_button) + Button leafpicBtn; private String accentColor; @@ -218,18 +270,24 @@ public class AboutActivity extends ThemedActivity final Context context = rootView.getContext(); accentColor = Helpers.colorToHex(ThemeHelper.getAccentColor()); - textLicenseBox.setTextFormatted(getString(R.string.fragment_license__license_content, - getMaintainersHtml(context), - getContributorsHtml(context), - getLicenseHtml(context) - )); - - textLicense3partyBox.setTextFormatted( - getLicense3dPartyHtml(context) - ); + maintainers.setTextFormatted(getString(R.string.fragment_license__maintainers_text, getMaintainersHtml(context))); + contributors.setTextFormatted(getString(R.string.fragment_license__contributors_thank_you, getContributorsHtml(context))); + thirdPartyLibs.setTextFormatted(getLicense3dPartyHtml(context)); return rootView; } + @OnClick({R.id.fragment_license__leafpic_button, R.id.fragment_license__license_button}) + public void buttonClicked(View v) { + switch (v.getId()) { + case R.id.fragment_license__leafpic_button: + Helpers.openInExternalBrowser(getContext(), getString(R.string.fragment_licesen__misc_leafpic_link)); + break; + case R.id.fragment_license__license_button: + Helpers.openInExternalBrowser(getContext(), getString(R.string.fragment_license__license_gpl_link)); + break; + } + } + public String getContributorsHtml(Context context) { String text = Helpers.readTextfileFromRawRessource(context, R.raw.contributors, "* ", "
"); @@ -244,12 +302,6 @@ public class AboutActivity extends ThemedActivity return text; } - public String getLicenseHtml(Context context) { - String text = Helpers.readTextfileFromRawRessource(context, R.raw.license, - "", "").replace("\n\n", "

"); - return text; - } - public String getLicense3dPartyHtml(Context context) { String text = Helpers.readTextfileFromRawRessource(context, R.raw.license_third_party, "", "
"); text = text.replace("NEWENTRY", "* "); @@ -258,8 +310,11 @@ public class AboutActivity extends ThemedActivity @Override protected void applyColorToViews() { - ThemeHelper.updateTextViewLinkColor(textLicense3partyBox); - ThemeHelper.updateTextViewLinkColor(textLicenseBox); + ThemeHelper.getInstance(getAppSettings()); + leafpicBtn.setTextColor(ThemeHelper.getAccentColor()); + licenseBtn.setTextColor(ThemeHelper.getAccentColor()); + ThemeHelper.updateTextViewLinkColor(maintainers); + ThemeHelper.updateTextViewLinkColor(thirdPartyLibs); } @Override diff --git a/app/src/main/java/com/github/dfa/diaspora_android/util/Helpers.java b/app/src/main/java/com/github/dfa/diaspora_android/util/Helpers.java index 5db1e5d2..c6059bd3 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/util/Helpers.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/util/Helpers.java @@ -150,4 +150,15 @@ public class Helpers { } return !isOnline; } + + /** + * Send an Intent that opens url in any browser + * @param context context + * @param url url + */ + public static void openInExternalBrowser(Context context, String url) { + Intent openBrowserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); + openBrowserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + context.startActivity(openBrowserIntent); + } } diff --git a/app/src/main/res/layout/about__fragment_about.xml b/app/src/main/res/layout/about__fragment_about.xml index 6283eee7..94f06710 100644 --- a/app/src/main/res/layout/about__fragment_about.xml +++ b/app/src/main/res/layout/about__fragment_about.xml @@ -1,10 +1,11 @@ - - - - + + android:layout_marginTop="16dp" + android:layout_marginBottom="8dp" + android:layout_marginStart="8dp" + android:layout_marginEnd="8dp" + style="?android:attr/buttonBarStyle" + card_view:cardElevation="5dp" + card_view:cardCornerRadius="5dp"> + - + - + - + + + + + + + + + android:layout_marginTop="8dp" + android:layout_marginBottom="8dp" + android:layout_marginStart="8dp" + android:layout_marginEnd="8dp" + style="?android:attr/buttonBarStyle" + card_view:cardElevation="5dp" + card_view:cardCornerRadius="5dp"> + + + + + + +