|
@@ -2,9 +2,6 @@ package com.ivalentin.margolariak;
|
|
|
|
|
|
|
|
import java.math.BigInteger;
|
|
import java.math.BigInteger;
|
|
|
import java.security.SecureRandom;
|
|
import java.security.SecureRandom;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
|
|
-import java.util.Calendar;
|
|
|
|
|
-import java.util.Locale;
|
|
|
|
|
|
|
|
|
|
import android.app.Activity;
|
|
import android.app.Activity;
|
|
|
import android.app.Fragment;
|
|
import android.app.Fragment;
|
|
@@ -55,64 +52,52 @@ public class MainActivity extends Activity {
|
|
|
//Alarm to get location and notifications.
|
|
//Alarm to get location and notifications.
|
|
|
private AlarmReceiver notificationAlarm;
|
|
private AlarmReceiver notificationAlarm;
|
|
|
|
|
|
|
|
- //The menu entries
|
|
|
|
|
- private RelativeLayout menuItem[];
|
|
|
|
|
private TextView menuText[];
|
|
private TextView menuText[];
|
|
|
private ImageView menuImage[];
|
|
private ImageView menuImage[];
|
|
|
|
|
|
|
|
//Handler to periodically check for location updates
|
|
//Handler to periodically check for location updates
|
|
|
private final Handler locationHandler = new Handler();
|
|
private final Handler locationHandler = new Handler();
|
|
|
// Code to check for location updates
|
|
// Code to check for location updates
|
|
|
|
|
+ private MainActivity activity = this;
|
|
|
private final Runnable checkForLocation = new Runnable() {
|
|
private final Runnable checkForLocation = new Runnable() {
|
|
|
@Override
|
|
@Override
|
|
|
public void run() {
|
|
public void run() {
|
|
|
|
|
|
|
|
- //Get location page and parse it
|
|
|
|
|
- boolean result = false;
|
|
|
|
|
- FetchURL fu = new FetchURL();
|
|
|
|
|
- //TODO: This needs a simple API too
|
|
|
|
|
- fu.Run(GM.SERVER + "/app/location.php");
|
|
|
|
|
- String lat = "", lon = "";
|
|
|
|
|
- String o = fu.getOutput().toString();
|
|
|
|
|
- Log.d("Location", "Fetched location page");
|
|
|
|
|
- if (o.contains("<location>none</location>"))
|
|
|
|
|
- result = false;
|
|
|
|
|
- if (o.contains("<lat>") && o.contains("<lon>")) {
|
|
|
|
|
- lat = o.substring(o.indexOf("<lat>") + 5, o.indexOf("</lat>"));
|
|
|
|
|
- lon = o.substring(o.indexOf("<lon>") + 5, o.indexOf("</lon>"));
|
|
|
|
|
- result = true;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //TODO: Store in database
|
|
|
|
|
- SharedPreferences settings = getSharedPreferences(GM.PREFERENCES.PREFERNCES, Context.MODE_PRIVATE);
|
|
|
|
|
- SharedPreferences.Editor editor = settings.edit();
|
|
|
|
|
- if (result) {
|
|
|
|
|
- editor.putLong(GM.PREF_GM_LATITUDE, Double.doubleToLongBits(Double.parseDouble(lat)));
|
|
|
|
|
- editor.putLong(GM.PREF_GM_LONGITUDE, Double.doubleToLongBits(Double.parseDouble(lon)));
|
|
|
|
|
- editor.putString(GM.PREF_GM_LOCATION, new SimpleDateFormat("yyyyMMddHHmmss", Locale.US).format(Calendar.getInstance().getTime()));
|
|
|
|
|
-
|
|
|
|
|
- //Show menu entry
|
|
|
|
|
- if (menuItem[1] != null) {
|
|
|
|
|
- menuItem[1].setVisibility(View.VISIBLE);
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- editor.putString(GM.PREF_GM_LOCATION, GM.DEFAULT_PREF_GM_LOCATION);
|
|
|
|
|
- if (menuItem[1] != null) {
|
|
|
|
|
- menuItem[1].setVisibility(View.GONE);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- editor.apply();
|
|
|
|
|
|
|
+ new ReceiveLocation(activity).execute();
|
|
|
|
|
|
|
|
//Repeat this the same runnable code block again another th specified interval
|
|
//Repeat this the same runnable code block again another th specified interval
|
|
|
- locationHandler.postDelayed(checkForLocation, GM.INTERVAL_LOCATION);
|
|
|
|
|
|
|
+ locationHandler.postDelayed(checkForLocation, GM.LOCATION.INTERVAL);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* ATTENTION: This was auto-generated to implement the App Indexing API.
|
|
* ATTENTION: This was auto-generated to implement the App Indexing API.
|
|
|
* See https://g.co/AppIndexing/AndroidStudio for more information.
|
|
* See https://g.co/AppIndexing/AndroidStudio for more information.
|
|
|
*/
|
|
*/
|
|
|
private GoogleApiClient client;
|
|
private GoogleApiClient client;
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Enables o disables the location section.
|
|
|
|
|
+ *
|
|
|
|
|
+ * Shows or hiddes the menu entry and the home fragment,
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param report True to show, false to hide.
|
|
|
|
|
+ */
|
|
|
|
|
+ public void gotLocation(boolean report){
|
|
|
|
|
+ if (report) {
|
|
|
|
|
+ findViewById(R.id.rl_menu_location).setVisibility(View.VISIBLE);
|
|
|
|
|
+ if (findViewById(R.id.ll_home_section_location) != null){
|
|
|
|
|
+ findViewById(R.id.ll_home_section_location).setVisibility(View.VISIBLE);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ else {
|
|
|
|
|
+ findViewById(R.id.rl_menu_location).setVisibility(View.GONE);
|
|
|
|
|
+ if (findViewById(R.id.ll_home_section_location) != null) {
|
|
|
|
|
+ findViewById(R.id.ll_home_section_location).setVisibility(View.GONE);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//Not referenced in code.
|
|
//Not referenced in code.
|
|
|
public void showMenu(View v) {
|
|
public void showMenu(View v) {
|
|
|
PopupMenu popup = new PopupMenu(this, v);
|
|
PopupMenu popup = new PopupMenu(this, v);
|
|
@@ -170,21 +155,21 @@ public class MainActivity extends Activity {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
switch (section) {
|
|
switch (section) {
|
|
|
- case GM.SECTION_HOME:
|
|
|
|
|
|
|
+ case GM.SECTION.HOME:
|
|
|
fragment = new HomeLayout();
|
|
fragment = new HomeLayout();
|
|
|
title = getString(R.string.menu_home);
|
|
title = getString(R.string.menu_home);
|
|
|
menuText[0].setTypeface(null, Typeface.BOLD);
|
|
menuText[0].setTypeface(null, Typeface.BOLD);
|
|
|
menuImage[0].getLayoutParams().height = 8;
|
|
menuImage[0].getLayoutParams().height = 8;
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
- case GM.SECTION_LOCATION:
|
|
|
|
|
|
|
+ case GM.SECTION.LOCATION:
|
|
|
fragment = new LocationLayout();
|
|
fragment = new LocationLayout();
|
|
|
title = getString(R.string.menu_location);
|
|
title = getString(R.string.menu_location);
|
|
|
menuText[1].setTypeface(null, Typeface.BOLD);
|
|
menuText[1].setTypeface(null, Typeface.BOLD);
|
|
|
menuImage[1].getLayoutParams().height = 8;
|
|
menuImage[1].getLayoutParams().height = 8;
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
- case GM.SECTION_LABLANCA:
|
|
|
|
|
|
|
+ case GM.SECTION.LABLANCA:
|
|
|
//Get settings
|
|
//Get settings
|
|
|
SharedPreferences sharedData = getSharedPreferences(GM.DATA.DATA, Context.MODE_PRIVATE);
|
|
SharedPreferences sharedData = getSharedPreferences(GM.DATA.DATA, Context.MODE_PRIVATE);
|
|
|
if (sharedData.getBoolean(GM.DATA.KEY.LABLANCA, GM.DATA.DEFAULT.LABLANCA)) {
|
|
if (sharedData.getBoolean(GM.DATA.KEY.LABLANCA, GM.DATA.DEFAULT.LABLANCA)) {
|
|
@@ -197,39 +182,39 @@ public class MainActivity extends Activity {
|
|
|
menuImage[2].getLayoutParams().height = 8;
|
|
menuImage[2].getLayoutParams().height = 8;
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
- case GM.SECTION_LABLANCA_SCHEDULE:
|
|
|
|
|
|
|
+ case GM.SECTION.SCHEDULE:
|
|
|
fragment = new ScheduleLayout();
|
|
fragment = new ScheduleLayout();
|
|
|
- bundle.putInt(GM.SCHEDULE, GM.SECTION_LABLANCA_SCHEDULE);
|
|
|
|
|
|
|
+ bundle.putInt(GM.SCHEDULE.KEY, GM.SCHEDULE.MARGOLARIAK);
|
|
|
fragment.setArguments(bundle);
|
|
fragment.setArguments(bundle);
|
|
|
title = getString(R.string.menu_lablanca_schedule);
|
|
title = getString(R.string.menu_lablanca_schedule);
|
|
|
menuText[2].setTypeface(null, Typeface.BOLD);
|
|
menuText[2].setTypeface(null, Typeface.BOLD);
|
|
|
menuImage[2].getLayoutParams().height = 8;
|
|
menuImage[2].getLayoutParams().height = 8;
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
- case GM.SECTION_LABLANCA_GM_SCHEDULE:
|
|
|
|
|
|
|
+ case GM.SECTION.GM_SCHEDULE:
|
|
|
fragment = new ScheduleLayout();
|
|
fragment = new ScheduleLayout();
|
|
|
- bundle.putInt(GM.SCHEDULE, GM.SECTION_LABLANCA_GM_SCHEDULE);
|
|
|
|
|
|
|
+ bundle.putInt(GM.SCHEDULE.KEY, GM.SCHEDULE.MARGOLARIAK);
|
|
|
fragment.setArguments(bundle);
|
|
fragment.setArguments(bundle);
|
|
|
title = getString(R.string.menu_lablanca_gm_schedule);
|
|
title = getString(R.string.menu_lablanca_gm_schedule);
|
|
|
menuText[2].setTypeface(null, Typeface.BOLD);
|
|
menuText[2].setTypeface(null, Typeface.BOLD);
|
|
|
menuImage[2].getLayoutParams().height = 8;
|
|
menuImage[2].getLayoutParams().height = 8;
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
- case GM.SECTION_ACTIVITIES:
|
|
|
|
|
|
|
+ case GM.SECTION.ACTIVITIES:
|
|
|
fragment = new ActivityLayout();
|
|
fragment = new ActivityLayout();
|
|
|
title = getString(R.string.menu_activities);
|
|
title = getString(R.string.menu_activities);
|
|
|
menuText[3].setTypeface(null, Typeface.BOLD);
|
|
menuText[3].setTypeface(null, Typeface.BOLD);
|
|
|
menuImage[3].getLayoutParams().height = 8;
|
|
menuImage[3].getLayoutParams().height = 8;
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
- case GM.SECTION_BLOG:
|
|
|
|
|
|
|
+ case GM.SECTION.BLOG:
|
|
|
fragment = new BlogLayout();
|
|
fragment = new BlogLayout();
|
|
|
title = getString(R.string.menu_blog);
|
|
title = getString(R.string.menu_blog);
|
|
|
menuText[4].setTypeface(null, Typeface.BOLD);
|
|
menuText[4].setTypeface(null, Typeface.BOLD);
|
|
|
menuImage[4].getLayoutParams().height = 8;
|
|
menuImage[4].getLayoutParams().height = 8;
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
- case GM.SECTION_GALLERY:
|
|
|
|
|
|
|
+ case GM.SECTION.GALLERY:
|
|
|
fragment = new GalleryLayout();
|
|
fragment = new GalleryLayout();
|
|
|
title = getString(R.string.menu_blog);
|
|
title = getString(R.string.menu_blog);
|
|
|
menuText[5].setTypeface(null, Typeface.BOLD);
|
|
menuText[5].setTypeface(null, Typeface.BOLD);
|
|
@@ -265,9 +250,9 @@ public class MainActivity extends Activity {
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
|
|
|
//Get intent extras
|
|
//Get intent extras
|
|
|
- String action = getIntent().getStringExtra(GM.EXTRA_ACTION);
|
|
|
|
|
- String actionText = getIntent().getStringExtra(GM.EXTRA_TEXT);
|
|
|
|
|
- String actionTitle = getIntent().getStringExtra(GM.EXTRA_TITLE);
|
|
|
|
|
|
|
+ String action = getIntent().getStringExtra(GM.EXTRA.ACTION);
|
|
|
|
|
+ String actionText = getIntent().getStringExtra(GM.EXTRA.TEXT);
|
|
|
|
|
+ String actionTitle = getIntent().getStringExtra(GM.EXTRA.TITLE);
|
|
|
|
|
|
|
|
//Set an alarm for notifications..
|
|
//Set an alarm for notifications..
|
|
|
//Wait a little
|
|
//Wait a little
|
|
@@ -304,7 +289,7 @@ public class MainActivity extends Activity {
|
|
|
setContentView(R.layout.activity_main);
|
|
setContentView(R.layout.activity_main);
|
|
|
|
|
|
|
|
//Assign menu items
|
|
//Assign menu items
|
|
|
- menuItem = new RelativeLayout[6];
|
|
|
|
|
|
|
+ RelativeLayout[] menuItem = new RelativeLayout[6];
|
|
|
menuItem[0] = (RelativeLayout) findViewById(R.id.rl_menu_home);
|
|
menuItem[0] = (RelativeLayout) findViewById(R.id.rl_menu_home);
|
|
|
menuItem[1] = (RelativeLayout) findViewById(R.id.rl_menu_location);
|
|
menuItem[1] = (RelativeLayout) findViewById(R.id.rl_menu_location);
|
|
|
menuItem[2] = (RelativeLayout) findViewById(R.id.rl_menu_lablanca);
|
|
menuItem[2] = (RelativeLayout) findViewById(R.id.rl_menu_lablanca);
|
|
@@ -334,37 +319,37 @@ public class MainActivity extends Activity {
|
|
|
menuItem[0].setOnClickListener(new OnClickListener() {
|
|
menuItem[0].setOnClickListener(new OnClickListener() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
public void onClick(View v) {
|
|
|
- loadSection(GM.SECTION_HOME);
|
|
|
|
|
|
|
+ loadSection(GM.SECTION.HOME);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
menuItem[1].setOnClickListener(new OnClickListener() {
|
|
menuItem[1].setOnClickListener(new OnClickListener() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
public void onClick(View v) {
|
|
|
- loadSection(GM.SECTION_LOCATION);
|
|
|
|
|
|
|
+ loadSection(GM.SECTION.LOCATION);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
menuItem[2].setOnClickListener(new OnClickListener() {
|
|
menuItem[2].setOnClickListener(new OnClickListener() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
public void onClick(View v) {
|
|
|
- loadSection(GM.SECTION_LABLANCA);
|
|
|
|
|
|
|
+ loadSection(GM.SECTION.LABLANCA);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
menuItem[3].setOnClickListener(new OnClickListener() {
|
|
menuItem[3].setOnClickListener(new OnClickListener() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
public void onClick(View v) {
|
|
|
- loadSection(GM.SECTION_ACTIVITIES);
|
|
|
|
|
|
|
+ loadSection(GM.SECTION.ACTIVITIES);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
menuItem[4].setOnClickListener(new OnClickListener() {
|
|
menuItem[4].setOnClickListener(new OnClickListener() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
public void onClick(View v) {
|
|
|
- loadSection(GM.SECTION_BLOG);
|
|
|
|
|
|
|
+ loadSection(GM.SECTION.BLOG);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
menuItem[5].setOnClickListener(new OnClickListener() {
|
|
menuItem[5].setOnClickListener(new OnClickListener() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
public void onClick(View v) {
|
|
|
- loadSection(GM.SECTION_GALLERY);
|
|
|
|
|
|
|
+ loadSection(GM.SECTION.GALLERY);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -372,13 +357,11 @@ public class MainActivity extends Activity {
|
|
|
SharedPreferences sharedData = getSharedPreferences(GM.PREFERENCES.PREFERNCES, Context.MODE_PRIVATE);
|
|
SharedPreferences sharedData = getSharedPreferences(GM.PREFERENCES.PREFERNCES, Context.MODE_PRIVATE);
|
|
|
SharedPreferences.Editor dataEditor = sharedData.edit();
|
|
SharedPreferences.Editor dataEditor = sharedData.edit();
|
|
|
|
|
|
|
|
- //TODO: Read database. If there is a recent location, show the menu entry
|
|
|
|
|
-
|
|
|
|
|
//If the user code is not set, generate one
|
|
//If the user code is not set, generate one
|
|
|
if (sharedData.getString(GM.DATA.KEY.USER, GM.DATA.DEFAULT.USER).length() == GM.DATA.DEFAULT.USER.length()) {
|
|
if (sharedData.getString(GM.DATA.KEY.USER, GM.DATA.DEFAULT.USER).length() == GM.DATA.DEFAULT.USER.length()) {
|
|
|
SecureRandom random = new SecureRandom();
|
|
SecureRandom random = new SecureRandom();
|
|
|
String newCode = new BigInteger(130, random).toString(32).substring(0, 16);
|
|
String newCode = new BigInteger(130, random).toString(32).substring(0, 16);
|
|
|
- dataEditor.putString(GM.USER_CODE, newCode);
|
|
|
|
|
|
|
+ dataEditor.putString(GM.DATA.KEY.USER, newCode);
|
|
|
dataEditor.apply();
|
|
dataEditor.apply();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -399,7 +382,7 @@ public class MainActivity extends Activity {
|
|
|
sync();
|
|
sync();
|
|
|
|
|
|
|
|
//Load initial section
|
|
//Load initial section
|
|
|
- loadSection(GM.SECTION_HOME);
|
|
|
|
|
|
|
+ loadSection(GM.SECTION.HOME);
|
|
|
|
|
|
|
|
//If the intent had extras (from notifications), do something
|
|
//If the intent had extras (from notifications), do something
|
|
|
if (actionText != null) {
|
|
if (actionText != null) {
|
|
@@ -448,7 +431,7 @@ public class MainActivity extends Activity {
|
|
|
if (action != null) {
|
|
if (action != null) {
|
|
|
switch (action) {
|
|
switch (action) {
|
|
|
|
|
|
|
|
- case GM.EXTRA_ACTION_LABLANCA:
|
|
|
|
|
|
|
+ case GM.EXTRA.SECTION.LABLANCA:
|
|
|
|
|
|
|
|
//Set up the action button
|
|
//Set up the action button
|
|
|
btDialogAction.setVisibility(View.VISIBLE);
|
|
btDialogAction.setVisibility(View.VISIBLE);
|
|
@@ -457,15 +440,15 @@ public class MainActivity extends Activity {
|
|
|
@Override
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
public void onClick(View v) {
|
|
|
dialog.dismiss();
|
|
dialog.dismiss();
|
|
|
- loadSection(GM.SECTION_LABLANCA);
|
|
|
|
|
|
|
+ loadSection(GM.SECTION.LABLANCA);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
- case GM.EXTRA_ACTION_LOCATION:
|
|
|
|
|
|
|
+ case GM.EXTRA.SECTION.LOCATION:
|
|
|
|
|
|
|
|
//TODO: Read from database
|
|
//TODO: Read from database
|
|
|
- if (!sharedData.getString(GM.PREF_GM_LOCATION, GM.DEFAULT_PREF_GM_LOCATION).equals(GM.DEFAULT_PREF_GM_LOCATION)) {
|
|
|
|
|
|
|
+ /*if (!sharedData.getString(GM.PREF_GM_LOCATION, GM.DEFAULT_PREF_GM_LOCATION).equals(GM.DEFAULT_PREF_GM_LOCATION)) {
|
|
|
//Set up the action button if location is reported
|
|
//Set up the action button if location is reported
|
|
|
btDialogAction.setVisibility(View.VISIBLE);
|
|
btDialogAction.setVisibility(View.VISIBLE);
|
|
|
btDialogAction.setText(this.getApplicationContext().getString(R.string.notification_action_location));
|
|
btDialogAction.setText(this.getApplicationContext().getString(R.string.notification_action_location));
|
|
@@ -477,10 +460,10 @@ public class MainActivity extends Activity {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ }*/
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
- case GM.EXTRA_ACTION_BLOG:
|
|
|
|
|
|
|
+ case GM.EXTRA.SECTION.BLOG:
|
|
|
|
|
|
|
|
//Set up the action button
|
|
//Set up the action button
|
|
|
btDialogAction.setVisibility(View.VISIBLE);
|
|
btDialogAction.setVisibility(View.VISIBLE);
|
|
@@ -489,12 +472,12 @@ public class MainActivity extends Activity {
|
|
|
@Override
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
public void onClick(View v) {
|
|
|
dialog.dismiss();
|
|
dialog.dismiss();
|
|
|
- loadSection(GM.SECTION_BLOG);
|
|
|
|
|
|
|
+ loadSection(GM.SECTION.BLOG);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
- case GM.EXTRA_ACTION_ACTIVITIES:
|
|
|
|
|
|
|
+ case GM.EXTRA.SECTION.ACTIVITIES:
|
|
|
|
|
|
|
|
//Set up the action button
|
|
//Set up the action button
|
|
|
btDialogAction.setVisibility(View.VISIBLE);
|
|
btDialogAction.setVisibility(View.VISIBLE);
|
|
@@ -503,12 +486,12 @@ public class MainActivity extends Activity {
|
|
|
@Override
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
public void onClick(View v) {
|
|
|
dialog.dismiss();
|
|
dialog.dismiss();
|
|
|
- loadSection(GM.SECTION_ACTIVITIES);
|
|
|
|
|
|
|
+ loadSection(GM.SECTION.ACTIVITIES);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
- case GM.EXTRA_ACTION_GALLERY:
|
|
|
|
|
|
|
+ case GM.EXTRA.SECTION.GALLERY:
|
|
|
|
|
|
|
|
//Set up the action button
|
|
//Set up the action button
|
|
|
btDialogAction.setVisibility(View.VISIBLE);
|
|
btDialogAction.setVisibility(View.VISIBLE);
|
|
@@ -517,12 +500,12 @@ public class MainActivity extends Activity {
|
|
|
@Override
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
public void onClick(View v) {
|
|
|
dialog.dismiss();
|
|
dialog.dismiss();
|
|
|
- loadSection(GM.SECTION_GALLERY);
|
|
|
|
|
|
|
+ loadSection(GM.SECTION.GALLERY);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
- case GM.EXTRA_ACTION_GMSCHEDULE:
|
|
|
|
|
|
|
+ case GM.EXTRA.SECTION.GMSCHEDULE:
|
|
|
|
|
|
|
|
if (festivals) {
|
|
if (festivals) {
|
|
|
//Set up the action button
|
|
//Set up the action button
|
|
@@ -532,13 +515,13 @@ public class MainActivity extends Activity {
|
|
|
@Override
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
public void onClick(View v) {
|
|
|
dialog.dismiss();
|
|
dialog.dismiss();
|
|
|
- loadSection(GM.SECTION_LABLANCA_GM_SCHEDULE);
|
|
|
|
|
|
|
+ loadSection(GM.SECTION.GM_SCHEDULE);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
- case GM.EXTRA_ACTION_CITYSCHEDULE:
|
|
|
|
|
|
|
+ case GM.EXTRA.SECTION.SCHEDULE:
|
|
|
if (festivals) {
|
|
if (festivals) {
|
|
|
//Set up the action button
|
|
//Set up the action button
|
|
|
btDialogAction.setVisibility(View.VISIBLE);
|
|
btDialogAction.setVisibility(View.VISIBLE);
|
|
@@ -547,7 +530,7 @@ public class MainActivity extends Activity {
|
|
|
@Override
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
public void onClick(View v) {
|
|
|
dialog.dismiss();
|
|
dialog.dismiss();
|
|
|
- loadSection(GM.SECTION_LABLANCA_SCHEDULE);
|
|
|
|
|
|
|
+ loadSection(GM.SECTION.SCHEDULE);
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
@@ -589,7 +572,7 @@ public class MainActivity extends Activity {
|
|
|
SQLiteDatabase db;
|
|
SQLiteDatabase db;
|
|
|
try {
|
|
try {
|
|
|
//Create database
|
|
//Create database
|
|
|
- db = openOrCreateDatabase(GM.DB_NAME, Activity.MODE_PRIVATE, null);
|
|
|
|
|
|
|
+ db = openOrCreateDatabase(GM.DB.NAME, Activity.MODE_PRIVATE, null);
|
|
|
db.execSQL(GM.DB.QUERY.CREATE.ACTIVITY);
|
|
db.execSQL(GM.DB.QUERY.CREATE.ACTIVITY);
|
|
|
db.execSQL(GM.DB.QUERY.CREATE.ACTIVITY_COMMENT);
|
|
db.execSQL(GM.DB.QUERY.CREATE.ACTIVITY_COMMENT);
|
|
|
db.execSQL(GM.DB.QUERY.CREATE.ACTIVITY_IMAGE);
|
|
db.execSQL(GM.DB.QUERY.CREATE.ACTIVITY_IMAGE);
|
|
@@ -612,7 +595,7 @@ public class MainActivity extends Activity {
|
|
|
db.execSQL(GM.DB.QUERY.CREATE.POST_COMMENT);
|
|
db.execSQL(GM.DB.QUERY.CREATE.POST_COMMENT);
|
|
|
db.execSQL(GM.DB.QUERY.CREATE.POST_IMAGE);
|
|
db.execSQL(GM.DB.QUERY.CREATE.POST_IMAGE);
|
|
|
db.execSQL(GM.DB.QUERY.CREATE.POST_TAG);
|
|
db.execSQL(GM.DB.QUERY.CREATE.POST_TAG);
|
|
|
- db.execSQL(GM.DB.QUERY.CREATE.SETTINGS);
|
|
|
|
|
|
|
+ //db.execSQL(GM.DB.QUERY.CREATE.SETTINGS);
|
|
|
db.execSQL(GM.DB.QUERY.CREATE.SPONSOR);
|
|
db.execSQL(GM.DB.QUERY.CREATE.SPONSOR);
|
|
|
db.execSQL(GM.DB.QUERY.CREATE.VERSION);
|
|
db.execSQL(GM.DB.QUERY.CREATE.VERSION);
|
|
|
db.close();
|
|
db.close();
|
|
@@ -625,9 +608,8 @@ public class MainActivity extends Activity {
|
|
|
* Creates the app database and fills it with the hard coded, default data.
|
|
* Creates the app database and fills it with the hard coded, default data.
|
|
|
*/
|
|
*/
|
|
|
private void deleteDatabase() {
|
|
private void deleteDatabase() {
|
|
|
- SQLiteDatabase db;
|
|
|
|
|
try {
|
|
try {
|
|
|
- getApplicationContext().deleteDatabase(GM.DB_NAME);
|
|
|
|
|
|
|
+ getApplicationContext().deleteDatabase(GM.DB.NAME);
|
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
|
Log.e("Error deleting database", ex.toString());
|
|
Log.e("Error deleting database", ex.toString());
|
|
|
}
|
|
}
|
|
@@ -690,7 +672,6 @@ public class MainActivity extends Activity {
|
|
|
}
|
|
}
|
|
|
} catch (Exception ex) {
|
|
} catch (Exception ex) {
|
|
|
Log.e("Error going back", "Finishing activity: " + ex.toString());
|
|
Log.e("Error going back", "Finishing activity: " + ex.toString());
|
|
|
- Log.e("RUNNABLE", "Finishing callback for location");
|
|
|
|
|
locationHandler.removeCallbacks(checkForLocation);
|
|
locationHandler.removeCallbacks(checkForLocation);
|
|
|
finish();
|
|
finish();
|
|
|
//super.onBackPressed();
|
|
//super.onBackPressed();
|
|
@@ -713,18 +694,36 @@ public class MainActivity extends Activity {
|
|
|
return super.onKeyUp(keyCode, event);
|
|
return super.onKeyUp(keyCode, event);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Overrides onResume().
|
|
|
|
|
+ * Resumes the location handler to check for location regularly.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @see Activity#onResume()
|
|
|
|
|
+ */
|
|
|
@Override
|
|
@Override
|
|
|
public void onResume() {
|
|
public void onResume() {
|
|
|
locationHandler.post(checkForLocation);
|
|
locationHandler.post(checkForLocation);
|
|
|
super.onResume();
|
|
super.onResume();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Overrides onPause().
|
|
|
|
|
+ * Stops the location handler to check for location regularly.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @see Activity#onPause()
|
|
|
|
|
+ */
|
|
|
@Override
|
|
@Override
|
|
|
public void onPause() {
|
|
public void onPause() {
|
|
|
locationHandler.removeCallbacks(checkForLocation);
|
|
locationHandler.removeCallbacks(checkForLocation);
|
|
|
super.onPause();
|
|
super.onPause();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Overrides onDestroy().
|
|
|
|
|
+ * Stops the location handler to check for location regularly.
|
|
|
|
|
+ *
|
|
|
|
|
+ * @see Activity#onDestroy()
|
|
|
|
|
+ */
|
|
|
@Override
|
|
@Override
|
|
|
public void onDestroy() {
|
|
public void onDestroy() {
|
|
|
locationHandler.removeCallbacks(checkForLocation);
|
|
locationHandler.removeCallbacks(checkForLocation);
|