Permalink
Browse files

Merge pull request #6 from swooshfydp/ui

Ui I will take your shit
  • Loading branch information...
2 parents 8a9ffbf + c80836e commit d936da9c83be8d48d9afedeb048ceb1c230fc2fe @SpazCode SpazCode committed on GitHub Feb 17, 2017
View
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="Encoding">
+ <file url="PROJECT" charset="UTF-8" />
+ </component>
+</project>
View
@@ -7,8 +7,8 @@
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
- <option value="/mnt/Data/Stuart/Git/Inputmethod" />
- <option value="/mnt/Data/Stuart/Git/Inputmethod/app" />
+ <option value="$PROJECT_DIR$" />
+ <option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
View
@@ -37,7 +37,7 @@
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
- <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
View
@@ -2,8 +2,8 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
- <module fileurl="file:///mnt/Data/Stuart/Git/Inputmethod/Inputmethod.iml" filepath="/mnt/Data/Stuart/Git/Inputmethod/Inputmethod.iml" />
- <module fileurl="file:///mnt/Data/Stuart/Git/Inputmethod/app/app.iml" filepath="/mnt/Data/Stuart/Git/Inputmethod/app/app.iml" />
+ <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
+ <module fileurl="file://$PROJECT_DIR$/inputmethod.iml" filepath="$PROJECT_DIR$/inputmethod.iml" />
</modules>
</component>
</project>
View
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="VcsDirectoryMappings">
+ <mapping directory="" vcs="Git" />
+ </component>
+</project>
@@ -1,25 +1,32 @@
package com.sighs.imputmethod.CashPager;
import android.content.Context;
+import android.graphics.Color;
import android.support.v4.view.PagerAdapter;
+import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
import android.widget.RelativeLayout;
+import android.widget.TextView;
import com.sighs.imputmethod.CashTable.CashTable;
-import com.sighs.imputmethod.CashTable.CashTableGridViewAdapter;
-import com.sighs.imputmethod.models.Coordinates;
-import com.sighs.imputmethod.models.Currency;
+import com.sighs.imputmethod.MainActivity;
+import com.sighs.imputmethod.R;
+import com.sighs.imputmethod.ServiceInputMethod;
import com.sighs.imputmethod.customviews.DragNDropImageView;
import com.sighs.imputmethod.customviews.OnDropEventListener;
-import com.sighs.imputmethod.R;
+import com.sighs.imputmethod.models.Coordinates;
+import com.sighs.imputmethod.models.Currency;
+
+public class CashPagerAdapter extends PagerAdapter implements OnDropEventListener, View.OnClickListener {
-public class CashPagerAdapter extends PagerAdapter implements OnDropEventListener, View.OnClickListener {
private final static String LOGKEY = "SWOOSH_INPUT";
- private LayoutInflater mInflater;
private Currency[] mNotes;
+ private LayoutInflater mInflater;
private View table;
private CashTable tableAdapter;
@@ -29,36 +36,22 @@ public CashPagerAdapter(Context context, Currency[] notes) {
}
@Override
- public int getCount() {
- return mNotes.length;
- }
-
- @Override
- public boolean isViewFromObject(View view, Object object) {
- return view == ((RelativeLayout) object);
- }
-
- @Override
public Object instantiateItem(ViewGroup container, int position) {
- container.setClipChildren(false);
- container.setClipToPadding(false);
- RelativeLayout itemView = (RelativeLayout) this.mInflater.inflate(R.layout.cashpager_view,
+ LinearLayout itemView = (LinearLayout) this.mInflater.inflate(R.layout.cashpager_view,
container, false);
- DragNDropImageView imageView = new DragNDropImageView(container.getContext(),
- this.mNotes[position].getBaseImage(), this.mNotes[position].getBaseImage(),
- container);
- imageView.setDimensions(200, 200);
+ ImageView imageView = (ImageView) itemView.findViewById(R.id.currency);
+ imageView.setImageResource(this.mNotes[position].getBaseImage());
+ TextView noteText = (TextView) itemView.findViewById(R.id.currencyText);
+ noteText.setText("" +this.mNotes[position].getValue());
+ itemView.setGravity(Gravity.CENTER);
+ imageView.setScaleX(0.8f);
+ imageView.setScaleY(0.8f);
imageView.setOnClickListener(this);
- itemView.addView(imageView);
container.addView(itemView);
imageView.setTag(mNotes[position].getId());
return itemView;
}
- @Override
- public void destroyItem(ViewGroup container, int position, Object object) {
- container.removeView((RelativeLayout) object);
- }
@Override
public void onItemDrop(View view, Coordinates c) {
@@ -80,8 +73,26 @@ public void setTableAdapter(CashTable adapter) {
this.tableAdapter = adapter;
}
+
+
+ @Override
+ public void destroyItem(ViewGroup container, int position, Object object) {
+ container.removeView((View)object);
+ }
+
+ @Override
+ public int getCount() {
+ return mNotes.length;
+ }
+
+ @Override
+ public boolean isViewFromObject(View view, Object object) {
+ return (view == object);
+ }
+
@Override
public void onClick(View view) {
tableAdapter.updateCashGrid((String) view.getTag(), 1);
}
-}
+
+}
@@ -0,0 +1,99 @@
+package com.sighs.imputmethod.CashPager;
+
+import android.content.Context;
+import android.graphics.Point;
+import android.support.v4.view.ViewPager;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.view.View;
+import android.widget.FrameLayout;
+
+import com.sighs.imputmethod.R;
+
+/**
+ * Created by hannahgautreau1 on 2017-02-07.
+ */
+public class PagerContainer extends FrameLayout implements ViewPager.OnPageChangeListener {
+
+ private ViewPager mPager;
+ boolean mNeedsRedraw = false;
+
+ public PagerContainer(Context context) {
+ super(context);
+ init();
+ }
+
+ public PagerContainer(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ init();
+ }
+
+ public PagerContainer(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ init();
+ }
+
+ private void init() {
+ //Disable clipping of children so non-selected pages are visible
+ setClipChildren(false);
+
+ //Child clipping doesn't work with hardware acceleration in Android 3.x/4.x
+ //You need to set this value here if using hardware acceleration in an
+ // application targeted at these releases.
+ setLayerType(View.LAYER_TYPE_SOFTWARE, null);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ try {
+ mPager = (ViewPager) findViewById(R.id.pagerView);
+ mPager.setOnPageChangeListener(this);
+ } catch (Exception e) {
+ throw new IllegalStateException("The root child of PagerContainer must be a ViewPager");
+ }
+ }
+
+ public ViewPager getViewPager() {
+ return mPager;
+ }
+
+ private Point mCenter = new Point();
+ private Point mInitialTouch = new Point();
+
+ @Override
+ protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ mCenter.x = w / 2;
+ mCenter.y = h / 2;
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent ev) {
+ //We capture any touches not already handled by the ViewPager
+ // to implement scrolling from a touch outside the pager bounds.
+ switch (ev.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ mInitialTouch.x = (int)ev.getX();
+ mInitialTouch.y = (int)ev.getY();
+ default:
+ ev.offsetLocation(mCenter.x - mInitialTouch.x, mCenter.y - mInitialTouch.y);
+ break;
+ }
+
+ return mPager.dispatchTouchEvent(ev);
+ }
+
+ @Override
+ public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
+ //Force the container to redraw on scrolling.
+ //Without this the outer pages render initially and then stay static
+ if (mNeedsRedraw) invalidate();
+ }
+
+ @Override
+ public void onPageSelected(int position) { }
+
+ @Override
+ public void onPageScrollStateChanged(int state) {
+ mNeedsRedraw = (state != ViewPager.SCROLL_STATE_IDLE);
+ }
+}
@@ -11,6 +11,7 @@
import android.widget.TextView;
import com.sighs.imputmethod.CashPager.CashPagerAdapter;
+import com.sighs.imputmethod.CashPager.PagerContainer;
import com.sighs.imputmethod.CashTable.CashTable;
import com.sighs.imputmethod.CashTable.CashTableGridViewAdapter;
import com.sighs.imputmethod.CashTable.OnCashTableUpdate;
@@ -22,7 +23,7 @@
public class ServiceInputMethod extends InputMethodService implements OnCashTableUpdate {
private CashPagerAdapter cashPagerAdapter;
- private ViewPager pagerView;
+ private ViewPager pagerView=null;
private TableLayout cashTable;
private CashTable cashTableAdapter;
private TextView cashValueOutput;
@@ -31,6 +32,8 @@
private ImageButton clearButton;
private ImageButton leftButton;
private ImageButton rightButton;
+ PagerContainer mContainer;
+
@Override
public View onCreateInputView() {
@@ -49,6 +52,10 @@ public View onCreateInputView() {
cashPagerAdapter.setTable(cashTable);
pagerView = (ViewPager) layout.findViewById(R.id.pagerView);
pagerView.setAdapter(cashPagerAdapter);
+ pagerView.setOffscreenPageLimit(cashPagerAdapter.getCount());
+ pagerView.setClipChildren(false);
+
+
// Set the Text Output
cashValueOutput = (TextView) layout.findViewById(R.id.txtValueOutput);
// Set the Buttons
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<inset xmlns:android="http://schemas.android.com/apk/res/android"
+ android:insetRight="-2dp"
+ android:insetBottom="-2dp"
+ android:insetLeft="-2dp">
+ <shape android:shape="rectangle">
+ <stroke android:width="2dp" android:color="@color/grey" />
+ </shape>
+</inset>
@@ -1,12 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
- android:layout_height="match_parent">
+ android:layout_height="match_parent"
+ android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
+ android:layout_height="98dp"
+ android:layout_gravity="center_horizontal"
+ android:layout_margin="0dp"
android:id="@+id/currency"
android:contentDescription="@string/cash_image" />
-</RelativeLayout>
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="22dp"
+ android:gravity="bottom"
+ android:background="@drawable/cash_pager_border"
+ android:id="@+id/currencyText"
+ android:text="@string/hello"
+ android:textAlignment="center"
+ android:textColor="@color/black"
+ />
+
+</LinearLayout>
Oops, something went wrong.

0 comments on commit d936da9

Please sign in to comment.