diff --git a/app/src/common/java/app/fedilab/android/activities/BaseFragmentActivity.java b/app/src/common/java/app/fedilab/android/activities/BaseFragmentActivity.java index 04a1445b0..0eedc8539 100644 --- a/app/src/common/java/app/fedilab/android/activities/BaseFragmentActivity.java +++ b/app/src/common/java/app/fedilab/android/activities/BaseFragmentActivity.java @@ -1,5 +1,8 @@ package app.fedilab.android.activities; +import com.vanniktech.emoji.EmojiManager; +import com.vanniktech.emoji.one.EmojiOneProvider; + import app.fedilab.android.helper.Helper; /* Copyright 2020 Thomas Schneider @@ -17,15 +20,7 @@ import app.fedilab.android.helper.Helper; * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see . */ - -import androidx.appcompat.app.AppCompatActivity; - -import com.vanniktech.emoji.EmojiManager; -import com.vanniktech.emoji.one.EmojiOneProvider; - -import app.fedilab.android.helper.Helper; - -public class BaseFragmentActivity extends MainBaseFragmentActivity{ +public class BaseFragmentActivity extends MainBaseFragmentActivity { static { Helper.installProvider(); diff --git a/app/src/common/java/app/fedilab/android/activities/OwnerChartsActivity.java b/app/src/common/java/app/fedilab/android/activities/OwnerChartsActivity.java index a55f43dc7..e990879c2 100644 --- a/app/src/common/java/app/fedilab/android/activities/OwnerChartsActivity.java +++ b/app/src/common/java/app/fedilab/android/activities/OwnerChartsActivity.java @@ -22,7 +22,6 @@ import android.content.SharedPreferences; import android.database.sqlite.SQLiteDatabase; import android.graphics.Color; import android.graphics.drawable.ColorDrawable; -import android.os.AsyncTask; import android.os.Bundle; import android.view.LayoutInflater; import android.view.MenuItem; diff --git a/app/src/common/java/app/fedilab/android/activities/OwnerNotificationActivity.java b/app/src/common/java/app/fedilab/android/activities/OwnerNotificationActivity.java index 090f683be..26a797263 100644 --- a/app/src/common/java/app/fedilab/android/activities/OwnerNotificationActivity.java +++ b/app/src/common/java/app/fedilab/android/activities/OwnerNotificationActivity.java @@ -23,7 +23,6 @@ import android.content.IntentFilter; import android.content.SharedPreferences; import android.database.sqlite.SQLiteDatabase; import android.graphics.drawable.ColorDrawable; -import android.os.AsyncTask; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; diff --git a/app/src/common/java/app/fedilab/android/activities/OwnerNotificationChartsActivity.java b/app/src/common/java/app/fedilab/android/activities/OwnerNotificationChartsActivity.java index 93bd5a0ce..e14ee4c02 100644 --- a/app/src/common/java/app/fedilab/android/activities/OwnerNotificationChartsActivity.java +++ b/app/src/common/java/app/fedilab/android/activities/OwnerNotificationChartsActivity.java @@ -22,7 +22,6 @@ import android.content.SharedPreferences; import android.database.sqlite.SQLiteDatabase; import android.graphics.Color; import android.graphics.drawable.ColorDrawable; -import android.os.AsyncTask; import android.os.Bundle; import android.view.LayoutInflater; import android.view.MenuItem; diff --git a/app/src/common/java/app/fedilab/android/activities/OwnerStatusActivity.java b/app/src/common/java/app/fedilab/android/activities/OwnerStatusActivity.java index 2c3eae251..818cdd281 100644 --- a/app/src/common/java/app/fedilab/android/activities/OwnerStatusActivity.java +++ b/app/src/common/java/app/fedilab/android/activities/OwnerStatusActivity.java @@ -23,7 +23,6 @@ import android.content.IntentFilter; import android.content.SharedPreferences; import android.database.sqlite.SQLiteDatabase; import android.graphics.drawable.ColorDrawable; -import android.os.AsyncTask; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; diff --git a/app/src/common/java/app/fedilab/android/activities/PixelfedComposeActivity.java b/app/src/common/java/app/fedilab/android/activities/PixelfedComposeActivity.java index a642c49bb..a9a800422 100644 --- a/app/src/common/java/app/fedilab/android/activities/PixelfedComposeActivity.java +++ b/app/src/common/java/app/fedilab/android/activities/PixelfedComposeActivity.java @@ -4,7 +4,6 @@ package app.fedilab.android.activities; import android.content.Intent; import android.net.Uri; import android.os.Bundle; -import com.vanniktech.emoji.EmojiPopup; /* Copyright 2020 Thomas Schneider @@ -21,7 +20,7 @@ import com.vanniktech.emoji.EmojiPopup; * * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see . */ -public class PixelfedComposeActivity extends BasePixelfedComposeActivity{ +public class PixelfedComposeActivity extends BasePixelfedComposeActivity { @Override diff --git a/app/src/common/java/app/fedilab/android/activities/TootActivity.java b/app/src/common/java/app/fedilab/android/activities/TootActivity.java index aa0c12e36..26fe4a150 100644 --- a/app/src/common/java/app/fedilab/android/activities/TootActivity.java +++ b/app/src/common/java/app/fedilab/android/activities/TootActivity.java @@ -44,7 +44,7 @@ import es.dmoral.toasty.Toasty; * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see . */ -public class TootActivity extends BaseTootActivity{ +public class TootActivity extends BaseTootActivity { private AlertDialog dialogTrans; diff --git a/app/src/common/java/app/fedilab/android/drawers/NotificationsListAdapter.java b/app/src/common/java/app/fedilab/android/drawers/NotificationsListAdapter.java index b4a4368c4..f2cc92800 100644 --- a/app/src/common/java/app/fedilab/android/drawers/NotificationsListAdapter.java +++ b/app/src/common/java/app/fedilab/android/drawers/NotificationsListAdapter.java @@ -23,13 +23,13 @@ import app.fedilab.android.client.Entities.Status; * * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see . */ -public class NotificationsListAdapter extends BaseNotificationsListAdapter{ +public class NotificationsListAdapter extends BaseNotificationsListAdapter { public NotificationsListAdapter(boolean isOnWifi, int behaviorWithAttachments, List notifications) { super(isOnWifi, behaviorWithAttachments, notifications); } - public void notificationStatusChart(Status status){ + public void notificationStatusChart(Status status) { Intent intent = new Intent(context, OwnerNotificationChartsActivity.class); Bundle b = new Bundle(); b.putString("status_id", status.getReblog() != null ? status.getReblog().getId() : status.getId()); diff --git a/app/src/common/java/app/fedilab/android/drawers/StatusListAdapter.java b/app/src/common/java/app/fedilab/android/drawers/StatusListAdapter.java index 1697ed203..3f695b6c1 100644 --- a/app/src/common/java/app/fedilab/android/drawers/StatusListAdapter.java +++ b/app/src/common/java/app/fedilab/android/drawers/StatusListAdapter.java @@ -13,8 +13,8 @@ package app.fedilab.android.drawers; * * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see . */ + import android.content.Intent; -import android.os.AsyncTask; import android.os.Bundle; import android.view.inputmethod.InputMethodManager; @@ -27,8 +27,8 @@ import app.fedilab.android.asynctasks.PostActionAsyncTask; import app.fedilab.android.asynctasks.RetrieveFeedsAsyncTask; import app.fedilab.android.client.API; import app.fedilab.android.client.Entities.Reaction; -import app.fedilab.android.client.Entities.StatusDrawerParams; import app.fedilab.android.client.Entities.Status; +import app.fedilab.android.client.Entities.StatusDrawerParams; import static android.content.Context.INPUT_METHOD_SERVICE; @@ -37,7 +37,7 @@ public class StatusListAdapter extends BaseStatusListAdapter { super(statusDrawerParams); } - public void statusAddReactionClick(Status status, ViewHolder holder){ + public void statusAddReactionClick(Status status, ViewHolder holder) { EmojiManager.install(new EmojiOneProvider()); final EmojiPopup emojiPopup = EmojiPopup.Builder.fromRootView(holder.status_add_reaction).setOnEmojiPopupDismissListener(() -> { InputMethodManager imm = (InputMethodManager) context.getSystemService(INPUT_METHOD_SERVICE); @@ -77,7 +77,7 @@ public class StatusListAdapter extends BaseStatusListAdapter { emojiPopup.toggle(); } - protected void notificationCharts(Status status){ + protected void notificationCharts(Status status) { Intent intent = new Intent(context, OwnerNotificationChartsActivity.class); Bundle b = new Bundle(); b.putString("status_id", status.getReblog() != null ? status.getReblog().getId() : status.getId()); diff --git a/app/src/common/java/app/fedilab/android/helper/Helper.java b/app/src/common/java/app/fedilab/android/helper/Helper.java index 3146541bc..f0eaefc81 100644 --- a/app/src/common/java/app/fedilab/android/helper/Helper.java +++ b/app/src/common/java/app/fedilab/android/helper/Helper.java @@ -13,10 +13,12 @@ package app.fedilab.android.helper; * * You should have received a copy of the GNU General Public License along with Fedilab; if not, * see . */ + import android.content.Context; import android.content.SharedPreferences; import org.conscrypt.Conscrypt; + import java.security.Security; import app.fedilab.android.activities.MainApplication; diff --git a/app/src/main/java/app/fedilab/android/activities/BasePixelfedComposeActivity.java b/app/src/main/java/app/fedilab/android/activities/BasePixelfedComposeActivity.java index cf3521997..e2d767e96 100644 --- a/app/src/main/java/app/fedilab/android/activities/BasePixelfedComposeActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/BasePixelfedComposeActivity.java @@ -439,16 +439,17 @@ public abstract class BasePixelfedComposeActivity extends BaseActivity implement } InputStream tempInput = null; SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); - boolean isWM = sharedpreferences.getBoolean(Helper.SET_WATERMARK, true); + boolean isWM = sharedpreferences.getBoolean(Helper.SET_WATERMARK, false); ContentResolver cr = activity.getContentResolver(); String mime = cr.getType(inUri); if ((mime == null || mime.toLowerCase().contains("image")) && isWM) { - String WMText = sharedpreferences.getString(Helper.SET_WATERMARK_TEXT, null); + String WMText = sharedpreferences.getString(Helper.SET_WATERMARK_TEXT+account.getId()+account.getInstance(), null); if( WMText == null || WMText.trim().length() == 0) { WMText = "@" + account.getUsername() + "@" + account.getInstance(); } + float textSize = 15; Paint mPaint = new Paint(); - mPaint.setTextSize(WMText.length()); + mPaint.setTextSize(textSize); float width = mPaint.measureText(WMText, 0, WMText.length()); try { Bitmap backgroundBitmap = MediaStore.Images.Media.getBitmap(activity.getContentResolver() , inUri); @@ -456,8 +457,8 @@ public abstract class BasePixelfedComposeActivity extends BaseActivity implement int w = backgroundBitmap.getWidth(); int h = backgroundBitmap.getHeight(); - float textSize = 15; - float valx = 1-(w - width - 10 )/(float)w; + + float valx = (float)1.0 - ( (Helper.convertDpToPixel(width, activity) + 10) )/(float)w; if( valx < 0 ) valx = 0; float valy = (h - Helper.convertDpToPixel(textSize, activity) - 10)/(float)h; diff --git a/app/src/main/java/app/fedilab/android/activities/BaseTootActivity.java b/app/src/main/java/app/fedilab/android/activities/BaseTootActivity.java index c2eac262c..afa14f26c 100644 --- a/app/src/main/java/app/fedilab/android/activities/BaseTootActivity.java +++ b/app/src/main/java/app/fedilab/android/activities/BaseTootActivity.java @@ -47,7 +47,6 @@ import android.text.InputType; import android.text.SpannableString; import android.text.TextWatcher; import android.text.style.ForegroundColorSpan; -import android.util.Log; import android.util.Patterns; import android.view.LayoutInflater; import android.view.Menu; @@ -513,27 +512,26 @@ public abstract class BaseTootActivity extends BaseActivity implements UploadSta } InputStream tempInput = null; SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); - boolean isWM = sharedpreferences.getBoolean(Helper.SET_WATERMARK, true); + boolean isWM = sharedpreferences.getBoolean(Helper.SET_WATERMARK, false); ContentResolver cr = activity.getContentResolver(); String mime = cr.getType(inUri); if ((mime == null || mime.toLowerCase().contains("image")) && isWM) { - String WMText = sharedpreferences.getString(Helper.SET_WATERMARK_TEXT, null); + String WMText = sharedpreferences.getString(Helper.SET_WATERMARK_TEXT+account.getId()+account.getInstance(), null); if( WMText == null || WMText.trim().length() == 0) { WMText = "@" + account.getUsername() + "@" + account.getInstance(); } + float textSize = 15; Paint mPaint = new Paint(); - mPaint.setTextSize(WMText.length()); + mPaint.setTextSize(textSize); float width = mPaint.measureText(WMText, 0, WMText.length()); - try { Bitmap backgroundBitmap = MediaStore.Images.Media.getBitmap(activity.getContentResolver() , inUri); int w = backgroundBitmap.getWidth(); int h = backgroundBitmap.getHeight(); - float textSize = 15; - float valx = 1-(w - width - 10 )/(float)w; + float valx = (float)1.0 - ( (Helper.convertDpToPixel(width, activity) + 10) )/(float)w; if( valx < 0 ) valx = 0; float valy = (h - Helper.convertDpToPixel(textSize, activity) - 10)/(float)h; diff --git a/app/src/main/java/app/fedilab/android/fragments/ContentSettingsFragment.java b/app/src/main/java/app/fedilab/android/fragments/ContentSettingsFragment.java index 936e18509..804fb169b 100644 --- a/app/src/main/java/app/fedilab/android/fragments/ContentSettingsFragment.java +++ b/app/src/main/java/app/fedilab/android/fragments/ContentSettingsFragment.java @@ -597,7 +597,8 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot editor.putBoolean(Helper.SET_NOTIF_VALIDATION, set_share_validation.isChecked()); editor.apply(); }); - } else if (type == NOTIFICATIONS) { + } + else if (type == NOTIFICATIONS) { rootView = inflater.inflate(R.layout.fragment_settings_notifications, container, false); @@ -1043,7 +1044,8 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot }); - } else if (type == ADMIN) { + } + else if (type == ADMIN) { rootView = inflater.inflate(R.layout.fragment_settings_admin, container, false); boolean display_admin_menu = sharedpreferences.getBoolean(Helper.SET_DISPLAY_ADMIN_MENU + userId + instance, false); @@ -1075,7 +1077,8 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot editor.apply(); }); - } else if (type == INTERFACE) { + } + else if (type == INTERFACE) { rootView = inflater.inflate(R.layout.fragment_settings_interface, container, false); @@ -1651,9 +1654,55 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot editor.putBoolean(Helper.SET_SECURITY_PROVIDER, set_security_provider.isChecked()); editor.apply(); }); - } else if (type == COMPOSE) { + } + else if (type == COMPOSE) { rootView = inflater.inflate(R.layout.fragment_settings_compose, container, false); + String watermarkText = sharedpreferences.getString(Helper.SET_WATERMARK_TEXT+account.getId()+account.getInstance(), null); + //Watermark + final SwitchCompat set_watermark = rootView.findViewById(R.id.set_watermark); + boolean watermark = sharedpreferences.getBoolean(Helper.SET_WATERMARK, false); + EditText set_watermark_text = rootView.findViewById(R.id.set_watermark_text); + + set_watermark_text.setText("@"+account.getUsername()+"@"+account.getInstance()); + if( watermarkText != null) { + set_watermark_text.setText(watermarkText); + set_watermark_text.setSelection(set_watermark_text.getText().length()); + } + if( watermark) { + set_watermark_text.setVisibility(View.VISIBLE); + }else{ + set_watermark_text.setVisibility(View.GONE); + } + set_watermark_text.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + + } + @Override + public void afterTextChanged(Editable s) { + SharedPreferences.Editor editor = sharedpreferences.edit(); + editor.putString(Helper.SET_WATERMARK_TEXT+account.getId()+account.getInstance(), s.toString().trim()); + editor.apply(); + } + }); + set_watermark.setChecked(watermark); + set_watermark.setOnClickListener(v -> { + SharedPreferences.Editor editor = sharedpreferences.edit(); + editor.putBoolean(Helper.SET_WATERMARK, set_watermark.isChecked()); + editor.apply(); + if( set_watermark.isChecked()) { + set_watermark_text.setVisibility(View.VISIBLE); + }else{ + set_watermark_text.setVisibility(View.GONE); + } + }); + //Resize final SwitchCompat set_resize_picture = rootView.findViewById(R.id.set_resize_picture); @@ -1677,6 +1726,9 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot }); + + + int split_size_val = sharedpreferences.getInt(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS_SIZE + userId + instance, Helper.SPLIT_TOOT_SIZE); LinearLayout set_split_container = rootView.findViewById(R.id.set_split_container); @@ -1964,7 +2016,8 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot }); - } else if (type == PRIVACY) { + } + else if (type == PRIVACY) { rootView = inflater.inflate(R.layout.fragment_settings_privacy, container, false); @@ -2216,7 +2269,8 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot } }); - } else if (type == MENU) { + } + else if (type == MENU) { rootView = inflater.inflate(R.layout.fragment_settings_menu, container, false); SwitchCompat nav_news = rootView.findViewById(R.id.nav_news); @@ -2280,7 +2334,8 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot startActivity(mainActivity); }); - } else if (type == LANGUAGE) { + } + else if (type == LANGUAGE) { rootView = inflater.inflate(R.layout.fragment_settings_language, container, false); Button about_translation = rootView.findViewById(R.id.about_translation); diff --git a/app/src/main/res/layout/fragment_settings_compose.xml b/app/src/main/res/layout/fragment_settings_compose.xml index d4ef6c762..5a9b8e8c8 100644 --- a/app/src/main/res/layout/fragment_settings_compose.xml +++ b/app/src/main/res/layout/fragment_settings_compose.xml @@ -197,6 +197,51 @@ + + + + + + + + + + + + + + + Add a reaction Use your favourite browser inside the app. Uncheck this feature to open links externally. Video cache in MB, zero means no cache. + Watermarks + Automatically add a watermark at the bottom of pictures. The text can be customized for each account. \ No newline at end of file