Background
I needed to develop a function for dynamically loading HTML5 websites that matched the system language. The website internationalization in my project was implemented by dynamically loading URLs. For example, if the system language of a mobile phone is Japanese, the URLs of web pages in Japanese are loaded. For simplified Chinese, those in simplified Chinese are loaded, and for English, those in English are loaded, and so on. Here, I have listed the steps for your reference.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Solution
Step 1: Bind a variable.
Bind a variable to the src attribute of the web component, to ensure that the attribute will not have a fixed value. In the following code, loadUrl in {{}} is a bound variable. It is defined under script in the UX file. You can skip this step if your project was created using the HTML5 template in Huawei Quick App IDE, downloaded from https://developer.huawei.com/consumer/en/doc/development/quickApp-Guides/quickapp-installtool, because the variable will be bound by the template code.
JavaScript:
<!-- template -->
<web src="{{loadUrl}}"
</web>
<!-- script -->
export default {
data: {
loadUrl: "https://transit.navitime.com/en",
},
Step 2: Initialize the variable.
Use the onInit() method in the quick app’s lifecycle to call the device API to obtain the system language and load the HTML5 page in the obtained language.
JavaScript:
onInit: function () {
const device = require("@system.device")
const res = device.getInfoSync();
let local = res.language; //system language
let region = res.region; //system region
console.info('onInit :localole= ' + local + ", region=" + region);
if (local === 'zh') {
if (region === "CN") {
this.loadUrl = "https://transit.navitime.com/zh-cn/";
} else if (region === "TW") {
this.loadUrl = "https://transit.navitime.com/zh-tw/";
}
} else if (local === 'ja') {
this.loadUrl = "https://transit.navitime.com/ja/?from=huawei.quickapp";
} else {
// For other languages, the HTML5 page in the default language is used.
this.loadUrl = "https://transit.navitime.com/en";
}
},
Step 3: Add a listener for system language switch.
Perform this step if you want the language on the HTML5 page to change accordingly, as the user changes the system language when the HTML5 quick app is running. You can skip this step if you don’t need to implement this function. The user can simply exit the app and re-enter it.
The code for adding a listener to listen to the system language switch is as follows:
JavaScript:
onConfigurationChanged(object) {
console.log("onConfigurationChanged object=" + JSON.stringify(object));
if (object.type === "locale") {
const configuration=require("@system.configuration")
var localeObject = configuration.getLocale();
let local= localeObject.language;
let region= localeObject.countryOrRegion;
console.info(onConfigurationChanged(object :localole= ' + local + ", region=" + region);
if (local === 'zh') {
if (region === "CN") {
this.loadUrl = "https://transit.navitime.com/zh-cn/";
} else if (region === "TW") {
this.loadUrl = "https://transit.navitime.com/zh-tw/";
}
} else if (local === 'ja') {
this.loadUrl = "https://transit.navitime.com/ja/?from=huawei.quickapp";
} else {
// For other languages, the HTML5 page in the default language is used.
this.loadUrl = "https://transit.navitime.com/en";
}
}
},
Summary
I hope you’ll find this post helpful, when planning the global release of your HTML5 quick app. Feel free to leave a question or comment below, to share your own experiences.
Impressive
Will help HTML5 developers for developing on huawei.
Hi there, i have entered the pixel 5 giveaway. Thank you for this chance XDA developers and Huawei team. Miss honor and Huawei phones in India.
Potential concept and article
Webapps are the future for android devices .
Related
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Dear XDA developers,
I've spent the last hours to develop a small Java Application (actually my first pure java app) that parses your Checkout Orders and then displays you your customer's countries, spoken languages or gender. And because XDA is awesome, I want to share it with you ;-)
Usage:
Countries:
Code:
java -jar StatMaker.jar country [yourCSV]
Languages:
Code:
java -jar StatMaker.jar lang [yourCSV] [languageCsvFile]
Gender:
Code:
java -jar StatMaker.jar gend [yourCSV] [genderCsvFile] [genderFile]
Output:
It will either print you some errors if something went wrong and/or will print you the data in CSV format. If you are collecting Language Date and the country is not saved in the languageCsvFile yet, it will ask you for the language of that country. Enter it and confirm with Enter.
Also the Gender output has an entry called "interpolated"; If true, this means that there are some unisex names and therefore these ones were interpolated.
You should run the app once and if the data looks good you can export the output to a CSV file on Unix/Linux with
Code:
java -jar StatMaker.jar [paramtersYouUsed] > /a/file.csv
Parameters:
yourCSV: Download your Orders as a CSV from Google Checkout (Archive/Download), make sure your language is set to english, I guess the row names will differ with other languages. Also make sure you tick the "Additional buyer info" checkbox. I recommend only downloading charged orders. Refunded orders are ignored by default in the app.
languageCsvFile: Point to the attached languages.csv. If the file does not exist, a new one will be created (but then you have to enter all languages again)
genderCsvFile: Just point anywhere: A new file will be created to store your used names (that will speed up looking up names).
genderFile: Point to the included nam_dict file. This file contains about 40.000 first names.
Like I said, I wrote this app within a few hours, so don't expect a high quality app. It just does what it says and will crash if anything goes wrong. Also there are no comments or whatsoever in the source code (included). Also, this app does not have a good coding style. It works, but it is not pretty.
How can I help?
If you have many orders, please share your language file with us, as currently there aren't many countries included.
You could grab the source code and add more functions or create a GUI
I don't want donations or anything, but if you want to support me, you could try my App "SMS, my Car and Me" ;-)
Examples:
Code:
java -jar StatMaker.jar gend /home/force/CheckoutStats.csv /home/force/names.csv /home/force/nam_dict
Code:
Language,Value
male,725
female,242
interpolated,true
Code:
java -jar StatMaker.jar lang /home/force/CheckoutStats.csv /home/force/languages.csv
Code:
Language,Value
Arabic,5
Bosnian,2
Czech,8
Danish,9
English,499
Finnish,2
French,12
German,346
Greek,3
Hungarian,1
Indian,19
Indonesian,1
Italian,3
Norge,4
Polish,1
Portuguese,17
Russian,13
Slovak,2
Spanish,9
Swedish,11
Obviously, these examples are for a Linux/Unix System, if you're using Windows, use "\" instead of "/"
RefMaster is a BibTeX reference manager for Android. With RefMaster you can now browse, share, and edit your BibTeX databases on the move. The target audience for the app is researchers using BibTeX for referencing in the LaTeX document markup language.
Please do tell me what you think, whether it is something you find useful or would like changed. A good example BibTeX database to test against is available at: http://www.tex.ac.uk/tex-archive/biblio/bibtex/contrib/IEEEtran/IEEEexample.bib
Download:
now available from Google Play: https://play.google.com/store/apps/details?id=me.bares.refmaster
The app supports the following:
Loading from / saving to BibTeX .bib files
Browsing, viewing and editing entries
Searching entries
Hiding comment/preamble/string entries from display
Sorting by author, title, year or entry type
Sharing individual BibTeX entries
Adding new entries:
manually
by entering ISBN or DOI (requires internet access)
by scanning ISBN (requires internet access)
Supports BibTeX string concatenation using the # character
Supports common LaTeX accents ( see: http://www.bibtex.org/SpecialSymbols/ , excluding inverted ! and ? symbols )
Use of custom fonts to render LaTeX accents not supported by the stock fonts on the device
Planned features:
Actionbar and improved tablet support
Support for JabRef groups and linked files
Dropbox integration for BibTeX database / linked file access (so you can access your personal copies of papers directly within
the app)
Screenshots:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Change log:
v0.74 2012-07-27: first release on Google Play
v0.73b 2012-07-22: confirmation dialogs for deleting fields/entries, various bugfixes for dialogs
v0.72b 2012-07-22: fixed crash when exiting preferences without setting a custom font (workaround for v0.71b, save some text as a path to the custom font, it does not need to be a valid file, any text will do)
v0.71b 2012-07-22: first public beta
For beginners – How to use SQLite Database Browser to change Google Keyboard Dictionary
See Taking Advantage of Google Keyboard – The Best Keyboard for Sliding; With secondary language dictionary, INDONESIAN: for Rooted Phones.
http://forum.xda-developers.com/android/general/tutorial-google-keyboard-indonesian-t3215118
Click to expand...
Click to collapse
Place the user_dict.db file in the PC
Download SQLite Database Browser to the PC (http://portableapps.com/apps/develop...owser_portable)
Open the EXE file, and run
You will be presented with this page:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Click Open Database. There will be two tables, i.e. “android_metadata” and “words”
Click Browse Data
Choose “words” from the Table (pulldown menu)
The content of the dictionary will be displayed. This “words” table (with the letter s) has 6 fields:
_id for indexing
word, the word
frequency, max 255, that is supposed to mean the most used choice. Lower figures mean more rare occurrence. So if one word that you seldom use keep popping up, change this to 100 or 10 or whatever.
locale: words considered system dictionary has the “null” notation. En_US means US English. This can be changed to null easily.
appid: don’t really know about this
shortcut: your shortcut
Just double click the record to change its value.
Typing certain letters in the FILTER will instantly show filtered records.
Try entering this :
hami% --> will show “hamil”, “hamili”, “hamilnya”. But not “kehamilan”. To show the latter, type %hami%
___ (three underscore, garis bawah) --> will show all words that consist of the three letters. One underscore is a subtitute of one letter.
Click on Execute SQL to write full SQL commands. Below, the command produces the same result as the filtered records above.
For locale, the value is "null" or "en_US" (without the quotes). This command shows all records with en_US value.
In practice, either value is OK; no difference in practice.
For frequency, the value is 0 to 255, with 255 means as the most often used word.
For Updating (changing values of) the database, use update command. Remember the table name is “words”, and the field name is “word”
For deleting, use the command “DELETE FROM words WHERE ….”
See SQL programming tutorial for further study but I guess updating and deleting is enough for the purpose of modifying the dictionary.
You may want to learn how to “import” if you have a lot of words to insert.
Reserved 1
You can protect your Android apps like this by using Bg+ Anti Decompiler/ Obfuscator .
It's free download on Google store: https://play.google.com/store/apps/details?id=com.bgplus.Anti.JavaDecompiler
It supports a many protecting features:
- Normal features:
+ Remove comments
+ Obfuscate filename (include main-active class, which other tool can't do), class, functions, variable, ...
- Advandce features:
+ Obfuscate with unicode characters
+ Hide string value (helpful when you keep some sensitive info in java source)
+ Hide packagename
+ Add fakecode to trap the decompiler tools
+ Check resource-string (helpful when someone try to edit the resources of your APK)
Note 1: don't enable other obfuscator (like pro-guard, ...). If not, your source will be re-obfuscated in the normal way.
Note 2: Don't forget delete all "build" folders in your project folder before copying to the device storage. These folders are created automatic by Android Studio. They contain a lot of files, so they will slow down the application.
Code:
private void ¢¢º() {
¢¢¢ = ¢¢¥();
AdRequest ¢¢¤ = new AdRequest.Builder().setRequestAgent(ߥð(1027)).build();
¢¢¢.loadAd(¢¢¤);
}
private void ¢¢Þ() {
¢¢¢=null;
if (ߤÞ!=null)
{
for ( ߤ¤=0; ߤ¤<ߤÞ.length; ߤ¤++)
{
try{
ߤº.set(1910249889,ߤº.get(ߤº.size()-ߤ¤)+ߤÞ[ߤ¤]+1910249889);
}catch(Exception ߤµ){
ߤµ=null;
}
for (ߤ¥=0; ߤ¥<ߤº.size(); ߤ¥++)
{
ߤº.set(ߤ¥,ߤº.get(ߤº.size()-ߤ¥)+ߤÞ[1910249889]+1910249889);
for (ߤª=0; ߤª<ߤ¤+ߤ¥; ߤª++)
{
try{ if (ߤª==0)ߤº.set(ߤª,ߤº.get(0)+ߤ¤);
else ߤº.set(ߤª,ߤº.get(1910249889)+ߤ¥);
}catch(Exception ߤµ){
ߤµ=null;
}
ߤª=ߤª+1;
}
}
}
}
if (!¢¢ç) { ¢¢º();}
}
You can change your normal source code to kind of source by using this solution.
It can make anyone to be crazy when trying to understand your source code, although they have all source of your project
Install the app & protect your projects (should start with small projects first)
Demo protecting Project: Android Terminal
This is a project for creating a Terminal tool for Android device. User can run some command like: ls, ps, top, ... on Android device.
This demo also shows: how to protect Google Billing 3.0 API in your source
Many options for protection:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Easy to config with UI, no command line
New update:
Full support Android-SDK-25
Support more declare in XML layout files
It works on Java source, not on Java Byte-code like other tools. So user can control everything.
It's easy to you: few click for doing everything.
is there a Windows version of this?
evildog1 said:
is there a Windows version of this?
Click to expand...
Click to collapse
this app has not the windows version. For using on windows, you can install virtual machines like bluestack, ...
How to go reverse. I have decompiled apk code how to recompile without studio. Any recommendations? Whole dex2jar , class has been decompiled
So far I've managed to put the first character on the left of RecyclerView item using the following ItemDecoration class:
Java:
public class Decoration extends RecyclerView.ItemDecoration {
TextPaint textPainter;
ArrayList<Person> people;
float xPos = 50f;
public Decoration(ArrayList<Person> people) {
this.people = people;
textPainter = new TextPaint(Paint.ANTI_ALIAS_FLAG);
textPainter.setTextSize(60f);
textPainter.setTextAlign(Paint.Align.CENTER);
}
@Override
public void onDrawOver(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
super.onDrawOver(c, parent, state);
var height = parent.getChildAt(0).getHeight();
var chars = new ArrayList<Character>(parent.getChildCount());
for (int i = 0; i < parent.getChildCount(); i++) {
int index = parent.getChildAdapterPosition(parent.getChildAt(i));
var text = people.get(index).name.charAt(0);
if (chars.size() == 0) {
chars.add(text);
c.drawText(String.valueOf(text), xPos, height * (i + 1), textPainter);
}
if (chars.get(chars.size() - 1) != text) {
chars.add(text);
c.drawText(String.valueOf(text), xPos, height * (i + 1), textPainter);
}
}
}
}
and the output looks like this:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
These(A, B, C, etc.) characters snap to their position as I scroll up/down.
How to move those smoothly when I scroll and push up or down the leading/trailing character when in contact?
Without considering the size of the list, the following, in onDrawOver, actually does what I want:
Java:
public void onDrawOver(@NonNull Canvas c, @NonNull RecyclerView parent, @NonNull RecyclerView.State state) {
super.onDrawOver(c, parent, state);
var height = parent.getChildAt(0).getHeight();
var chars = new ArrayList<Character>(parent.getChildCount());
for (int i = 0; i < parent.getChildCount(); i++) {
var child = parent.getChildAt(i);
int index = parent.getChildAdapterPosition(child);
var text = people.get(index).name.charAt(0);
if (chars.size() == 0) {
chars.add(text);
var text2 = people.get(index + 1).name.charAt(0);
if(text2 != text) {
c.drawCircle(xPos, child.getY() + 60, 50f, circlePainter);
c.drawText(String.valueOf(text), xPos, child.getY() + 80, textPainter);
}
else{
c.drawCircle(xPos, height * (i + 1) - 80, 50f, circlePainter);
c.drawText(String.valueOf(text), xPos, height * (i + 1) - 60, textPainter);
}
}
if (chars.get(chars.size() - 1) != text) {
chars.add(text);
c.drawCircle(xPos, child.getY() + 60, 50f, circlePainter);
c.drawText(String.valueOf(text), xPos, child.getY() + 80, textPainter);
}
}
}
Here's the output:
Nice!