Skip to content

Commit 794dacc

Browse files
committed
Revert "Merge branch 'main' of https://github.com/Aglag257/Android"
This reverts commit ae44302, reversing changes made to a1febbe.
1 parent ae44302 commit 794dacc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+138
-399
lines changed

.github/workflows/android.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
build:
3030
runs-on: ubuntu-latest
3131
steps:
32-
- uses: actions/[email protected].6
32+
- uses: actions/[email protected].5
3333
- name: Fail on bad translations
3434
run: if grep -ri "<xliff" app/src/main/res/values*/strings.xml; then echo "Invalidly escaped translations found"; exit 1; fi
3535
- uses: gradle/actions/wrapper-validation@v3

.github/workflows/changelog-to-fastlane.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
steps:
2828
- name: Checkout repo
2929
id: checkout
30-
uses: actions/[email protected].6
30+
uses: actions/[email protected].5
3131
- name: Setup Python
3232
uses: actions/[email protected]
3333
with:

.github/workflows/contributors-to-file.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
steps:
2626
- name: Checkout repo
2727
id: checkout
28-
uses: actions/[email protected].6
28+
uses: actions/[email protected].5
2929
- name: Update contributors
3030
id: update_contributors
3131
uses: TheLastProject/[email protected]

.github/workflows/generate-feature-graphic.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
generate-feature-graphic:
2525
runs-on: ubuntu-latest
2626
steps:
27-
- uses: actions/[email protected].6
27+
- uses: actions/[email protected].5
2828
- name: Install requirements
2929
run: |
3030
sudo apt-get update

.github/workflows/gradle-update.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
gradle-update:
2222
runs-on: ubuntu-latest
2323
steps:
24-
- uses: actions/[email protected].6
24+
- uses: actions/[email protected].5
2525
- uses: obfusk/[email protected]
2626
id: gradle-update
2727
- uses: gradle/actions/wrapper-validation@v3

.github/workflows/update-locales.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
update-locales:
2626
runs-on: ubuntu-latest
2727
steps:
28-
- uses: actions/[email protected].6
28+
- uses: actions/[email protected].5
2929
- name: Add new locales
3030
run: .scripts/new-locales.py
3131
- name: Update locales

.scripts/locales.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
]
2525
subprocess.run(sed, check=True)
2626

27-
with open("app/src/main/res/xml/locales_config.xml", "w", encoding="utf-8") as fh:
27+
with open("app/src/main/res/xml/locales_config.xml", "w") as fh:
2828
fh.write('<?xml version="1.0" encoding="utf-8"?>\n')
2929
fh.write('<locale-config xmlns:android="http://schemas.android.com/apk/res/android">\n')
3030
fh.write(' <locale android:name="en-US" />\n')

.scripts/new-locales.py

+10-22
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,15 @@
1919
STATS_URL = "https://hosted.weblate.org/api/components/catima/catima/statistics/"
2020

2121

22-
class Error(Exception):
23-
pass
24-
25-
2622
def get_weblate_langs() -> List[Tuple[str, int]]:
27-
url = STATS_URL
23+
r = requests.get(STATS_URL, timeout=5)
24+
r.raise_for_status()
2825
results = []
29-
for _ in range(16): # avoid endless loops just in case
30-
r = requests.get(url, timeout=5)
31-
r.raise_for_status()
32-
data = r.json()
33-
for lang in data["results"]:
34-
if lang["code"] != "en":
35-
code = REPLACE_CODES.get(lang["code"], lang["code"]).replace("_", "-r")
36-
results.append((code, round(lang["translated_percent"])))
37-
url = data["next"]
38-
if not url:
39-
return sorted(results)
40-
if not url.split("?")[0] == STATS_URL:
41-
raise Error(f"Unexpected next URL: {url}")
42-
raise Error("Too many pages")
26+
for lang in r.json()["results"]:
27+
if lang["code"] != "en":
28+
code = REPLACE_CODES.get(lang["code"], lang["code"]).replace("_", "-r")
29+
results.append((code, round(lang["translated_percent"])))
30+
return sorted(results)
4331

4432

4533
def get_dir_langs() -> List[str]:
@@ -54,7 +42,7 @@ def get_dir_langs() -> List[str]:
5442
def get_xml_langs() -> List[Tuple[str, bool]]:
5543
results = []
5644
in_section = False
57-
with open("app/src/main/res/values/settings.xml", encoding="utf-8") as fh:
45+
with open("app/src/main/res/values/settings.xml") as fh:
5846
for line in fh:
5947
if not in_section and 'name="locale_values"' in line:
6048
in_section = True
@@ -71,7 +59,7 @@ def get_xml_langs() -> List[Tuple[str, bool]]:
7159
def update_xml_langs(langs: List[Tuple[str, bool]]) -> None:
7260
lines: List[str] = []
7361
in_section = False
74-
with open("app/src/main/res/values/settings.xml", encoding="utf-8") as fh:
62+
with open("app/src/main/res/values/settings.xml") as fh:
7563
for line in fh:
7664
if not in_section and 'name="locale_values"' in line:
7765
in_section = True
@@ -82,7 +70,7 @@ def update_xml_langs(langs: List[Tuple[str, bool]]) -> None:
8270
else:
8371
continue
8472
lines.append(line)
85-
with open("app/src/main/res/values/settings.xml", "w", encoding="utf-8") as fh:
73+
with open("app/src/main/res/values/settings.xml", "w") as fh:
8674
for line in lines:
8775
fh.write(line)
8876

CHANGELOG.md

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
# Changelog
22

3-
## Unreleased - 136
4-
5-
- Support for creating a card when sharing plain text
6-
- Display image type instead of barcode below images
7-
- Fix possible crash when trying to import a backup from the Nextcloud app
8-
- Improved support for devices without camera
9-
10-
## v2.29.1 - 135 (2024-05-19)
3+
## Unreleased - 135
114

125
- Various fixes and improvements to balance handling
136

Gemfile.lock

+9-11
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ GEM
1010
artifactory (3.0.17)
1111
atomos (0.1.3)
1212
aws-eventstream (1.3.0)
13-
aws-partitions (1.931.0)
14-
aws-sdk-core (3.196.1)
13+
aws-partitions (1.916.0)
14+
aws-sdk-core (3.192.1)
1515
aws-eventstream (~> 1, >= 1.3.0)
1616
aws-partitions (~> 1, >= 1.651.0)
1717
aws-sigv4 (~> 1.8)
1818
jmespath (~> 1, >= 1.6.1)
19-
aws-sdk-kms (1.81.0)
20-
aws-sdk-core (~> 3, >= 3.193.0)
19+
aws-sdk-kms (1.79.0)
20+
aws-sdk-core (~> 3, >= 3.191.0)
2121
aws-sigv4 (~> 1.1)
22-
aws-sdk-s3 (1.151.0)
23-
aws-sdk-core (~> 3, >= 3.194.0)
22+
aws-sdk-s3 (1.147.0)
23+
aws-sdk-core (~> 3, >= 3.192.0)
2424
aws-sdk-kms (~> 1)
2525
aws-sigv4 (~> 1.8)
2626
aws-sigv4 (1.8.0)
@@ -157,7 +157,7 @@ GEM
157157
mini_magick (4.12.0)
158158
mini_mime (1.1.5)
159159
multi_json (1.15.0)
160-
multipart-post (2.4.1)
160+
multipart-post (2.4.0)
161161
nanaimo (0.3.0)
162162
naturally (2.2.1)
163163
nkf (0.2.0)
@@ -171,8 +171,7 @@ GEM
171171
trailblazer-option (>= 0.1.1, < 0.2.0)
172172
uber (< 0.2.0)
173173
retriable (3.1.2)
174-
rexml (3.2.8)
175-
strscan (>= 3.0.9)
174+
rexml (3.2.6)
176175
rouge (2.0.7)
177176
ruby2_keywords (0.0.5)
178177
rubyzip (2.3.2)
@@ -185,7 +184,6 @@ GEM
185184
simctl (1.6.10)
186185
CFPropertyList
187186
naturally
188-
strscan (3.1.0)
189187
terminal-notifier (2.0.0)
190188
terminal-table (3.0.2)
191189
unicode-display_width (>= 1.1.1, < 3)
@@ -216,4 +214,4 @@ DEPENDENCIES
216214
fastlane
217215

218216
BUNDLED WITH
219-
2.5.9
217+
2.3.26

app/build.gradle.kts

+12-4
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ android {
2121
applicationId = "me.hackerchick.catima"
2222
minSdk = 21
2323
targetSdk = 34
24-
versionCode = 135
25-
versionName = "2.29.1"
24+
versionCode = 134
25+
versionName = "2.29.0"
2626

2727
vectorDrawables.useSupportLibrary = true
2828
multiDexEnabled = true
@@ -87,7 +87,7 @@ android {
8787
dependencies {
8888

8989
// AndroidX
90-
implementation("androidx.appcompat:appcompat:1.7.0")
90+
implementation("androidx.appcompat:appcompat:1.6.1")
9191
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
9292
implementation("androidx.exifinterface:exifinterface:1.3.7")
9393
implementation("androidx.palette:palette:1.0.0")
@@ -112,7 +112,15 @@ dependencies {
112112
// Testing
113113
testImplementation("androidx.test:core:1.5.0")
114114
testImplementation("junit:junit:4.13.2")
115-
testImplementation("org.robolectric:robolectric:4.12.2")
115+
testImplementation("org.robolectric:robolectric:4.12.1")
116+
117+
// Mockito
118+
testImplementation 'org.mockito:mockito-core:4.0.0'
119+
// Android Testing Support Library
120+
androidTestImplementation 'androidx.test:runner:1.4.0'
121+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
122+
// For Parcel
123+
androidTestImplementation 'androidx.test:core:1.4.0'
116124
}
117125

118126
tasks.withType<SpotBugsTask>().configureEach {
+1-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<resources>
3-
<string name="app_name">Catima 除錯版</string>
4-
</resources>
2+
<resources></resources>

app/src/main/AndroidManifest.xml

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<uses-feature
1818
android:name="android.hardware.camera"
19-
android:required="false" />
19+
android:required="true" />
2020
<uses-feature
2121
android:name="android.hardware.camera.autofocus"
2222
android:required="false" />
@@ -43,7 +43,6 @@
4343
<action android:name="android.intent.action.SEND" />
4444

4545
<category android:name="android.intent.category.DEFAULT" />
46-
<data android:mimeType="text/plain" />
4746
<data android:mimeType="image/*" />
4847
<data android:mimeType="application/pdf" />
4948
</intent-filter>

app/src/main/java/protect/card_locker/CatimaCaptureManager.java

+5-7
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,22 @@
44
import android.content.Context;
55
import android.widget.Toast;
66

7-
import androidx.core.util.Consumer;
8-
97
import com.journeyapps.barcodescanner.CaptureManager;
108
import com.journeyapps.barcodescanner.DecoratedBarcodeView;
119

1210
public class CatimaCaptureManager extends CaptureManager {
13-
private final Consumer<String> mErrorCallback;
11+
private final Context mContext;
1412

15-
public CatimaCaptureManager(Activity activity, DecoratedBarcodeView barcodeView, Consumer<String> errorCallback) {
13+
public CatimaCaptureManager(Activity activity, DecoratedBarcodeView barcodeView) {
1614
super(activity, barcodeView);
1715

18-
mErrorCallback = errorCallback;
16+
mContext = activity.getApplicationContext();
1917
}
2018

2119
@Override
2220
protected void displayFrameworkBugMessageAndExit(String message) {
2321
// We don't want to exit, as we also have a enter from card image and add manually button here
24-
// So, instead, we call our error callback
25-
mErrorCallback.accept(message);
22+
// So we show a toast instead
23+
Toast.makeText(mContext, message, Toast.LENGTH_LONG).show();
2624
}
2725
}

app/src/main/java/protect/card_locker/ImportExportActivity.java

+17-30
Original file line numberDiff line numberDiff line change
@@ -80,21 +80,15 @@ protected void onCreate(Bundle savedInstanceState) {
8080
Log.e(TAG, "Activity returned NULL uri");
8181
return;
8282
}
83-
// Running this in a thread prevents Android from throwing a NetworkOnMainThreadException for large files
84-
// FIXME: This is still suboptimal, because showing that the export started is delayed until the network request finishes
85-
new Thread() {
86-
@Override
87-
public void run() {
88-
try {
89-
OutputStream writer = getContentResolver().openOutputStream(uri);
90-
Log.d(TAG, "Starting file export with: " + result);
91-
startExport(writer, uri, exportPassword.toCharArray(), true);
92-
} catch (IOException e) {
93-
Log.e(TAG, "Failed to export file: " + result, e);
94-
onExportComplete(new ImportExportResult(ImportExportResultType.GenericFailure, result.toString()), uri);
95-
}
96-
}
97-
}.start();
83+
try {
84+
OutputStream writer = getContentResolver().openOutputStream(uri);
85+
Log.e(TAG, "Starting file export with: " + result.toString());
86+
startExport(writer, uri, exportPassword.toCharArray(), true);
87+
} catch (IOException e) {
88+
Log.e(TAG, "Failed to export file: " + result.toString(), e);
89+
onExportComplete(new ImportExportResult(ImportExportResultType.GenericFailure, result.toString()), uri);
90+
}
91+
9892
});
9993
fileOpenLauncher = registerForActivityResult(new ActivityResultContracts.GetContent(), result -> {
10094
if (result == null) {
@@ -166,21 +160,14 @@ public void run() {
166160
}
167161

168162
private void openFileForImport(Uri uri, char[] password) {
169-
// Running this in a thread prevents Android from throwing a NetworkOnMainThreadException for large files
170-
// FIXME: This is still suboptimal, because showing that the import started is delayed until the network request finishes
171-
new Thread() {
172-
@Override
173-
public void run() {
174-
try {
175-
InputStream reader = getContentResolver().openInputStream(uri);
176-
Log.d(TAG, "Starting file import with: " + uri);
177-
startImport(reader, uri, importDataFormat, password, true);
178-
} catch (IOException e) {
179-
Log.e(TAG, "Failed to import file: " + uri, e);
180-
onImportComplete(new ImportExportResult(ImportExportResultType.GenericFailure, e.toString()), uri, importDataFormat);
181-
}
182-
}
183-
}.start();
163+
try {
164+
InputStream reader = getContentResolver().openInputStream(uri);
165+
Log.e(TAG, "Starting file import with: " + uri.toString());
166+
startImport(reader, uri, importDataFormat, password, true);
167+
} catch (IOException e) {
168+
Log.e(TAG, "Failed to import file: " + uri.toString(), e);
169+
onImportComplete(new ImportExportResult(ImportExportResultType.GenericFailure, e.toString()), uri, importDataFormat);
170+
}
184171
}
185172

186173
private void chooseImportType(boolean choosePicker,

app/src/main/java/protect/card_locker/LoyaltyCard.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,4 @@ public LoyaltyCard[] newArray(int size) {
215215
return new LoyaltyCard[size];
216216
}
217217
};
218-
}
218+
}

0 commit comments

Comments
 (0)