Auto evaluate emplacement

This commit is contained in:
Thomas 2020-08-08 19:22:16 +02:00
parent 76733161dc
commit d194cd43e4
15 changed files with 134 additions and 41 deletions

View File

@ -1,5 +1,8 @@
package app.fedilab.android.activities; package app.fedilab.android.activities;
import com.vanniktech.emoji.EmojiManager;
import com.vanniktech.emoji.one.EmojiOneProvider;
import app.fedilab.android.helper.Helper; import app.fedilab.android.helper.Helper;
/* Copyright 2020 Thomas Schneider /* 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, * You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */ * see <http://www.gnu.org/licenses>. */
public class BaseFragmentActivity extends MainBaseFragmentActivity {
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{
static { static {
Helper.installProvider(); Helper.installProvider();

View File

@ -22,7 +22,6 @@ import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;

View File

@ -23,7 +23,6 @@ import android.content.IntentFilter;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;

View File

@ -22,7 +22,6 @@ import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MenuItem; import android.view.MenuItem;

View File

@ -23,7 +23,6 @@ import android.content.IntentFilter;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;

View File

@ -4,7 +4,6 @@ package app.fedilab.android.activities;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import com.vanniktech.emoji.EmojiPopup;
/* Copyright 2020 Thomas Schneider /* 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, * You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */ * see <http://www.gnu.org/licenses>. */
public class PixelfedComposeActivity extends BasePixelfedComposeActivity{ public class PixelfedComposeActivity extends BasePixelfedComposeActivity {
@Override @Override

View File

@ -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, * You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */ * see <http://www.gnu.org/licenses>. */
public class TootActivity extends BaseTootActivity{ public class TootActivity extends BaseTootActivity {
private AlertDialog dialogTrans; private AlertDialog dialogTrans;

View File

@ -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, * You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */ * see <http://www.gnu.org/licenses>. */
public class NotificationsListAdapter extends BaseNotificationsListAdapter{ public class NotificationsListAdapter extends BaseNotificationsListAdapter {
public NotificationsListAdapter(boolean isOnWifi, int behaviorWithAttachments, List<Notification> notifications) { public NotificationsListAdapter(boolean isOnWifi, int behaviorWithAttachments, List<Notification> notifications) {
super(isOnWifi, behaviorWithAttachments, notifications); super(isOnWifi, behaviorWithAttachments, notifications);
} }
public void notificationStatusChart(Status status){ public void notificationStatusChart(Status status) {
Intent intent = new Intent(context, OwnerNotificationChartsActivity.class); Intent intent = new Intent(context, OwnerNotificationChartsActivity.class);
Bundle b = new Bundle(); Bundle b = new Bundle();
b.putString("status_id", status.getReblog() != null ? status.getReblog().getId() : status.getId()); b.putString("status_id", status.getReblog() != null ? status.getReblog().getId() : status.getId());

View File

@ -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, * You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */ * see <http://www.gnu.org/licenses>. */
import android.content.Intent; import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.view.inputmethod.InputMethodManager; 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.asynctasks.RetrieveFeedsAsyncTask;
import app.fedilab.android.client.API; import app.fedilab.android.client.API;
import app.fedilab.android.client.Entities.Reaction; 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.Status;
import app.fedilab.android.client.Entities.StatusDrawerParams;
import static android.content.Context.INPUT_METHOD_SERVICE; import static android.content.Context.INPUT_METHOD_SERVICE;
@ -37,7 +37,7 @@ public class StatusListAdapter extends BaseStatusListAdapter {
super(statusDrawerParams); super(statusDrawerParams);
} }
public void statusAddReactionClick(Status status, ViewHolder holder){ public void statusAddReactionClick(Status status, ViewHolder holder) {
EmojiManager.install(new EmojiOneProvider()); EmojiManager.install(new EmojiOneProvider());
final EmojiPopup emojiPopup = EmojiPopup.Builder.fromRootView(holder.status_add_reaction).setOnEmojiPopupDismissListener(() -> { final EmojiPopup emojiPopup = EmojiPopup.Builder.fromRootView(holder.status_add_reaction).setOnEmojiPopupDismissListener(() -> {
InputMethodManager imm = (InputMethodManager) context.getSystemService(INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) context.getSystemService(INPUT_METHOD_SERVICE);
@ -77,7 +77,7 @@ public class StatusListAdapter extends BaseStatusListAdapter {
emojiPopup.toggle(); emojiPopup.toggle();
} }
protected void notificationCharts(Status status){ protected void notificationCharts(Status status) {
Intent intent = new Intent(context, OwnerNotificationChartsActivity.class); Intent intent = new Intent(context, OwnerNotificationChartsActivity.class);
Bundle b = new Bundle(); Bundle b = new Bundle();
b.putString("status_id", status.getReblog() != null ? status.getReblog().getId() : status.getId()); b.putString("status_id", status.getReblog() != null ? status.getReblog().getId() : status.getId());

View File

@ -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, * You should have received a copy of the GNU General Public License along with Fedilab; if not,
* see <http://www.gnu.org/licenses>. */ * see <http://www.gnu.org/licenses>. */
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import org.conscrypt.Conscrypt; import org.conscrypt.Conscrypt;
import java.security.Security; import java.security.Security;
import app.fedilab.android.activities.MainApplication; import app.fedilab.android.activities.MainApplication;

View File

@ -439,16 +439,17 @@ public abstract class BasePixelfedComposeActivity extends BaseActivity implement
} }
InputStream tempInput = null; InputStream tempInput = null;
SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); 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(); ContentResolver cr = activity.getContentResolver();
String mime = cr.getType(inUri); String mime = cr.getType(inUri);
if ((mime == null || mime.toLowerCase().contains("image")) && isWM) { 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) { if( WMText == null || WMText.trim().length() == 0) {
WMText = "@" + account.getUsername() + "@" + account.getInstance(); WMText = "@" + account.getUsername() + "@" + account.getInstance();
} }
float textSize = 15;
Paint mPaint = new Paint(); Paint mPaint = new Paint();
mPaint.setTextSize(WMText.length()); mPaint.setTextSize(textSize);
float width = mPaint.measureText(WMText, 0, WMText.length()); float width = mPaint.measureText(WMText, 0, WMText.length());
try { try {
Bitmap backgroundBitmap = MediaStore.Images.Media.getBitmap(activity.getContentResolver() , inUri); 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 w = backgroundBitmap.getWidth();
int h = backgroundBitmap.getHeight(); 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 ) if( valx < 0 )
valx = 0; valx = 0;
float valy = (h - Helper.convertDpToPixel(textSize, activity) - 10)/(float)h; float valy = (h - Helper.convertDpToPixel(textSize, activity) - 10)/(float)h;

View File

@ -47,7 +47,6 @@ import android.text.InputType;
import android.text.SpannableString; import android.text.SpannableString;
import android.text.TextWatcher; import android.text.TextWatcher;
import android.text.style.ForegroundColorSpan; import android.text.style.ForegroundColorSpan;
import android.util.Log;
import android.util.Patterns; import android.util.Patterns;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
@ -513,27 +512,26 @@ public abstract class BaseTootActivity extends BaseActivity implements UploadSta
} }
InputStream tempInput = null; InputStream tempInput = null;
SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE); 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(); ContentResolver cr = activity.getContentResolver();
String mime = cr.getType(inUri); String mime = cr.getType(inUri);
if ((mime == null || mime.toLowerCase().contains("image")) && isWM) { 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) { if( WMText == null || WMText.trim().length() == 0) {
WMText = "@" + account.getUsername() + "@" + account.getInstance(); WMText = "@" + account.getUsername() + "@" + account.getInstance();
} }
float textSize = 15;
Paint mPaint = new Paint(); Paint mPaint = new Paint();
mPaint.setTextSize(WMText.length()); mPaint.setTextSize(textSize);
float width = mPaint.measureText(WMText, 0, WMText.length()); float width = mPaint.measureText(WMText, 0, WMText.length());
try { try {
Bitmap backgroundBitmap = MediaStore.Images.Media.getBitmap(activity.getContentResolver() , inUri); Bitmap backgroundBitmap = MediaStore.Images.Media.getBitmap(activity.getContentResolver() , inUri);
int w = backgroundBitmap.getWidth(); int w = backgroundBitmap.getWidth();
int h = backgroundBitmap.getHeight(); int h = backgroundBitmap.getHeight();
float textSize = 15; float valx = (float)1.0 - ( (Helper.convertDpToPixel(width, activity) + 10) )/(float)w;
float valx = 1-(w - width - 10 )/(float)w;
if( valx < 0 ) if( valx < 0 )
valx = 0; valx = 0;
float valy = (h - Helper.convertDpToPixel(textSize, activity) - 10)/(float)h; float valy = (h - Helper.convertDpToPixel(textSize, activity) - 10)/(float)h;

View File

@ -597,7 +597,8 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
editor.putBoolean(Helper.SET_NOTIF_VALIDATION, set_share_validation.isChecked()); editor.putBoolean(Helper.SET_NOTIF_VALIDATION, set_share_validation.isChecked());
editor.apply(); editor.apply();
}); });
} else if (type == NOTIFICATIONS) { }
else if (type == NOTIFICATIONS) {
rootView = inflater.inflate(R.layout.fragment_settings_notifications, container, false); 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); rootView = inflater.inflate(R.layout.fragment_settings_admin, container, false);
boolean display_admin_menu = sharedpreferences.getBoolean(Helper.SET_DISPLAY_ADMIN_MENU + userId + instance, 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(); editor.apply();
}); });
} else if (type == INTERFACE) { }
else if (type == INTERFACE) {
rootView = inflater.inflate(R.layout.fragment_settings_interface, container, false); 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.putBoolean(Helper.SET_SECURITY_PROVIDER, set_security_provider.isChecked());
editor.apply(); editor.apply();
}); });
} else if (type == COMPOSE) { }
else if (type == COMPOSE) {
rootView = inflater.inflate(R.layout.fragment_settings_compose, container, false); 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 //Resize
final SwitchCompat set_resize_picture = rootView.findViewById(R.id.set_resize_picture); 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); 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); 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); 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); rootView = inflater.inflate(R.layout.fragment_settings_menu, container, false);
SwitchCompat nav_news = rootView.findViewById(R.id.nav_news); SwitchCompat nav_news = rootView.findViewById(R.id.nav_news);
@ -2280,7 +2334,8 @@ public class ContentSettingsFragment extends Fragment implements OnRetrieveRemot
startActivity(mainActivity); startActivity(mainActivity);
}); });
} else if (type == LANGUAGE) { }
else if (type == LANGUAGE) {
rootView = inflater.inflate(R.layout.fragment_settings_language, container, false); rootView = inflater.inflate(R.layout.fragment_settings_language, container, false);
Button about_translation = rootView.findViewById(R.id.about_translation); Button about_translation = rootView.findViewById(R.id.about_translation);

View File

@ -197,6 +197,51 @@
</LinearLayout> </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/settings_option_margin"
android:layout_marginBottom="@dimen/settings_option_margin"
android:gravity="center_vertical"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/set_watermark"
android:labelFor="@+id/set_watermark_text"
android:textSize="16sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/set_watermark_indication"
android:textColor="@color/mastodonC2"
android:textSize="12sp" />
<EditText
android:id="@+id/set_watermark_text"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:importantForAutofill="noExcludeDescendants"
android:inputType="textUri" />
</LinearLayout>
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/set_watermark"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<!-- WYSIWYG --> <!-- WYSIWYG -->
<LinearLayout <LinearLayout
android:id="@+id/set_wysiwyg_container" android:id="@+id/set_wysiwyg_container"

View File

@ -1235,5 +1235,7 @@
<string name="add_reaction">Add a reaction</string> <string name="add_reaction">Add a reaction</string>
<string name="set_custom_tabs_indication">Use your favourite browser inside the app. Uncheck this feature to open links externally.</string> <string name="set_custom_tabs_indication">Use your favourite browser inside the app. Uncheck this feature to open links externally.</string>
<string name="set_video_cache">Video cache in MB, zero means no cache.</string> <string name="set_video_cache">Video cache in MB, zero means no cache.</string>
<string name="set_watermark">Watermarks</string>
<string name="set_watermark_indication">Automatically add a watermark at the bottom of pictures. The text can be customized for each account.</string>
</resources> </resources>