Merge remote-tracking branch 'upstream/bidforfixinside'

This commit is contained in:
Pavol Zibrita 2012-04-15 16:15:20 +02:00
commit 95cf3d50a7
12 changed files with 699 additions and 17 deletions

View file

@ -8,7 +8,15 @@
<!-- <uses-sdk android:minSdkVersion="3"/> -->
<!-- uncomment it to allow different screen supports (large/small)-->
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="4"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
<application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@style/OsmandTheme"
android:debuggable="true" android:name="net.osmand.plus.OsmandApplication"
android:backupAgent="net.osmand.plus.OsmandBackupAgent" android:restoreAnyVersion="true">
@ -72,15 +80,8 @@
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<activity android:name="net.osmand.plus.activities.OsmandBidForFixActivity"></activity>
</application>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
<uses-permission android:name="android.permission.WAKE_LOCK"></uses-permission>
</manifest>

View file

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/bidforfixitemlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white" >
<TextView
android:id="@+id/bffiText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="24dp"
android:layout_marginTop="8dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#72B123" />
<View
android:id="@+id/ruler"
android:layout_width="wrap_content"
android:layout_height="1px"
android:layout_alignParentLeft="true"
android:layout_below="@+id/bffiText"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="6dp"
android:background="#B0B0B0" />
<TextView
android:id="@+id/bffiSupport"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/bffiText"
android:layout_below="@+id/bffiText"
android:layout_marginTop="16dp"
android:text="18 supporters"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/bffiFunded"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/bffiSupport"
android:layout_below="@+id/bffiSupport"
android:text="Funded: 65%"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:id="@+id/bffiGraph"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/bffiSupport"
android:layout_marginRight="20dp"
android:src="@android:drawable/alert_dark_frame" />
</RelativeLayout>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="bidforfix_loading">Loading</string>
<string name="bidforfix_supporters">%1$d Supporters</string>
<string name="bidforfix_funded">funded: %d%%</string>
</resources>

View file

@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<resources>
<string name="default_buttons_support">Support</string>
<string name="support_new_features">Support new features</string>
<string name="show_ruler_level_descr">Display ruler on the map</string>
<string name="show_ruler_level">Display ruler</string>

View file

@ -1,11 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/profile_settings">
<ListPreference android:summary="@string/settings_preset_descr" android:title="@string/settings_preset" android:key="application_mode"></ListPreference>
<PreferenceScreen android:key="map_settings" android:title="@string/rendering_settings" android:summary="@string/rendering_settings_descr">
<PreferenceCategory android:title="@string/pref_raster_map">
<CheckBoxPreference android:summary="@string/map_vector_data_descr" android:title="@string/map_vector_data"
@ -123,7 +121,6 @@
</PreferenceCategory>
</PreferenceScreen>
<PreferenceScreen android:title="@string/osmand_service" android:summary="@string/osmand_service_descr">
<CheckBoxPreference android:summary="@string/background_router_service_descr" android:title="@string/background_router_service"
android:key="service_off_enabled"></CheckBoxPreference>
@ -139,6 +136,9 @@
<CheckBoxPreference android:key="scroll_map_by_gestures" android:title="@string/scroll_map_by_gestures" android:summary="@string/scroll_map_by_gestures_descr"></CheckBoxPreference>
<CheckBoxPreference android:key="use_short_object_names" android:title="@string/use_short_object_names" android:summary="@string/use_short_object_names_descr"></CheckBoxPreference>
</PreferenceScreen>
<Preference android:title="@string/support_new_features" android:key="bidforfix">
</Preference>
</PreferenceCategory>

View file

@ -0,0 +1,193 @@
package com.bidforfix.andorid;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.osmand.plus.R;
import android.app.Activity;
import android.app.Dialog;
import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.bidforfix.andorid.BidForFixHelper.BFFIssue;
import com.gafmedia.Graph.PieItem;
import com.gafmedia.Graph.View_PieChart;
public abstract class BidForFixActivity extends ListActivity {
private static final int LOAD_ITEMS = 0;
LoadItemsTask loadItemTask;
private BidForFixHelper helper;
public abstract BidForFixHelper getBidForFixHelper();
private BidForFixHelper getHelper() {
if (helper == null) {
helper = getBidForFixHelper();
}
return helper;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(android.R.style.Theme_Light);
super.onCreate(savedInstanceState);
if (getHelper().isReloadNeeded()) {
showDialog(LOAD_ITEMS);
} else {
setListAdapter(new BFFIssueArrayAdapter(this, getHelper().getList()));
}
}
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case LOAD_ITEMS:
return new ProgressDialog(this);
}
return super.onCreateDialog(id);
}
@Override
protected void onPrepareDialog(int id, Dialog dialog) {
switch (id) {
case LOAD_ITEMS:
dialog.setTitle(R.string.bidforfix_loading);
loadItemTask = new LoadItemsTask((ProgressDialog)dialog);
loadItemTask.execute();
return;
}
super.onPrepareDialog(id, dialog);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
BFFIssue issue = (BFFIssue) getListAdapter().getItem(position);
String url = issue.getLink();
try {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
} catch (ActivityNotFoundException ex) {
Toast.makeText(this, ex.getMessage() + " for " + url, Toast.LENGTH_LONG).show();
}
super.onListItemClick(l, v, position, id);
}
public class LoadItemsTask extends AsyncTask<Object, Integer, Integer> {
private final ProgressDialog dialog;
public LoadItemsTask(ProgressDialog dialog) {
this.dialog = dialog;
this.dialog.setIndeterminate(true);
}
@Override
protected Integer doInBackground(Object... params) {
getHelper().loadList();
return null;
}
@Override
protected void onPostExecute(Integer result) {
super.onPostExecute(result);
//set the adapter (clear,set)
setListAdapter(new BFFIssueArrayAdapter(BidForFixActivity.this, getHelper().getList()));
dismissDialog(LOAD_ITEMS);
}
}
public static class BFFIssueArrayAdapter extends ArrayAdapter<BFFIssue> {
private final Activity context;
private final List<BFFIssue> values;
Random random = new Random();
static class ViewHolder {
public TextView text;
public ImageView image;
public TextView support;
public TextView funded;
}
public BFFIssueArrayAdapter(Activity context, List<BFFIssue> values) {
super(context, R.layout.list_item_bidforfix, values);
this.context = context;
this.values = values;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View rowView = convertView;
if (rowView == null) {
LayoutInflater inflater = context.getLayoutInflater();
rowView = inflater.inflate(R.layout.list_item_bidforfix, null);
ViewHolder viewHolder = new ViewHolder();
viewHolder.text = (TextView) rowView.findViewById(R.id.bffiText);
viewHolder.support = (TextView) rowView.findViewById(R.id.bffiSupport);
viewHolder.funded = (TextView) rowView.findViewById(R.id.bffiFunded);
viewHolder.image = (ImageView) rowView.findViewById(R.id.bffiGraph);
rowView.setTag(viewHolder);
}
ViewHolder holder = (ViewHolder) rowView.getTag();
BFFIssue s = values.get(position);
holder.text.setText(s.getName());
holder.support.setText(context.getString(R.string.bidforfix_supporters, s.getBids_count()));
int funded = s.getPercent();
holder.funded.setText(context.getString(R.string.bidforfix_funded, funded));
List<PieItem> PieData = new ArrayList<PieItem>();
PieItem item = new PieItem();
item.Count = funded;
item.Color = 0xFF72B123;
PieItem item2 = new PieItem();
item2.Count = Math.max(100,funded)-funded;
item2.Color = 0xFFDDDDDD;
PieData.add(item);
PieData.add(item2);
int Size = Math.max(holder.image.getHeight(),40);
Bitmap mBackgroundImage = Bitmap.createBitmap(Size, Size, Bitmap.Config.RGB_565);
//------------------------------------------------------------------------------------------
// Generating Pie view
//------------------------------------------------------------------------------------------
View_PieChart pieChartView = new View_PieChart(context);
pieChartView.setLayoutParams(new LayoutParams(Size, Size));
pieChartView.setGeometry(Size, Size, 2, 2, 2, 2, -1); //OverlayId);
pieChartView.setSkinParams(0xffffffff);
pieChartView.setData(PieData, 100);
pieChartView.invalidate();
//------------------------------------------------------------------------------------------
// Draw Pie Vien on Bitmap canvas
//------------------------------------------------------------------------------------------
pieChartView.draw(new Canvas(mBackgroundImage));
holder.image.setImageBitmap(mBackgroundImage);
return rowView;
}
}
}

View file

@ -0,0 +1,260 @@
package com.bidforfix.andorid;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.net.Uri;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceCategory;
import android.preference.PreferenceScreen;
import android.util.Log;
import android.widget.Toast;
public class BidForFixHelper {
private static final long DAY = 1000*60*60*24; //A DAY in millis
private List<BFFIssue> bffIssues = new ArrayList<BFFIssue>();
private final String project;
private Thread t;
private Date initialized;
private final String supportButton;
private final String cancelButton;
public static class BFFIssue implements Comparable<BFFIssue> {
private final String link;
private final String name;
private final String shortname;
private final String descripton;
private final int percent;
private final int bids_count;
private final int position;
public BFFIssue(JSONObject jsonObject) {
this.link = getValue(jsonObject, "link");
this.name = getValue(jsonObject, "name");
this.shortname = getValue(jsonObject, "short_name");
this.descripton = getValue(jsonObject, "description");
this.percent = getInt(jsonObject, "percent");
this.bids_count = getInt(jsonObject, "bids_count");
this.position = getInt(jsonObject, "position");
}
private int getInt(JSONObject jsonObject, String key) {
try {
return jsonObject.getInt(key);
} catch (JSONException e) {
// ignore
}
return 0;
}
private String getValue(JSONObject jsonObject, String key) {
try {
return jsonObject.getString(key);
} catch (JSONException e) {
// ignore
}
return null;
}
// public BFFIssue(String link, String name, String shortname,
// String descripton) {
// this.link = link;
// this.name = name;
// this.shortname = shortname;
// this.descripton = descripton;
// }
public String getDescripton() {
return descripton;
}
public String getLink() {
if (link.startsWith("http://")) {
return link;
} else {
return "http://www.bidforfix.com"+link;
}
}
public String getName() {
return name;
}
public String getShortname() {
return shortname;
}
public int getBids_count() {
return bids_count;
}
public int getPercent() {
return percent;
}
@Override
public int compareTo(BFFIssue another) {
return another != null ? this.position - another.position : 1;
}
}
public BidForFixHelper(String project, String supportButton, String cancelButton) {
this.project = project;
this.supportButton = supportButton;
this.cancelButton = cancelButton;
}
public boolean isReloadNeeded() {
return initialized == null || initialized.before(new Date(System.currentTimeMillis()-DAY));
}
public List<BFFIssue> getList() {
return bffIssues;
}
public void loadList() {
if (isReloadNeeded()) {
BufferedReader in = null;
String url = "http://www.bidforfix.com/p/" + project + "/issues/?count=20";
try {
URL twitter = new URL(url);
URLConnection tc = twitter.openConnection();
in = new BufferedReader(new InputStreamReader(
tc.getInputStream()));
StringBuilder sb = new StringBuilder();
String line;
while ((line = in.readLine()) != null) {
sb.append(line);
}
JSONTokener json = new JSONTokener(sb.toString());
JSONObject root = (JSONObject) json.nextValue();
if (root != null) {
JSONArray issues = root.getJSONArray("issues");
for (int i = 0; i < issues.length(); i++) {
JSONObject jo = (JSONObject) issues.get(i);
bffIssues.add(new BFFIssue(jo));
}
}
Collections.sort(bffIssues);
initialized = new Date();
} catch (MalformedURLException e) {
initialized = new Date(Long.MAX_VALUE); //bad url, don't try anymore
Log.w("Bad URL:" + url, e);
} catch (IOException e) {
//we can try some more times...
} catch (JSONException e) {
//bad json, try in two day again
initialized = new Date(System.currentTimeMillis()+DAY*2);
Log.w("Bad JSON while parsing bidforfix output", e);
} finally {
if (in != null) {
try {
in.close();
} catch (IOException ex) {
// ignore
}
}
}
}
}
public void generatePreferenceList(final PreferenceScreen screen,
final String categoryName, final Activity context) {
t = new Thread("BidForFixThread") {
@Override
public void run() {
loadList();
// after loading, fill the screen
if (!bffIssues.isEmpty()) {
context.runOnUiThread(new Runnable() {
@Override
public void run() {
PreferenceCategory cat = new PreferenceCategory(
context);
cat.setTitle(categoryName);
screen.addPreference(cat);
for (int i = 0; i < bffIssues.size(); i++) {
final BFFIssue issue = bffIssues.get(i);
Preference preference = new Preference(context);
preference.setTitle(issue.getName());
preference.setSummary(issue.getDescripton());
preference
.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(
Preference preference) {
Builder builder = new AlertDialog.Builder(context);
builder.setTitle(issue.name);
builder.setMessage(issue.descripton);
builder.setPositiveButton(supportButton, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//edit the preference
String url = issue.getLink();
try {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
context.startActivity(i);
} catch (ActivityNotFoundException ex) {
Toast.makeText(context, ex.getMessage() + " for " + url, Toast.LENGTH_LONG).show();
}
}
});
builder.setNegativeButton(cancelButton, null);
builder.show();
return false;
}
});
cat.addPreference(preference);
}
}
});
}
t = null;
}
};
t.setDaemon(true);
t.start();
}
public void onDestroy() {
// close the thread, release resources...
if (t != null) {
try {
t.join(); // wait for the thread
// TODO we should wait for the runOnUIThread??? is that possible
// if we are in UI thread now?
} catch (InterruptedException e) {
// ignore
}
}
}
}

View file

@ -0,0 +1,7 @@
package com.gafmedia.Graph;
public class PieItem {
public int Count;
public String Label;
public float Percent;
public int Color;
}

View file

@ -0,0 +1,116 @@
package com.gafmedia.Graph;
import com.gafmedia.Graph.PieItem;
import java.util.List;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.BitmapFactory.Options;
import android.util.AttributeSet;
import android.view.View;
public class View_PieChart extends View {
private static final int WAIT = 0;
private static final int IS_READY_TO_DRAW = 1;
private static final int IS_DRAW = 2;
private static final float START_INC = 30;
private Paint mBgPaints = new Paint();
private Paint mLinePaints = new Paint();
private int mOverlayId;
private int mWidth;
private int mHeight;
private int mGapLeft;
private int mGapRight;
private int mGapTop;
private int mGapBottom;
private int mBgColor;
private int mState = WAIT;
private float mStart;
private float mSweep;
private int mMaxConnection;
private List<PieItem> mDataArray;
//--------------------------------------------------------------------------------------
public View_PieChart (Context context){
super(context);
}
//--------------------------------------------------------------------------------------
public View_PieChart(Context context, AttributeSet attrs) {
super(context, attrs);
}
//--------------------------------------------------------------------------------------
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
//------------------------------------------------------
if (mState != IS_READY_TO_DRAW) return;
canvas.drawColor(mBgColor);
//------------------------------------------------------
mBgPaints.setAntiAlias(true);
mBgPaints.setStyle(Paint.Style.FILL);
mBgPaints.setColor(0x88FF0000);
mBgPaints.setStrokeWidth(0.5f);
//------------------------------------------------------
mLinePaints.setAntiAlias(true);
mLinePaints.setStyle(Paint.Style.STROKE);
mLinePaints.setColor(0xff000000);
mLinePaints.setStrokeWidth(0.5f);
//------------------------------------------------------
RectF mOvals = new RectF( mGapLeft, mGapTop, mWidth - mGapRight, mHeight - mGapBottom);
//------------------------------------------------------
mStart = START_INC;
PieItem Item;
for (int i = 0; i < mDataArray.size(); i++) {
Item = (PieItem) mDataArray.get(i);
mBgPaints.setColor(Item.Color);
mSweep = (float) 360 * ( (float)Item.Count / (float)mMaxConnection );
canvas.drawArc(mOvals, mStart, mSweep, true, mBgPaints);
canvas.drawArc(mOvals, mStart, mSweep, true, mLinePaints);
mStart += mSweep;
}
//------------------------------------------------------
Options options = new BitmapFactory.Options();
options.inScaled = false;
// Bitmap OverlayBitmap = BitmapFactory.decodeResource(getResources(), mOverlayId, options);
// canvas.drawBitmap(OverlayBitmap, 0.0f, 0.0f, null);
//------------------------------------------------------
mState = IS_DRAW;
}
//--------------------------------------------------------------------------------------
public void setGeometry(int width, int height, int GapLeft, int GapRight, int GapTop, int GapBottom, int OverlayId) {
mWidth = width;
mHeight = height;
mGapLeft = GapLeft;
mGapRight = GapRight;
mGapTop = GapTop;
mGapBottom = GapBottom;
mOverlayId = OverlayId;
}
//--------------------------------------------------------------------------------------
public void setSkinParams(int bgColor) {
mBgColor = bgColor;
}
//--------------------------------------------------------------------------------------
public void setData(List<PieItem> data, int MaxConnection) {
mDataArray = data;
mMaxConnection = MaxConnection;
mState = IS_READY_TO_DRAW;
}
//--------------------------------------------------------------------------------------
public void setState(int State) {
mState = State;
}
//--------------------------------------------------------------------------------------
public int getColorValue( int Index ) {
if (mDataArray == null) return 0;
if (Index < 0){
return ((PieItem)mDataArray.get(0)).Color;
} else if (Index >= mDataArray.size()){
return ((PieItem)mDataArray.get(mDataArray.size()-1)).Color;
} else {
return ((PieItem)mDataArray.get(mDataArray.size()-1)).Color;
}
}
}

View file

@ -15,6 +15,11 @@ import net.osmand.FavouritePoint;
import net.osmand.GPXUtilities;
import net.osmand.GPXUtilities.GPXFile;
import net.osmand.GPXUtilities.WptPt;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.NavigationService;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.PoiFiltersHelper;
import net.osmand.plus.ProgressDialogImplementation;
import net.osmand.LogUtil;
import net.osmand.access.AccessibleToast;
import net.osmand.plus.activities.DayNightHelper;
@ -40,6 +45,8 @@ import android.os.Handler;
import android.text.format.DateFormat;
import android.widget.Toast;
import com.bidforfix.andorid.BidForFixHelper;
public class OsmandApplication extends Application {
public static final String EXCEPTION_PATH = ResourceManager.APP_DIR + "exception.log"; //$NON-NLS-1$
private static final org.apache.commons.logging.Log LOG = LogUtil.getLog(OsmandApplication.class);
@ -59,7 +66,8 @@ public class OsmandApplication extends Application {
DayNightHelper daynightHelper;
NavigationService navigationService;
RendererRegistry rendererRegistry;
BidForFixHelper bidforfix;
// start variables
private ProgressDialogImplementation startDialog;
private List<String> startingWarnings;
@ -78,6 +86,7 @@ public class OsmandApplication extends Application {
routingHelper = new RoutingHelper(osmandSettings, this, player);
manager = new ResourceManager(this);
daynightHelper = new DayNightHelper(this);
bidforfix = new BidForFixHelper("osmand.net", getString(R.string.default_buttons_support), getString(R.string.default_buttons_cancel));
uiHandler = new Handler();
rendererRegistry = new RendererRegistry();
checkPrefferedLocale();
@ -93,6 +102,9 @@ public class OsmandApplication extends Application {
if (routingHelper != null) {
routingHelper.getVoiceRouter().onApplicationTerminate(getApplicationContext());
}
if (bidforfix != null) {
bidforfix.onDestroy();
}
}
public RendererRegistry getRendererRegistry() {
@ -304,6 +316,11 @@ public class OsmandApplication extends Application {
public void setNavigationService(NavigationService navigationService) {
this.navigationService = navigationService;
}
public BidForFixHelper getBidForFix() {
return bidforfix;
}
public synchronized void closeApplication() {
if (applicationInitializing) {
@ -464,5 +481,4 @@ public class OsmandApplication extends Application {
}
}
}

View file

@ -0,0 +1,14 @@
package net.osmand.plus.activities;
import net.osmand.plus.OsmandApplication;
import com.bidforfix.andorid.BidForFixActivity;
import com.bidforfix.andorid.BidForFixHelper;
public class OsmandBidForFixActivity extends BidForFixActivity {
@Override
public BidForFixHelper getBidForFixHelper() {
return ((OsmandApplication) getApplication()).getBidForFix();
}
}

View file

@ -71,6 +71,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
private Preference saveCurrentTrack;
private Preference testVoiceCommands;
private Preference localOpenstreetmapPoints;
private Preference bidforfix;
private EditTextPreference applicationDir;
private ListPreference applicationModePreference;
@ -172,6 +173,9 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
String[] entrieValues;
PreferenceScreen screen = getPreferenceScreen();
osmandSettings = OsmandApplication.getSettings();
// BidForFixHelper bidForFixHelper = getMyApplication().getBidForFix();
// bidForFixHelper.generatePreferenceList(screen, getString(R.string.support_new_features), this);
registerBooleanPreference(osmandSettings.SHOW_VIEW_ANGLE,screen);
registerBooleanPreference(osmandSettings.USE_TRACKBALL_FOR_MOVEMENTS,screen);
@ -354,8 +358,8 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
applicationDir.setOnPreferenceChangeListener(this);
localOpenstreetmapPoints = (Preference) screen.findPreference(OsmandSettings.LOCAL_OPENSTREETMAP_POINTS);
localOpenstreetmapPoints.setOnPreferenceClickListener(this);
bidforfix = (Preference) screen.findPreference("bidforfix");
bidforfix.setOnPreferenceClickListener(this);
broadcastReceiver = new BroadcastReceiver(){
@Override
@ -818,6 +822,9 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
} else if(preference == localOpenstreetmapPoints){
startActivity(new Intent(this, LocalOpenstreetmapActivity.class));
return true;
} else if(preference == bidforfix){
startActivity(new Intent(this, OsmandBidForFixActivity.class));
return true;
}
return false;
}