GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com โ€” Strings Usage

Strings Usage

Jump to bottom
Efra Espada edited this page Dec 31, 2019 ยท 3 revisions

Obfuscating Resources

The plugin will obfuscate all string tags with hidden="true" as attribute.

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">String Obfuscator Sample</string>
    <string name="hello" hidden="true" androidTreatment="false" containsHtml="true">
        <i>Hello <strong>there</strong></i><br></br>
        General <strong>Kenobi</strong>.
    </string>
    <string name="pattern" hidden="true">%1$s (%2$d)</string>
    <string name="snake_msg_hidden" hidden="true">\n\nla-li-lu-le-lo\n\n๐Ÿ๐Ÿ˜„๐Ÿ‰</string>
    <string name="hello_world_a">Hello
        World
    </string>
    <string name="hello_world_b" hidden="true">Hello
        World
    </string>
    <string name="hello_world_c" hidden="true" androidTreatment="false">Hello
World
    </string>
</resources>

Use the reveal(int id) static method to expose obfuscated strings on code:

String hello = SC.reveal(R.string.hello); // Hello there
String pattern = SC.reveal(R.string.pattern, "hi", 3); // hi (3) 

With Kotlin functions:

val hello = R.string.hello.reveal() // Hello there
val pattern = R.string.pattern.reveal("hi", 3); // hi (3) 

You can also expose strings directly on layout:

<com.stringcare.library.SCTextView
    android:text="@string/hello"
    app:reveal="true"/>

Credits to @Narvelan

Programmatically Obfuscation

StringCare can be used for obfuscating data programmatically and read the original string where you want:

String obfuscated = SC.obfuscate("hello there");
String original = SC.reveal(obfuscated);

With Kotlin:

val obfuscated = "hello there".obfuscate();
val original = obfuscated.reveal()

Attributes

containsHtml

<string name="hello" hidden="true" containsHtml="true">
    <i>Hello <strong>there</strong></i><br></br>General <strong>Kenobi</strong>.
</string>

For printing directy on layout:

<com.stringcare.library.SCTextView
     android:text="@string/hello"
     app:htmlSupport="true"
     app:reveal="true"/>

androidTreatment

The androidTreatment attribute allows to configure the way you process strings. By default, StringCare process string resources like the Android system.

<string name="hello_world_a">Hello
    World
</string>
<string name="hello_world_b" hidden="true">Hello
    World
</string>
Hello World

The plugin can process the strings unescaping text:

    <string name="hello_world_c" hidden="true" androidTreatment="false">Hello
World
    </string>
Hello
World

For printing directy on layout:

<com.stringcare.library.SCTextView
     android:text="@string/hello_world_c"
     app:androidTreatment="true"
     app:reveal="true"/>

For use on code:

// SC.reveal(int resId, boolean androidTreatment)
String value = SC.reveal(R.string.hello_world_c, false);

For use with Kotlin:

val value = R.string.hello_world_c.reveal(false)

Java Sample

SC.init(getApplicationContext());

String password = getString(R.string.snake_msg_hidden);
String original = SC.reveal(password, Version.V3);

String message = "Snake, the password is " + password + original;

((TextView) findViewById(R.id.programmatically_obfuscation)).setText(message);
String numbers = getString(R.string.pattern, "hi", 3) + " is " + SC.reveal(R.string.pattern, "hi", 3);
((TextView) findViewById(R.id.pattern)).setText(numbers);

final SCTextView tvAuto = findViewById(R.id.auto_tv);
findViewById(R.id.btn_change).setOnClickListener(v -> {
   // button logic
   if (tvAuto.isHtmlEnabled()) {
       tvAuto.setHtmlSupport(!tvAuto.isHtmlEnabled());
   } else if (tvAuto.isRevealingValue()){
       tvAuto.setRevealed(!tvAuto.isRevealingValue());
   } else if (!tvAuto.isRevealingValue()){
       tvAuto.setRevealed(!tvAuto.isRevealingValue());
       tvAuto.setHtmlSupport(!tvAuto.isHtmlEnabled());
   }
});

boolean equals = SC.reveal(R.string.hello_world_b).equals(getString(R.string.hello_world_a));
String areEquals = "Same result: " +  equals;
((TextView) findViewById(R.id.same_value)).setText(areEquals);

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Home

Flutter Support

What Is StringCare

Implementation

Strings Usage

Assets Usage

Configuration

Publish APK

Limitations

Compatibility

Tasks

Resource Tips

Clone this wiki locally

You are visitor 01402503 โ€” GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800ร—600. No cookies required.