Fix some elements

This commit is contained in:
Thomas 2020-04-02 17:43:22 +02:00
parent c6460840f8
commit 2225d2f539
5 changed files with 23 additions and 26 deletions

View File

@ -595,18 +595,26 @@ public class MainActivity extends AppCompatActivity {
TextInputEditText nitter_instance = findViewById(R.id.nitter_instance);
TextInputEditText invidious_instance = findViewById(R.id.invidious_instance);
TextInputEditText bibliogram_instance = findViewById(R.id.bibliogram_instance);
TextView current_instance_nitter = findViewById(R.id.current_instance_nitter);
TextView current_instance_invidious = findViewById(R.id.current_instance_invidious);
TextView current_instance_bibliogram = findViewById(R.id.current_instance_bibliogram);
SharedPreferences sharedpreferences = getSharedPreferences(APP_PREFS, Context.MODE_PRIVATE);
String nitterHost = sharedpreferences.getString(SET_NITTER_HOST, null);
String invidiousHost = sharedpreferences.getString(SET_INVIDIOUS_HOST, null);
String bibliogramHost = sharedpreferences.getString(SET_BIBLIOGRAM_HOST, null);
if (nitterHost != null) {
nitter_instance.setText(nitterHost);
current_instance_nitter.setText(nitterHost);
}
if (invidiousHost != null) {
invidious_instance.setText(invidiousHost);
current_instance_invidious.setText(invidiousHost);
}
if (bibliogramHost != null) {
bibliogram_instance.setText(bibliogramHost);
current_instance_bibliogram.setText(bibliogramHost);
}
}

View File

@ -19,7 +19,6 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Build;
@ -27,7 +26,6 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Parcelable;
import android.util.Log;
import android.util.Patterns;
import android.view.View;
import android.widget.Button;
@ -75,7 +73,6 @@ public class TransformActivity extends Activity {
super.onCreate(savedInstanceState);
SharedPreferences sharedpreferences = getSharedPreferences(MainActivity.APP_PREFS, Context.MODE_PRIVATE);
Intent intent = getIntent();
Log.v(MainActivity.TAG,"intent: " + intent);
if (intent != null && intent.getStringExtra("nitterizeme") != null) {
finish();
return;
@ -84,11 +81,8 @@ public class TransformActivity extends Activity {
assert intent != null;
//Dealing with URLs
Log.v(MainActivity.TAG,"intent: " + intent);
if (Objects.requireNonNull(intent.getAction()).equals(Intent.ACTION_VIEW)) {
String url = Objects.requireNonNull(intent.getData()).toString();
Log.v(MainActivity.TAG,"url: " + url);
URL url_;
String host = null;
try {
@ -229,11 +223,9 @@ public class TransformActivity extends Activity {
//Twitter URLs
else if (Arrays.asList(twitter_domains).contains(host)) {
boolean nitter_enabled = sharedpreferences.getBoolean(SET_NITTER_ENABLED, true);
Log.v(MainActivity.TAG,"nitter_enabled: " + nitter_enabled);
if (nitter_enabled) {
Intent delegate = new Intent(Intent.ACTION_VIEW);
String transformedURL = transformUrl(url);
Log.v(MainActivity.TAG,"urlT: " + url);
if (transformedURL != null) {
delegate.setData(Uri.parse(transformUrl(url)));
delegate.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@ -316,13 +308,8 @@ public class TransformActivity extends Activity {
if( host != null && host.compareTo(invidiousHost) != 0 ){
transformedURL = url.replace(host, invidiousHost);
}
Intent delegate = new Intent(Intent.ACTION_VIEW);
delegate.setData(Uri.parse(transformedURL));
delegate.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (delegate.resolveActivity(getPackageManager()) != null) {
startActivity(delegate);
finish();
}
intent.setData(Uri.parse(transformedURL));
forwardToBrowser(intent);
} else {
forwardToBrowser(intent);
}
@ -351,13 +338,8 @@ public class TransformActivity extends Activity {
if( host != null && host.compareTo(bibliogramHost) != 0 ){
transformedURL = url.replace(host, bibliogramHost);
}
Intent delegate = new Intent(Intent.ACTION_VIEW);
delegate.setData(Uri.parse(transformedURL));
delegate.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (delegate.resolveActivity(getPackageManager()) != null) {
startActivity(delegate);
finish();
}
intent.setData(Uri.parse(transformedURL));
forwardToBrowser(intent);
} else {
forwardToBrowser(intent);
}

View File

@ -15,6 +15,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="20dp"
android:scrollbars="none">
<LinearLayout

View File

@ -15,7 +15,7 @@
* see <http://www.gnu.org/licenses>. */
-->
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
@ -675,12 +675,14 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:minHeight="1800dp"
android:overScrollMode="never"
android:layout_marginBottom="10dp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/buttons_container" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</androidx.core.widget.NestedScrollView>

View File

@ -1,3 +1,7 @@
Added:
- Allow to redirect Invidious, Nitter and Bibliogram links from an instance to your selected one.
- Unshorten support for buff.ly
- Allow to redirect Invidious, Nitter and Bibliogram links to the preferred instances
- Unshorten support for buff.ly
Fixed:
- Refresh issue when picking up another instance
- Last Bibliogram instances not accessible