diff --git a/app/build.gradle b/app/build.gradle index f77cfdfe3..2e31b866a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -33,4 +33,5 @@ dependencies { compile 'com.evernote:android-job:1.1.11' compile 'com.github.chrisbanes:PhotoView:2.0.0' + } 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 518d6954e..baafc4519 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 @@ -117,6 +117,14 @@ public class MediaActivity extends AppCompatActivity { finish(); if( getSupportActionBar() != null) getSupportActionBar().setDisplayHomeAsUpEnabled(true); + + RelativeLayout main_container_media = (RelativeLayout) findViewById(R.id.main_container_media); + if( theme == Helper.THEME_LIGHT){ + main_container_media.setBackgroundResource(R.color.background_image); + }else { + main_container_media.setBackgroundResource(R.color.colorPrimaryD); + } + loader = (RelativeLayout) findViewById(R.id.loader); imageView = (PhotoView) findViewById(R.id.media_picture); videoView = (VideoView) findViewById(R.id.media_video); 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 a162d472c..5255f584a 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 @@ -80,6 +80,8 @@ import fr.gouv.etalab.mastodon.sqlite.AccountDAO; import fr.gouv.etalab.mastodon.sqlite.Sqlite; import mastodon.etalab.gouv.fr.mastodon.R; +import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor; + /** * Created by Thomas on 01/05/2017. @@ -143,6 +145,25 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc toot_lv_accounts = (ListView) findViewById(R.id.toot_lv_accounts); toot_sensitive = (CheckBox) findViewById(R.id.toot_sensitive); + + if( theme == Helper.THEME_DARK){ + changeDrawableColor(TootActivity.this, R.drawable.ic_action_globe,R.color.dark_text); + changeDrawableColor(TootActivity.this, R.drawable.ic_action_lock_open,R.color.dark_text); + changeDrawableColor(TootActivity.this, R.drawable.ic_action_lock_closed,R.color.dark_text); + changeDrawableColor(TootActivity.this, R.drawable.ic_local_post_office,R.color.dark_text); + + changeDrawableColor(TootActivity.this, R.drawable.ic_action_globe,R.color.dark_text); + changeDrawableColor(TootActivity.this, R.drawable.ic_action_camera,R.color.dark_text); + }else { + changeDrawableColor(TootActivity.this, R.drawable.ic_action_globe,R.color.black); + changeDrawableColor(TootActivity.this, R.drawable.ic_action_lock_open,R.color.black); + changeDrawableColor(TootActivity.this, R.drawable.ic_action_lock_closed,R.color.black); + changeDrawableColor(TootActivity.this, R.drawable.ic_local_post_office,R.color.black); + + changeDrawableColor(TootActivity.this, R.drawable.ic_action_globe,R.color.black); + changeDrawableColor(TootActivity.this, R.drawable.ic_action_camera,R.color.black); + } + final LinearLayout drawer_layout = (LinearLayout) findViewById(R.id.drawer_layout); /*drawer_layout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { 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 381132990..b1d2f9dc0 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 @@ -62,6 +62,7 @@ import fr.gouv.etalab.mastodon.client.Entities.Attachment; import fr.gouv.etalab.mastodon.client.Entities.Status; import fr.gouv.etalab.mastodon.interfaces.OnPostActionInterface; +import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor; /** @@ -185,6 +186,32 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf if( type == RetrieveFeedsAsyncTask.Type.USER){ holder.status_action_container.setVisibility(View.GONE); } + //Manages theme for icon colors + final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); + int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_LIGHT); + if( theme == Helper.THEME_DARK){ + changeDrawableColor(context, R.drawable.ic_reply,R.color.dark_text); + changeDrawableColor(context, R.drawable.ic_action_more,R.color.dark_text); + changeDrawableColor(context, R.drawable.ic_action_globe,R.color.dark_text); + changeDrawableColor(context, R.drawable.ic_action_lock_open,R.color.dark_text); + changeDrawableColor(context, R.drawable.ic_action_lock_closed,R.color.dark_text); + changeDrawableColor(context, R.drawable.ic_local_post_office,R.color.dark_text); + changeDrawableColor(context, R.drawable.ic_retweet_black,R.color.dark_text); + changeDrawableColor(context, R.drawable.ic_fav_black,R.color.dark_text); + changeDrawableColor(context, R.drawable.ic_photo,R.color.dark_text); + }else { + changeDrawableColor(context, R.drawable.ic_reply,R.color.black); + changeDrawableColor(context, R.drawable.ic_action_more,R.color.black); + changeDrawableColor(context, R.drawable.ic_action_globe,R.color.black); + changeDrawableColor(context, R.drawable.ic_action_lock_open,R.color.black); + changeDrawableColor(context, R.drawable.ic_action_lock_closed,R.color.black); + changeDrawableColor(context, R.drawable.ic_local_post_office,R.color.black); + changeDrawableColor(context, R.drawable.ic_retweet_black,R.color.black); + changeDrawableColor(context, R.drawable.ic_fav_black,R.color.black); + changeDrawableColor(context, R.drawable.ic_photo,R.color.black); + } + + final float scale = context.getResources().getDisplayMetrics().density; if( !status.getIn_reply_to_account_id().equals("null") || !status.getIn_reply_to_id().equals("null") ){ Drawable img = ContextCompat.getDrawable(context, R.drawable.ic_reply); @@ -197,7 +224,8 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf }else{ holder.status_account_displayname.setCompoundDrawables( null, null, null, null); } - final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); + + //Click on a conversation if( type != RetrieveFeedsAsyncTask.Type.CONTEXT ){ holder.status_content.setOnClickListener(new View.OnClickListener() { @@ -211,7 +239,6 @@ public class StatusListAdapter extends BaseAdapter implements OnPostActionInterf } }); }else { - int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_LIGHT); if( theme == Helper.THEME_LIGHT){ if( position == ShowConversationActivity.position){ holder.main_container.setBackgroundResource(R.color.blue_light); 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 71028330b..e2dce425b 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 @@ -31,7 +31,9 @@ import android.database.sqlite.SQLiteDatabase; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Color; +import android.graphics.PorterDuff; import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; import android.media.RingtoneManager; import android.net.ConnectivityManager; import android.net.NetworkInfo; @@ -44,6 +46,7 @@ import android.support.annotation.ColorInt; import android.support.design.widget.NavigationView; import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationManagerCompat; +import android.support.v4.content.ContextCompat; import android.text.Html; import android.text.SpannableString; import android.text.Spanned; @@ -54,6 +57,7 @@ import android.util.DisplayMetrics; import android.util.Log; import android.util.TypedValue; import android.view.MenuItem; +import android.view.SubMenu; import android.view.View; import android.view.WindowManager; import android.webkit.CookieManager; @@ -691,20 +695,35 @@ public class Helper { if( currrentUserId == null) return; + MenuItem menu_account = navigationView.getMenu().findItem(R.id.nav_account_list); + MenuItem nav_main_com = navigationView.getMenu().findItem(R.id.nav_main_com); + MenuItem nav_main_opt= navigationView.getMenu().findItem(R.id.nav_main_opt); + final SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); + int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_LIGHT); + if( theme == Helper.THEME_DARK){ + 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); + }else { + changeDrawableColor(activity, R.drawable.ic_person_add,R.color.black); + changeDrawableColor(activity, R.drawable.ic_person,R.color.black); + changeDrawableColor(activity, R.drawable.ic_cancel,R.color.black); + } + if( !menuAccountsOpened ){ arrow.setImageResource(R.drawable.ic_arrow_drop_up); - navigationView.getMenu().clear(); - navigationView.inflateMenu(R.menu.menu_accounts); - SQLiteDatabase db = Sqlite.getInstance(activity, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); - + menu_account.setVisible(true); + nav_main_com.setVisible(false); + nav_main_opt.setVisible(false); final List accounts = new AccountDAO(activity, db).getAllAccount(); - navigationView.setItemIconTintList(null); + SubMenu navigationViewSub = navigationView.getMenu().findItem(R.id.nav_account_list).getSubMenu(); + navigationViewSub.clear(); for(final Account account: accounts) { if( !currrentUserId.equals(account.getId()) ) { - final MenuItem item = navigationView.getMenu().add("@" + account.getAcct() + "@" + account.getInstance()); + final MenuItem item = navigationViewSub.add("@" + account.getAcct() + "@" + account.getInstance()); ImageLoader imageLoader; DisplayImageOptions options = new DisplayImageOptions.Builder().displayer(new SimpleBitmapDisplayer()).cacheInMemory(false) .cacheOnDisk(true).resetViewBeforeLoading(true).build(); @@ -723,6 +742,7 @@ public class Helper { @Override public void onLoadingComplete(String s, View view, Bitmap bitmap) { item.setIcon(new BitmapDrawable(activity.getResources(), bitmap)); + item.getIcon().setColorFilter(0xFFFFFFFF, PorterDuff.Mode.MULTIPLY); } @Override @@ -770,7 +790,7 @@ public class Helper { } } - MenuItem addItem = navigationView.getMenu().add(R.string.add_account); + MenuItem addItem = navigationViewSub.add(R.string.add_account); addItem.setIcon(R.drawable.ic_person_add); addItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override @@ -782,13 +802,14 @@ public class Helper { } }); }else{ + menu_account.setVisible(false); + nav_main_com.setVisible(true); + nav_main_opt.setVisible(true); arrow.setImageResource(R.drawable.ic_arrow_drop_down); - navigationView.getMenu().clear(); - navigationView.inflateMenu(R.menu.activity_main_drawer); - final SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); SQLiteDatabase db = Sqlite.getInstance(activity, Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open(); String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null); Account account = new AccountDAO(activity, db).getAccountByID(userId); + if( account != null) { if (account.isLocked()) { navigationView.getMenu().findItem(R.id.nav_follow_request).setVisible(true); @@ -1059,6 +1080,7 @@ public class Helper { CookieManager cookieManager = CookieManager.getInstance(); cookieManager.setAcceptThirdPartyCookies(webView, cookies); } + webView.setBackgroundColor(Color.TRANSPARENT); webView.getSettings().setAppCacheEnabled(true); webView.getSettings().setDatabaseEnabled(true); webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT); @@ -1092,5 +1114,15 @@ public class Helper { return ""; } - + /** + * change color of a drawable + * @param drawable int the drawable + * @param hexaColor example 0xffff00 + */ + public static Drawable changeDrawableColor(Context context, int drawable, int hexaColor){ + int color = Color.parseColor(context.getString(hexaColor)); + Drawable mDrawable = ContextCompat.getDrawable(context, drawable); + mDrawable.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); + return mDrawable; + } } diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/webview/MastalabWebViewClient.java b/app/src/main/java/fr/gouv/etalab/mastodon/webview/MastalabWebViewClient.java index 9ff1d9348..c844119fd 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/webview/MastalabWebViewClient.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/webview/MastalabWebViewClient.java @@ -17,14 +17,11 @@ import android.app.Activity; import android.graphics.Bitmap; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.TextView; - -import fr.gouv.etalab.mastodon.helper.Helper; import mastodon.etalab.gouv.fr.mastodon.R; /** diff --git a/app/src/main/res/drawable-hdpi/ic_action_globe_menu.png b/app/src/main/res/drawable-hdpi/ic_action_globe_menu.png new file mode 100644 index 000000000..f76e15a6a Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_action_globe_menu.png differ diff --git a/app/src/main/res/drawable-ldpi/ic_action_globe_menu.png b/app/src/main/res/drawable-ldpi/ic_action_globe_menu.png new file mode 100644 index 000000000..bcf031640 Binary files /dev/null and b/app/src/main/res/drawable-ldpi/ic_action_globe_menu.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_action_globe_menu.png b/app/src/main/res/drawable-mdpi/ic_action_globe_menu.png new file mode 100644 index 000000000..6ddcc8102 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_action_globe_menu.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_action_globe_menu.png b/app/src/main/res/drawable-xhdpi/ic_action_globe_menu.png new file mode 100644 index 000000000..4f263b822 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_action_globe_menu.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_action_globe_menu.png b/app/src/main/res/drawable-xxhdpi/ic_action_globe_menu.png new file mode 100644 index 000000000..a51cef202 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_action_globe_menu.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_action_globe_menu.png b/app/src/main/res/drawable-xxxhdpi/ic_action_globe_menu.png new file mode 100644 index 000000000..332518dcb Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_action_globe_menu.png differ diff --git a/app/src/main/res/layout/activity_media.xml b/app/src/main/res/layout/activity_media.xml index e41911a99..22948ce35 100644 --- a/app/src/main/res/layout/activity_media.xml +++ b/app/src/main/res/layout/activity_media.xml @@ -19,7 +19,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@color/background_image" + android:id="@+id/main_container_media" > - + + + + + - + Communication Utilisateurs muets Utilisateurs bloqués + Comptes Notifications Demandes d\'abonnements Optimisation @@ -65,7 +66,7 @@ Envoyer un email Veuillez sélectionner un fichier Aucun explorateur de fichiers trouvé ! - Cliquez sur le chemin pour changer + Cliquer sur le chemin pour changer Aucun pouet à afficher ! Pouet ajouté aux favoris !