mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Some fixes
This commit is contained in:
parent
a5c3da1491
commit
5521a14fdd
17 changed files with 338 additions and 56 deletions
|
@ -90,7 +90,6 @@ import app.fedilab.android.activities.FollowRequestActivity;
|
|||
import app.fedilab.android.activities.InstanceActivity;
|
||||
import app.fedilab.android.activities.InstanceHealthActivity;
|
||||
import app.fedilab.android.activities.LoginActivity;
|
||||
import app.fedilab.android.activities.MainActivity;
|
||||
import app.fedilab.android.activities.MastodonListActivity;
|
||||
import app.fedilab.android.activities.PartnerShipActivity;
|
||||
import app.fedilab.android.activities.ProfileActivity;
|
||||
|
@ -109,6 +108,7 @@ import app.fedilab.android.client.entities.api.Status;
|
|||
import app.fedilab.android.client.entities.app.Account;
|
||||
import app.fedilab.android.client.entities.app.BaseAccount;
|
||||
import app.fedilab.android.client.entities.app.BottomMenu;
|
||||
import app.fedilab.android.client.entities.app.DomainsBlock;
|
||||
import app.fedilab.android.client.entities.app.Pinned;
|
||||
import app.fedilab.android.client.entities.app.PinnedTimeline;
|
||||
import app.fedilab.android.databinding.ActivityMainBinding;
|
||||
|
@ -251,7 +251,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
|||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(PREF_USER_TOKEN, account.token);
|
||||
editor.commit();
|
||||
Intent mainActivity = new Intent(this, MainActivity.class);
|
||||
Intent mainActivity = new Intent(this, BaseMainActivity.class);
|
||||
mainActivity.putExtra(Helper.INTENT_ACTION, Helper.OPEN_NOTIFICATION);
|
||||
startActivity(mainActivity);
|
||||
finish();
|
||||
|
@ -456,7 +456,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
|||
editor.commit();
|
||||
//The user is now aut
|
||||
//The user is now authenticated, it will be redirected to MainActivity
|
||||
Intent mainActivity = new Intent(this, MainActivity.class);
|
||||
Intent mainActivity = new Intent(this, BaseMainActivity.class);
|
||||
startActivity(mainActivity);
|
||||
finish();
|
||||
headerMainBinding.ownerAccounts.setImageResource(R.drawable.ic_baseline_arrow_drop_down_24);
|
||||
|
@ -694,7 +694,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
|||
binding.toolbarSearch.setOnSearchClickListener(v -> binding.tabLayout.setVisibility(View.VISIBLE));
|
||||
//For receiving data from other activities
|
||||
LocalBroadcastManager.getInstance(BaseMainActivity.this).registerReceiver(broadcast_data, new IntentFilter(Helper.BROADCAST_DATA));
|
||||
if (emojis == null || !emojis.containsKey(MainActivity.currentInstance)) {
|
||||
if (emojis == null || !emojis.containsKey(BaseMainActivity.currentInstance)) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
emojis.put(currentInstance, new EmojiInstance(BaseMainActivity.this).getEmojiList(BaseMainActivity.currentInstance));
|
||||
|
@ -703,6 +703,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
|||
}
|
||||
}).start();
|
||||
}
|
||||
DomainsBlock.updateDomains(BaseMainActivity.this);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,17 +14,18 @@ package app.fedilab.android.activities;
|
|||
* You should have received a copy of the GNU General Public License along with Fedilab; if not,
|
||||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
|
@ -39,14 +40,13 @@ import androidx.core.content.ContextCompat;
|
|||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.databinding.ActivityWebviewBinding;
|
||||
import app.fedilab.android.helper.CountDrawable;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.helper.ThemeHelper;
|
||||
import app.fedilab.android.sqlite.Sqlite;
|
||||
import app.fedilab.android.webview.CustomWebview;
|
||||
import app.fedilab.android.webview.FedilabWebChromeClient;
|
||||
import app.fedilab.android.webview.FedilabWebViewClient;
|
||||
|
@ -55,12 +55,13 @@ import es.dmoral.toasty.Toasty;
|
|||
|
||||
public class WebviewActivity extends BaseActivity {
|
||||
|
||||
public static List<String> trackingDomains;
|
||||
|
||||
private String url;
|
||||
private boolean peertubeLink;
|
||||
private CustomWebview webView;
|
||||
private FedilabWebViewClient FedilabWebViewClient;
|
||||
private ActivityWebviewBinding binding;
|
||||
private Menu defaultMenu;
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
@Override
|
||||
|
@ -133,24 +134,12 @@ public class WebviewActivity extends BaseActivity {
|
|||
});
|
||||
if (!url.toLowerCase().startsWith("http://") && !url.toLowerCase().startsWith("https://"))
|
||||
url = "http://" + url;
|
||||
if (trackingDomains == null) {
|
||||
AsyncTask.execute(() -> {
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
// trackingDomains = new DomainBlockDAO(WebviewActivity.this, db).getAll();
|
||||
if (trackingDomains == null)
|
||||
trackingDomains = new ArrayList<>();
|
||||
// Get a handler that can be used to post to the main thread
|
||||
Handler mainHandler = new Handler(getMainLooper());
|
||||
Runnable myRunnable = () -> webView.loadUrl(url);
|
||||
mainHandler.post(myRunnable);
|
||||
webView.loadUrl(url);
|
||||
|
||||
});
|
||||
} else
|
||||
webView.loadUrl(url);
|
||||
}
|
||||
|
||||
|
||||
/* public void setCount(Context context, String count) {
|
||||
public void setCount(Context context, String count) {
|
||||
if (defaultMenu != null && !peertubeLink) {
|
||||
MenuItem menuItem = defaultMenu.findItem(R.id.action_block);
|
||||
LayerDrawable icon = (LayerDrawable) menuItem.getIcon();
|
||||
|
@ -169,17 +158,20 @@ public class WebviewActivity extends BaseActivity {
|
|||
icon.mutate();
|
||||
icon.setDrawableByLayerId(R.id.ic_block_count, badge);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||
|
||||
if (!peertubeLink)
|
||||
setCount(WebviewActivity.this, "0");
|
||||
defaultMenu = menu;
|
||||
return super.onPrepareOptionsMenu(menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(@NotNull Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.main_webview, menu);
|
||||
defaultMenu = menu;
|
||||
if (peertubeLink) {
|
||||
menu.findItem(R.id.action_go).setVisible(false);
|
||||
menu.findItem(R.id.action_block).setVisible(false);
|
||||
|
|
|
@ -55,6 +55,7 @@ import app.fedilab.android.helper.ThemeHelper;
|
|||
import app.fedilab.android.viewmodel.mastodon.AccountsVM;
|
||||
import app.fedilab.android.viewmodel.mastodon.AdminVM;
|
||||
import app.fedilab.android.viewmodel.mastodon.OauthVM;
|
||||
import es.dmoral.toasty.Toasty;
|
||||
|
||||
|
||||
public class WebviewConnectActivity extends BaseActivity {
|
||||
|
@ -214,18 +215,23 @@ public class WebviewConnectActivity extends BaseActivity {
|
|||
//API call to retrieve account information for the new token
|
||||
AccountsVM accountsVM = new ViewModelProvider(WebviewConnectActivity.this).get(AccountsVM.class);
|
||||
accountsVM.getConnectedAccount(currentInstanceLogin, account.token).observe(WebviewConnectActivity.this, mastodonAccount -> {
|
||||
account.mastodon_account = mastodonAccount;
|
||||
account.user_id = mastodonAccount.id;
|
||||
//We check if user have really moderator rights
|
||||
if (requestedAdmin) {
|
||||
AdminVM adminVM = new ViewModelProvider(WebviewConnectActivity.this).get(AdminVM.class);
|
||||
adminVM.getAccount(account.instance, account.token, account.user_id).observe(WebviewConnectActivity.this, adminAccount -> {
|
||||
account.admin = adminAccount != null;
|
||||
if (mastodonAccount != null) {
|
||||
account.mastodon_account = mastodonAccount;
|
||||
account.user_id = mastodonAccount.id;
|
||||
//We check if user have really moderator rights
|
||||
if (requestedAdmin) {
|
||||
AdminVM adminVM = new ViewModelProvider(WebviewConnectActivity.this).get(AdminVM.class);
|
||||
adminVM.getAccount(account.instance, account.token, account.user_id).observe(WebviewConnectActivity.this, adminAccount -> {
|
||||
account.admin = adminAccount != null;
|
||||
proceedLogin(WebviewConnectActivity.this, account);
|
||||
});
|
||||
} else {
|
||||
proceedLogin(WebviewConnectActivity.this, account);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
proceedLogin(WebviewConnectActivity.this, account);
|
||||
Toasty.error(WebviewConnectActivity.this, getString(R.string.toast_error), Toasty.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
return true;
|
||||
|
|
|
@ -225,12 +225,14 @@ public interface MastodonTimelinesService {
|
|||
@Query("count") int count
|
||||
);
|
||||
|
||||
@Headers({"Accept: text/html,application/xhtml+xml,application/xml"})
|
||||
@GET("{names}/rss")
|
||||
Call<Nitter> getNitter(
|
||||
@Path("names") String id,
|
||||
@Query("max_position") String max_position
|
||||
);
|
||||
|
||||
@Headers({"Accept: text/html,application/xhtml+xml,application/xml"})
|
||||
@GET("{account}/rss")
|
||||
Call<Nitter> getNitterAccount(
|
||||
@Path("account") String account
|
||||
|
|
|
@ -33,7 +33,6 @@ import java.util.List;
|
|||
|
||||
import app.fedilab.android.BaseMainActivity;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.MainActivity;
|
||||
import app.fedilab.android.exception.DBException;
|
||||
import app.fedilab.android.sqlite.Sqlite;
|
||||
|
||||
|
@ -218,8 +217,8 @@ public class BottomMenu implements Serializable {
|
|||
return -1;
|
||||
}
|
||||
if (bottomMenu.user_id == null) {
|
||||
bottomMenu.user_id = MainActivity.currentUserID;
|
||||
bottomMenu.instance = MainActivity.currentInstance;
|
||||
bottomMenu.user_id = BaseMainActivity.currentUserID;
|
||||
bottomMenu.instance = BaseMainActivity.currentInstance;
|
||||
}
|
||||
boolean exists = bottomMenuExists(bottomMenu);
|
||||
long idReturned;
|
||||
|
@ -299,8 +298,8 @@ public class BottomMenu implements Serializable {
|
|||
|
||||
public BottomMenu defaultBottomMenu() {
|
||||
BottomMenu bottomMenu = new BottomMenu();
|
||||
bottomMenu.user_id = MainActivity.currentUserID;
|
||||
bottomMenu.instance = MainActivity.currentInstance;
|
||||
bottomMenu.user_id = BaseMainActivity.currentUserID;
|
||||
bottomMenu.instance = BaseMainActivity.currentInstance;
|
||||
bottomMenu.bottom_menu = new ArrayList<>();
|
||||
MenuItem menuItemHome = new MenuItem();
|
||||
menuItemHome.position = 0;
|
||||
|
|
|
@ -0,0 +1,127 @@
|
|||
package app.fedilab.android.client.entities.app;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import app.fedilab.android.exception.DBException;
|
||||
import app.fedilab.android.helper.Helper;
|
||||
import app.fedilab.android.sqlite.Sqlite;
|
||||
|
||||
|
||||
public class DomainsBlock {
|
||||
|
||||
public static final String LAST_DATE_OF_UPDATE = "LAST_DATE_OF_UPDATE";
|
||||
public static List<String> trackingDomains = null;
|
||||
|
||||
private static void getDomains(Context context) {
|
||||
if (trackingDomains == null) {
|
||||
try {
|
||||
SQLiteDatabase db = Sqlite.getInstance(context.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
Cursor c = db.query(Sqlite.TABLE_DOMAINS_TRACKING, null, null, null, null, null, null, null);
|
||||
trackingDomains = cursorToDomain(c);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateDomains(Context _mContext) {
|
||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(_mContext);
|
||||
String last_date = sharedpreferences.getString(LAST_DATE_OF_UPDATE, null);
|
||||
Date dateUpdate = new Date(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(10));
|
||||
Date dateLastUpdate = Helper.stringToDate(_mContext, last_date);
|
||||
SQLiteDatabase db = Sqlite.getInstance(_mContext.getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
if (last_date == null || dateUpdate.after(dateLastUpdate)) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
HttpsURLConnection connection = (HttpsURLConnection) new URL("https://hosts.fedilab.app/hosts").openConnection();
|
||||
if (connection.getResponseCode() > HttpsURLConnection.HTTP_MOVED_TEMP) {
|
||||
return;
|
||||
}
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String line;
|
||||
List<String> domains = new ArrayList<>();
|
||||
while ((line = br.readLine()) != null) {
|
||||
if (line.startsWith("0.0.0.0 ")) {
|
||||
domains.add(line.replace("0.0.0.0 ", "").trim());
|
||||
}
|
||||
}
|
||||
br.close();
|
||||
connection.disconnect();
|
||||
insertDomains(db, domains);
|
||||
SharedPreferences.Editor editor = sharedpreferences.edit();
|
||||
editor.putString(LAST_DATE_OF_UPDATE, Helper.dateToString(new Date()));
|
||||
editor.apply();
|
||||
} catch (IOException | DBException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
getDomains(_mContext);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a domains in db
|
||||
*
|
||||
* @param domains {@link List<String>}
|
||||
* @throws DBException exception with database
|
||||
*/
|
||||
private static void insertDomains(SQLiteDatabase db, List<String> domains) throws DBException {
|
||||
|
||||
if (db == null) {
|
||||
throw new DBException("db is null. Wrong initialization.");
|
||||
}
|
||||
db.delete(Sqlite.TABLE_DOMAINS_TRACKING, null, null);
|
||||
DomainsBlock.trackingDomains = new ArrayList<>();
|
||||
for (String domain : domains) {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(Sqlite.COL_DOMAIN, domain);
|
||||
//Inserts token
|
||||
try {
|
||||
db.insertOrThrow(Sqlite.TABLE_DOMAINS_TRACKING, null, values);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
DomainsBlock.trackingDomains.add(domain);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* Method to hydrate domain from database
|
||||
* @param c Cursor
|
||||
* @return List<String>
|
||||
*/
|
||||
private static List<String> cursorToDomain(Cursor c) {
|
||||
//No element found
|
||||
if (c.getCount() == 0) {
|
||||
c.close();
|
||||
return null;
|
||||
}
|
||||
List<String> domains = new ArrayList<>();
|
||||
while (c.moveToNext()) {
|
||||
domains.add(c.getString(c.getColumnIndexOrThrow(Sqlite.COL_DOMAIN)));
|
||||
}
|
||||
//Close the cursor
|
||||
c.close();
|
||||
//domains list is returned
|
||||
return domains;
|
||||
}
|
||||
}
|
|
@ -79,11 +79,12 @@ public class Nitter implements Serializable {
|
|||
status.id = feedItem.pubDate;
|
||||
status.content = feedItem.description;
|
||||
status.text = feedItem.title;
|
||||
status.content = status.content.replaceAll("<img [^>]*src=\"[^\"]+\"[^>]*>", "");
|
||||
status.visibility = "public";
|
||||
status.created_at = Helper.stringToDateWithFormat(context, feedItem.pubDate, "EEE, dd MMM yyyy HH:mm:ss zzz");
|
||||
status.uri = feedItem.guid;
|
||||
status.url = feedItem.link;
|
||||
if (!accounts.containsValue(feedItem.creator)) {
|
||||
if (!accounts.containsKey(feedItem.creator)) {
|
||||
MastodonTimelinesService mastodonTimelinesService = initInstanceXMLOnly(context, instance);
|
||||
Call<Nitter> accountCall = mastodonTimelinesService.getNitterAccount(feedItem.creator.replace("@", ""));
|
||||
if (accountCall != null) {
|
||||
|
|
116
app/src/main/java/app/fedilab/android/helper/CountDrawable.java
Normal file
116
app/src/main/java/app/fedilab/android/helper/CountDrawable.java
Normal file
|
@ -0,0 +1,116 @@
|
|||
package app.fedilab.android.helper;
|
||||
/* Copyright 2022 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 <http://www.gnu.org/licenses>. */
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import app.fedilab.android.R;
|
||||
|
||||
|
||||
public class CountDrawable extends Drawable {
|
||||
|
||||
private final Paint mBadgePaint;
|
||||
private final Paint mTextPaint;
|
||||
private final Rect mTxtRect = new Rect();
|
||||
|
||||
private String mCount = "";
|
||||
private boolean mWillDraw;
|
||||
|
||||
public CountDrawable(Context context) {
|
||||
float mTextSize = context.getResources().getDimension(R.dimen.badge_count_textsize);
|
||||
|
||||
mBadgePaint = new Paint();
|
||||
mBadgePaint.setColor(ContextCompat.getColor(context, R.color.red_1));
|
||||
mBadgePaint.setAntiAlias(true);
|
||||
mBadgePaint.setStyle(Paint.Style.FILL);
|
||||
|
||||
mTextPaint = new Paint();
|
||||
mTextPaint.setColor(Color.WHITE);
|
||||
mTextPaint.setTypeface(Typeface.DEFAULT);
|
||||
mTextPaint.setTextSize(mTextSize);
|
||||
mTextPaint.setAntiAlias(true);
|
||||
mTextPaint.setTextAlign(Paint.Align.CENTER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(@NonNull Canvas canvas) {
|
||||
|
||||
if (!mWillDraw) {
|
||||
return;
|
||||
}
|
||||
Rect bounds = getBounds();
|
||||
float width = bounds.right - bounds.left;
|
||||
float height = bounds.bottom - bounds.top;
|
||||
|
||||
// Position the badge in the top-right quadrant of the icon.
|
||||
|
||||
/*Using Math.max rather than Math.min */
|
||||
|
||||
float radius = ((Math.max(width, height) / 2)) / 2;
|
||||
float centerX = (width - radius - 1) + 5;
|
||||
float centerY = radius - 5;
|
||||
if (mCount.length() <= 2) {
|
||||
// Draw badge circle.
|
||||
canvas.drawCircle(centerX, centerY, (int) (radius + 5.5), mBadgePaint);
|
||||
} else {
|
||||
canvas.drawCircle(centerX, centerY, (int) (radius + 6.5), mBadgePaint);
|
||||
}
|
||||
// Draw badge count text inside the circle.
|
||||
mTextPaint.getTextBounds(mCount, 0, mCount.length(), mTxtRect);
|
||||
float textHeight = mTxtRect.bottom - mTxtRect.top;
|
||||
float textY = centerY + (textHeight / 2f);
|
||||
if (mCount.length() > 2)
|
||||
canvas.drawText("99+", centerX, textY, mTextPaint);
|
||||
else
|
||||
canvas.drawText(mCount, centerX, textY, mTextPaint);
|
||||
}
|
||||
|
||||
/*
|
||||
Sets the count (i.e notifications) to display.
|
||||
*/
|
||||
public void setCount(String count) {
|
||||
mCount = count;
|
||||
|
||||
// Only draw a badge if there are notifications.
|
||||
mWillDraw = !count.equalsIgnoreCase("0");
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter cf) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return PixelFormat.UNKNOWN;
|
||||
}
|
||||
}
|
|
@ -86,10 +86,12 @@ public class PushHelper {
|
|||
case "REPEAT_NOTIFICATIONS":
|
||||
new Thread(() -> {
|
||||
List<BaseAccount> accounts = new Account(context).getPushNotificationAccounts();
|
||||
for (BaseAccount account : accounts) {
|
||||
((Activity) context).runOnUiThread(() -> {
|
||||
UnifiedPush.unregisterApp(context, account.user_id + "@" + account.instance);
|
||||
});
|
||||
if (accounts != null) {
|
||||
for (BaseAccount account : accounts) {
|
||||
((Activity) context).runOnUiThread(() -> {
|
||||
UnifiedPush.unregisterApp(context, account.user_id + "@" + account.instance);
|
||||
});
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
new PeriodicWorkRequest.Builder(NotificationsWorker.class, 20, TimeUnit.MINUTES)
|
||||
|
|
|
@ -23,7 +23,7 @@ import android.database.sqlite.SQLiteOpenHelper;
|
|||
public class Sqlite extends SQLiteOpenHelper {
|
||||
|
||||
|
||||
public static final int DB_VERSION = 4;
|
||||
public static final int DB_VERSION = 5;
|
||||
public static final String DB_NAME = "fedilab_db";
|
||||
|
||||
//Table of owned accounts
|
||||
|
@ -81,7 +81,9 @@ public class Sqlite extends SQLiteOpenHelper {
|
|||
//Bottom menu
|
||||
public static final String TABLE_BOTTOM_MENU = "TABLE_BOTTOM_MENU";
|
||||
public static final String COL_BOTTOM_MENU = "BOTTOM_MENU";
|
||||
|
||||
//Tracking domains
|
||||
public static final String TABLE_DOMAINS_TRACKING = "TABLE_DOMAINS_TRACKING";
|
||||
public static final String COL_DOMAIN = "DOMAIN";
|
||||
|
||||
private static final String CREATE_TABLE_USER_ACCOUNT = "CREATE TABLE " + TABLE_USER_ACCOUNT + " ("
|
||||
+ COL_USER_ID + " TEXT NOT NULL, "
|
||||
|
@ -170,6 +172,10 @@ public class Sqlite extends SQLiteOpenHelper {
|
|||
+ COL_USER_ID + " TEXT NOT NULL, "
|
||||
+ COL_BOTTOM_MENU + " TEXT NOT NULL)";
|
||||
|
||||
private static final String CREATE_DOMAINS_TRACKING = "CREATE TABLE IF NOT EXISTS " + TABLE_DOMAINS_TRACKING + " ("
|
||||
+ COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
|
||||
+ COL_DOMAIN + " TEXT NOT NULL)";
|
||||
|
||||
public static SQLiteDatabase db;
|
||||
private static Sqlite sInstance;
|
||||
|
||||
|
@ -198,6 +204,7 @@ public class Sqlite extends SQLiteOpenHelper {
|
|||
db.execSQL(CREATE_TABLE_SCHEDULE_BOOST);
|
||||
db.execSQL(CREATE_TABLE_QUICK_LOAD);
|
||||
db.execSQL(CREATE_TABLE_BOTTOM_MENU);
|
||||
db.execSQL(CREATE_DOMAINS_TRACKING);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -214,6 +221,8 @@ public class Sqlite extends SQLiteOpenHelper {
|
|||
db.execSQL(CREATE_TABLE_BOTTOM_MENU);
|
||||
case 3:
|
||||
db.execSQL("ALTER TABLE " + TABLE_USER_ACCOUNT + " ADD COLUMN " + COL_ADMIN + " INTEGER NOT NULL DEFAULT 0");
|
||||
case 4:
|
||||
db.execSQL(CREATE_DOMAINS_TRACKING);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,6 @@ import java.util.List;
|
|||
|
||||
import app.fedilab.android.BaseMainActivity;
|
||||
import app.fedilab.android.R;
|
||||
import app.fedilab.android.activities.MainActivity;
|
||||
import app.fedilab.android.client.entities.api.Account;
|
||||
import app.fedilab.android.client.entities.api.Attachment;
|
||||
import app.fedilab.android.client.entities.api.Marker;
|
||||
|
@ -236,7 +235,11 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
} else if (list_id != null) {
|
||||
ident = "@l@" + list_id;
|
||||
} else if (remoteInstance != null) {
|
||||
ident = "@R@" + remoteInstance;
|
||||
if (pinnedTimeline.remoteInstance.type == RemoteInstance.InstanceType.NITTER) {
|
||||
ident = "@R@" + pinnedTimeline.remoteInstance.host;
|
||||
} else {
|
||||
ident = "@R@" + remoteInstance;
|
||||
}
|
||||
} else if (search != null) {
|
||||
ident = "@S@" + search;
|
||||
} else {
|
||||
|
|
|
@ -171,6 +171,7 @@ public class TimelinesVM extends AndroidViewModel {
|
|||
statusesMutableLiveData = new MutableLiveData<>();
|
||||
new Thread(() -> {
|
||||
Call<Nitter> publicTlCall = mastodonTimelinesService.getNitter(accountsStr, max_position);
|
||||
|
||||
Statuses statuses = new Statuses();
|
||||
if (publicTlCall != null) {
|
||||
try {
|
||||
|
|
|
@ -15,6 +15,8 @@ package app.fedilab.android.webview;
|
|||
* see <http://www.gnu.org/licenses>. */
|
||||
|
||||
|
||||
import static app.fedilab.android.client.entities.app.DomainsBlock.trackingDomains;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.http.SslError;
|
||||
|
@ -59,7 +61,7 @@ public class FedilabWebViewClient extends WebViewClient {
|
|||
|
||||
@Override
|
||||
public WebResourceResponse shouldInterceptRequest(final WebView view, String url) {
|
||||
if (WebviewActivity.trackingDomains != null) {
|
||||
if (trackingDomains != null) {
|
||||
URI uri;
|
||||
try {
|
||||
uri = new URI(url);
|
||||
|
@ -67,11 +69,11 @@ public class FedilabWebViewClient extends WebViewClient {
|
|||
if (domain != null) {
|
||||
domain = domain.startsWith("www.") ? domain.substring(4) : domain;
|
||||
}
|
||||
if (domain != null && WebviewActivity.trackingDomains.contains(domain)) {
|
||||
if (domain != null && trackingDomains.contains(domain)) {
|
||||
if (activity instanceof WebviewActivity) {
|
||||
count++;
|
||||
domains.add(url);
|
||||
// ((WebviewActivity) activity).setCount(activity, String.valueOf(count));
|
||||
((WebviewActivity) activity).setCount(activity, String.valueOf(count));
|
||||
}
|
||||
ByteArrayInputStream nothing = new ByteArrayInputStream("".getBytes());
|
||||
return new WebResourceResponse("text/plain", "utf-8", nothing);
|
||||
|
@ -86,11 +88,11 @@ public class FedilabWebViewClient extends WebViewClient {
|
|||
if (domain != null) {
|
||||
domain = domain.startsWith("www.") ? domain.substring(4) : domain;
|
||||
}
|
||||
if (domain != null && WebviewActivity.trackingDomains.contains(domain)) {
|
||||
if (domain != null && trackingDomains.contains(domain)) {
|
||||
if (activity instanceof WebviewActivity) {
|
||||
count++;
|
||||
domains.add(url);
|
||||
// ((WebviewActivity) activity).setCount(activity, String.valueOf(count));
|
||||
((WebviewActivity) activity).setCount(activity, String.valueOf(count));
|
||||
}
|
||||
ByteArrayInputStream nothing = new ByteArrayInputStream("".getBytes());
|
||||
return new WebResourceResponse("text/plain", "utf-8", nothing);
|
||||
|
|
12
app/src/main/res/drawable/browser_calls_blocked.xml
Normal file
12
app/src/main/res/drawable/browser_calls_blocked.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:drawable="@drawable/ic_block_script"
|
||||
android:gravity="center" />
|
||||
|
||||
<item
|
||||
android:id="@+id/ic_block_count"
|
||||
android:drawable="@color/transparent" />
|
||||
|
||||
</layer-list>
|
9
app/src/main/res/drawable/ic_block_script.xml
Normal file
9
app/src/main/res/drawable/ic_block_script.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM4,12c0,-4.42 3.58,-8 8,-8 1.85,0 3.55,0.63 4.9,1.69L5.69,16.9C4.63,15.55 4,13.85 4,12zM12,20c-1.85,0 -3.55,-0.63 -4.9,-1.69L18.31,7.1C19.37,8.45 20,10.15 20,12c0,4.42 -3.58,8 -8,8z" />
|
||||
</vector>
|
|
@ -3,7 +3,7 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/action_block"
|
||||
android:icon="@drawable/ic_baseline_block_24"
|
||||
android:icon="@drawable/browser_calls_blocked"
|
||||
android:title="@string/calls_blocked"
|
||||
app:showAsAction="always" />
|
||||
<item
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<dimen name="drawer_padding">2dp</dimen>
|
||||
<dimen name="layout_height_header">180dp</dimen>
|
||||
|
||||
|
||||
<dimen name="badge_count_textsize">12sp</dimen>
|
||||
<dimen name="editor_size">35dp</dimen>
|
||||
<dimen name="top_tool_icon_width">50dp</dimen>
|
||||
</resources>
|
Loading…
Reference in a new issue