-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Custom Carrier Label & Carrier Label Placement [1/2]
Squash commits: Keyguard/Statusbar Carrier label options [1/2] * Stock behavior(only on keyguard), only on statusbar,both disabled or both enabled * code originally writted by @Altaf-Mahdi i just squased into one commit PureNexusProject-Legacy/android_frameworks_base@688d56f Show carrier label / custom & change color [1/2] *code originally written by @martincz *includes various fixs by the du team PureNexusProject-Legacy/android_frameworks_base@16a247a Carrier label - fix capitilization bug PureNexusProject-Legacy/android_frameworks_base@4b9e22b remove carrier label color and make carrier label play nice with dark statusbar PureNexusProject-Legacy/android_frameworks_base@3f32102 Fix Carrier Label font size not changing on system font size change DirtyUnicorns/android_frameworks_base@8da9dcf include carrier label in icon merger width calculation PureNexusProject-Legacy/android_frameworks_base@9df3a0c Credit/Thanks to @Altaf-Mahdi @beanstown106 @dwitherell and @martincz PureNexus Edits: - Adapt statusbar hook for N AICPfy: - Adapt for AICP (CM14) source - add missing @hide AICP brought up to O by AliB: - Adapt to O statusbar - Adapt to DarkController - parts of the code adapted from http://gerrit.aicp-rom.com/#/c/53587/ Change-Id: Ic1ecdbc606248dce5b2a2277374a8fa04c23b164 Signed-off-by: PMS22 <prathams99@rediff.com>
- Loading branch information
Showing
14 changed files
with
406 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
151 changes: 151 additions & 0 deletions
151
packages/SystemUI/src/com/android/systemui/fh/carrierlabel/CarrierLabel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
/* | ||
* Copyright (C) 2014-2015 The MoKee OpenSource 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.systemui.fh.carrierlabel; | ||
|
||
import android.content.BroadcastReceiver; | ||
import android.content.ContentResolver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.IntentFilter; | ||
import android.database.ContentObserver; | ||
import android.graphics.Rect; | ||
import android.os.Handler; | ||
import com.android.internal.util.fh.FhUtils; | ||
import android.os.UserHandle; | ||
import android.provider.Settings; | ||
import android.telephony.TelephonyManager; | ||
import android.text.TextUtils; | ||
import android.util.AttributeSet; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.TextView; | ||
|
||
import com.android.internal.telephony.TelephonyIntents; | ||
import com.android.systemui.Dependency; | ||
import com.android.systemui.fh.carrierlabel.SpnOverride; | ||
import com.android.systemui.statusbar.policy.DarkIconDispatcher; | ||
import com.android.systemui.statusbar.policy.DarkIconDispatcher.DarkReceiver; | ||
|
||
import java.text.SimpleDateFormat; | ||
import java.util.Calendar; | ||
import java.util.TimeZone; | ||
|
||
import com.android.systemui.R; | ||
|
||
public class CarrierLabel extends TextView implements DarkReceiver { | ||
|
||
private Context mContext; | ||
private boolean mAttached; | ||
private static boolean isCN; | ||
|
||
public CarrierLabel(Context context) { | ||
this(context, null); | ||
} | ||
|
||
public CarrierLabel(Context context, AttributeSet attrs) { | ||
this(context, attrs, 0); | ||
} | ||
|
||
public CarrierLabel(Context context, AttributeSet attrs, int defStyle) { | ||
super(context, attrs, defStyle); | ||
mContext = context; | ||
updateNetworkName(true, null, false, null); | ||
} | ||
|
||
@Override | ||
protected void onAttachedToWindow() { | ||
super.onAttachedToWindow(); | ||
Dependency.get(DarkIconDispatcher.class).addDarkReceiver(this); | ||
if (!mAttached) { | ||
mAttached = true; | ||
IntentFilter filter = new IntentFilter(); | ||
filter.addAction(TelephonyIntents.SPN_STRINGS_UPDATED_ACTION); | ||
filter.addAction(Intent.ACTION_CUSTOM_CARRIER_LABEL_CHANGED); | ||
mContext.registerReceiver(mIntentReceiver, filter, null, getHandler()); | ||
} | ||
} | ||
|
||
@Override | ||
protected void onDetachedFromWindow() { | ||
super.onDetachedFromWindow(); | ||
Dependency.get(DarkIconDispatcher.class).removeDarkReceiver(this); | ||
if (mAttached) { | ||
mContext.unregisterReceiver(mIntentReceiver); | ||
mAttached = false; | ||
} | ||
} | ||
|
||
@Override | ||
public void onDarkChanged(Rect area, float darkIntensity, int tint) { | ||
setTextColor(DarkIconDispatcher.getTint(area, this, tint)); | ||
} | ||
|
||
private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { | ||
@Override | ||
public void onReceive(Context context, Intent intent) { | ||
String action = intent.getAction(); | ||
if (TelephonyIntents.SPN_STRINGS_UPDATED_ACTION.equals(action) | ||
|| Intent.ACTION_CUSTOM_CARRIER_LABEL_CHANGED.equals(action)) { | ||
updateNetworkName(intent.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_SPN, true), | ||
intent.getStringExtra(TelephonyIntents.EXTRA_SPN), | ||
intent.getBooleanExtra(TelephonyIntents.EXTRA_SHOW_PLMN, false), | ||
intent.getStringExtra(TelephonyIntents.EXTRA_PLMN)); | ||
isCN = FhUtils.isChineseLanguage(); | ||
} | ||
} | ||
}; | ||
|
||
void updateNetworkName(boolean showSpn, String spn, boolean showPlmn, String plmn) { | ||
final String str; | ||
final boolean plmnValid = showPlmn && !TextUtils.isEmpty(plmn); | ||
final boolean spnValid = showSpn && !TextUtils.isEmpty(spn); | ||
if (spnValid) { | ||
str = spn; | ||
} else if (plmnValid) { | ||
str = plmn; | ||
} else { | ||
str = ""; | ||
} | ||
String customCarrierLabel = Settings.System.getStringForUser(mContext.getContentResolver(), | ||
Settings.System.CUSTOM_CARRIER_LABEL, UserHandle.USER_CURRENT); | ||
if (!TextUtils.isEmpty(customCarrierLabel)) { | ||
setText(customCarrierLabel); | ||
} else { | ||
setText(TextUtils.isEmpty(str) ? getOperatorName() : str); | ||
} | ||
} | ||
|
||
private String getOperatorName() { | ||
String operatorName = getContext().getString(R.string.quick_settings_wifi_no_network); | ||
TelephonyManager telephonyManager = (TelephonyManager) getContext().getSystemService( | ||
Context.TELEPHONY_SERVICE); | ||
if (isCN) { | ||
String operator = telephonyManager.getNetworkOperator(); | ||
if (TextUtils.isEmpty(operator)) { | ||
operator = telephonyManager.getSimOperator(); | ||
} | ||
SpnOverride mSpnOverride = new SpnOverride(); | ||
operatorName = mSpnOverride.getSpn(operator); | ||
} else { | ||
operatorName = telephonyManager.getNetworkOperatorName(); | ||
} | ||
if (TextUtils.isEmpty(operatorName)) { | ||
operatorName = telephonyManager.getSimOperatorName(); | ||
} | ||
return operatorName; | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
packages/SystemUI/src/com/android/systemui/fh/carrierlabel/SpnOverride.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright (C) 2014 The MoKee OpenSource 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.systemui.fh.carrierlabel; | ||
|
||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.io.FileReader; | ||
import java.io.IOException; | ||
import java.util.HashMap; | ||
|
||
import org.xmlpull.v1.XmlPullParser; | ||
import org.xmlpull.v1.XmlPullParserException; | ||
|
||
import android.os.Environment; | ||
import android.telephony.Rlog; | ||
import android.util.Xml; | ||
|
||
import com.android.internal.util.XmlUtils; | ||
|
||
public class SpnOverride { | ||
private HashMap<String, String> mCarrierSpnMap; | ||
|
||
|
||
static final String LOG_TAG = "SpnOverride"; | ||
static final String PARTNER_SPN_OVERRIDE_PATH ="etc/spn-conf.xml"; | ||
|
||
public SpnOverride () { | ||
mCarrierSpnMap = new HashMap<String, String>(); | ||
loadSpnOverrides(); | ||
} | ||
|
||
public boolean containsCarrier(String carrier) { | ||
return mCarrierSpnMap.containsKey(carrier); | ||
} | ||
|
||
public String getSpn(String carrier) { | ||
return mCarrierSpnMap.get(carrier); | ||
} | ||
|
||
private void loadSpnOverrides() { | ||
FileReader spnReader; | ||
|
||
final File spnFile = new File(Environment.getRootDirectory(), | ||
PARTNER_SPN_OVERRIDE_PATH); | ||
|
||
try { | ||
spnReader = new FileReader(spnFile); | ||
} catch (FileNotFoundException e) { | ||
Rlog.w(LOG_TAG, "Can not open " + | ||
Environment.getRootDirectory() + "/" + PARTNER_SPN_OVERRIDE_PATH); | ||
return; | ||
} | ||
|
||
try { | ||
XmlPullParser parser = Xml.newPullParser(); | ||
parser.setInput(spnReader); | ||
|
||
XmlUtils.beginDocument(parser, "spnOverrides"); | ||
|
||
while (true) { | ||
XmlUtils.nextElement(parser); | ||
|
||
String name = parser.getName(); | ||
if (!"spnOverride".equals(name)) { | ||
break; | ||
} | ||
|
||
String numeric = parser.getAttributeValue(null, "numeric"); | ||
String data = parser.getAttributeValue(null, "spn"); | ||
|
||
mCarrierSpnMap.put(numeric, data); | ||
} | ||
spnReader.close(); | ||
} catch (XmlPullParserException e) { | ||
Rlog.w(LOG_TAG, "Exception in spn-conf parser " + e); | ||
} catch (IOException e) { | ||
Rlog.w(LOG_TAG, "Exception in spn-conf parser " + e); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.