Commit 13dd747f03642b9211b5c6acec6431ea146515e8
1 parent
9b4c6f17
- add index activitiy
Showing
8 changed files
with
154 additions
and
1 deletions
app/src/main/AndroidManifest.xml
... | ... | @@ -10,6 +10,7 @@ |
10 | 10 | android:allowBackup="true" |
11 | 11 | android:icon="@mipmap/ic_launcher" |
12 | 12 | android:label="@string/app_name" |
13 | + android:largeHeap="true" | |
13 | 14 | android:supportsRtl="true" |
14 | 15 | android:theme="@style/AppTheme" > |
15 | 16 | <activity |
... | ... | @@ -22,6 +23,8 @@ |
22 | 23 | <category android:name="android.intent.category.LAUNCHER" /> |
23 | 24 | </intent-filter> |
24 | 25 | </activity> |
26 | + <activity android:name=".IndexActivitiy"/> | |
27 | + | |
25 | 28 | </application> |
26 | 29 | |
27 | 30 | </manifest> | ... | ... |
app/src/main/java/net/devfac/userstory/Constants.java
... | ... | @@ -23,11 +23,13 @@ public class Constants { |
23 | 23 | FRAG_ADD_BOOK |
24 | 24 | } |
25 | 25 | |
26 | - //Web Scrapping | |
26 | + //Preferences | |
27 | 27 | public static final String PREF_USER_ID = "pref_user_id"; |
28 | 28 | public static final String PREF_USER_PWD = "pref_user_pwd"; |
29 | 29 | public static final String PREF_IS_LOGGED_IN = "pref_is_logged_in"; |
30 | + public static final String PREF_IS_FIRST_LAUNCHED = "pref_is_first_launched"; | |
30 | 31 | |
32 | + //Web Scrapping | |
31 | 33 | public static final String BASE_URL_MYPAGE = ".userstorybook.net"; |
32 | 34 | public static final String BASE_URL_MYSHELF = ".userstorybook.net/shelf"; |
33 | 35 | public static final String BASE_URL_MYSHELF_ALLBOOKS = ".userstorybook.net/shelf/0/"; | ... | ... |
app/src/main/java/net/devfac/userstory/IndexActivitiy.java
0 → 100644
1 | +package net.devfac.userstory; | |
2 | + | |
3 | +import android.app.Activity; | |
4 | +import android.content.Intent; | |
5 | +import android.content.res.Resources; | |
6 | +import android.graphics.Bitmap; | |
7 | +import android.graphics.BitmapFactory; | |
8 | +import android.os.Bundle; | |
9 | +import android.util.DisplayMetrics; | |
10 | +import android.view.View; | |
11 | +import android.widget.FrameLayout; | |
12 | +import android.widget.ImageButton; | |
13 | +import android.widget.ImageView; | |
14 | + | |
15 | +import net.devfac.userstory.Utils.PreferenceUtil; | |
16 | + | |
17 | +/** | |
18 | + * Created by Onether on 15. 11. 10.. | |
19 | + */ | |
20 | +public class IndexActivitiy extends Activity { | |
21 | + private ImageButton mImageButtonIndexStart; | |
22 | + private ImageView mImageViewIndexBackground; | |
23 | + private FrameLayout mFrameLayoutIndexContainer; | |
24 | + | |
25 | + @Override | |
26 | + protected void onCreate(Bundle savedInstanceState) { | |
27 | + super.onCreate(savedInstanceState); | |
28 | + | |
29 | + setContentView(R.layout.activity_index); | |
30 | + | |
31 | + mImageButtonIndexStart = (ImageButton)findViewById(R.id.imagebutton_index_start); | |
32 | + mImageViewIndexBackground = (ImageView)findViewById(R.id.imagevew_index_background); | |
33 | + mFrameLayoutIndexContainer = (FrameLayout)findViewById(R.id.framelayout_index_container); | |
34 | + | |
35 | + mImageButtonIndexStart.setOnClickListener(new View.OnClickListener() { | |
36 | + @Override | |
37 | + public void onClick(View v) { | |
38 | + PreferenceUtil.getInstance(IndexActivitiy.this).putIsFirstLaunched(true); | |
39 | + startActivity(new Intent(IndexActivitiy.this, MainActivity.class)); | |
40 | + finish(); | |
41 | + } | |
42 | + }); | |
43 | + | |
44 | +// mImageViewIndexBackground.setImageBitmap(decodeSampledBitmapFromResource(getResources(), | |
45 | +// R.drawable.index_background, metrics.widthPixels, | |
46 | +// metrics.heightPixels)); | |
47 | + | |
48 | +// mImageViewIndexBackground.setAdjustViewBounds(true); | |
49 | + | |
50 | +// mImageViewIndexBackground.setScaleType(ImageView.ScaleType.CENTER_CROP); | |
51 | + } | |
52 | + | |
53 | + @Override | |
54 | + public void onWindowFocusChanged(boolean hasFocus) { | |
55 | + super.onWindowFocusChanged(hasFocus); | |
56 | + | |
57 | + mImageViewIndexBackground.setImageBitmap(decodeSampledBitmapFromResource(getResources(), | |
58 | + R.drawable.index_background, mImageViewIndexBackground.getWidth()/3, | |
59 | + mImageViewIndexBackground.getHeight()/3)); | |
60 | + } | |
61 | + | |
62 | + public static Bitmap decodeSampledBitmapFromResource(Resources res, int resId, | |
63 | + int reqWidth, int reqHeight) { | |
64 | + | |
65 | + // First decode with inJustDecodeBounds=true to check dimensions | |
66 | + final BitmapFactory.Options options = new BitmapFactory.Options(); | |
67 | + options.inJustDecodeBounds = true; | |
68 | + BitmapFactory.decodeResource(res, resId, options); | |
69 | + | |
70 | + // Calculate inSampleSize | |
71 | + options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight); | |
72 | + | |
73 | + // Decode bitmap with inSampleSize set | |
74 | + options.inJustDecodeBounds = false; | |
75 | + return BitmapFactory.decodeResource(res, resId, options); | |
76 | + } | |
77 | + | |
78 | + public static int calculateInSampleSize( | |
79 | + BitmapFactory.Options options, int reqWidth, int reqHeight) { | |
80 | + // Raw height and width of image | |
81 | + final int height = options.outHeight; | |
82 | + final int width = options.outWidth; | |
83 | + int inSampleSize = 1; | |
84 | + | |
85 | + if (height > reqHeight || width > reqWidth) { | |
86 | + | |
87 | + final int halfHeight = height / 2; | |
88 | + final int halfWidth = width / 2; | |
89 | + | |
90 | + // Calculate the largest inSampleSize value that is a power of 2 and keeps both | |
91 | + // height and width larger than the requested height and width. | |
92 | + while ((halfHeight / inSampleSize) > reqHeight | |
93 | + && (halfWidth / inSampleSize) > reqWidth) { | |
94 | + inSampleSize *= 2; | |
95 | + } | |
96 | + } | |
97 | + | |
98 | + return inSampleSize; | |
99 | + } | |
100 | +} | ... | ... |
app/src/main/java/net/devfac/userstory/MainActivity.java
... | ... | @@ -3,6 +3,7 @@ package net.devfac.userstory; |
3 | 3 | import android.app.Dialog; |
4 | 4 | import android.app.Fragment; |
5 | 5 | import android.app.FragmentTransaction; |
6 | +import android.content.Intent; | |
6 | 7 | import android.os.Bundle; |
7 | 8 | import android.support.design.widget.FloatingActionButton; |
8 | 9 | import android.support.design.widget.Snackbar; |
... | ... | @@ -37,6 +38,11 @@ public class MainActivity extends AppCompatActivity |
37 | 38 | @Override |
38 | 39 | protected void onCreate(Bundle savedInstanceState) { |
39 | 40 | super.onCreate(savedInstanceState); |
41 | + | |
42 | + if( PreferenceUtil.getInstance(this).getIsFirstLaunched() ){ | |
43 | + startActivity(new Intent(this, IndexActivitiy.class)); | |
44 | + return; | |
45 | + } | |
40 | 46 | setContentView(R.layout.activity_main); |
41 | 47 | |
42 | 48 | initWidget(); | ... | ... |
app/src/main/java/net/devfac/userstory/Utils/PreferenceUtil.java
... | ... | @@ -31,6 +31,9 @@ public class PreferenceUtil extends BasePreferenceUtil { |
31 | 31 | public void putUserPwd(String userPwd) { put(Constants.PREF_USER_PWD, userPwd); } |
32 | 32 | public String getUserPwd() { return get(Constants.PREF_USER_PWD); } |
33 | 33 | |
34 | + public void putIsFirstLaunched(boolean is_first_launched) { put(Constants.PREF_IS_FIRST_LAUNCHED, is_first_launched); } | |
35 | + public boolean getIsFirstLaunched() { return get(Constants.PREF_IS_FIRST_LAUNCHED, true); } | |
36 | + | |
34 | 37 | public void putIsLoggedInState(boolean state){ put(Constants.PREF_IS_LOGGED_IN, state); } |
35 | 38 | public boolean getIsLoggedInState() { return get(Constants.PREF_IS_LOGGED_IN, false); } |
36 | 39 | } | ... | ... |
app/src/main/res/drawable/index_background.png
0 → 100644
2.01 MB
app/src/main/res/drawable/index_start_button.png
0 → 100644
30.5 KB
app/src/main/res/layout/activity_index.xml
0 → 100644
1 | +<?xml version="1.0" encoding="utf-8"?> | |
2 | +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
3 | + android:orientation="vertical" android:layout_width="match_parent" | |
4 | + android:layout_height="match_parent" | |
5 | + android:baselineAligned="false" | |
6 | + android:id="@+id/framelayout_index_container"> | |
7 | + | |
8 | + <ImageView | |
9 | + android:layout_width="fill_parent" | |
10 | + android:layout_height="fill_parent" | |
11 | + android:id="@+id/imagevew_index_background" | |
12 | + android:scaleType="centerCrop" | |
13 | + android:adjustViewBounds="false" /> | |
14 | + | |
15 | + <TextView | |
16 | + android:layout_width="wrap_content" | |
17 | + android:layout_height="wrap_content" | |
18 | + android:textAppearance="?android:attr/textAppearanceSmall" | |
19 | + android:text="유저스토리북 비공식\n안드로이드 클라이언트" | |
20 | + android:id="@+id/textView5" | |
21 | + android:layout_gravity="center" | |
22 | + android:layout_marginRight="70dp" | |
23 | + android:gravity="center_horizontal" /> | |
24 | + | |
25 | + <ImageButton | |
26 | + android:layout_width="103dp" | |
27 | + android:layout_height="110dp" | |
28 | + android:id="@+id/imagebutton_index_start" | |
29 | + android:layout_gravity="center" | |
30 | + android:src="@drawable/index_start_button" | |
31 | + android:background="@null" | |
32 | + android:adjustViewBounds="false" | |
33 | + android:baselineAlignBottom="false" | |
34 | + android:cropToPadding="false" | |
35 | + android:scaleType="centerCrop" | |
36 | + android:layout_marginRight="70dp" | |
37 | + android:layout_marginTop="100dp" /> | |
38 | + | |
39 | +</FrameLayout> | |
0 | 40 | \ No newline at end of file | ... | ... |