Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Commit

Permalink
Merge pull request #45 from itsyash/master
Browse files Browse the repository at this point in the history
developer specific keys in a separate properties file
  • Loading branch information
Rom Srinivasan committed Sep 17, 2013
2 parents 76af2ba + e2d8945 commit 2484787
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local.properties
bin/
gen/
obj/
assets/developerSpecific/
.classpath
.settings
*.so
Expand All @@ -13,4 +14,6 @@ src/org/geometerplus/android/fbreader/network/bookshare/socialnetworks/SocialNet
project.properties
res/raw/data__help__minihelp_en_fb2



.DS_Store
15 changes: 12 additions & 3 deletions HowToBuild
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,18 @@ E.g., on my computer 'local.properties' consists of 2 lines:
sdk.dir=/Users/geometer/android-sdk-mac_86
ndk.dir=/Users/geometer/android-ndk-r4b

2. You will have to edit src/org/geometerplus/android/fbreader/network/bookshare/BookshareDeveloperKey and enter your
Bookshare developer key if you want to access the Bookshare library. You can obtain a Bookshare developer key from
http://developer.bookshare.org. You can also optionally enter your Bugsense key to get crash reports.
2. Create a new folder 'developerSpecific' in assets folder.In that folder, Create 'developer.properties' file, that contains:
developerKey='your bookshare developer key'
bugSenseKey='your bugsense key'
optOutGoogleAnalytics='your choice'

If you want to access bookshare library, you will have to obtain a bookshare developer key at http://developer.bookshare.org.
You can also optionally enter your Bugsense key to get crash reports.

A sample file would be:
developerKey=abcdefgh123456789abcdefg
bugSenseKey=abcd12
optOutGoogleAnalytics=false

3. If you use Linux or MacOS, just run 'ant clean debug' to create an installable package that will provide debugging info.

Expand Down
4 changes: 2 additions & 2 deletions res/layout/bookshare_webservice_login.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
android:layout_marginRight="20dip"
android:textColor="#000"
android:layout_height="50dip"
android:inputType="text"
android:inputType="textEmailAddress"
android:contentDescription="@string/login_dialog_username_label"
android:nextFocusRight="@+id/bookshare_login_password_edit_text"
android:nextFocusDown="@+id/bookshare_login_password_edit_text"
Expand Down Expand Up @@ -92,7 +92,7 @@
android:layout_height="50dip"/>

</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
Expand Down
4 changes: 4 additions & 0 deletions src/org/geometerplus/android/fbreader/FBReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ protected ZLFile fileFromIntent(Intent intent) {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
BookshareDeveloperKey.initialize(getApplicationContext());
Log.i(LOG_LABEL,BookshareDeveloperKey.BUGSENSE_KEY);
Log.i(LOG_LABEL,BookshareDeveloperKey.DEVELOPER_KEY);
Log.i(LOG_LABEL,String.valueOf(BookshareDeveloperKey.OPT_OUT_GOOGLE_ANALYTICS));
BugSenseHandler.initAndStartSession(this, BookshareDeveloperKey.BUGSENSE_KEY);

//todo:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,56 @@
package org.geometerplus.android.fbreader.network.bookshare;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import android.content.Context;
import android.content.res.AssetManager;
import android.content.res.Resources;

/**
* Enter your developer key here.
* It will be read by other Bookshare classes
* This file reads the developer key from the developer.properties file in
* assets/developerSpecific folder. It will be read by other Bookshare classes.
* You can obtain a developer key from http://developer.bookshare.org
*/
public class BookshareDeveloperKey {

// Enter your developer key here
public static final String DEVELOPER_KEY = "";
public static final String BUGSENSE_KEY = "";
public static final boolean OPT_OUT_GOOGLE_ANALYTICS = false;

public static String DEVELOPER_KEY = "";
public static String BUGSENSE_KEY = "";
public static boolean OPT_OUT_GOOGLE_ANALYTICS = false;

public static void initialize(Context applicationContext) {
// TODO Auto-generated method stub
final Context mcontext = applicationContext;
getProperties(mcontext);

}

private static void getProperties(Context mcontext) {
// TODO Auto-generated method stub
Resources resources = mcontext.getResources();
AssetManager assetManager = resources.getAssets();

// Read from the /assets directory
try {
InputStream inputStream = assetManager
.open("developerSpecific/developer.properties");
Properties properties = new Properties();
properties.load(inputStream);
System.out.println("The properties are now loaded");
System.out.println("properties: " + properties);
BUGSENSE_KEY = properties.getProperty("bugSenseKey");
DEVELOPER_KEY = properties.getProperty("developerKey");
if (properties.getProperty("optOutGoogleAnalytics")
.equalsIgnoreCase("false")) {
OPT_OUT_GOOGLE_ANALYTICS = false;
} else {
OPT_OUT_GOOGLE_ANALYTICS = true;
}

} catch (IOException e) {
System.err.println("Failed to open developer.property file");
e.printStackTrace();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.bookshare_blank_page);
Log.i(LOG_TAG,developerKey);
resources = getApplicationContext().getResources();
myActivity = this;
// Set full screen
Expand Down

0 comments on commit 2484787

Please sign in to comment.