Skip to content

Commit 4f1bc9e

Browse files
Merge pull request #31 from happyfoxinc/cleanup
Code cleanup
2 parents 604403f + c422c9e commit 4f1bc9e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+511
-855
lines changed

HelpStackExample/AndroidManifest.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
xmlns:tools="http://schemas.android.com/tools"
43
package="com.example.helpstackexample"
54
android:versionCode="1"
65
android:versionName="1.0" >
76

87
<uses-sdk
9-
android:minSdkVersion="8"
8+
android:minSdkVersion="9"
109
android:targetSdkVersion="22" />
1110

1211
<uses-permission android:name="android.permission.INTERNET"/>
@@ -22,7 +21,6 @@
2221
android:label="@string/app_name" >
2322
<intent-filter>
2423
<action android:name="android.intent.action.MAIN" />
25-
2624
<category android:name="android.intent.category.LAUNCHER" />
2725
</intent-filter>
2826
</activity>

HelpStackExample/res/values-v14/styles.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
<!-- <item name="android:actionBarStyle">@style/MyActionBar</item> -->
1111
</style>
1212

13-
<style name="MyActionBar"
14-
parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
13+
<style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
1514

1615
</style>
1716

HelpStackExample/src/com/example/helpstackexample/HSApplication.java

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44

55
import com.tenmiles.helpstack.HSHelpStack;
66
import com.tenmiles.helpstack.gears.HSEmailGear;
7-
import com.tenmiles.helpstack.gears.HSZendeskGear;
87

9-
10-
11-
public class HSApplication extends Application{
8+
public class HSApplication extends Application {
129

1310
HSHelpStack helpStack;
1411

@@ -18,16 +15,16 @@ public void onCreate() {
1815

1916
helpStack = HSHelpStack.getInstance(this);
2017

21-
HSEmailGear emailGear = new HSEmailGear( "example@happyfox.com",R.xml.articles);
18+
HSEmailGear emailGear = new HSEmailGear("foo@bar.com", R.xml.articles);
2219
helpStack.setGear(emailGear);
2320

24-
25-
/* Uncomment the following to use the Happyfox gear with appropriate support email address */
26-
// HSHappyfoxGear happyfoxGear = new HSHappyfoxGear("https://example.happyfox.com",
27-
// "<Your API Key>",
28-
// "<Your Auth Code>",
29-
// "<Category ID>", "<Priority ID>");
21+
/* Uncomment the following to use the HappyFox gear with appropriate support email address */
22+
// HSHappyfoxGear happyfoxGear = new HSHappyfoxGear(
23+
// "https://example.happyfox.com",
24+
// "<API Key>",
25+
// "<Auth Code>",
26+
// "<Category ID>",
27+
// "<Priority ID>");
3028
// helpStack.setGear(happyfoxGear);
31-
3229
}
3330
}

HelpStackExample/src/com/example/helpstackexample/MainActivity.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ protected void onCreate(Bundle savedInstanceState) {
2222
setContentView(R.layout.activity_main);
2323

2424
if (savedInstanceState == null) {
25-
getSupportFragmentManager().beginTransaction()
26-
.add(R.id.container, new PlaceholderFragment()).commit();
25+
getSupportFragmentManager().beginTransaction().add(R.id.container, new PlaceholderFragment()).commit();
2726
}
2827

2928
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
@@ -33,25 +32,18 @@ protected void onCreate(Bundle savedInstanceState) {
3332

3433
@Override
3534
public boolean onCreateOptionsMenu(Menu menu) {
36-
37-
// Inflate the menu; this adds items to the action bar if it is present.
3835
getMenuInflater().inflate(R.menu.main, menu);
3936
return true;
4037
}
4138

4239
@Override
4340
public boolean onOptionsItemSelected(MenuItem item) {
44-
// Handle action bar item clicks here. The action bar will
45-
// automatically handle clicks on the Home/Up button, so long
46-
// as you specify a parent activity in AndroidManifest.xml.
4741
int id = item.getItemId();
4842
if (id == R.id.action_settings) {
4943
return true;
5044
}
5145
return super.onOptionsItemSelected(item);
5246
}
53-
54-
5547

5648
/**
5749
* A placeholder fragment containing a simple view.
@@ -62,10 +54,8 @@ public PlaceholderFragment() {
6254
}
6355

6456
@Override
65-
public View onCreateView(LayoutInflater inflater, ViewGroup container,
66-
Bundle savedInstanceState) {
67-
View rootView = inflater.inflate(R.layout.fragment_main, container,
68-
false);
57+
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
58+
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
6959
rootView.findViewById(R.id.button1).setOnClickListener(new OnClickListener() {
7060

7161
@Override

helpstack/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
android:versionName="1.0" >
66

77
<uses-sdk
8-
android:minSdkVersion="8"
8+
android:minSdkVersion="9"
99
android:targetSdkVersion="22" />
1010

1111
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

helpstack/res/layout/hs_activity_edit_attachment.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
android:orientation="vertical"
77
tools:context=".MainActivity" >
88

9-
<com.tenmiles.helpstack.activities.DrawingView
9+
<com.tenmiles.helpstack.theme.widget.DrawingView
1010
android:id="@+id/drawing"
1111
android:layout_width="fill_parent"
1212
android:layout_height="0dp"

helpstack/res/values/hs_strings.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<string name="hs_new_user_message">Please enter your contact details to reach you</string>
2121

2222
<!-- Strings used in new Issue screen -->
23-
<string name="hs_issue_created_raised">Your issue has been created and raised.</string>
23+
<string name="hs_issue_created_raised">Your issue has been created and raised</string>
2424
<string name="hs_new_issue_title">Report Issue</string>
2525
<string name="hs_subject_hint">Subject</string>
2626
<string name="hs_message_hint">Message</string>
@@ -57,8 +57,8 @@
5757
<string name="hs_download">Download</string>
5858
<string name="hs_downloading_attachment">Downloading Attachment</string>
5959
<string name="hs_download_complete">Download complete</string>
60-
<string name="hs_loading">Loading...</string>
61-
<string name="hs_notify_download_complete">You will be notified when the download finishes.</string>
60+
<string name="hs_loading">Loading</string>
61+
<string name="hs_notify_download_complete">You will be notified when the download finishes</string>
6262
<string name="hs_open_with">Open with</string>
6363

6464
<!-- String used in error messages -->
@@ -76,4 +76,7 @@
7676
<string name="hs_error_reporting_issue">Error in reporting issue</string>
7777
<string name="hs_error_subject_message_empty">Subject and message cannot be empty</string>
7878

79+
<string name="drawing_saved">Drawing saved to Gallery</string>
80+
<string name="image_not_saved">Image could not be saved</string>
81+
7982
</resources>

helpstack/src/com/tenmiles/helpstack/HSHelpStack.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,10 @@ public class HSHelpStack {
5050
public static HSHelpStack getInstance(Context context) {
5151
if (singletonInstance == null) {
5252
synchronized (HSHelpStack.class) { // 1
53-
if (singletonInstance == null) // 2
54-
{
53+
if (singletonInstance == null) { // 2
5554
Log.d(TAG, "New Instance");
56-
singletonInstance = new HSHelpStack(
57-
context.getApplicationContext()); // 3
55+
singletonInstance = new HSHelpStack(context.getApplicationContext()); // 3
5856
}
59-
6057
}
6158
}
6259
return singletonInstance;

helpstack/src/com/tenmiles/helpstack/activities/ArticleActivity.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,36 +36,27 @@ public class ArticleActivity extends HSActivityParent {
3636

3737
public static final String EXTRAS_ARTICLE_ITEM = "item";
3838

39-
40-
4139
@Override
4240
protected void onCreate(Bundle savedInstanceState) {
4341
super.onCreate(savedInstanceState);
4442
setContentView(R.layout.hs_activity_article);
4543

4644
if (savedInstanceState == null) {
47-
4845
HSKBItem kbItem = (HSKBItem)getIntent().getSerializableExtra("item");
4946
ArticleFragment sectionFragment = HSFragmentManager.getArticleFragment(this, kbItem);
5047
HSFragmentManager.putFragmentInActivity(this, R.id.container, sectionFragment, "Article");
5148
getHelpStackActionBar().setTitle(R.string.hs_article);
52-
5349
}
5450
}
5551

5652
@Override
5753
public boolean onCreateOptionsMenu(Menu menu) {
58-
59-
// Inflate the menu; this adds items to the action bar if it is present.
6054
getMenuInflater().inflate(R.menu.hs_article, menu);
6155
return true;
6256
}
6357

6458
@Override
6559
public boolean onOptionsItemSelected(MenuItem item) {
66-
// Handle action bar item clicks here. The action bar will
67-
// automatically handle clicks on the Home/Up button, so long
68-
// as you specify a parent activity in AndroidManifest.xml.
6960
int id = item.getItemId();
7061
if (id == android.R.id.home) {
7162
finish();

helpstack/src/com/tenmiles/helpstack/activities/EditAttachmentActivity.java

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
import com.tenmiles.helpstack.R;
4646
import com.tenmiles.helpstack.model.HSAttachment;
47+
import com.tenmiles.helpstack.theme.widget.DrawingView;
4748

4849
import java.io.FileNotFoundException;
4950
import java.util.UUID;
@@ -99,7 +100,6 @@ public void onClick(View view) {
99100

100101
@Override
101102
public boolean onCreateOptionsMenu(Menu menu) {
102-
// Inflate the menu items for use in the action bar
103103
MenuInflater inflater = getMenuInflater();
104104
inflater.inflate(R.menu.hs_edit_attachment, menu);
105105
return super.onCreateOptionsMenu(menu);
@@ -128,36 +128,40 @@ public void onBackPressed() {
128128
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
129129
super.onActivityResult(requestCode, resultCode, intent);
130130

131-
switch(requestCode) {
132-
case REQUEST_CODE_PHOTO_PICKER:
133-
if(resultCode == Activity.RESULT_OK){
134-
Uri selectedImage = intent.getData();
131+
if(requestCode == REQUEST_CODE_PHOTO_PICKER) {
132+
if(resultCode == Activity.RESULT_OK) {
133+
Uri selectedImage = intent.getData();
135134

136-
Cursor cursor = this.getContentResolver().query(selectedImage, new String[] {
135+
Cursor cursor = this.getContentResolver().query(selectedImage,
136+
new String[] {
137137
MediaStore.Images.ImageColumns.DATA,
138138
MediaStore.Images.ImageColumns.DISPLAY_NAME,
139-
MediaStore.Images.ImageColumns.MIME_TYPE }, null, null, null);
139+
MediaStore.Images.ImageColumns.MIME_TYPE
140+
}, null, null, null);
141+
142+
if (cursor != null) {
140143
cursor.moveToFirst();
144+
}
141145

142-
String display_name = cursor.getString(cursor.getColumnIndex(MediaStore.Images.ImageColumns.DISPLAY_NAME));
143-
String mime_type = cursor.getString(cursor.getColumnIndex(MediaStore.Images.ImageColumns.MIME_TYPE));
146+
String display_name = cursor.getString(cursor.getColumnIndex(MediaStore.Images.ImageColumns.DISPLAY_NAME));
147+
String mime_type = cursor.getString(cursor.getColumnIndex(MediaStore.Images.ImageColumns.MIME_TYPE));
144148

145-
cursor.close();
149+
cursor.close();
146150

147-
selectedAttachment = HSAttachment.createAttachment(selectedImage.toString(), display_name, mime_type);
151+
selectedAttachment = HSAttachment.createAttachment(selectedImage.toString(), display_name, mime_type);
148152

149-
try {
150-
Uri uri = Uri.parse(selectedAttachment.getUrl());
151-
originalBitmap = BitmapFactory.decodeStream(this.getContentResolver().openInputStream(uri), null, null);
152-
drawView.setCanvasBitmap(originalBitmap);
153-
} catch (FileNotFoundException e) {
154-
// TODO Auto-generated catch block
155-
e.printStackTrace();
156-
}
157-
}
158-
else {
159-
finish();
153+
try {
154+
Uri uri = Uri.parse(selectedAttachment.getUrl());
155+
originalBitmap = BitmapFactory.decodeStream(this.getContentResolver().openInputStream(uri), null, null);
156+
drawView.setCanvasBitmap(originalBitmap);
157+
} catch (FileNotFoundException e) {
158+
// TODO Auto-generated catch block
159+
e.printStackTrace();
160160
}
161+
}
162+
else {
163+
finish();
164+
}
161165
}
162166
}
163167

@@ -176,8 +180,7 @@ private void onSaveClick() {
176180
}
177181

178182
if(imageSaved!=null){
179-
Toast savedToast = Toast.makeText(getApplicationContext(),
180-
"Drawing saved to Gallery!", Toast.LENGTH_SHORT);
183+
Toast savedToast = Toast.makeText(getApplicationContext(), R.string.drawing_saved, Toast.LENGTH_SHORT);
181184
savedToast.show();
182185

183186
Intent resultIntent = new Intent();
@@ -187,8 +190,7 @@ private void onSaveClick() {
187190
finish();
188191
}
189192
else{
190-
Toast unsavedToast = Toast.makeText(getApplicationContext(),
191-
"Oops! Image could not be saved.", Toast.LENGTH_SHORT);
193+
Toast unsavedToast = Toast.makeText(getApplicationContext(), R.string.image_not_saved, Toast.LENGTH_SHORT);
192194
unsavedToast.show();
193195
}
194196

@@ -217,16 +219,16 @@ public void paintColorClicked(View view) {
217219
private void discardDraft() {
218220
if (drawView.hasBeenEdited()) {
219221
new AlertDialog.Builder(this)
220-
.setTitle(R.string.discard)
221-
.setMessage("Do you want to discard your changes?")
222-
.setNegativeButton(android.R.string.no, null)
223-
.setPositiveButton(R.string.discard, new DialogInterface.OnClickListener() {
224-
225-
public void onClick(DialogInterface arg0, int arg1) {
226-
EditAttachmentActivity.super.onBackPressed();
227-
}
228-
}
229-
).create().show();
222+
.setTitle(R.string.discard)
223+
.setMessage("Do you want to discard your changes?")
224+
.setNegativeButton(android.R.string.no, null)
225+
.setPositiveButton(R.string.discard, new DialogInterface.OnClickListener() {
226+
227+
public void onClick(DialogInterface arg0, int arg1) {
228+
EditAttachmentActivity.super.onBackPressed();
229+
}
230+
}
231+
).create().show();
230232
}
231233
else {
232234
HSActivityManager.finishSafe(this);

0 commit comments

Comments
 (0)