diff --git a/.gitignore b/.gitignore
index 3f0e177ba..9f6c5f69f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,6 @@
/gradle.properties
+/app/playstore/release/
+/app/lite/release/
+/app/fdroid/release/
diff --git a/app/build.gradle b/app/build.gradle
index da350357b..5e458bf86 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -4,10 +4,10 @@ android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
- minSdkVersion 19
+ minSdkVersion 21
targetSdkVersion 29
- versionCode 376
- versionName "2.36.2"
+ versionCode 379
+ versionName "2.37.0"
multiDexEnabled true
renderscriptTargetApi 28 as int
renderscriptSupportModeEnabled true
@@ -26,6 +26,8 @@ android {
pseudoLocalesEnabled true
}
}
+
+
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
@@ -38,12 +40,46 @@ android {
fdroid {
applicationId "fr.gouv.etalab.mastodon"
buildConfigField "boolean", "DONATIONS", "true"
+ buildConfigField "boolean", "lite", "false"
+ resValue "string", "app_name", "Fedilab"
+ }
+ lite {
+ minSdkVersion 21
+ applicationId "app.fedilab.lite"
+ buildConfigField "boolean", "DONATIONS", "true"
+ buildConfigField "boolean", "lite", "true"
+ resValue "string", "app_name", "Fedilab Lite"
}
playstore {
applicationId "app.fedilab.android"
buildConfigField "boolean", "DONATIONS", "false"
+ buildConfigField "boolean", "lite", "false"
+ resValue "string", "app_name", "Fedilab"
}
}
+
+ sourceSets {
+ playstore {
+ manifest.srcFile "src/common/AndroidManifest.xml"
+ assets.srcDirs = ['/src/mains/assets', 'src/common/assets']
+ java.srcDirs = ['src/main/java', 'src/playstore/java','src/common/java']
+ res.srcDirs = ['src/main/res', 'src/playstore/res','src/common/res']
+ }
+
+ fdroid {
+ manifest.srcFile "src/common/AndroidManifest.xml"
+ assets.srcDirs = ['/src/mains/assets', 'src/common/assets']
+ java.srcDirs = ['src/main/java', 'src/fdroid/java','src/common/java']
+ res.srcDirs = ['src/main/res', 'src/fdroid/res','src/common/res']
+ }
+ lite {
+ manifest.srcFile "src/lite/AndroidManifest.xml"
+ assets.srcDirs = ['/src/mains/assets']
+ java.srcDirs = ['src/main/java', 'src/lite/java']
+ res.srcDirs = ['src/main/res', 'src/lite/res']
+ }
+ }
+
packagingOptions {
exclude 'META-INF/proguard/androidx-annotations.pro'
}
@@ -61,11 +97,15 @@ allprojects {
task copyAllReleaseNotes(type: Copy) {
from "$buildDir/../src/main/assets/changelogs/"
include "*.txt"
- into "$buildDir/../../fastlane/metadata/android/en-US/changelogs/"
+ into "$buildDir/../../src/fdroid/fastlane/metadata/android/en-US/changelogs/"
+ from "$buildDir/../src/main/assets/changelogs/"
+ include "*.txt"
+ into "$buildDir/../../src/lite/fastlane/metadata/android/en-US/changelogs/"
}
task gitPushReleaseNotes(type: Exec, dependsOn: 'copyAllReleaseNotes') {
- ['sh', '-c', "git add $buildDir/../../fastlane/metadata/android/en-US/changelogs/*"].execute().text.trim()
+ ['sh', '-c', "git add $buildDir/../../src/fdroid/fastlane/metadata/android/en-US/changelogs/*"].execute().text.trim()
+ ['sh', '-c', "git add $buildDir/../../src/lite/fastlane/metadata/android/en-US/changelogs/*"].execute().text.trim()
['sh', '-c', "git commit -m 'copy release notes'"].execute().text.trim()
['sh', '-c', "git push"].execute().text.trim()
}
@@ -73,13 +113,13 @@ task gitPushReleaseNotes(type: Exec, dependsOn: 'copyAllReleaseNotes') {
dependencies {
- implementation 'androidx.appcompat:appcompat:1.1.0'
+ implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
- implementation 'androidx.browser:browser:1.2.0'
- implementation 'androidx.exifinterface:exifinterface:1.1.0'
- implementation 'androidx.constraintlayout:constraintlayout:1.0.2'
+ implementation 'androidx.browser:browser:1.3.0'
+ implementation 'androidx.exifinterface:exifinterface:1.3.2'
+ implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation "com.github.bumptech.glide:glide:4.11.0"
implementation ("com.github.bumptech.glide:recyclerview-integration:4.11.0") {
// Excludes the support library because it's already included by Glide.
@@ -87,17 +127,15 @@ dependencies {
}
annotationProcessor "com.github.bumptech.glide:compiler:4.11.0"
annotationProcessor 'com.android.support:support-annotations:28.0.0'
- implementation "org.conscrypt:conscrypt-android:2.4.0"
+
implementation "com.evernote:android-job:1.2.6"
implementation "com.google.code.gson:gson:2.8.6"
implementation "com.google.guava:guava:28.2-android"
implementation "com.github.chrisbanes:PhotoView:2.3.0"
implementation 'com.r0adkll:slidableactivity:2.1.0'
- implementation 'com.github.stom79:country-picker-android:1.2.0'
- implementation 'com.github.stom79:mytransl:2.0'
+ implementation 'com.github.stom79:mytransl:3.0'
implementation 'com.github.stom79:SparkButton:1.0.13'
- implementation "com.koushikdutta.async:androidasync:2.+"
- implementation 'com.vanniktech:emoji-one:0.6.0'
+ implementation "com.koushikdutta.async:androidasync:3.+"
implementation 'com.oguzdev:CircularFloatingActionMenu:1.0.2'
implementation 'com.github.franmontiel:LocaleChanger:0.9.2'
implementation 'com.github.GrenderG:Toasty:1.4.2'
@@ -108,28 +146,45 @@ dependencies {
implementation 'com.github.mabbas007:TagsEditText:1.0.5'
implementation "com.tonyodev.fetch2:fetch2:2.3.6"
implementation 'jp.wasabeef:glide-transformations:4.0.0'
- playstoreImplementation "io.github.kobakei:ratethisapp:1.2.0"
- implementation 'ja.burhanrashid52:photoeditor:0.4.0'
- api 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
+
+
+ implementation 'com.jaredrummler:cyanea:1.0.2'
implementation "net.gotev:uploadservice:3.5.2"
implementation "net.gotev:uploadservice-okhttp:3.5.2"
implementation "info.guardianproject.netcipher:netcipher:2.0.0-alpha1"
implementation "info.guardianproject.netcipher:netcipher-okhttp3:2.0.0-alpha1"
- implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.github.adrielcafe:AndroidAudioRecorder:0.3.0'
implementation 'yogesh.firzen:MukkiyaSevaigal:1.0.6'
implementation 'com.iceteck.silicompressorr:silicompressor:2.2.2'
implementation "ch.acra:acra-mail:5.5.0"
implementation "ch.acra:acra-limiter:5.5.0"
implementation "ch.acra:acra-notification:5.5.0"
- implementation 'com.github.stom79:Android-WYSIWYG-Editor:3.2.1'
implementation 'com.github.duanhong169:colorpicker:1.1.6'
implementation 'com.github.penfeizhou.android.animation:glide-plugin:2.2.0'
+ implementation 'com.github.stom79:Android-WYSIWYG-Editor:3.2.1'
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
implementation 'com.github.smarteist:autoimageslider:1.3.2'
//debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.2'
- implementation 'com.jaredrummler:cyanea:1.0.2'
+ implementation 'com.huangyz0918:androidwm-light:0.1.2'
+
+ //Flavors
+
+ //Playstore
+ playstoreApi 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
+ playstoreImplementation "io.github.kobakei:ratethisapp:1.2.0"
+ playstoreImplementation "org.conscrypt:conscrypt-android:2.4.0"
+ playstoreImplementation 'com.github.stom79:country-picker-android:1.2.0'
+ playstoreImplementation 'com.vanniktech:emoji-one:0.6.0'
+ playstoreImplementation 'ja.burhanrashid52:photoeditor:0.4.0'
+
+
+ //Fdroid
+ fdroidApi 'com.theartofdev.edmodo:android-image-cropper:2.8.+'
+ fdroidImplementation "org.conscrypt:conscrypt-android:2.4.0"
+ fdroidImplementation 'com.github.stom79:country-picker-android:1.2.0'
+ fdroidImplementation 'com.vanniktech:emoji-one:0.6.0'
+ fdroidImplementation 'ja.burhanrashid52:photoeditor:0.4.0'
}
diff --git a/app/src/common/AndroidManifest.xml b/app/src/common/AndroidManifest.xml
new file mode 100644
index 000000000..d08f233c2
--- /dev/null
+++ b/app/src/common/AndroidManifest.xml
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/assets/emojione-android.ttf b/app/src/common/assets/emojione-android.ttf
similarity index 100%
rename from app/src/main/assets/emojione-android.ttf
rename to app/src/common/assets/emojione-android.ttf
diff --git a/app/src/main/assets/filters/auto_fix.png b/app/src/common/assets/filters/auto_fix.png
similarity index 100%
rename from app/src/main/assets/filters/auto_fix.png
rename to app/src/common/assets/filters/auto_fix.png
diff --git a/app/src/main/assets/filters/b_n_w.png b/app/src/common/assets/filters/b_n_w.png
similarity index 100%
rename from app/src/main/assets/filters/b_n_w.png
rename to app/src/common/assets/filters/b_n_w.png
diff --git a/app/src/main/assets/filters/brightness.png b/app/src/common/assets/filters/brightness.png
similarity index 100%
rename from app/src/main/assets/filters/brightness.png
rename to app/src/common/assets/filters/brightness.png
diff --git a/app/src/main/assets/filters/contrast.png b/app/src/common/assets/filters/contrast.png
similarity index 100%
rename from app/src/main/assets/filters/contrast.png
rename to app/src/common/assets/filters/contrast.png
diff --git a/app/src/main/assets/filters/cross_process.png b/app/src/common/assets/filters/cross_process.png
similarity index 100%
rename from app/src/main/assets/filters/cross_process.png
rename to app/src/common/assets/filters/cross_process.png
diff --git a/app/src/main/assets/filters/documentary.png b/app/src/common/assets/filters/documentary.png
similarity index 100%
rename from app/src/main/assets/filters/documentary.png
rename to app/src/common/assets/filters/documentary.png
diff --git a/app/src/main/assets/filters/dual_tone.png b/app/src/common/assets/filters/dual_tone.png
similarity index 100%
rename from app/src/main/assets/filters/dual_tone.png
rename to app/src/common/assets/filters/dual_tone.png
diff --git a/app/src/main/assets/filters/fill_light.png b/app/src/common/assets/filters/fill_light.png
similarity index 100%
rename from app/src/main/assets/filters/fill_light.png
rename to app/src/common/assets/filters/fill_light.png
diff --git a/app/src/main/assets/filters/fish_eye.png b/app/src/common/assets/filters/fish_eye.png
similarity index 100%
rename from app/src/main/assets/filters/fish_eye.png
rename to app/src/common/assets/filters/fish_eye.png
diff --git a/app/src/main/assets/filters/flip_horizental.png b/app/src/common/assets/filters/flip_horizental.png
similarity index 100%
rename from app/src/main/assets/filters/flip_horizental.png
rename to app/src/common/assets/filters/flip_horizental.png
diff --git a/app/src/main/assets/filters/flip_vertical.png b/app/src/common/assets/filters/flip_vertical.png
similarity index 100%
rename from app/src/main/assets/filters/flip_vertical.png
rename to app/src/common/assets/filters/flip_vertical.png
diff --git a/app/src/main/assets/filters/grain.png b/app/src/common/assets/filters/grain.png
similarity index 100%
rename from app/src/main/assets/filters/grain.png
rename to app/src/common/assets/filters/grain.png
diff --git a/app/src/main/assets/filters/gray_scale.png b/app/src/common/assets/filters/gray_scale.png
similarity index 100%
rename from app/src/main/assets/filters/gray_scale.png
rename to app/src/common/assets/filters/gray_scale.png
diff --git a/app/src/main/assets/filters/lomish.png b/app/src/common/assets/filters/lomish.png
similarity index 100%
rename from app/src/main/assets/filters/lomish.png
rename to app/src/common/assets/filters/lomish.png
diff --git a/app/src/main/assets/filters/negative.png b/app/src/common/assets/filters/negative.png
similarity index 100%
rename from app/src/main/assets/filters/negative.png
rename to app/src/common/assets/filters/negative.png
diff --git a/app/src/main/assets/filters/original.jpg b/app/src/common/assets/filters/original.jpg
similarity index 100%
rename from app/src/main/assets/filters/original.jpg
rename to app/src/common/assets/filters/original.jpg
diff --git a/app/src/main/assets/filters/posterize.png b/app/src/common/assets/filters/posterize.png
similarity index 100%
rename from app/src/main/assets/filters/posterize.png
rename to app/src/common/assets/filters/posterize.png
diff --git a/app/src/main/assets/filters/rotate.png b/app/src/common/assets/filters/rotate.png
similarity index 100%
rename from app/src/main/assets/filters/rotate.png
rename to app/src/common/assets/filters/rotate.png
diff --git a/app/src/main/assets/filters/saturate.png b/app/src/common/assets/filters/saturate.png
similarity index 100%
rename from app/src/main/assets/filters/saturate.png
rename to app/src/common/assets/filters/saturate.png
diff --git a/app/src/main/assets/filters/sepia.png b/app/src/common/assets/filters/sepia.png
similarity index 100%
rename from app/src/main/assets/filters/sepia.png
rename to app/src/common/assets/filters/sepia.png
diff --git a/app/src/main/assets/filters/sharpen.png b/app/src/common/assets/filters/sharpen.png
similarity index 100%
rename from app/src/main/assets/filters/sharpen.png
rename to app/src/common/assets/filters/sharpen.png
diff --git a/app/src/main/assets/filters/temprature.png b/app/src/common/assets/filters/temprature.png
similarity index 100%
rename from app/src/main/assets/filters/temprature.png
rename to app/src/common/assets/filters/temprature.png
diff --git a/app/src/main/assets/filters/tint.png b/app/src/common/assets/filters/tint.png
similarity index 100%
rename from app/src/main/assets/filters/tint.png
rename to app/src/common/assets/filters/tint.png
diff --git a/app/src/main/assets/filters/vignette.png b/app/src/common/assets/filters/vignette.png
similarity index 100%
rename from app/src/main/assets/filters/vignette.png
rename to app/src/common/assets/filters/vignette.png
diff --git a/app/src/main/java/app/fedilab/android/activities/BaseFragmentActivity.java b/app/src/common/java/app/fedilab/android/activities/BaseActivity.java
similarity index 64%
rename from app/src/main/java/app/fedilab/android/activities/BaseFragmentActivity.java
rename to app/src/common/java/app/fedilab/android/activities/BaseActivity.java
index a4a2f6b0f..f73443a17 100644
--- a/app/src/main/java/app/fedilab/android/activities/BaseFragmentActivity.java
+++ b/app/src/common/java/app/fedilab/android/activities/BaseActivity.java
@@ -2,21 +2,19 @@ package app.fedilab.android.activities;
import android.annotation.SuppressLint;
-import androidx.appcompat.app.AppCompatActivity;
-
import com.vanniktech.emoji.EmojiManager;
import com.vanniktech.emoji.one.EmojiOneProvider;
import app.fedilab.android.helper.Helper;
+
/**
- * Created by Thomas on 16/05/2020.
- * Fragment base activity which updates security provider
+ * Created by Thomas on 12/12/2017.
+ * Base activity which updates security provider
*/
@SuppressLint("Registered")
-public class BaseFragmentActivity extends AppCompatActivity {
-
+public class BaseActivity extends AllBaseActivity {
static {
Helper.installProvider();
diff --git a/app/src/common/java/app/fedilab/android/activities/BaseFragmentActivity.java b/app/src/common/java/app/fedilab/android/activities/BaseFragmentActivity.java
new file mode 100644
index 000000000..0eedc8539
--- /dev/null
+++ b/app/src/common/java/app/fedilab/android/activities/BaseFragmentActivity.java
@@ -0,0 +1,29 @@
+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
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+
+public class BaseFragmentActivity extends MainBaseFragmentActivity {
+
+ static {
+ Helper.installProvider();
+ EmojiManager.install(new EmojiOneProvider());
+ }
+}
diff --git a/app/src/main/java/app/fedilab/android/activities/OwnerChartsActivity.java b/app/src/common/java/app/fedilab/android/activities/OwnerChartsActivity.java
similarity index 98%
rename from app/src/main/java/app/fedilab/android/activities/OwnerChartsActivity.java
rename to app/src/common/java/app/fedilab/android/activities/OwnerChartsActivity.java
index 4b9238b14..b882b90a4 100644
--- a/app/src/main/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;
@@ -88,7 +87,7 @@ public class OwnerChartsActivity extends BaseActivity implements OnRetrieveChart
private int theme;
private RelativeLayout loader;
private ImageButton validate;
- private DatePickerDialog.OnDateSetListener iniDateSetListener =
+ private final DatePickerDialog.OnDateSetListener iniDateSetListener =
new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year,
@@ -100,7 +99,7 @@ public class OwnerChartsActivity extends BaseActivity implements OnRetrieveChart
}
};
- private DatePickerDialog.OnDateSetListener endDateSetListener =
+ private final DatePickerDialog.OnDateSetListener endDateSetListener =
new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year,
@@ -257,7 +256,7 @@ public class OwnerChartsActivity extends BaseActivity implements OnRetrieveChart
chart.setVisibility(View.GONE);
loader.setVisibility(View.VISIBLE);
validate.setEnabled(false);
- new RetrieveChartsAsyncTask(OwnerChartsActivity.this, dateIni, dateEnd, OwnerChartsActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveChartsAsyncTask(OwnerChartsActivity.this, dateIni, dateEnd, OwnerChartsActivity.this);
}
@@ -397,7 +396,7 @@ public class OwnerChartsActivity extends BaseActivity implements OnRetrieveChart
@SuppressLint("ViewConstructor")
public static class CustomMarkerView extends MarkerView {
- private TextView tvContent;
+ private final TextView tvContent;
private MPPointF mOffset;
public CustomMarkerView(Context context, int layoutResource) {
@@ -424,8 +423,8 @@ public class OwnerChartsActivity extends BaseActivity implements OnRetrieveChart
}
public static class MyXAxisValueFormatter extends ValueFormatter {
- private DateFormat mDataFormat;
- private Date mDate;
+ private final DateFormat mDataFormat;
+ private final Date mDate;
MyXAxisValueFormatter() {
this.mDataFormat = new SimpleDateFormat("dd.MM", Locale.getDefault());
diff --git a/app/src/main/java/app/fedilab/android/activities/OwnerNotificationActivity.java b/app/src/common/java/app/fedilab/android/activities/OwnerNotificationActivity.java
similarity index 97%
rename from app/src/main/java/app/fedilab/android/activities/OwnerNotificationActivity.java
rename to app/src/common/java/app/fedilab/android/activities/OwnerNotificationActivity.java
index e594f9c8e..176f72b3b 100644
--- a/app/src/main/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;
@@ -101,7 +100,7 @@ public class OwnerNotificationActivity extends BaseActivity implements OnRetriev
private Date dateIni, dateEnd;
private View statsDialogView;
private StatisticsNotification statistics;
- private DatePickerDialog.OnDateSetListener iniDateSetListener =
+ private final DatePickerDialog.OnDateSetListener iniDateSetListener =
new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year,
@@ -113,7 +112,7 @@ public class OwnerNotificationActivity extends BaseActivity implements OnRetriev
}
};
- private DatePickerDialog.OnDateSetListener endDateSetListener =
+ private final DatePickerDialog.OnDateSetListener endDateSetListener =
new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year,
@@ -126,14 +125,14 @@ public class OwnerNotificationActivity extends BaseActivity implements OnRetriev
}
};
- private BroadcastReceiver backupFinishedReceiver = new BroadcastReceiver() {
+ private final BroadcastReceiver backupFinishedReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
max_id = null;
firstLoad = true;
flag_loading = true;
swiped = true;
- new RetrieveNotificationsCacheAsyncTask(OwnerNotificationActivity.this, filterNotifications, null, OwnerNotificationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveNotificationsCacheAsyncTask(OwnerNotificationActivity.this, filterNotifications, null, OwnerNotificationActivity.this);
}
};
@@ -222,13 +221,13 @@ public class OwnerNotificationActivity extends BaseActivity implements OnRetriev
swipeRefreshLayout.setColorSchemeColors(
c1, c2, c1
);
- new RetrieveNotificationsCacheAsyncTask(OwnerNotificationActivity.this, filterNotifications, null, OwnerNotificationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveNotificationsCacheAsyncTask(OwnerNotificationActivity.this, filterNotifications, null, OwnerNotificationActivity.this);
swipeRefreshLayout.setOnRefreshListener(() -> {
max_id = null;
firstLoad = true;
flag_loading = true;
swiped = true;
- new RetrieveNotificationsCacheAsyncTask(OwnerNotificationActivity.this, filterNotifications, null, OwnerNotificationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveNotificationsCacheAsyncTask(OwnerNotificationActivity.this, filterNotifications, null, OwnerNotificationActivity.this);
});
lv_notifications.addOnScrollListener(new RecyclerView.OnScrollListener() {
@@ -240,7 +239,7 @@ public class OwnerNotificationActivity extends BaseActivity implements OnRetriev
if (firstVisibleItem + visibleItemCount == totalItemCount) {
if (!flag_loading) {
flag_loading = true;
- new RetrieveNotificationsCacheAsyncTask(OwnerNotificationActivity.this, filterNotifications, max_id, OwnerNotificationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveNotificationsCacheAsyncTask(OwnerNotificationActivity.this, filterNotifications, max_id, OwnerNotificationActivity.this);
nextElementLoader.setVisibility(View.VISIBLE);
}
} else {
@@ -289,7 +288,7 @@ public class OwnerNotificationActivity extends BaseActivity implements OnRetriev
.setPositiveButton(R.string.close, (dialog, which) -> dialog.dismiss());
dialogBuilder.create().show();
if (statistics == null) {
- new RetrieveNotificationStatsAsyncTask(OwnerNotificationActivity.this, OwnerNotificationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveNotificationStatsAsyncTask(OwnerNotificationActivity.this, OwnerNotificationActivity.this);
} else {
displayStats();
}
@@ -376,7 +375,7 @@ public class OwnerNotificationActivity extends BaseActivity implements OnRetriev
firstLoad = true;
flag_loading = true;
swiped = true;
- new RetrieveNotificationsCacheAsyncTask(OwnerNotificationActivity.this, filterNotifications, null, OwnerNotificationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveNotificationsCacheAsyncTask(OwnerNotificationActivity.this, filterNotifications, null, OwnerNotificationActivity.this);
dialog.dismiss();
})
.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
diff --git a/app/src/main/java/app/fedilab/android/activities/OwnerNotificationChartsActivity.java b/app/src/common/java/app/fedilab/android/activities/OwnerNotificationChartsActivity.java
similarity index 98%
rename from app/src/main/java/app/fedilab/android/activities/OwnerNotificationChartsActivity.java
rename to app/src/common/java/app/fedilab/android/activities/OwnerNotificationChartsActivity.java
index 47799e275..40bb310cc 100644
--- a/app/src/main/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;
@@ -91,7 +90,7 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
private RelativeLayout loader;
private ImageButton validate;
private String status_id;
- private DatePickerDialog.OnDateSetListener iniDateSetListener =
+ private final DatePickerDialog.OnDateSetListener iniDateSetListener =
new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year,
@@ -103,7 +102,7 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
}
};
- private DatePickerDialog.OnDateSetListener endDateSetListener =
+ private final DatePickerDialog.OnDateSetListener endDateSetListener =
new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year,
@@ -473,7 +472,7 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
chart.setVisibility(View.GONE);
loader.setVisibility(View.VISIBLE);
validate.setEnabled(false);
- new RetrieveNotificationChartsAsyncTask(OwnerNotificationChartsActivity.this, status_id, dateIni, dateEnd, OwnerNotificationChartsActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveNotificationChartsAsyncTask(OwnerNotificationChartsActivity.this, status_id, dateIni, dateEnd, OwnerNotificationChartsActivity.this);
}
@@ -484,7 +483,7 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
@SuppressLint("ViewConstructor")
public static class CustomMarkerView extends MarkerView {
- private TextView tvContent;
+ private final TextView tvContent;
private MPPointF mOffset;
public CustomMarkerView(Context context, int layoutResource) {
@@ -511,8 +510,8 @@ public class OwnerNotificationChartsActivity extends BaseActivity implements OnR
}
public class MyXAxisValueFormatter extends ValueFormatter {
- private DateFormat mDataFormat;
- private Date mDate;
+ private final DateFormat mDataFormat;
+ private final Date mDate;
MyXAxisValueFormatter() {
if (status_id == null) {
diff --git a/app/src/main/java/app/fedilab/android/activities/OwnerStatusActivity.java b/app/src/common/java/app/fedilab/android/activities/OwnerStatusActivity.java
similarity index 96%
rename from app/src/main/java/app/fedilab/android/activities/OwnerStatusActivity.java
rename to app/src/common/java/app/fedilab/android/activities/OwnerStatusActivity.java
index 9c73f9646..07321e54f 100644
--- a/app/src/main/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;
@@ -106,7 +105,7 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
private Date dateIni, dateEnd;
private View statsDialogView;
private Statistics statistics;
- private DatePickerDialog.OnDateSetListener iniDateSetListener =
+ private final DatePickerDialog.OnDateSetListener iniDateSetListener =
new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year,
@@ -118,7 +117,7 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
}
};
- private DatePickerDialog.OnDateSetListener endDateSetListener =
+ private final DatePickerDialog.OnDateSetListener endDateSetListener =
new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker view, int year,
@@ -131,14 +130,14 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
}
};
- private BroadcastReceiver backupFinishedReceiver = new BroadcastReceiver() {
+ private final BroadcastReceiver backupFinishedReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
max_id = null;
firstLoad = true;
flag_loading = true;
swiped = true;
- new RetrieveFeedsAsyncTask(OwnerStatusActivity.this, filterToots, null, OwnerStatusActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveFeedsAsyncTask(OwnerStatusActivity.this, filterToots, null, OwnerStatusActivity.this);
}
};
@@ -231,13 +230,13 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
swipeRefreshLayout.setColorSchemeColors(
c1, c2, c1
);
- new RetrieveFeedsAsyncTask(OwnerStatusActivity.this, filterToots, null, OwnerStatusActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveFeedsAsyncTask(OwnerStatusActivity.this, filterToots, null, OwnerStatusActivity.this);
swipeRefreshLayout.setOnRefreshListener(() -> {
max_id = null;
firstLoad = true;
flag_loading = true;
swiped = true;
- new RetrieveFeedsAsyncTask(OwnerStatusActivity.this, filterToots, null, OwnerStatusActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveFeedsAsyncTask(OwnerStatusActivity.this, filterToots, null, OwnerStatusActivity.this);
});
lv_status.addOnScrollListener(new RecyclerView.OnScrollListener() {
@@ -249,7 +248,7 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
if (firstVisibleItem + visibleItemCount == totalItemCount) {
if (!flag_loading) {
flag_loading = true;
- new RetrieveFeedsAsyncTask(OwnerStatusActivity.this, filterToots, max_id, OwnerStatusActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveFeedsAsyncTask(OwnerStatusActivity.this, filterToots, max_id, OwnerStatusActivity.this);
nextElementLoader.setVisibility(View.VISIBLE);
}
} else {
@@ -298,7 +297,7 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
.setPositiveButton(R.string.close, (dialog, which) -> dialog.dismiss());
dialogBuilder.create().show();
if (statistics == null) {
- new RetrieveStatsAsyncTask(OwnerStatusActivity.this, OwnerStatusActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveStatsAsyncTask(OwnerStatusActivity.this, OwnerStatusActivity.this);
} else {
displayStats();
}
@@ -409,7 +408,7 @@ public class OwnerStatusActivity extends BaseActivity implements OnRetrieveFeeds
firstLoad = true;
flag_loading = true;
swiped = true;
- new RetrieveFeedsAsyncTask(OwnerStatusActivity.this, filterToots, null, OwnerStatusActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveFeedsAsyncTask(OwnerStatusActivity.this, filterToots, null, OwnerStatusActivity.this);
dialog.dismiss();
})
.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
diff --git a/app/src/main/java/app/fedilab/android/activities/PhotoEditorActivity.java b/app/src/common/java/app/fedilab/android/activities/PhotoEditorActivity.java
similarity index 100%
rename from app/src/main/java/app/fedilab/android/activities/PhotoEditorActivity.java
rename to app/src/common/java/app/fedilab/android/activities/PhotoEditorActivity.java
diff --git a/app/src/common/java/app/fedilab/android/activities/PixelfedComposeActivity.java b/app/src/common/java/app/fedilab/android/activities/PixelfedComposeActivity.java
new file mode 100644
index 000000000..a9a800422
--- /dev/null
+++ b/app/src/common/java/app/fedilab/android/activities/PixelfedComposeActivity.java
@@ -0,0 +1,38 @@
+package app.fedilab.android.activities;
+
+
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+
+
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+public class PixelfedComposeActivity extends BasePixelfedComposeActivity {
+
+
+ @Override
+ protected void launchPhotoEditor(Uri uri) {
+ Intent intent = new Intent(PixelfedComposeActivity.this, PhotoEditorActivity.class);
+ Bundle b = new Bundle();
+ intent.putExtra("imageUri", uri.toString());
+ intent.putExtras(b);
+ startActivity(intent);
+ }
+
+ @Override
+ protected void displayEmojiPopup() {
+ }
+}
diff --git a/app/src/main/java/app/fedilab/android/activities/SettingsActivity.java b/app/src/common/java/app/fedilab/android/activities/SettingsActivity.java
similarity index 100%
rename from app/src/main/java/app/fedilab/android/activities/SettingsActivity.java
rename to app/src/common/java/app/fedilab/android/activities/SettingsActivity.java
diff --git a/app/src/common/java/app/fedilab/android/activities/TootActivity.java b/app/src/common/java/app/fedilab/android/activities/TootActivity.java
new file mode 100644
index 000000000..26fe4a150
--- /dev/null
+++ b/app/src/common/java/app/fedilab/android/activities/TootActivity.java
@@ -0,0 +1,210 @@
+package app.fedilab.android.activities;
+
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.net.Uri;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.LinearLayout;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import androidx.appcompat.app.AlertDialog;
+import androidx.fragment.app.DialogFragment;
+
+import com.github.stom79.localepicker.CountryPicker;
+import com.github.stom79.mytransl.MyTransL;
+import com.github.stom79.mytransl.client.HttpsConnectionException;
+import com.github.stom79.mytransl.translate.Translate;
+import com.vanniktech.emoji.EmojiPopup;
+
+import java.util.Date;
+import java.util.concurrent.TimeUnit;
+
+import app.fedilab.android.R;
+import app.fedilab.android.helper.Helper;
+import es.dmoral.toasty.Toasty;
+
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+
+public class TootActivity extends BaseTootActivity {
+
+ private AlertDialog dialogTrans;
+
+ @Override
+ protected boolean actionTranslateClick() {
+
+ SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
+ final CountryPicker picker = CountryPicker.newInstance(getString(R.string.which_language)); // dialog title
+ if (theme == Helper.THEME_LIGHT) {
+ picker.setStyle(DialogFragment.STYLE_NO_TITLE, R.style.Dialog);
+ } else {
+ picker.setStyle(DialogFragment.STYLE_NO_TITLE, R.style.DialogDark);
+ }
+ if (toot_content.getText().length() == 0 && toot_cw_content.getText().length() == 0)
+ return true;
+ String dateString = sharedpreferences.getString(Helper.LAST_TRANSLATION_TIME, null);
+ if (dateString != null) {
+ Date dateCompare = Helper.stringToDate(TootActivity.this, dateString);
+ Date date = new Date();
+ if (date.before(dateCompare)) {
+ Toasty.info(TootActivity.this, getString(R.string.please_wait), Toast.LENGTH_SHORT).show();
+ return true;
+ }
+ }
+ picker.setListener((name, locale, flagDrawableResID) -> {
+ picker.dismiss();
+ AlertDialog.Builder transAlert = new AlertDialog.Builder(TootActivity.this, style);
+ transAlert.setTitle(R.string.translate_toot);
+
+ View popup_trans = getLayoutInflater().inflate(R.layout.popup_translate, new LinearLayout(TootActivity.this), false);
+ transAlert.setView(popup_trans);
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putString(Helper.LAST_TRANSLATION_TIME, Helper.dateToString(new Date(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(Helper.SECONDES_BETWEEN_TRANSLATE))));
+ editor.apply();
+ TextView yandex_translate = popup_trans.findViewById(R.id.yandex_translate);
+ yandex_translate.setOnClickListener(v -> {
+ Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://translate.yandex.com/"));
+ startActivity(browserIntent);
+ });
+ MyTransL myTransL = MyTransL.getInstance(MyTransL.translatorEngine.YANDEX);
+ myTransL.setYandexAPIKey(Helper.YANDEX_KEY);
+ myTransL.setObfuscation(true);
+ myTransL.setTimeout(60);
+ if (toot_cw_content.getText().toString().length() > 0)
+ myTransL.translate(toot_cw_content.getText().toString(), locale, new com.github.stom79.mytransl.client.Results() {
+ @Override
+ public void onSuccess(Translate translate) {
+ try {
+ if (translate.getTranslatedContent() == null)
+ return;
+ ProgressBar trans_progress_cw = popup_trans.findViewById(R.id.trans_progress_cw);
+ ProgressBar trans_progress_toot = popup_trans.findViewById(R.id.trans_progress_toot);
+ if (trans_progress_cw != null)
+ trans_progress_cw.setVisibility(View.GONE);
+ LinearLayout trans_container = popup_trans.findViewById(R.id.trans_container);
+ if (trans_container != null) {
+ TextView cw_trans = popup_trans.findViewById(R.id.cw_trans);
+ if (cw_trans != null) {
+ cw_trans.setVisibility(View.VISIBLE);
+ cw_trans.setText(translate.getTranslatedContent());
+ }
+ } else {
+ Toasty.error(TootActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
+ }
+ if (trans_progress_cw != null && trans_progress_toot != null && trans_progress_cw.getVisibility() == View.GONE && trans_progress_toot.getVisibility() == View.GONE)
+ if (dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE) != null)
+ dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE).setEnabled(true);
+ } catch (IllegalArgumentException e) {
+ Toasty.error(TootActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
+ }
+
+ }
+
+ @Override
+ public void onFail(HttpsConnectionException e) {
+ e.printStackTrace();
+ }
+ });
+ else {
+ ProgressBar trans_progress_cw = popup_trans.findViewById(R.id.trans_progress_cw);
+ trans_progress_cw.setVisibility(View.GONE);
+ }
+ if (toot_content.getText().toString().length() > 0)
+ myTransL.translate(toot_content.getText().toString(), locale, new com.github.stom79.mytransl.client.Results() {
+ @Override
+ public void onSuccess(Translate translate) {
+ try {
+ if (translate.getTranslatedContent() == null)
+ return;
+ ProgressBar trans_progress_cw = popup_trans.findViewById(R.id.trans_progress_cw);
+ ProgressBar trans_progress_toot = popup_trans.findViewById(R.id.trans_progress_toot);
+ if (trans_progress_toot != null)
+ trans_progress_toot.setVisibility(View.GONE);
+ LinearLayout trans_container = popup_trans.findViewById(R.id.trans_container);
+ if (trans_container != null) {
+ TextView toot_trans = popup_trans.findViewById(R.id.toot_trans);
+ if (toot_trans != null) {
+ toot_trans.setVisibility(View.VISIBLE);
+ toot_trans.setText(translate.getTranslatedContent());
+ }
+ } else {
+ Toasty.error(TootActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
+ }
+ if (trans_progress_cw != null && trans_progress_toot != null && trans_progress_cw.getVisibility() == View.GONE && trans_progress_toot.getVisibility() == View.GONE)
+ if (dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE) != null)
+ dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE).setEnabled(true);
+ } catch (IllegalArgumentException e) {
+ Toasty.error(TootActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
+ }
+ }
+
+ @Override
+ public void onFail(HttpsConnectionException e) {
+ e.printStackTrace();
+ }
+ });
+
+ transAlert.setPositiveButton(R.string.close, (dialog, whichButton) -> dialog.dismiss());
+ transAlert.setNegativeButton(R.string.validate, (dialog, whichButton) -> {
+ TextView toot_trans = popup_trans.findViewById(R.id.toot_trans);
+ TextView cw_trans = popup_trans.findViewById(R.id.cw_trans);
+ if (toot_trans != null) {
+ toot_content.setText(toot_trans.getText().toString());
+ toot_content.setSelection(toot_content.getText().length());
+ }
+ if (cw_trans != null)
+ toot_cw_content.setText(cw_trans.getText().toString());
+ dialog.dismiss();
+ });
+ dialogTrans = transAlert.create();
+ transAlert.show();
+
+ dialogTrans.setOnShowListener(dialog -> {
+ Button negativeButton = ((AlertDialog) dialog)
+ .getButton(AlertDialog.BUTTON_NEGATIVE);
+ if (negativeButton != null)
+ negativeButton.setEnabled(false);
+ });
+
+ });
+ picker.show(getSupportFragmentManager(), "COUNTRY_PICKER");
+ return true;
+ }
+
+
+ @Override
+ protected void launchPhotoEditor(Uri uri) {
+ Intent intent = new Intent(TootActivity.this, PhotoEditorActivity.class);
+ Bundle b = new Bundle();
+ intent.putExtra("imageUri", uri.toString());
+ intent.putExtras(b);
+ startActivity(intent);
+ }
+
+ @Override
+ protected void displayEmojiPopup() {
+ final EmojiPopup emojiPopup = EmojiPopup.Builder.fromRootView(drawer_layout).build(toot_content);
+
+ toot_emoji.setOnClickListener(v -> {
+ emojiPopup.toggle(); // Toggles visibility of the Popup.
+ });
+ }
+}
diff --git a/app/src/common/java/app/fedilab/android/drawers/NotificationsListAdapter.java b/app/src/common/java/app/fedilab/android/drawers/NotificationsListAdapter.java
new file mode 100644
index 000000000..f2cc92800
--- /dev/null
+++ b/app/src/common/java/app/fedilab/android/drawers/NotificationsListAdapter.java
@@ -0,0 +1,40 @@
+package app.fedilab.android.drawers;
+
+import android.content.Intent;
+import android.os.Bundle;
+
+import java.util.List;
+
+import app.fedilab.android.activities.OwnerNotificationChartsActivity;
+import app.fedilab.android.client.Entities.Notification;
+import app.fedilab.android.client.Entities.Status;
+
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+public class NotificationsListAdapter extends BaseNotificationsListAdapter {
+
+ public NotificationsListAdapter(boolean isOnWifi, int behaviorWithAttachments, List notifications) {
+ super(isOnWifi, behaviorWithAttachments, notifications);
+ }
+
+ 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());
+ intent.putExtras(b);
+ context.startActivity(intent);
+ }
+
+}
diff --git a/app/src/common/java/app/fedilab/android/drawers/StatusListAdapter.java b/app/src/common/java/app/fedilab/android/drawers/StatusListAdapter.java
new file mode 100644
index 000000000..4dd77b9b8
--- /dev/null
+++ b/app/src/common/java/app/fedilab/android/drawers/StatusListAdapter.java
@@ -0,0 +1,88 @@
+package app.fedilab.android.drawers;
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * 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.Bundle;
+import android.view.inputmethod.InputMethodManager;
+
+import com.vanniktech.emoji.EmojiManager;
+import com.vanniktech.emoji.EmojiPopup;
+import com.vanniktech.emoji.one.EmojiOneProvider;
+
+import app.fedilab.android.activities.OwnerNotificationChartsActivity;
+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.Status;
+import app.fedilab.android.client.Entities.StatusDrawerParams;
+
+import static android.content.Context.INPUT_METHOD_SERVICE;
+
+public class StatusListAdapter extends BaseStatusListAdapter {
+ public StatusListAdapter(StatusDrawerParams statusDrawerParams) {
+ super(statusDrawerParams);
+ }
+
+ 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);
+ assert imm != null;
+ imm.hideSoftInputFromWindow(holder.status_add_reaction.getWindowToken(), 0);
+ }).setOnEmojiClickListener((emoji, imageView) -> {
+ String emojiStr = imageView.getUnicode();
+ boolean alreadyAdded = false;
+ for (Reaction reaction : status.getReactions()) {
+ if (reaction.getName().compareTo(emojiStr) == 0) {
+ alreadyAdded = true;
+ reaction.setCount(reaction.getCount() - 1);
+ if (reaction.getCount() == 0) {
+ status.getReactions().remove(reaction);
+ }
+ notifyStatusChanged(status);
+ break;
+ }
+ }
+ if (!alreadyAdded) {
+ Reaction reaction = new Reaction();
+ reaction.setMe(true);
+ reaction.setCount(1);
+ reaction.setName(emojiStr);
+ status.getReactions().add(0, reaction);
+ notifyStatusChanged(status);
+ }
+ API.StatusAction statusAction;
+ if (type == RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS) {
+ statusAction = alreadyAdded ? API.StatusAction.REMOVE_REACTION : API.StatusAction.ADD_REACTION;
+ } else {
+ statusAction = alreadyAdded ? API.StatusAction.REMOVE_PLEROMA_REACTION : API.StatusAction.ADD_PLEROMA_REACTION;
+ }
+ new PostActionAsyncTask(context, statusAction, status.getId(), null, emojiStr, StatusListAdapter.this);
+ })
+ .build(holder.fake_edittext);
+ emojiPopup.toggle();
+ }
+
+ 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());
+ intent.putExtras(b);
+ context.startActivity(intent);
+ }
+
+}
diff --git a/app/src/main/java/app/fedilab/android/helper/CustomTextView.java b/app/src/common/java/app/fedilab/android/helper/CustomTextView.java
similarity index 100%
rename from app/src/main/java/app/fedilab/android/helper/CustomTextView.java
rename to app/src/common/java/app/fedilab/android/helper/CustomTextView.java
diff --git a/app/src/main/java/app/fedilab/android/helper/EmojiEditTextInterface.java b/app/src/common/java/app/fedilab/android/helper/EmojiEditTextInterface.java
similarity index 100%
rename from app/src/main/java/app/fedilab/android/helper/EmojiEditTextInterface.java
rename to app/src/common/java/app/fedilab/android/helper/EmojiEditTextInterface.java
diff --git a/app/src/common/java/app/fedilab/android/helper/Helper.java b/app/src/common/java/app/fedilab/android/helper/Helper.java
new file mode 100644
index 000000000..f0eaefc81
--- /dev/null
+++ b/app/src/common/java/app/fedilab/android/helper/Helper.java
@@ -0,0 +1,43 @@
+package app.fedilab.android.helper;
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * 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;
+
+public class Helper extends BaseHelper {
+ public static void installProvider() {
+
+ boolean patch_provider = true;
+ try {
+ Context ctx = MainApplication.getApp();
+ SharedPreferences sharedpreferences = ctx.getSharedPreferences(Helper.APP_PREFS, android.content.Context.MODE_PRIVATE);
+ patch_provider = sharedpreferences.getBoolean(Helper.SET_SECURITY_PROVIDER, true);
+ } catch (Exception ignored) {
+ }
+ if (patch_provider) {
+ try {
+ Security.insertProviderAt(Conscrypt.newProvider(), 1);
+ } catch (Exception ignored) {
+ }
+ }
+ }
+}
diff --git a/app/src/main/java/app/fedilab/android/helper/MastalabAutoCompleteTextView.java b/app/src/common/java/app/fedilab/android/helper/MastalabAutoCompleteTextView.java
similarity index 100%
rename from app/src/main/java/app/fedilab/android/helper/MastalabAutoCompleteTextView.java
rename to app/src/common/java/app/fedilab/android/helper/MastalabAutoCompleteTextView.java
diff --git a/app/src/main/java/app/fedilab/android/imageeditor/ColorPickerAdapter.java b/app/src/common/java/app/fedilab/android/imageeditor/ColorPickerAdapter.java
similarity index 100%
rename from app/src/main/java/app/fedilab/android/imageeditor/ColorPickerAdapter.java
rename to app/src/common/java/app/fedilab/android/imageeditor/ColorPickerAdapter.java
diff --git a/app/src/main/java/app/fedilab/android/imageeditor/EmojiBSFragment.java b/app/src/common/java/app/fedilab/android/imageeditor/EmojiBSFragment.java
similarity index 100%
rename from app/src/main/java/app/fedilab/android/imageeditor/EmojiBSFragment.java
rename to app/src/common/java/app/fedilab/android/imageeditor/EmojiBSFragment.java
diff --git a/app/src/main/java/app/fedilab/android/imageeditor/PropertiesBSFragment.java b/app/src/common/java/app/fedilab/android/imageeditor/PropertiesBSFragment.java
similarity index 100%
rename from app/src/main/java/app/fedilab/android/imageeditor/PropertiesBSFragment.java
rename to app/src/common/java/app/fedilab/android/imageeditor/PropertiesBSFragment.java
diff --git a/app/src/main/java/app/fedilab/android/imageeditor/StickerBSFragment.java b/app/src/common/java/app/fedilab/android/imageeditor/StickerBSFragment.java
similarity index 100%
rename from app/src/main/java/app/fedilab/android/imageeditor/StickerBSFragment.java
rename to app/src/common/java/app/fedilab/android/imageeditor/StickerBSFragment.java
diff --git a/app/src/main/java/app/fedilab/android/imageeditor/TextEditorDialogFragment.java b/app/src/common/java/app/fedilab/android/imageeditor/TextEditorDialogFragment.java
similarity index 100%
rename from app/src/main/java/app/fedilab/android/imageeditor/TextEditorDialogFragment.java
rename to app/src/common/java/app/fedilab/android/imageeditor/TextEditorDialogFragment.java
diff --git a/app/src/main/java/app/fedilab/android/imageeditor/filters/FilterListener.java b/app/src/common/java/app/fedilab/android/imageeditor/filters/FilterListener.java
similarity index 100%
rename from app/src/main/java/app/fedilab/android/imageeditor/filters/FilterListener.java
rename to app/src/common/java/app/fedilab/android/imageeditor/filters/FilterListener.java
diff --git a/app/src/main/java/app/fedilab/android/imageeditor/filters/FilterViewAdapter.java b/app/src/common/java/app/fedilab/android/imageeditor/filters/FilterViewAdapter.java
similarity index 100%
rename from app/src/main/java/app/fedilab/android/imageeditor/filters/FilterViewAdapter.java
rename to app/src/common/java/app/fedilab/android/imageeditor/filters/FilterViewAdapter.java
diff --git a/app/src/main/java/app/fedilab/android/imageeditor/tools/EditingToolsAdapter.java b/app/src/common/java/app/fedilab/android/imageeditor/tools/EditingToolsAdapter.java
similarity index 100%
rename from app/src/main/java/app/fedilab/android/imageeditor/tools/EditingToolsAdapter.java
rename to app/src/common/java/app/fedilab/android/imageeditor/tools/EditingToolsAdapter.java
diff --git a/app/src/main/java/app/fedilab/android/imageeditor/tools/ToolType.java b/app/src/common/java/app/fedilab/android/imageeditor/tools/ToolType.java
similarity index 100%
rename from app/src/main/java/app/fedilab/android/imageeditor/tools/ToolType.java
rename to app/src/common/java/app/fedilab/android/imageeditor/tools/ToolType.java
diff --git a/app/src/common/java/app/fedilab/android/jobs/BackupNotificationsSyncJob.java b/app/src/common/java/app/fedilab/android/jobs/BackupNotificationsSyncJob.java
new file mode 100644
index 000000000..6fa0fbf66
--- /dev/null
+++ b/app/src/common/java/app/fedilab/android/jobs/BackupNotificationsSyncJob.java
@@ -0,0 +1,23 @@
+package app.fedilab.android.jobs;
+
+import app.fedilab.android.helper.Helper;
+
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+public class BackupNotificationsSyncJob extends BaseBackupNotificationsSyncJob {
+ static {
+ Helper.installProvider();
+ }
+}
diff --git a/app/src/common/java/app/fedilab/android/jobs/BackupStatusesSyncJob.java b/app/src/common/java/app/fedilab/android/jobs/BackupStatusesSyncJob.java
new file mode 100644
index 000000000..9ee792b51
--- /dev/null
+++ b/app/src/common/java/app/fedilab/android/jobs/BackupStatusesSyncJob.java
@@ -0,0 +1,23 @@
+package app.fedilab.android.jobs;
+
+import app.fedilab.android.helper.Helper;
+
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+public class BackupStatusesSyncJob extends BaseBackupStatusesSyncJob {
+ static {
+ Helper.installProvider();
+ }
+}
diff --git a/app/src/common/java/app/fedilab/android/jobs/NotificationsSyncJob.java b/app/src/common/java/app/fedilab/android/jobs/NotificationsSyncJob.java
new file mode 100644
index 000000000..1f13acaf1
--- /dev/null
+++ b/app/src/common/java/app/fedilab/android/jobs/NotificationsSyncJob.java
@@ -0,0 +1,23 @@
+package app.fedilab.android.jobs;
+
+import app.fedilab.android.helper.Helper;
+
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+public class NotificationsSyncJob extends BaseNotificationsSyncJob {
+ static {
+ Helper.installProvider();
+ }
+}
diff --git a/app/src/common/java/app/fedilab/android/jobs/ScheduledBoostsSyncJob.java b/app/src/common/java/app/fedilab/android/jobs/ScheduledBoostsSyncJob.java
new file mode 100644
index 000000000..6137baaac
--- /dev/null
+++ b/app/src/common/java/app/fedilab/android/jobs/ScheduledBoostsSyncJob.java
@@ -0,0 +1,23 @@
+package app.fedilab.android.jobs;
+
+import app.fedilab.android.helper.Helper;
+
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+public class ScheduledBoostsSyncJob extends BaseScheduledBoostsSyncJob {
+ static {
+ Helper.installProvider();
+ }
+}
diff --git a/app/src/common/java/app/fedilab/android/jobs/ScheduledTootsSyncJob.java b/app/src/common/java/app/fedilab/android/jobs/ScheduledTootsSyncJob.java
new file mode 100644
index 000000000..2522e0aba
--- /dev/null
+++ b/app/src/common/java/app/fedilab/android/jobs/ScheduledTootsSyncJob.java
@@ -0,0 +1,23 @@
+package app.fedilab.android.jobs;
+
+import app.fedilab.android.helper.Helper;
+
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+public class ScheduledTootsSyncJob extends BaseScheduledTootsSyncJob {
+ static {
+ Helper.installProvider();
+ }
+}
diff --git a/app/src/common/java/app/fedilab/android/services/LiveNotificationService.java b/app/src/common/java/app/fedilab/android/services/LiveNotificationService.java
new file mode 100644
index 000000000..1e4bf19c3
--- /dev/null
+++ b/app/src/common/java/app/fedilab/android/services/LiveNotificationService.java
@@ -0,0 +1,23 @@
+package app.fedilab.android.services;
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+
+import app.fedilab.android.helper.Helper;
+
+public class LiveNotificationService extends BaseLiveNotificationService {
+ static {
+ Helper.installProvider();
+ }
+}
diff --git a/app/src/common/java/app/fedilab/android/services/StreamingFederatedTimelineService.java b/app/src/common/java/app/fedilab/android/services/StreamingFederatedTimelineService.java
new file mode 100644
index 000000000..7f46338b7
--- /dev/null
+++ b/app/src/common/java/app/fedilab/android/services/StreamingFederatedTimelineService.java
@@ -0,0 +1,23 @@
+package app.fedilab.android.services;
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+
+import app.fedilab.android.helper.Helper;
+
+public class StreamingFederatedTimelineService extends BaseStreamingFederatedTimelineService {
+ static {
+ Helper.installProvider();
+ }
+}
diff --git a/app/src/common/java/app/fedilab/android/services/StreamingHomeTimelineService.java b/app/src/common/java/app/fedilab/android/services/StreamingHomeTimelineService.java
new file mode 100644
index 000000000..6fea296b4
--- /dev/null
+++ b/app/src/common/java/app/fedilab/android/services/StreamingHomeTimelineService.java
@@ -0,0 +1,23 @@
+package app.fedilab.android.services;
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+
+import app.fedilab.android.helper.Helper;
+
+public class StreamingHomeTimelineService extends BaseStreamingHomeTimelineService {
+ static {
+ Helper.installProvider();
+ }
+}
diff --git a/app/src/common/java/app/fedilab/android/services/StreamingLocalTimelineService.java b/app/src/common/java/app/fedilab/android/services/StreamingLocalTimelineService.java
new file mode 100644
index 000000000..89cac067e
--- /dev/null
+++ b/app/src/common/java/app/fedilab/android/services/StreamingLocalTimelineService.java
@@ -0,0 +1,23 @@
+package app.fedilab.android.services;
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+
+import app.fedilab.android.helper.Helper;
+
+public class StreamingLocalTimelineService extends BaseStreamingLocalTimelineService {
+ static {
+ Helper.installProvider();
+ }
+}
diff --git a/app/src/main/res/layout/activity_photoeditor.xml b/app/src/common/res/layout/activity_photoeditor.xml
similarity index 100%
rename from app/src/main/res/layout/activity_photoeditor.xml
rename to app/src/common/res/layout/activity_photoeditor.xml
diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/common/res/layout/activity_settings.xml
similarity index 100%
rename from app/src/main/res/layout/activity_settings.xml
rename to app/src/common/res/layout/activity_settings.xml
diff --git a/app/src/fdroid/java/app/fedilab/android/activities/MainActivity.java b/app/src/fdroid/java/app/fedilab/android/activities/MainActivity.java
index d5b66b50c..a7b81ee1a 100644
--- a/app/src/fdroid/java/app/fedilab/android/activities/MainActivity.java
+++ b/app/src/fdroid/java/app/fedilab/android/activities/MainActivity.java
@@ -14,6 +14,8 @@
* see . */
package app.fedilab.android.activities;
+import android.content.Intent;
+
public class MainActivity extends BaseMainActivity {
@@ -21,4 +23,16 @@ public class MainActivity extends BaseMainActivity {
protected void rateThisApp() {
// do nothing
}
+
+ @Override
+ protected void launchOwnerStatusesActivity() {
+ Intent myIntent = new Intent(MainActivity.this, OwnerStatusActivity.class);
+ startActivity(myIntent);
+ }
+
+ @Override
+ protected void launchOwnerNotificationsActivity() {
+ Intent myIntent = new Intent(MainActivity.this, OwnerNotificationActivity.class);
+ startActivity(myIntent);
+ }
}
diff --git a/app/src/fdroid/res/xml/file_paths.xml b/app/src/fdroid/res/xml/file_paths.xml
index 967d67b2e..758bbce98 100644
--- a/app/src/fdroid/res/xml/file_paths.xml
+++ b/app/src/fdroid/res/xml/file_paths.xml
@@ -1,7 +1,11 @@
-
-
+
+
-
+
\ No newline at end of file
diff --git a/app/src/lite/AndroidManifest.xml b/app/src/lite/AndroidManifest.xml
new file mode 100644
index 000000000..612fd439c
--- /dev/null
+++ b/app/src/lite/AndroidManifest.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/lite/java/app/fedilab/android/activities/BaseActivity.java b/app/src/lite/java/app/fedilab/android/activities/BaseActivity.java
new file mode 100644
index 000000000..a440128c8
--- /dev/null
+++ b/app/src/lite/java/app/fedilab/android/activities/BaseActivity.java
@@ -0,0 +1,28 @@
+package app.fedilab.android.activities;
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+
+import android.annotation.SuppressLint;
+
+
+@SuppressLint("Registered")
+public class BaseActivity extends AllBaseActivity {
+
+ protected void launchOwnerStatusesActivity() {
+ }
+
+ protected void launchOwnerNotificationsActivity() {
+ }
+}
diff --git a/app/src/lite/java/app/fedilab/android/activities/BaseFragmentActivity.java b/app/src/lite/java/app/fedilab/android/activities/BaseFragmentActivity.java
new file mode 100644
index 000000000..449d24fd6
--- /dev/null
+++ b/app/src/lite/java/app/fedilab/android/activities/BaseFragmentActivity.java
@@ -0,0 +1,21 @@
+package app.fedilab.android.activities;
+
+
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+
+
+public class BaseFragmentActivity extends MainBaseFragmentActivity {
+}
diff --git a/app/src/lite/java/app/fedilab/android/activities/MainActivity.java b/app/src/lite/java/app/fedilab/android/activities/MainActivity.java
new file mode 100644
index 000000000..57ea2a401
--- /dev/null
+++ b/app/src/lite/java/app/fedilab/android/activities/MainActivity.java
@@ -0,0 +1,34 @@
+package app.fedilab.android.activities;
+
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+public class MainActivity extends BaseMainActivity {
+
+
+ @Override
+ protected void rateThisApp() {
+ // do nothing
+ }
+
+ @Override
+ protected void launchOwnerStatusesActivity() {
+ // do nothing
+ }
+
+ @Override
+ protected void launchOwnerNotificationsActivity() {
+ // do nothing
+ }
+}
diff --git a/app/src/lite/java/app/fedilab/android/activities/PixelfedComposeActivity.java b/app/src/lite/java/app/fedilab/android/activities/PixelfedComposeActivity.java
new file mode 100644
index 000000000..a083c7e72
--- /dev/null
+++ b/app/src/lite/java/app/fedilab/android/activities/PixelfedComposeActivity.java
@@ -0,0 +1,30 @@
+package app.fedilab.android.activities;
+
+import android.net.Uri;
+
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+public class PixelfedComposeActivity extends BasePixelfedComposeActivity {
+
+ @Override
+ protected void launchPhotoEditor(Uri uri) {
+ }
+
+ @Override
+ protected void displayEmojiPopup() {
+ }
+
+
+}
diff --git a/app/src/lite/java/app/fedilab/android/activities/SettingsActivity.java b/app/src/lite/java/app/fedilab/android/activities/SettingsActivity.java
new file mode 100644
index 000000000..00dbbd749
--- /dev/null
+++ b/app/src/lite/java/app/fedilab/android/activities/SettingsActivity.java
@@ -0,0 +1,651 @@
+/* Copyright 2019 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+package app.fedilab.android.activities;
+
+import android.app.NotificationManager;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.database.sqlite.SQLiteDatabase;
+import android.graphics.drawable.ColorDrawable;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Handler;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.LayoutInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.SeekBar;
+import android.widget.Spinner;
+import android.widget.TextView;
+import android.widget.Toast;
+
+import androidx.appcompat.app.ActionBar;
+import androidx.appcompat.app.AlertDialog;
+import androidx.appcompat.widget.SwitchCompat;
+import androidx.core.content.ContextCompat;
+
+import app.fedilab.android.R;
+import app.fedilab.android.client.Entities.Account;
+import app.fedilab.android.helper.Helper;
+import app.fedilab.android.jobs.ApplicationJob;
+import app.fedilab.android.jobs.NotificationsSyncJob;
+import app.fedilab.android.services.LiveNotificationDelayedService;
+import app.fedilab.android.services.LiveNotificationService;
+import app.fedilab.android.services.StopDelayedNotificationReceiver;
+import app.fedilab.android.services.StopLiveNotificationReceiver;
+import app.fedilab.android.sqlite.AccountDAO;
+import app.fedilab.android.sqlite.Sqlite;
+import es.dmoral.toasty.Toasty;
+
+import static app.fedilab.android.helper.BaseHelper.startStreaming;
+
+/**
+ * Created by Thomas on 01/07/2019.
+ * Settings activity
+ */
+
+public class SettingsActivity extends BaseActivity {
+
+
+ public static boolean needRestart;
+ protected int res;
+ private int style;
+ private int liveNotificationCount;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
+ int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
+ switch (theme) {
+ case Helper.THEME_LIGHT:
+ setTheme(R.style.AppTheme);
+ break;
+ case Helper.THEME_BLACK:
+ setTheme(R.style.AppThemeBlack);
+ break;
+ default:
+ setTheme(R.style.AppThemeDark);
+ }
+ needRestart = false;
+ if (getSupportActionBar() != null)
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ ActionBar actionBar = getSupportActionBar();
+ if (actionBar != null) {
+ LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
+ assert inflater != null;
+ View view = inflater.inflate(R.layout.simple_bar, new LinearLayout(SettingsActivity.this), false);
+ view.setBackground(new ColorDrawable(ContextCompat.getColor(SettingsActivity.this, R.color.cyanea_primary)));
+ actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
+ actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
+ ImageView toolbar_close = actionBar.getCustomView().findViewById(R.id.toolbar_close);
+ TextView toolbar_title = actionBar.getCustomView().findViewById(R.id.toolbar_title);
+ toolbar_close.setOnClickListener(v -> finish());
+ toolbar_title.setText(R.string.settings);
+ }
+ setContentView(R.layout.activity_settings);
+
+ if (theme == Helper.THEME_DARK) {
+ style = R.style.DialogDark;
+ } else if (theme == Helper.THEME_BLACK) {
+ style = R.style.DialogBlack;
+ } else {
+ style = R.style.Dialog;
+ }
+
+
+ boolean display_content_after_fetch_more = sharedpreferences.getBoolean(Helper.SET_DISPLAY_CONTENT_AFTER_FM, true);
+ final SwitchCompat set_display_content_after_fetch_more = findViewById(R.id.set_display_content_after_fetch_more);
+ set_display_content_after_fetch_more.setChecked(display_content_after_fetch_more);
+ set_display_content_after_fetch_more.setOnClickListener(v -> {
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putBoolean(Helper.SET_DISPLAY_CONTENT_AFTER_FM, set_display_content_after_fetch_more.isChecked());
+ editor.apply();
+ });
+
+ boolean notif_validation = sharedpreferences.getBoolean(Helper.SET_NOTIF_VALIDATION, false);
+ final SwitchCompat set_share_validation = findViewById(R.id.set_share_validation);
+ set_share_validation.setChecked(notif_validation);
+
+ set_share_validation.setOnClickListener(v -> {
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putBoolean(Helper.SET_NOTIF_VALIDATION, set_share_validation.isChecked());
+ editor.apply();
+ });
+
+ boolean notif_validation_fav = sharedpreferences.getBoolean(Helper.SET_NOTIF_VALIDATION_FAV, false);
+ final SwitchCompat set_share_validation_fav = findViewById(R.id.set_share_validation_fav);
+ set_share_validation_fav.setChecked(notif_validation_fav);
+
+ set_share_validation_fav.setOnClickListener(v -> {
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putBoolean(Helper.SET_NOTIF_VALIDATION_FAV, set_share_validation_fav.isChecked());
+ editor.apply();
+ });
+
+ EditText set_invidious_host = findViewById(R.id.set_invidious_host);
+ String invidiousHost = sharedpreferences.getString(Helper.SET_INVIDIOUS_HOST, null);
+ if (invidiousHost != null) {
+ set_invidious_host.setText(invidiousHost);
+ }
+ set_invidious_host.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();
+ if (s.toString().trim().length() > 0) {
+ editor.putString(Helper.SET_INVIDIOUS_HOST, s.toString().toLowerCase().trim());
+ } else {
+ editor.putString(Helper.SET_INVIDIOUS_HOST, null);
+ }
+ editor.apply();
+ }
+ });
+
+ EditText set_nitter_host = findViewById(R.id.set_nitter_host);
+ String nitterHost = sharedpreferences.getString(Helper.SET_NITTER_HOST, null);
+ if (nitterHost != null) {
+ set_nitter_host.setText(nitterHost);
+ }
+ set_nitter_host.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();
+ if (s.toString().trim().length() > 0) {
+ editor.putString(Helper.SET_NITTER_HOST, s.toString().toLowerCase().trim());
+ } else {
+ editor.putString(Helper.SET_NITTER_HOST, null);
+ }
+ editor.apply();
+ }
+ });
+
+
+ TextView set_bibliogram_host = findViewById(R.id.set_bibliogram_host);
+
+ String bibliogramHost = sharedpreferences.getString(Helper.SET_BIBLIOGRAM_HOST, null);
+ if (bibliogramHost != null) {
+ set_bibliogram_host.setText(bibliogramHost);
+ }
+ set_bibliogram_host.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();
+ if (s.toString().trim().length() > 0) {
+ editor.putString(Helper.SET_BIBLIOGRAM_HOST, s.toString().toLowerCase().trim());
+ } else {
+ editor.putString(Helper.SET_BIBLIOGRAM_HOST, null);
+ }
+ editor.apply();
+ }
+ });
+
+
+ boolean expand_cw = sharedpreferences.getBoolean(Helper.SET_EXPAND_CW, false);
+ final SwitchCompat set_expand_cw = findViewById(R.id.set_expand_cw);
+ set_expand_cw.setChecked(expand_cw);
+
+ set_expand_cw.setOnClickListener(v -> {
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putBoolean(Helper.SET_EXPAND_CW, set_expand_cw.isChecked());
+ editor.apply();
+ });
+
+ boolean expand_media = sharedpreferences.getBoolean(Helper.SET_EXPAND_MEDIA, false);
+ final SwitchCompat set_expand_media = findViewById(R.id.set_expand_image);
+ set_expand_media.setChecked(expand_media);
+
+ set_expand_media.setOnClickListener(v -> {
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putBoolean(Helper.SET_EXPAND_MEDIA, set_expand_media.isChecked());
+ editor.apply();
+ });
+
+
+ int truncate_toots_size = sharedpreferences.getInt(Helper.SET_TRUNCATE_TOOTS_SIZE, 0);
+ SeekBar set_truncate_size = findViewById(R.id.set_truncate_size);
+ set_truncate_size.setMax(20);
+ set_truncate_size.setProgress(truncate_toots_size);
+ TextView set_truncate_toots = findViewById(R.id.set_truncate_toots);
+ set_truncate_toots.setText(String.valueOf(truncate_toots_size));
+ set_truncate_size.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ set_truncate_toots.setText(String.valueOf(progress));
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putInt(Helper.SET_TRUNCATE_TOOTS_SIZE, progress);
+ editor.apply();
+ }
+ });
+
+ boolean quick_reply = sharedpreferences.getBoolean(Helper.SET_QUICK_REPLY, true);
+ final SwitchCompat set_quick_reply = findViewById(R.id.set_quick_reply);
+ set_quick_reply.setChecked(quick_reply);
+
+ set_quick_reply.setOnClickListener(v -> {
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putBoolean(Helper.SET_QUICK_REPLY, set_quick_reply.isChecked());
+ editor.apply();
+ });
+
+ boolean fit_preview = sharedpreferences.getBoolean(Helper.SET_FULL_PREVIEW, false);
+ final SwitchCompat set_fit_preview = findViewById(R.id.set_fit_preview);
+ set_fit_preview.setChecked(fit_preview);
+
+ set_fit_preview.setOnClickListener(v -> {
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putBoolean(Helper.SET_FULL_PREVIEW, set_fit_preview.isChecked());
+ editor.apply();
+ });
+
+
+ boolean disableGif = sharedpreferences.getBoolean(Helper.SET_DISABLE_GIF, false);
+ final SwitchCompat set_disable_gif = findViewById(R.id.set_disable_gif);
+ set_disable_gif.setChecked(disableGif);
+ set_disable_gif.setOnClickListener(v -> {
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putBoolean(Helper.SET_DISABLE_GIF, set_disable_gif.isChecked());
+ editor.apply();
+ recreate();
+ });
+
+
+ boolean disableAnimatedEmoji = sharedpreferences.getBoolean(Helper.SET_DISABLE_ANIMATED_EMOJI, false);
+ final SwitchCompat set_disable_animated_emoji = findViewById(R.id.set_disable_animated_emoji);
+ set_disable_animated_emoji.setChecked(disableAnimatedEmoji);
+ set_disable_animated_emoji.setOnClickListener(v -> {
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putBoolean(Helper.SET_DISABLE_ANIMATED_EMOJI, set_disable_animated_emoji.isChecked());
+ editor.apply();
+ });
+
+ boolean display_card = sharedpreferences.getBoolean(Helper.SET_DISPLAY_CARD, false);
+ final SwitchCompat set_display_card = findViewById(R.id.set_display_card);
+ set_display_card.setChecked(display_card);
+ set_display_card.setOnClickListener(v -> {
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putBoolean(Helper.SET_DISPLAY_CARD, set_display_card.isChecked());
+ editor.apply();
+ });
+
+ boolean notify = sharedpreferences.getBoolean(Helper.SET_NOTIFY, true);
+ final SwitchCompat switchCompatNotify = findViewById(R.id.set_notify);
+ switchCompatNotify.setChecked(notify);
+
+ switchCompatNotify.setOnCheckedChangeListener((buttonView, isChecked) -> {
+ // Save the state here
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putBoolean(Helper.SET_NOTIFY, isChecked);
+ editor.apply();
+ if (isChecked) {
+ startStreaming(SettingsActivity.this);
+ } else {
+ sendBroadcast(new Intent(getApplicationContext(), StopLiveNotificationReceiver.class));
+ if (Build.VERSION.SDK_INT >= 26) {
+ NotificationManager notif = ((NotificationManager) getSystemService(NOTIFICATION_SERVICE));
+ if (notif != null) {
+ notif.deleteNotificationChannel(LiveNotificationDelayedService.CHANNEL_ID);
+ }
+ }
+ }
+ });
+
+
+ SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
+ String userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
+ String instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(getApplicationContext()));
+ final Account account = new AccountDAO(getApplicationContext(), db).getUniqAccount(userId, instance);
+ boolean allow_live_notifications = sharedpreferences.getBoolean(Helper.SET_ALLOW_STREAM + userId + instance, true);
+ TextView set_allow_live_notifications_title = findViewById(R.id.set_allow_live_notifications_title);
+ set_allow_live_notifications_title.setText(getString(R.string.set_allow_live_notifications, account.getAcct() + "@" + account.getInstance()));
+ final SwitchCompat set_allow_live_notifications = findViewById(R.id.set_allow_live_notifications);
+ set_allow_live_notifications.setChecked(allow_live_notifications);
+ set_allow_live_notifications.setOnClickListener(v -> {
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putBoolean(Helper.SET_ALLOW_STREAM + userId + instance, set_allow_live_notifications.isChecked());
+ editor.apply();
+ if (set_allow_live_notifications.isChecked()) {
+ LiveNotificationDelayedService.totalAccount++;
+ } else {
+ LiveNotificationDelayedService.totalAccount--;
+ }
+ if (set_allow_live_notifications.isChecked()) {
+ LiveNotificationDelayedService.totalAccount++;
+ } else {
+ LiveNotificationDelayedService.totalAccount--;
+ }
+ startStreaming(SettingsActivity.this);
+
+ });
+ final ImageButton set_allow_live_notifications_others = findViewById(R.id.set_allow_live_notifications_others);
+ set_allow_live_notifications_others.setOnClickListener(view -> {
+ Intent intent = new Intent(SettingsActivity.this, LiveNotificationSettingsAccountsActivity.class);
+ startActivity(intent);
+ });
+
+ //Live notification mode
+ final Spinner set_live_type = findViewById(R.id.set_live_type);
+ String[] labels = {getString(R.string.live_notif), getString(R.string.live_delayed), getString(R.string.no_live_notif)};
+ ArrayAdapter adapterLive = new ArrayAdapter<>(SettingsActivity.this,
+ android.R.layout.simple_spinner_dropdown_item, labels);
+
+ LinearLayout live_notif_per_account = findViewById(R.id.live_notif_per_account);
+ set_live_type.setAdapter(adapterLive);
+ if (Helper.liveNotifType(SettingsActivity.this) == Helper.NOTIF_NONE) {
+ live_notif_per_account.setVisibility(View.GONE);
+ }
+ TextView set_live_type_indication = findViewById(R.id.set_live_type_indication);
+ switch (Helper.liveNotifType(SettingsActivity.this)) {
+ case Helper.NOTIF_LIVE:
+ set_live_type_indication.setText(R.string.live_notif_indication);
+ break;
+ case Helper.NOTIF_DELAYED:
+ set_live_type_indication.setText(R.string.set_live_type_indication);
+ break;
+ case Helper.NOTIF_NONE:
+ set_live_type_indication.setText(R.string.no_live_indication);
+ break;
+ }
+ set_live_type.setSelection(Helper.liveNotifType(SettingsActivity.this));
+ liveNotificationCount = 0;
+ set_live_type.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
+ @Override
+ public void onItemSelected(AdapterView> parent, View view, int position, long id) {
+ if (liveNotificationCount > 0) {
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+
+ sendBroadcast(new Intent(SettingsActivity.this, StopLiveNotificationReceiver.class));
+ sendBroadcast(new Intent(SettingsActivity.this, StopDelayedNotificationReceiver.class));
+ ApplicationJob.cancelAllJob(NotificationsSyncJob.NOTIFICATION_REFRESH);
+ switch (position) {
+ case Helper.NOTIF_LIVE:
+ editor.putBoolean(Helper.SET_LIVE_NOTIFICATIONS, true);
+ editor.putBoolean(Helper.SET_DELAYED_NOTIFICATIONS, false);
+ live_notif_per_account.setVisibility(View.VISIBLE);
+ editor.commit();
+ set_live_type_indication.setText(R.string.live_notif_indication);
+ Handler handler = new Handler();
+ handler.postDelayed(() -> {
+ startStreaming(SettingsActivity.this);
+ }, 1000);
+ break;
+ case Helper.NOTIF_DELAYED:
+ editor.putBoolean(Helper.SET_LIVE_NOTIFICATIONS, false);
+ editor.putBoolean(Helper.SET_DELAYED_NOTIFICATIONS, true);
+ live_notif_per_account.setVisibility(View.VISIBLE);
+ set_live_type_indication.setText(R.string.set_live_type_indication);
+ editor.commit();
+ handler = new Handler();
+ handler.postDelayed(() -> {
+ startStreaming(SettingsActivity.this);
+ }, 1000);
+ break;
+ case Helper.NOTIF_NONE:
+ editor.putBoolean(Helper.SET_LIVE_NOTIFICATIONS, false);
+ editor.putBoolean(Helper.SET_DELAYED_NOTIFICATIONS, false);
+ editor.commit();
+ set_live_type_indication.setText(R.string.no_live_indication);
+ live_notif_per_account.setVisibility(View.GONE);
+ NotificationsSyncJob.schedule(false);
+ break;
+ }
+ } else {
+ liveNotificationCount++;
+ }
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView> parent) {
+
+ }
+ });
+
+ boolean clear_cache_exit = sharedpreferences.getBoolean(Helper.SET_CLEAR_CACHE_EXIT, false);
+ final SwitchCompat set_clear_cache_exit = findViewById(R.id.set_clear_cache_exit);
+ set_clear_cache_exit.setChecked(clear_cache_exit);
+ set_clear_cache_exit.setOnClickListener(v -> {
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putBoolean(Helper.SET_CLEAR_CACHE_EXIT, set_clear_cache_exit.isChecked());
+ editor.apply();
+ });
+
+
+ // NSFW Timeout
+ SeekBar nsfwTimeoutSeekBar = findViewById(R.id.set_nsfw_timeout);
+ final TextView set_nsfw_timeout_value = findViewById(R.id.set_nsfw_timeout_value);
+
+ nsfwTimeoutSeekBar.setMax(30);
+
+ int nsfwTimeout = sharedpreferences.getInt(Helper.SET_NSFW_TIMEOUT, 5);
+
+ nsfwTimeoutSeekBar.setProgress(nsfwTimeout);
+ set_nsfw_timeout_value.setText(String.valueOf(nsfwTimeout));
+
+ nsfwTimeoutSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+
+ set_nsfw_timeout_value.setText(String.valueOf(progress));
+
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putInt(Helper.SET_NSFW_TIMEOUT, progress);
+ editor.apply();
+ }
+ });
+
+
+ final ImageView set_toot_visibility = findViewById(R.id.set_toot_visibility);
+ if (theme == Helper.THEME_DARK) {
+ Helper.changeDrawableColor(getApplicationContext(), set_toot_visibility, R.color.dark_text);
+ } else {
+ Helper.changeDrawableColor(getApplicationContext(), set_toot_visibility, R.color.white);
+ }
+ //Only displayed for non locked accounts
+ String defaultVisibility = account.isLocked() ? "private" : "public";
+ String tootVisibility = sharedpreferences.getString(Helper.SET_TOOT_VISIBILITY + "@" + account.getAcct() + "@" + account.getInstance(), defaultVisibility);
+ switch (tootVisibility) {
+ case "public":
+ set_toot_visibility.setImageResource(R.drawable.ic_public);
+ break;
+ case "unlisted":
+ set_toot_visibility.setImageResource(R.drawable.ic_lock_open);
+ break;
+ case "private":
+ set_toot_visibility.setImageResource(R.drawable.ic_lock_outline);
+ break;
+ case "direct":
+ set_toot_visibility.setImageResource(R.drawable.ic_mail_outline);
+ break;
+ }
+
+ set_toot_visibility.setOnClickListener(v -> {
+ final SharedPreferences sharedpreferences1 = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
+ if (theme == Helper.THEME_DARK) {
+ style = R.style.DialogDark;
+ } else if (theme == Helper.THEME_BLACK) {
+ style = R.style.DialogBlack;
+ } else {
+ style = R.style.Dialog;
+ }
+ AlertDialog.Builder dialog = new AlertDialog.Builder(SettingsActivity.this, style);
+ dialog.setTitle(R.string.toot_visibility_tilte);
+ final String[] stringArray = getResources().getStringArray(R.array.toot_visibility);
+ final ArrayAdapter arrayAdapter = new ArrayAdapter<>(getApplicationContext(), android.R.layout.simple_list_item_1, stringArray);
+ dialog.setNegativeButton(R.string.cancel, (dialog12, position) -> dialog12.dismiss());
+
+ dialog.setAdapter(arrayAdapter, (dialog1, position) -> {
+ String visibility = "public";
+
+ switch (position) {
+ case 0:
+ visibility = "public";
+ set_toot_visibility.setImageResource(R.drawable.ic_public);
+ break;
+ case 1:
+ visibility = "unlisted";
+ set_toot_visibility.setImageResource(R.drawable.ic_lock_open);
+ break;
+ case 2:
+ visibility = "private";
+ set_toot_visibility.setImageResource(R.drawable.ic_lock_outline);
+ break;
+ case 3:
+ visibility = "direct";
+ set_toot_visibility.setImageResource(R.drawable.ic_mail_outline);
+ break;
+ }
+ SharedPreferences.Editor editor = sharedpreferences1.edit();
+ editor.putString(Helper.SET_TOOT_VISIBILITY + "@" + account.getAcct() + "@" + account.getInstance(), visibility);
+ editor.apply();
+ Toasty.info(getApplicationContext(), getString(R.string.toast_visibility_changed, "@" + account.getAcct() + "@" + account.getInstance()), Toast.LENGTH_SHORT).show();
+
+ dialog1.dismiss();
+ });
+ dialog.show();
+ });
+
+ int split_size_val = sharedpreferences.getInt(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS_SIZE + userId + instance, Helper.SPLIT_TOOT_SIZE);
+
+ LinearLayout set_split_container = findViewById(R.id.set_split_container);
+ //split size
+ SeekBar split_size = findViewById(R.id.set_split_size);
+ final EditText split_text = findViewById(R.id.set_split_text);
+
+ split_size.setProgress(0);
+ split_text.setText(String.valueOf(split_size_val));
+ split_text.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { }
+
+ @Override
+ public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+ if (charSequence != null && charSequence.length() > 0) {
+ int newValue = Integer.parseInt(charSequence.toString());
+ if (newValue > 0) {
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putInt(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS_SIZE + userId + instance, newValue);
+ editor.apply();
+ }
+ }
+ }
+
+ @Override
+ public void afterTextChanged(Editable editable) {
+
+ }
+ });
+ split_size.setMax(5);
+ split_size.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ int newProgress = (progress + 1) * Helper.SPLIT_TOOT_SIZE;
+ split_text.setText(String.valueOf(newProgress));
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putInt(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS_SIZE + userId + instance, newProgress);
+ editor.apply();
+ }
+ });
+
+ boolean split_toot = sharedpreferences.getBoolean(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS + userId + instance, false);
+ if (!split_toot) {
+ set_split_container.setVisibility(View.GONE);
+ }
+ final SwitchCompat set_split_toot = findViewById(R.id.set_automatically_split_toot);
+ set_split_toot.setChecked(split_toot);
+ set_split_toot.setOnClickListener(v -> {
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putBoolean(Helper.SET_AUTOMATICALLY_SPLIT_TOOTS + userId + instance, set_split_toot.isChecked());
+ editor.apply();
+ if (set_split_toot.isChecked()) {
+ set_split_container.setVisibility(View.VISIBLE);
+ } else {
+ set_split_container.setVisibility(View.GONE);
+ }
+ });
+
+ }
+
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == android.R.id.home) {
+ finish();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+}
diff --git a/app/src/lite/java/app/fedilab/android/activities/TootActivity.java b/app/src/lite/java/app/fedilab/android/activities/TootActivity.java
new file mode 100644
index 000000000..d65c1e2da
--- /dev/null
+++ b/app/src/lite/java/app/fedilab/android/activities/TootActivity.java
@@ -0,0 +1,34 @@
+package app.fedilab.android.activities;
+
+import android.net.Uri;
+
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+public class TootActivity extends BaseTootActivity {
+ @Override
+ protected boolean actionTranslateClick() {
+ return true;
+ }
+
+ @Override
+ protected void launchPhotoEditor(Uri uri) {
+ }
+
+ @Override
+ protected void displayEmojiPopup() {
+ }
+
+
+}
diff --git a/app/src/lite/java/app/fedilab/android/drawers/NotificationsListAdapter.java b/app/src/lite/java/app/fedilab/android/drawers/NotificationsListAdapter.java
new file mode 100644
index 000000000..45170f1af
--- /dev/null
+++ b/app/src/lite/java/app/fedilab/android/drawers/NotificationsListAdapter.java
@@ -0,0 +1,31 @@
+package app.fedilab.android.drawers;
+
+import java.util.List;
+
+import app.fedilab.android.client.Entities.Notification;
+import app.fedilab.android.client.Entities.Status;
+
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+public class NotificationsListAdapter extends BaseNotificationsListAdapter {
+
+ public NotificationsListAdapter(boolean isOnWifi, int behaviorWithAttachments, List notifications) {
+ super(isOnWifi, behaviorWithAttachments, notifications);
+ }
+
+ public void notificationStatusChart(Status status) {
+ }
+
+}
diff --git a/app/src/lite/java/app/fedilab/android/drawers/StatusListAdapter.java b/app/src/lite/java/app/fedilab/android/drawers/StatusListAdapter.java
new file mode 100644
index 000000000..eb07583f4
--- /dev/null
+++ b/app/src/lite/java/app/fedilab/android/drawers/StatusListAdapter.java
@@ -0,0 +1,35 @@
+package app.fedilab.android.drawers;
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+
+import android.app.Activity;
+import android.view.WindowManager;
+
+import app.fedilab.android.client.Entities.Status;
+import app.fedilab.android.client.Entities.StatusDrawerParams;
+
+public class StatusListAdapter extends BaseStatusListAdapter {
+ public StatusListAdapter(StatusDrawerParams statusDrawerParams) {
+ super(statusDrawerParams);
+ }
+
+ protected void statusAddReactionClick(Status status, ViewHolder holder) {
+ ((Activity) context).getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
+ }
+
+ protected void notificationCharts(Status status) {
+
+ }
+}
diff --git a/app/src/lite/java/app/fedilab/android/helper/CustomTextView.java b/app/src/lite/java/app/fedilab/android/helper/CustomTextView.java
new file mode 100644
index 000000000..f8382e4a8
--- /dev/null
+++ b/app/src/lite/java/app/fedilab/android/helper/CustomTextView.java
@@ -0,0 +1,37 @@
+package app.fedilab.android.helper;
+
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+
+import android.content.Context;
+import android.util.AttributeSet;
+
+import androidx.appcompat.widget.AppCompatTextView;
+
+public class CustomTextView extends AppCompatTextView {
+
+
+ public CustomTextView(Context context) {
+ super(context);
+ }
+
+ public CustomTextView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public CustomTextView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+}
diff --git a/app/src/lite/java/app/fedilab/android/helper/Helper.java b/app/src/lite/java/app/fedilab/android/helper/Helper.java
new file mode 100644
index 000000000..76f09f2b2
--- /dev/null
+++ b/app/src/lite/java/app/fedilab/android/helper/Helper.java
@@ -0,0 +1,18 @@
+package app.fedilab.android.helper;
+
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+public class Helper extends BaseHelper {
+}
diff --git a/app/src/lite/java/app/fedilab/android/helper/MastalabAutoCompleteTextView.java b/app/src/lite/java/app/fedilab/android/helper/MastalabAutoCompleteTextView.java
new file mode 100644
index 000000000..c629e56af
--- /dev/null
+++ b/app/src/lite/java/app/fedilab/android/helper/MastalabAutoCompleteTextView.java
@@ -0,0 +1,104 @@
+package app.fedilab.android.helper;
+
+import android.content.Context;
+import android.os.Build;
+import android.os.Bundle;
+import android.util.AttributeSet;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputConnection;
+
+import androidx.core.view.inputmethod.EditorInfoCompat;
+import androidx.core.view.inputmethod.InputConnectionCompat;
+import androidx.core.view.inputmethod.InputContentInfoCompat;
+
+
+public class MastalabAutoCompleteTextView extends androidx.appcompat.widget.AppCompatAutoCompleteTextView {
+
+
+ private String[] imgTypeString;
+ private KeyBoardInputCallbackListener keyBoardInputCallbackListener;
+ final InputConnectionCompat.OnCommitContentListener callback =
+ new InputConnectionCompat.OnCommitContentListener() {
+ @Override
+ public boolean onCommitContent(InputContentInfoCompat inputContentInfo,
+ int flags, Bundle opts) {
+
+ // read and display inputContentInfo asynchronously
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1 && (flags &
+ InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0) {
+ try {
+ inputContentInfo.requestPermission();
+ } catch (Exception e) {
+ return false; // return false if failed
+ }
+ }
+ boolean supported = false;
+ for (final String mimeType : imgTypeString) {
+ if (inputContentInfo.getDescription().hasMimeType(mimeType)) {
+ supported = true;
+ break;
+ }
+ }
+ if (!supported) {
+ return false;
+ }
+
+ if (keyBoardInputCallbackListener != null) {
+ keyBoardInputCallbackListener.onCommitContent(inputContentInfo, flags, opts);
+ }
+ return true; // return true if succeeded
+ }
+ };
+
+
+ public MastalabAutoCompleteTextView(Context context) {
+ super(context);
+ initView();
+ }
+
+ public MastalabAutoCompleteTextView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ setText(getText());
+ initView();
+ }
+
+ public MastalabAutoCompleteTextView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ initView();
+ }
+
+ @Override
+ public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
+ final InputConnection ic = super.onCreateInputConnection(outAttrs);
+ EditorInfoCompat.setContentMimeTypes(outAttrs,
+ imgTypeString);
+ return InputConnectionCompat.createWrapper(ic, outAttrs, callback);
+ }
+
+ private void initView() {
+ imgTypeString = new String[]{"image/png",
+ "image/gif",
+ "image/jpeg",
+ "image/webp"};
+ }
+
+ public void setKeyBoardInputCallbackListener(KeyBoardInputCallbackListener keyBoardInputCallbackListener) {
+ this.keyBoardInputCallbackListener = keyBoardInputCallbackListener;
+ }
+
+ @SuppressWarnings("unused")
+ public String[] getImgTypeString() {
+ return imgTypeString;
+ }
+
+ @SuppressWarnings("unused")
+ public void setImgTypeString(String[] imgTypeString) {
+ this.imgTypeString = imgTypeString;
+ }
+
+
+ public interface KeyBoardInputCallbackListener {
+ void onCommitContent(InputContentInfoCompat inputContentInfo,
+ int flags, Bundle opts);
+ }
+}
diff --git a/app/src/lite/java/app/fedilab/android/jobs/BackupNotificationsSyncJob.java b/app/src/lite/java/app/fedilab/android/jobs/BackupNotificationsSyncJob.java
new file mode 100644
index 000000000..219b1cecb
--- /dev/null
+++ b/app/src/lite/java/app/fedilab/android/jobs/BackupNotificationsSyncJob.java
@@ -0,0 +1,18 @@
+package app.fedilab.android.jobs;
+
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+public class BackupNotificationsSyncJob extends BaseBackupNotificationsSyncJob {
+}
diff --git a/app/src/lite/java/app/fedilab/android/jobs/BackupStatusesSyncJob.java b/app/src/lite/java/app/fedilab/android/jobs/BackupStatusesSyncJob.java
new file mode 100644
index 000000000..009ffe315
--- /dev/null
+++ b/app/src/lite/java/app/fedilab/android/jobs/BackupStatusesSyncJob.java
@@ -0,0 +1,18 @@
+package app.fedilab.android.jobs;
+
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+public class BackupStatusesSyncJob extends BaseBackupStatusesSyncJob {
+}
diff --git a/app/src/lite/java/app/fedilab/android/jobs/NotificationsSyncJob.java b/app/src/lite/java/app/fedilab/android/jobs/NotificationsSyncJob.java
new file mode 100644
index 000000000..0ca21e87b
--- /dev/null
+++ b/app/src/lite/java/app/fedilab/android/jobs/NotificationsSyncJob.java
@@ -0,0 +1,18 @@
+package app.fedilab.android.jobs;
+
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+public class NotificationsSyncJob extends BaseNotificationsSyncJob {
+}
diff --git a/app/src/lite/java/app/fedilab/android/jobs/ScheduledBoostsSyncJob.java b/app/src/lite/java/app/fedilab/android/jobs/ScheduledBoostsSyncJob.java
new file mode 100644
index 000000000..f556b1bc7
--- /dev/null
+++ b/app/src/lite/java/app/fedilab/android/jobs/ScheduledBoostsSyncJob.java
@@ -0,0 +1,18 @@
+package app.fedilab.android.jobs;
+
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+public class ScheduledBoostsSyncJob extends BaseScheduledBoostsSyncJob {
+}
diff --git a/app/src/lite/java/app/fedilab/android/jobs/ScheduledTootsSyncJob.java b/app/src/lite/java/app/fedilab/android/jobs/ScheduledTootsSyncJob.java
new file mode 100644
index 000000000..144449233
--- /dev/null
+++ b/app/src/lite/java/app/fedilab/android/jobs/ScheduledTootsSyncJob.java
@@ -0,0 +1,18 @@
+package app.fedilab.android.jobs;
+
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+public class ScheduledTootsSyncJob extends BaseScheduledTootsSyncJob {
+}
diff --git a/app/src/lite/java/app/fedilab/android/services/LiveNotificationService.java b/app/src/lite/java/app/fedilab/android/services/LiveNotificationService.java
new file mode 100644
index 000000000..4fc524195
--- /dev/null
+++ b/app/src/lite/java/app/fedilab/android/services/LiveNotificationService.java
@@ -0,0 +1,18 @@
+package app.fedilab.android.services;
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+
+public class LiveNotificationService extends BaseLiveNotificationService {
+}
diff --git a/app/src/lite/java/app/fedilab/android/services/StreamingFederatedTimelineService.java b/app/src/lite/java/app/fedilab/android/services/StreamingFederatedTimelineService.java
new file mode 100644
index 000000000..be3d5fc82
--- /dev/null
+++ b/app/src/lite/java/app/fedilab/android/services/StreamingFederatedTimelineService.java
@@ -0,0 +1,18 @@
+package app.fedilab.android.services;
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+
+public class StreamingFederatedTimelineService extends BaseStreamingFederatedTimelineService {
+}
diff --git a/app/src/lite/java/app/fedilab/android/services/StreamingHomeTimelineService.java b/app/src/lite/java/app/fedilab/android/services/StreamingHomeTimelineService.java
new file mode 100644
index 000000000..66b415edd
--- /dev/null
+++ b/app/src/lite/java/app/fedilab/android/services/StreamingHomeTimelineService.java
@@ -0,0 +1,18 @@
+package app.fedilab.android.services;
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+
+public class StreamingHomeTimelineService extends BaseStreamingHomeTimelineService {
+}
diff --git a/app/src/lite/java/app/fedilab/android/services/StreamingLocalTimelineService.java b/app/src/lite/java/app/fedilab/android/services/StreamingLocalTimelineService.java
new file mode 100644
index 000000000..05c1c6170
--- /dev/null
+++ b/app/src/lite/java/app/fedilab/android/services/StreamingLocalTimelineService.java
@@ -0,0 +1,18 @@
+package app.fedilab.android.services;
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+
+public class StreamingLocalTimelineService extends BaseStreamingLocalTimelineService {
+}
diff --git a/app/src/lite/res/layout/activity_settings.xml b/app/src/lite/res/layout/activity_settings.xml
new file mode 100644
index 000000000..8eecbfbad
--- /dev/null
+++ b/app/src/lite/res/layout/activity_settings.xml
@@ -0,0 +1,619 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/lite/res/xml/file_paths.xml b/app/src/lite/res/xml/file_paths.xml
new file mode 100644
index 000000000..aeec230da
--- /dev/null
+++ b/app/src/lite/res/xml/file_paths.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index c3f41fc6d..e370273dc 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -111,11 +111,12 @@
-
+
@@ -164,20 +165,7 @@
-
-
-
-
-
-
-
+
@@ -285,7 +270,6 @@
@@ -301,158 +285,105 @@
+ />
+ />
-
-
-
+ />
-
-
-
-
@@ -460,19 +391,16 @@
android:name="app.fedilab.android.activities.PixelfedComposeActivity"
android:configChanges="orientation|screenSize"
android:fitsSystemWindows="true"
- android:label="@string/app_name"
android:launchMode="singleTop"
android:theme="@style/AppThemeDark"
android:windowSoftInputMode="stateAlwaysHidden" />
diff --git a/app/src/main/assets/changelogs/377.txt b/app/src/main/assets/changelogs/377.txt
new file mode 100644
index 000000000..fbfedf7a4
--- /dev/null
+++ b/app/src/main/assets/changelogs/377.txt
@@ -0,0 +1,9 @@
+Added:
+- Watermarks for pictures (default: disabled)
+- Blur sensitive media for Pixelfed
+- Put messages into drafts when replying to a deleted message
+- Allow to schedule with another account
+
+Fixed:
+- Quick replies lose text when doing another action
+- Fix refresh token (Peertube/Pixelfed)
\ No newline at end of file
diff --git a/app/src/main/assets/changelogs/378.txt b/app/src/main/assets/changelogs/378.txt
new file mode 100644
index 000000000..fbfedf7a4
--- /dev/null
+++ b/app/src/main/assets/changelogs/378.txt
@@ -0,0 +1,9 @@
+Added:
+- Watermarks for pictures (default: disabled)
+- Blur sensitive media for Pixelfed
+- Put messages into drafts when replying to a deleted message
+- Allow to schedule with another account
+
+Fixed:
+- Quick replies lose text when doing another action
+- Fix refresh token (Peertube/Pixelfed)
\ No newline at end of file
diff --git a/app/src/main/assets/changelogs/379.txt b/app/src/main/assets/changelogs/379.txt
new file mode 100644
index 000000000..aaae0921f
--- /dev/null
+++ b/app/src/main/assets/changelogs/379.txt
@@ -0,0 +1,11 @@
+Added:
+- Offset for replies in threads with a new decoration to make them easier to read
+- Fix translation issue (use https://translate.fedilab.app)
+- Watermarks for pictures (default: disabled)
+- Blur sensitive media for Pixelfed
+- Put messages into drafts when replying to a deleted message
+- Allow to schedule with another account
+
+Fixed:
+- Quick replies lose text when doing another action
+- Fix refresh token (Peertube/Pixelfed)
\ No newline at end of file
diff --git a/app/src/main/ic_launcher_lite-playstore.png b/app/src/main/ic_launcher_lite-playstore.png
new file mode 100644
index 000000000..86fccc4c4
Binary files /dev/null and b/app/src/main/ic_launcher_lite-playstore.png differ
diff --git a/app/src/main/java/app/fedilab/android/activities/AboutActivity.java b/app/src/main/java/app/fedilab/android/activities/AboutActivity.java
index 1d56b6ad7..1d21538f0 100644
--- a/app/src/main/java/app/fedilab/android/activities/AboutActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/AboutActivity.java
@@ -20,7 +20,6 @@ import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
-import android.os.AsyncTask;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.style.UnderlineSpan;
@@ -64,9 +63,9 @@ import es.dmoral.toasty.Toasty;
public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccountInterface, OnRetrieveRelationshipInterface {
- private List developers = new ArrayList<>();
- private List contributors = new ArrayList<>();
- private List uxuidesigners = new ArrayList<>();
+ private final List developers = new ArrayList<>();
+ private final List contributors = new ArrayList<>();
+ private final List uxuidesigners = new ArrayList<>();
private AccountSearchDevAdapter accountSearchWebAdapterDeveloper;
private AccountSearchDevAdapter accountSearchWebAdapterContributors;
@@ -208,17 +207,17 @@ public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccou
lv_ux.setAdapter(accountSearchWebAdapterUxUiDesigners);
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
- new RetrieveRemoteDataAsyncTask(AboutActivity.this, "fedilab", "toot.fedilab.app", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- new RetrieveRemoteDataAsyncTask(AboutActivity.this, "mmarif", "mastodon.social", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- new RetrieveRemoteDataAsyncTask(AboutActivity.this, "PhotonQyv", "mastodon.xyz", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- new RetrieveRemoteDataAsyncTask(AboutActivity.this, "angrytux", "social.tchncs.de", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- new RetrieveRemoteDataAsyncTask(AboutActivity.this, "guzzisti", "mastodon.social", AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveRemoteDataAsyncTask(AboutActivity.this, "apps", "toot.fedilab.app", AboutActivity.this);
+ new RetrieveRemoteDataAsyncTask(AboutActivity.this, "mmarif", "mastodon.social", AboutActivity.this);
+ new RetrieveRemoteDataAsyncTask(AboutActivity.this, "PhotonQyv", "mastodon.xyz", AboutActivity.this);
+ new RetrieveRemoteDataAsyncTask(AboutActivity.this, "angrytux", "social.tchncs.de", AboutActivity.this);
+ new RetrieveRemoteDataAsyncTask(AboutActivity.this, "guzzisti", "mastodon.social", AboutActivity.this);
} else {
- SpannableString name = new SpannableString("@fedilab@toot.fedilab.app");
+ SpannableString name = new SpannableString("@apps@toot.fedilab.app");
name.setSpan(new UnderlineSpan(), 0, name.length(), 0);
txt_developers.setText(name);
txt_developers.setVisibility(View.VISIBLE);
- txt_developers.setOnClickListener(v -> Helper.openBrowser(AboutActivity.this, "https://toot.fedilab.app/@fedilab"));
+ txt_developers.setOnClickListener(v -> Helper.openBrowser(AboutActivity.this, "https://toot.fedilab.app/@apps"));
name = new SpannableString("@mmarif@mastodon.social");
name.setSpan(new UnderlineSpan(), 0, name.length(), 0);
txt_ux.setText(name);
@@ -260,7 +259,7 @@ public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccou
account = accounts.get(0);
account.setFollowing(true);
switch (account.getUsername()) {
- case "fedilab":
+ case "apps":
developers.add(account);
accountSearchWebAdapterDeveloper.notifyDataSetChanged();
break;
@@ -273,7 +272,7 @@ public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccou
accountSearchWebAdapterContributors.notifyDataSetChanged();
break;
}
- new RetrieveRelationshipAsyncTask(AboutActivity.this, account.getId(), AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveRelationshipAsyncTask(AboutActivity.this, account.getId(), AboutActivity.this);
}
}
@@ -283,17 +282,17 @@ public class AboutActivity extends BaseActivity implements OnRetrieveRemoteAccou
super.onResume();
if (developers != null) {
for (Account account : developers) {
- new RetrieveRelationshipAsyncTask(AboutActivity.this, account.getId(), AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveRelationshipAsyncTask(AboutActivity.this, account.getId(), AboutActivity.this);
}
}
if (contributors != null) {
for (Account account : contributors) {
- new RetrieveRelationshipAsyncTask(AboutActivity.this, account.getId(), AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveRelationshipAsyncTask(AboutActivity.this, account.getId(), AboutActivity.this);
}
}
if (uxuidesigners != null) {
for (Account account : uxuidesigners) {
- new RetrieveRelationshipAsyncTask(AboutActivity.this, account.getId(), AboutActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveRelationshipAsyncTask(AboutActivity.this, account.getId(), AboutActivity.this);
}
}
}
diff --git a/app/src/main/java/app/fedilab/android/activities/AccountReportActivity.java b/app/src/main/java/app/fedilab/android/activities/AccountReportActivity.java
index 9fb9e16c4..7c4978714 100644
--- a/app/src/main/java/app/fedilab/android/activities/AccountReportActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/AccountReportActivity.java
@@ -19,7 +19,6 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.PorterDuff;
import android.graphics.drawable.ColorDrawable;
-import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@@ -139,7 +138,7 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
assign.setVisibility(View.GONE);
status.setVisibility(View.GONE);
if (account_id != null) {
- new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.GET_ONE_ACCOUNT, account_id, null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.GET_ONE_ACCOUNT, account_id, null, AccountReportActivity.this);
return;
}
if (report != null) {
@@ -157,7 +156,7 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
Group statuses_group = findViewById(R.id.statuses_group);
statuses_group.setVisibility(View.VISIBLE);
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
- new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.GET_ONE_ACCOUNT, report.getTarget_account().getUsername(), null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.GET_ONE_ACCOUNT, report.getTarget_account().getUsername(), null, AccountReportActivity.this);
}
}
@@ -227,13 +226,13 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
reject.setOnClickListener(view -> {
AdminAction adminAction = new AdminAction();
adminAction.setType(REJECT);
- new PostAdminActionAsyncTask(AccountReportActivity.this, REJECT, account_id, adminAction, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostAdminActionAsyncTask(AccountReportActivity.this, REJECT, account_id, adminAction, AccountReportActivity.this);
});
allow.setOnClickListener(view -> {
AdminAction adminAction = new AdminAction();
adminAction.setType(APPROVE);
- new PostAdminActionAsyncTask(AccountReportActivity.this, APPROVE, account_id, adminAction, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostAdminActionAsyncTask(AccountReportActivity.this, APPROVE, account_id, adminAction, AccountReportActivity.this);
});
warn.setOnClickListener(view -> {
@@ -241,7 +240,7 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
adminAction.setType(NONE);
adminAction.setSend_email_notification(email_user.isChecked());
adminAction.setText(comment.getText().toString().trim());
- new PostAdminActionAsyncTask(AccountReportActivity.this, NONE, account_id, adminAction, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostAdminActionAsyncTask(AccountReportActivity.this, NONE, account_id, adminAction, AccountReportActivity.this);
});
@@ -256,9 +255,9 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
adminAction.setType(SILENCE);
adminAction.setSend_email_notification(email_user.isChecked());
adminAction.setText(comment.getText().toString().trim());
- new PostAdminActionAsyncTask(AccountReportActivity.this, SILENCE, account_id, adminAction, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostAdminActionAsyncTask(AccountReportActivity.this, SILENCE, account_id, adminAction, AccountReportActivity.this);
} else {
- new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.UNSILENCE, account_id, null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.UNSILENCE, account_id, null, AccountReportActivity.this);
}
});
@@ -273,9 +272,9 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
adminAction.setType(DISABLE);
adminAction.setSend_email_notification(email_user.isChecked());
adminAction.setText(comment.getText().toString().trim());
- new PostAdminActionAsyncTask(AccountReportActivity.this, DISABLE, account_id, adminAction, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostAdminActionAsyncTask(AccountReportActivity.this, DISABLE, account_id, adminAction, AccountReportActivity.this);
} else {
- new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.ENABLE, account_id, null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.ENABLE, account_id, null, AccountReportActivity.this);
}
});
if (!accountAdmin.isSuspended()) {
@@ -289,9 +288,9 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
adminAction.setType(SUSPEND);
adminAction.setSend_email_notification(email_user.isChecked());
adminAction.setText(comment.getText().toString().trim());
- new PostAdminActionAsyncTask(AccountReportActivity.this, SUSPEND, account_id, adminAction, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostAdminActionAsyncTask(AccountReportActivity.this, SUSPEND, account_id, adminAction, AccountReportActivity.this);
} else {
- new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.UNSUSPEND, account_id, null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.UNSUSPEND, account_id, null, AccountReportActivity.this);
}
});
@@ -423,9 +422,9 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
}
assign.setOnClickListener(view -> {
if (report.getAssigned_account() == null) {
- new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.ASSIGN_TO_SELF, report.getId(), null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.ASSIGN_TO_SELF, report.getId(), null, AccountReportActivity.this);
} else {
- new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.UNASSIGN, report.getId(), null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.UNASSIGN, report.getId(), null, AccountReportActivity.this);
}
});
if (report.isAction_taken()) {
@@ -435,9 +434,9 @@ public class AccountReportActivity extends BaseActivity implements OnAdminAction
}
status.setOnClickListener(view -> {
if (report.isAction_taken()) {
- new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.REOPEN, report.getId(), null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.REOPEN, report.getId(), null, AccountReportActivity.this);
} else {
- new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.RESOLVE, report.getId(), null, AccountReportActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostAdminActionAsyncTask(AccountReportActivity.this, API.adminAction.RESOLVE, report.getId(), null, AccountReportActivity.this);
}
});
diff --git a/app/src/main/java/app/fedilab/android/activities/BaseActivity.java b/app/src/main/java/app/fedilab/android/activities/AllBaseActivity.java
similarity index 91%
rename from app/src/main/java/app/fedilab/android/activities/BaseActivity.java
rename to app/src/main/java/app/fedilab/android/activities/AllBaseActivity.java
index a1a7fef80..b40dffafa 100644
--- a/app/src/main/java/app/fedilab/android/activities/BaseActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/AllBaseActivity.java
@@ -19,14 +19,11 @@ import androidx.core.content.ContextCompat;
import com.franmontiel.localechanger.LocaleChanger;
import com.google.android.material.snackbar.Snackbar;
import com.jaredrummler.cyanea.app.CyaneaAppCompatActivity;
-import com.vanniktech.emoji.EmojiManager;
-import com.vanniktech.emoji.one.EmojiOneProvider;
import org.jetbrains.annotations.NotNull;
import java.util.Timer;
-import app.fedilab.android.helper.Helper;
import es.dmoral.toasty.Toasty;
/**
@@ -35,17 +32,13 @@ import es.dmoral.toasty.Toasty;
*/
@SuppressLint("Registered")
-public class BaseActivity extends CyaneaAppCompatActivity {
+public class AllBaseActivity extends CyaneaAppCompatActivity {
public static final int READ_WRITE_STORAGE = 52;
public static Timer timer;
public static boolean canShowActionMode = true;
- static {
- Helper.installProvider();
- EmojiManager.install(new EmojiOneProvider());
- }
private ProgressDialog mProgressDialog;
@@ -140,7 +133,7 @@ public class BaseActivity extends CyaneaAppCompatActivity {
if (view != null) {
Snackbar.make(view, message, Snackbar.LENGTH_SHORT).show();
} else {
- Toasty.info(BaseActivity.this, message, Toast.LENGTH_SHORT).show();
+ Toasty.info(AllBaseActivity.this, message, Toast.LENGTH_SHORT).show();
}
}
diff --git a/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java
index 06e9fcfb4..bc6c2cfc7 100644
--- a/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/BaseMainActivity.java
@@ -149,8 +149,7 @@ import app.fedilab.android.interfaces.OnRetrieveRemoteAccountInterface;
import app.fedilab.android.interfaces.OnSyncTimelineInterface;
import app.fedilab.android.interfaces.OnUpdateAccountInfoInterface;
import app.fedilab.android.services.BackupStatusService;
-import app.fedilab.android.services.LiveNotificationDelayedService;
-import app.fedilab.android.services.LiveNotificationService;
+import app.fedilab.android.services.DownloadTrackingDBScriptsService;
import app.fedilab.android.sqlite.AccountDAO;
import app.fedilab.android.sqlite.Sqlite;
import app.fedilab.android.sqlite.TempMuteDAO;
@@ -160,6 +159,7 @@ import es.dmoral.toasty.Toasty;
import static app.fedilab.android.activities.WebviewActivity.trackingDomains;
import static app.fedilab.android.asynctasks.ManageFiltersAsyncTask.action.GET_ALL_FILTER;
+import static app.fedilab.android.helper.BaseHelper.startStreaming;
import static app.fedilab.android.helper.Helper.changeDrawableColor;
@@ -183,9 +183,9 @@ public abstract class BaseMainActivity extends BaseActivity
public static iconLauncher mLauncher = iconLauncher.BUBBLES;
private static boolean notificationChecked = false;
private final int PICK_IMPORT = 5556;
+ private final HashMap tagTile = new HashMap<>();
+ private final HashMap tagItem = new HashMap<>();
private FloatingActionButton toot, delete_all, add_new;
- private HashMap tagTile = new HashMap<>();
- private HashMap tagItem = new HashMap<>();
private TextView toolbarTitle;
private SearchView toolbar_search;
private View headerLayout;
@@ -312,10 +312,11 @@ public abstract class BaseMainActivity extends BaseActivity
//This task will allow to instance a static PeertubeInformation class
if (social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
try {
- new RetrievePeertubeInformationAsyncTask(BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrievePeertubeInformationAsyncTask(BaseMainActivity.this);
} catch (Exception ignored) {
}
}
+
//Here, the user is authenticated
appBar = findViewById(R.id.appBar);
Toolbar toolbar = findViewById(R.id.toolbar);
@@ -419,7 +420,7 @@ public abstract class BaseMainActivity extends BaseActivity
main_app_container = findViewById(R.id.main_app_container);
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA || social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
- new SyncTimelinesAsyncTask(BaseMainActivity.this, 0, Helper.canFetchList(BaseMainActivity.this, account), BaseMainActivity.this).execute();
+ new SyncTimelinesAsyncTask(BaseMainActivity.this, 0, Helper.canFetchList(BaseMainActivity.this, account), BaseMainActivity.this);
} else if (social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
TabLayout.Tab pTabsub = tabLayout.newTab();
@@ -638,9 +639,10 @@ public abstract class BaseMainActivity extends BaseActivity
} else {
style = R.style.Dialog;
}
-
-
- Helper.startStreaming(BaseMainActivity.this);
+ boolean popupShown = sharedpreferences.getBoolean(Helper.SET_POPUP_PUSH, false);
+ if (popupShown) {
+ Helper.startStreaming(BaseMainActivity.this);
+ }
if (hidde_menu != null)
LocalBroadcastManager.getInstance(BaseMainActivity.this).unregisterReceiver(hidde_menu);
@@ -707,7 +709,7 @@ public abstract class BaseMainActivity extends BaseActivity
int position = 0;
if (tabLayout != null)
position = tabLayout.getSelectedTabPosition();
- new SyncTimelinesAsyncTask(BaseMainActivity.this, position, true, BaseMainActivity.this).execute();
+ new SyncTimelinesAsyncTask(BaseMainActivity.this, position, true, BaseMainActivity.this);
}
};
LocalBroadcastManager.getInstance(BaseMainActivity.this).registerReceiver(hidde_menu, new IntentFilter(Helper.RECEIVE_HIDE_ITEM));
@@ -930,6 +932,9 @@ public abstract class BaseMainActivity extends BaseActivity
if (action_size != null)
action_size.setVisible(false);
}
+ if (BuildConfig.lite) {
+ popup.getMenu().findItem(R.id.action_send_invitation).setVisible(false);
+ }
popup.setOnMenuItemClickListener(item -> {
switch (item.getItemId()) {
@@ -969,7 +974,7 @@ public abstract class BaseMainActivity extends BaseActivity
}
return true;
case R.id.action_cache:
- new Helper.CacheTask(BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new Helper.CacheTask(BaseMainActivity.this);
return true;
case R.id.action_size:
final SharedPreferences sharedpreferences1 = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
@@ -1106,11 +1111,7 @@ public abstract class BaseMainActivity extends BaseActivity
Helper.updateHeaderAccountInfo(activity, account, headerLayout);
//Locked account can see follow request
if (MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.GNU && MainActivity.social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
- if (account.isLocked()) {
- navigationView.getMenu().findItem(R.id.nav_follow_request).setVisible(true);
- } else {
- navigationView.getMenu().findItem(R.id.nav_follow_request).setVisible(false);
- }
+ navigationView.getMenu().findItem(R.id.nav_follow_request).setVisible(account.isLocked());
}
if (!BuildConfig.DONATIONS) {
@@ -1162,7 +1163,7 @@ public abstract class BaseMainActivity extends BaseActivity
});
// Asked once for notification opt-in
- boolean popupShown = sharedpreferences.getBoolean(Helper.SET_POPUP_PUSH, false);
+
if (!popupShown && (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA)) {
if (theme == Helper.THEME_DARK) {
style = R.style.DialogDark;
@@ -1196,7 +1197,7 @@ public abstract class BaseMainActivity extends BaseActivity
set_live_type_indication.setText(R.string.no_live_indication);
break;
}
- set_live_type.setSelection(Helper.liveNotifType(BaseMainActivity.this));
+ set_live_type.setSelection(Helper.liveNotifType(BaseMainActivity.this), false);
set_live_type.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView> parent, View view, int position, long id) {
@@ -1206,15 +1207,13 @@ public abstract class BaseMainActivity extends BaseActivity
editor.putBoolean(Helper.SET_LIVE_NOTIFICATIONS, true);
editor.putBoolean(Helper.SET_DELAYED_NOTIFICATIONS, false);
editor.apply();
- Intent streamingIntent = new Intent(BaseMainActivity.this, LiveNotificationService.class);
- startService(streamingIntent);
+ startStreaming(BaseMainActivity.this);
break;
case Helper.NOTIF_DELAYED:
editor.putBoolean(Helper.SET_LIVE_NOTIFICATIONS, false);
editor.putBoolean(Helper.SET_DELAYED_NOTIFICATIONS, true);
- streamingIntent = new Intent(BaseMainActivity.this, LiveNotificationDelayedService.class);
- startService(streamingIntent);
editor.apply();
+ startStreaming(BaseMainActivity.this);
break;
case Helper.NOTIF_NONE:
editor.putBoolean(Helper.SET_LIVE_NOTIFICATIONS, false);
@@ -1245,7 +1244,7 @@ public abstract class BaseMainActivity extends BaseActivity
dialogBuilderOptin.setPositiveButton(R.string.validate, (dialog, id) -> {
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putBoolean(Helper.SET_POPUP_PUSH, true);
- editor.apply();
+ editor.commit();
});
try {
@@ -1260,7 +1259,7 @@ public abstract class BaseMainActivity extends BaseActivity
int versionCode = BuildConfig.VERSION_CODE;
if (lastReleaseNoteRead != versionCode) { //Need to push release notes
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
- new RetrieveRemoteDataAsyncTask(BaseMainActivity.this, BaseMainActivity.this).execute();
+ new RetrieveRemoteDataAsyncTask(BaseMainActivity.this, BaseMainActivity.this);
}
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(getAssets().open("changelogs/" + versionCode + ".txt")))) {
@@ -1316,11 +1315,12 @@ public abstract class BaseMainActivity extends BaseActivity
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA || social == UpdateAccountInfoAsyncTask.SOCIAL.GNU || social == UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
// Retrieves instance
- new RetrieveInstanceAsyncTask(BaseMainActivity.this, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveInstanceAsyncTask(BaseMainActivity.this, BaseMainActivity.this);
// Retrieves filters
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
- new ManageFiltersAsyncTask(BaseMainActivity.this, GET_ALL_FILTER, null, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new ManageFiltersAsyncTask(BaseMainActivity.this, GET_ALL_FILTER, null, BaseMainActivity.this);
}
+
}
/* Clean cache for statuses */
@@ -1330,11 +1330,27 @@ public abstract class BaseMainActivity extends BaseActivity
new TimelineCacheDAO(BaseMainActivity.this, db).removeAfterDate(dateString);
});
if (Helper.isLoggedIn(BaseMainActivity.this)) {
- new UpdateAccountInfoByIDAsyncTask(BaseMainActivity.this, social, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ final Handler handler = new Handler();
+ handler.postDelayed(() -> new UpdateAccountInfoByIDAsyncTask(BaseMainActivity.this, account, BaseMainActivity.this), 2000);
+
}
mutedAccount = new TempMuteDAO(BaseMainActivity.this, db).getAllTimeMuted(account);
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
- new RetrieveFeedsAsyncTask(BaseMainActivity.this, RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS, null, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ final Handler handler = new Handler();
+ handler.postDelayed(() -> {
+ new RetrieveFeedsAsyncTask(BaseMainActivity.this, RetrieveFeedsAsyncTask.Type.ANNOUNCEMENTS, null, BaseMainActivity.this);
+ if (BuildConfig.lite) {
+ String datesupdate = sharedpreferences.getString(Helper.TRACKING_LAST_UPDATE, null);
+ Date dateLastUpdate = Helper.stringToDate(BaseMainActivity.this, datesupdate);
+ Date dateUpdate = new Date(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(10));
+ //Refresh tracking db if needed
+ if (datesupdate == null || dateUpdate.after(dateLastUpdate)) {
+ Intent scriptIntent = new Intent(BaseMainActivity.this, DownloadTrackingDBScriptsService.class);
+ startService(scriptIntent);
+ }
+ }
+ }, 3000);
+
}
}
@@ -1439,21 +1455,19 @@ public abstract class BaseMainActivity extends BaseActivity
} else if (extras.getInt(Helper.INTENT_ACTION) == Helper.ADD_USER_INTENT) {
this.recreate();
} else if (extras.getInt(Helper.INTENT_ACTION) == Helper.BACKUP_INTENT) {
- Intent myIntent = new Intent(BaseMainActivity.this, OwnerStatusActivity.class);
- startActivity(myIntent);
+ launchOwnerStatusesActivity();
} else if (extras.getInt(Helper.INTENT_ACTION) == Helper.BACKUP_NOTIFICATION_INTENT) {
- Intent myIntent = new Intent(BaseMainActivity.this, OwnerNotificationActivity.class);
- startActivity(myIntent);
+ launchOwnerNotificationsActivity();
} else if (extras.getInt(Helper.INTENT_ACTION) == Helper.REDRAW_MENU) {
Helper.hideMenuItem(BaseMainActivity.this, navigationView.getMenu());
} else if (extras.getInt(Helper.INTENT_ACTION) == Helper.SEARCH_TAG) {
- new SyncTimelinesAsyncTask(BaseMainActivity.this, -1, false, BaseMainActivity.this).execute();
+ new SyncTimelinesAsyncTask(BaseMainActivity.this, -1, false, BaseMainActivity.this);
} else if (extras.getInt(Helper.INTENT_ACTION) == Helper.REFRESH_TIMELINE) {
int position = 0;
boolean refreshList = extras.getBoolean(Helper.REFRESH_LIST_TIMELINE, false);
if (tabLayout != null)
position = tabLayout.getSelectedTabPosition();
- new SyncTimelinesAsyncTask(BaseMainActivity.this, position, refreshList, BaseMainActivity.this).execute();
+ new SyncTimelinesAsyncTask(BaseMainActivity.this, position, refreshList, BaseMainActivity.this);
} else if (extras.getInt(Helper.INTENT_ACTION) == Helper.SEARCH_REMOTE) {
String url = extras.getString(Helper.SEARCH_URL);
intent.replaceExtras(new Bundle());
@@ -1474,7 +1488,7 @@ public abstract class BaseMainActivity extends BaseActivity
if (!isUrl)
return;
//Here we know that the intent contains a valid URL
- new RetrieveRemoteDataAsyncTask(BaseMainActivity.this, url, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveRemoteDataAsyncTask(BaseMainActivity.this, url, BaseMainActivity.this);
}
} else if (Intent.ACTION_SEND.equals(action) && type != null) {
if ("text/plain".equals(type)) {
@@ -1499,7 +1513,7 @@ public abstract class BaseMainActivity extends BaseActivity
if (matchStart < matchEnd && sharedText.length() >= matchEnd)
url = sharedText.substring(matchStart, matchEnd);
}
- new RetrieveMetaDataAsyncTask(BaseMainActivity.this, shouldRetrieveMetaData, sharedSubject, sharedText, url, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveMetaDataAsyncTask(BaseMainActivity.this, shouldRetrieveMetaData, sharedSubject, sharedText, url, BaseMainActivity.this);
}
} else if (type.startsWith("image/") || type.startsWith("video/")) {
@@ -1561,7 +1575,7 @@ public abstract class BaseMainActivity extends BaseActivity
}
//Here we know that the intent contains a valid URL
if (!url.contains("medium.com")) {
- new RetrieveRemoteDataAsyncTask(BaseMainActivity.this, url, BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveRemoteDataAsyncTask(BaseMainActivity.this, url, BaseMainActivity.this);
} else {
forwardToBrowser(intent);
}
@@ -1709,8 +1723,7 @@ public abstract class BaseMainActivity extends BaseActivity
// Handle navigation view item clicks here.
int id = item.getItemId();
if (id == R.id.nav_archive) {
- Intent myIntent = new Intent(BaseMainActivity.this, OwnerStatusActivity.class);
- startActivity(myIntent);
+ launchOwnerStatusesActivity();
return false;
}
if (id == R.id.nav_trends) {
@@ -1721,8 +1734,7 @@ public abstract class BaseMainActivity extends BaseActivity
startActivity(myIntent);
return false;
} else if (id == R.id.nav_archive_notifications) {
- Intent myIntent = new Intent(BaseMainActivity.this, OwnerNotificationActivity.class);
- startActivity(myIntent);
+ launchOwnerNotificationsActivity();
return false;
} else if (id == R.id.nav_drag_timelines) {
Intent intent = new Intent(BaseMainActivity.this, ReorderTimelinesActivity.class);
@@ -2058,7 +2070,7 @@ public abstract class BaseMainActivity extends BaseActivity
if (accounts != null && accounts.size() > 0) {
developers = new ArrayList<>();
developers.addAll(accounts);
- new RetrieveRelationshipAsyncTask(BaseMainActivity.this, accounts.get(0).getId(), BaseMainActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveRelationshipAsyncTask(BaseMainActivity.this, accounts.get(0).getId(), BaseMainActivity.this);
}
}
}
@@ -2342,12 +2354,13 @@ public abstract class BaseMainActivity extends BaseActivity
}
try {
TabLayoutNotificationsFragment tabLayoutNotificationsFragment = (TabLayoutNotificationsFragment) mPageReferenceMap.get(position);
- assert tabLayoutNotificationsFragment != null;
- ViewPager notifViewPager = Objects.requireNonNull(tabLayoutNotificationsFragment).getViewPager();
- if (notifViewPager != null && notifViewPager.getAdapter() != null) {
- DisplayNotificationsFragment displayNotificationsFragment = (DisplayNotificationsFragment) notifViewPager.getAdapter().instantiateItem(notifViewPager, 0);
- displayNotificationsFragment.updateNotificationRead();
+ if (tabLayoutNotificationsFragment != null) {
+ ViewPager notifViewPager = tabLayoutNotificationsFragment.getViewPager();
+ if (notifViewPager != null && notifViewPager.getAdapter() != null) {
+ DisplayNotificationsFragment displayNotificationsFragment = (DisplayNotificationsFragment) notifViewPager.getAdapter().instantiateItem(notifViewPager, 0);
+ displayNotificationsFragment.updateNotificationRead();
+ }
}
} catch (Exception ignored) {
}
@@ -2409,6 +2422,10 @@ public abstract class BaseMainActivity extends BaseActivity
super.onDetachedFromWindow();
}
+ protected abstract void launchOwnerStatusesActivity();
+
+ protected abstract void launchOwnerNotificationsActivity();
+
public enum iconLauncher {
BUBBLES,
FEDIVERSE,
diff --git a/app/src/main/java/app/fedilab/android/activities/PixelfedComposeActivity.java b/app/src/main/java/app/fedilab/android/activities/BasePixelfedComposeActivity.java
similarity index 79%
rename from app/src/main/java/app/fedilab/android/activities/PixelfedComposeActivity.java
rename to app/src/main/java/app/fedilab/android/activities/BasePixelfedComposeActivity.java
index 8e66d2a9a..ec55c272d 100644
--- a/app/src/main/java/app/fedilab/android/activities/PixelfedComposeActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/BasePixelfedComposeActivity.java
@@ -29,10 +29,10 @@ import android.content.res.ColorStateList;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.Color;
+import android.graphics.Paint;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
-import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
@@ -44,6 +44,7 @@ import android.text.Html;
import android.text.InputType;
import android.text.SpannableString;
import android.text.TextWatcher;
+import android.text.format.DateFormat;
import android.text.style.ForegroundColorSpan;
import android.util.Patterns;
import android.view.LayoutInflater;
@@ -82,7 +83,8 @@ import com.bumptech.glide.request.transition.Transition;
import com.smarteist.autoimageslider.IndicatorAnimations;
import com.smarteist.autoimageslider.SliderAnimations;
import com.smarteist.autoimageslider.SliderView;
-import com.vanniktech.emoji.EmojiPopup;
+import com.watermark.androidwm_light.WatermarkBuilder;
+import com.watermark.androidwm_light.bean.WatermarkText;
import net.gotev.uploadservice.MultipartUploadRequest;
import net.gotev.uploadservice.ServerResponse;
@@ -96,6 +98,8 @@ import org.jetbrains.annotations.NotNull;
import org.json.JSONException;
import org.json.JSONObject;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@@ -168,19 +172,21 @@ import static app.fedilab.android.helper.Helper.countWithEmoji;
* Toot activity class
*/
-public class PixelfedComposeActivity extends BaseActivity implements UploadStatusDelegate, OnPostActionInterface, OnRetrieveSearcAccountshInterface, OnPostStatusActionInterface, OnRetrieveSearchInterface, OnRetrieveEmojiInterface, OnDownloadInterface, OnRetrieveAttachmentInterface {
+public abstract class BasePixelfedComposeActivity extends BaseActivity implements UploadStatusDelegate, OnPostActionInterface, OnRetrieveSearcAccountshInterface, OnPostStatusActionInterface, OnRetrieveSearchInterface, OnRetrieveEmojiInterface, OnDownloadInterface, OnRetrieveAttachmentInterface {
public static final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 754;
public static final int SEND_VOICE_MESSAGE = 1423;
+ private static final int searchDeep = 15;
public static HashMap filesMap;
public static boolean autocomplete;
public static Uri photoFileUri = null;
static boolean active = false;
- private static int searchDeep = 15;
private final int PICK_IMAGE = 56556;
private final int TAKE_PHOTO = 56532;
public long currentToId;
+ protected MastalabAutoCompleteTextView toot_content;
+ protected LinearLayout drawer_layout;
String mCurrentPhotoPath;
File photoFile = null;
private String visibility;
@@ -188,7 +194,6 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
private boolean isSensitive = false;
private ImageButton toot_visibility;
private Button toot_it;
- private MastalabAutoCompleteTextView toot_content;
private CheckBox toot_sensitive;
private long restored;
private TextView title;
@@ -212,17 +217,16 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
private SliderView imageSlider;
private SliderAdapter sliderAdapter;
private CheckBox pixelfed_story;
-
- private BroadcastReceiver imageReceiver = new BroadcastReceiver() {
+ private final BroadcastReceiver imageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String imgpath = intent.getStringExtra("imgpath");
if (imgpath != null) {
- prepareUpload(PixelfedComposeActivity.this, Uri.fromFile(new File(imgpath)), null, uploadReceiver);
+ prepareUpload(BasePixelfedComposeActivity.this, Uri.fromFile(new File(imgpath)), null, uploadReceiver);
}
}
};
- private BroadcastReceiver add_new_media = new BroadcastReceiver() {
+ private final BroadcastReceiver add_new_media = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
pixelfed_story.setEnabled(true);
@@ -395,7 +399,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
pp_progress.setVisibility(View.VISIBLE);
pp_actionBar.setVisibility(View.GONE);
}
- new RetrieveSearchAccountsAsyncTask(context, search, listenerAccount).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveSearchAccountsAsyncTask(context, search, listenerAccount);
} else {
mt = tPattern.matcher(searchIn);
if (mt.matches()) {
@@ -404,7 +408,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
pp_progress.setVisibility(View.VISIBLE);
pp_actionBar.setVisibility(View.GONE);
}
- new RetrieveSearchAsyncTask(context, search, true, listener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveSearchAsyncTask(context, search, true, listener);
} else {
mt = ePattern.matcher(searchIn);
if (mt.matches()) {
@@ -413,7 +417,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
pp_progress.setVisibility(View.VISIBLE);
pp_actionBar.setVisibility(View.GONE);
}
- new RetrieveEmojiAsyncTask(context, shortcode, listenerEmoji).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveEmojiAsyncTask(context, shortcode, listenerEmoji);
} else {
toot_content.dismissDropDown();
}
@@ -428,13 +432,60 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
return textw;
}
- static private void upload(Activity activity, boolean pixelfedStory, Uri inUri, String fname, UploadServiceSingleBroadcastReceiver uploadReceiver) {
+ static private void upload(Activity activity, boolean pixelfedStory, Account account, Uri inUri, String fname, UploadServiceSingleBroadcastReceiver uploadReceiver) {
String uploadId = UUID.randomUUID().toString();
if (uploadReceiver != null) {
uploadReceiver.setUploadID(uploadId);
}
- Uri uri;
InputStream tempInput = null;
+ SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
+ 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 + 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(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 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;
+ WatermarkText watermarkText = new WatermarkText(WMText)
+ .setPositionX(valx)
+ .setPositionY(valy)
+ .setTextColor(Color.WHITE)
+ .setTextShadow(0.1f, 1, 1, Color.LTGRAY)
+ .setTextAlpha(200)
+ .setRotation(0)
+ .setTextSize(textSize);
+
+ Bitmap bitmap = WatermarkBuilder
+ .create(activity, backgroundBitmap)
+ .loadWatermarkText(watermarkText)
+ .getWatermark()
+ .getOutputImage();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ bitmap.compress(Bitmap.CompressFormat.PNG, 0, bos);
+ byte[] bitmapdata = bos.toByteArray();
+ tempInput = new ByteArrayInputStream(bitmapdata);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ Uri uri;
FileOutputStream tempOut = null;
String filename = inUri.toString().substring(inUri.toString().lastIndexOf("/"));
int suffixPosition = filename.lastIndexOf(".");
@@ -442,7 +493,9 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
if (suffixPosition > 0) suffix = filename.substring(suffixPosition);
try {
File file;
- tempInput = activity.getContentResolver().openInputStream(inUri);
+ if (tempInput == null) {
+ tempInput = activity.getContentResolver().openInputStream(inUri);
+ }
if (fname.startsWith("fedilabins_")) {
file = File.createTempFile("fedilabins_randomTemp1", suffix, activity.getCacheDir());
} else {
@@ -462,9 +515,15 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
"fr.gouv.etalab.mastodon.fileProvider",
file);
} else {
- uri = FileProvider.getUriForFile(activity,
- "app.fedilab.android.fileProvider",
- file);
+ if (BuildConfig.lite) {
+ uri = FileProvider.getUriForFile(activity,
+ "app.fedilab.lite.fileProvider",
+ file);
+ } else {
+ uri = FileProvider.getUriForFile(activity,
+ "app.fedilab.android.fileProvider",
+ file);
+ }
}
tempInput.close();
tempOut.close();
@@ -479,7 +538,6 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
try {
final String fileName = FileNameCleaner.cleanFileName(fname);
- SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
String scheme = sharedpreferences.getString(Helper.SET_ONION_SCHEME + Helper.getLiveInstance(activity), "https");
String token = sharedpreferences.getString(Helper.PREF_KEY_OAUTH_TOKEN, null);
int maxUploadRetryTimes = sharedpreferences.getInt(Helper.MAX_UPLOAD_IMG_RETRY_TIMES, 3);
@@ -557,8 +615,8 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null;
- View view = inflater.inflate(R.layout.toot_action_bar, new LinearLayout(PixelfedComposeActivity.this), false);
- view.setBackground(new ColorDrawable(ContextCompat.getColor(PixelfedComposeActivity.this, R.color.cyanea_primary)));
+ View view = inflater.inflate(R.layout.toot_action_bar, new LinearLayout(BasePixelfedComposeActivity.this), false);
+ view.setBackground(new ColorDrawable(ContextCompat.getColor(BasePixelfedComposeActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
ImageView close_toot = actionBar.getCustomView().findViewById(R.id.close_toot);
@@ -574,14 +632,10 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
} else if (initialContent.trim().equals(toot_content.getText().toString().trim())) {
finish();
} else {
- AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(PixelfedComposeActivity.this, style);
+ AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(BasePixelfedComposeActivity.this, style);
dialogBuilder.setMessage(R.string.save_draft);
dialogBuilder.setPositiveButton(R.string.save, (dialog, id) -> {
- if (accountReply == null) {
- storeToot(true, false);
- } else {
- storeToot(false, false);
- }
+ storeToot(accountReply == null, false);
dialog.dismiss();
finish();
});
@@ -610,7 +664,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
toot_it = findViewById(R.id.toot_it);
attachments = new ArrayList<>();
imageSlider = findViewById(R.id.imageSlider);
- sliderAdapter = new SliderAdapter(new WeakReference<>(PixelfedComposeActivity.this), true, attachments);
+ sliderAdapter = new SliderAdapter(new WeakReference<>(BasePixelfedComposeActivity.this), true, attachments);
imageSlider.setIndicatorAnimation(IndicatorAnimations.WORM);
imageSlider.setSliderTransformAnimation(SliderAnimations.SIMPLETRANSFORMATION);
imageSlider.setSliderAdapter(sliderAdapter);
@@ -626,16 +680,12 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
//There is no media the button is hidden
upload_media.setVisibility(View.INVISIBLE);
toot_sensitive = findViewById(R.id.toot_sensitive);
- LinearLayout drawer_layout = findViewById(R.id.drawer_layout);
+ drawer_layout = findViewById(R.id.drawer_layout);
ImageButton toot_emoji = findViewById(R.id.toot_emoji);
LinearLayout bottom_bar_tooting = findViewById(R.id.bottom_bar_tooting);
isScheduled = false;
if (sharedpreferences.getBoolean(Helper.SET_DISPLAY_EMOJI, false)) {
- final EmojiPopup emojiPopup = EmojiPopup.Builder.fromRootView(drawer_layout).build(toot_content);
-
- toot_emoji.setOnClickListener(v -> {
- emojiPopup.toggle(); // Toggles visibility of the Popup.
- });
+ displayEmojiPopup();
} else {
toot_emoji.setVisibility(View.GONE);
}
@@ -653,11 +703,11 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(PixelfedComposeActivity.this);
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(BasePixelfedComposeActivity.this);
int iconColor = prefs.getInt("theme_icons_color", -1);
if (iconColor != -1) {
- Helper.changeDrawableColor(PixelfedComposeActivity.this, toot_visibility, iconColor);
- Helper.changeDrawableColor(PixelfedComposeActivity.this, toot_emoji, iconColor);
+ Helper.changeDrawableColor(BasePixelfedComposeActivity.this, toot_visibility, iconColor);
+ Helper.changeDrawableColor(BasePixelfedComposeActivity.this, toot_emoji, iconColor);
toot_sensitive.setButtonTintList(ColorStateList.valueOf(iconColor));
toot_sensitive.setTextColor(iconColor);
}
@@ -674,7 +724,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
if (accountReplyToken != null) {
String[] val = accountReplyToken.split("\\|");
if (val.length == 2) {
- accountReply = new AccountDAO(PixelfedComposeActivity.this, db).getUniqAccount(val[0], val[1]);
+ accountReply = new AccountDAO(BasePixelfedComposeActivity.this, db).getUniqAccount(val[0], val[1]);
}
}
removed = b.getBoolean("removed");
@@ -715,7 +765,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
instanceReply = accountReply.getInstance();
}
if (accountReply == null)
- account = new AccountDAO(PixelfedComposeActivity.this, db).getUniqAccount(userIdReply, instanceReply);
+ account = new AccountDAO(BasePixelfedComposeActivity.this, db).getUniqAccount(userIdReply, instanceReply);
else
account = accountReply;
@@ -725,7 +775,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
toot_content.requestFocus();
- Helper.loadGiF(PixelfedComposeActivity.this, account, pp_actionBar);
+ Helper.loadGiF(BasePixelfedComposeActivity.this, account, pp_actionBar);
if (visibility == null) {
@@ -760,9 +810,9 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
pickup_picture.setOnClickListener(v -> {
- if (ContextCompat.checkSelfPermission(PixelfedComposeActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) !=
+ if (ContextCompat.checkSelfPermission(BasePixelfedComposeActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) !=
PackageManager.PERMISSION_GRANTED) {
- ActivityCompat.requestPermissions(PixelfedComposeActivity.this,
+ ActivityCompat.requestPermissions(BasePixelfedComposeActivity.this,
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
return;
@@ -770,28 +820,19 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
Intent intent;
intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
- intent.setType("*/*");
- intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
- String[] mimetypes = {"image/*", "video/*", "audio/mpeg", "audio/opus", "audio/flac", "audio/wav", "audio/ogg"};
- intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes);
- startActivityForResult(intent, PICK_IMAGE);
- } else {
- intent.setType("image/* video/* audio/mpeg audio/opus audio/flac audio/wav audio/ogg");
- intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
- Intent pickIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
- Intent chooserIntent = Intent.createChooser(intent, getString(R.string.toot_select_image));
- chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{pickIntent});
- startActivityForResult(chooserIntent, PICK_IMAGE);
- }
+ intent.setType("*/*");
+ intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
+ String[] mimetypes = {"image/*", "video/*", "audio/mpeg", "audio/opus", "audio/flac", "audio/wav", "audio/ogg"};
+ intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes);
+ startActivityForResult(intent, PICK_IMAGE);
});
upload_media.setOnClickListener(v -> {
- if (ContextCompat.checkSelfPermission(PixelfedComposeActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) !=
+ if (ContextCompat.checkSelfPermission(BasePixelfedComposeActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) !=
PackageManager.PERMISSION_GRANTED) {
- ActivityCompat.requestPermissions(PixelfedComposeActivity.this,
+ ActivityCompat.requestPermissions(BasePixelfedComposeActivity.this,
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
return;
@@ -799,25 +840,16 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
Intent intent;
intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
- intent.setType("*/*");
- intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
- String[] mimetypes = {"image/*", "video/*", "audio/mpeg", "audio/opus", "audio/flac", "audio/wav", "audio/ogg"};
- intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes);
- startActivityForResult(intent, PICK_IMAGE);
- } else {
- intent.setType("image/* video/* audio/mpeg audio/opus audio/flac audio/wav audio/ogg");
- intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
- Intent pickIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
- Intent chooserIntent = Intent.createChooser(intent, getString(R.string.toot_select_image));
- chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{pickIntent});
- startActivityForResult(chooserIntent, PICK_IMAGE);
- }
+ intent.setType("*/*");
+ intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
+ String[] mimetypes = {"image/*", "video/*", "audio/mpeg", "audio/opus", "audio/flac", "audio/wav", "audio/ogg"};
+ intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes);
+ startActivityForResult(intent, PICK_IMAGE);
});
- TextWatcher textWatcher = initializeTextWatcher(PixelfedComposeActivity.this, social, toot_content, toot_space_left, pp_actionBar, pp_progress, PixelfedComposeActivity.this, PixelfedComposeActivity.this, PixelfedComposeActivity.this);
+ TextWatcher textWatcher = initializeTextWatcher(BasePixelfedComposeActivity.this, social, toot_content, toot_space_left, pp_actionBar, pp_progress, BasePixelfedComposeActivity.this, BasePixelfedComposeActivity.this, BasePixelfedComposeActivity.this);
toot_content.addTextChangedListener(textWatcher);
@@ -879,7 +911,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
}
}
} else {
- Toasty.success(PixelfedComposeActivity.this, getString(R.string.added_to_story), Toast.LENGTH_LONG).show();
+ Toasty.success(BasePixelfedComposeActivity.this, getString(R.string.added_to_story), Toast.LENGTH_LONG).show();
}
}
@@ -900,7 +932,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
if (mToast != null) {
mToast.cancel();
}
- mToast = Toasty.error(PixelfedComposeActivity.this, message, Toast.LENGTH_SHORT);
+ mToast = Toasty.error(BasePixelfedComposeActivity.this, message, Toast.LENGTH_SHORT);
mToast.show();
}
@@ -914,16 +946,16 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
break;
}
try {
- prepareUpload(PixelfedComposeActivity.this, fileUri, null, uploadReceiver);
+ prepareUpload(BasePixelfedComposeActivity.this, fileUri, null, uploadReceiver);
count++;
} catch (Exception e) {
e.printStackTrace();
- Toasty.error(PixelfedComposeActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
+ Toasty.error(BasePixelfedComposeActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
upload_media.setEnabled(true);
toot_it.setEnabled(true);
}
} else {
- Toasty.error(PixelfedComposeActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
+ Toasty.error(BasePixelfedComposeActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
}
}
}
@@ -937,7 +969,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
try {
photoFile = createImageFile();
} catch (IOException ignored) {
- Toasty.error(PixelfedComposeActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
+ Toasty.error(BasePixelfedComposeActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
}
// Continue only if the File was successfully created
if (photoFile != null) {
@@ -946,9 +978,15 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
"fr.gouv.etalab.mastodon.fileProvider",
photoFile);
} else {
- photoFileUri = FileProvider.getUriForFile(this,
- "app.fedilab.android.fileProvider",
- photoFile);
+ if (BuildConfig.lite) {
+ photoFileUri = FileProvider.getUriForFile(this,
+ "app.fedilab.lite.fileProvider",
+ photoFile);
+ } else {
+ photoFileUri = FileProvider.getUriForFile(this,
+ "app.fedilab.android.fileProvider",
+ photoFile);
+ }
}
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoFileUri);
startActivityForResult(takePictureIntent, TAKE_PHOTO);
@@ -978,13 +1016,13 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
boolean photo_editor = sharedpreferences.getBoolean(Helper.SET_PHOTO_EDITOR, true);
if (requestCode == PICK_IMAGE && resultCode == RESULT_OK) {
if (data == null) {
- Toasty.error(PixelfedComposeActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
+ Toasty.error(BasePixelfedComposeActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
return;
}
ClipData clipData = data.getClipData();
if (data.getData() == null && clipData == null) {
- Toasty.error(PixelfedComposeActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
+ Toasty.error(BasePixelfedComposeActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
return;
}
if (clipData != null) {
@@ -996,40 +1034,32 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
}
uploadSharedImage(mArrayUri);
} else {
- String filename = Helper.getFileName(PixelfedComposeActivity.this, data.getData());
+ String filename = Helper.getFileName(BasePixelfedComposeActivity.this, data.getData());
ContentResolver cr = getContentResolver();
String mime = cr.getType(data.getData());
if (mime != null && (mime.toLowerCase().contains("video") || mime.toLowerCase().contains("gif"))) {
- prepareUpload(PixelfedComposeActivity.this, data.getData(), filename, uploadReceiver);
+ prepareUpload(BasePixelfedComposeActivity.this, data.getData(), filename, uploadReceiver);
} else if (mime != null && mime.toLowerCase().contains("image")) {
if (photo_editor) {
- Intent intent = new Intent(PixelfedComposeActivity.this, PhotoEditorActivity.class);
- Bundle b = new Bundle();
- intent.putExtra("imageUri", data.getData().toString());
- intent.putExtras(b);
- startActivity(intent);
+ launchPhotoEditor(data.getData());
} else {
- prepareUpload(PixelfedComposeActivity.this, data.getData(), filename, uploadReceiver);
+ prepareUpload(BasePixelfedComposeActivity.this, data.getData(), filename, uploadReceiver);
}
} else if (mime != null && mime.toLowerCase().contains("audio")) {
- prepareUpload(PixelfedComposeActivity.this, data.getData(), filename, uploadReceiver);
+ prepareUpload(BasePixelfedComposeActivity.this, data.getData(), filename, uploadReceiver);
} else {
- Toasty.error(PixelfedComposeActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
+ Toasty.error(BasePixelfedComposeActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
}
}
} else if (requestCode == SEND_VOICE_MESSAGE && resultCode == RESULT_OK) {
Uri uri = Uri.fromFile(new File(getCacheDir() + "/fedilab_recorded_audio.wav"));
- prepareUpload(PixelfedComposeActivity.this, uri, "fedilab_recorded_audio.wav", uploadReceiver);
+ prepareUpload(BasePixelfedComposeActivity.this, uri, "fedilab_recorded_audio.wav", uploadReceiver);
} else if (requestCode == TAKE_PHOTO && resultCode == RESULT_OK) {
if (photo_editor) {
- Intent intent = new Intent(PixelfedComposeActivity.this, PhotoEditorActivity.class);
- Bundle b = new Bundle();
- intent.putExtra("imageUri", photoFileUri.toString());
- intent.putExtras(b);
- startActivity(intent);
+ launchPhotoEditor(photoFileUri);
} else {
- prepareUpload(PixelfedComposeActivity.this, photoFileUri, null, uploadReceiver);
+ prepareUpload(BasePixelfedComposeActivity.this, photoFileUri, null, uploadReceiver);
}
}
}
@@ -1037,18 +1067,18 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
private void prepareUpload(Activity activity, Uri uri, String filename, UploadServiceSingleBroadcastReceiver uploadReceiver) {
pixelfed_story.setEnabled(false);
if (uploadReceiver == null) {
- uploadReceiver = new UploadServiceSingleBroadcastReceiver(PixelfedComposeActivity.this);
+ uploadReceiver = new UploadServiceSingleBroadcastReceiver(BasePixelfedComposeActivity.this);
uploadReceiver.register(this);
}
- new asyncPicture(activity, pixelfed_story.isChecked(), uri, filename, uploadReceiver).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new asyncPicture(activity, pixelfed_story.isChecked(), account, uri, filename, uploadReceiver);
}
@Override
public void onPostAction(int statusCode, API.StatusAction statusAction, String userId, Error error) {
if (error != null) {
- Toasty.error(PixelfedComposeActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
+ Toasty.error(BasePixelfedComposeActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
} else {
- Toasty.success(PixelfedComposeActivity.this, getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show();
+ Toasty.success(BasePixelfedComposeActivity.this, getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show();
resetForNextToot();
}
}
@@ -1062,7 +1092,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
@Override
public void onError(Context context, UploadInfo uploadInfo, ServerResponse serverResponse,
Exception exception) {
- Toasty.error(PixelfedComposeActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
+ Toasty.error(BasePixelfedComposeActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
if (attachments.size() == 0) {
pickup_picture.setVisibility(View.VISIBLE);
imageSlider.setVisibility(View.GONE);
@@ -1074,14 +1104,14 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
@Override
public void onCompleted(Context context, UploadInfo uploadInfo, ServerResponse serverResponse) {
- JSONObject response = null;
+ JSONObject response;
pixelfed_story.setEnabled(true);
try {
response = new JSONObject(serverResponse.getBodyAsString());
+ addNewMedia(response, uploadInfo.getSuccessfullyUploadedFiles());
} catch (JSONException e) {
e.printStackTrace();
}
- addNewMedia(response, uploadInfo.getSuccessfullyUploadedFiles());
}
@Override
@@ -1098,12 +1128,12 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
if (extras != null && extras.getString("imageUri") != null) {
Uri imageUri = Uri.parse(extras.getString("imageUri"));
if (imageUri == null) {
- Toasty.error(PixelfedComposeActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
+ Toasty.error(BasePixelfedComposeActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
return;
}
- String filename = Helper.getFileName(PixelfedComposeActivity.this, imageUri);
+ String filename = Helper.getFileName(BasePixelfedComposeActivity.this, imageUri);
- prepareUpload(PixelfedComposeActivity.this, imageUri, filename, uploadReceiver);
+ prepareUpload(BasePixelfedComposeActivity.this, imageUri, filename, uploadReceiver);
}
}
@@ -1121,99 +1151,98 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
style = R.style.Dialog;
}
- switch (item.getItemId()) {
- case android.R.id.home:
- finish();
+ int itemId = item.getItemId();
+ if (itemId == android.R.id.home) {
+ finish();
+ return true;
+ } else if (itemId == R.id.action_photo_camera) {
+ dispatchTakePictureIntent();
+ return true;
+ } else if (itemId == R.id.action_store) {
+ storeToot(true, true);
+ return true;
+ } else if (itemId == R.id.action_schedule) {
+ if (toot_content.getText().toString().trim().length() == 0) {
+ Toasty.error(BasePixelfedComposeActivity.this, getString(R.string.toot_error_no_content), Toast.LENGTH_LONG).show();
return true;
- case R.id.action_photo_camera:
- dispatchTakePictureIntent();
- return true;
- case R.id.action_store:
- storeToot(true, true);
- return true;
- case R.id.action_schedule:
- if (toot_content.getText().toString().trim().length() == 0) {
- Toasty.error(PixelfedComposeActivity.this, getString(R.string.toot_error_no_content), Toast.LENGTH_LONG).show();
- return true;
+ }
+ AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(BasePixelfedComposeActivity.this, style);
+ LayoutInflater inflater = this.getLayoutInflater();
+ View dialogView = inflater.inflate(R.layout.datetime_picker, new LinearLayout(BasePixelfedComposeActivity.this), false);
+ dialogBuilder.setView(dialogView);
+ final AlertDialog alertDialog = dialogBuilder.create();
+
+ final DatePicker datePicker = dialogView.findViewById(R.id.date_picker);
+ final TimePicker timePicker = dialogView.findViewById(R.id.time_picker);
+ if (DateFormat.is24HourFormat(BasePixelfedComposeActivity.this))
+ timePicker.setIs24HourView(true);
+ Button date_time_cancel = dialogView.findViewById(R.id.date_time_cancel);
+ final ImageButton date_time_previous = dialogView.findViewById(R.id.date_time_previous);
+ final ImageButton date_time_next = dialogView.findViewById(R.id.date_time_next);
+ final ImageButton date_time_set = dialogView.findViewById(R.id.date_time_set);
+
+ //Buttons management
+ date_time_cancel.setOnClickListener(v -> alertDialog.dismiss());
+ date_time_next.setOnClickListener(v -> {
+ datePicker.setVisibility(View.GONE);
+ timePicker.setVisibility(View.VISIBLE);
+ date_time_previous.setVisibility(View.VISIBLE);
+ date_time_next.setVisibility(View.GONE);
+ date_time_set.setVisibility(View.VISIBLE);
+ });
+ date_time_previous.setOnClickListener(v -> {
+ datePicker.setVisibility(View.VISIBLE);
+ timePicker.setVisibility(View.GONE);
+ date_time_previous.setVisibility(View.GONE);
+ date_time_next.setVisibility(View.VISIBLE);
+ date_time_set.setVisibility(View.GONE);
+ });
+ date_time_set.setOnClickListener(v -> {
+ int hour, minute;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ hour = timePicker.getHour();
+ minute = timePicker.getMinute();
+ } else {
+ hour = timePicker.getCurrentHour();
+ minute = timePicker.getCurrentMinute();
}
- AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(PixelfedComposeActivity.this, style);
- LayoutInflater inflater = this.getLayoutInflater();
- View dialogView = inflater.inflate(R.layout.datetime_picker, new LinearLayout(PixelfedComposeActivity.this), false);
- dialogBuilder.setView(dialogView);
- final AlertDialog alertDialog = dialogBuilder.create();
+ Calendar calendar = new GregorianCalendar(datePicker.getYear(),
+ datePicker.getMonth(),
+ datePicker.getDayOfMonth(),
+ hour,
+ minute);
+ final long[] time = {calendar.getTimeInMillis()};
- final DatePicker datePicker = dialogView.findViewById(R.id.date_picker);
- final TimePicker timePicker = dialogView.findViewById(R.id.time_picker);
- if (android.text.format.DateFormat.is24HourFormat(PixelfedComposeActivity.this))
- timePicker.setIs24HourView(true);
- Button date_time_cancel = dialogView.findViewById(R.id.date_time_cancel);
- final ImageButton date_time_previous = dialogView.findViewById(R.id.date_time_previous);
- final ImageButton date_time_next = dialogView.findViewById(R.id.date_time_next);
- final ImageButton date_time_set = dialogView.findViewById(R.id.date_time_set);
-
- //Buttons management
- date_time_cancel.setOnClickListener(v -> alertDialog.dismiss());
- date_time_next.setOnClickListener(v -> {
- datePicker.setVisibility(View.GONE);
- timePicker.setVisibility(View.VISIBLE);
- date_time_previous.setVisibility(View.VISIBLE);
- date_time_next.setVisibility(View.GONE);
- date_time_set.setVisibility(View.VISIBLE);
- });
- date_time_previous.setOnClickListener(v -> {
- datePicker.setVisibility(View.VISIBLE);
- timePicker.setVisibility(View.GONE);
- date_time_previous.setVisibility(View.GONE);
- date_time_next.setVisibility(View.VISIBLE);
- date_time_set.setVisibility(View.GONE);
- });
- date_time_set.setOnClickListener(v -> {
- int hour, minute;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- hour = timePicker.getHour();
- minute = timePicker.getMinute();
- } else {
- hour = timePicker.getCurrentHour();
- minute = timePicker.getCurrentMinute();
- }
- Calendar calendar = new GregorianCalendar(datePicker.getYear(),
- datePicker.getMonth(),
- datePicker.getDayOfMonth(),
- hour,
- minute);
- final long[] time = {calendar.getTimeInMillis()};
-
- if ((time[0] - new Date().getTime()) < 60000) {
- Toasty.warning(PixelfedComposeActivity.this, getString(R.string.toot_scheduled_date), Toast.LENGTH_LONG).show();
- } else {
- AlertDialog.Builder builderSingle = new AlertDialog.Builder(PixelfedComposeActivity.this, style);
- builderSingle.setTitle(getString(R.string.choose_schedule));
- builderSingle.setNegativeButton(R.string.device_schedule, (dialog, which) -> {
- deviceSchedule(time[0]);
- dialog.dismiss();
- });
- builderSingle.setPositiveButton(R.string.server_schedule, (dialog, which) -> {
- int offset = TimeZone.getDefault().getRawOffset();
- calendar.add(Calendar.MILLISECOND, -offset);
- final String date = Helper.dateToString(new Date(calendar.getTimeInMillis()));
- serverSchedule(date);
- });
- builderSingle.show();
- alertDialog.dismiss();
- }
- });
- alertDialog.show();
- return true;
- default:
- return super.onOptionsItemSelected(item);
+ if ((time[0] - new Date().getTime()) < 60000) {
+ Toasty.warning(BasePixelfedComposeActivity.this, getString(R.string.toot_scheduled_date), Toast.LENGTH_LONG).show();
+ } else {
+ AlertDialog.Builder builderSingle = new AlertDialog.Builder(BasePixelfedComposeActivity.this, style);
+ builderSingle.setTitle(getString(R.string.choose_schedule));
+ builderSingle.setNegativeButton(R.string.device_schedule, (dialog, which) -> {
+ deviceSchedule(time[0]);
+ dialog.dismiss();
+ });
+ builderSingle.setPositiveButton(R.string.server_schedule, (dialog, which) -> {
+ int offset = TimeZone.getDefault().getRawOffset();
+ calendar.add(Calendar.MILLISECOND, -offset);
+ final String date = Helper.dateToString(new Date(calendar.getTimeInMillis()));
+ serverSchedule(date);
+ });
+ builderSingle.show();
+ alertDialog.dismiss();
+ }
+ });
+ alertDialog.show();
+ return true;
}
+ return super.onOptionsItemSelected(item);
}
private void sendToot(String timestamp) {
toot_it.setEnabled(false);
if (toot_content.getText().toString().trim().length() == 0 && attachments.size() == 0) {
- Toasty.error(PixelfedComposeActivity.this, getString(R.string.toot_error_no_content), Toast.LENGTH_LONG).show();
+ Toasty.error(BasePixelfedComposeActivity.this, getString(R.string.toot_error_no_content), Toast.LENGTH_LONG).show();
toot_it.setEnabled(true);
return;
}
@@ -1225,20 +1254,20 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
toot.setSensitive(isSensitive);
toot.setVisibility(visibility);
toot.setMedia_attachments(attachments);
- toot.setContent(PixelfedComposeActivity.this, tootContent);
+ toot.setContent(BasePixelfedComposeActivity.this, tootContent);
if (timestamp == null)
if (scheduledstatus == null)
- new PostStatusAsyncTask(PixelfedComposeActivity.this, social, account, toot, PixelfedComposeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostStatusAsyncTask(BasePixelfedComposeActivity.this, social, account, toot, BasePixelfedComposeActivity.this);
else {
toot.setScheduled_at(Helper.dateToString(scheduledstatus.getScheduled_date()));
scheduledstatus.setStatus(toot);
isScheduled = true;
- new PostActionAsyncTask(PixelfedComposeActivity.this, API.StatusAction.DELETESCHEDULED, scheduledstatus, PixelfedComposeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- new PostStatusAsyncTask(PixelfedComposeActivity.this, social, account, toot, PixelfedComposeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostActionAsyncTask(BasePixelfedComposeActivity.this, API.StatusAction.DELETESCHEDULED, scheduledstatus, BasePixelfedComposeActivity.this);
+ new PostStatusAsyncTask(BasePixelfedComposeActivity.this, social, account, toot, BasePixelfedComposeActivity.this);
}
else {
toot.setScheduled_at(timestamp);
- new PostStatusAsyncTask(PixelfedComposeActivity.this, social, account, toot, PixelfedComposeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostStatusAsyncTask(BasePixelfedComposeActivity.this, social, account, toot, BasePixelfedComposeActivity.this);
}
}
@@ -1255,7 +1284,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
storeToot(false, false);
isScheduled = true;
//Schedules the toot
- ScheduledTootsSyncJob.schedule(PixelfedComposeActivity.this, currentToId, time);
+ ScheduledTootsSyncJob.schedule(BasePixelfedComposeActivity.this, currentToId, time);
resetForNextToot();
}
@@ -1277,7 +1306,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
isSensitive = false;
toot_sensitive.setVisibility(View.GONE);
currentToId = -1;
- Toasty.info(PixelfedComposeActivity.this, getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show();
+ Toasty.info(BasePixelfedComposeActivity.this, getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show();
}
@Override
@@ -1315,7 +1344,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
String filename = FileNameCleaner.cleanFileName(url);
upload_media.setEnabled(false);
toot_it.setEnabled(false);
- upload(PixelfedComposeActivity.this, pixelfed_story.isChecked(), uri, filename, uploadReceiver);
+ upload(BasePixelfedComposeActivity.this, pixelfed_story.isChecked(), account, uri, filename, uploadReceiver);
}
}
@@ -1342,10 +1371,10 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
private void tootVisibilityDialog() {
- AlertDialog.Builder dialog = new AlertDialog.Builder(PixelfedComposeActivity.this, style);
+ AlertDialog.Builder dialog = new AlertDialog.Builder(BasePixelfedComposeActivity.this, style);
dialog.setTitle(R.string.toot_visibility_tilte);
final String[] stringArray = getResources().getStringArray(R.array.toot_visibility);
- final ArrayAdapter arrayAdapter = new ArrayAdapter<>(PixelfedComposeActivity.this, android.R.layout.simple_list_item_1, stringArray);
+ final ArrayAdapter arrayAdapter = new ArrayAdapter<>(BasePixelfedComposeActivity.this, android.R.layout.simple_list_item_1, stringArray);
dialog.setNegativeButton(R.string.cancel, (dialog12, position) -> dialog12.dismiss());
dialog.setAdapter(arrayAdapter, (dialog1, position) -> {
switch (position) {
@@ -1401,14 +1430,10 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
} else if (initialContent.trim().equals(toot_content.getText().toString().trim())) {
finish();
} else {
- AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(PixelfedComposeActivity.this, style);
+ AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(BasePixelfedComposeActivity.this, style);
dialogBuilder.setMessage(R.string.save_draft);
dialogBuilder.setPositiveButton(R.string.save, (dialog, id) -> {
- if (accountReply == null) {
- storeToot(true, false);
- } else {
- storeToot(false, false);
- }
+ storeToot(accountReply == null, false);
dialog.dismiss();
finish();
});
@@ -1443,6 +1468,9 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
if (apiResponse.getError().getStatusCode() == -33) {
storeToot(false, true);
} else {
+ if (apiResponse.getError().getStatusCode() == 404) {
+ storeToot(false, true);
+ }
showAToast(apiResponse.getError().getError());
return;
}
@@ -1453,10 +1481,10 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
if (apiResponse.getError() == null || apiResponse.getError().getStatusCode() != -33) {
if (restored != -1) {
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
- new StatusStoredDAO(PixelfedComposeActivity.this, db).remove(restored);
+ new StatusStoredDAO(BasePixelfedComposeActivity.this, db).remove(restored);
} else if (currentToId != -1) {
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
- new StatusStoredDAO(PixelfedComposeActivity.this, db).remove(currentToId);
+ new StatusStoredDAO(BasePixelfedComposeActivity.this, db).remove(currentToId);
}
}
//Clear the toot
@@ -1479,17 +1507,17 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
if (scheduledstatus == null && !isScheduled) {
boolean display_confirm = sharedpreferences.getBoolean(Helper.SET_DISPLAY_CONFIRM, true);
if (display_confirm) {
- Toasty.success(PixelfedComposeActivity.this, getString(R.string.toot_sent), Toast.LENGTH_LONG).show();
+ Toasty.success(BasePixelfedComposeActivity.this, getString(R.string.toot_sent), Toast.LENGTH_LONG).show();
}
} else
- Toasty.success(PixelfedComposeActivity.this, getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show();
+ Toasty.success(BasePixelfedComposeActivity.this, getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show();
} else {
if (apiResponse.getError().getStatusCode() == -33)
- Toasty.info(PixelfedComposeActivity.this, getString(R.string.toast_toot_saved_error), Toast.LENGTH_LONG).show();
+ Toasty.info(BasePixelfedComposeActivity.this, getString(R.string.toast_toot_saved_error), Toast.LENGTH_LONG).show();
}
toot_it.setEnabled(true);
//It's a reply, so the user will be redirect to its answer
- Intent intent = new Intent(PixelfedComposeActivity.this, MainActivity.class);
+ Intent intent = new Intent(BasePixelfedComposeActivity.this, MainActivity.class);
intent.putExtra(Helper.INTENT_ACTION, Helper.HOME_TIMELINE_INTENT);
startActivity(intent);
finish();
@@ -1507,7 +1535,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
final List accounts = apiResponse.getAccounts();
if (accounts != null && accounts.size() > 0) {
int currentCursorPosition = toot_content.getSelectionStart();
- AccountsSearchAdapter accountsListAdapter = new AccountsSearchAdapter(PixelfedComposeActivity.this, accounts);
+ AccountsSearchAdapter accountsListAdapter = new AccountsSearchAdapter(BasePixelfedComposeActivity.this, accounts);
toot_content.setThreshold(1);
toot_content.setAdapter(accountsListAdapter);
final String oldContent = toot_content.getText().toString();
@@ -1540,7 +1568,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
toot_content.setText(newContent);
toot_space_left.setText(String.valueOf(countLength(social, toot_content)));
toot_content.setSelection(newPosition);
- AccountsSearchAdapter accountsListAdapter1 = new AccountsSearchAdapter(PixelfedComposeActivity.this, new ArrayList<>());
+ AccountsSearchAdapter accountsListAdapter1 = new AccountsSearchAdapter(BasePixelfedComposeActivity.this, new ArrayList<>());
toot_content.setThreshold(1);
toot_content.setAdapter(accountsListAdapter1);
});
@@ -1572,7 +1600,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
if (emojis != null && emojis.size() > 0) {
int currentCursorPosition = toot_content.getSelectionStart();
- EmojisSearchAdapter emojisSearchAdapter = new EmojisSearchAdapter(PixelfedComposeActivity.this, emojis);
+ EmojisSearchAdapter emojisSearchAdapter = new EmojisSearchAdapter(BasePixelfedComposeActivity.this, emojis);
toot_content.setThreshold(1);
toot_content.setAdapter(emojisSearchAdapter);
final String oldContent = toot_content.getText().toString();
@@ -1604,7 +1632,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
toot_content.setText(newContent);
toot_space_left.setText(String.valueOf(countLength(social, toot_content)));
toot_content.setSelection(newPosition);
- EmojisSearchAdapter emojisSearchAdapter1 = new EmojisSearchAdapter(PixelfedComposeActivity.this, new ArrayList<>());
+ EmojisSearchAdapter emojisSearchAdapter1 = new EmojisSearchAdapter(BasePixelfedComposeActivity.this, new ArrayList<>());
toot_content.setThreshold(1);
toot_content.setAdapter(emojisSearchAdapter1);
@@ -1627,7 +1655,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
final List tags = results.getHashtags();
if (tags != null && tags.size() > 0) {
int currentCursorPosition = toot_content.getSelectionStart();
- TagsSearchAdapter tagsSearchAdapter = new TagsSearchAdapter(PixelfedComposeActivity.this, tags);
+ TagsSearchAdapter tagsSearchAdapter = new TagsSearchAdapter(BasePixelfedComposeActivity.this, tags);
toot_content.setThreshold(1);
toot_content.setAdapter(tagsSearchAdapter);
final String oldContent = toot_content.getText().toString();
@@ -1664,7 +1692,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
toot_content.setText(newContent);
toot_space_left.setText(String.valueOf(countLength(social, toot_content)));
toot_content.setSelection(newPosition);
- TagsSearchAdapter tagsSearchAdapter1 = new TagsSearchAdapter(PixelfedComposeActivity.this, new ArrayList<>());
+ TagsSearchAdapter tagsSearchAdapter1 = new TagsSearchAdapter(BasePixelfedComposeActivity.this, new ArrayList<>());
toot_content.setThreshold(1);
toot_content.setAdapter(tagsSearchAdapter1);
@@ -1674,13 +1702,13 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
private void restoreToot(long id) {
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
- StoredStatus draft = new StatusStoredDAO(PixelfedComposeActivity.this, db).getStatus(id);
+ StoredStatus draft = new StatusStoredDAO(BasePixelfedComposeActivity.this, db).getStatus(id);
if (draft == null)
return;
Status status = draft.getStatus();
//Retrieves attachments
if (removed) {
- new StatusStoredDAO(PixelfedComposeActivity.this, db).remove(draft.getId());
+ new StatusStoredDAO(BasePixelfedComposeActivity.this, db).remove(draft.getId());
}
restored = id;
attachments = status.getMedia_attachments();
@@ -1700,7 +1728,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
content = Html.fromHtml(content).toString();
}
if (attachments != null && attachments.size() > 0) {
- sliderAdapter = new SliderAdapter(new WeakReference<>(PixelfedComposeActivity.this), true, attachments);
+ sliderAdapter = new SliderAdapter(new WeakReference<>(BasePixelfedComposeActivity.this), true, attachments);
imageSlider.setIndicatorAnimation(IndicatorAnimations.WORM);
imageSlider.setSliderTransformAnimation(SliderAnimations.SIMPLETRANSFORMATION);
imageSlider.setSliderAdapter(sliderAdapter);
@@ -1768,7 +1796,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
if (position > attachments.size()) {
position = attachments.size();
}
- sliderAdapter = new SliderAdapter(new WeakReference<>(PixelfedComposeActivity.this), true, attachments);
+ sliderAdapter = new SliderAdapter(new WeakReference<>(BasePixelfedComposeActivity.this), true, attachments);
imageSlider.setIndicatorAnimation(IndicatorAnimations.WORM);
imageSlider.setSliderTransformAnimation(SliderAnimations.SIMPLETRANSFORMATION);
imageSlider.setSliderAdapter(sliderAdapter);
@@ -1795,7 +1823,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
String url = attachment.getPreview_url();
if (url == null || url.trim().equals(""))
url = attachment.getUrl();
- final ImageView imageView = new ImageView(PixelfedComposeActivity.this);
+ final ImageView imageView = new ImageView(BasePixelfedComposeActivity.this);
Random rand = new Random();
int n = rand.nextInt(10000000);
imageView.setId(n);
@@ -1803,7 +1831,7 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
LinearLayout.LayoutParams imParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
imParams.setMargins(20, 5, 20, 5);
- imParams.height = (int) Helper.convertDpToPixel(100, PixelfedComposeActivity.this);
+ imParams.height = (int) Helper.convertDpToPixel(100, BasePixelfedComposeActivity.this);
imageView.setAdjustViewBounds(true);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
@@ -1886,27 +1914,29 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
toot.setSensitive(isSensitive);
toot.setMedia_attachments(attachments);
toot.setVisibility(visibility);
- toot.setContent(PixelfedComposeActivity.this, currentContent);
+ toot.setContent(BasePixelfedComposeActivity.this, currentContent);
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
+ String userId = accountReply != null ? accountReply.getId() : account.getId();
+ String instance = accountReply != null ? accountReply.getInstance() : account.getInstance();
try {
if (currentToId == -1) {
- currentToId = new StatusStoredDAO(PixelfedComposeActivity.this, db).insertStatus(toot, null);
+ currentToId = new StatusStoredDAO(BasePixelfedComposeActivity.this, db).insertStatus(toot, null, userId, instance);
} else {
- StoredStatus storedStatus = new StatusStoredDAO(PixelfedComposeActivity.this, db).getStatus(currentToId);
+ StoredStatus storedStatus = new StatusStoredDAO(BasePixelfedComposeActivity.this, db).getStatus(currentToId);
if (storedStatus != null) {
- new StatusStoredDAO(PixelfedComposeActivity.this, db).updateStatus(currentToId, toot);
+ new StatusStoredDAO(BasePixelfedComposeActivity.this, db).updateStatus(currentToId, toot);
} else { //Might have been deleted, so it needs insertion
- new StatusStoredDAO(PixelfedComposeActivity.this, db).insertStatus(toot, null);
+ new StatusStoredDAO(BasePixelfedComposeActivity.this, db).insertStatus(toot, null, userId, instance);
}
}
if (message)
- Toasty.success(PixelfedComposeActivity.this, getString(R.string.toast_toot_saved), Toast.LENGTH_LONG).show();
+ Toasty.success(BasePixelfedComposeActivity.this, getString(R.string.toast_toot_saved), Toast.LENGTH_LONG).show();
} catch (Exception e) {
if (message)
- Toasty.error(PixelfedComposeActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
+ Toasty.error(BasePixelfedComposeActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
}
}
@@ -1923,7 +1953,11 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
active = false;
}
- static class asyncPicture extends AsyncTask {
+ protected abstract void launchPhotoEditor(Uri uri);
+
+ protected abstract void displayEmojiPopup();
+
+ static class asyncPicture {
String commpressedFilePath = null;
WeakReference activityWeakReference;
@@ -1932,53 +1966,51 @@ public class PixelfedComposeActivity extends BaseActivity implements UploadStatu
UploadServiceSingleBroadcastReceiver uploadReceiver;
String filename;
boolean pixelfedStory;
+ Account account;
- asyncPicture(Activity activity, boolean pixelfedStory, Uri uri, String filename, UploadServiceSingleBroadcastReceiver uploadReceiver) {
+ asyncPicture(Activity activity, boolean pixelfedStory, Account account, Uri uri, String filename, UploadServiceSingleBroadcastReceiver uploadReceiver) {
this.activityWeakReference = new WeakReference<>(activity);
this.uriFile = uri;
this.uploadReceiver = uploadReceiver;
this.filename = filename;
this.pixelfedStory = pixelfedStory;
- }
-
- @Override
- protected void onPreExecute() {
+ this.account = account;
if (uriFile == null) {
Toasty.error(activityWeakReference.get(), activityWeakReference.get().getString(R.string.toast_error), Toast.LENGTH_SHORT).show();
error = true;
}
activityWeakReference.get().findViewById(R.id.compression_loader).setVisibility(View.VISIBLE);
-
+ doInBackground();
}
-
- @Override
- protected Void doInBackground(Void... voids) {
- if (error) {
- return null;
- }
- commpressedFilePath = Helper.compressImagePath(activityWeakReference.get(), uriFile);
- return null;
- }
-
- @Override
- protected void onPostExecute(Void result) {
- activityWeakReference.get().findViewById(R.id.compression_loader).setVisibility(View.GONE);
- if (!error) {
- if (commpressedFilePath != null) {
- uriFile = Uri.fromFile(new File(commpressedFilePath));
+ protected void doInBackground() {
+ new Thread(() -> {
+ if (error) {
+ return;
}
- Button upload_media = this.activityWeakReference.get().findViewById(R.id.upload_media);
- Button toot_it = this.activityWeakReference.get().findViewById(R.id.toot_it);
- upload_media.setEnabled(false);
- toot_it.setEnabled(false);
- if (filename == null) {
- filename = Helper.getFileName(this.activityWeakReference.get(), uriFile);
- }
- filesMap.put(filename, uriFile);
- upload(activityWeakReference.get(), pixelfedStory, uriFile, filename, uploadReceiver);
- }
+ commpressedFilePath = Helper.compressImagePath(activityWeakReference.get(), uriFile);
+ Handler mainHandler = new Handler(Looper.getMainLooper());
+ Runnable myRunnable = () -> {
+ activityWeakReference.get().findViewById(R.id.compression_loader).setVisibility(View.GONE);
+ if (!error) {
+ if (commpressedFilePath != null) {
+ uriFile = Uri.fromFile(new File(commpressedFilePath));
+ }
+ Button upload_media = this.activityWeakReference.get().findViewById(R.id.upload_media);
+ Button toot_it = this.activityWeakReference.get().findViewById(R.id.toot_it);
+ upload_media.setEnabled(false);
+ toot_it.setEnabled(false);
+ if (filename == null) {
+ filename = Helper.getFileName(this.activityWeakReference.get(), uriFile);
+ }
+ filesMap.put(filename, uriFile);
+ upload(activityWeakReference.get(), pixelfedStory, account, uriFile, filename, uploadReceiver);
+ }
+ };
+ mainHandler.post(myRunnable);
+ }).start();
}
+
}
}
diff --git a/app/src/main/java/app/fedilab/android/activities/TootActivity.java b/app/src/main/java/app/fedilab/android/activities/BaseTootActivity.java
similarity index 78%
rename from app/src/main/java/app/fedilab/android/activities/TootActivity.java
rename to app/src/main/java/app/fedilab/android/activities/BaseTootActivity.java
index 6b702a6e8..005f4ad74 100644
--- a/app/src/main/java/app/fedilab/android/activities/TootActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/BaseTootActivity.java
@@ -22,7 +22,6 @@ import android.content.BroadcastReceiver;
import android.content.ClipData;
import android.content.ContentResolver;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
@@ -30,10 +29,10 @@ import android.content.pm.PackageManager;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.Color;
+import android.graphics.Paint;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
-import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
@@ -46,6 +45,7 @@ import android.text.InputFilter;
import android.text.InputType;
import android.text.SpannableString;
import android.text.TextWatcher;
+import android.text.format.DateFormat;
import android.text.style.ForegroundColorSpan;
import android.util.Patterns;
import android.view.LayoutInflater;
@@ -85,7 +85,6 @@ import androidx.appcompat.widget.SwitchCompat;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.core.content.FileProvider;
-import androidx.fragment.app.DialogFragment;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import androidx.preference.PreferenceManager;
import androidx.recyclerview.widget.LinearLayoutManager;
@@ -97,11 +96,8 @@ import com.bumptech.glide.request.transition.Transition;
import com.github.irshulx.Editor;
import com.github.irshulx.EditorListener;
import com.github.irshulx.models.EditorTextStyle;
-import com.github.stom79.localepicker.CountryPicker;
-import com.github.stom79.mytransl.MyTransL;
-import com.github.stom79.mytransl.client.HttpsConnectionException;
-import com.github.stom79.mytransl.translate.Translate;
-import com.vanniktech.emoji.EmojiPopup;
+import com.watermark.androidwm_light.WatermarkBuilder;
+import com.watermark.androidwm_light.bean.WatermarkText;
import net.gotev.uploadservice.MultipartUploadRequest;
import net.gotev.uploadservice.ServerResponse;
@@ -115,6 +111,8 @@ import org.jetbrains.annotations.NotNull;
import org.json.JSONException;
import org.json.JSONObject;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
@@ -136,7 +134,6 @@ import java.util.Map;
import java.util.Objects;
import java.util.Random;
import java.util.UUID;
-import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -215,21 +212,27 @@ import static app.fedilab.android.helper.Helper.isValidContextForGlide;
* Toot activity class
*/
-public class TootActivity extends BaseActivity implements UploadStatusDelegate, OnPostActionInterface, OnRetrieveSearcAccountshInterface, OnPostStatusActionInterface, OnRetrieveSearchInterface, OnRetrieveAccountsReplyInterface, OnRetrieveEmojiInterface, OnDownloadInterface, OnRetrieveAttachmentInterface, OnRetrieveRelationshipInterface {
+public abstract class BaseTootActivity extends BaseActivity implements UploadStatusDelegate, OnPostActionInterface, OnRetrieveSearcAccountshInterface, OnPostStatusActionInterface, OnRetrieveSearchInterface, OnRetrieveAccountsReplyInterface, OnRetrieveEmojiInterface, OnDownloadInterface, OnRetrieveAttachmentInterface, OnRetrieveRelationshipInterface {
public static final int MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE = 754;
public static final int REQUEST_CAMERA_PERMISSION_RESULT = 1653;
public static final int SEND_VOICE_MESSAGE = 1423;
+ private static final int searchDeep = 15;
public static HashMap filesMap;
public static boolean autocomplete;
public static Uri photoFileUri = null;
static boolean active = false;
private static String instance;
- private static int searchDeep = 15;
private final int PICK_IMAGE = 56556;
private final int TAKE_PHOTO = 56532;
public long currentToId;
+ protected MastalabAutoCompleteTextView toot_content;
+ protected EditText toot_cw_content;
+ protected LinearLayout drawer_layout;
+ protected ImageButton toot_emoji;
+ protected int style;
+ protected int theme;
List emojis;
String mCurrentPhotoPath;
File photoFile = null;
@@ -240,8 +243,6 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
private boolean isSensitive = false;
private ImageButton toot_visibility;
private Button toot_it;
- private MastalabAutoCompleteTextView toot_content;
- private EditText toot_cw_content;
private Status tootReply = null;
private String tootMention = null;
private String urlMention = null;
@@ -252,13 +253,10 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
private ImageView pp_actionBar;
private ProgressBar pp_progress;
private Toast mToast;
- private LinearLayout drawer_layout;
private HorizontalScrollView picture_scrollview;
private TextView toot_space_left;
private String initialContent;
private Account accountReply;
- private View popup_trans;
- private AlertDialog dialogTrans;
private AlertDialog alertDialogEmoji;
private String mentionAccount;
private Status idRedirect;
@@ -268,7 +266,6 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
private int stepSpliToot;
private boolean removed;
private boolean restoredScheduled;
- private int style;
private StoredStatus scheduledstatus;
private boolean isScheduled;
private List checkedValues;
@@ -280,35 +277,35 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
private Poll poll;
private ImageButton poll_action;
private int pollCountItem;
- private UploadServiceSingleBroadcastReceiver uploadReceiver;
private String quickmessagecontent, quickmessagevisibility;
private TextView warning_message;
private Editor wysiwyg;
private EditText wysiwygEditText;
private String url_for_media;
private UpdateAccountInfoAsyncTask.SOCIAL social;
- private BroadcastReceiver imageReceiver = new BroadcastReceiver() {
+ private final BroadcastReceiver imageReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String imgpath = intent.getStringExtra("imgpath");
if (imgpath != null) {
- prepareUpload(TootActivity.this, Uri.fromFile(new File(imgpath)), null, uploadReceiver);
+ prepareUpload(BaseTootActivity.this, Uri.fromFile(new File(imgpath)), null);
}
}
};
- private BroadcastReceiver add_new_media = new BroadcastReceiver() {
+ private final BroadcastReceiver add_new_media = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
- JSONObject response = null;
+ JSONObject response;
ArrayList successfullyUploadedFiles;
try {
response = new JSONObject(Objects.requireNonNull(intent.getStringExtra("response")));
+ successfullyUploadedFiles = intent.getStringArrayListExtra("uploadInfo");
+ addNewMedia(response, successfullyUploadedFiles);
} catch (JSONException e) {
e.printStackTrace();
}
- successfullyUploadedFiles = intent.getStringArrayListExtra("uploadInfo");
- addNewMedia(response, successfullyUploadedFiles);
+
}
};
@@ -329,7 +326,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
final int[] currentCursorPosition = {toot_content.getSelectionStart()};
final String[] newContent = {null};
final int[] searchLength = {searchDeep};
- TextWatcher textw = null;
+ TextWatcher textw;
textw = new TextWatcher() {
@Override
@@ -474,7 +471,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
pp_progress.setVisibility(View.VISIBLE);
pp_actionBar.setVisibility(View.GONE);
}
- new RetrieveSearchAccountsAsyncTask(context, search, listenerAccount).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveSearchAccountsAsyncTask(context, search, listenerAccount);
} else {
mt = tPattern.matcher(searchIn);
if (mt.matches()) {
@@ -483,7 +480,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
pp_progress.setVisibility(View.VISIBLE);
pp_actionBar.setVisibility(View.GONE);
}
- new RetrieveSearchAsyncTask(context, search, true, listener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveSearchAsyncTask(context, search, true, listener);
} else {
mt = ePattern.matcher(searchIn);
if (mt.matches()) {
@@ -492,7 +489,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
pp_progress.setVisibility(View.VISIBLE);
pp_actionBar.setVisibility(View.GONE);
}
- new RetrieveEmojiAsyncTask(context, shortcode, listenerEmoji).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveEmojiAsyncTask(context, shortcode, listenerEmoji);
} else {
toot_content.dismissDropDown();
}
@@ -512,8 +509,55 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (uploadReceiver != null) {
uploadReceiver.setUploadID(uploadId);
}
- Uri uri;
InputStream tempInput = null;
+ SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
+ 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 + 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(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 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;
+ WatermarkText watermarkText = new WatermarkText(WMText)
+ .setPositionX(valx)
+ .setPositionY(valy)
+ .setTextColor(Color.WHITE)
+ .setTextShadow(0.1f, 1, 1, Color.LTGRAY)
+ .setTextAlpha(200)
+ .setRotation(0)
+ .setTextSize(textSize);
+
+ Bitmap bitmap = WatermarkBuilder
+ .create(activity, backgroundBitmap)
+ .loadWatermarkText(watermarkText)
+ .getWatermark()
+ .getOutputImage();
+
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ bitmap.compress(Bitmap.CompressFormat.PNG, 0, bos);
+ byte[] bitmapdata = bos.toByteArray();
+ tempInput = new ByteArrayInputStream(bitmapdata);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ Uri uri;
FileOutputStream tempOut = null;
String filename = inUri.toString().substring(inUri.toString().lastIndexOf("/"));
int suffixPosition = filename.lastIndexOf(".");
@@ -521,7 +565,9 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (suffixPosition > 0) suffix = filename.substring(suffixPosition);
try {
File file;
- tempInput = activity.getContentResolver().openInputStream(inUri);
+ if (tempInput == null) {
+ tempInput = activity.getContentResolver().openInputStream(inUri);
+ }
if (fname.startsWith("fedilabins_")) {
file = File.createTempFile("fedilabins_randomTemp1", suffix, activity.getCacheDir());
} else {
@@ -541,9 +587,15 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
"fr.gouv.etalab.mastodon.fileProvider",
file);
} else {
- uri = FileProvider.getUriForFile(activity,
- "app.fedilab.android.fileProvider",
- file);
+ if (BuildConfig.lite) {
+ uri = FileProvider.getUriForFile(activity,
+ "app.fedilab.lite.fileProvider",
+ file);
+ } else {
+ uri = FileProvider.getUriForFile(activity,
+ "app.fedilab.android.fileProvider",
+ file);
+ }
}
tempInput.close();
tempOut.close();
@@ -557,7 +609,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
try {
final String fileName = FileNameCleaner.cleanFileName(fname);
- SharedPreferences sharedpreferences = activity.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
+
String scheme = sharedpreferences.getString(Helper.SET_ONION_SCHEME + account.getInstance(), "https");
String token = account.getToken();
@@ -698,7 +750,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
super.onCreate(savedInstanceState);
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
- instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(TootActivity.this));
+ instance = sharedpreferences.getString(Helper.PREF_INSTANCE, Helper.getLiveInstance(BaseTootActivity.this));
final int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
switch (theme) {
case Helper.THEME_LIGHT:
@@ -727,8 +779,8 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (actionBar != null) {
LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
assert inflater != null;
- View view = inflater.inflate(R.layout.toot_action_bar, new LinearLayout(TootActivity.this), false);
- view.setBackground(new ColorDrawable(ContextCompat.getColor(TootActivity.this, R.color.cyanea_primary)));
+ View view = inflater.inflate(R.layout.toot_action_bar, new LinearLayout(BaseTootActivity.this), false);
+ view.setBackground(new ColorDrawable(ContextCompat.getColor(BaseTootActivity.this, R.color.cyanea_primary)));
actionBar.setCustomView(view, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
ImageView close_toot = actionBar.getCustomView().findViewById(R.id.close_toot);
@@ -746,14 +798,10 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
} else if (displayWYSIWYG() && initialContent.trim().equals(wysiwyg.getContentAsHTML().trim())) {
finish();
} else {
- AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(TootActivity.this, style);
+ AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(BaseTootActivity.this, style);
dialogBuilder.setMessage(R.string.save_draft);
dialogBuilder.setPositiveButton(R.string.save, (dialog, id) -> {
- if (accountReply == null) {
- storeToot(true, false);
- } else {
- storeToot(false, false);
- }
+ storeToot(accountReply == null, false);
dialog.dismiss();
finish();
});
@@ -798,7 +846,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
picture_scrollview = findViewById(R.id.picture_scrollview);
toot_sensitive = findViewById(R.id.toot_sensitive);
drawer_layout = findViewById(R.id.drawer_layout);
- ImageButton toot_emoji = findViewById(R.id.toot_emoji);
+ toot_emoji = findViewById(R.id.toot_emoji);
warning_message = findViewById(R.id.warning_message);
poll_action = findViewById(R.id.poll_action);
@@ -809,45 +857,37 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (inputContentInfo != null) {
Uri uri = inputContentInfo.getContentUri();
- String filename = Helper.getFileName(TootActivity.this, uri);
+ String filename = Helper.getFileName(BaseTootActivity.this, uri);
ContentResolver cr = getContentResolver();
String mime = cr.getType(uri);
if (mime != null && (mime.toLowerCase().contains("video") || mime.toLowerCase().contains("gif"))) {
- prepareUpload(TootActivity.this, uri, filename, uploadReceiver);
+ prepareUpload(BaseTootActivity.this, uri, filename);
} else if (mime != null && mime.toLowerCase().contains("image")) {
if (photo_editor) {
- Intent intent = new Intent(TootActivity.this, PhotoEditorActivity.class);
- Bundle b = new Bundle();
- intent.putExtra("imageUri", uri.toString());
- intent.putExtras(b);
- startActivity(intent);
+ launchPhotoEditor(uri);
} else {
- prepareUpload(TootActivity.this, uri, filename, uploadReceiver);
+ prepareUpload(BaseTootActivity.this, uri, filename);
}
} else if (mime != null && mime.toLowerCase().contains("audio")) {
- prepareUpload(TootActivity.this, uri, filename, uploadReceiver);
+ prepareUpload(BaseTootActivity.this, uri, filename);
} else {
- Toasty.error(TootActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
+ Toasty.error(BaseTootActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
}
}
});
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(TootActivity.this);
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(BaseTootActivity.this);
int iconColor = prefs.getInt("theme_icons_color", -1);
if (iconColor != -1) {
- Helper.changeDrawableColor(TootActivity.this, toot_emoji, iconColor);
- Helper.changeDrawableColor(TootActivity.this, toot_visibility, iconColor);
- Helper.changeDrawableColor(TootActivity.this, poll_action, iconColor);
- Helper.changeDrawableColor(TootActivity.this, toot_picture, iconColor);
+ Helper.changeDrawableColor(BaseTootActivity.this, toot_emoji, iconColor);
+ Helper.changeDrawableColor(BaseTootActivity.this, toot_visibility, iconColor);
+ Helper.changeDrawableColor(BaseTootActivity.this, poll_action, iconColor);
+ Helper.changeDrawableColor(BaseTootActivity.this, toot_picture, iconColor);
}
isScheduled = false;
if (sharedpreferences.getBoolean(Helper.SET_DISPLAY_EMOJI, false)) {
- final EmojiPopup emojiPopup = EmojiPopup.Builder.fromRootView(drawer_layout).build(toot_content);
-
- toot_emoji.setOnClickListener(v -> {
- emojiPopup.toggle(); // Toggles visibility of the Popup.
- });
+ displayEmojiPopup();
} else {
toot_emoji.setVisibility(View.GONE);
}
@@ -907,7 +947,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
pp_progress.setVisibility(View.VISIBLE);
pp_actionBar.setVisibility(View.GONE);
}
- new RetrieveSearchAccountsAsyncTask(TootActivity.this, search, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveSearchAccountsAsyncTask(BaseTootActivity.this, search, BaseTootActivity.this);
} else {
mt = tPattern.matcher(searchIn);
if (mt.matches()) {
@@ -916,7 +956,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
pp_progress.setVisibility(View.VISIBLE);
pp_actionBar.setVisibility(View.GONE);
}
- new RetrieveSearchAsyncTask(TootActivity.this, search, true, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveSearchAsyncTask(BaseTootActivity.this, search, true, BaseTootActivity.this);
} else {
mt = ePattern.matcher(searchIn);
if (mt.matches()) {
@@ -925,7 +965,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
pp_progress.setVisibility(View.VISIBLE);
pp_actionBar.setVisibility(View.GONE);
}
- new RetrieveEmojiAsyncTask(TootActivity.this, shortcode, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveEmojiAsyncTask(BaseTootActivity.this, shortcode, BaseTootActivity.this);
}
}
}
@@ -949,15 +989,15 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
drawer_layout.getViewTreeObserver().addOnGlobalLayoutListener(() -> {
int heightDiff = drawer_layout.getRootView().getHeight() - drawer_layout.getHeight();
- if (heightDiff > Helper.convertDpToPixel(200, TootActivity.this)) {
+ if (heightDiff > Helper.convertDpToPixel(200, BaseTootActivity.this)) {
ViewGroup.LayoutParams params = toot_picture_container.getLayoutParams();
- params.height = (int) Helper.convertDpToPixel(50, TootActivity.this);
- params.width = (int) Helper.convertDpToPixel(50, TootActivity.this);
+ params.height = (int) Helper.convertDpToPixel(50, BaseTootActivity.this);
+ params.width = (int) Helper.convertDpToPixel(50, BaseTootActivity.this);
toot_picture_container.setLayoutParams(params);
} else {
ViewGroup.LayoutParams params = toot_picture_container.getLayoutParams();
- params.height = (int) Helper.convertDpToPixel(100, TootActivity.this);
- params.width = (int) Helper.convertDpToPixel(100, TootActivity.this);
+ params.height = (int) Helper.convertDpToPixel(100, BaseTootActivity.this);
+ params.width = (int) Helper.convertDpToPixel(100, BaseTootActivity.this);
toot_picture_container.setLayoutParams(params);
}
});
@@ -974,7 +1014,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (accountReplyToken != null) {
String[] val = accountReplyToken.split("\\|");
if (val.length == 2) {
- accountReply = new AccountDAO(TootActivity.this, db).getUniqAccount(val[0], val[1]);
+ accountReply = new AccountDAO(BaseTootActivity.this, db).getUniqAccount(val[0], val[1]);
}
}
tootMention = b.getString("tootMention", null);
@@ -1011,7 +1051,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
warning_message.setVisibility(View.VISIBLE);
}
assert tootReply.getAccount() != null;
- new RetrieveRelationshipAsyncTask(TootActivity.this, tootReply.getAccount().getId(), TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveRelationshipAsyncTask(BaseTootActivity.this, tootReply.getAccount().getId(), BaseTootActivity.this);
}
if (scheduledstatus != null)
toot_it.setText(R.string.modify);
@@ -1028,7 +1068,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
instanceReply = accountReply.getInstance();
}
if (accountReply == null)
- account = new AccountDAO(TootActivity.this, db).getUniqAccount(userIdReply, instanceReply);
+ account = new AccountDAO(BaseTootActivity.this, db).getUniqAccount(userIdReply, instanceReply);
else
account = accountReply;
@@ -1095,7 +1135,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
initialContent = displayWYSIWYG() ? wysiwyg.getContentAsHTML() : toot_content.getText().toString();
- Helper.loadGiF(TootActivity.this, account, pp_actionBar);
+ Helper.loadGiF(BaseTootActivity.this, account, pp_actionBar);
if (sharedContent != null) { //Shared content
@@ -1121,7 +1161,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
toot_space_left.setText(String.valueOf(countLength(social, toot_content, toot_cw_content)));
}
if (image != null) {
- new HttpsConnection(TootActivity.this, instance).download(image, TootActivity.this);
+ new HttpsConnection(BaseTootActivity.this, instance).download(image, BaseTootActivity.this);
}
int selectionBefore = toot_content.getSelectionStart();
toot_content.setText(String.format("\n%s", sharedContent));
@@ -1185,23 +1225,19 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA && !displayWYSIWYG())
toot_it.setOnLongClickListener(v -> {
- PopupMenu popup = new PopupMenu(TootActivity.this, toot_it);
+ PopupMenu popup = new PopupMenu(BaseTootActivity.this, toot_it);
popup.getMenuInflater()
.inflate(R.menu.main_content_type, popup.getMenu());
popup.setOnMenuItemClickListener(item -> {
- switch (item.getItemId()) {
- case R.id.action_plain_text:
- contentType = "text/plain";
- break;
- case R.id.action_html:
- contentType = "text/html";
- break;
- case R.id.action_markdown:
- contentType = "text/markdown";
- break;
- case R.id.action_bbcode:
- contentType = "text/bbcode";
- break;
+ int itemId = item.getItemId();
+ if (itemId == R.id.action_plain_text) {
+ contentType = "text/plain";
+ } else if (itemId == R.id.action_html) {
+ contentType = "text/html";
+ } else if (itemId == R.id.action_markdown) {
+ contentType = "text/markdown";
+ } else if (itemId == R.id.action_bbcode) {
+ contentType = "text/bbcode";
}
popup.dismiss();
sendToot(null, contentType);
@@ -1213,9 +1249,9 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
toot_picture.setOnClickListener(v -> {
- if (ContextCompat.checkSelfPermission(TootActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) !=
+ if (ContextCompat.checkSelfPermission(BaseTootActivity.this, Manifest.permission.READ_EXTERNAL_STORAGE) !=
PackageManager.PERMISSION_GRANTED) {
- ActivityCompat.requestPermissions(TootActivity.this,
+ ActivityCompat.requestPermissions(BaseTootActivity.this,
new String[]{Manifest.permission.READ_EXTERNAL_STORAGE},
MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE);
return;
@@ -1223,20 +1259,11 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
Intent intent;
intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
- intent.setType("*/*");
- intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
- String[] mimetypes = {"image/*", "video/*", "audio/mpeg", "audio/opus", "audio/flac", "audio/wav", "audio/ogg"};
- intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes);
- startActivityForResult(intent, PICK_IMAGE);
- } else {
- intent.setType("image/* video/* audio/mpeg audio/opus audio/flac audio/wav audio/ogg");
- intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
- Intent pickIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
- Intent chooserIntent = Intent.createChooser(intent, getString(R.string.toot_select_image));
- chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{pickIntent});
- startActivityForResult(chooserIntent, PICK_IMAGE);
- }
+ intent.setType("*/*");
+ intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
+ String[] mimetypes = {"image/*", "video/*", "audio/mpeg", "audio/opus", "audio/flac", "audio/wav", "audio/ogg"};
+ intent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes);
+ startActivityForResult(intent, PICK_IMAGE);
});
@@ -1256,7 +1283,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
}
});
- TextWatcher textWatcher = initializeTextWatcher(TootActivity.this, social, null, toot_content, toot_cw_content, toot_space_left, pp_actionBar, pp_progress, TootActivity.this, TootActivity.this, TootActivity.this);
+ TextWatcher textWatcher = initializeTextWatcher(BaseTootActivity.this, social, null, toot_content, toot_cw_content, toot_space_left, pp_actionBar, pp_progress, BaseTootActivity.this, BaseTootActivity.this, BaseTootActivity.this);
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA)
toot_content.addTextChangedListener(textWatcher);
@@ -1276,9 +1303,6 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
.registerReceiver(imageReceiver,
new IntentFilter(Helper.INTENT_SEND_MODIFIED_IMAGE));
- uploadReceiver = new UploadServiceSingleBroadcastReceiver(this);
- uploadReceiver.register(this);
-
LocalBroadcastManager.getInstance(this)
.registerReceiver(add_new_media,
new IntentFilter(Helper.INTENT_ADD_UPLOADED_MEDIA));
@@ -1289,7 +1313,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
Attachment attachment;
//response = new JSONObject(serverResponse.getBodyAsString());
if (response == null) {
- Toasty.error(TootActivity.this, getString(R.string.toast_error), Toasty.LENGTH_SHORT).show();
+ Toasty.error(BaseTootActivity.this, getString(R.string.toast_error), Toasty.LENGTH_SHORT).show();
return;
}
if (social != UpdateAccountInfoAsyncTask.SOCIAL.GNU && social != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
@@ -1321,7 +1345,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
url = attachment.getUrl();
- final ImageView imageView = new ImageView(TootActivity.this);
+ final ImageView imageView = new ImageView(BaseTootActivity.this);
Random rand = new Random();
int n = rand.nextInt(10000000);
imageView.setId(n);
@@ -1393,7 +1417,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
LinearLayout.LayoutParams imParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
imParams.setMargins(20, 5, 20, 5);
- imParams.height = (int) Helper.convertDpToPixel(100, TootActivity.this);
+ imParams.height = (int) Helper.convertDpToPixel(100, BaseTootActivity.this);
imageView.setAdjustViewBounds(true);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
final SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
@@ -1455,7 +1479,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (mToast != null) {
mToast.cancel();
}
- mToast = Toasty.error(TootActivity.this, message, Toast.LENGTH_SHORT);
+ mToast = Toasty.error(BaseTootActivity.this, message, Toast.LENGTH_SHORT);
mToast.show();
}
@@ -1470,16 +1494,16 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
}
picture_scrollview.setVisibility(View.VISIBLE);
try {
- prepareUpload(TootActivity.this, fileUri, null, uploadReceiver);
+ prepareUpload(BaseTootActivity.this, fileUri, null);
count++;
} catch (Exception e) {
e.printStackTrace();
- Toasty.error(TootActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
+ Toasty.error(BaseTootActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
toot_picture.setEnabled(true);
toot_it.setEnabled(true);
}
} else {
- Toasty.error(TootActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
+ Toasty.error(BaseTootActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
}
}
}
@@ -1493,7 +1517,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
try {
photoFile = createImageFile();
} catch (IOException ignored) {
- Toasty.error(TootActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
+ Toasty.error(BaseTootActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
}
// Continue only if the File was successfully created
if (photoFile != null) {
@@ -1502,9 +1526,15 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
"fr.gouv.etalab.mastodon.fileProvider",
photoFile);
} else {
- photoFileUri = FileProvider.getUriForFile(this,
- "app.fedilab.android.fileProvider",
- photoFile);
+ if (BuildConfig.lite) {
+ photoFileUri = FileProvider.getUriForFile(this,
+ "app.fedilab.lite.fileProvider",
+ photoFile);
+ } else {
+ photoFileUri = FileProvider.getUriForFile(this,
+ "app.fedilab.android.fileProvider",
+ photoFile);
+ }
}
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoFileUri);
startActivityForResult(takePictureIntent, TAKE_PHOTO);
@@ -1534,13 +1564,13 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
boolean photo_editor = sharedpreferences.getBoolean(Helper.SET_PHOTO_EDITOR, true);
if (requestCode == PICK_IMAGE && resultCode == RESULT_OK) {
if (data == null) {
- Toasty.error(TootActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
+ Toasty.error(BaseTootActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
return;
}
ClipData clipData = data.getClipData();
if (data.getData() == null && clipData == null) {
- Toasty.error(TootActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
+ Toasty.error(BaseTootActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
return;
}
@@ -1553,61 +1583,51 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
}
uploadSharedImage(mArrayUri);
} else {
- String filename = Helper.getFileName(TootActivity.this, data.getData());
+ String filename = Helper.getFileName(BaseTootActivity.this, data.getData());
ContentResolver cr = getContentResolver();
String mime = cr.getType(data.getData());
if (mime != null && (mime.toLowerCase().contains("video") || mime.toLowerCase().contains("gif"))) {
- prepareUpload(TootActivity.this, data.getData(), filename, uploadReceiver);
+ prepareUpload(BaseTootActivity.this, data.getData(), filename);
} else if (mime != null && mime.toLowerCase().contains("image")) {
if (photo_editor) {
- Intent intent = new Intent(TootActivity.this, PhotoEditorActivity.class);
- Bundle b = new Bundle();
- intent.putExtra("imageUri", data.getData().toString());
- intent.putExtras(b);
- startActivity(intent);
+ launchPhotoEditor(data.getData());
} else {
- prepareUpload(TootActivity.this, data.getData(), filename, uploadReceiver);
+ prepareUpload(BaseTootActivity.this, data.getData(), filename);
}
} else if (mime != null && mime.toLowerCase().contains("audio")) {
- prepareUpload(TootActivity.this, data.getData(), filename, uploadReceiver);
+ prepareUpload(BaseTootActivity.this, data.getData(), filename);
} else {
- Toasty.error(TootActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
+ Toasty.error(BaseTootActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
}
}
} else if (requestCode == SEND_VOICE_MESSAGE && resultCode == RESULT_OK) {
Uri uri = Uri.fromFile(new File(getCacheDir() + "/fedilab_recorded_audio.wav"));
- prepareUpload(TootActivity.this, uri, "fedilab_recorded_audio.wav", uploadReceiver);
+ prepareUpload(BaseTootActivity.this, uri, "fedilab_recorded_audio.wav");
} else if (requestCode == TAKE_PHOTO && resultCode == RESULT_OK) {
if (photo_editor) {
- Intent intent = new Intent(TootActivity.this, PhotoEditorActivity.class);
- Bundle b = new Bundle();
- intent.putExtra("imageUri", photoFileUri.toString());
- intent.putExtras(b);
- startActivity(intent);
+ launchPhotoEditor(photoFileUri);
} else {
- prepareUpload(TootActivity.this, photoFileUri, null, uploadReceiver);
+ prepareUpload(BaseTootActivity.this, photoFileUri, null);
}
} else if (requestCode == wysiwyg.PICK_IMAGE_REQUEST && resultCode == Activity.RESULT_OK && data != null && data.getData() != null) {
- String filename = Helper.getFileName(TootActivity.this, data.getData());
- prepareUpload(TootActivity.this, data.getData(), "fedilabins_" + filename, uploadReceiver);
+ String filename = Helper.getFileName(BaseTootActivity.this, data.getData());
+ prepareUpload(BaseTootActivity.this, data.getData(), "fedilabins_" + filename);
}
}
- private void prepareUpload(Activity activity, android.net.Uri uri, String filename, UploadServiceSingleBroadcastReceiver uploadReceiver) {
- if (uploadReceiver == null) {
- uploadReceiver = new UploadServiceSingleBroadcastReceiver(TootActivity.this);
- uploadReceiver.register(this);
- }
- new asyncPicture(activity, account, social, uri, filename, uploadReceiver).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ private void prepareUpload(Activity activity, android.net.Uri uri, String filename) {
+ UploadServiceSingleBroadcastReceiver uploadReceiver = new UploadServiceSingleBroadcastReceiver(BaseTootActivity.this);
+ uploadReceiver.register(this);
+ new asyncPicture(activity, account, social, uri, filename, uploadReceiver);
}
@Override
public void onPostAction(int statusCode, API.StatusAction statusAction, String userId, Error error) {
if (error != null) {
- Toasty.error(TootActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
+ Toasty.error(BaseTootActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
} else {
- Toasty.success(TootActivity.this, getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show();
+ Toasty.success(BaseTootActivity.this, getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show();
resetForNextToot();
}
}
@@ -1620,7 +1640,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
@Override
public void onError(Context context, UploadInfo uploadInfo, ServerResponse serverResponse,
Exception exception) {
- Toasty.error(TootActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
+ Toasty.error(BaseTootActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
if (attachments.size() == 0)
toot_picture_container.setVisibility(View.GONE);
toot_picture.setEnabled(true);
@@ -1661,12 +1681,12 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (extras != null && extras.getString("imageUri") != null) {
Uri imageUri = Uri.parse(extras.getString("imageUri"));
if (imageUri == null) {
- Toasty.error(TootActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
+ Toasty.error(BaseTootActivity.this, getString(R.string.toot_select_image_error), Toast.LENGTH_LONG).show();
return;
}
- String filename = Helper.getFileName(TootActivity.this, imageUri);
+ String filename = Helper.getFileName(BaseTootActivity.this, imageUri);
- prepareUpload(TootActivity.this, imageUri, filename, uploadReceiver);
+ prepareUpload(BaseTootActivity.this, imageUri, filename);
}
}
@@ -1677,7 +1697,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
final SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
int style;
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
- int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
+ theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
if (theme == Helper.THEME_DARK) {
style = R.style.DialogDark;
} else if (theme == Helper.THEME_BLACK) {
@@ -1686,420 +1706,281 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
style = R.style.Dialog;
}
- switch (item.getItemId()) {
- case android.R.id.home:
- finish();
- return true;
- case R.id.action_view_reply:
- AlertDialog.Builder alert = new AlertDialog.Builder(TootActivity.this, style);
- alert.setTitle(R.string.toot_reply_content_title);
- final TextView input = new TextView(TootActivity.this);
- //Set the padding
- input.setPadding(30, 30, 30, 30);
- alert.setView(input);
- String content = tootReply.getContent();
- if (tootReply.getReblog() != null)
- content = tootReply.getReblog().getContent();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
- input.setText(Html.fromHtml(content, Html.FROM_HTML_MODE_LEGACY));
- else
- input.setText(Html.fromHtml(content));
- alert.setPositiveButton(R.string.close, (dialog, whichButton) -> dialog.dismiss());
- alert.setNegativeButton(R.string.accounts, (dialog, whichButton) -> {
- new RetrieveAccountsForReplyAsyncTask(TootActivity.this, tootReply.getReblog() != null ? tootReply.getReblog() : tootReply, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- dialog.dismiss();
+ int itemId = item.getItemId();
+ if (itemId == android.R.id.home) {
+ finish();
+ return true;
+ } else if (itemId == R.id.action_view_reply) {
+ AlertDialog.Builder alert = new AlertDialog.Builder(BaseTootActivity.this, style);
+ alert.setTitle(R.string.toot_reply_content_title);
+ final TextView input = new TextView(BaseTootActivity.this);
+ //Set the padding
+ input.setPadding(30, 30, 30, 30);
+ alert.setView(input);
+ String content = tootReply.getContent();
+ if (tootReply.getReblog() != null)
+ content = tootReply.getReblog().getContent();
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
+ input.setText(Html.fromHtml(content, Html.FROM_HTML_MODE_LEGACY));
+ else
+ input.setText(Html.fromHtml(content));
+ alert.setPositiveButton(R.string.close, (dialog, whichButton) -> dialog.dismiss());
+ alert.setNegativeButton(R.string.accounts, (dialog, whichButton) -> {
+ new RetrieveAccountsForReplyAsyncTask(BaseTootActivity.this, tootReply.getReblog() != null ? tootReply.getReblog() : tootReply, BaseTootActivity.this);
+ dialog.dismiss();
+ });
+ alert.show();
+ return true;
+ } else if (itemId == R.id.action_poll) {
+ displayPollPopup();
+ return false;
+ } else if (itemId == R.id.action_translate) {
+ return actionTranslateClick();
+ } else if (itemId == R.id.action_emoji) {
+ if (emojis != null) {
+ emojis.clear();
+ emojis = null;
+ }
+ emojis = new CustomEmojiDAO(BaseTootActivity.this, db).getAllEmojis(account.getInstance());
+ final AlertDialog.Builder builder = new AlertDialog.Builder(this, style);
+ int paddingPixel = 15;
+ float density = getResources().getDisplayMetrics().density;
+ int paddingDp = (int) (paddingPixel * density);
+ builder.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
+ builder.setTitle(R.string.insert_emoji);
+ if (emojis != null && emojis.size() > 0) {
+ GridView gridView = new GridView(BaseTootActivity.this);
+ gridView.setAdapter(new CustomEmojiAdapter(emojis));
+ gridView.setNumColumns(5);
+ gridView.setOnItemClickListener((parent, view, position, id) -> {
+ toot_content.getText().insert(toot_content.getSelectionStart(), " :" + emojis.get(position).getShortcode() + ": ");
+ alertDialogEmoji.dismiss();
});
- alert.show();
- return true;
+ gridView.setPadding(paddingDp, paddingDp, paddingDp, paddingDp);
+ builder.setView(gridView);
+ } else {
+ TextView textView = new TextView(BaseTootActivity.this);
+ textView.setText(getString(R.string.no_emoji));
+ textView.setPadding(paddingDp, paddingDp, paddingDp, paddingDp);
+ builder.setView(textView);
+ }
+ alertDialogEmoji = builder.show();
+
+
+ return true;
+ } else if (itemId == R.id.action_photo_camera) {
+ dispatchTakePictureIntent();
+ return true;
+ } else if (itemId == R.id.action_contacts) {
+ AlertDialog.Builder builderSingle = new AlertDialog.Builder(BaseTootActivity.this, style);
+
+ builderSingle.setTitle(getString(R.string.select_accounts));
+ LayoutInflater inflater = getLayoutInflater();
+ View dialogView = inflater.inflate(R.layout.popup_contact, new LinearLayout(BaseTootActivity.this), false);
+
+ loader = dialogView.findViewById(R.id.loader);
+ EditText search_account = dialogView.findViewById(R.id.search_account);
+ lv_accounts_search = dialogView.findViewById(R.id.lv_accounts_search);
+ loader.setVisibility(View.VISIBLE);
+ new RetrieveSearchAccountsAsyncTask(BaseTootActivity.this, "a", true, BaseTootActivity.this);
+
+ search_account.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) {
+ if (count > 0) {
+ search_account.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_close, 0);
+ } else {
+ search_account.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_search, 0);
+ }
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ if (s != null && s.length() > 0) {
+ new RetrieveSearchAccountsAsyncTask(BaseTootActivity.this, s.toString(), true, BaseTootActivity.this);
+ }
+ }
+ });
+ search_account.setOnTouchListener((v, event) -> {
+ final int DRAWABLE_RIGHT = 2;
+ if (event.getAction() == MotionEvent.ACTION_UP) {
+ if (search_account.length() > 0 && event.getRawX() >= (search_account.getRight() - search_account.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
+ search_account.setText("");
+ new RetrieveSearchAccountsAsyncTask(BaseTootActivity.this, "a", true, BaseTootActivity.this);
+ }
+ }
- case R.id.action_poll:
- displayPollPopup();
return false;
- case R.id.action_translate:
- final CountryPicker picker = CountryPicker.newInstance(getString(R.string.which_language)); // dialog title
- if (theme == Helper.THEME_LIGHT) {
- picker.setStyle(DialogFragment.STYLE_NO_TITLE, R.style.Dialog);
- } else {
- picker.setStyle(DialogFragment.STYLE_NO_TITLE, R.style.DialogDark);
- }
- if (toot_content.getText().length() == 0 && toot_cw_content.getText().length() == 0)
- return true;
- String dateString = sharedpreferences.getString(Helper.LAST_TRANSLATION_TIME, null);
- if (dateString != null) {
- Date dateCompare = Helper.stringToDate(TootActivity.this, dateString);
- Date date = new Date();
- if (date.before(dateCompare)) {
- Toasty.info(TootActivity.this, getString(R.string.please_wait), Toast.LENGTH_SHORT).show();
- return true;
- }
- }
- picker.setListener((name, locale, flagDrawableResID) -> {
- picker.dismiss();
- AlertDialog.Builder transAlert = new AlertDialog.Builder(TootActivity.this, style);
- transAlert.setTitle(R.string.translate_toot);
+ });
+ builderSingle.setView(dialogView);
+ builderSingle.setNegativeButton(R.string.validate, (dialog, which) -> {
+ dialog.dismiss();
+ toot_content.setSelection(toot_content.getText().length());
+ });
+ builderSingle.show();
- popup_trans = getLayoutInflater().inflate(R.layout.popup_translate, new LinearLayout(TootActivity.this), false);
- transAlert.setView(popup_trans);
- SharedPreferences.Editor editor = sharedpreferences.edit();
- editor.putString(Helper.LAST_TRANSLATION_TIME, Helper.dateToString(new Date(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(Helper.SECONDES_BETWEEN_TRANSLATE))));
- editor.apply();
- TextView yandex_translate = popup_trans.findViewById(R.id.yandex_translate);
- yandex_translate.setOnClickListener(v -> {
- Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://translate.yandex.com/"));
- startActivity(browserIntent);
- });
- MyTransL myTransL = MyTransL.getInstance(MyTransL.translatorEngine.YANDEX);
- myTransL.setYandexAPIKey(Helper.YANDEX_KEY);
- myTransL.setObfuscation(true);
- myTransL.setTimeout(60);
- if (toot_cw_content.getText().toString().length() > 0)
- myTransL.translate(toot_cw_content.getText().toString(), locale, new com.github.stom79.mytransl.client.Results() {
- @Override
- public void onSuccess(Translate translate) {
- try {
- if (translate.getTranslatedContent() == null)
- return;
- if (popup_trans != null) {
- ProgressBar trans_progress_cw = popup_trans.findViewById(R.id.trans_progress_cw);
- ProgressBar trans_progress_toot = popup_trans.findViewById(R.id.trans_progress_toot);
- if (trans_progress_cw != null)
- trans_progress_cw.setVisibility(View.GONE);
- LinearLayout trans_container = popup_trans.findViewById(R.id.trans_container);
- if (trans_container != null) {
- TextView cw_trans = popup_trans.findViewById(R.id.cw_trans);
- if (cw_trans != null) {
- cw_trans.setVisibility(View.VISIBLE);
- cw_trans.setText(translate.getTranslatedContent());
- }
- } else {
- Toasty.error(TootActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
- }
- if (trans_progress_cw != null && trans_progress_toot != null && trans_progress_cw.getVisibility() == View.GONE && trans_progress_toot.getVisibility() == View.GONE)
- if (dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE) != null)
- dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE).setEnabled(true);
- }
- } catch (IllegalArgumentException e) {
- Toasty.error(TootActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
- }
-
- }
-
- @Override
- public void onFail(HttpsConnectionException e) {
- e.printStackTrace();
- }
- });
- else {
- ProgressBar trans_progress_cw = popup_trans.findViewById(R.id.trans_progress_cw);
- trans_progress_cw.setVisibility(View.GONE);
- }
- if (toot_content.getText().toString().length() > 0)
- myTransL.translate(toot_content.getText().toString(), locale, new com.github.stom79.mytransl.client.Results() {
- @Override
- public void onSuccess(Translate translate) {
- try {
- if (translate.getTranslatedContent() == null)
- return;
- if (popup_trans != null) {
- ProgressBar trans_progress_cw = popup_trans.findViewById(R.id.trans_progress_cw);
- ProgressBar trans_progress_toot = popup_trans.findViewById(R.id.trans_progress_toot);
- if (trans_progress_toot != null)
- trans_progress_toot.setVisibility(View.GONE);
- LinearLayout trans_container = popup_trans.findViewById(R.id.trans_container);
- if (trans_container != null) {
- TextView toot_trans = popup_trans.findViewById(R.id.toot_trans);
- if (toot_trans != null) {
- toot_trans.setVisibility(View.VISIBLE);
- toot_trans.setText(translate.getTranslatedContent());
- }
- } else {
- Toasty.error(TootActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
- }
- if (trans_progress_cw != null && trans_progress_toot != null && trans_progress_cw.getVisibility() == View.GONE && trans_progress_toot.getVisibility() == View.GONE)
- if (dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE) != null)
- dialogTrans.getButton(DialogInterface.BUTTON_NEGATIVE).setEnabled(true);
- }
- } catch (IllegalArgumentException e) {
- Toasty.error(TootActivity.this, getString(R.string.toast_error_translate), Toast.LENGTH_LONG).show();
- }
- }
-
- @Override
- public void onFail(HttpsConnectionException e) {
- e.printStackTrace();
- }
- });
-
- transAlert.setPositiveButton(R.string.close, (dialog, whichButton) -> dialog.dismiss());
- transAlert.setNegativeButton(R.string.validate, (dialog, whichButton) -> {
- TextView toot_trans = popup_trans.findViewById(R.id.toot_trans);
- TextView cw_trans = popup_trans.findViewById(R.id.cw_trans);
- if (toot_trans != null) {
- toot_content.setText(toot_trans.getText().toString());
- toot_content.setSelection(toot_content.getText().length());
- }
- if (cw_trans != null)
- toot_cw_content.setText(cw_trans.getText().toString());
- dialog.dismiss();
- });
- dialogTrans = transAlert.create();
- transAlert.show();
-
- dialogTrans.setOnShowListener(dialog -> {
- Button negativeButton = ((AlertDialog) dialog)
- .getButton(AlertDialog.BUTTON_NEGATIVE);
- if (negativeButton != null)
- negativeButton.setEnabled(false);
- });
-
- });
- picker.show(getSupportFragmentManager(), "COUNTRY_PICKER");
- return true;
- case R.id.action_emoji:
- if (emojis != null) {
- emojis.clear();
- emojis = null;
- }
- emojis = new CustomEmojiDAO(TootActivity.this, db).getAllEmojis(account.getInstance());
- final AlertDialog.Builder builder = new AlertDialog.Builder(this, style);
- int paddingPixel = 15;
- float density = getResources().getDisplayMetrics().density;
- int paddingDp = (int) (paddingPixel * density);
- builder.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
- builder.setTitle(R.string.insert_emoji);
- if (emojis != null && emojis.size() > 0) {
- GridView gridView = new GridView(TootActivity.this);
- gridView.setAdapter(new CustomEmojiAdapter(emojis));
- gridView.setNumColumns(5);
- gridView.setOnItemClickListener((parent, view, position, id) -> {
- toot_content.getText().insert(toot_content.getSelectionStart(), " :" + emojis.get(position).getShortcode() + ": ");
- alertDialogEmoji.dismiss();
- });
- gridView.setPadding(paddingDp, paddingDp, paddingDp, paddingDp);
- builder.setView(gridView);
- } else {
- TextView textView = new TextView(TootActivity.this);
- textView.setText(getString(R.string.no_emoji));
- textView.setPadding(paddingDp, paddingDp, paddingDp, paddingDp);
- builder.setView(textView);
- }
- alertDialogEmoji = builder.show();
-
-
- return true;
- case R.id.action_photo_camera:
- dispatchTakePictureIntent();
- return true;
- case R.id.action_contacts:
-
- AlertDialog.Builder builderSingle = new AlertDialog.Builder(TootActivity.this, style);
-
- builderSingle.setTitle(getString(R.string.select_accounts));
- LayoutInflater inflater = getLayoutInflater();
- View dialogView = inflater.inflate(R.layout.popup_contact, new LinearLayout(TootActivity.this), false);
-
- loader = dialogView.findViewById(R.id.loader);
- EditText search_account = dialogView.findViewById(R.id.search_account);
- lv_accounts_search = dialogView.findViewById(R.id.lv_accounts_search);
- loader.setVisibility(View.VISIBLE);
- new RetrieveSearchAccountsAsyncTask(TootActivity.this, "a", true, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
-
- search_account.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) {
- if (count > 0) {
- search_account.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_close, 0);
- } else {
- search_account.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ic_search, 0);
- }
- }
-
- @Override
- public void afterTextChanged(Editable s) {
- if (s != null && s.length() > 0) {
- new RetrieveSearchAccountsAsyncTask(TootActivity.this, s.toString(), true, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- }
- }
- });
- search_account.setOnTouchListener((v, event) -> {
- final int DRAWABLE_RIGHT = 2;
- if (event.getAction() == MotionEvent.ACTION_UP) {
- if (search_account.length() > 0 && event.getRawX() >= (search_account.getRight() - search_account.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width())) {
- search_account.setText("");
- new RetrieveSearchAccountsAsyncTask(TootActivity.this, "a", true, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- }
- }
-
- return false;
- });
- builderSingle.setView(dialogView);
- builderSingle.setNegativeButton(R.string.validate, (dialog, which) -> {
- dialog.dismiss();
- toot_content.setSelection(toot_content.getText().length());
- });
- builderSingle.show();
-
- return true;
- case R.id.action_microphone:
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) ==
- PackageManager.PERMISSION_GRANTED) {
- recordAudio();
- } else {
- if (shouldShowRequestPermissionRationale(Manifest.permission.RECORD_AUDIO)) {
- Toast.makeText(this,
- getString(R.string.audio), Toast.LENGTH_SHORT).show();
- }
- requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO
- }, REQUEST_CAMERA_PERMISSION_RESULT);
- }
-
- } else {
+ return true;
+ } else if (itemId == R.id.action_microphone) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ if (ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) ==
+ PackageManager.PERMISSION_GRANTED) {
recordAudio();
+ } else {
+ if (shouldShowRequestPermissionRationale(Manifest.permission.RECORD_AUDIO)) {
+ Toast.makeText(this,
+ getString(R.string.audio), Toast.LENGTH_SHORT).show();
+ }
+ requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO
+ }, REQUEST_CAMERA_PERMISSION_RESULT);
}
+ } else {
+ recordAudio();
+ }
- return true;
- case R.id.action_store:
- storeToot(true, true);
- return true;
- case R.id.action_tags:
- Intent intentTags = new Intent(TootActivity.this, TagCacheActivity.class);
- intentTags.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
- startActivity(intentTags);
- return true;
- case R.id.action_restore:
- try {
- final List drafts = new StatusStoredDAO(TootActivity.this, db).getAllDrafts();
- if (drafts == null || drafts.size() == 0) {
- Toasty.info(TootActivity.this, getString(R.string.no_draft), Toast.LENGTH_LONG).show();
- return true;
- }
- builderSingle = new AlertDialog.Builder(TootActivity.this, style);
- builderSingle.setTitle(getString(R.string.choose_toot));
- final DraftsListAdapter draftsListAdapter = new DraftsListAdapter(drafts);
- final int[] ids = new int[drafts.size()];
- int i = 0;
- for (StoredStatus draft : drafts) {
- ids[i] = draft.getId();
- i++;
- }
- builderSingle.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
- builderSingle.setPositiveButton(R.string.delete_all, (dialog, which) -> {
- AlertDialog.Builder builder1 = new AlertDialog.Builder(TootActivity.this, style);
- builder1.setTitle(R.string.delete_all);
- builder1.setIcon(android.R.drawable.ic_dialog_alert)
- .setPositiveButton(R.string.yes, (dialogConfirm, which1) -> {
- new StatusStoredDAO(TootActivity.this, db).removeAllDrafts();
- dialogConfirm.dismiss();
- dialog.dismiss();
- })
- .setNegativeButton(R.string.no, (dialogConfirm, which12) -> dialogConfirm.dismiss())
- .show();
- });
- builderSingle.setAdapter(draftsListAdapter,
- (dialog, which) -> {
- int id = ids[which];
- restoreToot(id);
- dialog.dismiss();
- });
- builderSingle.show();
- } catch (Exception e) {
- Toasty.error(TootActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
- }
- return true;
-
- case R.id.action_schedule:
- if (toot_content.getText().toString().trim().length() == 0) {
- Toasty.error(TootActivity.this, getString(R.string.toot_error_no_content), Toast.LENGTH_LONG).show();
+ return true;
+ } else if (itemId == R.id.action_store) {
+ storeToot(true, true);
+ return true;
+ } else if (itemId == R.id.action_tags) {
+ Intent intentTags = new Intent(BaseTootActivity.this, TagCacheActivity.class);
+ intentTags.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
+ startActivity(intentTags);
+ return true;
+ } else if (itemId == R.id.action_restore) {
+ AlertDialog.Builder builderSingle;
+ try {
+ final List drafts = new StatusStoredDAO(BaseTootActivity.this, db).getAllDrafts();
+ if (drafts == null || drafts.size() == 0) {
+ Toasty.info(BaseTootActivity.this, getString(R.string.no_draft), Toast.LENGTH_LONG).show();
return true;
}
- AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(TootActivity.this, style);
- inflater = this.getLayoutInflater();
- dialogView = inflater.inflate(R.layout.datetime_picker, new LinearLayout(TootActivity.this), false);
- dialogBuilder.setView(dialogView);
- final AlertDialog alertDialog = dialogBuilder.create();
+ builderSingle = new AlertDialog.Builder(BaseTootActivity.this, style);
+ builderSingle.setTitle(getString(R.string.choose_toot));
+ final DraftsListAdapter draftsListAdapter = new DraftsListAdapter(drafts);
+ final int[] ids = new int[drafts.size()];
+ int i = 0;
+ for (StoredStatus draft : drafts) {
+ ids[i] = draft.getId();
+ i++;
+ }
+ builderSingle.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
+ builderSingle.setPositiveButton(R.string.delete_all, (dialog, which) -> {
+ AlertDialog.Builder builder1 = new AlertDialog.Builder(BaseTootActivity.this, style);
+ builder1.setTitle(R.string.delete_all);
+ builder1.setIcon(android.R.drawable.ic_dialog_alert)
+ .setPositiveButton(R.string.yes, (dialogConfirm, which1) -> {
+ new StatusStoredDAO(BaseTootActivity.this, db).removeAllDrafts();
+ dialogConfirm.dismiss();
+ dialog.dismiss();
+ })
+ .setNegativeButton(R.string.no, (dialogConfirm, which12) -> dialogConfirm.dismiss())
+ .show();
- final DatePicker datePicker = dialogView.findViewById(R.id.date_picker);
- final TimePicker timePicker = dialogView.findViewById(R.id.time_picker);
- if (android.text.format.DateFormat.is24HourFormat(TootActivity.this))
- timePicker.setIs24HourView(true);
- Button date_time_cancel = dialogView.findViewById(R.id.date_time_cancel);
- final ImageButton date_time_previous = dialogView.findViewById(R.id.date_time_previous);
- final ImageButton date_time_next = dialogView.findViewById(R.id.date_time_next);
- final ImageButton date_time_set = dialogView.findViewById(R.id.date_time_set);
-
- //Buttons management
- date_time_cancel.setOnClickListener(v -> alertDialog.dismiss());
- date_time_next.setOnClickListener(v -> {
- datePicker.setVisibility(View.GONE);
- timePicker.setVisibility(View.VISIBLE);
- date_time_previous.setVisibility(View.VISIBLE);
- date_time_next.setVisibility(View.GONE);
- date_time_set.setVisibility(View.VISIBLE);
});
- date_time_previous.setOnClickListener(v -> {
- datePicker.setVisibility(View.VISIBLE);
- timePicker.setVisibility(View.GONE);
- date_time_previous.setVisibility(View.GONE);
- date_time_next.setVisibility(View.VISIBLE);
- date_time_set.setVisibility(View.GONE);
- });
- date_time_set.setOnClickListener(v -> {
- int hour, minute;
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
- hour = timePicker.getHour();
- minute = timePicker.getMinute();
- } else {
- hour = timePicker.getCurrentHour();
- minute = timePicker.getCurrentMinute();
- }
- Calendar calendar = new GregorianCalendar(datePicker.getYear(),
- datePicker.getMonth(),
- datePicker.getDayOfMonth(),
- hour,
- minute);
- final long[] time = {calendar.getTimeInMillis()};
-
- if ((time[0] - new Date().getTime()) < 60000) {
- Toasty.warning(TootActivity.this, getString(R.string.toot_scheduled_date), Toast.LENGTH_LONG).show();
- } else {
- AlertDialog.Builder builderSingle1 = new AlertDialog.Builder(TootActivity.this, style);
- builderSingle1.setTitle(getString(R.string.choose_schedule));
- builderSingle1.setNegativeButton(R.string.device_schedule, (dialog, which) -> {
- deviceSchedule(time[0]);
+ builderSingle.setAdapter(draftsListAdapter,
+ (dialog, which) -> {
+ int id = ids[which];
+ restoreToot(id);
dialog.dismiss();
});
- builderSingle1.setPositiveButton(R.string.server_schedule, (dialog, which) -> {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.getDefault());
- String date = sdf.format(calendar.getTime());
- serverSchedule(date);
- });
- builderSingle1.show();
- alertDialog.dismiss();
- }
- });
- alertDialog.show();
+ builderSingle.show();
+ } catch (Exception e) {
+ Toasty.error(BaseTootActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
+ }
+ return true;
+ } else if (itemId == R.id.action_schedule) {
+ View dialogView;
+ LayoutInflater inflater;
+ if (toot_content.getText().toString().trim().length() == 0) {
+ Toasty.error(BaseTootActivity.this, getString(R.string.toot_error_no_content), Toast.LENGTH_LONG).show();
return true;
- default:
- return super.onOptionsItemSelected(item);
+ }
+ AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(BaseTootActivity.this, style);
+ inflater = this.getLayoutInflater();
+ dialogView = inflater.inflate(R.layout.datetime_picker, new LinearLayout(BaseTootActivity.this), false);
+ dialogBuilder.setView(dialogView);
+ final AlertDialog alertDialog = dialogBuilder.create();
+
+ final DatePicker datePicker = dialogView.findViewById(R.id.date_picker);
+ final TimePicker timePicker = dialogView.findViewById(R.id.time_picker);
+ if (DateFormat.is24HourFormat(BaseTootActivity.this))
+ timePicker.setIs24HourView(true);
+ Button date_time_cancel = dialogView.findViewById(R.id.date_time_cancel);
+ final ImageButton date_time_previous = dialogView.findViewById(R.id.date_time_previous);
+ final ImageButton date_time_next = dialogView.findViewById(R.id.date_time_next);
+ final ImageButton date_time_set = dialogView.findViewById(R.id.date_time_set);
+
+ //Buttons management
+ date_time_cancel.setOnClickListener(v -> alertDialog.dismiss());
+ date_time_next.setOnClickListener(v -> {
+ datePicker.setVisibility(View.GONE);
+ timePicker.setVisibility(View.VISIBLE);
+ date_time_previous.setVisibility(View.VISIBLE);
+ date_time_next.setVisibility(View.GONE);
+ date_time_set.setVisibility(View.VISIBLE);
+ });
+ date_time_previous.setOnClickListener(v -> {
+ datePicker.setVisibility(View.VISIBLE);
+ timePicker.setVisibility(View.GONE);
+ date_time_previous.setVisibility(View.GONE);
+ date_time_next.setVisibility(View.VISIBLE);
+ date_time_set.setVisibility(View.GONE);
+ });
+ date_time_set.setOnClickListener(v -> {
+ int hour, minute;
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+ hour = timePicker.getHour();
+ minute = timePicker.getMinute();
+ } else {
+ hour = timePicker.getCurrentHour();
+ minute = timePicker.getCurrentMinute();
+ }
+ Calendar calendar = new GregorianCalendar(datePicker.getYear(),
+ datePicker.getMonth(),
+ datePicker.getDayOfMonth(),
+ hour,
+ minute);
+ final long[] time = {calendar.getTimeInMillis()};
+
+ if ((time[0] - new Date().getTime()) < 60000) {
+ Toasty.warning(BaseTootActivity.this, getString(R.string.toot_scheduled_date), Toast.LENGTH_LONG).show();
+ } else {
+ AlertDialog.Builder builderSingle1 = new AlertDialog.Builder(BaseTootActivity.this, style);
+ builderSingle1.setTitle(getString(R.string.choose_schedule));
+ builderSingle1.setNegativeButton(R.string.device_schedule, (dialog, which) -> {
+ deviceSchedule(time[0]);
+ dialog.dismiss();
+ });
+ builderSingle1.setPositiveButton(R.string.server_schedule, (dialog, which) -> {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ", Locale.getDefault());
+ String date = sdf.format(calendar.getTime());
+ serverSchedule(date);
+ });
+ builderSingle1.show();
+ alertDialog.dismiss();
+ }
+ });
+ alertDialog.show();
+ return true;
}
+ return super.onOptionsItemSelected(item);
}
private void sendToot(String timestamp, String content_type) {
toot_it.setEnabled(false);
if (!displayWYSIWYG() && toot_content.getText().toString().trim().length() == 0 && attachments.size() == 0) {
- Toasty.error(TootActivity.this, getString(R.string.toot_error_no_content), Toast.LENGTH_LONG).show();
+ Toasty.error(BaseTootActivity.this, getString(R.string.toot_error_no_content), Toast.LENGTH_LONG).show();
toot_it.setEnabled(true);
return;
}
if (displayWYSIWYG() && wysiwyg.getContent().toString().trim().length() == 0 && attachments.size() == 0) {
- Toasty.error(TootActivity.this, getString(R.string.toot_error_no_content), Toast.LENGTH_LONG).show();
+ Toasty.error(BaseTootActivity.this, getString(R.string.toot_error_no_content), Toast.LENGTH_LONG).show();
toot_it.setEnabled(true);
return;
}
@@ -2129,10 +2010,10 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
stepSpliToot = 1;
- AlertDialog.Builder builderInner = new AlertDialog.Builder(TootActivity.this, style);
+ AlertDialog.Builder builderInner = new AlertDialog.Builder(BaseTootActivity.this, style);
builderInner.setTitle(R.string.message_preview);
- View preview = getLayoutInflater().inflate(R.layout.popup_message_preview, new LinearLayout(TootActivity.this), false);
+ View preview = getLayoutInflater().inflate(R.layout.popup_message_preview, new LinearLayout(BaseTootActivity.this), false);
builderInner.setView(preview);
//Text for report
@@ -2193,7 +2074,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
toot.setVisibility(visibility);
if (tootReply != null)
toot.setIn_reply_to_id(tootReply.getId());
- toot.setContent(TootActivity.this, tootContent);
+ toot.setContent(BaseTootActivity.this, tootContent);
if (social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
if (poll != null) {
toot.setPoll(poll);
@@ -2208,17 +2089,17 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
}
if (timestamp == null)
if (scheduledstatus == null)
- new PostStatusAsyncTask(TootActivity.this, social, account, toot, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostStatusAsyncTask(BaseTootActivity.this, social, account, toot, BaseTootActivity.this);
else {
toot.setScheduled_at(Helper.dateToString(scheduledstatus.getScheduled_date()));
scheduledstatus.setStatus(toot);
isScheduled = true;
- new PostActionAsyncTask(TootActivity.this, API.StatusAction.DELETESCHEDULED, scheduledstatus, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- new PostStatusAsyncTask(TootActivity.this, social, account, toot, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostActionAsyncTask(BaseTootActivity.this, API.StatusAction.DELETESCHEDULED, scheduledstatus, BaseTootActivity.this);
+ new PostStatusAsyncTask(BaseTootActivity.this, social, account, toot, BaseTootActivity.this);
}
else {
toot.setScheduled_at(timestamp);
- new PostStatusAsyncTask(TootActivity.this, social, account, toot, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostStatusAsyncTask(BaseTootActivity.this, social, accountReply != null ? accountReply : account, toot, BaseTootActivity.this);
}
}
@@ -2233,7 +2114,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
storeToot(false, false);
isScheduled = true;
//Schedules the toot
- ScheduledTootsSyncJob.schedule(TootActivity.this, currentToId, time);
+ ScheduledTootsSyncJob.schedule(BaseTootActivity.this, currentToId, time);
resetForNextToot();
}
@@ -2255,7 +2136,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
isSensitive = false;
toot_sensitive.setVisibility(View.GONE);
currentToId = -1;
- Toasty.info(TootActivity.this, getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show();
+ Toasty.info(BaseTootActivity.this, getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show();
}
@Override
@@ -2282,20 +2163,13 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
MenuItem itemEmoji = menu.findItem(R.id.action_emoji);
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
- final List emojis = new CustomEmojiDAO(TootActivity.this, db).getAllEmojis();
+ final List emojis = new CustomEmojiDAO(BaseTootActivity.this, db).getAllEmojis();
//Displays button only if custom emojis
- if (emojis != null && emojis.size() > 0) {
- itemEmoji.setVisible(true);
- } else {
- itemEmoji.setVisible(false);
- }
+ itemEmoji.setVisible(emojis != null && emojis.size() > 0);
if (accountReply != null) {
MenuItem itemRestore = menu.findItem(R.id.action_restore);
if (itemRestore != null)
itemRestore.setVisible(false);
- MenuItem itemSchedule = menu.findItem(R.id.action_schedule);
- if (itemSchedule != null)
- itemSchedule.setVisible(false);
MenuItem itemStore = menu.findItem(R.id.action_store);
if (itemStore != null)
itemStore.setVisible(false);
@@ -2329,7 +2203,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
toot_picture_container.setVisibility(View.VISIBLE);
toot_picture.setEnabled(false);
toot_it.setEnabled(false);
- upload(TootActivity.this, account, social, uri, filename, uploadReceiver);
+ prepareUpload(BaseTootActivity.this, uri, filename);
}
}
@@ -2354,17 +2228,17 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
}
private void showAddDescription(final Attachment attachment) {
- AlertDialog.Builder builderInner = new AlertDialog.Builder(TootActivity.this, style);
+ AlertDialog.Builder builderInner = new AlertDialog.Builder(BaseTootActivity.this, style);
builderInner.setTitle(R.string.upload_form_description);
- View popup_media_description = getLayoutInflater().inflate(R.layout.popup_media_description, new LinearLayout(TootActivity.this), false);
+ View popup_media_description = getLayoutInflater().inflate(R.layout.popup_media_description, new LinearLayout(BaseTootActivity.this), false);
builderInner.setView(popup_media_description);
//Text for report
final EditText input = popup_media_description.findViewById(R.id.media_description);
input.setFilters(new InputFilter[]{new InputFilter.LengthFilter(1500)});
final ImageView media_picture = popup_media_description.findViewById(R.id.media_picture);
- Glide.with(TootActivity.this)
+ Glide.with(BaseTootActivity.this)
.asBitmap()
.load(attachment.getUrl())
.into(new CustomTarget() {
@@ -2388,7 +2262,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
input.setSelection(input.getText().length());
}
builderInner.setPositiveButton(R.string.validate, (dialog, which) -> {
- new UpdateDescriptionAttachmentAsyncTask(TootActivity.this, attachment.getId(), input.getText().toString(), account, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new UpdateDescriptionAttachmentAsyncTask(BaseTootActivity.this, attachment.getId(), input.getText().toString(), account, BaseTootActivity.this);
attachment.setDescription(input.getText().toString());
addBorder();
dialog.dismiss();
@@ -2406,7 +2280,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
*/
private void showRemove(final int viewId) {
- AlertDialog.Builder dialog = new AlertDialog.Builder(TootActivity.this, style);
+ AlertDialog.Builder dialog = new AlertDialog.Builder(BaseTootActivity.this, style);
dialog.setMessage(R.string.toot_delete_media);
dialog.setNegativeButton(R.string.cancel, (dialog1, which) -> dialog1.dismiss());
@@ -2445,10 +2319,10 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
private void tootVisibilityDialog() {
- AlertDialog.Builder dialog = new AlertDialog.Builder(TootActivity.this, style);
+ AlertDialog.Builder dialog = new AlertDialog.Builder(BaseTootActivity.this, style);
dialog.setTitle(R.string.toot_visibility_tilte);
final String[] stringArray = getResources().getStringArray(R.array.toot_visibility);
- final ArrayAdapter arrayAdapter = new ArrayAdapter<>(TootActivity.this, android.R.layout.simple_list_item_1, stringArray);
+ final ArrayAdapter arrayAdapter = new ArrayAdapter<>(BaseTootActivity.this, android.R.layout.simple_list_item_1, stringArray);
dialog.setNegativeButton(R.string.cancel, (dialog1, position) -> dialog1.dismiss());
dialog.setAdapter(arrayAdapter, (dialog12, position) -> {
switch (position) {
@@ -2502,14 +2376,10 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
} else if (initialContent.trim().equals(toot_content.getText().toString().trim())) {
finish();
} else {
- AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(TootActivity.this, style);
+ AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(BaseTootActivity.this, style);
dialogBuilder.setMessage(R.string.save_draft);
dialogBuilder.setPositiveButton(R.string.save, (dialog, id) -> {
- if (accountReply == null) {
- storeToot(true, false);
- } else {
- storeToot(false, false);
- }
+ storeToot(accountReply == null, false);
dialog.dismiss();
finish();
});
@@ -2534,7 +2404,6 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
.unregisterReceiver(imageReceiver);
LocalBroadcastManager.getInstance(this)
.unregisterReceiver(add_new_media);
- uploadReceiver.unregister(this);
}
@Override
@@ -2544,6 +2413,9 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (apiResponse.getError().getStatusCode() == -33) {
storeToot(false, true);
} else {
+ if (apiResponse.getError().getStatusCode() == 404) {
+ storeToot(false, true);
+ }
showAToast(apiResponse.getError().getError());
return;
}
@@ -2562,18 +2434,18 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
toot.setVisibility(visibility);
if (apiResponse.getStatuses() != null && apiResponse.getStatuses().size() > 0)
toot.setIn_reply_to_id(apiResponse.getStatuses().get(0).getId());
- toot.setContent(TootActivity.this, tootContent);
- new PostStatusAsyncTask(TootActivity.this, social, account, toot, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ toot.setContent(BaseTootActivity.this, tootContent);
+ new PostStatusAsyncTask(BaseTootActivity.this, social, account, toot, BaseTootActivity.this);
return;
}
if (apiResponse.getError() == null || apiResponse.getError().getStatusCode() != -33) {
if (restored != -1) {
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
- new StatusStoredDAO(TootActivity.this, db).remove(restored);
+ new StatusStoredDAO(BaseTootActivity.this, db).remove(restored);
} else if (currentToId != -1) {
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
- new StatusStoredDAO(TootActivity.this, db).remove(currentToId);
+ new StatusStoredDAO(BaseTootActivity.this, db).remove(currentToId);
}
}
//Clear the toot
@@ -2597,13 +2469,13 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (scheduledstatus == null && !isScheduled) {
boolean display_confirm = sharedpreferences.getBoolean(Helper.SET_DISPLAY_CONFIRM, true);
if (display_confirm) {
- Toasty.success(TootActivity.this, getString(R.string.toot_sent), Toast.LENGTH_LONG).show();
+ Toasty.success(BaseTootActivity.this, getString(R.string.toot_sent), Toast.LENGTH_LONG).show();
}
} else
- Toasty.success(TootActivity.this, getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show();
+ Toasty.success(BaseTootActivity.this, getString(R.string.toot_scheduled), Toast.LENGTH_LONG).show();
} else {
if (apiResponse.getError().getStatusCode() == -33)
- Toasty.info(TootActivity.this, getString(R.string.toast_toot_saved_error), Toast.LENGTH_LONG).show();
+ Toasty.info(BaseTootActivity.this, getString(R.string.toast_toot_saved_error), Toast.LENGTH_LONG).show();
}
toot_it.setEnabled(true);
//It's a reply, so the user will be redirect to its answer
@@ -2612,7 +2484,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (statuses != null && statuses.size() > 0) {
Status status = statuses.get(0);
if (status != null) {
- Intent intent = new Intent(TootActivity.this, ShowConversationActivity.class);
+ Intent intent = new Intent(BaseTootActivity.this, ShowConversationActivity.class);
Bundle b = new Bundle();
if (idRedirect == null)
b.putParcelable("status", status);
@@ -2625,7 +2497,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
}
}
} else {
- Intent intent = new Intent(TootActivity.this, MainActivity.class);
+ Intent intent = new Intent(BaseTootActivity.this, MainActivity.class);
intent.putExtra(Helper.INTENT_ACTION, Helper.HOME_TIMELINE_INTENT);
startActivity(intent);
finish();
@@ -2645,7 +2517,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (accounts != null && accounts.size() > 0) {
if (!displayWYSIWYG()) {
int currentCursorPosition = toot_content.getSelectionStart();
- AccountsSearchAdapter accountsListAdapter = new AccountsSearchAdapter(TootActivity.this, accounts);
+ AccountsSearchAdapter accountsListAdapter = new AccountsSearchAdapter(BaseTootActivity.this, accounts);
toot_content.setThreshold(1);
toot_content.setAdapter(accountsListAdapter);
final String oldContent = toot_content.getText().toString();
@@ -2678,7 +2550,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
toot_content.setText(newContent);
toot_space_left.setText(String.valueOf(countLength(social, toot_content, toot_cw_content)));
toot_content.setSelection(newPosition);
- AccountsSearchAdapter accountsListAdapter1 = new AccountsSearchAdapter(TootActivity.this, new ArrayList<>());
+ AccountsSearchAdapter accountsListAdapter1 = new AccountsSearchAdapter(BaseTootActivity.this, new ArrayList<>());
toot_content.setThreshold(1);
toot_content.setAdapter(accountsListAdapter1);
});
@@ -2752,7 +2624,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
this.checkedValues.add(toot_content.getText().toString().contains("@" + account.getAcct()));
}
this.loader.setVisibility(View.GONE);
- AccountsReplyAdapter contactAdapter = new AccountsReplyAdapter(new WeakReference<>(TootActivity.this), this.contacts, this.checkedValues);
+ AccountsReplyAdapter contactAdapter = new AccountsReplyAdapter(new WeakReference<>(BaseTootActivity.this), this.contacts, this.checkedValues);
this.lv_accounts_search.setAdapter(contactAdapter);
}
@@ -2776,7 +2648,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (emojis != null && emojis.size() > 0) {
if (!displayWYSIWYG()) {
int currentCursorPosition = toot_content.getSelectionStart();
- EmojisSearchAdapter emojisSearchAdapter = new EmojisSearchAdapter(TootActivity.this, emojis);
+ EmojisSearchAdapter emojisSearchAdapter = new EmojisSearchAdapter(BaseTootActivity.this, emojis);
toot_content.setThreshold(1);
toot_content.setAdapter(emojisSearchAdapter);
final String oldContent = toot_content.getText().toString();
@@ -2808,7 +2680,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
toot_content.setText(newContent);
toot_space_left.setText(String.valueOf(countLength(social, toot_content, toot_cw_content)));
toot_content.setSelection(newPosition);
- EmojisSearchAdapter emojisSearchAdapter1 = new EmojisSearchAdapter(TootActivity.this, new ArrayList<>());
+ EmojisSearchAdapter emojisSearchAdapter1 = new EmojisSearchAdapter(BaseTootActivity.this, new ArrayList<>());
toot_content.setThreshold(1);
toot_content.setAdapter(emojisSearchAdapter1);
@@ -2885,7 +2757,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (tags != null && tags.size() > 0) {
if (!displayWYSIWYG()) {
int currentCursorPosition = toot_content.getSelectionStart();
- TagsSearchAdapter tagsSearchAdapter = new TagsSearchAdapter(TootActivity.this, tags);
+ TagsSearchAdapter tagsSearchAdapter = new TagsSearchAdapter(BaseTootActivity.this, tags);
toot_content.setThreshold(1);
toot_content.setAdapter(tagsSearchAdapter);
final String oldContent = toot_content.getText().toString();
@@ -2922,7 +2794,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
toot_content.setText(newContent);
toot_space_left.setText(String.valueOf(countLength(social, toot_content, toot_cw_content)));
toot_content.setSelection(newPosition);
- TagsSearchAdapter tagsSearchAdapter1 = new TagsSearchAdapter(TootActivity.this, new ArrayList<>());
+ TagsSearchAdapter tagsSearchAdapter1 = new TagsSearchAdapter(BaseTootActivity.this, new ArrayList<>());
toot_content.setThreshold(1);
toot_content.setAdapter(tagsSearchAdapter1);
@@ -2985,13 +2857,13 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
private void restoreToot(long id) {
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
- StoredStatus draft = new StatusStoredDAO(TootActivity.this, db).getStatus(id);
+ StoredStatus draft = new StatusStoredDAO(BaseTootActivity.this, db).getStatus(id);
if (draft == null)
return;
Status status = draft.getStatus();
//Retrieves attachments
if (removed) {
- new StatusStoredDAO(TootActivity.this, db).remove(draft.getId());
+ new StatusStoredDAO(BaseTootActivity.this, db).remove(draft.getId());
}
restored = id;
attachments = status.getMedia_attachments();
@@ -3044,12 +2916,12 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
String url = attachment.getPreview_url();
if (url == null || url.trim().equals(""))
url = attachment.getUrl();
- final ImageView imageView = new ImageView(TootActivity.this);
+ final ImageView imageView = new ImageView(BaseTootActivity.this);
imageView.setId(attachment.getViewId());
LinearLayout.LayoutParams imParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
imParams.setMargins(20, 5, 20, 5);
- imParams.height = (int) Helper.convertDpToPixel(100, TootActivity.this);
+ imParams.height = (int) Helper.convertDpToPixel(100, BaseTootActivity.this);
imageView.setAdjustViewBounds(true);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
toot_picture_container.addView(imageView, i, imParams);
@@ -3192,12 +3064,12 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
String url = attachment.getPreview_url();
if (url == null || url.trim().equals(""))
url = attachment.getUrl();
- final ImageView imageView = new ImageView(TootActivity.this);
+ final ImageView imageView = new ImageView(BaseTootActivity.this);
imageView.setId(attachment.getViewId());
LinearLayout.LayoutParams imParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
imParams.setMargins(20, 5, 20, 5);
- imParams.height = (int) Helper.convertDpToPixel(100, TootActivity.this);
+ imParams.height = (int) Helper.convertDpToPixel(100, BaseTootActivity.this);
imageView.setAdjustViewBounds(true);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
toot_picture_container.addView(imageView, i, imParams);
@@ -3373,7 +3245,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
}
if (tootReply != null) {
- manageMentions(TootActivity.this, social, userIdReply, toot_content, toot_cw_content, toot_space_left, tootReply);
+ manageMentions(BaseTootActivity.this, social, userIdReply, toot_content, toot_cw_content, toot_space_left, tootReply);
}
boolean forwardTags = sharedpreferences.getBoolean(Helper.SET_FORWARD_TAGS_IN_REPLY, false);
if (tootReply != null && forwardTags && tootReply.getTags() != null && tootReply.getTags().size() > 0) {
@@ -3393,9 +3265,9 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
}
private void displayPollPopup() {
- AlertDialog.Builder alertPoll = new AlertDialog.Builder(TootActivity.this, style);
+ AlertDialog.Builder alertPoll = new AlertDialog.Builder(BaseTootActivity.this, style);
alertPoll.setTitle(R.string.create_poll);
- View view = getLayoutInflater().inflate(R.layout.popup_poll, new LinearLayout(TootActivity.this), false);
+ View view = getLayoutInflater().inflate(R.layout.popup_poll, new LinearLayout(BaseTootActivity.this), false);
alertPoll.setView(view);
Spinner poll_choice = view.findViewById(R.id.poll_choice);
Spinner poll_duration = view.findViewById(R.id.poll_duration);
@@ -3423,7 +3295,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
int finalMax_length = max_length;
add.setOnClickListener(v -> {
if (pollCountItem < finalMax_entry) {
- EditText poll_item = new EditText(TootActivity.this);
+ EditText poll_item = new EditText(BaseTootActivity.this);
InputFilter[] fArray1 = new InputFilter[1];
fArray1[0] = new InputFilter.LengthFilter(finalMax_length);
poll_item.setFilters(fArray1);
@@ -3452,10 +3324,10 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
add.setVisibility(View.VISIBLE);
});
- ArrayAdapter pollduration = ArrayAdapter.createFromResource(TootActivity.this,
+ ArrayAdapter pollduration = ArrayAdapter.createFromResource(BaseTootActivity.this,
R.array.poll_duration, android.R.layout.simple_spinner_dropdown_item);
- ArrayAdapter pollchoice = ArrayAdapter.createFromResource(TootActivity.this,
+ ArrayAdapter pollchoice = ArrayAdapter.createFromResource(BaseTootActivity.this,
R.array.poll_choice_type, android.R.layout.simple_spinner_dropdown_item);
poll_choice.setAdapter(pollchoice);
poll_duration.setAdapter(pollduration);
@@ -3471,7 +3343,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (pollOptions.getTitle() != null)
choice_2.setText(pollOptions.getTitle());
} else {
- EditText poll_item = new EditText(TootActivity.this);
+ EditText poll_item = new EditText(BaseTootActivity.this);
fArray = new InputFilter[1];
fArray[0] = new InputFilter.LengthFilter(finalMax_length);
poll_item.setFilters(fArray);
@@ -3543,7 +3415,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
String choice2 = choice_2.getText().toString().trim();
if (choice1.isEmpty() && choice2.isEmpty()) {
- Toasty.error(TootActivity.this, getString(R.string.poll_invalid_choices), Toast.LENGTH_SHORT).show();
+ Toasty.error(BaseTootActivity.this, getString(R.string.poll_invalid_choices), Toast.LENGTH_SHORT).show();
} else {
poll = new Poll();
poll.setMultiple(poll_choice_pos != 0);
@@ -3605,7 +3477,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
poll.setOptionsList(pollOptions);
dialog.dismiss();
} else {
- Toasty.error(TootActivity.this, getString(R.string.poll_duplicated_entry), Toast.LENGTH_SHORT).show();
+ Toasty.error(BaseTootActivity.this, getString(R.string.poll_duplicated_entry), Toast.LENGTH_SHORT).show();
}
}
poll_action.setVisibility(View.VISIBLE);
@@ -3639,30 +3511,32 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (toot_cw_content.getText().toString().trim().length() > 0)
toot.setSpoiler_text(toot_cw_content.getText().toString().trim());
toot.setVisibility(visibility);
- toot.setContent(TootActivity.this, currentContent);
+ toot.setContent(BaseTootActivity.this, currentContent);
if (poll != null)
toot.setPoll(poll);
if (tootReply != null)
toot.setIn_reply_to_id(tootReply.getId());
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
+ //TODO: insert should be done with connected account
+ String userId = accountReply != null ? accountReply.getId() : account.getId();
+ String instance = accountReply != null ? accountReply.getInstance() : account.getInstance();
try {
if (currentToId == -1) {
- currentToId = new StatusStoredDAO(TootActivity.this, db).insertStatus(toot, tootReply);
-
+ currentToId = new StatusStoredDAO(BaseTootActivity.this, db).insertStatus(toot, tootReply, userId, instance);
} else {
- StoredStatus storedStatus = new StatusStoredDAO(TootActivity.this, db).getStatus(currentToId);
+ StoredStatus storedStatus = new StatusStoredDAO(BaseTootActivity.this, db).getStatus(currentToId);
if (storedStatus != null) {
- new StatusStoredDAO(TootActivity.this, db).updateStatus(currentToId, toot);
+ new StatusStoredDAO(BaseTootActivity.this, db).updateStatus(currentToId, toot);
} else { //Might have been deleted, so it needs insertion
- new StatusStoredDAO(TootActivity.this, db).insertStatus(toot, tootReply);
+ new StatusStoredDAO(BaseTootActivity.this, db).insertStatus(toot, tootReply, userId, instance);
}
}
if (message)
- Toasty.success(TootActivity.this, getString(R.string.toast_toot_saved), Toast.LENGTH_LONG).show();
+ Toasty.success(BaseTootActivity.this, getString(R.string.toast_toot_saved), Toast.LENGTH_LONG).show();
} catch (Exception e) {
if (message)
- Toasty.error(TootActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
+ Toasty.error(BaseTootActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
}
}
@@ -3675,8 +3549,8 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
checkedValues[i] = toot_content.getText().toString().contains("@" + account.getAcct());
i++;
}
- final AlertDialog.Builder builderSingle = new AlertDialog.Builder(TootActivity.this, style);
- AccountsReplyAdapter accountsReplyAdapter = new AccountsReplyAdapter(new WeakReference<>(TootActivity.this), accounts, checkedValues);
+ final AlertDialog.Builder builderSingle = new AlertDialog.Builder(BaseTootActivity.this, style);
+ AccountsReplyAdapter accountsReplyAdapter = new AccountsReplyAdapter(new WeakReference<>(BaseTootActivity.this), accounts, checkedValues);
builderSingle.setTitle(getString(R.string.select_accounts)).setAdapter(accountsReplyAdapter, null);
builderSingle.setNegativeButton(R.string.validate, (dialog, which) -> {
dialog.dismiss();
@@ -3713,13 +3587,13 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
for (Attachment attachment : attachments) {
if (attachment.getType().toLowerCase().equals("image"))
if (v.getTag().toString().trim().equals(attachment.getId().trim())) {
- int borderSize = (int) Helper.convertDpToPixel(1, TootActivity.this);
- int borderSizeTop = (int) Helper.convertDpToPixel(6, TootActivity.this);
+ int borderSize = (int) Helper.convertDpToPixel(1, BaseTootActivity.this);
+ int borderSizeTop = (int) Helper.convertDpToPixel(6, BaseTootActivity.this);
v.setPadding(borderSize, borderSizeTop, borderSize, borderSizeTop);
if (attachment.getDescription() == null || attachment.getDescription().trim().equals("null") || attachment.getDescription().trim().equals("")) {
- v.setBackgroundColor(ContextCompat.getColor(TootActivity.this, R.color.red_1));
+ v.setBackgroundColor(ContextCompat.getColor(BaseTootActivity.this, R.color.red_1));
} else
- v.setBackgroundColor(ContextCompat.getColor(TootActivity.this, R.color.green_1));
+ v.setBackgroundColor(ContextCompat.getColor(BaseTootActivity.this, R.color.green_1));
}
}
@@ -3786,7 +3660,7 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
findViewById(R.id.action_bulleted).setOnClickListener(v -> wysiwyg.insertList(false));
- findViewById(R.id.action_color).setOnClickListener(v -> new ColorPickerPopup.Builder(TootActivity.this)
+ findViewById(R.id.action_color).setOnClickListener(v -> new ColorPickerPopup.Builder(BaseTootActivity.this)
.enableAlpha(false)
.okTitle(getString(R.string.validate))
.cancelTitle(getString(R.string.cancel))
@@ -3831,8 +3705,15 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
return String.format(Locale.getDefault(), "#%02X%02X%02X", r, g, b);
}
- static class asyncPicture extends AsyncTask {
+ protected abstract boolean actionTranslateClick();
+ protected abstract void launchPhotoEditor(Uri uri);
+
+ protected abstract void displayEmojiPopup();
+
+ static class asyncPicture {
+
+ private final Account account;
String commpressedFilePath;
WeakReference activityWeakReference;
android.net.Uri uriFile;
@@ -3840,7 +3721,6 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
UploadServiceSingleBroadcastReceiver uploadReceiver;
String filename;
UpdateAccountInfoAsyncTask.SOCIAL social;
- private Account account;
asyncPicture(Activity activity, Account account, UpdateAccountInfoAsyncTask.SOCIAL social, android.net.Uri uri, String filename, UploadServiceSingleBroadcastReceiver uploadReceiver) {
this.activityWeakReference = new WeakReference<>(activity);
@@ -3849,10 +3729,6 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
this.filename = filename;
this.social = social;
this.account = account;
- }
-
- @Override
- protected void onPreExecute() {
if (uriFile == null) {
Toasty.error(activityWeakReference.get(), activityWeakReference.get().getString(R.string.toast_error), Toast.LENGTH_SHORT).show();
error = true;
@@ -3860,52 +3736,52 @@ public class TootActivity extends BaseActivity implements UploadStatusDelegate,
if (activityWeakReference.get().findViewById(R.id.compression_loader) != null) {
activityWeakReference.get().findViewById(R.id.compression_loader).setVisibility(View.VISIBLE);
}
-
+ doInBackground();
}
-
- @Override
- protected Void doInBackground(Void... voids) {
- if (error) {
- return null;
- }
- commpressedFilePath = Helper.compressImagePath(activityWeakReference.get(), uriFile);
- return null;
+ protected void doInBackground() {
+ new Thread(() -> {
+ if (error) {
+ return;
+ }
+ commpressedFilePath = Helper.compressImagePath(activityWeakReference.get(), uriFile);
+ Handler mainHandler = new Handler(Looper.getMainLooper());
+ Runnable myRunnable = () -> {
+ if (activityWeakReference.get().findViewById(R.id.compression_loader) != null) {
+ activityWeakReference.get().findViewById(R.id.compression_loader).setVisibility(View.GONE);
+ }
+ if (activityWeakReference.get().findViewById(R.id.picture_scrollview) != null) {
+ activityWeakReference.get().findViewById(R.id.picture_scrollview).setVisibility(View.VISIBLE);
+ }
+ if (!error) {
+ if (commpressedFilePath != null) {
+ uriFile = Uri.fromFile(new File(commpressedFilePath));
+ }
+ ImageButton toot_picture;
+ Button toot_it;
+ LinearLayout toot_picture_container;
+ toot_picture = this.activityWeakReference.get().findViewById(R.id.toot_picture);
+ toot_it = this.activityWeakReference.get().findViewById(R.id.toot_it);
+ toot_picture_container = this.activityWeakReference.get().findViewById(R.id.toot_picture_container);
+ if (toot_picture_container != null) {
+ toot_picture_container.setVisibility(View.VISIBLE);
+ }
+ if (toot_picture != null) {
+ toot_picture.setEnabled(false);
+ }
+ if (toot_it != null) {
+ toot_it.setEnabled(false);
+ }
+ if (filename == null) {
+ filename = Helper.getFileName(this.activityWeakReference.get(), uriFile);
+ }
+ filesMap.put(filename, uriFile);
+ upload(activityWeakReference.get(), account, social, uriFile, filename, uploadReceiver);
+ }
+ };
+ mainHandler.post(myRunnable);
+ }).start();
}
- @Override
- protected void onPostExecute(Void result) {
- if (activityWeakReference.get().findViewById(R.id.compression_loader) != null) {
- activityWeakReference.get().findViewById(R.id.compression_loader).setVisibility(View.GONE);
- }
- if (activityWeakReference.get().findViewById(R.id.picture_scrollview) != null) {
- activityWeakReference.get().findViewById(R.id.picture_scrollview).setVisibility(View.VISIBLE);
- }
- if (!error) {
- if (commpressedFilePath != null) {
- uriFile = Uri.fromFile(new File(commpressedFilePath));
- }
- ImageButton toot_picture;
- Button toot_it;
- LinearLayout toot_picture_container;
- toot_picture = this.activityWeakReference.get().findViewById(R.id.toot_picture);
- toot_it = this.activityWeakReference.get().findViewById(R.id.toot_it);
- toot_picture_container = this.activityWeakReference.get().findViewById(R.id.toot_picture_container);
- if (toot_picture_container != null) {
- toot_picture_container.setVisibility(View.VISIBLE);
- }
- if (toot_picture != null) {
- toot_picture.setEnabled(false);
- }
- if (toot_it != null) {
- toot_it.setEnabled(false);
- }
- if (filename == null) {
- filename = Helper.getFileName(this.activityWeakReference.get(), uriFile);
- }
- filesMap.put(filename, uriFile);
- upload(activityWeakReference.get(), account, social, uriFile, filename, uploadReceiver);
- }
- }
}
}
diff --git a/app/src/main/java/app/fedilab/android/activities/BookmarkActivity.java b/app/src/main/java/app/fedilab/android/activities/BookmarkActivity.java
index a720e1dbc..d369860ef 100644
--- a/app/src/main/java/app/fedilab/android/activities/BookmarkActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/BookmarkActivity.java
@@ -18,7 +18,6 @@ import android.content.Context;
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;
@@ -126,7 +125,7 @@ public class BookmarkActivity extends BaseActivity implements OnRetrieveFeedsInt
mainLoader = findViewById(R.id.loader);
textviewNoAction = findViewById(R.id.no_action);
mainLoader.setVisibility(View.VISIBLE);
- new RetrieveFeedsAsyncTask(BookmarkActivity.this, RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS, null, BookmarkActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveFeedsAsyncTask(BookmarkActivity.this, RetrieveFeedsAsyncTask.Type.CACHE_BOOKMARKS, null, BookmarkActivity.this);
}
@@ -138,10 +137,10 @@ public class BookmarkActivity extends BaseActivity implements OnRetrieveFeedsInt
finish();
return true;
case R.id.action_export_bookmarks:
- new SyncBookmarksAsyncTask(BookmarkActivity.this, SyncBookmarksAsyncTask.sync.EXPORT, BookmarkActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new SyncBookmarksAsyncTask(BookmarkActivity.this, SyncBookmarksAsyncTask.sync.EXPORT, BookmarkActivity.this);
return true;
case R.id.action_import_bookmarks:
- new SyncBookmarksAsyncTask(BookmarkActivity.this, SyncBookmarksAsyncTask.sync.IMPORT, BookmarkActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new SyncBookmarksAsyncTask(BookmarkActivity.this, SyncBookmarksAsyncTask.sync.IMPORT, BookmarkActivity.this);
return true;
default:
return super.onOptionsItemSelected(item);
@@ -216,7 +215,7 @@ public class BookmarkActivity extends BaseActivity implements OnRetrieveFeedsInt
lv_status.setAdapter(statusListAdapter);
statusListAdapter.notifyDataSetChanged();
textviewNoAction.setVisibility(View.VISIBLE);
- new PostActionAsyncTask(BookmarkActivity.this, API.StatusAction.UNBOOKMARK).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostActionAsyncTask(BookmarkActivity.this, API.StatusAction.UNBOOKMARK);
dialogConfirm.dismiss();
})
.setNegativeButton(R.string.no, (dialogConfirm, which) -> dialogConfirm.dismiss())
diff --git a/app/src/main/java/app/fedilab/android/activities/CustomSharingActivity.java b/app/src/main/java/app/fedilab/android/activities/CustomSharingActivity.java
index c12a187a0..d2f8c7c2d 100644
--- a/app/src/main/java/app/fedilab/android/activities/CustomSharingActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/CustomSharingActivity.java
@@ -19,7 +19,6 @@ import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
-import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
@@ -186,7 +185,7 @@ public class CustomSharingActivity extends BaseActivity implements OnCustomShari
"http://example.net/add?token=YOUR_TOKEN&url=${url}&title=${title}" +
"&source=${source}&id=${id}&description=${description}&keywords=${keywords}&creator=${creator}&thumbnailurl=${thumbnailurl}");
encodedCustomSharingURL = encodeCustomSharingURL();
- new CustomSharingAsyncTask(CustomSharingActivity.this, encodedCustomSharingURL, CustomSharingActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new CustomSharingAsyncTask(CustomSharingActivity.this, encodedCustomSharingURL, CustomSharingActivity.this);
});
}
diff --git a/app/src/main/java/app/fedilab/android/activities/EditProfileActivity.java b/app/src/main/java/app/fedilab/android/activities/EditProfileActivity.java
index b3de860c8..d10146b25 100644
--- a/app/src/main/java/app/fedilab/android/activities/EditProfileActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/EditProfileActivity.java
@@ -27,7 +27,6 @@ import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.media.ThumbnailUtils;
import android.net.Uri;
-import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.text.Editable;
@@ -172,7 +171,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
set_profile_description.setEnabled(false);
set_lock_account.setEnabled(false);
set_sensitive_content.setEnabled(false);
- new RetrieveAccountInfoAsyncTask(EditProfileActivity.this, EditProfileActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveAccountInfoAsyncTask(EditProfileActivity.this, EditProfileActivity.this);
}
@@ -213,14 +212,8 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
set_profile_description.setEnabled(true);
set_lock_account.setEnabled(true);
set_sensitive_content.setEnabled(true);
- if (account.isLocked())
- set_lock_account.setChecked(true);
- else
- set_lock_account.setChecked(false);
- if (account.isSensitive())
- set_sensitive_content.setChecked(true);
- else
- set_sensitive_content.setChecked(false);
+ set_lock_account.setChecked(account.isLocked());
+ set_sensitive_content.setChecked(account.isSensitive());
set_profile_description.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
@@ -424,7 +417,7 @@ public class EditProfileActivity extends BaseActivity implements OnRetrieveAccou
newCustomFields.put(key3, val3);
newCustomFields.put(key4, val4);
- new UpdateCredentialAsyncTask(EditProfileActivity.this, newCustomFields, profile_username, profile_note, profile_picture, avatarName, header_picture, headerName, profile_privacy, sensitive, EditProfileActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new UpdateCredentialAsyncTask(EditProfileActivity.this, newCustomFields, profile_username, profile_note, profile_picture, avatarName, header_picture, headerName, profile_privacy, sensitive, EditProfileActivity.this);
});
dialogBuilder.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
AlertDialog alertDialog = dialogBuilder.create();
diff --git a/app/src/main/java/app/fedilab/android/activities/GroupActivity.java b/app/src/main/java/app/fedilab/android/activities/GroupActivity.java
index b5d05f4eb..91810fa50 100644
--- a/app/src/main/java/app/fedilab/android/activities/GroupActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/GroupActivity.java
@@ -16,7 +16,6 @@ package app.fedilab.android.activities;
import android.content.SharedPreferences;
-import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
@@ -131,7 +130,7 @@ public class GroupActivity extends BaseActivity implements OnRetrieveFeedsInterf
statuses = new ArrayList<>();
firstLoad = true;
flag_loading = true;
- new RetrieveFeedsAsyncTask(GroupActivity.this, RetrieveFeedsAsyncTask.Type.GNU_GROUP_TIMELINE, groupname, null, max_id, GroupActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveFeedsAsyncTask(GroupActivity.this, RetrieveFeedsAsyncTask.Type.GNU_GROUP_TIMELINE, groupname, null, max_id, GroupActivity.this);
});
final LinearLayoutManager mLayoutManager;
mLayoutManager = new LinearLayoutManager(this);
@@ -145,7 +144,7 @@ public class GroupActivity extends BaseActivity implements OnRetrieveFeedsInterf
if (firstVisibleItem + visibleItemCount == totalItemCount) {
if (!flag_loading) {
flag_loading = true;
- new RetrieveFeedsAsyncTask(GroupActivity.this, RetrieveFeedsAsyncTask.Type.GNU_GROUP_TIMELINE, groupname, null, max_id, GroupActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveFeedsAsyncTask(GroupActivity.this, RetrieveFeedsAsyncTask.Type.GNU_GROUP_TIMELINE, groupname, null, max_id, GroupActivity.this);
nextElementLoader.setVisibility(View.VISIBLE);
}
@@ -155,7 +154,7 @@ public class GroupActivity extends BaseActivity implements OnRetrieveFeedsInterf
}
}
});
- new RetrieveFeedsAsyncTask(GroupActivity.this, RetrieveFeedsAsyncTask.Type.GNU_GROUP_TIMELINE, groupname, null, max_id, GroupActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveFeedsAsyncTask(GroupActivity.this, RetrieveFeedsAsyncTask.Type.GNU_GROUP_TIMELINE, groupname, null, max_id, GroupActivity.this);
}
diff --git a/app/src/main/java/app/fedilab/android/activities/HashTagActivity.java b/app/src/main/java/app/fedilab/android/activities/HashTagActivity.java
index f148ef613..a03042353 100644
--- a/app/src/main/java/app/fedilab/android/activities/HashTagActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/HashTagActivity.java
@@ -18,7 +18,6 @@ package app.fedilab.android.activities;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
-import android.os.AsyncTask;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
@@ -151,7 +150,7 @@ public class HashTagActivity extends BaseActivity implements OnRetrieveFeedsInte
statuses = new ArrayList<>();
firstLoad = true;
flag_loading = true;
- new RetrieveFeedsAsyncTask(HashTagActivity.this, RetrieveFeedsAsyncTask.Type.TAG, tag, null, max_id, HashTagActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveFeedsAsyncTask(HashTagActivity.this, RetrieveFeedsAsyncTask.Type.TAG, tag, null, max_id, HashTagActivity.this);
});
final LinearLayoutManager mLayoutManager;
mLayoutManager = new LinearLayoutManager(this);
@@ -165,7 +164,7 @@ public class HashTagActivity extends BaseActivity implements OnRetrieveFeedsInte
if (firstVisibleItem + visibleItemCount == totalItemCount) {
if (!flag_loading) {
flag_loading = true;
- new RetrieveFeedsAsyncTask(HashTagActivity.this, RetrieveFeedsAsyncTask.Type.TAG, tag, null, max_id, HashTagActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveFeedsAsyncTask(HashTagActivity.this, RetrieveFeedsAsyncTask.Type.TAG, tag, null, max_id, HashTagActivity.this);
nextElementLoader.setVisibility(View.VISIBLE);
}
@@ -175,7 +174,7 @@ public class HashTagActivity extends BaseActivity implements OnRetrieveFeedsInte
}
}
});
- new RetrieveFeedsAsyncTask(HashTagActivity.this, RetrieveFeedsAsyncTask.Type.TAG, tag, null, max_id, HashTagActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveFeedsAsyncTask(HashTagActivity.this, RetrieveFeedsAsyncTask.Type.TAG, tag, null, max_id, HashTagActivity.this);
}
@@ -199,22 +198,21 @@ public class HashTagActivity extends BaseActivity implements OnRetrieveFeedsInte
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- finish();
- return true;
- case R.id.action_pin:
- SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
- new SearchDAO(HashTagActivity.this, db).insertSearch(tag);
- Intent intent = new Intent(HashTagActivity.this, MainActivity.class);
- intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
- intent.putExtra(Helper.INTENT_ACTION, Helper.SEARCH_TAG);
- intent.putExtra(Helper.SEARCH_KEYWORD, tag);
- startActivity(intent);
- return true;
- default:
- return super.onOptionsItemSelected(item);
+ int itemId = item.getItemId();
+ if (itemId == android.R.id.home) {
+ finish();
+ return true;
+ } else if (itemId == R.id.action_pin) {
+ SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
+ new SearchDAO(HashTagActivity.this, db).insertSearch(tag);
+ Intent intent = new Intent(HashTagActivity.this, MainActivity.class);
+ intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.putExtra(Helper.INTENT_ACTION, Helper.SEARCH_TAG);
+ intent.putExtra(Helper.SEARCH_KEYWORD, tag);
+ startActivity(intent);
+ return true;
}
+ return super.onOptionsItemSelected(item);
}
@Override
diff --git a/app/src/main/java/app/fedilab/android/activities/InstanceActivity.java b/app/src/main/java/app/fedilab/android/activities/InstanceActivity.java
index 986ea6608..10f44c569 100644
--- a/app/src/main/java/app/fedilab/android/activities/InstanceActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/InstanceActivity.java
@@ -20,7 +20,6 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
-import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
@@ -96,7 +95,7 @@ public class InstanceActivity extends BaseActivity implements OnRetrieveInstance
instance_container.setVisibility(View.GONE);
loader.setVisibility(View.VISIBLE);
setTitle(getString(R.string.action_about_instance));
- new RetrieveInstanceAsyncTask(InstanceActivity.this, InstanceActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveInstanceAsyncTask(InstanceActivity.this, InstanceActivity.this);
}
diff --git a/app/src/main/java/app/fedilab/android/activities/ListActivity.java b/app/src/main/java/app/fedilab/android/activities/ListActivity.java
index f186032fa..1b90f3a73 100644
--- a/app/src/main/java/app/fedilab/android/activities/ListActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/ListActivity.java
@@ -17,7 +17,6 @@ package app.fedilab.android.activities;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.os.AsyncTask;
import android.os.Bundle;
import android.text.InputFilter;
import android.view.LayoutInflater;
@@ -154,7 +153,7 @@ public class ListActivity extends BaseActivity implements OnListActionInterface
if (firstVisibleItem + visibleItemCount == totalItemCount) {
if (!flag_loading) {
flag_loading = true;
- new ManageListsAsyncTask(ListActivity.this, listId, max_id, null, ListActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new ManageListsAsyncTask(ListActivity.this, listId, max_id, null, ListActivity.this);
nextElementLoader.setVisibility(View.VISIBLE);
}
} else {
@@ -171,10 +170,10 @@ public class ListActivity extends BaseActivity implements OnListActionInterface
flag_loading = true;
swiped = true;
MainActivity.countNewStatus = 0;
- new ManageListsAsyncTask(ListActivity.this, listId, null, null, ListActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new ManageListsAsyncTask(ListActivity.this, listId, null, null, ListActivity.this);
});
- new ManageListsAsyncTask(ListActivity.this, listId, null, null, ListActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new ManageListsAsyncTask(ListActivity.this, listId, null, null, ListActivity.this);
}
@@ -216,7 +215,7 @@ public class ListActivity extends BaseActivity implements OnListActionInterface
editText.setText(title);
dialogBuilder.setPositiveButton(R.string.validate, (dialog, id) -> {
if (editText.getText() != null && editText.getText().toString().trim().length() > 0)
- new ManageListsAsyncTask(ListActivity.this, ManageListsAsyncTask.action.UPDATE_LIST, null, listId, editText.getText().toString(), editText.getText().toString().trim(), ListActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new ManageListsAsyncTask(ListActivity.this, ManageListsAsyncTask.action.UPDATE_LIST, null, listId, editText.getText().toString().trim(), ListActivity.this);
dialog.dismiss();
});
dialogBuilder.setNegativeButton(R.string.cancel, (dialog, id) -> dialog.dismiss());
diff --git a/app/src/main/java/app/fedilab/android/activities/LoginActivity.java b/app/src/main/java/app/fedilab/android/activities/LoginActivity.java
index 4f62c8cff..481089020 100644
--- a/app/src/main/java/app/fedilab/android/activities/LoginActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/LoginActivity.java
@@ -23,7 +23,6 @@ import android.database.sqlite.SQLiteDatabase;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
-import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Editable;
import android.text.SpannableString;
@@ -69,6 +68,7 @@ import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
+import app.fedilab.android.BuildConfig;
import app.fedilab.android.R;
import app.fedilab.android.asynctasks.UpdateAccountInfoAsyncTask;
import app.fedilab.android.client.API;
@@ -152,16 +152,16 @@ public class LoginActivity extends BaseActivity {
JSONObject resobj;
try {
resobj = new JSONObject(response);
- String token = resobj.get("access_token").toString();
+ String token = resobj.getString("access_token");
String refresh_token = null;
if (resobj.has("refresh_token"))
- refresh_token = resobj.get("refresh_token").toString();
+ refresh_token = resobj.getString("refresh_token");
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, token);
- editor.apply();
+ editor.commit();
//Update the account with the token;
- new UpdateAccountInfoAsyncTask(LoginActivity.this, token, client_id, client_secret, refresh_token, instance, socialNetwork).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new UpdateAccountInfoAsyncTask(LoginActivity.this, token, client_id, client_secret, refresh_token, instance, socialNetwork);
} catch (JSONException e) {
e.printStackTrace();
}
@@ -248,7 +248,7 @@ public class LoginActivity extends BaseActivity {
return;
}
instance = login_instance.getText().toString().trim().toLowerCase();
- if(instance.length() == 0) {
+ if (instance.length() == 0) {
return;
}
connect_button.setEnabled(false);
@@ -588,16 +588,17 @@ public class LoginActivity extends BaseActivity {
if (socialNetwork != UpdateAccountInfoAsyncTask.SOCIAL.GNU && socialNetwork != UpdateAccountInfoAsyncTask.SOCIAL.FRIENDICA) {
try {
resobj = new JSONObject(response);
- String token = resobj.get("access_token").toString();
+ String token = resobj.getString("access_token");
String refresh_token = null;
if (resobj.has("refresh_token"))
refresh_token = resobj.getString("refresh_token");
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, token);
editor.apply();
+
//Update the account with the token;
if (instance != null) {
- new UpdateAccountInfoAsyncTask(LoginActivity.this, token, client_id, client_secret, refresh_token, instance, socialNetwork).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new UpdateAccountInfoAsyncTask(LoginActivity.this, token, client_id, client_secret, refresh_token, instance, socialNetwork);
} else {
connectionButton.setEnabled(true);
Toasty.error(LoginActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
@@ -621,9 +622,10 @@ public class LoginActivity extends BaseActivity {
editor.putBoolean(Helper.PREF_IS_ADMINISTRATOR, account.isAdmin());
editor.putString(Helper.PREF_INSTANCE, instance);
editor.apply();
- if (userExists)
+ if (userExists) {
+
new AccountDAO(LoginActivity.this, db).updateAccount(account);
- else {
+ } else {
if (account.getUsername() != null && account.getCreated_at() != null)
new AccountDAO(LoginActivity.this, db).insertAccount(account);
}
@@ -686,6 +688,10 @@ public class LoginActivity extends BaseActivity {
public boolean onCreateOptionsMenu(@NotNull Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main_login, menu);
+ if (BuildConfig.lite) {
+ menu.findItem(R.id.action_custom_tabs).setVisible(false);
+ menu.findItem(R.id.action_provider).setVisible(false);
+ }
SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
boolean embedded_browser = sharedpreferences.getBoolean(Helper.SET_EMBEDDED_BROWSER, true);
menu.findItem(R.id.action_custom_tabs).setChecked(!embedded_browser);
@@ -695,7 +701,7 @@ public class LoginActivity extends BaseActivity {
}
@Override
- public boolean onOptionsItemSelected(MenuItem item) {
+ public boolean onOptionsItemSelected(@NotNull MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
diff --git a/app/src/main/java/app/fedilab/android/activities/MainBaseFragmentActivity.java b/app/src/main/java/app/fedilab/android/activities/MainBaseFragmentActivity.java
new file mode 100644
index 000000000..02da9bbc3
--- /dev/null
+++ b/app/src/main/java/app/fedilab/android/activities/MainBaseFragmentActivity.java
@@ -0,0 +1,20 @@
+package app.fedilab.android.activities;
+/* Copyright 2020 Thomas Schneider
+ *
+ * This file is a part of Fedilab
+ *
+ * This program is free software; you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+ * Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Fedilab; if not,
+ * see . */
+
+import androidx.appcompat.app.AppCompatActivity;
+
+public abstract class MainBaseFragmentActivity extends AppCompatActivity {
+}
diff --git a/app/src/main/java/app/fedilab/android/activities/ManageAccountsInListActivity.java b/app/src/main/java/app/fedilab/android/activities/ManageAccountsInListActivity.java
index 6c61cd55a..1bbd0db74 100644
--- a/app/src/main/java/app/fedilab/android/activities/ManageAccountsInListActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/ManageAccountsInListActivity.java
@@ -15,7 +15,6 @@
package app.fedilab.android.activities;
import android.content.SharedPreferences;
-import android.os.AsyncTask;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
@@ -100,7 +99,7 @@ public class ManageAccountsInListActivity extends BaseActivity implements OnList
list_title.setText(title);
loader.setVisibility(View.VISIBLE);
- new ManageListsAsyncTask(ManageAccountsInListActivity.this, ManageListsAsyncTask.action.GET_LIST_ACCOUNT, null, null, listId, null, ManageAccountsInListActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new ManageListsAsyncTask(ManageAccountsInListActivity.this, ManageListsAsyncTask.action.GET_LIST_ACCOUNT, null, listId, null, ManageAccountsInListActivity.this);
search_account.addTextChangedListener(new TextWatcher() {
@@ -120,7 +119,7 @@ public class ManageAccountsInListActivity extends BaseActivity implements OnList
@Override
public void afterTextChanged(Editable s) {
if (s != null && s.length() > 0) {
- new ManageListsAsyncTask(ManageAccountsInListActivity.this, s.toString(), ManageAccountsInListActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new ManageListsAsyncTask(ManageAccountsInListActivity.this, s.toString(), ManageAccountsInListActivity.this);
} else {
lv_accounts_search.setVisibility(View.GONE);
lv_accounts_current.setVisibility(View.VISIBLE);
diff --git a/app/src/main/java/app/fedilab/android/activities/MastodonRegisterActivity.java b/app/src/main/java/app/fedilab/android/activities/MastodonRegisterActivity.java
index 413dd6452..d96b16e46 100644
--- a/app/src/main/java/app/fedilab/android/activities/MastodonRegisterActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/MastodonRegisterActivity.java
@@ -19,8 +19,9 @@ import android.animation.AnimatorListenerAdapter;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.drawable.ColorDrawable;
-import android.os.AsyncTask;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
import android.text.Html;
import android.text.SpannableString;
import android.text.Spanned;
@@ -65,7 +66,6 @@ import app.fedilab.android.interfaces.OnPostStatusActionInterface;
import app.fedilab.android.interfaces.OnRetrieveInstanceInterface;
import es.dmoral.toasty.Toasty;
-import static android.os.AsyncTask.THREAD_POOL_EXECUTOR;
/**
* Created by Thomas on 13/06/2019.
@@ -150,7 +150,7 @@ public class MastodonRegisterActivity extends BaseActivity implements OnRetrieve
reg_category.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView> parent, View view, int position, long id) {
- new RetrieveInstanceRegAsyncTask(MastodonRegisterActivity.this, RetrieveInstanceRegAsyncTask.instanceType.MASTODON, itemA[position], MastodonRegisterActivity.this).executeOnExecutor(THREAD_POOL_EXECUTOR);
+ new RetrieveInstanceRegAsyncTask(MastodonRegisterActivity.this, RetrieveInstanceRegAsyncTask.instanceType.MASTODON, itemA[position], MastodonRegisterActivity.this);
}
@Override
@@ -159,7 +159,7 @@ public class MastodonRegisterActivity extends BaseActivity implements OnRetrieve
}
});
- new RetrieveInstanceRegAsyncTask(MastodonRegisterActivity.this, RetrieveInstanceRegAsyncTask.instanceType.MASTODON, "general", MastodonRegisterActivity.this).executeOnExecutor(THREAD_POOL_EXECUTOR);
+ new RetrieveInstanceRegAsyncTask(MastodonRegisterActivity.this, RetrieveInstanceRegAsyncTask.instanceType.MASTODON, "general", MastodonRegisterActivity.this);
signup = findViewById(R.id.signup);
EditText username = findViewById(R.id.username);
@@ -198,7 +198,7 @@ public class MastodonRegisterActivity extends BaseActivity implements OnRetrieve
accountCreation.setPassword(password.getText().toString().trim());
accountCreation.setPasswordConfirm(password_confirm.getText().toString().trim());
accountCreation.setUsername(username.getText().toString().trim());
- new CreateMastodonAccountAsyncTask(MastodonRegisterActivity.this, RetrieveInstanceRegAsyncTask.instanceType.MASTODON, accountCreation, instance, MastodonRegisterActivity.this).executeOnExecutor(THREAD_POOL_EXECUTOR);
+ new CreateMastodonAccountAsyncTask(MastodonRegisterActivity.this, RetrieveInstanceRegAsyncTask.instanceType.MASTODON, accountCreation, instance, MastodonRegisterActivity.this);
});
@@ -287,7 +287,7 @@ public class MastodonRegisterActivity extends BaseActivity implements OnRetrieve
private void checkInstance(Context context, String instance) {
- new checkRegistration(context, instance).executeOnExecutor(THREAD_POOL_EXECUTOR);
+ new checkRegistration(context, instance);
}
@Override
@@ -337,43 +337,43 @@ public class MastodonRegisterActivity extends BaseActivity implements OnRetrieve
}
- private static class checkRegistration extends AsyncTask {
+ private static class checkRegistration {
- private String instance;
- private WeakReference weakReference;
+ private final String instance;
+ private final WeakReference weakReference;
checkRegistration(Context context, String instance) {
this.instance = instance;
this.weakReference = new WeakReference<>(context);
+ doInBackground();
}
- @Override
- protected String doInBackground(Void... params) {
- String response = null;
- try {
- URL url = new URL("https://" + instance + "/auth/sign_up");
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
- java.util.Scanner s = new java.util.Scanner(connection.getInputStream()).useDelimiter("\\A");
- response = s.hasNext() ? s.next() : "";
+ protected void doInBackground() {
+ new Thread(() -> {
+ String response = null;
+ try {
+ URL url = new URL("https://" + instance + "/auth/sign_up");
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
+ java.util.Scanner s = new java.util.Scanner(connection.getInputStream()).useDelimiter("\\A");
+ response = s.hasNext() ? s.next() : "";
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
}
- } catch (IOException e) {
- e.printStackTrace();
- }
- return response;
+ Handler mainHandler = new Handler(Looper.getMainLooper());
+ String finalResponse = response;
+ Runnable myRunnable = () -> {
+ if (finalResponse != null && finalResponse.contains("invite_request_attributes")) {
+ TextView invitation = ((MastodonRegisterActivity) (weakReference.get())).findViewById(R.id.invitation);
+ if (invitation != null) {
+ invitation.setVisibility(View.VISIBLE);
+ }
+ }
+ };
+ mainHandler.post(myRunnable);
+ }).start();
}
- @Override
- protected void onPostExecute(String result) {
-
-
- if (result != null && result.contains("invite_request_attributes")) {
- TextView invitation = ((MastodonRegisterActivity) (weakReference.get())).findViewById(R.id.invitation);
- if (invitation != null) {
- invitation.setVisibility(View.VISIBLE);
- }
- }
-
- }
}
}
\ No newline at end of file
diff --git a/app/src/main/java/app/fedilab/android/activities/MastodonShareRegisterActivity.java b/app/src/main/java/app/fedilab/android/activities/MastodonShareRegisterActivity.java
index 5241ce51c..1af7329ba 100644
--- a/app/src/main/java/app/fedilab/android/activities/MastodonShareRegisterActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/MastodonShareRegisterActivity.java
@@ -20,8 +20,9 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
-import android.os.AsyncTask;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
@@ -59,7 +60,6 @@ import app.fedilab.android.interfaces.OnPostStatusActionInterface;
import app.fedilab.android.interfaces.OnRetrieveInstanceInterface;
import es.dmoral.toasty.Toasty;
-import static android.os.AsyncTask.THREAD_POOL_EXECUTOR;
/**
* Created by Thomas on 17/08/2019.
@@ -165,7 +165,7 @@ public class MastodonShareRegisterActivity extends BaseActivity implements OnRet
accountCreation.setPassword(password.getText().toString().trim());
accountCreation.setPasswordConfirm(password_confirm.getText().toString().trim());
accountCreation.setUsername(username.getText().toString().trim());
- new CreateMastodonAccountAsyncTask(MastodonShareRegisterActivity.this, RetrieveInstanceRegAsyncTask.instanceType.MASTODON, accountCreation, instance, MastodonShareRegisterActivity.this).executeOnExecutor(THREAD_POOL_EXECUTOR);
+ new CreateMastodonAccountAsyncTask(MastodonShareRegisterActivity.this, RetrieveInstanceRegAsyncTask.instanceType.MASTODON, accountCreation, instance, MastodonShareRegisterActivity.this);
});
@@ -220,7 +220,7 @@ public class MastodonShareRegisterActivity extends BaseActivity implements OnRet
private void checkInstance(Context context, String instance) {
- new checkRegistration(context, instance).executeOnExecutor(THREAD_POOL_EXECUTOR);
+ new checkRegistration(context, instance);
}
@Override
@@ -270,43 +270,42 @@ public class MastodonShareRegisterActivity extends BaseActivity implements OnRet
}
- private static class checkRegistration extends AsyncTask {
+ private static class checkRegistration {
- private String instance;
- private WeakReference weakReference;
+ private final String instance;
+ private final WeakReference weakReference;
checkRegistration(Context context, String instance) {
this.instance = instance;
this.weakReference = new WeakReference<>(context);
+ doInBackground();
}
- @Override
- protected String doInBackground(Void... params) {
- String response = null;
- try {
- URL url = new URL("https://" + instance + "/auth/sign_up");
- HttpURLConnection connection = (HttpURLConnection) url.openConnection();
- if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
- java.util.Scanner s = new java.util.Scanner(connection.getInputStream()).useDelimiter("\\A");
- response = s.hasNext() ? s.next() : "";
+ protected void doInBackground() {
+ new Thread(() -> {
+ String response = null;
+ try {
+ URL url = new URL("https://" + instance + "/auth/sign_up");
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
+ java.util.Scanner s = new java.util.Scanner(connection.getInputStream()).useDelimiter("\\A");
+ response = s.hasNext() ? s.next() : "";
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
}
- } catch (IOException e) {
- e.printStackTrace();
- }
- return response;
- }
-
- @Override
- protected void onPostExecute(String result) {
-
-
- if (result != null && result.contains("invite_request_attributes")) {
- TextView invitation = ((MastodonShareRegisterActivity) (weakReference.get())).findViewById(R.id.invitation);
- if (invitation != null) {
- invitation.setVisibility(View.VISIBLE);
- }
- }
-
+ Handler mainHandler = new Handler(Looper.getMainLooper());
+ String finalResponse = response;
+ Runnable myRunnable = () -> {
+ if (finalResponse != null && finalResponse.contains("invite_request_attributes")) {
+ TextView invitation = ((MastodonShareRegisterActivity) (weakReference.get())).findViewById(R.id.invitation);
+ if (invitation != null) {
+ invitation.setVisibility(View.VISIBLE);
+ }
+ }
+ };
+ mainHandler.post(myRunnable);
+ }).start();
}
}
}
\ No newline at end of file
diff --git a/app/src/main/java/app/fedilab/android/activities/MutedInstanceActivity.java b/app/src/main/java/app/fedilab/android/activities/MutedInstanceActivity.java
index 72be71f04..97b72ca2e 100644
--- a/app/src/main/java/app/fedilab/android/activities/MutedInstanceActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/MutedInstanceActivity.java
@@ -20,7 +20,6 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.graphics.drawable.ColorDrawable;
-import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
@@ -76,7 +75,6 @@ public class MutedInstanceActivity extends BaseActivity implements OnRetrieveDom
private final int PICK_IMPORT_INSTANCE = 5326;
private boolean flag_loading;
- private AsyncTask asyncTask;
private DomainsListAdapter domainsListAdapter;
private String max_id;
private List domains;
@@ -141,7 +139,7 @@ public class MutedInstanceActivity extends BaseActivity implements OnRetrieveDom
EditText add_domain = dialogView.findViewById(R.id.add_domain);
dialogBuilder.setPositiveButton(R.string.validate, (dialog, id) -> {
if (add_domain.getText() != null && add_domain.getText().toString().trim().matches("^[\\da-zA-Z.-]+\\.[a-zA-Z.]{2,10}$")) {
- new PostActionAsyncTask(MutedInstanceActivity.this, API.StatusAction.BLOCK_DOMAIN, add_domain.getText().toString().trim(), MutedInstanceActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostActionAsyncTask(MutedInstanceActivity.this, API.StatusAction.BLOCK_DOMAIN, add_domain.getText().toString().trim(), MutedInstanceActivity.this);
dialog.dismiss();
} else {
Toasty.error(MutedInstanceActivity.this, getString(R.string.toast_empty_content)).show();
@@ -225,7 +223,7 @@ public class MutedInstanceActivity extends BaseActivity implements OnRetrieveDom
if (firstVisibleItem + visibleItemCount == totalItemCount) {
if (!flag_loading) {
flag_loading = true;
- asyncTask = new RetrieveDomainsAsyncTask(MutedInstanceActivity.this, max_id, MutedInstanceActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveDomainsAsyncTask(MutedInstanceActivity.this, max_id, MutedInstanceActivity.this);
nextElementLoader.setVisibility(View.VISIBLE);
}
} else {
@@ -240,7 +238,7 @@ public class MutedInstanceActivity extends BaseActivity implements OnRetrieveDom
firstLoad = true;
flag_loading = true;
swiped = true;
- asyncTask = new RetrieveDomainsAsyncTask(MutedInstanceActivity.this, max_id, MutedInstanceActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveDomainsAsyncTask(MutedInstanceActivity.this, max_id, MutedInstanceActivity.this);
});
switch (theme) {
case Helper.THEME_LIGHT:
@@ -263,7 +261,7 @@ public class MutedInstanceActivity extends BaseActivity implements OnRetrieveDom
break;
}
- asyncTask = new RetrieveDomainsAsyncTask(MutedInstanceActivity.this, max_id, MutedInstanceActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveDomainsAsyncTask(MutedInstanceActivity.this, max_id, MutedInstanceActivity.this);
setTitle(R.string.blocked_domains);
}
@@ -271,8 +269,6 @@ public class MutedInstanceActivity extends BaseActivity implements OnRetrieveDom
@Override
public void onDestroy() {
super.onDestroy();
- if (asyncTask != null && asyncTask.getStatus() == AsyncTask.Status.RUNNING)
- asyncTask.cancel(true);
}
@Override
diff --git a/app/src/main/java/app/fedilab/android/activities/PartnerShipActivity.java b/app/src/main/java/app/fedilab/android/activities/PartnerShipActivity.java
index 2b35efeb7..d9b1e30ca 100644
--- a/app/src/main/java/app/fedilab/android/activities/PartnerShipActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/PartnerShipActivity.java
@@ -18,7 +18,6 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
-import android.os.AsyncTask;
import android.os.Bundle;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
@@ -58,7 +57,7 @@ import es.dmoral.toasty.Toasty;
public class PartnerShipActivity extends BaseActivity implements OnRetrieveRemoteAccountInterface, OnRetrieveRelationshipInterface {
- private List mastohostAcct = new ArrayList<>();
+ private final List mastohostAcct = new ArrayList<>();
private AccountSearchDevAdapter mastohostAdapter;
@@ -115,7 +114,7 @@ public class PartnerShipActivity extends BaseActivity implements OnRetrieveRemot
lv_mastohost.setAdapter(mastohostAdapter);
- new RetrieveRemoteDataAsyncTask(PartnerShipActivity.this, "mastohost", "mastodon.social", PartnerShipActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveRemoteDataAsyncTask(PartnerShipActivity.this, "mastohost", "mastodon.social", PartnerShipActivity.this);
}
@Override
@@ -143,7 +142,7 @@ public class PartnerShipActivity extends BaseActivity implements OnRetrieveRemot
mastohostAcct.add(account);
mastohostAdapter.notifyDataSetChanged();
}
- new RetrieveRelationshipAsyncTask(PartnerShipActivity.this, account.getId(), PartnerShipActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveRelationshipAsyncTask(PartnerShipActivity.this, account.getId(), PartnerShipActivity.this);
}
}
@@ -153,7 +152,7 @@ public class PartnerShipActivity extends BaseActivity implements OnRetrieveRemot
super.onResume();
if (mastohostAcct != null) {
for (Account account : mastohostAcct) {
- new RetrieveRelationshipAsyncTask(PartnerShipActivity.this, account.getId(), PartnerShipActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveRelationshipAsyncTask(PartnerShipActivity.this, account.getId(), PartnerShipActivity.this);
}
}
}
diff --git a/app/src/main/java/app/fedilab/android/activities/PeertubeActivity.java b/app/src/main/java/app/fedilab/android/activities/PeertubeActivity.java
index 002d1f101..18a0901c0 100644
--- a/app/src/main/java/app/fedilab/android/activities/PeertubeActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/PeertubeActivity.java
@@ -28,9 +28,10 @@ import android.database.sqlite.SQLiteDatabase;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
-import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
+import android.os.Handler;
+import android.os.Looper;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.Menu;
@@ -212,7 +213,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
send.setOnClickListener(v -> {
String comment = add_comment_write.getText().toString();
if (comment.trim().length() > 0) {
- new PostActionAsyncTask(PeertubeActivity.this, API.StatusAction.PEERTUBECOMMENT, peertube.getId(), null, comment, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostActionAsyncTask(PeertubeActivity.this, API.StatusAction.PEERTUBECOMMENT, peertube.getId(), null, comment, PeertubeActivity.this);
add_comment_write.setText("");
add_comment_read.setVisibility(View.VISIBLE);
add_comment_write.setVisibility(View.GONE);
@@ -303,10 +304,10 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
}
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
- new ManagePlaylistsAsyncTask(PeertubeActivity.this, GET_PLAYLIST, null, null, null, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new ManagePlaylistsAsyncTask(PeertubeActivity.this, GET_PLAYLIST, null, null, null, PeertubeActivity.this);
}
- new RetrievePeertubeSingleAsyncTask(PeertubeActivity.this, peertubeInstance, videoId, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrievePeertubeSingleAsyncTask(PeertubeActivity.this, peertubeInstance, videoId, PeertubeActivity.this);
}
public void change() {
@@ -361,52 +362,51 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- finish();
- return true;
- case R.id.action_comment:
- if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
- Toasty.info(PeertubeActivity.this, getString(R.string.retrieve_remote_status), Toast.LENGTH_LONG).show();
- new commentTask(new WeakReference<>(PeertubeActivity.this), peertube).execute();
- } else if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
- if (!peertube.isCommentsEnabled()) {
- Toasty.info(PeertubeActivity.this, getString(R.string.comment_no_allowed_peertube), Toast.LENGTH_LONG).show();
- return true;
- }
- int style;
- SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
- int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
- if (theme == Helper.THEME_DARK) {
- style = R.style.DialogDark;
- } else if (theme == Helper.THEME_BLACK) {
- style = R.style.DialogBlack;
- } else {
- style = R.style.Dialog;
- }
- AlertDialog.Builder builderInner;
- builderInner = new AlertDialog.Builder(PeertubeActivity.this, style);
- builderInner.setTitle(R.string.comment);
- EditText input = new EditText(PeertubeActivity.this);
- LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.MATCH_PARENT,
- LinearLayout.LayoutParams.WRAP_CONTENT);
- input.setLayoutParams(lp);
- builderInner.setView(input);
- builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
- builderInner.setPositiveButton(R.string.validate, (dialog, which) -> {
- String comment = input.getText().toString();
- if (comment.trim().length() > 0) {
- new PostActionAsyncTask(PeertubeActivity.this, API.StatusAction.PEERTUBECOMMENT, peertube.getId(), null, comment, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- dialog.dismiss();
- }
- });
- builderInner.show();
+ int itemId = item.getItemId();
+ if (itemId == android.R.id.home) {
+ finish();
+ return true;
+ } else if (itemId == R.id.action_comment) {
+ if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA) {
+ Toasty.info(PeertubeActivity.this, getString(R.string.retrieve_remote_status), Toast.LENGTH_LONG).show();
+ new commentTask(new WeakReference<>(PeertubeActivity.this), peertube);
+ } else if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
+ if (!peertube.isCommentsEnabled()) {
+ Toasty.info(PeertubeActivity.this, getString(R.string.comment_no_allowed_peertube), Toast.LENGTH_LONG).show();
+ return true;
}
- return true;
- default:
- return super.onOptionsItemSelected(item);
+ int style;
+ SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
+ int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
+ if (theme == Helper.THEME_DARK) {
+ style = R.style.DialogDark;
+ } else if (theme == Helper.THEME_BLACK) {
+ style = R.style.DialogBlack;
+ } else {
+ style = R.style.Dialog;
+ }
+ AlertDialog.Builder builderInner;
+ builderInner = new AlertDialog.Builder(PeertubeActivity.this, style);
+ builderInner.setTitle(R.string.comment);
+ EditText input = new EditText(PeertubeActivity.this);
+ LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
+ LinearLayout.LayoutParams.MATCH_PARENT,
+ LinearLayout.LayoutParams.WRAP_CONTENT);
+ input.setLayoutParams(lp);
+ builderInner.setView(input);
+ builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
+ builderInner.setPositiveButton(R.string.validate, (dialog, which) -> {
+ String comment = input.getText().toString();
+ if (comment.trim().length() > 0) {
+ new PostActionAsyncTask(PeertubeActivity.this, API.StatusAction.PEERTUBECOMMENT, peertube.getId(), null, comment, PeertubeActivity.this);
+ dialog.dismiss();
+ }
+ });
+ builderInner.show();
+ }
+ return true;
}
+ return super.onOptionsItemSelected(item);
}
public FullScreenMediaController.fullscreen getFullscreen() {
@@ -434,7 +434,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
peertube = apiResponse.getPeertubes().get(0);
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
- new ManagePlaylistsAsyncTask(PeertubeActivity.this, GET_PLAYLIST_FOR_VIDEO, null, peertube.getId(), null, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new ManagePlaylistsAsyncTask(PeertubeActivity.this, GET_PLAYLIST_FOR_VIDEO, null, peertube.getId(), null, PeertubeActivity.this);
}
@@ -470,11 +470,11 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
});
if (playlistForVideo.contains(playlist.getId())) {
item1.setTitle(playlist.getDisplayName());
- new ManagePlaylistsAsyncTask(PeertubeActivity.this, ManagePlaylistsAsyncTask.action.DELETE_VIDEOS, playlist, peertube.getId(), null, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new ManagePlaylistsAsyncTask(PeertubeActivity.this, ManagePlaylistsAsyncTask.action.DELETE_VIDEOS, playlist, peertube.getId(), null, PeertubeActivity.this);
playlistForVideo.remove(playlist.getId());
} else {
item1.setTitle("✔ " + playlist.getDisplayName());
- new ManagePlaylistsAsyncTask(PeertubeActivity.this, ManagePlaylistsAsyncTask.action.ADD_VIDEOS, playlist, peertube.getId(), null, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new ManagePlaylistsAsyncTask(PeertubeActivity.this, ManagePlaylistsAsyncTask.action.ADD_VIDEOS, playlist, peertube.getId(), null, PeertubeActivity.this);
playlistForVideo.add(playlist.getId());
}
return false;
@@ -486,7 +486,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
if (peertube.isCommentsEnabled()) {
- new RetrievePeertubeSingleCommentsAsyncTask(PeertubeActivity.this, peertubeInstance, videoId, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrievePeertubeSingleCommentsAsyncTask(PeertubeActivity.this, peertubeInstance, videoId, PeertubeActivity.this);
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
write_comment_container.setVisibility(View.VISIBLE);
} else {
@@ -512,13 +512,13 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
peertube_like_count.setOnClickListener(v -> {
String newState = peertube.getMyRating().equals("like") ? "none" : "like";
- new PostActionAsyncTask(PeertubeActivity.this, API.StatusAction.RATEVIDEO, peertube.getId(), null, newState, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostActionAsyncTask(PeertubeActivity.this, API.StatusAction.RATEVIDEO, peertube.getId(), null, newState, PeertubeActivity.this);
peertube.setMyRating(newState);
changeColor();
});
peertube_dislike_count.setOnClickListener(v -> {
String newState = peertube.getMyRating().equals("dislike") ? "none" : "dislike";
- new PostActionAsyncTask(PeertubeActivity.this, API.StatusAction.RATEVIDEO, peertube.getId(), null, newState, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostActionAsyncTask(PeertubeActivity.this, API.StatusAction.RATEVIDEO, peertube.getId(), null, newState, PeertubeActivity.this);
peertube.setMyRating(newState);
changeColor();
});
@@ -777,7 +777,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
public void onPostAction(int statusCode, API.StatusAction statusAction, String userId, Error error) {
if (peertube.isCommentsEnabled() && statusAction == API.StatusAction.PEERTUBECOMMENT)
- new RetrievePeertubeSingleCommentsAsyncTask(PeertubeActivity.this, peertubeInstance, videoId, PeertubeActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrievePeertubeSingleCommentsAsyncTask(PeertubeActivity.this, peertubeInstance, videoId, PeertubeActivity.this);
}
@@ -852,48 +852,50 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
}
}
- private static class commentTask extends AsyncTask {
+ private static class commentTask {
- private WeakReference contextReference;
- private Peertube peertube;
+ private final WeakReference contextReference;
+ private final Peertube peertube;
commentTask(WeakReference contextReference, Peertube peertube) {
this.peertube = peertube;
this.contextReference = contextReference;
+ doInBackground();
}
- @Override
- protected app.fedilab.android.client.Entities.Status doInBackground(Void... voids) {
-
- List remoteStatuses = null;
- if (peertube != null) {
- APIResponse search = new API(contextReference.get()).search("https://" + peertube.getAccount().getHost() + "/videos/watch/" + peertube.getUuid());
- if (search != null && search.getResults() != null) {
- remoteStatuses = search.getResults().getStatuses();
+ protected void doInBackground() {
+ new Thread(() -> {
+ List remoteStatuses = null;
+ if (peertube != null) {
+ APIResponse search = new API(contextReference.get()).search("https://" + peertube.getAccount().getHost() + "/videos/watch/" + peertube.getUuid());
+ if (search != null && search.getResults() != null) {
+ remoteStatuses = search.getResults().getStatuses();
+ }
}
- }
- if (remoteStatuses != null && remoteStatuses.size() > 0) {
- return remoteStatuses.get(0);
- } else {
- return null;
- }
+ app.fedilab.android.client.Entities.Status remoteStatuse = null;
+ if (remoteStatuses != null && remoteStatuses.size() > 0) {
+ remoteStatuse = remoteStatuses.get(0);
+ }
+ Handler mainHandler = new Handler(Looper.getMainLooper());
+ app.fedilab.android.client.Entities.Status finalRemoteStatuse = remoteStatuse;
+ Runnable myRunnable = () -> {
+ Intent intent = new Intent(contextReference.get(), TootActivity.class);
+ Bundle b = new Bundle();
+ if (finalRemoteStatuse == null) {
+ Toasty.error(contextReference.get(), contextReference.get().getString(R.string.toast_error), Toast.LENGTH_SHORT).show();
+ return;
+ }
+ if (finalRemoteStatuse.getReblog() != null) {
+ b.putParcelable("tootReply", finalRemoteStatuse.getReblog());
+ } else {
+ b.putParcelable("tootReply", finalRemoteStatuse);
+ }
+ intent.putExtras(b);
+ contextReference.get().startActivity(intent);
+ };
+ mainHandler.post(myRunnable);
+ }).start();
}
- @Override
- protected void onPostExecute(app.fedilab.android.client.Entities.Status remoteStatuses) {
- Intent intent = new Intent(contextReference.get(), TootActivity.class);
- Bundle b = new Bundle();
- if (remoteStatuses == null) {
- Toasty.error(contextReference.get(), contextReference.get().getString(R.string.toast_error), Toast.LENGTH_SHORT).show();
- return;
- }
- if (remoteStatuses.getReblog() != null) {
- b.putParcelable("tootReply", remoteStatuses.getReblog());
- } else {
- b.putParcelable("tootReply", remoteStatuses);
- }
- intent.putExtras(b);
- contextReference.get().startActivity(intent);
- }
}
}
diff --git a/app/src/main/java/app/fedilab/android/activities/PeertubeEditUploadActivity.java b/app/src/main/java/app/fedilab/android/activities/PeertubeEditUploadActivity.java
index 11cc30f75..f9b1a5ff5 100644
--- a/app/src/main/java/app/fedilab/android/activities/PeertubeEditUploadActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/PeertubeEditUploadActivity.java
@@ -18,7 +18,6 @@ package app.fedilab.android.activities;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.ColorDrawable;
-import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
@@ -60,7 +59,6 @@ import app.fedilab.android.interfaces.OnRetrievePeertubeInterface;
import es.dmoral.toasty.Toasty;
import mabbas007.tagsedittext.TagsEditText;
-import static android.os.AsyncTask.THREAD_POOL_EXECUTOR;
import static app.fedilab.android.asynctasks.RetrievePeertubeInformationAsyncTask.peertubeInformation;
public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrievePeertubeInterface, OnPostActionInterface {
@@ -152,7 +150,7 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
builderInner.setMessage(getString(R.string.delete_video_confirmation));
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
builderInner.setPositiveButton(R.string.yes, (dialog, which) -> {
- new PostActionAsyncTask(PeertubeEditUploadActivity.this, API.StatusAction.PEERTUBEDELETEVIDEO, videoId, PeertubeEditUploadActivity.this).executeOnExecutor(THREAD_POOL_EXECUTOR);
+ new PostActionAsyncTask(PeertubeEditUploadActivity.this, API.StatusAction.PEERTUBEDELETEVIDEO, videoId, PeertubeEditUploadActivity.this);
dialog.dismiss();
});
builderInner.show();
@@ -238,7 +236,7 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
String peertubeInstance = Helper.getLiveInstance(PeertubeEditUploadActivity.this);
- new RetrievePeertubeSingleAsyncTask(PeertubeEditUploadActivity.this, peertubeInstance, videoId, PeertubeEditUploadActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrievePeertubeSingleAsyncTask(PeertubeEditUploadActivity.this, peertubeInstance, videoId, PeertubeEditUploadActivity.this);
channels = new LinkedHashMap<>();
@@ -265,7 +263,7 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
peertube.setUpdate(false);
set_upload_submit.setEnabled(true);
} else {
- new RetrievePeertubeChannelsAsyncTask(PeertubeEditUploadActivity.this, PeertubeEditUploadActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrievePeertubeChannelsAsyncTask(PeertubeEditUploadActivity.this, PeertubeEditUploadActivity.this);
}
languageToSend = peertube.getLanguage();
@@ -529,7 +527,7 @@ public class PeertubeEditUploadActivity extends BaseActivity implements OnRetrie
List tags = p_video_tags.getTags();
peertube.setTags(tags);
set_upload_submit.setEnabled(false);
- new PostPeertubeAsyncTask(PeertubeEditUploadActivity.this, peertube, PeertubeEditUploadActivity.this).executeOnExecutor(THREAD_POOL_EXECUTOR);
+ new PostPeertubeAsyncTask(PeertubeEditUploadActivity.this, peertube, PeertubeEditUploadActivity.this);
});
set_upload_privacy.setSelection(privacyPosition);
diff --git a/app/src/main/java/app/fedilab/android/activities/PeertubeRegisterActivity.java b/app/src/main/java/app/fedilab/android/activities/PeertubeRegisterActivity.java
index 712d7a6e6..78990f05d 100644
--- a/app/src/main/java/app/fedilab/android/activities/PeertubeRegisterActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/PeertubeRegisterActivity.java
@@ -57,8 +57,6 @@ import app.fedilab.android.interfaces.OnPostStatusActionInterface;
import app.fedilab.android.interfaces.OnRetrieveInstanceInterface;
import es.dmoral.toasty.Toasty;
-import static android.os.AsyncTask.THREAD_POOL_EXECUTOR;
-
/**
* Created by Thomas on 04/11/2019.
* Register activity class
@@ -104,7 +102,7 @@ public class PeertubeRegisterActivity extends BaseActivity implements OnRetrieve
}
- new RetrieveInstanceRegAsyncTask(PeertubeRegisterActivity.this, RetrieveInstanceRegAsyncTask.instanceType.PEERTUBE, null, PeertubeRegisterActivity.this).executeOnExecutor(THREAD_POOL_EXECUTOR);
+ new RetrieveInstanceRegAsyncTask(PeertubeRegisterActivity.this, RetrieveInstanceRegAsyncTask.instanceType.PEERTUBE, null, PeertubeRegisterActivity.this);
signup = findViewById(R.id.signup);
EditText username = findViewById(R.id.username);
@@ -143,7 +141,7 @@ public class PeertubeRegisterActivity extends BaseActivity implements OnRetrieve
accountCreation.setPassword(password.getText().toString().trim());
accountCreation.setPasswordConfirm(password_confirm.getText().toString().trim());
accountCreation.setUsername(username.getText().toString().trim());
- new CreateMastodonAccountAsyncTask(PeertubeRegisterActivity.this, RetrieveInstanceRegAsyncTask.instanceType.PEERTUBE, accountCreation, instance, PeertubeRegisterActivity.this).executeOnExecutor(THREAD_POOL_EXECUTOR);
+ new CreateMastodonAccountAsyncTask(PeertubeRegisterActivity.this, RetrieveInstanceRegAsyncTask.instanceType.PEERTUBE, accountCreation, instance, PeertubeRegisterActivity.this);
});
diff --git a/app/src/main/java/app/fedilab/android/activities/PeertubeUploadActivity.java b/app/src/main/java/app/fedilab/android/activities/PeertubeUploadActivity.java
index c7af019bc..f855da7ea 100644
--- a/app/src/main/java/app/fedilab/android/activities/PeertubeUploadActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/PeertubeUploadActivity.java
@@ -26,7 +26,6 @@ import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
-import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.OpenableColumns;
import android.view.LayoutInflater;
@@ -132,7 +131,7 @@ public class PeertubeUploadActivity extends BaseActivity implements OnRetrievePe
set_upload_submit = findViewById(R.id.set_upload_submit);
video_title = findViewById(R.id.video_title);
- new RetrievePeertubeChannelsAsyncTask(PeertubeUploadActivity.this, PeertubeUploadActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrievePeertubeChannelsAsyncTask(PeertubeUploadActivity.this, PeertubeUploadActivity.this);
channels = new HashMap<>();
uploadReceiver = new UploadServiceSingleBroadcastReceiver(this);
diff --git a/app/src/main/java/app/fedilab/android/activities/PlaylistsActivity.java b/app/src/main/java/app/fedilab/android/activities/PlaylistsActivity.java
index 4ccf1bb94..d6a5f4f3b 100644
--- a/app/src/main/java/app/fedilab/android/activities/PlaylistsActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/PlaylistsActivity.java
@@ -17,7 +17,6 @@ package app.fedilab.android.activities;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.drawable.ColorDrawable;
-import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MenuItem;
@@ -161,7 +160,7 @@ public class PlaylistsActivity extends BaseActivity implements OnPlaylistActionI
if (firstVisibleItem + visibleItemCount == totalItemCount) {
if (!flag_loading) {
flag_loading = true;
- new ManagePlaylistsAsyncTask(PlaylistsActivity.this, GET_LIST_VIDEOS, playlist, null, max_id, PlaylistsActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new ManagePlaylistsAsyncTask(PlaylistsActivity.this, GET_LIST_VIDEOS, playlist, null, max_id, PlaylistsActivity.this);
nextElementLoader.setVisibility(View.VISIBLE);
}
} else {
@@ -178,10 +177,10 @@ public class PlaylistsActivity extends BaseActivity implements OnPlaylistActionI
flag_loading = true;
swiped = true;
MainActivity.countNewStatus = 0;
- new ManagePlaylistsAsyncTask(PlaylistsActivity.this, GET_LIST_VIDEOS, playlist, null, null, PlaylistsActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new ManagePlaylistsAsyncTask(PlaylistsActivity.this, GET_LIST_VIDEOS, playlist, null, null, PlaylistsActivity.this);
});
- new ManagePlaylistsAsyncTask(PlaylistsActivity.this, GET_LIST_VIDEOS, playlist, null, null, PlaylistsActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new ManagePlaylistsAsyncTask(PlaylistsActivity.this, GET_LIST_VIDEOS, playlist, null, null, PlaylistsActivity.this);
}
diff --git a/app/src/main/java/app/fedilab/android/activities/ReorderTimelinesActivity.java b/app/src/main/java/app/fedilab/android/activities/ReorderTimelinesActivity.java
index a642ee536..c9888e551 100644
--- a/app/src/main/java/app/fedilab/android/activities/ReorderTimelinesActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/ReorderTimelinesActivity.java
@@ -20,7 +20,6 @@ import android.content.SharedPreferences;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Paint;
import android.graphics.drawable.ColorDrawable;
-import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
@@ -238,14 +237,9 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
if (radioGroup.getCheckedRadioButtonId() != R.id.twitter_accounts) {
Pattern host = Pattern.compile("([\\da-z.-]+\\.[a-z.]{2,12})");
Matcher matcher = host.matcher(s.toString().trim());
- if (s.toString().trim().length() == 0 || !matcher.find()) {
- alertDialog.getButton(
- AlertDialog.BUTTON_POSITIVE).setEnabled(false);
- } else {
- // Something into edit text. Enable the button.
- alertDialog.getButton(
- AlertDialog.BUTTON_POSITIVE).setEnabled(true);
- }
+ // Something into edit text. Enable the button.
+ alertDialog.getButton(
+ AlertDialog.BUTTON_POSITIVE).setEnabled(s.toString().trim().length() != 0 && matcher.find());
if (s.length() > 2 && !isLoadingInstance) {
final String action = "/instances/search";
final HashMap parameters = new HashMap<>();
@@ -364,7 +358,7 @@ public class ReorderTimelinesActivity extends BaseActivity implements OnStartDra
break;
case LIST:
timeline = manageTimelines;
- new ManageListsAsyncTask(ReorderTimelinesActivity.this, ManageListsAsyncTask.action.DELETE_LIST, null, null, manageTimelines.getListTimeline().getId(), null, ReorderTimelinesActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new ManageListsAsyncTask(ReorderTimelinesActivity.this, ManageListsAsyncTask.action.DELETE_LIST, null, manageTimelines.getListTimeline().getId(), null, ReorderTimelinesActivity.this);
new TimelinesDAO(ReorderTimelinesActivity.this, db).remove(timeline);
refresh_list = true;
break;
diff --git a/app/src/main/java/app/fedilab/android/activities/SearchResultActivity.java b/app/src/main/java/app/fedilab/android/activities/SearchResultActivity.java
index 1a86dbcab..25366c765 100644
--- a/app/src/main/java/app/fedilab/android/activities/SearchResultActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/SearchResultActivity.java
@@ -16,7 +16,6 @@ package app.fedilab.android.activities;
import android.content.SharedPreferences;
import android.graphics.drawable.ColorDrawable;
-import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MenuItem;
@@ -88,7 +87,7 @@ public class SearchResultActivity extends BaseActivity implements OnRetrieveSear
if (b != null) {
search = b.getString("search");
if (search != null)
- new RetrieveSearchAsyncTask(SearchResultActivity.this, search.trim(), SearchResultActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveSearchAsyncTask(SearchResultActivity.this, search.trim(), SearchResultActivity.this);
else
Toasty.error(SearchResultActivity.this, getString(R.string.toast_error_search), Toast.LENGTH_LONG).show();
} else {
diff --git a/app/src/main/java/app/fedilab/android/activities/ShowAccountActivity.java b/app/src/main/java/app/fedilab/android/activities/ShowAccountActivity.java
index 1c4b764d7..e079def11 100644
--- a/app/src/main/java/app/fedilab/android/activities/ShowAccountActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/ShowAccountActivity.java
@@ -22,7 +22,6 @@ import android.content.res.ColorStateList;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
-import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.text.Spannable;
@@ -161,8 +160,6 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
private String accountId;
private boolean ischannel;
private ScheduledExecutorService scheduledExecutorService;
- private AsyncTask accountAsync;
- private AsyncTask retrieveRelationship;
private action doAction;
private API.StatusAction doActionAccount;
@@ -206,7 +203,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
ischannel = b.getBoolean("ischannel", false);
peertubeAccount = b.getBoolean("peertubeaccount", false);
if (account == null) {
- accountAsync = new RetrieveAccountAsyncTask(ShowAccountActivity.this, accountId, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveAccountAsyncTask(ShowAccountActivity.this, accountId, ShowAccountActivity.this);
}
userId = sharedpreferences.getString(Helper.PREF_KEY_ID, null);
@@ -297,7 +294,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE) {
accountIdRelation = account.getAcct();
}
- retrieveRelationship = new RetrieveRelationshipAsyncTask(ShowAccountActivity.this, accountIdRelation, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveRelationshipAsyncTask(ShowAccountActivity.this, accountIdRelation, ShowAccountActivity.this);
if (account.getId() != null && account.getId().equals(userId) && (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA || MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PIXELFED)) {
account_follow.setVisibility(View.GONE);
@@ -306,7 +303,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
}
//TODO: add other software that supports identity proofs
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.MASTODON) {
- new RetrieveIdentityProofAsyncTask(ShowAccountActivity.this, account.getId(), ShowAccountActivity.this).execute();
+ new RetrieveIdentityProofAsyncTask(ShowAccountActivity.this, account.getId(), ShowAccountActivity.this);
}
String urlHeader = account.getHeader();
if (urlHeader != null && urlHeader.startsWith("/")) {
@@ -623,11 +620,8 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
account_note.setText(account.getNoteSpan(), TextView.BufferType.SPANNABLE);
account_note.setMovementMethod(LinkMovementMethod.getInstance());
if (!peertubeAccount && tabLayout.getTabAt(0) != null && tabLayout.getTabAt(1) != null && tabLayout.getTabAt(2) != null) {
- //noinspection ConstantConditions
tabLayout.getTabAt(0).setText(getString(R.string.status_cnt, Helper.withSuffix(account.getStatuses_count())));
- //noinspection ConstantConditions
tabLayout.getTabAt(1).setText(getString(R.string.following_cnt, Helper.withSuffix(account.getFollowing_count())));
- //noinspection ConstantConditions
tabLayout.getTabAt(2).setText(getString(R.string.followers_cnt, Helper.withSuffix(account.getFollowers_count())));
//Allows to filter by long click
@@ -687,28 +681,24 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
return false;
}
});
- switch (item.getItemId()) {
- case R.id.action_show_pinned:
- showPinned = !showPinned;
- break;
- case R.id.action_show_media:
- showMediaOnly = !showMediaOnly;
- break;
- case R.id.action_show_boosts:
- show_boosts = !show_boosts;
- SharedPreferences.Editor editor = sharedpreferences.edit();
- editor.putBoolean(Helper.SHOW_ACCOUNT_BOOSTS, show_boosts);
- editor.apply();
- break;
- case R.id.action_show_replies:
- show_replies = !show_replies;
- editor = sharedpreferences.edit();
- editor.putBoolean(Helper.SHOW_ACCOUNT_REPLIES, show_replies);
- editor.apply();
- break;
+ int itemId = item.getItemId();
+ if (itemId == R.id.action_show_pinned) {
+ showPinned = !showPinned;
+ } else if (itemId == R.id.action_show_media) {
+ showMediaOnly = !showMediaOnly;
+ } else if (itemId == R.id.action_show_boosts) {
+ show_boosts = !show_boosts;
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putBoolean(Helper.SHOW_ACCOUNT_BOOSTS, show_boosts);
+ editor.apply();
+ } else if (itemId == R.id.action_show_replies) {
+ SharedPreferences.Editor editor;
+ show_replies = !show_replies;
+ editor = sharedpreferences.edit();
+ editor.putBoolean(Helper.SHOW_ACCOUNT_REPLIES, show_replies);
+ editor.apply();
}
if (tabLayout.getTabAt(0) != null)
- //noinspection ConstantConditions
tabLayout.getTabAt(0).select();
PagerAdapter mPagerAdapter1 = new ScreenSlidePagerAdapter(getSupportFragmentManager());
mPager.setAdapter(mPagerAdapter1);
@@ -760,7 +750,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
Toasty.info(ShowAccountActivity.this, getString(R.string.nothing_to_do), Toast.LENGTH_LONG).show();
} else if (doAction == action.FOLLOW) {
account_follow.setEnabled(false);
- new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.FOLLOW, finalTarget, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.FOLLOW, finalTarget, ShowAccountActivity.this);
} else if (doAction == action.UNFOLLOW) {
boolean confirm_unfollow = sharedpreferences.getBoolean(Helper.SET_UNFOLLOW_VALIDATION, true);
if (confirm_unfollow) {
@@ -770,18 +760,18 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
unfollowConfirm.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
unfollowConfirm.setPositiveButton(R.string.yes, (dialog, which) -> {
account_follow.setEnabled(false);
- new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.UNFOLLOW, finalTarget, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.UNFOLLOW, finalTarget, ShowAccountActivity.this);
dialog.dismiss();
});
unfollowConfirm.show();
} else {
account_follow.setEnabled(false);
- new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.UNFOLLOW, finalTarget, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.UNFOLLOW, finalTarget, ShowAccountActivity.this);
}
} else if (doAction == action.UNBLOCK) {
account_follow.setEnabled(false);
- new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.UNBLOCK, finalTarget, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.UNBLOCK, finalTarget, ShowAccountActivity.this);
}
});
account_follow.setOnLongClickListener(v -> {
@@ -875,7 +865,6 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
if (pins != null && pins.size() > 0) {
if (pins.get(0).isPinned()) {
this.statuses.addAll(pins);
- //noinspection ConstantConditions
tabLayout.getTabAt(3).setText(getString(R.string.pins_cnt, pins.size()));
statusListAdapter.notifyDataSetChanged();
}
@@ -1117,241 +1106,242 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
style = R.style.Dialog;
}
final SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
- switch (item.getItemId()) {
- case R.id.action_follow_instance:
- String finalInstanceName = splitAcct[1];
- List remoteInstances = new InstancesDAO(ShowAccountActivity.this, db).getInstanceByName(finalInstanceName);
- if (remoteInstances != null && remoteInstances.size() > 0) {
- Toasty.info(ShowAccountActivity.this, getString(R.string.toast_instance_already_added), Toast.LENGTH_LONG).show();
- Intent intent = new Intent(ShowAccountActivity.this, MainActivity.class);
- Bundle bundle = new Bundle();
- bundle.putInt(Helper.INTENT_ACTION, Helper.SEARCH_INSTANCE);
- bundle.putString(Helper.INSTANCE_NAME, finalInstanceName);
- intent.putExtras(bundle);
- startActivity(intent);
+ int itemId = item.getItemId();
+ if (itemId == R.id.action_follow_instance) {
+ String finalInstanceName = splitAcct[1];
+ List remoteInstances = new InstancesDAO(ShowAccountActivity.this, db).getInstanceByName(finalInstanceName);
+ if (remoteInstances != null && remoteInstances.size() > 0) {
+ Toasty.info(ShowAccountActivity.this, getString(R.string.toast_instance_already_added), Toast.LENGTH_LONG).show();
+ Intent intent = new Intent(ShowAccountActivity.this, MainActivity.class);
+ Bundle bundle = new Bundle();
+ bundle.putInt(Helper.INTENT_ACTION, Helper.SEARCH_INSTANCE);
+ bundle.putString(Helper.INSTANCE_NAME, finalInstanceName);
+ intent.putExtras(bundle);
+ startActivity(intent);
+ return true;
+ }
+ new Thread(() -> {
+ try {
+ if (!peertubeAccount) {
+ //Here we can't know if the instance is a Mastodon one or not
+ try { //Testing Mastodon
+ new HttpsConnection(ShowAccountActivity.this, null).get("https://" + finalInstanceName + "/api/v1/timelines/public?local=true", 10, null, null);
+ } catch (Exception ignored) {
+ new HttpsConnection(ShowAccountActivity.this, null).get("https://" + finalInstanceName + "/api/v1/videos/", 10, null, null);
+ peertubeAccount = true;
+ }
+ } else
+ new HttpsConnection(ShowAccountActivity.this, null).get("https://" + finalInstanceName + "/api/v1/videos/", 10, null, null);
+
+ runOnUiThread(() -> {
+ if (!peertubeAccount)
+ new InstancesDAO(ShowAccountActivity.this, db).insertInstance(finalInstanceName, "MASTODON");
+ else
+ new InstancesDAO(ShowAccountActivity.this, db).insertInstance(finalInstanceName, "PEERTUBE");
+ Toasty.success(ShowAccountActivity.this, getString(R.string.toast_instance_followed), Toast.LENGTH_LONG).show();
+ Intent intent = new Intent(ShowAccountActivity.this, MainActivity.class);
+ Bundle bundle = new Bundle();
+ bundle.putInt(Helper.INTENT_ACTION, Helper.SEARCH_INSTANCE);
+ bundle.putString(Helper.INSTANCE_NAME, finalInstanceName);
+ intent.putExtras(bundle);
+ startActivity(intent);
+ });
+ } catch (final Exception e) {
+ e.printStackTrace();
+ runOnUiThread(() -> Toasty.warning(ShowAccountActivity.this, getString(R.string.toast_instance_unavailable), Toast.LENGTH_LONG).show());
+ }
+ }).start();
+ return true;
+ } else if (itemId == R.id.action_filter) {
+ AlertDialog.Builder filterTagDialog = new AlertDialog.Builder(ShowAccountActivity.this, style);
+ Set featuredTagsSet = sharedpreferences.getStringSet(Helper.SET_FEATURED_TAGS, null);
+ List tags = new ArrayList<>();
+ if (featuredTagsSet != null) {
+ tags = new ArrayList<>(featuredTagsSet);
+ }
+ tags.add(0, getString(R.string.no_tags));
+ String[] tagsString = tags.toArray(new String[0]);
+ List finalTags = tags;
+ String tag = sharedpreferences.getString(Helper.SET_FEATURED_TAG_ACTION, null);
+ int checkedposition = 0;
+ int i = 0;
+ for (String _t : tags) {
+ if (_t.equals(tag))
+ checkedposition = i;
+ i++;
+ }
+ filterTagDialog.setSingleChoiceItems(tagsString, checkedposition, (dialog, item1) -> {
+ String tag1;
+ if (item1 == 0) {
+ tag1 = null;
+ } else {
+ tag1 = finalTags.get(item1);
+ }
+ SharedPreferences.Editor editor = sharedpreferences.edit();
+ editor.putString(Helper.SET_FEATURED_TAG_ACTION, tag1);
+ editor.apply();
+ dialog.dismiss();
+ });
+ filterTagDialog.show();
+ return true;
+ } else if (itemId == R.id.action_endorse) {
+ if (relationship != null)
+ if (relationship.isEndorsed()) {
+ new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.UNENDORSE, account.getId(), ShowAccountActivity.this);
+ } else {
+ new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.ENDORSE, account.getId(), ShowAccountActivity.this);
+ }
+ return true;
+ } else if (itemId == R.id.action_hide_boost) {
+ if (relationship != null)
+ if (relationship.isShowing_reblogs()) {
+ new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.HIDE_BOOST, account.getId(), ShowAccountActivity.this);
+ } else {
+ new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.SHOW_BOOST, account.getId(), ShowAccountActivity.this);
+ }
+ return true;
+ } else if (itemId == R.id.action_direct_message) {
+ Intent intent = new Intent(ShowAccountActivity.this, TootActivity.class);
+ Bundle b = new Bundle();
+ b.putString("mentionAccount", account.getAcct());
+ b.putString("visibility", "direct");
+ intent.putExtras(b);
+ startActivity(intent);
+ return true;
+ } else if (itemId == R.id.action_add_to_list) {
+ if (timelines != null) {
+ ArrayAdapter arrayAdapter = new ArrayAdapter<>(ShowAccountActivity.this, android.R.layout.select_dialog_item);
+ boolean hasLists = false;
+ for (ManageTimelines timeline : timelines) {
+ if (timeline.getListTimeline() != null) {
+ arrayAdapter.add(timeline.getListTimeline().getTitle());
+ hasLists = true;
+ }
+ }
+ if (!hasLists) {
+ Toasty.info(ShowAccountActivity.this, getString(R.string.action_lists_empty), Toast.LENGTH_SHORT).show();
return true;
}
- new Thread(() -> {
- try {
- if (!peertubeAccount) {
- //Here we can't know if the instance is a Mastodon one or not
- try { //Testing Mastodon
- new HttpsConnection(ShowAccountActivity.this, null).get("https://" + finalInstanceName + "/api/v1/timelines/public?local=true", 10, null, null);
- } catch (Exception ignored) {
- new HttpsConnection(ShowAccountActivity.this, null).get("https://" + finalInstanceName + "/api/v1/videos/", 10, null, null);
- peertubeAccount = true;
- }
- } else
- new HttpsConnection(ShowAccountActivity.this, null).get("https://" + finalInstanceName + "/api/v1/videos/", 10, null, null);
+ AlertDialog.Builder builderSingle = new AlertDialog.Builder(ShowAccountActivity.this, style);
+ builderSingle.setTitle(getString(R.string.action_lists_add_to));
+ builderSingle.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
- runOnUiThread(() -> {
- if (!peertubeAccount)
- new InstancesDAO(ShowAccountActivity.this, db).insertInstance(finalInstanceName, "MASTODON");
- else
- new InstancesDAO(ShowAccountActivity.this, db).insertInstance(finalInstanceName, "PEERTUBE");
- Toasty.success(ShowAccountActivity.this, getString(R.string.toast_instance_followed), Toast.LENGTH_LONG).show();
- Intent intent = new Intent(ShowAccountActivity.this, MainActivity.class);
- Bundle bundle = new Bundle();
- bundle.putInt(Helper.INTENT_ACTION, Helper.SEARCH_INSTANCE);
- bundle.putString(Helper.INSTANCE_NAME, finalInstanceName);
- intent.putExtras(bundle);
- startActivity(intent);
- });
- } catch (final Exception e) {
- e.printStackTrace();
- runOnUiThread(() -> Toasty.warning(ShowAccountActivity.this, getString(R.string.toast_instance_unavailable), Toast.LENGTH_LONG).show());
- }
- }).start();
- return true;
- case R.id.action_filter:
- AlertDialog.Builder filterTagDialog = new AlertDialog.Builder(ShowAccountActivity.this, style);
- Set featuredTagsSet = sharedpreferences.getStringSet(Helper.SET_FEATURED_TAGS, null);
- List tags = new ArrayList<>();
- if (featuredTagsSet != null) {
- tags = new ArrayList<>(featuredTagsSet);
- }
- tags.add(0, getString(R.string.no_tags));
- String[] tagsString = tags.toArray(new String[0]);
- List finalTags = tags;
- String tag = sharedpreferences.getString(Helper.SET_FEATURED_TAG_ACTION, null);
- int checkedposition = 0;
- int i = 0;
- for (String _t : tags) {
- if (_t.equals(tag))
- checkedposition = i;
- i++;
- }
- filterTagDialog.setSingleChoiceItems(tagsString, checkedposition, (dialog, item1) -> {
- String tag1;
- if (item1 == 0) {
- tag1 = null;
- } else {
- tag1 = finalTags.get(item1);
- }
- SharedPreferences.Editor editor = sharedpreferences.edit();
- editor.putString(Helper.SET_FEATURED_TAG_ACTION, tag1);
- editor.apply();
- dialog.dismiss();
- });
- filterTagDialog.show();
- return true;
- case R.id.action_endorse:
- if (relationship != null)
- if (relationship.isEndorsed()) {
- new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.UNENDORSE, account.getId(), ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- } else {
- new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.ENDORSE, account.getId(), ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- }
- return true;
- case R.id.action_hide_boost:
- if (relationship != null)
- if (relationship.isShowing_reblogs()) {
- new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.HIDE_BOOST, account.getId(), ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- } else {
- new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.SHOW_BOOST, account.getId(), ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- }
- return true;
- case R.id.action_direct_message:
- Intent intent = new Intent(ShowAccountActivity.this, TootActivity.class);
- Bundle b = new Bundle();
- b.putString("mentionAccount", account.getAcct());
- b.putString("visibility", "direct");
- intent.putExtras(b);
- startActivity(intent);
- return true;
- case R.id.action_add_to_list:
- if (timelines != null) {
- ArrayAdapter arrayAdapter = new ArrayAdapter<>(ShowAccountActivity.this, android.R.layout.select_dialog_item);
- boolean hasLists = false;
+ builderSingle.setAdapter(arrayAdapter, (dialog, which) -> {
+ String listTitle = arrayAdapter.getItem(which);
for (ManageTimelines timeline : timelines) {
- if (timeline.getListTimeline() != null) {
- arrayAdapter.add(timeline.getListTimeline().getTitle());
- hasLists = true;
- }
- }
- if (!hasLists) {
- Toasty.info(ShowAccountActivity.this, getString(R.string.action_lists_empty), Toast.LENGTH_SHORT).show();
- return true;
- }
- AlertDialog.Builder builderSingle = new AlertDialog.Builder(ShowAccountActivity.this, style);
- builderSingle.setTitle(getString(R.string.action_lists_add_to));
- builderSingle.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
-
- builderSingle.setAdapter(arrayAdapter, (dialog, which) -> {
- String listTitle = arrayAdapter.getItem(which);
- for (ManageTimelines timeline : timelines) {
- if (timeline.getListTimeline() != null && timeline.getListTimeline().getTitle().equals(listTitle)) {
- app.fedilab.android.client.Entities.List list = timeline.getListTimeline();
- if (relationship == null || !relationship.isFollowing()) {
- addToList = list.getId();
- new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.FOLLOW, account.getId(), ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- } else {
- new ManageListsAsyncTask(ShowAccountActivity.this, ManageListsAsyncTask.action.ADD_USERS, new String[]{account.getId()}, null, list.getId(), null, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- }
- break;
+ if (timeline.getListTimeline() != null && timeline.getListTimeline().getTitle().equals(listTitle)) {
+ app.fedilab.android.client.Entities.List list = timeline.getListTimeline();
+ if (relationship == null || !relationship.isFollowing()) {
+ addToList = list.getId();
+ new PostActionAsyncTask(ShowAccountActivity.this, API.StatusAction.FOLLOW, account.getId(), ShowAccountActivity.this);
+ } else {
+ new ManageListsAsyncTask(ShowAccountActivity.this, ManageListsAsyncTask.action.ADD_USERS, new String[]{account.getId()}, list.getId(), null, ShowAccountActivity.this);
}
+ break;
}
- });
- builderSingle.show();
- }
- return true;
- case R.id.action_open_browser:
- if (accountUrl != null) {
- if (!accountUrl.toLowerCase().startsWith("http://") && !accountUrl.toLowerCase().startsWith("https://"))
- accountUrl = "http://" + accountUrl;
- Helper.openBrowser(ShowAccountActivity.this, accountUrl);
- }
- return true;
- case R.id.action_mention:
- intent = new Intent(ShowAccountActivity.this, TootActivity.class);
- b = new Bundle();
- b.putString("mentionAccount", account.getAcct());
- intent.putExtras(b);
- startActivity(intent);
- return true;
- case R.id.action_mute:
- if (relationship.isMuting()) {
- builderInner = new AlertDialog.Builder(ShowAccountActivity.this, style);
- builderInner.setTitle(stringArrayConf[4]);
- doActionAccount = API.StatusAction.UNMUTE;
- } else {
- builderInner = new AlertDialog.Builder(ShowAccountActivity.this, style);
- builderInner.setTitle(stringArrayConf[0]);
- doActionAccount = API.StatusAction.MUTE;
- }
- break;
- case R.id.action_report:
- builderInner = new AlertDialog.Builder(ShowAccountActivity.this, style);
- builderInner.setTitle(R.string.report_account);
- //Text for report
- EditText input = new EditText(ShowAccountActivity.this);
- LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.MATCH_PARENT,
- LinearLayout.LayoutParams.WRAP_CONTENT);
- input.setLayoutParams(lp);
- builderInner.setView(input);
- doActionAccount = API.StatusAction.REPORT;
- builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
- builderInner.setPositiveButton(R.string.yes, (dialog, which) -> {
- String comment = null;
- if (input.getText() != null)
- comment = input.getText().toString();
- new PostActionAsyncTask(ShowAccountActivity.this, doActionAccount, account.getId(), null, comment, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- dialog.dismiss();
- });
- builderInner.show();
- return true;
- case R.id.action_add_notes:
- UserNote userNote = new NotesDAO(ShowAccountActivity.this, db).getUserNote(account.getAcct());
- builderInner = new AlertDialog.Builder(ShowAccountActivity.this, style);
- builderInner.setTitle(R.string.note_for_account);
- input = new EditText(ShowAccountActivity.this);
- lp = new LinearLayout.LayoutParams(
- LinearLayout.LayoutParams.MATCH_PARENT,
- LinearLayout.LayoutParams.WRAP_CONTENT);
- input.setLayoutParams(lp);
- input.setSingleLine(false);
- if (userNote != null) {
- input.setText(userNote.getNote());
- }
- input.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION);
- builderInner.setView(input);
- builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
- builderInner.setPositiveButton(R.string.validate, (dialog, which) -> {
- UserNote userNote1 = new NotesDAO(ShowAccountActivity.this, db).getUserNote(account.getAcct());
- if (userNote1 == null) {
- userNote1 = new UserNote();
- userNote1.setAcct(account.getAcct());
}
- userNote1.setNote(input.getText().toString());
- new NotesDAO(ShowAccountActivity.this, db).insertInstance(userNote1);
- if (input.getText().toString().trim().length() > 0) {
- account_personal_note.setVisibility(View.VISIBLE);
- } else {
- account_personal_note.setVisibility(View.GONE);
- }
- dialog.dismiss();
});
- builderInner.show();
- return true;
- case R.id.action_block:
+ builderSingle.show();
+ }
+ return true;
+ } else if (itemId == R.id.action_open_browser) {
+ if (accountUrl != null) {
+ if (!accountUrl.toLowerCase().startsWith("http://") && !accountUrl.toLowerCase().startsWith("https://"))
+ accountUrl = "http://" + accountUrl;
+ Helper.openBrowser(ShowAccountActivity.this, accountUrl);
+ }
+ return true;
+ } else if (itemId == R.id.action_mention) {
+ Intent intent;
+ Bundle b;
+ intent = new Intent(ShowAccountActivity.this, TootActivity.class);
+ b = new Bundle();
+ b.putString("mentionAccount", account.getAcct());
+ intent.putExtras(b);
+ startActivity(intent);
+ return true;
+ } else if (itemId == R.id.action_mute) {
+ if (relationship.isMuting()) {
builderInner = new AlertDialog.Builder(ShowAccountActivity.this, style);
- if (relationship.isBlocking()) {
- builderInner.setTitle(stringArrayConf[5]);
- doActionAccount = API.StatusAction.UNBLOCK;
- } else {
- builderInner.setTitle(stringArrayConf[1]);
- doActionAccount = API.StatusAction.BLOCK;
+ builderInner.setTitle(stringArrayConf[4]);
+ doActionAccount = API.StatusAction.UNMUTE;
+ } else {
+ builderInner = new AlertDialog.Builder(ShowAccountActivity.this, style);
+ builderInner.setTitle(stringArrayConf[0]);
+ doActionAccount = API.StatusAction.MUTE;
+ }
+ } else if (itemId == R.id.action_report) {
+ builderInner = new AlertDialog.Builder(ShowAccountActivity.this, style);
+ builderInner.setTitle(R.string.report_account);
+ //Text for report
+ EditText input = new EditText(ShowAccountActivity.this);
+ LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
+ LinearLayout.LayoutParams.MATCH_PARENT,
+ LinearLayout.LayoutParams.WRAP_CONTENT);
+ input.setLayoutParams(lp);
+ builderInner.setView(input);
+ doActionAccount = API.StatusAction.REPORT;
+ builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
+ builderInner.setPositiveButton(R.string.yes, (dialog, which) -> {
+ String comment = null;
+ if (input.getText() != null)
+ comment = input.getText().toString();
+ new PostActionAsyncTask(ShowAccountActivity.this, doActionAccount, account.getId(), null, comment, ShowAccountActivity.this);
+ dialog.dismiss();
+ });
+ builderInner.show();
+ return true;
+ } else if (itemId == R.id.action_add_notes) {
+ EditText input;
+ LinearLayout.LayoutParams lp;
+ UserNote userNote = new NotesDAO(ShowAccountActivity.this, db).getUserNote(account.getAcct());
+ builderInner = new AlertDialog.Builder(ShowAccountActivity.this, style);
+ builderInner.setTitle(R.string.note_for_account);
+ input = new EditText(ShowAccountActivity.this);
+ lp = new LinearLayout.LayoutParams(
+ LinearLayout.LayoutParams.MATCH_PARENT,
+ LinearLayout.LayoutParams.WRAP_CONTENT);
+ input.setLayoutParams(lp);
+ input.setSingleLine(false);
+ if (userNote != null) {
+ input.setText(userNote.getNote());
+ }
+ input.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION);
+ builderInner.setView(input);
+ builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
+ builderInner.setPositiveButton(R.string.validate, (dialog, which) -> {
+ UserNote userNote1 = new NotesDAO(ShowAccountActivity.this, db).getUserNote(account.getAcct());
+ if (userNote1 == null) {
+ userNote1 = new UserNote();
+ userNote1.setAcct(account.getAcct());
}
- break;
- case R.id.action_block_instance:
- builderInner = new AlertDialog.Builder(ShowAccountActivity.this, style);
- doActionAccount = API.StatusAction.BLOCK_DOMAIN;
- String domain = account.getAcct().split("@")[1];
- builderInner.setMessage(getString(R.string.block_domain_confirm_message, domain));
- break;
- default:
- return true;
+ userNote1.setNote(input.getText().toString());
+ new NotesDAO(ShowAccountActivity.this, db).insertInstance(userNote1);
+ if (input.getText().toString().trim().length() > 0) {
+ account_personal_note.setVisibility(View.VISIBLE);
+ } else {
+ account_personal_note.setVisibility(View.GONE);
+ }
+ dialog.dismiss();
+ });
+ builderInner.show();
+ return true;
+ } else if (itemId == R.id.action_block) {
+ builderInner = new AlertDialog.Builder(ShowAccountActivity.this, style);
+ if (relationship.isBlocking()) {
+ builderInner.setTitle(stringArrayConf[5]);
+ doActionAccount = API.StatusAction.UNBLOCK;
+ } else {
+ builderInner.setTitle(stringArrayConf[1]);
+ doActionAccount = API.StatusAction.BLOCK;
+ }
+ } else if (itemId == R.id.action_block_instance) {
+ builderInner = new AlertDialog.Builder(ShowAccountActivity.this, style);
+ doActionAccount = API.StatusAction.BLOCK_DOMAIN;
+ String domain = account.getAcct().split("@")[1];
+ builderInner.setMessage(getString(R.string.block_domain_confirm_message, domain));
+ } else {
+ return true;
}
builderInner.setNegativeButton(R.string.cancel, (dialog, which) -> dialog.dismiss());
builderInner.setPositiveButton(R.string.yes, (dialog, which) -> {
@@ -1361,7 +1351,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
} else {
targetedId = account.getId();
}
- new PostActionAsyncTask(ShowAccountActivity.this, doActionAccount, targetedId, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostActionAsyncTask(ShowAccountActivity.this, doActionAccount, targetedId, ShowAccountActivity.this);
dialog.dismiss();
});
builderInner.show();
@@ -1381,12 +1371,6 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
if (scheduledExecutorService != null) {
scheduledExecutorService.shutdownNow();
}
- if (accountAsync != null && !accountAsync.isCancelled()) {
- accountAsync.cancel(true);
- }
- if (retrieveRelationship != null && !retrieveRelationship.isCancelled()) {
- retrieveRelationship.cancel(true);
- }
}
@Override
@@ -1401,7 +1385,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
return;
}
if (addToList != null) {
- new ManageListsAsyncTask(ShowAccountActivity.this, ManageListsAsyncTask.action.ADD_USERS, new String[]{account.getId()}, null, addToList, null, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new ManageListsAsyncTask(ShowAccountActivity.this, ManageListsAsyncTask.action.ADD_USERS, new String[]{account.getId()}, addToList, null, ShowAccountActivity.this);
} else {
Helper.manageMessageStatusCode(ShowAccountActivity.this, statusCode, statusAction);
}
@@ -1415,7 +1399,7 @@ public class ShowAccountActivity extends BaseActivity implements OnPostActionInt
}
if (MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PEERTUBE)
target = account.getAcct();
- retrieveRelationship = new RetrieveRelationshipAsyncTask(ShowAccountActivity.this, target, ShowAccountActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveRelationshipAsyncTask(ShowAccountActivity.this, target, ShowAccountActivity.this);
}
@Override
diff --git a/app/src/main/java/app/fedilab/android/activities/ShowConversationActivity.java b/app/src/main/java/app/fedilab/android/activities/ShowConversationActivity.java
index 45fe57945..6f571c08d 100644
--- a/app/src/main/java/app/fedilab/android/activities/ShowConversationActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/ShowConversationActivity.java
@@ -21,7 +21,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.View;
import android.widget.ImageView;
@@ -169,11 +168,7 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
if (statuses != null && statuses.size() > 0) {
spoilerShown = !spoilerShown;
for (Status status : statuses) {
- if (spoilerBehaviour && !status.isSpoilerShown()) {
- status.setAutoHiddenCW(true);
- } else {
- status.setAutoHiddenCW(false);
- }
+ status.setAutoHiddenCW(spoilerBehaviour && !status.isSpoilerShown());
status.setSpoilerShown(spoilerShown);
status.setShowSpoiler(spoilerShown);
}
@@ -243,7 +238,7 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
if (conversationId != null)
statusIdToFetch = conversationId;
- new RetrieveContextAsyncTask(ShowConversationActivity.this, expanded, detailsStatus.getVisibility().equals("direct"), statusIdToFetch, ShowConversationActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new RetrieveContextAsyncTask(ShowConversationActivity.this, expanded, detailsStatus.getVisibility().equals("direct"), statusIdToFetch, ShowConversationActivity.this);
swipeRefreshLayout.setDistanceToTriggerSync(500);
swipeRefreshLayout.setOnRefreshListener(() -> {
Intent intent = new Intent(ShowConversationActivity.this, ShowConversationActivity.class);
@@ -344,7 +339,7 @@ public class ShowConversationActivity extends BaseActivity implements OnRetrieve
statuses = new ArrayList<>();
statuses.clear();
for (Status status : apiResponse.getContext().getAncestors()) {
- if (detailsStatus.equals(status)) {
+ if (detailsStatus != null && detailsStatus.equals(status)) {
break;
}
i++;
diff --git a/app/src/main/java/app/fedilab/android/activities/SlideMediaActivity.java b/app/src/main/java/app/fedilab/android/activities/SlideMediaActivity.java
index 86381e200..99e4fc5c3 100644
--- a/app/src/main/java/app/fedilab/android/activities/SlideMediaActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/SlideMediaActivity.java
@@ -76,15 +76,7 @@ public class SlideMediaActivity extends BaseFragmentActivity implements OnDownlo
private int mediaPosition;
private ViewPager mPager;
private long downloadID;
- private boolean fullscreen;
- private TextView media_description;
- private Handler handler;
- private int minTouch, maxTouch;
- private float startX;
- private float startY;
- private int bgColor;
-
- private BroadcastReceiver onDownloadComplete = new BroadcastReceiver() {
+ private final BroadcastReceiver onDownloadComplete = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
long id = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID, -1);
@@ -109,6 +101,13 @@ public class SlideMediaActivity extends BaseFragmentActivity implements OnDownlo
}
}
};
+ private boolean fullscreen;
+ private TextView media_description;
+ private Handler handler;
+ private int minTouch, maxTouch;
+ private float startX;
+ private float startY;
+ private int bgColor;
private MediaSliderFragment mCurrentFragment;
@Override
@@ -279,26 +278,23 @@ public class SlideMediaActivity extends BaseFragmentActivity implements OnDownlo
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
- switch (requestCode) {
- case Helper.EXTERNAL_STORAGE_REQUEST_CODE_MEDIA_SAVE:
- if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- int position = mPager.getCurrentItem();
- Attachment attachment = attachments.get(position);
- if (attachment.getType().compareTo("image") == 0) {
- Helper.manageMove(SlideMediaActivity.this, attachment.getUrl(), false);
- } else {
- Helper.manageDownloadsNoPopup(SlideMediaActivity.this, attachment.getUrl());
- downloadID = -1;
- }
- } else { /*Todo: Toast "Storage Permission Required" */ }
- return;
- case Helper.EXTERNAL_STORAGE_REQUEST_CODE_MEDIA_SHARE:
- if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
- int position = mPager.getCurrentItem();
- Attachment attachment = attachments.get(position);
- downloadID = Helper.manageDownloadsNoPopup(SlideMediaActivity.this, attachment.getUrl());
- } else { /*Todo: Toast "Storage Permission Required" */ }
- break;
+ if (requestCode == Helper.EXTERNAL_STORAGE_REQUEST_CODE_MEDIA_SAVE) {
+ if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+ int position = mPager.getCurrentItem();
+ Attachment attachment = attachments.get(position);
+ if (attachment.getType().compareTo("image") == 0) {
+ Helper.manageMove(SlideMediaActivity.this, attachment.getUrl(), false);
+ } else {
+ Helper.manageDownloadsNoPopup(SlideMediaActivity.this, attachment.getUrl());
+ downloadID = -1;
+ }
+ } else { /*Todo: Toast "Storage Permission Required" */ }
+ } else if (requestCode == Helper.EXTERNAL_STORAGE_REQUEST_CODE_MEDIA_SHARE) {
+ if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+ int position = mPager.getCurrentItem();
+ Attachment attachment = attachments.get(position);
+ downloadID = Helper.manageDownloadsNoPopup(SlideMediaActivity.this, attachment.getUrl());
+ } else { /*Todo: Toast "Storage Permission Required" */ }
}
}
diff --git a/app/src/main/java/app/fedilab/android/activities/WebviewActivity.java b/app/src/main/java/app/fedilab/android/activities/WebviewActivity.java
index a0eda86da..651f272db 100644
--- a/app/src/main/java/app/fedilab/android/activities/WebviewActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/WebviewActivity.java
@@ -29,6 +29,7 @@ import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
+import android.os.Looper;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@@ -213,54 +214,53 @@ public class WebviewActivity extends BaseActivity {
@Override
public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case android.R.id.home:
- finish();
- return true;
- case R.id.action_block:
- SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
- final int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
+ int itemId = item.getItemId();
+ if (itemId == android.R.id.home) {
+ finish();
+ return true;
+ } else if (itemId == R.id.action_block) {
+ SharedPreferences sharedpreferences = getSharedPreferences(Helper.APP_PREFS, MODE_PRIVATE);
+ final int theme = sharedpreferences.getInt(Helper.SET_THEME, Helper.THEME_DARK);
- List domains = mastalabWebViewClient.getDomains();
+ List domains = mastalabWebViewClient.getDomains();
- final ArrayAdapter arrayAdapter = new ArrayAdapter<>(WebviewActivity.this, R.layout.domains_blocked);
- arrayAdapter.addAll(domains);
- int style;
- if (theme == Helper.THEME_DARK) {
- style = R.style.DialogDark;
- } else if (theme == Helper.THEME_BLACK) {
- style = R.style.DialogBlack;
- } else {
- style = R.style.Dialog;
- }
- AlertDialog.Builder builder = new AlertDialog.Builder(WebviewActivity.this, style);
- builder.setTitle(R.string.list_of_blocked_domains);
+ final ArrayAdapter arrayAdapter = new ArrayAdapter<>(WebviewActivity.this, R.layout.domains_blocked);
+ arrayAdapter.addAll(domains);
+ int style;
+ if (theme == Helper.THEME_DARK) {
+ style = R.style.DialogDark;
+ } else if (theme == Helper.THEME_BLACK) {
+ style = R.style.DialogBlack;
+ } else {
+ style = R.style.Dialog;
+ }
+ AlertDialog.Builder builder = new AlertDialog.Builder(WebviewActivity.this, style);
+ builder.setTitle(R.string.list_of_blocked_domains);
- builder.setNegativeButton(R.string.close, (dialog, which) -> dialog.dismiss());
+ builder.setNegativeButton(R.string.close, (dialog, which) -> dialog.dismiss());
- builder.setAdapter(arrayAdapter, (dialog, which) -> {
- String strName = arrayAdapter.getItem(which);
- assert strName != null;
- Toasty.info(WebviewActivity.this, strName, Toast.LENGTH_LONG).show();
- });
- builder.show();
+ builder.setAdapter(arrayAdapter, (dialog, which) -> {
+ String strName = arrayAdapter.getItem(which);
+ assert strName != null;
+ Toasty.info(WebviewActivity.this, strName, Toast.LENGTH_LONG).show();
+ });
+ builder.show();
- return true;
- case R.id.action_go:
- Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
- try {
- startActivity(browserIntent);
- } catch (Exception e) {
- Toasty.error(WebviewActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
- }
- return true;
- case R.id.action_comment:
- Toasty.info(WebviewActivity.this, getString(R.string.retrieve_remote_status), Toast.LENGTH_LONG).show();
- new connnectAsync(new WeakReference<>(WebviewActivity.this), url, peertubeLinkToFetch).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
- return true;
- default:
- return super.onOptionsItemSelected(item);
+ return true;
+ } else if (itemId == R.id.action_go) {
+ Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
+ try {
+ startActivity(browserIntent);
+ } catch (Exception e) {
+ Toasty.error(WebviewActivity.this, getString(R.string.toast_error), Toast.LENGTH_LONG).show();
+ }
+ return true;
+ } else if (itemId == R.id.action_comment) {
+ Toasty.info(WebviewActivity.this, getString(R.string.retrieve_remote_status), Toast.LENGTH_LONG).show();
+ new connnectAsync(new WeakReference<>(WebviewActivity.this), url, peertubeLinkToFetch);
+ return true;
}
+ return super.onOptionsItemSelected(item);
}
public void setUrl(String newUrl) {
@@ -297,44 +297,46 @@ public class WebviewActivity extends BaseActivity {
webView.destroy();
}
- static class connnectAsync extends AsyncTask> {
- private WeakReference contextReference;
- private String url;
- private String peertubeLinkToFetch;
+ static class connnectAsync {
+ private final WeakReference contextReference;
+ private final String url;
+ private final String peertubeLinkToFetch;
connnectAsync(WeakReference contextReference, String url, String peertubeLinkToFetch) {
this.contextReference = contextReference;
this.url = url;
this.peertubeLinkToFetch = peertubeLinkToFetch;
+ doInBackground();
}
- @Override
- protected List doInBackground(Void... voids) {
- List remoteStatuses = null;
- if (url != null) {
- APIResponse search = new API(contextReference.get()).search(peertubeLinkToFetch);
- if (search != null && search.getResults() != null) {
- remoteStatuses = search.getResults().getStatuses();
+ protected void doInBackground() {
+ new Thread(() -> {
+ List remoteStatuses = null;
+ if (url != null) {
+ APIResponse search = new API(contextReference.get()).search(peertubeLinkToFetch);
+ if (search != null && search.getResults() != null) {
+ remoteStatuses = search.getResults().getStatuses();
+ }
}
- }
- return remoteStatuses;
- }
-
- @Override
- protected void onPostExecute(List remoteStatuses) {
- Intent intent = new Intent(contextReference.get(), TootActivity.class);
- Bundle b = new Bundle();
- if (remoteStatuses == null || remoteStatuses.size() == 0) {
- Toasty.error(contextReference.get(), contextReference.get().getString(R.string.toast_error), Toast.LENGTH_LONG).show();
- return;
- }
- if (remoteStatuses.get(0).getReblog() != null) {
- b.putParcelable("tootReply", remoteStatuses.get(0).getReblog());
- } else {
- b.putParcelable("tootReply", remoteStatuses.get(0));
- }
- intent.putExtras(b); //Put your id to your next Intent
- contextReference.get().startActivity(intent);
+ Handler mainHandler = new Handler(Looper.getMainLooper());
+ List finalRemoteStatuses = remoteStatuses;
+ Runnable myRunnable = () -> {
+ Intent intent = new Intent(contextReference.get(), TootActivity.class);
+ Bundle b = new Bundle();
+ if (finalRemoteStatuses == null || finalRemoteStatuses.size() == 0) {
+ Toasty.error(contextReference.get(), contextReference.get().getString(R.string.toast_error), Toast.LENGTH_LONG).show();
+ return;
+ }
+ if (finalRemoteStatuses.get(0).getReblog() != null) {
+ b.putParcelable("tootReply", finalRemoteStatuses.get(0).getReblog());
+ } else {
+ b.putParcelable("tootReply", finalRemoteStatuses.get(0));
+ }
+ intent.putExtras(b); //Put your id to your next Intent
+ contextReference.get().startActivity(intent);
+ };
+ mainHandler.post(myRunnable);
+ }).start();
}
}
}
diff --git a/app/src/main/java/app/fedilab/android/activities/WebviewConnectActivity.java b/app/src/main/java/app/fedilab/android/activities/WebviewConnectActivity.java
index 230ff009c..2217ecabf 100644
--- a/app/src/main/java/app/fedilab/android/activities/WebviewConnectActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/WebviewConnectActivity.java
@@ -21,7 +21,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.drawable.ColorDrawable;
-import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
@@ -67,6 +66,7 @@ public class WebviewConnectActivity extends BaseActivity {
private String instance;
private UpdateAccountInfoAsyncTask.SOCIAL social;
+ @SuppressWarnings("deprecation")
public static void clearCookies(Context context) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
@@ -178,16 +178,16 @@ public class WebviewConnectActivity extends BaseActivity {
JSONObject resobj;
try {
resobj = new JSONObject(response);
- String token = resobj.get("access_token").toString();
+ String token = resobj.getString("access_token");
String refresh_token = null;
if (resobj.has("refresh_token"))
- refresh_token = resobj.get("refresh_token").toString();
+ refresh_token = resobj.getString("refresh_token");
SharedPreferences sharedpreferences1 = getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedpreferences1.edit();
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, token);
- editor.apply();
+ editor.commit();
//Update the account with the token;
- new UpdateAccountInfoAsyncTask(WebviewConnectActivity.this, token, clientId, clientSecret, refresh_token, instance, social).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new UpdateAccountInfoAsyncTask(WebviewConnectActivity.this, token, clientId, clientSecret, refresh_token, instance, social);
} catch (JSONException ignored) {
}
} catch (Exception ignored) {
diff --git a/app/src/main/java/app/fedilab/android/activities/WhoToFollowActivity.java b/app/src/main/java/app/fedilab/android/activities/WhoToFollowActivity.java
index 07da16947..7770560d2 100644
--- a/app/src/main/java/app/fedilab/android/activities/WhoToFollowActivity.java
+++ b/app/src/main/java/app/fedilab/android/activities/WhoToFollowActivity.java
@@ -16,7 +16,6 @@ package app.fedilab.android.activities;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.view.MenuItem;
@@ -106,7 +105,7 @@ public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoTo
cal.add(Calendar.MINUTE, -5);
Date dateAllowed = cal.getTime();
if (lastDateListNameRefresh == null || Helper.stringToDate(WhoToFollowActivity.this, lastDateListNameRefresh).before(dateAllowed)) {
- new WhoToFollowAsyncTask(WhoToFollowActivity.this, item, WhoToFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new WhoToFollowAsyncTask(WhoToFollowActivity.this, item, WhoToFollowActivity.this);
mainLoader.setVisibility(View.VISIBLE);
} else {
String lastList = sharedpreferences.getString(Helper.LAST_LIST_NAME + item, null);
@@ -172,7 +171,7 @@ public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoTo
if (val.length > 1) {
account.setAcct(val[0]);
account.setInstance(val[1]);
- new PostActionAsyncTask(WhoToFollowActivity.this, null, account, API.StatusAction.FOLLOW, WhoToFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostActionAsyncTask(WhoToFollowActivity.this, null, account, API.StatusAction.FOLLOW, WhoToFollowActivity.this);
} else {
Toasty.error(WhoToFollowActivity.this, getString(R.string.toast_impossible_to_follow), Toast.LENGTH_LONG).show();
follow_accounts.setEnabled(true);
@@ -219,7 +218,7 @@ public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoTo
followedId.add(userId);
if (followedId != null && followedId.size() >= toFollowdId.size()) {
progess_action.setText(getString(R.string.create_list_trunk, item));
- new ManageListsAsyncTask(WhoToFollowActivity.this, ManageListsAsyncTask.action.CREATE_LIST, null, null, null, item, WhoToFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new ManageListsAsyncTask(WhoToFollowActivity.this, ManageListsAsyncTask.action.CREATE_LIST, null, null, item, WhoToFollowActivity.this);
} else {
Account account = new Account();
assert followedId != null;
@@ -228,7 +227,7 @@ public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoTo
if (val.length > 1) {
account.setAcct(val[0]);
account.setInstance(val[1]);
- new PostActionAsyncTask(WhoToFollowActivity.this, null, account, API.StatusAction.FOLLOW, WhoToFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new PostActionAsyncTask(WhoToFollowActivity.this, null, account, API.StatusAction.FOLLOW, WhoToFollowActivity.this);
}
}
@@ -242,7 +241,7 @@ public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoTo
progess_action.setText(R.string.add_account_list_trunk);
listId = lists.get(0).getId();
listTitle = lists.get(0).getTitle();
- new ManageListsAsyncTask(WhoToFollowActivity.this, ManageListsAsyncTask.action.ADD_USERS, new String[]{followedId.get(0)}, null, lists.get(0).getId(), null, WhoToFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new ManageListsAsyncTask(WhoToFollowActivity.this, ManageListsAsyncTask.action.ADD_USERS, new String[]{followedId.get(0)}, lists.get(0).getId(), null, WhoToFollowActivity.this);
accountListId = new ArrayList<>();
} else if (accountListId != null) {
@@ -263,7 +262,7 @@ public class WhoToFollowActivity extends BaseActivity implements OnRetrieveWhoTo
accountListId.add(followedId.get(accountListId.size()));
progess_action.setText(R.string.adding_account_list_trunk);
String userIdToAdd = followedId.get(accountListId.size());
- new ManageListsAsyncTask(WhoToFollowActivity.this, ManageListsAsyncTask.action.ADD_USERS, new String[]{userIdToAdd}, null, listId, null, WhoToFollowActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
+ new ManageListsAsyncTask(WhoToFollowActivity.this, ManageListsAsyncTask.action.ADD_USERS, new String[]{userIdToAdd}, listId, null, WhoToFollowActivity.this);
}
}
diff --git a/app/src/main/java/app/fedilab/android/asynctasks/CreateMastodonAccountAsyncTask.java b/app/src/main/java/app/fedilab/android/asynctasks/CreateMastodonAccountAsyncTask.java
index 44f5d4fb1..f8cad5966 100644
--- a/app/src/main/java/app/fedilab/android/asynctasks/CreateMastodonAccountAsyncTask.java
+++ b/app/src/main/java/app/fedilab/android/asynctasks/CreateMastodonAccountAsyncTask.java
@@ -15,7 +15,8 @@
package app.fedilab.android.asynctasks;
import android.content.Context;
-import android.os.AsyncTask;
+import android.os.Handler;
+import android.os.Looper;
import java.lang.ref.WeakReference;
@@ -31,15 +32,14 @@ import app.fedilab.android.interfaces.OnPostStatusActionInterface;
* Create a Mastodon account
*/
-public class CreateMastodonAccountAsyncTask extends AsyncTask {
+public class CreateMastodonAccountAsyncTask {
- private OnPostStatusActionInterface listener;
+ private final OnPostStatusActionInterface listener;
+ private final AccountCreation accountCreation;
+ private final WeakReference contextReference;
+ private final String instance;
+ private final RetrieveInstanceRegAsyncTask.instanceType type;
private APIResponse apiResponse;
- private app.fedilab.android.client.Entities.Status status;
- private AccountCreation accountCreation;
- private WeakReference contextReference;
- private String instance;
- private RetrieveInstanceRegAsyncTask.instanceType type;
public CreateMastodonAccountAsyncTask(Context context, RetrieveInstanceRegAsyncTask.instanceType type, AccountCreation accountCreation, String instance, OnPostStatusActionInterface onPostStatusActionInterface) {
this.contextReference = new WeakReference<>(context);
@@ -47,22 +47,21 @@ public class CreateMastodonAccountAsyncTask extends AsyncTask
this.accountCreation = accountCreation;
this.instance = instance;
this.type = type;
+ doInBackground();
}
- @Override
- protected Void doInBackground(Void... params) {
- if (type == RetrieveInstanceRegAsyncTask.instanceType.MASTODON) {
- apiResponse = new API(contextReference.get(), instance, null).createAccount(accountCreation);
- } else {
- apiResponse = new PeertubeAPI(contextReference.get(), instance, null).createAccount(accountCreation);
- }
- return null;
+ protected void doInBackground() {
+ new Thread(() -> {
+ if (type == RetrieveInstanceRegAsyncTask.instanceType.MASTODON) {
+ apiResponse = new API(contextReference.get(), instance, null).createAccount(accountCreation);
+ } else {
+ apiResponse = new PeertubeAPI(contextReference.get(), instance, null).createAccount(accountCreation);
+ }
+ Handler mainHandler = new Handler(Looper.getMainLooper());
+ Runnable myRunnable = () -> listener.onPostStatusAction(apiResponse);
+ mainHandler.post(myRunnable);
+ }).start();
}
- @Override
- protected void onPostExecute(Void result) {
- listener.onPostStatusAction(apiResponse);
-
- }
}
diff --git a/app/src/main/java/app/fedilab/android/asynctasks/CustomSharingAsyncTask.java b/app/src/main/java/app/fedilab/android/asynctasks/CustomSharingAsyncTask.java
index cd1a7d7b3..d9adae905 100644
--- a/app/src/main/java/app/fedilab/android/asynctasks/CustomSharingAsyncTask.java
+++ b/app/src/main/java/app/fedilab/android/asynctasks/CustomSharingAsyncTask.java
@@ -16,7 +16,8 @@ package app.fedilab.android.asynctasks;
import android.content.Context;
-import android.os.AsyncTask;
+import android.os.Handler;
+import android.os.Looper;
import java.lang.ref.WeakReference;
@@ -29,28 +30,27 @@ import app.fedilab.android.interfaces.OnCustomSharingInterface;
* Custom share status metadata to remote content aggregator
*/
-public class CustomSharingAsyncTask extends AsyncTask {
+public class CustomSharingAsyncTask {
- private String encodedCustomSharingURL;
+ private final String encodedCustomSharingURL;
+ private final OnCustomSharingInterface listener;
+ private final WeakReference contextReference;
private CustomSharingResponse customSharingResponse;
- private OnCustomSharingInterface listener;
- private WeakReference contextReference;
public CustomSharingAsyncTask(Context context, String encodedCustomSharingURL, OnCustomSharingInterface onCustomSharingInterface) {
this.contextReference = new WeakReference<>(context);
this.encodedCustomSharingURL = encodedCustomSharingURL;
this.listener = onCustomSharingInterface;
+ doInBackground();
}
- @Override
- protected Void doInBackground(Void... params) {
- customSharingResponse = new CustomSharing(this.contextReference.get()).customShare(encodedCustomSharingURL);
- return null;
- }
-
- @Override
- protected void onPostExecute(Void result) {
- listener.onCustomSharing(customSharingResponse);
+ protected void doInBackground() {
+ new Thread(() -> {
+ customSharingResponse = new CustomSharing(this.contextReference.get()).customShare(encodedCustomSharingURL);
+ Handler mainHandler = new Handler(Looper.getMainLooper());
+ Runnable myRunnable = () -> listener.onCustomSharing(customSharingResponse);
+ mainHandler.post(myRunnable);
+ }).start();
}
}
\ No newline at end of file
diff --git a/app/src/main/java/app/fedilab/android/asynctasks/DeleteDomainsAsyncTask.java b/app/src/main/java/app/fedilab/android/asynctasks/DeleteDomainsAsyncTask.java
index 687418135..c47c09d5f 100644
--- a/app/src/main/java/app/fedilab/android/asynctasks/DeleteDomainsAsyncTask.java
+++ b/app/src/main/java/app/fedilab/android/asynctasks/DeleteDomainsAsyncTask.java
@@ -15,7 +15,8 @@
package app.fedilab.android.asynctasks;
import android.content.Context;
-import android.os.AsyncTask;
+import android.os.Handler;
+import android.os.Looper;
import java.lang.ref.WeakReference;
@@ -28,30 +29,32 @@ import app.fedilab.android.interfaces.OnRetrieveDomainsInterface;
* Delete a blocked instance
*/
-public class DeleteDomainsAsyncTask extends AsyncTask {
+public class DeleteDomainsAsyncTask {
- private OnRetrieveDomainsInterface listener;
- private WeakReference contextReference;
+ private final OnRetrieveDomainsInterface listener;
+ private final WeakReference contextReference;
+ private final String domainName;
private int response;
- private String domainName;
public DeleteDomainsAsyncTask(Context context, String domainName, OnRetrieveDomainsInterface onRetrieveDomainsInterface) {
this.contextReference = new WeakReference<>(context);
this.listener = onRetrieveDomainsInterface;
this.domainName = domainName;
+ doInBackground();
}
- @Override
- protected Void doInBackground(Void... params) {
- API api = new API(this.contextReference.get());
- response = api.deleteBlockedDomain(domainName);
- return null;
+ protected void doInBackground() {
+
+ new Thread(() -> {
+ API api = new API(this.contextReference.get());
+ response = api.deleteBlockedDomain(domainName);
+ Handler mainHandler = new Handler(Looper.getMainLooper());
+ Runnable myRunnable = () ->
+ listener.onRetrieveDomainsDeleted(response);
+ mainHandler.post(myRunnable);
+ }).start();
}
- @Override
- protected void onPostExecute(Void result) {
- listener.onRetrieveDomainsDeleted(response);
- }
}
diff --git a/app/src/main/java/app/fedilab/android/asynctasks/DownloadTrackingDomainsAsyncTask.java b/app/src/main/java/app/fedilab/android/asynctasks/DownloadTrackingDomainsAsyncTask.java
deleted file mode 100644
index 8dfb2132f..000000000
--- a/app/src/main/java/app/fedilab/android/asynctasks/DownloadTrackingDomainsAsyncTask.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Copyright 2019 NickFreeman
- *
- * This file is a part of Fedilab
- *
- * This program is free software; you can redistribute it and/or modify it under the terms of the
- * GNU General Public License as published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
- *
- * Fedilab is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
- * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
- * Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with Fedilab; if not,
- * see . */
-package app.fedilab.android.asynctasks;
-
-
-import android.content.Context;
-import android.database.sqlite.SQLiteDatabase;
-import android.os.AsyncTask;
-import android.os.Handler;
-import android.widget.Button;
-import android.widget.Toast;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.lang.ref.WeakReference;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.net.ssl.HttpsURLConnection;
-
-import app.fedilab.android.R;
-import app.fedilab.android.sqlite.DomainBlockDAO;
-import app.fedilab.android.sqlite.Sqlite;
-import es.dmoral.toasty.Toasty;
-
-/**
- * Created by NickFreeman on 11/05/2019.
- * Download the list of blocked tracking domains for build-in browser
- */
-
-public class DownloadTrackingDomainsAsyncTask extends AsyncTask {
-
- private WeakReference context;
- private WeakReference