Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
dieterbeelaert committed Jul 24, 2014
2 parents 57bacb8 + a6a4c8d commit bef2778
Show file tree
Hide file tree
Showing 29 changed files with 89 additions and 112 deletions.
Binary file not shown.
Binary file removed app/src/main/assets/fonts/Uni Sans Heavy Italic.otf
Binary file not shown.
Binary file removed app/src/main/assets/fonts/Uni Sans Heavy.otf
Binary file not shown.
Binary file removed app/src/main/assets/fonts/Uni Sans Thin Italic.otf
Binary file not shown.
Binary file removed app/src/main/assets/fonts/Uni Sans Thin.otf
Binary file not shown.
Binary file removed app/src/main/assets/fonts/Uni-Sans-Bold.otf
Binary file not shown.
Binary file removed app/src/main/assets/fonts/Uni-Sans-Book.otf
Binary file not shown.
Binary file removed app/src/main/assets/fonts/Uni-Sans-Regular.otf
Binary file not shown.
Binary file removed app/src/main/assets/fonts/Uni-Sans-SemiBold.otf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,20 @@
import be.artoria.belfortapp.R;
import be.artoria.belfortapp.app.PrefUtils;

public class BaseActivity extends FragmentActivity {
protected static Typeface book;
protected static Typeface athelas;
protected static Typeface regular;
protected static Typeface semibold;
protected static Typeface bold;
public class BaseActivity extends ActionBarActivity {

protected static Typeface athelas;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActionBar ab = getActionBar();
final ActionBar ab = getActionBar();
if(ab != null ) {
ab.setDisplayHomeAsUpEnabled(true);
ab.setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.color2)));
}
PrefUtils.loadLanguage(this);

athelas = Typeface.createFromAsset(getAssets(), "fonts/Athelas.ttc");
regular = Typeface.createFromAsset(getAssets(), "fonts/Uni-Sans-Regular.otf");
semibold = Typeface.createFromAsset(getAssets(), "fonts/Uni-Sans-SemiBold.otf");
bold = Typeface.createFromAsset(getAssets(), "fonts/Uni-Sans-Bold.otf");
book = Typeface.createFromAsset(getAssets(), "fonts/Uni-Sans-Book.otf");
}


Expand All @@ -58,7 +49,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if(id == android.R.id.home){
Intent i = new Intent(this,MainActivity.class);
final Intent i = new Intent(this,MainActivity.class);
startActivity(i);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public class LanguageChoiceActivity extends BaseActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_language_choice);
TextView tv = (TextView) findViewById(R.id.to);
final TextView tv = (TextView) findViewById(R.id.to);
tv.setTypeface(athelas);
TextView tv1 = (TextView) findViewById(R.id.string_welcome);
final TextView tv1 = (TextView) findViewById(R.id.string_welcome);
tv1.setTypeface(athelas);
TextView tv2 = (TextView) findViewById(R.id.string_belfry);
final TextView tv2 = (TextView) findViewById(R.id.string_belfry);
tv2.setTypeface(athelas);
TextView tv3 = (TextView) findViewById(R.id.string_choose_language);
final TextView tv3 = (TextView) findViewById(R.id.string_choose_language);
tv3.setTypeface(athelas);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,11 @@

public class MainActivity extends BaseActivity {
MainAdapter menuAdapter;
private static String dataSetUrl;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
dataSetUrl = getResources().getString(R.string.dataset_url);
initGui();
}

Expand All @@ -66,8 +64,8 @@ public static void downloadData() {
/* Either there is no last download ( case == 0)
* or it is older than 12 hours, which is 43200000 milliseconds according to google */
// TODO change this back!
if((lastDownload == 0 || timeSinceLastDownload > 5*60*1000) && !downloading){
//if((lastDownload == 0 || timeSinceLastDownload > 43200000) && !downloading){
// if((lastDownload == 0 || timeSinceLastDownload > 5*60*1000) && !downloading){
if((lastDownload == 0 || timeSinceLastDownload > 1000*60*60*6) && !downloading){
downloading = true;
Log.i(PrefUtils.TAG,"Started downloading in the background");
new DownloadDataTask().execute(PrefUtils.DATASET_URL);
Expand All @@ -91,7 +89,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
return super.onOptionsItemSelected(item);
}

Expand All @@ -100,13 +97,13 @@ private void initGui(){
final ListView lstMenu = (ListView)findViewById(R.id.lstMenu);
final Button btnSettings = (Button)findViewById(R.id.btnSettings);
final Button btnAbout = (Button)findViewById(R.id.btnAbout);
String[] strings = getResources().getStringArray(R.array.lstMenu);
Drawable[] drawables = new Drawable[]{
final String[] strings = getResources().getStringArray(R.array.lstMenu);
final Drawable[] drawables = new Drawable[]{
getResources().getDrawable((R.drawable.panorama)),
getResources().getDrawable((R.drawable.menu)),
getResources().getDrawable((R.drawable.route))
};
List<DescriptionRow> list = new ArrayList<DescriptionRow>();
final List<DescriptionRow> list = new ArrayList<DescriptionRow>();
for (int i = 0; i < strings.length; i++) {
list.add(new DescriptionRow(drawables[i],strings[i]));
}
Expand Down Expand Up @@ -177,7 +174,7 @@ private boolean deviceSupported() {
private static class DownloadDataTask extends AsyncTask<String, Void, String> {
@Override
protected String doInBackground(String... urls) {
String response = "";
StringBuilder response = new StringBuilder();
for (String url : urls) {
final DefaultHttpClient client = new DefaultHttpClient();
final HttpGet httpGet = new HttpGet(url);
Expand All @@ -186,16 +183,16 @@ protected String doInBackground(String... urls) {
final InputStream content = execute.getEntity().getContent();

final BufferedReader buffer = new BufferedReader(new InputStreamReader(content));
String s = "";
String s;
while ((s = buffer.readLine()) != null) {
response += s;
response.append(s);
}

} catch (final Exception e) {
e.printStackTrace();
}
}
return response;
return response.toString();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import be.artoria.belfortapp.app.DataManager;
import be.artoria.belfortapp.app.POI;
import be.artoria.belfortapp.app.RouteManager;
import be.artoria.belfortapp.app.ScreenUtils;
import be.artoria.belfortapp.mixare.MixView;

public class MonumentDetailActivity extends BaseActivity {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void drop(int from, int to)
{
if (from != to)
{
POI item = adapter.getItem(from);
final POI item = adapter.getItem(from);
adapter.remove(item);
adapter.insert(item, to);
//recalculate route
Expand Down Expand Up @@ -70,7 +70,7 @@ protected void onCreate(Bundle savedInstanceState) {
.add(R.id.container, mapFragment)
.commit();
}else{
MapFragment mfrag = (MapFragment) getSupportFragmentManager().findFragmentById(R.id.container);
final MapFragment mfrag = (MapFragment) getSupportFragmentManager().findFragmentById(R.id.container);
mfrag.isFullscreen = false;
}
}
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/be/artoria/belfortapp/app/ArtoriaApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.app.Application;

import be.artoria.belfortapp.activities.MainActivity;
import be.artoria.belfortapp.sql.POIDAO;

/**
* Created by Laurens on 03/07/2014.
Expand All @@ -17,5 +16,4 @@ public void onCreate() {
MainActivity.downloadData();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Created by Dieter Beelaert on 7/07/2014.
*/
public class ArtoriaOverlayItem extends OverlayItem {
public POI poi;
public final POI poi;

public ArtoriaOverlayItem(POI poi) {
super(poi.getName(),poi.getDescription(), new GeoPoint(Double.parseDouble(poi.lat),Double.parseDouble(poi.lon)));
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/be/artoria/belfortapp/app/DataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ public enum Language{
public static Language lang = null;

private static final DataManager INSTANCE = new DataManager();
private static List<POI> poiList = new ArrayList<POI>();
public static POIDAO poidao = new POIDAO(PrefUtils.getContext());
private static final List<POI> poiList = new ArrayList<POI>();
public static final POIDAO poidao = new POIDAO(PrefUtils.getContext());


/*Route start point (belfort Ghent) needs to be replaced by current location in the future*/
public static final double BELFORT_LON = 3.724833;
public static final double BELFORT_LAT = 51.053623;
public static final double BELFORT_LON = 3.724801;//3.724833;
public static final double BELFORT_LAT = 51.053541;//51.053623;

// Private constructor prevents instantiation from other classes
private DataManager() { }
Expand All @@ -43,7 +43,7 @@ public Language getCurrentLanguage(){
}

public static List<POI> getAll(){
/* poiList might very well be empty after resuming the app */
/* poiList might very well be empty after resuming the app */
if(poiList.isEmpty()){
try {
poidao.open();
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/java/be/artoria/belfortapp/app/POI.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public boolean equals(Object o) {
}

public String getName() {
DataManager.Language lang = DataManager.getInstance().getCurrentLanguage();
final DataManager.Language lang = DataManager.getInstance().getCurrentLanguage();
switch(lang){
case ENGLISH:
return this.ENG_name;
Expand All @@ -72,12 +72,12 @@ public String getName() {
case DUTCH:
default:
/*Default is Dutch*/
return this.NL_name;
return this.NL_name;
}
}

public String getDescription() {
DataManager.Language lang = DataManager.getInstance().getCurrentLanguage();
final DataManager.Language lang = DataManager.getInstance().getCurrentLanguage();
switch(lang){
case ENGLISH:
return this.ENG_description;
Expand Down Expand Up @@ -113,7 +113,7 @@ public static Drawable getTypePopupImgLandscape(int type, Context context){
private static final int POPUP_LANDSCAPE = 2;

private static Drawable getTypeImage(int type, Context context, int viewType){
Resources res = context.getResources();
final Resources res = context.getResources();
switch(type){
case BOAT: return res.getDrawable(getCorrectImageId(R.drawable.drag_boat,R.drawable.popup_boat,R.drawable.popup_boat_land,viewType));
case CASTLE: return res.getDrawable(getCorrectImageId(R.drawable.drag_castle,R.drawable.popup_castle,R.drawable.popup_castle_land,viewType));
Expand Down
19 changes: 9 additions & 10 deletions app/src/main/java/be/artoria/belfortapp/app/PrefUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,25 +94,25 @@ public static DataManager.Language getLanguage() {
public static void saveLanguage(DataManager.Language lang){
String lng = "nl";//default dutch
if(lang == DataManager.Language.ENGLISH){lng="en";}
if(lang == DataManager.Language.FRENCH){lng = "fr";}
if(lang == DataManager.Language.FRENCH){lng ="fr";}
getPrefs().edit().putString(ARG_LANG,lng).apply();
}

public static void loadLanguage(Context context){
String lang = getPrefs().getString(ARG_LANG,"nl");/*Default dutch*/
Locale locale = new Locale(lang);
final String lang = getPrefs().getString(ARG_LANG,"nl");/*Default dutch*/
final Locale locale = new Locale(lang);
LanguageChoiceActivity.setLang(locale,context);
}

public static List<POI> getSavedRoute(){
String poiIds = getPrefs().getString(ARG_ROUTE,"");
List<POI> toReturn = new ArrayList<POI>();
final String poiIds = getPrefs().getString(ARG_ROUTE,"");
final List<POI> toReturn = new ArrayList<POI>();
if(!poiIds.equals("")){
String[] splitted = poiIds.split(",");
final String[] splitted = poiIds.split(",");
for(String s: splitted){
try {
int id = Integer.parseInt(s);
POI toAdd = DataManager.getPOIbyID(id);
final int id = Integer.parseInt(s);
final POI toAdd = DataManager.getPOIbyID(id);
toReturn.add(toAdd);
}catch(Exception ex){
//can't parse string to int ....
Expand All @@ -123,7 +123,7 @@ public static List<POI> getSavedRoute(){
}

public static void saveRoute(List<POI> route){
StringBuilder sb = new StringBuilder();
final StringBuilder sb = new StringBuilder();
for(POI poi : route){
sb.append(poi.id);
sb.append(",");
Expand All @@ -144,5 +144,4 @@ public static boolean isFirstPanoramaTime() {
return getPrefs().getBoolean(ARG_FIRS_PANORAMA_TIME, true);
}


}
15 changes: 0 additions & 15 deletions app/src/main/java/be/artoria/belfortapp/app/ScreenUtils.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* Created by Dieter Beelaert on 4/07/2014.
*/
public class DescriptionRow {
public Drawable imageDescription;
public String description;
public final Drawable imageDescription;
public final String description;

public DescriptionRow(Drawable imageDescription, String description){
this.imageDescription = imageDescription;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ private class ViewHolder {
}

public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
POI rowItem = getItem(position);
final ViewHolder holder ;
final POI rowItem = getItem(position);

LayoutInflater mInflater = (LayoutInflater) context
final LayoutInflater mInflater = (LayoutInflater) context
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.route_list_item, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ private class ViewHolder {
}

public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
DescriptionRow rowItem = getItem(position);
final ViewHolder holder;
final DescriptionRow rowItem = getItem(position);

LayoutInflater mInflater = (LayoutInflater) context
final LayoutInflater mInflater = (LayoutInflater) context
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.main_list_item, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ private class ViewHolder {
}

public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
DescriptionRow rowItem = getItem(position);
final ViewHolder holder;
final DescriptionRow rowItem = getItem(position);

LayoutInflater mInflater = (LayoutInflater) context
final LayoutInflater mInflater = (LayoutInflater) context
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
convertView = mInflater.inflate(R.layout.description_list_item, null);
Expand Down
Loading

0 comments on commit bef2778

Please sign in to comment.