Files
Michael W 33a84aa20e Dialer: Add a helpline phone book
* Expose the sensitive numbers to the user so they can easily call one
  of them
* Make sure to leave as few traces of access as possible:
  * Calling a number closes the helpline activity
  * Opening a link closes the helpline activity
  * Before opening a link, a warning about browser history appears

* This makes use of a changed xml-format, which now allows adding
  various things:
<item>
    <categories>violence|human trafficking</categories>
    <name>Some NGO or whatever</name>
    <number>1234</number>
    <anything>anything else</anything>
</item>

Includes:

Author: Luca Stefani <[email protected]>
Date:   Sat Mar 13 17:37:29 2021 +0100

    Dialer: Move to SPN schema classes

    Change-Id: I2cd3706f64bf45a2a6dd53caa9d5da48cf93ea28

Author: Michael W <[email protected]>
Date:   Sat May 22 16:38:57 2021 +0200

    Dialer: Helplines: Add Bullying and Immigration categories

    Change-Id: I7969fd0dd610a4f041f55ce04e6ede5c66005dee

Author: Luca Stefani <[email protected]>
Date:   Fri Mar 26 14:20:33 2021 +0100

    Dialer: Helplines: Use a webview dialog

    * Instead of relying on one browser we can actually display a webview
      ourselves
    * Set various headers to clear cache and to not track
    * Displays a progressbar and loading text while the page loads

    Co-authored-by: Michael W <[email protected]>
    Change-Id: Ibad2832c0cb6bcef79b5f348c40ca76c2516b295

Author: Michael W <[email protected]>
Date:   Fri May 28 19:08:24 2021 +0200

    Dialer: Helplines: Fix a few casing issues

    Change-Id: I31c2423aee5310ae08c9295971fbe7aced1f8f9b

Change-Id: I952bf10ee9516b83e595d8a19450696b303393b6
2023-10-08 19:10:45 +03:00

55 lines
2.1 KiB
Java

/**
* Copyright (C) 2016 The CyanogenMod project
* Copyright (C) 2019 The LineageOS Project
*
* 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.
*/
package com.android.dialer.helplines.utils;
import android.content.res.Resources;
import android.util.Log;
public class ResourceUtils {
private static final String TAG = ResourceUtils.class.getSimpleName();
private static final boolean DEBUG = false;
public static String getLocalizedString(final Resources res,
final String stringName,
final String stringFormat) {
String name = stringName.toLowerCase();
final String[] nonTokens = { "'", ",", "- ", "-", "(", ")" };
for (String token : nonTokens) {
name = name.replace(token, "");
}
final String[] underscoreTokens = { " ", "/" };
for (String token : underscoreTokens) {
name = name.replace(token, "_");
}
final String nameRes = String.format(stringFormat, name);
return getStringForResourceName(res, nameRes, stringName);
}
public static String getStringForResourceName(final Resources res,
final String resourceName,
final String defaultValue) {
final int resId = res.getIdentifier(resourceName, "string", "com.android.dialer");
if (resId <= 0) {
if (DEBUG) Log.d(TAG, "No resource found for " + resourceName);
return defaultValue;
} else {
return res.getString(resId);
}
}
}