diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 330e51d..aac76e6 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -22,7 +22,8 @@ + android:noHistory="true" + android:screenOrientation="portrait" > @@ -31,13 +32,14 @@ - + android:theme="@style/AppTheme.NoActionBar" + android:screenOrientation="portrait" > + android:noHistory="true" + android:screenOrientation="portrait" > \ No newline at end of file diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/ListAdapter.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/ListAdapter.java index a58dbde..38b2e2d 100644 --- a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/ListAdapter.java +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/ListAdapter.java @@ -1,6 +1,7 @@ package com.android_app.matan.ara.sagi.thesocialnotework; import android.content.Context; +import android.graphics.drawable.Drawable; import android.text.Html; import android.view.LayoutInflater; import android.view.View; @@ -57,7 +58,8 @@ public class ListAdapter extends BaseAdapter { v = inflater.inflate(R.layout.note_view_mini , parent , false); } TextView title = (TextView) v.findViewById(R.id.nvm_title_textview); - TextView datetime = (TextView) v.findViewById(R.id.nvm_time_textview); + TextView time = (TextView) v.findViewById(R.id.nvm_time_textview); + TextView date = (TextView) v.findViewById(R.id.nvm_date_textview); TextView location = (TextView) v.findViewById(R.id.nvm_location_textview); TextView likes = (TextView) v.findViewById(R.id.nvm_likes_textview); TextView permission = (TextView) v.findViewById(R.id.nvm_permission_textview); @@ -66,10 +68,12 @@ public class ListAdapter extends BaseAdapter { // thumbNail.setImageUrl(url, VolleyUtilSingleTone.getInstance(mContext).getImageLoader()); Note curNote = mNotes.get(position); title.setText(curNote.getTitle()); - datetime.setText(Html.fromHtml(curNote.getTimestamp())); + time.setText(curNote.getTime()); + date.setText(curNote.getDate()); location.setText(curNote.getAddress()); - likes.setText(""+curNote.getLikes()); - permission.setText(curNote.isPublic() ? "Public":"Private"); + if(likes !=null )likes.setText(""+curNote.getLikes()); +// permission.setText(curNote.isPublic() ? "Public":"Private"); + permission.setBackground(curNote.isPublic() ? v.getResources().getDrawable(R.drawable.public_icon): v.getResources().getDrawable(R.drawable.private_icon)); // Animation animation = AnimationUtils.loadAnimation(mContext, (position > lastPosition) ? R.anim.up_from_bottom : R.anim.down_from_top); // v.startAnimation(animation); diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/MainActivity.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/MainActivity.java index 7761f25..8a2c2c8 100644 --- a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/MainActivity.java +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/MainActivity.java @@ -32,26 +32,14 @@ public class MainActivity extends AppCompatActivity setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); - - FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); - fab.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Snackbar.make(view, "This should Open the new Note thingy", Snackbar.LENGTH_LONG) - .setAction("Action", null).show(); - } - }); - DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); - NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); - //get Bundle data (Userid) Bundle b = getIntent().getExtras(); userId = b.getString("user_id"); @@ -122,7 +110,8 @@ public class MainActivity extends AppCompatActivity DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); drawer.closeDrawer(GravityCompat.START); return true; - }public GPSUtils getGPSUtils() { + } + public GPSUtils getGPSUtils() { return this.gpsUtils; } diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/Note.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/Note.java index 2fc2e2d..34329fd 100644 --- a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/Note.java +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/Note.java @@ -3,7 +3,10 @@ package com.android_app.matan.ara.sagi.thesocialnotework; import android.os.Parcel; import android.os.Parcelable; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; /** * Created by JERLocal on 7/1/2016. @@ -174,28 +177,16 @@ public class Note implements Parcelable{ dest.writeByte((byte) (isPublic ? 1 : 0)); } + public String getTime() { + Date d = new Date(timestamp); + DateFormat format = new SimpleDateFormat("HH:mm"); + return format.format(d); + } -// public void save(SQLiteOpenHelper dbHelper, Context context){ -// SQLiteDatabase db = dbHelper.getWritableDatabase(); -// ContentValues values = new ContentValues(); -// -// values.put(appDB.LocationsEntry.ADDRESS, this.address); -// -// String where = appDB.LocationsEntry._ID + " =?"; -// String[] whereArgs = {Integer.toString(this.id)}; -// -// db.update(appDB.LocationsEntry.TABLE_NAME, values, where, whereArgs); -// -// db.close(); -// -// Toast.makeText(context, "Address saved!", Toast.LENGTH_LONG).show(); -// } -// -// public static Cursor getAll(DBHelper dbHelper) { -// SQLiteDatabase db = dbHelper.getReadableDatabase(); -// String[] selectionArgs = {}; -// -// return db.rawQuery("SELECT * FROM "+appDB.LocationsEntry.TABLE_NAME, selectionArgs); -// } + public String getDate() { + Date d = new Date(); + DateFormat format = new SimpleDateFormat("dd MMM yyy"); + return format.format(d); + } } diff --git a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/PersonalFragment.java b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/PersonalFragment.java index ebe4a60..c6d4dcf 100644 --- a/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/PersonalFragment.java +++ b/app/src/main/java/com/android_app/matan/ara/sagi/thesocialnotework/PersonalFragment.java @@ -6,6 +6,8 @@ import android.content.Context; import android.content.pm.PackageManager; import android.net.Uri; import android.os.Bundle; +import android.support.design.widget.FloatingActionButton; +import android.support.design.widget.Snackbar; import android.support.v4.app.ActivityCompat; import android.support.v4.app.Fragment; import android.support.v4.content.ContextCompat; @@ -41,10 +43,8 @@ import java.util.List; public class PersonalFragment extends Fragment { protected ListView noteList; - protected Button addBtn; private final int FINE_PERM = 0; private final String BASE_URL = "http://thesocialnotework-api.appspot.com/api"; - private boolean locationPermission; private GPSUtils gpsUtils; private List listOfNotes; private ListAdapter noteListAdapter; @@ -64,29 +64,25 @@ public class PersonalFragment extends Fragment { Bundle bundle = getArguments(); this.userId = bundle.getString("user_id"); Log.d(TAG, "onCreateView: userID: " + userId); - this.locationPermission = true; - //check for permission ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, FINE_PERM); this.noteList = (ListView) view.findViewById(R.id.ps_list_listview); - addBtn = (Button) view.findViewById(R.id.ps_new_note_button); gpsUtils = ((MainActivity)getActivity()).getGPSUtils(); gpsUtils.getLocation(); - - listOfNotes = new ArrayList<>(); - //TODO - remove -add demo notes to view -// addDemoNotes(listOfNotes); noteListAdapter = new ListAdapter(getContext(), listOfNotes); - noteList.setAdapter(noteListAdapter); // new HeavyWorker(this).execute(); + MainActivity.showLoadingDialog(getActivity(), "Fetching..", "getting your notes"); getAllNotes(); //https://thesocialnotework-api.appspot.com/api/note/all?uid= - addBtn.setOnClickListener(addNewNoteDialog); + // The New "Add Button" + FloatingActionButton fab = (FloatingActionButton)view.findViewById(R.id.fab); + fab.setOnClickListener(addNewNoteDialog); + return view; } @@ -109,10 +105,6 @@ public class PersonalFragment extends Fragment { VolleyUtilSingleton.getInstance(getActivity()).get(BASE_URL + "/note/all?uid="+userId, getNotesSuccessListener, genericErrorListener); } - public void setLocationPermission(boolean locationPermission) { - this.locationPermission = locationPermission; - } - private View.OnClickListener addNewNoteDialog = new View.OnClickListener() { public void onClick(View v) { @@ -248,6 +240,7 @@ public class PersonalFragment extends Fragment { @Override public void onResponse(JSONObject response) { Log.d(TAG,"getNotesSuccessListener: "+response.toString()); + MainActivity.dismissLoadingDialog(); try { //need to get all notes and add to listOfNotes JSONArray noteObjectsArray = response.getJSONArray("notes"); @@ -285,6 +278,7 @@ public class PersonalFragment extends Fragment { @Override public void onErrorResponse(VolleyError error) { Log.d(TAG,"getNotesErrorListener: "+error.getMessage()); + MainActivity.dismissLoadingDialog(); } }; @@ -293,61 +287,12 @@ public class PersonalFragment extends Fragment { @Override public void onErrorResponse(VolleyError error) { Log.d(TAG,"genericErrorListener"); + MainActivity.dismissLoadingDialog(); error.printStackTrace(); } }; - public void requestPermissions(){ - // Here, thisActivity is the current activity - if (ContextCompat.checkSelfPermission(getActivity(), - Manifest.permission.ACCESS_FINE_LOCATION) - != PackageManager.PERMISSION_GRANTED) { - - - ActivityCompat.requestPermissions(getActivity(), - new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, - FINE_PERM); - - // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an - // app-defined int constant. The callback method gets the - // result of the request. - - } - - if (ContextCompat.checkSelfPermission(getActivity(), - Manifest.permission.ACCESS_FINE_LOCATION) - != PackageManager.PERMISSION_GRANTED) { - - - ActivityCompat.requestPermissions(getActivity(), - new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, - 1); - - // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an - // app-defined int constant. The callback method gets the - // result of the request. - - } - - if (ContextCompat.checkSelfPermission(getActivity(), - Manifest.permission.ACCESS_COARSE_LOCATION) - != PackageManager.PERMISSION_GRANTED) { - - - ActivityCompat.requestPermissions(getActivity(), - new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, - FINE_PERM); - - // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an - // app-defined int constant. The callback method gets the - // result of the request. - - } - - } - - private ArrayList jsonArrayToStringArray(JSONArray jArray){ ArrayList stringArray = new ArrayList(); diff --git a/app/src/main/res/drawable/like_icon.png b/app/src/main/res/drawable/like_icon.png new file mode 100644 index 0000000..981b6b6 Binary files /dev/null and b/app/src/main/res/drawable/like_icon.png differ diff --git a/app/src/main/res/drawable/private_icon.png b/app/src/main/res/drawable/private_icon.png new file mode 100644 index 0000000..74d8070 Binary files /dev/null and b/app/src/main/res/drawable/private_icon.png differ diff --git a/app/src/main/res/drawable/public_icon.png b/app/src/main/res/drawable/public_icon.png new file mode 100644 index 0000000..473e075 Binary files /dev/null and b/app/src/main/res/drawable/public_icon.png differ diff --git a/app/src/main/res/layout/app_bar_main.xml b/app/src/main/res/layout/app_bar_main.xml index 2858d96..8efb5f7 100644 --- a/app/src/main/res/layout/app_bar_main.xml +++ b/app/src/main/res/layout/app_bar_main.xml @@ -27,12 +27,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:paddingTop="40dp"> - + diff --git a/app/src/main/res/layout/fragment_personal.xml b/app/src/main/res/layout/fragment_personal.xml index 1f43f6c..0ff44ae 100644 --- a/app/src/main/res/layout/fragment_personal.xml +++ b/app/src/main/res/layout/fragment_personal.xml @@ -29,19 +29,6 @@ android:text="Filters and Shit" android:layout_weight="0.8"/> -