Update 0.2.0-pre3

pull/27/head 0.2.0-pre3
Fox2Code 4 years ago
parent 5f2f43c12a
commit 7cca8636be

@ -10,8 +10,8 @@ android {
applicationId "com.fox2code.mmm"
minSdk 21
targetSdk 30
versionCode 7
versionName "0.2.0-pre2"
versionCode 8
versionName "0.2.0-pre3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

@ -14,6 +14,7 @@ import android.util.TypedValue;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.fox2code.mmm.compat.CompatActivity;
import com.fox2code.mmm.installer.InstallerInitializer;
@ -32,7 +33,6 @@ public class MainActivity extends CompatActivity implements SwipeRefreshLayout.O
private ModuleViewAdapter moduleViewAdapter;
private SwipeRefreshLayout swipeRefreshLayout;
private RecyclerView moduleList;
private LinearLayout searchContainer;
private CardView searchCard;
private SearchView searchView;
private boolean initMode;
@ -55,7 +55,6 @@ public class MainActivity extends CompatActivity implements SwipeRefreshLayout.O
this.progressIndicator = findViewById(R.id.progress_bar);
this.swipeRefreshLayout = findViewById(R.id.swipe_refresh);
this.moduleList = findViewById(R.id.module_list);
this.searchContainer = findViewById(R.id.search_container);
this.searchCard = findViewById(R.id.search_card);
this.searchView = findViewById(R.id.search_bar);
this.moduleViewAdapter = new ModuleViewAdapter();
@ -134,7 +133,6 @@ public class MainActivity extends CompatActivity implements SwipeRefreshLayout.O
}
private void cardIconifyUpdate() {
this.moduleViewListBuilder.setFooterPx(this.searchContainer.getHeight());
boolean iconified = this.searchView.isIconified();
int backgroundAttr = iconified ?
R.attr.colorSecondary : R.attr.colorPrimarySurface;
@ -201,7 +199,6 @@ public class MainActivity extends CompatActivity implements SwipeRefreshLayout.O
}
this.progressIndicator.setVisibility(View.VISIBLE);
this.progressIndicator.setProgressCompat(0, false);
this.moduleViewListBuilder.setFooterPx(this.searchContainer.getHeight());
// this.swipeRefreshLayout.setRefreshing(true); ??
new Thread(() -> {
RepoManager.getINSTANCE().update(value -> runOnUiThread(() ->

@ -4,6 +4,7 @@ import android.content.Context;
import android.content.pm.PackageManager;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import com.fox2code.mmm.installer.InstallerInitializer;
@ -54,7 +55,7 @@ public final class ModuleHolder implements Comparable<ModuleHolder> {
}
public boolean isModuleHolder() {
return this.notificationType == null && this.separator == null;
return this.notificationType == null && this.separator == null && this.footerPx == 0;
}
public ModuleInfo getMainModuleInfo() {
@ -124,7 +125,7 @@ public final class ModuleHolder implements Comparable<ModuleHolder> {
public boolean shouldRemove() {
return this.notificationType != null ? this.notificationType.shouldRemove() :
this.moduleInfo == null && (this.repoModule == null);
this.footerPx == 0 && this.moduleInfo == null && this.repoModule == null;
}
public void getButtons(Context context, List<ActionButtonType> buttonTypeList, boolean showcaseMode) {
@ -230,6 +231,7 @@ public final class ModuleHolder implements Comparable<ModuleHolder> {
}
}
@NonNull
@Override
public String toString() {
return "ModuleHolder{" +

@ -29,7 +29,6 @@ public class ModuleViewListBuilder {
private final Activity activity;
@NonNull
private String query = "";
private int footerPx;
private boolean noUpdate;
public ModuleViewListBuilder(Activity activity) {
@ -142,9 +141,6 @@ public class ModuleViewListBuilder {
this.activity.runOnUiThread(() -> {
final EnumSet<NotificationType> oldNotifications =
EnumSet.noneOf(NotificationType.class);
if (this.footerPx != 0) {
moduleHolders.add(new ModuleHolder(this.footerPx));
}
boolean isTop = !moduleList.canScrollVertically(-1);
boolean isBottom = !isTop && !moduleList.canScrollVertically(1);
int oldNotificationsLen = 0;
@ -194,10 +190,6 @@ public class ModuleViewListBuilder {
});
}
public void setFooterPx(int footerPx) {
this.footerPx = Math.max(footerPx, 0);
}
private boolean matchFilter(ModuleHolder moduleHolder) {
if (this.query.isEmpty()) return true;
ModuleInfo moduleInfo = moduleHolder.getMainModuleInfo();

@ -11,7 +11,9 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.Proxy;
import java.net.UnknownHostException;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
@ -22,6 +24,7 @@ import java.util.concurrent.TimeUnit;
import okhttp3.Cache;
import okhttp3.Cookie;
import okhttp3.CookieJar;
import okhttp3.Dns;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
@ -31,30 +34,44 @@ import okhttp3.dnsoverhttps.DnsOverHttps;
public class Http {
private static final OkHttpClient httpClient;
private static final OkHttpClient httpClientCachable;
private static final OkHttpClient httpClientWithCache;
static {
OkHttpClient.Builder httpclientBuilder = new OkHttpClient.Builder();
httpclientBuilder.connectTimeout(11, TimeUnit.SECONDS);
// Default is 10, extend it a bit for slow mobile connections.
httpclientBuilder.connectTimeout(15, TimeUnit.SECONDS);
httpclientBuilder.writeTimeout(15, TimeUnit.SECONDS);
httpclientBuilder.readTimeout(15, TimeUnit.SECONDS);
httpclientBuilder.proxy(Proxy.NO_PROXY); // Do not use system proxy
Dns dns = Dns.SYSTEM;
try {
InetAddress[] cloudflareBootstrap = new InetAddress[] {
InetAddress.getByName("162.159.36.1"),
InetAddress.getByName("162.159.46.1"),
InetAddress.getByName("1.1.1.1"),
InetAddress.getByName("1.0.0.1"),
InetAddress.getByName("162.159.132.53"),
InetAddress.getByName("2606:4700:4700::1111"),
InetAddress.getByName("2606:4700:4700::1001"),
InetAddress.getByName("2606:4700:4700::0064"),
InetAddress.getByName("2606:4700:4700::6400")
};
dns = s -> {
if ("cloudflare-dns.com".equals(s)) {
return Arrays.asList(cloudflareBootstrap);
}
return Dns.SYSTEM.lookup(s);
};
httpclientBuilder.dns(dns);
httpclientBuilder.cookieJar(new CDNCookieJar());
httpclientBuilder.dns(new DnsOverHttps.Builder().client(httpclientBuilder.build()).url(
dns = new DnsOverHttps.Builder().client(httpclientBuilder.build()).url(
Objects.requireNonNull(HttpUrl.parse("https://cloudflare-dns.com/dns-query")))
.bootstrapDnsHosts(
InetAddress.getByName("162.159.36.1"),
InetAddress.getByName("162.159.46.1"),
InetAddress.getByName("1.1.1.1"),
InetAddress.getByName("1.0.0.1"),
InetAddress.getByName("162.159.132.53"),
InetAddress.getByName("2606:4700:4700::1111"),
InetAddress.getByName("2606:4700:4700::1001"),
InetAddress.getByName("2606:4700:4700::0064"),
InetAddress.getByName("2606:4700:4700::6400")
).resolvePrivateAddresses(true).build());
.bootstrapDnsHosts(cloudflareBootstrap).resolvePrivateAddresses(true).build();
} catch (UnknownHostException|RuntimeException e) {
Log.e("Http", "Failed to init DoH", e);
}
httpclientBuilder.cookieJar(CookieJar.NO_COOKIES);
httpclientBuilder.dns(dns);
httpClient = httpclientBuilder.build();
MainApplication mainApplication = MainApplication.getINSTANCE();
if (mainApplication != null) {
@ -62,9 +79,9 @@ public class Http {
new File(mainApplication.getCacheDir(), "http_cache"),
2L * 1024L * 1024L)); // 2Mib of cache
httpclientBuilder.cookieJar(new CDNCookieJar());
httpClientCachable = httpclientBuilder.build();
httpClientWithCache = httpclientBuilder.build();
} else {
httpClientCachable = httpClient;
httpClientWithCache = httpClient;
}
}
@ -73,7 +90,7 @@ public class Http {
}
public static OkHttpClient getHttpclientWithCache() {
return httpClientCachable;
return httpClientWithCache;
}
private static Request.Builder makeRequestBuilder() {
@ -82,7 +99,7 @@ public class Http {
}
public static byte[] doHttpGet(String url,boolean allowCache) throws IOException {
Response response = (allowCache ? httpClientCachable : httpClient).newCall(
Response response = (allowCache ? httpClientWithCache : httpClient).newCall(
makeRequestBuilder().url(url).get().build()
).execute();
// 200 == success, 304 == cache valid

Loading…
Cancel
Save