Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixzone support create by region id #505

Merged
merged 20 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

buildscript {
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.3'
classpath 'com.android.tools.build:gradle:7.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand Down
7 changes: 3 additions & 4 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,16 @@ android {

dependencies {
implementation 'com.squareup.okhttp3:okhttp:4.9.1'

// implementation 'com.squareup.okhttp3:okhttp:3.12.+'
implementation 'com.qiniu:happy-dns:2.0.1'

// for javax.annotation.Nullable use in custom MultipartBody and Headers implements.
// implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation 'org.conscrypt:conscrypt-android:2.2.1'
implementation fileTree(include: ['*.jar'], dir: 'libs')

androidTestImplementation 'junit:junit:4.13.2'
androidTestImplementation "androidx.test.ext:junit:1.1.3"
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

// androidTestImplementation "androidx.test:runner:1.4.0"
// androidTestImplementation "androidx.test:core:1.4.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.qiniu.android.common;


import androidx.test.ext.junit.runners.AndroidJUnit4;

import com.qiniu.android.BaseTest;

import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(AndroidJUnit4.class)
public class FixZoneTest extends BaseTest {

@Test
public void testCreateByRegionId() {
FixedZone zone = FixedZone.createWithRegionId("na0");
ZoneInfo zoneInfo = zone.getZonesInfo(null).zonesInfo.get(0);

assertTrue(zoneInfo.regionId.equals("na0"));
assertTrue(zoneInfo.domains.get(0).equals("upload-na0.qiniup.com"));
assertTrue(zoneInfo.domains.get(1).equals("up-na0.qiniup.com"));
}
}
34 changes: 34 additions & 0 deletions library/src/main/java/com/qiniu/android/common/FixedZone.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,82 @@
public final class FixedZone extends Zone {
/**
* 华东机房
* <p>
* 废弃,使用 {@link FixedZone#createWithRegionId} 替换,regionId:z0
*/
@Deprecated
public static final Zone zone0 = new FixedZone(new String[]{"upload.qiniup.com", "up.qiniup.com"},
new String[]{"upload.qbox.me", "up.qbox.me"},
"z0");

/**
* 华东浙江 2 机房
* <p>
* 废弃,使用 {@link FixedZone#createWithRegionId} 替换,regionId:cn-east-2
*/
@Deprecated
public static final Zone zoneCnEast2 = new FixedZone(new String[]{"upload-cn-east-2.qiniup.com", "up-cn-east-2.qiniup.com"},
null,
"cn-east-2");

/**
* 华北机房
* <p>
* 废弃,使用 {@link FixedZone#createWithRegionId} 替换,regionId:z1
*/
@Deprecated
public static final Zone zone1 = new FixedZone(new String[]{"upload-z1.qiniup.com", "up-z1.qiniup.com"},
new String[]{"upload-z1.qbox.me", "up-z1.qbox.me"},
"z1");

/**
* 华南机房
* <p>
* 废弃,使用 {@link FixedZone#createWithRegionId} 替换,regionId:z2
*/
@Deprecated
public static final Zone zone2 = new FixedZone(new String[]{"upload-z2.qiniup.com", "up-z2.qiniup.com"},
new String[]{"upload-z2.qbox.me", "up-z2.qbox.me"},
"z2");

/**
* 北美机房
* <p>
* 废弃,使用 {@link FixedZone#createWithRegionId} 替换,regionId:na0
*/
@Deprecated
public static final Zone zoneNa0 = new FixedZone(new String[]{"upload-na0.qiniup.com", "up-na0.qiniup.com"},
new String[]{"upload-na0.qbox.me", "up-na0.qbox.me"},
"na0");

/**
* 新加坡机房
* <p>
* 废弃,使用 {@link FixedZone#createWithRegionId} 替换,regionId:as0
*/
@Deprecated
public static final Zone zoneAs0 = new FixedZone(new String[]{"upload-as0.qiniup.com", "up-as0.qiniup.com"},
new String[]{"upload-as0.qbox.me", "up-as0.qbox.me"},
"as0");

/**
* FixedZone 构造方法
* regionId 参考链接:https://developer.qiniu.com/kodo/1671/region-endpoint-fq
*
* @param regionId 根据区域 ID 创建 Zone
* @return Zone 实例
*/
public static FixedZone createWithRegionId(String regionId) {
String[] upDomains = new String[]{
"upload-" + regionId + ".qiniup.com",
"up-" + regionId + ".qiniup.com"
};
return new FixedZone(upDomains, new String[]{}, regionId);
}

private ZonesInfo zonesInfo;

@Deprecated
public static FixedZone localsZoneInfo() {
FixedZone[] localsZone = new FixedZone[]{
(FixedZone) zone0, (FixedZone) zoneCnEast2,
Expand Down
24 changes: 19 additions & 5 deletions mvn_push.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ publishing {
artifactId = POM_ARTIFACT_ID
version = VERSION_NAME

afterEvaluate {
from components.release
artifacts {
artifact(androidSourcesJar)
artifact(androidJavadocsJar)
artifact("$buildDir/outputs/aar/${project.name}-release.aar")
}

artifact(androidSourcesJar)
artifact(androidJavadocsJar)

pom {
name = POM_NAME
Expand Down Expand Up @@ -97,6 +97,20 @@ publishing {
developerConnection=POM_SCM_DEV_CONNECTION
url=POM_SCM_URL
}

withXml {
def dependencies = asNode().appendNode("dependencies")

configurations
.getByName("releaseCompileClasspath")
.resolvedConfiguration
.firstLevelModuleDependencies.forEach {
def dependency = dependencies.appendNode("dependency")
dependency.appendNode("groupId", it.moduleGroup)
dependency.appendNode("artifactId", it.moduleName)
dependency.appendNode("version", it.moduleVersion)
}
}
}
}
}
Expand All @@ -117,5 +131,5 @@ publishing {

signing {
required { isReleaseBuild()}
sign publishing.publications.mavenJava
sign publishing.publications
}