some changes

This commit is contained in:
Thomas 2020-06-26 19:16:00 +02:00
parent 51860ff399
commit c30e2d6a40
9 changed files with 447 additions and 786 deletions

View File

@ -15,7 +15,9 @@ android {
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
@ -53,6 +55,7 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
implementation 'com.github.GrenderG:Toasty:1.4.2'
implementation 'com.google.android.exoplayer:exoplayer:2.10.6'
implementation "com.github.mabbas007:TagsEditText:1.0.5"

View File

@ -28,6 +28,25 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".PeertubeActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name" />
<activity
android:name=".PeertubeEditUploadActivity"
android:configChanges="orientation|screenSize"
android:label="@string/app_name"
android:windowSoftInputMode="stateAlwaysHidden" />
<receiver
android:name="app.fedilab.android.services.PeertubeUploadReceiver"
android:exported="false">
<intent-filter>
<action android:name="app.fedilab.android.uploadservice.broadcast.status" />
</intent-filter>
</receiver>
</application>
</manifest>

View File

@ -9,6 +9,9 @@ public class FedilabTupe extends MultiDexApplication {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
MultiDex.install(FedilabTupe.this);
}
}

View File

@ -1975,7 +1975,7 @@ public class PeertubeAPI {
private String getAbsoluteUrl(String action) {
return Helper.instanceWithProtocol(this.instance) + "/api/v1" + action;
return Helper.instanceWithProtocol(context) + "/api/v1" + action;
}
}

View File

@ -1,5 +1,6 @@
package app.fedilab.fedilabtube.helper;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.DownloadManager;
import android.content.Context;
@ -159,14 +160,14 @@ public class Helper {
public static final String SET_EMBEDDED_BROWSER = "set_embedded_browser";
public static final String SET_CUSTOM_TABS = "set_custom_tabs";
public static final String SET_DISPLAY_CONFIRM = "set_display_confirm";
public static final String INTENT_ADD_UPLOADED_MEDIA = "intent_add_uploaded_media";
/**
* Returns the peertube URL depending of the academic domain name
* @param acad String academic domain name
* @return String the peertube URL
*/
public static String getPeertubeUrl(String acad) {
return "https://tube-"+acad.replace("ac\\-|\\.fr","")+".beta.education.fr/";
private static String getPeertubeUrl(String acad) {
return "tube-"+acad.replaceAll("ac-|\\.fr","")+".beta.education.fr";
}
@ -178,19 +179,13 @@ public class Helper {
*/
public static String getLiveInstance(Context context) {
final SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
return sharedpreferences.getString(Helper.PREF_INSTANCE, null);
String acad = sharedpreferences.getString(Helper.PREF_INSTANCE, "ac-lyon.fr");
return getPeertubeUrl(acad);
}
public static String getLiveInstanceWithProtocol(Context context) {
return instanceWithProtocol(getLiveInstance(context));
}
public static String instanceWithProtocol(String instance) {
if (instance == null)
return null;
return "https://" + instance;
public static String instanceWithProtocol(Context context) {
return "https://"+getLiveInstance(context);
}
/**
@ -349,15 +344,11 @@ public class Helper {
public static void loadGiF(final Context context, Account account, final ImageView imageView) {
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
String url = account.getAvatar();
if (url != null && url.startsWith("/")) {
url = Helper.getLiveInstanceWithProtocol(context) + url;
url = Helper.getLiveInstance(context) + url;
}
try {
Glide.with(imageView.getContext())
.asDrawable()
@ -426,6 +417,7 @@ public class Helper {
}
@SuppressLint("SetJavaScriptEnabled")
public static CustomWebview initializeWebview(Activity activity, int webviewId, View rootView) {
CustomWebview webView;

View File

@ -0,0 +1,63 @@
package app.fedilab.fedilabtube.services;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import net.gotev.uploadservice.ServerResponse;
import net.gotev.uploadservice.UploadInfo;
import net.gotev.uploadservice.UploadServiceBroadcastReceiver;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import app.fedilab.fedilabtube.helper.Helper;
public class PeertubeUploadReceiver extends UploadServiceBroadcastReceiver {
@Override
public void onProgress(Context context, UploadInfo uploadInfo) {
// your code here
}
@Override
public void onError(Context context, UploadInfo uploadInfo, ServerResponse serverResponse,
Exception exception) {
// your code here
}
@Override
public void onCompleted(Context context, UploadInfo uploadInfo, ServerResponse serverResponse) {
try {
JSONObject response = new JSONObject(serverResponse.getBodyAsString());
if (!response.has("video")) { //IT's not from Peertube
ArrayList<String> file = uploadInfo.getSuccessfullyUploadedFiles();
Intent addMedia = new Intent(Helper.INTENT_ADD_UPLOADED_MEDIA);
addMedia.putExtra("response", serverResponse.getBodyAsString());
addMedia.putStringArrayListExtra("uploadInfo", file);
LocalBroadcastManager.getInstance(context).sendBroadcast(addMedia);
} else {
String videoID = response.getJSONObject("video").get("id").toString();
SharedPreferences sharedpreferences = context.getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.VIDEO_ID, videoID);
editor.commit();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
@Override
public void onCancelled(Context context, UploadInfo uploadInfo) {
// your code here
}
}

View File

@ -18,7 +18,7 @@
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/bottom_nav_menu" />
<androidx.fragment.app.FragmentContainerView
<fragment
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"

View File

@ -12,7 +12,7 @@
tools:layout="@layout/fragment_video" >
<argument
android:name="type"
app:argType="app.fedilab.fedilabtube.asynctasks.RetrieveFeedsAsyncTask.Type"
app:argType=".asynctasks.RetrieveFeedsAsyncTask$Type"
android:defaultValue="PLOCAL"/>
</fragment>
@ -23,7 +23,7 @@
tools:layout="@layout/fragment_video">
<argument
android:name="type"
app:argType="app.fedilab.fedilabtube.asynctasks.RetrieveFeedsAsyncTask.Type"
app:argType=".asynctasks.RetrieveFeedsAsyncTask$Type"
android:defaultValue="PRECENTLYADDED"/>
</fragment>
@ -34,7 +34,7 @@
tools:layout="@layout/fragment_video">
<argument
android:name="type"
app:argType="app.fedilab.fedilabtube.asynctasks.RetrieveFeedsAsyncTask.Type"
app:argType=".asynctasks.RetrieveFeedsAsyncTask$Type"
android:defaultValue="PMOSTLIKED"/>
</fragment>
@ -45,7 +45,7 @@
tools:layout="@layout/fragment_video">
<argument
android:name="type"
app:argType="app.fedilab.fedilabtube.asynctasks.RetrieveFeedsAsyncTask.Type"
app:argType=".asynctasks.RetrieveFeedsAsyncTask$Type"
android:defaultValue="PTRENDING"/>
</fragment>
@ -56,7 +56,7 @@
tools:layout="@layout/fragment_video">
<argument
android:name="type"
app:argType="app.fedilab.fedilabtube.asynctasks.RetrieveFeedsAsyncTask.Type"
app:argType=".asynctasks.RetrieveFeedsAsyncTask$Type"
android:defaultValue="PPUBLIC"/>
</fragment>