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

Commit 22640b9a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Support copy action in ExtServices"

parents 6a6f9f59 9e0dfdce
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3681,6 +3681,7 @@
  <java-symbol type="array" name="config_displayWhiteBalanceAmbientColorTemperatures" />
  <java-symbol type="array" name="config_displayWhiteBalanceDisplayColorTemperatures" />
  <java-symbol type="drawable" name="ic_action_open" />
  <java-symbol type="drawable" name="ic_menu_copy_material" />

  <!-- MIME types -->
  <java-symbol type="string" name="mime_type_folder" />
+0 −4
Original line number Diff line number Diff line
@@ -25,10 +25,6 @@ LOCAL_PRIVATE_PLATFORM_APIS := true

LOCAL_CERTIFICATE := platform

LOCAL_AAPT_FLAGS := --shared-lib

LOCAL_EXPORT_PACKAGE_RESOURCES := true

LOCAL_PROGUARD_FLAG_FILES := proguard.proguard

LOCAL_PRIVILEGED_MODULE := true
+4 −0
Original line number Diff line number Diff line
@@ -78,6 +78,10 @@
            </intent-filter>
        </service>

        <activity android:name=".notification.CopyCodeActivity"
                  android:exported="false"
                  android:theme="@android:style/Theme.NoDisplay"/>

        <library android:name="android.ext.services"/>
    </application>

+6 −0
Original line number Diff line number Diff line
@@ -24,4 +24,10 @@
        <item>EDIT_DISTANCE</item>
        <item>EXACT_MATCH</item>
    </string-array>

    <!-- Action chip to copy a one time code to the user's clipboard [CHAR LIMIT=NONE]-->
    <string name="copy_code_desc">Copy \u201c<xliff:g id="code" example="12345">%1$s</xliff:g>\u201c</string>
    <!-- Toast to display when text is copied to the device clipboard [CHAR LIMIT=64]-->
    <string name="code_copied_to_clipboard">Code copied</string>

</resources>
+54 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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 android.ext.services.notification;

import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Intent;
import android.ext.services.R;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;

/**
 * An activity that copies text in the Bundle.
 */
public class CopyCodeActivity extends Activity {
    private static final String TAG = "CopyCodeActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        handleIntent();
        finish();
    }

    private void handleIntent() {
        String code = getIntent().getStringExtra(Intent.EXTRA_TEXT);
        if (TextUtils.isEmpty(code)) {
            Log.w(TAG, "handleIntent: empty code");
            return;
        }
        ClipboardManager clipboardManager = getSystemService(ClipboardManager.class);
        ClipData clipData = ClipData.newPlainText(null, code);
        clipboardManager.setPrimaryClip(clipData);
        Toast.makeText(getApplicationContext(), R.string.code_copied_to_clipboard,
                Toast.LENGTH_SHORT).show();
    }
}
Loading