Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue[19][20][25] solved. #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,25 @@
Licensed under GPLv3.
See the file COPYING, included with this source.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

For Developers :
---------------
*** For building/running the project on eclipse/android studio, the following libraries have to be imported namely:

android-support-v4-1.jar
hamcrest-1.3.jar
annotations-10.0.2.jar
gson-2.2.2.jar
retrofit-1.2.1.jar
junit.jar
jetbrains-annotations.jar

*** For importing BookieClient API and BookieParserClient API, download the source projects from here:

https://github.com/bookieio/BookieClient
https://github.com/bookieio/BookieParserClient

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


3 changes: 2 additions & 1 deletion res/layout/main.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">
Expand All @@ -8,4 +9,4 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
</LinearLayout>
13 changes: 13 additions & 0 deletions res/values/array.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="backgroundColorEntries">
<item name="Dark">Dark</item>
<item name="Light">Light</item>
<item name="Transparent">Glass</item>
</string-array>
<string-array name="backgroundValues">
<item name="Dark">1</item>
<item name="Light">2</item>
<item name="Transparent">3</item>
</string-array>
</resources>
3 changes: 3 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Bookie</string>
<string name="fetch_all_bm">Fetching all Bookmarks"</string>
<string name="update_your_bm">Updating your Bookmarks</string>
<string name="please_enter">Please enter your username and API key in the Settings menu</string>
<string name="generic_dialog_positive_button">OK</string>
<string name="generic_dialog_cancel_button">Cancel</string>
<string name="title_all">All</string>
Expand Down
11 changes: 11 additions & 0 deletions res/xml/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,16 @@
android:defaultValue="@string/settings_parseurl_defaultvalue"/>

</PreferenceCategory>
<PreferenceCategory
android:title="Theme"
android:key="theme">
<ListPreference
android:key="theme_preference"
android:title="Choose your theme"
android:entries="@array/backgroundColorEntries"
android:entryValues="@array/backgroundValues"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting should use spaces, not tabs



</PreferenceCategory>

</PreferenceScreen>
3 changes: 3 additions & 0 deletions src/main/java/us/bmark/android/AllBookmarkListFragment.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package us.bmark.android;

import android.os.Bundle;
import android.widget.Toast;

public class AllBookmarkListFragment extends BookmarkListFragment {

@Override
void refresh() {
Toast.makeText(getActivity(),R.string.fetch_all_bm,
Toast.LENGTH_SHORT).show();
int nextPage = pagesLoaded;
refreshState.setStateInProgress();
service.everyonesRecent(countPP, nextPage, new ServiceCallback());
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/us/bmark/android/BookMarkDetailActivity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package us.bmark.android;


import us.bmark.android.R;
import us.bmark.android.prefs.SharedPrefsBackedUserSettings;
import us.bmark.android.utils.IntentConstants;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
Expand All @@ -13,8 +17,6 @@
import com.google.gson.JsonParseException;
import com.google.gson.JsonSyntaxException;

import us.bmark.android.prefs.SharedPrefsBackedUserSettings;
import us.bmark.android.utils.IntentConstants;
import us.bmark.bookieclient.Bookmark;
import us.bmark.bookieclient.Tag;

Expand Down Expand Up @@ -46,6 +48,8 @@ private void dealWithIntents() {
populateFields(bmark);
} catch (JsonSyntaxException e) {
Log.e(TAG, "Error getting bookmark detail", e);
Toast.makeText(getActivity(),"Some error occured while fetching bookmark details" ,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a string resource instead of hard-coding a string

Toast.LENGTH_SHORT).show();
}
}

Expand Down Expand Up @@ -90,7 +94,7 @@ private TableRow createTagRow(CharSequence tagText) {
}

private UserSettings userSettings() {
return new SharedPrefsBackedUserSettings(this);
return (UserSettings) new SharedPrefsBackedUserSettings(this);
}

}
32 changes: 17 additions & 15 deletions src/main/java/us/bmark/android/BookmarkListFragment.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
package us.bmark.android;

import static us.bmark.android.utils.Utils.isBlank;

import java.util.ArrayList;
import java.util.List;

import retrofit.Callback;
import retrofit.RestAdapter;
import retrofit.RetrofitError;
import retrofit.client.Response;
import us.bmark.android.R;
import us.bmark.android.prefs.SharedPrefsBackedUserSettings;
import us.bmark.android.utils.ErrorHandler;
import us.bmark.android.utils.IntentConstants;
import us.bmark.android.utils.JustDisplayToastErrorHandler;
import android.app.Activity;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
Expand All @@ -17,25 +32,12 @@
import android.widget.ListView;
import android.widget.TextView;

import com.google.gson.Gson;

import java.util.ArrayList;
import java.util.List;

import retrofit.Callback;
import retrofit.RestAdapter;
import retrofit.RetrofitError;
import retrofit.client.Response;
import us.bmark.android.prefs.SharedPrefsBackedUserSettings;
import us.bmark.android.utils.ErrorHandler;
import us.bmark.android.utils.IntentConstants;
import us.bmark.android.utils.JustDisplayToastErrorHandler;
import us.bmark.bookieclient.BookieService;
import us.bmark.bookieclient.BookieServiceUtils;
import us.bmark.bookieclient.Bookmark;
import us.bmark.bookieclient.BookmarkList;

import static us.bmark.android.utils.Utils.isBlank;
import com.google.gson.Gson;

public abstract class BookmarkListFragment extends ListFragment {

Expand Down Expand Up @@ -136,7 +138,7 @@ public View onCreateView(LayoutInflater inflater,
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);

settings = new SharedPrefsBackedUserSettings(getActivity());
settings = (UserSettings) new SharedPrefsBackedUserSettings(getActivity());

String serverUrl = settings.getBaseUrl();
RestAdapter restAdapter = new RestAdapter.Builder()
Expand Down
60 changes: 49 additions & 11 deletions src/main/java/us/bmark/android/BookmarkListsActivity.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
package us.bmark.android;

import java.util.ArrayList;
import java.util.Collection;

import us.bmark.android.prefs.SettingsActivity;
import android.app.ActionBar;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
Expand All @@ -13,14 +21,11 @@
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.SearchView;

import java.util.ArrayList;
import java.util.Collection;

import us.bmark.android.prefs.SettingsActivity;

public class BookmarkListsActivity extends FragmentActivity {

private static final String TAG = BookmarkListsActivity.class.getName();
Expand All @@ -31,7 +36,7 @@ public class BookmarkListsActivity extends FragmentActivity {
private BookmarkListFragment allFragment;
private SearchBookmarkFragment searchFragment;
private ViewPager pager;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace

private ActionBar.TabListener tabListener = new ActionBar.TabListener() {

@Override
Expand All @@ -51,19 +56,33 @@ public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
};
private MultiRefreshStateObserver observer;
private BookmarkListsActivity.BookiePagerAdapter tabsPagerAdapter;

String id="something";
SharedPreferences settings;
Editor editor;
String col;
ActionBar actionBar;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These fields (id, settings, editor, col, actionbar) can be local variables

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.main);
pager = (ViewPager) findViewById(R.id.pager);
createFragments(savedInstanceState);

final ActionBar actionBar = getActionBar();
id = getIntent().getStringExtra("caller");
//Get Sharedpreferences
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These comments can be removed

settings = getSharedPreferences("mypref", MODE_PRIVATE);
//Get editor
editor = settings.edit();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

editor appears unused

//always set col to the color saved last time user had chosen it(for the first time 1--dark)
col = settings.getString("mycolor", "1");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if it won't be clearer to the color or theme names as string constants instead of "1", "2" etc


actionBar = getActionBar();
actionBar.setDisplayHomeAsUpEnabled(false); // Hides the '<' button in the ActionBar
actionBar.setHomeButtonEnabled(true); // Enables the 'B' icon to be tappable on the list Activity
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

//always change color to that.
ChangeColor(col);

pager.setOnPageChangeListener(
new ViewPager.SimpleOnPageChangeListener() {
Expand All @@ -76,6 +95,25 @@ public void onPageSelected(int position) {
});

}
//changing theme color of main
public void ChangeColor(String a){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo, I think it should be changeColor not ChangeColor

View v = findViewById(R.id.main);
if(a.equals("1"))
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bracket goes on same line, to match style of rest of project

v.setBackgroundColor(Color.BLACK);
actionBar.setBackgroundDrawable(new ColorDrawable(Color.BLACK));
}
else if(a.equals("2"))
{
v.setBackgroundColor(Color.GRAY);
actionBar.setBackgroundDrawable(new ColorDrawable(Color.GRAY));
}
else if(a.equals("3"))
{
v.setBackgroundColor(Color.TRANSPARENT);
actionBar.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
}

@Override
protected void onResume() {
Expand Down Expand Up @@ -209,7 +247,6 @@ public Fragment getItem(int position) {
return fragments[position];
}

@Override
public CharSequence getPageTitle(int position) {
return getString(titleIds[position]);
}
Expand Down Expand Up @@ -270,4 +307,5 @@ private void refreshActiveFragment() {
(BookmarkListFragment) tabsPagerAdapter.getFragments()[pager.getCurrentItem()];
activeFragment.refresh();
}
}

}
8 changes: 6 additions & 2 deletions src/main/java/us/bmark/android/MineBookmarkListFragment.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package us.bmark.android;

import static us.bmark.android.utils.Utils.isBlank;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;

import static us.bmark.android.utils.Utils.isBlank;
import android.widget.Toast;

public class MineBookmarkListFragment extends BookmarkListFragment {

Expand All @@ -17,6 +17,8 @@ void refresh() {
ListView bookieList = getListView();
bookieList.setVisibility(View.GONE);
}
Toast.makeText(getActivity(),R.string.update_your_bm,
Toast.LENGTH_SHORT).show();
int nextPage = pagesLoaded;
refreshState.setStateInProgress();
service.recent(settings.getUsername(),
Expand All @@ -38,6 +40,8 @@ public void onActivityCreated(Bundle savedInstanceState) {

private void populateNotLoggedInTextView() {
TextView userNotLoggedInMessagae = findView(R.id.userNotLoggedInMessagae);
Toast.makeText(getActivity(),R.string.please_enter,
Toast.LENGTH_SHORT).show();
userNotLoggedInMessagae.setVisibility(View.VISIBLE);
userNotLoggedInMessagae.setText(R.string.message_user_not_logged_in);
userNotLoggedInMessagae.setGravity(Gravity.CENTER);
Expand Down
Loading