Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 31d1bcfd authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "Regional: Customize Wifi hotspot,direct name and date format and bluetooth name"

parents 3e88f9e4 9e2a6bf0
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -44,4 +44,17 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
         for some cdma carriers -->
    <java-symbol type="bool" name="config_fetch_apn_from_omh_card" />
    <bool name="config_fetch_apn_from_omh_card">false</bool>
    <!-- Set Wifi hotspot security type
    NONE : 0
    WPA2 PSK: 4
    -->
    <integer name="wifi_hotspot_security_type">4</integer>
    <!-- Default wi-fi hotspot pass -->
    <string name="def_wifi_wifihotspot_pass" translatable="false"></string>
    <!-- Default wi-fi direct name -->
    <string name="def_wifi_direct_name" translatable="false"></string>
    <!-- Setting customize default bluetooth name -->
    <string name="def_custom_bt_defname"></string>
    <!-- custom date format or not  -->
    <bool name="config_dateformat">false</bool>
</resources>
+7 −0
Original line number Diff line number Diff line
@@ -2381,4 +2381,11 @@
  <!-- Data Connectivity Error Configurations -->
  <java-symbol type="bool" name="config_reject_ggsn_perm_failure" />
  <java-symbol type="bool" name="config_protocol_errors_perm_failure" />

  <!-- Regional Specific Symbols -->
  <java-symbol type="bool" name="config_dateformat" />
  <java-symbol type="integer" name="wifi_hotspot_security_type" />
  <java-symbol type="string" name="def_wifi_wifihotspot_pass" />
  <java-symbol type="string" name="def_wifi_direct_name" />
  <java-symbol type="string" name="def_custom_bt_defname" />
</resources>
+12 −9
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.UserHandle;
import android.provider.Settings;
import android.text.TextUtils;
import android.text.format.DateFormat;
import android.util.AttributeSet;
@@ -229,25 +230,27 @@ public class KeyguardStatusView extends GridLayout {
                    : R.string.abbrev_wday_month_day_no_year);
            final String clockView12Skel = res.getString(R.string.clock_12hr_format);
            final String clockView24Skel = res.getString(R.string.clock_24hr_format);
            final String key = locale.toString() + dateViewSkel + clockView12Skel + clockView24Skel;
            if (res.getBoolean(com.android.internal.R.bool.config_dateformat)) {
                final String dateformat = Settings.System.getString(context.getContentResolver(),
                        Settings.System.DATE_FORMAT);
                dateView = dateformat.equals(dateView) ? dateView : dateformat;
            } else {
                final String key = locale.toString() + dateViewSkel + clockView12Skel +
                        clockView24Skel;
                if (key.equals(cacheKey)) return;

                dateView = DateFormat.getBestDateTimePattern(locale, dateViewSkel);

                cacheKey = key;
            }
            clockView12 = DateFormat.getBestDateTimePattern(locale, clockView12Skel);
            // CLDR insists on adding an AM/PM indicator even though it wasn't in the skeleton
            // format.  The following code removes the AM/PM indicator if we didn't want it.
            if (!clockView12Skel.contains("a")) {
                clockView12 = clockView12.replaceAll("a", "").trim();
            }

            clockView24 = DateFormat.getBestDateTimePattern(locale, clockView24Skel);

            // Use fancy colon.
            clockView24 = clockView24.replace(':', '\uee01');
            clockView12 = clockView12.replace(':', '\uee01');

            cacheKey = key;
        }
    }
}
+26 −0
Original line number Diff line number Diff line
@@ -23,6 +23,9 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.Log;

import com.android.settingslib.R;
@@ -107,6 +110,7 @@ public final class BluetoothEventManager {
        addHandler(Intent.ACTION_DOCK_EVENT, new DockEventHandler());

        mContext.registerReceiver(mBroadcastReceiver, mAdapterIntentFilter, null, mReceiverHandler);
        setDefaultBtName();
    }

    void registerProfileIntentReceiver() {
@@ -120,6 +124,25 @@ public final class BluetoothEventManager {
        registerProfileIntentReceiver();
    }

    // set bluetooth default name
    private void setDefaultBtName() {
        String name = mContext.getResources().getString(
            com.android.internal.R.string.def_custom_bt_defname);
        boolean needSet = !TextUtils.isEmpty(name);
        Log.d(TAG, "custom bluetooth name: " + name);
        // This flag is to only set default bluetooth name once.
        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mContext);
        boolean notSet = preferences.getBoolean("is_first_boot",true);
        // only bluetooth state is on, set name will success, or, it will fail.
        boolean okToSet = mLocalAdapter.getBluetoothState() == BluetoothAdapter.STATE_ON;
        if (needSet && notSet && okToSet) {
            mLocalAdapter.setName(name);
            SharedPreferences.Editor edit = preferences.edit();
            edit.putBoolean("is_first_boot",false);
            edit.apply();
        }
    }

    /** Register to start receiving callbacks for Bluetooth events. */
    public void registerCallback(BluetoothCallback callback) {
        synchronized (mCallbacks) {
@@ -155,6 +178,9 @@ public final class BluetoothEventManager {
                                    BluetoothAdapter.ERROR);
            // update local profiles and get paired devices
            mLocalAdapter.setBluetoothStateInt(state);
            if (state == BluetoothAdapter.STATE_ON) {
                setDefaultBtName();
            }
            // send callback to update UI and possibly start scanning
            synchronized (mCallbacks) {
                for (BluetoothCallback callback : mCallbacks) {
+11 −1
Original line number Diff line number Diff line
@@ -106,10 +106,20 @@ public class DateView extends TextView {

        mCurrentTime.setTime(System.currentTimeMillis());

        final String text = mDateFormat.format(mCurrentTime);
        final String text = getDateFormat();
        if (!text.equals(mLastText)) {
            setText(text);
            mLastText = text;
        }
    }

    private String getDateFormat() {
        if (getContext().getResources().getBoolean(
                com.android.internal.R.bool.config_dateformat)
                ) {
            return DateFormat.getDateFormat(getContext()).format(mCurrentTime);
        } else {
            return mDateFormat.format(mCurrentTime);
        }
    }
}