Skip to content

Commit

Permalink
完成1.0.2版本的所有开发
Browse files Browse the repository at this point in the history
  • Loading branch information
coder-pig committed Feb 28, 2018
1 parent 46dcac2 commit dbe9d6e
Show file tree
Hide file tree
Showing 21 changed files with 693 additions and 15 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ android {
applicationId "com.coderpig.drysisters"
minSdkVersion depend_android["minSdkVersion"]
targetSdkVersion depend_android["targetSdkVersion"]
versionCode 2
versionName "1.0.1"
versionCode 3
versionName "1.0.2"
}
buildTypes {
debug {
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@

<activity
android:name=".ui.activity.SettingActivity"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/Theme.Slidr.Slidable"/>

<activity
android:name=".ui.activity.AboutActivity"
android:screenOrientation="portrait" />
android:screenOrientation="portrait"
android:theme="@style/Theme.Slidr.Slidable"/>

</application>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;

import com.coderpig.drysisters.R;
import com.coderpig.drysisters.ui.fragment.AboutFragment;
import com.r0adkll.slidr.Slidr;

/**
* 描述:关于的Activity
Expand All @@ -13,9 +16,29 @@
*/

public class AboutActivity extends AppCompatActivity{

private Toolbar toolbar;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.actvitiy_about);
setContentView(R.layout.activity_about);
Slidr.attach(this);
initData();
initView();
}

private void initData() {

}

private void initView() {
toolbar = findViewById(R.id.toolbar);
toolbar.setTitle("关于");
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
toolbar.setNavigationOnClickListener(view -> finish());

getSupportFragmentManager().beginTransaction().replace(R.id.cly_root, AboutFragment.newInstance()).commit();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.widget.TextView;

import com.coderpig.drysisters.DryConstant;
import com.coderpig.drysisters.R;
Expand All @@ -20,13 +21,15 @@
import com.coderpig.drysisters.ui.fragment.SubwayFragment;
import com.coderpig.drysisters.ui.fragment.ToolsFragment;
import com.coderpig.drysisters.ui.fragment.WeatherFragment;
import com.coderpig.drysisters.utils.PackageUtils;
import com.coderpig.drysisters.utils.ResUtils;

public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {

private Toolbar toolbar;
private DrawerLayout drawer_layout;
private NavigationView nav_view;
private TextView tv_nav_title;
private ConstraintLayout cly_main_content;
private FragmentManager mFgManager;

Expand All @@ -42,6 +45,7 @@ protected void onCreate(Bundle savedInstanceState) {
private void initView() {
toolbar = findViewById(R.id.toolbar);
nav_view = findViewById(R.id.nav_view);
tv_nav_title = nav_view.getHeaderView(0).findViewById(R.id.tv_nav_title);
drawer_layout = findViewById(R.id.drawer_layout);
cly_main_content = findViewById(R.id.cly_main_content);

Expand All @@ -59,6 +63,11 @@ private void initData() {
mFgManager.beginTransaction().replace(R.id.cly_main_content,
LittleSisterFragment.newInstance(), DryConstant.FG_LITTLE_SISTER).commit();
toolbar.setTitle(ResUtils.getString(R.string.menu_see_little_sister));
String version = PackageUtils.packageName();
if(version != null) {
String msg = String.format(ResUtils.getString(R.string.menu_drysister_version), version);
tv_nav_title.setText(msg);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.coderpig.drysisters.ui.activity;

import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;

import com.coderpig.drysisters.R;
import com.coderpig.drysisters.ui.fragment.SettingFragment;
import com.r0adkll.slidr.Slidr;

/**
* 描述:设置的Activity
Expand All @@ -14,9 +16,32 @@
*/

public class SettingActivity extends AppCompatActivity{

private Toolbar toolbar;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setting);
Slidr.attach(this);
initData();
initView();
}

private void initData() {

}

private void initView() {
toolbar = findViewById(R.id.toolbar);
toolbar.setTitle("设置");
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
toolbar.setNavigationOnClickListener(view -> finish());

getSupportFragmentManager().beginTransaction().replace(R.id.cly_root, SettingFragment.newInstance()).commit();

}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.coderpig.drysisters.ui.fragment;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.coderpig.drysisters.R;
import com.coderpig.drysisters.utils.PackageUtils;
import com.coderpig.drysisters.utils.ResUtils;

/**
* 描述: 关于的Fragment
*
* @author CoderPig on 2018/02/28 14:33.
*/

public class AboutFragment extends Fragment {

private TextView tv_app_version;

public static AboutFragment newInstance() {
AboutFragment fragment = new AboutFragment();
return fragment;
}

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_about, container, false);
tv_app_version = view.findViewById(R.id.tv_app_version);
return view;
}

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
String version = PackageUtils.packageName();
if(version != null) {
String msg = String.format(ResUtils.getString(R.string.app_version), version);
tv_app_version.setText(msg);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.coderpig.drysisters.ui.fragment;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.coderpig.drysisters.R;
import com.coderpig.drysisters.utils.PackageUtils;
import com.coderpig.drysisters.utils.ResUtils;

/**
* 描述: 应用设置的Fragment
*
* @author CoderPig on 2018/02/28 13:56.
*/

public class SettingFragment extends Fragment {

private TextView tv_app_version;

public static SettingFragment newInstance() {
SettingFragment fragment = new SettingFragment();
return fragment;
}

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_setting, container, false);
tv_app_version = view.findViewById(R.id.tv_app_version);
return view;
}

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
String version = PackageUtils.packageName();
if(version != null) {
String msg = String.format(ResUtils.getString(R.string.cur_version), version);
tv_app_version.setText(msg);
}
}
}
39 changes: 39 additions & 0 deletions app/src/main/java/com/coderpig/drysisters/utils/PackageUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.coderpig.drysisters.utils;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;

import com.coderpig.drysisters.DrySisterApp;

/**
* 描述:应用包相关的工具类
*
* @author CoderPig on 2018/02/28 18:01.
*/

public class PackageUtils {

public static int packageCode() {
PackageManager manager = DrySisterApp.getContext().getPackageManager();
int code = 0;
try {
PackageInfo info = manager.getPackageInfo(DrySisterApp.getContext().getPackageName(), 0);
code = info.versionCode;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return code;
}

public static String packageName() {
PackageManager manager = DrySisterApp.getContext().getPackageManager();
String name = null;
try {
PackageInfo info = manager.getPackageInfo(DrySisterApp.getContext().getPackageName(), 0);
name = info.versionName;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
return name;
}
}
Binary file removed app/src/main/res/drawable-xxxhdpi/ic_github.png
Binary file not shown.
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/shape_bg_about_text.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/colorPrimaryDark" />
<corners android:radius="5dp" />
<padding
android:bottom="15dp"
android:left="15dp"
android:right="15dp"
android:top="15dp" />

</shape>
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/shape_bg_about_text_green.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/green" />
<corners android:radius="5dp" />
<padding
android:bottom="15dp"
android:left="15dp"
android:right="15dp"
android:top="15dp" />

</shape>
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/shape_bg_about_text_purple.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/purple" />
<corners android:radius="5dp" />
<padding
android:bottom="15dp"
android:left="15dp"
android:right="15dp"
android:top="15dp" />

</shape>
Binary file removed app/src/main/res/drawable/test.jpg
Binary file not shown.
35 changes: 35 additions & 0 deletions app/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">

<android.support.design.widget.AppBarLayout
android:id="@+id/ably_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ToolbarTheme" />

</android.support.design.widget.AppBarLayout>

<android.support.constraint.ConstraintLayout
android:id="@+id/cly_root"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ably_bar" />

</android.support.constraint.ConstraintLayout>
Loading

0 comments on commit dbe9d6e

Please sign in to comment.