Skip to content

Commit ee1a777

Browse files
update the addRepoActivity ,the repo name can be filled or not
1 parent 120ea01 commit ee1a777

5 files changed

Lines changed: 20 additions & 12 deletions

File tree

app/src/main/java/com/loopeer/codereader/ui/activity/AddRepoActivity.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import android.os.Bundle;
44
import android.text.Editable;
5+
import android.text.TextUtils;
56
import android.widget.Button;
67
import android.widget.EditText;
78

@@ -11,6 +12,7 @@
1112
import com.loopeer.codereader.ui.view.AddRepoChecker;
1213
import com.loopeer.codereader.ui.view.Checker;
1314
import com.loopeer.codereader.ui.view.TextWatcherImpl;
15+
import com.loopeer.codereader.utils.DownloadUrlParser;
1416
import com.loopeer.codereader.utils.FileCache;
1517

1618
import butterknife.BindView;
@@ -60,13 +62,21 @@ public void check(boolean b) {
6062
public void onClick() {
6163
hideSoftInputMethod();
6264

63-
Repo repo = new Repo(
64-
mAddRepoChecker.repoName.trim()
65-
, FileCache.getInstance().getRepoAbsolutePath(mAddRepoChecker.repoName)
66-
, mAddRepoChecker.repoDownloadUrl.trim()
67-
, true
68-
, 0);
69-
Navigator.startDownloadNewRepoService(this, repo);
65+
if (TextUtils.isEmpty(mAddRepoChecker.repoName)) {
66+
//未填写文件名则默认为项目原名
67+
if (!TextUtils.isEmpty(mAddRepoChecker.repoDownloadUrl.trim())
68+
&& !DownloadUrlParser.parseGithubUrlAndDownload(AddRepoActivity.this, mAddRepoChecker.repoDownloadUrl.trim())) {
69+
showMessage(getString(R.string.repo_download_url_parse_error));
70+
}
71+
} else {
72+
Repo repo = new Repo(
73+
mAddRepoChecker.repoName.trim()
74+
, FileCache.getInstance().getRepoAbsolutePath(mAddRepoChecker.repoName)
75+
, mAddRepoChecker.repoDownloadUrl.trim()
76+
, true
77+
, 0);
78+
Navigator.startDownloadNewRepoService(this, repo);
79+
}
7080
// this.finish();
7181

7282
}

app/src/main/java/com/loopeer/codereader/ui/activity/MainActivity.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@
4040

4141
public class MainActivity extends BaseActivity {
4242
private static final String TAG = "MainActivity";
43-
//TODO 下载项目的逻辑 kt版下载了两种
4443
//TODO 7.0fab动画
4544
//TODO 7.0不能解压
4645
//TODO 8.0不能下载
4746
//TODO 文件状态识别出错
48-
//TODO 下载页面的下载链接检查和可下载链接不匹配
4947

5048

5149
public static final int MY_PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 1000;

app/src/main/java/com/loopeer/codereader/ui/view/AddRepoChecker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ public void setRepoDownloadUrl(String repoDownloadUrl) {
2222

2323
@Override
2424
public boolean isEnable() {
25-
return !TextUtils.isEmpty(repoName) && !TextUtils.isEmpty(repoDownloadUrl);
25+
return !TextUtils.isEmpty(repoDownloadUrl);
2626
}
2727
}

app/src/main/res/values-zh/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<string name="web_url_input_hint">请输入网址</string>
4949

5050
<!-- add repo -->
51-
<string name="add_repo_name_hint">本地项目保存名称</string>
51+
<string name="add_repo_name_hint">本地项目保存名称,不填写则为默认名</string>
5252
<string name="add_repo_url_hint">项目的下载链接</string>
5353
<string name="add_repo_btn">下载</string>
5454

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<string name="web_url_input_hint">Please input url</string>
4949

5050
<!-- add repo -->
51-
<string name="add_repo_name_hint">Repo Name</string>
51+
<string name="add_repo_name_hint">Repo Name,Is The Default Name If Not Input </string>
5252
<string name="add_repo_url_hint">Repo Download Url</string>
5353
<string name="add_repo_btn">Download</string>
5454
<string name="error_invalid_email">This email address is invalid</string>

0 commit comments

Comments
 (0)