diff --git a/app/build.gradle b/app/build.gradle index 190e5920..d1c1dd79 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -44,9 +44,11 @@ dependencies { // Android standard libs compile 'com.android.support:appcompat-v7:24.2.1' - compile 'com.android.support:design:24.1.0' //Don't update. Broken up to 24.2.1 + 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: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..93801cb0 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,11 @@ 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.graphics.PorterDuff; +import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.support.design.widget.AppBarLayout; @@ -37,6 +40,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; @@ -45,6 +49,7 @@ import com.github.dfa.diaspora_android.App; import com.github.dfa.diaspora_android.R; import com.github.dfa.diaspora_android.listener.IntellihideToolbarActivityListener; import com.github.dfa.diaspora_android.ui.HtmlTextView; +import com.github.dfa.diaspora_android.ui.theme.CustomFragment; import com.github.dfa.diaspora_android.ui.theme.ThemeHelper; import com.github.dfa.diaspora_android.ui.theme.ThemedActivity; import com.github.dfa.diaspora_android.ui.theme.ThemedFragment; @@ -142,15 +147,33 @@ public class AboutActivity extends ThemedActivity /** * Fragment that shows general information about the app */ - public static class AboutFragment extends ThemedFragment { + public static class AboutFragment extends ThemedFragment implements View.OnClickListener { 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__markdown_button) + protected Button btnMarkdown; + + @BindView(R.id.fragment_about__translate_button) + protected Button btnTranslate; + + @BindView(R.id.fragment_about__issue_tracker_button) + protected Button btnIssueTracker; + + @BindView(R.id.fragment_about__source_code_button) + protected Button btnSourceCode; + + @BindView(R.id.fragment_about__spread_the_word_button) + protected Button btnSpreadTheWord; @BindView(R.id.fragment_about__app_version) - TextView appVersion; + protected TextView txtAppVersion; + + @BindView(R.id.fragment_about__app_codename) + protected TextView txtAppCodename; + + @BindView(R.id.fragment_about__spread_the_word) + protected HtmlTextView txtSpreadTheWord; public AboutFragment() { } @@ -163,18 +186,31 @@ public class AboutActivity extends ThemedActivity if (isAdded()) { try { PackageInfo pInfo = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0); - appVersion.setText(getString(R.string.fragment_debug__app_version, pInfo.versionName + " (" + pInfo.versionCode + ")")); + txtAppVersion.setText(getString(R.string.fragment_debug__app_version, pInfo.versionName + " (" + pInfo.versionCode + ")")); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } } + txtAppCodename.setText(getString(R.string.fragment_debug__app_codename, "Alter Falter")); + btnIssueTracker.setOnClickListener(this); + btnMarkdown.setOnClickListener(this); + btnSourceCode.setOnClickListener(this); + btnSpreadTheWord.setOnClickListener(this); + btnTranslate.setOnClickListener(this); return rootView; } @Override protected void applyColorToViews() { - ThemeHelper.updateTextViewLinkColor(aboutText); + ThemeHelper.getInstance(getAppSettings()); + int colorBtn = ThemeHelper.getAccentColor(); + ThemeHelper.updateButtonColor(btnIssueTracker, colorBtn); + ThemeHelper.updateButtonColor(btnMarkdown, colorBtn); + ThemeHelper.updateButtonColor(btnSourceCode, colorBtn); + ThemeHelper.updateButtonColor(btnSpreadTheWord, colorBtn); + ThemeHelper.updateButtonColor(btnTranslate, colorBtn); + ThemeHelper.updateTextViewLinkColor(txtSpreadTheWord); } @Override @@ -191,6 +227,42 @@ public class AboutActivity extends ThemedActivity public boolean onBackPressed() { return false; } + + @Override + public void onClick(View view) { + switch (view.getId()) { + case R.id.fragment_about__markdown_button: { + openLink(getString(R.string.fragment_about__about_markdown_link)); + break; + } + case R.id.fragment_about__translate_button: { + openLink(getString(R.string.fragment_about__translations_link)); + break; + } + case R.id.fragment_about__issue_tracker_button: { + openLink(getString(R.string.fragment_about__github_issue_link)); + break; + } + case R.id.fragment_about__source_code_button: { + openLink(getString(R.string.fragment_about__github_repo_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__share_app_text, getString(R.string.fragment_about__fdroid_link))); + startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.action_share_dotdotdot))); + break; + } + } + } + + public void openLink(String address) { + Intent openBrowserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(address)); + openBrowserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(openBrowserIntent); + } } /** @@ -216,6 +288,7 @@ public class AboutActivity extends ThemedActivity View rootView = inflater.inflate(R.layout.about__fragment_license, container, false); ButterKnife.bind(this, rootView); final Context context = rootView.getContext(); + ThemeHelper.getInstance(getAppSettings()); accentColor = Helpers.colorToHex(ThemeHelper.getAccentColor()); textLicenseBox.setTextFormatted(getString(R.string.fragment_license__license_content, @@ -231,9 +304,8 @@ public class AboutActivity extends ThemedActivity } public String getContributorsHtml(Context context) { - String text = Helpers.readTextfileFromRawRessource(context, R.raw.contributors, + return Helpers.readTextfileFromRawRessource(context, R.raw.contributors, "* ", "
"); - return text; } public String getMaintainersHtml(Context context) { @@ -245,9 +317,8 @@ public class AboutActivity extends ThemedActivity } public String getLicenseHtml(Context context) { - String text = Helpers.readTextfileFromRawRessource(context, R.raw.license, + return Helpers.readTextfileFromRawRessource(context, R.raw.license, "", "").replace("\n\n", "

"); - return text; } public String getLicense3dPartyHtml(Context context) { @@ -278,6 +349,37 @@ public class AboutActivity extends ThemedActivity } } + public static class ChangelogFragment extends CustomFragment { + public static final String TAG = "com.github.dfa.diaspora_android.AboutActivity.ChangelogFragment"; + + @BindView(R.id.fragment_changelog__content) + protected TextView textChangelogContent; + + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View rootView = inflater.inflate(R.layout.about__fragment_changelog, container, false); + ButterKnife.bind(this, rootView); + final Context context = rootView.getContext(); + textChangelogContent.setText(Helpers.readTextfileFromRawRessource(context, R.raw.changelog, "", "")); + return rootView; + } + + @Override + public String getFragmentTag() { + return TAG; + } + + @Override + public void onCreateBottomOptionsMenu(Menu menu, MenuInflater inflater) { + /* Nothing to do */ + } + + @Override + public boolean onBackPressed() { + return false; + } + } + /** * Fragment that shows debug information like app version, pod version... */ @@ -362,8 +464,17 @@ public class AboutActivity extends ThemedActivity @Override public void update(Observable observable, Object o) { - if (logBox != null) { - logBox.setText(AppLog.Log.getLogBuffer()); + updateLog(); + } + + private synchronized void updateLog() { + if (isAdded() && logBox != null) { + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + logBox.setText(AppLog.Log.getLogBuffer()); + } + }); } } } @@ -374,7 +485,7 @@ public class AboutActivity extends ThemedActivity */ public class SectionsPagerAdapter extends FragmentPagerAdapter { - public SectionsPagerAdapter(FragmentManager fm) { + SectionsPagerAdapter(FragmentManager fm) { super(fm); } @@ -385,6 +496,8 @@ public class AboutActivity extends ThemedActivity return new AboutFragment(); case 1: //License return new LicenseFragment(); + case 2: //Changelog + return new ChangelogFragment(); case 3: //Debug default: return new DebugFragment(); @@ -393,8 +506,8 @@ public class AboutActivity extends ThemedActivity @Override public int getCount() { - // Show 3 total pages. - return 3; + // Show 4 total pages. + return 4; } @Override @@ -405,6 +518,8 @@ public class AboutActivity extends ThemedActivity case 1: return getString(R.string.about_activity__title_about_license); case 2: + return getString(R.string.fragment_changelog__changelog); + case 3: return getString(R.string.about_activity__title_debug_info); } return null; diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java index 72661e1b..94163bc6 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/MainActivity.java @@ -1111,6 +1111,8 @@ public class MainActivity extends ThemedActivity ThemeHelper.updateActionMenuViewColor(toolbarBottom); navDrawerLayout.setBackgroundColor(appSettings.getPrimaryColor()); navProfilePictureArea.setBackgroundColor(appSettings.getPrimaryColor()); + navheaderTitle.setTextColor(ThemeHelper.getTextColorFromBackgroundColor(ThemeHelper.getPrimaryColor())); + navheaderDescription.setTextColor(ThemeHelper.getTextColorFromBackgroundColor(ThemeHelper.getPrimaryColor())); } @Override diff --git a/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java b/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java index 268c11a1..08ec9398 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/activity/SettingsActivity.java @@ -307,11 +307,13 @@ public class SettingsActivity extends ThemedActivity { shade.setColors(ColorPalette.getColors(context, current[0])); shade.setSelectedColor(current[1]); titleBackground.setBackgroundColor(shade.getColor()); + title.setTextColor(ThemeHelper.getTextColorFromBackgroundColor(shade.getColor())); base.setOnColorChangedListener(new OnColorChangedListener() { @Override public void onColorChanged(int i) { shade.setColors(ColorPalette.getColors(context, i)); titleBackground.setBackgroundColor(i); + title.setTextColor(ThemeHelper.getTextColorFromBackgroundColor(i)); if (i == current[0]) { shade.setSelectedColor(current[1]); titleBackground.setBackgroundColor(shade.getColor()); @@ -324,6 +326,7 @@ public class SettingsActivity extends ThemedActivity { @Override public void onColorChanged(int i) { titleBackground.setBackgroundColor(i); + title.setTextColor(ThemeHelper.getTextColorFromBackgroundColor(i)); } }); diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/BadgeDrawable.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/BadgeDrawable.java index ef74eafc..d8409f4c 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/ui/BadgeDrawable.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/BadgeDrawable.java @@ -54,7 +54,7 @@ public class BadgeDrawable extends Drawable { badgeBackground.setAntiAlias(true); badgeBackground.setStyle(Paint.Style.FILL); badgeStroke = new Paint(); - badgeStroke.setColor(ContextCompat.getColor(context.getApplicationContext(), R.color.colorPrimaryDark)); + badgeStroke.setColor(ContextCompat.getColor(context.getApplicationContext(), R.color.color_primary_dark)); badgeStroke.setAntiAlias(true); badgeStroke.setStyle(Paint.Style.FILL); diff --git a/app/src/main/java/com/github/dfa/diaspora_android/ui/theme/ThemeHelper.java b/app/src/main/java/com/github/dfa/diaspora_android/ui/theme/ThemeHelper.java index 64030905..c5b89636 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/ui/theme/ThemeHelper.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/ui/theme/ThemeHelper.java @@ -29,6 +29,7 @@ import android.support.v4.widget.CompoundButtonCompat; import android.support.v7.widget.ActionMenuView; import android.support.v7.widget.Toolbar; import android.view.View; +import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; import android.widget.ProgressBar; @@ -84,8 +85,13 @@ public class ThemeHelper { public static void updateTabLayoutColor(TabLayout tabLayout) { if (tabLayout != null) { - tabLayout.setBackgroundColor(getInstance().appSettings.getPrimaryColor()); - tabLayout.setSelectedTabIndicatorColor(getInstance().appSettings.getAccentColor()); + tabLayout.setBackgroundColor(getPrimaryColor()); + tabLayout.setSelectedTabIndicatorColor(getAccentColor()); + int selectedColor = getTextColorFromBackgroundColor(getPrimaryColor()); + int normalColor = selectedColor == Color.WHITE ? + tabLayout.getContext().getResources().getColor(R.color.md_grey_300) : + tabLayout.getContext().getResources().getColor(R.color.md_grey_700); + tabLayout.setTabTextColors(normalColor, selectedColor); } } @@ -105,6 +111,7 @@ public class ThemeHelper { public static void updateToolbarColor(Toolbar toolbar) { if (toolbar != null) { toolbar.setBackgroundColor(getInstance().appSettings.getPrimaryColor()); + toolbar.setTitleTextColor(getTextColorFromBackgroundColor(getInstance().appSettings.getPrimaryColor())); } } @@ -150,7 +157,23 @@ public class ThemeHelper { } } + public static void updateButtonColor(Button button, int color) { + if(button != null) { + button.getBackground().setColorFilter(color, PorterDuff.Mode.MULTIPLY); + button.setTextColor(getTextColorFromBackgroundColor(color)); + } + } + public static int getNeutralGreyColor() { return ContextCompat.getColor(getInstance().appSettings.getApplicationContext(), R.color.md_grey_800); } + + public static int getTextColorFromBackgroundColor(int backgroundColor) { + int med = (Color.red(backgroundColor) + Color.green(backgroundColor) + Color.blue(backgroundColor)) / 3; + return med < 128 ? Color.WHITE : Color.BLACK; + } + + public static boolean darkDrawables() { + return getTextColorFromBackgroundColor(getInstance().appSettings.getPrimaryColor()) == Color.BLACK; + } } diff --git a/app/src/main/java/com/github/dfa/diaspora_android/util/AppLog.java b/app/src/main/java/com/github/dfa/diaspora_android/util/AppLog.java index 8f3df81b..76a823a7 100644 --- a/app/src/main/java/com/github/dfa/diaspora_android/util/AppLog.java +++ b/app/src/main/java/com/github/dfa/diaspora_android/util/AppLog.java @@ -59,37 +59,37 @@ public class AppLog { */ public static void v(Object source, String _text) { if (isLoggingEnabled()) { - Log.v(getLogPrefix(source), _text); + Log.v(source != null? getLogPrefix(source) : "null", _text); } } public static void i(Object source, String _text) { if (isLoggingEnabled()) { - Log.i(getLogPrefix(source), _text); + Log.i(source != null? getLogPrefix(source) : "null", _text); } } public static void d(Object source, String _text) { if (isLoggingEnabled()) { - Log.d(getLogPrefix(source), _text); + Log.d(source != null? getLogPrefix(source) : "null", _text); } } public static void e(Object source, String _text) { if (isLoggingEnabled()) { - Log.e(getLogPrefix(source), _text); + Log.e(source != null? getLogPrefix(source) : "null", _text); } } public static void w(Object source, String _text) { if (isLoggingEnabled()) { - Log.w(getLogPrefix(source), _text); + Log.w(source != null? getLogPrefix(source) : "null", _text); } } public static void spam(Object source, String _text) { if (isLoggingEnabled() && isLoggingSpamEnabled()) { - Log.v(getLogPrefix(source), _text); + Log.v(source != null? getLogPrefix(source) : "null", _text); } } diff --git a/app/src/main/res/drawable/ic_media_video_poster.xml b/app/src/main/res/drawable/ic_media_video_poster.xml new file mode 100644 index 00000000..8c977c38 --- /dev/null +++ b/app/src/main/res/drawable/ic_media_video_poster.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/about__activity.xml b/app/src/main/res/layout/about__activity.xml index 6f0f2006..8fc92f51 100644 --- a/app/src/main/res/layout/about__activity.xml +++ b/app/src/main/res/layout/about__activity.xml @@ -31,7 +31,8 @@ + android:layout_height="wrap_content" + app:tabMode="scrollable"/> diff --git a/app/src/main/res/layout/about__fragment_about.xml b/app/src/main/res/layout/about__fragment_about.xml index 6283eee7..631d122b 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="@dimen/card_view__margin__top_bottom_double" + android:layout_marginBottom="@dimen/card_view__margin__top_bottom" + android:layout_marginStart="@dimen/card_view__margin__start_end" + android:layout_marginEnd="@dimen/card_view__margin__start_end" + card_view:cardElevation="@dimen/card_view__elevation" + card_view:cardCornerRadius="@dimen/card_view__corner_radius"> + - + - + - + + + + + +