forked from mirrors/Fedilab
Remove context dependency
This commit is contained in:
parent
3d1d9534be
commit
7119c12467
10 changed files with 137 additions and 50 deletions
|
@ -171,8 +171,8 @@ dependencies {
|
|||
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'
|
||||
implementation 'com.google.android.exoplayer:extension-mediasession:2.18.1'
|
||||
implementation "com.github.mabbas007:TagsEditText:1.0.5"
|
||||
implementation "net.gotev:uploadservice:4.5.1"
|
||||
implementation "net.gotev:uploadservice-okhttp:4.5.1"
|
||||
implementation "net.gotev:uploadservice:4.7.0"
|
||||
implementation "net.gotev:uploadservice-okhttp:4.7.0"
|
||||
implementation 'androidx.media:media:1.6.0'
|
||||
implementation 'com.github.mancj:MaterialSearchBar:0.8.5'
|
||||
|
||||
|
|
|
@ -15,8 +15,11 @@ package app.fedilab.android;
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Build;
|
||||
import android.os.StrictMode;
|
||||
import android.webkit.WebView;
|
||||
|
||||
|
@ -26,6 +29,9 @@ import androidx.preference.PreferenceManager;
|
|||
|
||||
import com.google.android.material.color.DynamicColors;
|
||||
|
||||
import net.gotev.uploadservice.UploadServiceConfig;
|
||||
import net.gotev.uploadservice.observer.request.GlobalRequestObserver;
|
||||
|
||||
import org.acra.ACRA;
|
||||
import org.acra.ReportField;
|
||||
import org.acra.config.CoreConfigurationBuilder;
|
||||
|
@ -33,24 +39,21 @@ import org.acra.config.DialogConfigurationBuilder;
|
|||
import org.acra.config.MailSenderConfigurationBuilder;
|
||||
import org.acra.data.StringFormat;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import app.fedilab.android.mastodon.helper.ThemeHelper;
|
||||
import app.fedilab.android.peertube.services.GlobalUploadObserver;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
|
||||
public class MainApplication extends MultiDexApplication {
|
||||
|
||||
public static String UPLOAD_CHANNEL_ID = "upload_info_peertube";
|
||||
private static MainApplication app;
|
||||
private WebView webView;
|
||||
|
||||
public static MainApplication getApp() {
|
||||
return app;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
app = this;
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(MainApplication.this);
|
||||
try {
|
||||
webView = new WebView(this);
|
||||
|
@ -69,6 +72,11 @@ public class MainApplication extends MultiDexApplication {
|
|||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
createNotificationChannel();
|
||||
UploadServiceConfig.initialize(MainApplication.this, UPLOAD_CHANNEL_ID, true);
|
||||
|
||||
new GlobalRequestObserver(this, new GlobalUploadObserver());
|
||||
}
|
||||
|
||||
|
||||
|
@ -111,4 +119,15 @@ public class MainApplication extends MultiDexApplication {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void createNotificationChannel() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationChannel channel = new NotificationChannel(UPLOAD_CHANNEL_ID,
|
||||
getString(R.string.notification_channel_name),
|
||||
NotificationManager.IMPORTANCE_LOW);
|
||||
channel.setSound(null, null);
|
||||
((NotificationManager) Objects.requireNonNull(getSystemService(Context.NOTIFICATION_SERVICE))).createNotificationChannel(channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,10 @@ import androidx.preference.PreferenceManager;
|
|||
import com.vanniktech.emoji.EmojiManager;
|
||||
import com.vanniktech.emoji.one.EmojiOneProvider;
|
||||
|
||||
import org.conscrypt.Conscrypt;
|
||||
|
||||
import java.security.Security;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.mastodon.helper.Helper;
|
||||
import app.fedilab.android.mastodon.helper.ThemeHelper;
|
||||
|
@ -44,14 +48,24 @@ public class BaseActivity extends AppCompatActivity {
|
|||
public static int currentThemeId;
|
||||
|
||||
static {
|
||||
Helper.installProvider();
|
||||
EmojiManager.install(new EmojiOneProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
|
||||
boolean patch_provider = true;
|
||||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
try {
|
||||
patch_provider = sharedpreferences.getBoolean(Helper.SET_SECURITY_PROVIDER, true);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
if (patch_provider) {
|
||||
try {
|
||||
Security.insertProviderAt(Conscrypt.newProvider(), 1);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
String currentTheme = sharedpreferences.getString(getString(R.string.SET_THEME_BASE), getString(R.string.SET_DEFAULT_THEME));
|
||||
//Default automatic switch
|
||||
if (currentTheme.equals(getString(R.string.SET_DEFAULT_THEME))) {
|
||||
|
|
|
@ -33,6 +33,10 @@ import androidx.preference.PreferenceManager;
|
|||
import com.vanniktech.emoji.EmojiManager;
|
||||
import com.vanniktech.emoji.one.EmojiOneProvider;
|
||||
|
||||
import org.conscrypt.Conscrypt;
|
||||
|
||||
import java.security.Security;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.mastodon.helper.Helper;
|
||||
import app.fedilab.android.mastodon.helper.ThemeHelper;
|
||||
|
@ -42,14 +46,24 @@ import app.fedilab.android.mastodon.helper.ThemeHelper;
|
|||
public class BaseAlertDialogActivity extends AppCompatActivity {
|
||||
|
||||
static {
|
||||
Helper.installProvider();
|
||||
EmojiManager.install(new EmojiOneProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
|
||||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
boolean patch_provider = true;
|
||||
try {
|
||||
patch_provider = sharedpreferences.getBoolean(Helper.SET_SECURITY_PROVIDER, true);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
if (patch_provider) {
|
||||
try {
|
||||
Security.insertProviderAt(Conscrypt.newProvider(), 1);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
String currentTheme = sharedpreferences.getString(getString(R.string.SET_THEME_BASE), getString(R.string.SET_DEFAULT_THEME));
|
||||
//Default automatic switch
|
||||
if (currentTheme.equals(getString(R.string.SET_DEFAULT_THEME))) {
|
||||
|
|
|
@ -33,6 +33,10 @@ import androidx.preference.PreferenceManager;
|
|||
import com.vanniktech.emoji.EmojiManager;
|
||||
import com.vanniktech.emoji.one.EmojiOneProvider;
|
||||
|
||||
import org.conscrypt.Conscrypt;
|
||||
|
||||
import java.security.Security;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.mastodon.helper.Helper;
|
||||
import app.fedilab.android.mastodon.helper.ThemeHelper;
|
||||
|
@ -42,13 +46,23 @@ import app.fedilab.android.mastodon.helper.ThemeHelper;
|
|||
public class BaseBarActivity extends AppCompatActivity {
|
||||
|
||||
static {
|
||||
Helper.installProvider();
|
||||
EmojiManager.install(new EmojiOneProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
boolean patch_provider = true;
|
||||
try {
|
||||
patch_provider = sharedpreferences.getBoolean(Helper.SET_SECURITY_PROVIDER, true);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
if (patch_provider) {
|
||||
try {
|
||||
Security.insertProviderAt(Conscrypt.newProvider(), 1);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
String currentTheme = sharedpreferences.getString(getString(R.string.SET_THEME_BASE), getString(R.string.SET_DEFAULT_THEME));
|
||||
//Default automatic switch
|
||||
if (currentTheme.equals(getString(R.string.SET_DEFAULT_THEME))) {
|
||||
|
|
|
@ -15,12 +15,20 @@ package app.fedilab.android.mastodon.activities;
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import com.vanniktech.emoji.EmojiManager;
|
||||
import com.vanniktech.emoji.one.EmojiOneProvider;
|
||||
|
||||
import org.conscrypt.Conscrypt;
|
||||
|
||||
import java.security.Security;
|
||||
|
||||
import app.fedilab.android.mastodon.helper.Helper;
|
||||
|
||||
|
||||
|
@ -29,9 +37,23 @@ public class BaseFragmentActivity extends FragmentActivity {
|
|||
|
||||
|
||||
static {
|
||||
Helper.installProvider();
|
||||
EmojiManager.install(new EmojiOneProvider());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
boolean patch_provider = true;
|
||||
try {
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
patch_provider = sharedpreferences.getBoolean(Helper.SET_SECURITY_PROVIDER, true);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
if (patch_provider) {
|
||||
try {
|
||||
Security.insertProviderAt(Conscrypt.newProvider(), 1);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,10 @@ import androidx.preference.PreferenceManager;
|
|||
import com.vanniktech.emoji.EmojiManager;
|
||||
import com.vanniktech.emoji.one.EmojiOneProvider;
|
||||
|
||||
import org.conscrypt.Conscrypt;
|
||||
|
||||
import java.security.Security;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.mastodon.helper.Helper;
|
||||
import app.fedilab.android.mastodon.helper.ThemeHelper;
|
||||
|
@ -42,13 +46,23 @@ import app.fedilab.android.mastodon.helper.ThemeHelper;
|
|||
public class BaseTransparentActivity extends AppCompatActivity {
|
||||
|
||||
static {
|
||||
Helper.installProvider();
|
||||
EmojiManager.install(new EmojiOneProvider());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
final SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
boolean patch_provider = true;
|
||||
try {
|
||||
patch_provider = sharedpreferences.getBoolean(Helper.SET_SECURITY_PROVIDER, true);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
if (patch_provider) {
|
||||
try {
|
||||
Security.insertProviderAt(Conscrypt.newProvider(), 1);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
String currentTheme = sharedpreferences.getString(getString(R.string.SET_THEME_BASE), getString(R.string.SET_DEFAULT_THEME));
|
||||
//Default automatic switch
|
||||
if (currentTheme.equals(getString(R.string.SET_DEFAULT_THEME))) {
|
||||
|
|
|
@ -104,8 +104,6 @@ import com.google.gson.stream.JsonReader;
|
|||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
import org.conscrypt.Conscrypt;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
@ -120,7 +118,6 @@ import java.net.PasswordAuthentication;
|
|||
import java.net.Proxy;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.Security;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -143,7 +140,6 @@ import java.util.regex.Pattern;
|
|||
|
||||
import app.fedilab.android.BaseMainActivity;
|
||||
import app.fedilab.android.BuildConfig;
|
||||
import app.fedilab.android.MainApplication;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.LoginActivity;
|
||||
import app.fedilab.android.activities.MainActivity;
|
||||
|
@ -453,22 +449,7 @@ public class Helper {
|
|||
}
|
||||
}
|
||||
|
||||
public static void installProvider() {
|
||||
|
||||
boolean patch_provider = true;
|
||||
try {
|
||||
Context ctx = MainApplication.getApp();
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(ctx);
|
||||
patch_provider = sharedpreferences.getBoolean(Helper.SET_SECURITY_PROVIDER, true);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
if (patch_provider) {
|
||||
try {
|
||||
Security.insertProviderAt(Conscrypt.newProvider(), 1);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* Check if the user is connected to Internet
|
||||
|
|
|
@ -19,6 +19,7 @@ import static app.fedilab.android.peertube.activities.PeertubeMainActivity.userM
|
|||
import static app.fedilab.android.peertube.client.RetrofitPeertubeAPI.DataType.MY_CHANNELS;
|
||||
import static app.fedilab.android.peertube.helper.Helper.peertubeInformation;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Intent;
|
||||
|
@ -333,10 +334,18 @@ public class PeertubeUploadActivity extends BaseBarActivity {
|
|||
});
|
||||
}
|
||||
|
||||
@SuppressLint("UnspecifiedImmutableFlag")
|
||||
UploadNotificationConfig getNotificationConfig(String uploadId) {
|
||||
PendingIntent clickIntent = PendingIntent.getActivity(
|
||||
PendingIntent clickIntent;
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
|
||||
clickIntent = PendingIntent.getActivity(
|
||||
PeertubeUploadActivity.this, 1, new Intent(this, PeertubeEditUploadActivity.class), PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
} else {
|
||||
clickIntent = PendingIntent.getActivity(
|
||||
PeertubeUploadActivity.this, 1, new Intent(this, PeertubeEditUploadActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
}
|
||||
|
||||
final boolean autoClear = false;
|
||||
final boolean clearOnAction = true;
|
||||
final boolean ringToneEnabled = true;
|
||||
|
|
|
@ -132,13 +132,13 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/sepia_element_nsfw_label">
|
||||
|
||||
<RadioButton
|
||||
<com.google.android.material.radiobutton.MaterialRadioButton
|
||||
android:id="@+id/sepia_element_nsfw_yes"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/yes" />
|
||||
|
||||
<RadioButton
|
||||
<com.google.android.material.radiobutton.MaterialRadioButton
|
||||
android:id="@+id/sepia_element_nsfw_no"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -169,31 +169,31 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RadioButton
|
||||
<com.google.android.material.radiobutton.MaterialRadioButton
|
||||
android:id="@+id/sepia_element_published_date_any"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/any" />
|
||||
|
||||
<RadioButton
|
||||
<com.google.android.material.radiobutton.MaterialRadioButton
|
||||
android:id="@+id/sepia_element_published_date_today"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/today" />
|
||||
|
||||
<RadioButton
|
||||
<com.google.android.material.radiobutton.MaterialRadioButton
|
||||
android:id="@+id/sepia_element_published_date_last_7_days"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/last_7_days" />
|
||||
|
||||
<RadioButton
|
||||
<com.google.android.material.radiobutton.MaterialRadioButton
|
||||
android:id="@+id/sepia_element_published_date_last_30_days"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/last_30_days" />
|
||||
|
||||
<RadioButton
|
||||
<com.google.android.material.radiobutton.MaterialRadioButton
|
||||
android:id="@+id/sepia_element_published_date_last_365_days"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -225,25 +225,25 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<RadioButton
|
||||
<com.google.android.material.radiobutton.MaterialRadioButton
|
||||
android:id="@+id/sepia_element_duration_any"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/any" />
|
||||
|
||||
<RadioButton
|
||||
<com.google.android.material.radiobutton.MaterialRadioButton
|
||||
android:id="@+id/sepia_element_duration_short"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/duration_short" />
|
||||
|
||||
<RadioButton
|
||||
<com.google.android.material.radiobutton.MaterialRadioButton
|
||||
android:id="@+id/sepia_element_duration_medium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/duration_medium" />
|
||||
|
||||
<RadioButton
|
||||
<com.google.android.material.radiobutton.MaterialRadioButton
|
||||
android:id="@+id/sepia_element_duration_long"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -354,9 +354,9 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/sepia_element_one_of_tags_label" />
|
||||
|
||||
<Button
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/apply_filter"
|
||||
style="@style/Base.Widget.AppCompat.Button.Colored"
|
||||
style="@style/Widget.Material3.Button.ElevatedButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/apply_filter"
|
||||
|
|
Loading…
Reference in a new issue