Skip to content
This repository was archived by the owner on Nov 5, 2020. It is now read-only.

Commit 3f8f15d

Browse files
committed
添加welcome,侧边栏
1 parent 23f3560 commit 3f8f15d

38 files changed

+805
-65
lines changed

.gitignore

Lines changed: 14 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,14 @@
1-
# Built application files
2-
*.apk
3-
*.ap_
4-
5-
# Files for the ART/Dalvik VM
6-
*.dex
7-
8-
# Java class files
9-
*.class
10-
11-
# Generated files
12-
bin/
13-
gen/
14-
out/
15-
16-
# Gradle files
17-
.gradle/
18-
build/
19-
20-
# Local configuration file (sdk path, etc)
21-
local.properties
22-
23-
# Proguard folder generated by Eclipse
24-
proguard/
25-
26-
# Log Files
27-
*.log
28-
29-
# Android Studio Navigation editor temp files
30-
.navigation/
31-
32-
# Android Studio captures folder
33-
captures/
34-
35-
# IntelliJ
36-
*.iml
37-
.idea/workspace.xml
38-
.idea/tasks.xml
39-
.idea/gradle.xml
40-
.idea/assetWizardSettings.xml
41-
.idea/dictionaries
42-
.idea/libraries
43-
.idea/caches
44-
45-
# Keystore files
46-
# Uncomment the following line if you do not want to check your keystore files in.
47-
#*.jks
48-
49-
# External native build folder generated in Android Studio 2.2 and later
50-
.externalNativeBuild
51-
52-
# Google Services (e.g. APIs or Firebase)
53-
google-services.json
54-
55-
# Freeline
56-
freeline.py
57-
freeline/
58-
freeline_project_description.json
59-
60-
# fastlane
61-
fastlane/report.xml
62-
fastlane/Preview.html
63-
fastlane/screenshots
64-
fastlane/test_output
65-
fastlane/readme.md
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/caches/build_file_checksums.ser
5+
/.idea/libraries
6+
/.idea/modules.xml
7+
/.idea/workspace.xml
8+
.DS_Store
9+
/build
10+
/captures
11+
.externalNativeBuild
12+
13+
.idea/
14+
app/build/

app/build.gradle

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 26
5+
defaultConfig {
6+
applicationId "io.github.zhaoqi99.snnu_android"
7+
minSdkVersion 16
8+
targetSdkVersion 26
9+
versionCode 1
10+
versionName "1.0"
11+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12+
}
13+
buildTypes {
14+
release {
15+
minifyEnabled false
16+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17+
}
18+
}
19+
}
20+
21+
dependencies {
22+
implementation fileTree(dir: 'libs', include: ['*.jar'])
23+
implementation 'com.android.support:appcompat-v7:26.0.0'
24+
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
25+
testImplementation 'junit:junit:4.12'
26+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
27+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
28+
implementation 'com.stephentuso:welcome:1.4.1'
29+
implementation 'com.android.support:design:26.0.0'
30+
}

app/proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package io.github.zhaoqi99.snnu_android;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumented test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("io.github.zhaoqi99.snnu_android", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="io.github.zhaoqi99.snnu_android">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:supportsRtl="true"
11+
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
12+
<activity
13+
android:name=".MyWelcomeActivity"
14+
android:theme="@style/WelcomeScreenTheme">
15+
</activity>
16+
17+
<activity android:name=".MainActivity">
18+
<intent-filter>
19+
<action android:name="android.intent.action.MAIN" />
20+
<category android:name="android.intent.category.LAUNCHER" />
21+
22+
</intent-filter>
23+
</activity>
24+
</application>
25+
26+
</manifest>
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package io.github.zhaoqi99.snnu_android;
2+
3+
import android.support.annotation.NonNull;
4+
import android.support.design.widget.NavigationView;
5+
import android.support.v4.view.GravityCompat;
6+
import android.support.v4.widget.DrawerLayout;
7+
import android.support.v7.app.ActionBarDrawerToggle;
8+
import android.support.v7.app.AppCompatActivity;
9+
import android.os.Bundle;
10+
import android.support.v7.widget.Toolbar;
11+
import android.view.MenuItem;
12+
import android.widget.Toast;
13+
14+
import com.stephentuso.welcome.WelcomeHelper;
15+
16+
public class MainActivity extends AppCompatActivity {
17+
WelcomeHelper welcomeScreen;
18+
NavigationView navigationView;
19+
DrawerLayout drawerLayout;
20+
Toolbar mToolBar;
21+
22+
@Override
23+
protected void onCreate(Bundle savedInstanceState) {
24+
super.onCreate(savedInstanceState);
25+
setContentView(R.layout.activity_main);
26+
welcomeScreen = new WelcomeHelper(this, MyWelcomeActivity.class);
27+
welcomeScreen.show(savedInstanceState);
28+
29+
drawerLayout = this.findViewById(R.id.drawer_layout);
30+
mToolBar = this.findViewById(R.id.mToolBar);
31+
navigationView=this.findViewById(R.id.navigation_view);
32+
33+
ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout,
34+
mToolBar, 0, 0);
35+
drawerLayout.addDrawerListener(mDrawerToggle);
36+
mDrawerToggle.syncState(); // 添加此句,toolbar左上角显示开启侧边栏图标
37+
38+
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
39+
@Override
40+
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
41+
switch (menuItem.getItemId()) {
42+
case R.id.navigation_item_home:
43+
Toast.makeText(MainActivity.this, "x", Toast.LENGTH_SHORT).show();
44+
break;
45+
}
46+
drawerLayout.closeDrawer(GravityCompat.START);
47+
return true;
48+
}
49+
});
50+
51+
}
52+
53+
@Override
54+
protected void onSaveInstanceState(Bundle outState) {
55+
super.onSaveInstanceState(outState);
56+
welcomeScreen.onSaveInstanceState(outState);
57+
}
58+
59+
60+
@SuppressWarnings("StatementWithEmptyBody")
61+
public boolean onNavigationItemSelected(MenuItem item)
62+
{
63+
// Handle navigation view item clicks here.
64+
int id = item.getItemId();
65+
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
66+
drawer.closeDrawer(GravityCompat.START);
67+
return true;
68+
}
69+
70+
@Override
71+
public void onBackPressed()
72+
{
73+
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
74+
if (drawer.isDrawerOpen(GravityCompat.START)) {
75+
drawer.closeDrawer(GravityCompat.START);
76+
} else {
77+
super.onBackPressed();
78+
}
79+
}
80+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package io.github.zhaoqi99.snnu_android;
2+
3+
import com.stephentuso.welcome.BasicPage;
4+
import com.stephentuso.welcome.TitlePage;
5+
import com.stephentuso.welcome.WelcomeActivity;
6+
import com.stephentuso.welcome.WelcomeConfiguration;
7+
8+
public class MyWelcomeActivity extends WelcomeActivity {
9+
10+
@Override
11+
protected WelcomeConfiguration configuration() {
12+
return new WelcomeConfiguration.Builder(this)
13+
.defaultBackgroundColor(R.color.red_background)
14+
.page(new TitlePage(R.drawable.logo,
15+
"Title")
16+
)
17+
.page(new BasicPage(R.drawable.logo,
18+
"Header",
19+
"More text.")
20+
.background(R.color.red_background)
21+
)
22+
.page(new BasicPage(R.drawable.logo,
23+
"Lorem ipsum",
24+
"dolor sit amet.")
25+
)
26+
.swipeToDismiss(true)
27+
.build();
28+
}
29+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:aapt="http://schemas.android.com/aapt"
3+
android:width="108dp"
4+
android:height="108dp"
5+
android:viewportHeight="108"
6+
android:viewportWidth="108">
7+
<path
8+
android:fillType="evenOdd"
9+
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
10+
android:strokeColor="#00000000"
11+
android:strokeWidth="1">
12+
<aapt:attr name="android:fillColor">
13+
<gradient
14+
android:endX="78.5885"
15+
android:endY="90.9159"
16+
android:startX="48.7653"
17+
android:startY="61.0927"
18+
android:type="linear">
19+
<item
20+
android:color="#44000000"
21+
android:offset="0.0" />
22+
<item
23+
android:color="#00000000"
24+
android:offset="1.0" />
25+
</gradient>
26+
</aapt:attr>
27+
</path>
28+
<path
29+
android:fillColor="#FFFFFF"
30+
android:fillType="nonZero"
31+
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
32+
android:strokeColor="#00000000"
33+
android:strokeWidth="1" />
34+
</vector>

0 commit comments

Comments
 (0)