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

Commit b762f479 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Update Simulator to launch SpeakEasy"

parents 274b285b 2c4fc1c9
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -32,12 +32,16 @@ import com.android.dialer.enrichedcall.simulator.EnrichedCallSimulatorActivity;
import com.android.dialer.persistentlog.PersistentLogger;
import com.android.dialer.preferredsim.PreferredSimFallbackContract;
import com.android.incallui.rtt.impl.RttChatActivity;
import com.android.incallui.speakeasy.SpeakEasy;
import com.android.incallui.speakeasy.SpeakEasyActivity;
import com.android.incallui.speakeasy.SpeakEasyComponent;

/** Implements the top level simulator menu. */
final class SimulatorMainMenu {

  static ActionProvider getActionProvider(@NonNull AppCompatActivity activity) {
    return new SimulatorSubMenu(activity.getApplicationContext())
    SimulatorSubMenu simulatorSubMenu = new SimulatorSubMenu(activity.getApplicationContext());
    simulatorSubMenu
        .addItem("Voice call", SimulatorVoiceCall.getActionProvider(activity))
        .addItem(
            "IMS video", SimulatorVideoCall.getActionProvider(activity.getApplicationContext()))
@@ -61,12 +65,23 @@ final class SimulatorMainMenu {
            () ->
                activity.startActivity(
                    EnrichedCallSimulatorActivity.newIntent(activity.getApplicationContext())));
    SpeakEasy speakEasy = SpeakEasyComponent.get(activity.getApplicationContext()).speakEasy();
    if (speakEasy.isEnabled()) {
      simulatorSubMenu.addItem(
          "SpeakEasy call mock", () -> simulateSpeakEasyCallMock(activity.getApplicationContext()));
    }

    return simulatorSubMenu;
  }

  private static void simulateRttCallMock(@NonNull Context context) {
    context.startActivity(new Intent(context, RttChatActivity.class));
  }

  private static void simulateSpeakEasyCallMock(@NonNull Context context) {
    context.startActivity(new Intent(context, SpeakEasyActivity.class));
  }

  private static void populateDatabase(@NonNull Context context) {
    DialerExecutorComponent.get(context)
        .dialerExecutorFactory()
+26 −0
Original line number Diff line number Diff line
<!--
  ~ Copyright (C) 2018 The Android Open Source 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
  -->
<manifest
    package="com.android.incallui.speakeasy"
    xmlns:android="http://schemas.android.com/apk/res/android">
  <application android:theme="@style/Theme.AppCompat">
  <activity
      android:name=".SpeakEasyActivity"
      android:exported="false"
      android:theme="@style/DialerThemeBase.NoActionBar"
      android:windowSoftInputMode="adjustResize"/>
  </application>
</manifest>
+16 −1
Original line number Diff line number Diff line
@@ -16,9 +16,24 @@

package com.android.incallui.speakeasy;

import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;

/** This interface provides a wrapper between callers and the Whisper client. */
public interface SpeakEasy {

  /** Signals to the user interface that the feature is abailable for use. */
  /** Signals to the user interface that the feature is available for use. */
  boolean isEnabled();

  /**
   * Create a new instance of SpeakEasy fragment.
   *
   * @param callId call id of the call.
   * @param nameOrNumber name or number of the caller to be displayed
   * @param sessionStartTimeMillis start time of the session in terms of {@link
   *     android.os.SystemClock#elapsedRealtime}.
   * @return new SpeakEasy fragment. Null if the SpeakEasy feature is not available for use
   */
  @Nullable
  Fragment getSpeakEasyFragment(String callId, String nameOrNumber, long sessionStartTimeMillis);
}
+47 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source 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.incallui.speakeasy;

import android.os.Bundle;
import android.os.SystemClock;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.view.View;

/** Activity to for SpeakEasy component. */
public class SpeakEasyActivity extends FragmentActivity {

  private SpeakEasy speakEasy;

  @Override
  protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    speakEasy = SpeakEasyComponent.get(this).speakEasy();
    setContentView(R.layout.activity_speakeasy);
    Fragment speakEasyFragment =
        speakEasy.getSpeakEasyFragment("", "John Snow", SystemClock.elapsedRealtime());
    if (speakEasyFragment != null) {
      getSupportFragmentManager()
          .beginTransaction()
          .add(R.id.fragment_speakeasy, speakEasyFragment)
          .commit();
    }
    getWindow().setStatusBarColor(getColor(R.color.speakeasy_status_bar_color));
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
  }
}
+8 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.incallui.speakeasy;

import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import javax.inject.Inject;

/** Default implementation of SpeakEasy. */
@@ -28,4 +30,10 @@ public class SpeakEasyStub implements SpeakEasy {
  public boolean isEnabled() {
    return false;
  }

  @Override
  public @Nullable Fragment getSpeakEasyFragment(
      String callId, String nameOrNumber, long sessionStartTimeMillis) {
    return null;
  }
}
Loading