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

Updating the UI of Giraffe app #3

Merged
merged 4 commits into from
Jul 20, 2017
Merged
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
18 changes: 14 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ def getCurrentGitHash() {
}

android {
compileSdkVersion 23
buildToolsVersion "22.0.1"
compileSdkVersion 25
buildToolsVersion "25.0.2"

defaultConfig {
applicationId "org.splitbrain.giraffe"
minSdkVersion 4
targetSdkVersion 23
minSdkVersion 11
targetSdkVersion 25
versionName "0.8.1"
versionCode getNumberOfGitCommits()
resValue "string", "app_git_hash", getCurrentGitHash()
Expand All @@ -42,8 +42,18 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
compileOptions {
targetCompatibility 1.6
sourceCompatibility 1.6
}
}
dependencies {
testCompile 'junit:junit:4.12'

//Essential google libraries
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
}

2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
android:fullBackupContent="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@android:style/Theme.Light.NoTitleBar">
android:theme="@style/AppTheme">
<activity
android:name="MainActivity"
android:label="@string/app_name">
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/org/splitbrain/giraffe/DBAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;

public class DBAdapter {
private static final String DATABASE_NAME = "EventPlanner";
Expand Down
122 changes: 54 additions & 68 deletions app/src/main/java/org/splitbrain/giraffe/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.splitbrain.giraffe;

import android.app.AlertDialog;
import android.app.ListActivity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
Expand All @@ -12,20 +11,22 @@
import android.net.Uri;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MenuItem.OnMenuItemClickListener;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends ListActivity {
public class MainActivity extends AppCompatActivity {
Context context;
DBAdapter db;
SharedPreferences prefs;
int filterstate = 0;
ListView listview;
TextView title;

/**
* Called when the activity is first created.
Expand All @@ -36,23 +37,22 @@ public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.main);
this.context = this;

setTitle("");

db = new DBAdapter(this);
db.openReadOnly();

listview = (ListView) findViewById(R.id.list);

prefs = PreferenceManager.getDefaultSharedPreferences(this);
EventItemCursorAdapter listAdapter = new EventItemCursorAdapter(this, null);
setListAdapter(listAdapter);
listview.setAdapter(listAdapter);
setFilter(0);


ImageView iv;
iv = (ImageView) findViewById(R.id.filterbtn_fav);
iv.setOnClickListener(click_filter);
iv = (ImageView) findViewById(R.id.filterbtn_future);
iv.setOnClickListener(click_filter);

TextView title = (TextView) findViewById(R.id.titlebar);
title.setOnClickListener(click_title);
title = (TextView) findViewById(R.id.titlebar);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_main);
setSupportActionBar(toolbar);

// pass URL intents to the option activity
Uri intentdata = getIntent().getData();
Expand All @@ -63,7 +63,7 @@ public void onCreate(Bundle savedInstanceState) {
}

if (prefs.getString("url", "").equals("")) {
AlertDialog.Builder noFeedBuilder = new AlertDialog.Builder(context);
AlertDialog.Builder noFeedBuilder = new AlertDialog.Builder(context,R.style.AlertDialogCustom);
noFeedBuilder.setMessage(R.string.main_no_feed_text)
.setTitle(R.string.main_no_feed_title)
.setPositiveButton(R.string.common_yes, new DialogInterface.OnClickListener() {
Expand All @@ -88,11 +88,10 @@ public void onClick(DialogInterface dialog, int id) {
*/
@Override
public void onResume() {
EventItemCursorAdapter eica = (EventItemCursorAdapter) getListAdapter();
Cursor cursor = eica.getCursor();
if (cursor != null) {
cursor.requery();
}
prefs = PreferenceManager.getDefaultSharedPreferences(this);
EventItemCursorAdapter listAdapter = new EventItemCursorAdapter(this, null);
listview.setAdapter(listAdapter);
setFilter(0);
super.onResume();
}

Expand Down Expand Up @@ -125,19 +124,6 @@ private void setFilter(int filter) {
Toast toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
toast.show();
}
// update button images
ImageView iv1 = (ImageView) findViewById(R.id.filterbtn_fav);
ImageView iv2 = (ImageView) findViewById(R.id.filterbtn_future);
if ((filterstate & 1) > 0) {
iv1.setImageResource(R.drawable.filter1_on);
} else {
iv1.setImageResource(R.drawable.filter1_off);
}
if ((filterstate & 2) > 0) {
iv2.setImageResource(R.drawable.filter2_on);
} else {
iv2.setImageResource(R.drawable.filter2_off);
}

// create WHERE clause
String where = "";
Expand All @@ -154,50 +140,50 @@ private void setFilter(int filter) {
// apply the filter
Cursor cursor = db.getEventsCursor(where);
startManagingCursor(cursor);
EventItemCursorAdapter eica = (EventItemCursorAdapter) getListAdapter();
EventItemCursorAdapter eica = (EventItemCursorAdapter) listview.getAdapter();
eica.changeCursor(cursor);
}

public void titleOption(View view) {

new AlertDialog.Builder(this, R.style.AlertDialogCustom)
.setTitle("Options")
.setMessage("Select the option to change URL or read about the app.")
.setPositiveButton("URL",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent i = new Intent(MainActivity.this, OptionsActivity.class);
startActivity(i);
}
})
.setNegativeButton("About",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent i = new Intent(MainActivity.this, AboutActivity.class);
startActivity(i);
}
}).create().show();

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuItem item1 = menu.add(R.string.menu_urlsetup);
item1.setIcon(android.R.drawable.ic_menu_preferences);
item1.setOnMenuItemClickListener(click_options);

MenuItem item2 = menu.add(R.string.menu_about);
item2.setIcon(android.R.drawable.ic_menu_info_details);
item2.setOnMenuItemClickListener(click_about);

return super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}

private final OnMenuItemClickListener click_about = new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem arg0) {
Intent i = new Intent(context, AboutActivity.class);
startActivity(i);
return true;
}
};

private final OnMenuItemClickListener click_options = new OnMenuItemClickListener() {
public boolean onMenuItemClick(MenuItem arg0) {
Intent i = new Intent(context, OptionsActivity.class);
startActivity(i);
return true;
}
};
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();

private final OnClickListener click_filter = new OnClickListener() {
public void onClick(View v) {
int state = Integer.parseInt((String) v.getTag());
setFilter(state);
if (id == R.id.action_bookmark) {
setFilter(1);
} else if (id == R.id.action_filter) {
setFilter(2);
}
};
return super.onOptionsItemSelected(item);
}

private final OnClickListener click_title = new OnClickListener() {
public void onClick(View view) {
openOptionsMenu();
}
};
}
Binary file added app/src/main/res/drawable-hdpi/ic_bookmark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable-hdpi/ic_filter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
120 changes: 76 additions & 44 deletions app/src/main/res/layout/about.xml
Original file line number Diff line number Diff line change
@@ -1,63 +1,95 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background"
android:orientation="vertical">

<LinearLayout
android:layout_width="fill_parent"
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dip">
android:background="@android:color/transparent"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dip">
<android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar_about"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark">

<ImageView
android:id="@+id/imageView1"
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dip"
android:src="@drawable/giraffe"
tools:ignore="ContentDescription" />
android:text="@string/about"
android:textColor="@color/colorAccent"
android:textSize="20sp" />

</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>

<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/background"
android:fillViewport="true">

<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@color/background"
android:padding="5dip">

<LinearLayout
android:id="@+id/linearLayout2"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
android:layout_height="wrap_content"
android:layout_marginBottom="10dip">

<TextView
android:id="@+id/textView1"
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/highlight" />
android:layout_marginRight="10dip"
android:src="@drawable/giraffe"
tools:ignore="ContentDescription" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_about" />
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">

<TextView
android:id="@+id/version"
tools:text="version"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/colorAccent" />

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_about" />

<TextView
android:id="@+id/version"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="version" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_usage" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_usage" />

</LinearLayout>
</ScrollView>
</LinearLayout>
</ScrollView>
</LinearLayout>
Loading