Temporary remove account visibility support pushapiauthenticator.

Refactor push api test apps to have more similar code and use another
manifest entry.

Bug: https://b.corp.google.com/issues/33046496
Test: none

Change-Id: I2c87ccae0e73892eb15fb3e6f98bbb7372e0a24a
This commit is contained in:
Dmitry Dementyev
2016-12-02 14:09:27 -08:00
parent 47fde50bf6
commit d9fc9adf22
9 changed files with 88 additions and 93 deletions

View File

@@ -132,6 +132,8 @@ public class MainActivity extends Activity {
selectOption.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//TODO update Authenticator once AccountManager API is updated
/*
Account currentAccount = terraAccount;
int checkedAccount = accountChooser.getCheckedRadioButtonId();
int checkedOption = optionChooser.getCheckedRadioButtonId();
@@ -211,6 +213,7 @@ public class MainActivity extends Activity {
authStatus.setText("----");
}
}
*/
}
});
}

View File

@@ -31,7 +31,7 @@
</intent-filter>
</receiver>
<meta-data
android:name="android.accounts.SupportedLoginTypes"
android:name="android.accounts.SupportedAccountTypes"
android:value="com.google;com.whatsapp;com.example.android.pushapiauthenticator" />
</application>
</manifest>

View File

@@ -32,7 +32,7 @@
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Test Application One"
android:id="@+id/testapponetext"
android:id="@+id/testapptext"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="27dp" />
@@ -44,7 +44,7 @@
android:text="Visible Accounts"
android:id="@+id/visibleaccountstext"
android:layout_marginTop="58dp"
android:layout_below="@+id/testapponetext"
android:layout_below="@+id/testapptext"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />

View File

@@ -72,7 +72,7 @@ public class MainActivity extends Activity {
ApplicationInfo ai = getPackageManager().getApplicationInfo(getPackageName(),
PackageManager.GET_META_DATA);
Bundle bundle = ai.metaData;
supportedPackages = bundle.getString("android.accounts.SupportedLoginTypes");
supportedPackages = bundle.getString("android.accounts.SupportedAccountTypes");
} catch (PackageManager.NameNotFoundException e) {
Log.e("PushApiTestAppOne", "Failed to load meta-data, NameNotFound: "
+ e.getMessage());

View File

@@ -14,18 +14,21 @@
* limitations under the License.
*/
package com.example.android.pushapithirdpartyone;
package com.example.android.pushapithirdpartytwo;
import android.accounts.Account;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;
public class MessageReceiver extends BroadcastReceiver{
private static final String TAG = "PushApiTestAppOne";
public void onReceive(Context context, Intent intent) {
Account account = (Account) intent.getParcelableExtra("android.accounts.KEY_ACCOUNT");
Toast.makeText(context, "Account " + account.name + " received by Test App 1",
Toast.makeText(context, " android.accounts.VISIBLE_ACCOUNTS_CHANGED Broadcast received",
Toast.LENGTH_LONG).show();
Log.i(TAG, "android.accounts.VISIBLE_ACCOUNTS_CHANGED Broadcast received");
}
}

View File

@@ -17,7 +17,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.pushapithirdpartytwo">
<uses-permission android:name="android.permission.GET_ACCOUNTS"/>
<!-- <uses-permission android:name="android.permission.GET_ACCOUNTS"/> -->
<application android:label="3P App 2" android:icon="@drawable/push">
<activity android:name="MainActivity">
<intent-filter>
@@ -27,11 +27,11 @@
</activity>
<receiver android:name="com.example.android.pushapithirdpartytwo.MessageReceiver">
<intent-filter>
<action android:name="android.accounts.NEW_ACCOUNT_VISIBLE"/>
<action android:name="android.accounts.VISIBLE_ACCOUNTS_CHANGED"/>
</intent-filter>
</receiver>
<meta-data
android:name="android.accounts.SupportedLoginTypes"
android:name="android.accounts.SupportedAccountTypes"
android:value="com.google;com.whatsapp;com.example.android.pushapiauthenticator" />
</application>
</manifest>

View File

@@ -18,88 +18,74 @@
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ADE6B4"
android:background="#ADD8E6"
android:orientation="vertical"
android:fillViewport="false">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:layout_height="wrap_content"
android:id="@+id/relativelayout">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="----"
android:id="@+id/logintypesregistered2"
android:layout_below="@+id/logintypesregisteredtext"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Accounts Registered to Support:"
android:id="@+id/logintypesregisteredtext"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="34dp"
android:layout_below="@+id/placeholder" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Visible Accounts"
android:id="@+id/textView5"
android:layout_alignTop="@+id/getvisibleaccounts2"
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/visibleaccounts2"
android:layout_below="@+id/getvisibleaccounts2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<EditText
android:layout_width="1dp"
android:layout_height="wrap_content"
android:id="@+id/placeholder"
android:layout_alignRight="@+id/logintypesregistered2"
android:layout_alignEnd="@+id/logintypesregistered2"
android:layout_below="@+id/visibleaccounts2" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Get!"
android:id="@+id/getvisibleaccounts2"
android:layout_below="@+id/textView"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="37dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Test Application Two"
android:id="@+id/textView"
android:id="@+id/testapptext"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="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" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="----"
android:id="@+id/logintypesregistered"
android:layout_below="@+id/logintypesregisteredtext"
android:layout_alignLeft="@+id/logintypesregisteredtext"
android:layout_alignStart="@+id/logintypesregisteredtext" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Accounts Registered to Support"
android:id="@+id/logintypesregisteredtext"
android:layout_marginTop="58dp"
android:layout_below="@+id/getvisibleaccounts" />
</RelativeLayout>

View File

@@ -52,9 +52,9 @@ public class MainActivity extends Activity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
am = AccountManager.get(getApplicationContext());
final TextView loginTypesRegistered = (TextView) findViewById(R.id.logintypesregistered2);
final TextView visibleAccounts = (TextView) findViewById(R.id.visibleaccounts2);
final Button getVisibleAccounts = (Button) findViewById(R.id.getvisibleaccounts2);
final TextView loginTypesRegistered = (TextView) findViewById(R.id.logintypesregistered);
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!",
@@ -77,7 +77,7 @@ public class MainActivity extends Activity {
ApplicationInfo ai = getPackageManager().getApplicationInfo(getPackageName(),
PackageManager.GET_META_DATA);
Bundle bundle = ai.metaData;
supportedPackages = bundle.getString("android.accounts.SupportedLoginTypes");
supportedPackages = bundle.getString("android.accounts.SupportedAccountTypes");
} catch (PackageManager.NameNotFoundException e) {
Log.e("PushApiTestAppTwo", "Failed to load meta-data, NameNotFound: "
+ e.getMessage());

View File

@@ -20,12 +20,15 @@ import android.accounts.Account;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;
public class MessageReceiver extends BroadcastReceiver{
private static final String TAG = "PushApiTestAppTwo";
public void onReceive(Context context, Intent intent) {
Account account = (Account) intent.getParcelableExtra("android.accounts.KEY_ACCOUNT");
Toast.makeText(context, "Account " + account.name + " received by Test App 2",
Toast.makeText(context, " android.accounts.VISIBLE_ACCOUNTS_CHANGED Broadcast received",
Toast.LENGTH_LONG).show();
Log.i(TAG, "android.accounts.VISIBLE_ACCOUNTS_CHANGED Broadcast received");
}
}