Skip to content

Commit

Permalink
Feature/ui refinement (geeeeeeeeek#221)
Browse files Browse the repository at this point in the history
* Support the English language on UI.

* Update UI design for 4.0.

* Remove auto reply.
  • Loading branch information
Zhongyi Tong authored Jan 27, 2017
1 parent d1ddf96 commit d1f578d
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 121 deletions.
1 change: 1 addition & 0 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/reload-dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/restart-dex" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public class MainActivity extends Activity implements AccessibilityManager.Acces
//AccessibilityService 管理
private AccessibilityManager accessibilityManager;

private AdView adView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -44,8 +42,6 @@ protected void onCreate(Bundle savedInstanceState) {
pluginStatusText = (TextView) findViewById(R.id.layout_control_accessibility_text);
pluginStatusIcon = (ImageView) findViewById(R.id.layout_control_accessibility_icon);

loadAd();

handleMaterialStatusBar();

explicitlyLoadPreferences();
Expand Down Expand Up @@ -78,26 +74,14 @@ private void handleMaterialStatusBar() {

}

private void loadAd() {
adView = (AdView) findViewById(R.id.adViewMain);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
}

@Override
protected void onPause() {
if (adView != null) {
adView.pause();
}
super.onPause();
}

@Override
protected void onResume() {
super.onResume();
if (adView != null) {
adView.resume();
}

// Check for update when WIFI is connected or on first time.
if (ConnectivityUtil.isWifi(this) || UpdateTask.count == 0)
Expand All @@ -106,9 +90,6 @@ protected void onResume() {

@Override
protected void onDestroy() {
if (adView != null) {
adView.destroy();
}
//移除监听服务
accessibilityManager.removeAccessibilityStateChangeListener(this);
super.onDestroy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.view.View;
import android.widget.EditText;
import android.widget.SeekBar;
import android.widget.TextView;
import org.w3c.dom.Text;
import xyz.monkeytong.hongbao.R;

/**
Expand All @@ -31,7 +29,7 @@ public SeekBarPreference(Context context, AttributeSet attrs) {
}
}
if (prefKind.equals("pref_open_delay")) {
hintText = "拆开红包";
hintText = getContext().getString(R.string.delay_open);
} else if (prefKind.equals("pref_comment_delay")) {
hintText = "发送回复(暂不支持延时)";
}
Expand All @@ -52,20 +50,12 @@ protected void onBindDialogView(View view) {
}

this.textView = (TextView) view.findViewById(R.id.pref_seekbar_textview);
if (delay == 0) {
this.textView.setText("立即" + hintText);
} else {
this.textView.setText("延迟" + delay + "秒" + hintText);
}
setHintText(0);

this.seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
if (i == 0) {
textView.setText("立即" + hintText);
} else {
textView.setText("延迟" + i + "秒" + hintText);
}
setHintText(i);
}

@Override
Expand All @@ -89,4 +79,12 @@ protected void onDialogClosed(boolean positiveResult) {
}
super.onDialogClosed(positiveResult);
}

private void setHintText(int delay) {
if (delay == 0) {
this.textView.setText(getContext().getString(R.string.delay_instantly) + hintText);
} else {
this.textView.setText(getContext().getString(R.string.delay_delay) + delay + getContext().getString(R.string.delay_sec) + getContext().getString(R.string.delay_then) + hintText);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;
import android.widget.Toast;
import org.w3c.dom.Text;
import xyz.monkeytong.hongbao.R;
import xyz.monkeytong.hongbao.fragments.CommentSettingsFragment;
Expand Down Expand Up @@ -87,6 +88,7 @@ public void performBack(View view) {
}

public void enterAccessibilityPage(View view) {
Toast.makeText(this, getString(R.string.turn_on_toast), Toast.LENGTH_SHORT).show();
Intent mAccessibleIntent =
new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
startActivity(mAccessibleIntent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public class WebViewActivity extends Activity {
private WebView webView;
private String webViewUrl, webViewTitle;

private AdView adView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -83,40 +81,23 @@ public void onPageFinished(WebView view, String url) {
});
webView.loadUrl(webViewUrl);
}

loadAd();
}

@Override
protected void onPause() {
if (adView != null) {
adView.pause();
}
super.onPause();
}

@Override
protected void onResume() {
super.onResume();
if (adView != null) {
adView.resume();
}
}

@Override
protected void onDestroy() {
if (adView != null) {
adView.destroy();
}
super.onDestroy();
}

private void loadAd() {
adView = (AdView) findViewById(R.id.adViewWebView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
}

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void loadUI() {
setContentView(R.layout.activity_webview);
Expand Down
76 changes: 29 additions & 47 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
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"
tools:context=".MainActivity"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:background="#faf6f1">
android:background="#fff">
<ImageView
android:layout_width="fill_parent"
android:layout_height="0dp"
Expand All @@ -27,8 +26,6 @@
android:textColor="#fff"
android:gravity="center_vertical|center_horizontal"
android:textSize="28dp"
android:layout_above="@+id/layout_control"
android:layout_alignParentTop="true"
android:layout_marginTop="40dp"
android:textIsSelectable="false"/>
<TextView android:layout_width="fill_parent"
Expand All @@ -37,25 +34,28 @@
android:text="@string/app_version"
android:textColor="#fff"
android:gravity="center_vertical|center_horizontal"
android:layout_above="@+id/layout_control"
android:layout_alignParentTop="true"
android:layout_marginTop="4dp"/>
</LinearLayout>

<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@mipmap/bg_snow"
android:id="@+id/main_bg_snow"
android:layout_alignBottom="@id/layout_header"/>
<LinearLayout android:id="@+id/layout_control"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="110dp"
android:layout_above="@+id/layout_uber"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp">
<LinearLayout style="?android:attr/borderlessButtonStyle"
android:id="@+id/layout_control_community"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff"
android:background="#ffffff"
android:textColor="#858585"
android:layout_above="@+id/layout_uber"
android:textSize="20dp"
Expand All @@ -75,14 +75,14 @@
android:text="@string/community"
android:id="@+id/textView2"
android:layout_margin="5dp"
android:textColor="#858585"/>
android:textColor="#858585" android:textSize="16sp" android:textStyle="bold"/>
</LinearLayout>
<LinearLayout
android:id="@+id/layout_control_accessibility"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:onClick="openAccessibility"
android:background="#fff"
android:background="#ffffff"
android:textColor="#858585"
style="?android:attr/borderlessButtonStyle"
android:layout_above="@+id/layout_uber"
Expand All @@ -94,21 +94,21 @@
<ImageView android:layout_width="32dp"
android:layout_height="32dp"
android:id="@+id/layout_control_accessibility_icon"
android:layout_marginBottom="4dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="6dp"
android:layout_marginTop="6dp"
android:background="@mipmap/ic_start"/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/service_on"
android:id="@+id/layout_control_accessibility_text"
android:layout_margin="5dp"
android:textColor="#dfaa6a"/>
android:textColor="#dfaa6a" android:textStyle="bold" android:textSize="16sp"/>
</LinearLayout>
<LinearLayout style="?android:attr/borderlessButtonStyle"
android:id="@+id/layout_control_settings"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff"
android:background="#ffffff"
android:textColor="#858585"
android:layout_above="@+id/layout_uber"
android:textSize="20dp"
Expand All @@ -126,16 +126,16 @@
android:text="@string/settings"
android:id="@+id/textView3"
android:layout_margin="5dp"
android:textColor="#858585"/>
android:textColor="#858585" android:textSize="16sp" android:textStyle="bold"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/layout_uber"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="72dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:background="#ffffff"
android:layout_marginTop="8dp"
android:layout_alignParentBottom="false"
Expand All @@ -147,7 +147,7 @@
android:layout_height="60dp"
android:id="@+id/icon_uber"
android:src="@mipmap/ic_uber"
android:layout_marginLeft="15dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="10dp"
android:layout_gravity="center_vertical"
android:layout_marginBottom="2dp"/>
Expand All @@ -169,27 +169,26 @@
android:text="@string/uber_ad_text"
android:id="@+id/label_uber_link"
android:layout_margin="2dp"
android:textColor="#dfaa6a"/>
android:textColor="#dfaa6a" android:textStyle="bold"/>
</LinearLayout>
</LinearLayout>
<LinearLayout android:id="@+id/linearLayout2"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:background="#ffffff"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_marginBottom="24dp"
android:onClick="openGitHub"
android:layout_alignParentBottom="false"
android:layout_above="@+id/layout_admob_main">
android:layout_alignParentBottom="true">
<ImageView android:layout_width="20dp"
android:layout_height="20dp"
android:id="@+id/imageView2"
android:src="@mipmap/ic_github"
android:layout_marginLeft="20dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="5dp"
android:layout_gravity="center_vertical"/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -212,7 +211,7 @@
android:textColor="#dfaa6a"
android:layout_gravity="center_vertical"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"/>
android:layout_marginRight="2dp" android:textStyle="bold"/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/github_2"
Expand All @@ -221,21 +220,4 @@
android:textColor="#858585"
android:layout_gravity="center_vertical"/>
</LinearLayout>
<LinearLayout android:id="@+id/layout_admob_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="0dp"
android:layout_centerHorizontal="true"
android:gravity="center"
android:layout_alignParentBottom="true">
<com.google.android.gms.ads.AdView
android:id="@+id/adViewMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/home_banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
</LinearLayout>

</RelativeLayout>
9 changes: 0 additions & 9 deletions app/src/main/res/layout/activity_webview.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,7 @@
android:layout_height="match_parent"
android:id="@+id/webView"
android:layout_gravity="center_horizontal"
android:layout_above="@+id/adViewWebView"
android:foreground="#E46C62"/>
<com.google.android.gms.ads.AdView
android:id="@+id/adViewWebView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/webview_banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
</RelativeLayout>

</LinearLayout>
Binary file added app/src/main/res/mipmap-xxhdpi/bg_snow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xxhdpi/bg_snow_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit d1f578d

Please sign in to comment.