Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 18fd7a1e authored by Wes Garner's avatar Wes Garner
Browse files

CMParts: Add ChangeLog to CMParts

Change-Id: Ic9857b587581a28683f0e60a6a473275f0eb606c
Change-Id: Idd3eb7774185410cf5f867d76a57c3323aa7dd38
parent fb63aa8e
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -128,6 +128,12 @@
            </intent-filter>
        </activity>

        <activity android:name=".activities.ChangeLog" android:label="@string/changelog_title">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
            </intent-filter>
        </activity>

        <receiver android:name=".provider.RenderFXWidgetProvider" android:label="@string/widget_name">
            <intent-filter>
                <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
+8 −0
Original line number Diff line number Diff line
@@ -395,4 +395,12 @@
    <string name="pref_lockscreen_disable_unlock_tab">Disable unlock slider</string>
    <string name="pref_lockscreen_disable_unlock_tab_summary">Note: You need to enable trackball, menu key, or gesture unlocking before this option becomes available</string>
    <string name="gestures_explain_create_screen">Pick an action to perform (or select Unlock or Sound) and draw a gesture on the screen.</string>

    <!-- Change Log strings -->
    <string name="changelog_title">View changelog</string>
    <string name="changelog_dialog">Changelog</string>
    <string name="changelog_loading">Loading changelog...</string>
    <string name="changelog_error">Error loading changelog...</string>
    <string name="changelog_unknown">Unknown</string>
    <string name="changelog_version">Version</string>
</resources>
+8 −0
Original line number Diff line number Diff line
@@ -67,4 +67,12 @@
            android:targetClass="com.cyanogenmod.stats.MainActivity" />
    </PreferenceScreen>

    <!-- Change Log -->
    <PreferenceScreen
        android:key="changelog"
            android:title="@string/changelog_title">
        <intent android:action="android.intent.action.MAIN"
            android:targetPackage="com.cyanogenmod.cmparts"
            android:targetClass="com.cyanogenmod.cmparts.activities.ChangeLog" />
    </PreferenceScreen>
</PreferenceScreen>
+97 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2007 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.cyanogenmod.cmparts.activities;

import com.cyanogenmod.cmparts.R;

import android.os.Bundle;
import android.text.TextUtils;
import android.util.Config;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;

import com.android.internal.app.AlertActivity;
import com.android.internal.app.AlertController;

public class ChangeLog extends AlertActivity {

    private static final String CHANGELOG_PATH = "/system/etc/CHANGELOG-CM.txt";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        InputStreamReader inputReader = null;
        StringBuilder data = null;
        try {
            data = new StringBuilder(2048);
            char tmp[] = new char[2048];
            int numRead;
            inputReader = new FileReader(CHANGELOG_PATH);
            while ((numRead = inputReader.read(tmp)) >= 0) {
                data.append(tmp, 0, numRead);
            }
        } catch (IOException e) {
            showErrorAndFinish();
            return;
        } finally {
            try {
                if (inputReader != null) {
                    inputReader.close();
                }
            } catch (IOException e) {
            }
        }

        if (TextUtils.isEmpty(data)) {
            showErrorAndFinish();
            return;
        }

        WebView webView = new WebView(this);

        // Begin the loading.  This will be done in a separate thread in WebView.
        webView.loadDataWithBaseURL(null, data.toString(), "text/plain", "utf-8", null);
        webView.setWebViewClient(new WebViewClient() {
            @Override
            public void onPageFinished(WebView view, String url) {
                // Change from 'Loading...' to the real title
                mAlert.setTitle(getString(R.string.changelog_dialog));
            }
        });

        final AlertController.AlertParams p = mAlertParams;
        p.mTitle = getString(R.string.changelog_loading);
        p.mView = webView;
        p.mForceInverseBackground = true;
        setupAlert();
    }

    private void showErrorAndFinish() {
        Toast.makeText(this, R.string.changelog_error, Toast.LENGTH_LONG)
                .show();
        finish();
    }

}
+4 −0
Original line number Diff line number Diff line
package com.cyanogenmod.cmparts.activities;

import android.os.Bundle;
import android.os.SystemProperties;
import android.preference.Preference;
import android.preference.PreferenceActivity;

import com.cyanogenmod.cmparts.R;
@@ -12,6 +14,8 @@ public class MainActivity extends PreferenceActivity {
        super.onCreate(savedInstanceState);

        addPreferencesFromResource(R.xml.cmparts);
        findPreference("changelog").setSummary(getString(R.string.changelog_version) + ": " +
            SystemProperties.get("ro.modversion", getResources().getString(R.string.changelog_unknown)));
    }
}