Fix pixelfed compose colors

This commit is contained in:
tom79 2019-11-10 15:05:14 +01:00
parent e11d0f8508
commit d1a51264a9
4 changed files with 31 additions and 94 deletions

View File

@ -56,10 +56,8 @@ import android.widget.DatePicker;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
@ -67,7 +65,6 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
@ -92,7 +89,6 @@ import org.apache.poi.util.IOUtils;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@ -133,7 +129,6 @@ import app.fedilab.android.client.Entities.Results;
import app.fedilab.android.client.Entities.Status;
import app.fedilab.android.client.Entities.StoredStatus;
import app.fedilab.android.client.Entities.Version;
import app.fedilab.android.drawers.AccountsReplyAdapter;
import app.fedilab.android.drawers.AccountsSearchAdapter;
import app.fedilab.android.drawers.EmojisSearchAdapter;
import app.fedilab.android.drawers.SliderAdapter;
@ -155,7 +150,6 @@ import app.fedilab.android.sqlite.StatusStoredDAO;
import es.dmoral.toasty.Toasty;
import static app.fedilab.android.helper.Helper.ALPHA;
import static app.fedilab.android.helper.Helper.MORSE;
import static app.fedilab.android.helper.Helper.changeDrawableColor;
import static app.fedilab.android.helper.Helper.countWithEmoji;
@ -195,10 +189,6 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
private int style;
private StoredStatus scheduledstatus;
private boolean isScheduled;
private List<Boolean> checkedValues;
private List<Account> contacts;
private ListView lv_accounts_search;
private RelativeLayout loader;
private int max_media_count;
public static HashMap<String, Uri> filesMap;
public static boolean autocomplete;
@ -302,15 +292,10 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
pp_progress = actionBar.getCustomView().findViewById(R.id.pp_progress);
}
changeColor();
//By default the toot is not restored so the id -1 is defined
currentToId = -1;
restoredScheduled = false;
String contentType = null;
checkedValues = new ArrayList<>();
contacts = new ArrayList<>();
toot_it = findViewById(R.id.toot_it);
attachments = new ArrayList<>();
imageSlider = findViewById(R.id.imageSlider);
@ -1395,9 +1380,6 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
if (theme == Helper.THEME_LIGHT)
Helper.colorizeIconMenu(menu, R.color.black);
changeColor();
return true;
}
@ -1669,17 +1651,6 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
@Override
public void onRetrieveContact(APIResponse apiResponse) {
if (apiResponse.getError() != null || apiResponse.getAccounts() == null)
return;
this.contacts = new ArrayList<>();
this.checkedValues = new ArrayList<>();
this.contacts.addAll(apiResponse.getAccounts());
for (Account account : contacts) {
this.checkedValues.add(toot_content.getText().toString().contains("@" + account.getAcct()));
}
this.loader.setVisibility(View.GONE);
AccountsReplyAdapter contactAdapter = new AccountsReplyAdapter(new WeakReference<>(PixelfedComposeActivity.this), this.contacts, this.checkedValues);
this.lv_accounts_search.setAdapter(contactAdapter);
}
@Override
@ -2048,42 +2019,6 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
}
}
private void changeColor() {
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
if (theme == Helper.THEME_DARK || theme == Helper.THEME_BLACK) {
changeDrawableColor(PixelfedComposeActivity.this, R.drawable.ic_public_toot, R.color.dark_text);
changeDrawableColor(PixelfedComposeActivity.this, R.drawable.ic_lock_open_toot, R.color.dark_text);
changeDrawableColor(PixelfedComposeActivity.this, R.drawable.ic_lock_outline_toot, R.color.dark_text);
changeDrawableColor(PixelfedComposeActivity.this, R.drawable.ic_mail_outline_toot, R.color.dark_text);
changeDrawableColor(PixelfedComposeActivity.this, R.drawable.ic_insert_photo, R.color.dark_text);
changeDrawableColor(PixelfedComposeActivity.this, R.drawable.ic_skip_previous, R.color.dark_text);
changeDrawableColor(PixelfedComposeActivity.this, R.drawable.ic_skip_next, R.color.dark_text);
changeDrawableColor(PixelfedComposeActivity.this, R.drawable.ic_check, R.color.dark_text);
//bottom action
changeDrawableColor(PixelfedComposeActivity.this, findViewById(R.id.poll_action), R.color.dark_text);
changeDrawableColor(PixelfedComposeActivity.this, findViewById(R.id.toot_visibility), R.color.dark_text);
changeDrawableColor(PixelfedComposeActivity.this, findViewById(R.id.toot_emoji), R.color.dark_text);
Helper.changeButtonTextColor(PixelfedComposeActivity.this, findViewById(R.id.toot_cw), R.color.dark_text);
} else {
changeDrawableColor(PixelfedComposeActivity.this, R.drawable.ic_public_toot, R.color.white);
changeDrawableColor(PixelfedComposeActivity.this, R.drawable.ic_lock_open_toot, R.color.white);
changeDrawableColor(PixelfedComposeActivity.this, R.drawable.ic_lock_outline_toot, R.color.white);
changeDrawableColor(PixelfedComposeActivity.this, R.drawable.ic_mail_outline_toot, R.color.white);
changeDrawableColor(PixelfedComposeActivity.this, R.drawable.ic_insert_photo, R.color.white);
changeDrawableColor(PixelfedComposeActivity.this, R.drawable.ic_skip_previous, R.color.white);
changeDrawableColor(PixelfedComposeActivity.this, R.drawable.ic_skip_next, R.color.white);
changeDrawableColor(PixelfedComposeActivity.this, R.drawable.ic_check, R.color.white);
//bottom action
changeDrawableColor(PixelfedComposeActivity.this, findViewById(R.id.poll_action), R.color.black);
changeDrawableColor(PixelfedComposeActivity.this, findViewById(R.id.toot_visibility), R.color.black);
changeDrawableColor(PixelfedComposeActivity.this, findViewById(R.id.toot_emoji), R.color.black);
Helper.changeButtonTextColor(PixelfedComposeActivity.this, findViewById(R.id.toot_cw), R.color.black);
}
}
@Override

View File

@ -33,6 +33,7 @@ import androidx.appcompat.widget.PopupMenu;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;
import androidx.cardview.widget.CardView;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@ -92,6 +93,7 @@ import app.fedilab.android.client.Entities.Status;
import app.fedilab.android.helper.CrossActions;
import app.fedilab.android.helper.Helper;
import app.fedilab.android.helper.MastalabAutoCompleteTextView;
import app.fedilab.android.helper.ThemeHelper;
import app.fedilab.android.interfaces.OnPostStatusActionInterface;
import app.fedilab.android.interfaces.OnRetrieveContextInterface;
import app.fedilab.android.interfaces.OnRetrieveFeedsInterface;
@ -488,6 +490,19 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
}
});
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
int iconColor = prefs.getInt("theme_icons_color", -1);
if( iconColor == -1){
iconColor = ThemeHelper.getAttColor(context, R.attr.iconColor);
}
int reblogColor = prefs.getInt("theme_boost_header_color", -1);
int statusColor = prefs.getInt("theme_statuses_color", -1);
if( holder.pf_cardview != null && statusColor != -1) {
holder.pf_cardview.setCardBackgroundColor(statusColor);
}else if(holder.pf_cardview != null){
holder.pf_cardview.setCardBackgroundColor(ThemeHelper.getAttColor(context, R.attr.cardviewColor));
}
holder.quick_reply_switch_to_full.setVisibility(View.GONE);
if (status.isShortReply()) {
holder.quick_reply_container.setVisibility(View.VISIBLE);
@ -1026,28 +1041,11 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
if (theme == Helper.THEME_BLACK) {
holder.pf_fav.setInActiveImageTint(R.color.action_black);
holder.pf_share.setInActiveImageTint(R.color.action_black);
Helper.changeDrawableColor(context, R.drawable.ic_pixelfed_favorite_border, R.color.action_black);
Helper.changeDrawableColor(context, holder.pf_comment, R.color.action_black);
Helper.changeDrawableColor(context, holder.status_more, R.color.action_black);
holder.pf_cardview.setCardBackgroundColor(ContextCompat.getColor(context, R.color.black_3));
} else if (theme == Helper.THEME_DARK) {
holder.pf_fav.setInActiveImageTint(R.color.action_dark);
holder.pf_share.setInActiveImageTint(R.color.action_dark);
Helper.changeDrawableColor(context, holder.pf_comment, R.color.action_dark);
Helper.changeDrawableColor(context, holder.status_more, R.color.action_dark);
Helper.changeDrawableColor(context, R.drawable.ic_pixelfed_favorite_border, R.color.action_dark);
holder.pf_cardview.setCardBackgroundColor(ContextCompat.getColor(context, R.color.mastodonC1_));
} else {
holder.pf_fav.setInActiveImageTint(R.color.action_light);
holder.pf_share.setInActiveImageTint(R.color.action_light);
Helper.changeDrawableColor(context, holder.pf_comment, R.color.action_light);
Helper.changeDrawableColor(context, holder.status_more, R.color.action_light);
Helper.changeDrawableColor(context, R.drawable.ic_pixelfed_favorite_border, R.color.action_light);
holder.pf_cardview.setCardBackgroundColor(ContextCompat.getColor(context, R.color.white));
}
holder.pf_fav.setInActiveImageTintColor(iconColor);
holder.pf_share.setInActiveImageTintColor(iconColor);
Helper.changeDrawableColor(context, holder.pf_comment, iconColor);
Helper.changeDrawableColor(context, holder.status_more,iconColor);
Helper.changeDrawableColor(context, R.drawable.ic_pixelfed_favorite_border, iconColor);
holder.pf_fav.pressOnTouch(false);
@ -1151,7 +1149,6 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
statusToTranslate = Html.fromHtml(status.getReblog() != null ? status.getReblog().getContent() : status.getContent(), Html.FROM_HTML_MODE_LEGACY).toString();
else
//noinspection deprecation
statusToTranslate = Html.fromHtml(status.getReblog() != null ? status.getReblog().getContent() : status.getContent()).toString();
//TODO: removes the replaceAll once fixed with the lib
myTransL.translate(statusToTranslate, myTransL.getLocale(), new Results() {
@ -1335,9 +1332,7 @@ public class PixelfedListAdapter extends RecyclerView.Adapter implements OnPostA
hour = timePicker.getHour();
minute = timePicker.getMinute();
} else {
//noinspection deprecation
hour = timePicker.getCurrentHour();
//noinspection deprecation
minute = timePicker.getCurrentMinute();
}
Calendar calendar = new GregorianCalendar(datePicker.getYear(),

View File

@ -208,7 +208,9 @@
android:layout_width="wrap_content"
android:layout_gravity="center"
android:layout_height="wrap_content"
android:text="@string/cw" />
android:text="@string/cw"
android:buttonTint="?attr/iconColor"
android:textColor="?attr/iconColor"/>
<TextView
android:id="@+id/toot_space_left"

View File

@ -36,13 +36,15 @@
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:orientation="horizontal">
android:orientation="horizontal"
tools:ignore="UseCompoundDrawables">
<ImageView
android:id="@+id/pf_pp"
android:layout_gravity="center"
android:layout_width="40dp"
android:layout_height="40dp" />
android:layout_height="40dp"
android:contentDescription="@string/profile_picture" />
<TextView
android:layout_marginLeft="15dp"
@ -125,6 +127,7 @@
android:id="@+id/pf_comment"
android:contentDescription="@string/leave_a_comment"
android:src="@drawable/ic_pixelfed_comment"
android:tint="?attr/iconColor"
android:layout_width="30dp"
android:layout_height="30dp" />
@ -143,7 +146,9 @@
android:layout_width="30dp"
android:layout_height="30dp"
android:src="@drawable/ic_more_pixelfed"
android:layout_gravity="end|center_vertical" />
android:tint="?attr/iconColor"
android:layout_gravity="end|center_vertical"
android:contentDescription="@string/display_toot_truncate" />
</LinearLayout>
<LinearLayout