upload android base code part7
This commit is contained in:
parent
4e516ec6ed
commit
841ae54672
25229 changed files with 1709508 additions and 0 deletions
20
android/development/apps/PushApiTestAppOne/Android.mk
Normal file
20
android/development/apps/PushApiTestAppOne/Android.mk
Normal file
|
@ -0,0 +1,20 @@
|
|||
LOCAL_PATH:= $(call my-dir)
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE_TAGS := tests
|
||||
|
||||
# Only compile source java files in this apk.
|
||||
LOCAL_SRC_FILES := $(call all-java-files-under, src)
|
||||
|
||||
LOCAL_PACKAGE_NAME := PushApiTestAppOne
|
||||
|
||||
LOCAL_SDK_VERSION := current
|
||||
|
||||
LOCAL_DEX_PREOPT := false
|
||||
|
||||
LOCAL_CERTIFICATE := $(LOCAL_PATH)/cert
|
||||
|
||||
include $(BUILD_PACKAGE)
|
||||
|
||||
# Use the following include to make our test apk.
|
||||
include $(call all-makefiles-under,$(LOCAL_PATH))
|
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- Copyright (C) 2016 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 xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.android.pushapithirdpartyone">
|
||||
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS"/>
|
||||
<!-- Should target O API level(26) or above to test GET_ACCOUNTS account visibility logic -->
|
||||
<uses-sdk android:minSdkVersion="1"
|
||||
android:targetSdkVersion="26"/>
|
||||
<application android:label="3P App 1" android:icon="@drawable/push">
|
||||
<activity android:name="MainActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<receiver android:name="com.example.android.pushapithirdpartyone.MessageReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.accounts.LOGIN_ACCOUNTS_CHANGED"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
</application>
|
||||
</manifest>
|
BIN
android/development/apps/PushApiTestAppOne/cert.pk8
Normal file
BIN
android/development/apps/PushApiTestAppOne/cert.pk8
Normal file
Binary file not shown.
24
android/development/apps/PushApiTestAppOne/cert.x509.pem
Normal file
24
android/development/apps/PushApiTestAppOne/cert.x509.pem
Normal file
|
@ -0,0 +1,24 @@
|
|||
-----BEGIN CERTIFICATE-----
|
||||
MIID/TCCAuWgAwIBAgIJAJQhygyzfNTkMA0GCSqGSIb3DQEBCwUAMIGUMQswCQYD
|
||||
VQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4g
|
||||
VmlldzEQMA4GA1UECgwHQW5kcm9pZDEQMA4GA1UECwwHQW5kcm9pZDEQMA4GA1UE
|
||||
AwwHQW5kcm9pZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTAe
|
||||
Fw0xNzAxMDUyMTE1MThaFw00NDA1MjMyMTE1MThaMIGUMQswCQYDVQQGEwJVUzET
|
||||
MBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNTW91bnRhaW4gVmlldzEQMA4G
|
||||
A1UECgwHQW5kcm9pZDEQMA4GA1UECwwHQW5kcm9pZDEQMA4GA1UEAwwHQW5kcm9p
|
||||
ZDEiMCAGCSqGSIb3DQEJARYTYW5kcm9pZEBhbmRyb2lkLmNvbTCCASIwDQYJKoZI
|
||||
hvcNAQEBBQADggEPADCCAQoCggEBANGi5LzphWNe/XUJ4xrZQmES4eg97nbt2aN/
|
||||
6Anw1C/7fNkYhMaPXDmju/V4DquCRDAlihRJslreusq/3JpZ4hX/F1xcjBF2sPda
|
||||
hGQf4LSJRZG7mxCjekRH9W6vUMsALQ2ckhx/QONWayoyVBezvBwmzfOjVXMpmTwt
|
||||
qGOv4Kq/YRP/Og1A4+QbI9YmXitknjDSXizExlU7hrb0HYrbQ8PGMPZuKh2+f6uN
|
||||
EVUc7/OWlHeTb1QEbohHIxCFTmfgh37RiQ+oH65Hl3w2ihwIGfarsEXg/aVKxZAE
|
||||
8T5JhNk2X5kdLdQx2cl8YT0w353Ppv+LU+sIpvyqXA1tc4zYCQ0CAwEAAaNQME4w
|
||||
HQYDVR0OBBYEFMTJcp+DkufKA0VNM2d7FykV/uXBMB8GA1UdIwQYMBaAFMTJcp+D
|
||||
kufKA0VNM2d7FykV/uXBMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEB
|
||||
AMBqip+t6vvUTU/lziiUQyboJ4EP79776AvZRIP+V61aNnQvDHYI0Ok99i9+auJS
|
||||
YtkWu+V53AMwEEzXGJsZVNCjdHjeWZwCbncZI/nmkHIhW1gHXmJqwwm5H2iChXDI
|
||||
3HAZL5s6+T23OZV/T91q1ZWAnTBTTv7mJBqcrerxrrUHw5pWEwMmwbfS87h1KlEj
|
||||
fQuQeldvmMn5jc+fn0tL09EdgbYQ+3HXvjmVcNRQyZe0yFSDESBv19P1mKDFyjcp
|
||||
8KqTr+3eaDkRx0gaIjGO1rjB6rCncN5nlA1Xeeu/ECFZO39PYh2GfPyhIYOHKeDs
|
||||
8D6CT+FwXp7PxXqJEmwWjC0=
|
||||
-----END CERTIFICATE-----
|
BIN
android/development/apps/PushApiTestAppOne/res/drawable/push.png
Normal file
BIN
android/development/apps/PushApiTestAppOne/res/drawable/push.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
|
@ -0,0 +1,73 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- Copyright (C) 2016 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.
|
||||
-->
|
||||
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#ADD8E6"
|
||||
android:orientation="vertical"
|
||||
android:fillViewport="false">
|
||||
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/relativelayout">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="Test Application One"
|
||||
android:id="@+id/testapptext"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="27dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceLarge"
|
||||
android:text="Visible Accounts"
|
||||
android:id="@+id/visibleaccountstext"
|
||||
android:layout_marginTop="58dp"
|
||||
android:layout_below="@+id/testapptext"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:text="----"
|
||||
android:id="@+id/visibleaccounts"
|
||||
android:layout_below="@+id/visibleaccountstext"
|
||||
android:layout_alignLeft="@+id/visibleaccountstext"
|
||||
android:layout_alignStart="@+id/visibleaccountstext" />
|
||||
|
||||
<Button
|
||||
style="?android:attr/buttonStyleSmall"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Get!"
|
||||
android:id="@+id/getvisibleaccounts"
|
||||
android:layout_alignTop="@+id/visibleaccountstext"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
</ScrollView>
|
|
@ -0,0 +1,126 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.example.android.pushapithirdpartyone;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.accounts.AccountManager;
|
||||
import android.accounts.AccountManagerCallback;
|
||||
import android.accounts.AccountManagerFuture;
|
||||
import android.accounts.AuthenticatorDescription;
|
||||
import android.accounts.OnAccountsUpdateListener;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.widget.ToggleButton;
|
||||
|
||||
public class MainActivity extends Activity {
|
||||
|
||||
private static final int REQUEST_CODE_PICK_ACCOUNT = 0;
|
||||
private static final String TAG = "PushApiTestAppOne";
|
||||
private static AccountManager am;
|
||||
private static OnAccountsUpdateListener mListener;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
am = AccountManager.get(getApplicationContext());
|
||||
mListener = new OnAccountsUpdateListener() {
|
||||
@Override
|
||||
public void onAccountsUpdated(Account[] accounts) {
|
||||
Log.i(TAG, "onAccountsUpdated is called:");
|
||||
if (accounts != null) {
|
||||
for (Account account : accounts) {
|
||||
Log.i(TAG, "visible account: " + account);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
am.addOnAccountsUpdatedListener(mListener, null, false,
|
||||
new String[] {"com.example.android.pushapiauthenticator", "com.google"});
|
||||
final TextView visibleAccounts = (TextView) findViewById(R.id.visibleaccounts);
|
||||
final Button getVisibleAccounts = (Button) findViewById(R.id.getvisibleaccounts);
|
||||
final Toast notifOn =
|
||||
Toast.makeText(getApplicationContext(), "Notifs Turned On!", Toast.LENGTH_SHORT);
|
||||
final Toast notifOff =
|
||||
Toast.makeText(getApplicationContext(), "Notifs Turned Off!", Toast.LENGTH_SHORT);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
builder.setMessage("Welcome to Test App 1.\nPlease make sure you have:\n\n1. Test App 2\n"
|
||||
+ "\n2. Auth App \n\ninstalled for the demo. These applications together provide"
|
||||
+ " tests, use cases, and proof of concept of Account Discovery API!\n")
|
||||
.setTitle("WELCOME")
|
||||
.setPositiveButton("Okay", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
// do nothing
|
||||
}
|
||||
});
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
getVisibleAccounts.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Account[] accountsAccessedByAuthApp = am.getAccounts();
|
||||
StringBuilder masterString = new StringBuilder();
|
||||
for (int i = 0; i < accountsAccessedByAuthApp.length; i++) {
|
||||
masterString.append(accountsAccessedByAuthApp[i].name + ", "
|
||||
+ accountsAccessedByAuthApp[i].type + "\n");
|
||||
}
|
||||
if (masterString.length() > 0) {
|
||||
visibleAccounts.setText(masterString);
|
||||
} else {
|
||||
visibleAccounts.setText("----");
|
||||
}
|
||||
|
||||
Intent intent = AccountManager.newChooseAccountIntent(null, null, null, null, null,
|
||||
null, null); // Show all accounts
|
||||
startActivityForResult(intent, REQUEST_CODE_PICK_ACCOUNT);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
am.removeOnAccountsUpdatedListener(mListener);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == REQUEST_CODE_PICK_ACCOUNT) {
|
||||
// Receiving a result from the AccountPicker
|
||||
if (resultCode == RESULT_OK) {
|
||||
Toast.makeText(this, data.getStringExtra(AccountManager.KEY_ACCOUNT_TYPE),
|
||||
Toast.LENGTH_LONG).show();
|
||||
} else if (resultCode == RESULT_CANCELED) {
|
||||
Toast.makeText(this, "No account was chosen", Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright (C) 2016 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.example.android.pushapithirdpartyone;
|
||||
|
||||
import android.accounts.Account;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
public class MessageReceiver extends BroadcastReceiver {
|
||||
private static final String TAG = "PushApiTestAppOne";
|
||||
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.i(TAG, "LOGIN_ACCOUNTS_CHANGED Broadcast received");
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue