Skip to content

Commit

Permalink
Merge pull request #184 from camarm-dev/dev
Browse files Browse the repository at this point in the history
Version 1.2.3
  • Loading branch information
camarm-dev authored Jul 1, 2024
2 parents 5ae4cec + bdc6a76 commit 666fd84
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 21 deletions.
4 changes: 2 additions & 2 deletions app/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId "com.camarm.remede"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 122
versionName '1.2.2 — Brown Sheep, revison 2'
versionCode 123
versionName '1.2.3 — Brown Sheep, revison 3'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,55 @@
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

public class ActiveRemedeActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
CharSequence text = getIntent().getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT);
Boolean readonly = getIntent().getBooleanExtra(Intent.EXTRA_PROCESS_TEXT_READONLY, false);

String readonlyArg;

if (readonly) {
readonlyArg = "true";
} else {
readonlyArg = "false";
}

Uri page;
boolean endProcess;
if (text.toString().contains(" ") && text.charAt(0) != 'à') {
page = Uri.parse(getResources().getString(R.string.custom_url_scheme) + "://correction?data=" + text);
page = Uri.parse(getResources().getString(R.string.custom_url_scheme) + "://correction?data=" + text.toString().replaceAll("\n", "<newline>") + "&readonly=" + readonlyArg);
endProcess = false;
} else {
page = Uri.parse(getResources().getString(R.string.custom_url_scheme) + "://dictionnaire/" + text.toString().toLowerCase());
page = Uri.parse(getResources().getString(R.string.custom_url_scheme) + "://dictionnaire/" + text.toString().toLowerCase() + "?close=true");
endProcess = true;
}

Intent definitionIntent = new Intent(this, MainActivity.class)
.setData(page)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(definitionIntent);
.setData(page);
startActivityForResult(definitionIntent, 1);
if (endProcess) {
setResult(Activity.RESULT_OK);
finish();
}
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);

if (resultCode == RESULT_OK) {
String result = data.getStringExtra("com.camarm.remede.ACTIVE_REMEDE_RESULT");
Log.w("Active Remede", result);
Intent outgoingIntent = new Intent().putExtra(Intent.EXTRA_PROCESS_TEXT, result);
setResult(Activity.RESULT_OK, outgoingIntent);
finish();
}
}

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
package com.camarm.remede;

import android.os.Bundle;

import com.getcapacitor.BridgeActivity;

public class MainActivity extends BridgeActivity {}
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
registerPlugin(SetResult.class);
super.onCreate(savedInstanceState);
}
}
22 changes: 22 additions & 0 deletions app/android/app/src/main/java/com/camarm/remede/SetResult.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.camarm.remede;

import android.app.Activity;
import android.content.Intent;

import com.getcapacitor.Plugin;
import com.getcapacitor.PluginCall;
import com.getcapacitor.PluginMethod;
import com.getcapacitor.annotation.CapacitorPlugin;

@CapacitorPlugin(name = "SetResult")
public class SetResult extends Plugin {

@PluginMethod()
public void sendActiveRemedeResult(PluginCall call) {
String value = call.getString("value");

Intent returnIntent = new Intent().putExtra("com.camarm.remede.ACTIVE_REMEDE_RESULT", value).putExtra(Intent.EXTRA_PROCESS_TEXT, value);
getActivity().setResult(Activity.RESULT_OK, returnIntent);
getActivity().finish();
}
}
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "remede",
"private": true,
"version": "1.2.2",
"version": "1.2.3",
"type": "module",
"license": "Cecill V2.1",
"author": {
Expand Down
9 changes: 9 additions & 0 deletions app/src/functions/plugins/setResult.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { registerPlugin } from "@capacitor/core"

export interface SetResultPlugin {
sendActiveRemedeResult(options: { value: string }): Promise<void>;
}

const SetResult = registerPlugin<SetResultPlugin>("SetResult")

export default SetResult
44 changes: 39 additions & 5 deletions app/src/views/CorrectionPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,32 @@
Copier&nbsp;<ion-icon :icon="copyOutline"/>
</ion-button>
<ion-button color="success" @click="content = getPartiallyCorrectedContent(); locked = false">
Réutiliser&nbsp;<ion-icon :icon="chevronForwardOutline"/>
Recorriger&nbsp;<ion-icon :icon="chevronForwardOutline"/>
</ion-button>
</ion-buttons>
</ion-item>
</ion-list>

<div v-if="openedFromSelection && !loading && explainSegments.length > 0">
<div class="ion-padding">
<ion-button expand="block" @click="getBackToSelection()" color="primary">
<ion-icon :icon="returnUpBackOutline" class="ion-margin-end"/>
<span v-if="textSelectionReadOnly">Copier et retourner à l'application</span>
<span v-else>Retourner à l'application</span>
</ion-button>
</div>
<div class="ion-padding">
<ion-note v-if="textSelectionReadOnly">
<ion-icon :icon="informationCircleOutline"/>
Copie le texte corrigé et retourne à l'application précédente. Vous n'aurez plus qu'a coller le texte !
</ion-note>
<ion-note v-else>
<ion-icon :icon="informationCircleOutline"/>
Retourner à l'application utilisera le texte corrigé.
</ion-note>
</div>
</div>

<div class="ion-padding">
<ion-note>
Correction grâce à <a href="https://languagetool.org" target="_blank">Languagetool</a>, <i>hébergé par Remède</i>.
Expand Down Expand Up @@ -149,13 +170,14 @@ import {
pencilOutline,
sparkles,
closeOutline,
trashOutline, languageOutline
trashOutline, languageOutline, informationCircleOutline, returnUpBackOutline
} from "ionicons/icons"
</script>

<script lang="ts">
import { Clipboard } from "@capacitor/clipboard"
import {ExplainSegment, LanguageToolCorrection} from "@/functions/types/languagetool"
import SetResult from "@/functions/plugins/setResult"
export default {
data() {
Expand All @@ -167,18 +189,23 @@ export default {
explainSegments: [] as ExplainSegment[],
modalsOpenStates: {} as { [key: string]: any },
ignoredErrors: [] as any[],
pageElement: null as any
pageElement: null as any,
openedFromSelection: false,
textSelectionReadOnly: false
}
},
mounted() {
this.loadExceptions()
this.pageElement = this.$refs.page.$el
const url = new URLSearchParams(location.search)
const data = url.get("data")
const readonly = url.get("readonly")
if (data) {
const content = data.replaceAll("?data=", "")
this.content = content
const content = data
this.content = content.replaceAll("<newline>", "\n")
if (content != "") {
this.openedFromSelection = true
this.textSelectionReadOnly = readonly ? readonly == "true": false
this.correct()
}
}
Expand Down Expand Up @@ -218,6 +245,13 @@ export default {
saveExceptions() {
localStorage.setItem("correctionExceptions", JSON.stringify(this.ignoredErrors))
},
getBackToSelection() {
const result = this.getPartiallyCorrectedContent()
if (this.textSelectionReadOnly) {
this.copy(result)
}
SetResult.sendActiveRemedeResult({ value: result })
},
correct() {
this.loading = true
this.modalsOpenStates = {}
Expand Down
19 changes: 16 additions & 3 deletions app/src/views/WordModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
} from "@ionic/vue"
import {
bookmark,
bookmarkOutline,
bookmarkOutline, chevronBackOutline,
chevronDownOutline,
documentAttachOutline,
ellipsisVertical,
Expand All @@ -51,7 +51,11 @@ const closeModal = () => detailsModal.value.$el.dismiss(null, "cancel")
<ion-header :translucent="true">
<ion-toolbar>
<ion-buttons slot="start">
<ion-back-button text="Retour" default-href="/dictionnaire"></ion-back-button>
<ion-button @click="quitApp()" v-if="closeApp" size="small">
<ion-icon :icon="chevronBackOutline"/>
Retour à l'application
</ion-button>
<ion-back-button v-else text="Retour" default-href="/dictionnaire"></ion-back-button>
</ion-buttons>
<ion-title class="remede-font">{{ mot }}</ion-title>
<ion-buttons slot="end">
Expand Down Expand Up @@ -307,6 +311,7 @@ import "swiper/css"
import "swiper/css/pagination"
import "@ionic/vue/css/ionic-swiper.css"
import {generateId} from "@/functions/id"
import {App} from "@capacitor/app"
export default defineComponent({
Expand Down Expand Up @@ -343,7 +348,8 @@ export default defineComponent({
console.log(path)
} as (path: string) => void,
el: null as any,
loading: false
loading: false,
closeApp: false
}
},
mounted() {
Expand All @@ -355,6 +361,10 @@ export default defineComponent({
this.el = ref(this.$el)
this.goTo = goTo as (path: string) => void
const url = new URLSearchParams(location.search)
const data = url.get("close")
this.closeApp = data ? data == "true": false
},
created() {
this.loading = true
Expand All @@ -367,6 +377,9 @@ export default defineComponent({
})
},
methods: {
quitApp() {
App.exitApp()
},
async loadData(mot: null | string) {
this.mot = mot || this.motRemede
if (!this.mot) {
Expand Down
2 changes: 1 addition & 1 deletion docs/download.html
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ <h1 class="title no-mg is-large has-text-dark">
<td><span class="tag">1.2.2 </span></td>
<td>15/06/24</td>
<td>5.5MB</td>
<td><a class="button is-small" href="https://api-remede.camarm.fr/release/apk" download="remede.apk">Download</a></td>
<td><a class="button is-small" href="https://api-remede.camarm.fr/release/apk?cache=no" download="remede.apk">Download</a></td>
</tr>
<tr>
<td>Windows</td>
Expand Down
11 changes: 8 additions & 3 deletions scripts/check_wordlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from bs4 import BeautifulSoup
import requests

from generate_index import sanitize_word


def get_phoneme(word: str):
result = requests.get(f'https://fr.wiktionary.org/wiki/{word}').content
Expand All @@ -12,22 +14,25 @@ def get_phoneme(word: str):


def iterate():
result = ""
result = []
total = len(TO_CHECK)
for word in TO_CHECK:
print(f"\033[A\033[KMot {TO_CHECK.index(word)}/{total} | Mot \"{word}\"")
if word in WORDLIST:
continue
try:
phoneme = get_phoneme(word)
result += f"{word}\t{phoneme}\n"
result.append(f"{word}\t{phoneme}")
except KeyboardInterrupt:
print("Exiting")
exit()
except:
continue
with open('.words_to_add', 'w+') as file:
file.write(result)
print(f"Sorting in alphabetic order...")
result.sort(key=lambda val: sanitize_word(val))
print(f"Saving {len(result)} new entries...")
file.write("\n".join(result))


def getTimeDetails(time_object):
Expand Down

0 comments on commit 666fd84

Please sign in to comment.