summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorTrumeet <liangyuteng12345@gmail.com>2018-09-08 21:08:14 -0700
committerTrumeet <liangyuteng12345@gmail.com>2018-09-08 21:08:14 -0700
commit4b38a99961fac44b14848cf8782d5619c7b3dddc (patch)
tree0794ba93d3118c00bf05d58f5e165c5924a898ea /app
downloadPageIndicator-4b38a99961fac44b14848cf8782d5619c7b3dddc.tar
PageIndicator-4b38a99961fac44b14848cf8782d5619c7b3dddc.tar.gz
PageIndicator-4b38a99961fac44b14848cf8782d5619c7b3dddc.tar.bz2
PageIndicator-4b38a99961fac44b14848cf8782d5619c7b3dddc.zip
Diffstat (limited to 'app')
-rw-r--r--app/.gitignore1
-rw-r--r--app/build.gradle26
-rw-r--r--app/proguard-rules.pro21
-rw-r--r--app/src/main/AndroidManifest.xml22
-rw-r--r--app/src/main/java/moe/yuuta/pageindicator/MainActivity.java94
-rw-r--r--app/src/main/java/moe/yuuta/pageindicator/PageFragment.java43
-rw-r--r--app/src/main/res/layout/activity_main.xml21
-rw-r--r--app/src/main/res/layout/fragment_page.xml11
-rw-r--r--app/src/main/res/mipmap-hdpi/ic_launcher.pngbin0 -> 2963 bytes
-rw-r--r--app/src/main/res/mipmap-mdpi/ic_launcher.pngbin0 -> 2060 bytes
-rw-r--r--app/src/main/res/mipmap-xhdpi/ic_launcher.pngbin0 -> 4490 bytes
-rw-r--r--app/src/main/res/mipmap-xxhdpi/ic_launcher.pngbin0 -> 6387 bytes
-rw-r--r--app/src/main/res/mipmap-xxxhdpi/ic_launcher.pngbin0 -> 9128 bytes
-rw-r--r--app/src/main/res/values/colors.xml6
-rw-r--r--app/src/main/res/values/strings.xml3
-rw-r--r--app/src/main/res/values/styles.xml13
16 files changed, 261 insertions, 0 deletions
diff --git a/app/.gitignore b/app/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/app/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/app/build.gradle b/app/build.gradle
new file mode 100644
index 0000000..209a7d3
--- /dev/null
+++ b/app/build.gradle
@@ -0,0 +1,26 @@
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 28
+ defaultConfig {
+ applicationId "moe.yuuta.pageindicator"
+ minSdkVersion 21
+ targetSdkVersion 28
+ versionCode 1
+ versionName "1.0"
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ }
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation project(':library')
+ implementation 'androidx.viewpager:viewpager:1.0.0-rc02'
+ implementation 'androidx.fragment:fragment:1.0.0-rc02'
+}
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
new file mode 100644
index 0000000..f1b4245
--- /dev/null
+++ b/app/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..4f2b7a3
--- /dev/null
+++ b/app/src/main/AndroidManifest.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ package="moe.yuuta.pageindicator">
+
+ <application
+ android:allowBackup="true"
+ android:icon="@mipmap/ic_launcher"
+ android:label="@string/app_name"
+ android:supportsRtl="true"
+ android:theme="@style/AppTheme"
+ tools:ignore="GoogleAppIndexingWarning">
+ <activity android:name=".MainActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest> \ No newline at end of file
diff --git a/app/src/main/java/moe/yuuta/pageindicator/MainActivity.java b/app/src/main/java/moe/yuuta/pageindicator/MainActivity.java
new file mode 100644
index 0000000..e314737
--- /dev/null
+++ b/app/src/main/java/moe/yuuta/pageindicator/MainActivity.java
@@ -0,0 +1,94 @@
+package moe.yuuta.pageindicator;
+
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.widget.Toast;
+
+import com.android.systemui.qr.PageIndicator;
+
+import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
+import androidx.fragment.app.FragmentActivity;
+import androidx.fragment.app.FragmentPagerAdapter;
+import androidx.viewpager.widget.ViewPager;
+
+public class MainActivity extends FragmentActivity {
+ private PageIndicator mPageIndicator;
+ private float mPageIndicatorPosition;
+ private int mNumPages;
+ private ViewPager mPager;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ mPager = findViewById(R.id.pager);
+ setPageIndicator((PageIndicator) findViewById(R.id.indicator));
+ mPager.addOnPageChangeListener(this.mOnPageChangeListener);
+ mPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {
+ @Override
+ public Fragment getItem(int position) {
+ return PageFragment.newInstance(position);
+ }
+
+ @Override
+ public int getCount() {
+ return mNumPages;
+ }
+ });
+ Toast.makeText(this, "Tap 'ADD' to add pages!", Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ protected void onPostCreate(@Nullable Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+ addPage();
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ menu.add(0, 0, 0, "Add").setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getItemId() == 0) {
+ addPage();
+ return true;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+
+ private void addPage () {
+ if (mPager.getAdapter() == null) {
+ // onCreate not finished, just skip
+ return;
+ }
+ mNumPages++;
+ mPager.getAdapter().notifyDataSetChanged();
+ mPageIndicator.setNumPages(mNumPages);
+ }
+
+ public void setPageIndicator(PageIndicator indicator) {
+ mPageIndicator = indicator;
+ mPageIndicator.setNumPages(mNumPages);
+ mPageIndicator.setLocation(mPageIndicatorPosition);
+ }
+
+ private final ViewPager.OnPageChangeListener mOnPageChangeListener =
+ new ViewPager.SimpleOnPageChangeListener() {
+ @Override
+ public void onPageSelected(int position) {
+ }
+
+ @Override
+ public void onPageScrolled(int position, float positionOffset,
+ int positionOffsetPixels) {
+ if (mPageIndicator == null) return;
+ mPageIndicatorPosition = position + positionOffset;
+ mPageIndicator.setLocation(mPageIndicatorPosition);
+ }
+ };
+}
diff --git a/app/src/main/java/moe/yuuta/pageindicator/PageFragment.java b/app/src/main/java/moe/yuuta/pageindicator/PageFragment.java
new file mode 100644
index 0000000..5524540
--- /dev/null
+++ b/app/src/main/java/moe/yuuta/pageindicator/PageFragment.java
@@ -0,0 +1,43 @@
+package moe.yuuta.pageindicator;
+
+import android.annotation.SuppressLint;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.fragment.app.Fragment;
+
+public class PageFragment extends Fragment {
+ private static final String EXTRA_PAGE_INDEX = PageFragment.class.getName() + ".EXTRA_PAGE_INDEX";
+
+ private int index;
+
+ static PageFragment newInstance (int index) {
+ Bundle args = new Bundle();
+ PageFragment fragment = new PageFragment();
+
+ args.putInt(EXTRA_PAGE_INDEX, index);
+ fragment.setArguments(args);
+ return fragment;
+ }
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ if (getArguments() == null) return;
+ this.index = getArguments().getInt(EXTRA_PAGE_INDEX);
+ }
+
+ @SuppressLint("SetTextI18n")
+ @Nullable
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.fragment_page, container, false);
+ ((TextView) view.findViewById(R.id.text_page_digit)).setText(Integer.toString(index));
+ return view;
+ }
+}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..e17567e
--- /dev/null
+++ b/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".MainActivity">
+ <androidx.viewpager.widget.ViewPager
+ android:id="@+id/pager"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+ </androidx.viewpager.widget.ViewPager>
+ <com.android.systemui.qr.PageIndicator
+ android:id="@+id/indicator"
+ android:layout_width="match_parent"
+ android:layout_height="48dp"
+ android:layout_gravity="bottom"
+ android:layout_marginBottom="24dp"
+ android:focusable="true"
+ android:gravity="center"
+ android:importantForAccessibility="yes"/>
+</FrameLayout> \ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_page.xml b/app/src/main/res/layout/fragment_page.xml
new file mode 100644
index 0000000..0b6eec8
--- /dev/null
+++ b/app/src/main/res/layout/fragment_page.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+ <TextView
+ android:id="@+id/text_page_digit"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:gravity="center"
+ android:textAppearance="@android:style/TextAppearance.Material.Headline"/>
+</FrameLayout> \ No newline at end of file
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..898f3ed
--- /dev/null
+++ b/app/src/main/res/mipmap-hdpi/ic_launcher.png
Binary files differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..64ba76f
--- /dev/null
+++ b/app/src/main/res/mipmap-mdpi/ic_launcher.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..e5ed465
--- /dev/null
+++ b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..b0907ca
--- /dev/null
+++ b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..2c18de9
--- /dev/null
+++ b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Binary files differ
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
new file mode 100644
index 0000000..69b2233
--- /dev/null
+++ b/app/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <color name="colorPrimary">#008577</color>
+ <color name="colorPrimaryDark">#00574B</color>
+ <color name="colorAccent">#D81B60</color>
+</resources>
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
new file mode 100644
index 0000000..054390a
--- /dev/null
+++ b/app/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+<resources>
+ <string name="app_name">PageIndicator</string>
+</resources>
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
new file mode 100644
index 0000000..5e8b5e3
--- /dev/null
+++ b/app/src/main/res/values/styles.xml
@@ -0,0 +1,13 @@
+<resources>
+
+ <!-- Base application theme. -->
+ <style name="AppTheme" parent="@android:style/Theme.Material.Light.DarkActionBar">
+ <!-- Customize your theme here. -->
+ <item name="android:colorPrimary">@color/colorPrimary</item>
+ <item name="android:colorPrimaryDark">@color/colorPrimaryDark</item>
+ <item name="android:colorAccent">@color/colorAccent</item>
+ <!-- use colorControlActivated to customize indicator's color! -->
+ <item name="android:colorControlActivated">?android:colorPrimary</item>
+ </style>
+
+</resources>