1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2024-11-24 21:32:07 +01:00

Fixed coloring link in AboutFragment, Color buttons in AboutFragment, Added ChangeLogFragment, made updating logBoxText synchronized in DebugFragment, Color some textViews and buttons according to chosen background color, created methods for calculating text color from background color, caught possible nullpointer in applog, added workaround drawable ic_media_video_poster.xml to prevent webview crash (not clear, if this fixes the issue), made tablayout in aboutActivity scrollable, renamed some color names to lowercase

This commit is contained in:
vanitasvitae 2016-11-02 19:57:30 +01:00
parent e166cc0164
commit e320cce188
Signed by: vanitasvitae
GPG key ID: DCCFB3302C9E4615
20 changed files with 181 additions and 43 deletions

View file

@ -44,9 +44,9 @@ 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'

View file

@ -24,6 +24,7 @@ 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;
@ -48,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;
@ -170,6 +172,9 @@ public class AboutActivity extends ThemedActivity
@BindView(R.id.fragment_about__app_codename)
protected TextView txtAppCodename;
@BindView(R.id.fragment_about__spread_the_word)
protected HtmlTextView txtSpreadTheWord;
public AboutFragment() {
}
@ -198,7 +203,14 @@ public class AboutActivity extends ThemedActivity
@Override
protected void applyColorToViews() {
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
@ -337,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...
*/
@ -421,9 +464,14 @@ public class AboutActivity extends ThemedActivity
@Override
public void update(Observable observable, Object o) {
if (logBox != null) {
if (isAdded() && logBox != null) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
logBox.setText(AppLog.Log.getLogBuffer());
}
});
}
}
}
@ -444,6 +492,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();
@ -452,8 +502,8 @@ public class AboutActivity extends ThemedActivity
@Override
public int getCount() {
// Show 3 total pages.
return 3;
// Show 4 total pages.
return 4;
}
@Override
@ -464,6 +514,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;

View file

@ -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

View file

@ -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));
}
});

View file

@ -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);

View file

@ -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;
}
}

View file

@ -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);
}
}

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<!-- This is a workaround for webview crashes: https://bugs.chromium.org/p/chromium/issues/detail?id=521753 -->
<path
android:fillColor="#000000"
android:pathData="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8
4v2h16v-2c0-2.66-5.33-4-8-4z" />
<path
android:pathData="M0 0h24v24H0z" />
</vector>

View file

@ -31,7 +31,8 @@
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
app:tabMode="scrollable"/>
</LinearLayout>
</android.support.design.widget.AppBarLayout>

View file

@ -16,12 +16,12 @@
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginBottom="8dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
card_view:cardElevation="5dp"
card_view:cardCornerRadius="5dp">
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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -76,12 +76,12 @@
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
card_view:cardElevation="5dp"
card_view:cardCornerRadius="5dp">
android:layout_marginTop="@dimen/card_view__margin__top_bottom"
android:layout_marginBottom="@dimen/card_view__margin__top_bottom_double"
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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@ -134,6 +134,7 @@
android:text="@string/fragment_about__translations"
android:layout_marginBottom="8dp"/>
<com.github.dfa.diaspora_android.ui.HtmlTextView
android:id="@+id/fragment_about__spread_the_word"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat"

View file

@ -0,0 +1,33 @@
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
tools:context="com.github.dfa.diaspora_android.activity.AboutActivity$LicenseFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!--Vertical Padding-->
<android.support.v4.widget.Space
android:layout_width="match_parent"
android:layout_height="@dimen/activity_vertical_margin" />
<TextView
style="@android:style/TextAppearance.DeviceDefault.Large"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/fragment_changelog__changelog" />
<TextView
android:id="@+id/fragment_changelog__content"
style="@android:style/TextAppearance.DeviceDefault.Small"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>

View file

@ -39,7 +39,7 @@
android:id="@+id/main__bottombar"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="@color/colorPrimary"
android:background="@color/color_primary"
android:theme="@style/BottomToolbarMenuOverflowStyle"
app:layout_scrollFlags="scroll|enterAlways|snap"
app:popupTheme="@style/Theme.AppCompat.NoActionBar" />

View file

@ -3,7 +3,7 @@
android:id="@+id/nav_drawer"
android:layout_width="wrap_content"
android:layout_height="110dp"
android:background="@color/colorPrimary"
android:background="@color/color_primary"
android:gravity="bottom"
android:orientation="vertical"
android:theme="@style/ThemeOverlay.AppCompat.Dark">

View file

@ -4,6 +4,6 @@
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@color/colorPrimary</item>
<item name="android:statusBarColor">@color/color_primary</item>
</style>
</resources>

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">@color/md_blue_650</color>
<color name="colorPrimaryDark">@color/md_blue_750</color>
<color name="colorAccent">@color/md_deep_orange_650</color>
<color name="color_primary">@color/md_blue_650</color>
<color name="color_primary_dark">@color/md_blue_750</color>
<color name="color_accent">@color/md_deep_orange_650</color>
<!-- Colors from Palette -->
<color name="primary">@color/md_blue_650</color>
@ -17,7 +17,7 @@
<color name="white">#ffffff</color>
<color name="black">#000000</color>
<color name="actvitiy_white">#eeeeee</color>
<color name="activity_white">#eeeeee</color>
<color name="transparent_black">#c4000000</color>
<color name="alternate_row_color">@color/md_grey_200</color>

View file

@ -16,4 +16,10 @@
<dimen name="textsize_badge_count">11sp</dimen>
<dimen name="color_picker_circle_size">30dp</dimen>
<dimen name="card_view__margin__start_end">16dp</dimen>
<dimen name="card_view__margin__top_bottom">8dp</dimen>
<dimen name="card_view__margin__top_bottom_double">16dp</dimen>
<dimen name="card_view__elevation">5dp</dimen>
<dimen name="card_view__corner_radius">5dp</dimen>
</resources>

View file

@ -46,6 +46,9 @@
<string name="fragment_about__spread_the_word">Spread the word!</string>
<string name="fragment_about__share_app_text">Hey! Check out #DiasporaForAndroid! %1$s</string>
<string name="fragment_about__fdroid_link" translatable="false">https://f-droid.org/app/com.github.dfa.diaspora_android</string>
<!-- Changelog -->
<string name="fragment_changelog__changelog">Changelog</string>
<!-- Lorem ipsum -->
<string name="lorem_ipsum" translatable="false">Auch gibt es niemanden, der den Schmerz an sich liebt, sucht oder wünscht, nur, weil er Schmerz ist, es sei denn, es kommt zu zufälligen Umständen, in denen Mühen und Schmerz ihm große Freude bereiten können. Um ein triviales Beispiel zu nehmen, wer von uns unterzieht sich je anstrengender körperlicher Betätigung, außer um Vorteile daraus zu ziehen? Aber wer hat irgend ein Recht, einen Menschen zu tadeln, der die Entscheidung trifft, eine Freude zu genießen, die keine unangenehmen Folgen hat, oder einen, der Schmerz vermeidet, welcher keine daraus resultierende Freude nach sich zieht? Auch gibt es niemanden, der den Schmerz an sich liebt, sucht oder wünscht, nur, weil er Schmerz ist, es sei denn, es kommt zu zufälligen Umständen, in denen Mühen und Schmerz ihm große Freude bereiten können. Um ein triviales Beispiel zu nehmen, wer von uns unterzieht sich je anstrengender körperlicher Betätigung, außer um Vorteile daraus zu ziehen? Aber wer hat irgend ein Recht, einen Menschen zu tadeln, der die Entscheidung trifft, eine Freude zu genießen, die keine unangenehmen Folgen hat, oder einen, der Schmerz vermeidet, welcher keine daraus resultierende Freude nach sich zieht?</string>
</resources>

View file

@ -116,8 +116,8 @@
<string name="pref_desc__http_proxy_enabled">Proxy Diaspora\'s traffic to circumvent firewalls.\nMay require restart. This might not work on some phones.</string>
<string name="pref_title__http_proxy_host">Host</string>
<string name="pref_title__http_proxy_port">Port</string>
<string name="HTTP" translatable="false">HTTP</string>
<string name="SOCKS5" translatable="false">SOCKS5</string>
<string name="http" translatable="false">HTTP</string>
<string name="socks5" translatable="false">SOCKS5</string>
<string name="toast__proxy_disabled__restart_required">App needs to restart to disable proxy usage</string>
<string name="toast__proxy_orbot_preset_loaded">Orbot proxy preset loaded</string>

View file

@ -3,10 +3,10 @@
<!-- Base application theme. -->
<style name="DiasporaLight" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="actionMenuTextColor">@color/colorAccent</item>
<item name="colorPrimary">@color/color_primary</item>
<item name="colorPrimaryDark">@color/color_primary_dark</item>
<item name="colorAccent">@color/color_accent</item>
<item name="actionMenuTextColor">@color/color_accent</item>
</style>
<style name="DiasporaLight.NoActionBar">

View file

@ -2,7 +2,7 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<com.github.dfa.diaspora_android.ui.theme.ThemedPreferenceCategory
android:key="@string/pref_key__title__proxy"
android:title="@string/HTTP">
android:title="@string/http">
<com.github.dfa.diaspora_android.ui.theme.ThemedCheckBoxPreference
android:defaultValue="false"
android:key="@string/pref_key__http_proxy_enabled"