Skip to content

Commit

Permalink
Icons changed to backgroundless versions to make it easier to set the…
Browse files Browse the repository at this point in the history
…ir background with a circle defined in xml.

Samples changed. Dynamic child sample added, to demonstrate the ability to add and remove views at runtime.
  • Loading branch information
szugyi committed Feb 6, 2016
1 parent bf1a51a commit 9ee6785
Show file tree
Hide file tree
Showing 98 changed files with 206 additions and 291 deletions.
Binary file removed icons.xcf
Binary file not shown.
Binary file added icons/Business-Card-01-256.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/Calendar-Date-256.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/Cloud-256.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/Finance-256.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/Key-Access-256.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/Message-Mail-256.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/Tag-256.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/User-Profile-256.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/Voice-Search-256.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 10 additions & 23 deletions sample/src/main/java/com/szugyi/circlemenusample/MainActivity.java
@@ -1,52 +1,39 @@
package com.szugyi.circlemenusample;


import android.app.ListActivity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

public class MainActivity extends ListActivity {
public class MainActivity extends AppCompatActivity implements AdapterView.OnItemClickListener {

protected void onCreate(android.os.Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

((ListView) findViewById(android.R.id.list)).setOnItemClickListener(this);
}

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);

public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Intent intent = new Intent(this, SampleActivity.class);
switch (position) {
case 0:
intent.putExtra(SampleActivity.ARG_LAYOUT, R.layout.sample);
break;
case 1:
intent.putExtra(SampleActivity.ARG_LAYOUT, R.layout.sample_fast);
intent.putExtra(SampleActivity.ARG_LAYOUT, R.layout.sample_no_rotation);
break;
case 2:
intent.putExtra(SampleActivity.ARG_LAYOUT,
R.layout.sample_no_rotation);
intent.putExtra(SampleActivity.ARG_LAYOUT, R.layout.sample_attributes);
break;
case 3:
intent.putExtra(SampleActivity.ARG_LAYOUT, R.layout.sample_west);
intent.putExtra(SampleActivity.ARG_LAYOUT, R.layout.sample_any_items);
break;
case 4:
intent.putExtra(SampleActivity.ARG_LAYOUT,
R.layout.sample_with_background);
break;
case 5:
intent.putExtra(SampleActivity.ARG_LAYOUT,
R.layout.sample_7_items);
break;
case 6:
intent.putExtra(SampleActivity.ARG_LAYOUT,
R.layout.sample_8_items);
break;
case 7:
intent.putExtra(SampleActivity.ARG_LAYOUT,
R.layout.sample_any_items);
intent.putExtra(SampleActivity.ARG_LAYOUT, R.layout.sample_dynamic_children);
break;
}

Expand Down
Expand Up @@ -16,8 +16,10 @@
* limitations under the License.
*/

import android.app.Activity;
import android.os.Bundle;
import android.os.Looper;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.RotateAnimation;
Expand All @@ -31,13 +33,13 @@
import com.szugyi.circlemenu.view.CircleLayout.OnItemSelectedListener;
import com.szugyi.circlemenu.view.CircleLayout.OnRotationFinishedListener;

public class SampleActivity extends Activity implements OnItemSelectedListener,
public class SampleActivity extends AppCompatActivity implements OnItemSelectedListener,
OnItemClickListener, OnRotationFinishedListener, OnCenterClickListener {
public static final String ARG_LAYOUT = "layout";

private CircleLayout circleLayout;
private TextView selectedTextView;


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -48,16 +50,16 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(layoutId);

// Set listeners
CircleLayout circleMenu = (CircleLayout) findViewById(R.id.main_circle_layout);
circleMenu.setOnItemSelectedListener(this);
circleMenu.setOnItemClickListener(this);
circleMenu.setOnRotationFinishedListener(this);
circleMenu.setOnCenterClickListener(this);
circleLayout = (CircleLayout) findViewById(R.id.circle_layout);
circleLayout.setOnItemSelectedListener(this);
circleLayout.setOnItemClickListener(this);
circleLayout.setOnRotationFinishedListener(this);
circleLayout.setOnCenterClickListener(this);

selectedTextView = (TextView) findViewById(R.id.main_selected_textView);
selectedTextView = (TextView) findViewById(R.id.selected_textView);

String name = null;
View view = circleMenu.getSelectedItem();
View view = circleLayout.getSelectedItem();
if (view instanceof CircleImageView) {
name = ((CircleImageView) view).getName();
}
Expand All @@ -66,12 +68,22 @@ protected void onCreate(Bundle savedInstanceState) {

@Override
public void onItemSelected(View view) {
String name = null;
boolean isMain = Looper.myLooper() == Looper.getMainLooper();
Log.v("SampleActivity", "is it the main thread? " + String.valueOf(isMain));

final String name;
if (view instanceof CircleImageView) {
name = ((CircleImageView) view).getName();
} else {
name = null;
}

//selectedTextView.post(new Runnable() {
// @Override
//public void run() {
selectedTextView.setText(name);
// }
//});

switch (view.getId()) {
case R.id.main_calendar_image:
Expand All @@ -80,12 +92,12 @@ public void onItemSelected(View view) {
case R.id.main_cloud_image:
// Handle cloud selection
break;
case R.id.main_facebook_image:
// Handle facebook selection
break;
case R.id.main_key_image:
// Handle key selection
break;
case R.id.main_mail_image:
// Handle facebook selection
break;
case R.id.main_profile_image:
// Handle profile selection
break;
Expand All @@ -102,9 +114,8 @@ public void onItemClick(View view) {
name = ((CircleImageView) view).getName();
}

Toast.makeText(getApplicationContext(),
getResources().getString(R.string.start_app) + " " + name,
Toast.LENGTH_SHORT).show();
String text = getResources().getString(R.string.start_app, name);
Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();

switch (view.getId()) {
case R.id.main_calendar_image:
Expand All @@ -113,12 +124,12 @@ public void onItemClick(View view) {
case R.id.main_cloud_image:
// Handle cloud click
break;
case R.id.main_facebook_image:
// Handle facebook click
break;
case R.id.main_key_image:
// Handle key click
break;
case R.id.main_mail_image:
// Handle facebook click
break;
case R.id.main_profile_image:
// Handle profile click
break;
Expand All @@ -130,20 +141,27 @@ public void onItemClick(View view) {

@Override
public void onRotationFinished(View view) {
String name = null;
if (view instanceof CircleImageView) {
name = ((CircleImageView) view).getName();
}

Animation animation = new RotateAnimation(0, 360, view.getWidth() / 2,
view.getHeight() / 2);
Animation animation = new RotateAnimation(0, 360, view.getWidth() / 2, view.getHeight() / 2);
animation.setDuration(250);
view.startAnimation(animation);
}

@Override
public void onCenterClick() {
Toast.makeText(getApplicationContext(), R.string.center_click,
Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), R.string.center_click, Toast.LENGTH_SHORT).show();
}

public void onAddClick(View view) {
CircleImageView newMenu = new CircleImageView(this);
newMenu.setBackgroundResource(R.drawable.circle);
newMenu.setImageResource(R.drawable.ic_voice);
newMenu.setName(getString(R.string.voice_search));
circleLayout.addView(newMenu);
}

public void onRemoveClick(View view) {
if (circleLayout.getChildCount() > 0) {
circleLayout.removeViewAt(circleLayout.getChildCount() - 1);
}
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample/src/main/res/drawable-hdpi/ic_calendar.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample/src/main/res/drawable-hdpi/ic_cloud.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample/src/main/res/drawable-hdpi/ic_finance.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample/src/main/res/drawable-hdpi/ic_key.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample/src/main/res/drawable-hdpi/ic_mail.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample/src/main/res/drawable-hdpi/ic_profile.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample/src/main/res/drawable-hdpi/ic_tag.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sample/src/main/res/drawable-hdpi/ic_voice.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file removed sample/src/main/res/drawable-hdpi/icon_calendar.png
Binary file not shown.
Binary file removed sample/src/main/res/drawable-hdpi/icon_cloud.png
Binary file not shown.
Binary file removed sample/src/main/res/drawable-hdpi/icon_facebook.png
Binary file not shown.
Binary file removed sample/src/main/res/drawable-hdpi/icon_key.png
Binary file not shown.
Binary file removed sample/src/main/res/drawable-hdpi/icon_mail.png
Binary file not shown.
Binary file removed sample/src/main/res/drawable-hdpi/icon_profile.png
Binary file not shown.
Binary file removed sample/src/main/res/drawable-hdpi/icon_tag.png
Diff not rendered.
Diff not rendered.
Binary file added sample/src/main/res/drawable-mdpi/ic_calendar.png
Binary file added sample/src/main/res/drawable-mdpi/ic_cloud.png
Binary file added sample/src/main/res/drawable-mdpi/ic_finance.png
Binary file added sample/src/main/res/drawable-mdpi/ic_key.png
Binary file added sample/src/main/res/drawable-mdpi/ic_mail.png
Binary file added sample/src/main/res/drawable-mdpi/ic_profile.png
Binary file added sample/src/main/res/drawable-mdpi/ic_tag.png
Binary file added sample/src/main/res/drawable-mdpi/ic_voice.png
Diff not rendered.
Binary file removed sample/src/main/res/drawable-mdpi/icon_calendar.png
Diff not rendered.
Binary file removed sample/src/main/res/drawable-mdpi/icon_cloud.png
Diff not rendered.
Binary file removed sample/src/main/res/drawable-mdpi/icon_facebook.png
Diff not rendered.
Binary file removed sample/src/main/res/drawable-mdpi/icon_key.png
Diff not rendered.
Binary file removed sample/src/main/res/drawable-mdpi/icon_mail.png
Diff not rendered.
Binary file removed sample/src/main/res/drawable-mdpi/icon_profile.png
Diff not rendered.
Binary file removed sample/src/main/res/drawable-mdpi/icon_tag.png
Diff not rendered.
Diff not rendered.
Binary file added sample/src/main/res/drawable-xhdpi/ic_cloud.png
Binary file added sample/src/main/res/drawable-xhdpi/ic_key.png
Binary file added sample/src/main/res/drawable-xhdpi/ic_mail.png
Binary file added sample/src/main/res/drawable-xhdpi/ic_profile.png
Binary file added sample/src/main/res/drawable-xhdpi/ic_tag.png
Binary file added sample/src/main/res/drawable-xhdpi/ic_voice.png
Diff not rendered.
Binary file removed sample/src/main/res/drawable-xhdpi/icon_calendar.png
Diff not rendered.
Binary file removed sample/src/main/res/drawable-xhdpi/icon_cloud.png
Diff not rendered.
Binary file removed sample/src/main/res/drawable-xhdpi/icon_facebook.png
Diff not rendered.
Binary file removed sample/src/main/res/drawable-xhdpi/icon_key.png
Diff not rendered.
Binary file removed sample/src/main/res/drawable-xhdpi/icon_mail.png
Diff not rendered.
Binary file removed sample/src/main/res/drawable-xhdpi/icon_profile.png
Diff not rendered.
Binary file removed sample/src/main/res/drawable-xhdpi/icon_tag.png
Diff not rendered.
Diff not rendered.
Binary file added sample/src/main/res/drawable-xxhdpi/ic_cloud.png
Binary file added sample/src/main/res/drawable-xxhdpi/ic_key.png
Binary file added sample/src/main/res/drawable-xxhdpi/ic_mail.png
Binary file added sample/src/main/res/drawable-xxhdpi/ic_tag.png
Binary file added sample/src/main/res/drawable-xxhdpi/ic_voice.png
Binary file added sample/src/main/res/drawable-xxxhdpi/ic_cloud.png
Binary file added sample/src/main/res/drawable-xxxhdpi/ic_key.png
Binary file added sample/src/main/res/drawable-xxxhdpi/ic_mail.png
Binary file added sample/src/main/res/drawable-xxxhdpi/ic_voice.png
10 changes: 10 additions & 0 deletions sample/src/main/res/drawable/circle.xml
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">

<solid android:color="@color/colorAccent" />

<size
android:width="64dp"
android:height="64dp" />
</shape>
40 changes: 26 additions & 14 deletions sample/src/main/res/layout/menu_items.xml
Expand Up @@ -2,48 +2,60 @@
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:circle="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent" >
android:layout_height="match_parent">

<com.szugyi.circlemenu.view.CircleImageView
android:id="@+id/main_calendar_image"
circle:name="@string/calendar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_calendar" />
android:background="@drawable/circle"
android:elevation="2dp"
android:src="@drawable/ic_calendar"
circle:name="@string/calendar" />

<com.szugyi.circlemenu.view.CircleImageView
android:id="@+id/main_cloud_image"
circle:name="@string/cloud"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_cloud" />
android:background="@drawable/circle"
android:elevation="2dp"
android:src="@drawable/ic_cloud"
circle:name="@string/cloud" />


<com.szugyi.circlemenu.view.CircleImageView
android:id="@+id/main_facebook_image"
circle:name="@string/facebook"
android:id="@+id/main_mail_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_facebook" />
android:background="@drawable/circle"
android:elevation="2dp"
android:src="@drawable/ic_mail"
circle:name="@string/mail" />

<com.szugyi.circlemenu.view.CircleImageView
android:id="@+id/main_key_image"
circle:name="@string/key"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_key" />
android:background="@drawable/circle"
android:src="@drawable/ic_key"
circle:name="@string/key" />

<com.szugyi.circlemenu.view.CircleImageView
android:id="@+id/main_profile_image"
circle:name="@string/profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_profile" />
android:background="@drawable/circle"
android:elevation="2dp"
android:src="@drawable/ic_profile"
circle:name="@string/profile" />

<com.szugyi.circlemenu.view.CircleImageView
android:id="@+id/main_tap_image"
circle:name="@string/tag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_tag" />
android:background="@drawable/circle"
android:elevation="2dp"
android:src="@drawable/ic_tag"
circle:name="@string/tag" />

</merge>
9 changes: 5 additions & 4 deletions sample/src/main/res/layout/sample.xml
Expand Up @@ -21,19 +21,20 @@
tools:context=".SampleActivity" >

<com.szugyi.circlemenu.view.CircleLayout
android:id="@+id/main_circle_layout"
android:id="@+id/circle_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/main_selected_textView"
android:layout_above="@+id/selected_textView"
android:layout_gravity="center_horizontal" >

<include layout="@layout/menu_items" />
</com.szugyi.circlemenu.view.CircleLayout>

<TextView
android:id="@+id/main_selected_textView"
android:layout_width="wrap_content"
android:id="@+id/selected_textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="50dp"
Expand Down
49 changes: 0 additions & 49 deletions sample/src/main/res/layout/sample_7_items.xml

This file was deleted.

0 comments on commit 9ee6785

Please sign in to comment.