2 * Copyright (C) 2012 The CyanogenMod Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.cyanogenmod.filemanager.activities;
19 import android.app.Activity;
20 import android.app.AlertDialog;
21 import android.content.BroadcastReceiver;
22 import android.content.Context;
23 import android.content.DialogInterface;
24 import android.content.DialogInterface.OnCancelListener;
25 import android.content.DialogInterface.OnDismissListener;
26 import android.content.Intent;
27 import android.content.IntentFilter;
28 import android.os.Bundle;
29 import android.util.Log;
31 import com.cyanogenmod.filemanager.R;
32 import com.cyanogenmod.filemanager.preferences.FileManagerSettings;
33 import com.cyanogenmod.filemanager.ui.ThemeManager;
34 import com.cyanogenmod.filemanager.ui.ThemeManager.Theme;
35 import com.cyanogenmod.filemanager.util.DialogHelper;
37 import java.io.InputStream;
40 * The activity for show the changelog of the application
42 public class ChangeLogActivity extends Activity implements OnCancelListener, OnDismissListener {
44 private static final String TAG = "ChangeLogActivity"; //$NON-NLS-1$
46 private static boolean DEBUG = false;
48 private final BroadcastReceiver mNotificationReceiver = new BroadcastReceiver() {
50 public void onReceive(Context context, Intent intent) {
52 if (intent.getAction().compareTo(FileManagerSettings.INTENT_THEME_CHANGED) == 0) {
63 protected void onCreate(Bundle state) {
65 Log.d(TAG, "ChangeLogActivity.onCreate"); //$NON-NLS-1$
68 // Register the broadcast receiver
69 IntentFilter filter = new IntentFilter();
70 filter.addAction(FileManagerSettings.INTENT_THEME_CHANGED);
71 registerReceiver(this.mNotificationReceiver, filter);
75 super.onCreate(state);
84 protected void onDestroy() {
86 Log.d(TAG, "ChangeLogActivity.onDestroy"); //$NON-NLS-1$
89 // Unregister the receiver
91 unregisterReceiver(this.mNotificationReceiver);
92 } catch (Throwable ex) {
96 //All destroy. Continue
101 * Initialize the activity. This method handles the passed intent, opens
102 * the appropriate activity and ends.
104 private void init() {
105 InputStream is = getApplicationContext().getResources().openRawResource(R.raw.changelog);
107 Log.e(TAG, "Changelog file not exists"); //$NON-NLS-1$
113 // Read the changelog
114 StringBuilder sb = new StringBuilder();
116 byte[] data = new byte[512];
117 while ((read = is.read(data, 0, 512)) != -1) {
118 sb.append(new String(data, 0, read));
122 AlertDialog dialog = DialogHelper.createAlertDialog(
123 this, R.drawable.ic_launcher,
124 R.string.changelog_title, sb.toString(), false);
125 dialog.setOnCancelListener(this);
126 dialog.setOnDismissListener(this);
127 DialogHelper.delegateDialogShow(this, dialog);
129 } catch (Exception e) {
130 Log.e(TAG, "Failed to read changelog file", e); //$NON-NLS-1$
136 } catch (Exception e) {/**NON BLOCK**/}
144 public void onDismiss(DialogInterface dialog) {
145 // We have to finish here; this activity is only a wrapper
153 public void onCancel(DialogInterface dialog) {
154 // We have to finish here; this activity is only a wrapper
159 * Method that applies the current theme to the activity
163 Theme theme = ThemeManager.getCurrentTheme(this);
164 theme.setBaseTheme(this, true);