summaryrefslogtreecommitdiffstats
path: root/src/com/android/dialer/incall/CallMethodStatusReceiver.java
blob: be1905a6e47f3d9049c2bdb4fe8474e6c291c7a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.android.dialer.incall;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import com.android.dialer.DialtactsActivity;

public class CallMethodStatusReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        Bundle b = intent.getExtras();

        SharedPreferences preferences = context
                .getSharedPreferences(DialtactsActivity.SHARED_PREFS_NAME, Context.MODE_PRIVATE);

        if (b != null) {
            String pluginName = b.getString(com.cyanogen.ambient.incall.PluginStatusConstants.EXTRA_PLUGIN_COMPONENT);
            int pluginStatus = b.getInt(com.cyanogen.ambient.incall.PluginStatusConstants.EXTRA_PLUGIN_STATUS);
            if (pluginStatus == com.cyanogen.ambient.incall.InCallPluginStatus.ENABLED) {

                String lastProviderEnabled =
                        preferences.getString(CallMethodUtils.PREF_LAST_ENABLED_PROVIDER, null);

                // No provider was previously enabled, show coachmark
                if (lastProviderEnabled == null) {
                    preferences.edit()
                            .putBoolean(CallMethodUtils.PREF_SPINNER_COACHMARK_SHOW, true).apply();
                }

                preferences.edit()
                        .putString(CallMethodUtils.PREF_LAST_ENABLED_PROVIDER, pluginName).apply();
            }
        }
    }

}