From 4b09e5d1061b561f3d2eff3ee50c444f244b8ad5 Mon Sep 17 00:00:00 2001 From: stom79 Date: Fri, 11 May 2018 10:30:25 +0200 Subject: [PATCH 001/116] Black theme - style + drawables --- .../res/drawable/imageview_border_black.xml | 7 ++ .../main/res/drawable/menu_selector_black.xml | 7 ++ .../shape_border_bottom_settings_black.xml | 19 +++ .../main/res/drawable/side_nav_bar_black.xml | 9 ++ app/src/main/res/values/styles.xml | 114 +++++++++++++++++- 5 files changed, 154 insertions(+), 2 deletions(-) create mode 100644 app/src/main/res/drawable/imageview_border_black.xml create mode 100644 app/src/main/res/drawable/menu_selector_black.xml create mode 100644 app/src/main/res/drawable/shape_border_bottom_settings_black.xml create mode 100644 app/src/main/res/drawable/side_nav_bar_black.xml diff --git a/app/src/main/res/drawable/imageview_border_black.xml b/app/src/main/res/drawable/imageview_border_black.xml new file mode 100644 index 000000000..d7d8c85b4 --- /dev/null +++ b/app/src/main/res/drawable/imageview_border_black.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/menu_selector_black.xml b/app/src/main/res/drawable/menu_selector_black.xml new file mode 100644 index 000000000..62f94d137 --- /dev/null +++ b/app/src/main/res/drawable/menu_selector_black.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/shape_border_bottom_settings_black.xml b/app/src/main/res/drawable/shape_border_bottom_settings_black.xml new file mode 100644 index 000000000..b86c0b5a0 --- /dev/null +++ b/app/src/main/res/drawable/shape_border_bottom_settings_black.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/side_nav_bar_black.xml b/app/src/main/res/drawable/side_nav_bar_black.xml new file mode 100644 index 000000000..a0d127490 --- /dev/null +++ b/app/src/main/res/drawable/side_nav_bar_black.xml @@ -0,0 +1,9 @@ + + + \ No newline at end of file diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 05069ee39..e973d2af8 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -115,6 +115,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - From ca384748ea6e493d994abfc7fb51ba56a9602994 Mon Sep 17 00:00:00 2001 From: stom79 Date: Fri, 11 May 2018 10:40:58 +0200 Subject: [PATCH 002/116] Black theme - Apply to settings --- .../mastodon/fragments/SettingsFragment.java | 63 ++++++++++++++----- .../gouv/etalab/mastodon/helper/Helper.java | 2 + .../res/layout-sw600dp/fragment_settings.xml | 10 +-- app/src/main/res/layout/fragment_settings.xml | 12 ++-- app/src/main/res/values/strings.xml | 7 +++ 5 files changed, 64 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsFragment.java b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsFragment.java index b52df4569..798fd91fd 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsFragment.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/fragments/SettingsFragment.java @@ -70,7 +70,7 @@ public class SettingsFragment extends Fragment { private Context context; private static final int ACTIVITY_CHOOSE_FILE = 411; private TextView set_folder; - int count1, count2 = 0; + int count1, count2, count3 = 0; @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -428,25 +428,56 @@ public class SettingsFragment extends Fragment { file_chooser.setVisibility(View.GONE); } - final SwitchCompat set_night_mode = rootView.findViewById(R.id.set_night_mode); - set_night_mode.setChecked(theme == Helper.THEME_DARK); - set_night_mode.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + final Spinner set_night_mode = rootView.findViewById(R.id.set_night_mode); + ArrayAdapter adapterTheme = ArrayAdapter.createFromResource(getContext(), + R.array.settings_theme, android.R.layout.simple_spinner_item); + set_night_mode.setAdapter(adapterTheme); + + int positionSpinnerTheme; + switch (sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK)){ + case Helper.THEME_DARK: + positionSpinnerTheme = 0; + break; + case Helper.THEME_LIGHT: + positionSpinnerTheme = 1; + break; + case Helper.THEME_BLACK: + positionSpinnerTheme = 2; + break; + default: + positionSpinnerTheme = 0; + } + set_night_mode.setSelection(positionSpinnerTheme); + set_night_mode.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - SharedPreferences.Editor editor = sharedpreferences.edit(); - editor.putInt(Helper.SET_THEME, isChecked?Helper.THEME_DARK:Helper.THEME_LIGHT); - editor.apply(); - if( isChecked){ + public void onItemSelected(AdapterView parent, View view, int position, long id) { + if( count3 > 0){ + SharedPreferences.Editor editor = sharedpreferences.edit(); + switch (position){ + case 0: + editor.putInt(Helper.SET_THEME, Helper.THEME_DARK); + editor.apply(); + break; + case 1: + editor.putInt(Helper.SET_THEME, Helper.THEME_LIGHT); + editor.apply(); + break; + case 2: + editor.putInt(Helper.SET_THEME, Helper.THEME_BLACK); + editor.apply(); + break; + } if( getActivity() != null) - getActivity().setTheme(R.style.AppThemeDark); + getActivity().recreate(); + Intent intent = new Intent(context, MainActivity.class); + intent.putExtra(INTENT_ACTION, CHANGE_THEME_INTENT); + startActivity(intent); }else { - if( getActivity() != null) - getActivity().setTheme(R.style.AppTheme); + count3++; } - getActivity().recreate(); - Intent intent = new Intent(context, MainActivity.class); - intent.putExtra(INTENT_ACTION, CHANGE_THEME_INTENT); - startActivity(intent); + } + @Override + public void onNothingSelected(AdapterView parent) { } }); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java index e640c4e7b..a1d8a062e 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java @@ -248,8 +248,10 @@ public class Helper { public static final int ATTACHMENT_ALWAYS = 1; public static final int ATTACHMENT_WIFI = 2; public static final int ATTACHMENT_ASK = 3; + public static final int THEME_LIGHT = 1; public static final int THEME_DARK = 2; + public static final int THEME_BLACK = 3; public static final int LED_COLOUR = 0; diff --git a/app/src/main/res/layout-sw600dp/fragment_settings.xml b/app/src/main/res/layout-sw600dp/fragment_settings.xml index cabc2c0fb..8bda1cb0e 100644 --- a/app/src/main/res/layout-sw600dp/fragment_settings.xml +++ b/app/src/main/res/layout-sw600dp/fragment_settings.xml @@ -314,15 +314,11 @@ android:layout_gravity="center_vertical" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/set_night_mode"/> - + + android:layout_height="wrap_content" /> diff --git a/app/src/main/res/layout/fragment_settings.xml b/app/src/main/res/layout/fragment_settings.xml index 87bc171d7..7e7306d86 100644 --- a/app/src/main/res/layout/fragment_settings.xml +++ b/app/src/main/res/layout/fragment_settings.xml @@ -302,6 +302,8 @@ /> + + - + + android:layout_height="wrap_content" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 47d504dd2..69559c4c7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -352,6 +352,12 @@ No + + Dark + Light + Black + + No 512 Kb @@ -526,6 +532,7 @@ Port Login Password + Theme: HTTP SOCKS From 41d40c162ecee8331d55c626819dd06203f0a39c Mon Sep 17 00:00:00 2001 From: stom79 Date: Fri, 11 May 2018 11:28:05 +0200 Subject: [PATCH 003/116] Black theme - Changes main colors --- .../mastodon/activities/AboutActivity.java | 17 ++++++--- .../mastodon/activities/BaseMainActivity.java | 16 ++++++--- .../activities/EditProfileActivity.java | 17 ++++++--- .../mastodon/activities/HashTagActivity.java | 16 ++++++--- .../mastodon/activities/InstanceActivity.java | 17 ++++++--- .../mastodon/activities/ListActivity.java | 16 ++++++--- .../mastodon/activities/LoginActivity.java | 17 ++++++--- .../activities/OwnerStatusActivity.java | 16 ++++++--- .../mastodon/activities/PrivacyActivity.java | 17 ++++++--- .../activities/RemoteFollowActivity.java | 17 ++++++--- .../activities/SearchResultActivity.java | 17 ++++++--- .../activities/ShowAccountActivity.java | 16 ++++++--- .../activities/ShowConversationActivity.java | 16 ++++++--- .../mastodon/activities/TootActivity.java | 17 ++++++--- .../mastodon/activities/WebviewActivity.java | 17 ++++++--- .../activities/WebviewConnectActivity.java | 17 ++++++--- .../mastodon/client/Entities/Status.java | 6 ++-- .../mastodon/drawers/StatusListAdapter.java | 36 ++++++++++++------- .../gouv/etalab/mastodon/helper/Helper.java | 8 +++-- .../res/drawable/button_selector_black.xml | 6 ++++ app/src/main/res/values/colors.xml | 4 ++- app/src/main/res/values/styles.xml | 24 +------------ 22 files changed, 245 insertions(+), 105 deletions(-) create mode 100644 app/src/main/res/drawable/button_selector_black.xml diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/AboutActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/AboutActivity.java index 4a27eb076..8908c60d7 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/AboutActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/AboutActivity.java @@ -69,11 +69,20 @@ public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccou super.onCreate(savedInstanceState); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); - if( theme == Helper.THEME_LIGHT){ - setTheme(R.style.AppTheme); - }else { - setTheme(R.style.AppThemeDark); + switch (theme){ + case Helper.THEME_LIGHT: + setTheme(R.style.AppTheme); + break; + case Helper.THEME_DARK: + setTheme(R.style.AppThemeDark); + break; + case Helper.THEME_BLACK: + setTheme(R.style.AppThemeBlack); + break; + default: + setTheme(R.style.AppThemeDark); } + if( getSupportActionBar() != null) getSupportActionBar().setDisplayHomeAsUpEnabled(true); setContentView(R.layout.activity_about); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java index 6aed798f6..80268f2e5 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java @@ -165,10 +165,18 @@ public abstract class BaseMainActivity extends BaseActivity final int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); - if( theme == Helper.THEME_LIGHT){ - setTheme(R.style.AppTheme_NoActionBar); - }else { - setTheme(R.style.AppThemeDark_NoActionBar); + switch (theme){ + case Helper.THEME_LIGHT: + setTheme(R.style.AppTheme_NoActionBar); + break; + case Helper.THEME_DARK: + setTheme(R.style.AppThemeDark_NoActionBar); + break; + case Helper.THEME_BLACK: + setTheme(R.style.AppThemeBlack_NoActionBar); + break; + default: + setTheme(R.style.AppThemeDark_NoActionBar); } setContentView(R.layout.activity_main); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/EditProfileActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/EditProfileActivity.java index e45f41a91..9976e3fa9 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/EditProfileActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/EditProfileActivity.java @@ -112,11 +112,20 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); - if( theme == Helper.THEME_LIGHT){ - setTheme(R.style.AppTheme); - }else { - setTheme(R.style.AppThemeDark); + switch (theme){ + case Helper.THEME_LIGHT: + setTheme(R.style.AppTheme); + break; + case Helper.THEME_DARK: + setTheme(R.style.AppThemeDark); + break; + case Helper.THEME_BLACK: + setTheme(R.style.AppThemeBlack); + break; + default: + setTheme(R.style.AppThemeDark); } + setContentView(R.layout.activity_edit_profile); ActionBar actionBar = getSupportActionBar(); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/HashTagActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/HashTagActivity.java index 54bcc996a..9e5cb0a87 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/HashTagActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/HashTagActivity.java @@ -68,10 +68,18 @@ public class HashTagActivity extends BaseActivity implements OnRetrieveFeedsInte SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); - if( theme == Helper.THEME_LIGHT){ - setTheme(R.style.AppTheme_NoActionBar); - }else { - setTheme(R.style.AppThemeDark_NoActionBar); + switch (theme){ + case Helper.THEME_LIGHT: + setTheme(R.style.AppTheme_NoActionBar); + break; + case Helper.THEME_DARK: + setTheme(R.style.AppThemeDark_NoActionBar); + break; + case Helper.THEME_BLACK: + setTheme(R.style.AppThemeBlack_NoActionBar); + break; + default: + setTheme(R.style.AppThemeDark_NoActionBar); } setContentView(R.layout.activity_hashtag); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/InstanceActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/InstanceActivity.java index 8ef609e14..edf8b8325 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/InstanceActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/InstanceActivity.java @@ -57,11 +57,20 @@ public class InstanceActivity extends BaseActivity implements OnRetrieveInstance super.onCreate(savedInstanceState); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); - if( theme == Helper.THEME_LIGHT){ - setTheme(R.style.AppTheme); - }else { - setTheme(R.style.AppThemeDark); + switch (theme){ + case Helper.THEME_LIGHT: + setTheme(R.style.AppTheme); + break; + case Helper.THEME_DARK: + setTheme(R.style.AppThemeDark); + break; + case Helper.THEME_BLACK: + setTheme(R.style.AppThemeBlack); + break; + default: + setTheme(R.style.AppThemeDark); } + if( getSupportActionBar() != null) getSupportActionBar().setDisplayHomeAsUpEnabled(true); setContentView(R.layout.activity_instance); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/ListActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/ListActivity.java index 94ac52a5b..db711000d 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/ListActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/ListActivity.java @@ -76,10 +76,18 @@ public class ListActivity extends BaseActivity implements OnListActionInterface super.onCreate(savedInstanceState); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); - if( theme == Helper.THEME_LIGHT){ - setTheme(R.style.AppTheme_NoActionBar); - }else { - setTheme(R.style.AppThemeDark_NoActionBar); + switch (theme){ + case Helper.THEME_LIGHT: + setTheme(R.style.AppTheme_NoActionBar); + break; + case Helper.THEME_DARK: + setTheme(R.style.AppThemeDark_NoActionBar); + break; + case Helper.THEME_BLACK: + setTheme(R.style.AppThemeBlack_NoActionBar); + break; + default: + setTheme(R.style.AppThemeDark_NoActionBar); } setContentView(R.layout.activity_list); Toolbar toolbar = findViewById(R.id.toolbar); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/LoginActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/LoginActivity.java index d9ccaf4cb..e98ecd531 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/LoginActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/LoginActivity.java @@ -111,11 +111,20 @@ public class LoginActivity extends BaseActivity { SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); - if (theme == Helper.THEME_LIGHT) { - setTheme(R.style.AppTheme); - } else { - setTheme(R.style.AppThemeDark); + switch (theme){ + case Helper.THEME_LIGHT: + setTheme(R.style.AppTheme); + break; + case Helper.THEME_DARK: + setTheme(R.style.AppThemeDark); + break; + case Helper.THEME_BLACK: + setTheme(R.style.AppThemeBlack); + break; + default: + setTheme(R.style.AppThemeDark); } + setContentView(R.layout.activity_login); if (theme == Helper.THEME_DARK) { diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/OwnerStatusActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/OwnerStatusActivity.java index c41c53d61..dc5e9196e 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/OwnerStatusActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/OwnerStatusActivity.java @@ -104,10 +104,18 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); - if( theme == Helper.THEME_LIGHT){ - setTheme(R.style.AppTheme_NoActionBar); - }else { - setTheme(R.style.AppThemeDark_NoActionBar); + switch (theme){ + case Helper.THEME_LIGHT: + setTheme(R.style.AppTheme_NoActionBar); + break; + case Helper.THEME_DARK: + setTheme(R.style.AppThemeDark_NoActionBar); + break; + case Helper.THEME_BLACK: + setTheme(R.style.AppThemeBlack_NoActionBar); + break; + default: + setTheme(R.style.AppThemeDark_NoActionBar); } setContentView(R.layout.activity_ower_status); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/PrivacyActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/PrivacyActivity.java index aaffb0a84..0b9353e22 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/PrivacyActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/PrivacyActivity.java @@ -36,11 +36,20 @@ public class PrivacyActivity extends BaseActivity { super.onCreate(savedInstanceState); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); - if( theme == Helper.THEME_LIGHT){ - setTheme(R.style.AppTheme); - }else { - setTheme(R.style.AppThemeDark); + switch (theme){ + case Helper.THEME_LIGHT: + setTheme(R.style.AppTheme); + break; + case Helper.THEME_DARK: + setTheme(R.style.AppThemeDark); + break; + case Helper.THEME_BLACK: + setTheme(R.style.AppThemeBlack); + break; + default: + setTheme(R.style.AppThemeDark); } + if( getSupportActionBar() != null) getSupportActionBar().setDisplayHomeAsUpEnabled(true); setContentView(R.layout.activity_privacy); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/RemoteFollowActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/RemoteFollowActivity.java index 325623f4d..553421a2d 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/RemoteFollowActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/RemoteFollowActivity.java @@ -100,11 +100,20 @@ public class RemoteFollowActivity extends BaseActivity implements OnRetrieveRemo SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); - if( theme == Helper.THEME_LIGHT){ - setTheme(R.style.AppTheme); - }else { - setTheme(R.style.AppThemeDark); + switch (theme){ + case Helper.THEME_LIGHT: + setTheme(R.style.AppTheme); + break; + case Helper.THEME_DARK: + setTheme(R.style.AppThemeDark); + break; + case Helper.THEME_BLACK: + setTheme(R.style.AppThemeBlack); + break; + default: + setTheme(R.style.AppThemeDark); } + setContentView(R.layout.activity_remote_follow); rf_instance = findViewById(R.id.rf_instance); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/SearchResultActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/SearchResultActivity.java index 864428242..b023a3310 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/SearchResultActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/SearchResultActivity.java @@ -57,11 +57,20 @@ public class SearchResultActivity extends BaseActivity implements OnRetrieveSear super.onCreate(savedInstanceState); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); - if( theme == Helper.THEME_LIGHT){ - setTheme(R.style.AppTheme); - }else { - setTheme(R.style.AppThemeDark); + switch (theme){ + case Helper.THEME_LIGHT: + setTheme(R.style.AppTheme); + break; + case Helper.THEME_DARK: + setTheme(R.style.AppThemeDark); + break; + case Helper.THEME_BLACK: + setTheme(R.style.AppThemeBlack); + break; + default: + setTheme(R.style.AppThemeDark); } + setContentView(R.layout.activity_search_result); loader = findViewById(R.id.loader); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java index 3c04a56b3..3b80e5d67 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowAccountActivity.java @@ -140,10 +140,18 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt super.onCreate(savedInstanceState); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); - if( theme == Helper.THEME_LIGHT){ - setTheme(R.style.AppTheme_NoActionBar); - }else { - setTheme(R.style.AppThemeDark_NoActionBar); + switch (theme){ + case Helper.THEME_LIGHT: + setTheme(R.style.AppTheme_NoActionBar); + break; + case Helper.THEME_DARK: + setTheme(R.style.AppThemeDark_NoActionBar); + break; + case Helper.THEME_BLACK: + setTheme(R.style.AppThemeBlack_NoActionBar); + break; + default: + setTheme(R.style.AppThemeDark_NoActionBar); } setContentView(R.layout.activity_show_account); setTitle(""); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowConversationActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowConversationActivity.java index f22428e82..64ac03cff 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowConversationActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowConversationActivity.java @@ -90,10 +90,18 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); - if( theme == Helper.THEME_LIGHT){ - setTheme(R.style.AppTheme_NoActionBar); - }else { - setTheme(R.style.AppThemeDark_NoActionBar); + switch (theme){ + case Helper.THEME_LIGHT: + setTheme(R.style.AppTheme_NoActionBar); + break; + case Helper.THEME_DARK: + setTheme(R.style.AppThemeDark_NoActionBar); + break; + case Helper.THEME_BLACK: + setTheme(R.style.AppThemeBlack_NoActionBar); + break; + default: + setTheme(R.style.AppThemeDark_NoActionBar); } expanded = false; diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java index 7353987de..41f804111 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/TootActivity.java @@ -200,11 +200,20 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext())); final int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); - if( theme == Helper.THEME_LIGHT){ - setTheme(R.style.AppTheme); - }else { - setTheme(R.style.AppThemeDark); + switch (theme){ + case Helper.THEME_LIGHT: + setTheme(R.style.AppTheme); + break; + case Helper.THEME_DARK: + setTheme(R.style.AppThemeDark); + break; + case Helper.THEME_BLACK: + setTheme(R.style.AppThemeBlack); + break; + default: + setTheme(R.style.AppThemeDark); } + setContentView(R.layout.activity_toot); ActionBar actionBar = getSupportActionBar(); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/WebviewActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/WebviewActivity.java index 38bb1b756..dda6bdb68 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/WebviewActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/WebviewActivity.java @@ -58,11 +58,20 @@ public class WebviewActivity extends BaseActivity { super.onCreate(savedInstanceState); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); - if( theme == Helper.THEME_LIGHT){ - setTheme(R.style.AppTheme); - }else { - setTheme(R.style.AppThemeDark); + switch (theme){ + case Helper.THEME_LIGHT: + setTheme(R.style.AppTheme); + break; + case Helper.THEME_DARK: + setTheme(R.style.AppThemeDark); + break; + case Helper.THEME_BLACK: + setTheme(R.style.AppThemeBlack); + break; + default: + setTheme(R.style.AppThemeDark); } + setContentView(R.layout.activity_webview); Bundle b = getIntent().getExtras(); if(b != null) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/WebviewConnectActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/WebviewConnectActivity.java index bed1aba9a..635888897 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/WebviewConnectActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/WebviewConnectActivity.java @@ -59,11 +59,20 @@ public class WebviewConnectActivity extends BaseActivity { super.onCreate(savedInstanceState); SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); - if( theme == Helper.THEME_LIGHT){ - setTheme(R.style.AppTheme); - }else { - setTheme(R.style.AppThemeDark); + switch (theme){ + case Helper.THEME_LIGHT: + setTheme(R.style.AppTheme); + break; + case Helper.THEME_DARK: + setTheme(R.style.AppThemeDark); + break; + case Helper.THEME_BLACK: + setTheme(R.style.AppThemeBlack); + break; + default: + setTheme(R.style.AppThemeDark); } + setContentView(R.layout.activity_webview_connect); Bundle b = getIntent().getExtras(); if(b != null) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Status.java b/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Status.java index ee1554f7f..92d4cf87a 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Status.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/client/Entities/Status.java @@ -661,7 +661,7 @@ public class Status implements Parcelable{ matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); if( matchStart >= 0 && matchEnd <= spannableString.toString().length() && matchEnd >= matchStart) - spannableString.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, theme==Helper.THEME_DARK?R.color.mastodonC2:R.color.mastodonC4)), matchStart, matchEnd, + spannableString.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, (theme==Helper.THEME_DARK||theme==Helper.THEME_BLACK)?R.color.mastodonC2:R.color.mastodonC4)), matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); } //Deals with mention to make them clickable @@ -693,7 +693,7 @@ public class Status implements Parcelable{ startPosition, endPosition, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); if( startPosition >= 0 && endPosition <= spannableString.toString().length() && endPosition >= startPosition) - spannableString.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, theme==Helper.THEME_DARK?R.color.mastodonC2:R.color.mastodonC4)), startPosition, endPosition, + spannableString.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, (theme==Helper.THEME_DARK||theme==Helper.THEME_BLACK)?R.color.mastodonC2:R.color.mastodonC4)), startPosition, endPosition, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); } } @@ -722,7 +722,7 @@ public class Status implements Parcelable{ } }, matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); if( matchStart >= 0 && matchEnd <= spannableString.toString().length() && matchEnd >= matchStart) - spannableString.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, theme==Helper.THEME_DARK?R.color.mastodonC2:R.color.mastodonC4)), matchStart, matchEnd, + spannableString.setSpan(new ForegroundColorSpan(ContextCompat.getColor(context, (theme==Helper.THEME_DARK||theme==Helper.THEME_BLACK)?R.color.mastodonC2:R.color.mastodonC4)), matchStart, matchEnd, Spanned.SPAN_INCLUSIVE_EXCLUSIVE); } return spannableString; diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java index 522017102..7b85cac5a 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/StatusListAdapter.java @@ -117,6 +117,7 @@ import fr.gouv.etalab.mastodon.sqlite.StatusCacheDAO; import fr.gouv.etalab.mastodon.sqlite.TempMuteDAO; import static fr.gouv.etalab.mastodon.activities.MainActivity.currentLocale; +import static fr.gouv.etalab.mastodon.helper.Helper.THEME_BLACK; import static fr.gouv.etalab.mastodon.helper.Helper.THEME_DARK; import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor; import static fr.gouv.etalab.mastodon.helper.Helper.getLiveInstance; @@ -521,7 +522,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct holder.status_bookmark.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_bookmark)); else holder.status_bookmark.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_bookmark_border)); - changeDrawableColor(context, R.drawable.ic_fiber_new,R.color.mastodonC4); + if( status.isNew()) holder.new_element.setVisibility(View.VISIBLE); else @@ -562,8 +563,13 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct //Manages theme for icon colors int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); + if( theme == Helper.THEME_BLACK) + changeDrawableColor(context, R.drawable.ic_fiber_new,R.color.dark_icon); + else + changeDrawableColor(context, R.drawable.ic_fiber_new,R.color.mastodonC4); + boolean expand_cw = sharedpreferences.getBoolean(Helper.SET_EXPAND_CW, false); - if( theme == Helper.THEME_DARK){ + if( theme == Helper.THEME_DARK || theme == Helper.THEME_BLACK){ changeDrawableColor(context, R.drawable.ic_reply,R.color.dark_icon); changeDrawableColor(context, holder.status_more, R.color.dark_icon); changeDrawableColor(context, holder.status_privacy, R.color.dark_icon); @@ -716,7 +722,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct //Change the color in gray for accounts in DARK Theme only Spannable wordtoSpan = new SpannableString(name); - if( theme == THEME_DARK) { + if( theme == THEME_DARK || theme == Helper.THEME_BLACK) { Pattern hashAcct; if( status.getReblog() != null) hashAcct = Pattern.compile("\\s(@"+status.getReblog().getAccount().getAcct()+")"); @@ -899,7 +905,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct else status.setSensitive(true); - if( theme == Helper.THEME_DARK) + if( theme == Helper.THEME_DARK || theme == Helper.THEME_BLACK) changeDrawableColor(context, R.drawable.ic_photo,R.color.dark_text); else changeDrawableColor(context, R.drawable.ic_photo,R.color.mastodonC4); @@ -916,7 +922,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct else status.setSensitive(true); - if( theme == Helper.THEME_DARK) + if( theme == Helper.THEME_DARK || theme == Helper.THEME_BLACK) changeDrawableColor(context, R.drawable.ic_photo,R.color.dark_text); else changeDrawableColor(context, R.drawable.ic_photo,R.color.mastodonC4); @@ -968,7 +974,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct changeDrawableColor(context, R.drawable.ic_star,R.color.marked_icon); imgFav = ContextCompat.getDrawable(context, R.drawable.ic_star); }else { - if( theme == THEME_DARK) + if( theme == THEME_DARK || theme == THEME_BLACK) changeDrawableColor(context, R.drawable.ic_star_border,R.color.dark_icon); else changeDrawableColor(context, R.drawable.ic_star_border,R.color.black); @@ -979,7 +985,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct changeDrawableColor(context, R.drawable.ic_repeat_boost,R.color.boost_icon); imgReblog = ContextCompat.getDrawable(context, R.drawable.ic_repeat_boost); }else { - if( theme == THEME_DARK) + if( theme == THEME_DARK || theme == THEME_BLACK) changeDrawableColor(context, R.drawable.ic_repeat,R.color.dark_icon); else changeDrawableColor(context, R.drawable.ic_repeat,R.color.black); @@ -987,7 +993,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct } - if( theme == THEME_DARK) + if( theme == THEME_DARK || theme == THEME_BLACK) changeDrawableColor(context, R.drawable.ic_reply,R.color.dark_icon); else changeDrawableColor(context, R.drawable.ic_reply,R.color.black); @@ -1015,7 +1021,7 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct changeDrawableColor(context, R.drawable.ic_pin_drop_p,R.color.marked_icon); imgPin = ContextCompat.getDrawable(context, R.drawable.ic_pin_drop_p); }else { - if( theme == THEME_DARK) + if( theme == THEME_DARK || theme == THEME_BLACK) changeDrawableColor(context, R.drawable.ic_pin_drop,R.color.dark_icon); else changeDrawableColor(context, R.drawable.ic_pin_drop,R.color.black); @@ -1076,16 +1082,20 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct } if( theme == Helper.THEME_LIGHT){ holder.main_container.setBackgroundResource(R.color.mastodonC3__); - }else { + }else if (theme == Helper.THEME_DARK){ holder.main_container.setBackgroundResource(R.color.mastodonC1_); + }else if (theme == Helper.THEME_BLACK){ + holder.main_container.setBackgroundResource(R.color.black); } if( type == RetrieveFeedsAsyncTask.Type.CONTEXT ){ if( position == conversationPosition){ if( theme == Helper.THEME_LIGHT) holder.main_container.setBackgroundResource(R.color.mastodonC3_); - else + else if( theme == Helper.THEME_DARK) holder.main_container.setBackgroundResource(R.color.mastodonC1___); + else if( theme == Helper.THEME_BLACK) + holder.main_container.setBackgroundResource(R.color.black_2); if( status.getCard() != null){ holder.status_cardview_content.setText(status.getCard().getDescription()); @@ -1137,8 +1147,10 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct holder.status_cardview_video.setVisibility(View.GONE); if( theme == Helper.THEME_LIGHT) holder.main_container.setBackgroundResource(R.color.mastodonC3__); - else + else if( theme == Helper.THEME_DARK) holder.main_container.setBackgroundResource(R.color.mastodonC1_); + else if (theme == Helper.THEME_BLACK) + holder.main_container.setBackgroundResource(R.color.black); } } diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java index a1d8a062e..e4992e3f1 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/helper/Helper.java @@ -972,7 +972,7 @@ public class Helper { final SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); - if( theme == Helper.THEME_DARK){ + if( theme == Helper.THEME_DARK || theme == Helper.THEME_BLACK){ changeDrawableColor(activity, R.drawable.ic_person_add,R.color.dark_text); changeDrawableColor(activity, R.drawable.ic_person,R.color.dark_text); changeDrawableColor(activity, R.drawable.ic_cancel,R.color.dark_text); @@ -1865,7 +1865,11 @@ public class Helper { int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); if (theme == Helper.THEME_DARK) { canvas.drawColor(ContextCompat.getColor(context, R.color.mastodonC1)); - }else { + + }else if( theme == Helper.THEME_BLACK){ + canvas.drawColor(ContextCompat.getColor(context, R.color.black)); + } + else { canvas.drawColor(Color.WHITE); } } diff --git a/app/src/main/res/drawable/button_selector_black.xml b/app/src/main/res/drawable/button_selector_black.xml new file mode 100644 index 000000000..236998710 --- /dev/null +++ b/app/src/main/res/drawable/button_selector_black.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index e95fe46d0..3061c1ae7 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -34,7 +34,7 @@ #B3E5FC #D7CCC8 #000 - + #222 #585c67 #454b5b @@ -49,6 +49,8 @@ #1b80c9 + #8089A4 + #404964 #313543 #353947 diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index e973d2af8..6ca8e1735 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -58,7 +58,6 @@ @color/mastodonC3 - - - - - @@ -206,20 +201,14 @@ @color/black - - - - - - @@ -297,7 +286,6 @@ @color/mastodonC1 - - - - @@ -320,7 +305,6 @@ @color/mastodonC1 - @@ -329,17 +313,11 @@ @drawable/imageview_border_dark - - - - - - From f73d6649be76a3a2c02a6dce429d9c50b74a60e9 Mon Sep 17 00:00:00 2001 From: stom79 Date: Fri, 11 May 2018 13:53:08 +0200 Subject: [PATCH 004/116] Black theme - Apply to notifications and some others changes --- .../mastodon/activities/BaseMainActivity.java | 19 +++++++-- .../mastodon/activities/HashTagActivity.java | 4 ++ .../mastodon/activities/ListActivity.java | 6 ++- .../mastodon/activities/MediaActivity.java | 21 ++++++---- .../activities/OwnerStatusActivity.java | 5 +++ .../activities/ShowConversationActivity.java | 5 +++ .../drawers/NotificationsListAdapter.java | 39 ++++++++++++++----- app/src/main/res/layout/activity_media.xml | 2 + app/src/main/res/values/colors.xml | 6 +++ app/src/main/res/values/styles.xml | 16 ++++++++ 10 files changed, 102 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java index 80268f2e5..aba1ea835 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/BaseMainActivity.java @@ -25,6 +25,7 @@ import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.database.sqlite.SQLiteDatabase; +import android.graphics.Paint; import android.graphics.PorterDuff; import android.net.Uri; import android.os.AsyncTask; @@ -117,6 +118,7 @@ import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_ACTION; import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_TARGETED_ACCOUNT; import static fr.gouv.etalab.mastodon.helper.Helper.NOTIFICATION_INTENT; import static fr.gouv.etalab.mastodon.helper.Helper.PREF_KEY_ID; +import static fr.gouv.etalab.mastodon.helper.Helper.THEME_BLACK; import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor; import static fr.gouv.etalab.mastodon.helper.Helper.changeUser; import static fr.gouv.etalab.mastodon.helper.Helper.menuAccounts; @@ -200,6 +202,8 @@ public abstract class BaseMainActivity extends BaseActivity //Here, the user is authenticated appBar = findViewById(R.id.appBar); Toolbar toolbar = findViewById(R.id.toolbar); + if( theme == THEME_BLACK) + toolbar.setBackgroundColor(ContextCompat.getColor(BaseMainActivity.this, R.color.black)); setSupportActionBar(toolbar); toolbarTitle = toolbar.findViewById(R.id.toolbar_title); toolbar_search = toolbar.findViewById(R.id.toolbar_search); @@ -218,7 +222,10 @@ public abstract class BaseMainActivity extends BaseActivity iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_text), PorterDuff.Mode.SRC_IN); iconHome.setImageResource(R.drawable.ic_home); - iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.mastodonC4), PorterDuff.Mode.SRC_IN); + if( theme == THEME_BLACK) + iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_icon), PorterDuff.Mode.SRC_IN); + else + iconHome.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.mastodonC4), PorterDuff.Mode.SRC_IN); @SuppressWarnings("ConstantConditions") @SuppressLint("CutPasteId") @@ -395,7 +402,11 @@ public abstract class BaseMainActivity extends BaseActivity if( tab.getCustomView() != null) { ImageView icon = tab.getCustomView().findViewById(R.id.tab_icon); if( icon != null) - icon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.mastodonC4), PorterDuff.Mode.SRC_IN); + if( theme == THEME_BLACK) + icon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.dark_icon), PorterDuff.Mode.SRC_IN); + else + icon.setColorFilter(ContextCompat.getColor(getApplicationContext(), R.color.mastodonC4), PorterDuff.Mode.SRC_IN); + } } @@ -577,8 +588,10 @@ public abstract class BaseMainActivity extends BaseActivity }); //Hide the default title - if( getSupportActionBar() != null) + if( getSupportActionBar() != null) { getSupportActionBar().setDisplayShowTitleEnabled(false); + getSupportActionBar().getThemedContext().setTheme(R.style.AppThemeBlack); + } //Defines the current locale of the device in a static variable currentLocale = Helper.currentLocale(getApplicationContext()); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/HashTagActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/HashTagActivity.java index 9e5cb0a87..52da9edf6 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/HashTagActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/HashTagActivity.java @@ -19,6 +19,7 @@ import android.content.Context; import android.content.SharedPreferences; import android.os.AsyncTask; import android.os.Bundle; +import android.support.v4.content.ContextCompat; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.widget.DividerItemDecoration; import android.support.v7.widget.LinearLayoutManager; @@ -40,6 +41,7 @@ import fr.gouv.etalab.mastodon.drawers.StatusListAdapter; import fr.gouv.etalab.mastodon.helper.Helper; import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface; +import static fr.gouv.etalab.mastodon.helper.Helper.THEME_BLACK; /** @@ -84,6 +86,8 @@ public class HashTagActivity extends BaseActivity implements OnRetrieveFeedsInte setContentView(R.layout.activity_hashtag); Toolbar toolbar = findViewById(R.id.toolbar); + if( theme == THEME_BLACK) + toolbar.setBackgroundColor(ContextCompat.getColor(HashTagActivity.this, R.color.black)); setSupportActionBar(toolbar); if( getSupportActionBar() != null) diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/ListActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/ListActivity.java index db711000d..23548223d 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/ListActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/ListActivity.java @@ -21,6 +21,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.os.AsyncTask; import android.os.Bundle; +import android.support.v4.content.ContextCompat; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.app.AlertDialog; import android.support.v7.widget.LinearLayoutManager; @@ -50,6 +51,8 @@ import fr.gouv.etalab.mastodon.drawers.StatusListAdapter; import fr.gouv.etalab.mastodon.helper.Helper; import fr.gouv.etalab.mastodon.interfaces.OnListActionInterface; +import static fr.gouv.etalab.mastodon.helper.Helper.THEME_BLACK; + /** * Created by Thomas on 14/12/2017. @@ -91,8 +94,9 @@ public class ListActivity extends BaseActivity implements OnListActionInterface } setContentView(R.layout.activity_list); Toolbar toolbar = findViewById(R.id.toolbar); + if( theme == THEME_BLACK) + toolbar.setBackgroundColor(ContextCompat.getColor(ListActivity.this, R.color.black)); setSupportActionBar(toolbar); - if( getSupportActionBar() != null) getSupportActionBar().setDisplayHomeAsUpEnabled(true); statuses = new ArrayList<>(); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java index a6c86dc2b..589c47035 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/MediaActivity.java @@ -64,6 +64,7 @@ import fr.gouv.etalab.mastodon.interfaces.OnDownloadInterface; import static fr.gouv.etalab.mastodon.helper.Helper.EXTERNAL_STORAGE_REQUEST_CODE; +import static fr.gouv.etalab.mastodon.helper.Helper.THEME_BLACK; import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor; @@ -105,12 +106,11 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface { @Override protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE); int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); - + if( theme == THEME_BLACK) + setTheme(R.style.TransparentBlack); + super.onCreate(savedInstanceState); setContentView(R.layout.activity_media); SwipeBackLayout mSwipeBackLayout = new SwipeBackLayout(MediaActivity.this); mSwipeBackLayout.setDirectionMode(SwipeBackLayout.FROM_BOTTOM); @@ -140,7 +140,9 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface { RelativeLayout main_container_media = findViewById(R.id.main_container_media); if( theme == Helper.THEME_LIGHT){ main_container_media.setBackgroundResource(R.color.mastodonC2); - }else { + }else if( theme == Helper.THEME_BLACK){ + main_container_media.setBackgroundResource(R.color.black); + }else if( theme == Helper.THEME_DARK){ main_container_media.setBackgroundResource(R.color.mastodonC1_); } message_ready = findViewById(R.id.message_ready); @@ -187,8 +189,13 @@ public class MediaActivity extends BaseActivity implements OnDownloadInterface { videoView = findViewById(R.id.media_video); prev = findViewById(R.id.media_prev); next = findViewById(R.id.media_next); - changeDrawableColor(getApplicationContext(), prev,R.color.mastodonC4); - changeDrawableColor(getApplicationContext(), next,R.color.mastodonC4); + if( theme == THEME_BLACK){ + changeDrawableColor(getApplicationContext(), prev, R.color.dark_icon); + changeDrawableColor(getApplicationContext(), next, R.color.dark_icon); + }else { + changeDrawableColor(getApplicationContext(), prev, R.color.mastodonC4); + changeDrawableColor(getApplicationContext(), next, R.color.mastodonC4); + } prev.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/OwnerStatusActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/OwnerStatusActivity.java index dc5e9196e..a9e331786 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/OwnerStatusActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/OwnerStatusActivity.java @@ -29,6 +29,7 @@ import android.graphics.drawable.BitmapDrawable; import android.os.AsyncTask; import android.os.Bundle; import android.support.annotation.NonNull; +import android.support.v4.content.ContextCompat; import android.support.v4.content.LocalBroadcastManager; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.app.ActionBar; @@ -73,6 +74,8 @@ import fr.gouv.etalab.mastodon.sqlite.AccountDAO; import fr.gouv.etalab.mastodon.sqlite.Sqlite; import fr.gouv.etalab.mastodon.sqlite.StatusCacheDAO; +import static fr.gouv.etalab.mastodon.helper.Helper.THEME_BLACK; + /** * Created by Thomas on 17/02/2018. @@ -126,6 +129,8 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds new IntentFilter(Helper.INTENT_BACKUP_FINISH)); Toolbar toolbar = findViewById(R.id.toolbar); + if( theme == THEME_BLACK) + toolbar.setBackgroundColor(ContextCompat.getColor(OwnerStatusActivity.this, R.color.black)); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowConversationActivity.java b/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowConversationActivity.java index 64ac03cff..25feb993f 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowConversationActivity.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/activities/ShowConversationActivity.java @@ -24,6 +24,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.support.annotation.NonNull; +import android.support.v4.content.ContextCompat; import android.support.v4.widget.SwipeRefreshLayout; import android.support.v7.app.ActionBar; import android.support.v7.widget.DividerItemDecoration; @@ -65,6 +66,8 @@ import fr.gouv.etalab.mastodon.interfaces.OnRetrieveFeedsInterface; import fr.gouv.etalab.mastodon.sqlite.AccountDAO; import fr.gouv.etalab.mastodon.sqlite.Sqlite; +import static fr.gouv.etalab.mastodon.helper.Helper.THEME_BLACK; + /** * Created by Thomas on 04/05/2017. @@ -108,6 +111,8 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve setContentView(R.layout.activity_show_conversation); Toolbar toolbar = findViewById(R.id.toolbar); + if( theme == THEME_BLACK) + toolbar.setBackgroundColor(ContextCompat.getColor(ShowConversationActivity.this, R.color.black)); setSupportActionBar(toolbar); Bundle b = getIntent().getExtras(); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java index a2c3f5614..e7c3c3a4b 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/drawers/NotificationsListAdapter.java @@ -77,6 +77,7 @@ import fr.gouv.etalab.mastodon.client.Entities.Notification; import fr.gouv.etalab.mastodon.client.Entities.Status; import fr.gouv.etalab.mastodon.helper.Helper; +import static fr.gouv.etalab.mastodon.helper.Helper.THEME_BLACK; import static fr.gouv.etalab.mastodon.helper.Helper.THEME_DARK; import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor; import static fr.gouv.etalab.mastodon.helper.Helper.getLiveInstance; @@ -131,7 +132,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK); boolean expand_cw = sharedpreferences.getBoolean(Helper.SET_EXPAND_CW, false); - if (theme == THEME_DARK){ + if (theme == THEME_DARK || theme == THEME_BLACK){ holder.main_container_trans.setAlpha(.3f); }else { holder.main_container_trans.setAlpha(.1f); @@ -146,6 +147,8 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On typeString = String.format("@%s %s", notification.getAccount().getUsername(),context.getString(R.string.notif_mention)); if( theme == Helper.THEME_DARK){ holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_dark_1)); + }else if( theme == Helper.THEME_BLACK){ + holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_black_1)); }else { holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_light_1)); } @@ -161,6 +164,8 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On typeString = String.format("@%s %s", notification.getAccount().getUsername(),context.getString(R.string.notif_reblog)); if( theme == Helper.THEME_DARK){ holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_dark_2)); + }else if( theme == Helper.THEME_BLACK){ + holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_black_2)); }else { holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_light_2)); } @@ -176,6 +181,8 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On typeString = String.format("@%s %s", notification.getAccount().getUsername(),context.getString(R.string.notif_favourite)); if( theme == Helper.THEME_DARK){ holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_dark_3)); + }else if( theme == Helper.THEME_BLACK){ + holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_black_3)); }else { holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_light_3)); } @@ -191,6 +198,8 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On typeString = String.format("@%s %s", notification.getAccount().getUsername(),context.getString(R.string.notif_follow)); if( theme == Helper.THEME_DARK){ holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_dark_4)); + }else if( theme == Helper.THEME_BLACK){ + holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_black_4)); }else { holder.card_status_container.setBackgroundColor(ContextCompat.getColor(context, R.color.notif_light_4)); } @@ -198,10 +207,20 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On holder.main_container_trans.setVisibility(View.GONE); break; } - changeDrawableColor(context, R.drawable.ic_chat_bubble_outline, R.color.mastodonC4); - changeDrawableColor(context, R.drawable.ic_repeat_head,R.color.mastodonC4); - changeDrawableColor(context, R.drawable.ic_star_border_header,R.color.mastodonC4); - changeDrawableColor(context, R.drawable.ic_follow_notif_header,R.color.mastodonC4); + + if( theme == THEME_BLACK){ + changeDrawableColor(context, R.drawable.ic_chat_bubble_outline, R.color.dark_icon); + changeDrawableColor(context, R.drawable.ic_repeat_head,R.color.dark_icon); + changeDrawableColor(context, R.drawable.ic_star_border_header,R.color.dark_icon); + changeDrawableColor(context, R.drawable.ic_follow_notif_header,R.color.dark_icon); + }else { + changeDrawableColor(context, R.drawable.ic_chat_bubble_outline, R.color.mastodonC4); + changeDrawableColor(context, R.drawable.ic_repeat_head,R.color.mastodonC4); + changeDrawableColor(context, R.drawable.ic_star_border_header,R.color.mastodonC4); + changeDrawableColor(context, R.drawable.ic_follow_notif_header,R.color.mastodonC4); + } + + holder.notification_type.setText(typeString); if( imgH != null) { holder.notification_type.setCompoundDrawablePadding((int)Helper.convertDpToPixel(5, context)); @@ -221,7 +240,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On //Manages theme for icon colors - if( theme == Helper.THEME_DARK){ + if( theme == Helper.THEME_DARK || theme == THEME_BLACK){ changeDrawableColor(context, R.drawable.ic_reply,R.color.dark_icon); changeDrawableColor(context, holder.status_more, R.color.dark_icon); changeDrawableColor(context, holder.status_privacy, R.color.dark_icon); @@ -300,7 +319,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On changeDrawableColor(context, R.drawable.ic_star,R.color.marked_icon); imgFav = ContextCompat.getDrawable(context, R.drawable.ic_star); }else { - if( theme == THEME_DARK) + if( theme == THEME_DARK || theme == THEME_BLACK) changeDrawableColor(context, R.drawable.ic_star_border,R.color.dark_icon); else changeDrawableColor(context, R.drawable.ic_star_border,R.color.black); @@ -311,13 +330,13 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On changeDrawableColor(context, R.drawable.ic_repeat_boost,R.color.boost_icon); imgReblog = ContextCompat.getDrawable(context, R.drawable.ic_repeat_boost); }else { - if( theme == THEME_DARK) + if( theme == THEME_DARK || theme == THEME_BLACK) changeDrawableColor(context, R.drawable.ic_repeat,R.color.dark_icon); else changeDrawableColor(context, R.drawable.ic_repeat,R.color.black); imgReblog = ContextCompat.getDrawable(context, R.drawable.ic_repeat); } - if( theme == THEME_DARK) + if( theme == THEME_DARK || theme == THEME_BLACK) changeDrawableColor(context, R.drawable.ic_reply,R.color.dark_icon); else changeDrawableColor(context, R.drawable.ic_reply,R.color.black); @@ -371,7 +390,7 @@ public class NotificationsListAdapter extends RecyclerView.Adapter implements On holder.status_reblog_count.setCompoundDrawables(imgReblog, null, null, null); holder.status_reply.setCompoundDrawables(imgReply, null, null, null); - if( theme == THEME_DARK){ + if( theme == THEME_DARK || theme == THEME_BLACK){ holder.status_favorite_count.setTextColor(ContextCompat.getColor(context, R.color.dark_icon)); holder.status_reblog_count.setTextColor(ContextCompat.getColor(context, R.color.dark_icon)); holder.status_reply.setTextColor(ContextCompat.getColor(context, R.color.dark_icon)); diff --git a/app/src/main/res/layout/activity_media.xml b/app/src/main/res/layout/activity_media.xml index f50919e0b..aa3a5184a 100644 --- a/app/src/main/res/layout/activity_media.xml +++ b/app/src/main/res/layout/activity_media.xml @@ -108,6 +108,7 @@ android:layout_marginLeft="10dp" android:layout_marginTop="5dp" android:layout_width="30dp" + app:backgroundTint="?colorAccent" android:layout_height="30dp" android:src="@drawable/ic_close" /> @@ -121,6 +122,7 @@ android:layout_marginEnd="10dp" android:layout_marginRight="10dp" android:layout_marginTop="5dp" + app:backgroundTint="?colorAccent" android:layout_width="30dp" android:layout_height="30dp" android:src="@drawable/ic_save_white" diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 3061c1ae7..5e9ae6fe9 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -57,6 +57,12 @@ #393f4f #494f5f + + #050505 + #151515 + #202020 + #252525 + #efefef #ebf3fa #d9e1e8 diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 6ca8e1735..b3c4eb3c9 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -69,6 +69,17 @@ @color/mastodonC4 + + @@ -159,6 +170,11 @@ @style/BlackdropDownListViewStyle @color/mastodonC3 @color/mastodonC3 + @style/BlackActionBarTheme + + + @@ -177,16 +177,16 @@ @color/mastodonC3 @color/mastodonC3 @style/BlackActionBarTheme - @color/black + @color/black_3 @color/black