mirror of
https://github.com/fergalmoran/chrometophone.git
synced 2025-12-22 09:41:51 +00:00
Preliminary phone<->tablet support
This commit is contained in:
@@ -39,7 +39,6 @@
|
||||
android:screenOrientation="portrait">
|
||||
</activity>
|
||||
|
||||
<!--
|
||||
<activity android:name=".ShareLinkActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
@@ -47,7 +46,6 @@
|
||||
<data android:mimeType="text/plain" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
-->
|
||||
|
||||
<!-- In order to use the c2dm library, an
|
||||
application must declare a class with the name C2DMReceiver, in its
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
@@ -85,8 +86,12 @@ public class C2DMReceiver extends C2DMBaseReceiver {
|
||||
|
||||
// Notify and optionally start activity
|
||||
if (settings.getBoolean("launchBrowserOrMaps", true) && launchIntent != null) {
|
||||
LauncherUtils.playNotificationSound(context);
|
||||
try {
|
||||
context.startActivity(launchIntent);
|
||||
LauncherUtils.playNotificationSound(context);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (sel != null && sel.length() > 0) { // have selection
|
||||
LauncherUtils.generateNotification(context, sel,
|
||||
|
||||
@@ -26,7 +26,9 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.provider.Settings.Secure;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.WindowManager;
|
||||
|
||||
/**
|
||||
* Register/unregister with the Chrome to Phone App Engine server.
|
||||
@@ -118,7 +120,19 @@ public class DeviceRegistrar {
|
||||
params.add(new BasicNameValuePair("deviceId", deviceId));
|
||||
}
|
||||
|
||||
// TODO: Allow device name to be configured
|
||||
params.add(new BasicNameValuePair("deviceName", isTablet(context) ? "Tablet" : "Phone"));
|
||||
|
||||
AppEngineClient client = new AppEngineClient(context, accountName);
|
||||
return client.makeRequest(urlPath, params);
|
||||
}
|
||||
|
||||
static boolean isTablet (Context context) {
|
||||
// Look for a width/height >= 7 inches (which is min xlarge width)
|
||||
// TODO: Remove this hack once we allow user to specify device name
|
||||
WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
DisplayMetrics metrics = new DisplayMetrics();
|
||||
wm.getDefaultDisplay().getMetrics(metrics);
|
||||
return (metrics.widthPixels / metrics.xdpi >= 7 || metrics.heightPixels / metrics.ydpi >= 7);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.google.android.apps.chrometophone;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -56,8 +55,10 @@ public class ShareLink implements Handler.Callback {
|
||||
sendToast(mContext.getString(R.string.sending_link_toast));
|
||||
try {
|
||||
List<NameValuePair> params = new ArrayList<NameValuePair>();
|
||||
params.add(new BasicNameValuePair("url", URLEncoder.encode(link)));
|
||||
params.add(new BasicNameValuePair("deviceType", "chrome"));
|
||||
params.add(new BasicNameValuePair("url", link));
|
||||
params.add(new BasicNameValuePair("deviceName", "Chrome," +
|
||||
(DeviceRegistrar.isTablet(mContext) ? "Phone" : "Tablet")));
|
||||
|
||||
SharedPreferences settings = Prefs.get(mContext);
|
||||
final String accountName = settings.getString("accountName", null);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user