Skip to content

Instantly share code, notes, and snippets.

@helpshift
Last active December 14, 2015 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save helpshift/5003847 to your computer and use it in GitHub Desktop.
Save helpshift/5003847 to your computer and use it in GitHub Desktop.
Android SDK v2 docs gists.
<activity android:name="com.helpshift.HelpshiftActivity"
android:configChanges="orientation|screenSize"
android:theme="@style/HSThemeLight" />
<activity android:name="com.helpshift.HSAddIssue"
android:theme="@style/HSThemeLight"/>
<activity android:name="com.helpshift.HSAddProfile"
android:theme="@style/HSThemeLight" />
<activity android:name="com.helpshift.HSMessages"
android:theme="@style/HSThemeLight" />
<activity android:name="com.helpshift.HSQuestionsList"
android:theme="@style/HSThemeLight" />
<activity android:name="com.helpshift.HSQuestion"
android:hardwareAccelerated="true"
android:configChanges="orientation|screenSize"
android:theme="@style/HSThemeLight" />
<activity android:name="com.helpshift.HSSection"
android:hardwareAccelerated="true"
android:configChanges="orientation|screenSize"
android:theme="@style/HSThemeLight" />
<activity android:name="com.helpshift.HSInbox"
android:hardwareAccelerated="true"
android:configChanges="orientation|screenSize"
android:theme="@style/HSThemeLight" />
<activity android:name="com.helpshift.HSFaqs"
android:hardwareAccelerated="true"
android:configChanges="orientation|screenSize"
android:theme="@style/HSThemeLight" />
<activity android:name="com.helpshift.HelpshiftActivity"
android:configChanges="orientation|screenSize"
android:theme="@style/HSThemeLight" />
<activity android:name="com.helpshift.HSAddIssue"
android:theme="@style/HSThemeLight" />
<activity android:name="com.helpshift.HSAddProfile"
android:theme="@style/HSThemeLight" />
<activity android:name="com.helpshift.HSMessages"
android:theme="@style/HSThemeLight" />
<activity android:name="com.helpshift.HSQuestionsList"
android:theme="@style/HSThemeLight" />
<activity android:name="com.helpshift.HSQuestion"
android:hardwareAccelerated="true"
android:configChanges="orientation|screenSize"
android:theme="@style/HSThemeLight" />
<activity android:name="com.helpshift.HSSection"
android:hardwareAccelerated="true"
android:configChanges="orientation|screenSize"
android:theme="@style/HSThemeLight" />
<activity android:name="com.helpshift.HSInbox"
android:hardwareAccelerated="true"
android:configChanges="orientation|screenSize"
android:theme="@style/HSThemeLight" />
public class GCMIntentReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
}
}
<receiver android:name="GCMIntentReceiver" >
<intent-filter>
<action android:name="YOUR_ACTION_NAME" />
</intent-filter>
</receiver>
@Override
public void onReceive(Context context, Intent intent) {
Helpshift hs = new Helpshift(context);
final String regId = GCMRegistrar.getRegistrationId(context);
hs.setDeviceToken(regId);
}
@Override
protected void onRegistered(Context context, String registrationId) {
Intent intent = new Intent();
intent.setAction("YOUR_ACTION_NAME");
sendBroadcast(intent);
}
@Override
protected void onMessage(Context context, Intent intent) {
Helpshift hs = new Helpshift(context);
if(!hs.isForeground()) {
generateNotification(context, intent);
}
}
private void generateNotification(Context context, Intent i) {
PendingIntent intent;
Helpshift hs = new Helpshift(context);
if(i.getExtras().getString("origin").equals("helpshift")) {
intent = hs.getPendingIntentOnPush(context, i);
}
int icon = R.drawable.ic_launcher;
Bundle extras = i.getExtras();
String message = extras.getString("alert");
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, message, when);
String title = context.getString(R.string.app_name);
notification.setLatestEventInfo(context, title, message, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
NotificationManager notificationManager = (NotificationManager)
context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notification);
}
<attr name="hs_activityHeaderStyleRef" format="reference"/>
...etc
<!-- Light theme colors -->
<color name="hs_light_header_background_color">#58759d</color>
...etc
<!-- Dark theme colors -->
<color name="hs_dark_header_background_color">#222222</color>
...etc
<style name="HSThemeCustom" parent="style/HSThemeLight">
<!-- Attributes -->
<item name="hs_activityHeaderStyleRef">@style/hs_customActivityHeaderStyle</item>
...etc
</style>
<style name="hs_customActivityHeaderStyle">
<item name="android:background">@color/hs_custom_header_background_color</item>
<item name="android:textColor">@color/hs_custom_header_font_color</item>
</style>
...etc
<style name="HSThemeDark" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Attributes -->
<item name="hs_activityHeaderStyleRef">@style/hs_darkActivityHeaderStyle</item>
...etc
</style>
<style name="hs_darkActivityHeaderStyle">
<item name="android:background">@color/hs_dark_header_background_color</item>
<item name="android:textColor">@color/hs_dark_header_font_color</item>
</style>
<style name="HSThemeLight" parent="@android:style/Theme.Light.NoTitleBar">
<!-- Attributes -->
<item name="hs_activityHeaderStyleRef">@style/hs_lightActivityHeaderStyle</item>
...etc
</style>
<style name="hs_lightActivityHeaderStyle">
<item name="android:background">@color/hs_light_header_background_color</item>
<item name="android:textColor">@color/hs_light_header_font_color</item>
</style>
import com.helpshift.HSCallable;
k.put ("hello", "world");
k.put ("foo", "bar");
hs.setMetadataCallback (new HSCallable (){
public HashMap call() {
return k;
}
});
Helpshift hs;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
hs = new Helpshift (MyActivity.this);
}
<path id="helpshift-classpath">
<fileset dir="./libs/">
<include name="Helpshift.jar"/>
</fileset>
</path>
<java classname="com.helpshift.HSPostCompileCheck" failonerror="true">
<classpath refid="helpshift-classpath"/>
<arg value="<YOUR.APPLICATION.NAMESPACE>"/>
</java>
-keepattributes InnerClasses
-keep class **.R
-keep class **.R$* {
<fields>;
}
-keep class com.helpshift.** { *; }
-keep class com.ibm.** { *; }
hs.showInbox(MyActivity.this);
hs.showQuestion(MyActivity.this, "QUESTION_PUBLISH_ID");
hs.showSection(MyActivity.this, "SECTION_PUBLISH_ID");
HashMap config = new HashMap ();
config.put("showConvOnReportIssue", true);
config.put("showReportIssue", true);
hs.showFaqs(MyActivity.this, config);
HashMap config = new HashMap ();
config.putExtra("showConvOnReportIssue", true);
hs.showReportIssue(MyActivity.this, HashMap config);
HashMap config = new HashMap ();
config.putExtra("showConvOnReportIssue", true);
hs.showSupport(MyActivity.this, HashMap config);
String action = intent.getAction();
if (action.equals(PushManager.ACTION_REGISTRATION_FINISHED)) {
hs.setDeviceToken(PushManager.shared().getAPID());
}
String action = intent.getAction();
if (action.equals(PushManager.ACTION_NOTIFICATION_OPENED)) {
if(intent.getExtras().getString("origin").equals("helpshift")) {
hs.showSupportOnPush(intent);
}
}
public Notification buildNotification(String alert, Map<String, String> extras) {
if(!hs.isForeground()) {
return super.buildNotification(alert, extras);
} else {
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment