Skip to content

Commit b623da9

Browse files
authored
Add files via upload
1 parent cf93700 commit b623da9

File tree

2 files changed

+155
-0
lines changed

2 files changed

+155
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package com.v2ray.ang.helper;
2+
3+
import androidx.annotation.NonNull;
4+
import androidx.appcompat.app.ActionBar;
5+
import androidx.appcompat.app.AppCompatActivity;
6+
7+
import android.content.Context;
8+
import android.os.Bundle;
9+
import android.view.MenuItem;
10+
import android.widget.TextView;
11+
12+
import com.v2ray.ang.R;
13+
14+
import java.io.InputStreamReader;
15+
import java.io.Reader;
16+
17+
public class GFW_privacy_policy_Activity extends AppCompatActivity {
18+
19+
@Override
20+
protected void onCreate(Bundle savedInstanceState) {
21+
super.onCreate(savedInstanceState);
22+
setContentView(R.layout.activity_gfw_privacy_policy);
23+
24+
25+
ActionBar actionBar = getSupportActionBar();
26+
if(actionBar!=null) {
27+
actionBar.setDisplayHomeAsUpEnabled(true);
28+
}
29+
30+
31+
TextView tv = (TextView) findViewById(R.id.textView_privacy_policy);
32+
33+
String tmp = fetch_text_file_from_asset(GFW_privacy_policy_Activity.this);
34+
tv.setText(tmp);
35+
36+
37+
}
38+
39+
40+
41+
42+
43+
// read text file from asset
44+
private String fetch_text_file_from_asset(Context ctx){
45+
try {
46+
47+
int bufferSize = 4096;
48+
char[] buffer = new char[bufferSize];
49+
StringBuilder sb = new StringBuilder();
50+
Reader in = new InputStreamReader(ctx.getAssets().open("privacy_policy.txt"));
51+
for (int numRead; (numRead = in.read(buffer, 0, buffer.length)) > 0; ) {
52+
sb.append(buffer, 0, numRead);
53+
}
54+
in.close();
55+
return sb.toString();
56+
57+
}catch(Exception e){
58+
System.out.println("file reading ERR: "+e.getMessage());
59+
return "";
60+
}
61+
}
62+
63+
64+
@Override
65+
public boolean onOptionsItemSelected(@NonNull MenuItem item){
66+
if (item.getItemId() == android.R.id.home) {
67+
this.finish();
68+
return true;
69+
}
70+
return super.onOptionsItemSelected(item);
71+
}
72+
73+
74+
75+
76+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package com.v2ray.ang.helper;
2+
3+
import androidx.annotation.NonNull;
4+
import androidx.appcompat.app.ActionBar;
5+
import androidx.appcompat.app.AppCompatActivity;
6+
7+
import android.content.Context;
8+
import android.os.Bundle;
9+
import android.os.TestLooperManager;
10+
import android.view.MenuItem;
11+
import android.widget.TextView;
12+
13+
import com.v2ray.ang.R;
14+
15+
import java.io.BufferedReader;
16+
import java.io.InputStream;
17+
import java.io.InputStreamReader;
18+
import java.io.Reader;
19+
import java.nio.charset.StandardCharsets;
20+
21+
public class GFW_terms_service_Activity extends AppCompatActivity {
22+
23+
@Override
24+
protected void onCreate(Bundle savedInstanceState) {
25+
super.onCreate(savedInstanceState);
26+
setContentView(R.layout.activity_gfw_terms_service);
27+
28+
29+
ActionBar actionBar = getSupportActionBar();
30+
if(actionBar!=null) {
31+
actionBar.setDisplayHomeAsUpEnabled(true);
32+
}
33+
34+
35+
TextView tv = (TextView) findViewById(R.id.textView_terms_service);
36+
37+
String tmp = fetch_text_file_from_asset(GFW_terms_service_Activity.this);
38+
tv.setText(tmp);
39+
40+
41+
}
42+
43+
44+
45+
46+
47+
48+
// read text file from asset
49+
private String fetch_text_file_from_asset(Context ctx){
50+
try {
51+
52+
int bufferSize = 4096;
53+
char[] buffer = new char[bufferSize];
54+
StringBuilder sb = new StringBuilder();
55+
Reader in = new InputStreamReader(ctx.getAssets().open("terms_of_service.txt"));
56+
for (int numRead; (numRead = in.read(buffer, 0, buffer.length)) > 0; ) {
57+
sb.append(buffer, 0, numRead);
58+
}
59+
in.close();
60+
return sb.toString();
61+
62+
}catch(Exception e){
63+
System.out.println("file reading ERR: "+e.getMessage());
64+
return "";
65+
}
66+
}
67+
68+
69+
@Override
70+
public boolean onOptionsItemSelected(@NonNull MenuItem item){
71+
if (item.getItemId() == android.R.id.home) {
72+
this.finish();
73+
return true;
74+
}
75+
return super.onOptionsItemSelected(item);
76+
}
77+
78+
79+
}

0 commit comments

Comments
 (0)