Skip to content

Commit

Permalink
Added logic for server side processing in ProductDetailsActivity and …
Browse files Browse the repository at this point in the history
…added logic for fetch notifications and feeds
  • Loading branch information
rajagopal28 committed Mar 18, 2015
1 parent 18e1e60 commit bbf2116
Show file tree
Hide file tree
Showing 33 changed files with 486 additions and 186 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,17 @@
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" />
<orderEntry type="jdk" jdkName="Android API 21 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" name="support-v13-21.0.3" level="project" />
<orderEntry type="library" exported="" name="spring-android-rest-template-1.0.1.RELEASE" level="project" />
<orderEntry type="library" exported="" name="gson-2.3.1" level="project" />
<orderEntry type="library" exported="" name="gimbal" level="project" />
<orderEntry type="library" exported="" name="play-services-6.5.87" level="project" />
<orderEntry type="library" exported="" name="support-annotations-21.0.3" level="project" />
<orderEntry type="library" exported="" name="support-v4-21.0.3" level="project" />
<orderEntry type="library" exported="" name="spring-android-core-1.0.1.RELEASE" level="project" />
<orderEntry type="library" exported="" name="gimbal-dev-logging" level="project" />
</component>
</module>

8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
compileSdkVersion 21
buildToolsVersion "21.1.2"

defaultConfig {
applicationId "com.avnet.gears.codes.gimbal.store"
minSdkVersion 19
targetSdkVersion 19
minSdkVersion 21
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
Expand Down
63 changes: 43 additions & 20 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.avnet.gears.codes.gimbal.store" >
package="com.avnet.gears.codes.gimbal.store">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
Expand All @@ -10,6 +10,12 @@
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />

<permission
Expand All @@ -22,7 +28,7 @@
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
android:theme="@style/AppTheme">

<!-- Required for applications which use Google Play Services. -->
<meta-data
Expand All @@ -31,7 +37,7 @@

<activity
android:name=".activity.HomeActivity"
android:label="@string/app_name" >
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand All @@ -43,24 +49,33 @@
android:label="@string/title_activity_feed_list" />
<activity
android:name=".activity.ProductsListActivity"
android:label="@string/title_activity_products_list" >
android:label="@string/title_activity_products_list">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.avnet.gears.codes.gimbal.store.activity.HomeActivity" />
</activity>
<activity
android:name=".activity.ProductDetailsActivity"
android:label="@string/title_activity_product_details"
android:parentActivityName=".activity.ProductsListActivity" >
android:parentActivityName=".activity.ProductsListActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.avnet.gears.codes.gimbal.store.activity.ProductsListActivity" />
</activity>
<activity
android:name=".authenticator.activity.StoreAuthenticatorActivity"
android:label="@string/title_activity_store_authenticator" />
<activity
android:name=".activity.NotificationsListActivity"
android:label="@string/title_activity_notifications_list" />
<activity
android:name=".activity.UserSettingsActivity"
android:label="@string/title_activity_user_settings"></activity>

<service
android:name=".service.StoreAuthenticationService"
android:enabled="true"
android:exported="true" >
android:exported="true">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
Expand All @@ -69,32 +84,40 @@
android:name="android.accounts.AccountAuthenticator"
android:resource="@xml/authenticator" />
</service>

<activity
android:name=".authenticator.activity.StoreAuthenticatorActivity"
android:label="@string/title_activity_store_authenticator" />

<service
android:name=".service.StoreGcmServiceIntent"
android:exported="false" />
<service
android:name=".service.StoreGimbalDeviceService"
android:exported="false"></service>

<receiver
android:name=".receiver.StoreGcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />

<category android:name="com.example.gcm" />
<category android:name="com.avnet.gears.codes.gimbal.store.gcm" />
</intent-filter>
</receiver>

<activity
android:name=".activity.NotificationsListActivity"
android:label="@string/title_activity_notifications_list" />
<activity
android:name=".activity.UserSettingsActivity"
android:label="@string/title_activity_user_settings" >
</activity>
<receiver
android:name=".receiver.StoreGimbalDeviceBroadcastReceiver"
android:permission="android.permission.BLUETOOTH"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.bluetooth.adapter.action.STATE_CHANGED" />
</intent-filter>
</receiver>
<receiver
android:name=".receiver.StoreBootBroadcastReceiver"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public class FeedListActivity extends Activity implements ActionBar.TabListener
ViewPager mViewPager;

private GimbalStoreConstants.FEED_ITEM_TYPE[] feedItemTypes = new GimbalStoreConstants.FEED_ITEM_TYPE[]{
GimbalStoreConstants.FEED_ITEM_TYPE.FRIEND_RECOMMENDATION,
GimbalStoreConstants.FEED_ITEM_TYPE.FRIEND_REVIEW,
GimbalStoreConstants.FEED_ITEM_TYPE.FRIEND_RECOMMENDED,
GimbalStoreConstants.FEED_ITEM_TYPE.FRIEND_REVIEWED,
GimbalStoreConstants.FEED_ITEM_TYPE.SUGGESTED_PRODUCTS
};

Expand All @@ -57,7 +57,7 @@ protected void onCreate(Bundle savedInstanceState) {
GimbalStoreConstants.DEFAULT_SPINNER_INFO_TEXT);
Map<String, String> feedItemParams = ServerURLUtil.getBasicConfigParamsMap(getResources());
feedItemParams.put(GimbalStoreConstants.StoreParameterKeys.type.toString(),
GimbalStoreConstants.StoreParameterValues.feedItem.toString());
GimbalStoreConstants.StoreParameterValues.fetchFeeds.toString());
feedItemParams.put(GimbalStoreConstants.StoreParameterKeys.identifier.toString(),
GimbalStoreConstants.StoreParameterValues.top.toString());
feedItemParams.put(GimbalStoreConstants.StoreParameterKeys.uniqueId.toString(),
Expand Down Expand Up @@ -112,7 +112,7 @@ public void onPageSelected(int position) {
paramsMap.put(GimbalStoreConstants.StoreParameterKeys.identifier.toString(),
GimbalStoreConstants.StoreParameterValues.top.toString());
paramsMap.put(GimbalStoreConstants.StoreParameterKeys.type.toString(),
GimbalStoreConstants.StoreParameterValues.feedItem.toString());
GimbalStoreConstants.StoreParameterValues.fetchFeeds.toString());

FeedItemListDataProcessor feedItemListDataProcessor = new FeedItemListDataProcessor(this, mViewPager,
feedItemTypes, progressDialog);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,9 @@
import com.avnet.gears.codes.gimbal.store.utils.ServerURLUtil;
import com.avnet.gears.codes.gimbal.store.utils.TypeConversionUtil;

import com.gimbal.android.Beacon;
import com.gimbal.android.BeaconEventListener;
import com.gimbal.android.BeaconManager;
import com.gimbal.android.BeaconSighting;
import com.gimbal.android.Gimbal;
import com.gimbal.android.PlaceEventListener;
import com.gimbal.android.PlaceManager;
import com.gimbal.android.Visit;

import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;

Expand All @@ -75,10 +65,6 @@ public class HomeActivity extends Activity
private ProgressDialog progressDialog;
private AccountManager accountManager;

//Gimbal
private PlaceEventListener placeEventListener;
private BeaconEventListener beaconSightingListener;
private BeaconManager beaconManager;

private static final int SETTINGS_RESULT = 1;

Expand All @@ -88,6 +74,9 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_home);

gimbalInitialize();
/*IntentFilter filter1 = new IntentFilter(BluetoothDevice.ACTION_ACL_CONNECTED);
IntentFilter filter2 = new IntentFilter(BluetoothDevice.ACTION_ACL_DISCONNECT_REQUESTED);
IntentFilter filter3 = new IntentFilter(BluetoothDevice.ACTION_ACL_DISCONNECTED); */

mNavigationDrawerFragment = (NavigationDrawerFragment)
getFragmentManager().findFragmentById(R.id.navigation_drawer);
Expand Down Expand Up @@ -125,68 +114,21 @@ protected void onCreate(Bundle savedInstanceState) {
asyncTask.execute();
return;
}
Log.d("DEBUG", "cookieString = " + cookieString);
Log.d("DEBUG", "Home Activity , cookieString = " + cookieString);
}
processCategoryListData();
}

private void gimbalInitialize() {
Toast t = Toast.makeText(getApplicationContext(), "Gimbal initialise", Toast.LENGTH_SHORT);
t.show();
Gimbal.setApiKey(this.getApplication(), "70e4f8df-8332-46fd-99de-efa092ee57f9");

final TextView placeView = (TextView)findViewById(R.id.placeView);
final TextView sightingView = (TextView)findViewById(R.id.sightingView);
final TextView sightingRssiView = (TextView) findViewById(R.id.sightingRssiView);
final TextView beaconDetailsView = (TextView) findViewById(R.id.beaconDetailsView);

placeEventListener = new PlaceEventListener() {
@Override
public void onVisitStart(Visit visit) {

placeView.setText("Place : Enter: " + visit.getPlace().getName() + ", at: " + new Date(visit.getArrivalTimeInMillis()));
// This will be invoked when a place is entered. Example below shows a simple log upon enter
Log.i("Info:", "Enter: " + visit.getPlace().getName() + ", at: " + new Date(visit.getArrivalTimeInMillis()));

boolean setting = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("example_checkbox", true);
Toast t = Toast.makeText(getApplicationContext(), "Onvisitstart : " + String.valueOf(setting), Toast.LENGTH_SHORT);
t.show();
}

@Override
public void onVisitEnd(Visit visit) {

placeView.setText("Place : Exit: " + visit.getPlace().getName() + ", at: " + new Date(visit.getDepartureTimeInMillis()));
// This will be invoked when a place is exited. Example below shows a simple log upon exit
Log.i("Info:", "Exit: " + visit.getPlace().getName() + ", at: " + new Date(visit.getDepartureTimeInMillis()));

boolean setting = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()).getBoolean("example_checkbox", true);
Toast t = Toast.makeText(getApplicationContext(), "Onvisitend : " + String.valueOf(setting), Toast.LENGTH_SHORT);
t.show();
}
};

PlaceManager.getInstance().addListener(placeEventListener);

beaconSightingListener = new BeaconEventListener() {
@Override
public void onBeaconSighting(BeaconSighting sighting) {

sightingView.setText("BeaconSighting");
sightingRssiView.setText("RSSI : " + sighting.getRSSI() + "\nTime in Millis : " + new Date(sighting.getTimeInMillis()));

Beacon beacon = sighting.getBeacon();
beaconDetailsView.setText("Beacon Name : " + beacon.getName() +
"\nIdentifier : " + beacon.getIdentifier() +
"\nBattery Level : " + beacon.getBatteryLevel() +
"\nBeacon Temperature : " + beacon.getTemperature());
Log.i("INFO", sighting.toString());
}
};
beaconManager = new BeaconManager();
beaconManager.addListener(beaconSightingListener);

PlaceManager.getInstance().startMonitoring();
beaconManager.startListening();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class NotificationsListActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_notifications_list);
AndroidUtil.instantiateGimbal(this);
ListView notificationListView = (ListView) findViewById(R.id.user_notification_list_view);
ListView promotionsListView = (ListView) findViewById(R.id.promotions_list_view);
ProgressDialog progressDialog = AndroidUtil.showProgressDialog(this,
Expand All @@ -39,9 +40,7 @@ protected void onCreate(Bundle savedInstanceState) {
paramsMap.put(GimbalStoreConstants.StoreParameterKeys.identifier.toString(),
GimbalStoreConstants.StoreParameterValues.top.toString());
paramsMap.put(GimbalStoreConstants.StoreParameterKeys.type.toString(),
GimbalStoreConstants.StoreParameterValues.notificationItem.toString());
//TODO finalize

GimbalStoreConstants.StoreParameterValues.fetchNotifications.toString());
HttpConnectionAsyncTask asyncTask = new HttpConnectionAsyncTask(GimbalStoreConstants.HTTP_METHODS.GET,
Arrays.asList(urlString),
Arrays.asList(paramsMap),
Expand Down
Loading

0 comments on commit bbf2116

Please sign in to comment.