Skip to content

Commit ab4653e

Browse files
committed
update: add mirror page
1 parent f3233f4 commit ab4653e

File tree

8 files changed

+166
-50
lines changed

8 files changed

+166
-50
lines changed

.gitignore

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
1-
# Compiled class file
2-
*.class
3-
4-
# Log file
5-
*.log
6-
7-
# BlueJ files
8-
*.ctxt
9-
10-
# Mobile Tools for Java (J2ME)
11-
.mtj.tmp/
12-
13-
# Package Files #
14-
*.jar
15-
*.war
16-
*.nar
17-
*.ear
18-
*.zip
19-
*.tar.gz
20-
*.rar
21-
22-
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23-
hs_err_pid*
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
/.idea/navEditor.xml
9+
/.idea/assetWizardSettings.xml
10+
.DS_Store
11+
/build
12+
/captures
13+
.externalNativeBuild
14+
.cxx
15+
local.properties
16+
app/release/

README.md

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,92 @@
1-
# android-book
2-
نسخه وب اپلیکیشن کتاب زبان گو فارسی اندروید
1+
# WebView
2+
3+
4+
5+
## Getting started
6+
7+
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
8+
9+
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
10+
11+
## Add your files
12+
13+
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
14+
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
15+
16+
```
17+
cd existing_repo
18+
git remote add origin https://gitlab.com/bootiyar_work/personal/webview.git
19+
git branch -M main
20+
git push -uf origin main
21+
```
22+
23+
## Integrate with your tools
24+
25+
- [ ] [Set up project integrations](https://gitlab.com/bootiyar_work/personal/webview/-/settings/integrations)
26+
27+
## Collaborate with your team
28+
29+
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
30+
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
31+
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
32+
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
33+
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
34+
35+
## Test and Deploy
36+
37+
Use the built-in continuous integration in GitLab.
38+
39+
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
40+
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
41+
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
42+
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
43+
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
44+
45+
***
46+
47+
# Editing this README
48+
49+
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
50+
51+
## Suggestions for a good README
52+
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
53+
54+
## Name
55+
Choose a self-explaining name for your project.
56+
57+
## Description
58+
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
59+
60+
## Badges
61+
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
62+
63+
## Visuals
64+
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
65+
66+
## Installation
67+
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
68+
69+
## Usage
70+
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
71+
72+
## Support
73+
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
74+
75+
## Roadmap
76+
If you have ideas for releases in the future, it is a good idea to list them in the README.
77+
78+
## Contributing
79+
State if you are open to contributions and what your requirements are for accepting them.
80+
81+
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
82+
83+
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
84+
85+
## Authors and acknowledgment
86+
Show your appreciation to those who have contributed to the project.
87+
88+
## License
89+
For open source projects, say how it is licensed.
90+
91+
## Project status
92+
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ android {
1010
applicationId "com.gofarsi.book"
1111
minSdk 21
1212
targetSdk 32
13-
versionCode 1
14-
versionName "1.0.0"
13+
versionCode 3
14+
versionName "1.0.2"
1515

1616
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1717
}

app/release/gofarsi_1.0.2_3.apk

4.21 MB
Binary file not shown.

app/release/output-metadata.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
"type": "SINGLE",
1212
"filters": [],
1313
"attributes": [],
14-
"versionCode": 1,
15-
"versionName": "1.0.0",
14+
"versionCode": 3,
15+
"versionName": "1.0.2",
1616
"outputFile": "app-release.apk"
1717
}
1818
],

app/src/main/java/com/book/gofarsi/WebActivity.kt

Lines changed: 51 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ package com.book.gofarsi
22

33
import android.content.Context
44
import android.content.Intent
5+
import android.graphics.Bitmap
6+
import android.net.Uri
57
import android.os.Build
68
import android.os.Bundle
7-
import android.os.Handler
8-
import android.os.Looper
9+
import android.util.Log
910
import android.view.View
10-
import android.webkit.CookieManager
11-
import android.webkit.WebSettings
12-
import android.webkit.WebView
13-
import android.webkit.WebViewClient
11+
import android.webkit.*
1412
import android.widget.RelativeLayout
1513
import android.widget.TextView
1614
import androidx.appcompat.app.AppCompatActivity
@@ -19,7 +17,11 @@ import androidx.appcompat.app.AppCompatActivity
1917
//import org.jsoup.Jsoup
2018

2119
class WebActivity : AppCompatActivity() {
22-
var myWebView :WebView? = null;
20+
var myWebView: WebView? = null
21+
private val list = arrayListOf("https://book.gofarsi.ir/", "https://book.ir1.gofarsi.ir/", "https://ipfs-book.gofarsi.ir/", "https://book.m1.gofarsi.ir/")
22+
var urlIndex = 0
23+
var hasErrorInLoading = false
24+
var currentUrl = ""
2325
override fun onCreate(savedInstanceState: Bundle?) {
2426
super.onCreate(savedInstanceState)
2527
setContentView(R.layout.activity_web)
@@ -29,16 +31,51 @@ class WebActivity : AppCompatActivity() {
2931
var title = intent.extras?.getString(KEY_TITLE) ?: ""
3032
var link = intent.extras?.getString(KEY_LINK) ?: ""
3133

32-
link = "https://book.gofarsi.ir/"
34+
link = list[urlIndex]
3335

3436
findViewById<TextView>(R.id.tvVersion).text = BuildConfig.VERSION_NAME
3537
myWebView = findViewById(R.id.webview);
3638
loadWebView(this, link, myWebView!!)
37-
var view = findViewById<RelativeLayout>(R.id.loading)
38-
Handler(Looper.getMainLooper()).postDelayed({
39-
view.visibility = View.INVISIBLE
40-
}, 5000)
39+
myWebView?.webViewClient = object : WebViewClient() {
40+
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
41+
Log.d("bootiyar", url)
42+
if (!url.contains("gofarsi.ir")) {
43+
loadBrowser(url)
44+
return true
45+
}
46+
return false
47+
}
48+
49+
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
50+
super.onPageStarted(view, url, favicon)
51+
Log.d("bootiyar", "onPageStarted: $url")
52+
hasErrorInLoading = false
53+
}
54+
55+
override fun onReceivedError(view: WebView?, request: WebResourceRequest?, error: WebResourceError?) {
56+
Log.d("bootiyar", "onReceivedError")
57+
super.onReceivedError(view, request, error)
58+
hasErrorInLoading = true
59+
if (urlIndex == 3) return
60+
myWebView?.loadUrl(list[++urlIndex])
61+
}
62+
63+
override fun onPageFinished(view: WebView?, url: String?) {
64+
super.onPageFinished(view, url)
65+
currentUrl = url ?: ""
66+
if (!hasErrorInLoading) findViewById<RelativeLayout>(R.id.loading).visibility = View.INVISIBLE
67+
Log.d("bootiyar", "onPageFinished: $url")
68+
}
4169

70+
}
71+
72+
}
73+
74+
75+
fun loadBrowser(url:String){
76+
val uri: Uri = Uri.parse(url)
77+
val intent = Intent(Intent.ACTION_VIEW, uri)
78+
startActivity(intent)
4279
}
4380

4481

@@ -96,16 +133,12 @@ class WebActivity : AppCompatActivity() {
96133
}
97134
it.settings?.pluginState = WebSettings.PluginState.ON
98135
}
99-
myWebView.webViewClient = object : WebViewClient() {
100-
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
101-
return false
102-
}
103-
}
104136
}
105137
}
106138

139+
107140
override fun onBackPressed() {
108-
if (myWebView?.canGoBack() == true) {
141+
if (myWebView?.canGoBack() == true && currentUrl != list[urlIndex]) {
109142
myWebView?.goBack()
110143
} else {
111144
super.onBackPressed()

app/src/main/res/layout/activity_web.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
android:layout_width="match_parent"
4-
android:layout_height="match_parent">
4+
android:layout_height="match_parent"
5+
android:background="@color/white">
56

67
<WebView
78
android:id="@+id/webview"
89
android:layout_width="match_parent"
9-
android:layout_height="match_parent"
10-
android:layout_margin="4dp" />
10+
android:layout_height="match_parent" />
1111

1212

1313
<RelativeLayout

gradle/wrapper/gradle-wrapper.jar

57.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)