|
|
@@ -77,6 +77,34 @@ public class MainActivity extends Activity {
|
|
|
*/
|
|
|
private GoogleApiClient client;
|
|
|
|
|
|
+ // Shareable URL
|
|
|
+ private String shareURL = GM.SHARE.HOME;
|
|
|
+ private String shareTitle = "";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Sets the displayed section url and localized title.
|
|
|
+ * Thy can be retrieved later with getShareLink() to share the URL.
|
|
|
+ *
|
|
|
+ * @param title The title of the displayed section.
|
|
|
+ * @param url The URL of the current section.
|
|
|
+ *
|
|
|
+ * @see MainActivity#getShareLink();
|
|
|
+ */
|
|
|
+ public void setShareLink(String title, String url){
|
|
|
+ shareTitle = title;
|
|
|
+ shareURL = url;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Returns the url of the current sections and a title.
|
|
|
+ * To be used with the share option.
|
|
|
+ *
|
|
|
+ * @return String array. Index 0 has the title of the section. Index 1 has the URL.
|
|
|
+ */
|
|
|
+ public String[] getShareLink(){
|
|
|
+ return(new String[]{shareTitle, shareURL});
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Enables o disables the location section.
|
|
|
*
|
|
|
@@ -99,13 +127,30 @@ public class MainActivity extends Activity {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //Not referenced in code.
|
|
|
+ /**
|
|
|
+ * Opens and closes the app menu.
|
|
|
+ * Not referenced in code.
|
|
|
+ *
|
|
|
+ * @param v Menu view.
|
|
|
+ */
|
|
|
public void showMenu(View v) {
|
|
|
PopupMenu popup = new PopupMenu(this, v);
|
|
|
MenuInflater inflater = popup.getMenuInflater();
|
|
|
inflater.inflate(R.menu.menu, popup.getMenu());
|
|
|
|
|
|
popup.getMenu().getItem(0).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onMenuItemClick(MenuItem item) {
|
|
|
+ Intent sendIntent = new Intent();
|
|
|
+ sendIntent.setAction(Intent.ACTION_SEND);
|
|
|
+ sendIntent.putExtra(Intent.EXTRA_TEXT, getShareLink()[0] + "\n\n" + getShareLink()[1] + "\n\n");
|
|
|
+ sendIntent.setType("text/plain");
|
|
|
+ startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.share_with)));
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ popup.getMenu().getItem(1).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
|
|
@Override
|
|
|
public boolean onMenuItemClick(MenuItem item) {
|
|
|
Intent intent = new Intent(MainActivity.this, AboutActivity.class);
|
|
|
@@ -114,7 +159,7 @@ public class MainActivity extends Activity {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- popup.getMenu().getItem(1).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
|
|
+ popup.getMenu().getItem(2).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
|
|
@Override
|
|
|
public boolean onMenuItemClick(MenuItem item) {
|
|
|
Intent intent = new Intent(MainActivity.this, SponsorActivity.class);
|
|
|
@@ -123,7 +168,7 @@ public class MainActivity extends Activity {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- popup.getMenu().getItem(2).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
|
|
+ popup.getMenu().getItem(3).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
|
|
@Override
|
|
|
public boolean onMenuItemClick(MenuItem item) {
|
|
|
Intent intent = new Intent(MainActivity.this, SettingsActivity.class);
|
|
|
@@ -146,6 +191,8 @@ public class MainActivity extends Activity {
|
|
|
FragmentTransaction ft = fm.beginTransaction();
|
|
|
Fragment fragment = null;
|
|
|
String title = "";
|
|
|
+ String shareURL = GM.SHARE.HOME;
|
|
|
+ String shareTitle = getString(R.string.share_home);
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
|
|
//Get measures in dp
|
|
|
@@ -164,6 +211,8 @@ public class MainActivity extends Activity {
|
|
|
case GM.SECTION.HOME:
|
|
|
fragment = new HomeLayout();
|
|
|
title = getString(R.string.menu_home);
|
|
|
+ shareURL = GM.SHARE.HOME;
|
|
|
+ shareTitle = getString(R.string.share_home);
|
|
|
menuText[0].setTypeface(null, Typeface.BOLD);
|
|
|
menuImage[0].getLayoutParams().height = dp7;
|
|
|
break;
|
|
|
@@ -171,6 +220,8 @@ public class MainActivity extends Activity {
|
|
|
case GM.SECTION.LOCATION:
|
|
|
fragment = new LocationLayout();
|
|
|
title = getString(R.string.menu_location);
|
|
|
+ shareURL = GM.SHARE.HOME;
|
|
|
+ shareTitle = getString(R.string.share_home);
|
|
|
menuText[1].setTypeface(null, Typeface.BOLD);
|
|
|
menuImage[1].getLayoutParams().height = dp7;
|
|
|
break;
|
|
|
@@ -184,6 +235,8 @@ public class MainActivity extends Activity {
|
|
|
fragment = new LablancaNoFestivalsLayout();
|
|
|
}
|
|
|
title = getString(R.string.menu_lablanca);
|
|
|
+ shareURL = GM.SHARE.LABLANCA;
|
|
|
+ shareTitle = getString(R.string.share_lablanca);
|
|
|
menuText[2].setTypeface(null, Typeface.BOLD);
|
|
|
menuImage[2].getLayoutParams().height = dp7;
|
|
|
break;
|
|
|
@@ -193,6 +246,8 @@ public class MainActivity extends Activity {
|
|
|
bundle.putInt(GM.SCHEDULE.KEY, GM.SCHEDULE.MARGOLARIAK);
|
|
|
fragment.setArguments(bundle);
|
|
|
title = getString(R.string.menu_lablanca_schedule);
|
|
|
+ shareURL = GM.SHARE.LABLANCA;
|
|
|
+ shareTitle = getString(R.string.share_lablanca);
|
|
|
menuText[2].setTypeface(null, Typeface.BOLD);
|
|
|
menuImage[2].getLayoutParams().height = dp7;
|
|
|
break;
|
|
|
@@ -202,6 +257,8 @@ public class MainActivity extends Activity {
|
|
|
bundle.putInt(GM.SCHEDULE.KEY, GM.SCHEDULE.MARGOLARIAK);
|
|
|
fragment.setArguments(bundle);
|
|
|
title = getString(R.string.menu_lablanca_gm_schedule);
|
|
|
+ shareURL = GM.SHARE.LABLANCA;
|
|
|
+ shareTitle = getString(R.string.share_lablanca);
|
|
|
menuText[2].setTypeface(null, Typeface.BOLD);
|
|
|
menuImage[2].getLayoutParams().height = dp7;
|
|
|
break;
|
|
|
@@ -209,6 +266,8 @@ public class MainActivity extends Activity {
|
|
|
case GM.SECTION.ACTIVITIES:
|
|
|
fragment = new ActivityLayout();
|
|
|
title = getString(R.string.menu_activities);
|
|
|
+ shareURL = GM.SHARE.ACTIVITIES;
|
|
|
+ shareTitle = getString(R.string.share_activities);
|
|
|
menuText[3].setTypeface(null, Typeface.BOLD);
|
|
|
menuImage[3].getLayoutParams().height = dp7;
|
|
|
break;
|
|
|
@@ -216,6 +275,8 @@ public class MainActivity extends Activity {
|
|
|
case GM.SECTION.BLOG:
|
|
|
fragment = new BlogLayout();
|
|
|
title = getString(R.string.menu_blog);
|
|
|
+ shareURL = GM.SHARE.BLOG;
|
|
|
+ shareTitle = getString(R.string.share_blog);
|
|
|
menuText[4].setTypeface(null, Typeface.BOLD);
|
|
|
menuImage[4].getLayoutParams().height = dp7;
|
|
|
break;
|
|
|
@@ -223,6 +284,8 @@ public class MainActivity extends Activity {
|
|
|
case GM.SECTION.GALLERY:
|
|
|
fragment = new GalleryLayout();
|
|
|
title = getString(R.string.menu_blog);
|
|
|
+ shareURL = GM.SHARE.GALLERY;
|
|
|
+ shareTitle = getString(R.string.share_gallery);
|
|
|
menuText[5].setTypeface(null, Typeface.BOLD);
|
|
|
menuImage[5].getLayoutParams().height = dp7;
|
|
|
break;
|
|
|
@@ -233,6 +296,8 @@ public class MainActivity extends Activity {
|
|
|
//ft.addToBackStack(title);
|
|
|
ft.commit();
|
|
|
setSectionTitle(title);
|
|
|
+ //Set the shareable url
|
|
|
+ setShareLink(shareTitle, shareURL);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -360,7 +425,7 @@ public class MainActivity extends Activity {
|
|
|
});
|
|
|
|
|
|
//Get preferences
|
|
|
- SharedPreferences sharedData = getSharedPreferences(GM.PREFERENCES.PREFERNCES, Context.MODE_PRIVATE);
|
|
|
+ SharedPreferences sharedData = getSharedPreferences(GM.DATA.DATA, Context.MODE_PRIVATE);
|
|
|
SharedPreferences.Editor dataEditor = sharedData.edit();
|
|
|
|
|
|
//If the user code is not set, generate one
|
|
|
@@ -632,6 +697,14 @@ public class MainActivity extends Activity {
|
|
|
new Sync(this, pbSync, ivSync).execute();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Asks the activity to performa a sync.
|
|
|
+ * Intended to be called from any screen.
|
|
|
+ */
|
|
|
+ public void bgSync(){
|
|
|
+ new Sync(this).execute();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Perform an initial sync before the app can be used.
|
|
|
* A dialog will block the UI.
|