update button style on compose activity

This commit is contained in:
Len Chan 2019-03-30 20:27:16 +08:00
parent 8aefa82386
commit bec6569af5
4 changed files with 99 additions and 61 deletions

View File

@ -157,6 +157,7 @@ import fr.gouv.etalab.mastodon.sqlite.StatusStoredDAO;
import static fr.gouv.etalab.mastodon.helper.Helper.HOME_TIMELINE_INTENT;
import static fr.gouv.etalab.mastodon.helper.Helper.INTENT_ACTION;
import static fr.gouv.etalab.mastodon.helper.Helper.THEME_LIGHT;
import static fr.gouv.etalab.mastodon.helper.Helper.changeButtonTextColor;
import static fr.gouv.etalab.mastodon.helper.Helper.changeDrawableColor;
import static fr.gouv.etalab.mastodon.helper.Helper.convertDpToPixel;
@ -2883,8 +2884,6 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
Toasty.error(getApplicationContext(), getString(R.string.toast_error), Toast.LENGTH_LONG).show();
}
}
private void changeColor(){
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
@ -2898,6 +2897,13 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
changeDrawableColor(TootActivity.this, R.drawable.ic_skip_next, R.color.dark_text);
changeDrawableColor(TootActivity.this, R.drawable.ic_check, R.color.dark_text);
changeDrawableColor(TootActivity.this, R.drawable.emoji_one_category_smileysandpeople, R.color.dark_text);
//bottom action
changeDrawableColor(TootActivity.this, findViewById(R.id.toot_picture), R.color.dark_text);
changeDrawableColor(TootActivity.this, findViewById(R.id.poll_action), R.color.dark_text);
changeDrawableColor(TootActivity.this, findViewById(R.id.toot_visibility), R.color.dark_text);
changeDrawableColor(TootActivity.this, findViewById(R.id.toot_emoji), R.color.dark_text);
changeButtonTextColor(TootActivity.this, findViewById(R.id.toot_cw), R.color.dark_text);
}else {
changeDrawableColor(TootActivity.this, R.drawable.ic_public_toot, R.color.white);
changeDrawableColor(TootActivity.this, R.drawable.ic_lock_open_toot, R.color.white);
@ -2908,6 +2914,13 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
changeDrawableColor(TootActivity.this, R.drawable.ic_skip_next, R.color.white);
changeDrawableColor(TootActivity.this, R.drawable.ic_check, R.color.white);
changeDrawableColor(TootActivity.this, R.drawable.emoji_one_category_smileysandpeople, R.color.black);
//bottom action
changeDrawableColor(TootActivity.this, findViewById(R.id.toot_picture), R.color.black);
changeDrawableColor(TootActivity.this, findViewById(R.id.poll_action), R.color.black);
changeDrawableColor(TootActivity.this, findViewById(R.id.toot_visibility), R.color.black);
changeDrawableColor(TootActivity.this, findViewById(R.id.toot_emoji), R.color.black);
changeButtonTextColor(TootActivity.this, findViewById(R.id.toot_cw), R.color.black);
}
}

View File

@ -95,6 +95,7 @@ import android.webkit.MimeTypeMap;
import android.webkit.URLUtil;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
@ -2303,6 +2304,14 @@ public class Helper {
imageButton.setColorFilter(context.getResources().getColor(hexaColor));
}
/**
* change color of a drawable
* @param button int the button
* @param hexaColor example 0xffff00
*/
public static void changeButtonTextColor(Context context, Button button, int hexaColor){
button.setTextColor(context.getResources().getColor(hexaColor));
}
/**
* Returns the current locale of the device
* @param context Context

View File

@ -100,7 +100,9 @@
android:layout_width="50dp"
android:layout_height="50dp"
android:scaleType="centerCrop"
android:padding="5dp"
style="@style/Base.Widget.AppCompat.Button.Colored"
android:background="@color/transparent"
android:src="@drawable/ic_insert_photo"
android:contentDescription="@string/toot_select_image" />
<ImageButton
@ -108,8 +110,10 @@
android:visibility="gone"
android:layout_width="50dp"
android:layout_height="50dp"
android:padding="5dp"
android:scaleType="centerCrop"
style="@style/Base.Widget.AppCompat.Button.Colored"
android:background="@color/transparent"
android:src="@drawable/ic_view_list_poll"
android:contentDescription="@string/poll" />
<ImageButton
@ -119,7 +123,9 @@
android:layout_width="50dp"
android:layout_height="50dp"
android:scaleType="centerCrop"
android:padding="5dp"
style="@style/Base.Widget.AppCompat.Button.Colored"
android:background="@color/transparent"
android:src="@drawable/ic_public"
android:contentDescription="@string/toot_visibility_tilte"/>
<Button
@ -128,9 +134,11 @@
android:layout_marginStart="5dp"
android:padding="5dp"
android:text="@string/cw"
android:textSize="20sp"
android:adjustViewBounds="true"
android:layout_gravity="center"
style="@style/Widget.AppCompat.Button.Colored"
android:background="@color/transparent"
android:layout_width="50dp"
android:layout_height="50dp"
android:scaleType="centerCrop"/>
@ -141,10 +149,11 @@
android:layout_marginStart="5dp"
android:minWidth="0dp"
android:layout_gravity="center"
android:padding="10dp"
android:padding="5dp"
android:contentDescription="@string/emoji_picker"
android:src="@drawable/ic_emoji_selector"
style="@style/Widget.AppCompat.Button.Colored"
android:background="@color/transparent"
android:layout_width="50dp"
android:layout_height="50dp"
android:scaleType="centerCrop"

View File

@ -46,136 +46,143 @@
android:minLines="4"
android:layout_weight="1"
android:layout_height="0dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:visibility="gone"
android:id="@+id/progress_bar_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:visibility="gone">
<ProgressBar
style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal"
android:indeterminate="false"
android:id="@+id/upload_progress"
style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal"
android:layout_width="match_parent"
android:max="100"
android:progress="0"
android:layout_height="wrap_content"
/>
android:indeterminate="false"
android:max="100"
android:progress="0" />
<TextView
android:id="@+id/toolbar_text"
android:layout_width="match_parent"
android:textColor="@color/dark_text"
android:gravity="center"
android:textSize="12sp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_height="wrap_content" />
android:gravity="center"
android:textColor="@color/dark_text"
android:textSize="12sp" />
</RelativeLayout>
<HorizontalScrollView
android:id="@+id/picture_scrollview"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
android:visibility="gone">
<LinearLayout
android:padding="5dp"
android:id="@+id/toot_picture_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxHeight="100dp"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:maxHeight="100dp"
android:orientation="horizontal"
>
</LinearLayout>
android:padding="5dp"></LinearLayout>
</HorizontalScrollView>
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:orientation="horizontal">
<fr.gouv.etalab.mastodon.helper.SquareImageButton
<ImageButton
android:id="@+id/toot_picture"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_width="40dp"
android:layout_height="40dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:background="@color/transparent"
android:contentDescription="@string/toot_select_image"
android:padding="5dp"
android:scaleType="centerCrop"
android:src="@drawable/ic_insert_photo" />
<fr.gouv.etalab.mastodon.helper.SquareImageButton
<ImageButton
android:id="@+id/poll_action"
android:visibility="gone"
android:scaleType="centerCrop"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_width="40dp"
android:layout_height="40dp"
android:adjustViewBounds="true"
style="@style/Widget.AppCompat.Button.Colored"
android:background="@color/transparent"
android:contentDescription="@string/poll"
android:padding="5dp"
android:scaleType="centerCrop"
android:src="@drawable/ic_view_list_poll"
android:contentDescription="@string/poll" />
<fr.gouv.etalab.mastodon.helper.SquareImageButton
android:scaleType="centerCrop"
android:visibility="gone" />
<ImageButton
android:id="@+id/toot_visibility"
android:layout_width="40dp"
android:layout_height="40dp"
android:adjustViewBounds="true"
android:layout_width="45dp"
android:layout_height="45dp"
style="@style/Widget.AppCompat.Button.Colored"
android:src="@drawable/ic_public"
android:contentDescription="@string/toot_visibility_tilte" />
android:background="@color/transparent"
android:contentDescription="@string/toot_visibility_tilte"
android:padding="5dp"
android:scaleType="centerCrop"
android:src="@drawable/ic_public" />
<fr.gouv.etalab.mastodon.helper.SquareButton
<Button
android:id="@+id/toot_cw"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="45dp"
android:layout_height="45dp"
android:scaleType="fitXY"
android:layout_gravity="center"
android:layout_width="40dp"
android:layout_height="40dp"
android:adjustViewBounds="true"
android:padding="2dp"
android:text="@string/cw" />
android:background="@color/transparent"
android:text="@string/cw"
android:textSize="20sp" />
<fr.gouv.etalab.mastodon.helper.SquareImageButton
<ImageButton
android:id="@+id/toot_emoji"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:background="@color/transparent"
android:contentDescription="@string/emoji_picker"
android:minWidth="0dp"
android:minHeight="0dp"
android:padding="8dp"
android:padding="5dp"
android:scaleType="centerCrop"
android:src="@drawable/ic_emoji_selector" />
<TextView
android:id="@+id/toot_space_left"
android:layout_width="0dp"
android:textColor="?colorAccent"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:layout_gravity="center"
android:layout_height="45dp" />
android:textColor="?colorAccent" />
<Button
android:id="@+id/toot_it"
style="@style/Widget.AppCompat.Button.Colored"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_height="40dp"
android:layout_gravity="end"
android:gravity="center"
android:padding="5dp"
android:text="@string/toot_it" />
</LinearLayout>
<CheckBox
android:text="@string/toot_sensitive"
android:visibility="gone"
android:id="@+id/toot_sensitive"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="wrap_content"
android:text="@string/toot_sensitive"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
</ScrollView>