Skip to content

Commit

Permalink
在主页面用底部导航栏代替了浮动按钮,以充分利用日益增大的屏幕纵向空间;调整设置页面的初始值,使之更加适应当前实际情况;微调信箱页面;去掉了…
Browse files Browse the repository at this point in the history
…多余模块
  • Loading branch information
e729 committed Jun 10, 2024
1 parent dcd5572 commit b4674f5
Show file tree
Hide file tree
Showing 11 changed files with 762 additions and 953 deletions.
2 changes: 0 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
apply plugin: 'com.android.application'
apply from: 'MobSDK.gradle'

// http://www.race604.com/android-auto-version/
// use git count as build number, as current date as build version
Expand Down Expand Up @@ -150,7 +149,6 @@ dependencies {

// my gradles
implementation project(':multiple-images-selector')
implementation project(':device_model_to_marketing_name')

// https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-stdlib-jdk8
// implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:latest.release'
Expand Down
8 changes: 3 additions & 5 deletions app/src/main/java/com/zfdang/SMTHApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import android.app.Application;
import android.content.Context;

import androidx.appcompat.app.AppCompatDelegate;
import androidx.multidex.MultiDex;

import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.imagepipeline.backends.okhttp3.OkHttpImagePipelineConfigFactory;
import com.facebook.imagepipeline.core.ImagePipelineConfig;
import com.mob.MobSDK;
import com.umeng.commonsdk.UMConfigure;
import com.zfdang.zsmth_android.Settings;
import com.zfdang.zsmth_android.helpers.GEODatabase;
Expand All @@ -15,7 +17,6 @@
import com.zfdang.zsmth_android.services.UserStatusReceiver;

import okhttp3.OkHttpClient;
import androidx.multidex.MultiDex;

/**
* Created by zfdang on 2016-3-18.
Expand Down Expand Up @@ -77,9 +78,6 @@ public void onCreate() {
// init IP lookup database
geoDB = new GEODatabase(this);

// init shareSDK
MobSDK.init(this);

// init umeng SDK
UMConfigure.init(this, "56e8c05567e58e0a9e0011cc", "UMENG_CHANNEL", UMConfigure.DEVICE_TYPE_PHONE, null);

Expand Down
1,335 changes: 609 additions & 726 deletions app/src/main/java/com/zfdang/zsmth_android/MainActivity.java

Large diffs are not rendered by default.

71 changes: 0 additions & 71 deletions app/src/main/java/com/zfdang/zsmth_android/PostListActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@
import java.util.HashMap;
import java.util.List;

import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.PlatformActionListener;
import cn.sharesdk.onekeyshare.OnekeyShare;
import io.reactivex.Observable;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
Expand Down Expand Up @@ -814,74 +811,6 @@ public void OnBanIDAction(Post post, String banReason, Integer day) {
}

public void sharePost(Post post) {
OnekeyShare oks = new OnekeyShare();
//关闭sso授权
oks.disableSSOWhenAuthorize();

// prepare information from the post
String title = String.format("[%s] %s @ 水木社区", mTopic.getBoardChsName(), mTopic.getTitle());
String postURL =
String.format(SMTHHelper.SMTH_MOBILE_URL + "/article/%s/%s?p=%d", mTopic.getBoardEngName(), mTopic.getTopicID(), mCurrentPageNo);
String content = String.format("[%s]在大作中写到: %s", post.getAuthor(), post.getRawContent());
// the max length of webo is 140
if (content.length() > 110) {
content = content.substring(0, 110);
}
content += String.format("...\nLink:%s", postURL);

// default: use zSMTH logo
String imageURL = "http://zsmth.zfdang.com/zsmth.png";
List<Attachment> attaches = post.getAttachFiles();
if (attaches != null && attaches.size() > 0) {
// use the first attached image
imageURL = attaches.get(0).getResizedImageSource();
}

// more information about OnekeyShare
// http://wiki.mob.com/docs/sharesdk/android/cn/sharesdk/onekeyshare/OnekeyShare.html

// title标题,印象笔记、邮箱、信息、微信、人人网、QQ和QQ空间使用
oks.setTitle(title);

// titleUrl是标题的网络链接,仅在Linked-in,QQ和QQ空间使用
// oks.setTitleUrl("http://sharesdk.cn");

// text是分享文本,所有平台都需要这个字段
oks.setText(content);

// 分享网络图片,新浪微博分享网络图片需要通过审核后申请高级写入接口,否则请注释掉测试新浪微博
// imageUrl是图片的网络路径,新浪微博、人人网、QQ空间和Linked-In支持此字段
oks.setImageUrl(imageURL);

// imagePath是图片的本地路径,Linked-In以外的平台都支持此参数
//oks.setImagePath("/sdcard/test.jpg");//确保SDcard下面存在此张图片

// url仅在微信(包括好友和朋友圈)中使用
oks.setUrl(postURL);

// comment是我对这条分享的评论,仅在人人网和QQ空间使用
// oks.setComment("我是测试评论文本");
// site是分享此内容的网站名称,仅在QQ空间使用
// oks.setSite("ShareSDK");
// siteUrl是分享此内容的网站地址,仅在QQ空间使用
// oks.setSiteUrl("http://sharesdk.cn");

// set callback functions
oks.setCallback(new PlatformActionListener() {
@Override public void onComplete(Platform platform, int i, HashMap<String, Object> hashMap) {
Toast.makeText(PostListActivity.this, "分享成功!", Toast.LENGTH_SHORT).show();
}

@Override public void onError(Platform platform, int i, Throwable throwable) {
Toast.makeText(PostListActivity.this, "分享失败:\n" + throwable.toString(), Toast.LENGTH_LONG).show();
}

@Override public void onCancel(Platform platform, int i) {
}
});

// 启动分享GUI
oks.show(this);
}

@Override public boolean onTouch(View v, MotionEvent event) {
Expand Down
18 changes: 9 additions & 9 deletions app/src/main/java/com/zfdang/zsmth_android/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.util.Log;
import com.zfdang.SMTHApplication;
import com.zfdang.devicemodeltomarketingname.DeviceMarketingName;

/**
* Usage:
Expand Down Expand Up @@ -473,18 +473,18 @@ private void initSettings() {
bLastLoginSuccess = mPreference.getBoolean(LAST_LOGIN_SUCCESS, false);
bUserOnline = mPreference.getBoolean(USER_ONLINE, false);

bUseSignature = mPreference.getBoolean(USE_DEVICE_SIGNATURE, true);
bUseSignature = mPreference.getBoolean(USE_DEVICE_SIGNATURE, false);
mSignature = mPreference.getString(DEVICE_SIGNATURE, "");
if (mSignature.length() == 0) {
String marketingName = DeviceMarketingName.getInstance(SMTHApplication.getAppContext()).getDeviceMarketingName(true);
setSignature(marketingName);
// String marketingName = DeviceMarketingName.getInstance(SMTHApplication.getAppContext()).getDeviceMarketingName(true);
setSignature(Build.MODEL);
}

mTarget = mPreference.getString(FORWARD_TAEGET, "");

bLoadOriginalImage = mPreference.getBoolean(LOAD_ORIGINAL_IMAGE, true);
bLoadOriginalImage = mPreference.getBoolean(LOAD_ORIGINAL_IMAGE, false);
bLoginWithVerification = mPreference.getBoolean(LOGIN_WITH_VERIFICATION, true);
bImageSourceCDN = mPreference.getBoolean(IMAGE_SOURCE_CDN, true);
bImageSourceCDN = mPreference.getBoolean(IMAGE_SOURCE_CDN, false);

bBoardMasterOnly = mPreference.getBoolean(BOARD_MASTER_ONLY, false);

Expand All @@ -497,11 +497,11 @@ private void initSettings() {
bNotificationLike = mPreference.getBoolean(NOTIFICATION_LIKE, true);
bNotificationReply = mPreference.getBoolean(NOTIFICATION_REPLY, true);

bLaunchHotTopic = mPreference.getBoolean(LAUNCH_HOTTOPIC_AS_ENTRY, true);
bLaunchHotTopic = mPreference.getBoolean(LAUNCH_HOTTOPIC_AS_ENTRY, false);

bPostNavBar = mPreference.getBoolean(SHOW_POST_NAVITATION_BAR, true);
bVolumeKeyScroll = mPreference.getBoolean(VOLUME_KEY_SCROLL, true);
iFontIndex = mPreference.getInt(ZSMTH_FONT_INDEX, 1);
bVolumeKeyScroll = mPreference.getBoolean(VOLUME_KEY_SCROLL, false);
iFontIndex = mPreference.getInt(ZSMTH_FONT_INDEX, 4);

mPostCache = mPreference.getString(COMPOSE_POST_CACHE, "");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ public Result doWork() {
if (count > 3) {
Log.d("KeepAliveService", "STOP");
receiver.onServiceFailed();
}
else {
} else {
Log.d("KeepAliveService", "retry: " + count);
doNext(retry);
}
Expand Down
74 changes: 41 additions & 33 deletions app/src/main/res/layout/app_bar_main.xml
Original file line number Diff line number Diff line change
@@ -1,45 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.zfdang.zsmth_android.MainActivity"
>
tools:context="com.zfdang.zsmth_android.MainActivity">

<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"
>

<!--https://guides.codepath.com/android/Using-the-App-ToolBar-->
<!--http://developer.android.com/reference/android/support/v7/widget/Toolbar.html-->
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbarlayout"
android:layout_width="match_parent"
android:layout_height="@dimen/zsmth_actionbar_size"
android:background="?attr/colorPrimary"
android:padding="0dp"
android:theme="@style/ThemeOverlay.ToolBar"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:layout_scrollFlags="scroll|enterAlways"
app:titleTextAppearance="@style/Toolbar.TitleText"
/>
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">

</com.google.android.material.appbar.AppBarLayout>
<!--https://guides.codepath.com/android/Using-the-App-ToolBar-->
<!--http://developer.android.com/reference/android/support/v7/widget/Toolbar.html-->
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="@dimen/zsmth_actionbar_size"
android:background="?attr/colorPrimary"
android:padding="0dp"
android:theme="@style/ThemeOverlay.ToolBar"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:titleTextAppearance="@style/Toolbar.TitleText" />

<include layout="@layout/content_main"/>
</com.google.android.material.appbar.AppBarLayout>

<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:fabSize="mini"
android:src="@drawable/zpad"
/>
<include
layout="@layout/content_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/mainactivity_bottomNavigationView"
android:layout_below="@+id/appbarlayout" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/mainactivity_bottomNavigationView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:background="@color/colorPrimaryDark"
app:itemBackground="@drawable/nav_item_background"
app:itemIconTint="@color/white"
app:itemTextColor="@color/white"
app:menu="@menu/bottom_nav_menu"
app:labelVisibilityMode="labeled"
tools:targetApi="n" />
</RelativeLayout>
Loading

0 comments on commit b4674f5

Please sign in to comment.